media: verisilicon: Create AV1 helper library
Subsystems (3)
Benjamin Gaignard
maintainerv7 cover media: verisilicon: Create AV1 helper library
Regroup all none hardware related AV1 functions into a helper library. The goal is to avoid code duplication for future AV1 codecs.
Tested on rock 5b board Fluster score remains the same 204/241.
change in v7:
- prepend 2 patches with Fixes tag for backport
- rebase the series on v7.4-rc3 tag
change in v6:
- include b84f6533a8ed ("media: verisilicon: rockchip: guard VPU981 AV1 divisor and tile buffer") and 367db8b23c26 ("media: verisilicon: rockchip: reject AV1 frames exceeding the tile capacity") fixes into the patch to not losing these improvements.
Benjamin Gaignard (3):
media: verisilicon: AV1: Check reference frame index
media: verisilicon: AV1: Fix luma size
media: verisilicon: Create AV1 helper library
drivers/media/platform/verisilicon/Makefile | 7 +-
.../media/platform/verisilicon/hantro_av1.c | 816 +++++++++++++
.../media/platform/verisilicon/hantro_av1.h | 64 +
...entropymode.c => hantro_av1_entropymode.c} | 18 +-
...entropymode.h => hantro_av1_entropymode.h} | 18 +-
...av1_filmgrain.c => hantro_av1_filmgrain.c} | 125 +-
.../verisilicon/hantro_av1_filmgrain.h | 48 +
.../media/platform/verisilicon/hantro_hw.h | 7 +-
.../verisilicon/rockchip_av1_filmgrain.h | 36 -
.../verisilicon/rockchip_vpu981_hw_av1_dec.c | 1082 ++---------------
.../platform/verisilicon/rockchip_vpu_hw.c | 7 +-
11 files changed, 1140 insertions(+), 1088 deletions(-)
create mode 100644 drivers/media/platform/verisilicon/hantro_av1.c
create mode 100644 drivers/media/platform/verisilicon/hantro_av1.h
rename drivers/media/platform/verisilicon/{rockchip_av1_entropymode.c => hantro_av1_entropymode.c} (99%)
rename drivers/media/platform/verisilicon/{rockchip_av1_entropymode.h => hantro_av1_entropymode.h} (95%)
rename drivers/media/platform/verisilicon/{rockchip_av1_filmgrain.c => hantro_av1_filmgrain.c} (85%)
create mode 100644 drivers/media/platform/verisilicon/hantro_av1_filmgrain.h
delete mode 100644 drivers/media/platform/verisilicon/rockchip_av1_filmgrain.hSignature · 1 line
2.53.0
Benjamin Gaignard
maintainerPATCH v7 1/3 media: verisilicon: AV1: Check reference frame index
Make sure that reference frame index is valid before using it.
--- .../platform/verisilicon/rockchip_vpu981_hw_av1_dec.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c +10 -1
@@ -121,7 +121,12 @@ static int rockchip_vpu981_get_frame_index(struct hantro_ctx *ctx, int ref)struct hantro_av1_dec_ctrls *ctrls = &av1_dec->ctrls;const struct v4l2_ctrl_av1_frame *frame = ctrls->frame;u64 timestamp; -int i, idx = frame->ref_frame_idx[ref]; +int i, idx; + +if (ref <0 || ref >=V4L2_AV1_REFS_PER_FRAME ) +return AV1_INVALID_IDX ; + + idx = frame->ref_frame_idx[ref];if (idx >=V4L2_AV1_TOTAL_REFS_PER_FRAME || idx <0 )return AV1_INVALID_IDX ;
@@ -1262,6 +1267,10 @@ static void rockchip_vpu981_av1_dec_set_prob(struct hantro_ctx *ctx)rockchip_av1_default_coeff_probs (quantization->base_q_idx, av1_dec->cdfs); }else { +if (frame->primary_ref_frame <0 || + frame->primary_ref_frame >=V4L2_AV1_REFS_PER_FRAME ) +return ; +rockchip_av1_get_cdfs (ctx, frame->ref_frame_idx[frame->primary_ref_frame]); }rockchip_av1_store_cdfs (ctx, frame->refresh_frame_flags);
Signature · 1 line
2.53.0
Nicolas Dufresne
maintainerRe: [PATCH v7 1/3] media: verisilicon: AV1: Check reference frame index
Le vendredi 20 novembre 2026 à 15:31 +0100, Benjamin Gaignard a écrit :
Quoted 27 lines
Make sure that reference frame index is valid before using it.
Signed-off-by Benjamin Gaignard <[email protected]>Fixes 727a400686a2c ("media: verisilicon: Add Rockchip AV1 decoder")--- .../platform/verisilicon/rockchip_vpu981_hw_av1_dec.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c +6
-1@@ -121,7 +121,12 @@ static int rockchip_vpu981_get_frame_index(struct hantro_ctx *ctx, int ref)struct hantro_av1_dec_ctrls *ctrls = &av1_dec->ctrls;const struct v4l2_ctrl_av1_frame *frame = ctrls->frame;u64 timestamp; -int i, idx = frame->ref_frame_idx[ref]; +int i, idx; + +if (ref <0 || ref >=V4L2_AV1_REFS_PER_FRAME ) +return AV1_INVALID_IDX ; + + idx = frame->ref_frame_idx[ref];if (idx >=V4L2_AV1_TOTAL_REFS_PER_FRAME || idx <0 )return AV1_INVALID_IDX ;
drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c static void rockchip_vpu981_av1_dec_set_prob(struct hantro_ctx *ctx) · line 1272
Quoted 6 lines
drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c +3
-0@@ -1262,6 +1267,10 @@ static void rockchip_vpu981_av1_dec_set_prob(struct hantro_ctx *ctx)rockchip_av1_default_coeff_probs (quantization->base_q_idx, av1_dec->cdfs); }else { +if (frame->primary_ref_frame <0 || + frame->primary_ref_frame >=V4L2_AV1_REFS_PER_FRAME ) +return ;
Just returning does not abort dec_run() and will lead to triggering the HW with partially initialized data. Either this should lead to some default cdf to be picked, or we add a return value and check it in dec_run().
May I propose to validate these once once in prepare_run()?
drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c static void rockchip_vpu981_av1_dec_set_prob(struct hantro_ctx *ctx) · line 1274
Quoted 2 lines
drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c +1
-0+rockchip_av1_get_cdfs (ctx, frame->ref_frame_idx[frame->primary_ref_frame]);
Here, the index passed to get_cdfs() is not validated and will lead to out of band indexing inside that function..
Quoted 2 lines
drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c +0
-0}rockchip_av1_store_cdfs (ctx, frame->refresh_frame_flags);
Benjamin Gaignard
maintainerRe: [PATCH v7 1/3] media: verisilicon: AV1: Check reference frame index
Le 24/11/2026 à 04:29, Nicolas Dufresne a écrit :
Quoted 38 lines
Le vendredi 20 novembre 2026 à 15:31 +0100, Benjamin Gaignard a écrit :
Quoted 27 lines
Make sure that reference frame index is valid before using it.
Signed-off-by Benjamin Gaignard <[email protected]>Fixes 727a400686a2c ("media: verisilicon: Add Rockchip AV1 decoder")--- .../platform/verisilicon/rockchip_vpu981_hw_av1_dec.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c +6
-1@@ -121,7 +121,12 @@ static int rockchip_vpu981_get_frame_index(struct hantro_ctx *ctx, int ref)struct hantro_av1_dec_ctrls *ctrls = &av1_dec->ctrls;const struct v4l2_ctrl_av1_frame *frame = ctrls->frame;u64 timestamp; -int i, idx = frame->ref_frame_idx[ref]; +int i, idx; + +if (ref <0 || ref >=V4L2_AV1_REFS_PER_FRAME ) +return AV1_INVALID_IDX ; + + idx = frame->ref_frame_idx[ref];if (idx >=V4L2_AV1_TOTAL_REFS_PER_FRAME || idx <0 )return AV1_INVALID_IDX ;drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c static void rockchip_vpu981_av1_dec_set_prob(struct hantro_ctx *ctx) · line 1272
Quoted 6 lines
drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c +3
-0@@ -1262,6 +1267,10 @@ static void rockchip_vpu981_av1_dec_set_prob(struct hantro_ctx *ctx)rockchip_av1_default_coeff_probs (quantization->base_q_idx, av1_dec->cdfs); }else { +if (frame->primary_ref_frame <0 || + frame->primary_ref_frame >=V4L2_AV1_REFS_PER_FRAME ) +return ;Just returning does not abort
dec_run()and will lead to triggering the HW with partially initialized data. Either this should lead to some default cdf to be picked, or we add a return value and check it indec_run().
Quoted 1 line
May I propose to validate these once once in
prepare_run()?
I will do it when validating AV1 frame parameters in v4l2-ctrl-core.c
Regards,
Benjamin
Quoted 9 lines
drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c static void rockchip_vpu981_av1_dec_set_prob(struct hantro_ctx *ctx) · line 1274
Quoted 3 lines
drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c +1
-0+rockchip_av1_get_cdfs (ctx, frame->ref_frame_idx[frame->primary_ref_frame]);Here, the index passed to
get_cdfs()is not validated and will lead to out of band indexing inside that function..Quoted 2 lines
drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c +0
-0}rockchip_av1_store_cdfs (ctx, frame->refresh_frame_flags);
Benjamin Gaignard
maintainerPATCH v7 2/3 media: verisilicon: AV1: Fix luma size
In reply to Benjamin GaignardUse the values computed by v4l2 helpers to get luma size. Unlile before this will also take care of padding.
--- drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c +1 -1
@@ -221,7 +221,7 @@ static void rockchip_vpu981_av1_dec_clean_refs(struct hantro_ctx *ctx)static size_t rockchip_vpu981_av1_dec_luma_size (struct hantro_ctx *ctx) { -return ctx->dst_fmt.width * ctx->dst_fmt.height * ctx->bit_depth /8 ; +return ctx->ref_fmt.plane_fmt[0 ].bytesperline * ctx->ref_fmt.height; }static size_t rockchip_vpu981_av1_dec_chroma_size (struct hantro_ctx *ctx)
Signature · 1 line
2.53.0
Re: [PATCH v7 2/3] media: verisilicon: AV1: Fix luma size
Le vendredi 20 novembre 2026 à 15:31 +0100, Benjamin Gaignard a écrit :
Quoted 5 lines
Use the values computed by v4l2 helpers to get luma size. Unlile before this will also take care of padding.
Signed-off-by Benjamin Gaignard <[email protected]>Fixes 727a400686a2c ("media: verisilicon: Add Rockchip AV1 decoder")
Quoted 17 lines
--- drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c +1
-1@@ -221,7 +221,7 @@ static void rockchip_vpu981_av1_dec_clean_refs(struct hantro_ctx *ctx)static size_t rockchip_vpu981_av1_dec_luma_size (struct hantro_ctx *ctx) { -return ctx->dst_fmt.width * ctx->dst_fmt.height * ctx->bit_depth /8 ; +return ctx->ref_fmt.plane_fmt[0 ].bytesperline * ctx->ref_fmt.height; }static size_t rockchip_vpu981_av1_dec_chroma_size (struct hantro_ctx *ctx)
Nicolas Dufresne
maintainerRe: [PATCH v7 2/3] media: verisilicon: AV1: Fix luma size
Since you need a v8 ...
Le lundi 23 novembre 2026 à 22:30 -0500, Nicolas Dufresne a écrit :
Quoted 3 lines
Le vendredi 20 novembre 2026 à 15:31 +0100, Benjamin Gaignard a écrit :
Quoted 2 lines
Use the values computed by v4l2 helpers to get luma size. Unlile before this will also take care of padding.
Unlike
Quoted 3 lines
Quoted 3 lines
Signed-off-by Benjamin Gaignard <[email protected]>Fixes 727a400686a2c ("media: verisilicon: Add Rockchip AV1 decoder")
Fixes goes before Signed-off-by, does this need to be cc to stable?
Quoted 20 lines
Reviewed-by Nicolas Dufresne <[email protected]>Quoted 17 lines
--- drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c +1
-1@@ -221,7 +221,7 @@ static void rockchip_vpu981_av1_dec_clean_refs(struct hantro_ctx *ctx)static size_t rockchip_vpu981_av1_dec_luma_size (struct hantro_ctx *ctx) { -return ctx->dst_fmt.width * ctx->dst_fmt.height * ctx->bit_depth /8 ; +return ctx->ref_fmt.plane_fmt[0 ].bytesperline * ctx->ref_fmt.height; }static size_t rockchip_vpu981_av1_dec_chroma_size (struct hantro_ctx *ctx)
Benjamin Gaignard
maintainerPATCH v7 3/3 media: verisilicon: Create AV1 helper library
In reply to Benjamin GaignardRegroup all none hardware related AV1 functions into a helper library. The goal is to avoid code duplication for future AV1 codecs.
Tested on rock 5b board Fluster score remains the same 204/241.
---
change in v7:
- rebase the series on v7.4-rc3 tag
change in v6:
- include b84f6533a8ed ("media: verisilicon: rockchip: guard VPU981 AV1 divisor and tile buffer") and 367db8b23c26 ("media: verisilicon: rockchip: reject AV1 frames exceeding the tile capacity") fixes into the patch to not losing these improvements.
drivers/media/platform/verisilicon/Makefile | 7 +-
.../media/platform/verisilicon/hantro_av1.c | 816 ++++++++++++
.../media/platform/verisilicon/hantro_av1.h | 64 +
...entropymode.c => hantro_av1_entropymode.c} | 18 +-
...entropymode.h => hantro_av1_entropymode.h} | 18 +-
...av1_filmgrain.c => hantro_av1_filmgrain.c} | 125 +-
.../verisilicon/hantro_av1_filmgrain.h | 48 +
.../media/platform/verisilicon/hantro_hw.h | 7 +-
.../verisilicon/rockchip_av1_filmgrain.h | 36 -
.../verisilicon/rockchip_vpu981_hw_av1_dec.c | 1091 ++---------------
.../platform/verisilicon/rockchip_vpu_hw.c | 7 +-
11 files changed, 1140 insertions(+), 1097 deletions(-)
create mode 100644 drivers/media/platform/verisilicon/hantro_av1.c
create mode 100644 drivers/media/platform/verisilicon/hantro_av1.h
rename drivers/media/platform/verisilicon/{rockchip_av1_entropymode.c => hantro_av1_entropymode.c} (99%)
rename drivers/media/platform/verisilicon/{rockchip_av1_entropymode.h => hantro_av1_entropymode.h} (95%)
rename drivers/media/platform/verisilicon/{rockchip_av1_filmgrain.c => hantro_av1_filmgrain.c} (85%)
create mode 100644 drivers/media/platform/verisilicon/hantro_av1_filmgrain.h
delete mode 100644 drivers/media/platform/verisilicon/rockchip_av1_filmgrain.hdrivers/media/platform/verisilicon/Makefile +4 -3
@@ -19,7 +19,10 @@ hantro-vpu-y += \ hantro_hevc.o \ hantro_mpeg2.o \ hantro_vp8.o \ - hantro_vp9.o + hantro_vp9.o \ + hantro_av1.o \ + hantro_av1_filmgrain.o \ + hantro_av1_entropymode.o hantro-vpu-$(CONFIG_VIDEO_HANTRO_IMX8M) += \ imx8m_vpu_hw.o
@@ -33,8 +36,6 @@ hantro-vpu-$(CONFIG_VIDEO_HANTRO_ROCKCHIP) += \ rockchip_vpu2_hw_mpeg2_dec.o \ rockchip_vpu2_hw_vp8_dec.o \ rockchip_vpu981_hw_av1_dec.o \ - rockchip_av1_filmgrain.o \ - rockchip_av1_entropymode.o \ rockchip_vpu_hw.o hantro-vpu-$(CONFIG_VIDEO_HANTRO_SUNXI) += \
drivers/media/platform/verisilicon/hantro_av1.c new file +816 -0
816 lines not on this page · raw message
drivers/media/platform/verisilicon/hantro_av1.h new file +64 -0
64 lines not on this page · raw message
drivers/media/platform/verisilicon/hantro_av1_entropymode.c renamed from drivers/media/platform/verisilicon/rockchip_av1_entropymode.c +9 -9
@@ -11,7 +11,7 @@*/ #include "hantro.h" -#include "rockchip_av1_entropymode.h" +#include "hantro_av1_entropymode.h" #define AOM_ICDF ICDF#define AOM_CDF2 (a0) AOM_ICDF(a0)
@@ -4195,7 +4195,7 @@ static const u16 default_bits_cdf[][10] = { } }; -static int rockchip_av1_get_q_ctx (int q) +static int hantro_av1_get_q_ctx (int q) {if (q <=20 )return 0 ;
@@ -4206,10 +4206,10 @@ static int rockchip_av1_get_q_ctx(int q)return 3 ; } -void rockchip_av1_default_coeff_probs (u32 base_qindex,void *ptr) +void hantro_av1_default_coeff_probs (u32 base_qindex,void *ptr) {struct av1cdfs *cdfs = (struct av1cdfs *)ptr; -const int index =rockchip_av1_get_q_ctx (base_qindex); +const int index =hantro_av1_get_q_ctx (base_qindex);memcpy (cdfs->txb_skip_cdf, av1_default_txb_skip_cdfs[index],sizeof (av1_default_txb_skip_cdfs[0 ]));
@@ -4240,8 +4240,8 @@ void rockchip_av1_default_coeff_probs(u32 base_qindex, void *ptr) sizeof(av1_default_eob_multi1024_cdfs[0])); } -void rockchip_av1_set_default_cdfs (struct av1cdfs *cdfs, -struct mvcdfs *cdfs_ndvc) +void hantro_av1_set_default_cdfs (struct av1cdfs *cdfs, +struct mvcdfs *cdfs_ndvc) {memcpy (cdfs->partition_cdf, default_partition_cdf,sizeof (cdfs->partition_cdf));
@@ -4398,7 +4398,7 @@ void rockchip_av1_set_default_cdfs(struct av1cdfs *cdfs, sizeof(cdfs->compound_idx_cdf)); } -void rockchip_av1_get_cdfs (struct hantro_ctx *ctx,u32 ref_idx) +void hantro_av1_get_cdfs (struct hantro_ctx *ctx,u32 ref_idx) {struct hantro_av1_dec_hw_ctx *av1_dec = &ctx->av1_dec;
@@ -4406,8 +4406,8 @@ void rockchip_av1_get_cdfs(struct hantro_ctx *ctx, u32 ref_idx) av1_dec->cdfs_ndvc = &av1_dec->cdfs_last_ndvc[ref_idx]; } -void rockchip_av1_store_cdfs (struct hantro_ctx *ctx, -u32 refresh_frame_flags) +void hantro_av1_store_cdfs (struct hantro_ctx *ctx, +u32 refresh_frame_flags) {struct hantro_av1_dec_hw_ctx *av1_dec = &ctx->av1_dec;int i;
drivers/media/platform/verisilicon/hantro_av1_entropymode.h renamed from drivers/media/platform/verisilicon/rockchip_av1_entropymode.h +9 -9
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0-only */ -#ifndef _ROCKCHIP_AV1_ENTROPYMODE_H_ -#define _ROCKCHIP_AV1_ENTROPYMODE_H_ +#ifndef _HANTRO_AV1_ENTROPYMODE_H_ +#define _HANTRO_AV1_ENTROPYMODE_H_#include <linux/types.h>
@@ -262,11 +262,11 @@ struct av1cdfs { u16 dummy3[16]; }; -void rockchip_av1_store_cdfs (struct hantro_ctx *ctx, -u32 refresh_frame_flags); -void rockchip_av1_get_cdfs (struct hantro_ctx *ctx,u32 ref_idx); -void rockchip_av1_set_default_cdfs (struct av1cdfs *cdfs, -struct mvcdfs *cdfs_ndvc); -void rockchip_av1_default_coeff_probs (u32 base_qindex,void *ptr); +void hantro_av1_store_cdfs (struct hantro_ctx *ctx, +u32 refresh_frame_flags); +void hantro_av1_get_cdfs (struct hantro_ctx *ctx,u32 ref_idx); +void hantro_av1_set_default_cdfs (struct av1cdfs *cdfs, +struct mvcdfs *cdfs_ndvc); +void hantro_av1_default_coeff_probs (u32 base_qindex,void *ptr); -#endif /* _ROCKCHIP_AV1_ENTROPYMODE_H_ */ +#endif /* _HANTRO_AV1_ENTROPYMODE_H_ */
drivers/media/platform/verisilicon/hantro_av1_filmgrain.c renamed from drivers/media/platform/verisilicon/rockchip_av1_filmgrain.c +60 -65
229 lines not on this page · raw message
drivers/media/platform/verisilicon/hantro_av1_filmgrain.h new file +48 -0
48 lines not on this page · raw message
drivers/media/platform/verisilicon/hantro_hw.h +2 -5
@@ -15,8 +15,8 @@#include <media/v4l2-vp9.h> #include <media/videobuf2-core.h> -#include "rockchip_av1_entropymode.h" -#include "rockchip_av1_filmgrain.h" +#include "hantro_av1_entropymode.h" +#include "hantro_av1_filmgrain.h" #define DEC_8190_ALIGN_MASK 0x07U
@@ -458,10 +458,7 @@ void hantro_hevc_ref_init(struct hantro_ctx *ctx);dma_addr_t hantro_hevc_get_ref_buf (struct hantro_ctx *ctx,s32 poc);int hantro_hevc_add_ref_buf (struct hantro_ctx *ctx,int poc,dma_addr_t addr); -int rockchip_vpu981_av1_dec_init (struct hantro_ctx *ctx); -void rockchip_vpu981_av1_dec_exit (struct hantro_ctx *ctx);int rockchip_vpu981_av1_dec_run (struct hantro_ctx *ctx); -void rockchip_vpu981_av1_dec_done (struct hantro_ctx *ctx);static inline unsigned short hantro_vp9_num_sbs (unsigned short dimension) {
drivers/media/platform/verisilicon/rockchip_av1_filmgrain.h deleted +0 -36
@@ -1,36 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ - -#ifndef _ROCKCHIP_AV1_FILMGRAIN_H_ -#define _ROCKCHIP_AV1_FILMGRAIN_H_ - -#include <linux/types.h> - -void rockchip_av1_generate_luma_grain_block (s32 (*luma_grain_block)[73 ][82 ], -s32 bitdepth, -u8 num_y_points, -s32 grain_scale_shift, -s32 ar_coeff_lag, -s32 (*ar_coeffs_y)[24 ], -s32 ar_coeff_shift, -s32 grain_min, -s32 grain_max, -u16 random_seed); - -void rockchip_av1_generate_chroma_grain_block (s32 (*luma_grain_block)[73 ][82 ], -s32 (*cb_grain_block)[38 ][44 ], -s32 (*cr_grain_block)[38 ][44 ], -s32 bitdepth, -u8 num_y_points, -u8 num_cb_points, -u8 num_cr_points, -s32 grain_scale_shift, -s32 ar_coeff_lag, -s32 (*ar_coeffs_cb)[25 ], -s32 (*ar_coeffs_cr)[25 ], -s32 ar_coeff_shift, -s32 grain_min, -s32 grain_max, -u8 chroma_scaling_from_luma, -u16 random_seed); - -#endif
drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c +124 -967
1,397 lines not on this page · raw message
drivers/media/platform/verisilicon/rockchip_vpu_hw.c +4 -3
@@ -9,6 +9,7 @@#include <linux/clk.h> #include "hantro.h" +#include "hantro_av1.h" #include "hantro_jpeg.h" #include "hantro_g1_regs.h" #include "hantro_h1_regs.h"
@@ -608,9 +609,9 @@ static const struct hantro_codec_ops rk3568_vepu_codec_ops[] = {static const struct hantro_codec_ops rk3588_vpu981_codec_ops[] = { [HANTRO_MODE_AV1_DEC ] = { .run = rockchip_vpu981_av1_dec_run, - .init = rockchip_vpu981_av1_dec_init, - .exit = rockchip_vpu981_av1_dec_exit, - .done = rockchip_vpu981_av1_dec_done, + .init = hantro_av1_init, + .exit = hantro_av1_exit, + .done = hantro_av1_update_prob, }, };/*
Signature · 1 line
2.53.0
Nicolas Dufresne
maintainerLe vendredi 20 novembre 2026 à 15:31 +0100, Benjamin Gaignard a écrit :
Quoted 67 lines
Regroup all none hardware related AV1 functions into a helper library. The goal is to avoid code duplication for future AV1 codecs.
Tested on rock 5b board Fluster score remains the same 204/241.
Signed-off-by Benjamin Gaignard <[email protected]>Reviewed-by Nicolas Dufresne <[email protected]>---
change in v7:
- rebase the series on v7.4-rc3 tagchange in v6:
- includeb84f6533a8ed("media: verisilicon: rockchip: guard VPU981 AV1 divisor and tile buffer") and367db8b23c26("media: verisilicon: rockchip: reject AV1 frames exceeding the tile capacity") fixes into the patch to not losing these improvements.drivers/media/platform/verisilicon/Makefile | 7 +- .../media/platform/verisilicon/hantro_av1.c | 816 ++++++++++++ .../media/platform/verisilicon/hantro_av1.h | 64 + ...entropymode.c => hantro_av1_entropymode.c} | 18 +- ...entropymode.h => hantro_av1_entropymode.h} | 18 +- ...av1_filmgrain.c => hantro_av1_filmgrain.c} | 125 +- .../verisilicon/hantro_av1_filmgrain.h | 48 + .../media/platform/verisilicon/hantro_hw.h | 7 +- .../verisilicon/rockchip_av1_filmgrain.h | 36 - .../verisilicon/rockchip_vpu981_hw_av1_dec.c | 1091 ++--------------- .../platform/verisilicon/rockchip_vpu_hw.c | 7 +- 11 files changed, 1140 insertions(+), 1097 deletions(-) create mode 100644 drivers/media/platform/verisilicon/hantro_av1.c create mode 100644 drivers/media/platform/verisilicon/hantro_av1.h rename drivers/media/platform/verisilicon/{rockchip_av1_entropymode.c => hantro_av1_entropymode.c} (99%) rename drivers/media/platform/verisilicon/{rockchip_av1_entropymode.h => hantro_av1_entropymode.h} (95%) rename drivers/media/platform/verisilicon/{rockchip_av1_filmgrain.c => hantro_av1_filmgrain.c} (85%) create mode 100644 drivers/media/platform/verisilicon/hantro_av1_filmgrain.h delete mode 100644 drivers/media/platform/verisilicon/rockchip_av1_filmgrain.hdrivers/media/platform/verisilicon/Makefile +4
-3@@ -19,7 +19,10 @@ hantro-vpu-y += \ hantro_hevc.o \ hantro_mpeg2.o \ hantro_vp8.o \ - hantro_vp9.o + hantro_vp9.o \ + hantro_av1.o \ + hantro_av1_filmgrain.o \ + hantro_av1_entropymode.o hantro-vpu-$(CONFIG_VIDEO_HANTRO_IMX8M) += \ imx8m_vpu_hw.o@@ -33,8 +36,6 @@ hantro-vpu-$(CONFIG_VIDEO_HANTRO_ROCKCHIP) += \ rockchip_vpu2_hw_mpeg2_dec.o \ rockchip_vpu2_hw_vp8_dec.o \ rockchip_vpu981_hw_av1_dec.o \ - rockchip_av1_filmgrain.o \ - rockchip_av1_entropymode.o \ rockchip_vpu_hw.o hantro-vpu-$(CONFIG_VIDEO_HANTRO_SUNXI) += \drivers/media/platform/verisilicon/hantro_av1.c new file +0
-0
drivers/media/platform/verisilicon/hantro_av1.c line 3
Quoted 3 lines
drivers/media/platform/verisilicon/hantro_av1.c new file +3
-0@@ -0,0 +1,816 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (c) 2026, Collabora
To be accurate:
+ * Copyright (c) 2023-2026, Collabora