diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2017-11-06 12:39:32 +0100 |
---|---|---|
committer | Nicolas Dufresne <nicolas.dufresne@collabora.com> | 2018-01-24 11:50:54 -0500 |
commit | a1b271d2ecd9dfc60c12e90abcbbe9c18c8eed4f (patch) | |
tree | 3a873021e805a222140cd638533bc6065f71e074 | |
parent | 07c8417799940da697212246398ffd828f39b169 (diff) |
h26{4,5}parse: expose chroma format and bit depth in caps
This information could be used for example to pick a decoder supporting
a specific chroma and/or bit depth, like 4:2:2 10 bits.
It can also be used to inform earlier decoder about the format it is
about to decode.
https://bugzilla.gnome.org/show_bug.cgi?id=792039
-rw-r--r-- | gst/videoparsers/gsth264parse.c | 28 | ||||
-rw-r--r-- | gst/videoparsers/gsth265parse.c | 28 |
2 files changed, 56 insertions, 0 deletions
diff --git a/gst/videoparsers/gsth264parse.c b/gst/videoparsers/gsth264parse.c index 7003caf24..f53a5595b 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 7800b15ae..ba8fbe7ca 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); } } |