static int RENAME(dct_quantize)(MpegEncContext *s,

                            DCTELEM *block, int n,

                            int qscale)

{

    int i, level, last_non_zero_p1, q;

    const UINT16 *qmat;

    static __align8 INT16 temp_block[64];

    int minLevel, maxLevel;

    

    if(s->avctx!=NULL && s->avctx->codec->id==CODEC_ID_MPEG4){

	/* mpeg4 */

        minLevel= -2048;

	maxLevel= 2047;

    }else if(s->out_format==FMT_MPEG1){

	/* mpeg1 */

        minLevel= -255;

	maxLevel= 255;

    }else if(s->out_format==FMT_MJPEG){

	/* (m)jpeg */

        minLevel= -1023;

	maxLevel= 1023;

    }else{

	/* h263 / msmpeg4 */

        minLevel= -128;

	maxLevel= 127;

    }



    av_fdct (block);

    

    if (s->mb_intra) {

        int dummy;

        if (n < 4)

            q = s->y_dc_scale;

        else

            q = s->c_dc_scale;

        

        /* note: block[0] is assumed to be positive */

#if 1

	asm volatile (

		"xorl %%edx, %%edx	\n\t"

		"mul %%ecx		\n\t"

		: "=d" (temp_block[0]), "=a"(dummy)

		: "a" (block[0] + (q >> 1)), "c" (inverse[q])

	);

#else

	asm volatile (

		"xorl %%edx, %%edx	\n\t"

		"divw %%cx		\n\t"

		"movzwl %%ax, %%eax	\n\t"

		: "=a" (temp_block[0])

		: "a" (block[0] + (q >> 1)), "c" (q)

		: "%edx"

	);

#endif

//        temp_block[0] = (block[0] + (q >> 1)) / q;

        i = 1;

        last_non_zero_p1 = 1;

        if (s->out_format == FMT_H263) {

            qmat = s->q_non_intra_matrix16;

        } else {

            qmat = s->q_intra_matrix16;

        }

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

            level = block[i] * qmat[i];

            level = level / (1 << (QMAT_SHIFT_MMX - 3));

            /* XXX: currently, this code is not optimal. the range should be:

               mpeg1: -255..255

               mpeg2: -2048..2047

               h263:  -128..127

               mpeg4: -2048..2047

            */

            if (level > maxLevel)

                level = maxLevel;

            else if (level < minLevel)

                level = minLevel;

            temp_block[i] = level;



	    if(level) 

	        if(last_non_zero_p1 < inv_zigzag_direct16[i]) last_non_zero_p1= inv_zigzag_direct16[i];

	    block[i]=0;

        }

    } else {

        i = 0;

        last_non_zero_p1 = 0;

        qmat = s->q_non_intra_matrix16;

    }



    asm volatile( /* XXX: small rounding bug, but it shouldnt matter */

	"movd %3, %%mm3			\n\t"

	SPREADW(%%mm3)

	"movd %4, %%mm4			\n\t"

	SPREADW(%%mm4)

#ifndef HAVE_MMX2	

	"movd %5, %%mm5			\n\t"

	SPREADW(%%mm5)

#endif

	"pxor %%mm7, %%mm7		\n\t"

	"movd %%eax, %%mm2		\n\t"

	SPREADW(%%mm2)

	"movl %6, %%eax			\n\t"

	".balign 16			\n\t"

	"1:				\n\t"

	"movq (%1, %%eax), %%mm0	\n\t"

	"movq (%2, %%eax), %%mm1	\n\t"

	"movq %%mm0, %%mm6		\n\t"

	"psraw $15, %%mm6		\n\t"

	"pmulhw %%mm0, %%mm1		\n\t"

	"psubsw %%mm6, %%mm1		\n\t"

#ifdef HAVE_MMX2

	"pminsw %%mm3, %%mm1		\n\t"

	"pmaxsw %%mm4, %%mm1		\n\t"

#else

	"paddsw %%mm3, %%mm1		\n\t"

	"psubusw %%mm4, %%mm1		\n\t"

	"paddsw %%mm5, %%mm1		\n\t"

#endif

	"movq %%mm1, (%8, %%eax)	\n\t"

	"pcmpeqw %%mm7, %%mm1		\n\t"

	"movq (%7, %%eax), %%mm0	\n\t"

	"movq %%mm7, (%1, %%eax)	\n\t"

	"pandn %%mm0, %%mm1		\n\t"

	PMAXW(%%mm1, %%mm2)

	"addl $8, %%eax			\n\t"

	" js 1b				\n\t"

	"movq %%mm2, %%mm0		\n\t"

	"psrlq $32, %%mm2		\n\t"

	PMAXW(%%mm0, %%mm2)

	"movq %%mm2, %%mm0		\n\t"

	"psrlq $16, %%mm2		\n\t"

	PMAXW(%%mm0, %%mm2)

	"movd %%mm2, %%eax		\n\t"

	"movzbl %%al, %%eax		\n\t"

	: "+a" (last_non_zero_p1)

	: "r" (block+64), "r" (qmat+64), 

#ifdef HAVE_MMX2

	  "m" (maxLevel),          "m" (minLevel),                    "m" (minLevel /* dummy */), "g" (2*i - 128),

#else

	  "m" (0x7FFF - maxLevel), "m" (0x7FFF -maxLevel + minLevel), "m" (minLevel),             "g" (2*i - 128),

#endif

	  "r" (inv_zigzag_direct16+64), "r" (temp_block+64)

    );

// last_non_zero_p1=64;       

    /* permute for IDCT */

    asm volatile(

	"movl %0, %%eax			\n\t"

	"pushl %%ebp			\n\t"

	"movl %%esp, " MANGLE(esp_temp) "\n\t"

	"1:				\n\t"

	"movzbl (%1, %%eax), %%ebx	\n\t"

	"movzbl 1(%1, %%eax), %%ebp	\n\t"

	"movw (%2, %%ebx, 2), %%cx	\n\t"

	"movw (%2, %%ebp, 2), %%sp	\n\t"

	"movzbl " MANGLE(permutation) "(%%ebx), %%ebx\n\t"

	"movzbl " MANGLE(permutation) "(%%ebp), %%ebp\n\t"

	"movw %%cx, (%3, %%ebx, 2)	\n\t"

	"movw %%sp, (%3, %%ebp, 2)	\n\t"

	"addl $2, %%eax			\n\t"

	" js 1b				\n\t"

	"movl " MANGLE(esp_temp) ", %%esp\n\t"

	"popl %%ebp			\n\t"

	: 

	: "g" (-last_non_zero_p1), "d" (zigzag_direct_noperm+last_non_zero_p1), "S" (temp_block), "D" (block)

	: "%eax", "%ebx", "%ecx"

	);

/*

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

    {

       int j= zigzag_direct_noperm[i];

       block[block_permute_op(j)]= temp_block[j];

    }

*/

//block_permute(block);

    return last_non_zero_p1 - 1;

}

static int RENAME(dct_quantize)(MpegEncContext *s,

                            DCTELEM *block, int n,

                            int qscale)

{

    int i, level, last_non_zero_p1, q;

    const UINT16 *qmat;

    static __align8 INT16 temp_block[64];

    int minLevel, maxLevel;

    

    if(s->avctx!=NULL && s->avctx->codec->id==CODEC_ID_MPEG4){

	

        minLevel= -2048;

	maxLevel= 2047;

    }else if(s->out_format==FMT_MPEG1){

	

        minLevel= -255;

	maxLevel= 255;

    }else if(s->out_format==FMT_MJPEG){

	

        minLevel= -1023;

	maxLevel= 1023;

    }else{

	

        minLevel= -128;

	maxLevel= 127;

    }



    av_fdct (block);

    

    if (s->mb_intra) {

        int dummy;

        if (n < 4)

            q = s->y_dc_scale;

        else

            q = s->c_dc_scale;

        

        

#if 1

	asm volatile (

		"xorl %%edx, %%edx	\n\t"

		"mul %%ecx		\n\t"

		: "=d" (temp_block[0]), "=a"(dummy)

		: "a" (block[0] + (q >> 1)), "c" (inverse[q])

	);

#else

	asm volatile (

		"xorl %%edx, %%edx	\n\t"

		"divw %%cx		\n\t"

		"movzwl %%ax, %%eax	\n\t"

		: "=a" (temp_block[0])

		: "a" (block[0] + (q >> 1)), "c" (q)

		: "%edx"

	);

#endif



        i = 1;

        last_non_zero_p1 = 1;

        if (s->out_format == FMT_H263) {

            qmat = s->q_non_intra_matrix16;

        } else {

            qmat = s->q_intra_matrix16;

        }

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

            level = block[i] * qmat[i];

            level = level / (1 << (QMAT_SHIFT_MMX - 3));

            











            if (level > maxLevel)

                level = maxLevel;

            else if (level < minLevel)

                level = minLevel;

            temp_block[i] = level;



	    if(level) 

	        if(last_non_zero_p1 < inv_zigzag_direct16[i]) last_non_zero_p1= inv_zigzag_direct16[i];

	    block[i]=0;

        }

    } else {

        i = 0;

        last_non_zero_p1 = 0;

        qmat = s->q_non_intra_matrix16;

    }



    asm volatile( 

	"movd %3, %%mm3			\n\t"

	SPREADW(%%mm3)

	"movd %4, %%mm4			\n\t"

	SPREADW(%%mm4)

#ifndef HAVE_MMX2	

	"movd %5, %%mm5			\n\t"

	SPREADW(%%mm5)

#endif

	"pxor %%mm7, %%mm7		\n\t"

	"movd %%eax, %%mm2		\n\t"

	SPREADW(%%mm2)

	"movl %6, %%eax			\n\t"

	".balign 16			\n\t"

	"1:				\n\t"

	"movq (%1, %%eax), %%mm0	\n\t"

	"movq (%2, %%eax), %%mm1	\n\t"

	"movq %%mm0, %%mm6		\n\t"

	"psraw $15, %%mm6		\n\t"

	"pmulhw %%mm0, %%mm1		\n\t"

	"psubsw %%mm6, %%mm1		\n\t"

#ifdef HAVE_MMX2

	"pminsw %%mm3, %%mm1		\n\t"

	"pmaxsw %%mm4, %%mm1		\n\t"

#else

	"paddsw %%mm3, %%mm1		\n\t"

	"psubusw %%mm4, %%mm1		\n\t"

	"paddsw %%mm5, %%mm1		\n\t"

#endif

	"movq %%mm1, (%8, %%eax)	\n\t"

	"pcmpeqw %%mm7, %%mm1		\n\t"

	"movq (%7, %%eax), %%mm0	\n\t"

	"movq %%mm7, (%1, %%eax)	\n\t"

	"pandn %%mm0, %%mm1		\n\t"

	PMAXW(%%mm1, %%mm2)

	"addl $8, %%eax			\n\t"

	" js 1b				\n\t"

	"movq %%mm2, %%mm0		\n\t"

	"psrlq $32, %%mm2		\n\t"

	PMAXW(%%mm0, %%mm2)

	"movq %%mm2, %%mm0		\n\t"

	"psrlq $16, %%mm2		\n\t"

	PMAXW(%%mm0, %%mm2)

	"movd %%mm2, %%eax		\n\t"

	"movzbl %%al, %%eax		\n\t"

	: "+a" (last_non_zero_p1)

	: "r" (block+64), "r" (qmat+64), 

#ifdef HAVE_MMX2

	  "m" (maxLevel),          "m" (minLevel),                    "m" (minLevel ), "g" (2*i - 128),

#else

	  "m" (0x7FFF - maxLevel), "m" (0x7FFF -maxLevel + minLevel), "m" (minLevel),             "g" (2*i - 128),

#endif

	  "r" (inv_zigzag_direct16+64), "r" (temp_block+64)

    );



    

    asm volatile(

	"movl %0, %%eax			\n\t"

	"pushl %%ebp			\n\t"

	"movl %%esp, " MANGLE(esp_temp) "\n\t"

	"1:				\n\t"

	"movzbl (%1, %%eax), %%ebx	\n\t"

	"movzbl 1(%1, %%eax), %%ebp	\n\t"

	"movw (%2, %%ebx, 2), %%cx	\n\t"

	"movw (%2, %%ebp, 2), %%sp	\n\t"

	"movzbl " MANGLE(permutation) "(%%ebx), %%ebx\n\t"

	"movzbl " MANGLE(permutation) "(%%ebp), %%ebp\n\t"

	"movw %%cx, (%3, %%ebx, 2)	\n\t"

	"movw %%sp, (%3, %%ebp, 2)	\n\t"

	"addl $2, %%eax			\n\t"

	" js 1b				\n\t"

	"movl " MANGLE(esp_temp) ", %%esp\n\t"

	"popl %%ebp			\n\t"

	: 

	: "g" (-last_non_zero_p1), "d" (zigzag_direct_noperm+last_non_zero_p1), "S" (temp_block), "D" (block)

	: "%eax", "%ebx", "%ecx"

	);

















    return last_non_zero_p1 - 1;

}

                            int qscale)     int i, level, last_non_zero_p1, q;     const UINT16 *qmat;     int minLevel, maxLevel;     if(s->avctx!=NULL && s->avctx->codec->id==CODEC_ID_MPEG4){         minLevel= -2048; 	maxLevel= 2047;     }else if(s->out_format==FMT_MPEG1){         minLevel= -255; 	maxLevel= 255;     }else if(s->out_format==FMT_MJPEG){         minLevel= -1023; 	maxLevel= 1023;     }else{         minLevel= -128; 	maxLevel= 127; 	asm volatile ( 		"xorl %%edx, %%edx	\n\t" 		"mul %%ecx		\n\t" 		: "=d" (temp_block[0]), "=a"(dummy) 		: "a" (block[0] + (q >> 1)), "c" (inverse[q]) 	); 	asm volatile ( 		"xorl %%edx, %%edx	\n\t" 		"divw %%cx		\n\t" 		"movzwl %%ax, %%eax	\n\t" 		: "=a" (temp_block[0]) 		: "a" (block[0] + (q >> 1)), "c" (q) 		: "%edx" 	);         i = 1;         if (s->out_format == FMT_H263) {             qmat = s->q_non_intra_matrix16;         } else {             qmat = s->q_intra_matrix16;         for(i=1;i<4;i++) {             level = block[i] * qmat[i];             level = level / (1 << (QMAT_SHIFT_MMX - 3));             if (level > maxLevel)                 level = maxLevel;             else if (level < minLevel)                 level = minLevel;             temp_block[i] = level; 	    if(level)  	        if(last_non_zero_p1 < inv_zigzag_direct16[i]) last_non_zero_p1= inv_zigzag_direct16[i]; 	    block[i]=0;         i = 0;         qmat = s->q_non_intra_matrix16; 	"movd %3, %%mm3			\n\t" 	SPREADW(%%mm3) 	"movd %4, %%mm4			\n\t" 	SPREADW(%%mm4) #ifndef HAVE_MMX2	 	"movd %5, %%mm5			\n\t" 	SPREADW(%%mm5) #endif 	"pxor %%mm7, %%mm7		\n\t" 	"movd %%eax, %%mm2		\n\t" 	SPREADW(%%mm2) 	"movl %6, %%eax			\n\t" 	".balign 16			\n\t" 	"1:				\n\t" 	"movq (%1, %%eax), %%mm0	\n\t" 	"movq (%2, %%eax), %%mm1	\n\t" 	"movq %%mm0, %%mm6		\n\t" 	"psraw $15, %%mm6		\n\t" 	"pmulhw %%mm0, %%mm1		\n\t" 	"psubsw %%mm6, %%mm1		\n\t" #ifdef HAVE_MMX2 	"pminsw %%mm3, %%mm1		\n\t" 	"pmaxsw %%mm4, %%mm1		\n\t" #else 	"paddsw %%mm3, %%mm1		\n\t" 	"psubusw %%mm4, %%mm1		\n\t" 	"paddsw %%mm5, %%mm1		\n\t" #endif 	"movq %%mm1, (%8, %%eax)	\n\t" 	"pcmpeqw %%mm7, %%mm1		\n\t" 	"movq (%7, %%eax), %%mm0	\n\t" 	"movq %%mm7, (%1, %%eax)	\n\t" 	"pandn %%mm0, %%mm1		\n\t" 	PMAXW(%%mm1, %%mm2) 	"addl $8, %%eax			\n\t" 	" js 1b				\n\t" 	"movq %%mm2, %%mm0		\n\t" 	"psrlq $32, %%mm2		\n\t" 	PMAXW(%%mm0, %%mm2) 	"movq %%mm2, %%mm0		\n\t" 	"psrlq $16, %%mm2		\n\t" 	PMAXW(%%mm0, %%mm2) 	"movd %%mm2, %%eax		\n\t" 	"movzbl %%al, %%eax		\n\t" 	: "+a" (last_non_zero_p1) 	: "r" (block+64), "r" (qmat+64),  #ifdef HAVE_MMX2 #else 	  "m" (0x7FFF - maxLevel), "m" (0x7FFF -maxLevel + minLevel), "m" (minLevel),             "g" (2*i - 128), #endif 	  "r" (inv_zigzag_direct16+64), "r" (temp_block+64)     ); 	"movl %0, %%eax			\n\t"     } else {     } else {     int minLevel, maxLevel;     if(s->avctx!=NULL && s->avctx->codec->id==CODEC_ID_MPEG4){         minLevel= -2048; 	maxLevel= 2047;     }else if(s->out_format==FMT_MPEG1){         minLevel= -255; 	maxLevel= 255;     }else if(s->out_format==FMT_MJPEG){         minLevel= -1023; 	maxLevel= 1023;     }else{         minLevel= -128; 	maxLevel= 127;         if (s->out_format == FMT_H263) {         } else { #endif             if (level > maxLevel)                 level = maxLevel;             else if (level < minLevel)                 level = minLevel;         } else {
static int FUNC_0(dct_quantize)(MpegEncContext *s,

                            DCTELEM *block, int n,

                            int qscale)

{

    int VAR_0, VAR_1, VAR_2, VAR_3;

    const UINT16 *VAR_4;

    static __align8 VAR_5 temp_block[64];

    int VAR_6, VAR_7;

    

    if(s->avctx!=NULL && s->avctx->codec->id==CODEC_ID_MPEG4){

	

        VAR_6= -2048;

	VAR_7= 2047;

    }else if(s->out_format==FMT_MPEG1){

	

        VAR_6= -255;

	VAR_7= 255;

    }else if(s->out_format==FMT_MJPEG){

	

        VAR_6= -1023;

	VAR_7= 1023;

    }else{

	

        VAR_6= -128;

	VAR_7= 127;

    }



    av_fdct (block);

    

    if (s->mb_intra) {

        int VAR_8;

        if (n < 4)

            VAR_3 = s->y_dc_scale;

        else

            VAR_3 = s->c_dc_scale;

        

        

#if 1

	asm volatile (

		"xorl %%edx, %%edx	\n\t"

		"mul %%ecx		\n\t"

		: "=d" (temp_block[0]), "=a"(VAR_8)

		: "a" (block[0] + (VAR_3 >> 1)), "c" (inverse[VAR_3])

	);

#else

	asm volatile (

		"xorl %%edx, %%edx	\n\t"

		"divw %%cx		\n\t"

		"movzwl %%ax, %%eax	\n\t"

		: "=a" (temp_block[0])

		: "a" (block[0] + (VAR_3 >> 1)), "c" (VAR_3)

		: "%edx"

	);

#endif



        VAR_0 = 1;

        VAR_2 = 1;

        if (s->out_format == FMT_H263) {

            VAR_4 = s->q_non_intra_matrix16;

        } else {

            VAR_4 = s->q_intra_matrix16;

        }

        for(VAR_0=1;VAR_0<4;VAR_0++) {

            VAR_1 = block[VAR_0] * VAR_4[VAR_0];

            VAR_1 = VAR_1 / (1 << (QMAT_SHIFT_MMX - 3));

            











            if (VAR_1 > VAR_7)

                VAR_1 = VAR_7;

            else if (VAR_1 < VAR_6)

                VAR_1 = VAR_6;

            temp_block[VAR_0] = VAR_1;



	    if(VAR_1) 

	        if(VAR_2 < inv_zigzag_direct16[VAR_0]) VAR_2= inv_zigzag_direct16[VAR_0];

	    block[VAR_0]=0;

        }

    } else {

        VAR_0 = 0;

        VAR_2 = 0;

        VAR_4 = s->q_non_intra_matrix16;

    }



    asm volatile( 

	"movd %3, %%mm3			\n\t"

	SPREADW(%%mm3)

	"movd %4, %%mm4			\n\t"

	SPREADW(%%mm4)

#ifndef HAVE_MMX2	

	"movd %5, %%mm5			\n\t"

	SPREADW(%%mm5)

#endif

	"pxor %%mm7, %%mm7		\n\t"

	"movd %%eax, %%mm2		\n\t"

	SPREADW(%%mm2)

	"movl %6, %%eax			\n\t"

	".balign 16			\n\t"

	"1:				\n\t"

	"movq (%1, %%eax), %%mm0	\n\t"

	"movq (%2, %%eax), %%mm1	\n\t"

	"movq %%mm0, %%mm6		\n\t"

	"psraw $15, %%mm6		\n\t"

	"pmulhw %%mm0, %%mm1		\n\t"

	"psubsw %%mm6, %%mm1		\n\t"

#ifdef HAVE_MMX2

	"pminsw %%mm3, %%mm1		\n\t"

	"pmaxsw %%mm4, %%mm1		\n\t"

#else

	"paddsw %%mm3, %%mm1		\n\t"

	"psubusw %%mm4, %%mm1		\n\t"

	"paddsw %%mm5, %%mm1		\n\t"

#endif

	"movq %%mm1, (%8, %%eax)	\n\t"

	"pcmpeqw %%mm7, %%mm1		\n\t"

	"movq (%7, %%eax), %%mm0	\n\t"

	"movq %%mm7, (%1, %%eax)	\n\t"

	"pandn %%mm0, %%mm1		\n\t"

	PMAXW(%%mm1, %%mm2)

	"addl $8, %%eax			\n\t"

	" js 1b				\n\t"

	"movq %%mm2, %%mm0		\n\t"

	"psrlq $32, %%mm2		\n\t"

	PMAXW(%%mm0, %%mm2)

	"movq %%mm2, %%mm0		\n\t"

	"psrlq $16, %%mm2		\n\t"

	PMAXW(%%mm0, %%mm2)

	"movd %%mm2, %%eax		\n\t"

	"movzbl %%al, %%eax		\n\t"

	: "+a" (VAR_2)

	: "r" (block+64), "r" (VAR_4+64), 

#ifdef HAVE_MMX2

	  "m" (VAR_7),          "m" (VAR_6),                    "m" (VAR_6 ), "g" (2*VAR_0 - 128),

#else

	  "m" (0x7FFF - VAR_7), "m" (0x7FFF -VAR_7 + VAR_6), "m" (VAR_6),             "g" (2*VAR_0 - 128),

#endif

	  "r" (inv_zigzag_direct16+64), "r" (temp_block+64)

    );



    

    asm volatile(

	"movl %0, %%eax			\n\t"

	"pushl %%ebp			\n\t"

	"movl %%esp, " MANGLE(esp_temp) "\n\t"

	"1:				\n\t"

	"movzbl (%1, %%eax), %%ebx	\n\t"

	"movzbl 1(%1, %%eax), %%ebp	\n\t"

	"movw (%2, %%ebx, 2), %%cx	\n\t"

	"movw (%2, %%ebp, 2), %%sp	\n\t"

	"movzbl " MANGLE(permutation) "(%%ebx), %%ebx\n\t"

	"movzbl " MANGLE(permutation) "(%%ebp), %%ebp\n\t"

	"movw %%cx, (%3, %%ebx, 2)	\n\t"

	"movw %%sp, (%3, %%ebp, 2)	\n\t"

	"addl $2, %%eax			\n\t"

	" js 1b				\n\t"

	"movl " MANGLE(esp_temp) ", %%esp\n\t"

	"popl %%ebp			\n\t"

	: 

	: "g" (-VAR_2), "d" (zigzag_direct_noperm+VAR_2), "S" (temp_block), "D" (block)

	: "%eax", "%ebx", "%ecx"

	);

















    return VAR_2 - 1;

}

static int FUNC_0(dct_quantize)(MpegEncContext *s,
DCTELEM *block, int n,
int qscale)
{ int VAR_0, VAR_1, VAR_2, VAR_3; const UINT16 *VAR_4; static __align8 VAR_5 temp_block[64]; int VAR_6, VAR_7; if(s->avctx!=NULL && s->avctx->codec->id==CODEC_ID_MPEG4){ VAR_6= -2048; VAR_7= 2047; }else if(s->out_format==FMT_MPEG1){ VAR_6= -255; VAR_7= 255; }else if(s->out_format==FMT_MJPEG){ VAR_6= -1023; VAR_7= 1023; }else{ VAR_6= -128; VAR_7= 127; } av_fdct (block); if (s->mb_intra) { int VAR_8; if (n < 4)
VAR_3 = s->y_dc_scale; else
VAR_3 = s->c_dc_scale; #if 1
asm volatile (
"xorl %%edx, %%edx	\n\t"
"mul %%ecx		\n\t"
: "=d" (temp_block[0]), "=a"(VAR_8)
: "a" (block[0] + (VAR_3 >> 1)), "c" (inverse[VAR_3])
); #else
asm volatile (
"xorl %%edx, %%edx	\n\t"
"divw %%cx		\n\t"
"movzwl %%ax, %%eax	\n\t"
: "=a" (temp_block[0])
: "a" (block[0] + (VAR_3 >> 1)), "c" (VAR_3)
: "%edx"
); #endif
VAR_0 = 1; VAR_2 = 1; if (s->out_format == FMT_H263) { VAR_4 = s->q_non_intra_matrix16; } else { VAR_4 = s->q_intra_matrix16; } for(VAR_0=1;VAR_0<4;VAR_0++) { VAR_1 = block[VAR_0] * VAR_4[VAR_0]; VAR_1 = VAR_1 / (1 << (QMAT_SHIFT_MMX - 3)); if (VAR_1 > VAR_7)
VAR_1 = VAR_7; else if (VAR_1 < VAR_6)
VAR_1 = VAR_6; temp_block[VAR_0] = VAR_1; if(VAR_1)
if(VAR_2 < inv_zigzag_direct16[VAR_0]) VAR_2= inv_zigzag_direct16[VAR_0]; block[VAR_0]=0; } } else { VAR_0 = 0; VAR_2 = 0; VAR_4 = s->q_non_intra_matrix16; } asm volatile(
"movd %3, %%mm3			\n\t"
SPREADW(%%mm3)
"movd %4, %%mm4			\n\t"
SPREADW(%%mm4)
#ifndef HAVE_MMX2
"movd %5, %%mm5			\n\t"
SPREADW(%%mm5)
#endif
"pxor %%mm7, %%mm7		\n\t"
"movd %%eax, %%mm2		\n\t"
SPREADW(%%mm2)
"movl %6, %%eax			\n\t"
".balign 16			\n\t"
"1:				\n\t"
"movq (%1, %%eax), %%mm0	\n\t"
"movq (%2, %%eax), %%mm1	\n\t"
"movq %%mm0, %%mm6		\n\t"
"psraw $15, %%mm6		\n\t"
"pmulhw %%mm0, %%mm1		\n\t"
"psubsw %%mm6, %%mm1		\n\t"
#ifdef HAVE_MMX2
"pminsw %%mm3, %%mm1		\n\t"
"pmaxsw %%mm4, %%mm1		\n\t"
#else
"paddsw %%mm3, %%mm1		\n\t"
"psubusw %%mm4, %%mm1		\n\t"
"paddsw %%mm5, %%mm1		\n\t"
#endif
"movq %%mm1, (%8, %%eax)	\n\t"
"pcmpeqw %%mm7, %%mm1		\n\t"
"movq (%7, %%eax), %%mm0	\n\t"
"movq %%mm7, (%1, %%eax)	\n\t"
"pandn %%mm0, %%mm1		\n\t"
PMAXW(%%mm1, %%mm2)
"addl $8, %%eax			\n\t"
" js 1b				\n\t"
"movq %%mm2, %%mm0		\n\t"
"psrlq $32, %%mm2		\n\t"
PMAXW(%%mm0, %%mm2)
"movq %%mm2, %%mm0		\n\t"
"psrlq $16, %%mm2		\n\t"
PMAXW(%%mm0, %%mm2)
"movd %%mm2, %%eax		\n\t"
"movzbl %%al, %%eax		\n\t"
: "+a" (VAR_2)
: "r" (block+64), "r" (VAR_4+64),
#ifdef HAVE_MMX2
"m" (VAR_7),          "m" (VAR_6),                    "m" (VAR_6 ), "g" (2*VAR_0 - 128),
#else
"m" (0x7FFF - VAR_7), "m" (0x7FFF -VAR_7 + VAR_6), "m" (VAR_6),             "g" (2*VAR_0 - 128),
#endif
"r" (inv_zigzag_direct16+64), "r" (temp_block+64)
); asm volatile(
"movl %0, %%eax			\n\t"
"pushl %%ebp			\n\t"
"movl %%esp, " MANGLE(esp_temp) "\n\t"
"1:				\n\t"
"movzbl (%1, %%eax), %%ebx	\n\t"
"movzbl 1(%1, %%eax), %%ebp	\n\t"
"movw (%2, %%ebx, 2), %%cx	\n\t"
"movw (%2, %%ebp, 2), %%sp	\n\t"
"movzbl " MANGLE(permutation) "(%%ebx), %%ebx\n\t"
"movzbl " MANGLE(permutation) "(%%ebp), %%ebp\n\t"
"movw %%cx, (%3, %%ebx, 2)	\n\t"
"movw %%sp, (%3, %%ebp, 2)	\n\t"
"addl $2, %%eax			\n\t"
" js 1b				\n\t"
"movl " MANGLE(esp_temp) ", %%esp\n\t"
"popl %%ebp			\n\t"
:
: "g" (-VAR_2), "d" (zigzag_direct_noperm+VAR_2), "S" (temp_block), "D" (block)
: "%eax", "%ebx", "%ecx"
); return VAR_2 - 1; }