h265parse: use same algo for MDCV and CLL SEI management

This commit is contained in:
Stéphane Cerveau 2019-12-05 16:48:05 +01:00 committed by Guillaume Desmottes
parent b481edd745
commit d414e90eff

View file

@ -615,19 +615,17 @@ gst_h265_parse_process_sei (GstH265Parse * h265parse, GstH265NalUnit * nalu)
minfo.max_luma_d = minfo.min_luma_d = luma_den; minfo.max_luma_d = minfo.min_luma_d = luma_den;
GST_LOG_OBJECT (h265parse, "mastering display info found"); GST_LOG_OBJECT (h265parse, "mastering display info found: "
GST_LOG_OBJECT (h265parse, "\tRed (%u/%u, %u/%u)", minfo.Rx_n, "Red(%u/%u, %u/%u) "
minfo.Rx_d, minfo.Ry_n, minfo.Ry_d); "Green(%u/%u, %u/%u) "
GST_LOG_OBJECT (h265parse, "\tGreen(%u/%u, %u/%u)", minfo.Gx_n, "Blue(%u/%u, %u/%u) "
minfo.Gx_d, minfo.Gy_n, minfo.Gy_d); "White(%u/%u, %u/%u) "
GST_LOG_OBJECT (h265parse, "\tBlue (%u/%u, %u/%u)", minfo.Bx_n, "max_luminance(%u/%u) "
minfo.Bx_d, minfo.By_n, minfo.By_d); "min_luminance(%u/%u) ", minfo.Rx_n, minfo.Rx_d, minfo.Ry_n,
GST_LOG_OBJECT (h265parse, "\tWhite(%u/%u, %u/%u)", minfo.Wx_n, minfo.Ry_d, minfo.Gx_n, minfo.Gx_d, minfo.Gy_n, minfo.Gy_d,
minfo.Wx_d, minfo.Wy_n, minfo.Wy_d); minfo.Bx_n, minfo.Bx_d, minfo.By_n, minfo.By_d, minfo.Wx_n,
GST_LOG_OBJECT (h265parse, minfo.Wx_d, minfo.Wy_n, minfo.Wy_d, minfo.max_luma_n,
"\tmax_luminance:(%u/%u), min_luminance:(%u/%u)", minfo.max_luma_d, minfo.min_luma_n, minfo.min_luma_d);
minfo.max_luma_n, minfo.max_luma_d, minfo.min_luma_n,
minfo.min_luma_d);
if (h265parse->mastering_display_info_state == if (h265parse->mastering_display_info_state ==
GST_H265_PARSE_SEI_EXPIRED) { GST_H265_PARSE_SEI_EXPIRED) {
@ -652,9 +650,8 @@ gst_h265_parse_process_sei (GstH265Parse * h265parse, GstH265NalUnit * nalu)
cll.maxCLL_d = cll.maxFALL_d = 1; cll.maxCLL_d = cll.maxFALL_d = 1;
GST_LOG_OBJECT (h265parse, "content light level found"); GST_LOG_OBJECT (h265parse, "content light level found: "
GST_LOG_OBJECT (h265parse, "maxCLL:(%u/%u), maxFALL:(%u/%u)", cll.maxCLL_n, cll.maxCLL_d,
"\tmaxCLL:(%u/%u), maxFALL:(%u/%u)", cll.maxCLL_n, cll.maxCLL_d,
cll.maxFALL_n, cll.maxFALL_d); cll.maxFALL_n, cll.maxFALL_d);
if (h265parse->content_light_level_state == GST_H265_PARSE_SEI_EXPIRED) { if (h265parse->content_light_level_state == GST_H265_PARSE_SEI_EXPIRED) {
@ -924,14 +921,20 @@ gst_h265_parse_process_nal (GstH265Parse * h265parse, GstH265NalUnit * nalu)
is_irap = ((nal_type >= GST_H265_NAL_SLICE_BLA_W_LP) is_irap = ((nal_type >= GST_H265_NAL_SLICE_BLA_W_LP)
&& (nal_type <= GST_H265_NAL_SLICE_CRA_NUT)) ? TRUE : FALSE; && (nal_type <= GST_H265_NAL_SLICE_CRA_NUT)) ? TRUE : FALSE;
if (h265parse->mastering_display_info_state != GST_H265_PARSE_SEI_EXPIRED if (no_rasl_output_flag && is_irap) {
&& no_rasl_output_flag && is_irap) if (h265parse->mastering_display_info_state ==
h265parse->mastering_display_info_state--; GST_H265_PARSE_SEI_PARSED)
h265parse->mastering_display_info_state = GST_H265_PARSE_SEI_ACTIVE;
if (h265parse->content_light_level_state != GST_H265_PARSE_SEI_EXPIRED && else if (h265parse->mastering_display_info_state ==
no_rasl_output_flag && is_irap) GST_H265_PARSE_SEI_ACTIVE)
h265parse->content_light_level_state--; h265parse->mastering_display_info_state = GST_H265_PARSE_SEI_EXPIRED;
if (h265parse->content_light_level_state == GST_H265_PARSE_SEI_PARSED)
h265parse->content_light_level_state = GST_H265_PARSE_SEI_ACTIVE;
else if (h265parse->content_light_level_state ==
GST_H265_PARSE_SEI_ACTIVE)
h265parse->content_light_level_state = GST_H265_PARSE_SEI_EXPIRED;
}
if (G_LIKELY (!is_irap && !h265parse->push_codec)) if (G_LIKELY (!is_irap && !h265parse->push_codec))
break; break;
@ -2105,8 +2108,8 @@ gst_h265_parse_update_src_caps (GstH265Parse * h265parse, GstCaps * caps)
if (caps) { if (caps) {
gint par_n, par_d; gint par_n, par_d;
const gchar *mastering_info_str; const gchar *mdi_str = NULL;
const gchar *cll_str; const gchar *cll_str = NULL;
gst_caps_set_simple (caps, "parsed", G_TYPE_BOOLEAN, TRUE, gst_caps_set_simple (caps, "parsed", G_TYPE_BOOLEAN, TRUE,
"stream-format", G_TYPE_STRING, "stream-format", G_TYPE_STRING,
@ -2144,26 +2147,26 @@ gst_h265_parse_update_src_caps (GstH265Parse * h265parse, GstCaps * caps)
ensure_caps_profile (h265parse, caps, sps, p); ensure_caps_profile (h265parse, caps, sps, p);
} }
if (s if (s)
&& (mastering_info_str = mdi_str = gst_structure_get_string (s, "mastering-display-info");
gst_structure_get_string (s, "mastering-display-info"))) { if (mdi_str) {
gst_caps_set_simple (caps, "mastering-display-info", G_TYPE_STRING, gst_caps_set_simple (caps, "mastering-display-info", G_TYPE_STRING,
mastering_info_str, NULL); mdi_str, NULL);
} else if (h265parse->mastering_display_info_state != } else if (h265parse->mastering_display_info_state !=
GST_H265_PARSE_SEI_EXPIRED GST_H265_PARSE_SEI_EXPIRED &&
&&
!gst_video_mastering_display_info_add_to_caps !gst_video_mastering_display_info_add_to_caps
(&h265parse->mastering_display_info, caps)) { (&h265parse->mastering_display_info, caps)) {
GST_WARNING_OBJECT (h265parse, GST_WARNING_OBJECT (h265parse,
"Couldn't set mastering display info to caps"); "Couldn't set mastering display info to caps");
} }
if (s && (cll_str = gst_structure_get_string (s, "content-light-level"))) { if (s)
cll_str = gst_structure_get_string (s, "content-light-level");
if (cll_str) {
gst_caps_set_simple (caps, "content-light-level", G_TYPE_STRING, cll_str, gst_caps_set_simple (caps, "content-light-level", G_TYPE_STRING, cll_str,
NULL); NULL);
} else if (h265parse->content_light_level_state != } else if (h265parse->content_light_level_state !=
GST_H265_PARSE_SEI_EXPIRED GST_H265_PARSE_SEI_EXPIRED &&
&&
!gst_video_content_light_level_add_to_caps !gst_video_content_light_level_add_to_caps
(&h265parse->content_light_level, caps)) { (&h265parse->content_light_level, caps)) {
GST_WARNING_OBJECT (h265parse, GST_WARNING_OBJECT (h265parse,