h264parse: Avoid setting wrong colorimetry info if the stream doesn't contain it
authorThibault Saunier <tsaunier@igalia.com>
Wed, 7 Dec 2022 15:28:55 +0000 (12:28 -0300)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 7 Dec 2022 17:30:51 +0000 (17:30 +0000)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3543>

subprojects/gst-plugins-bad/gst/videoparsers/gsth264parse.c

index 2ecc7fa..e08e3f0 100644 (file)
@@ -2146,16 +2146,20 @@ gst_h264_parse_update_src_caps (GstH264Parse * h264parse, GstCaps * caps)
       GstVideoColorimetry ci = { 0, };
       gchar *old_colorimetry = NULL;
 
-      if (vui->video_full_range_flag)
-        ci.range = GST_VIDEO_COLOR_RANGE_0_255;
-      else
-        ci.range = GST_VIDEO_COLOR_RANGE_16_235;
-
       ci.matrix = gst_video_color_matrix_from_iso (vui->matrix_coefficients);
       ci.transfer =
           gst_video_transfer_function_from_iso (vui->transfer_characteristics);
       ci.primaries = gst_video_color_primaries_from_iso (vui->colour_primaries);
 
+      if (ci.matrix != GST_VIDEO_COLOR_MATRIX_UNKNOWN
+          && ci.transfer != GST_VIDEO_TRANSFER_UNKNOWN
+          && ci.primaries != GST_VIDEO_COLOR_PRIMARIES_UNKNOWN) {
+        if (vui->video_full_range_flag)
+          ci.range = GST_VIDEO_COLOR_RANGE_0_255;
+        else
+          ci.range = GST_VIDEO_COLOR_RANGE_16_235;
+      }
+
       old_colorimetry =
           gst_video_colorimetry_to_string (&h264parse->parsed_colorimetry);
       colorimetry = gst_video_colorimetry_to_string (&ci);