Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] media: rkvdec: vdpu381: compress the co-located motion vectors
@ 2026-12-01 11:02 Arun Iyengar via B4 Relay
  2026-12-01 11:02 ` [PATCH v2 1/2] media: rkvdec: vdpu381: Compress the co-located motion vectors of H.264 Arun Iyengar via B4 Relay
  2026-12-01 11:03 ` [PATCH v2 2/2] media: rkvdec: vdpu381: Compress the co-located motion vectors of HEVC Arun Iyengar via B4 Relay
  0 siblings, 2 replies; 3+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-01 11:02 UTC (permalink / raw)
  To: Detlev Casanova, Ezequiel Garcia, Mauro Carvalho Chehab,
	Heiko Stuebner
  Cc: linux-media, linux-rockchip, linux-arm-kernel, linux-kernel,
	Arun Iyengar

The VDPU381 can store the co-located motion vectors of a frame
compressed. The Rockchip MPP does so for frame-only H.264 and for HEVC;
mainline never does. The H.264 worst case needs twice the space reserved
today: 8.3 MB instead of 4.1 MB per 4K CAPTURE buffer.

Patch 1 enables it for H.264 and reserves the worst case.
Patch 2 enables it for HEVC.

Tested on an Orange Pi 5 (RK3588S), GStreamer into fakevideosink, 240
frames, compression off -> on: H.264 4K 65.4 -> 68.4 fps, 1080p 214 ->
234 fps, HEVC 4K 98.6-102.8 -> 104.6 fps. The frame checksums are the
same off and on and match FFmpeg's software decoders. Fluster is
unchanged (JCT-VC-HEVC_V1 146/147, JVT-AVC_V1 129/135, JVT-FR-EXT 65/69).

Developed with Claude (Anthropic), which wrote the code and the commit
messages; I reviewed and tested every change.

Changes in v2:
- Shorter messages and comments. No functional change.
- Link to v1: https://lore.kernel.org/r/20261110-rkvdec-colmv-v1-0-012b84ea43f7@gmail.com

---
Arun Iyengar (2):
      media: rkvdec: vdpu381: Compress the co-located motion vectors of H.264
      media: rkvdec: vdpu381: Compress the co-located motion vectors of HEVC

 drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-h264.c |  2 ++
 drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-hevc.c |  2 ++
 drivers/media/platform/rockchip/rkvdec/rkvdec.c              | 12 +++++++++++-
 3 files changed, 15 insertions(+), 1 deletion(-)
---
base-commit: 95c189b26efb07257888ccf9d873a5c366aafbc6
change-id: 20261110-rkvdec-colmv-455057cb3974

Best regards,
--  
Arun Iyengar <aiyengar1990@gmail.com>




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2 1/2] media: rkvdec: vdpu381: Compress the co-located motion vectors of H.264
  2026-12-01 11:02 [PATCH v2 0/2] media: rkvdec: vdpu381: compress the co-located motion vectors Arun Iyengar via B4 Relay
@ 2026-12-01 11:02 ` Arun Iyengar via B4 Relay
  2026-12-01 11:03 ` [PATCH v2 2/2] media: rkvdec: vdpu381: Compress the co-located motion vectors of HEVC Arun Iyengar via B4 Relay
  1 sibling, 0 replies; 3+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-01 11:02 UTC (permalink / raw)
  To: Detlev Casanova, Ezequiel Garcia, Mauro Carvalho Chehab,
	Heiko Stuebner
  Cc: linux-media, linux-rockchip, linux-arm-kernel, linux-kernel,
	Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

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 <aiyengar1990@gmail.com>
---
 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 <linux/platform_device.h>
 #include <linux/pm.h>
 #include <linux/pm_runtime.h>
+#include <linux/sizes.h>
 #include <linux/slab.h>
 #include <linux/videodev2.h>
 #include <linux/workqueue.h>
@@ -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




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v2 2/2] media: rkvdec: vdpu381: Compress the co-located motion vectors of HEVC
  2026-12-01 11:02 [PATCH v2 0/2] media: rkvdec: vdpu381: compress the co-located motion vectors Arun Iyengar via B4 Relay
  2026-12-01 11:02 ` [PATCH v2 1/2] media: rkvdec: vdpu381: Compress the co-located motion vectors of H.264 Arun Iyengar via B4 Relay
@ 2026-12-01 11:03 ` Arun Iyengar via B4 Relay
  1 sibling, 0 replies; 3+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-12-01 11:03 UTC (permalink / raw)
  To: Detlev Casanova, Ezequiel Garcia, Mauro Carvalho Chehab,
	Heiko Stuebner
  Cc: linux-media, linux-rockchip, linux-arm-kernel, linux-kernel,
	Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

Store the co-located motion vectors of HEVC frames compressed, as the
vendor code (MPP, hal_h265d_vdpu34x.c) always does.

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-hevc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-hevc.c b/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-hevc.c
index e1936e87f45b..f2c3138af032 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-hevc.c
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-hevc.c
@@ -404,6 +404,8 @@ static void config_registers(struct rkvdec_ctx *ctx,
 	/* Set HEVC mode */
 	regs->common.reg009_dec_mode.dec_mode = VDPU381_MODE_HEVC;
 
+	regs->common.reg012_secondary_en.colmv_compress_en = 1;
+
 	/* Set config */
 	regs->common.reg011_important_en.buf_empty_en = 1;
 	regs->common.reg011_important_en.dec_clkgate_e = 1;

-- 
2.55.0




^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-01 11:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 11:02 [PATCH v2 0/2] media: rkvdec: vdpu381: compress the co-located motion vectors Arun Iyengar via B4 Relay
2026-12-01 11:02 ` [PATCH v2 1/2] media: rkvdec: vdpu381: Compress the co-located motion vectors of H.264 Arun Iyengar via B4 Relay
2026-12-01 11:03 ` [PATCH v2 2/2] media: rkvdec: vdpu381: Compress the co-located motion vectors of HEVC Arun Iyengar via B4 Relay

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox