From be223ad316bbd044dd9e3ea51e33b53edcd00b2b Mon Sep 17 00:00:00 2001 From: He Junyan Date: Tue, 20 Jul 2021 23:36:38 +0800 Subject: codecs: h264dec: Add a flag to record whether picture is reference. The picture->ref field will change from time to time according to decoder's state and reference sliding window. We need another flag to record whether the picture is a reference picture when it is created, and this can help the bumping check. Part-of: --- gst-libs/gst/codecs/gsth264decoder.c | 1 + gst-libs/gst/codecs/gsth264picture.c | 10 ++++++++-- gst-libs/gst/codecs/gsth264picture.h | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) (limited to 'gst-libs') diff --git a/gst-libs/gst/codecs/gsth264decoder.c b/gst-libs/gst/codecs/gsth264decoder.c index 189ed2620..da70095a6 100644 --- a/gst-libs/gst/codecs/gsth264decoder.c +++ b/gst-libs/gst/codecs/gsth264decoder.c @@ -2199,6 +2199,7 @@ gst_h264_decoder_init_gap_picture (GstH264Decoder * self, picture->frame_num = picture->pic_num = frame_num; picture->dec_ref_pic_marking.adaptive_ref_pic_marking_mode_flag = FALSE; picture->ref = GST_H264_PICTURE_REF_SHORT_TERM; + picture->ref_pic = TRUE; picture->dec_ref_pic_marking.long_term_reference_flag = FALSE; picture->field = GST_H264_PICTURE_FIELD_FRAME; diff --git a/gst-libs/gst/codecs/gsth264picture.c b/gst-libs/gst/codecs/gsth264picture.c index e7bf8c687..417986c62 100644 --- a/gst-libs/gst/codecs/gsth264picture.c +++ b/gst-libs/gst/codecs/gsth264picture.c @@ -707,7 +707,7 @@ gst_h264_dpb_needs_bump (GstH264Dpb * dpb, GstH264Picture * to_insert, return FALSE; } - if (to_insert->ref != GST_H264_PICTURE_REF_NONE) { + if (to_insert->ref_pic) { GST_TRACE ("No empty frame buffer for ref frame, need bumping."); return TRUE; } @@ -1055,7 +1055,13 @@ gst_h264_picture_set_reference (GstH264Picture * picture, g_return_if_fail (picture != NULL); picture->ref = reference; + if (reference > GST_H264_PICTURE_REF_NONE) + picture->ref_pic = TRUE; - if (other_field && picture->other_field) + if (other_field && picture->other_field) { picture->other_field->ref = reference; + + if (reference > GST_H264_PICTURE_REF_NONE) + picture->other_field->ref_pic = TRUE; + } } diff --git a/gst-libs/gst/codecs/gsth264picture.h b/gst-libs/gst/codecs/gsth264picture.h index 4e9a7a0b8..962ed5e66 100644 --- a/gst-libs/gst/codecs/gsth264picture.h +++ b/gst-libs/gst/codecs/gsth264picture.h @@ -143,6 +143,8 @@ struct _GstH264Picture gboolean idr; gint idr_pic_id; GstH264PictureReference ref; + /* Whether a reference picture. */ + gboolean ref_pic; gboolean needed_for_output; gboolean mem_mgmt_5; -- cgit v1.2.1