Revision 95f163b3 libswscale/swscale.c

View differences:

libswscale/swscale.c
266 266
};
267 267
#endif
268 268

  
269
DECLARE_ALIGNED(8, const uint8_t, dithers)[8][8][8]={
270
{
271
  {   0,  1,  0,  1,  0,  1,  0,  1,},
272
  {   1,  0,  1,  0,  1,  0,  1,  0,},
273
  {   0,  1,  0,  1,  0,  1,  0,  1,},
274
  {   1,  0,  1,  0,  1,  0,  1,  0,},
275
  {   0,  1,  0,  1,  0,  1,  0,  1,},
276
  {   1,  0,  1,  0,  1,  0,  1,  0,},
277
  {   0,  1,  0,  1,  0,  1,  0,  1,},
278
  {   1,  0,  1,  0,  1,  0,  1,  0,},
279
},{
280
  {   1,  2,  1,  2,  1,  2,  1,  2,},
281
  {   3,  0,  3,  0,  3,  0,  3,  0,},
282
  {   1,  2,  1,  2,  1,  2,  1,  2,},
283
  {   3,  0,  3,  0,  3,  0,  3,  0,},
284
  {   1,  2,  1,  2,  1,  2,  1,  2,},
285
  {   3,  0,  3,  0,  3,  0,  3,  0,},
286
  {   1,  2,  1,  2,  1,  2,  1,  2,},
287
  {   3,  0,  3,  0,  3,  0,  3,  0,},
288
},{
289
  {   2,  4,  3,  5,  2,  4,  3,  5,},
290
  {   6,  0,  7,  1,  6,  0,  7,  1,},
291
  {   3,  5,  2,  4,  3,  5,  2,  4,},
292
  {   7,  1,  6,  0,  7,  1,  6,  0,},
293
  {   2,  4,  3,  5,  2,  4,  3,  5,},
294
  {   6,  0,  7,  1,  6,  0,  7,  1,},
295
  {   3,  5,  2,  4,  3,  5,  2,  4,},
296
  {   7,  1,  6,  0,  7,  1,  6,  0,},
297
},{
298
  {   4,  8,  7, 11,  4,  8,  7, 11,},
299
  {  12,  0, 15,  3, 12,  0, 15,  3,},
300
  {   6, 10,  5,  9,  6, 10,  5,  9,},
301
  {  14,  2, 13,  1, 14,  2, 13,  1,},
302
  {   4,  8,  7, 11,  4,  8,  7, 11,},
303
  {  12,  0, 15,  3, 12,  0, 15,  3,},
304
  {   6, 10,  5,  9,  6, 10,  5,  9,},
305
  {  14,  2, 13,  1, 14,  2, 13,  1,},
306
},{
307
  {   9, 17, 15, 23,  8, 16, 14, 22,},
308
  {  25,  1, 31,  7, 24,  0, 30,  6,},
309
  {  13, 21, 11, 19, 12, 20, 10, 18,},
310
  {  29,  5, 27,  3, 28,  4, 26,  2,},
311
  {   8, 16, 14, 22,  9, 17, 15, 23,},
312
  {  24,  0, 30,  6, 25,  1, 31,  7,},
313
  {  12, 20, 10, 18, 13, 21, 11, 19,},
314
  {  28,  4, 26,  2, 29,  5, 27,  3,},
315
},{
316
  {  18, 34, 30, 46, 17, 33, 29, 45,},
317
  {  50,  2, 62, 14, 49,  1, 61, 13,},
318
  {  26, 42, 22, 38, 25, 41, 21, 37,},
319
  {  58, 10, 54,  6, 57,  9, 53,  5,},
320
  {  16, 32, 28, 44, 19, 35, 31, 47,},
321
  {  48,  0, 60, 12, 51,  3, 63, 15,},
322
  {  24, 40, 20, 36, 27, 43, 23, 39,},
323
  {  56,  8, 52,  4, 59, 11, 55,  7,},
324
},{
325
  {  18, 34, 30, 46, 17, 33, 29, 45,},
326
  {  50,  2, 62, 14, 49,  1, 61, 13,},
327
  {  26, 42, 22, 38, 25, 41, 21, 37,},
328
  {  58, 10, 54,  6, 57,  9, 53,  5,},
329
  {  16, 32, 28, 44, 19, 35, 31, 47,},
330
  {  48,  0, 60, 12, 51,  3, 63, 15,},
331
  {  24, 40, 20, 36, 27, 43, 23, 39,},
332
  {  56,  8, 52,  4, 59, 11, 55,  7,},
333
},{
334
  {  36, 68, 60, 92, 34, 66, 58, 90,},
335
  { 100,  4,124, 28, 98,  2,122, 26,},
336
  {  52, 84, 44, 76, 50, 82, 42, 74,},
337
  { 116, 20,108, 12,114, 18,106, 10,},
338
  {  32, 64, 56, 88, 38, 70, 62, 94,},
339
  {  96,  0,120, 24,102,  6,126, 30,},
340
  {  48, 80, 40, 72, 54, 86, 46, 78,},
341
  { 112, 16,104,  8,118, 22,110, 14,},
342
}};
343

  
269 344
static av_always_inline void yuv2yuvX16inC_template(const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize,
270 345
                                                    const int16_t *chrFilter, const int16_t **chrSrc, int chrFilterSize,
271 346
                                                    const int16_t **alpSrc, uint16_t *dest, uint16_t *uDest, uint16_t *vDest, uint16_t *aDest,
......
1761 1836
                        srcPtr2 += srcStride[plane]/2;
1762 1837
                    }
1763 1838
                } else {
1764
                    // FIXME Maybe dither instead.
1765 1839
                    for (i = 0; i < height; i++) {
1766
                        for (j = 0; j < length; j++)
1767
                            dstPtr[j] = srcPtr2[j]>>(depth-8);
1840
                        uint8_t *dither= dithers[depth-9][i&7];
1841
                        for (j = 0; j < length-7; j+=8){
1842
                            dstPtr[j+0] = (srcPtr2[j+0] + dither[0])>>(depth-8);
1843
                            dstPtr[j+1] = (srcPtr2[j+1] + dither[1])>>(depth-8);
1844
                            dstPtr[j+2] = (srcPtr2[j+2] + dither[2])>>(depth-8);
1845
                            dstPtr[j+3] = (srcPtr2[j+3] + dither[3])>>(depth-8);
1846
                            dstPtr[j+4] = (srcPtr2[j+4] + dither[4])>>(depth-8);
1847
                            dstPtr[j+5] = (srcPtr2[j+5] + dither[5])>>(depth-8);
1848
                            dstPtr[j+6] = (srcPtr2[j+6] + dither[6])>>(depth-8);
1849
                            dstPtr[j+7] = (srcPtr2[j+7] + dither[7])>>(depth-8);
1850
                        }
1851
                        for (; j < length; j++)
1852
                            dstPtr[j] = (srcPtr2[j] + dither[j&7])>>(depth-8);
1768 1853
                        dstPtr  += dstStride[plane];
1769 1854
                        srcPtr2 += srcStride[plane]/2;
1770 1855
                    }
1771 1856
                }
1772 1857
            } else if(is16BPS(c->srcFormat) && !is16BPS(c->dstFormat)) {
1858
                //FIXME add dither
1773 1859
                if (!isBE(c->srcFormat)) srcPtr++;
1774 1860
                for (i=0; i<height; i++) {
1775 1861
                    for (j=0; j<length; j++) dstPtr[j] = srcPtr[j<<1];

Also available in: Unified diff