v4l2codecs: h264: Properly set pic_num/frame_num

The V4L2 uAPI uses pic_num for both PicNum and ShortTermPicNum. It also
doe the same for both FrameNum and LongTermFrameIdx. This change does
not change the fluster score, but fixed a visual corruption noticed
with some third party streams.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1387>
This commit is contained in:
Nicolas Dufresne 2021-11-24 11:17:40 -05:00 committed by GStreamer Marge Bot
parent b5c07e11ca
commit 83933b7772

View file

@ -582,6 +582,7 @@ gst_v4l2_codec_h264_dec_fill_decoder_params (GstV4l2CodecH264Dec * self,
for (i = 0; i < refs->len; i++) { for (i = 0; i < refs->len; i++) {
GstH264Picture *ref_pic = g_array_index (refs, GstH264Picture *, i); GstH264Picture *ref_pic = g_array_index (refs, GstH264Picture *, i);
gint pic_num = ref_pic->pic_num; gint pic_num = ref_pic->pic_num;
gint frame_num = ref_pic->frame_num;
struct v4l2_h264_dpb_entry *entry; struct v4l2_h264_dpb_entry *entry;
/* Skip non-reference as they are not useful to decoding */ /* Skip non-reference as they are not useful to decoding */
@ -592,6 +593,13 @@ gst_v4l2_codec_h264_dec_fill_decoder_params (GstV4l2CodecH264Dec * self,
if (ref_pic->second_field) if (ref_pic->second_field)
continue; continue;
/* V4L2 uAPI uses pic_num for both PicNum and LongTermPicNum, and
* frame_num for both FrameNum and LongTermFrameIdx */
if (GST_H264_PICTURE_IS_LONG_TERM_REF (ref_pic)) {
pic_num = ref_pic->long_term_pic_num;
frame_num = ref_pic->long_term_frame_idx;
}
entry = &self->decode_params.dpb[entry_id++]; entry = &self->decode_params.dpb[entry_id++];
*entry = (struct v4l2_h264_dpb_entry) { *entry = (struct v4l2_h264_dpb_entry) {
/* /*
@ -599,7 +607,7 @@ gst_v4l2_codec_h264_dec_fill_decoder_params (GstV4l2CodecH264Dec * self,
* seconds and this TS is nanosecond. * seconds and this TS is nanosecond.
*/ */
.reference_ts = (guint64) ref_pic->system_frame_number * 1000, .reference_ts = (guint64) ref_pic->system_frame_number * 1000,
.frame_num = ref_pic->frame_num, .frame_num = frame_num,
.pic_num = pic_num, .pic_num = pic_num,
.flags = V4L2_H264_DPB_ENTRY_FLAG_VALID .flags = V4L2_H264_DPB_ENTRY_FLAG_VALID
| (GST_H264_PICTURE_IS_REF (ref_pic) ? V4L2_H264_DPB_ENTRY_FLAG_ACTIVE : 0) | (GST_H264_PICTURE_IS_REF (ref_pic) ? V4L2_H264_DPB_ENTRY_FLAG_ACTIVE : 0)