public inbox for linux-rockchip@lists.infradead.org
 help / color / mirror / Atom feed
From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
To: Sebastian Fricke <sebastian.fricke@collabora.com>
Cc: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	kernel@collabora.com, Jonas Karlman <jonas@kwiboo.se>,
	 linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org,
	 linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 22/24] media: hantro: h264: Make dpb entry management more robust
Date: Wed, 30 Mar 2022 11:15:58 -0400	[thread overview]
Message-ID: <4740735d92c0dac3708aa922b3d73db7a61fbdda.camel@collabora.com> (raw)
In-Reply-To: <20220330075913.wfl3prsyw5fvsv4t@basti-XPS-13-9310>

Le mercredi 30 mars 2022 à 09:59 +0200, Sebastian Fricke a écrit :
> Hey Nicolas,
> 
> On 28.03.2022 15:59, Nicolas Dufresne wrote:
> > From: Jonas Karlman <jonas@kwiboo.se>
> > 
> > The driver maintains stable slot location for reference pictures. This
> 
> s/slot location/slot locations/
> 
> > change makes the code more robust by using the reference_ts as key and
> > by marking all entries invalid right from the start.
> > 
> > Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
> > Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> > ---
> > drivers/staging/media/hantro/hantro_h264.c | 10 ++++------
> > 1 file changed, 4 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/staging/media/hantro/hantro_h264.c b/drivers/staging/media/hantro/hantro_h264.c
> > index 228629fb3cdf..7377fc26f780 100644
> > --- a/drivers/staging/media/hantro/hantro_h264.c
> > +++ b/drivers/staging/media/hantro/hantro_h264.c
> > @@ -258,8 +258,7 @@ static void prepare_table(struct hantro_ctx *ctx)
> > static bool dpb_entry_match(const struct v4l2_h264_dpb_entry *a,
> > 			    const struct v4l2_h264_dpb_entry *b)
> > {
> > -	return a->top_field_order_cnt == b->top_field_order_cnt &&
> > -	       a->bottom_field_order_cnt == b->bottom_field_order_cnt;
> > +	return a->reference_ts == b->reference_ts;
> > }
> > 
> > static void update_dpb(struct hantro_ctx *ctx)
> > @@ -273,13 +272,13 @@ static void update_dpb(struct hantro_ctx *ctx)
> > 
> > 	/* Disable all entries by default. */
> > 	for (i = 0; i < ARRAY_SIZE(ctx->h264_dec.dpb); i++)
> > -		ctx->h264_dec.dpb[i].flags &= ~V4L2_H264_DPB_ENTRY_FLAG_ACTIVE;
> > +		ctx->h264_dec.dpb[i].flags = 0;
> 
> Ehm ... we just remove all flags? Can't this have any unwanted side
> effects like removing a flag that we actually wanted to keep?
> (Like long term or the field flags?)

This is a local copy of the dpb, the DPB is fully passed for every decode. So
these flags will be fully restored lower when we copy the found entry. In fact,
holding a state here would not represent well the userland intention and can
have negative side effect on the decoding. Flags are not immutable between
decode and can change. This simplify the code, and make things less error prone.
This part of the code is already a bit complex, no need for an extra layer.

> If we just want to set the DPB entry inactive, then removing the ACTIVE
> flag seems like the correct approach to me.
> If we want to get rid of the VALID flag as well, then we could just do:
> 		ctx->h264_dec.dpb[i].flags &=
>        ~(V4L2_H264_DPB_ENTRY_FLAG_ACTIVE | V4L2_H264_DPB_ENTRY_FLAG_VALID);
> 
> In case we really want to reset all flags, I'd say adjust the comment
> above it:
> ```
> - 	/* Disable all entries by default. */
> + 	/* Reset the flags for all entries by default. */
> ```

This reads the same to me, but I can do that yes. understand that VALID means
the reference exist and the TS should point to some existing past reference
(unless there was some decode error, which the userland may not be aware yet as
this is asynchronous). While ACTIVE means that it is used as a reference. FFMPEG
is known not to filter inactive references. ACTIVE is just a flag without bunch
of other flags that can change for every decode. So none of this make sense
between 2 decodes.

> 
> Greetings,
> Sebastian
> 
> > 
> > 	/* Try to match new DPB entries with existing ones by their POCs. */
> > 	for (i = 0; i < ARRAY_SIZE(dec_param->dpb); i++) {
> > 		const struct v4l2_h264_dpb_entry *ndpb = &dec_param->dpb[i];
> > 
> > -		if (!(ndpb->flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE))
> > +		if (!(ndpb->flags & V4L2_H264_DPB_ENTRY_FLAG_VALID))
> > 			continue;
> > 
> > 		/*
> > @@ -290,8 +289,7 @@ static void update_dpb(struct hantro_ctx *ctx)
> > 			struct v4l2_h264_dpb_entry *cdpb;
> > 
> > 			cdpb = &ctx->h264_dec.dpb[j];
> > -			if (cdpb->flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE ||
> > -			    !dpb_entry_match(cdpb, ndpb))
> > +			if (!dpb_entry_match(cdpb, ndpb))
> > 				continue;
> > 
> > 			*cdpb = *ndpb;
> > -- 
> > 2.34.1
> > 


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

  reply	other threads:[~2022-03-30 15:22 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220328195936.82552-1-nicolas.dufresne@collabora.com>
2022-03-28 19:59 ` [PATCH v1 01/24] media: h264: Increase reference lists size to 32 Nicolas Dufresne
2022-03-29  8:25   ` Sebastian Fricke
2022-03-28 19:59 ` [PATCH v1 12/24] media: rkvdec: Stop overclocking the decoder Nicolas Dufresne
2022-03-29 15:15   ` Sebastian Fricke
2022-03-28 19:59 ` [PATCH v1 13/24] media: rkvdec: h264: Fix reference frame_num wrap for second field Nicolas Dufresne
2022-03-29 15:17   ` Sebastian Fricke
2022-03-28 19:59 ` [PATCH v1 14/24] media: rkvdec: h264: Fix dpb_valid implementation Nicolas Dufresne
2022-03-29 15:27   ` Sebastian Fricke
2022-03-28 19:59 ` [PATCH v1 15/24] media: rkvdec: Enable capture buffer holding for H264 Nicolas Dufresne
2022-03-29 15:34   ` Sebastian Fricke
2022-03-28 19:59 ` [PATCH v1 16/24] media: rkvdec: Ensure decoded resolution fit coded resolution Nicolas Dufresne
2022-03-29 15:39   ` Sebastian Fricke
2022-03-30  9:06     ` Sebastian Fricke
2022-03-28 19:59 ` [PATCH v1 17/24] media: rkvdec: h264: Validate and use pic width and height in mbs Nicolas Dufresne
2022-03-30  6:48   ` Sebastian Fricke
2022-03-28 19:59 ` [PATCH v1 18/24] media: rkvdec: h264: Fix bit depth wrap in pps packet Nicolas Dufresne
2022-03-30  6:59   ` Sebastian Fricke
2022-03-28 19:59 ` [PATCH v1 19/24] media: rkvdec-h264: Add field decoding support Nicolas Dufresne
2022-03-29  8:13   ` Dan Carpenter
2022-03-29 20:54     ` Nicolas Dufresne
2022-03-30  5:15       ` Dan Carpenter
2022-03-30 13:39         ` Nicolas Dufresne
2022-03-30 15:16           ` Dan Carpenter
2022-03-31 13:40             ` Nicolas Dufresne
2022-03-30  7:10   ` Sebastian Fricke
2022-03-28 19:59 ` [PATCH v1 20/24] media: hantro: Enable HOLD_CAPTURE_BUF for H.264 Nicolas Dufresne
2022-03-30  7:36   ` Sebastian Fricke
2022-03-31 18:25     ` Nicolas Dufresne
2022-03-28 19:59 ` [PATCH v1 21/24] media: hantro: Stop using H.264 parameter pic_num Nicolas Dufresne
2022-03-30  7:42   ` Sebastian Fricke
2022-03-30 15:08     ` Nicolas Dufresne
2022-03-28 19:59 ` [PATCH v1 22/24] media: hantro: h264: Make dpb entry management more robust Nicolas Dufresne
2022-03-30  7:59   ` Sebastian Fricke
2022-03-30 15:15     ` Nicolas Dufresne [this message]
2022-03-30 23:43       ` Ezequiel Garcia
2022-03-31  6:54         ` Sebastian Fricke
2022-03-28 19:59 ` [PATCH v1 23/24] media: hantro: Add H.264 field decoding support Nicolas Dufresne
2022-03-30  9:03   ` Sebastian Fricke
2022-03-30 15:25     ` Nicolas Dufresne
2022-03-28 19:59 ` [PATCH v1 24/24] media: rkvdec-h264: Don't hardcode SPS/PPS parameters Nicolas Dufresne
2022-03-29  7:22   ` Sebastian Fricke
2022-03-30 15:27     ` Nicolas Dufresne

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4740735d92c0dac3708aa922b3d73db7a61fbdda.camel@collabora.com \
    --to=nicolas.dufresne@collabora.com \
    --cc=ezequiel@vanguardiasur.com.ar \
    --cc=gregkh@linuxfoundation.org \
    --cc=jonas@kwiboo.se \
    --cc=kernel@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=mchehab@kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=sebastian.fricke@collabora.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox