diff options
author | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2011-01-05 14:15:13 +0000 |
---|---|---|
committer | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2011-01-05 14:15:13 +0000 |
commit | 5d3d238f826872fa5b42125d7a8efefc63a4e492 (patch) | |
tree | bb39b0019dedd805e0c00abbd0b19e7445aa127a /libavdevice/v4l2.c | |
parent | 8621a37d9feff940be19e47344cc521adca1fca2 (diff) | |
download | ffmpeg-5d3d238f826872fa5b42125d7a8efefc63a4e492.tar.gz |
Factorize common code in v4l2_set_parameters().
Originally committed as revision 26225 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavdevice/v4l2.c')
-rw-r--r-- | libavdevice/v4l2.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index 26f879a509..1e41c44775 100644 --- a/libavdevice/v4l2.c +++ b/libavdevice/v4l2.c @@ -442,8 +442,12 @@ static int v4l2_set_parameters(AVFormatContext *s1, AVFormatParameters *ap) struct video_data *s = s1->priv_data; struct v4l2_input input; struct v4l2_standard standard; + struct v4l2_streamparm streamparm = { 0 }; + struct v4l2_fract *tpf = &streamparm.parm.capture.timeperframe; int i; + streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + if (ap->channel>=0) { /* set tv video input */ memset (&input, 0, sizeof (input)); @@ -490,12 +494,8 @@ static int v4l2_set_parameters(AVFormatContext *s1, AVFormatParameters *ap) } if (ap->time_base.num && ap->time_base.den) { - struct v4l2_streamparm streamparm = { 0 }; - struct v4l2_fract *tpf = &streamparm.parm.capture.timeperframe; - av_log(s1, AV_LOG_DEBUG, "Setting time per frame to %d/%d\n", ap->time_base.num, ap->time_base.den); - streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; tpf->numerator = ap->time_base.num; tpf->denominator = ap->time_base.den; if (ioctl(s->fd, VIDIOC_S_PARM, &streamparm) != 0) { @@ -511,23 +511,16 @@ static int v4l2_set_parameters(AVFormatContext *s1, AVFormatParameters *ap) "The driver changed the time per frame from %d/%d to %d/%d\n", ap->time_base.num, ap->time_base.den, tpf->numerator, tpf->denominator); - ap->time_base.num = tpf->numerator; - ap->time_base.den = tpf->denominator; } } else { - /* if timebase value is not set in ap, read the timebase value - * from the driver and set it in ap */ - struct v4l2_streamparm streamparm = { 0 }; - struct v4l2_fract *tpf = &streamparm.parm.capture.timeperframe; - - streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + /* if timebase value is not set in ap, read the timebase value from the driver */ if (ioctl(s->fd, VIDIOC_G_PARM, &streamparm) != 0) { av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_G_PARM): %s\n", strerror(errno)); return AVERROR(errno); } - ap->time_base.num = tpf->numerator; - ap->time_base.den = tpf->denominator; } + ap->time_base.num = tpf->numerator; + ap->time_base.den = tpf->denominator; return 0; } |