[FFmpeg-devel] [PATCH] V4L2 compliance: Make sure VIDIOC_S_INPUT is called before querying/setting any input properties

Rupert Eibauer Rupert.Eibauer at ces.ch
Wed Jan 11 21:46:57 CET 2012


Michael Niedermayer <michaelni at gmx.at> wrote on 01/11/2012 09:23:45 PM:
> 
> On Wed, Jan 11, 2012 at 08:01:25PM +0100, Rupert Eibauer wrote:
> > Hello,
> > 
> > This solves a problem with a V4L device which supports different 
inputs.
> > The problem is that the different inputs have different resolutions, 
and 
> > the device cannot do image scaling.
> > This is what happened:
> > - ffmpeg calls VIDIOC_S_FMT with the resolution we specified on the 
> > command line.
> > - The driver responds with a resolution which is correct for the 
default 
> > input.
> > - ffmpeg calls VIDIOC_S_INPUT, and the driver switches to the 
resolution 
> > supported by that input.
> > - Now we have a problem: ffmpegs idea about the image resolution is 
wrong. 
> > 
> > 
> > The patch below fixes that problem. Please apply it.
> 
> The patch looks like its linebreaks where messed up

Sorry, automatic line wrapping. I hope it works better this time (or the 
attachment).

> > It is for 0.8.9, because this is the version I am currently using. 
0.9.1 
> > and git do not compile because of some asm errors.
> 
> please report the asm issue, so it can be fixed

Are you sure you want to care about this? If it happened with recent 
versions of yasm,
somebody else would have noticed. I am using SLES 11.

Best regards,
Rupert Eibauer

--- ffmpeg-0.8.9.orig/libavdevice/v4l2.c        2011-12-25 
22:18:30.000000000 +0100
+++ ffmpeg-0.8.9/libavdevice/v4l2.c     2012-01-11 18:43:47.000000000 
+0100
@@ -621,6 +621,9 @@
         av_log(s1, AV_LOG_VERBOSE, "Setting frame size to %dx%d\n", 
s->width, s->height);
     }
 
+    if ((res = v4l2_set_parameters(s1, ap) < 0))
+        goto out;
+
     desired_format = device_try_init(s1, pix_fmt, &s->width, &s->height, 
&codec_id);
     if (desired_format == 0) {
         av_log(s1, AV_LOG_ERROR, "Cannot find a proper format for "
@@ -634,9 +637,6 @@
         goto out;
     s->frame_format = desired_format;
 
-    if ((res = v4l2_set_parameters(s1, ap) < 0))
-        goto out;
-
     st->codec->pix_fmt = fmt_v4l2ff(desired_format, codec_id);
     s->frame_size = avpicture_get_size(st->codec->pix_fmt, s->width, 
s->height);
     if (capabilities & V4L2_CAP_STREAMING) {



-------------- next part --------------
A non-text attachment was scrubbed...
Name: ffmpeg-v4l2-compliance.diff
Type: application/octet-stream
Size: 870 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120111/fecf8d3f/attachment.obj>


More information about the ffmpeg-devel mailing list