mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-21 10:55:51 +02:00
simplify AVFormatParameters NULL checks
Originally committed as revision 5146 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
e7c8206e5c
commit
c04c3282b4
@ -217,7 +217,7 @@ static int audio_read_header(AVFormatContext *s1, AVFormatParameters *ap)
|
||||
AVStream *st;
|
||||
int ret;
|
||||
|
||||
if (!ap || ap->sample_rate <= 0 || ap->channels <= 0)
|
||||
if (ap->sample_rate <= 0 || ap->channels <= 0)
|
||||
return -1;
|
||||
|
||||
st = av_new_stream(s1, 0);
|
||||
|
@ -68,7 +68,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
|
||||
const char *video_device;
|
||||
int j;
|
||||
|
||||
if (!ap || ap->width <= 0 || ap->height <= 0 || ap->time_base.den <= 0)
|
||||
if (ap->width <= 0 || ap->height <= 0 || ap->time_base.den <= 0)
|
||||
return -1;
|
||||
|
||||
width = ap->width;
|
||||
|
@ -245,7 +245,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
|
||||
int format = -1;
|
||||
const char *video_device;
|
||||
|
||||
if (!ap || ap->width <= 0 || ap->height <= 0 || ap->time_base.den <= 0)
|
||||
if (ap->width <= 0 || ap->height <= 0 || ap->time_base.den <= 0)
|
||||
return -1;
|
||||
|
||||
width = ap->width;
|
||||
|
@ -120,7 +120,7 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (ap && ap->image_format)
|
||||
if (ap->image_format)
|
||||
s->img_fmt = ap->image_format;
|
||||
|
||||
pstrcpy(s->path, sizeof(s->path), s1->filename);
|
||||
@ -133,7 +133,7 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap)
|
||||
else
|
||||
s->is_pipe = 1;
|
||||
|
||||
if (!ap || !ap->time_base.num) {
|
||||
if (!ap->time_base.num) {
|
||||
st->codec->time_base= (AVRational){1,25};
|
||||
} else {
|
||||
st->codec->time_base= ap->time_base;
|
||||
@ -255,7 +255,7 @@ static int img_set_parameters(AVFormatContext *s, AVFormatParameters *ap)
|
||||
int i;
|
||||
|
||||
/* find output image format */
|
||||
if (ap && ap->image_format) {
|
||||
if (ap->image_format) {
|
||||
img_fmt = ap->image_format;
|
||||
} else {
|
||||
img_fmt = guess_image_format(s->filename);
|
||||
|
@ -187,13 +187,13 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap)
|
||||
st->need_parsing= 1;
|
||||
}
|
||||
|
||||
if (!ap || !ap->time_base.num) {
|
||||
if (!ap->time_base.num) {
|
||||
av_set_pts_info(st, 60, 1, 25);
|
||||
} else {
|
||||
av_set_pts_info(st, 60, ap->time_base.num, ap->time_base.den);
|
||||
}
|
||||
|
||||
if(ap && ap->width && ap->height){
|
||||
if(ap->width && ap->height){
|
||||
st->codec->width = ap->width;
|
||||
st->codec->height= ap->height;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
|
||||
st = av_new_stream(s, 0);
|
||||
if (!st)
|
||||
return AVERROR_NOMEM;
|
||||
if (ap) {
|
||||
|
||||
id = s->iformat->value;
|
||||
if (id == CODEC_ID_RAWVIDEO) {
|
||||
st->codec->codec_type = CODEC_TYPE_VIDEO;
|
||||
@ -74,9 +74,6 @@ static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -289,7 +286,7 @@ static int video_read_header(AVFormatContext *s,
|
||||
|
||||
/* for mjpeg, specify frame rate */
|
||||
/* for mpeg4 specify it too (most mpeg4 streams dont have the fixed_vop_rate set ...)*/
|
||||
if (ap && ap->time_base.num) {
|
||||
if (ap->time_base.num) {
|
||||
av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
|
||||
} else if ( st->codec->codec_id == CODEC_ID_MJPEG ||
|
||||
st->codec->codec_id == CODEC_ID_MPEG4 ||
|
||||
|
@ -994,7 +994,7 @@ static int rtsp_read_header(AVFormatContext *s,
|
||||
rt->state = RTSP_STATE_IDLE;
|
||||
rt->seek_timestamp = 0; /* default is to start stream at position
|
||||
zero */
|
||||
if (ap && ap->initial_pause) {
|
||||
if (ap->initial_pause) {
|
||||
/* do not start immediately */
|
||||
} else {
|
||||
if (rtsp_read_play(s) < 0) {
|
||||
|
@ -465,6 +465,12 @@ int av_open_input_stream(AVFormatContext **ic_ptr,
|
||||
{
|
||||
int err;
|
||||
AVFormatContext *ic;
|
||||
AVFormatParameters default_ap;
|
||||
|
||||
if(!ap){
|
||||
ap=&default_ap;
|
||||
memset(ap, 0, sizeof(default_ap));
|
||||
}
|
||||
|
||||
ic = av_alloc_format_context();
|
||||
if (!ic) {
|
||||
|
@ -384,7 +384,7 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
|
||||
uint32_t desired_format, capabilities;
|
||||
const char *video_device;
|
||||
|
||||
if (!ap || ap->width <= 0 || ap->height <= 0 || ap->time_base.den <= 0) {
|
||||
if (ap->width <= 0 || ap->height <= 0 || ap->time_base.den <= 0) {
|
||||
av_log(s1, AV_LOG_ERROR, "Missing/Wrong parameters\n");
|
||||
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user