static void initMMX2HScaler(int dstW, int xInc, uint8_t *funnyCode)

{

	uint8_t *fragment;

	int imm8OfPShufW1;

	int imm8OfPShufW2;

	int fragmentLength;



	int xpos, i;



	// create an optimized horizontal scaling routine



	//code fragment



	asm volatile(

		"jmp 9f				\n\t"

	// Begin

		"0:				\n\t"

		"movq (%%esi), %%mm0		\n\t" //FIXME Alignment

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

		"psrlq $8, %%mm0		\n\t"

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

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

		"punpcklbw %%mm7, %%mm0	\n\t"

		"addw %%bx, %%cx		\n\t" //2*xalpha += (4*lumXInc)&0xFFFF

		"pshufw $0xFF, %%mm1, %%mm1	\n\t"

		"1:				\n\t"

		"adcl %%edx, %%esi		\n\t" //xx+= (4*lumXInc)>>16 + carry

		"pshufw $0xFF, %%mm0, %%mm0	\n\t"

		"2:				\n\t"

		"psrlw $9, %%mm3		\n\t"

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

		"pmullw %%mm3, %%mm0		\n\t"

		"paddw %%mm6, %%mm2		\n\t" // 2*alpha += xpos&0xFFFF

		"psllw $7, %%mm1		\n\t"

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



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



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

	// End

		"9:				\n\t"

//		"int $3\n\t"

		"leal 0b, %0			\n\t"

		"leal 1b, %1			\n\t"

		"leal 2b, %2			\n\t"

		"decl %1			\n\t"

		"decl %2			\n\t"

		"subl %0, %1			\n\t"

		"subl %0, %2			\n\t"

		"leal 9b, %3			\n\t"

		"subl %0, %3			\n\t"

		:"=r" (fragment), "=r" (imm8OfPShufW1), "=r" (imm8OfPShufW2),

		"=r" (fragmentLength)

	);



	xpos= 0; //lumXInc/2 - 0x8000; // difference between pixel centers



	for(i=0; i<dstW/8; i++)

	{

		int xx=xpos>>16;



		if((i&3) == 0)

		{

			int a=0;

			int b=((xpos+xInc)>>16) - xx;

			int c=((xpos+xInc*2)>>16) - xx;

			int d=((xpos+xInc*3)>>16) - xx;



			memcpy(funnyCode + fragmentLength*i/4, fragment, fragmentLength);



			funnyCode[fragmentLength*i/4 + imm8OfPShufW1]=

			funnyCode[fragmentLength*i/4 + imm8OfPShufW2]=

				a | (b<<2) | (c<<4) | (d<<6);



			// if we dont need to read 8 bytes than dont :), reduces the chance of

			// crossing a cache line

			if(d<3) funnyCode[fragmentLength*i/4 + 1]= 0x6E;



			funnyCode[fragmentLength*(i+4)/4]= RET;

		}

		xpos+=xInc;

	}

}

static void initMMX2HScaler(int dstW, int xInc, uint8_t *funnyCode)

{

	uint8_t *fragment;

	int imm8OfPShufW1;

	int imm8OfPShufW2;

	int fragmentLength;



	int xpos, i;



	



	



	asm volatile(

		"jmp 9f				\n\t"

	

		"0:				\n\t"

		"movq (%%esi), %%mm0		\n\t" 

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

		"psrlq $8, %%mm0		\n\t"

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

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

		"punpcklbw %%mm7, %%mm0	\n\t"

		"addw %%bx, %%cx		\n\t" 

		"pshufw $0xFF, %%mm1, %%mm1	\n\t"

		"1:				\n\t"

		"adcl %%edx, %%esi		\n\t" 

		"pshufw $0xFF, %%mm0, %%mm0	\n\t"

		"2:				\n\t"

		"psrlw $9, %%mm3		\n\t"

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

		"pmullw %%mm3, %%mm0		\n\t"

		"paddw %%mm6, %%mm2		\n\t" 

		"psllw $7, %%mm1		\n\t"

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



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



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

	

		"9:				\n\t"



		"leal 0b, %0			\n\t"

		"leal 1b, %1			\n\t"

		"leal 2b, %2			\n\t"

		"decl %1			\n\t"

		"decl %2			\n\t"

		"subl %0, %1			\n\t"

		"subl %0, %2			\n\t"

		"leal 9b, %3			\n\t"

		"subl %0, %3			\n\t"

		:"=r" (fragment), "=r" (imm8OfPShufW1), "=r" (imm8OfPShufW2),

		"=r" (fragmentLength)

	);



	xpos= 0; 



	for(i=0; i<dstW/8; i++)

	{

		int xx=xpos>>16;



		if((i&3) == 0)

		{

			int a=0;

			int b=((xpos+xInc)>>16) - xx;

			int c=((xpos+xInc*2)>>16) - xx;

			int d=((xpos+xInc*3)>>16) - xx;



			memcpy(funnyCode + fragmentLength*i/4, fragment, fragmentLength);



			funnyCode[fragmentLength*i/4 + imm8OfPShufW1]=

			funnyCode[fragmentLength*i/4 + imm8OfPShufW2]=

				a | (b<<2) | (c<<4) | (d<<6);



			

			

			if(d<3) funnyCode[fragmentLength*i/4 + 1]= 0x6E;



			funnyCode[fragmentLength*(i+4)/4]= RET;

		}

		xpos+=xInc;

	}

}

static void initMMX2HScaler(int dstW, int xInc, uint8_t *funnyCode) 	uint8_t *fragment; 	int imm8OfPShufW1; 	int imm8OfPShufW2; 	int fragmentLength; 		"movq %%mm0, %%mm1		\n\t" 		"psrlq $8, %%mm0		\n\t" 		"punpcklbw %%mm7, %%mm1	\n\t" 		"movq %%mm2, %%mm3		\n\t" 		"punpcklbw %%mm7, %%mm0	\n\t" 		"psrlw $9, %%mm3		\n\t" 		:"=r" (fragment), "=r" (imm8OfPShufW1), "=r" (imm8OfPShufW2), 		"=r" (fragmentLength) 	for(i=0; i<dstW/8; i++) 			memcpy(funnyCode + fragmentLength*i/4, fragment, fragmentLength); 			funnyCode[fragmentLength*i/4 + imm8OfPShufW1]= 			funnyCode[fragmentLength*i/4 + imm8OfPShufW2]= 				a | (b<<2) | (c<<4) | (d<<6); 			if(d<3) funnyCode[fragmentLength*i/4 + 1]= 0x6E; 			funnyCode[fragmentLength*(i+4)/4]= RET; 	);
static void FUNC_0(int VAR_0, int VAR_1, uint8_t *VAR_2)

{

	uint8_t *fragment;

	int VAR_3;

	int VAR_4;

	int VAR_5;



	int VAR_6, VAR_7;



	



	



	asm volatile(

		"jmp 9f				\n\t"

	

		"0:				\n\t"

		"movq (%%esi), %%mm0		\n\t" 

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

		"psrlq $8, %%mm0		\n\t"

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

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

		"punpcklbw %%mm7, %%mm0	\n\t"

		"addw %%bx, %%cx		\n\t" 

		"pshufw $0xFF, %%mm1, %%mm1	\n\t"

		"1:				\n\t"

		"adcl %%edx, %%esi		\n\t" 

		"pshufw $0xFF, %%mm0, %%mm0	\n\t"

		"2:				\n\t"

		"psrlw $9, %%mm3		\n\t"

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

		"pmullw %%mm3, %%mm0		\n\t"

		"paddw %%mm6, %%mm2		\n\t" 

		"psllw $7, %%mm1		\n\t"

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



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



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

	

		"9:				\n\t"



		"leal 0b, %0			\n\t"

		"leal 1b, %1			\n\t"

		"leal 2b, %2			\n\t"

		"decl %1			\n\t"

		"decl %2			\n\t"

		"subl %0, %1			\n\t"

		"subl %0, %2			\n\t"

		"leal 9b, %3			\n\t"

		"subl %0, %3			\n\t"

		:"=r" (fragment), "=r" (VAR_3), "=r" (VAR_4),

		"=r" (VAR_5)

	);



	VAR_6= 0; 



	for(VAR_7=0; VAR_7<VAR_0/8; VAR_7++)

	{

		int VAR_8=VAR_6>>16;



		if((VAR_7&3) == 0)

		{

			int VAR_9=0;

			int VAR_10=((VAR_6+VAR_1)>>16) - VAR_8;

			int VAR_11=((VAR_6+VAR_1*2)>>16) - VAR_8;

			int VAR_12=((VAR_6+VAR_1*3)>>16) - VAR_8;



			memcpy(VAR_2 + VAR_5*VAR_7/4, fragment, VAR_5);



			VAR_2[VAR_5*VAR_7/4 + VAR_3]=

			VAR_2[VAR_5*VAR_7/4 + VAR_4]=

				VAR_9 | (VAR_10<<2) | (VAR_11<<4) | (VAR_12<<6);



			

			

			if(VAR_12<3) VAR_2[VAR_5*VAR_7/4 + 1]= 0x6E;



			VAR_2[VAR_5*(VAR_7+4)/4]= RET;

		}

		VAR_6+=VAR_1;

	}

}

static void FUNC_0(int VAR_0, int VAR_1, uint8_t *VAR_2)
{ uint8_t *fragment; int VAR_3; int VAR_4; int VAR_5; int VAR_6, VAR_7; asm volatile(
"jmp 9f				\n\t"
"0:				\n\t"
"movq (%%esi), %%mm0		\n\t"
"movq %%mm0, %%mm1		\n\t"
"psrlq $8, %%mm0		\n\t"
"punpcklbw %%mm7, %%mm1	\n\t"
"movq %%mm2, %%mm3		\n\t"
"punpcklbw %%mm7, %%mm0	\n\t"
"addw %%bx, %%cx		\n\t"
"pshufw $0xFF, %%mm1, %%mm1	\n\t"
"1:				\n\t"
"adcl %%edx, %%esi		\n\t"
"pshufw $0xFF, %%mm0, %%mm0	\n\t"
"2:				\n\t"
"psrlw $9, %%mm3		\n\t"
"psubw %%mm1, %%mm0		\n\t"
"pmullw %%mm3, %%mm0		\n\t"
"paddw %%mm6, %%mm2		\n\t"
"psllw $7, %%mm1		\n\t"
"paddw %%mm1, %%mm0		\n\t"
"movq %%mm0, (%%edi, %%eax)	\n\t"
"addl $8, %%eax			\n\t"
"9:				\n\t"
"leal 0b, %0			\n\t"
"leal 1b, %1			\n\t"
"leal 2b, %2			\n\t"
"decl %1			\n\t"
"decl %2			\n\t"
"subl %0, %1			\n\t"
"subl %0, %2			\n\t"
"leal 9b, %3			\n\t"
"subl %0, %3			\n\t"
:"=r" (fragment), "=r" (VAR_3), "=r" (VAR_4),
"=r" (VAR_5)
); VAR_6= 0; for(VAR_7=0; VAR_7<VAR_0/8; VAR_7++) { int VAR_8=VAR_6>>16; if((VAR_7&3) == 0)
{ int VAR_9=0; int VAR_10=((VAR_6+VAR_1)>>16) - VAR_8; int VAR_11=((VAR_6+VAR_1*2)>>16) - VAR_8; int VAR_12=((VAR_6+VAR_1*3)>>16) - VAR_8; memcpy(VAR_2 + VAR_5*VAR_7/4, fragment, VAR_5); VAR_2[VAR_5*VAR_7/4 + VAR_3]=
VAR_2[VAR_5*VAR_7/4 + VAR_4]=
VAR_9 | (VAR_10<<2) | (VAR_11<<4) | (VAR_12<<6); if(VAR_12<3) VAR_2[VAR_5*VAR_7/4 + 1]= 0x6E; VAR_2[VAR_5*(VAR_7+4)/4]= RET; } VAR_6+=VAR_1; } }