Revision 88e2a9ae

View differences:

libswscale/swscale.c
205 205
DECLARE_ASM_CONST(8, uint64_t, bm11111000)=0xFFFFFFFFFF000000LL;
206 206
DECLARE_ASM_CONST(8, uint64_t, bm01010101)=0x00FF00FF00FF00FFLL;
207 207

  
208
static volatile uint64_t attribute_used __attribute__((aligned(8))) b5Dither;
209
static volatile uint64_t attribute_used __attribute__((aligned(8))) g5Dither;
210
static volatile uint64_t attribute_used __attribute__((aligned(8))) r5Dither;
211

  
212 208
const DECLARE_ALIGNED(8, uint64_t, ff_dither4[2]) = {
213 209
        0x0103010301030103LL,
214 210
        0x0200020002000200LL,};
libswscale/swscale_template.c
1091 1091
                YSCALEYUV2RGBX
1092 1092
                /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
1093 1093
#ifdef DITHER1XBPP
1094
                "paddusb "MANGLE(b5Dither)", %%mm2\n\t"
1095
                "paddusb "MANGLE(g5Dither)", %%mm4\n\t"
1096
                "paddusb "MANGLE(r5Dither)", %%mm5\n\t"
1094
                "paddusb "BLUE_DITHER"(%0), %%mm2\n\t"
1095
                "paddusb "GREEN_DITHER"(%0), %%mm4\n\t"
1096
                "paddusb "RED_DITHER"(%0), %%mm5\n\t"
1097 1097
#endif
1098 1098

  
1099 1099
                WRITERGB15(%4, %5, %%REGa)
......
1104 1104
                YSCALEYUV2RGBX
1105 1105
                /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
1106 1106
#ifdef DITHER1XBPP
1107
                "paddusb "MANGLE(b5Dither)", %%mm2\n\t"
1108
                "paddusb "MANGLE(g5Dither)", %%mm4\n\t"
1109
                "paddusb "MANGLE(r5Dither)", %%mm5\n\t"
1107
                "paddusb "BLUE_DITHER"(%0), %%mm2\n\t"
1108
                "paddusb "GREEN_DITHER"(%0), %%mm4\n\t"
1109
                "paddusb "RED_DITHER"(%0), %%mm5\n\t"
1110 1110
#endif
1111 1111

  
1112 1112
                WRITERGB16(%4, %5, %%REGa)
......
1151 1151
                YSCALEYUV2RGBX
1152 1152
                /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
1153 1153
#ifdef DITHER1XBPP
1154
                "paddusb "MANGLE(b5Dither)", %%mm2  \n\t"
1155
                "paddusb "MANGLE(g5Dither)", %%mm4  \n\t"
1156
                "paddusb "MANGLE(r5Dither)", %%mm5  \n\t"
1154
                "paddusb "BLUE_DITHER"(%0), %%mm2  \n\t"
1155
                "paddusb "GREEN_DITHER"(%0), %%mm4  \n\t"
1156
                "paddusb "RED_DITHER"(%0), %%mm5  \n\t"
1157 1157
#endif
1158 1158

  
1159 1159
                WRITERGB15(%4, %5, %%REGa)
......
1164 1164
                YSCALEYUV2RGBX
1165 1165
                /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
1166 1166
#ifdef DITHER1XBPP
1167
                "paddusb "MANGLE(b5Dither)", %%mm2  \n\t"
1168
                "paddusb "MANGLE(g5Dither)", %%mm4  \n\t"
1169
                "paddusb "MANGLE(r5Dither)", %%mm5  \n\t"
1167
                "paddusb "BLUE_DITHER"(%0), %%mm2  \n\t"
1168
                "paddusb "GREEN_DITHER"(%0), %%mm4  \n\t"
1169
                "paddusb "RED_DITHER"(%0), %%mm5  \n\t"
1170 1170
#endif
1171 1171

  
1172 1172
                WRITERGB16(%4, %5, %%REGa)
......
1468 1468
                YSCALEYUV2RGB(%%REGBP, %5)
1469 1469
                /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
1470 1470
#ifdef DITHER1XBPP
1471
                "paddusb "MANGLE(b5Dither)", %%mm2      \n\t"
1472
                "paddusb "MANGLE(g5Dither)", %%mm4      \n\t"
1473
                "paddusb "MANGLE(r5Dither)", %%mm5      \n\t"
1471
                "paddusb "BLUE_DITHER"(%5), %%mm2      \n\t"
1472
                "paddusb "GREEN_DITHER"(%5), %%mm4      \n\t"
1473
                "paddusb "RED_DITHER"(%5), %%mm5      \n\t"
1474 1474
#endif
1475 1475

  
1476 1476
                WRITERGB15(%%REGb, 8280(%5), %%REGBP)
......
1489 1489
                YSCALEYUV2RGB(%%REGBP, %5)
1490 1490
                /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
1491 1491
#ifdef DITHER1XBPP
1492
                "paddusb "MANGLE(b5Dither)", %%mm2      \n\t"
1493
                "paddusb "MANGLE(g5Dither)", %%mm4      \n\t"
1494
                "paddusb "MANGLE(r5Dither)", %%mm5      \n\t"
1492
                "paddusb "BLUE_DITHER"(%5), %%mm2      \n\t"
1493
                "paddusb "GREEN_DITHER"(%5), %%mm4      \n\t"
1494
                "paddusb "RED_DITHER"(%5), %%mm5      \n\t"
1495 1495
#endif
1496 1496

  
1497 1497
                WRITERGB16(%%REGb, 8280(%5), %%REGBP)
......
1581 1581
                YSCALEYUV2RGB1(%%REGBP, %5)
1582 1582
                /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
1583 1583
#ifdef DITHER1XBPP
1584
                "paddusb "MANGLE(b5Dither)", %%mm2      \n\t"
1585
                "paddusb "MANGLE(g5Dither)", %%mm4      \n\t"
1586
                "paddusb "MANGLE(r5Dither)", %%mm5      \n\t"
1584
                "paddusb "BLUE_DITHER"(%5), %%mm2      \n\t"
1585
                "paddusb "GREEN_DITHER"(%5), %%mm4      \n\t"
1586
                "paddusb "RED_DITHER"(%5), %%mm5      \n\t"
1587 1587
#endif
1588 1588
                WRITERGB15(%%REGb, 8280(%5), %%REGBP)
1589 1589
                "pop %%"REG_BP"                         \n\t"
......
1601 1601
                YSCALEYUV2RGB1(%%REGBP, %5)
1602 1602
                /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
1603 1603
#ifdef DITHER1XBPP
1604
                "paddusb "MANGLE(b5Dither)", %%mm2      \n\t"
1605
                "paddusb "MANGLE(g5Dither)", %%mm4      \n\t"
1606
                "paddusb "MANGLE(r5Dither)", %%mm5      \n\t"
1604
                "paddusb "BLUE_DITHER"(%5), %%mm2      \n\t"
1605
                "paddusb "GREEN_DITHER"(%5), %%mm4      \n\t"
1606
                "paddusb "RED_DITHER"(%5), %%mm5      \n\t"
1607 1607
#endif
1608 1608

  
1609 1609
                WRITERGB16(%%REGb, 8280(%5), %%REGBP)
......
1670 1670
                YSCALEYUV2RGB1b(%%REGBP, %5)
1671 1671
                /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
1672 1672
#ifdef DITHER1XBPP
1673
                "paddusb "MANGLE(b5Dither)", %%mm2      \n\t"
1674
                "paddusb "MANGLE(g5Dither)", %%mm4      \n\t"
1675
                "paddusb "MANGLE(r5Dither)", %%mm5      \n\t"
1673
                "paddusb "BLUE_DITHER"(%5), %%mm2      \n\t"
1674
                "paddusb "GREEN_DITHER"(%5), %%mm4      \n\t"
1675
                "paddusb "RED_DITHER"(%5), %%mm5      \n\t"
1676 1676
#endif
1677 1677
                WRITERGB15(%%REGb, 8280(%5), %%REGBP)
1678 1678
                "pop %%"REG_BP"                         \n\t"
......
1690 1690
                YSCALEYUV2RGB1b(%%REGBP, %5)
1691 1691
                /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
1692 1692
#ifdef DITHER1XBPP
1693
                "paddusb "MANGLE(b5Dither)", %%mm2      \n\t"
1694
                "paddusb "MANGLE(g5Dither)", %%mm4      \n\t"
1695
                "paddusb "MANGLE(r5Dither)", %%mm5      \n\t"
1693
                "paddusb "BLUE_DITHER"(%5), %%mm2      \n\t"
1694
                "paddusb "GREEN_DITHER"(%5), %%mm4      \n\t"
1695
                "paddusb "RED_DITHER"(%5), %%mm5      \n\t"
1696 1696
#endif
1697 1697

  
1698 1698
                WRITERGB16(%%REGb, 8280(%5), %%REGBP)
......
3091 3091
        }
3092 3092

  
3093 3093
#ifdef HAVE_MMX
3094
        b5Dither= ff_dither8[dstY&1];
3094
        c->blueDither= ff_dither8[dstY&1];
3095 3095
        if (c->dstFormat == PIX_FMT_RGB555 || c->dstFormat == PIX_FMT_BGR555)
3096
            g5Dither= ff_dither8[dstY&1];
3096
            c->greenDither= ff_dither8[dstY&1];
3097 3097
        else
3098
            g5Dither= ff_dither4[dstY&1];
3099
        r5Dither= ff_dither8[(dstY+1)&1];
3098
            c->greenDither= ff_dither4[dstY&1];
3099
        c->redDither= ff_dither8[(dstY+1)&1];
3100 3100
#endif
3101 3101
        if (dstY < dstH-2)
3102 3102
        {
libswscale/yuv2rgb.c
54 54
DECLARE_ASM_CONST(8, uint64_t, mmx_redmask) = 0xf8f8f8f8f8f8f8f8ULL;
55 55
DECLARE_ASM_CONST(8, uint64_t, mmx_grnmask) = 0xfcfcfcfcfcfcfcfcULL;
56 56

  
57
// The volatile is required because gcc otherwise optimizes some writes away
58
// not knowing that these are read in the ASM block.
59
static volatile uint64_t attribute_used __attribute__((aligned(8))) b5Dither;
60
static volatile uint64_t attribute_used __attribute__((aligned(8))) g5Dither;
61
static volatile uint64_t attribute_used __attribute__((aligned(8))) r5Dither;
62

  
63 57
#undef HAVE_MMX
64 58

  
65 59
//MMX versions
libswscale/yuv2rgb_template.c
134 134
    if(h_size*2 > FFABS(dstStride[0])) h_size-=8;
135 135

  
136 136
    asm volatile ("pxor %mm4, %mm4;" /* zero mm4 */ );
137
    //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],
137
    //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],
138 138
    //srcStride[0],srcStride[1],srcStride[2],dstStride[0]);
139 139
    for (y= 0; y<srcSliceH; y++ ) {
140 140
        uint8_t *image = dst[0] + (y+srcSliceY)*dstStride[0];
......
143 143
        uint8_t *pv = src[2] + (y>>1)*srcStride[2];
144 144
        long index= -h_size/2;
145 145

  
146
        b5Dither= ff_dither8[y&1];
147
        g5Dither= ff_dither4[y&1];
148
        r5Dither= ff_dither8[(y+1)&1];
146
        c->blueDither= ff_dither8[y&1];
147
        c->greenDither= ff_dither4[y&1];
148
        c->redDither= ff_dither8[(y+1)&1];
149 149
        /* This MMX assembly code deals with a SINGLE scan line at a time,
150 150
         * it converts 8 pixels in each iteration. */
151 151
        asm volatile (
......
164 164
YUV2RGB
165 165

  
166 166
#ifdef DITHER1XBPP
167
        "paddusb "MANGLE(b5Dither)", %%mm0;"
168
        "paddusb "MANGLE(g5Dither)", %%mm2;"
169
        "paddusb "MANGLE(r5Dither)", %%mm1;"
167
        "paddusb "BLUE_DITHER"(%4), %%mm0;"
168
        "paddusb "GREEN_DITHER"(%4), %%mm2;"
169
        "paddusb "RED_DITHER"(%4), %%mm1;"
170 170
#endif
171 171
        /* mask unneeded bits off */
172 172
        "pand "MANGLE(mmx_redmask)", %%mm0;" /* b7b6b5b4 b3_0_0_0 b7b6b5b4 b3_0_0_0 */
......
228 228
    if(h_size*2 > FFABS(dstStride[0])) h_size-=8;
229 229

  
230 230
    asm volatile ("pxor %mm4, %mm4;" /* zero mm4 */ );
231
    //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],
231
    //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],
232 232
    //srcStride[0],srcStride[1],srcStride[2],dstStride[0]);
233 233
    for (y= 0; y<srcSliceH; y++ ) {
234 234
        uint8_t *image = dst[0] + (y+srcSliceY)*dstStride[0];
......
237 237
        uint8_t *pv = src[2] + (y>>1)*srcStride[2];
238 238
        long index= -h_size/2;
239 239

  
240
        b5Dither= ff_dither8[y&1];
241
        g5Dither= ff_dither8[y&1];
242
        r5Dither= ff_dither8[(y+1)&1];
240
        c->blueDither= ff_dither8[y&1];
241
        c->greenDither= ff_dither8[y&1];
242
        c->redDither= ff_dither8[(y+1)&1];
243 243
        /* This MMX assembly code deals with a SINGLE scan line at a time,
244 244
         * it converts 8 pixels in each iteration. */
245 245
        asm volatile (
......
252 252
YUV2RGB
253 253

  
254 254
#ifdef DITHER1XBPP
255
        "paddusb "MANGLE(b5Dither)", %%mm0  \n\t"
256
        "paddusb "MANGLE(g5Dither)", %%mm2  \n\t"
257
        "paddusb "MANGLE(r5Dither)", %%mm1  \n\t"
255
        "paddusb "BLUE_DITHER"(%4), %%mm0  \n\t"
256
        "paddusb "GREEN_DITHER"(%4), %%mm2  \n\t"
257
        "paddusb "RED_DITHER"(%4), %%mm1  \n\t"
258 258
#endif
259 259

  
260 260
        /* mask unneeded bits off */

Also available in: Unified diff