Skip to content

v4l2src: need maintain the caps order in caps compare when fixate

Haihua Hu requested to merge JaredHu/gstreamer:fix-v4l2src-caps-swap into main

if the calculated "distance" of caps A and B from the preference are equal, need to keep the original order instead of swap them. eg, when run below cmdline

gst-launch-1.0 v4l2src device=/dev/video3 ! videoconvert ! video/x-raw,format=YUY2,width=1920,height=1080 ! videoconvert ! waylandsink

User want to use yuy2 instead NV16 as v4l2src's output, but the actual result is NV16 is placed in the first place

0:00:00.642391213 17684 0xffff7c000b70 DEBUG                v4l2src gstv4l2src.c:535:gst_v4l2src_fixate:<v4l2src0> Preferred size 1920x1080
0:00:00.642556591 17684 0xffff7c000b70 TRACE                v4l2src gstv4l2src.c:478:gst_v4l2src_fixed_caps_compare: Placing video/x-raw, width=(int)1920, height=(int)1080, framerate=(fraction)60/1, format=(string)NV12, pixel-aspect-ratio=(fraction)1/1 before video/x-raw, format=(string)YUY2, width=(int)1920, height=(int)1080, framerate=(fraction)60/1, pixel-aspect-ratio=(fraction)1/1
0:00:00.642671469 17684 0xffff7c000b70 TRACE                v4l2src gstv4l2src.c:478:gst_v4l2src_fixed_caps_compare: Placing video/x-raw, width=(int)1920, height=(int)1080, framerate=(fraction)60/1, format=(string)NV16, pixel-aspect-ratio=(fraction)1/1 before video/x-raw, width=(int)1920, height=(int)1080, framerate=(fraction)60/1, format=(string)NV12, pixel-aspect-ratio=(fraction)1/1
0:00:00.642779221 17684 0xffff7c000b70 DEBUG                v4l2src gstv4l2src.c:558:gst_v4l2src_fixate:<v4l2src0> sorted and normalized caps video/x-raw, width=(int)1920, height=(int)1080, framerate=(fraction)60/1, format=(string)NV16, pixel-aspect-ratio=(fraction)1/1; video/x-raw, width=(int)1920, height=(int)1080, framerate=(fraction)60/1, format=(string)NV12, pixel-aspect-ratio=(fraction)1/1; video/x-raw, format=(string)YUY2, width=(int)1920, height=(int)1080, framerate=(fraction)60/1, pixel-aspect-ratio=(fraction)1/1
0:00:00.665755453 17684 0xffff7c000b70 DEBUG                v4l2src gstv4l2src.c:617:gst_v4l2src_fixate:<v4l2src0> fixated caps video/x-raw, width=(int)1920, height=(int)1080, framerate=(fraction)60/1, format=(string)NV16, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, colorimetry=(string)bt709

Merge request reports