From: Arun Iyengar Date: Tue, 01 Dec 2026 11:02:59 +0000 Subject: [PATCH v2 1/2] media: rkvdec: vdpu381: Compress the co-located motion vectors of H.264 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261201-rkvdec-colmv-v2-1-8ba3e18eab46@gmail.com> References: <20261201-rkvdec-colmv-v2-0-8ba3e18eab46@gmail.com> In-Reply-To: <20261201-rkvdec-colmv-v2-0-8ba3e18eab46@gmail.com> To: Detlev Casanova , Ezequiel Garcia , Mauro Carvalho Chehab , Heiko Stuebner Cc: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Arun Iyengar X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796122980; l=2917; i=aiyengar1990@gmail.com; s=20261110; h=from:subject:message-id; bh=xUcDexkDvXpP9NvQ7Yeaxf7cUJh7BnBc4mUP/T8FmOw=; b=HrrWiJNMgiZEVuv40t6tdVgnXESAgrshJK4XbPHzx42nyz/kSEEADci/xU0TuPdEuNIA/VEC0 uKzLMfD3wwrAYTEbWhMElNsRbf/7Vlxxn9DYbWs52A5vw8ZThcS/r2d X-Developer-Key: i=aiyengar1990@gmail.com; a=ed25519; pk=zXpRgUTrhaFe6jLyPqbBy3ccfkj04w0g2690Wv3mg+0= X-Endpoint-Received: by B4 Relay for aiyengar1990@gmail.com/20261110 with auth_id=1480 List-Id: B4 Relay Submissions The VDPU381 can store the co-located motion vectors compressed (reg012 colmv_compress_en). Enable it for frame-only H.264 streams, as the vendor code (MPP, hal_h264d_vdpu34x.c) does. On RK3588 a 4K stream decodes at 68.4 instead of 65.4 fps and a 1080p one at 234 instead of 214 fps, with identical frames. Compressed, a 64x16 segment takes up to 1 KiB plus a header byte, twice the 128 bytes per macroblock reserved today. Reserve that, as the vendor code does: 8.3 MB instead of 4.1 MB per 4K CAPTURE buffer, also for HEVC. Signed-off-by: Arun Iyengar --- drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-h264.c | 2 ++ drivers/media/platform/rockchip/rkvdec/rkvdec.c | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-h264.c b/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-h264.c index b961fddc8583..afc7f5b49b1d 100644 --- a/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-h264.c +++ b/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-h264.c @@ -242,6 +242,8 @@ static void config_registers(struct rkvdec_ctx *ctx, * with some frames, it will try to use the address set in the register. */ regs->common.reg012_secondary_en.scanlist_addr_valid_en = 1; + regs->common.reg012_secondary_en.colmv_compress_en = + !!(run->sps->flags & V4L2_H264_SPS_FLAG_FRAME_MBS_ONLY); /* Set IDR flag */ regs->common.reg013_en_mode_set.cur_pic_is_idr = diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec.c b/drivers/media/platform/rockchip/rkvdec/rkvdec.c index 6cd7445b18c4..6bbb6c065e8b 100644 --- a/drivers/media/platform/rockchip/rkvdec/rkvdec.c +++ b/drivers/media/platform/rockchip/rkvdec/rkvdec.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -93,6 +94,15 @@ static u32 rkvdec_colmv_size(u16 width, u16 height) return 128 * DIV_ROUND_UP(width, 16) * DIV_ROUND_UP(height, 16); } +/* Compressed H.264 worst case: a header byte and 1 KiB per 64x16 segment */ +static u32 vdpu381_colmv_size(u16 width, u16 height) +{ + u32 seg_w = DIV_ROUND_UP(width, 64); + u32 seg_h = DIV_ROUND_UP(height, 16); + + return ALIGN(ALIGN(seg_w, 16) * seg_h + seg_w * seg_h * SZ_1K, 128); +} + static u32 vdpu383_colmv_size(u16 width, u16 height) { return ALIGN(width, 64) * ALIGN(height, 16); @@ -1719,7 +1729,7 @@ static const struct rcb_size_info vdpu381_rcb_sizes[] = { static const struct rkvdec_variant_ops vdpu381_variant_ops = { .irq_handler = vdpu381_irq_handler, - .colmv_size = rkvdec_colmv_size, + .colmv_size = vdpu381_colmv_size, .flatten_matrices = transpose_and_flatten_matrices, }; -- 2.55.0