From 4299596d16870b52ae4efc1e49154ec028c1fc7e Mon Sep 17 00:00:00 2001 From: He Junyan Date: Fri, 16 Jul 2021 15:24:11 +0800 Subject: [PATCH] codecs: h265decoder: Fix a typo of NumPocTotalCurr when process ref pic list. We should use the NumPocTotalCurr value stored in decoder, which is a calculated valid value, rather than use the invalid value in the slice header. Most of the time, the NumPocTotalCurr is 0 and make the tmp_refs a very short length, and causes the decoder's wrong result. By the way, the NumPocTotalCurr is not the correct name specified in H265 spec, its name should be NumPicTotalCurr. We change it to the correct name. Part-of: --- gst-libs/gst/codecs/gsth265decoder.c | 8 ++++---- gst-libs/gst/codecs/gsth265decoder.h | 2 +- sys/nvcodec/gstnvh265dec.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gst-libs/gst/codecs/gsth265decoder.c b/gst-libs/gst/codecs/gsth265decoder.c index 081fe7e0af..16d4122a21 100644 --- a/gst-libs/gst/codecs/gsth265decoder.c +++ b/gst-libs/gst/codecs/gsth265decoder.c @@ -492,7 +492,7 @@ gst_h265_decoder_process_ref_pic_lists (GstH265Decoder * self, /* NumRpsCurrTempList0 */ num_tmp_refs = MAX (slice->header.num_ref_idx_l0_active_minus1 + 1, - slice->header.NumPocTotalCurr); + self->NumPicTotalCurr); while (tmp_refs->len < num_tmp_refs) { for (i = 0; i < self->NumPocStCurrBefore && tmp_refs->len < num_tmp_refs; @@ -542,7 +542,7 @@ gst_h265_decoder_process_ref_pic_lists (GstH265Decoder * self, /* NumRpsCurrTempList1 */ num_tmp_refs = MAX (slice->header.num_ref_idx_l1_active_minus1 + 1, - slice->header.NumPocTotalCurr); + self->NumPicTotalCurr); while (tmp_refs->len < num_tmp_refs) { for (i = 0; i < self->NumPocStCurrAfter && tmp_refs->len < num_tmp_refs; @@ -1405,7 +1405,7 @@ gst_h265_decoder_prepare_rps (GstH265Decoder * self, const GstH265Slice * slice, numtotalcurr++; } - self->NumPocTotalCurr = numtotalcurr; + self->NumPicTotalCurr = numtotalcurr; /* The variable DeltaPocMsbCycleLt[i] is derived as follows: (7-38) */ for (i = 0; i < num_lt_pics; i++) { @@ -1442,7 +1442,7 @@ gst_h265_decoder_prepare_rps (GstH265Decoder * self, const GstH265Slice * slice, GST_LOG_OBJECT (self, "NumPocStFoll: %d", self->NumPocStFoll); GST_LOG_OBJECT (self, "NumPocLtCurr: %d", self->NumPocLtCurr); GST_LOG_OBJECT (self, "NumPocLtFoll: %d", self->NumPocLtFoll); - GST_LOG_OBJECT (self, "NumPocTotalCurr: %d", self->NumPocTotalCurr); + GST_LOG_OBJECT (self, "NumPicTotalCurr: %d", self->NumPicTotalCurr); /* the derivation process for the RPS and the picture marking */ gst_h265_decoder_derive_and_mark_rps (self, picture, diff --git a/gst-libs/gst/codecs/gsth265decoder.h b/gst-libs/gst/codecs/gsth265decoder.h index 39e65ed120..a45629d0a2 100644 --- a/gst-libs/gst/codecs/gsth265decoder.h +++ b/gst-libs/gst/codecs/gsth265decoder.h @@ -64,7 +64,7 @@ struct _GstH265Decoder guint NumPocStFoll; guint NumPocLtCurr; guint NumPocLtFoll; - guint NumPocTotalCurr; + guint NumPicTotalCurr; /*< private >*/ GstH265DecoderPrivate *priv; diff --git a/sys/nvcodec/gstnvh265dec.c b/sys/nvcodec/gstnvh265dec.c index 725b9ad0ca..6c9c43543b 100644 --- a/sys/nvcodec/gstnvh265dec.c +++ b/sys/nvcodec/gstnvh265dec.c @@ -740,7 +740,7 @@ gst_nv_h265_dec_start_picture (GstH265Decoder * decoder, slice_header->short_term_ref_pic_set_size; h265_params->NumDeltaPocsOfRefRpsIdx = slice_header->short_term_ref_pic_sets.NumDeltaPocsOfRefRpsIdx; - h265_params->NumPocTotalCurr = decoder->NumPocTotalCurr; + h265_params->NumPocTotalCurr = decoder->NumPicTotalCurr; h265_params->NumPocStCurrBefore = decoder->NumPocStCurrBefore; h265_params->NumPocStCurrAfter = decoder->NumPocStCurrAfter; h265_params->NumPocLtCurr = decoder->NumPocLtCurr;