decklink: fix 10 bit RGB (r210) format auto detection

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/2391

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4332>
This commit is contained in:
Wojciech Kapsa 2023-04-04 12:22:31 +02:00 committed by Sebastian Dröge
parent cd827e790a
commit 8d4916df84
5 changed files with 35 additions and 10 deletions

File diff suppressed because one or more lines are too long

View file

@ -171,8 +171,8 @@ gst_decklink_video_format_get_type (void)
{GST_DECKLINK_VIDEO_FORMAT_10BIT_YUV, "bmdFormat10BitYUV", "10bit-yuv"},
{GST_DECKLINK_VIDEO_FORMAT_8BIT_ARGB, "bmdFormat8BitARGB", "8bit-argb"},
{GST_DECKLINK_VIDEO_FORMAT_8BIT_BGRA, "bmdFormat8BitBGRA", "8bit-bgra"},
/* Not yet supported:
{GST_DECKLINK_VIDEO_FORMAT_10BIT_RGB, "bmdFormat10BitRGB", "10bit-rgb"},
/* Not yet supported:
{GST_DECKLINK_VIDEO_FORMAT_12BIT_RGB, "bmdFormat12BitRGB", "12bit-rgb"},
{GST_DECKLINK_VIDEO_FORMAT_12BIT_RGBLE, "bmdFormat12BitRGBLE", "12bit-rgble"},
{GST_DECKLINK_VIDEO_FORMAT_10BIT_RGBXLE, "bmdFormat10BitRGBXLE", "10bit-rgbxle"},
@ -455,8 +455,8 @@ static const struct
{bmdFormat10BitYUV, 4, GST_VIDEO_FORMAT_v210},
{bmdFormat8BitARGB, 4, GST_VIDEO_FORMAT_ARGB},
{bmdFormat8BitBGRA, 4, GST_VIDEO_FORMAT_BGRA},
{bmdFormat10BitRGB, 4, GST_VIDEO_FORMAT_r210},
/* Not yet supported
{bmdFormat10BitRGB, FIXME, FIXME},
{bmdFormat12BitRGB, FIXME, FIXME},
{bmdFormat12BitRGBLE, FIXME, FIXME},
{bmdFormat10BitRGBXLE, FIXME, FIXME},
@ -881,6 +881,8 @@ gst_decklink_mode_get_structure (GstDecklinkModeEnum e, BMDPixelFormat f,
gst_structure_set (s, "format", G_TYPE_STRING, "BGRA", NULL);
break;
case bmdFormat10BitRGB: /* 'r210' Big-endian RGB 10-bit per component with SMPTE video levels (64-960). Packed as 2:10:10:10 */
gst_structure_set (s, "format", G_TYPE_STRING, "r210", NULL);
break;
case bmdFormat12BitRGB: /* 'R12B' Big-endian RGB 12-bit per component with full range (0-4095). Packed as 12-bit per component */
case bmdFormat12BitRGBLE: /* 'R12L' Little-endian RGB 12-bit per component with full range (0-4095). Packed as 12-bit per component */
case bmdFormat10BitRGBXLE: /* 'R10l' Little-endian 10-bit RGB with SMPTE video levels (64-940) */
@ -1108,14 +1110,19 @@ public:
GST_INFO ("Video input format changed");
/* Detect input format */
if ((formatFlags & bmdDetectedVideoInputRGB444)
&& (formatFlags & bmdDetectedVideoInput8BitDepth)) {
if (formatFlags & bmdDetectedVideoInputRGB444) {
if (formatFlags & bmdDetectedVideoInput10BitDepth) {
pixelFormat = bmdFormat10BitRGB;
} else if (formatFlags & bmdDetectedVideoInput8BitDepth) {
/* Cannot detect ARGB vs BGRA, so assume ARGB unless user sets BGRA */
if (m_input->format == bmdFormat8BitBGRA) {
pixelFormat = bmdFormat8BitBGRA;
} else {
pixelFormat = bmdFormat8BitARGB;
}
} else {
GST_ERROR ("Not implemented depth");
}
} else if (formatFlags & bmdDetectedVideoInputYCbCr422) {
if (formatFlags & bmdDetectedVideoInput10BitDepth) {
pixelFormat = bmdFormat10BitYUV;

View file

@ -303,11 +303,20 @@ typedef enum {
GST_DECKLINK_VIDEO_FORMAT_10BIT_YUV, /* bmdFormat10BitYUV */
GST_DECKLINK_VIDEO_FORMAT_8BIT_ARGB, /* bmdFormat8BitARGB */
GST_DECKLINK_VIDEO_FORMAT_8BIT_BGRA, /* bmdFormat8BitBGRA */
/**
* GstDecklinkVideoFormat::10bit-rgb:
*
* Since: 1.22.2
*/
GST_DECKLINK_VIDEO_FORMAT_10BIT_RGB, /* bmdFormat10BitRGB */
/* Not yet supported */
#if 0
GST_DECKLINK_VIDEO_FORMAT_12BIT_RGB, /* bmdFormat12BitRGB */
GST_DECKLINK_VIDEO_FORMAT_12BIT_RGBLE, /* bmdFormat12BitRGBLE */
GST_DECKLINK_VIDEO_FORMAT_10BIT_RGBXLE, /* bmdFormat10BitRGBXLE */
GST_DECKLINK_VIDEO_FORMAT_10BIT_RGBX, /* bmdFormat10BitRGBX */
#endif
} GstDecklinkVideoFormat;
#define GST_TYPE_DECKLINK_VIDEO_FORMAT (gst_decklink_video_format_get_type ())
GType gst_decklink_video_format_get_type (void);

View file

@ -387,6 +387,8 @@ public:
return bmdFormat8BitARGB;
case GST_VIDEO_FORMAT_BGRA:
return bmdFormat8BitBGRA;
case GST_VIDEO_FORMAT_r210:
return bmdFormat10BitRGB;
default:
g_assert_not_reached ();
}
@ -776,6 +778,7 @@ gst_decklink_video_sink_set_property (GObject * object, guint property_id,
case GST_DECKLINK_VIDEO_FORMAT_10BIT_YUV:
case GST_DECKLINK_VIDEO_FORMAT_8BIT_ARGB:
case GST_DECKLINK_VIDEO_FORMAT_8BIT_BGRA:
case GST_DECKLINK_VIDEO_FORMAT_10BIT_RGB:
break;
default:
GST_ELEMENT_WARNING (GST_ELEMENT (self), CORE, NOT_IMPLEMENTED,

View file

@ -483,6 +483,7 @@ gst_decklink_video_src_set_property (GObject * object, guint property_id,
switch (self->video_format) {
case GST_DECKLINK_VIDEO_FORMAT_8BIT_YUV:
case GST_DECKLINK_VIDEO_FORMAT_10BIT_YUV:
case GST_DECKLINK_VIDEO_FORMAT_10BIT_RGB:
case GST_DECKLINK_VIDEO_FORMAT_8BIT_ARGB:
case GST_DECKLINK_VIDEO_FORMAT_8BIT_BGRA:
self->caps_format =