GNOME Bugzilla – Bug 732621
video-info: wrong stride with NV12 buffers
Last modified: 2014-07-02 14:43:56 UTC
In video-info.c, the fill_planes() function align the strides value to multiple of 4: info->stride[0] = GST_ROUND_UP_4 (width); info->stride[1] = info->stride[0]; This is wrong, the stride (as well as the width) shall be rounded to a multiple of 2. Indeed the NV12 pixel format uses 2x2 sub-sampling (details: http://www.fourcc.org/yuv.php#NV12), and as a consequence it is expected that the dimensions of a NV12 buffer are multiple of 2.
I think it's not really right or wrong, it's just the default value used if you don't negotiate/announce your own custom strides. The default values tend to be what X expects IIRC.
Created attachment 279747 [details] [review] Align to 2 for NV12
Note that these values are only the GStreamer defaults, you can use different strides and offsets if you use buffers with a GstVideoMeta attached to them. Also fourcc.org quotes some MS documentation that says that the stride is supposed to be the same as for the Y plane. We use 4-byte aligned strides by default mostly because it's what most APIs expected.
I'd add that this default was chosen because it's word aligned, so it's most likely a fair optimization for SW operation. There should be no issue if you HW produce lower alignment, though take this with a grain of salt, it wasn't thoroughly tested. For your interest, not only X uses 4 bytes alignment, but also most camera drivers (if not more).