]> git.sesse.net Git - ffmpeg/blobdiff - libswscale/rgb2rgb_template.c
Remove duplicate *.lib from rm command.
[ffmpeg] / libswscale / rgb2rgb_template.c
index 807da6166f563c11eb0984ea071afa3a9783ee58..0dbc657ced09a90e53ddf38a5810d9b49b8f7ec0 100644 (file)
@@ -5,15 +5,29 @@
  *               Software YUV to YUV convertor
  *               Software YUV to RGB convertor
  *  Written by Nick Kurshev.
- *  palette & yuv & runtime cpu stuff by Michael (michaelni@gmx.at) (under GPL)
+ *  palette & YUV & runtime CPU stuff by Michael (michaelni@gmx.at)
  *  lot of big-endian byteorder fixes by Alex Beregszaszi
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <stddef.h>
 #include <inttypes.h> /* for __WORDSIZE */
 
-#include "asmalign.h"
-
 #ifndef __WORDSIZE
 // #warning You have misconfigured system and probably will lose performance!
 #define __WORDSIZE MP_WORDSIZE
@@ -46,8 +60,8 @@
 #define PREFETCH "#"
 #define PREFETCHW "#"
 #else
-#define PREFETCH "/nop"
-#define PREFETCHW "/nop"
+#define PREFETCH  " # nop"
+#define PREFETCHW " # nop"
 #endif
 #endif
 
 #define SFENCE "sfence"
 #else
 #define MOVNTQ "movq"
-#ifdef __APPLE__
-#define SFENCE "#"
-#else
-#define SFENCE "/nop"
-#endif
+#define SFENCE " # nop"
 #endif
 
 static inline void RENAME(rgb24to32)(const uint8_t *src,uint8_t *dst,long src_size)
@@ -343,7 +353,7 @@ static inline void RENAME(rgb32to16)(const uint8_t *src, uint8_t *dst, long src_
                "movq %3, %%mm5                 \n\t"
                "movq %4, %%mm6                 \n\t"
                "movq %5, %%mm7                 \n\t"
-               ASMALIGN16
+               ASMALIGN(4)
                "1:                             \n\t"
                PREFETCH" 32(%1)                \n\t"
                "movd   (%1), %%mm0             \n\t"
@@ -500,7 +510,7 @@ static inline void RENAME(rgb32to15)(const uint8_t *src, uint8_t *dst, long src_
                "movq %3, %%mm5                 \n\t"
                "movq %4, %%mm6                 \n\t"
                "movq %5, %%mm7                 \n\t"
-               ASMALIGN16
+               ASMALIGN(4)
                "1:                             \n\t"
                PREFETCH" 32(%1)                \n\t"
                "movd   (%1), %%mm0             \n\t"
@@ -1355,7 +1365,7 @@ static inline void RENAME(rgb32tobgr32)(const uint8_t *src, uint8_t *dst, long s
 /* TODO: unroll this loop */
        asm volatile (
                "xor %%"REG_a", %%"REG_a"       \n\t"
-               ASMALIGN16
+               ASMALIGN(4)
                "1:                             \n\t"
                PREFETCH" 32(%0, %%"REG_a")     \n\t"
                "movq (%0, %%"REG_a"), %%mm0    \n\t"
@@ -1405,7 +1415,7 @@ static inline void RENAME(rgb24tobgr24)(const uint8_t *src, uint8_t *dst, long s
                "movq "MANGLE(mask24r)", %%mm5  \n\t"
                "movq "MANGLE(mask24g)", %%mm6  \n\t"
                "movq "MANGLE(mask24b)", %%mm7  \n\t"
-               ASMALIGN16
+               ASMALIGN(4)
                "1:                             \n\t"
                PREFETCH" 32(%1, %%"REG_a")     \n\t"
                "movq   (%1, %%"REG_a"), %%mm0  \n\t" // BGR BGR BG
@@ -1475,7 +1485,7 @@ static inline void RENAME(yuvPlanartoyuy2)(const uint8_t *ysrc, const uint8_t *u
 //FIXME handle 2 lines a once (fewer prefetch, reuse some chrom, but very likely limited by mem anyway)
                asm volatile(
                        "xor %%"REG_a", %%"REG_a"       \n\t"
-                       ASMALIGN16
+                       ASMALIGN(4)
                        "1:                             \n\t"
                        PREFETCH" 32(%1, %%"REG_a", 2)  \n\t"
                        PREFETCH" 32(%2, %%"REG_a")     \n\t"
@@ -1628,7 +1638,7 @@ static inline void RENAME(yuvPlanartouyvy)(const uint8_t *ysrc, const uint8_t *u
 //FIXME handle 2 lines a once (fewer prefetch, reuse some chrom, but very likely limited by mem anyway)
                asm volatile(
                        "xor %%"REG_a", %%"REG_a"       \n\t"
-                       ASMALIGN16
+                       ASMALIGN(4)
                        "1:                             \n\t"
                        PREFETCH" 32(%1, %%"REG_a", 2)  \n\t"
                        PREFETCH" 32(%2, %%"REG_a")     \n\t"
@@ -1752,7 +1762,7 @@ static inline void RENAME(yuy2toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t
                        "xor %%"REG_a", %%"REG_a"       \n\t"
                        "pcmpeqw %%mm7, %%mm7           \n\t"
                        "psrlw $8, %%mm7                \n\t" // FF,00,FF,00...
-                       ASMALIGN16
+                       ASMALIGN(4)
                        "1:                             \n\t"
                        PREFETCH" 64(%0, %%"REG_a", 4)  \n\t"
                        "movq (%0, %%"REG_a", 4), %%mm0 \n\t" // YUYV YUYV(0)
@@ -1805,7 +1815,7 @@ static inline void RENAME(yuy2toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t
 
                asm volatile(
                        "xor %%"REG_a", %%"REG_a"       \n\t"
-                       ASMALIGN16
+                       ASMALIGN(4)
                        "1:                             \n\t"
                        PREFETCH" 64(%0, %%"REG_a", 4)  \n\t"
                        "movq (%0, %%"REG_a", 4), %%mm0 \n\t" // YUYV YUYV(0)
@@ -1990,7 +2000,7 @@ static inline void RENAME(uyvytoyv12)(const uint8_t *src, uint8_t *ydst, uint8_t
                        "xorl %%eax, %%eax              \n\t"
                        "pcmpeqw %%mm7, %%mm7           \n\t"
                        "psrlw $8, %%mm7                \n\t" // FF,00,FF,00...
-                       ASMALIGN16
+                       ASMALIGN(4)
                        "1:                             \n\t"
                        PREFETCH" 64(%0, %%eax, 4)      \n\t"
                        "movq (%0, %%eax, 4), %%mm0     \n\t" // UYVY UYVY(0)
@@ -2043,7 +2053,7 @@ static inline void RENAME(uyvytoyv12)(const uint8_t *src, uint8_t *ydst, uint8_t
 
                asm volatile(
                        "xorl %%eax, %%eax              \n\t"
-                       ASMALIGN16
+                       ASMALIGN(4)
                        "1:                             \n\t"
                        PREFETCH" 64(%0, %%eax, 4)      \n\t"
                        "movq (%0, %%eax, 4), %%mm0     \n\t" // YUYV YUYV(0)
@@ -2120,16 +2130,16 @@ static inline void RENAME(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_
                                "movq "MANGLE(bgr2YCoeff)", %%mm6               \n\t"
                                "movq "MANGLE(w1111)", %%mm5            \n\t"
                                "pxor %%mm7, %%mm7              \n\t"
-                               "lea (%%"REG_a", %%"REG_a", 2), %%"REG_b"\n\t"
-                               ASMALIGN16
+                               "lea (%%"REG_a", %%"REG_a", 2), %%"REG_d"\n\t"
+                               ASMALIGN(4)
                                "1:                             \n\t"
-                               PREFETCH" 64(%0, %%"REG_b")     \n\t"
-                               "movd (%0, %%"REG_b"), %%mm0    \n\t"
-                               "movd 3(%0, %%"REG_b"), %%mm1   \n\t"
+                               PREFETCH" 64(%0, %%"REG_d")     \n\t"
+                               "movd (%0, %%"REG_d"), %%mm0    \n\t"
+                               "movd 3(%0, %%"REG_d"), %%mm1   \n\t"
                                "punpcklbw %%mm7, %%mm0         \n\t"
                                "punpcklbw %%mm7, %%mm1         \n\t"
-                               "movd 6(%0, %%"REG_b"), %%mm2   \n\t"
-                               "movd 9(%0, %%"REG_b"), %%mm3   \n\t"
+                               "movd 6(%0, %%"REG_d"), %%mm2   \n\t"
+                               "movd 9(%0, %%"REG_d"), %%mm3   \n\t"
                                "punpcklbw %%mm7, %%mm2         \n\t"
                                "punpcklbw %%mm7, %%mm3         \n\t"
                                "pmaddwd %%mm6, %%mm0           \n\t"
@@ -2149,12 +2159,12 @@ static inline void RENAME(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_
                                "packssdw %%mm2, %%mm0          \n\t"
                                "psraw $7, %%mm0                \n\t"
 
-                               "movd 12(%0, %%"REG_b"), %%mm4  \n\t"
-                               "movd 15(%0, %%"REG_b"), %%mm1  \n\t"
+                               "movd 12(%0, %%"REG_d"), %%mm4  \n\t"
+                               "movd 15(%0, %%"REG_d"), %%mm1  \n\t"
                                "punpcklbw %%mm7, %%mm4         \n\t"
                                "punpcklbw %%mm7, %%mm1         \n\t"
-                               "movd 18(%0, %%"REG_b"), %%mm2  \n\t"
-                               "movd 21(%0, %%"REG_b"), %%mm3  \n\t"
+                               "movd 18(%0, %%"REG_d"), %%mm2  \n\t"
+                               "movd 21(%0, %%"REG_d"), %%mm3  \n\t"
                                "punpcklbw %%mm7, %%mm2         \n\t"
                                "punpcklbw %%mm7, %%mm3         \n\t"
                                "pmaddwd %%mm6, %%mm4           \n\t"
@@ -2171,7 +2181,7 @@ static inline void RENAME(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_
                                "packssdw %%mm3, %%mm2          \n\t"
                                "pmaddwd %%mm5, %%mm4           \n\t"
                                "pmaddwd %%mm5, %%mm2           \n\t"
-                               "add $24, %%"REG_b"             \n\t"
+                               "add $24, %%"REG_d"             \n\t"
                                "packssdw %%mm2, %%mm4          \n\t"
                                "psraw $7, %%mm4                \n\t"
 
@@ -2182,7 +2192,7 @@ static inline void RENAME(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_
                                "add $8, %%"REG_a"              \n\t"
                                " js 1b                         \n\t"
                                : : "r" (src+width*3), "r" (ydst+width), "g" (-width)
-                               : "%"REG_a, "%"REG_b
+                               : "%"REG_a, "%"REG_d
                        );
                        ydst += lumStride;
                        src  += srcStride;
@@ -2193,17 +2203,17 @@ static inline void RENAME(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_
                        "movq "MANGLE(w1111)", %%mm5            \n\t"
                        "movq "MANGLE(bgr2UCoeff)", %%mm6               \n\t"
                        "pxor %%mm7, %%mm7              \n\t"
-                       "lea (%%"REG_a", %%"REG_a", 2), %%"REG_b"\n\t"
-                       "add %%"REG_b", %%"REG_b"       \n\t"
-                       ASMALIGN16
+                       "lea (%%"REG_a", %%"REG_a", 2), %%"REG_d"\n\t"
+                       "add %%"REG_d", %%"REG_d"       \n\t"
+                       ASMALIGN(4)
                        "1:                             \n\t"
-                       PREFETCH" 64(%0, %%"REG_b")     \n\t"
-                       PREFETCH" 64(%1, %%"REG_b")     \n\t"
+                       PREFETCH" 64(%0, %%"REG_d")     \n\t"
+                       PREFETCH" 64(%1, %%"REG_d")     \n\t"
 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW)
-                       "movq (%0, %%"REG_b"), %%mm0    \n\t"
-                       "movq (%1, %%"REG_b"), %%mm1    \n\t"
-                       "movq 6(%0, %%"REG_b"), %%mm2   \n\t"
-                       "movq 6(%1, %%"REG_b"), %%mm3   \n\t"
+                       "movq (%0, %%"REG_d"), %%mm0    \n\t"
+                       "movq (%1, %%"REG_d"), %%mm1    \n\t"
+                       "movq 6(%0, %%"REG_d"), %%mm2   \n\t"
+                       "movq 6(%1, %%"REG_d"), %%mm3   \n\t"
                        PAVGB" %%mm1, %%mm0             \n\t"
                        PAVGB" %%mm3, %%mm2             \n\t"
                        "movq %%mm0, %%mm1              \n\t"
@@ -2215,10 +2225,10 @@ static inline void RENAME(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_
                        "punpcklbw %%mm7, %%mm0         \n\t"
                        "punpcklbw %%mm7, %%mm2         \n\t"
 #else
-                       "movd (%0, %%"REG_b"), %%mm0    \n\t"
-                       "movd (%1, %%"REG_b"), %%mm1    \n\t"
-                       "movd 3(%0, %%"REG_b"), %%mm2   \n\t"
-                       "movd 3(%1, %%"REG_b"), %%mm3   \n\t"
+                       "movd (%0, %%"REG_d"), %%mm0    \n\t"
+                       "movd (%1, %%"REG_d"), %%mm1    \n\t"
+                       "movd 3(%0, %%"REG_d"), %%mm2   \n\t"
+                       "movd 3(%1, %%"REG_d"), %%mm3   \n\t"
                        "punpcklbw %%mm7, %%mm0         \n\t"
                        "punpcklbw %%mm7, %%mm1         \n\t"
                        "punpcklbw %%mm7, %%mm2         \n\t"
@@ -2226,10 +2236,10 @@ static inline void RENAME(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_
                        "paddw %%mm1, %%mm0             \n\t"
                        "paddw %%mm3, %%mm2             \n\t"
                        "paddw %%mm2, %%mm0             \n\t"
-                       "movd 6(%0, %%"REG_b"), %%mm4   \n\t"
-                       "movd 6(%1, %%"REG_b"), %%mm1   \n\t"
-                       "movd 9(%0, %%"REG_b"), %%mm2   \n\t"
-                       "movd 9(%1, %%"REG_b"), %%mm3   \n\t"
+                       "movd 6(%0, %%"REG_d"), %%mm4   \n\t"
+                       "movd 6(%1, %%"REG_d"), %%mm1   \n\t"
+                       "movd 9(%0, %%"REG_d"), %%mm2   \n\t"
+                       "movd 9(%1, %%"REG_d"), %%mm3   \n\t"
                        "punpcklbw %%mm7, %%mm4         \n\t"
                        "punpcklbw %%mm7, %%mm1         \n\t"
                        "punpcklbw %%mm7, %%mm2         \n\t"
@@ -2261,10 +2271,10 @@ static inline void RENAME(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_
                        "psraw $7, %%mm0                \n\t"
 
 #if defined (HAVE_MMX2) || defined (HAVE_3DNOW)
-                       "movq 12(%0, %%"REG_b"), %%mm4  \n\t"
-                       "movq 12(%1, %%"REG_b"), %%mm1  \n\t"
-                       "movq 18(%0, %%"REG_b"), %%mm2  \n\t"
-                       "movq 18(%1, %%"REG_b"), %%mm3  \n\t"
+                       "movq 12(%0, %%"REG_d"), %%mm4  \n\t"
+                       "movq 12(%1, %%"REG_d"), %%mm1  \n\t"
+                       "movq 18(%0, %%"REG_d"), %%mm2  \n\t"
+                       "movq 18(%1, %%"REG_d"), %%mm3  \n\t"
                        PAVGB" %%mm1, %%mm4             \n\t"
                        PAVGB" %%mm3, %%mm2             \n\t"
                        "movq %%mm4, %%mm1              \n\t"
@@ -2276,10 +2286,10 @@ static inline void RENAME(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_
                        "punpcklbw %%mm7, %%mm4         \n\t"
                        "punpcklbw %%mm7, %%mm2         \n\t"
 #else
-                       "movd 12(%0, %%"REG_b"), %%mm4  \n\t"
-                       "movd 12(%1, %%"REG_b"), %%mm1  \n\t"
-                       "movd 15(%0, %%"REG_b"), %%mm2  \n\t"
-                       "movd 15(%1, %%"REG_b"), %%mm3  \n\t"
+                       "movd 12(%0, %%"REG_d"), %%mm4  \n\t"
+                       "movd 12(%1, %%"REG_d"), %%mm1  \n\t"
+                       "movd 15(%0, %%"REG_d"), %%mm2  \n\t"
+                       "movd 15(%1, %%"REG_d"), %%mm3  \n\t"
                        "punpcklbw %%mm7, %%mm4         \n\t"
                        "punpcklbw %%mm7, %%mm1         \n\t"
                        "punpcklbw %%mm7, %%mm2         \n\t"
@@ -2287,10 +2297,10 @@ static inline void RENAME(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_
                        "paddw %%mm1, %%mm4             \n\t"
                        "paddw %%mm3, %%mm2             \n\t"
                        "paddw %%mm2, %%mm4             \n\t"
-                       "movd 18(%0, %%"REG_b"), %%mm5  \n\t"
-                       "movd 18(%1, %%"REG_b"), %%mm1  \n\t"
-                       "movd 21(%0, %%"REG_b"), %%mm2  \n\t"
-                       "movd 21(%1, %%"REG_b"), %%mm3  \n\t"
+                       "movd 18(%0, %%"REG_d"), %%mm5  \n\t"
+                       "movd 18(%1, %%"REG_d"), %%mm1  \n\t"
+                       "movd 21(%0, %%"REG_d"), %%mm2  \n\t"
+                       "movd 21(%1, %%"REG_d"), %%mm3  \n\t"
                        "punpcklbw %%mm7, %%mm5         \n\t"
                        "punpcklbw %%mm7, %%mm1         \n\t"
                        "punpcklbw %%mm7, %%mm2         \n\t"
@@ -2319,7 +2329,7 @@ static inline void RENAME(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_
                        "packssdw %%mm3, %%mm1          \n\t"
                        "pmaddwd %%mm5, %%mm4           \n\t"
                        "pmaddwd %%mm5, %%mm1           \n\t"
-                       "add $24, %%"REG_b"             \n\t"
+                       "add $24, %%"REG_d"             \n\t"
                        "packssdw %%mm1, %%mm4          \n\t" // V3 V2 U3 U2
                        "psraw $7, %%mm4                \n\t"
 
@@ -2334,7 +2344,7 @@ static inline void RENAME(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_
                        "add $4, %%"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)
-                       : "%"REG_a, "%"REG_b
+                       : "%"REG_a, "%"REG_d
                );
 
                udst += chromStride;