From: He Junyan Date: Fri, 9 Oct 2020 08:13:28 +0000 (+0800) Subject: codecparsers: av1: Add an API to reset the annex_b state only. X-Git-Tag: 1.19.3~507^2~1037 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c4aaeb0509f98799df2393d2d084279dee8a0522;p=platform%2Fupstream%2Fgstreamer.git codecparsers: av1: Add an API to reset the annex_b state only. In practice, we encounter streams that have one or more temporal units error. When that kind of error temporal units is in annex b format, the whole temporal unit should be discarded. But the temporal units before it are correct and can be used. More important, because of the error temporal unit, the parser is in a wrong state and all later temporal unit are also parsed uncorrectly. We need to add this API to reset the annex_b state only when we meet some temporal unit error. Part-of: --- diff --git a/gst-libs/gst/codecparsers/gstav1parser.c b/gst-libs/gst/codecparsers/gstav1parser.c index e1658df..6e09551 100644 --- a/gst-libs/gst/codecparsers/gstav1parser.c +++ b/gst-libs/gst/codecparsers/gstav1parser.c @@ -568,29 +568,44 @@ gst_av1_parser_reset (GstAV1Parser * parser, gboolean annex_b) { g_return_if_fail (parser != NULL); - if (parser->annex_b) { - g_assert (parser->temporal_unit_consumed <= parser->temporal_unit_size); - if (parser->temporal_unit_consumed < parser->temporal_unit_size) - GST_DEBUG ("temporal_unit_consumed: %d, temporal_unit_size:%d, " - "discard the left %d bytes for a temporal_unit.", - parser->temporal_unit_consumed, parser->temporal_unit_size, - parser->temporal_unit_size - parser->temporal_unit_consumed); - - g_assert (parser->frame_unit_consumed <= parser->frame_unit_size); - if (parser->frame_unit_consumed < parser->frame_unit_size) - GST_DEBUG (" frame_unit_consumed %d, frame_unit_size: %d " - "discard the left %d bytes for a frame_unit.", - parser->frame_unit_consumed, parser->frame_unit_size, - parser->frame_unit_size - parser->frame_unit_consumed); - } + parser->annex_b = annex_b; + if (parser->annex_b) + gst_av1_parser_reset_annex_b (parser); + + gst_av1_parse_reset_state (parser, TRUE); +} + +/** + * gst_av1_parser_reset_annex_b: + * @parser: the #GstAV1Parser + * + * Only reset the current #GstAV1Parser's annex b context. + * The other part of the state is kept. + * + * Since: 1.20 + */ +void +gst_av1_parser_reset_annex_b (GstAV1Parser * parser) +{ + g_return_if_fail (parser != NULL); + g_return_if_fail (parser->annex_b); + + if (parser->temporal_unit_consumed < parser->temporal_unit_size) + GST_DEBUG ("temporal_unit_consumed: %d, temporal_unit_size:%d, " + "discard the left %d bytes for a temporal_unit.", + parser->temporal_unit_consumed, parser->temporal_unit_size, + parser->temporal_unit_size - parser->temporal_unit_consumed); + + if (parser->frame_unit_consumed < parser->frame_unit_size) + GST_DEBUG (" frame_unit_consumed %d, frame_unit_size: %d " + "discard the left %d bytes for a frame_unit.", + parser->frame_unit_consumed, parser->frame_unit_size, + parser->frame_unit_size - parser->frame_unit_consumed); parser->temporal_unit_consumed = 0; parser->temporal_unit_size = 0; parser->frame_unit_consumed = 0; parser->frame_unit_size = 0; - parser->annex_b = annex_b; - - gst_av1_parse_reset_state (parser, TRUE); } /* 5.3.2 */ diff --git a/gst-libs/gst/codecparsers/gstav1parser.h b/gst-libs/gst/codecparsers/gstav1parser.h index f8a2d88..afcce6f 100644 --- a/gst-libs/gst/codecparsers/gstav1parser.h +++ b/gst-libs/gst/codecparsers/gstav1parser.h @@ -1777,6 +1777,10 @@ void gst_av1_parser_reset (GstAV1Parser * parser, gboolean annex_b); GST_CODEC_PARSERS_API +void +gst_av1_parser_reset_annex_b (GstAV1Parser * parser); + +GST_CODEC_PARSERS_API GstAV1ParserResult gst_av1_parser_identify_one_obu (GstAV1Parser * parser, const guint8 * data, guint32 size, GstAV1OBU * obu, guint32 * consumed);