v4l2src with NV12: failed to map video frame

Nicolas Dufresne nicolas.dufresne at collabora.com
Tue Feb 17 06:36:42 PST 2015


Another pointer:

https://github.com/Vodalys/linux-veobox/blob/veobox/drivers/staging/media/imx6/capture/mx6-camif.c#L233
/*

* The YUYV format is four bytes for every two pixels, so bytesperline
* is width * 2.

*/


This is wrong for planar and multi-planar formats. The bytesperline is 
defined as the stride of the first plane. For I420 and NV12, first plane 
has 1 byte per pixel. The other strides are calculated by scaling the 
first plane stride base on the subsampling ratio. For NV12 the second 
stride is the same, since it has half the pixel but two bytes per pixels.

Nicolas

Le 2015-02-17 09:06, Nicolas Dufresne a écrit :
> Hi Fred,
>
> here I extracted and stripped a small part of the trace.
>
> gst_v4l2_object_set_format:<v4l2src0> progressive video
> gst_v4l2_object_set_format:<v4l2src0> Desired format 1280x720, format 
> NV12 stride: 1280
> gst_v4l2_object_set_format:<v4l2src0> Desired format is 1280x720, 
> format NV12, nb planes 1
> gst_v4l2_object_set_format:<v4l2src0> stride 1280
> gst_v4l2_object_set_format:<v4l2src0> Got format of 1280x720, format 
> NV12, nb planes 1, colorspace 3
> gst_v4l2_object_set_format:<v4l2src0> stride 1920, sizeimage 1382400
> gst_v4l2_object_set_format:<v4l2src0> Desired framerate: 50/1
> gst_v4l2_object_extrapolate_info:<v4l2src0> Extrapolated for plane 0 
> with base stride 1920: stride 1920, offset 0
> gst_v4l2_object_extrapolate_info:<v4l2src0> Extrapolated for plane 1 
> with base stride 1920: stride 1920, offset 1382400
>
> As you can see, the driver chose a stride for 1280x720 which is 1920. 
> Then it pick a size that only fits the first plane. The selected 
> stride is very suspicious in itself, I think it should have been 1280. 
> If I do the math with that stride:
>
>    sizeimage = 1280bytes * 720lines + 1280bytes * 360lines = 1382400
>
> My conclusion is that this is a driver bug. I think v4l2-ctl simply 
> write sizeimage to disk, ignoring the stride. As mplayer will assume a 
> 1280 stride, the playback just work, pointing that reported driver 
> stride is not correct.
>
> cheers,
> Nicolas
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



More information about the gstreamer-devel mailing list