⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resample_mmx.c

📁 Trolltech公司发布的图形界面操作系统。可在qt-embedded-2.3.10平台上编译为嵌入式图形界面操作系统。
💻 C
📖 第 1 页 / 共 2 页
字号:
// MMX optimizations from Michael Niedermayer (michaelni@gmx.at) (under GPL)/* optimization TODO / NOTES     movntq is slightly faster (0.5% with the current test.c benchmark) 	(but thats just test.c so that needs to be testd in reallity)	and it would mean (C / MMX2 / MMX / 3DNOW) versions */static uint64_t __attribute__((aligned(8))) magicF2W= 0x43c0000043c00000LL;static uint64_t __attribute__((aligned(8))) wm1010= 0xFFFF0000FFFF0000LL;static uint64_t __attribute__((aligned(8))) wm0101= 0x0000FFFF0000FFFFLL;static uint64_t __attribute__((aligned(8))) wm1100= 0xFFFFFFFF00000000LL;static int a52_resample_MONO_to_5_MMX(float * _f, int16_t * s16){    int32_t * f = (int32_t *) _f;	asm volatile(		"movl $-512, %%esi		\n\t"		"movq "MANGLE(magicF2W)", %%mm7	\n\t"		"movq "MANGLE(wm1100)", %%mm3	\n\t"		"movq "MANGLE(wm0101)", %%mm4	\n\t"		"movq "MANGLE(wm1010)", %%mm5	\n\t"		"pxor %%mm6, %%mm6		\n\t"		"1:				\n\t"		"movq (%1, %%esi, 2), %%mm0	\n\t"		"movq 8(%1, %%esi, 2), %%mm1	\n\t"		"leal (%%esi, %%esi, 4), %%edi	\n\t"		"psubd %%mm7, %%mm0		\n\t"		"psubd %%mm7, %%mm1		\n\t"		"packssdw %%mm1, %%mm0		\n\t"		"movq %%mm0, %%mm1		\n\t"		"pand %%mm4, %%mm0		\n\t"		"pand %%mm5, %%mm1		\n\t"		"movq %%mm6, (%0, %%edi)	\n\t" // 0 0 0 0		"movd %%mm0, 8(%0, %%edi)	\n\t" // A 0		"pand %%mm3, %%mm0		\n\t"		"movd %%mm6, 12(%0, %%edi)	\n\t" // 0 0		"movd %%mm1, 16(%0, %%edi)	\n\t" // 0 B		"pand %%mm3, %%mm1		\n\t"		"movd %%mm6, 20(%0, %%edi)	\n\t" // 0 0		"movq %%mm0, 24(%0, %%edi)	\n\t" // 0 0 C 0		"movq %%mm1, 32(%0, %%edi)	\n\t" // 0 0 0 B		"addl $8, %%esi			\n\t"		" jnz 1b			\n\t"		"emms				\n\t"		:: "r" (s16+1280), "r" (f+256)		:"%esi", "%edi", "memory"	);    return 5*256;}static int a52_resample_STEREO_to_2_MMX(float * _f, int16_t * s16){    int32_t * f = (int32_t *) _f;/* benchmark scores are 0.3% better with SSE but we would need to set bias=0 and premultiply it#ifdef HAVE_SSE	asm volatile(		"movl $-1024, %%esi		\n\t"		"1:				\n\t"		"cvtps2pi (%1, %%esi), %%mm0	\n\t"		"cvtps2pi 1024(%1, %%esi), %%mm2\n\t"		"movq %%mm0, %%mm1		\n\t"		"punpcklwd %%mm2, %%mm0		\n\t"		"punpckhwd %%mm2, %%mm1		\n\t"		"movq %%mm0, (%0, %%esi)	\n\t"		"movq %%mm1, 8(%0, %%esi)	\n\t"		"addl $16, %%esi		\n\t"		" jnz 1b			\n\t"		"emms				\n\t"		:: "r" (s16+512), "r" (f+256)		:"%esi", "memory"	);*/	asm volatile(		"movl $-1024, %%esi		\n\t"		"movq "MANGLE(magicF2W)", %%mm7	\n\t"		"1:				\n\t"		"movq (%1, %%esi), %%mm0	\n\t"		"movq 8(%1, %%esi), %%mm1	\n\t"		"movq 1024(%1, %%esi), %%mm2	\n\t"		"movq 1032(%1, %%esi), %%mm3	\n\t"		"psubd %%mm7, %%mm0		\n\t"		"psubd %%mm7, %%mm1		\n\t"		"psubd %%mm7, %%mm2		\n\t"		"psubd %%mm7, %%mm3		\n\t"		"packssdw %%mm1, %%mm0		\n\t"		"packssdw %%mm3, %%mm2		\n\t"		"movq %%mm0, %%mm1		\n\t"		"punpcklwd %%mm2, %%mm0		\n\t"		"punpckhwd %%mm2, %%mm1		\n\t"		"movq %%mm0, (%0, %%esi)	\n\t"		"movq %%mm1, 8(%0, %%esi)	\n\t"		"addl $16, %%esi		\n\t"		" jnz 1b			\n\t"		"emms				\n\t"		:: "r" (s16+512), "r" (f+256)		:"%esi", "memory"	);    return 2*256;}static int a52_resample_3F_to_5_MMX(float * _f, int16_t * s16){    int32_t * f = (int32_t *) _f;	asm volatile(		"movl $-1024, %%esi		\n\t"		"movq "MANGLE(magicF2W)", %%mm7	\n\t"		"pxor %%mm6, %%mm6		\n\t"		"movq %%mm7, %%mm5		\n\t"		"punpckldq %%mm6, %%mm5		\n\t"		"1:				\n\t"		"movd (%1, %%esi), %%mm0	\n\t"		"punpckldq 2048(%1, %%esi), %%mm0\n\t"		"movd 1024(%1, %%esi), %%mm1	\n\t"		"punpckldq 4(%1, %%esi), %%mm1	\n\t"		"movd 2052(%1, %%esi), %%mm2	\n\t"		"movq %%mm7, %%mm3		\n\t"		"punpckldq 1028(%1, %%esi), %%mm3\n\t"		"movd 8(%1, %%esi), %%mm4	\n\t"		"punpckldq 2056(%1, %%esi), %%mm4\n\t"		"leal (%%esi, %%esi, 4), %%edi	\n\t"		"sarl $1, %%edi			\n\t"		"psubd %%mm7, %%mm0		\n\t"		"psubd %%mm7, %%mm1		\n\t"		"psubd %%mm5, %%mm2		\n\t"		"psubd %%mm7, %%mm3		\n\t"		"psubd %%mm7, %%mm4		\n\t"		"packssdw %%mm6, %%mm0		\n\t"		"packssdw %%mm2, %%mm1		\n\t"		"packssdw %%mm4, %%mm3		\n\t"		"movq %%mm0, (%0, %%edi)	\n\t"		"movq %%mm1, 8(%0, %%edi)	\n\t"		"movq %%mm3, 16(%0, %%edi)	\n\t"				"movd 1032(%1, %%esi), %%mm1	\n\t"		"punpckldq 12(%1, %%esi), %%mm1\n\t"		"movd 2060(%1, %%esi), %%mm2	\n\t"		"movq %%mm7, %%mm3		\n\t"		"punpckldq 1036(%1, %%esi), %%mm3\n\t"		"pxor %%mm0, %%mm0		\n\t"		"psubd %%mm7, %%mm1		\n\t"		"psubd %%mm5, %%mm2		\n\t"		"psubd %%mm7, %%mm3		\n\t"		"packssdw %%mm1, %%mm0		\n\t"		"packssdw %%mm3, %%mm2		\n\t"		"movq %%mm0, 24(%0, %%edi)	\n\t"		"movq %%mm2, 32(%0, %%edi)	\n\t"						"addl $16, %%esi		\n\t"		" jnz 1b			\n\t"		"emms				\n\t"		:: "r" (s16+1280), "r" (f+256)		:"%esi", "%edi", "memory"	);    return 5*256;}static int a52_resample_2F_2R_to_4_MMX(float * _f, int16_t * s16){    int32_t * f = (int32_t *) _f;	asm volatile(		"movl $-1024, %%esi		\n\t"		"movq "MANGLE(magicF2W)", %%mm7	\n\t"		"1:				\n\t"		"movq (%1, %%esi), %%mm0	\n\t"		"movq 8(%1, %%esi), %%mm1	\n\t"		"movq 1024(%1, %%esi), %%mm2	\n\t"		"movq 1032(%1, %%esi), %%mm3	\n\t"		"psubd %%mm7, %%mm0		\n\t"		"psubd %%mm7, %%mm1		\n\t"		"psubd %%mm7, %%mm2		\n\t"		"psubd %%mm7, %%mm3		\n\t"		"packssdw %%mm1, %%mm0		\n\t"		"packssdw %%mm3, %%mm2		\n\t"		"movq 2048(%1, %%esi), %%mm3	\n\t"		"movq 2056(%1, %%esi), %%mm4	\n\t"		"movq 3072(%1, %%esi), %%mm5	\n\t"		"movq 3080(%1, %%esi), %%mm6	\n\t"		"psubd %%mm7, %%mm3		\n\t"		"psubd %%mm7, %%mm4		\n\t"		"psubd %%mm7, %%mm5		\n\t"		"psubd %%mm7, %%mm6		\n\t"		"packssdw %%mm4, %%mm3		\n\t"		"packssdw %%mm6, %%mm5		\n\t"		"movq %%mm0, %%mm1		\n\t"		"movq %%mm3, %%mm4		\n\t"		"punpcklwd %%mm2, %%mm0		\n\t"		"punpckhwd %%mm2, %%mm1		\n\t"		"punpcklwd %%mm5, %%mm3		\n\t"		"punpckhwd %%mm5, %%mm4		\n\t"		"movq %%mm0, %%mm2		\n\t"		"movq %%mm1, %%mm5		\n\t"		"punpckldq %%mm3, %%mm0		\n\t"		"punpckhdq %%mm3, %%mm2		\n\t"		"punpckldq %%mm4, %%mm1		\n\t"		"punpckhdq %%mm4, %%mm5		\n\t"		"movq %%mm0, (%0, %%esi,2)	\n\t"		"movq %%mm2, 8(%0, %%esi,2)	\n\t"		"movq %%mm1, 16(%0, %%esi,2)	\n\t"		"movq %%mm5, 24(%0, %%esi,2)	\n\t"		"addl $16, %%esi		\n\t"		" jnz 1b			\n\t"		"emms				\n\t"		:: "r" (s16+1024), "r" (f+256)		:"%esi", "memory"	);    return 4*256;}static int a52_resample_3F_2R_to_5_MMX(float * _f, int16_t * s16){    int32_t * f = (int32_t *) _f;	asm volatile(		"movl $-1024, %%esi		\n\t"		"movq "MANGLE(magicF2W)", %%mm7	\n\t"		"1:				\n\t"		"movd (%1, %%esi), %%mm0	\n\t"		"punpckldq 2048(%1, %%esi), %%mm0\n\t"		"movd 3072(%1, %%esi), %%mm1	\n\t"		"punpckldq 4096(%1, %%esi), %%mm1\n\t"		"movd 1024(%1, %%esi), %%mm2	\n\t"		"punpckldq 4(%1, %%esi), %%mm2	\n\t"		"movd 2052(%1, %%esi), %%mm3	\n\t"		"punpckldq 3076(%1, %%esi), %%mm3\n\t"		"movd 4100(%1, %%esi), %%mm4	\n\t"		"punpckldq 1028(%1, %%esi), %%mm4\n\t"		"movd 8(%1, %%esi), %%mm5	\n\t"		"punpckldq 2056(%1, %%esi), %%mm5\n\t"		"leal (%%esi, %%esi, 4), %%edi	\n\t"		"sarl $1, %%edi			\n\t"		"psubd %%mm7, %%mm0		\n\t"		"psubd %%mm7, %%mm1		\n\t"		"psubd %%mm7, %%mm2		\n\t"		"psubd %%mm7, %%mm3		\n\t"		"psubd %%mm7, %%mm4		\n\t"		"psubd %%mm7, %%mm5		\n\t"		"packssdw %%mm1, %%mm0		\n\t"		"packssdw %%mm3, %%mm2		\n\t"		"packssdw %%mm5, %%mm4		\n\t"		"movq %%mm0, (%0, %%edi)	\n\t"		"movq %%mm2, 8(%0, %%edi)	\n\t"		"movq %%mm4, 16(%0, %%edi)	\n\t"				"movd 3080(%1, %%esi), %%mm0	\n\t"		"punpckldq 4104(%1, %%esi), %%mm0\n\t"		"movd 1032(%1, %%esi), %%mm1	\n\t"		"punpckldq 12(%1, %%esi), %%mm1\n\t"		"movd 2060(%1, %%esi), %%mm2	\n\t"		"punpckldq 3084(%1, %%esi), %%mm2\n\t"		"movd 4108(%1, %%esi), %%mm3	\n\t"		"punpckldq 1036(%1, %%esi), %%mm3\n\t"		"psubd %%mm7, %%mm0		\n\t"		"psubd %%mm7, %%mm1		\n\t"		"psubd %%mm7, %%mm2		\n\t"		"psubd %%mm7, %%mm3		\n\t"		"packssdw %%mm1, %%mm0		\n\t"		"packssdw %%mm3, %%mm2		\n\t"		"movq %%mm0, 24(%0, %%edi)	\n\t"		"movq %%mm2, 32(%0, %%edi)	\n\t"						"addl $16, %%esi		\n\t"		" jnz 1b			\n\t"		"emms				\n\t"		:: "r" (s16+1280), "r" (f+256)		:"%esi", "%edi", "memory"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -