static void RENAME(postProcess)(const uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height,

                                const QP_STORE_T QPs[], int QPStride, int isColor, PPContext *c2)

{

    DECLARE_ALIGNED(8, PPContext, c)= *c2; //copy to stack for faster access

    int x,y;

#ifdef TEMPLATE_PP_TIME_MODE

    const int mode= TEMPLATE_PP_TIME_MODE;

#else

    const int mode= isColor ? c.ppMode.chromMode : c.ppMode.lumMode;

#endif

    int black=0, white=255; // blackest black and whitest white in the picture

    int QPCorrecture= 256*256;



    int copyAhead;

#if TEMPLATE_PP_MMX

    int i;

#endif



    const int qpHShift= isColor ? 4-c.hChromaSubSample : 4;

    const int qpVShift= isColor ? 4-c.vChromaSubSample : 4;



    //FIXME remove

    uint64_t * const yHistogram= c.yHistogram;

    uint8_t * const tempSrc= srcStride > 0 ? c.tempSrc : c.tempSrc - 23*srcStride;

    uint8_t * const tempDst= (dstStride > 0 ? c.tempDst : c.tempDst - 23*dstStride) + 32;

    //const int mbWidth= isColor ? (width+7)>>3 : (width+15)>>4;



    if (mode & VISUALIZE){

        if(!(mode & (V_A_DEBLOCK | H_A_DEBLOCK)) || TEMPLATE_PP_MMX) {

            av_log(c2, AV_LOG_WARNING, "Visualization is currently only supported with the accurate deblock filter without SIMD\n");

        }

    }



#if TEMPLATE_PP_MMX

    for(i=0; i<57; i++){

        int offset= ((i*c.ppMode.baseDcDiff)>>8) + 1;

        int threshold= offset*2 + 1;

        c.mmxDcOffset[i]= 0x7F - offset;

        c.mmxDcThreshold[i]= 0x7F - threshold;

        c.mmxDcOffset[i]*= 0x0101010101010101LL;

        c.mmxDcThreshold[i]*= 0x0101010101010101LL;

    }

#endif



    if(mode & CUBIC_IPOL_DEINT_FILTER) copyAhead=16;

    else if(   (mode & LINEAR_BLEND_DEINT_FILTER)

            || (mode & FFMPEG_DEINT_FILTER)

            || (mode & LOWPASS5_DEINT_FILTER)) copyAhead=14;

    else if(   (mode & V_DEBLOCK)

            || (mode & LINEAR_IPOL_DEINT_FILTER)

            || (mode & MEDIAN_DEINT_FILTER)

            || (mode & V_A_DEBLOCK)) copyAhead=13;

    else if(mode & V_X1_FILTER) copyAhead=11;

//    else if(mode & V_RK1_FILTER) copyAhead=10;

    else if(mode & DERING) copyAhead=9;

    else copyAhead=8;



    copyAhead-= 8;



    if(!isColor){

        uint64_t sum= 0;

        int i;

        uint64_t maxClipped;

        uint64_t clipped;

        double scale;



        c.frameNum++;

        // first frame is fscked so we ignore it

        if(c.frameNum == 1) yHistogram[0]= width*(uint64_t)height/64*15/256;



        for(i=0; i<256; i++){

            sum+= yHistogram[i];

        }



        /* We always get a completely black picture first. */

        maxClipped= (uint64_t)(sum * c.ppMode.maxClippedThreshold);



        clipped= sum;

        for(black=255; black>0; black--){

            if(clipped < maxClipped) break;

            clipped-= yHistogram[black];

        }



        clipped= sum;

        for(white=0; white<256; white++){

            if(clipped < maxClipped) break;

            clipped-= yHistogram[white];

        }



        scale= (double)(c.ppMode.maxAllowedY - c.ppMode.minAllowedY) / (double)(white-black);



#if TEMPLATE_PP_MMXEXT

        c.packedYScale= (uint16_t)(scale*256.0 + 0.5);

        c.packedYOffset= (((black*c.packedYScale)>>8) - c.ppMode.minAllowedY) & 0xFFFF;

#else

        c.packedYScale= (uint16_t)(scale*1024.0 + 0.5);

        c.packedYOffset= (black - c.ppMode.minAllowedY) & 0xFFFF;

#endif



        c.packedYOffset|= c.packedYOffset<<32;

        c.packedYOffset|= c.packedYOffset<<16;



        c.packedYScale|= c.packedYScale<<32;

        c.packedYScale|= c.packedYScale<<16;



        if(mode & LEVEL_FIX)        QPCorrecture= (int)(scale*256*256 + 0.5);

        else                        QPCorrecture= 256*256;

    }else{

        c.packedYScale= 0x0100010001000100LL;

        c.packedYOffset= 0;

        QPCorrecture= 256*256;

    }



    /* copy & deinterlace first row of blocks */

    y=-BLOCK_SIZE;

    {

        const uint8_t *srcBlock= &(src[y*srcStride]);

        uint8_t *dstBlock= tempDst + dstStride;



        // From this point on it is guaranteed that we can read and write 16 lines downward

        // finish 1 block before the next otherwise we might have a problem

        // with the L1 Cache of the P4 ... or only a few blocks at a time or something

        for(x=0; x<width; x+=BLOCK_SIZE){



#if TEMPLATE_PP_MMXEXT && HAVE_6REGS

/*

            prefetchnta(srcBlock + (((x>>2)&6) + 5)*srcStride + 32);

            prefetchnta(srcBlock + (((x>>2)&6) + 6)*srcStride + 32);

            prefetcht0(dstBlock + (((x>>2)&6) + 5)*dstStride + 32);

            prefetcht0(dstBlock + (((x>>2)&6) + 6)*dstStride + 32);

*/



            __asm__(

                "mov %4, %%"REG_a"              \n\t"

                "shr $2, %%"REG_a"              \n\t"

                "and $6, %%"REG_a"              \n\t"

                "add %5, %%"REG_a"              \n\t"

                "mov %%"REG_a", %%"REG_d"       \n\t"

                "imul %1, %%"REG_a"             \n\t"

                "imul %3, %%"REG_d"             \n\t"

                "prefetchnta 32(%%"REG_a", %0)  \n\t"

                "prefetcht0 32(%%"REG_d", %2)   \n\t"

                "add %1, %%"REG_a"              \n\t"

                "add %3, %%"REG_d"              \n\t"

                "prefetchnta 32(%%"REG_a", %0)  \n\t"

                "prefetcht0 32(%%"REG_d", %2)   \n\t"

                :: "r" (srcBlock), "r" ((x86_reg)srcStride), "r" (dstBlock), "r" ((x86_reg)dstStride),

                "g" ((x86_reg)x), "g" ((x86_reg)copyAhead)

                : "%"REG_a, "%"REG_d

            );



#elif TEMPLATE_PP_3DNOW

//FIXME check if this is faster on an 3dnow chip or if it is faster without the prefetch or ...

/*          prefetch(srcBlock + (((x>>3)&3) + 5)*srcStride + 32);

            prefetch(srcBlock + (((x>>3)&3) + 9)*srcStride + 32);

            prefetchw(dstBlock + (((x>>3)&3) + 5)*dstStride + 32);

            prefetchw(dstBlock + (((x>>3)&3) + 9)*dstStride + 32);

*/

#endif



            RENAME(blockCopy)(dstBlock + dstStride*8, dstStride,

                              srcBlock + srcStride*8, srcStride, mode & LEVEL_FIX, &c.packedYOffset);



            RENAME(duplicate)(dstBlock + dstStride*8, dstStride);



            if(mode & LINEAR_IPOL_DEINT_FILTER)

                RENAME(deInterlaceInterpolateLinear)(dstBlock, dstStride);

            else if(mode & LINEAR_BLEND_DEINT_FILTER)

                RENAME(deInterlaceBlendLinear)(dstBlock, dstStride, c.deintTemp + x);

            else if(mode & MEDIAN_DEINT_FILTER)

                RENAME(deInterlaceMedian)(dstBlock, dstStride);

            else if(mode & CUBIC_IPOL_DEINT_FILTER)

                RENAME(deInterlaceInterpolateCubic)(dstBlock, dstStride);

            else if(mode & FFMPEG_DEINT_FILTER)

                RENAME(deInterlaceFF)(dstBlock, dstStride, c.deintTemp + x);

            else if(mode & LOWPASS5_DEINT_FILTER)

                RENAME(deInterlaceL5)(dstBlock, dstStride, c.deintTemp + x, c.deintTemp + width + x);

/*          else if(mode & CUBIC_BLEND_DEINT_FILTER)

                RENAME(deInterlaceBlendCubic)(dstBlock, dstStride);

*/

            dstBlock+=8;

            srcBlock+=8;

        }

        if(width==FFABS(dstStride))

            linecpy(dst, tempDst + 9*dstStride, copyAhead, dstStride);

        else{

            int i;

            for(i=0; i<copyAhead; i++){

                memcpy(dst + i*dstStride, tempDst + (9+i)*dstStride, width);

            }

        }

    }



    for(y=0; y<height; y+=BLOCK_SIZE){

        //1% speedup if these are here instead of the inner loop

        const uint8_t *srcBlock= &(src[y*srcStride]);

        uint8_t *dstBlock= &(dst[y*dstStride]);

#if TEMPLATE_PP_MMX

        uint8_t *tempBlock1= c.tempBlocks;

        uint8_t *tempBlock2= c.tempBlocks + 8;

#endif

        const int8_t *QPptr= &QPs[(y>>qpVShift)*QPStride];

        int8_t *nonBQPptr= &c.nonBQPTable[(y>>qpVShift)*FFABS(QPStride)];

        int QP=0;

        /* can we mess with a 8x16 block from srcBlock/dstBlock downwards and 1 line upwards

           if not than use a temporary buffer */

        if(y+15 >= height){

            int i;

            /* copy from line (copyAhead) to (copyAhead+7) of src, these will be copied with

               blockcopy to dst later */

            linecpy(tempSrc + srcStride*copyAhead, srcBlock + srcStride*copyAhead,

                    FFMAX(height-y-copyAhead, 0), srcStride);



            /* duplicate last line of src to fill the void up to line (copyAhead+7) */

            for(i=FFMAX(height-y, 8); i<copyAhead+8; i++)

                    memcpy(tempSrc + srcStride*i, src + srcStride*(height-1), FFABS(srcStride));



            /* copy up to (copyAhead+1) lines of dst (line -1 to (copyAhead-1))*/

            linecpy(tempDst, dstBlock - dstStride, FFMIN(height-y+1, copyAhead+1), dstStride);



            /* duplicate last line of dst to fill the void up to line (copyAhead) */

            for(i=height-y+1; i<=copyAhead; i++)

                    memcpy(tempDst + dstStride*i, dst + dstStride*(height-1), FFABS(dstStride));



            dstBlock= tempDst + dstStride;

            srcBlock= tempSrc;

        }



        // From this point on it is guaranteed that we can read and write 16 lines downward

        // finish 1 block before the next otherwise we might have a problem

        // with the L1 Cache of the P4 ... or only a few blocks at a time or something

        for(x=0; x<width; x+=BLOCK_SIZE){

            const int stride= dstStride;

#if TEMPLATE_PP_MMX

            uint8_t *tmpXchg;

#endif

            if(isColor){

                QP= QPptr[x>>qpHShift];

                c.nonBQP= nonBQPptr[x>>qpHShift];

            }else{

                QP= QPptr[x>>4];

                QP= (QP* QPCorrecture + 256*128)>>16;

                c.nonBQP= nonBQPptr[x>>4];

                c.nonBQP= (c.nonBQP* QPCorrecture + 256*128)>>16;

                yHistogram[ srcBlock[srcStride*12 + 4] ]++;

            }

            c.QP= QP;

#if TEMPLATE_PP_MMX

            __asm__ volatile(

                "movd %1, %%mm7         \n\t"

                "packuswb %%mm7, %%mm7  \n\t" // 0, 0, 0, QP, 0, 0, 0, QP

                "packuswb %%mm7, %%mm7  \n\t" // 0,QP, 0, QP, 0,QP, 0, QP

                "packuswb %%mm7, %%mm7  \n\t" // QP,..., QP

                "movq %%mm7, %0         \n\t"

                : "=m" (c.pQPb)

                : "r" (QP)

            );

#endif





#if TEMPLATE_PP_MMXEXT && HAVE_6REGS

/*

            prefetchnta(srcBlock + (((x>>2)&6) + 5)*srcStride + 32);

            prefetchnta(srcBlock + (((x>>2)&6) + 6)*srcStride + 32);

            prefetcht0(dstBlock + (((x>>2)&6) + 5)*dstStride + 32);

            prefetcht0(dstBlock + (((x>>2)&6) + 6)*dstStride + 32);

*/



            __asm__(

                "mov %4, %%"REG_a"              \n\t"

                "shr $2, %%"REG_a"              \n\t"

                "and $6, %%"REG_a"              \n\t"

                "add %5, %%"REG_a"              \n\t"

                "mov %%"REG_a", %%"REG_d"       \n\t"

                "imul %1, %%"REG_a"             \n\t"

                "imul %3, %%"REG_d"             \n\t"

                "prefetchnta 32(%%"REG_a", %0)  \n\t"

                "prefetcht0 32(%%"REG_d", %2)   \n\t"

                "add %1, %%"REG_a"              \n\t"

                "add %3, %%"REG_d"              \n\t"

                "prefetchnta 32(%%"REG_a", %0)  \n\t"

                "prefetcht0 32(%%"REG_d", %2)   \n\t"

                :: "r" (srcBlock), "r" ((x86_reg)srcStride), "r" (dstBlock), "r" ((x86_reg)dstStride),

                "g" ((x86_reg)x), "g" ((x86_reg)copyAhead)

                : "%"REG_a, "%"REG_d

            );



#elif TEMPLATE_PP_3DNOW

//FIXME check if this is faster on an 3dnow chip or if it is faster without the prefetch or ...

/*          prefetch(srcBlock + (((x>>3)&3) + 5)*srcStride + 32);

            prefetch(srcBlock + (((x>>3)&3) + 9)*srcStride + 32);

            prefetchw(dstBlock + (((x>>3)&3) + 5)*dstStride + 32);

            prefetchw(dstBlock + (((x>>3)&3) + 9)*dstStride + 32);

*/

#endif



            RENAME(blockCopy)(dstBlock + dstStride*copyAhead, dstStride,

                              srcBlock + srcStride*copyAhead, srcStride, mode & LEVEL_FIX, &c.packedYOffset);



            if(mode & LINEAR_IPOL_DEINT_FILTER)

                RENAME(deInterlaceInterpolateLinear)(dstBlock, dstStride);

            else if(mode & LINEAR_BLEND_DEINT_FILTER)

                RENAME(deInterlaceBlendLinear)(dstBlock, dstStride, c.deintTemp + x);

            else if(mode & MEDIAN_DEINT_FILTER)

                RENAME(deInterlaceMedian)(dstBlock, dstStride);

            else if(mode & CUBIC_IPOL_DEINT_FILTER)

                RENAME(deInterlaceInterpolateCubic)(dstBlock, dstStride);

            else if(mode & FFMPEG_DEINT_FILTER)

                RENAME(deInterlaceFF)(dstBlock, dstStride, c.deintTemp + x);

            else if(mode & LOWPASS5_DEINT_FILTER)

                RENAME(deInterlaceL5)(dstBlock, dstStride, c.deintTemp + x, c.deintTemp + width + x);

/*          else if(mode & CUBIC_BLEND_DEINT_FILTER)

                RENAME(deInterlaceBlendCubic)(dstBlock, dstStride);

*/



            /* only deblock if we have 2 blocks */

            if(y + 8 < height){

                if(mode & V_X1_FILTER)

                    RENAME(vertX1Filter)(dstBlock, stride, &c);

                else if(mode & V_DEBLOCK){

                    const int t= RENAME(vertClassify)(dstBlock, stride, &c);



                    if(t==1)

                        RENAME(doVertLowPass)(dstBlock, stride, &c);

                    else if(t==2)

                        RENAME(doVertDefFilter)(dstBlock, stride, &c);

                }else if(mode & V_A_DEBLOCK){

                    RENAME(do_a_deblock)(dstBlock, stride, 1, &c, mode);

                }

            }



#if TEMPLATE_PP_MMX

            RENAME(transpose1)(tempBlock1, tempBlock2, dstBlock, dstStride);

#endif

            /* check if we have a previous block to deblock it with dstBlock */

            if(x - 8 >= 0){

#if TEMPLATE_PP_MMX

                if(mode & H_X1_FILTER)

                        RENAME(vertX1Filter)(tempBlock1, 16, &c);

                else if(mode & H_DEBLOCK){

//START_TIMER

                    const int t= RENAME(vertClassify)(tempBlock1, 16, &c);

//STOP_TIMER("dc & minmax")

                    if(t==1)

                        RENAME(doVertLowPass)(tempBlock1, 16, &c);

                    else if(t==2)

                        RENAME(doVertDefFilter)(tempBlock1, 16, &c);

                }else if(mode & H_A_DEBLOCK){

                        RENAME(do_a_deblock)(tempBlock1, 16, 1, &c, mode);

                }



                RENAME(transpose2)(dstBlock-4, dstStride, tempBlock1 + 4*16);



#else

                if(mode & H_X1_FILTER)

                    horizX1Filter(dstBlock-4, stride, QP);

                else if(mode & H_DEBLOCK){

#if TEMPLATE_PP_ALTIVEC

                    DECLARE_ALIGNED(16, unsigned char, tempBlock)[272];

                    int t;

                    transpose_16x8_char_toPackedAlign_altivec(tempBlock, dstBlock - (4 + 1), stride);



                    t = vertClassify_altivec(tempBlock-48, 16, &c);

                    if(t==1) {

                        doVertLowPass_altivec(tempBlock-48, 16, &c);

                        transpose_8x16_char_fromPackedAlign_altivec(dstBlock - (4 + 1), tempBlock, stride);

                    }

                    else if(t==2) {

                        doVertDefFilter_altivec(tempBlock-48, 16, &c);

                        transpose_8x16_char_fromPackedAlign_altivec(dstBlock - (4 + 1), tempBlock, stride);

                    }

#else

                    const int t= RENAME(horizClassify)(dstBlock-4, stride, &c);



                    if(t==1)

                        RENAME(doHorizLowPass)(dstBlock-4, stride, &c);

                    else if(t==2)

                        RENAME(doHorizDefFilter)(dstBlock-4, stride, &c);

#endif

                }else if(mode & H_A_DEBLOCK){

                    RENAME(do_a_deblock)(dstBlock-8, 1, stride, &c, mode);

                }

#endif //TEMPLATE_PP_MMX

                if(mode & DERING){

                //FIXME filter first line

                    if(y>0) RENAME(dering)(dstBlock - stride - 8, stride, &c);

                }



                if(mode & TEMP_NOISE_FILTER)

                {

                    RENAME(tempNoiseReducer)(dstBlock-8, stride,

                            c.tempBlurred[isColor] + y*dstStride + x,

                            c.tempBlurredPast[isColor] + (y>>3)*256 + (x>>3) + 256,

                            c.ppMode.maxTmpNoise);

                }

            }



            dstBlock+=8;

            srcBlock+=8;



#if TEMPLATE_PP_MMX

            tmpXchg= tempBlock1;

            tempBlock1= tempBlock2;

            tempBlock2 = tmpXchg;

#endif

        }



        if(mode & DERING){

            if(y > 0) RENAME(dering)(dstBlock - dstStride - 8, dstStride, &c);

        }



        if((mode & TEMP_NOISE_FILTER)){

            RENAME(tempNoiseReducer)(dstBlock-8, dstStride,

                    c.tempBlurred[isColor] + y*dstStride + x,

                    c.tempBlurredPast[isColor] + (y>>3)*256 + (x>>3) + 256,

                    c.ppMode.maxTmpNoise);

        }



        /* did we use a tmp buffer for the last lines*/

        if(y+15 >= height){

            uint8_t *dstBlock= &(dst[y*dstStride]);

            if(width==FFABS(dstStride))

                linecpy(dstBlock, tempDst + dstStride, height-y, dstStride);

            else{

                int i;

                for(i=0; i<height-y; i++){

                    memcpy(dstBlock + i*dstStride, tempDst + (i+1)*dstStride, width);

                }

            }

        }

/*

        for(x=0; x<width; x+=32){

            volatile int i;

            i+=   dstBlock[x + 7*dstStride] + dstBlock[x + 8*dstStride]

                + dstBlock[x + 9*dstStride] + dstBlock[x +10*dstStride]

                + dstBlock[x +11*dstStride] + dstBlock[x +12*dstStride];

                + dstBlock[x +13*dstStride]

                + dstBlock[x +14*dstStride] + dstBlock[x +15*dstStride];

        }*/

    }

#if   TEMPLATE_PP_3DNOW

    __asm__ volatile("femms");

#elif TEMPLATE_PP_MMX

    __asm__ volatile("emms");

#endif



#ifdef DEBUG_BRIGHTNESS

    if(!isColor){

        int max=1;

        int i;

        for(i=0; i<256; i++)

            if(yHistogram[i] > max) max=yHistogram[i];



        for(i=1; i<256; i++){

            int x;

            int start=yHistogram[i-1]/(max/256+1);

            int end=yHistogram[i]/(max/256+1);

            int inc= end > start ? 1 : -1;

            for(x=start; x!=end+inc; x+=inc)

                dst[ i*dstStride + x]+=128;

        }



        for(i=0; i<100; i+=2){

            dst[ (white)*dstStride + i]+=128;

            dst[ (black)*dstStride + i]+=128;

        }

    }

#endif



    *c2= c; //copy local context back



}

static void RENAME(postProcess)(const uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height,

                                const QP_STORE_T QPs[], int QPStride, int isColor, PPContext *c2)

{

    DECLARE_ALIGNED(8, PPContext, c)= *c2; 

    int x,y;

#ifdef TEMPLATE_PP_TIME_MODE

    const int mode= TEMPLATE_PP_TIME_MODE;

#else

    const int mode= isColor ? c.ppMode.chromMode : c.ppMode.lumMode;

#endif

    int black=0, white=255; 

    int QPCorrecture= 256*256;



    int copyAhead;

#if TEMPLATE_PP_MMX

    int i;

#endif



    const int qpHShift= isColor ? 4-c.hChromaSubSample : 4;

    const int qpVShift= isColor ? 4-c.vChromaSubSample : 4;



    

    uint64_t * const yHistogram= c.yHistogram;

    uint8_t * const tempSrc= srcStride > 0 ? c.tempSrc : c.tempSrc - 23*srcStride;

    uint8_t * const tempDst= (dstStride > 0 ? c.tempDst : c.tempDst - 23*dstStride) + 32;

    



    if (mode & VISUALIZE){

        if(!(mode & (V_A_DEBLOCK | H_A_DEBLOCK)) || TEMPLATE_PP_MMX) {

            av_log(c2, AV_LOG_WARNING, "Visualization is currently only supported with the accurate deblock filter without SIMD\n");

        }

    }



#if TEMPLATE_PP_MMX

    for(i=0; i<57; i++){

        int offset= ((i*c.ppMode.baseDcDiff)>>8) + 1;

        int threshold= offset*2 + 1;

        c.mmxDcOffset[i]= 0x7F - offset;

        c.mmxDcThreshold[i]= 0x7F - threshold;

        c.mmxDcOffset[i]*= 0x0101010101010101LL;

        c.mmxDcThreshold[i]*= 0x0101010101010101LL;

    }

#endif



    if(mode & CUBIC_IPOL_DEINT_FILTER) copyAhead=16;

    else if(   (mode & LINEAR_BLEND_DEINT_FILTER)

            || (mode & FFMPEG_DEINT_FILTER)

            || (mode & LOWPASS5_DEINT_FILTER)) copyAhead=14;

    else if(   (mode & V_DEBLOCK)

            || (mode & LINEAR_IPOL_DEINT_FILTER)

            || (mode & MEDIAN_DEINT_FILTER)

            || (mode & V_A_DEBLOCK)) copyAhead=13;

    else if(mode & V_X1_FILTER) copyAhead=11;



    else if(mode & DERING) copyAhead=9;

    else copyAhead=8;



    copyAhead-= 8;



    if(!isColor){

        uint64_t sum= 0;

        int i;

        uint64_t maxClipped;

        uint64_t clipped;

        double scale;



        c.frameNum++;

        

        if(c.frameNum == 1) yHistogram[0]= width*(uint64_t)height/64*15/256;



        for(i=0; i<256; i++){

            sum+= yHistogram[i];

        }



        

        maxClipped= (uint64_t)(sum * c.ppMode.maxClippedThreshold);



        clipped= sum;

        for(black=255; black>0; black--){

            if(clipped < maxClipped) break;

            clipped-= yHistogram[black];

        }



        clipped= sum;

        for(white=0; white<256; white++){

            if(clipped < maxClipped) break;

            clipped-= yHistogram[white];

        }



        scale= (double)(c.ppMode.maxAllowedY - c.ppMode.minAllowedY) / (double)(white-black);



#if TEMPLATE_PP_MMXEXT

        c.packedYScale= (uint16_t)(scale*256.0 + 0.5);

        c.packedYOffset= (((black*c.packedYScale)>>8) - c.ppMode.minAllowedY) & 0xFFFF;

#else

        c.packedYScale= (uint16_t)(scale*1024.0 + 0.5);

        c.packedYOffset= (black - c.ppMode.minAllowedY) & 0xFFFF;

#endif



        c.packedYOffset|= c.packedYOffset<<32;

        c.packedYOffset|= c.packedYOffset<<16;



        c.packedYScale|= c.packedYScale<<32;

        c.packedYScale|= c.packedYScale<<16;



        if(mode & LEVEL_FIX)        QPCorrecture= (int)(scale*256*256 + 0.5);

        else                        QPCorrecture= 256*256;

    }else{

        c.packedYScale= 0x0100010001000100LL;

        c.packedYOffset= 0;

        QPCorrecture= 256*256;

    }



    

    y=-BLOCK_SIZE;

    {

        const uint8_t *srcBlock= &(src[y*srcStride]);

        uint8_t *dstBlock= tempDst + dstStride;



        

        

        

        for(x=0; x<width; x+=BLOCK_SIZE){



#if TEMPLATE_PP_MMXEXT && HAVE_6REGS















            __asm__(

                "mov %4, %%"REG_a"              \n\t"

                "shr $2, %%"REG_a"              \n\t"

                "and $6, %%"REG_a"              \n\t"

                "add %5, %%"REG_a"              \n\t"

                "mov %%"REG_a", %%"REG_d"       \n\t"

                "imul %1, %%"REG_a"             \n\t"

                "imul %3, %%"REG_d"             \n\t"

                "prefetchnta 32(%%"REG_a", %0)  \n\t"

                "prefetcht0 32(%%"REG_d", %2)   \n\t"

                "add %1, %%"REG_a"              \n\t"

                "add %3, %%"REG_d"              \n\t"

                "prefetchnta 32(%%"REG_a", %0)  \n\t"

                "prefetcht0 32(%%"REG_d", %2)   \n\t"

                :: "r" (srcBlock), "r" ((x86_reg)srcStride), "r" (dstBlock), "r" ((x86_reg)dstStride),

                "g" ((x86_reg)x), "g" ((x86_reg)copyAhead)

                : "%"REG_a, "%"REG_d

            );



#elif TEMPLATE_PP_3DNOW













#endif



            RENAME(blockCopy)(dstBlock + dstStride*8, dstStride,

                              srcBlock + srcStride*8, srcStride, mode & LEVEL_FIX, &c.packedYOffset);



            RENAME(duplicate)(dstBlock + dstStride*8, dstStride);



            if(mode & LINEAR_IPOL_DEINT_FILTER)

                RENAME(deInterlaceInterpolateLinear)(dstBlock, dstStride);

            else if(mode & LINEAR_BLEND_DEINT_FILTER)

                RENAME(deInterlaceBlendLinear)(dstBlock, dstStride, c.deintTemp + x);

            else if(mode & MEDIAN_DEINT_FILTER)

                RENAME(deInterlaceMedian)(dstBlock, dstStride);

            else if(mode & CUBIC_IPOL_DEINT_FILTER)

                RENAME(deInterlaceInterpolateCubic)(dstBlock, dstStride);

            else if(mode & FFMPEG_DEINT_FILTER)

                RENAME(deInterlaceFF)(dstBlock, dstStride, c.deintTemp + x);

            else if(mode & LOWPASS5_DEINT_FILTER)

                RENAME(deInterlaceL5)(dstBlock, dstStride, c.deintTemp + x, c.deintTemp + width + x);







            dstBlock+=8;

            srcBlock+=8;

        }

        if(width==FFABS(dstStride))

            linecpy(dst, tempDst + 9*dstStride, copyAhead, dstStride);

        else{

            int i;

            for(i=0; i<copyAhead; i++){

                memcpy(dst + i*dstStride, tempDst + (9+i)*dstStride, width);

            }

        }

    }



    for(y=0; y<height; y+=BLOCK_SIZE){

        

        const uint8_t *srcBlock= &(src[y*srcStride]);

        uint8_t *dstBlock= &(dst[y*dstStride]);

#if TEMPLATE_PP_MMX

        uint8_t *tempBlock1= c.tempBlocks;

        uint8_t *tempBlock2= c.tempBlocks + 8;

#endif

        const int8_t *QPptr= &QPs[(y>>qpVShift)*QPStride];

        int8_t *nonBQPptr= &c.nonBQPTable[(y>>qpVShift)*FFABS(QPStride)];

        int QP=0;

        



        if(y+15 >= height){

            int i;

            



            linecpy(tempSrc + srcStride*copyAhead, srcBlock + srcStride*copyAhead,

                    FFMAX(height-y-copyAhead, 0), srcStride);



            

            for(i=FFMAX(height-y, 8); i<copyAhead+8; i++)

                    memcpy(tempSrc + srcStride*i, src + srcStride*(height-1), FFABS(srcStride));



            

            linecpy(tempDst, dstBlock - dstStride, FFMIN(height-y+1, copyAhead+1), dstStride);



            

            for(i=height-y+1; i<=copyAhead; i++)

                    memcpy(tempDst + dstStride*i, dst + dstStride*(height-1), FFABS(dstStride));



            dstBlock= tempDst + dstStride;

            srcBlock= tempSrc;

        }



        

        

        

        for(x=0; x<width; x+=BLOCK_SIZE){

            const int stride= dstStride;

#if TEMPLATE_PP_MMX

            uint8_t *tmpXchg;

#endif

            if(isColor){

                QP= QPptr[x>>qpHShift];

                c.nonBQP= nonBQPptr[x>>qpHShift];

            }else{

                QP= QPptr[x>>4];

                QP= (QP* QPCorrecture + 256*128)>>16;

                c.nonBQP= nonBQPptr[x>>4];

                c.nonBQP= (c.nonBQP* QPCorrecture + 256*128)>>16;

                yHistogram[ srcBlock[srcStride*12 + 4] ]++;

            }

            c.QP= QP;

#if TEMPLATE_PP_MMX

            __asm__ volatile(

                "movd %1, %%mm7         \n\t"

                "packuswb %%mm7, %%mm7  \n\t" 

                "packuswb %%mm7, %%mm7  \n\t" 

                "packuswb %%mm7, %%mm7  \n\t" 

                "movq %%mm7, %0         \n\t"

                : "=m" (c.pQPb)

                : "r" (QP)

            );

#endif





#if TEMPLATE_PP_MMXEXT && HAVE_6REGS















            __asm__(

                "mov %4, %%"REG_a"              \n\t"

                "shr $2, %%"REG_a"              \n\t"

                "and $6, %%"REG_a"              \n\t"

                "add %5, %%"REG_a"              \n\t"

                "mov %%"REG_a", %%"REG_d"       \n\t"

                "imul %1, %%"REG_a"             \n\t"

                "imul %3, %%"REG_d"             \n\t"

                "prefetchnta 32(%%"REG_a", %0)  \n\t"

                "prefetcht0 32(%%"REG_d", %2)   \n\t"

                "add %1, %%"REG_a"              \n\t"

                "add %3, %%"REG_d"              \n\t"

                "prefetchnta 32(%%"REG_a", %0)  \n\t"

                "prefetcht0 32(%%"REG_d", %2)   \n\t"

                :: "r" (srcBlock), "r" ((x86_reg)srcStride), "r" (dstBlock), "r" ((x86_reg)dstStride),

                "g" ((x86_reg)x), "g" ((x86_reg)copyAhead)

                : "%"REG_a, "%"REG_d

            );



#elif TEMPLATE_PP_3DNOW













#endif



            RENAME(blockCopy)(dstBlock + dstStride*copyAhead, dstStride,

                              srcBlock + srcStride*copyAhead, srcStride, mode & LEVEL_FIX, &c.packedYOffset);



            if(mode & LINEAR_IPOL_DEINT_FILTER)

                RENAME(deInterlaceInterpolateLinear)(dstBlock, dstStride);

            else if(mode & LINEAR_BLEND_DEINT_FILTER)

                RENAME(deInterlaceBlendLinear)(dstBlock, dstStride, c.deintTemp + x);

            else if(mode & MEDIAN_DEINT_FILTER)

                RENAME(deInterlaceMedian)(dstBlock, dstStride);

            else if(mode & CUBIC_IPOL_DEINT_FILTER)

                RENAME(deInterlaceInterpolateCubic)(dstBlock, dstStride);

            else if(mode & FFMPEG_DEINT_FILTER)

                RENAME(deInterlaceFF)(dstBlock, dstStride, c.deintTemp + x);

            else if(mode & LOWPASS5_DEINT_FILTER)

                RENAME(deInterlaceL5)(dstBlock, dstStride, c.deintTemp + x, c.deintTemp + width + x);









            

            if(y + 8 < height){

                if(mode & V_X1_FILTER)

                    RENAME(vertX1Filter)(dstBlock, stride, &c);

                else if(mode & V_DEBLOCK){

                    const int t= RENAME(vertClassify)(dstBlock, stride, &c);



                    if(t==1)

                        RENAME(doVertLowPass)(dstBlock, stride, &c);

                    else if(t==2)

                        RENAME(doVertDefFilter)(dstBlock, stride, &c);

                }else if(mode & V_A_DEBLOCK){

                    RENAME(do_a_deblock)(dstBlock, stride, 1, &c, mode);

                }

            }



#if TEMPLATE_PP_MMX

            RENAME(transpose1)(tempBlock1, tempBlock2, dstBlock, dstStride);

#endif

            

            if(x - 8 >= 0){

#if TEMPLATE_PP_MMX

                if(mode & H_X1_FILTER)

                        RENAME(vertX1Filter)(tempBlock1, 16, &c);

                else if(mode & H_DEBLOCK){



                    const int t= RENAME(vertClassify)(tempBlock1, 16, &c);



                    if(t==1)

                        RENAME(doVertLowPass)(tempBlock1, 16, &c);

                    else if(t==2)

                        RENAME(doVertDefFilter)(tempBlock1, 16, &c);

                }else if(mode & H_A_DEBLOCK){

                        RENAME(do_a_deblock)(tempBlock1, 16, 1, &c, mode);

                }



                RENAME(transpose2)(dstBlock-4, dstStride, tempBlock1 + 4*16);



#else

                if(mode & H_X1_FILTER)

                    horizX1Filter(dstBlock-4, stride, QP);

                else if(mode & H_DEBLOCK){

#if TEMPLATE_PP_ALTIVEC

                    DECLARE_ALIGNED(16, unsigned char, tempBlock)[272];

                    int t;

                    transpose_16x8_char_toPackedAlign_altivec(tempBlock, dstBlock - (4 + 1), stride);



                    t = vertClassify_altivec(tempBlock-48, 16, &c);

                    if(t==1) {

                        doVertLowPass_altivec(tempBlock-48, 16, &c);

                        transpose_8x16_char_fromPackedAlign_altivec(dstBlock - (4 + 1), tempBlock, stride);

                    }

                    else if(t==2) {

                        doVertDefFilter_altivec(tempBlock-48, 16, &c);

                        transpose_8x16_char_fromPackedAlign_altivec(dstBlock - (4 + 1), tempBlock, stride);

                    }

#else

                    const int t= RENAME(horizClassify)(dstBlock-4, stride, &c);



                    if(t==1)

                        RENAME(doHorizLowPass)(dstBlock-4, stride, &c);

                    else if(t==2)

                        RENAME(doHorizDefFilter)(dstBlock-4, stride, &c);

#endif

                }else if(mode & H_A_DEBLOCK){

                    RENAME(do_a_deblock)(dstBlock-8, 1, stride, &c, mode);

                }

#endif 

                if(mode & DERING){

                

                    if(y>0) RENAME(dering)(dstBlock - stride - 8, stride, &c);

                }



                if(mode & TEMP_NOISE_FILTER)

                {

                    RENAME(tempNoiseReducer)(dstBlock-8, stride,

                            c.tempBlurred[isColor] + y*dstStride + x,

                            c.tempBlurredPast[isColor] + (y>>3)*256 + (x>>3) + 256,

                            c.ppMode.maxTmpNoise);

                }

            }



            dstBlock+=8;

            srcBlock+=8;



#if TEMPLATE_PP_MMX

            tmpXchg= tempBlock1;

            tempBlock1= tempBlock2;

            tempBlock2 = tmpXchg;

#endif

        }



        if(mode & DERING){

            if(y > 0) RENAME(dering)(dstBlock - dstStride - 8, dstStride, &c);

        }



        if((mode & TEMP_NOISE_FILTER)){

            RENAME(tempNoiseReducer)(dstBlock-8, dstStride,

                    c.tempBlurred[isColor] + y*dstStride + x,

                    c.tempBlurredPast[isColor] + (y>>3)*256 + (x>>3) + 256,

                    c.ppMode.maxTmpNoise);

        }



        

        if(y+15 >= height){

            uint8_t *dstBlock= &(dst[y*dstStride]);

            if(width==FFABS(dstStride))

                linecpy(dstBlock, tempDst + dstStride, height-y, dstStride);

            else{

                int i;

                for(i=0; i<height-y; i++){

                    memcpy(dstBlock + i*dstStride, tempDst + (i+1)*dstStride, width);

                }

            }

        }



















    }

#if   TEMPLATE_PP_3DNOW

    __asm__ volatile("femms");

#elif TEMPLATE_PP_MMX

    __asm__ volatile("emms");

#endif



#ifdef DEBUG_BRIGHTNESS

    if(!isColor){

        int max=1;

        int i;

        for(i=0; i<256; i++)

            if(yHistogram[i] > max) max=yHistogram[i];



        for(i=1; i<256; i++){

            int x;

            int start=yHistogram[i-1]/(max/256+1);

            int end=yHistogram[i]/(max/256+1);

            int inc= end > start ? 1 : -1;

            for(x=start; x!=end+inc; x+=inc)

                dst[ i*dstStride + x]+=128;

        }



        for(i=0; i<100; i+=2){

            dst[ (white)*dstStride + i]+=128;

            dst[ (black)*dstStride + i]+=128;

        }

    }

#endif



    *c2= c; 



}

static void FUNC_0(postProcess)(const uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height,

                                const QP_STORE_T QPs[], int QPStride, int isColor, PPContext *c2)

{

    DECLARE_ALIGNED(8, PPContext, c)= *c2; 

    int VAR_0,VAR_1;

#ifdef TEMPLATE_PP_TIME_MODE

    const int VAR_2= TEMPLATE_PP_TIME_MODE;

#else

    const int VAR_2= isColor ? c.ppMode.chromMode : c.ppMode.lumMode;

#endif

    int VAR_3=0, VAR_4=255; 

    int VAR_5= 256*256;



    int VAR_6;

#if TEMPLATE_PP_MMX

    int VAR_12;

#endif



    const int VAR_7= isColor ? 4-c.hChromaSubSample : 4;

    const int VAR_8= isColor ? 4-c.vChromaSubSample : 4;



    

    uint64_t * const yHistogram= c.yHistogram;

    uint8_t * const tempSrc= srcStride > 0 ? c.tempSrc : c.tempSrc - 23*srcStride;

    uint8_t * const tempDst= (dstStride > 0 ? c.tempDst : c.tempDst - 23*dstStride) + 32;

    



    if (VAR_2 & VISUALIZE){

        if(!(VAR_2 & (V_A_DEBLOCK | H_A_DEBLOCK)) || TEMPLATE_PP_MMX) {

            av_log(c2, AV_LOG_WARNING, "Visualization is currently only supported with the accurate deblock filter without SIMD\n");

        }

    }



#if TEMPLATE_PP_MMX

    for(VAR_12=0; VAR_12<57; VAR_12++){

        int offset= ((VAR_12*c.ppMode.baseDcDiff)>>8) + 1;

        int threshold= offset*2 + 1;

        c.mmxDcOffset[VAR_12]= 0x7F - offset;

        c.mmxDcThreshold[VAR_12]= 0x7F - threshold;

        c.mmxDcOffset[VAR_12]*= 0x0101010101010101LL;

        c.mmxDcThreshold[VAR_12]*= 0x0101010101010101LL;

    }

#endif



    if(VAR_2 & CUBIC_IPOL_DEINT_FILTER) VAR_6=16;

    else if(   (VAR_2 & LINEAR_BLEND_DEINT_FILTER)

            || (VAR_2 & FFMPEG_DEINT_FILTER)

            || (VAR_2 & LOWPASS5_DEINT_FILTER)) VAR_6=14;

    else if(   (VAR_2 & V_DEBLOCK)

            || (VAR_2 & LINEAR_IPOL_DEINT_FILTER)

            || (VAR_2 & MEDIAN_DEINT_FILTER)

            || (VAR_2 & V_A_DEBLOCK)) VAR_6=13;

    else if(VAR_2 & V_X1_FILTER) VAR_6=11;



    else if(VAR_2 & DERING) VAR_6=9;

    else VAR_6=8;



    VAR_6-= 8;



    if(!isColor){

        uint64_t sum= 0;

        int VAR_12;

        uint64_t maxClipped;

        uint64_t clipped;

        double VAR_10;



        c.frameNum++;

        

        if(c.frameNum == 1) yHistogram[0]= width*(uint64_t)height/64*15/256;



        for(VAR_12=0; VAR_12<256; VAR_12++){

            sum+= yHistogram[VAR_12];

        }



        

        maxClipped= (uint64_t)(sum * c.ppMode.maxClippedThreshold);



        clipped= sum;

        for(VAR_3=255; VAR_3>0; VAR_3--){

            if(clipped < maxClipped) break;

            clipped-= yHistogram[VAR_3];

        }



        clipped= sum;

        for(VAR_4=0; VAR_4<256; VAR_4++){

            if(clipped < maxClipped) break;

            clipped-= yHistogram[VAR_4];

        }



        VAR_10= (double)(c.ppMode.maxAllowedY - c.ppMode.minAllowedY) / (double)(VAR_4-VAR_3);



#if TEMPLATE_PP_MMXEXT

        c.packedYScale= (uint16_t)(VAR_10*256.0 + 0.5);

        c.packedYOffset= (((VAR_3*c.packedYScale)>>8) - c.ppMode.minAllowedY) & 0xFFFF;

#else

        c.packedYScale= (uint16_t)(VAR_10*1024.0 + 0.5);

        c.packedYOffset= (VAR_3 - c.ppMode.minAllowedY) & 0xFFFF;

#endif



        c.packedYOffset|= c.packedYOffset<<32;

        c.packedYOffset|= c.packedYOffset<<16;



        c.packedYScale|= c.packedYScale<<32;

        c.packedYScale|= c.packedYScale<<16;



        if(VAR_2 & LEVEL_FIX)        VAR_5= (int)(VAR_10*256*256 + 0.5);

        else                        VAR_5= 256*256;

    }else{

        c.packedYScale= 0x0100010001000100LL;

        c.packedYOffset= 0;

        VAR_5= 256*256;

    }



    

    VAR_1=-BLOCK_SIZE;

    {

        const uint8_t *VAR_11= &(src[VAR_1*srcStride]);

        uint8_t *dstBlock= tempDst + dstStride;



        

        

        

        for(VAR_0=0; VAR_0<width; VAR_0+=BLOCK_SIZE){



#if TEMPLATE_PP_MMXEXT && HAVE_6REGS















            __asm__(

                "mov %4, %%"REG_a"              \n\t"

                "shr $2, %%"REG_a"              \n\t"

                "and $6, %%"REG_a"              \n\t"

                "add %5, %%"REG_a"              \n\t"

                "mov %%"REG_a", %%"REG_d"       \n\t"

                "imul %1, %%"REG_a"             \n\t"

                "imul %3, %%"REG_d"             \n\t"

                "prefetchnta 32(%%"REG_a", %0)  \n\t"

                "prefetcht0 32(%%"REG_d", %2)   \n\t"

                "add %1, %%"REG_a"              \n\t"

                "add %3, %%"REG_d"              \n\t"

                "prefetchnta 32(%%"REG_a", %0)  \n\t"

                "prefetcht0 32(%%"REG_d", %2)   \n\t"

                :: "r" (VAR_11), "r" ((x86_reg)srcStride), "r" (dstBlock), "r" ((x86_reg)dstStride),

                "g" ((x86_reg)VAR_0), "g" ((x86_reg)VAR_6)

                : "%"REG_a, "%"REG_d

            );



#elif TEMPLATE_PP_3DNOW













#endif



            FUNC_0(blockCopy)(dstBlock + dstStride*8, dstStride,

                              VAR_11 + srcStride*8, srcStride, VAR_2 & LEVEL_FIX, &c.packedYOffset);



            FUNC_0(duplicate)(dstBlock + dstStride*8, dstStride);



            if(VAR_2 & LINEAR_IPOL_DEINT_FILTER)

                FUNC_0(deInterlaceInterpolateLinear)(dstBlock, dstStride);

            else if(VAR_2 & LINEAR_BLEND_DEINT_FILTER)

                FUNC_0(deInterlaceBlendLinear)(dstBlock, dstStride, c.deintTemp + VAR_0);

            else if(VAR_2 & MEDIAN_DEINT_FILTER)

                FUNC_0(deInterlaceMedian)(dstBlock, dstStride);

            else if(VAR_2 & CUBIC_IPOL_DEINT_FILTER)

                FUNC_0(deInterlaceInterpolateCubic)(dstBlock, dstStride);

            else if(VAR_2 & FFMPEG_DEINT_FILTER)

                FUNC_0(deInterlaceFF)(dstBlock, dstStride, c.deintTemp + VAR_0);

            else if(VAR_2 & LOWPASS5_DEINT_FILTER)

                FUNC_0(deInterlaceL5)(dstBlock, dstStride, c.deintTemp + VAR_0, c.deintTemp + width + VAR_0);







            dstBlock+=8;

            VAR_11+=8;

        }

        if(width==FFABS(dstStride))

            linecpy(dst, tempDst + 9*dstStride, VAR_6, dstStride);

        else{

            int VAR_12;

            for(VAR_12=0; VAR_12<VAR_6; VAR_12++){

                memcpy(dst + VAR_12*dstStride, tempDst + (9+VAR_12)*dstStride, width);

            }

        }

    }



    for(VAR_1=0; VAR_1<height; VAR_1+=BLOCK_SIZE){

        

        const uint8_t *VAR_11= &(src[VAR_1*srcStride]);

        uint8_t *dstBlock= &(dst[VAR_1*dstStride]);

#if TEMPLATE_PP_MMX

        uint8_t *tempBlock1= c.tempBlocks;

        uint8_t *tempBlock2= c.tempBlocks + 8;

#endif

        const int8_t *QPptr= &QPs[(VAR_1>>VAR_8)*QPStride];

        int8_t *nonBQPptr= &c.nonBQPTable[(VAR_1>>VAR_8)*FFABS(QPStride)];

        int QP=0;

        



        if(VAR_1+15 >= height){

            int VAR_12;

            



            linecpy(tempSrc + srcStride*VAR_6, VAR_11 + srcStride*VAR_6,

                    FFMAX(height-VAR_1-VAR_6, 0), srcStride);



            

            for(VAR_12=FFMAX(height-VAR_1, 8); VAR_12<VAR_6+8; VAR_12++)

                    memcpy(tempSrc + srcStride*VAR_12, src + srcStride*(height-1), FFABS(srcStride));



            

            linecpy(tempDst, dstBlock - dstStride, FFMIN(height-VAR_1+1, VAR_6+1), dstStride);



            

            for(VAR_12=height-VAR_1+1; VAR_12<=VAR_6; VAR_12++)

                    memcpy(tempDst + dstStride*VAR_12, dst + dstStride*(height-1), FFABS(dstStride));



            dstBlock= tempDst + dstStride;

            VAR_11= tempSrc;

        }



        

        

        

        for(VAR_0=0; VAR_0<width; VAR_0+=BLOCK_SIZE){

            const int stride= dstStride;

#if TEMPLATE_PP_MMX

            uint8_t *tmpXchg;

#endif

            if(isColor){

                QP= QPptr[VAR_0>>VAR_7];

                c.nonBQP= nonBQPptr[VAR_0>>VAR_7];

            }else{

                QP= QPptr[VAR_0>>4];

                QP= (QP* VAR_5 + 256*128)>>16;

                c.nonBQP= nonBQPptr[VAR_0>>4];

                c.nonBQP= (c.nonBQP* VAR_5 + 256*128)>>16;

                yHistogram[ VAR_11[srcStride*12 + 4] ]++;

            }

            c.QP= QP;

#if TEMPLATE_PP_MMX

            __asm__ volatile(

                "movd %1, %%mm7         \n\t"

                "packuswb %%mm7, %%mm7  \n\t" 

                "packuswb %%mm7, %%mm7  \n\t" 

                "packuswb %%mm7, %%mm7  \n\t" 

                "movq %%mm7, %0         \n\t"

                : "=m" (c.pQPb)

                : "r" (QP)

            );

#endif





#if TEMPLATE_PP_MMXEXT && HAVE_6REGS















            __asm__(

                "mov %4, %%"REG_a"              \n\t"

                "shr $2, %%"REG_a"              \n\t"

                "and $6, %%"REG_a"              \n\t"

                "add %5, %%"REG_a"              \n\t"

                "mov %%"REG_a", %%"REG_d"       \n\t"

                "imul %1, %%"REG_a"             \n\t"

                "imul %3, %%"REG_d"             \n\t"

                "prefetchnta 32(%%"REG_a", %0)  \n\t"

                "prefetcht0 32(%%"REG_d", %2)   \n\t"

                "add %1, %%"REG_a"              \n\t"

                "add %3, %%"REG_d"              \n\t"

                "prefetchnta 32(%%"REG_a", %0)  \n\t"

                "prefetcht0 32(%%"REG_d", %2)   \n\t"

                :: "r" (VAR_11), "r" ((x86_reg)srcStride), "r" (dstBlock), "r" ((x86_reg)dstStride),

                "g" ((x86_reg)VAR_0), "g" ((x86_reg)VAR_6)

                : "%"REG_a, "%"REG_d

            );



#elif TEMPLATE_PP_3DNOW













#endif



            FUNC_0(blockCopy)(dstBlock + dstStride*VAR_6, dstStride,

                              VAR_11 + srcStride*VAR_6, srcStride, VAR_2 & LEVEL_FIX, &c.packedYOffset);



            if(VAR_2 & LINEAR_IPOL_DEINT_FILTER)

                FUNC_0(deInterlaceInterpolateLinear)(dstBlock, dstStride);

            else if(VAR_2 & LINEAR_BLEND_DEINT_FILTER)

                FUNC_0(deInterlaceBlendLinear)(dstBlock, dstStride, c.deintTemp + VAR_0);

            else if(VAR_2 & MEDIAN_DEINT_FILTER)

                FUNC_0(deInterlaceMedian)(dstBlock, dstStride);

            else if(VAR_2 & CUBIC_IPOL_DEINT_FILTER)

                FUNC_0(deInterlaceInterpolateCubic)(dstBlock, dstStride);

            else if(VAR_2 & FFMPEG_DEINT_FILTER)

                FUNC_0(deInterlaceFF)(dstBlock, dstStride, c.deintTemp + VAR_0);

            else if(VAR_2 & LOWPASS5_DEINT_FILTER)

                FUNC_0(deInterlaceL5)(dstBlock, dstStride, c.deintTemp + VAR_0, c.deintTemp + width + VAR_0);









            

            if(VAR_1 + 8 < height){

                if(VAR_2 & V_X1_FILTER)

                    FUNC_0(vertX1Filter)(dstBlock, stride, &c);

                else if(VAR_2 & V_DEBLOCK){

                    const int t= FUNC_0(vertClassify)(dstBlock, stride, &c);



                    if(t==1)

                        FUNC_0(doVertLowPass)(dstBlock, stride, &c);

                    else if(t==2)

                        FUNC_0(doVertDefFilter)(dstBlock, stride, &c);

                }else if(VAR_2 & V_A_DEBLOCK){

                    FUNC_0(do_a_deblock)(dstBlock, stride, 1, &c, VAR_2);

                }

            }



#if TEMPLATE_PP_MMX

            FUNC_0(transpose1)(tempBlock1, tempBlock2, dstBlock, dstStride);

#endif

            

            if(VAR_0 - 8 >= 0){

#if TEMPLATE_PP_MMX

                if(VAR_2 & H_X1_FILTER)

                        FUNC_0(vertX1Filter)(tempBlock1, 16, &c);

                else if(VAR_2 & H_DEBLOCK){



                    const int t= FUNC_0(vertClassify)(tempBlock1, 16, &c);



                    if(t==1)

                        FUNC_0(doVertLowPass)(tempBlock1, 16, &c);

                    else if(t==2)

                        FUNC_0(doVertDefFilter)(tempBlock1, 16, &c);

                }else if(VAR_2 & H_A_DEBLOCK){

                        FUNC_0(do_a_deblock)(tempBlock1, 16, 1, &c, VAR_2);

                }



                FUNC_0(transpose2)(dstBlock-4, dstStride, tempBlock1 + 4*16);



#else

                if(VAR_2 & H_X1_FILTER)

                    horizX1Filter(dstBlock-4, stride, QP);

                else if(VAR_2 & H_DEBLOCK){

#if TEMPLATE_PP_ALTIVEC

                    DECLARE_ALIGNED(16, unsigned char, tempBlock)[272];

                    int t;

                    transpose_16x8_char_toPackedAlign_altivec(tempBlock, dstBlock - (4 + 1), stride);



                    t = vertClassify_altivec(tempBlock-48, 16, &c);

                    if(t==1) {

                        doVertLowPass_altivec(tempBlock-48, 16, &c);

                        transpose_8x16_char_fromPackedAlign_altivec(dstBlock - (4 + 1), tempBlock, stride);

                    }

                    else if(t==2) {

                        doVertDefFilter_altivec(tempBlock-48, 16, &c);

                        transpose_8x16_char_fromPackedAlign_altivec(dstBlock - (4 + 1), tempBlock, stride);

                    }

#else

                    const int t= FUNC_0(horizClassify)(dstBlock-4, stride, &c);



                    if(t==1)

                        FUNC_0(doHorizLowPass)(dstBlock-4, stride, &c);

                    else if(t==2)

                        FUNC_0(doHorizDefFilter)(dstBlock-4, stride, &c);

#endif

                }else if(VAR_2 & H_A_DEBLOCK){

                    FUNC_0(do_a_deblock)(dstBlock-8, 1, stride, &c, VAR_2);

                }

#endif 

                if(VAR_2 & DERING){

                

                    if(VAR_1>0) FUNC_0(dering)(dstBlock - stride - 8, stride, &c);

                }



                if(VAR_2 & TEMP_NOISE_FILTER)

                {

                    FUNC_0(tempNoiseReducer)(dstBlock-8, stride,

                            c.tempBlurred[isColor] + VAR_1*dstStride + VAR_0,

                            c.tempBlurredPast[isColor] + (VAR_1>>3)*256 + (VAR_0>>3) + 256,

                            c.ppMode.maxTmpNoise);

                }

            }



            dstBlock+=8;

            VAR_11+=8;



#if TEMPLATE_PP_MMX

            tmpXchg= tempBlock1;

            tempBlock1= tempBlock2;

            tempBlock2 = tmpXchg;

#endif

        }



        if(VAR_2 & DERING){

            if(VAR_1 > 0) FUNC_0(dering)(dstBlock - dstStride - 8, dstStride, &c);

        }



        if((VAR_2 & TEMP_NOISE_FILTER)){

            FUNC_0(tempNoiseReducer)(dstBlock-8, dstStride,

                    c.tempBlurred[isColor] + VAR_1*dstStride + VAR_0,

                    c.tempBlurredPast[isColor] + (VAR_1>>3)*256 + (VAR_0>>3) + 256,

                    c.ppMode.maxTmpNoise);

        }



        

        if(VAR_1+15 >= height){

            uint8_t *dstBlock= &(dst[VAR_1*dstStride]);

            if(width==FFABS(dstStride))

                linecpy(dstBlock, tempDst + dstStride, height-VAR_1, dstStride);

            else{

                int VAR_12;

                for(VAR_12=0; VAR_12<height-VAR_1; VAR_12++){

                    memcpy(dstBlock + VAR_12*dstStride, tempDst + (VAR_12+1)*dstStride, width);

                }

            }

        }



















    }

#if   TEMPLATE_PP_3DNOW

    __asm__ volatile("femms");

#elif TEMPLATE_PP_MMX

    __asm__ volatile("emms");

#endif



#ifdef DEBUG_BRIGHTNESS

    if(!isColor){

        int max=1;

        int VAR_12;

        for(VAR_12=0; VAR_12<256; VAR_12++)

            if(yHistogram[VAR_12] > max) max=yHistogram[VAR_12];



        for(VAR_12=1; VAR_12<256; VAR_12++){

            int VAR_0;

            int start=yHistogram[VAR_12-1]/(max/256+1);

            int end=yHistogram[VAR_12]/(max/256+1);

            int inc= end > start ? 1 : -1;

            for(VAR_0=start; VAR_0!=end+inc; VAR_0+=inc)

                dst[ VAR_12*dstStride + VAR_0]+=128;

        }



        for(VAR_12=0; VAR_12<100; VAR_12+=2){

            dst[ (VAR_4)*dstStride + VAR_12]+=128;

            dst[ (VAR_3)*dstStride + VAR_12]+=128;

        }

    }

#endif



    *c2= c; 



}

static void FUNC_0(postProcess)(const uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height,
const QP_STORE_T QPs[], int QPStride, int isColor, PPContext *c2)
{ DECLARE_ALIGNED(8, PPContext, c)= *c2; int VAR_0,VAR_1; #ifdef TEMPLATE_PP_TIME_MODE
const int VAR_2= TEMPLATE_PP_TIME_MODE; #else
const int VAR_2= isColor ? c.ppMode.chromMode : c.ppMode.lumMode; #endif
int VAR_3=0, VAR_4=255; int VAR_5= 256*256; int VAR_6; #if TEMPLATE_PP_MMX
int VAR_12; #endif
const int VAR_7= isColor ? 4-c.hChromaSubSample : 4; const int VAR_8= isColor ? 4-c.vChromaSubSample : 4; uint64_t * const yHistogram= c.yHistogram; uint8_t * const tempSrc= srcStride > 0 ? c.tempSrc : c.tempSrc - 23*srcStride; uint8_t * const tempDst= (dstStride > 0 ? c.tempDst : c.tempDst - 23*dstStride) + 32; if (VAR_2 & VISUALIZE){ if(!(VAR_2 & (V_A_DEBLOCK | H_A_DEBLOCK)) || TEMPLATE_PP_MMX) { av_log(c2, AV_LOG_WARNING, "Visualization is currently only supported with the accurate deblock filter without SIMD\n"); } } #if TEMPLATE_PP_MMX
for(VAR_12=0; VAR_12<57; VAR_12++){ int offset= ((VAR_12*c.ppMode.baseDcDiff)>>8) + 1; int threshold= offset*2 + 1; c.mmxDcOffset[VAR_12]= 0x7F - offset; c.mmxDcThreshold[VAR_12]= 0x7F - threshold; c.mmxDcOffset[VAR_12]*= 0x0101010101010101LL; c.mmxDcThreshold[VAR_12]*= 0x0101010101010101LL; } #endif
if(VAR_2 & CUBIC_IPOL_DEINT_FILTER) VAR_6=16; else if(   (VAR_2 & LINEAR_BLEND_DEINT_FILTER)
|| (VAR_2 & FFMPEG_DEINT_FILTER)
|| (VAR_2 & LOWPASS5_DEINT_FILTER)) VAR_6=14; else if(   (VAR_2 & V_DEBLOCK)
|| (VAR_2 & LINEAR_IPOL_DEINT_FILTER)
|| (VAR_2 & MEDIAN_DEINT_FILTER)
|| (VAR_2 & V_A_DEBLOCK)) VAR_6=13; else if(VAR_2 & V_X1_FILTER) VAR_6=11; else if(VAR_2 & DERING) VAR_6=9; else VAR_6=8; VAR_6-= 8; if(!isColor){ uint64_t sum= 0; int VAR_12; uint64_t maxClipped; uint64_t clipped; double VAR_10; c.frameNum++; if(c.frameNum == 1) yHistogram[0]= width*(uint64_t)height/64*15/256; for(VAR_12=0; VAR_12<256; VAR_12++){ sum+= yHistogram[VAR_12]; } maxClipped= (uint64_t)(sum * c.ppMode.maxClippedThreshold); clipped= sum; for(VAR_3=255; VAR_3>0; VAR_3--){ if(clipped < maxClipped) break; clipped-= yHistogram[VAR_3]; } clipped= sum; for(VAR_4=0; VAR_4<256; VAR_4++){ if(clipped < maxClipped) break; clipped-= yHistogram[VAR_4]; } VAR_10= (double)(c.ppMode.maxAllowedY - c.ppMode.minAllowedY) / (double)(VAR_4-VAR_3); #if TEMPLATE_PP_MMXEXT
c.packedYScale= (uint16_t)(VAR_10*256.0 + 0.5); c.packedYOffset= (((VAR_3*c.packedYScale)>>8) - c.ppMode.minAllowedY) & 0xFFFF; #else
c.packedYScale= (uint16_t)(VAR_10*1024.0 + 0.5); c.packedYOffset= (VAR_3 - c.ppMode.minAllowedY) & 0xFFFF; #endif
c.packedYOffset|= c.packedYOffset<<32; c.packedYOffset|= c.packedYOffset<<16; c.packedYScale|= c.packedYScale<<32; c.packedYScale|= c.packedYScale<<16; if(VAR_2 & LEVEL_FIX)        VAR_5= (int)(VAR_10*256*256 + 0.5); else                        VAR_5= 256*256; }else{ c.packedYScale= 0x0100010001000100LL; c.packedYOffset= 0; VAR_5= 256*256; } VAR_1=-BLOCK_SIZE; { const uint8_t *VAR_11= &(src[VAR_1*srcStride]); uint8_t *dstBlock= tempDst + dstStride; for(VAR_0=0; VAR_0<width; VAR_0+=BLOCK_SIZE){ #if TEMPLATE_PP_MMXEXT && HAVE_6REGS
__asm__(
"mov %4, %%"REG_a"              \n\t"
"shr $2, %%"REG_a"              \n\t"
"and $6, %%"REG_a"              \n\t"
"add %5, %%"REG_a"              \n\t"
"mov %%"REG_a", %%"REG_d"       \n\t"
"imul %1, %%"REG_a"             \n\t"
"imul %3, %%"REG_d"             \n\t"
"prefetchnta 32(%%"REG_a", %0)  \n\t"
"prefetcht0 32(%%"REG_d", %2)   \n\t"
"add %1, %%"REG_a"              \n\t"
"add %3, %%"REG_d"              \n\t"
"prefetchnta 32(%%"REG_a", %0)  \n\t"
"prefetcht0 32(%%"REG_d", %2)   \n\t"
:: "r" (VAR_11), "r" ((x86_reg)srcStride), "r" (dstBlock), "r" ((x86_reg)dstStride),
"g" ((x86_reg)VAR_0), "g" ((x86_reg)VAR_6)
: "%"REG_a, "%"REG_d
); #elif TEMPLATE_PP_3DNOW
#endif
FUNC_0(blockCopy)(dstBlock + dstStride*8, dstStride,
VAR_11 + srcStride*8, srcStride, VAR_2 & LEVEL_FIX, &c.packedYOffset); FUNC_0(duplicate)(dstBlock + dstStride*8, dstStride); if(VAR_2 & LINEAR_IPOL_DEINT_FILTER)
FUNC_0(deInterlaceInterpolateLinear)(dstBlock, dstStride); else if(VAR_2 & LINEAR_BLEND_DEINT_FILTER)
FUNC_0(deInterlaceBlendLinear)(dstBlock, dstStride, c.deintTemp + VAR_0); else if(VAR_2 & MEDIAN_DEINT_FILTER)
FUNC_0(deInterlaceMedian)(dstBlock, dstStride); else if(VAR_2 & CUBIC_IPOL_DEINT_FILTER)
FUNC_0(deInterlaceInterpolateCubic)(dstBlock, dstStride); else if(VAR_2 & FFMPEG_DEINT_FILTER)
FUNC_0(deInterlaceFF)(dstBlock, dstStride, c.deintTemp + VAR_0); else if(VAR_2 & LOWPASS5_DEINT_FILTER)
FUNC_0(deInterlaceL5)(dstBlock, dstStride, c.deintTemp + VAR_0, c.deintTemp + width + VAR_0); dstBlock+=8; VAR_11+=8; } if(width==FFABS(dstStride))
linecpy(dst, tempDst + 9*dstStride, VAR_6, dstStride); else{ int VAR_12; for(VAR_12=0; VAR_12<VAR_6; VAR_12++){ memcpy(dst + VAR_12*dstStride, tempDst + (9+VAR_12)*dstStride, width); } } } for(VAR_1=0; VAR_1<height; VAR_1+=BLOCK_SIZE){ const uint8_t *VAR_11= &(src[VAR_1*srcStride]); uint8_t *dstBlock= &(dst[VAR_1*dstStride]); #if TEMPLATE_PP_MMX
uint8_t *tempBlock1= c.tempBlocks; uint8_t *tempBlock2= c.tempBlocks + 8; #endif
const int8_t *QPptr= &QPs[(VAR_1>>VAR_8)*QPStride]; int8_t *nonBQPptr= &c.nonBQPTable[(VAR_1>>VAR_8)*FFABS(QPStride)]; int QP=0; if(VAR_1+15 >= height){ int VAR_12; linecpy(tempSrc + srcStride*VAR_6, VAR_11 + srcStride*VAR_6,
FFMAX(height-VAR_1-VAR_6, 0), srcStride); for(VAR_12=FFMAX(height-VAR_1, 8); VAR_12<VAR_6+8; VAR_12++) memcpy(tempSrc + srcStride*VAR_12, src + srcStride*(height-1), FFABS(srcStride)); linecpy(tempDst, dstBlock - dstStride, FFMIN(height-VAR_1+1, VAR_6+1), dstStride); for(VAR_12=height-VAR_1+1; VAR_12<=VAR_6; VAR_12++) memcpy(tempDst + dstStride*VAR_12, dst + dstStride*(height-1), FFABS(dstStride)); dstBlock= tempDst + dstStride; VAR_11= tempSrc; } for(VAR_0=0; VAR_0<width; VAR_0+=BLOCK_SIZE){ const int stride= dstStride; #if TEMPLATE_PP_MMX
uint8_t *tmpXchg; #endif
if(isColor){ QP= QPptr[VAR_0>>VAR_7]; c.nonBQP= nonBQPptr[VAR_0>>VAR_7]; }else{ QP= QPptr[VAR_0>>4]; QP= (QP* VAR_5 + 256*128)>>16; c.nonBQP= nonBQPptr[VAR_0>>4]; c.nonBQP= (c.nonBQP* VAR_5 + 256*128)>>16; yHistogram[ VAR_11[srcStride*12 + 4] ]++; } c.QP= QP; #if TEMPLATE_PP_MMX
__asm__ volatile(
"movd %1, %%mm7         \n\t"
"packuswb %%mm7, %%mm7  \n\t"
"packuswb %%mm7, %%mm7  \n\t"
"packuswb %%mm7, %%mm7  \n\t"
"movq %%mm7, %0         \n\t"
: "=m" (c.pQPb)
: "r" (QP)
); #endif
#if TEMPLATE_PP_MMXEXT && HAVE_6REGS
__asm__(
"mov %4, %%"REG_a"              \n\t"
"shr $2, %%"REG_a"              \n\t"
"and $6, %%"REG_a"              \n\t"
"add %5, %%"REG_a"              \n\t"
"mov %%"REG_a", %%"REG_d"       \n\t"
"imul %1, %%"REG_a"             \n\t"
"imul %3, %%"REG_d"             \n\t"
"prefetchnta 32(%%"REG_a", %0)  \n\t"
"prefetcht0 32(%%"REG_d", %2)   \n\t"
"add %1, %%"REG_a"              \n\t"
"add %3, %%"REG_d"              \n\t"
"prefetchnta 32(%%"REG_a", %0)  \n\t"
"prefetcht0 32(%%"REG_d", %2)   \n\t"
:: "r" (VAR_11), "r" ((x86_reg)srcStride), "r" (dstBlock), "r" ((x86_reg)dstStride),
"g" ((x86_reg)VAR_0), "g" ((x86_reg)VAR_6)
: "%"REG_a, "%"REG_d
); #elif TEMPLATE_PP_3DNOW
#endif
FUNC_0(blockCopy)(dstBlock + dstStride*VAR_6, dstStride,
VAR_11 + srcStride*VAR_6, srcStride, VAR_2 & LEVEL_FIX, &c.packedYOffset); if(VAR_2 & LINEAR_IPOL_DEINT_FILTER)
FUNC_0(deInterlaceInterpolateLinear)(dstBlock, dstStride); else if(VAR_2 & LINEAR_BLEND_DEINT_FILTER)
FUNC_0(deInterlaceBlendLinear)(dstBlock, dstStride, c.deintTemp + VAR_0); else if(VAR_2 & MEDIAN_DEINT_FILTER)
FUNC_0(deInterlaceMedian)(dstBlock, dstStride); else if(VAR_2 & CUBIC_IPOL_DEINT_FILTER)
FUNC_0(deInterlaceInterpolateCubic)(dstBlock, dstStride); else if(VAR_2 & FFMPEG_DEINT_FILTER)
FUNC_0(deInterlaceFF)(dstBlock, dstStride, c.deintTemp + VAR_0); else if(VAR_2 & LOWPASS5_DEINT_FILTER)
FUNC_0(deInterlaceL5)(dstBlock, dstStride, c.deintTemp + VAR_0, c.deintTemp + width + VAR_0); if(VAR_1 + 8 < height){ if(VAR_2 & V_X1_FILTER)
FUNC_0(vertX1Filter)(dstBlock, stride, &c); else if(VAR_2 & V_DEBLOCK){ const int t= FUNC_0(vertClassify)(dstBlock, stride, &c); if(t==1)
FUNC_0(doVertLowPass)(dstBlock, stride, &c); else if(t==2)
FUNC_0(doVertDefFilter)(dstBlock, stride, &c); }else if(VAR_2 & V_A_DEBLOCK){ FUNC_0(do_a_deblock)(dstBlock, stride, 1, &c, VAR_2); } } #if TEMPLATE_PP_MMX
FUNC_0(transpose1)(tempBlock1, tempBlock2, dstBlock, dstStride); #endif
if(VAR_0 - 8 >= 0){ #if TEMPLATE_PP_MMX
if(VAR_2 & H_X1_FILTER)
FUNC_0(vertX1Filter)(tempBlock1, 16, &c); else if(VAR_2 & H_DEBLOCK){ const int t= FUNC_0(vertClassify)(tempBlock1, 16, &c); if(t==1)
FUNC_0(doVertLowPass)(tempBlock1, 16, &c); else if(t==2)
FUNC_0(doVertDefFilter)(tempBlock1, 16, &c); }else if(VAR_2 & H_A_DEBLOCK){ FUNC_0(do_a_deblock)(tempBlock1, 16, 1, &c, VAR_2); } FUNC_0(transpose2)(dstBlock-4, dstStride, tempBlock1 + 4*16); #else
if(VAR_2 & H_X1_FILTER)
horizX1Filter(dstBlock-4, stride, QP); else if(VAR_2 & H_DEBLOCK){ #if TEMPLATE_PP_ALTIVEC
DECLARE_ALIGNED(16, unsigned char, tempBlock)[272]; int t; transpose_16x8_char_toPackedAlign_altivec(tempBlock, dstBlock - (4 + 1), stride); t = vertClassify_altivec(tempBlock-48, 16, &c); if(t==1) { doVertLowPass_altivec(tempBlock-48, 16, &c); transpose_8x16_char_fromPackedAlign_altivec(dstBlock - (4 + 1), tempBlock, stride); } else if(t==2) { doVertDefFilter_altivec(tempBlock-48, 16, &c); transpose_8x16_char_fromPackedAlign_altivec(dstBlock - (4 + 1), tempBlock, stride); } #else
const int t= FUNC_0(horizClassify)(dstBlock-4, stride, &c); if(t==1)
FUNC_0(doHorizLowPass)(dstBlock-4, stride, &c); else if(t==2)
FUNC_0(doHorizDefFilter)(dstBlock-4, stride, &c); #endif
}else if(VAR_2 & H_A_DEBLOCK){ FUNC_0(do_a_deblock)(dstBlock-8, 1, stride, &c, VAR_2); } #endif
if(VAR_2 & DERING){ if(VAR_1>0) FUNC_0(dering)(dstBlock - stride - 8, stride, &c); } if(VAR_2 & TEMP_NOISE_FILTER)
{ FUNC_0(tempNoiseReducer)(dstBlock-8, stride,
c.tempBlurred[isColor] + VAR_1*dstStride + VAR_0,
c.tempBlurredPast[isColor] + (VAR_1>>3)*256 + (VAR_0>>3) + 256,
c.ppMode.maxTmpNoise); } } dstBlock+=8; VAR_11+=8; #if TEMPLATE_PP_MMX
tmpXchg= tempBlock1; tempBlock1= tempBlock2; tempBlock2 = tmpXchg; #endif
} if(VAR_2 & DERING){ if(VAR_1 > 0) FUNC_0(dering)(dstBlock - dstStride - 8, dstStride, &c); } if((VAR_2 & TEMP_NOISE_FILTER)){ FUNC_0(tempNoiseReducer)(dstBlock-8, dstStride,
c.tempBlurred[isColor] + VAR_1*dstStride + VAR_0,
c.tempBlurredPast[isColor] + (VAR_1>>3)*256 + (VAR_0>>3) + 256,
c.ppMode.maxTmpNoise); } if(VAR_1+15 >= height){ uint8_t *dstBlock= &(dst[VAR_1*dstStride]); if(width==FFABS(dstStride))
linecpy(dstBlock, tempDst + dstStride, height-VAR_1, dstStride); else{ int VAR_12; for(VAR_12=0; VAR_12<height-VAR_1; VAR_12++){ memcpy(dstBlock + VAR_12*dstStride, tempDst + (VAR_12+1)*dstStride, width); } } } } #if   TEMPLATE_PP_3DNOW
__asm__ volatile("femms"); #elif TEMPLATE_PP_MMX
__asm__ volatile("emms"); #endif
#ifdef DEBUG_BRIGHTNESS
if(!isColor){ int max=1; int VAR_12; for(VAR_12=0; VAR_12<256; VAR_12++) if(yHistogram[VAR_12] > max) max=yHistogram[VAR_12]; for(VAR_12=1; VAR_12<256; VAR_12++){ int VAR_0; int start=yHistogram[VAR_12-1]/(max/256+1); int end=yHistogram[VAR_12]/(max/256+1); int inc= end > start ? 1 : -1; for(VAR_0=start; VAR_0!=end+inc; VAR_0+=inc) dst[ VAR_12*dstStride + VAR_0]+=128; } for(VAR_12=0; VAR_12<100; VAR_12+=2){ dst[ (VAR_4)*dstStride + VAR_12]+=128; dst[ (VAR_3)*dstStride + VAR_12]+=128; } } #endif
*c2= c; }