]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: hantro: HEVC: Fix output frame chroma offset
authorBenjamin Gaignard <benjamin.gaignard@collabora.com>
Thu, 14 Apr 2022 15:50:59 +0000 (17:50 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Aug 2022 12:41:01 +0000 (14:41 +0200)
[ Upstream commit 579846ec52593e6ca123c30379103377cd25728a ]

Hantro decoder doesn't take care of the requested and aligned size
of the capture buffer.
Stop using the bitstream width/height and use capture frame size
stored in the context to get the correct values.

hantro_hevc_chroma_offset() and hantro_hevc_motion_vectors_offset()
are only used in hantro_g2_hevc_dec.c so take the opportunity
to move them here.

fluster HEVC score goes up from 77 to 85 successful tests (over 147)
with this patch.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/staging/media/hantro/hantro_g2_hevc_dec.c
drivers/staging/media/hantro/hantro_hevc.c
drivers/staging/media/hantro/hantro_hw.h

index a4642ed1f463d2a9929529e07a6fc039b76fcbb8..7c046d456038452296f39c5fe5cfc3f3611842d2 100644 (file)
@@ -8,6 +8,20 @@
 #include "hantro_hw.h"
 #include "hantro_g2_regs.h"
 
+#define G2_ALIGN       16
+
+static size_t hantro_hevc_chroma_offset(struct hantro_ctx *ctx)
+{
+       return ctx->dst_fmt.width * ctx->dst_fmt.height;
+}
+
+static size_t hantro_hevc_motion_vectors_offset(struct hantro_ctx *ctx)
+{
+       size_t cr_offset = hantro_hevc_chroma_offset(ctx);
+
+       return ALIGN((cr_offset * 3) / 2, G2_ALIGN);
+}
+
 static void prepare_tile_info_buffer(struct hantro_ctx *ctx)
 {
        struct hantro_dev *vpu = ctx->dev;
@@ -330,7 +344,6 @@ static void set_ref_pic_list(struct hantro_ctx *ctx)
 static int set_ref(struct hantro_ctx *ctx)
 {
        const struct hantro_hevc_dec_ctrls *ctrls = &ctx->hevc_dec.ctrls;
-       const struct v4l2_ctrl_hevc_sps *sps = ctrls->sps;
        const struct v4l2_ctrl_hevc_pps *pps = ctrls->pps;
        const struct v4l2_ctrl_hevc_decode_params *decode_params = ctrls->decode_params;
        const struct v4l2_hevc_dpb_entry *dpb = decode_params->dpb;
@@ -338,8 +351,8 @@ static int set_ref(struct hantro_ctx *ctx)
        struct hantro_dev *vpu = ctx->dev;
        struct vb2_v4l2_buffer *vb2_dst;
        struct hantro_decoded_buffer *dst;
-       size_t cr_offset = hantro_hevc_chroma_offset(sps);
-       size_t mv_offset = hantro_hevc_motion_vectors_offset(sps);
+       size_t cr_offset = hantro_hevc_chroma_offset(ctx);
+       size_t mv_offset = hantro_hevc_motion_vectors_offset(ctx);
        u32 max_ref_frames;
        u16 dpb_longterm_e;
        static const struct hantro_reg cur_poc[] = {
index 9c351f7fe6bd9be53f85b4eb5b43d0f5661eca0f..b3a057beaf19616b01057a0b6164688f5058ff3f 100644 (file)
 
 #define UNUSED_REF     -1
 
-#define G2_ALIGN               16
-
-size_t hantro_hevc_chroma_offset(const struct v4l2_ctrl_hevc_sps *sps)
-{
-       int bytes_per_pixel = sps->bit_depth_luma_minus8 == 0 ? 1 : 2;
-
-       return sps->pic_width_in_luma_samples *
-              sps->pic_height_in_luma_samples * bytes_per_pixel;
-}
-
-size_t hantro_hevc_motion_vectors_offset(const struct v4l2_ctrl_hevc_sps *sps)
-{
-       size_t cr_offset = hantro_hevc_chroma_offset(sps);
-
-       return ALIGN((cr_offset * 3) / 2, G2_ALIGN);
-}
-
 static void hantro_hevc_ref_init(struct hantro_ctx *ctx)
 {
        struct hantro_hevc_dec_hw_ctx *hevc_dec = &ctx->hevc_dec;
index c5dc77125fb74606acd77ad8f97cde3ccaba5d74..df142f31e31b8e13ad3e0a3b3af62e1fde5dcb41 100644 (file)
@@ -341,8 +341,6 @@ int hantro_hevc_dec_prepare_run(struct hantro_ctx *ctx);
 dma_addr_t hantro_hevc_get_ref_buf(struct hantro_ctx *ctx, int poc);
 int hantro_hevc_add_ref_buf(struct hantro_ctx *ctx, int poc, dma_addr_t addr);
 void hantro_hevc_ref_remove_unused(struct hantro_ctx *ctx);
-size_t hantro_hevc_chroma_offset(const struct v4l2_ctrl_hevc_sps *sps);
-size_t hantro_hevc_motion_vectors_offset(const struct v4l2_ctrl_hevc_sps *sps);
 
 static inline unsigned short hantro_vp9_num_sbs(unsigned short dimension)
 {