Unable to specify non-standard strides in video meta
Describe your issue
I'm experiencing a regression after what appears to be this commit by @gdesmott. I'm developing a source element for a camera that may produce images with odd widths. If I'm not mistaken, GStreamer will automatically assume a 4-byte aligned stride. My camera won't add this stride, so I indicate the actual stride in my buffer's video meta. For a 321x240 RGB image, the actual stride my camera gives is 963 (321*3) instead of the 964 GStreamer assumes, for example.
This used to work fine, however, on GStreamer 1.20 if I run the following pipeline:
GST_DEBUG=2 gst-launch-1.0 oddsrc ! video/x-raw,format=BGR,width=321,height=240 ! videoconvert ! autovideosink
I get the following per-buffer warning and nothing gets displayed:
0:00:00.582173000 92829 0x107016f00 WARN videometa gstvideometa.c:416:gst_video_meta_validate_alignment: Stride of plane 0 defined in meta (963) is different from the one computed from the alignment (964)
Note that I cannot test this with videotestsrc, because unlike videotestsrc, my camera doesn't actually add any padding. Here's a mock source element that reproduces this same issue.
Studying the source code, I noticed the following check:
if (GST_VIDEO_INFO_PLANE_STRIDE (&info, i) != meta->stride[i]) {
GST_WARNING
("Stride of plane %d defined in meta (%d) is different from the one computed from the alignment (%d)",
i, meta->stride[i], GST_VIDEO_INFO_PLANE_STRIDE (&info, i));
return FALSE;
}
which seems off to me. I understand my use case is rare, but this would also forbid sources from ever using different strides from the GStreamer computed ones.
Am I missing something? I'd be happy to collaborate with a fix if you consider this to be unwanted behavior.
Expected Behavior
My source element creates buffers with non-standard strides and it indicates these strides using gst_buffer_add_video_meta_full
. The following pipeline used to work fine:
GST_DEBUG=2 gst-launch-1.0 oddsrc ! video/x-raw,format=BGR,width=321,height=240 ! videoconvert ! autovideosink
Observed Behavior
I get these per-buffer warnings:
0:00:00.582173000 92829 0x107016f00 WARN videometa gstvideometa.c:416:gst_video_meta_validate_alignment: Stride of plane 0 defined in meta (963) is different from the one computed from the alignment (964)
Setup
- Operating System: MacOS Monterrey 12.3.1
- Device: Computer
- GStreamer Version: 1.20.1
-
Command line:
GST_DEBUG=2 gst-launch-1.0 oddsrc ! videoconvert ! autovideosink
Steps to reproduce the bug
- open terminal
- copy the contents of gstoddsrc.c into a file with the same name.
- build the plug-in with
gcc gstoddsrc.c $(pkg-config --cflags --libs gstreamer-1.0 gstreamer-base-1.0 gstreamer-video-1.0) -shared -o gstoddsrc.so
- export the current location as a plugin-path:
export GST_PLUGIN_PATH=$(pwd)
- run the following pipeline:
GST_DEBUG=2 gst-launch-1.0 oddsrc ! videoconvert ! autovideosink
How reproducible is the bug?
The reproducibility of the bug is Always after doing a very specific set of steps
Screenshots if relevant
Solutions you have tried
Related non-duplicate issues
Additional Information
I can help with the fix if you consider this to be real!