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
This commit is contained in:
Guillaume Desmottes 2017-11-06 12:39:32 +01:00 committed by Nicolas Dufresne
parent 07c8417799
commit a1b271d2ec
2 changed files with 56 additions and 0 deletions

View file

@ -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);
}
}

View file

@ -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);
}
}