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, linux-media@vger.kernel.org,
	 linux-rockchip@lists.infradead.org,
	linux-staging@lists.linux.dev,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 20/24] media: hantro: Enable HOLD_CAPTURE_BUF for H.264
Date: Thu, 31 Mar 2022 14:25:37 -0400	[thread overview]
Message-ID: <8a59875f62ac1a60aec91c9170c1471234e1b4db.camel@collabora.com> (raw)
In-Reply-To: <20220330073600.crbi5wqlp4rimx2a@basti-XPS-13-9310>

Le mercredi 30 mars 2022 à 09:36 +0200, Sebastian Fricke a écrit :
> Hey Nicolas,
> 
> On 28.03.2022 15:59, Nicolas Dufresne wrote:
> > This is needed to optimizing field decoding. Each field will be
> 
> s/is needed to optimizing/is needed to optimize/
> 
> > decoded in the same capture buffer, so to make use of the queues
> 
> s/in the same/into the same/
> 
> > we need to be able to ask the driver to keep the capture buffer.
> 
> How about:
> """
> During field decoding each field will be decoded into the same capture
> buffer. Optimise this mode by asking the driver to hold the buffer until
> all fields are written into it.
> """
> 
> > 
> > Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> Reviewed-by: Sebastian Fricke <sebastian.fricke@collabora.com>

Perhaps avoid giving a reviewed by if you are to comment around modifying the
code ? I will though keep the code as is, I believe there is more good then bad
around the form.

> 
> > ---
> > drivers/staging/media/hantro/hantro_v4l2.c | 25 ++++++++++++++++++++++
> > 1 file changed, 25 insertions(+)
> > 
> > diff --git a/drivers/staging/media/hantro/hantro_v4l2.c b/drivers/staging/media/hantro/hantro_v4l2.c
> > index 67148ba346f5..50d636678ff3 100644
> > --- a/drivers/staging/media/hantro/hantro_v4l2.c
> > +++ b/drivers/staging/media/hantro/hantro_v4l2.c
> > @@ -409,6 +409,30 @@ hantro_update_requires_request(struct hantro_ctx *ctx, u32 fourcc)
> > 	}
> > }
> > 
> > +static void
> > +hantro_update_requires_hold_capture_buf(struct hantro_ctx *ctx, u32 fourcc)
> > +{
> > +	struct vb2_queue *vq;
> > +
> > +	vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx,
> > +			     V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE);
> > +
> > +	switch (fourcc) {
> > +	case V4L2_PIX_FMT_JPEG:
> > +	case V4L2_PIX_FMT_MPEG2_SLICE:
> > +	case V4L2_PIX_FMT_VP8_FRAME:
> > +	case V4L2_PIX_FMT_HEVC_SLICE:
> > +	case V4L2_PIX_FMT_VP9_FRAME:
> > +		vq->subsystem_flags &= ~(VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF);
> > +		break;
> 
> Out of curiosity, why would it be bad for the other codecs to have
> support for that feature activated? As this doesn't actually hold the
> buffers but only makes sure that they could be held.
> 
> > +	case V4L2_PIX_FMT_H264_SLICE:
> > +		vq->subsystem_flags |= VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF;
> 
> I think it is worth it to highlight with a comment why only this one
> receives support for holding the buffer. As it is quite confusing
> without background info and just the code.

As this code is quite separate from the actual codec code, I believe it will be
more robust this way. It could happen in the future that code get modified
without taking into account that a buffer may be held. This also mimic how this
was implemented in Cedrus fwiw.

Note that it needs to be added for MPEG2 field decoding too, but I believe this
is unrelated to this patchset, the form is nice for adding more in the future.

> 
> How about:
> ```
> /*
>   * During field decoding in H264, all fields are written into the
>   * same capture buffer, thus we need to be able to hold the buffer
>   * until all fields are written to it
>   */
> ```
> 
> > +		break;
> > +	default:
> 
> The only other decoding formats remaining are:
> - V4L2_PIX_FMT_NV12_4L4
> - V4L2_PIX_FMT_NV12

You'll never get raw formats in that switch. The cases are exhaustive for the
context, yet the compiler does not understand that context.

> 
> Both have codec mode HANTRO_MODE_NONE.
> 
> My thought is:
> If we don't care for these two, the we might as well disable buffer holding
> support for them as well. So, we could make this simplier
> (but a bit less descriptive):
> 
> ```
> /*
>   * During field decoding in H264, all fields are written into the
>   * same capture buffer, thus we need to be able to hold the buffer
>   * until all fields are written to it
>   */
> if (fourcc == V4L2_PIX_FMT_H264_SLICE)
>      vq->subsystem_flags |= VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF;
> else 
> 		vq->subsystem_flags &= ~(VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF);
> ```
> 
> Greetings,
> Sebastian
> 
> > +		break;
> > +	}
> > +}
> > +
> > static int hantro_set_fmt_out(struct hantro_ctx *ctx,
> > 			      struct v4l2_pix_format_mplane *pix_mp)
> > {
> > @@ -472,6 +496,7 @@ static int hantro_set_fmt_out(struct hantro_ctx *ctx,
> > 	ctx->dst_fmt.quantization = pix_mp->quantization;
> > 
> > 	hantro_update_requires_request(ctx, pix_mp->pixelformat);
> > +	hantro_update_requires_hold_capture_buf(ctx, pix_mp->pixelformat);
> > 
> > 	vpu_debug(0, "OUTPUT codec mode: %d\n", ctx->vpu_src_fmt->codec_mode);
> > 	vpu_debug(0, "fmt - w: %d, h: %d\n",
> > -- 
> > 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-31 18:26 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 [this message]
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
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=8a59875f62ac1a60aec91c9170c1471234e1b4db.camel@collabora.com \
    --to=nicolas.dufresne@collabora.com \
    --cc=ezequiel@vanguardiasur.com.ar \
    --cc=gregkh@linuxfoundation.org \
    --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