v4l2: caps negotiate wrong as interlace feature

gst_caps_simplify() will move interlace format before normal video
format. It will cause caps negotiate prefer interlaced caps which
isn't expected. Seperate normal caps and interlaced caps and then
merge it will keep prefer progress video format.
Add ARGB/BGRA for interlaced caps.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/802

Part-of <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/813>

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/813>
This commit is contained in:
Bing Song 2020-11-12 09:32:30 +08:00 committed by GStreamer Merge Bot
parent 79748dab2b
commit 8a0a7d932a
2 changed files with 12 additions and 6 deletions

View file

@ -23555,7 +23555,7 @@
"long-name": "Video (video4linux2) Sink",
"pad-templates": {
"sink": {
"caps": "image/jpeg:\nvideo/mpeg:\n mpegversion: 4\n systemstream: false\nvideo/mpeg:\n mpegversion: { (int)1, (int)2 }\nvideo/mpegts:\n systemstream: true\nvideo/x-bayer:\n format: { bggr, gbrg, grbg, rggb }\n width: [ 1, 32768 ]\n height: [ 1, 32768 ]\n framerate: [ 0/1, 2147483647/1 ]\nvideo/x-dv:\n systemstream: true\nvideo/x-fwht:\nvideo/x-h263:\n variant: itu\nvideo/x-h264:\n stream-format: { (string)byte-stream, (string)avc }\n alignment: au\nvideo/x-h265:\n stream-format: byte-stream\n alignment: au\nvideo/x-pwc1:\n width: [ 1, 32768 ]\n height: [ 1, 32768 ]\n framerate: [ 0/1, 2147483647/1 ]\nvideo/x-pwc2:\n width: [ 1, 32768 ]\n height: [ 1, 32768 ]\n framerate: [ 0/1, 2147483647/1 ]\n\nvideo/x-raw(format:Interlaced):\n format: { RGB16, BGR, BGRA, ABGR, xBGR, RGBx, ARGB, GRAY8, GRAY16_LE, GRAY16_BE, YVU9, YV12, YUY2, YVYU, UYVY, Y42B, Y41B, YUV9, NV12_64Z32, NV24, NV61, NV16, NV21, NV12, I420, xRGB, BGRx, RGB, BGR15, RGB15 }\n width: [ 1, 32768 ]\n height: [ 1, 32768 ]\n framerate: [ 0/1, 2147483647/1 ]\n interlace-mode: alternate\nvideo/x-raw:\n format: { RGB16, BGR, ABGR, xBGR, RGBx, GRAY8, GRAY16_LE, GRAY16_BE, YVU9, YV12, YUY2, YVYU, UYVY, Y42B, Y41B, YUV9, NV12_64Z32, NV24, NV61, NV16, NV21, NV12, I420, ARGB, xRGB, RGB, BGRA, BGRx, BGR15, RGB15 }\n width: [ 1, 32768 ]\n height: [ 1, 32768 ]\n framerate: [ 0/1, 2147483647/1 ]\nvideo/x-sonix:\n width: [ 1, 32768 ]\n height: [ 1, 32768 ]\n framerate: [ 0/1, 2147483647/1 ]\nvideo/x-vp8:\nvideo/x-vp9:\nvideo/x-wmv:\n wmvversion: 3\n format: WVC1\n",
"caps": "image/jpeg:\nvideo/mpeg:\n mpegversion: 4\n systemstream: false\nvideo/mpeg:\n mpegversion: { (int)1, (int)2 }\nvideo/mpegts:\n systemstream: true\nvideo/x-bayer:\n format: { bggr, gbrg, grbg, rggb }\n width: [ 1, 32768 ]\n height: [ 1, 32768 ]\n framerate: [ 0/1, 2147483647/1 ]\nvideo/x-dv:\n systemstream: true\nvideo/x-fwht:\nvideo/x-h263:\n variant: itu\nvideo/x-h264:\n stream-format: { (string)byte-stream, (string)avc }\n alignment: au\nvideo/x-h265:\n stream-format: byte-stream\n alignment: au\nvideo/x-pwc1:\n width: [ 1, 32768 ]\n height: [ 1, 32768 ]\n framerate: [ 0/1, 2147483647/1 ]\nvideo/x-pwc2:\n width: [ 1, 32768 ]\n height: [ 1, 32768 ]\n framerate: [ 0/1, 2147483647/1 ]\nvideo/x-raw:\n format: { RGB16, BGR, ABGR, xBGR, RGBx, GRAY8, GRAY16_LE, GRAY16_BE, YVU9, YV12, YUY2, YVYU, UYVY, Y42B, Y41B, YUV9, NV12_64Z32, NV24, NV61, NV16, NV21, NV12, I420, ARGB, xRGB, RGB, BGRA, BGRx, BGR15, RGB15 }\n width: [ 1, 32768 ]\n height: [ 1, 32768 ]\n framerate: [ 0/1, 2147483647/1 ]\nvideo/x-sonix:\n width: [ 1, 32768 ]\n height: [ 1, 32768 ]\n framerate: [ 0/1, 2147483647/1 ]\nvideo/x-vp8:\nvideo/x-vp9:\nvideo/x-wmv:\n wmvversion: 3\n format: WVC1\n\nvideo/x-raw(format:Interlaced):\n format: { RGB16, BGR, ABGR, xBGR, RGBx, GRAY8, GRAY16_LE, GRAY16_BE, YVU9, YV12, YUY2, YVYU, UYVY, Y42B, Y41B, YUV9, NV12_64Z32, NV24, NV61, NV16, NV21, NV12, I420, ARGB, xRGB, RGB, BGRA, BGRx, BGR15, RGB15 }\n width: [ 1, 32768 ]\n height: [ 1, 32768 ]\n framerate: [ 0/1, 2147483647/1 ]\n interlace-mode: alternate\n",
"direction": "sink",
"presence": "always"
}
@ -23863,7 +23863,7 @@
"long-name": "Video (video4linux2) Source",
"pad-templates": {
"src": {
"caps": "image/jpeg:\nvideo/mpeg:\n mpegversion: 4\n systemstream: false\nvideo/mpeg:\n mpegversion: { (int)1, (int)2 }\nvideo/mpegts:\n systemstream: true\nvideo/x-bayer:\n format: { bggr, gbrg, grbg, rggb }\n width: [ 1, 32768 ]\n height: [ 1, 32768 ]\n framerate: [ 0/1, 2147483647/1 ]\nvideo/x-dv:\n systemstream: true\nvideo/x-fwht:\nvideo/x-h263:\n variant: itu\nvideo/x-h264:\n stream-format: { (string)byte-stream, (string)avc }\n alignment: au\nvideo/x-h265:\n stream-format: byte-stream\n alignment: au\nvideo/x-pwc1:\n width: [ 1, 32768 ]\n height: [ 1, 32768 ]\n framerate: [ 0/1, 2147483647/1 ]\nvideo/x-pwc2:\n width: [ 1, 32768 ]\n height: [ 1, 32768 ]\n framerate: [ 0/1, 2147483647/1 ]\n\nvideo/x-raw(format:Interlaced):\n format: { RGB16, BGR, BGRA, ABGR, xBGR, RGBx, ARGB, GRAY8, GRAY16_LE, GRAY16_BE, YVU9, YV12, YUY2, YVYU, UYVY, Y42B, Y41B, YUV9, NV12_64Z32, NV24, NV61, NV16, NV21, NV12, I420, xRGB, BGRx, RGB, BGR15, RGB15 }\n width: [ 1, 32768 ]\n height: [ 1, 32768 ]\n framerate: [ 0/1, 2147483647/1 ]\n interlace-mode: alternate\nvideo/x-raw:\n format: { RGB16, BGR, ABGR, xBGR, RGBx, GRAY8, GRAY16_LE, GRAY16_BE, YVU9, YV12, YUY2, YVYU, UYVY, Y42B, Y41B, YUV9, NV12_64Z32, NV24, NV61, NV16, NV21, NV12, I420, ARGB, xRGB, RGB, BGRA, BGRx, BGR15, RGB15 }\n width: [ 1, 32768 ]\n height: [ 1, 32768 ]\n framerate: [ 0/1, 2147483647/1 ]\nvideo/x-sonix:\n width: [ 1, 32768 ]\n height: [ 1, 32768 ]\n framerate: [ 0/1, 2147483647/1 ]\nvideo/x-vp8:\nvideo/x-vp9:\nvideo/x-wmv:\n wmvversion: 3\n format: WVC1\n",
"caps": "image/jpeg:\nvideo/mpeg:\n mpegversion: 4\n systemstream: false\nvideo/mpeg:\n mpegversion: { (int)1, (int)2 }\nvideo/mpegts:\n systemstream: true\nvideo/x-bayer:\n format: { bggr, gbrg, grbg, rggb }\n width: [ 1, 32768 ]\n height: [ 1, 32768 ]\n framerate: [ 0/1, 2147483647/1 ]\nvideo/x-dv:\n systemstream: true\nvideo/x-fwht:\nvideo/x-h263:\n variant: itu\nvideo/x-h264:\n stream-format: { (string)byte-stream, (string)avc }\n alignment: au\nvideo/x-h265:\n stream-format: byte-stream\n alignment: au\nvideo/x-pwc1:\n width: [ 1, 32768 ]\n height: [ 1, 32768 ]\n framerate: [ 0/1, 2147483647/1 ]\nvideo/x-pwc2:\n width: [ 1, 32768 ]\n height: [ 1, 32768 ]\n framerate: [ 0/1, 2147483647/1 ]\nvideo/x-raw:\n format: { RGB16, BGR, ABGR, xBGR, RGBx, GRAY8, GRAY16_LE, GRAY16_BE, YVU9, YV12, YUY2, YVYU, UYVY, Y42B, Y41B, YUV9, NV12_64Z32, NV24, NV61, NV16, NV21, NV12, I420, ARGB, xRGB, RGB, BGRA, BGRx, BGR15, RGB15 }\n width: [ 1, 32768 ]\n height: [ 1, 32768 ]\n framerate: [ 0/1, 2147483647/1 ]\nvideo/x-sonix:\n width: [ 1, 32768 ]\n height: [ 1, 32768 ]\n framerate: [ 0/1, 2147483647/1 ]\nvideo/x-vp8:\nvideo/x-vp9:\nvideo/x-wmv:\n wmvversion: 3\n format: WVC1\n\nvideo/x-raw(format:Interlaced):\n format: { RGB16, BGR, ABGR, xBGR, RGBx, GRAY8, GRAY16_LE, GRAY16_BE, YVU9, YV12, YUY2, YVYU, UYVY, Y42B, Y41B, YUV9, NV12_64Z32, NV24, NV61, NV16, NV21, NV12, I420, ARGB, xRGB, RGB, BGRA, BGRx, BGR15, RGB15 }\n width: [ 1, 32768 ]\n height: [ 1, 32768 ]\n framerate: [ 0/1, 2147483647/1 ]\n interlace-mode: alternate\n",
"direction": "src",
"presence": "always"
}

View file

@ -1644,10 +1644,11 @@ static GstCaps *
gst_v4l2_object_get_caps_helper (GstV4L2FormatFlags flags)
{
GstStructure *structure;
GstCaps *caps;
GstCaps *caps, *caps_interlaced;
guint i;
caps = gst_caps_new_empty ();
caps_interlaced = gst_caps_new_empty ();
for (i = 0; i < GST_V4L2_FORMAT_COUNT; i++) {
if ((gst_v4l2_formats[i].flags & flags) == 0)
@ -1680,14 +1681,19 @@ gst_v4l2_object_get_caps_helper (GstV4L2FormatFlags flags)
gst_caps_append_structure (caps, structure);
if (alt_s)
if (alt_s) {
gst_caps_append_structure (caps, alt_s);
add_alternate_variant (NULL, caps_interlaced, alt_s);
}
add_alternate_variant (NULL, caps, structure);
add_alternate_variant (NULL, caps_interlaced, structure);
}
}
return gst_caps_simplify (caps);
caps = gst_caps_simplify (caps);
caps_interlaced = gst_caps_simplify (caps_interlaced);
return gst_caps_merge (caps, caps_interlaced);
}
GstCaps *