PR #22539 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22539
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22539.patch


>From 935c01329c63da8895d92f29d9eee9cc9e656d4b Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <[email protected]>
Date: Wed, 18 Mar 2026 10:39:33 +0100
Subject: [PATCH 1/3] avcodec/x86/rv34dsp: Port ff_rv34_idct_dc_noround_mmxext
 to sse2

No change in benchmarks here.

Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 libavcodec/x86/rv34dsp.asm    | 12 +++++-------
 libavcodec/x86/rv34dsp_init.c |  8 ++++----
 tests/checkasm/rv34dsp.c      |  2 +-
 3 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/libavcodec/x86/rv34dsp.asm b/libavcodec/x86/rv34dsp.asm
index 01a3d6f590..52d2497007 100644
--- a/libavcodec/x86/rv34dsp.asm
+++ b/libavcodec/x86/rv34dsp.asm
@@ -44,16 +44,14 @@ SECTION .text
     sar    %1, 10
 %endmacro
 
-INIT_MMX mmxext
-cglobal rv34_idct_dc_noround, 1, 2, 0
+INIT_XMM sse2
+cglobal rv34_idct_dc_noround, 1, 2, 1
     movsx   r1, word [r0]
     IDCT_DC_NOROUND r1
     movd    m0, r1d
-    pshufw  m0, m0, 0
-    movq    [r0+ 0], m0
-    movq    [r0+ 8], m0
-    movq    [r0+16], m0
-    movq    [r0+24], m0
+    SPLATW  m0, m0
+    mova    [r0+ 0], m0
+    mova    [r0+16], m0
     RET
 
 ; Load coeffs and perform row transform
diff --git a/libavcodec/x86/rv34dsp_init.c b/libavcodec/x86/rv34dsp_init.c
index caa5c2d653..c4dcae929a 100644
--- a/libavcodec/x86/rv34dsp_init.c
+++ b/libavcodec/x86/rv34dsp_init.c
@@ -24,8 +24,7 @@
 #include "libavutil/x86/cpu.h"
 #include "libavcodec/rv34dsp.h"
 
-void ff_rv34_idct_dc_mmxext(int16_t *block);
-void ff_rv34_idct_dc_noround_mmxext(int16_t *block);
+void ff_rv34_idct_dc_noround_sse2(int16_t *block);
 void ff_rv34_idct_dc_add_sse2(uint8_t *dst, ptrdiff_t stride, int dc);
 void ff_rv34_idct_dc_add_sse4(uint8_t *dst, ptrdiff_t stride, int dc);
 void ff_rv34_idct_add_mmxext(uint8_t *dst, ptrdiff_t stride, int16_t *block);
@@ -35,11 +34,12 @@ av_cold void ff_rv34dsp_init_x86(RV34DSPContext* c)
     int cpu_flags = av_get_cpu_flags();
 
     if (EXTERNAL_MMXEXT(cpu_flags)) {
-        c->rv34_inv_transform_dc = ff_rv34_idct_dc_noround_mmxext;
         c->rv34_idct_add         = ff_rv34_idct_add_mmxext;
     }
-    if (EXTERNAL_SSE2(cpu_flags))
+    if (EXTERNAL_SSE2(cpu_flags)) {
+        c->rv34_inv_transform_dc = ff_rv34_idct_dc_noround_sse2;
         c->rv34_idct_dc_add = ff_rv34_idct_dc_add_sse2;
+    }
     if (EXTERNAL_SSE4(cpu_flags))
         c->rv34_idct_dc_add = ff_rv34_idct_dc_add_sse4;
 }
diff --git a/tests/checkasm/rv34dsp.c b/tests/checkasm/rv34dsp.c
index 0d4716d2ad..5703ba9b82 100644
--- a/tests/checkasm/rv34dsp.c
+++ b/tests/checkasm/rv34dsp.c
@@ -34,7 +34,7 @@
     } while (0)
 
 static void test_rv34_inv_transform_dc(RV34DSPContext *s) {
-    declare_func_emms(AV_CPU_FLAG_MMX, void, int16_t *block);
+    declare_func(void, int16_t *block);
 
     if (check_func(s->rv34_inv_transform_dc, "rv34_inv_transform_dc")) {
         LOCAL_ALIGNED_16(int16_t, p1, [BUF_SIZE]);
-- 
2.52.0


>From d25852ad905522b52026ac8efaa6864b6a225ae9 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <[email protected]>
Date: Wed, 18 Mar 2026 11:07:22 +0100
Subject: [PATCH 2/3] tests/checkasm/rv34dsp: Don't use unnecessarily large
 buffers

RV34 uses 4x4 blocks.

Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 tests/checkasm/rv34dsp.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/tests/checkasm/rv34dsp.c b/tests/checkasm/rv34dsp.c
index 5703ba9b82..efb4ce913b 100644
--- a/tests/checkasm/rv34dsp.c
+++ b/tests/checkasm/rv34dsp.c
@@ -25,8 +25,6 @@
 
 #include "checkasm.h"
 
-#define BUF_SIZE 1024
-
 #define randomize(buf, len) \
     do { \
         for (int i = 0; i < len; i++) \
@@ -37,16 +35,16 @@ static void test_rv34_inv_transform_dc(RV34DSPContext *s) {
     declare_func(void, int16_t *block);
 
     if (check_func(s->rv34_inv_transform_dc, "rv34_inv_transform_dc")) {
-        LOCAL_ALIGNED_16(int16_t, p1, [BUF_SIZE]);
-        LOCAL_ALIGNED_16(int16_t, p2, [BUF_SIZE]);
+        DECLARE_ALIGNED_16(int16_t, p1)[4*4];
+        DECLARE_ALIGNED_16(int16_t, p2)[4*4];
 
-        randomize(p1, BUF_SIZE);
-        memcpy(p2, p1, BUF_SIZE * sizeof(*p1));
+        randomize(p1, FF_ARRAY_ELEMS(p1));
+        memcpy(p2, p1, sizeof(p1));
 
         call_ref(p1);
         call_new(p2);
 
-        if (memcmp(p1,  p2,  BUF_SIZE * sizeof (*p1)) != 0) {
+        if (memcmp(p1, p2, sizeof(p1))) {
             fail();
         }
 
@@ -60,16 +58,16 @@ static void test_rv34_idct_dc_add(RV34DSPContext *s) {
     declare_func(void, uint8_t *dst, ptrdiff_t stride, int dc);
 
     if (check_func(s->rv34_idct_dc_add, "rv34_idct_dc_add")) {
-        LOCAL_ALIGNED_16(uint8_t, p1, [BUF_SIZE]);
-        LOCAL_ALIGNED_16(uint8_t, p2, [BUF_SIZE]);
+        DECLARE_ALIGNED_16(uint8_t, p1)[4*4];
+        DECLARE_ALIGNED_16(uint8_t, p2)[4*4];
 
-        randomize(p1, BUF_SIZE);
-        memcpy(p2, p1, BUF_SIZE * sizeof(*p1));
+        randomize(p1, FF_ARRAY_ELEMS(p1));
+        memcpy(p2, p1, sizeof(p1));
 
         call_ref(p1, 4, 5);
         call_new(p2, 4, 5);
 
-        if (memcmp(p1,  p2,  BUF_SIZE * sizeof (*p1)) != 0) {
+        if (memcmp(p1, p2, sizeof(p1))) {
             fail();
         }
 
-- 
2.52.0


>From e9542bb04a4fbc04d6526a753e663d7941bf0972 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <[email protected]>
Date: Wed, 18 Mar 2026 11:37:25 +0100
Subject: [PATCH 3/3] avcodec/rv34dsp: Reduce size of chroma pixels tabs

Only two sizes exist.

Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 libavcodec/rv34dsp.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/rv34dsp.h b/libavcodec/rv34dsp.h
index c9fbd95e4e..9adf84bf26 100644
--- a/libavcodec/rv34dsp.h
+++ b/libavcodec/rv34dsp.h
@@ -57,8 +57,8 @@ typedef int (*rv40_loop_filter_strength_func)(uint8_t *src, 
ptrdiff_t stride,
 typedef struct RV34DSPContext {
     qpel_mc_func put_pixels_tab[2][16];
     qpel_mc_func avg_pixels_tab[2][16];
-    h264_chroma_mc_func put_chroma_pixels_tab[3];
-    h264_chroma_mc_func avg_chroma_pixels_tab[3];
+    h264_chroma_mc_func put_chroma_pixels_tab[2];
+    h264_chroma_mc_func avg_chroma_pixels_tab[2];
     /**
      * Biweight functions, first dimension is transform size (16/8),
      * second is whether the weight is prescaled by 1/512 to skip
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to