Show
Ignore:
Timestamp:
05/22/08 16:45:06 (6 months ago)
Author:
astrange
Message:

Merge trunk to 1.1 branch.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/perian-1.1

    • Property svn:externals changed from
      ffmpeg -r11099 svn://svn.mplayerhq.hu/ffmpeg/trunk
      libebml -r1297 http://svn.matroska.org/svn/matroska/trunk/libebml
      libmatroska -r1297 http://svn.matroska.org/svn/matroska/trunk/libmatroska
      a52codec -r61 http://svn.cod3r.com/a52codec/trunk
      to
      ffmpeg -r 13239 svn://svn.mplayerhq.hu/ffmpeg/trunk
      libebml -r 1306 https://services.corecodec.com/svn/matroska/trunk/libebml
      libmatroska -r 1306 https://services.corecodec.com/svn/matroska/trunk/libmatroska
      a52codec -r 64 http://svn.cod3r.com/a52codec/trunk
  • branches/perian-1.1/ColorConversions.c

    r629 r887  
    2424#include <sys/sysctl.h> 
    2525 
     26#ifndef GOOD_COMPILER 
     27#define noinline __attribute__((noinline)) 
     28#else 
     29#define noinline 
     30#endif 
     31 
     32#define unlikely(x) __builtin_expect(x, 0) 
     33 
    2634//----------------------------------------------------------------- 
    2735// FastY420 
     
    5866// have a decent OS/QT version. 
    5967//----------------------------------------------------------------- 
     68 
     69static void noinline Y420toY422_lastrow(UInt8 *o, const UInt8 *yc, const UInt8 *uc, const UInt8 *vc, unsigned halfWidth) 
     70{ 
     71        unsigned x; 
     72        for(x=0; x < halfWidth; x++) 
     73        { 
     74                unsigned x4 = x*4, x2 = x*2; 
     75                o[x4] = uc[x]; 
     76                o[x4+1] = yc[x2]; 
     77                o[x4+2] = vc[x]; 
     78                o[x4+3] = yc[x2+1]; 
     79        } 
     80} 
     81 
     82#define HandleLastRow(o, yc, uc, vc, halfWidth, height) if (unlikely(height & 1)) Y420toY422_lastrow(o, yc, uc, vc, halfWidth) 
    6083 
    6184#ifdef __BIG_ENDIAN__ 
     
    104127                 baseAddr += outRB * 2; 
    105128         } 
     129         
     130        HandleLastRow(baseAddr, inY, inU, inV, halfWidth, height); 
    106131 } 
    107132 
     
    154179                vc += rV; 
    155180        } 
     181         
     182        HandleLastRow(o, yc, uc, vc, width / 2, height); 
    156183} 
    157184 
     
    186213                __m128i * uv = (__m128i*)uc,* vv  = (__m128i*)vc; 
    187214                 
     215#if 0 
     216                asm volatile( 
     217                        "\n0:                   \n\t" 
     218                        "movdqa         (%2),   %%xmm0  \n\t" 
     219                        "movdqa         16(%2), %%xmm2  \n\t" 
     220                        "movdqa         (%3),           %%xmm1  \n\t" 
     221                        "movdqa         16(%3), %%xmm3  \n\t" 
     222                        "movdqu         (%4),   %%xmm4  \n\t" 
     223                        "movdqu         (%5),   %%xmm5  \n\t" 
     224                        "addl           $32,    %2              \n\t" 
     225                        "addl           $32,    %3              \n\t" 
     226                        "addl           $16,    %4              \n\t" 
     227                        "addl           $16,    %5              \n\t" 
     228                        "movdqa         %%xmm4, %%xmm6  \n\t" 
     229                        "punpcklbw      %%xmm5, %%xmm4  \n\t" /*chroma_l*/ 
     230                        "punpckhbw      %%xmm5, %%xmm6  \n\t" /*chroma_h*/ 
     231                        "movdqa         %%xmm4, %%xmm5  \n\t" 
     232                        "punpcklbw      %%xmm0, %%xmm5  \n\t" 
     233                        "movntdq        %%xmm5, (%0)    \n\t" /*ov[x4]*/ 
     234                        "movdqa         %%xmm4, %%xmm5  \n\t" 
     235                        "punpckhbw      %%xmm0, %%xmm5  \n\t" 
     236                        "movntdq        %%xmm5, 16(%0)  \n\t" /*ov[x4+1]*/ 
     237                        "movdqa         %%xmm6, %%xmm5  \n\t" 
     238                        "punpcklbw      %%xmm2, %%xmm5  \n\t" 
     239                        "movntdq        %%xmm5, 32(%0)  \n\t" /*ov[x4+2]*/ 
     240                        "movdqa         %%xmm6, %%xmm5  \n\t" 
     241                        "punpckhbw      %%xmm2, %%xmm5  \n\t" 
     242                        "movntdq        %%xmm5, 48(%0)  \n\t" /*ov[x4+3]*/ 
     243                        "addl           $64,    %0              \n\t" 
     244                        "movdqa         %%xmm4, %%xmm5  \n\t" 
     245                        "punpcklbw      %%xmm1, %%xmm5  \n\t" 
     246                        "movntdq        %%xmm5, (%1)    \n\t" /*ov2[x4]*/ 
     247                        "punpckhbw      %%xmm1, %%xmm4  \n\t" 
     248                        "movntdq        %%xmm4, 16(%1)  \n\t" /*ov2[x4+1]*/ 
     249                        "movdqa         %%xmm6, %%xmm5  \n\t" 
     250                        "punpcklbw      %%xmm3, %%xmm5  \n\t" 
     251                        "movntdq        %%xmm5, 32(%1)  \n\t" /*ov2[x4+2]*/ 
     252                        "punpckhbw      %%xmm3, %%xmm6  \n\t" 
     253                        "movntdq        %%xmm6, 48(%1)  \n\t" /*ov2[x4+3]*/ 
     254                        "addl           $64,    %1              \n\t" 
     255                        "dec            %6                              \n\t" 
     256                        "jnz            0b                              \n\t" 
     257                        : "+r" (ov), "+r" (ov2), 
     258                        "+r" (yv), "+r" (yv2), "+r" (uv), "+r" (vv) 
     259                        : "r" (vWidth) 
     260                        ); 
     261#else 
    188262                for (x = 0; x < vWidth; x++) { 
    189263                        unsigned x2 = x*2, x4 = x*4; 
     
    205279                        _mm_stream_si128(&ov2[x4+3],_mm_unpackhi_epi8(chroma_h, tmp_y4)); 
    206280                } 
    207                  
    208                 for (x = x * 16; x < halfwidth; x++) { 
     281#endif 
     282 
     283                for (x=vWidth * 16; x < halfwidth; x++) { 
    209284                        unsigned x4 = x*4, x2 = x*2; 
    210285                        o2[x4] = o[x4] = uc[x]; 
     
    221296                vc += rV; 
    222297        } 
    223 
    224  
    225  
    226 static void __attribute__((noinline)) Y420toY422_x86_scalar(UInt8 * o, unsigned outRB, unsigned width, unsigned height, AVFrame * picture) 
     298         
     299        _mm_sfence(); 
     300         
     301        HandleLastRow(o, yc, uc, vc, halfwidth, height); 
     302
     303 
     304 
     305static void noinline Y420toY422_x86_scalar(UInt8 * o, unsigned outRB, unsigned width, unsigned height, AVFrame * picture) 
    227306{ 
    228307        UInt8           *yc = picture->data[0], *u = picture->data[1], *v = picture->data[2]; 
     
    248327                v += rV; 
    249328        } 
     329 
     330        HandleLastRow(o, yc, u, v, halfwidth, height); 
    250331} 
    251332 
     
    255336 
    256337        //make sure the ffmpeg picture buffers are aligned enough, they're only guaranteed to be 8-byte for some reason... 
    257         if ((yc | picture->linesize[0]) % 16 == 0) { 
    258                 Y420toY422_sse2(o, outRB, width, height, picture); 
    259                 _mm_sfence(); 
    260         } else Y420toY422_x86_scalar(o, outRB, width, height, picture); 
     338        if (!unlikely((yc | picture->linesize[0]) % 16)) Y420toY422_sse2(o, outRB, width, height, picture);  
     339        else Y420toY422_x86_scalar(o, outRB, width, height, picture); 
    261340} 
    262341#endif 
     342 
     343void YA420toV408(UInt8* o, unsigned outRB, unsigned width, unsigned height, AVFrame * picture) 
     344{ 
     345        UInt8          *yc = picture->data[0], *u = picture->data[1], *v = picture->data[2], *a = picture->data[3]; 
     346        unsigned       rY = picture->linesize[0], rU = picture->linesize[1], rV = picture->linesize[2], rA = picture->linesize[3], y, x; 
     347         
     348        for (y = 0; y < height; y++) { 
     349                for (x = 0; x < width; x++) { 
     350                        o[x*4] = u[x/2]; 
     351                        o[x*4+1] = yc[x]; 
     352                        o[x*4+2] = v[x/2]; 
     353                        o[x*4+3] = a[x]; 
     354                } 
     355                 
     356                o += outRB; 
     357                yc += rY; 
     358                a += rA; 
     359                if (y & 1) { 
     360                        u += rU; 
     361                        v += rV; 
     362                } 
     363        } 
     364} 
    263365 
    264366void BGR24toRGB24(UInt8 *baseAddr, unsigned rowBytes, unsigned width, unsigned height, AVFrame *picture) 
     
    266368        unsigned i, j; 
    267369        UInt8 *srcPtr = picture->data[0]; 
    268         unsigned width_third = width / 3; 
    269370         
    270371        for (i = 0; i < height; ++i) 
    271372        { 
    272                 for (j = 0; j < width_third; j ++) 
     373                for (j = 0; j < width; j ++) 
    273374                { 
    274375                        unsigned j3 = j * 3; 
     
    301402} 
    302403 
     404void RGB24toRGB24(UInt8 *baseAddr, unsigned rowBytes, unsigned width, unsigned height, AVFrame *picture) 
     405{ 
     406        unsigned y; 
     407        UInt8 *srcPtr = picture->data[0]; 
     408         
     409        for (y = 0; y < height; y++) { 
     410                memcpy(baseAddr, srcPtr, width * 3); 
     411                 
     412                baseAddr += rowBytes; 
     413                srcPtr += picture->linesize[0]; 
     414        } 
     415} 
     416 
    303417void Y422toY422(UInt8* o, unsigned outRB, unsigned width, unsigned height, AVFrame * picture) 
    304418{