Patches attached
From 0c6e52fee3a2d8335e2b31f180811f2c02a89603 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinha...@outlook.com>
Date: Sun, 12 Jan 2025 19:43:12 +0100
Subject: [PATCH 1/2] swscale/x86/swscale: Move some constants to rgb2rgb.c

ff_w1111 and ff_bgr2(Y|UV)Offset are only used there
(and only on x86-32 since caaec2ea957290941eecfe5d87baf5c0a500b450).
Also make them static.

Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com>
---
 libswscale/x86/rgb2rgb.c | 20 ++++++++++----------
 libswscale/x86/swscale.c |  5 -----
 2 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/libswscale/x86/rgb2rgb.c b/libswscale/x86/rgb2rgb.c
index 6790551a38..6428615adf 100644
--- a/libswscale/x86/rgb2rgb.c
+++ b/libswscale/x86/rgb2rgb.c
@@ -70,10 +70,6 @@ DECLARE_ASM_CONST(8, uint64_t, mul15_mid)    = 0x4200420042004200ULL;
 DECLARE_ASM_CONST(8, uint64_t, mul15_hi)     = 0x0210021002100210ULL;
 DECLARE_ASM_CONST(8, uint64_t, mul16_mid)    = 0x2080208020802080ULL;
 
-DECLARE_ALIGNED(8, extern const uint64_t, ff_bgr2YOffset);
-DECLARE_ALIGNED(8, extern const uint64_t, ff_w1111);
-DECLARE_ALIGNED(8, extern const uint64_t, ff_bgr2UVOffset);
-
 #define BY ((int)( 0.098*(1<<RGB2YUV_SHIFT)+0.5))
 #define BV ((int)(-0.071*(1<<RGB2YUV_SHIFT)+0.5))
 #define BU ((int)( 0.439*(1<<RGB2YUV_SHIFT)+0.5))
@@ -1481,6 +1477,10 @@ static inline void planar2x_mmxext(const uint8_t *src, uint8_t *dst, int srcWidt
  * FIXME: Write HQ version.
  */
 #if ARCH_X86_32 && HAVE_7REGS
+DECLARE_ASM_CONST(8, uint64_t, bgr2YOffset)  = 0x1010101010101010ULL;
+DECLARE_ASM_CONST(8, uint64_t, bgr2UVOffset) = 0x8080808080808080ULL;
+DECLARE_ASM_CONST(8, uint64_t, w1111)        = 0x0001000100010001ULL;
+
 static inline void rgb24toyv12_mmxext(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
                                        int width, int height,
                                        int lumStride, int chromStride, int srcStride,
@@ -1506,7 +1506,7 @@ static inline void rgb24toyv12_mmxext(const uint8_t *src, uint8_t *ydst, uint8_t
             __asm__ volatile(
                 "mov                        %2, %%"FF_REG_a"\n\t"
                 "movq          "BGR2Y_IDX"(%3), %%mm6       \n\t"
-                "movq       "MANGLE(ff_w1111)", %%mm5       \n\t"
+                "movq          "MANGLE(w1111)", %%mm5       \n\t"
                 "pxor                    %%mm7, %%mm7       \n\t"
                 "lea (%%"FF_REG_a", %%"FF_REG_a", 2), %%"FF_REG_d" \n\t"
                 ".p2align                    4              \n\t"
@@ -1560,13 +1560,13 @@ static inline void rgb24toyv12_mmxext(const uint8_t *src, uint8_t *ydst, uint8_t
                 "psraw                      $7, %%mm4       \n\t"
 
                 "packuswb                %%mm4, %%mm0       \n\t"
-                "paddusb "MANGLE(ff_bgr2YOffset)", %%mm0    \n\t"
+                "paddusb "MANGLE(bgr2YOffset)", %%mm0       \n\t"
 
                 MOVNTQ"                  %%mm0, (%1, %%"FF_REG_a") \n\t"
                 "add                        $8,      %%"FF_REG_a"  \n\t"
                 " js                        1b                     \n\t"
                 : : "r" (src+width*3), "r" (ydst+width), "g" ((x86_reg)-width), "r"(rgb2yuv)
-                  NAMED_CONSTRAINTS_ADD(ff_w1111,ff_bgr2YOffset)
+                  NAMED_CONSTRAINTS_ADD(w1111,bgr2YOffset)
                 : "%"FF_REG_a, "%"FF_REG_d
             );
             ydst += lumStride;
@@ -1575,7 +1575,7 @@ static inline void rgb24toyv12_mmxext(const uint8_t *src, uint8_t *ydst, uint8_t
         src -= srcStride*2;
         __asm__ volatile(
             "mov                        %4, %%"FF_REG_a"\n\t"
-            "movq       "MANGLE(ff_w1111)", %%mm5       \n\t"
+            "movq          "MANGLE(w1111)", %%mm5       \n\t"
             "movq          "BGR2U_IDX"(%5), %%mm6       \n\t"
             "pxor                    %%mm7, %%mm7       \n\t"
             "lea (%%"FF_REG_a", %%"FF_REG_a", 2), %%"FF_REG_d" \n\t"
@@ -1653,14 +1653,14 @@ static inline void rgb24toyv12_mmxext(const uint8_t *src, uint8_t *ydst, uint8_t
             "punpckldq               %%mm4, %%mm0           \n\t"
             "punpckhdq               %%mm4, %%mm1           \n\t"
             "packsswb                %%mm1, %%mm0           \n\t"
-            "paddb "MANGLE(ff_bgr2UVOffset)", %%mm0         \n\t"
+            "paddb  "MANGLE(bgr2UVOffset)", %%mm0           \n\t"
             "movd                    %%mm0, (%2, %%"FF_REG_a") \n\t"
             "punpckhdq               %%mm0, %%mm0              \n\t"
             "movd                    %%mm0, (%3, %%"FF_REG_a") \n\t"
             "add                        $4, %%"FF_REG_a"       \n\t"
             " js                        1b              \n\t"
             : : "r" (src+chromWidth*6), "r" (src+srcStride+chromWidth*6), "r" (udst+chromWidth), "r" (vdst+chromWidth), "g" (-chromWidth), "r"(rgb2yuv)
-              NAMED_CONSTRAINTS_ADD(ff_w1111,ff_bgr2UVOffset)
+              NAMED_CONSTRAINTS_ADD(w1111,bgr2UVOffset)
             : "%"FF_REG_a, "%"FF_REG_d
         );
 
diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c
index a7985a3b01..ea82fa81a9 100644
--- a/libswscale/x86/swscale.c
+++ b/libswscale/x86/swscale.c
@@ -47,11 +47,6 @@ DECLARE_ASM_ALIGNED(8, const uint64_t, ff_M24A)         = 0x00FF0000FF0000FFLL;
 DECLARE_ASM_ALIGNED(8, const uint64_t, ff_M24B)         = 0xFF0000FF0000FF00LL;
 DECLARE_ASM_ALIGNED(8, const uint64_t, ff_M24C)         = 0x0000FF0000FF0000LL;
 
-DECLARE_ASM_ALIGNED(8, const uint64_t, ff_bgr2YOffset)  = 0x1010101010101010ULL;
-DECLARE_ASM_ALIGNED(8, const uint64_t, ff_bgr2UVOffset) = 0x8080808080808080ULL;
-DECLARE_ASM_ALIGNED(8, const uint64_t, ff_w1111)        = 0x0001000100010001ULL;
-
-
 // MMXEXT versions
 #if HAVE_MMXEXT_INLINE
 #undef RENAME
-- 
2.45.2

From 5970c1caa085819a8a659e564a0aa7b6ab536c22 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinha...@outlook.com>
Date: Sun, 12 Jan 2025 19:59:08 +0100
Subject: [PATCH 2/2] swscale/x86/swscale: Make M24 variables static

Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com>
---
 libswscale/x86/swscale.c          |  6 +++---
 libswscale/x86/swscale_template.c | 18 +++++++++---------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c
index ea82fa81a9..e9ad2a1e95 100644
--- a/libswscale/x86/swscale.c
+++ b/libswscale/x86/swscale.c
@@ -43,9 +43,9 @@ const DECLARE_ALIGNED(8, uint64_t, ff_dither8)[2] = {
 DECLARE_ASM_CONST(8, uint64_t, bF8)=       0xF8F8F8F8F8F8F8F8LL;
 DECLARE_ASM_CONST(8, uint64_t, bFC)=       0xFCFCFCFCFCFCFCFCLL;
 
-DECLARE_ASM_ALIGNED(8, const uint64_t, ff_M24A)         = 0x00FF0000FF0000FFLL;
-DECLARE_ASM_ALIGNED(8, const uint64_t, ff_M24B)         = 0xFF0000FF0000FF00LL;
-DECLARE_ASM_ALIGNED(8, const uint64_t, ff_M24C)         = 0x0000FF0000FF0000LL;
+DECLARE_ASM_CONST(8, uint64_t, M24A) = 0x00FF0000FF0000FFLL;
+DECLARE_ASM_CONST(8, uint64_t, M24B) = 0xFF0000FF0000FF00LL;
+DECLARE_ASM_CONST(8, uint64_t, M24C) = 0x0000FF0000FF0000LL;
 
 // MMXEXT versions
 #if HAVE_MMXEXT_INLINE
diff --git a/libswscale/x86/swscale_template.c b/libswscale/x86/swscale_template.c
index e09310ab91..cdf8a6105f 100644
--- a/libswscale/x86/swscale_template.c
+++ b/libswscale/x86/swscale_template.c
@@ -541,8 +541,8 @@ static void RENAME(yuv2rgb555_X)(SwsInternal *c, const int16_t *lumFilter,
 
 #define WRITEBGR24MMXEXT(dst, dstw, index) \
     /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */\
-    "movq "MANGLE(ff_M24A)", %%mm0 \n\t"\
-    "movq "MANGLE(ff_M24C)", %%mm7 \n\t"\
+    "movq "MANGLE(M24A)", %%mm0 \n\t"\
+    "movq "MANGLE(M24C)", %%mm7 \n\t"\
     "pshufw $0x50, %%mm2, %%mm1 \n\t" /* B3 B2 B3 B2  B1 B0 B1 B0 */\
     "pshufw $0x50, %%mm4, %%mm3 \n\t" /* G3 G2 G3 G2  G1 G0 G1 G0 */\
     "pshufw $0x00, %%mm5, %%mm6 \n\t" /* R1 R0 R1 R0  R1 R0 R1 R0 */\
@@ -561,7 +561,7 @@ static void RENAME(yuv2rgb555_X)(SwsInternal *c, const int16_t *lumFilter,
     "pshufw $0x55, %%mm4, %%mm3 \n\t" /* G4 G3 G4 G3  G4 G3 G4 G3 */\
     "pshufw $0xA5, %%mm5, %%mm6 \n\t" /* R5 R4 R5 R4  R3 R2 R3 R2 */\
 \
-    "pand "MANGLE(ff_M24B)", %%mm1 \n\t" /* B5       B4        B3    */\
+    "pand "MANGLE(M24B)", %%mm1 \n\t" /* B5       B4        B3    */\
     "pand   %%mm7, %%mm3        \n\t" /*       G4        G3       */\
     "pand   %%mm0, %%mm6        \n\t" /*    R4        R3       R2 */\
 \
@@ -575,7 +575,7 @@ static void RENAME(yuv2rgb555_X)(SwsInternal *c, const int16_t *lumFilter,
 \
     "pand   %%mm7, %%mm1        \n\t" /*       B7        B6       */\
     "pand   %%mm0, %%mm3        \n\t" /*    G7        G6       G5 */\
-    "pand "MANGLE(ff_M24B)", %%mm6 \n\t" /* R7       R6        R5    */\
+    "pand "MANGLE(M24B)", %%mm6 \n\t" /* R7       R6        R5    */\
 \
     "por    %%mm1, %%mm3        \n\t"\
     "por    %%mm3, %%mm6        \n\t"\
@@ -611,7 +611,7 @@ static void RENAME(yuv2bgr24_X_ar)(SwsInternal *c, const int16_t *lumFilter,
     :: "r" (&c->redDither),
        "m" (dummy), "m" (dummy), "m" (dummy),
        "r" (dest), "m" (dstW_reg), "m"(uv_off)
-       NAMED_CONSTRAINTS_ADD(ff_M24A,ff_M24C,ff_M24B)
+       NAMED_CONSTRAINTS_ADD(M24A,M24C,M24B)
     : "%"FF_REG_a, "%"FF_REG_c, "%"FF_REG_d, "%"FF_REG_S
     );
 }
@@ -636,7 +636,7 @@ static void RENAME(yuv2bgr24_X)(SwsInternal *c, const int16_t *lumFilter,
     :: "r" (&c->redDither),
        "m" (dummy), "m" (dummy), "m" (dummy),
        "r" (dest),  "m" (dstW_reg), "m"(uv_off)
-       NAMED_CONSTRAINTS_ADD(ff_M24A,ff_M24C,ff_M24B)
+       NAMED_CONSTRAINTS_ADD(M24A,M24C,M24B)
     : "%"FF_REG_a, "%"FF_REG_c, "%"FF_REG_d, "%"FF_REG_S
     );
 }
@@ -864,7 +864,7 @@ static void RENAME(yuv2bgr24_2)(SwsInternal *c, const int16_t *buf[2],
         "mov "ESP_OFFSET"(%5), %%"FF_REG_b"     \n\t"
         :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
            "a" (&c->redDither)
-           NAMED_CONSTRAINTS_ADD(ff_M24A,ff_M24C,ff_M24B)
+           NAMED_CONSTRAINTS_ADD(M24A,M24C,M24B)
     );
 }
 
@@ -1191,7 +1191,7 @@ static void RENAME(yuv2bgr24_1)(SwsInternal *c, const int16_t *buf0,
             "mov "ESP_OFFSET"(%5), %%"FF_REG_b"     \n\t"
             :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
                "a" (&c->redDither)
-               NAMED_CONSTRAINTS_ADD(ff_M24A,ff_M24C,ff_M24B)
+               NAMED_CONSTRAINTS_ADD(M24A,M24C,M24B)
         );
     } else {
         const int16_t *ubuf1 = ubuf[1];
@@ -1206,7 +1206,7 @@ static void RENAME(yuv2bgr24_1)(SwsInternal *c, const int16_t *buf0,
             "mov "ESP_OFFSET"(%5), %%"FF_REG_b"     \n\t"
             :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
                "a" (&c->redDither)
-               NAMED_CONSTRAINTS_ADD(ff_M24A,ff_M24C,ff_M24B)
+               NAMED_CONSTRAINTS_ADD(M24A,M24C,M24B)
         );
     }
 }
-- 
2.45.2

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to