[FFmpeg-devel] [PATCH]Remove *5Dither from libswscale

Carl Eugen Hoyos cehoyos
Sat Oct 4 21:10:34 CEST 2008


Hi!

Attached patch removes b5Dither, g5Dither and r5Dither from libswscale.
Output of swscale-example after patch with both icc and gcc matches gcc's 
output without patch.

Please comment, Carl Eugen
-------------- next part --------------
Index: libswscale/yuv2rgb.c
===================================================================
--- libswscale/yuv2rgb.c	(Revision 27715)
+++ libswscale/yuv2rgb.c	(Arbeitskopie)
@@ -54,12 +54,6 @@
 DECLARE_ASM_CONST(8, uint64_t, mmx_redmask) = 0xf8f8f8f8f8f8f8f8ULL;
 DECLARE_ASM_CONST(8, uint64_t, mmx_grnmask) = 0xfcfcfcfcfcfcfcfcULL;
 
-// The volatile is required because gcc otherwise optimizes some writes away
-// not knowing that these are read in the ASM block.
-static volatile uint64_t attribute_used __attribute__((aligned(8))) b5Dither;
-static volatile uint64_t attribute_used __attribute__((aligned(8))) g5Dither;
-static volatile uint64_t attribute_used __attribute__((aligned(8))) r5Dither;
-
 #undef HAVE_MMX
 
 //MMX versions
Index: libswscale/swscale.c
===================================================================
--- libswscale/swscale.c	(Revision 27715)
+++ libswscale/swscale.c	(Arbeitskopie)
@@ -205,10 +205,6 @@
 DECLARE_ASM_CONST(8, uint64_t, bm11111000)=0xFFFFFFFFFF000000LL;
 DECLARE_ASM_CONST(8, uint64_t, bm01010101)=0x00FF00FF00FF00FFLL;
 
-static volatile uint64_t attribute_used __attribute__((aligned(8))) b5Dither;
-static volatile uint64_t attribute_used __attribute__((aligned(8))) g5Dither;
-static volatile uint64_t attribute_used __attribute__((aligned(8))) r5Dither;
-
 const DECLARE_ALIGNED(8, uint64_t, ff_dither4[2]) = {
         0x0103010301030103LL,
         0x0200020002000200LL,};
Index: libswscale/yuv2rgb_template.c
===================================================================
--- libswscale/yuv2rgb_template.c	(Revision 27715)
+++ libswscale/yuv2rgb_template.c	(Arbeitskopie)
@@ -134,7 +134,7 @@
     if(h_size*2 > FFABS(dstStride[0])) h_size-=8;
 
     asm volatile ("pxor %mm4, %mm4;" /* zero mm4 */ );
-    //printf("%X %X %X %X %X %X %X %X %X %X\n", (int)&c->redDither, (int)&b5Dither, (int)src[0], (int)src[1], (int)src[2], (int)dst[0],
+    //printf("%X %X %X %X %X %X %X %X %X %X\n", (int)&c->redDither, (int)&c->blueDither, (int)src[0], (int)src[1], (int)src[2], (int)dst[0],
     //srcStride[0],srcStride[1],srcStride[2],dstStride[0]);
     for (y= 0; y<srcSliceH; y++ ) {
         uint8_t *image = dst[0] + (y+srcSliceY)*dstStride[0];
@@ -143,9 +143,9 @@
         uint8_t *pv = src[2] + (y>>1)*srcStride[2];
         long index= -h_size/2;
 
-        b5Dither= ff_dither8[y&1];
-        g5Dither= ff_dither4[y&1];
-        r5Dither= ff_dither8[(y+1)&1];
+        c->blueDither= ff_dither8[y&1];
+        c->greenDither= ff_dither4[y&1];
+        c->redDither= ff_dither8[(y+1)&1];
         /* This MMX assembly code deals with a SINGLE scan line at a time,
          * it converts 8 pixels in each iteration. */
         asm volatile (
@@ -164,9 +164,9 @@
 YUV2RGB
 
 #ifdef DITHER1XBPP
-        "paddusb "MANGLE(b5Dither)", %%mm0;"
-        "paddusb "MANGLE(g5Dither)", %%mm2;"
-        "paddusb "MANGLE(r5Dither)", %%mm1;"
+        "paddusb "BLUE_DITHER"(%4), %%mm0;"
+        "paddusb "GREEN_DITHER"(%4), %%mm2;"
+        "paddusb "RED_DITHER"(%4), %%mm1;"
 #endif
         /* mask unneeded bits off */
         "pand "MANGLE(mmx_redmask)", %%mm0;" /* b7b6b5b4 b3_0_0_0 b7b6b5b4 b3_0_0_0 */
@@ -228,7 +228,7 @@
     if(h_size*2 > FFABS(dstStride[0])) h_size-=8;
 
     asm volatile ("pxor %mm4, %mm4;" /* zero mm4 */ );
-    //printf("%X %X %X %X %X %X %X %X %X %X\n", (int)&c->redDither, (int)&b5Dither, (int)src[0], (int)src[1], (int)src[2], (int)dst[0],
+    //printf("%X %X %X %X %X %X %X %X %X %X\n", (int)&c->redDither, (int)&c->blueDither, (int)src[0], (int)src[1], (int)src[2], (int)dst[0],
     //srcStride[0],srcStride[1],srcStride[2],dstStride[0]);
     for (y= 0; y<srcSliceH; y++ ) {
         uint8_t *image = dst[0] + (y+srcSliceY)*dstStride[0];
@@ -237,9 +237,9 @@
         uint8_t *pv = src[2] + (y>>1)*srcStride[2];
         long index= -h_size/2;
 
-        b5Dither= ff_dither8[y&1];
-        g5Dither= ff_dither8[y&1];
-        r5Dither= ff_dither8[(y+1)&1];
+        c->blueDither= ff_dither8[y&1];
+        c->greenDither= ff_dither8[y&1];
+        c->redDither= ff_dither8[(y+1)&1];
         /* This MMX assembly code deals with a SINGLE scan line at a time,
          * it converts 8 pixels in each iteration. */
         asm volatile (
@@ -252,9 +252,9 @@
 YUV2RGB
 
 #ifdef DITHER1XBPP
-        "paddusb "MANGLE(b5Dither)", %%mm0  \n\t"
-        "paddusb "MANGLE(g5Dither)", %%mm2  \n\t"
-        "paddusb "MANGLE(r5Dither)", %%mm1  \n\t"
+        "paddusb "BLUE_DITHER"(%4), %%mm0  \n\t"
+        "paddusb "GREEN_DITHER"(%4), %%mm2  \n\t"
+        "paddusb "RED_DITHER"(%4), %%mm1  \n\t"
 #endif
 
         /* mask unneeded bits off */
Index: libswscale/swscale_template.c
===================================================================
--- libswscale/swscale_template.c	(Revision 27715)
+++ libswscale/swscale_template.c	(Arbeitskopie)
@@ -1091,9 +1091,9 @@
                 YSCALEYUV2RGBX
                 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
 #ifdef DITHER1XBPP
-                "paddusb "MANGLE(b5Dither)", %%mm2\n\t"
-                "paddusb "MANGLE(g5Dither)", %%mm4\n\t"
-                "paddusb "MANGLE(r5Dither)", %%mm5\n\t"
+                "paddusb "BLUE_DITHER"(%0), %%mm2\n\t"
+                "paddusb "GREEN_DITHER"(%0), %%mm4\n\t"
+                "paddusb "RED_DITHER"(%0), %%mm5\n\t"
 #endif
 
                 WRITERGB15(%4, %5, %%REGa)
@@ -1104,9 +1104,9 @@
                 YSCALEYUV2RGBX
                 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
 #ifdef DITHER1XBPP
-                "paddusb "MANGLE(b5Dither)", %%mm2\n\t"
-                "paddusb "MANGLE(g5Dither)", %%mm4\n\t"
-                "paddusb "MANGLE(r5Dither)", %%mm5\n\t"
+                "paddusb "BLUE_DITHER"(%0), %%mm2\n\t"
+                "paddusb "GREEN_DITHER"(%0), %%mm4\n\t"
+                "paddusb "RED_DITHER"(%0), %%mm5\n\t"
 #endif
 
                 WRITERGB16(%4, %5, %%REGa)
@@ -1151,9 +1151,9 @@
                 YSCALEYUV2RGBX
                 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
 #ifdef DITHER1XBPP
-                "paddusb "MANGLE(b5Dither)", %%mm2  \n\t"
-                "paddusb "MANGLE(g5Dither)", %%mm4  \n\t"
-                "paddusb "MANGLE(r5Dither)", %%mm5  \n\t"
+                "paddusb "BLUE_DITHER"(%0), %%mm2  \n\t"
+                "paddusb "GREEN_DITHER"(%0), %%mm4  \n\t"
+                "paddusb "RED_DITHER"(%0), %%mm5  \n\t"
 #endif
 
                 WRITERGB15(%4, %5, %%REGa)
@@ -1164,9 +1164,9 @@
                 YSCALEYUV2RGBX
                 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
 #ifdef DITHER1XBPP
-                "paddusb "MANGLE(b5Dither)", %%mm2  \n\t"
-                "paddusb "MANGLE(g5Dither)", %%mm4  \n\t"
-                "paddusb "MANGLE(r5Dither)", %%mm5  \n\t"
+                "paddusb "BLUE_DITHER"(%0), %%mm2  \n\t"
+                "paddusb "GREEN_DITHER"(%0), %%mm4  \n\t"
+                "paddusb "RED_DITHER"(%0), %%mm5  \n\t"
 #endif
 
                 WRITERGB16(%4, %5, %%REGa)
@@ -1468,9 +1468,9 @@
                 YSCALEYUV2RGB(%%REGBP, %5)
                 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
 #ifdef DITHER1XBPP
-                "paddusb "MANGLE(b5Dither)", %%mm2      \n\t"
-                "paddusb "MANGLE(g5Dither)", %%mm4      \n\t"
-                "paddusb "MANGLE(r5Dither)", %%mm5      \n\t"
+                "paddusb "BLUE_DITHER"(%5), %%mm2      \n\t"
+                "paddusb "GREEN_DITHER"(%5), %%mm4      \n\t"
+                "paddusb "RED_DITHER"(%5), %%mm5      \n\t"
 #endif
 
                 WRITERGB15(%%REGb, 8280(%5), %%REGBP)
@@ -1489,9 +1489,9 @@
                 YSCALEYUV2RGB(%%REGBP, %5)
                 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
 #ifdef DITHER1XBPP
-                "paddusb "MANGLE(b5Dither)", %%mm2      \n\t"
-                "paddusb "MANGLE(g5Dither)", %%mm4      \n\t"
-                "paddusb "MANGLE(r5Dither)", %%mm5      \n\t"
+                "paddusb "BLUE_DITHER"(%5), %%mm2      \n\t"
+                "paddusb "GREEN_DITHER"(%5), %%mm4      \n\t"
+                "paddusb "RED_DITHER"(%5), %%mm5      \n\t"
 #endif
 
                 WRITERGB16(%%REGb, 8280(%5), %%REGBP)
@@ -1581,9 +1581,9 @@
                 YSCALEYUV2RGB1(%%REGBP, %5)
                 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
 #ifdef DITHER1XBPP
-                "paddusb "MANGLE(b5Dither)", %%mm2      \n\t"
-                "paddusb "MANGLE(g5Dither)", %%mm4      \n\t"
-                "paddusb "MANGLE(r5Dither)", %%mm5      \n\t"
+                "paddusb "BLUE_DITHER"(%5), %%mm2      \n\t"
+                "paddusb "GREEN_DITHER"(%5), %%mm4      \n\t"
+                "paddusb "RED_DITHER"(%5), %%mm5      \n\t"
 #endif
                 WRITERGB15(%%REGb, 8280(%5), %%REGBP)
                 "pop %%"REG_BP"                         \n\t"
@@ -1601,9 +1601,9 @@
                 YSCALEYUV2RGB1(%%REGBP, %5)
                 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
 #ifdef DITHER1XBPP
-                "paddusb "MANGLE(b5Dither)", %%mm2      \n\t"
-                "paddusb "MANGLE(g5Dither)", %%mm4      \n\t"
-                "paddusb "MANGLE(r5Dither)", %%mm5      \n\t"
+                "paddusb "BLUE_DITHER"(%5), %%mm2      \n\t"
+                "paddusb "GREEN_DITHER"(%5), %%mm4      \n\t"
+                "paddusb "RED_DITHER"(%5), %%mm5      \n\t"
 #endif
 
                 WRITERGB16(%%REGb, 8280(%5), %%REGBP)
@@ -1670,9 +1670,9 @@
                 YSCALEYUV2RGB1b(%%REGBP, %5)
                 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
 #ifdef DITHER1XBPP
-                "paddusb "MANGLE(b5Dither)", %%mm2      \n\t"
-                "paddusb "MANGLE(g5Dither)", %%mm4      \n\t"
-                "paddusb "MANGLE(r5Dither)", %%mm5      \n\t"
+                "paddusb "BLUE_DITHER"(%5), %%mm2      \n\t"
+                "paddusb "GREEN_DITHER"(%5), %%mm4      \n\t"
+                "paddusb "RED_DITHER"(%5), %%mm5      \n\t"
 #endif
                 WRITERGB15(%%REGb, 8280(%5), %%REGBP)
                 "pop %%"REG_BP"                         \n\t"
@@ -1690,9 +1690,9 @@
                 YSCALEYUV2RGB1b(%%REGBP, %5)
                 /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
 #ifdef DITHER1XBPP
-                "paddusb "MANGLE(b5Dither)", %%mm2      \n\t"
-                "paddusb "MANGLE(g5Dither)", %%mm4      \n\t"
-                "paddusb "MANGLE(r5Dither)", %%mm5      \n\t"
+                "paddusb "BLUE_DITHER"(%5), %%mm2      \n\t"
+                "paddusb "GREEN_DITHER"(%5), %%mm4      \n\t"
+                "paddusb "RED_DITHER"(%5), %%mm5      \n\t"
 #endif
 
                 WRITERGB16(%%REGb, 8280(%5), %%REGBP)
@@ -3091,12 +3091,12 @@
         }
 
 #ifdef HAVE_MMX
-        b5Dither= ff_dither8[dstY&1];
+        c->blueDither= ff_dither8[dstY&1];
         if (c->dstFormat == PIX_FMT_RGB555 || c->dstFormat == PIX_FMT_BGR555)
-            g5Dither= ff_dither8[dstY&1];
+            c->greenDither= ff_dither8[dstY&1];
         else
-            g5Dither= ff_dither4[dstY&1];
-        r5Dither= ff_dither8[(dstY+1)&1];
+            c->greenDither= ff_dither4[dstY&1];
+        c->redDither= ff_dither8[(dstY+1)&1];
 #endif
         if (dstY < dstH-2)
         {



More information about the ffmpeg-devel mailing list