* [PATCH 0/2] media: verisilicon: av1: Fix two reference reads
@ 2026-11-15 8:59 Arun Iyengar via B4 Relay
2026-11-15 8:59 ` [PATCH 1/2] media: verisilicon: av1: Find the reference buffers by timestamp Arun Iyengar via B4 Relay
2026-11-15 8:59 ` [PATCH 2/2] media: verisilicon: av1: Read the segmentation map at the reference's offset Arun Iyengar via B4 Relay
0 siblings, 2 replies; 5+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-11-15 8:59 UTC (permalink / raw)
To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
Mauro Carvalho Chehab, Heiko Stuebner, Hans Verkuil
Cc: linux-media, linux-rockchip, linux-kernel, linux-arm-kernel,
stable, Arun Iyengar
The RK3588 AV1 decoder (VPU981) can read a CAPTURE buffer freed with
VIDIOC_REMOVE_BUFS (patch 1), and reads the segmentation map past the
end of a smaller reference after a switch to a larger CAPTURE format
(patch 2).
Found by code review; neither was reproduced. Tested on an Orange Pi 5
(RK3588S), 7.3-based tree with these patches: fluster AV1 test vectors,
no new failures.
Developed with Claude (Anthropic), which wrote the code and the commit
messages. I reviewed every change.
---
Arun Iyengar (2):
media: verisilicon: av1: Find the reference buffers by timestamp
media: verisilicon: av1: Read the segmentation map at the reference's offset
drivers/media/platform/verisilicon/hantro_hw.h | 1 -
.../verisilicon/rockchip_vpu981_hw_av1_dec.c | 45 +++++++++++++---------
2 files changed, 26 insertions(+), 20 deletions(-)
---
base-commit: 48fe5a7834cc10081887d7bcd9ff0a4cadc3fa8c
change-id: 20261114-b4-vpu981-av1-refs-d9419af12e0d
Best regards,
--
Arun Iyengar <aiyengar1990@gmail.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] media: verisilicon: av1: Find the reference buffers by timestamp
2026-11-15 8:59 [PATCH 0/2] media: verisilicon: av1: Fix two reference reads Arun Iyengar via B4 Relay
@ 2026-11-15 8:59 ` Arun Iyengar via B4 Relay
2026-11-17 15:49 ` Benjamin Gaignard
2026-11-15 8:59 ` [PATCH 2/2] media: verisilicon: av1: Read the segmentation map at the reference's offset Arun Iyengar via B4 Relay
1 sibling, 1 reply; 5+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-11-15 8:59 UTC (permalink / raw)
To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
Mauro Carvalho Chehab, Heiko Stuebner, Hans Verkuil
Cc: linux-media, linux-rockchip, linux-kernel, linux-arm-kernel,
stable, Arun Iyengar
From: Arun Iyengar <aiyengar1990@gmail.com>
frame_refs[] keeps a CAPTURE buffer pointer per reference across jobs.
VIDIOC_REMOVE_BUFS can free that buffer, and a missing reference falls
back to slot 0, which can hold a stale pointer.
Look the buffer up by timestamp at each job, as the other Hantro codecs
do, and use the current CAPTURE buffer and frame size when the reference
is missing.
Fixes: 727a400686a2 ("media: verisilicon: Add Rockchip AV1 decoder")
Cc: stable@vger.kernel.org
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
drivers/media/platform/verisilicon/hantro_hw.h | 1 -
.../verisilicon/rockchip_vpu981_hw_av1_dec.c | 37 ++++++++++++----------
2 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/drivers/media/platform/verisilicon/hantro_hw.h b/drivers/media/platform/verisilicon/hantro_hw.h
index 13e573f1f19d..36df8caa077d 100644
--- a/drivers/media/platform/verisilicon/hantro_hw.h
+++ b/drivers/media/platform/verisilicon/hantro_hw.h
@@ -287,7 +287,6 @@ struct hantro_av1_frame_ref {
bool used;
u32 order_hint;
u32 order_hints[V4L2_AV1_TOTAL_REFS_PER_FRAME];
- struct vb2_v4l2_buffer *vb2_ref;
};
/**
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..59f2adf74850 100644
--- a/drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c
+++ b/drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c
@@ -169,7 +169,6 @@ static int rockchip_vpu981_av1_dec_frame_ref(struct hantro_ctx *ctx,
av1_dec->frame_refs[i].timestamp = timestamp;
av1_dec->frame_refs[i].frame_type = frame->frame_type;
av1_dec->frame_refs[i].order_hint = frame->order_hint;
- av1_dec->frame_refs[i].vb2_ref = hantro_get_dst_buf(ctx);
for (j = 0; j < V4L2_AV1_TOTAL_REFS_PER_FRAME; j++)
av1_dec->frame_refs[i].order_hints[j] = frame->order_hints[j];
@@ -182,6 +181,18 @@ static int rockchip_vpu981_av1_dec_frame_ref(struct hantro_ctx *ctx,
return AV1_INVALID_IDX;
}
+static struct vb2_buffer *rockchip_vpu981_av1_dec_ref_buf(struct hantro_ctx *ctx, int idx)
+{
+ struct hantro_av1_dec_hw_ctx *av1_dec = &ctx->av1_dec;
+ struct vb2_queue *q = v4l2_m2m_get_dst_vq(ctx->fh.m2m_ctx);
+ struct vb2_buffer *buf = NULL;
+
+ if (idx >= 0 && av1_dec->frame_refs[idx].used)
+ buf = vb2_find_buffer(q, av1_dec->frame_refs[idx].timestamp);
+
+ return buf ?: &hantro_get_dst_buf(ctx)->vb2_buf;
+}
+
static void rockchip_vpu981_av1_dec_frame_unref(struct hantro_ctx *ctx, int idx)
{
struct hantro_av1_dec_hw_ctx *av1_dec = &ctx->av1_dec;
@@ -829,7 +840,7 @@ rockchip_vpu981_av1_dec_set_ref(struct hantro_ctx *ctx, int ref, int idx,
pr_warn("AV1 invalid reference frame index\n");
}
- dst = vb2_to_hantro_decoded_buf(&av1_dec->frame_refs[idx].vb2_ref->vb2_buf);
+ dst = vb2_to_hantro_decoded_buf(rockchip_vpu981_av1_dec_ref_buf(ctx, idx));
luma_addr = hantro_get_dec_buf_addr(ctx, &dst->base.vb.vb2_buf);
chroma_addr = luma_addr + dst->av1.chroma_offset;
mv_addr = luma_addr + dst->av1.mv_offset;
@@ -894,7 +905,7 @@ static void rockchip_vpu981_av1_dec_set_segmentation(struct hantro_ctx *ctx)
struct hantro_decoded_buffer *seg;
size_t mv_offset = rockchip_vpu981_av1_dec_chroma_size(ctx);
- seg = vb2_to_hantro_decoded_buf(&av1_dec->frame_refs[idx].vb2_ref->vb2_buf);
+ seg = vb2_to_hantro_decoded_buf(rockchip_vpu981_av1_dec_ref_buf(ctx, idx));
luma_addr = hantro_get_dec_buf_addr(ctx, &seg->base.vb.vb2_buf);
mv_addr = luma_addr + mv_offset;
@@ -1983,16 +1994,13 @@ static void rockchip_vpu981_av1_dec_set_reference_frames(struct hantro_ctx *ctx)
for (i = V4L2_AV1_REF_LAST_FRAME; i < V4L2_AV1_TOTAL_REFS_PER_FRAME; i++) {
u32 ref = i - 1;
- int idx = 0;
- int width, height;
+ int idx = AV1_INVALID_IDX;
+ int width = frame->frame_width_minus_1 + 1;
+ int height = frame->frame_height_minus_1 + 1;
- if (allow_intrabc) {
- idx = av1_dec->current_frame_index;
- width = frame->frame_width_minus_1 + 1;
- height = frame->frame_height_minus_1 + 1;
- } else {
- if (rockchip_vpu981_get_frame_index(ctx, ref) > 0)
- idx = rockchip_vpu981_get_frame_index(ctx, ref);
+ if (!allow_intrabc)
+ idx = rockchip_vpu981_get_frame_index(ctx, ref);
+ if (idx >= 0) {
width = av1_dec->frame_refs[idx].width;
height = av1_dec->frame_refs[idx].height;
}
@@ -2185,16 +2193,13 @@ rockchip_vpu981_av1_dec_set_input_buffer(struct hantro_ctx *ctx,
static void
rockchip_vpu981_av1_dec_set_output_buffer(struct hantro_ctx *ctx)
{
- struct hantro_av1_dec_hw_ctx *av1_dec = &ctx->av1_dec;
struct hantro_dev *vpu = ctx->dev;
struct hantro_decoded_buffer *dst;
- struct vb2_v4l2_buffer *vb2_dst;
dma_addr_t luma_addr, chroma_addr, mv_addr = 0;
size_t cr_offset = rockchip_vpu981_av1_dec_luma_size(ctx);
size_t mv_offset = rockchip_vpu981_av1_dec_chroma_size(ctx);
- vb2_dst = av1_dec->frame_refs[av1_dec->current_frame_index].vb2_ref;
- dst = vb2_to_hantro_decoded_buf(&vb2_dst->vb2_buf);
+ dst = vb2_to_hantro_decoded_buf(&hantro_get_dst_buf(ctx)->vb2_buf);
luma_addr = hantro_get_dec_buf_addr(ctx, &dst->base.vb.vb2_buf);
chroma_addr = luma_addr + cr_offset;
mv_addr = luma_addr + mv_offset;
--
2.55.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] media: verisilicon: av1: Read the segmentation map at the reference's offset
2026-11-15 8:59 [PATCH 0/2] media: verisilicon: av1: Fix two reference reads Arun Iyengar via B4 Relay
2026-11-15 8:59 ` [PATCH 1/2] media: verisilicon: av1: Find the reference buffers by timestamp Arun Iyengar via B4 Relay
@ 2026-11-15 8:59 ` Arun Iyengar via B4 Relay
2026-11-17 15:50 ` Benjamin Gaignard
1 sibling, 1 reply; 5+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-11-15 8:59 UTC (permalink / raw)
To: Nicolas Dufresne, Benjamin Gaignard, Philipp Zabel,
Mauro Carvalho Chehab, Heiko Stuebner, Hans Verkuil
Cc: linux-media, linux-rockchip, linux-kernel, linux-arm-kernel,
stable, Arun Iyengar
From: Arun Iyengar <aiyengar1990@gmail.com>
The segmentation map of the primary reference is read at the motion
vector offset of the current CAPTURE format. After a switch to a larger
format, that is past the end of a reference held in a smaller buffer.
Use the reference's own offset, and skip the map of a reference of
another size (the spec then uses segment 0, load_previous_segment_ids()
in section 6.8.2).
Fixes: 727a400686a2 ("media: verisilicon: Add Rockchip AV1 decoder")
Cc: stable@vger.kernel.org
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
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 59f2adf74850..f23af435f961 100644
--- a/drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c
+++ b/drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c
@@ -899,15 +899,17 @@ static void rockchip_vpu981_av1_dec_set_segmentation(struct hantro_ctx *ctx)
if (!!(seg->flags & V4L2_AV1_SEGMENTATION_FLAG_ENABLED) &&
frame->primary_ref_frame < V4L2_AV1_REFS_PER_FRAME) {
int idx = rockchip_vpu981_get_frame_index(ctx, frame->primary_ref_frame);
+ int mi_cols = DIV_ROUND_UP(frame->frame_width_minus_1 + 1, 8);
+ int mi_rows = DIV_ROUND_UP(frame->frame_height_minus_1 + 1, 8);
- if (idx >= 0) {
+ if (idx >= 0 && av1_dec->frame_refs[idx].mi_cols == mi_cols &&
+ av1_dec->frame_refs[idx].mi_rows == mi_rows) {
dma_addr_t luma_addr, mv_addr = 0;
struct hantro_decoded_buffer *seg;
- size_t mv_offset = rockchip_vpu981_av1_dec_chroma_size(ctx);
seg = vb2_to_hantro_decoded_buf(rockchip_vpu981_av1_dec_ref_buf(ctx, idx));
luma_addr = hantro_get_dec_buf_addr(ctx, &seg->base.vb.vb2_buf);
- mv_addr = luma_addr + mv_offset;
+ mv_addr = luma_addr + seg->av1.mv_offset;
hantro_write_addr(vpu, AV1_SEGMENTATION, mv_addr);
hantro_reg_write(vpu, &av1_use_temporal3_mvs, 1);
--
2.55.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] media: verisilicon: av1: Find the reference buffers by timestamp
2026-11-15 8:59 ` [PATCH 1/2] media: verisilicon: av1: Find the reference buffers by timestamp Arun Iyengar via B4 Relay
@ 2026-11-17 15:49 ` Benjamin Gaignard
0 siblings, 0 replies; 5+ messages in thread
From: Benjamin Gaignard @ 2026-11-17 15:49 UTC (permalink / raw)
To: aiyengar1990, Nicolas Dufresne, Philipp Zabel,
Mauro Carvalho Chehab, Heiko Stuebner, Hans Verkuil
Cc: linux-media, linux-rockchip, linux-kernel, linux-arm-kernel,
stable
Le 15/11/2026 à 09:59, Arun Iyengar via B4 Relay a écrit :
> From: Arun Iyengar <aiyengar1990@gmail.com>
>
> frame_refs[] keeps a CAPTURE buffer pointer per reference across jobs.
> VIDIOC_REMOVE_BUFS can free that buffer, and a missing reference falls
> back to slot 0, which can hold a stale pointer.
>
> Look the buffer up by timestamp at each job, as the other Hantro codecs
> do, and use the current CAPTURE buffer and frame size when the reference
> is missing.
>
> Fixes: 727a400686a2 ("media: verisilicon: Add Rockchip AV1 decoder")
> Cc: stable@vger.kernel.org
> Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
I have tested the series on rock5b with fluster.
Reviewed-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Thanks for the patch.
Benjamin
> ---
> drivers/media/platform/verisilicon/hantro_hw.h | 1 -
> .../verisilicon/rockchip_vpu981_hw_av1_dec.c | 37 ++++++++++++----------
> 2 files changed, 21 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/media/platform/verisilicon/hantro_hw.h b/drivers/media/platform/verisilicon/hantro_hw.h
> index 13e573f1f19d..36df8caa077d 100644
> --- a/drivers/media/platform/verisilicon/hantro_hw.h
> +++ b/drivers/media/platform/verisilicon/hantro_hw.h
> @@ -287,7 +287,6 @@ struct hantro_av1_frame_ref {
> bool used;
> u32 order_hint;
> u32 order_hints[V4L2_AV1_TOTAL_REFS_PER_FRAME];
> - struct vb2_v4l2_buffer *vb2_ref;
> };
>
> /**
> 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..59f2adf74850 100644
> --- a/drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c
> +++ b/drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c
> @@ -169,7 +169,6 @@ static int rockchip_vpu981_av1_dec_frame_ref(struct hantro_ctx *ctx,
> av1_dec->frame_refs[i].timestamp = timestamp;
> av1_dec->frame_refs[i].frame_type = frame->frame_type;
> av1_dec->frame_refs[i].order_hint = frame->order_hint;
> - av1_dec->frame_refs[i].vb2_ref = hantro_get_dst_buf(ctx);
>
> for (j = 0; j < V4L2_AV1_TOTAL_REFS_PER_FRAME; j++)
> av1_dec->frame_refs[i].order_hints[j] = frame->order_hints[j];
> @@ -182,6 +181,18 @@ static int rockchip_vpu981_av1_dec_frame_ref(struct hantro_ctx *ctx,
> return AV1_INVALID_IDX;
> }
>
> +static struct vb2_buffer *rockchip_vpu981_av1_dec_ref_buf(struct hantro_ctx *ctx, int idx)
> +{
> + struct hantro_av1_dec_hw_ctx *av1_dec = &ctx->av1_dec;
> + struct vb2_queue *q = v4l2_m2m_get_dst_vq(ctx->fh.m2m_ctx);
> + struct vb2_buffer *buf = NULL;
> +
> + if (idx >= 0 && av1_dec->frame_refs[idx].used)
> + buf = vb2_find_buffer(q, av1_dec->frame_refs[idx].timestamp);
> +
> + return buf ?: &hantro_get_dst_buf(ctx)->vb2_buf;
> +}
> +
> static void rockchip_vpu981_av1_dec_frame_unref(struct hantro_ctx *ctx, int idx)
> {
> struct hantro_av1_dec_hw_ctx *av1_dec = &ctx->av1_dec;
> @@ -829,7 +840,7 @@ rockchip_vpu981_av1_dec_set_ref(struct hantro_ctx *ctx, int ref, int idx,
> pr_warn("AV1 invalid reference frame index\n");
> }
>
> - dst = vb2_to_hantro_decoded_buf(&av1_dec->frame_refs[idx].vb2_ref->vb2_buf);
> + dst = vb2_to_hantro_decoded_buf(rockchip_vpu981_av1_dec_ref_buf(ctx, idx));
> luma_addr = hantro_get_dec_buf_addr(ctx, &dst->base.vb.vb2_buf);
> chroma_addr = luma_addr + dst->av1.chroma_offset;
> mv_addr = luma_addr + dst->av1.mv_offset;
> @@ -894,7 +905,7 @@ static void rockchip_vpu981_av1_dec_set_segmentation(struct hantro_ctx *ctx)
> struct hantro_decoded_buffer *seg;
> size_t mv_offset = rockchip_vpu981_av1_dec_chroma_size(ctx);
>
> - seg = vb2_to_hantro_decoded_buf(&av1_dec->frame_refs[idx].vb2_ref->vb2_buf);
> + seg = vb2_to_hantro_decoded_buf(rockchip_vpu981_av1_dec_ref_buf(ctx, idx));
> luma_addr = hantro_get_dec_buf_addr(ctx, &seg->base.vb.vb2_buf);
> mv_addr = luma_addr + mv_offset;
>
> @@ -1983,16 +1994,13 @@ static void rockchip_vpu981_av1_dec_set_reference_frames(struct hantro_ctx *ctx)
>
> for (i = V4L2_AV1_REF_LAST_FRAME; i < V4L2_AV1_TOTAL_REFS_PER_FRAME; i++) {
> u32 ref = i - 1;
> - int idx = 0;
> - int width, height;
> + int idx = AV1_INVALID_IDX;
> + int width = frame->frame_width_minus_1 + 1;
> + int height = frame->frame_height_minus_1 + 1;
>
> - if (allow_intrabc) {
> - idx = av1_dec->current_frame_index;
> - width = frame->frame_width_minus_1 + 1;
> - height = frame->frame_height_minus_1 + 1;
> - } else {
> - if (rockchip_vpu981_get_frame_index(ctx, ref) > 0)
> - idx = rockchip_vpu981_get_frame_index(ctx, ref);
> + if (!allow_intrabc)
> + idx = rockchip_vpu981_get_frame_index(ctx, ref);
> + if (idx >= 0) {
> width = av1_dec->frame_refs[idx].width;
> height = av1_dec->frame_refs[idx].height;
> }
> @@ -2185,16 +2193,13 @@ rockchip_vpu981_av1_dec_set_input_buffer(struct hantro_ctx *ctx,
> static void
> rockchip_vpu981_av1_dec_set_output_buffer(struct hantro_ctx *ctx)
> {
> - struct hantro_av1_dec_hw_ctx *av1_dec = &ctx->av1_dec;
> struct hantro_dev *vpu = ctx->dev;
> struct hantro_decoded_buffer *dst;
> - struct vb2_v4l2_buffer *vb2_dst;
> dma_addr_t luma_addr, chroma_addr, mv_addr = 0;
> size_t cr_offset = rockchip_vpu981_av1_dec_luma_size(ctx);
> size_t mv_offset = rockchip_vpu981_av1_dec_chroma_size(ctx);
>
> - vb2_dst = av1_dec->frame_refs[av1_dec->current_frame_index].vb2_ref;
> - dst = vb2_to_hantro_decoded_buf(&vb2_dst->vb2_buf);
> + dst = vb2_to_hantro_decoded_buf(&hantro_get_dst_buf(ctx)->vb2_buf);
> luma_addr = hantro_get_dec_buf_addr(ctx, &dst->base.vb.vb2_buf);
> chroma_addr = luma_addr + cr_offset;
> mv_addr = luma_addr + mv_offset;
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] media: verisilicon: av1: Read the segmentation map at the reference's offset
2026-11-15 8:59 ` [PATCH 2/2] media: verisilicon: av1: Read the segmentation map at the reference's offset Arun Iyengar via B4 Relay
@ 2026-11-17 15:50 ` Benjamin Gaignard
0 siblings, 0 replies; 5+ messages in thread
From: Benjamin Gaignard @ 2026-11-17 15:50 UTC (permalink / raw)
To: aiyengar1990, Nicolas Dufresne, Philipp Zabel,
Mauro Carvalho Chehab, Heiko Stuebner, Hans Verkuil
Cc: linux-media, linux-rockchip, linux-kernel, linux-arm-kernel,
stable
Le 15/11/2026 à 09:59, Arun Iyengar via B4 Relay a écrit :
> From: Arun Iyengar <aiyengar1990@gmail.com>
>
> The segmentation map of the primary reference is read at the motion
> vector offset of the current CAPTURE format. After a switch to a larger
> format, that is past the end of a reference held in a smaller buffer.
>
> Use the reference's own offset, and skip the map of a reference of
> another size (the spec then uses segment 0, load_previous_segment_ids()
> in section 6.8.2).
>
> Fixes: 727a400686a2 ("media: verisilicon: Add Rockchip AV1 decoder")
> Cc: stable@vger.kernel.org
> Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
Reviewed-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
> ---
> drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> 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 59f2adf74850..f23af435f961 100644
> --- a/drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c
> +++ b/drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c
> @@ -899,15 +899,17 @@ static void rockchip_vpu981_av1_dec_set_segmentation(struct hantro_ctx *ctx)
> if (!!(seg->flags & V4L2_AV1_SEGMENTATION_FLAG_ENABLED) &&
> frame->primary_ref_frame < V4L2_AV1_REFS_PER_FRAME) {
> int idx = rockchip_vpu981_get_frame_index(ctx, frame->primary_ref_frame);
> + int mi_cols = DIV_ROUND_UP(frame->frame_width_minus_1 + 1, 8);
> + int mi_rows = DIV_ROUND_UP(frame->frame_height_minus_1 + 1, 8);
>
> - if (idx >= 0) {
> + if (idx >= 0 && av1_dec->frame_refs[idx].mi_cols == mi_cols &&
> + av1_dec->frame_refs[idx].mi_rows == mi_rows) {
> dma_addr_t luma_addr, mv_addr = 0;
> struct hantro_decoded_buffer *seg;
> - size_t mv_offset = rockchip_vpu981_av1_dec_chroma_size(ctx);
>
> seg = vb2_to_hantro_decoded_buf(rockchip_vpu981_av1_dec_ref_buf(ctx, idx));
> luma_addr = hantro_get_dec_buf_addr(ctx, &seg->base.vb.vb2_buf);
> - mv_addr = luma_addr + mv_offset;
> + mv_addr = luma_addr + seg->av1.mv_offset;
>
> hantro_write_addr(vpu, AV1_SEGMENTATION, mv_addr);
> hantro_reg_write(vpu, &av1_use_temporal3_mvs, 1);
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-17 15:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-15 8:59 [PATCH 0/2] media: verisilicon: av1: Fix two reference reads Arun Iyengar via B4 Relay
2026-11-15 8:59 ` [PATCH 1/2] media: verisilicon: av1: Find the reference buffers by timestamp Arun Iyengar via B4 Relay
2026-11-17 15:49 ` Benjamin Gaignard
2026-11-15 8:59 ` [PATCH 2/2] media: verisilicon: av1: Read the segmentation map at the reference's offset Arun Iyengar via B4 Relay
2026-11-17 15:50 ` Benjamin Gaignard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox