static inline void RENAME(hyscale)(uint16_t *dst, int dstWidth, uint8_t *src, int srcW, int xInc)

{

#ifdef HAVE_MMX

	// use the new MMX scaler if th mmx2 cant be used (its faster than the x86asm one)

    if(sws_flags != SWS_FAST_BILINEAR || (!canMMX2BeUsed))

#else

    if(sws_flags != SWS_FAST_BILINEAR)

#endif

    {

    	RENAME(hScale)(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize);

    }

    else // Fast Bilinear upscale / crap downscale

    {

#ifdef ARCH_X86

#ifdef HAVE_MMX2

	int i;

	if(canMMX2BeUsed)

	{

		asm volatile(

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

			"pxor %%mm2, %%mm2		\n\t" // 2*xalpha

			"movd %5, %%mm6			\n\t" // xInc&0xFFFF

			"punpcklwd %%mm6, %%mm6		\n\t"

			"punpcklwd %%mm6, %%mm6		\n\t"

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

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

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

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

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

			"psllq $16, %%mm2		\n\t" //0,t,2t,3t		t=xInc&0xFF

			"movq %%mm2, "MANGLE(temp0)"	\n\t"

			"movd %4, %%mm6			\n\t" //(xInc*4)&0xFFFF

			"punpcklwd %%mm6, %%mm6		\n\t"

			"punpcklwd %%mm6, %%mm6		\n\t"

			"xorl %%eax, %%eax		\n\t" // i

			"movl %0, %%esi			\n\t" // src

			"movl %1, %%edi			\n\t" // buf1

			"movl %3, %%edx			\n\t" // (xInc*4)>>16

			"xorl %%ecx, %%ecx		\n\t"

			"xorl %%ebx, %%ebx		\n\t"

			"movw %4, %%bx			\n\t" // (xInc*4)&0xFFFF



#define FUNNY_Y_CODE \

			PREFETCH" 1024(%%esi)		\n\t"\

			PREFETCH" 1056(%%esi)		\n\t"\

			PREFETCH" 1088(%%esi)		\n\t"\

			"call "MANGLE(funnyYCode)"	\n\t"\

			"movq "MANGLE(temp0)", %%mm2	\n\t"\

			"xorl %%ecx, %%ecx		\n\t"



FUNNY_Y_CODE

FUNNY_Y_CODE

FUNNY_Y_CODE

FUNNY_Y_CODE

FUNNY_Y_CODE

FUNNY_Y_CODE

FUNNY_Y_CODE

FUNNY_Y_CODE



			:: "m" (src), "m" (dst), "m" (dstWidth), "m" ((xInc*4)>>16),

			"m" ((xInc*4)&0xFFFF), "m" (xInc&0xFFFF)

			: "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi"

		);

		for(i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) dst[i] = src[srcW-1]*128;

	}

	else

	{

#endif

	//NO MMX just normal asm ...

	asm volatile(

		"xorl %%eax, %%eax		\n\t" // i

		"xorl %%ebx, %%ebx		\n\t" // xx

		"xorl %%ecx, %%ecx		\n\t" // 2*xalpha

		".balign 16			\n\t"

		"1:				\n\t"

		"movzbl  (%0, %%ebx), %%edi	\n\t" //src[xx]

		"movzbl 1(%0, %%ebx), %%esi	\n\t" //src[xx+1]

		"subl %%edi, %%esi		\n\t" //src[xx+1] - src[xx]

		"imull %%ecx, %%esi		\n\t" //(src[xx+1] - src[xx])*2*xalpha

		"shll $16, %%edi		\n\t"

		"addl %%edi, %%esi		\n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha)

		"movl %1, %%edi			\n\t"

		"shrl $9, %%esi			\n\t"

		"movw %%si, (%%edi, %%eax, 2)	\n\t"

		"addw %4, %%cx			\n\t" //2*xalpha += xInc&0xFF

		"adcl %3, %%ebx			\n\t" //xx+= xInc>>8 + carry



		"movzbl (%0, %%ebx), %%edi	\n\t" //src[xx]

		"movzbl 1(%0, %%ebx), %%esi	\n\t" //src[xx+1]

		"subl %%edi, %%esi		\n\t" //src[xx+1] - src[xx]

		"imull %%ecx, %%esi		\n\t" //(src[xx+1] - src[xx])*2*xalpha

		"shll $16, %%edi		\n\t"

		"addl %%edi, %%esi		\n\t" //src[xx+1]*2*xalpha + src[xx]*(1-2*xalpha)

		"movl %1, %%edi			\n\t"

		"shrl $9, %%esi			\n\t"

		"movw %%si, 2(%%edi, %%eax, 2)	\n\t"

		"addw %4, %%cx			\n\t" //2*xalpha += xInc&0xFF

		"adcl %3, %%ebx			\n\t" //xx+= xInc>>8 + carry





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

		"cmpl %2, %%eax			\n\t"

		" jb 1b				\n\t"





		:: "r" (src), "m" (dst), "m" (dstWidth), "m" (xInc>>16), "m" (xInc&0xFFFF)

		: "%eax", "%ebx", "%ecx", "%edi", "%esi"

		);

#ifdef HAVE_MMX2

	} //if MMX2 cant be used

#endif

#else

	int i;

	unsigned int xpos=0;

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

	{

		register unsigned int xx=xpos>>16;

		register unsigned int xalpha=(xpos&0xFFFF)>>9;

		dst[i]= (src[xx]<<7) + (src[xx+1] - src[xx])*xalpha;

		xpos+=xInc;

	}

#endif

    }

}

static inline void RENAME(hyscale)(uint16_t *dst, int dstWidth, uint8_t *src, int srcW, int xInc)

{

#ifdef HAVE_MMX

	

    if(sws_flags != SWS_FAST_BILINEAR || (!canMMX2BeUsed))

#else

    if(sws_flags != SWS_FAST_BILINEAR)

#endif

    {

    	RENAME(hScale)(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize);

    }

    else 

    {

#ifdef ARCH_X86

#ifdef HAVE_MMX2

	int i;

	if(canMMX2BeUsed)

	{

		asm volatile(

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

			"pxor %%mm2, %%mm2		\n\t" 

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

			"punpcklwd %%mm6, %%mm6		\n\t"

			"punpcklwd %%mm6, %%mm6		\n\t"

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

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

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

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

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

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

			"movq %%mm2, "MANGLE(temp0)"	\n\t"

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

			"punpcklwd %%mm6, %%mm6		\n\t"

			"punpcklwd %%mm6, %%mm6		\n\t"

			"xorl %%eax, %%eax		\n\t" 

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

			"movl %1, %%edi			\n\t" 

			"movl %3, %%edx			\n\t" 

			"xorl %%ecx, %%ecx		\n\t"

			"xorl %%ebx, %%ebx		\n\t"

			"movw %4, %%bx			\n\t" 



#define FUNNY_Y_CODE \

			PREFETCH" 1024(%%esi)		\n\t"\

			PREFETCH" 1056(%%esi)		\n\t"\

			PREFETCH" 1088(%%esi)		\n\t"\

			"call "MANGLE(funnyYCode)"	\n\t"\

			"movq "MANGLE(temp0)", %%mm2	\n\t"\

			"xorl %%ecx, %%ecx		\n\t"



FUNNY_Y_CODE

FUNNY_Y_CODE

FUNNY_Y_CODE

FUNNY_Y_CODE

FUNNY_Y_CODE

FUNNY_Y_CODE

FUNNY_Y_CODE

FUNNY_Y_CODE



			:: "m" (src), "m" (dst), "m" (dstWidth), "m" ((xInc*4)>>16),

			"m" ((xInc*4)&0xFFFF), "m" (xInc&0xFFFF)

			: "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi"

		);

		for(i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) dst[i] = src[srcW-1]*128;

	}

	else

	{

#endif

	

	asm volatile(

		"xorl %%eax, %%eax		\n\t" 

		"xorl %%ebx, %%ebx		\n\t" 

		"xorl %%ecx, %%ecx		\n\t" 

		".balign 16			\n\t"

		"1:				\n\t"

		"movzbl  (%0, %%ebx), %%edi	\n\t" 

		"movzbl 1(%0, %%ebx), %%esi	\n\t" 

		"subl %%edi, %%esi		\n\t"  - src[xx]

		"imull %%ecx, %%esi		\n\t" 

		"shll $16, %%edi		\n\t"

		"addl %%edi, %%esi		\n\t" *2*xalpha + src[xx]*(1-2*xalpha)

		"movl %1, %%edi			\n\t"

		"shrl $9, %%esi			\n\t"

		"movw %%si, (%%edi, %%eax, 2)	\n\t"

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

		"adcl %3, %%ebx			\n\t" 



		"movzbl (%0, %%ebx), %%edi	\n\t" 

		"movzbl 1(%0, %%ebx), %%esi	\n\t" 

		"subl %%edi, %%esi		\n\t"  - src[xx]

		"imull %%ecx, %%esi		\n\t" 

		"shll $16, %%edi		\n\t"

		"addl %%edi, %%esi		\n\t" *2*xalpha + src[xx]*(1-2*xalpha)

		"movl %1, %%edi			\n\t"

		"shrl $9, %%esi			\n\t"

		"movw %%si, 2(%%edi, %%eax, 2)	\n\t"

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

		"adcl %3, %%ebx			\n\t" 





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

		"cmpl %2, %%eax			\n\t"

		" jb 1b				\n\t"





		:: "r" (src), "m" (dst), "m" (dstWidth), "m" (xInc>>16), "m" (xInc&0xFFFF)

		: "%eax", "%ebx", "%ecx", "%edi", "%esi"

		);

#ifdef HAVE_MMX2

	} 

#endif

#else

	int i;

	unsigned int xpos=0;

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

	{

		register unsigned int xx=xpos>>16;

		register unsigned int xalpha=(xpos&0xFFFF)>>9;

		dst[i]= (src[xx]<<7) + (src[xx+1] - src[xx])*xalpha;

		xpos+=xInc;

	}

#endif

    }

}

#else #endif #else #endif #ifdef HAVE_MMX2 #else static inline void RENAME(hyscale)(uint16_t *dst, int dstWidth, uint8_t *src, int srcW, int xInc)     if(sws_flags != SWS_FAST_BILINEAR || (!canMMX2BeUsed))     if(sws_flags != SWS_FAST_BILINEAR) 			"movq %%mm2, "MANGLE(temp0)"	\n\t" 			"call "MANGLE(funnyYCode)"	\n\t"\ 			"movq "MANGLE(temp0)", %%mm2	\n\t"\ 			"m" ((xInc*4)&0xFFFF), "m" (xInc&0xFFFF)     if(sws_flags != SWS_FAST_BILINEAR || (!canMMX2BeUsed))     if(sws_flags != SWS_FAST_BILINEAR) 			"movq "MANGLE(temp0)", %%mm2	\n\t"\ 	int i; #ifdef HAVE_MMX #endif #ifdef HAVE_MMX2 	asm volatile( 		"1:				\n\t" 		xpos+=xInc; #ifdef HAVE_MMX2 #else #endif #else #endif #ifdef HAVE_MMX2 #else #endif #endif #ifdef HAVE_MMX #else #endif #ifdef HAVE_MMX2 #endif #ifdef HAVE_MMX #endif #ifdef HAVE_MMX2 #else #endif #ifdef HAVE_MMX #else #endif #ifdef HAVE_MMX #else #endif
static inline void FUNC_0(hyscale)(uint16_t *dst, int dstWidth, uint8_t *src, int srcW, int xInc)

{

#ifdef HAVE_MMX

	

    if(sws_flags != SWS_FAST_BILINEAR || (!canMMX2BeUsed))

#else

    if(sws_flags != SWS_FAST_BILINEAR)

#endif

    {

    	FUNC_0(hScale)(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize);

    }

    else 

    {

#ifdef ARCH_X86

#ifdef HAVE_MMX2

	int VAR_0;

	if(canMMX2BeUsed)

	{

		asm volatile(

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

			"pxor %%mm2, %%mm2		\n\t" 

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

			"punpcklwd %%mm6, %%mm6		\n\t"

			"punpcklwd %%mm6, %%mm6		\n\t"

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

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

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

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

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

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

			"movq %%mm2, "MANGLE(temp0)"	\n\t"

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

			"punpcklwd %%mm6, %%mm6		\n\t"

			"punpcklwd %%mm6, %%mm6		\n\t"

			"xorl %%eax, %%eax		\n\t" 

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

			"movl %1, %%edi			\n\t" 

			"movl %3, %%edx			\n\t" 

			"xorl %%ecx, %%ecx		\n\t"

			"xorl %%ebx, %%ebx		\n\t"

			"movw %4, %%bx			\n\t" 



#define FUNNY_Y_CODE \

			PREFETCH" 1024(%%esi)		\n\t"\

			PREFETCH" 1056(%%esi)		\n\t"\

			PREFETCH" 1088(%%esi)		\n\t"\

			"call "MANGLE(funnyYCode)"	\n\t"\

			"movq "MANGLE(temp0)", %%mm2	\n\t"\

			"xorl %%ecx, %%ecx		\n\t"



FUNNY_Y_CODE

FUNNY_Y_CODE

FUNNY_Y_CODE

FUNNY_Y_CODE

FUNNY_Y_CODE

FUNNY_Y_CODE

FUNNY_Y_CODE

FUNNY_Y_CODE



			:: "m" (src), "m" (dst), "m" (dstWidth), "m" ((xInc*4)>>16),

			"m" ((xInc*4)&0xFFFF), "m" (xInc&0xFFFF)

			: "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi"

		);

		for(VAR_0=dstWidth-1; (VAR_0*xInc)>>16 >=srcW-1; VAR_0--) dst[VAR_0] = src[srcW-1]*128;

	}

	else

	{

#endif

	

	asm volatile(

		"xorl %%eax, %%eax		\n\t" 

		"xorl %%ebx, %%ebx		\n\t" 

		"xorl %%ecx, %%ecx		\n\t" 

		".balign 16			\n\t"

		"1:				\n\t"

		"movzbl  (%0, %%ebx), %%edi	\n\t" 

		"movzbl 1(%0, %%ebx), %%esi	\n\t" 

		"subl %%edi, %%esi		\n\t"  - src[xx]

		"imull %%ecx, %%esi		\n\t" 

		"shll $16, %%edi		\n\t"

		"addl %%edi, %%esi		\n\t" *2*xalpha + src[xx]*(1-2*xalpha)

		"movl %1, %%edi			\n\t"

		"shrl $9, %%esi			\n\t"

		"movw %%si, (%%edi, %%eax, 2)	\n\t"

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

		"adcl %3, %%ebx			\n\t" 



		"movzbl (%0, %%ebx), %%edi	\n\t" 

		"movzbl 1(%0, %%ebx), %%esi	\n\t" 

		"subl %%edi, %%esi		\n\t"  - src[xx]

		"imull %%ecx, %%esi		\n\t" 

		"shll $16, %%edi		\n\t"

		"addl %%edi, %%esi		\n\t" *2*xalpha + src[xx]*(1-2*xalpha)

		"movl %1, %%edi			\n\t"

		"shrl $9, %%esi			\n\t"

		"movw %%si, 2(%%edi, %%eax, 2)	\n\t"

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

		"adcl %3, %%ebx			\n\t" 





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

		"cmpl %2, %%eax			\n\t"

		" jb 1b				\n\t"





		:: "r" (src), "m" (dst), "m" (dstWidth), "m" (xInc>>16), "m" (xInc&0xFFFF)

		: "%eax", "%ebx", "%ecx", "%edi", "%esi"

		);

#ifdef HAVE_MMX2

	} 

#endif

#else

	int VAR_0;

	unsigned int VAR_1=0;

	for(VAR_0=0;VAR_0<dstWidth;VAR_0++)

	{

		register unsigned int xx=VAR_1>>16;

		register unsigned int xalpha=(VAR_1&0xFFFF)>>9;

		dst[VAR_0]= (src[xx]<<7) + (src[xx+1] - src[xx])*xalpha;

		VAR_1+=xInc;

	}

#endif

    }

}

static inline void FUNC_0(hyscale)(uint16_t *dst, int dstWidth, uint8_t *src, int srcW, int xInc)
{ #ifdef HAVE_MMX
if(sws_flags != SWS_FAST_BILINEAR || (!canMMX2BeUsed))
#else
if(sws_flags != SWS_FAST_BILINEAR)
#endif
{ FUNC_0(hScale)(dst, dstWidth, src, srcW, xInc, hLumFilter, hLumFilterPos, hLumFilterSize); } else
{ #ifdef ARCH_X86
#ifdef HAVE_MMX2
int VAR_0; if(canMMX2BeUsed)
{ asm volatile(
"pxor %%mm7, %%mm7		\n\t"
"pxor %%mm2, %%mm2		\n\t"
"movd %5, %%mm6			\n\t"
"punpcklwd %%mm6, %%mm6		\n\t"
"punpcklwd %%mm6, %%mm6		\n\t"
"movq %%mm6, %%mm2		\n\t"
"psllq $16, %%mm2		\n\t"
"paddw %%mm6, %%mm2		\n\t"
"psllq $16, %%mm2		\n\t"
"paddw %%mm6, %%mm2		\n\t"
"psllq $16, %%mm2		\n\t"
"movq %%mm2, "MANGLE(temp0)"	\n\t"
"movd %4, %%mm6			\n\t"
"punpcklwd %%mm6, %%mm6		\n\t"
"punpcklwd %%mm6, %%mm6		\n\t"
"xorl %%eax, %%eax		\n\t"
"movl %0, %%esi			\n\t"
"movl %1, %%edi			\n\t"
"movl %3, %%edx			\n\t"
"xorl %%ecx, %%ecx		\n\t"
"xorl %%ebx, %%ebx		\n\t"
"movw %4, %%bx			\n\t"
#define FUNNY_Y_CODE \
PREFETCH" 1024(%%esi)		\n\t"\
PREFETCH" 1056(%%esi)		\n\t"\
PREFETCH" 1088(%%esi)		\n\t"\
"call "MANGLE(funnyYCode)"	\n\t"\
"movq "MANGLE(temp0)", %%mm2	\n\t"\
"xorl %%ecx, %%ecx		\n\t"
FUNNY_Y_CODE
FUNNY_Y_CODE
FUNNY_Y_CODE
FUNNY_Y_CODE
FUNNY_Y_CODE
FUNNY_Y_CODE
FUNNY_Y_CODE
FUNNY_Y_CODE
:: "m" (src), "m" (dst), "m" (dstWidth), "m" ((xInc*4)>>16),
"m" ((xInc*4)&0xFFFF), "m" (xInc&0xFFFF)
: "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi"
); for(VAR_0=dstWidth-1; (VAR_0*xInc)>>16 >=srcW-1; VAR_0--) dst[VAR_0] = src[srcW-1]*128; } else
{ #endif
asm volatile(
"xorl %%eax, %%eax		\n\t"
"xorl %%ebx, %%ebx		\n\t"
"xorl %%ecx, %%ecx		\n\t"
".balign 16			\n\t"
"1:				\n\t"
"movzbl  (%0, %%ebx), %%edi	\n\t"
"movzbl 1(%0, %%ebx), %%esi	\n\t"
"subl %%edi, %%esi		\n\t"  - src[xx]
"imull %%ecx, %%esi		\n\t"
"shll $16, %%edi		\n\t"
"addl %%edi, %%esi		\n\t" *2*xalpha + src[xx]*(1-2*xalpha)
"movl %1, %%edi			\n\t"
"shrl $9, %%esi			\n\t"
"movw %%si, (%%edi, %%eax, 2)	\n\t"
"addw %4, %%cx			\n\t"
"adcl %3, %%ebx			\n\t"
"movzbl (%0, %%ebx), %%edi	\n\t"
"movzbl 1(%0, %%ebx), %%esi	\n\t"
"subl %%edi, %%esi		\n\t"  - src[xx]
"imull %%ecx, %%esi		\n\t"
"shll $16, %%edi		\n\t"
"addl %%edi, %%esi		\n\t" *2*xalpha + src[xx]*(1-2*xalpha)
"movl %1, %%edi			\n\t"
"shrl $9, %%esi			\n\t"
"movw %%si, 2(%%edi, %%eax, 2)	\n\t"
"addw %4, %%cx			\n\t"
"adcl %3, %%ebx			\n\t"
"addl $2, %%eax			\n\t"
"cmpl %2, %%eax			\n\t"
" jb 1b				\n\t"
:: "r" (src), "m" (dst), "m" (dstWidth), "m" (xInc>>16), "m" (xInc&0xFFFF)
: "%eax", "%ebx", "%ecx", "%edi", "%esi"
); #ifdef HAVE_MMX2
} #endif
#else
int VAR_0; unsigned int VAR_1=0; for(VAR_0=0;VAR_0<dstWidth;VAR_0++) { register unsigned int xx=VAR_1>>16; register unsigned int xalpha=(VAR_1&0xFFFF)>>9; dst[VAR_0]= (src[xx]<<7) + (src[xx+1] - src[xx])*xalpha; VAR_1+=xInc; } #endif
} }