Devicetree
 help / color / mirror / Atom feed
From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
To: Paul Kocialkowski <paulk@sys-base.io>,
	devicetree@vger.kernel.org,  imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	 linux-kernel@vger.kernel.org, linux-media@vger.kernel.org
Cc: Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	 Pengutronix Kernel Team	 <kernel@pengutronix.de>,
	Benjamin Gaignard <benjamin.gaignard@collabora.com>,
	 Philipp Zabel <p.zabel@pengutronix.de>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Hans Verkuil	 <hverkuil@kernel.org>,
	Marco Felsch <m.felsch@pengutronix.de>,
	Michael Tretter	 <m.tretter@pengutronix.de>
Subject: Re: [PATCH 01/14] media: h264: Add a more generic reflist builder init
Date: Tue, 17 Nov 2026 16:06:05 -0500	[thread overview]
Message-ID: <760e33e8de1f139be7dba2270313c80aeb53c1d3.camel@collabora.com> (raw)
In-Reply-To: <20260522101653.2565125-2-paulk@sys-base.io>

[-- Attachment #1: Type: text/plain, Size: 4501 bytes --]

Hi,

Le vendredi 22 mai 2026 à 12:16 +0200, Paul Kocialkowski a écrit :
> This should become part of a larger reflist builder rework.

Maybe a tiny bit more meet would help? What am I reviewing, what is this new
builder used for?
> 
> Signed-off-by: Paul Kocialkowski <paulk@sys-base.io>
> ---
>  drivers/media/v4l2-core/v4l2-h264.c | 69 +++++++++++++++++++++++++++++
>  include/media/v4l2-h264.h           |  7 +++
>  2 files changed, 76 insertions(+)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-h264.c b/drivers/media/v4l2-core/v4l2-h264.c
> index c00197d095e7..4e5a177ca2c7 100644
> --- a/drivers/media/v4l2-core/v4l2-h264.c
> +++ b/drivers/media/v4l2-core/v4l2-h264.c
> @@ -105,6 +105,75 @@ v4l2_h264_init_reflist_builder(struct v4l2_h264_reflist_builder *b,
>  }
>  EXPORT_SYMBOL_GPL(v4l2_h264_init_reflist_builder);
>  
> +void
> +v4l2_h264_init_reflist_builder_gen(struct v4l2_h264_reflist_builder *b,
> +		const struct v4l2_ctrl_h264_sps *sps,
> +		const struct v4l2_h264_dpb_entry dpb[V4L2_H264_NUM_DPB_ENTRIES],
> +		unsigned int pic_order_count, unsigned int frame_num, unsigned int fields)

Add a doc comment.

> +{
> +	int cur_frame_num, max_frame_num;
> +	unsigned int i;
> +
> +	max_frame_num = 1 << (sps->log2_max_frame_num_minus4 + 4);
> +	cur_frame_num = frame_num;
> +
> +	memset(b, 0, sizeof(*b));
> +	b->cur_pic_order_count = pic_order_count;
> +	b->cur_pic_fields = fields;
> +
> +	for (i = 0; i < V4L2_H264_NUM_DPB_ENTRIES; i++) {
> +		if (!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE))
> +			continue;
> +
> +		if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM)
> +			b->refs[i].longterm = true;
> +
> +		/*
> +		 * Handle frame_num wraparound as described in section
> +		 * '8.2.4.1 Decoding process for picture numbers' of the spec.
> +		 * For long term references, frame_num is set to
> +		 * long_term_frame_idx which requires no wrapping.
> +		 */
> +		if (!b->refs[i].longterm && dpb[i].frame_num > cur_frame_num)
> +			b->refs[i].frame_num = (int)dpb[i].frame_num -
> +					       max_frame_num;
> +		else
> +			b->refs[i].frame_num = dpb[i].frame_num;
> +
> +		b->refs[i].top_field_order_cnt = dpb[i].top_field_order_cnt;
> +		b->refs[i].bottom_field_order_cnt = dpb[i].bottom_field_order_cnt;
> +
> +		if (b->cur_pic_fields == V4L2_H264_FRAME_REF) {
> +			u8 fields = V4L2_H264_FRAME_REF;
> +
> +			b->unordered_reflist[b->num_valid].index = i;
> +			b->unordered_reflist[b->num_valid].fields = fields;
> +			b->num_valid++;
> +			continue;
> +		}
> +
> +		if (dpb[i].fields & V4L2_H264_TOP_FIELD_REF) {
> +			u8 fields = V4L2_H264_TOP_FIELD_REF;
> +
> +			b->unordered_reflist[b->num_valid].index = i;
> +			b->unordered_reflist[b->num_valid].fields = fields;
> +			b->num_valid++;
> +		}
> +
> +		if (dpb[i].fields & V4L2_H264_BOTTOM_FIELD_REF) {
> +			u8 fields = V4L2_H264_BOTTOM_FIELD_REF;
> +
> +			b->unordered_reflist[b->num_valid].index = i;
> +			b->unordered_reflist[b->num_valid].fields = fields;
> +			b->num_valid++;
> +		}
> +	}
> +
> +	for (i = b->num_valid; i < ARRAY_SIZE(b->unordered_reflist); i++)
> +		b->unordered_reflist[i].index = i;
> +}
> +EXPORT_SYMBOL_GPL(v4l2_h264_init_reflist_builder_gen);
> +
>  static s32 v4l2_h264_get_poc(const struct v4l2_h264_reflist_builder *b,
>  			     const struct v4l2_h264_reference *ref)
>  {
> diff --git a/include/media/v4l2-h264.h b/include/media/v4l2-h264.h
> index 0d9eaa956123..1833c0556963 100644
> --- a/include/media/v4l2-h264.h
> +++ b/include/media/v4l2-h264.h
> @@ -42,6 +42,7 @@ struct v4l2_h264_reflist_builder {
>  	u8 cur_pic_fields;
>  
>  	struct v4l2_h264_reference unordered_reflist[V4L2_H264_REF_LIST_LEN];
> +	/* FIXME: confusing with valid flag (active is checked). Proper terminology is "used" */

Just drop a patch before that rename it?

>  	u8 num_valid;

>  };
>  
> @@ -51,6 +52,12 @@ v4l2_h264_init_reflist_builder(struct v4l2_h264_reflist_builder *b,
>  		const struct v4l2_ctrl_h264_sps *sps,
>  		const struct v4l2_h264_dpb_entry dpb[V4L2_H264_NUM_DPB_ENTRIES]);
>  
> +void
> +v4l2_h264_init_reflist_builder_gen(struct v4l2_h264_reflist_builder *b,
> +		const struct v4l2_ctrl_h264_sps *sps,
> +		const struct v4l2_h264_dpb_entry dpb[V4L2_H264_NUM_DPB_ENTRIES],
> +		unsigned int pic_order_count, unsigned int frame_num, unsigned int fields);
> +
>  /**
>   * v4l2_h264_build_b_ref_lists() - Build the B0/B1 reference lists
>   *

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2026-11-17 21:06 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-22 10:16 [PATCH 00/14] media: Add V4L2 H.264 stateless encode and VC8000E support Paul Kocialkowski
2026-05-22 10:16 ` [PATCH 01/14] media: h264: Add a more generic reflist builder init Paul Kocialkowski
2026-11-17 21:06   ` Nicolas Dufresne [this message]
2026-05-22 10:16 ` [PATCH 02/14] media: uapi: Add H.264 stateless encode support Paul Kocialkowski
2026-11-17 21:30   ` Nicolas Dufresne
2026-05-22 10:16 ` [PATCH 03/14] media: h264: Add SPS video definitions Paul Kocialkowski
2026-11-17 21:31   ` Nicolas Dufresne
2026-11-17 21:34   ` Nicolas Dufresne
2026-05-22 10:16 ` [PATCH 04/14] media: h264: Add stateless encode core Paul Kocialkowski
2026-11-17 21:37   ` Nicolas Dufresne
2026-05-22 10:16 ` [PATCH 05/14] media: h264: Add stateless encode rbsp Paul Kocialkowski
2026-05-22 10:16 ` [PATCH 06/14] media: h264: Add stateless encode reference management Paul Kocialkowski
2026-05-22 10:16 ` [PATCH 07/14] media: h264: Add stateless encode rate control Paul Kocialkowski
2026-05-22 10:16 ` [PATCH 08/14] media: verisilicon: Report default pixel coding for non-JPEG and fix JPEG case Paul Kocialkowski
2026-05-22 10:16 ` [PATCH 09/14] media: verisilicon: Cancel job with runtime pm put/clk disable on failure Paul Kocialkowski
2026-11-17 21:42   ` Nicolas Dufresne
2026-05-22 10:16 ` [PATCH 10/14] media: hantro: use hantro_decoded_buffer only for dst_vq Paul Kocialkowski
2026-11-17 21:48   ` Nicolas Dufresne
2026-05-22 10:16 ` [PATCH 11/14] media: verisilicon: Add common encoder parm and frameintervals ioctls Paul Kocialkowski
2026-11-17 21:50   ` Nicolas Dufresne
2026-05-22 10:16 ` [PATCH 12/14] media: verisilicon: Add support for the VC8000E H.264 encoder Paul Kocialkowski
2026-11-17 22:00   ` Nicolas Dufresne
2026-05-22 10:16 ` [PATCH 13/14] media: verilisicon: imx8m: Add support for the VC8000E on i.MX8MP Paul Kocialkowski
2026-05-22 10:16 ` [PATCH 14/14] arm64: dts: imx8mp: add VC8000E encoder node Paul Kocialkowski
2026-05-22 11:28   ` Fabio Estevam
2026-11-17 22:02   ` Nicolas Dufresne
2026-05-22 14:47 ` [PATCH 00/14] media: Add V4L2 H.264 stateless encode and VC8000E support Nicolas Dufresne
2026-09-23 12:10   ` Michael Nazzareno Trimarchi
2026-09-23 20:05     ` Paul Kocialkowski
2026-09-24  5:30       ` Michael Nazzareno Trimarchi
2026-09-24 18:09         ` Paul Kocialkowski
2026-09-24 19:38           ` Michael Nazzareno Trimarchi
2026-09-24 19:44             ` Nicolas Dufresne
2026-09-24 20:30               ` Paul Kocialkowski
2026-09-24 20:46                 ` Nicolas Dufresne
2026-09-30  4:14                   ` Chen-Yu Tsai

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=760e33e8de1f139be7dba2270313c80aeb53c1d3.camel@collabora.com \
    --to=nicolas.dufresne@collabora.com \
    --cc=benjamin.gaignard@collabora.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=hverkuil@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=kernel@pengutronix.de \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=m.felsch@pengutronix.de \
    --cc=m.tretter@pengutronix.de \
    --cc=mchehab@kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=paulk@sys-base.io \
    --cc=robh@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    /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