static int swScale(SwsContext *c, const uint8_t* src[],

                   int srcStride[], int srcSliceY,

                   int srcSliceH, uint8_t* dst[], int dstStride[])

{

    /* load a few things into local vars to make the code more readable? and faster */

    const int srcW= c->srcW;

    const int dstW= c->dstW;

    const int dstH= c->dstH;

    const int chrDstW= c->chrDstW;

    const int chrSrcW= c->chrSrcW;

    const int lumXInc= c->lumXInc;

    const int chrXInc= c->chrXInc;

    const enum PixelFormat dstFormat= c->dstFormat;

    const int flags= c->flags;

    int16_t *vLumFilterPos= c->vLumFilterPos;

    int16_t *vChrFilterPos= c->vChrFilterPos;

    int16_t *hLumFilterPos= c->hLumFilterPos;

    int16_t *hChrFilterPos= c->hChrFilterPos;

    int16_t *vLumFilter= c->vLumFilter;

    int16_t *vChrFilter= c->vChrFilter;

    int16_t *hLumFilter= c->hLumFilter;

    int16_t *hChrFilter= c->hChrFilter;

    int32_t *lumMmxFilter= c->lumMmxFilter;

    int32_t *chrMmxFilter= c->chrMmxFilter;

    int32_t av_unused *alpMmxFilter= c->alpMmxFilter;

    const int vLumFilterSize= c->vLumFilterSize;

    const int vChrFilterSize= c->vChrFilterSize;

    const int hLumFilterSize= c->hLumFilterSize;

    const int hChrFilterSize= c->hChrFilterSize;

    int16_t **lumPixBuf= c->lumPixBuf;

    int16_t **chrUPixBuf= c->chrUPixBuf;

    int16_t **chrVPixBuf= c->chrVPixBuf;

    int16_t **alpPixBuf= c->alpPixBuf;

    const int vLumBufSize= c->vLumBufSize;

    const int vChrBufSize= c->vChrBufSize;

    uint8_t *formatConvBuffer= c->formatConvBuffer;

    const int chrSrcSliceY= srcSliceY >> c->chrSrcVSubSample;

    const int chrSrcSliceH= -((-srcSliceH) >> c->chrSrcVSubSample);

    int lastDstY;

    uint32_t *pal=c->pal_yuv;

    yuv2planar1_fn yuv2yuv1 = c->yuv2yuv1;

    yuv2planarX_fn yuv2yuvX = c->yuv2yuvX;

    yuv2packed1_fn yuv2packed1 = c->yuv2packed1;

    yuv2packed2_fn yuv2packed2 = c->yuv2packed2;

    yuv2packedX_fn yuv2packedX = c->yuv2packedX;



    /* vars which will change and which we need to store back in the context */

    int dstY= c->dstY;

    int lumBufIndex= c->lumBufIndex;

    int chrBufIndex= c->chrBufIndex;

    int lastInLumBuf= c->lastInLumBuf;

    int lastInChrBuf= c->lastInChrBuf;



    if (isPacked(c->srcFormat)) {

        src[0]=

        src[1]=

        src[2]=

        src[3]= src[0];

        srcStride[0]=

        srcStride[1]=

        srcStride[2]=

        srcStride[3]= srcStride[0];

    }

    srcStride[1]<<= c->vChrDrop;

    srcStride[2]<<= c->vChrDrop;



    DEBUG_BUFFERS("swScale() %p[%d] %p[%d] %p[%d] %p[%d] -> %p[%d] %p[%d] %p[%d] %p[%d]\n",

                  src[0], srcStride[0], src[1], srcStride[1], src[2], srcStride[2], src[3], srcStride[3],

                  dst[0], dstStride[0], dst[1], dstStride[1], dst[2], dstStride[2], dst[3], dstStride[3]);

    DEBUG_BUFFERS("srcSliceY: %d srcSliceH: %d dstY: %d dstH: %d\n",

                   srcSliceY,    srcSliceH,    dstY,    dstH);

    DEBUG_BUFFERS("vLumFilterSize: %d vLumBufSize: %d vChrFilterSize: %d vChrBufSize: %d\n",

                   vLumFilterSize,    vLumBufSize,    vChrFilterSize,    vChrBufSize);



    if (dstStride[0]%8 !=0 || dstStride[1]%8 !=0 || dstStride[2]%8 !=0 || dstStride[3]%8 != 0) {

        static int warnedAlready=0; //FIXME move this into the context perhaps

        if (flags & SWS_PRINT_INFO && !warnedAlready) {

            av_log(c, AV_LOG_WARNING, "Warning: dstStride is not aligned!\n"

                   "         ->cannot do aligned memory accesses anymore\n");

            warnedAlready=1;

        }

    }



    /* Note the user might start scaling the picture in the middle so this

       will not get executed. This is not really intended but works

       currently, so people might do it. */

    if (srcSliceY ==0) {

        lumBufIndex=-1;

        chrBufIndex=-1;

        dstY=0;

        lastInLumBuf= -1;

        lastInChrBuf= -1;

    }



    lastDstY= dstY;



    for (;dstY < dstH; dstY++) {

        unsigned char *dest =dst[0]+dstStride[0]*dstY;

        const int chrDstY= dstY>>c->chrDstVSubSample;

        unsigned char *uDest=dst[1]+dstStride[1]*chrDstY;

        unsigned char *vDest=dst[2]+dstStride[2]*chrDstY;

        unsigned char *aDest=(CONFIG_SWSCALE_ALPHA && alpPixBuf) ? dst[3]+dstStride[3]*dstY : NULL;



        const int firstLumSrcY= vLumFilterPos[dstY]; //First line needed as input

        const int firstLumSrcY2= vLumFilterPos[FFMIN(dstY | ((1<<c->chrDstVSubSample) - 1), dstH-1)];

        const int firstChrSrcY= vChrFilterPos[chrDstY]; //First line needed as input

        int lastLumSrcY= firstLumSrcY + vLumFilterSize -1; // Last line needed as input

        int lastLumSrcY2=firstLumSrcY2+ vLumFilterSize -1; // Last line needed as input

        int lastChrSrcY= firstChrSrcY + vChrFilterSize -1; // Last line needed as input

        int enough_lines;



        //handle holes (FAST_BILINEAR & weird filters)

        if (firstLumSrcY > lastInLumBuf) lastInLumBuf= firstLumSrcY-1;

        if (firstChrSrcY > lastInChrBuf) lastInChrBuf= firstChrSrcY-1;

        assert(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1);

        assert(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1);



        DEBUG_BUFFERS("dstY: %d\n", dstY);

        DEBUG_BUFFERS("\tfirstLumSrcY: %d lastLumSrcY: %d lastInLumBuf: %d\n",

                         firstLumSrcY,    lastLumSrcY,    lastInLumBuf);

        DEBUG_BUFFERS("\tfirstChrSrcY: %d lastChrSrcY: %d lastInChrBuf: %d\n",

                         firstChrSrcY,    lastChrSrcY,    lastInChrBuf);



        // Do we have enough lines in this slice to output the dstY line

        enough_lines = lastLumSrcY2 < srcSliceY + srcSliceH && lastChrSrcY < -((-srcSliceY - srcSliceH)>>c->chrSrcVSubSample);



        if (!enough_lines) {

            lastLumSrcY = srcSliceY + srcSliceH - 1;

            lastChrSrcY = chrSrcSliceY + chrSrcSliceH - 1;

            DEBUG_BUFFERS("buffering slice: lastLumSrcY %d lastChrSrcY %d\n",

                                            lastLumSrcY, lastChrSrcY);

        }



        //Do horizontal scaling

        while(lastInLumBuf < lastLumSrcY) {

            const uint8_t *src1= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0];

            const uint8_t *src2= src[3]+(lastInLumBuf + 1 - srcSliceY)*srcStride[3];

            lumBufIndex++;

            assert(lumBufIndex < 2*vLumBufSize);

            assert(lastInLumBuf + 1 - srcSliceY < srcSliceH);

            assert(lastInLumBuf + 1 - srcSliceY >= 0);

            hyscale(c, lumPixBuf[ lumBufIndex ], dstW, src1, srcW, lumXInc,

                    hLumFilter, hLumFilterPos, hLumFilterSize,

                    formatConvBuffer,

                    pal, 0);

            if (CONFIG_SWSCALE_ALPHA && alpPixBuf)

                hyscale(c, alpPixBuf[ lumBufIndex ], dstW, src2, srcW,

                        lumXInc, hLumFilter, hLumFilterPos, hLumFilterSize,

                        formatConvBuffer,

                        pal, 1);

            lastInLumBuf++;

            DEBUG_BUFFERS("\t\tlumBufIndex %d: lastInLumBuf: %d\n",

                               lumBufIndex,    lastInLumBuf);

        }

        while(lastInChrBuf < lastChrSrcY) {

            const uint8_t *src1= src[1]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[1];

            const uint8_t *src2= src[2]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[2];

            chrBufIndex++;

            assert(chrBufIndex < 2*vChrBufSize);

            assert(lastInChrBuf + 1 - chrSrcSliceY < (chrSrcSliceH));

            assert(lastInChrBuf + 1 - chrSrcSliceY >= 0);

            //FIXME replace parameters through context struct (some at least)



            if (c->needs_hcscale)

                hcscale(c, chrUPixBuf[chrBufIndex], chrVPixBuf[chrBufIndex],

                          chrDstW, src1, src2, chrSrcW, chrXInc,

                          hChrFilter, hChrFilterPos, hChrFilterSize,

                          formatConvBuffer, pal);

            lastInChrBuf++;

            DEBUG_BUFFERS("\t\tchrBufIndex %d: lastInChrBuf: %d\n",

                               chrBufIndex,    lastInChrBuf);

        }

        //wrap buf index around to stay inside the ring buffer

        if (lumBufIndex >= vLumBufSize) lumBufIndex-= vLumBufSize;

        if (chrBufIndex >= vChrBufSize) chrBufIndex-= vChrBufSize;

        if (!enough_lines)

            break; //we can't output a dstY line so let's try with the next slice



#if HAVE_MMX

        updateMMXDitherTables(c, dstY, lumBufIndex, chrBufIndex, lastInLumBuf, lastInChrBuf);

#endif

        if (dstY >= dstH-2) {

            // hmm looks like we can't use MMX here without overwriting this array's tail

            find_c_packed_planar_out_funcs(c, &yuv2yuv1, &yuv2yuvX,

                                           &yuv2packed1, &yuv2packed2,

                                           &yuv2packedX);

        }



        {

            const int16_t **lumSrcPtr= (const int16_t **) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;

            const int16_t **chrUSrcPtr= (const int16_t **) chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;

            const int16_t **chrVSrcPtr= (const int16_t **) chrVPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;

            const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL;

            if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { //YV12 like

                const int chrSkipMask= (1<<c->chrDstVSubSample)-1;

                if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi

                if (c->yuv2yuv1 && vLumFilterSize == 1 && vChrFilterSize == 1) { // unscaled YV12

                    const int16_t *lumBuf = lumSrcPtr[0];

                    const int16_t *chrUBuf= chrUSrcPtr[0];

                    const int16_t *chrVBuf= chrVSrcPtr[0];

                    const int16_t *alpBuf= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? alpSrcPtr[0] : NULL;

                    yuv2yuv1(c, lumBuf, chrUBuf, chrVBuf, alpBuf, dest,

                                uDest, vDest, aDest, dstW, chrDstW);

                } else { //General YV12

                    yuv2yuvX(c,

                                vLumFilter+dstY*vLumFilterSize   , lumSrcPtr, vLumFilterSize,

                                vChrFilter+chrDstY*vChrFilterSize, chrUSrcPtr,

                                chrVSrcPtr, vChrFilterSize,

                                alpSrcPtr, dest, uDest, vDest, aDest, dstW, chrDstW);

                }

            } else {

                assert(lumSrcPtr  + vLumFilterSize - 1 < lumPixBuf  + vLumBufSize*2);

                assert(chrUSrcPtr + vChrFilterSize - 1 < chrUPixBuf + vChrBufSize*2);

                if (c->yuv2packed1 && vLumFilterSize == 1 && vChrFilterSize == 2) { //unscaled RGB

                    int chrAlpha= vChrFilter[2*dstY+1];

                    yuv2packed1(c, *lumSrcPtr, *chrUSrcPtr, *(chrUSrcPtr+1),

                                   *chrVSrcPtr, *(chrVSrcPtr+1),

                                   alpPixBuf ? *alpSrcPtr : NULL,

                                   dest, dstW, chrAlpha, dstFormat, flags, dstY);

                } else if (c->yuv2packed2 && vLumFilterSize == 2 && vChrFilterSize == 2) { //bilinear upscale RGB

                    int lumAlpha= vLumFilter[2*dstY+1];

                    int chrAlpha= vChrFilter[2*dstY+1];

                    lumMmxFilter[2]=

                    lumMmxFilter[3]= vLumFilter[2*dstY   ]*0x10001;

                    chrMmxFilter[2]=

                    chrMmxFilter[3]= vChrFilter[2*chrDstY]*0x10001;

                    yuv2packed2(c, *lumSrcPtr, *(lumSrcPtr+1), *chrUSrcPtr, *(chrUSrcPtr+1),

                                   *chrVSrcPtr, *(chrVSrcPtr+1),

                                   alpPixBuf ? *alpSrcPtr : NULL, alpPixBuf ? *(alpSrcPtr+1) : NULL,

                                   dest, dstW, lumAlpha, chrAlpha, dstY);

                } else { //general RGB

                    yuv2packedX(c,

                                   vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,

                                   vChrFilter+dstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize,

                                   alpSrcPtr, dest, dstW, dstY);

                }

            }

        }

    }



    if ((dstFormat == PIX_FMT_YUVA420P) && !alpPixBuf)

        fillPlane(dst[3], dstStride[3], dstW, dstY-lastDstY, lastDstY, 255);



#if HAVE_MMX2

    if (av_get_cpu_flags() & AV_CPU_FLAG_MMX2)

        __asm__ volatile("sfence":::"memory");

#endif

    emms_c();



    /* store changed local vars back in the context */

    c->dstY= dstY;

    c->lumBufIndex= lumBufIndex;

    c->chrBufIndex= chrBufIndex;

    c->lastInLumBuf= lastInLumBuf;

    c->lastInChrBuf= lastInChrBuf;



    return dstY - lastDstY;

}

static int swScale(SwsContext *c, const uint8_t* src[],

                   int srcStride[], int srcSliceY,

                   int srcSliceH, uint8_t* dst[], int dstStride[])

{

    

    const int srcW= c->srcW;

    const int dstW= c->dstW;

    const int dstH= c->dstH;

    const int chrDstW= c->chrDstW;

    const int chrSrcW= c->chrSrcW;

    const int lumXInc= c->lumXInc;

    const int chrXInc= c->chrXInc;

    const enum PixelFormat dstFormat= c->dstFormat;

    const int flags= c->flags;

    int16_t *vLumFilterPos= c->vLumFilterPos;

    int16_t *vChrFilterPos= c->vChrFilterPos;

    int16_t *hLumFilterPos= c->hLumFilterPos;

    int16_t *hChrFilterPos= c->hChrFilterPos;

    int16_t *vLumFilter= c->vLumFilter;

    int16_t *vChrFilter= c->vChrFilter;

    int16_t *hLumFilter= c->hLumFilter;

    int16_t *hChrFilter= c->hChrFilter;

    int32_t *lumMmxFilter= c->lumMmxFilter;

    int32_t *chrMmxFilter= c->chrMmxFilter;

    int32_t av_unused *alpMmxFilter= c->alpMmxFilter;

    const int vLumFilterSize= c->vLumFilterSize;

    const int vChrFilterSize= c->vChrFilterSize;

    const int hLumFilterSize= c->hLumFilterSize;

    const int hChrFilterSize= c->hChrFilterSize;

    int16_t **lumPixBuf= c->lumPixBuf;

    int16_t **chrUPixBuf= c->chrUPixBuf;

    int16_t **chrVPixBuf= c->chrVPixBuf;

    int16_t **alpPixBuf= c->alpPixBuf;

    const int vLumBufSize= c->vLumBufSize;

    const int vChrBufSize= c->vChrBufSize;

    uint8_t *formatConvBuffer= c->formatConvBuffer;

    const int chrSrcSliceY= srcSliceY >> c->chrSrcVSubSample;

    const int chrSrcSliceH= -((-srcSliceH) >> c->chrSrcVSubSample);

    int lastDstY;

    uint32_t *pal=c->pal_yuv;

    yuv2planar1_fn yuv2yuv1 = c->yuv2yuv1;

    yuv2planarX_fn yuv2yuvX = c->yuv2yuvX;

    yuv2packed1_fn yuv2packed1 = c->yuv2packed1;

    yuv2packed2_fn yuv2packed2 = c->yuv2packed2;

    yuv2packedX_fn yuv2packedX = c->yuv2packedX;



    

    int dstY= c->dstY;

    int lumBufIndex= c->lumBufIndex;

    int chrBufIndex= c->chrBufIndex;

    int lastInLumBuf= c->lastInLumBuf;

    int lastInChrBuf= c->lastInChrBuf;



    if (isPacked(c->srcFormat)) {

        src[0]=

        src[1]=

        src[2]=

        src[3]= src[0];

        srcStride[0]=

        srcStride[1]=

        srcStride[2]=

        srcStride[3]= srcStride[0];

    }

    srcStride[1]<<= c->vChrDrop;

    srcStride[2]<<= c->vChrDrop;



    DEBUG_BUFFERS("swScale() %p[%d] %p[%d] %p[%d] %p[%d] -> %p[%d] %p[%d] %p[%d] %p[%d]\n",

                  src[0], srcStride[0], src[1], srcStride[1], src[2], srcStride[2], src[3], srcStride[3],

                  dst[0], dstStride[0], dst[1], dstStride[1], dst[2], dstStride[2], dst[3], dstStride[3]);

    DEBUG_BUFFERS("srcSliceY: %d srcSliceH: %d dstY: %d dstH: %d\n",

                   srcSliceY,    srcSliceH,    dstY,    dstH);

    DEBUG_BUFFERS("vLumFilterSize: %d vLumBufSize: %d vChrFilterSize: %d vChrBufSize: %d\n",

                   vLumFilterSize,    vLumBufSize,    vChrFilterSize,    vChrBufSize);



    if (dstStride[0]%8 !=0 || dstStride[1]%8 !=0 || dstStride[2]%8 !=0 || dstStride[3]%8 != 0) {

        static int warnedAlready=0; 

        if (flags & SWS_PRINT_INFO && !warnedAlready) {

            av_log(c, AV_LOG_WARNING, "Warning: dstStride is not aligned!\n"

                   "         ->cannot do aligned memory accesses anymore\n");

            warnedAlready=1;

        }

    }



    





    if (srcSliceY ==0) {

        lumBufIndex=-1;

        chrBufIndex=-1;

        dstY=0;

        lastInLumBuf= -1;

        lastInChrBuf= -1;

    }



    lastDstY= dstY;



    for (;dstY < dstH; dstY++) {

        unsigned char *dest =dst[0]+dstStride[0]*dstY;

        const int chrDstY= dstY>>c->chrDstVSubSample;

        unsigned char *uDest=dst[1]+dstStride[1]*chrDstY;

        unsigned char *vDest=dst[2]+dstStride[2]*chrDstY;

        unsigned char *aDest=(CONFIG_SWSCALE_ALPHA && alpPixBuf) ? dst[3]+dstStride[3]*dstY : NULL;



        const int firstLumSrcY= vLumFilterPos[dstY]; 

        const int firstLumSrcY2= vLumFilterPos[FFMIN(dstY | ((1<<c->chrDstVSubSample) - 1), dstH-1)];

        const int firstChrSrcY= vChrFilterPos[chrDstY]; 

        int lastLumSrcY= firstLumSrcY + vLumFilterSize -1; 

        int lastLumSrcY2=firstLumSrcY2+ vLumFilterSize -1; 

        int lastChrSrcY= firstChrSrcY + vChrFilterSize -1; 

        int enough_lines;



        

        if (firstLumSrcY > lastInLumBuf) lastInLumBuf= firstLumSrcY-1;

        if (firstChrSrcY > lastInChrBuf) lastInChrBuf= firstChrSrcY-1;

        assert(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1);

        assert(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1);



        DEBUG_BUFFERS("dstY: %d\n", dstY);

        DEBUG_BUFFERS("\tfirstLumSrcY: %d lastLumSrcY: %d lastInLumBuf: %d\n",

                         firstLumSrcY,    lastLumSrcY,    lastInLumBuf);

        DEBUG_BUFFERS("\tfirstChrSrcY: %d lastChrSrcY: %d lastInChrBuf: %d\n",

                         firstChrSrcY,    lastChrSrcY,    lastInChrBuf);



        

        enough_lines = lastLumSrcY2 < srcSliceY + srcSliceH && lastChrSrcY < -((-srcSliceY - srcSliceH)>>c->chrSrcVSubSample);



        if (!enough_lines) {

            lastLumSrcY = srcSliceY + srcSliceH - 1;

            lastChrSrcY = chrSrcSliceY + chrSrcSliceH - 1;

            DEBUG_BUFFERS("buffering slice: lastLumSrcY %d lastChrSrcY %d\n",

                                            lastLumSrcY, lastChrSrcY);

        }



        

        while(lastInLumBuf < lastLumSrcY) {

            const uint8_t *src1= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0];

            const uint8_t *src2= src[3]+(lastInLumBuf + 1 - srcSliceY)*srcStride[3];

            lumBufIndex++;

            assert(lumBufIndex < 2*vLumBufSize);

            assert(lastInLumBuf + 1 - srcSliceY < srcSliceH);

            assert(lastInLumBuf + 1 - srcSliceY >= 0);

            hyscale(c, lumPixBuf[ lumBufIndex ], dstW, src1, srcW, lumXInc,

                    hLumFilter, hLumFilterPos, hLumFilterSize,

                    formatConvBuffer,

                    pal, 0);

            if (CONFIG_SWSCALE_ALPHA && alpPixBuf)

                hyscale(c, alpPixBuf[ lumBufIndex ], dstW, src2, srcW,

                        lumXInc, hLumFilter, hLumFilterPos, hLumFilterSize,

                        formatConvBuffer,

                        pal, 1);

            lastInLumBuf++;

            DEBUG_BUFFERS("\t\tlumBufIndex %d: lastInLumBuf: %d\n",

                               lumBufIndex,    lastInLumBuf);

        }

        while(lastInChrBuf < lastChrSrcY) {

            const uint8_t *src1= src[1]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[1];

            const uint8_t *src2= src[2]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[2];

            chrBufIndex++;

            assert(chrBufIndex < 2*vChrBufSize);

            assert(lastInChrBuf + 1 - chrSrcSliceY < (chrSrcSliceH));

            assert(lastInChrBuf + 1 - chrSrcSliceY >= 0);

            



            if (c->needs_hcscale)

                hcscale(c, chrUPixBuf[chrBufIndex], chrVPixBuf[chrBufIndex],

                          chrDstW, src1, src2, chrSrcW, chrXInc,

                          hChrFilter, hChrFilterPos, hChrFilterSize,

                          formatConvBuffer, pal);

            lastInChrBuf++;

            DEBUG_BUFFERS("\t\tchrBufIndex %d: lastInChrBuf: %d\n",

                               chrBufIndex,    lastInChrBuf);

        }

        

        if (lumBufIndex >= vLumBufSize) lumBufIndex-= vLumBufSize;

        if (chrBufIndex >= vChrBufSize) chrBufIndex-= vChrBufSize;

        if (!enough_lines)

            break; 



#if HAVE_MMX

        updateMMXDitherTables(c, dstY, lumBufIndex, chrBufIndex, lastInLumBuf, lastInChrBuf);

#endif

        if (dstY >= dstH-2) {

            

            find_c_packed_planar_out_funcs(c, &yuv2yuv1, &yuv2yuvX,

                                           &yuv2packed1, &yuv2packed2,

                                           &yuv2packedX);

        }



        {

            const int16_t **lumSrcPtr= (const int16_t **) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;

            const int16_t **chrUSrcPtr= (const int16_t **) chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;

            const int16_t **chrVSrcPtr= (const int16_t **) chrVPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;

            const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL;

            if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { 

                const int chrSkipMask= (1<<c->chrDstVSubSample)-1;

                if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; 

                if (c->yuv2yuv1 && vLumFilterSize == 1 && vChrFilterSize == 1) { 

                    const int16_t *lumBuf = lumSrcPtr[0];

                    const int16_t *chrUBuf= chrUSrcPtr[0];

                    const int16_t *chrVBuf= chrVSrcPtr[0];

                    const int16_t *alpBuf= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? alpSrcPtr[0] : NULL;

                    yuv2yuv1(c, lumBuf, chrUBuf, chrVBuf, alpBuf, dest,

                                uDest, vDest, aDest, dstW, chrDstW);

                } else { 

                    yuv2yuvX(c,

                                vLumFilter+dstY*vLumFilterSize   , lumSrcPtr, vLumFilterSize,

                                vChrFilter+chrDstY*vChrFilterSize, chrUSrcPtr,

                                chrVSrcPtr, vChrFilterSize,

                                alpSrcPtr, dest, uDest, vDest, aDest, dstW, chrDstW);

                }

            } else {

                assert(lumSrcPtr  + vLumFilterSize - 1 < lumPixBuf  + vLumBufSize*2);

                assert(chrUSrcPtr + vChrFilterSize - 1 < chrUPixBuf + vChrBufSize*2);

                if (c->yuv2packed1 && vLumFilterSize == 1 && vChrFilterSize == 2) { 

                    int chrAlpha= vChrFilter[2*dstY+1];

                    yuv2packed1(c, *lumSrcPtr, *chrUSrcPtr, *(chrUSrcPtr+1),

                                   *chrVSrcPtr, *(chrVSrcPtr+1),

                                   alpPixBuf ? *alpSrcPtr : NULL,

                                   dest, dstW, chrAlpha, dstFormat, flags, dstY);

                } else if (c->yuv2packed2 && vLumFilterSize == 2 && vChrFilterSize == 2) { 

                    int lumAlpha= vLumFilter[2*dstY+1];

                    int chrAlpha= vChrFilter[2*dstY+1];

                    lumMmxFilter[2]=

                    lumMmxFilter[3]= vLumFilter[2*dstY   ]*0x10001;

                    chrMmxFilter[2]=

                    chrMmxFilter[3]= vChrFilter[2*chrDstY]*0x10001;

                    yuv2packed2(c, *lumSrcPtr, *(lumSrcPtr+1), *chrUSrcPtr, *(chrUSrcPtr+1),

                                   *chrVSrcPtr, *(chrVSrcPtr+1),

                                   alpPixBuf ? *alpSrcPtr : NULL, alpPixBuf ? *(alpSrcPtr+1) : NULL,

                                   dest, dstW, lumAlpha, chrAlpha, dstY);

                } else { 

                    yuv2packedX(c,

                                   vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,

                                   vChrFilter+dstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize,

                                   alpSrcPtr, dest, dstW, dstY);

                }

            }

        }

    }



    if ((dstFormat == PIX_FMT_YUVA420P) && !alpPixBuf)

        fillPlane(dst[3], dstStride[3], dstW, dstY-lastDstY, lastDstY, 255);



#if HAVE_MMX2

    if (av_get_cpu_flags() & AV_CPU_FLAG_MMX2)

        __asm__ volatile("sfence":::"memory");

#endif

    emms_c();



    

    c->dstY= dstY;

    c->lumBufIndex= lumBufIndex;

    c->chrBufIndex= chrBufIndex;

    c->lastInLumBuf= lastInLumBuf;

    c->lastInChrBuf= lastInChrBuf;



    return dstY - lastDstY;

}

static int FUNC_0(SwsContext *VAR_0, const uint8_t* VAR_1[],

                   int VAR_2[], int VAR_3,

                   int VAR_4, uint8_t* VAR_5[], int VAR_6[])

{

    

    const int VAR_7= VAR_0->VAR_7;

    const int VAR_8= VAR_0->VAR_8;

    const int VAR_9= VAR_0->VAR_9;

    const int VAR_10= VAR_0->VAR_10;

    const int VAR_11= VAR_0->VAR_11;

    const int VAR_12= VAR_0->VAR_12;

    const int VAR_13= VAR_0->VAR_13;

    const enum PixelFormat VAR_14= VAR_0->VAR_14;

    const int VAR_15= VAR_0->VAR_15;

    int16_t *vLumFilterPos= VAR_0->vLumFilterPos;

    int16_t *vChrFilterPos= VAR_0->vChrFilterPos;

    int16_t *hLumFilterPos= VAR_0->hLumFilterPos;

    int16_t *hChrFilterPos= VAR_0->hChrFilterPos;

    int16_t *vLumFilter= VAR_0->vLumFilter;

    int16_t *vChrFilter= VAR_0->vChrFilter;

    int16_t *hLumFilter= VAR_0->hLumFilter;

    int16_t *hChrFilter= VAR_0->hChrFilter;

    int32_t *lumMmxFilter= VAR_0->lumMmxFilter;

    int32_t *chrMmxFilter= VAR_0->chrMmxFilter;

    int32_t av_unused *alpMmxFilter= VAR_0->alpMmxFilter;

    const int VAR_16= VAR_0->VAR_16;

    const int VAR_17= VAR_0->VAR_17;

    const int VAR_18= VAR_0->VAR_18;

    const int VAR_19= VAR_0->VAR_19;

    int16_t **lumPixBuf= VAR_0->lumPixBuf;

    int16_t **chrUPixBuf= VAR_0->chrUPixBuf;

    int16_t **chrVPixBuf= VAR_0->chrVPixBuf;

    int16_t **alpPixBuf= VAR_0->alpPixBuf;

    const int VAR_20= VAR_0->VAR_20;

    const int VAR_21= VAR_0->VAR_21;

    uint8_t *formatConvBuffer= VAR_0->formatConvBuffer;

    const int VAR_22= VAR_3 >> VAR_0->chrSrcVSubSample;

    const int VAR_23= -((-VAR_4) >> VAR_0->chrSrcVSubSample);

    int VAR_24;

    uint32_t *pal=VAR_0->pal_yuv;

    yuv2planar1_fn yuv2yuv1 = VAR_0->yuv2yuv1;

    yuv2planarX_fn yuv2yuvX = VAR_0->yuv2yuvX;

    yuv2packed1_fn yuv2packed1 = VAR_0->yuv2packed1;

    yuv2packed2_fn yuv2packed2 = VAR_0->yuv2packed2;

    yuv2packedX_fn yuv2packedX = VAR_0->yuv2packedX;



    

    int VAR_25= VAR_0->VAR_25;

    int VAR_26= VAR_0->VAR_26;

    int VAR_27= VAR_0->VAR_27;

    int VAR_28= VAR_0->VAR_28;

    int VAR_29= VAR_0->VAR_29;



    if (isPacked(VAR_0->srcFormat)) {

        VAR_1[0]=

        VAR_1[1]=

        VAR_1[2]=

        VAR_1[3]= VAR_1[0];

        VAR_2[0]=

        VAR_2[1]=

        VAR_2[2]=

        VAR_2[3]= VAR_2[0];

    }

    VAR_2[1]<<= VAR_0->vChrDrop;

    VAR_2[2]<<= VAR_0->vChrDrop;



    DEBUG_BUFFERS("FUNC_0() %p[%d] %p[%d] %p[%d] %p[%d] -> %p[%d] %p[%d] %p[%d] %p[%d]\n",

                  VAR_1[0], VAR_2[0], VAR_1[1], VAR_2[1], VAR_1[2], VAR_2[2], VAR_1[3], VAR_2[3],

                  VAR_5[0], VAR_6[0], VAR_5[1], VAR_6[1], VAR_5[2], VAR_6[2], VAR_5[3], VAR_6[3]);

    DEBUG_BUFFERS("VAR_3: %d VAR_4: %d VAR_25: %d VAR_9: %d\n",

                   VAR_3,    VAR_4,    VAR_25,    VAR_9);

    DEBUG_BUFFERS("VAR_16: %d VAR_20: %d VAR_17: %d VAR_21: %d\n",

                   VAR_16,    VAR_20,    VAR_17,    VAR_21);



    if (VAR_6[0]%8 !=0 || VAR_6[1]%8 !=0 || VAR_6[2]%8 !=0 || VAR_6[3]%8 != 0) {

        static int VAR_30=0; 

        if (VAR_15 & SWS_PRINT_INFO && !VAR_30) {

            av_log(VAR_0, AV_LOG_WARNING, "Warning: VAR_6 is not aligned!\n"

                   "         ->cannot do aligned memory accesses anymore\n");

            VAR_30=1;

        }

    }



    





    if (VAR_3 ==0) {

        VAR_26=-1;

        VAR_27=-1;

        VAR_25=0;

        VAR_28= -1;

        VAR_29= -1;

    }



    VAR_24= VAR_25;



    for (;VAR_25 < VAR_9; VAR_25++) {

        unsigned char *VAR_31 =VAR_5[0]+VAR_6[0]*VAR_25;

        const int VAR_32= VAR_25>>VAR_0->chrDstVSubSample;

        unsigned char *VAR_33=VAR_5[1]+VAR_6[1]*VAR_32;

        unsigned char *VAR_34=VAR_5[2]+VAR_6[2]*VAR_32;

        unsigned char *VAR_35=(CONFIG_SWSCALE_ALPHA && alpPixBuf) ? VAR_5[3]+VAR_6[3]*VAR_25 : NULL;



        const int VAR_36= vLumFilterPos[VAR_25]; 

        const int VAR_37= vLumFilterPos[FFMIN(VAR_25 | ((1<<VAR_0->chrDstVSubSample) - 1), VAR_9-1)];

        const int VAR_38= vChrFilterPos[VAR_32]; 

        int VAR_39= VAR_36 + VAR_16 -1; 

        int VAR_40=VAR_37+ VAR_16 -1; 

        int VAR_41= VAR_38 + VAR_17 -1; 

        int VAR_42;



        

        if (VAR_36 > VAR_28) VAR_28= VAR_36-1;

        if (VAR_38 > VAR_29) VAR_29= VAR_38-1;

        assert(VAR_36 >= VAR_28 - VAR_20 + 1);

        assert(VAR_38 >= VAR_29 - VAR_21 + 1);



        DEBUG_BUFFERS("VAR_25: %d\n", VAR_25);

        DEBUG_BUFFERS("\tfirstLumSrcY: %d VAR_39: %d VAR_28: %d\n",

                         VAR_36,    VAR_39,    VAR_28);

        DEBUG_BUFFERS("\tfirstChrSrcY: %d VAR_41: %d VAR_29: %d\n",

                         VAR_38,    VAR_41,    VAR_29);



        

        VAR_42 = VAR_40 < VAR_3 + VAR_4 && VAR_41 < -((-VAR_3 - VAR_4)>>VAR_0->chrSrcVSubSample);



        if (!VAR_42) {

            VAR_39 = VAR_3 + VAR_4 - 1;

            VAR_41 = VAR_22 + VAR_23 - 1;

            DEBUG_BUFFERS("buffering slice: VAR_39 %d VAR_41 %d\n",

                                            VAR_39, VAR_41);

        }



        

        while(VAR_28 < VAR_39) {

            const uint8_t *VAR_45= VAR_1[0]+(VAR_28 + 1 - VAR_3)*VAR_2[0];

            const uint8_t *VAR_45= VAR_1[3]+(VAR_28 + 1 - VAR_3)*VAR_2[3];

            VAR_26++;

            assert(VAR_26 < 2*VAR_20);

            assert(VAR_28 + 1 - VAR_3 < VAR_4);

            assert(VAR_28 + 1 - VAR_3 >= 0);

            hyscale(VAR_0, lumPixBuf[ VAR_26 ], VAR_8, VAR_45, VAR_7, VAR_12,

                    hLumFilter, hLumFilterPos, VAR_18,

                    formatConvBuffer,

                    pal, 0);

            if (CONFIG_SWSCALE_ALPHA && alpPixBuf)

                hyscale(VAR_0, alpPixBuf[ VAR_26 ], VAR_8, VAR_45, VAR_7,

                        VAR_12, hLumFilter, hLumFilterPos, VAR_18,

                        formatConvBuffer,

                        pal, 1);

            VAR_28++;

            DEBUG_BUFFERS("\t\tlumBufIndex %d: VAR_28: %d\n",

                               VAR_26,    VAR_28);

        }

        while(VAR_29 < VAR_41) {

            const uint8_t *VAR_45= VAR_1[1]+(VAR_29 + 1 - VAR_22)*VAR_2[1];

            const uint8_t *VAR_45= VAR_1[2]+(VAR_29 + 1 - VAR_22)*VAR_2[2];

            VAR_27++;

            assert(VAR_27 < 2*VAR_21);

            assert(VAR_29 + 1 - VAR_22 < (VAR_23));

            assert(VAR_29 + 1 - VAR_22 >= 0);

            



            if (VAR_0->needs_hcscale)

                hcscale(VAR_0, chrUPixBuf[VAR_27], chrVPixBuf[VAR_27],

                          VAR_10, VAR_45, VAR_45, VAR_11, VAR_13,

                          hChrFilter, hChrFilterPos, VAR_19,

                          formatConvBuffer, pal);

            VAR_29++;

            DEBUG_BUFFERS("\t\tchrBufIndex %d: VAR_29: %d\n",

                               VAR_27,    VAR_29);

        }

        

        if (VAR_26 >= VAR_20) VAR_26-= VAR_20;

        if (VAR_27 >= VAR_21) VAR_27-= VAR_21;

        if (!VAR_42)

            break; 



#if HAVE_MMX

        updateMMXDitherTables(VAR_0, VAR_25, VAR_26, VAR_27, VAR_28, VAR_29);

#endif

        if (VAR_25 >= VAR_9-2) {

            

            find_c_packed_planar_out_funcs(VAR_0, &yuv2yuv1, &yuv2yuvX,

                                           &yuv2packed1, &yuv2packed2,

                                           &yuv2packedX);

        }



        {

            const int16_t **VAR_45= (const int16_t **) lumPixBuf + VAR_26 + VAR_36 - VAR_28 + VAR_20;

            const int16_t **VAR_46= (const int16_t **) chrUPixBuf + VAR_27 + VAR_38 - VAR_29 + VAR_21;

            const int16_t **VAR_47= (const int16_t **) chrVPixBuf + VAR_27 + VAR_38 - VAR_29 + VAR_21;

            const int16_t **VAR_48= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + VAR_26 + VAR_36 - VAR_28 + VAR_20 : NULL;

            if (isPlanarYUV(VAR_14) || VAR_14==PIX_FMT_GRAY8) { 

                const int VAR_49= (1<<VAR_0->chrDstVSubSample)-1;

                if ((VAR_25&VAR_49) || isGray(VAR_14)) VAR_33=VAR_34= NULL; 

                if (VAR_0->yuv2yuv1 && VAR_16 == 1 && VAR_17 == 1) { 

                    const int16_t *VAR_50 = VAR_45[0];

                    const int16_t *VAR_51= VAR_46[0];

                    const int16_t *VAR_52= VAR_47[0];

                    const int16_t *VAR_53= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? VAR_48[0] : NULL;

                    yuv2yuv1(VAR_0, VAR_50, VAR_51, VAR_52, VAR_53, VAR_31,

                                VAR_33, VAR_34, VAR_35, VAR_8, VAR_10);

                } else { 

                    yuv2yuvX(VAR_0,

                                vLumFilter+VAR_25*VAR_16   , VAR_45, VAR_16,

                                vChrFilter+VAR_32*VAR_17, VAR_46,

                                VAR_47, VAR_17,

                                VAR_48, VAR_31, VAR_33, VAR_34, VAR_35, VAR_8, VAR_10);

                }

            } else {

                assert(VAR_45  + VAR_16 - 1 < lumPixBuf  + VAR_20*2);

                assert(VAR_46 + VAR_17 - 1 < chrUPixBuf + VAR_21*2);

                if (VAR_0->yuv2packed1 && VAR_16 == 1 && VAR_17 == 2) { 

                    int VAR_56= vChrFilter[2*VAR_25+1];

                    yuv2packed1(VAR_0, *VAR_45, *VAR_46, *(VAR_46+1),

                                   *VAR_47, *(VAR_47+1),

                                   alpPixBuf ? *VAR_48 : NULL,

                                   VAR_31, VAR_8, VAR_56, VAR_14, VAR_15, VAR_25);

                } else if (VAR_0->yuv2packed2 && VAR_16 == 2 && VAR_17 == 2) { 

                    int VAR_55= vLumFilter[2*VAR_25+1];

                    int VAR_56= vChrFilter[2*VAR_25+1];

                    lumMmxFilter[2]=

                    lumMmxFilter[3]= vLumFilter[2*VAR_25   ]*0x10001;

                    chrMmxFilter[2]=

                    chrMmxFilter[3]= vChrFilter[2*VAR_32]*0x10001;

                    yuv2packed2(VAR_0, *VAR_45, *(VAR_45+1), *VAR_46, *(VAR_46+1),

                                   *VAR_47, *(VAR_47+1),

                                   alpPixBuf ? *VAR_48 : NULL, alpPixBuf ? *(VAR_48+1) : NULL,

                                   VAR_31, VAR_8, VAR_55, VAR_56, VAR_25);

                } else { 

                    yuv2packedX(VAR_0,

                                   vLumFilter+VAR_25*VAR_16, VAR_45, VAR_16,

                                   vChrFilter+VAR_25*VAR_17, VAR_46, VAR_47, VAR_17,

                                   VAR_48, VAR_31, VAR_8, VAR_25);

                }

            }

        }

    }



    if ((VAR_14 == PIX_FMT_YUVA420P) && !alpPixBuf)

        fillPlane(VAR_5[3], VAR_6[3], VAR_8, VAR_25-VAR_24, VAR_24, 255);



#if HAVE_MMX2

    if (av_get_cpu_flags() & AV_CPU_FLAG_MMX2)

        __asm__ volatile("sfence":::"memory");

#endif

    emms_c();



    

    VAR_0->VAR_25= VAR_25;

    VAR_0->VAR_26= VAR_26;

    VAR_0->VAR_27= VAR_27;

    VAR_0->VAR_28= VAR_28;

    VAR_0->VAR_29= VAR_29;



    return VAR_25 - VAR_24;

}

static int FUNC_0(SwsContext *VAR_0, const uint8_t* VAR_1[],
int VAR_2[], int VAR_3,
int VAR_4, uint8_t* VAR_5[], int VAR_6[])
{ const int VAR_7= VAR_0->VAR_7; const int VAR_8= VAR_0->VAR_8; const int VAR_9= VAR_0->VAR_9; const int VAR_10= VAR_0->VAR_10; const int VAR_11= VAR_0->VAR_11; const int VAR_12= VAR_0->VAR_12; const int VAR_13= VAR_0->VAR_13; const enum PixelFormat VAR_14= VAR_0->VAR_14; const int VAR_15= VAR_0->VAR_15; int16_t *vLumFilterPos= VAR_0->vLumFilterPos; int16_t *vChrFilterPos= VAR_0->vChrFilterPos; int16_t *hLumFilterPos= VAR_0->hLumFilterPos; int16_t *hChrFilterPos= VAR_0->hChrFilterPos; int16_t *vLumFilter= VAR_0->vLumFilter; int16_t *vChrFilter= VAR_0->vChrFilter; int16_t *hLumFilter= VAR_0->hLumFilter; int16_t *hChrFilter= VAR_0->hChrFilter; int32_t *lumMmxFilter= VAR_0->lumMmxFilter; int32_t *chrMmxFilter= VAR_0->chrMmxFilter; int32_t av_unused *alpMmxFilter= VAR_0->alpMmxFilter; const int VAR_16= VAR_0->VAR_16; const int VAR_17= VAR_0->VAR_17; const int VAR_18= VAR_0->VAR_18; const int VAR_19= VAR_0->VAR_19; int16_t **lumPixBuf= VAR_0->lumPixBuf; int16_t **chrUPixBuf= VAR_0->chrUPixBuf; int16_t **chrVPixBuf= VAR_0->chrVPixBuf; int16_t **alpPixBuf= VAR_0->alpPixBuf; const int VAR_20= VAR_0->VAR_20; const int VAR_21= VAR_0->VAR_21; uint8_t *formatConvBuffer= VAR_0->formatConvBuffer; const int VAR_22= VAR_3 >> VAR_0->chrSrcVSubSample; const int VAR_23= -((-VAR_4) >> VAR_0->chrSrcVSubSample); int VAR_24; uint32_t *pal=VAR_0->pal_yuv; yuv2planar1_fn yuv2yuv1 = VAR_0->yuv2yuv1; yuv2planarX_fn yuv2yuvX = VAR_0->yuv2yuvX; yuv2packed1_fn yuv2packed1 = VAR_0->yuv2packed1; yuv2packed2_fn yuv2packed2 = VAR_0->yuv2packed2; yuv2packedX_fn yuv2packedX = VAR_0->yuv2packedX; int VAR_25= VAR_0->VAR_25; int VAR_26= VAR_0->VAR_26; int VAR_27= VAR_0->VAR_27; int VAR_28= VAR_0->VAR_28; int VAR_29= VAR_0->VAR_29; if (isPacked(VAR_0->srcFormat)) { VAR_1[0]=
VAR_1[1]=
VAR_1[2]=
VAR_1[3]= VAR_1[0]; VAR_2[0]=
VAR_2[1]=
VAR_2[2]=
VAR_2[3]= VAR_2[0]; } VAR_2[1]<<= VAR_0->vChrDrop; VAR_2[2]<<= VAR_0->vChrDrop; DEBUG_BUFFERS("FUNC_0() %p[%d] %p[%d] %p[%d] %p[%d] -> %p[%d] %p[%d] %p[%d] %p[%d]\n",
VAR_1[0], VAR_2[0], VAR_1[1], VAR_2[1], VAR_1[2], VAR_2[2], VAR_1[3], VAR_2[3],
VAR_5[0], VAR_6[0], VAR_5[1], VAR_6[1], VAR_5[2], VAR_6[2], VAR_5[3], VAR_6[3]); DEBUG_BUFFERS("VAR_3: %d VAR_4: %d VAR_25: %d VAR_9: %d\n",
VAR_3,    VAR_4,    VAR_25,    VAR_9); DEBUG_BUFFERS("VAR_16: %d VAR_20: %d VAR_17: %d VAR_21: %d\n",
VAR_16,    VAR_20,    VAR_17,    VAR_21); if (VAR_6[0]%8 !=0 || VAR_6[1]%8 !=0 || VAR_6[2]%8 !=0 || VAR_6[3]%8 != 0) { static int VAR_30=0; if (VAR_15 & SWS_PRINT_INFO && !VAR_30) { av_log(VAR_0, AV_LOG_WARNING, "Warning: VAR_6 is not aligned!\n"
"         ->cannot do aligned memory accesses anymore\n"); VAR_30=1; } } if (VAR_3 ==0) { VAR_26=-1; VAR_27=-1; VAR_25=0; VAR_28= -1; VAR_29= -1; } VAR_24= VAR_25; for (;VAR_25 < VAR_9; VAR_25++) { unsigned char *VAR_31 =VAR_5[0]+VAR_6[0]*VAR_25; const int VAR_32= VAR_25>>VAR_0->chrDstVSubSample; unsigned char *VAR_33=VAR_5[1]+VAR_6[1]*VAR_32; unsigned char *VAR_34=VAR_5[2]+VAR_6[2]*VAR_32; unsigned char *VAR_35=(CONFIG_SWSCALE_ALPHA && alpPixBuf) ? VAR_5[3]+VAR_6[3]*VAR_25 : NULL; const int VAR_36= vLumFilterPos[VAR_25]; const int VAR_37= vLumFilterPos[FFMIN(VAR_25 | ((1<<VAR_0->chrDstVSubSample) - 1), VAR_9-1)]; const int VAR_38= vChrFilterPos[VAR_32]; int VAR_39= VAR_36 + VAR_16 -1; int VAR_40=VAR_37+ VAR_16 -1; int VAR_41= VAR_38 + VAR_17 -1; int VAR_42; if (VAR_36 > VAR_28) VAR_28= VAR_36-1; if (VAR_38 > VAR_29) VAR_29= VAR_38-1; assert(VAR_36 >= VAR_28 - VAR_20 + 1); assert(VAR_38 >= VAR_29 - VAR_21 + 1); DEBUG_BUFFERS("VAR_25: %d\n", VAR_25); DEBUG_BUFFERS("\tfirstLumSrcY: %d VAR_39: %d VAR_28: %d\n",
VAR_36,    VAR_39,    VAR_28); DEBUG_BUFFERS("\tfirstChrSrcY: %d VAR_41: %d VAR_29: %d\n",
VAR_38,    VAR_41,    VAR_29); VAR_42 = VAR_40 < VAR_3 + VAR_4 && VAR_41 < -((-VAR_3 - VAR_4)>>VAR_0->chrSrcVSubSample); if (!VAR_42) { VAR_39 = VAR_3 + VAR_4 - 1; VAR_41 = VAR_22 + VAR_23 - 1; DEBUG_BUFFERS("buffering slice: VAR_39 %d VAR_41 %d\n",
VAR_39, VAR_41); } while(VAR_28 < VAR_39) { const uint8_t *VAR_45= VAR_1[0]+(VAR_28 + 1 - VAR_3)*VAR_2[0]; const uint8_t *VAR_45= VAR_1[3]+(VAR_28 + 1 - VAR_3)*VAR_2[3]; VAR_26++; assert(VAR_26 < 2*VAR_20); assert(VAR_28 + 1 - VAR_3 < VAR_4); assert(VAR_28 + 1 - VAR_3 >= 0); hyscale(VAR_0, lumPixBuf[ VAR_26 ], VAR_8, VAR_45, VAR_7, VAR_12,
hLumFilter, hLumFilterPos, VAR_18,
formatConvBuffer,
pal, 0); if (CONFIG_SWSCALE_ALPHA && alpPixBuf)
hyscale(VAR_0, alpPixBuf[ VAR_26 ], VAR_8, VAR_45, VAR_7,
VAR_12, hLumFilter, hLumFilterPos, VAR_18,
formatConvBuffer,
pal, 1); VAR_28++; DEBUG_BUFFERS("\t\tlumBufIndex %d: VAR_28: %d\n",
VAR_26,    VAR_28); } while(VAR_29 < VAR_41) { const uint8_t *VAR_45= VAR_1[1]+(VAR_29 + 1 - VAR_22)*VAR_2[1]; const uint8_t *VAR_45= VAR_1[2]+(VAR_29 + 1 - VAR_22)*VAR_2[2]; VAR_27++; assert(VAR_27 < 2*VAR_21); assert(VAR_29 + 1 - VAR_22 < (VAR_23)); assert(VAR_29 + 1 - VAR_22 >= 0); if (VAR_0->needs_hcscale)
hcscale(VAR_0, chrUPixBuf[VAR_27], chrVPixBuf[VAR_27],
VAR_10, VAR_45, VAR_45, VAR_11, VAR_13,
hChrFilter, hChrFilterPos, VAR_19,
formatConvBuffer, pal); VAR_29++; DEBUG_BUFFERS("\t\tchrBufIndex %d: VAR_29: %d\n",
VAR_27,    VAR_29); } if (VAR_26 >= VAR_20) VAR_26-= VAR_20; if (VAR_27 >= VAR_21) VAR_27-= VAR_21; if (!VAR_42)
break; #if HAVE_MMX
updateMMXDitherTables(VAR_0, VAR_25, VAR_26, VAR_27, VAR_28, VAR_29); #endif
if (VAR_25 >= VAR_9-2) { find_c_packed_planar_out_funcs(VAR_0, &yuv2yuv1, &yuv2yuvX,
&yuv2packed1, &yuv2packed2,
&yuv2packedX); } { const int16_t **VAR_45= (const int16_t **) lumPixBuf + VAR_26 + VAR_36 - VAR_28 + VAR_20; const int16_t **VAR_46= (const int16_t **) chrUPixBuf + VAR_27 + VAR_38 - VAR_29 + VAR_21; const int16_t **VAR_47= (const int16_t **) chrVPixBuf + VAR_27 + VAR_38 - VAR_29 + VAR_21; const int16_t **VAR_48= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + VAR_26 + VAR_36 - VAR_28 + VAR_20 : NULL; if (isPlanarYUV(VAR_14) || VAR_14==PIX_FMT_GRAY8) { const int VAR_49= (1<<VAR_0->chrDstVSubSample)-1; if ((VAR_25&VAR_49) || isGray(VAR_14)) VAR_33=VAR_34= NULL; if (VAR_0->yuv2yuv1 && VAR_16 == 1 && VAR_17 == 1) { const int16_t *VAR_50 = VAR_45[0]; const int16_t *VAR_51= VAR_46[0]; const int16_t *VAR_52= VAR_47[0]; const int16_t *VAR_53= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? VAR_48[0] : NULL; yuv2yuv1(VAR_0, VAR_50, VAR_51, VAR_52, VAR_53, VAR_31,
VAR_33, VAR_34, VAR_35, VAR_8, VAR_10); } else { yuv2yuvX(VAR_0,
vLumFilter+VAR_25*VAR_16   , VAR_45, VAR_16,
vChrFilter+VAR_32*VAR_17, VAR_46,
VAR_47, VAR_17,
VAR_48, VAR_31, VAR_33, VAR_34, VAR_35, VAR_8, VAR_10); } } else { assert(VAR_45  + VAR_16 - 1 < lumPixBuf  + VAR_20*2); assert(VAR_46 + VAR_17 - 1 < chrUPixBuf + VAR_21*2); if (VAR_0->yuv2packed1 && VAR_16 == 1 && VAR_17 == 2) { int VAR_56= vChrFilter[2*VAR_25+1]; yuv2packed1(VAR_0, *VAR_45, *VAR_46, *(VAR_46+1),
*VAR_47, *(VAR_47+1),
alpPixBuf ? *VAR_48 : NULL,
VAR_31, VAR_8, VAR_56, VAR_14, VAR_15, VAR_25); } else if (VAR_0->yuv2packed2 && VAR_16 == 2 && VAR_17 == 2) { int VAR_55= vLumFilter[2*VAR_25+1]; int VAR_56= vChrFilter[2*VAR_25+1]; lumMmxFilter[2]=
lumMmxFilter[3]= vLumFilter[2*VAR_25   ]*0x10001; chrMmxFilter[2]=
chrMmxFilter[3]= vChrFilter[2*VAR_32]*0x10001; yuv2packed2(VAR_0, *VAR_45, *(VAR_45+1), *VAR_46, *(VAR_46+1),
*VAR_47, *(VAR_47+1),
alpPixBuf ? *VAR_48 : NULL, alpPixBuf ? *(VAR_48+1) : NULL,
VAR_31, VAR_8, VAR_55, VAR_56, VAR_25); } else { yuv2packedX(VAR_0,
vLumFilter+VAR_25*VAR_16, VAR_45, VAR_16,
vChrFilter+VAR_25*VAR_17, VAR_46, VAR_47, VAR_17,
VAR_48, VAR_31, VAR_8, VAR_25); } } } } if ((VAR_14 == PIX_FMT_YUVA420P) && !alpPixBuf)
fillPlane(VAR_5[3], VAR_6[3], VAR_8, VAR_25-VAR_24, VAR_24, 255); #if HAVE_MMX2
if (av_get_cpu_flags() & AV_CPU_FLAG_MMX2)
__asm__ volatile("sfence":::"memory"); #endif
emms_c(); VAR_0->VAR_25= VAR_25; VAR_0->VAR_26= VAR_26; VAR_0->VAR_27= VAR_27; VAR_0->VAR_28= VAR_28; VAR_0->VAR_29= VAR_29; return VAR_25 - VAR_24; }