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: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2373>
This commit is contained in:
He Junyan 2021-07-20 23:36:38 +08:00 committed by GStreamer Marge Bot
parent b4e3887449
commit be223ad316
3 changed files with 11 additions and 2 deletions

View file

@ -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;

View file

@ -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;
}
}

View file

@ -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;