Message ID | 20220331193726.289559-14-nicolas.dufresne@collabora.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Hans Verkuil |
Headers |
Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from <linux-media-owner@vger.kernel.org>) id 1na0ca-00EjlD-ND; Thu, 31 Mar 2022 19:38:16 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240916AbiCaTkC (ORCPT <rfc822;mkrufky@linuxtv.org> + 1 other); Thu, 31 Mar 2022 15:40:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240910AbiCaTjx (ORCPT <rfc822;linux-media@vger.kernel.org>); Thu, 31 Mar 2022 15:39:53 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4E4C239324; Thu, 31 Mar 2022 12:37:55 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: nicolas) with ESMTPSA id A363D1F47259 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1648755474; bh=3kRlflMZKylSksBlTGyBHGjQWwONuPlHkkyiaE6iWjY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mBFH7UXO/BWTgn0mge7OZnNiQGKEOEaL6P/pQiX4Ig4krhPmp8vindah+nakwuOEm g+w5iw0mm/dh9cG9ldqAZkBPPHwfVAHf7eghaXlkbDB6P9WzjNNvhoYlIYATxTyi// yhDiFcfMo4iNJQxxm2trUN8PC3/l1iP/Xhw2Duv345c9/sMRSg2T34tFM0w7CgIEeF guIual9HLdo8qKc2EEpkdNbPxMhPeGJk6GPHvXfvEzkfI7+jhlVQ9fh2XOEh+wj11x W2OX0h/f8jGe+PUhf2bK2h490khW4JkfIbzcWNqsNXNdNRRiZw1EnafTLN76t5F6sv JFZMjSWr1QZwg== From: Nicolas Dufresne <nicolas.dufresne@collabora.com> To: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>, Mauro Carvalho Chehab <mchehab@kernel.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: kernel@collabora.com, Sebastian Fricke <sebastian.fricke@collabora.com>, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 13/23] media: rkvdec: h264: Fix dpb_valid implementation Date: Thu, 31 Mar 2022 15:37:15 -0400 Message-Id: <20220331193726.289559-14-nicolas.dufresne@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220331193726.289559-1-nicolas.dufresne@collabora.com> References: <20220331193726.289559-1-nicolas.dufresne@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-media.vger.kernel.org> X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -2.5 (--) X-LSpam-Report: No, score=-2.5 required=5.0 tests=BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no |
Series |
[v2,01/23] media: doc: Document dual use of H.264 pic_num/frame_num
|
|
Commit Message
Nicolas Dufresne
March 31, 2022, 7:37 p.m. UTC
The ref builder only provided references that are marked as valid in the dpb. Thus the current implementation of dpb_valid would always set the flag to 1. This is not representing missing frames (this is called 'non-existing' pictures in the spec). In some context, these non-existing pictures still need to occupy a slot in the reference list according to the spec. Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Reviewed-by: Sebastian Fricke <sebastian.fricke@collabora.com> --- drivers/staging/media/rkvdec/rkvdec-h264.c | 33 ++++++++++++++++------ 1 file changed, 24 insertions(+), 9 deletions(-)
Comments
On Thu, Mar 31, 2022 at 03:37:15PM -0400, Nicolas Dufresne wrote: > The ref builder only provided references that are marked as valid in the > dpb. Thus the current implementation of dpb_valid would always set the > flag to 1. This is not representing missing frames (this is called > 'non-existing' pictures in the spec). In some context, these non-existing > pictures still need to occupy a slot in the reference list according to > the spec. > Good catch! OOC, did you find this because it was failing a test vector? > Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> > Reviewed-by: Sebastian Fricke <sebastian.fricke@collabora.com> Fixes: cd33c830448ba ("media: rkvdec: Add the rkvdec driver") Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> Thanks, Ezequiel > --- > drivers/staging/media/rkvdec/rkvdec-h264.c | 33 ++++++++++++++++------ > 1 file changed, 24 insertions(+), 9 deletions(-) > > diff --git a/drivers/staging/media/rkvdec/rkvdec-h264.c b/drivers/staging/media/rkvdec/rkvdec-h264.c > index dff89732ddd0..bcde37d72244 100644 > --- a/drivers/staging/media/rkvdec/rkvdec-h264.c > +++ b/drivers/staging/media/rkvdec/rkvdec-h264.c > @@ -112,6 +112,7 @@ struct rkvdec_h264_run { > const struct v4l2_ctrl_h264_sps *sps; > const struct v4l2_ctrl_h264_pps *pps; > const struct v4l2_ctrl_h264_scaling_matrix *scaling_matrix; > + int ref_buf_idx[V4L2_H264_NUM_DPB_ENTRIES]; > }; > > struct rkvdec_h264_ctx { > @@ -725,6 +726,26 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx, > } > } > > +static void lookup_ref_buf_idx(struct rkvdec_ctx *ctx, > + struct rkvdec_h264_run *run) > +{ > + const struct v4l2_ctrl_h264_decode_params *dec_params = run->decode_params; > + u32 i; > + > + for (i = 0; i < ARRAY_SIZE(dec_params->dpb); i++) { > + struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; > + const struct v4l2_h264_dpb_entry *dpb = run->decode_params->dpb; > + struct vb2_queue *cap_q = &m2m_ctx->cap_q_ctx.q; > + int buf_idx = -1; > + > + if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE) > + buf_idx = vb2_find_timestamp(cap_q, > + dpb[i].reference_ts, 0); > + > + run->ref_buf_idx[i] = buf_idx; > + } > +} > + > static void assemble_hw_rps(struct rkvdec_ctx *ctx, > struct rkvdec_h264_run *run) > { > @@ -762,7 +783,7 @@ static void assemble_hw_rps(struct rkvdec_ctx *ctx, > > for (j = 0; j < RKVDEC_NUM_REFLIST; j++) { > for (i = 0; i < h264_ctx->reflists.num_valid; i++) { > - u8 dpb_valid = 0; > + bool dpb_valid = run->ref_buf_idx[i] >= 0; > u8 idx = 0; > > switch (j) { > @@ -779,8 +800,6 @@ static void assemble_hw_rps(struct rkvdec_ctx *ctx, > > if (idx >= ARRAY_SIZE(dec_params->dpb)) > continue; > - dpb_valid = !!(dpb[idx].flags & > - V4L2_H264_DPB_ENTRY_FLAG_ACTIVE); > > set_ps_field(hw_rps, DPB_INFO(i, j), > idx | dpb_valid << 4); > @@ -859,13 +878,8 @@ get_ref_buf(struct rkvdec_ctx *ctx, struct rkvdec_h264_run *run, > unsigned int dpb_idx) > { > struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; > - const struct v4l2_h264_dpb_entry *dpb = run->decode_params->dpb; > struct vb2_queue *cap_q = &m2m_ctx->cap_q_ctx.q; > - int buf_idx = -1; > - > - if (dpb[dpb_idx].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE) > - buf_idx = vb2_find_timestamp(cap_q, > - dpb[dpb_idx].reference_ts, 0); > + int buf_idx = run->ref_buf_idx[dpb_idx]; > > /* > * If a DPB entry is unused or invalid, address of current destination > @@ -1102,6 +1116,7 @@ static int rkvdec_h264_run(struct rkvdec_ctx *ctx) > > assemble_hw_scaling_list(ctx, &run); > assemble_hw_pps(ctx, &run); > + lookup_ref_buf_idx(ctx, &run); > assemble_hw_rps(ctx, &run); > config_registers(ctx, &run); > > -- > 2.34.1 >
Le samedi 02 avril 2022 à 08:16 -0300, Ezequiel Garcia a écrit : > On Thu, Mar 31, 2022 at 03:37:15PM -0400, Nicolas Dufresne wrote: > > The ref builder only provided references that are marked as valid in the > > dpb. Thus the current implementation of dpb_valid would always set the > > flag to 1. This is not representing missing frames (this is called > > 'non-existing' pictures in the spec). In some context, these non-existing > > pictures still need to occupy a slot in the reference list according to > > the spec. > > > > Good catch! OOC, did you find this because it was failing a test vector? The effect is complex, so I could not correlate to specific tests. Also, what I wanted to fix isn't covered by the ITU conformance, its mostly resiliance requirement. But this should remove some of the IOMMU fault on broken streams and make it less likely to use references that don't exists or aren't set what we expect. After this change, the driver was getting more stable, and results was also more reproducible (specially in parallel decode case, which I use to speed up testing). > > > Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> > > Reviewed-by: Sebastian Fricke <sebastian.fricke@collabora.com> > > Fixes: cd33c830448ba ("media: rkvdec: Add the rkvdec driver") > Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> Thanks for the review. > > Thanks, > Ezequiel > > > --- > > drivers/staging/media/rkvdec/rkvdec-h264.c | 33 ++++++++++++++++------ > > 1 file changed, 24 insertions(+), 9 deletions(-) > > > > diff --git a/drivers/staging/media/rkvdec/rkvdec-h264.c b/drivers/staging/media/rkvdec/rkvdec-h264.c > > index dff89732ddd0..bcde37d72244 100644 > > --- a/drivers/staging/media/rkvdec/rkvdec-h264.c > > +++ b/drivers/staging/media/rkvdec/rkvdec-h264.c > > @@ -112,6 +112,7 @@ struct rkvdec_h264_run { > > const struct v4l2_ctrl_h264_sps *sps; > > const struct v4l2_ctrl_h264_pps *pps; > > const struct v4l2_ctrl_h264_scaling_matrix *scaling_matrix; > > + int ref_buf_idx[V4L2_H264_NUM_DPB_ENTRIES]; > > }; > > > > struct rkvdec_h264_ctx { > > @@ -725,6 +726,26 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx, > > } > > } > > > > +static void lookup_ref_buf_idx(struct rkvdec_ctx *ctx, > > + struct rkvdec_h264_run *run) > > +{ > > + const struct v4l2_ctrl_h264_decode_params *dec_params = run->decode_params; > > + u32 i; > > + > > + for (i = 0; i < ARRAY_SIZE(dec_params->dpb); i++) { > > + struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; > > + const struct v4l2_h264_dpb_entry *dpb = run->decode_params->dpb; > > + struct vb2_queue *cap_q = &m2m_ctx->cap_q_ctx.q; > > + int buf_idx = -1; > > + > > + if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE) > > + buf_idx = vb2_find_timestamp(cap_q, > > + dpb[i].reference_ts, 0); > > + > > + run->ref_buf_idx[i] = buf_idx; > > + } > > +} > > + > > static void assemble_hw_rps(struct rkvdec_ctx *ctx, > > struct rkvdec_h264_run *run) > > { > > @@ -762,7 +783,7 @@ static void assemble_hw_rps(struct rkvdec_ctx *ctx, > > > > for (j = 0; j < RKVDEC_NUM_REFLIST; j++) { > > for (i = 0; i < h264_ctx->reflists.num_valid; i++) { > > - u8 dpb_valid = 0; > > + bool dpb_valid = run->ref_buf_idx[i] >= 0; > > u8 idx = 0; > > > > switch (j) { > > @@ -779,8 +800,6 @@ static void assemble_hw_rps(struct rkvdec_ctx *ctx, > > > > if (idx >= ARRAY_SIZE(dec_params->dpb)) > > continue; > > - dpb_valid = !!(dpb[idx].flags & > > - V4L2_H264_DPB_ENTRY_FLAG_ACTIVE); > > > > set_ps_field(hw_rps, DPB_INFO(i, j), > > idx | dpb_valid << 4); > > @@ -859,13 +878,8 @@ get_ref_buf(struct rkvdec_ctx *ctx, struct rkvdec_h264_run *run, > > unsigned int dpb_idx) > > { > > struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; > > - const struct v4l2_h264_dpb_entry *dpb = run->decode_params->dpb; > > struct vb2_queue *cap_q = &m2m_ctx->cap_q_ctx.q; > > - int buf_idx = -1; > > - > > - if (dpb[dpb_idx].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE) > > - buf_idx = vb2_find_timestamp(cap_q, > > - dpb[dpb_idx].reference_ts, 0); > > + int buf_idx = run->ref_buf_idx[dpb_idx]; > > > > /* > > * If a DPB entry is unused or invalid, address of current destination > > @@ -1102,6 +1116,7 @@ static int rkvdec_h264_run(struct rkvdec_ctx *ctx) > > > > assemble_hw_scaling_list(ctx, &run); > > assemble_hw_pps(ctx, &run); > > + lookup_ref_buf_idx(ctx, &run); > > assemble_hw_rps(ctx, &run); > > config_registers(ctx, &run); > > > > -- > > 2.34.1 > >
On Tue, Apr 5, 2022 at 12:11 PM Nicolas Dufresne <nicolas.dufresne@collabora.com> wrote: > > Le samedi 02 avril 2022 à 08:16 -0300, Ezequiel Garcia a écrit : > > On Thu, Mar 31, 2022 at 03:37:15PM -0400, Nicolas Dufresne wrote: > > > The ref builder only provided references that are marked as valid in the > > > dpb. Thus the current implementation of dpb_valid would always set the > > > flag to 1. This is not representing missing frames (this is called > > > 'non-existing' pictures in the spec). In some context, these non-existing > > > pictures still need to occupy a slot in the reference list according to > > > the spec. > > > > > > > Good catch! OOC, did you find this because it was failing a test vector? > > The effect is complex, so I could not correlate to specific tests. Also, what I > wanted to fix isn't covered by the ITU conformance, its mostly resiliance > requirement. But this should remove some of the IOMMU fault on broken streams > and make it less likely to use references that don't exists or aren't set what > we expect. After this change, the driver was getting more stable, and results > was also more reproducible (specially in parallel decode case, which I use to > speed up testing). > Thanks for the details. This sounds like something that could be added to the commit description itself. > > > > > Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> > > > Reviewed-by: Sebastian Fricke <sebastian.fricke@collabora.com> > > > > Fixes: cd33c830448ba ("media: rkvdec: Add the rkvdec driver") > > Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> > > Thanks for the review. > No problem :) > > > > Thanks, > > Ezequiel > > > > > --- > > > drivers/staging/media/rkvdec/rkvdec-h264.c | 33 ++++++++++++++++------ > > > 1 file changed, 24 insertions(+), 9 deletions(-) > > > > > > diff --git a/drivers/staging/media/rkvdec/rkvdec-h264.c b/drivers/staging/media/rkvdec/rkvdec-h264.c > > > index dff89732ddd0..bcde37d72244 100644 > > > --- a/drivers/staging/media/rkvdec/rkvdec-h264.c > > > +++ b/drivers/staging/media/rkvdec/rkvdec-h264.c > > > @@ -112,6 +112,7 @@ struct rkvdec_h264_run { > > > const struct v4l2_ctrl_h264_sps *sps; > > > const struct v4l2_ctrl_h264_pps *pps; > > > const struct v4l2_ctrl_h264_scaling_matrix *scaling_matrix; > > > + int ref_buf_idx[V4L2_H264_NUM_DPB_ENTRIES]; > > > }; > > > > > > struct rkvdec_h264_ctx { > > > @@ -725,6 +726,26 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx, > > > } > > > } > > > > > > +static void lookup_ref_buf_idx(struct rkvdec_ctx *ctx, > > > + struct rkvdec_h264_run *run) > > > +{ > > > + const struct v4l2_ctrl_h264_decode_params *dec_params = run->decode_params; > > > + u32 i; > > > + > > > + for (i = 0; i < ARRAY_SIZE(dec_params->dpb); i++) { > > > + struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; > > > + const struct v4l2_h264_dpb_entry *dpb = run->decode_params->dpb; > > > + struct vb2_queue *cap_q = &m2m_ctx->cap_q_ctx.q; > > > + int buf_idx = -1; > > > + > > > + if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE) > > > + buf_idx = vb2_find_timestamp(cap_q, > > > + dpb[i].reference_ts, 0); > > > + > > > + run->ref_buf_idx[i] = buf_idx; > > > + } > > > +} > > > + > > > static void assemble_hw_rps(struct rkvdec_ctx *ctx, > > > struct rkvdec_h264_run *run) > > > { > > > @@ -762,7 +783,7 @@ static void assemble_hw_rps(struct rkvdec_ctx *ctx, > > > > > > for (j = 0; j < RKVDEC_NUM_REFLIST; j++) { > > > for (i = 0; i < h264_ctx->reflists.num_valid; i++) { > > > - u8 dpb_valid = 0; > > > + bool dpb_valid = run->ref_buf_idx[i] >= 0; > > > u8 idx = 0; > > > > > > switch (j) { > > > @@ -779,8 +800,6 @@ static void assemble_hw_rps(struct rkvdec_ctx *ctx, > > > > > > if (idx >= ARRAY_SIZE(dec_params->dpb)) > > > continue; > > > - dpb_valid = !!(dpb[idx].flags & > > > - V4L2_H264_DPB_ENTRY_FLAG_ACTIVE); > > > > > > set_ps_field(hw_rps, DPB_INFO(i, j), > > > idx | dpb_valid << 4); > > > @@ -859,13 +878,8 @@ get_ref_buf(struct rkvdec_ctx *ctx, struct rkvdec_h264_run *run, > > > unsigned int dpb_idx) > > > { > > > struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; > > > - const struct v4l2_h264_dpb_entry *dpb = run->decode_params->dpb; > > > struct vb2_queue *cap_q = &m2m_ctx->cap_q_ctx.q; > > > - int buf_idx = -1; > > > - > > > - if (dpb[dpb_idx].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE) > > > - buf_idx = vb2_find_timestamp(cap_q, > > > - dpb[dpb_idx].reference_ts, 0); > > > + int buf_idx = run->ref_buf_idx[dpb_idx]; > > > > > > /* > > > * If a DPB entry is unused or invalid, address of current destination > > > @@ -1102,6 +1116,7 @@ static int rkvdec_h264_run(struct rkvdec_ctx *ctx) > > > > > > assemble_hw_scaling_list(ctx, &run); > > > assemble_hw_pps(ctx, &run); > > > + lookup_ref_buf_idx(ctx, &run); > > > assemble_hw_rps(ctx, &run); > > > config_registers(ctx, &run); > > > > > > -- > > > 2.34.1 > > > >
diff --git a/drivers/staging/media/rkvdec/rkvdec-h264.c b/drivers/staging/media/rkvdec/rkvdec-h264.c index dff89732ddd0..bcde37d72244 100644 --- a/drivers/staging/media/rkvdec/rkvdec-h264.c +++ b/drivers/staging/media/rkvdec/rkvdec-h264.c @@ -112,6 +112,7 @@ struct rkvdec_h264_run { const struct v4l2_ctrl_h264_sps *sps; const struct v4l2_ctrl_h264_pps *pps; const struct v4l2_ctrl_h264_scaling_matrix *scaling_matrix; + int ref_buf_idx[V4L2_H264_NUM_DPB_ENTRIES]; }; struct rkvdec_h264_ctx { @@ -725,6 +726,26 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx, } } +static void lookup_ref_buf_idx(struct rkvdec_ctx *ctx, + struct rkvdec_h264_run *run) +{ + const struct v4l2_ctrl_h264_decode_params *dec_params = run->decode_params; + u32 i; + + for (i = 0; i < ARRAY_SIZE(dec_params->dpb); i++) { + struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; + const struct v4l2_h264_dpb_entry *dpb = run->decode_params->dpb; + struct vb2_queue *cap_q = &m2m_ctx->cap_q_ctx.q; + int buf_idx = -1; + + if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE) + buf_idx = vb2_find_timestamp(cap_q, + dpb[i].reference_ts, 0); + + run->ref_buf_idx[i] = buf_idx; + } +} + static void assemble_hw_rps(struct rkvdec_ctx *ctx, struct rkvdec_h264_run *run) { @@ -762,7 +783,7 @@ static void assemble_hw_rps(struct rkvdec_ctx *ctx, for (j = 0; j < RKVDEC_NUM_REFLIST; j++) { for (i = 0; i < h264_ctx->reflists.num_valid; i++) { - u8 dpb_valid = 0; + bool dpb_valid = run->ref_buf_idx[i] >= 0; u8 idx = 0; switch (j) { @@ -779,8 +800,6 @@ static void assemble_hw_rps(struct rkvdec_ctx *ctx, if (idx >= ARRAY_SIZE(dec_params->dpb)) continue; - dpb_valid = !!(dpb[idx].flags & - V4L2_H264_DPB_ENTRY_FLAG_ACTIVE); set_ps_field(hw_rps, DPB_INFO(i, j), idx | dpb_valid << 4); @@ -859,13 +878,8 @@ get_ref_buf(struct rkvdec_ctx *ctx, struct rkvdec_h264_run *run, unsigned int dpb_idx) { struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; - const struct v4l2_h264_dpb_entry *dpb = run->decode_params->dpb; struct vb2_queue *cap_q = &m2m_ctx->cap_q_ctx.q; - int buf_idx = -1; - - if (dpb[dpb_idx].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE) - buf_idx = vb2_find_timestamp(cap_q, - dpb[dpb_idx].reference_ts, 0); + int buf_idx = run->ref_buf_idx[dpb_idx]; /* * If a DPB entry is unused or invalid, address of current destination @@ -1102,6 +1116,7 @@ static int rkvdec_h264_run(struct rkvdec_ctx *ctx) assemble_hw_scaling_list(ctx, &run); assemble_hw_pps(ctx, &run); + lookup_ref_buf_idx(ctx, &run); assemble_hw_rps(ctx, &run); config_registers(ctx, &run);