From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
To: Benjamin Gaignard <benjamin.gaignard@collabora.com>,
p.zabel@pengutronix.de, mchehab@kernel.org, heiko@sntech.de,
hverkuil@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
linux-rockchip@lists.infradead.org,
linux-arm-kernel@lists.infradead.org, kernel@collabora.com
Subject: Re: [PATCH v8 1/3] media: v4l2-ctrls: validate AV1 reference frame index
Date: Tue, 24 Nov 2026 12:08:00 -0500 [thread overview]
Message-ID: <deea128399ee10bcd7e789a48763222b961ae0f1.camel@collabora.com> (raw)
In-Reply-To: <20261124131816.115131-2-benjamin.gaignard@collabora.com>
[-- Attachment #1: Type: text/plain, Size: 3633 bytes --]
Le mardi 24 novembre 2026 à 14:18 +0100, Benjamin Gaignard a écrit :
> The stateless AV1 decoders use primary_ref_frame and ref_frame_idx[] to
> to find the matching reference frames.
> V4L2_AV1_PRIMARY_REF_NONE is the value of primary_ref_frame indicating
> that there is no primary reference frame.
> Reject invalid indexes to avoid issues in the drivers while validate other
> frame parameters.
>
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
> ---
> changes in v8
> - check reference frame index when validating the frame before
> calling the driver.
>
> .../verisilicon/rockchip_vpu981_hw_av1_dec.c | 3 +--
> drivers/media/v4l2-core/v4l2-ctrls-core.c | 20 +++++++++++++++++++
> include/uapi/linux/v4l2-controls.h | 1 +
> 3 files changed, 22 insertions(+), 2 deletions(-)
Split core from driver changes.
>
> diff --git a/drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c b/drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c
> index 2a145433e6d1..bbfca34688eb 100644
> --- a/drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c
> +++ b/drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c
> @@ -20,7 +20,6 @@
> #define AV1_REF_SCALE_SHIFT 14
> #define AV1_INVALID_IDX -1
> #define MAX_FRAME_DISTANCE 31
> -#define AV1_PRIMARY_REF_NONE 7
> #define AV1_TILE_SIZE ALIGN(32 * 128, 4096)
> /*
> * These 3 values aren't defined enum v4l2_av1_segment_feature because
> @@ -1256,7 +1255,7 @@ static void rockchip_vpu981_av1_dec_set_prob(struct hantro_ctx *ctx)
> bool frame_is_intra = IS_INTRA(frame->frame_type);
>
> if (error_resilient_mode || frame_is_intra ||
> - frame->primary_ref_frame == AV1_PRIMARY_REF_NONE) {
> + frame->primary_ref_frame == V4L2_AV1_PRIMARY_REF_NONE) {
> av1_dec->cdfs = &av1_dec->default_cdfs;
> av1_dec->cdfs_ndvc = &av1_dec->default_cdfs_ndvc;
> rockchip_av1_default_coeff_probs(quantization->base_q_idx,
> diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2-core/v4l2-ctrls-core.c
> index 6e751a043a21..f4c2a04fb721 100644
> --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c
> +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c
> @@ -817,10 +817,30 @@ static int validate_av1_tile_info(struct v4l2_av1_tile_info *t)
> return 0;
> }
>
> +static int validate_av1_reference_index(struct v4l2_ctrl_av1_frame *f)
> +{
> + int idx;
> +
> + if (f->primary_ref_frame > V4L2_AV1_PRIMARY_REF_NONE)
> + return -EINVAL;
> +
> + if (f->primary_ref_frame == V4L2_AV1_PRIMARY_REF_NONE)
> + return 0;
> +
> + idx = f->ref_frame_idx[f->primary_ref_frame];
> + if (idx < 0 || idx >= V4L2_AV1_TOTAL_REFS_PER_FRAME)
> + return -EINVAL;
> +
> + return 0;
> +}
> +
> static int validate_av1_frame(struct v4l2_ctrl_av1_frame *f)
> {
> int ret = 0;
>
> + ret = validate_av1_reference_index(f);
> + if (ret)
> + return ret;
> ret = validate_av1_tile_info(&f->tile_info);
> if (ret)
> return ret;
> diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
> index d17e41d51d2e..82023fbffd6a 100644
> --- a/include/uapi/linux/v4l2-controls.h
> +++ b/include/uapi/linux/v4l2-controls.h
> @@ -2940,6 +2940,7 @@ struct v4l2_ctrl_vp9_compressed_hdr {
> #define V4L2_AV1_MAX_TILE_COLS 64
> #define V4L2_AV1_MAX_TILE_ROWS 64
> #define V4L2_AV1_MAX_TILE_COUNT 512
> +#define V4L2_AV1_PRIMARY_REF_NONE 7
>
> #define V4L2_AV1_SEQUENCE_FLAG_STILL_PICTURE 0x00000001
> #define V4L2_AV1_SEQUENCE_FLAG_USE_128X128_SUPERBLOCK 0x00000002
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2026-11-24 17:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 13:18 [PATCH v8 0/3] media: verisilicon: Create AV1 helper library Benjamin Gaignard
2026-11-24 13:18 ` [PATCH v8 1/3] media: v4l2-ctrls: validate AV1 reference frame index Benjamin Gaignard
2026-11-24 17:08 ` Nicolas Dufresne [this message]
2026-11-24 13:18 ` [PATCH v8 2/3] media: verisilicon: AV1: Fix luma size Benjamin Gaignard
2026-11-24 13:18 ` [PATCH v8 3/3] media: verisilicon: Create AV1 helper library Benjamin Gaignard
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=deea128399ee10bcd7e789a48763222b961ae0f1.camel@collabora.com \
--to=nicolas.dufresne@collabora.com \
--cc=benjamin.gaignard@collabora.com \
--cc=heiko@sntech.de \
--cc=hverkuil@kernel.org \
--cc=kernel@collabora.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=mchehab@kernel.org \
--cc=p.zabel@pengutronix.de \
/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
all inboxes | Powered by JetHome®