decklinkvideosrc: ignore HDR metadata consisting of all zeros

In some cases decklinkvideosink may produce such stream when the
information is unknown.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7742>
This commit is contained in:
Matthew Waters 2024-10-22 13:23:06 +11:00 committed by GStreamer Marge Bot
parent 06c344d43a
commit 19a60f341c

View file

@ -1031,6 +1031,7 @@ gst_decklink_video_src_got_frame (GstElement * element,
} }
if (frame->GetFlags () & bmdFrameContainsHDRMetadata) { if (frame->GetFlags () & bmdFrameContainsHDRMetadata) {
gboolean undefined_mastering_info = TRUE;
double max_cll, max_fll, x, y; double max_cll, max_fll, x, y;
gint64 tf; gint64 tf;
@ -1046,7 +1047,7 @@ gst_decklink_video_src_got_frame (GstElement * element,
bmdDeckLinkFrameMetadataHDRMaximumFrameAverageLightLevel, &max_fll); bmdDeckLinkFrameMetadataHDRMaximumFrameAverageLightLevel, &max_fll);
GST_LOG_OBJECT (self, "ret %x maxcll %f maxfll %f", (gint) dk_ret, max_cll, GST_LOG_OBJECT (self, "ret %x maxcll %f maxfll %f", (gint) dk_ret, max_cll,
max_fll); max_fll);
if (dk_ret == S_OK) { if (dk_ret == S_OK && ((guint16) max_cll > 0 || (guint16) max_fll > 0)) {
f.have_light_level = TRUE; f.have_light_level = TRUE;
f.light_level.max_content_light_level = (guint16) max_cll; f.light_level.max_content_light_level = (guint16) max_cll;
f.light_level.max_frame_average_light_level = (guint16) max_fll; f.light_level.max_frame_average_light_level = (guint16) max_fll;
@ -1060,6 +1061,7 @@ gst_decklink_video_src_got_frame (GstElement * element,
bmdDeckLinkFrameMetadataHDRDisplayPrimariesRedY, &y); bmdDeckLinkFrameMetadataHDRDisplayPrimariesRedY, &y);
f.mastering_info.display_primaries[0].x = (guint16) (x * 50000.0); f.mastering_info.display_primaries[0].x = (guint16) (x * 50000.0);
f.mastering_info.display_primaries[0].y = (guint16) (y * 50000.0); f.mastering_info.display_primaries[0].y = (guint16) (y * 50000.0);
undefined_mastering_info &= x <= 0 && y <= 0;
dk_ret |= dk_ret |=
frame_metadata->GetFloat ( frame_metadata->GetFloat (
bmdDeckLinkFrameMetadataHDRDisplayPrimariesGreenX, &x); bmdDeckLinkFrameMetadataHDRDisplayPrimariesGreenX, &x);
@ -1068,6 +1070,7 @@ gst_decklink_video_src_got_frame (GstElement * element,
bmdDeckLinkFrameMetadataHDRDisplayPrimariesGreenY, &y); bmdDeckLinkFrameMetadataHDRDisplayPrimariesGreenY, &y);
f.mastering_info.display_primaries[1].x = (guint16) (x * 50000.0); f.mastering_info.display_primaries[1].x = (guint16) (x * 50000.0);
f.mastering_info.display_primaries[1].y = (guint16) (y * 50000.0); f.mastering_info.display_primaries[1].y = (guint16) (y * 50000.0);
undefined_mastering_info &= x <= 0 && y <= 0;
dk_ret |= dk_ret |=
frame_metadata->GetFloat ( frame_metadata->GetFloat (
bmdDeckLinkFrameMetadataHDRDisplayPrimariesBlueX, &x); bmdDeckLinkFrameMetadataHDRDisplayPrimariesBlueX, &x);
@ -1076,12 +1079,14 @@ gst_decklink_video_src_got_frame (GstElement * element,
bmdDeckLinkFrameMetadataHDRDisplayPrimariesBlueY, &y); bmdDeckLinkFrameMetadataHDRDisplayPrimariesBlueY, &y);
f.mastering_info.display_primaries[2].x = (guint16) (x * 50000.0); f.mastering_info.display_primaries[2].x = (guint16) (x * 50000.0);
f.mastering_info.display_primaries[2].y = (guint16) (y * 50000.0); f.mastering_info.display_primaries[2].y = (guint16) (y * 50000.0);
undefined_mastering_info &= x <= 0 && y <= 0;
dk_ret |= dk_ret |=
frame_metadata->GetFloat (bmdDeckLinkFrameMetadataHDRWhitePointX, &x); frame_metadata->GetFloat (bmdDeckLinkFrameMetadataHDRWhitePointX, &x);
dk_ret |= dk_ret |=
frame_metadata->GetFloat (bmdDeckLinkFrameMetadataHDRWhitePointY, &y); frame_metadata->GetFloat (bmdDeckLinkFrameMetadataHDRWhitePointY, &y);
f.mastering_info.white_point.x = (guint16) (x * 50000.0); f.mastering_info.white_point.x = (guint16) (x * 50000.0);
f.mastering_info.white_point.y = (guint16) (y * 50000.0); f.mastering_info.white_point.y = (guint16) (y * 50000.0);
undefined_mastering_info &= x <= 0 && y <= 0;
dk_ret |= dk_ret |=
frame_metadata->GetFloat ( frame_metadata->GetFloat (
bmdDeckLinkFrameMetadataHDRMaxDisplayMasteringLuminance, &x); bmdDeckLinkFrameMetadataHDRMaxDisplayMasteringLuminance, &x);
@ -1090,6 +1095,7 @@ gst_decklink_video_src_got_frame (GstElement * element,
bmdDeckLinkFrameMetadataHDRMinDisplayMasteringLuminance, &y); bmdDeckLinkFrameMetadataHDRMinDisplayMasteringLuminance, &y);
f.mastering_info.max_display_mastering_luminance = (guint32) (x * 10000.0 / 65535.0); f.mastering_info.max_display_mastering_luminance = (guint32) (x * 10000.0 / 65535.0);
f.mastering_info.min_display_mastering_luminance = (guint32) (y * 10000.0 / 6.5535); f.mastering_info.min_display_mastering_luminance = (guint32) (y * 10000.0 / 6.5535);
undefined_mastering_info &= x <= 0 && y <= 0;
GST_LOG_OBJECT (self, "ret 0x%x mastering_info " GST_LOG_OBJECT (self, "ret 0x%x mastering_info "
"R:%u,%u G:%u,%u B:%u,%u W:%u,%u", (gint) dk_ret, "R:%u,%u G:%u,%u B:%u,%u W:%u,%u", (gint) dk_ret,
f.mastering_info.display_primaries[0].x, f.mastering_info.display_primaries[0].x,
@ -1099,7 +1105,7 @@ gst_decklink_video_src_got_frame (GstElement * element,
f.mastering_info.display_primaries[2].x, f.mastering_info.display_primaries[2].x,
f.mastering_info.display_primaries[2].y, f.mastering_info.display_primaries[2].y,
f.mastering_info.white_point.x, f.mastering_info.white_point.y); f.mastering_info.white_point.x, f.mastering_info.white_point.y);
if (dk_ret == S_OK) if (dk_ret == S_OK && !undefined_mastering_info)
f.have_mastering_info = TRUE; f.have_mastering_info = TRUE;
dk_ret = dk_ret =