From 8899a471e3ffb98f6b97b4b0885d69504729f234 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Fri, 28 Jun 2019 14:50:00 +1000 Subject: [PATCH] h264parse lib: Remove the SPS parse_vui_params flag The SPS parsing functions take a parse_vui_param flag to skip VUI parsing, but there's no indication in the output SPS struct that the VUI was skipped. The only caller that ever passed FALSE seems to be the important gst_h264_parser_parse_nal() function, meaning - so the cached SPS were always silently invalid. That needs changing anyway, meaning noone ever passes FALSE. I don't see any use for saving a few microseconds in order to silently produce garbage, and since this is still unstable API, let's remove the parse_vui_param. --- ext/smoothstreaming/gstmssmanifest.c | 2 +- gst-libs/gst/codecparsers/gsth264parser.c | 35 +++++++++-------------- gst-libs/gst/codecparsers/gsth264parser.h | 8 +++--- gst/videoparsers/gsth264parse.c | 4 +-- 4 files changed, 20 insertions(+), 29 deletions(-) diff --git a/ext/smoothstreaming/gstmssmanifest.c b/ext/smoothstreaming/gstmssmanifest.c index 232aa87343..a349bf1770 100644 --- a/ext/smoothstreaming/gstmssmanifest.c +++ b/ext/smoothstreaming/gstmssmanifest.c @@ -637,7 +637,7 @@ _gst_mss_stream_add_h264_codec_data (GstCaps * caps, const gchar * codecdatastr) nalu.header_bytes = 0; nalu.extension_type = GST_H264_NAL_EXTENSION_NONE; - parseres = gst_h264_parse_sps (&nalu, &sps_struct, TRUE); + parseres = gst_h264_parse_sps (&nalu, &sps_struct); if (parseres == GST_H264_PARSER_OK) { gint fps_num, fps_den; diff --git a/gst-libs/gst/codecparsers/gsth264parser.c b/gst-libs/gst/codecparsers/gsth264parser.c index 69da6e5869..be07acfc0c 100644 --- a/gst-libs/gst/codecparsers/gsth264parser.c +++ b/gst-libs/gst/codecparsers/gsth264parser.c @@ -1532,7 +1532,7 @@ gst_h264_parser_parse_nal (GstH264NalParser * nalparser, GstH264NalUnit * nalu) switch (nalu->type) { case GST_H264_NAL_SPS: - return gst_h264_parser_parse_sps (nalparser, nalu, &sps, FALSE); + return gst_h264_parser_parse_sps (nalparser, nalu, &sps); break; case GST_H264_NAL_PPS: return gst_h264_parser_parse_pps (nalparser, nalu, &pps); @@ -1546,7 +1546,6 @@ gst_h264_parser_parse_nal (GstH264NalParser * nalparser, GstH264NalUnit * nalu) * @nalparser: a #GstH264NalParser * @nalu: The #GST_H264_NAL_SPS #GstH264NalUnit to parse * @sps: The #GstH264SPS to fill. - * @parse_vui_params: Whether to parse the vui_params or not * * Parses @nalu containing a Sequence Parameter Set, and fills @sps. * @@ -1554,9 +1553,9 @@ gst_h264_parser_parse_nal (GstH264NalParser * nalparser, GstH264NalUnit * nalu) */ GstH264ParserResult gst_h264_parser_parse_sps (GstH264NalParser * nalparser, GstH264NalUnit * nalu, - GstH264SPS * sps, gboolean parse_vui_params) + GstH264SPS * sps) { - GstH264ParserResult res = gst_h264_parse_sps (nalu, sps, parse_vui_params); + GstH264ParserResult res = gst_h264_parse_sps (nalu, sps); if (res == GST_H264_PARSER_OK) { GST_DEBUG ("adding sequence parameter set with id: %d to array", sps->id); @@ -1570,8 +1569,7 @@ gst_h264_parser_parse_sps (GstH264NalParser * nalparser, GstH264NalUnit * nalu, /* Parse seq_parameter_set_data() */ static gboolean -gst_h264_parse_sps_data (NalReader * nr, GstH264SPS * sps, - gboolean parse_vui_params) +gst_h264_parse_sps_data (NalReader * nr, GstH264SPS * sps) { gint width, height; guint subwc[] = { 1, 2, 2, 1 }; @@ -1666,10 +1664,9 @@ gst_h264_parse_sps_data (NalReader * nr, GstH264SPS * sps, } READ_UINT8 (nr, sps->vui_parameters_present_flag, 1); - if (sps->vui_parameters_present_flag && parse_vui_params) { + if (sps->vui_parameters_present_flag) if (!gst_h264_parse_vui_parameters (sps, nr)) goto error; - } /* calculate ChromaArrayType */ if (!sps->separate_colour_plane_flag) @@ -1719,8 +1716,7 @@ error: /* Parse subset_seq_parameter_set() data for MVC */ static gboolean -gst_h264_parse_sps_mvc_data (NalReader * nr, GstH264SPS * sps, - gboolean parse_vui_params) +gst_h264_parse_sps_mvc_data (NalReader * nr, GstH264SPS * sps) { GstH264SPSExtMVC *const mvc = &sps->extension.mvc; guint8 bit_equal_to_one; @@ -1820,15 +1816,13 @@ error: * gst_h264_parse_sps: * @nalu: The #GST_H264_NAL_SPS #GstH264NalUnit to parse * @sps: The #GstH264SPS to fill. - * @parse_vui_params: Whether to parse the vui_params or not * * Parses @data, and fills the @sps structure. * * Returns: a #GstH264ParserResult */ GstH264ParserResult -gst_h264_parse_sps (GstH264NalUnit * nalu, GstH264SPS * sps, - gboolean parse_vui_params) +gst_h264_parse_sps (GstH264NalUnit * nalu, GstH264SPS * sps) { NalReader nr; @@ -1837,7 +1831,7 @@ gst_h264_parse_sps (GstH264NalUnit * nalu, GstH264SPS * sps, nal_reader_init (&nr, nalu->data + nalu->offset + nalu->header_bytes, nalu->size - nalu->header_bytes); - if (!gst_h264_parse_sps_data (&nr, sps, parse_vui_params)) + if (!gst_h264_parse_sps_data (&nr, sps)) goto error; sps->valid = TRUE; @@ -1855,7 +1849,6 @@ error: * @nalparser: a #GstH264NalParser * @nalu: The #GST_H264_NAL_SUBSET_SPS #GstH264NalUnit to parse * @sps: The #GstH264SPS to fill. - * @parse_vui_params: Whether to parse the vui_params or not * * Parses @data, and fills in the @sps structure. * @@ -1874,11 +1867,11 @@ error: */ GstH264ParserResult gst_h264_parser_parse_subset_sps (GstH264NalParser * nalparser, - GstH264NalUnit * nalu, GstH264SPS * sps, gboolean parse_vui_params) + GstH264NalUnit * nalu, GstH264SPS * sps) { GstH264ParserResult res; - res = gst_h264_parse_subset_sps (nalu, sps, parse_vui_params); + res = gst_h264_parse_subset_sps (nalu, sps); if (res == GST_H264_PARSER_OK) { GST_DEBUG ("adding sequence parameter set with id: %d to array", sps->id); @@ -1895,7 +1888,6 @@ gst_h264_parser_parse_subset_sps (GstH264NalParser * nalparser, * gst_h264_parse_subset_sps: * @nalu: The #GST_H264_NAL_SUBSET_SPS #GstH264NalUnit to parse * @sps: The #GstH264SPS to fill. - * @parse_vui_params: Whether to parse the vui_params or not * * Parses @data, and fills in the @sps structure. * @@ -1913,8 +1905,7 @@ gst_h264_parser_parse_subset_sps (GstH264NalParser * nalparser, * Since: 1.6 */ GstH264ParserResult -gst_h264_parse_subset_sps (GstH264NalUnit * nalu, GstH264SPS * sps, - gboolean parse_vui_params) +gst_h264_parse_subset_sps (GstH264NalUnit * nalu, GstH264SPS * sps) { NalReader nr; @@ -1923,12 +1914,12 @@ gst_h264_parse_subset_sps (GstH264NalUnit * nalu, GstH264SPS * sps, nal_reader_init (&nr, nalu->data + nalu->offset + nalu->header_bytes, nalu->size - nalu->header_bytes); - if (!gst_h264_parse_sps_data (&nr, sps, TRUE)) + if (!gst_h264_parse_sps_data (&nr, sps)) goto error; if (sps->profile_idc == GST_H264_PROFILE_MULTIVIEW_HIGH || sps->profile_idc == GST_H264_PROFILE_STEREO_HIGH) { - if (!gst_h264_parse_sps_mvc_data (&nr, sps, parse_vui_params)) + if (!gst_h264_parse_sps_mvc_data (&nr, sps)) goto error; } diff --git a/gst-libs/gst/codecparsers/gsth264parser.h b/gst-libs/gst/codecparsers/gsth264parser.h index caa04021cc..b032f92999 100644 --- a/gst-libs/gst/codecparsers/gsth264parser.h +++ b/gst-libs/gst/codecparsers/gsth264parser.h @@ -1092,11 +1092,11 @@ GstH264ParserResult gst_h264_parser_parse_slice_hdr (GstH264NalParser *nalpars GST_CODEC_PARSERS_API GstH264ParserResult gst_h264_parser_parse_subset_sps (GstH264NalParser *nalparser, GstH264NalUnit *nalu, - GstH264SPS *sps, gboolean parse_vui_params); + GstH264SPS *sps); GST_CODEC_PARSERS_API GstH264ParserResult gst_h264_parser_parse_sps (GstH264NalParser *nalparser, GstH264NalUnit *nalu, - GstH264SPS *sps, gboolean parse_vui_params); + GstH264SPS *sps); GST_CODEC_PARSERS_API GstH264ParserResult gst_h264_parser_parse_pps (GstH264NalParser *nalparser, @@ -1111,11 +1111,11 @@ void gst_h264_nal_parser_free (GstH264NalParser *nalpars GST_CODEC_PARSERS_API GstH264ParserResult gst_h264_parse_subset_sps (GstH264NalUnit *nalu, - GstH264SPS *sps, gboolean parse_vui_params); + GstH264SPS *sps); GST_CODEC_PARSERS_API GstH264ParserResult gst_h264_parse_sps (GstH264NalUnit *nalu, - GstH264SPS *sps, gboolean parse_vui_params); + GstH264SPS *sps); GST_CODEC_PARSERS_API GstH264ParserResult gst_h264_parse_pps (GstH264NalParser *nalparser, diff --git a/gst/videoparsers/gsth264parse.c b/gst/videoparsers/gsth264parse.c index eed669e157..6de80810e6 100644 --- a/gst/videoparsers/gsth264parse.c +++ b/gst/videoparsers/gsth264parse.c @@ -837,13 +837,13 @@ gst_h264_parse_process_nal (GstH264Parse * h264parse, GstH264NalUnit * nalu) case GST_H264_NAL_SUBSET_SPS: if (!GST_H264_PARSE_STATE_VALID (h264parse, GST_H264_PARSE_STATE_GOT_SPS)) return FALSE; - pres = gst_h264_parser_parse_subset_sps (nalparser, nalu, &sps, TRUE); + pres = gst_h264_parser_parse_subset_sps (nalparser, nalu, &sps); goto process_sps; case GST_H264_NAL_SPS: /* reset state, everything else is obsolete */ h264parse->state = 0; - pres = gst_h264_parser_parse_sps (nalparser, nalu, &sps, TRUE); + pres = gst_h264_parser_parse_sps (nalparser, nalu, &sps); process_sps: /* arranged for a fallback sps.id, so use that one and only warn */