Revision 300e497b libswscale/swscale.c

View differences:

libswscale/swscale.c
1857 1857
    return srcSliceH;
1858 1858
}
1859 1859

  
1860
#define DITHER_COPY(dst, dstStride, src, srcStride)\
1861
    for (i = 0; i < height; i++) {\
1862
        uint8_t *dither= dithers[src_depth-9][i&7];\
1863
        for (j = 0; j < length-7; j+=8){\
1864
            dst[j+0] = (src[j+0] + dither[0])>>(src_depth-dst_depth);\
1865
            dst[j+1] = (src[j+1] + dither[1])>>(src_depth-dst_depth);\
1866
            dst[j+2] = (src[j+2] + dither[2])>>(src_depth-dst_depth);\
1867
            dst[j+3] = (src[j+3] + dither[3])>>(src_depth-dst_depth);\
1868
            dst[j+4] = (src[j+4] + dither[4])>>(src_depth-dst_depth);\
1869
            dst[j+5] = (src[j+5] + dither[5])>>(src_depth-dst_depth);\
1870
            dst[j+6] = (src[j+6] + dither[6])>>(src_depth-dst_depth);\
1871
            dst[j+7] = (src[j+7] + dither[7])>>(src_depth-dst_depth);\
1872
        }\
1873
        for (; j < length; j++)\
1874
            dst[j] = (src[j] + dither[j&7])>>(src_depth-dst_depth);\
1875
        dst += dstStride;\
1876
        src += srcStride;\
1877
    }
1878

  
1879

  
1860 1880
static int planarCopyWrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
1861 1881
                             int srcSliceH, uint8_t* dst[], int dstStride[])
1862 1882
{
......
1883 1903
                uint16_t *dstPtr2 = (uint16_t*)dstPtr;
1884 1904

  
1885 1905
                if (dst_depth == 8) {
1886
                    for (i = 0; i < height; i++) {
1887
                        uint8_t *dither= dithers[src_depth-9][i&7];
1888
                        for (j = 0; j < length-7; j+=8){
1889
                            dstPtr[j+0] = (srcPtr2[j+0] + dither[0])>>(src_depth-8);
1890
                            dstPtr[j+1] = (srcPtr2[j+1] + dither[1])>>(src_depth-8);
1891
                            dstPtr[j+2] = (srcPtr2[j+2] + dither[2])>>(src_depth-8);
1892
                            dstPtr[j+3] = (srcPtr2[j+3] + dither[3])>>(src_depth-8);
1893
                            dstPtr[j+4] = (srcPtr2[j+4] + dither[4])>>(src_depth-8);
1894
                            dstPtr[j+5] = (srcPtr2[j+5] + dither[5])>>(src_depth-8);
1895
                            dstPtr[j+6] = (srcPtr2[j+6] + dither[6])>>(src_depth-8);
1896
                            dstPtr[j+7] = (srcPtr2[j+7] + dither[7])>>(src_depth-8);
1897
                        }
1898
                        for (; j < length; j++)
1899
                            dstPtr[j] = (srcPtr2[j] + dither[j&7])>>(src_depth-8);
1900
                        dstPtr  += dstStride[plane];
1901
                        srcPtr2 += srcStride[plane]/2;
1902
                    }
1906
                    DITHER_COPY(dstPtr, dstStride[plane], srcPtr2, srcStride[plane]/2)
1903 1907
                } else if (src_depth == 8) {
1904 1908
                    for (i = 0; i < height; i++) {
1905 1909
                        for (j = 0; j < length; j++)
......
1923 1927
                        srcPtr2 += srcStride[plane]/2;
1924 1928
                    }
1925 1929
                } else {
1926
                    for (i = 0; i < height; i++) {
1927
                        uint8_t *dither= dithers[src_depth-9][i&7];
1928
                        for (j = 0; j < length-7; j+=8){
1929
                            dstPtr2[j+0] = (srcPtr2[j+0] + dither[0])>>(src_depth-dst_depth);
1930
                            dstPtr2[j+1] = (srcPtr2[j+1] + dither[1])>>(src_depth-dst_depth);
1931
                            dstPtr2[j+2] = (srcPtr2[j+2] + dither[2])>>(src_depth-dst_depth);
1932
                            dstPtr2[j+3] = (srcPtr2[j+3] + dither[3])>>(src_depth-dst_depth);
1933
                            dstPtr2[j+4] = (srcPtr2[j+4] + dither[4])>>(src_depth-dst_depth);
1934
                            dstPtr2[j+5] = (srcPtr2[j+5] + dither[5])>>(src_depth-dst_depth);
1935
                            dstPtr2[j+6] = (srcPtr2[j+6] + dither[6])>>(src_depth-dst_depth);
1936
                            dstPtr2[j+7] = (srcPtr2[j+7] + dither[7])>>(src_depth-dst_depth);
1937
                        }
1938
                        for (; j < length; j++)
1939
                            dstPtr2[j] = (srcPtr2[j] + dither[j&7])>>(src_depth-dst_depth);
1940
                        dstPtr2 += dstStride[plane];
1941
                        srcPtr2 += srcStride[plane]/2;
1942
                    }
1930
                    DITHER_COPY(dstPtr2, dstStride[plane]/2, srcPtr2, srcStride[plane]/2)
1943 1931
                }
1944 1932
            } else if(is16BPS(c->srcFormat) && !is16BPS(c->dstFormat)) {
1945 1933
                //FIXME add dither

Also available in: Unified diff