Skip to content

Commit 1b9ef27

Browse files
Benjamin Gaignardmchehab
authored andcommitted
media: verisilicon: Compute motion vectors size for AV1 frames
Compute the additional space required to store motion vectors at the end of the frames buffers. Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
1 parent 7040ed4 commit 1b9ef27

3 files changed

Lines changed: 21 additions & 0 deletions

File tree

drivers/media/platform/verisilicon/hantro_hw.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,19 @@ hantro_hevc_mv_size(unsigned int width, unsigned int height)
417417
return width * height / 16;
418418
}
419419

420+
static inline unsigned short hantro_av1_num_sbs(unsigned short dimension)
421+
{
422+
return DIV_ROUND_UP(dimension, 64);
423+
}
424+
425+
static inline size_t
426+
hantro_av1_mv_size(unsigned int width, unsigned int height)
427+
{
428+
size_t num_sbs = hantro_av1_num_sbs(width) * hantro_av1_num_sbs(height);
429+
430+
return ALIGN(num_sbs * 384, 16) * 2 + 512;
431+
}
432+
420433
int hantro_g1_mpeg2_dec_run(struct hantro_ctx *ctx);
421434
int rockchip_vpu2_mpeg2_dec_run(struct hantro_ctx *ctx);
422435
void hantro_mpeg2_dec_copy_qtable(u8 *qtable,

drivers/media/platform/verisilicon/hantro_postproc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ int hantro_postproc_alloc(struct hantro_ctx *ctx)
213213
else if (ctx->vpu_src_fmt->fourcc == V4L2_PIX_FMT_HEVC_SLICE)
214214
buf_size += hantro_hevc_mv_size(pix_mp.width,
215215
pix_mp.height);
216+
else if (ctx->vpu_src_fmt->fourcc == V4L2_PIX_FMT_AV1_FRAME)
217+
buf_size += hantro_av1_mv_size(pix_mp.width,
218+
pix_mp.height);
216219

217220
for (i = 0; i < num_buffers; ++i) {
218221
struct hantro_aux_buf *priv = &ctx->postproc.dec_q[i];

drivers/media/platform/verisilicon/hantro_v4l2.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,11 @@ static int hantro_try_fmt(const struct hantro_ctx *ctx,
333333
pix_mp->plane_fmt[0].sizeimage +=
334334
hantro_hevc_mv_size(pix_mp->width,
335335
pix_mp->height);
336+
else if (ctx->vpu_src_fmt->fourcc == V4L2_PIX_FMT_AV1_FRAME &&
337+
!hantro_needs_postproc(ctx, fmt))
338+
pix_mp->plane_fmt[0].sizeimage +=
339+
hantro_av1_mv_size(pix_mp->width,
340+
pix_mp->height);
336341
} else if (!pix_mp->plane_fmt[0].sizeimage) {
337342
/*
338343
* For coded formats the application can specify

0 commit comments

Comments
 (0)