diff --git a/gst/videoparsers/gsth264parse.c b/gst/videoparsers/gsth264parse.c index 7003caf246..f53a5595b3 100644 --- a/gst/videoparsers/gsth264parse.c +++ b/gst/videoparsers/gsth264parse.c @@ -1825,6 +1825,8 @@ gst_h264_parse_update_src_caps (GstH264Parse * h264parse, GstCaps * caps) const gchar *caps_mview_mode = NULL; GstVideoMultiviewMode mview_mode = h264parse->multiview_mode; GstVideoMultiviewFlags mview_flags = h264parse->multiview_flags; + const gchar *chroma_format = NULL; + guint bit_depth_chroma; fps_num = h264parse->fps_num; fps_den = h264parse->fps_den; @@ -1900,6 +1902,32 @@ gst_h264_parse_update_src_caps (GstH264Parse * h264parse, GstCaps * caps) if (s && !gst_structure_has_field (s, "interlace-mode")) gst_caps_set_simple (caps, "interlace-mode", G_TYPE_STRING, gst_video_interlace_mode_to_string (imode), NULL); + + bit_depth_chroma = sps->bit_depth_chroma_minus8 + 8; + + switch (sps->chroma_format_idc) { + case 0: + chroma_format = "4:0:0"; + bit_depth_chroma = 0; + break; + case 1: + chroma_format = "4:2:0"; + break; + case 2: + chroma_format = "4:2:2"; + break; + case 3: + chroma_format = "4:4:4"; + break; + default: + break; + } + + if (chroma_format) + gst_caps_set_simple (caps, + "chroma-format", G_TYPE_STRING, chroma_format, + "bit-depth-luma", G_TYPE_UINT, sps->bit_depth_luma_minus8 + 8, + "bit-depth-chroma", G_TYPE_UINT, bit_depth_chroma, NULL); } } diff --git a/gst/videoparsers/gsth265parse.c b/gst/videoparsers/gsth265parse.c index 7800b15ae1..ba8fbe7caa 100644 --- a/gst/videoparsers/gsth265parse.c +++ b/gst/videoparsers/gsth265parse.c @@ -1456,6 +1456,8 @@ gst_h265_parse_update_src_caps (GstH265Parse * h265parse, GstCaps * caps) caps = gst_caps_copy (sink_caps); } else { gint crop_width, crop_height; + const gchar *chroma_format = NULL; + guint bit_depth_chroma; if (sps->conformance_window_flag) { crop_width = sps->crop_rect_width; @@ -1536,6 +1538,32 @@ gst_h265_parse_update_src_caps (GstH265Parse * h265parse, GstCaps * caps) gst_base_parse_set_latency (GST_BASE_PARSE (h265parse), latency, latency); } + + bit_depth_chroma = sps->bit_depth_chroma_minus8 + 8; + + switch (sps->chroma_format_idc) { + case 0: + chroma_format = "4:0:0"; + bit_depth_chroma = 0; + break; + case 1: + chroma_format = "4:2:0"; + break; + case 2: + chroma_format = "4:2:2"; + break; + case 3: + chroma_format = "4:4:4"; + break; + default: + break; + } + + if (chroma_format) + gst_caps_set_simple (caps, "chroma-format", G_TYPE_STRING, + chroma_format, "bit-depth-luma", G_TYPE_UINT, + sps->bit_depth_luma_minus8 + 8, "bit-depth-chroma", G_TYPE_UINT, + bit_depth_chroma, NULL); } }