From 573d3f5ba5725b59aeb245eed4a673aa39504d54 Mon Sep 17 00:00:00 2001 From: He Junyan Date: Tue, 20 Jul 2021 23:49:12 +0800 Subject: codecs: h264dec: Add help function of dpb_set_max_num_reorder_frames. The max_num_reorder_frames can be useful for bump check. We store it in the DPB and no need for the decoder now. Part-of: --- gst-libs/gst/codecs/gsth264decoder.c | 22 ++++++++++++---------- gst-libs/gst/codecs/gsth264picture.c | 19 +++++++++++++++++++ gst-libs/gst/codecs/gsth264picture.h | 4 ++++ 3 files changed, 35 insertions(+), 10 deletions(-) (limited to 'gst-libs/gst') diff --git a/gst-libs/gst/codecs/gsth264decoder.c b/gst-libs/gst/codecs/gsth264decoder.c index da70095a6..144249854 100644 --- a/gst-libs/gst/codecs/gsth264decoder.c +++ b/gst-libs/gst/codecs/gsth264decoder.c @@ -109,7 +109,6 @@ struct _GstH264DecoderPrivate gint max_frame_num; gint max_pic_num; gint max_long_term_frame_idx; - gsize max_num_reorder_frames; gint prev_frame_num; gint prev_ref_frame_num; @@ -1915,21 +1914,23 @@ gst_h264_decoder_update_max_num_reorder_frames (GstH264Decoder * self, GstH264SPS * sps) { GstH264DecoderPrivate *priv = self->priv; + gsize max_num_reorder_frames = 0; if (sps->vui_parameters_present_flag && sps->vui_parameters.bitstream_restriction_flag) { - priv->max_num_reorder_frames = sps->vui_parameters.num_reorder_frames; - if (priv->max_num_reorder_frames > - gst_h264_dpb_get_max_num_frames (priv->dpb)) { + max_num_reorder_frames = sps->vui_parameters.num_reorder_frames; + if (max_num_reorder_frames > gst_h264_dpb_get_max_num_frames (priv->dpb)) { GST_WARNING ("max_num_reorder_frames present, but larger than MaxDpbFrames (%d > %d)", - (gint) priv->max_num_reorder_frames, + (gint) max_num_reorder_frames, gst_h264_dpb_get_max_num_frames (priv->dpb)); - priv->max_num_reorder_frames = 0; + max_num_reorder_frames = 0; return FALSE; } + gst_h264_dpb_set_max_num_reorder_frames (priv->dpb, max_num_reorder_frames); + return TRUE; } @@ -1943,17 +1944,18 @@ gst_h264_decoder_update_max_num_reorder_frames (GstH264Decoder * self, case 110: case 122: case 244: - priv->max_num_reorder_frames = 0; + max_num_reorder_frames = 0; break; default: - priv->max_num_reorder_frames = - gst_h264_dpb_get_max_num_frames (priv->dpb); + max_num_reorder_frames = gst_h264_dpb_get_max_num_frames (priv->dpb); break; } } else { - priv->max_num_reorder_frames = gst_h264_dpb_get_max_num_frames (priv->dpb); + max_num_reorder_frames = gst_h264_dpb_get_max_num_frames (priv->dpb); } + gst_h264_dpb_set_max_num_reorder_frames (priv->dpb, max_num_reorder_frames); + return TRUE; } diff --git a/gst-libs/gst/codecs/gsth264picture.c b/gst-libs/gst/codecs/gsth264picture.c index 417986c62..a824b785a 100644 --- a/gst-libs/gst/codecs/gsth264picture.c +++ b/gst-libs/gst/codecs/gsth264picture.c @@ -108,6 +108,7 @@ struct _GstH264Dpb GArray *pic_list; gint max_num_frames; gint num_output_needed; + guint32 max_num_reorder_frames; gint32 last_output_poc; gboolean interlaced; @@ -239,6 +240,24 @@ gst_h264_dpb_clear (GstH264Dpb * dpb) gst_h264_dpb_init (dpb); } +/** + * gst_h264_dpb_set_max_num_reorder_frames: + * @dpb: a #GstH264Dpb + * @max_num_reorder_frames: the max number of reorder frames, which + * should not exceed the max size of DPB. + * + * Since: 1.20 + */ +void +gst_h264_dpb_set_max_num_reorder_frames (GstH264Dpb * dpb, + guint32 max_num_reorder_frames) +{ + g_return_if_fail (dpb != NULL); + g_return_if_fail (max_num_reorder_frames <= dpb->max_num_frames); + + dpb->max_num_reorder_frames = max_num_reorder_frames; +} + /** * gst_h264_dpb_add: * @dpb: a #GstH264Dpb diff --git a/gst-libs/gst/codecs/gsth264picture.h b/gst-libs/gst/codecs/gsth264picture.h index 962ed5e66..3ac505c03 100644 --- a/gst-libs/gst/codecs/gsth264picture.h +++ b/gst-libs/gst/codecs/gsth264picture.h @@ -229,6 +229,10 @@ void gst_h264_dpb_set_interlaced (GstH264Dpb * dpb, GST_CODECS_API gboolean gst_h264_dpb_get_interlaced (GstH264Dpb * dpb); +GST_CODECS_API +void gst_h264_dpb_set_max_num_reorder_frames (GstH264Dpb * dpb, + guint32 max_num_reorder_frames); + GST_CODECS_API void gst_h264_dpb_free (GstH264Dpb * dpb); -- cgit v1.2.1