; Fraunhofer MP3 decoder
;
; CPolyphase::window_band_s(int bufOffset,short *out_samples,int short_window)
; CPolyphase::window_band_m(int bufOffset,short *out_samples,int short_window)

pmmtext:		db "mm%i = [ %8x, %8x ] ", 10, 0
EXTERN debugger
EXTERN printf
%macro PRINT_MMX_REG 1
	pusha
	sub esp, 40
	mov eax, pmmtext
	mov [esp],eax
	mov [esp+4], dword %1
	movq [esp+8], mm%1
	call printf
	add esp, 40
	popa
%endmacro


;SECTION .data progbits alloc noexec write align=16
SECTION .data ;progbits alloc noexec write align=16

syn_f_window_int:
dw 0x0000, 0x0000, 0x0001, 0x0001 
dw 0x0007, 0x0007, 0x001a, 0x001a 
dw 0x0035, 0x0035, 0xffffffdb, 0xffffffdb 
dw 0x0072, 0x0072, 0x0187, 0x0187 
dw 0x01fd, 0x01fd, 0x000b, 0x000b 
dw 0x0508, 0x0508, 0x097f, 0x097f 
dw 0x066b, 0x066b, 0x09bd, 0x09bd 
dw 0x249c, 0x249c, 0x3e84, 0x3e84 
dw 0x4947, 0x4947, 0xffffc17b, 0xffffc17b 
dw 0xffffdb64, 0xffffdb64, 0xfffff642, 0xfffff642 
dw 0x066b, 0x066b, 0xfffff680, 0xfffff680 
dw 0xfffffaf8, 0xfffffaf8, 0xfffffff5, 0xfffffff5 
dw 0x01fd, 0x01fd, 0xfffffe78, 0xfffffe78 
dw 0xffffff8d, 0xffffff8d, 0x0024, 0x0024 
dw 0x0035, 0x0035, 0xffffffe6, 0xffffffe6 
dw 0xfffffff9, 0xfffffff9, 0xffffffff, 0xffffffff 
dw 0x0000, 0x0000, 0x0006, 0x0006 
dw 0x0007, 0x0007, 0x0034, 0x0034 
dw 0x0036, 0x0036, 0x0064, 0x0064 
dw 0x0081, 0x0081, 0x0203, 0x0203 
dw 0x01f4, 0x01f4, 0x04ad, 0x04ad 
dw 0x0563, 0x0563, 0x06f7, 0x06f7 
dw 0x05d1, 0x05d1, 0x22ce, 0x22ce 
dw 0x266a, 0x266a, 0x493c, 0x493c 
dw 0x493c, 0x493c, 0xffffd996, 0xffffd996 
dw 0xffffdd32, 0xffffdd32, 0x05d1, 0x05d1 
dw 0x06f7, 0x06f7, 0xfffffa9d, 0xfffffa9d 
dw 0xfffffb53, 0xfffffb53, 0x01f4, 0x01f4 
dw 0x0203, 0x0203, 0xffffff7e, 0xffffff7e 
dw 0xffffff9c, 0xffffff9c, 0x0036, 0x0036 
dw 0x0034, 0x0034, 0xfffffff8, 0xfffffff8 
dw 0xfffffff9, 0xfffffff9, 0x0000, 0x0000 
dw 0x0000, 0x0000, 0x0006, 0x0006 
dw 0x0008, 0x0008, 0x0032, 0x0032 
dw 0x0037, 0x0037, 0x0056, 0x0056 
dw 0x0091, 0x0091, 0x0208, 0x0208 
dw 0x01e8, 0x01e8, 0x0452, 0x0452 
dw 0x05bd, 0x05bd, 0x0776, 0x0776 
dw 0x052a, 0x052a, 0x20ff, 0x20ff 
dw 0x2836, 0x2836, 0x491a, 0x491a 
dw 0x491a, 0x491a, 0xffffd7ca, 0xffffd7ca 
dw 0xffffdf00, 0xffffdf00, 0x052a, 0x052a 
dw 0x0776, 0x0776, 0xfffffa42, 0xfffffa42 
dw 0xfffffbae, 0xfffffbae, 0x01e8, 0x01e8 
dw 0x0208, 0x0208, 0xffffff6f, 0xffffff6f 
dw 0xffffffa9, 0xffffffa9, 0x0037, 0x0037 
dw 0x0032, 0x0032, 0xfffffff7, 0xfffffff7 
dw 0xfffffffa, 0xfffffffa, 0x0000, 0x0000 
dw 0x0000, 0x0000, 0x0005, 0x0005 
dw 0x0009, 0x0009, 0x0031, 0x0031 
dw 0x0038, 0x0038, 0x0049, 0x0049 
dw 0x00a1, 0x00a1, 0x0209, 0x0209 
dw 0x01d9, 0x01d9, 0x03f7, 0x03f7 
dw 0x0617, 0x0617, 0x07e7, 0x07e7 
dw 0x0474, 0x0474, 0x1f32, 0x1f32 
dw 0x29ff, 0x29ff, 0x48e1, 0x48e1 
dw 0x48e1, 0x48e1, 0xffffd600, 0xffffd600 
dw 0xffffe0cd, 0xffffe0cd, 0x0474, 0x0474 
dw 0x07e7, 0x07e7, 0xfffff9e9, 0xfffff9e9 
dw 0xfffffc08, 0xfffffc08, 0x01d9, 0x01d9 
dw 0x0209, 0x0209, 0xffffff5f, 0xffffff5f 
dw 0xffffffb6, 0xffffffb6, 0x0038, 0x0038 
dw 0x0031, 0x0031, 0xfffffff6, 0xfffffff6 
dw 0xfffffffb, 0xfffffffb, 0x0000, 0x0000 
dw 0x0000, 0x0000, 0x0004, 0x0004 
dw 0x000a, 0x000a, 0x002f, 0x002f 
dw 0x0038, 0x0038, 0x003d, 0x003d 
dw 0x00b1, 0x00b1, 0x0209, 0x0209 
dw 0x01c7, 0x01c7, 0x039e, 0x039e 
dw 0x066f, 0x066f, 0x084b, 0x084b 
dw 0x03b0, 0x03b0, 0x1d68, 0x1d68 
dw 0x2bc5, 0x2bc5, 0x4892, 0x4892 
dw 0x4892, 0x4892, 0xffffd43b, 0xffffd43b 
dw 0xffffe298, 0xffffe298, 0x03b0, 0x03b0 
dw 0x084b, 0x084b, 0xfffff991, 0xfffff991 
dw 0xfffffc62, 0xfffffc62, 0x01c7, 0x01c7 
dw 0x0209, 0x0209, 0xffffff4e, 0xffffff4e 
dw 0xffffffc3, 0xffffffc3, 0x0038, 0x0038 
dw 0x002f, 0x002f, 0xfffffff6, 0xfffffff6 
dw 0xfffffffb, 0xfffffffb, 0x0000, 0x0000 
dw 0x0000, 0x0000, 0x0004, 0x0004 
dw 0x000b, 0x000b, 0x002d, 0x002d 
dw 0x0039, 0x0039, 0x0031, 0x0031 
dw 0x00c2, 0x00c2, 0x0206, 0x0206 
dw 0x01b2, 0x01b2, 0x0345, 0x0345 
dw 0x06c5, 0x06c5, 0x08a2, 0x08a2 
dw 0x02dd, 0x02dd, 0x1ba0, 0x1ba0 
dw 0x2d86, 0x2d86, 0x482d, 0x482d 
dw 0x482d, 0x482d, 0xffffd27a, 0xffffd27a 
dw 0xffffe460, 0xffffe460, 0x02dd, 0x02dd 
dw 0x08a2, 0x08a2, 0xfffff93a, 0xfffff93a 
dw 0xfffffcba, 0xfffffcba, 0x01b2, 0x01b2 
dw 0x0206, 0x0206, 0xffffff3d, 0xffffff3d 
dw 0xffffffcf, 0xffffffcf, 0x0039, 0x0039 
dw 0x002d, 0x002d, 0xfffffff5, 0xfffffff5 
dw 0xfffffffc, 0xfffffffc, 0x0000, 0x0000 
dw 0x0000, 0x0000, 0x0004, 0x0004 
dw 0x000c, 0x000c, 0x002c, 0x002c 
dw 0x0039, 0x0039, 0x0026, 0x0026 
dw 0x00d4, 0x00d4, 0x0202, 0x0202 
dw 0x019b, 0x019b, 0x02ef, 0x02ef 
dw 0x0719, 0x0719, 0x08ec, 0x08ec 
dw 0x01fd, 0x01fd, 0x19dc, 0x19dc 
dw 0x2f41, 0x2f41, 0x47b1, 0x47b1 
dw 0x47b1, 0x47b1, 0xffffd0be, 0xffffd0be 
dw 0xffffe623, 0xffffe623, 0x01fd, 0x01fd 
dw 0x08ec, 0x08ec, 0xfffff8e6, 0xfffff8e6 
dw 0xfffffd11, 0xfffffd11, 0x019b, 0x019b 
dw 0x0202, 0x0202, 0xffffff2c, 0xffffff2c 
dw 0xffffffda, 0xffffffda, 0x0039, 0x0039 
dw 0x002c, 0x002c, 0xfffffff4, 0xfffffff4 
dw 0xfffffffc, 0xfffffffc, 0x0000, 0x0000 
dw 0xffffffff, 0xffffffff, 0x0003, 0x0003 
dw 0x000d, 0x000d, 0x002a, 0x002a 
dw 0x0038, 0x0038, 0x001b, 0x001b 
dw 0x00e5, 0x00e5, 0x01fc, 0x01fc 
dw 0x017f, 0x017f, 0x0299, 0x0299 
dw 0x076b, 0x076b, 0x092b, 0x092b 
dw 0x010e, 0x010e, 0x181d, 0x181d 
dw 0x30f6, 0x30f6, 0x4720, 0x4720 
dw 0x4720, 0x4720, 0xffffcf0a, 0xffffcf0a 
dw 0xffffe7e2, 0xffffe7e2, 0x010e, 0x010e 
dw 0x092b, 0x092b, 0xfffff895, 0xfffff895 
dw 0xfffffd66, 0xfffffd66, 0x017f, 0x017f 
dw 0x01fc, 0x01fc, 0xffffff1a, 0xffffff1a 
dw 0xffffffe4, 0xffffffe4, 0x0038, 0x0038 
dw 0x002a, 0x002a, 0xfffffff3, 0xfffffff3 
dw 0xfffffffc, 0xfffffffc, 0xffffffff, 0xffffffff 
dw 0xffffffff, 0xffffffff, 0x0003, 0x0003 
dw 0x000e, 0x000e, 0x0028, 0x0028 
dw 0x0038, 0x0038, 0x0012, 0x0012 
dw 0x00f7, 0x00f7, 0x01f4, 0x01f4 
dw 0x0161, 0x0161, 0x0246, 0x0246 
dw 0x07b9, 0x07b9, 0x095e, 0x095e 
dw 0x0011, 0x0011, 0x1664, 0x1664 
dw 0x32a3, 0x32a3, 0x467a, 0x467a 
dw 0x467a, 0x467a, 0xffffcd5d, 0xffffcd5d 
dw 0xffffe99c, 0xffffe99c, 0x0011, 0x0011 
dw 0x095e, 0x095e, 0xfffff846, 0xfffff846 
dw 0xfffffdb9, 0xfffffdb9, 0x0161, 0x0161 
dw 0x01f4, 0x01f4, 0xffffff08, 0xffffff08 
dw 0xffffffee, 0xffffffee, 0x0038, 0x0038 
dw 0x0028, 0x0028, 0xfffffff1, 0xfffffff1 
dw 0xfffffffd, 0xfffffffd, 0xffffffff, 0xffffffff 
dw 0xffffffff, 0xffffffff, 0x0002, 0x0002 
dw 0x000f, 0x000f, 0x0026, 0x0026 
dw 0x0037, 0x0037, 0x0009, 0x0009 
dw 0x010a, 0x010a, 0x01ea, 0x01ea 
dw 0x0140, 0x0140, 0x01f5, 0x01f5 
dw 0x0804, 0x0804, 0x0985, 0x0985 
dw 0xffffff06, 0xffffff06, 0x14b1, 0x14b1 
dw 0x3447, 0x3447, 0x45bf, 0x45bf 
dw 0x45bf, 0x45bf, 0xffffcbb8, 0xffffcbb8 
dw 0xffffeb4f, 0xffffeb4f, 0xffffff06, 0xffffff06 
dw 0x0985, 0x0985, 0xfffff7fc, 0xfffff7fc 
dw 0xfffffe0a, 0xfffffe0a, 0x0140, 0x0140 
dw 0x01ea, 0x01ea, 0xfffffef6, 0xfffffef6 
dw 0xfffffff7, 0xfffffff7, 0x0037, 0x0037 
dw 0x0026, 0x0026, 0xfffffff0, 0xfffffff0 
dw 0xfffffffd, 0xfffffffd, 0xffffffff, 0xffffffff 
dw 0xffffffff, 0xffffffff, 0x0002, 0x0002 
dw 0x0011, 0x0011, 0x0024, 0x0024 
dw 0x0035, 0x0035, 0x0000, 0x0000 
dw 0x011c, 0x011c, 0x01df, 0x01df 
dw 0x011a, 0x011a, 0x01a7, 0x01a7 
dw 0x084a, 0x084a, 0x09a1, 0x09a1 
dw 0xfffffded, 0xfffffded, 0x1305, 0x1305 
dw 0x35e2, 0x35e2, 0x44ef, 0x44ef 
dw 0x44ef, 0x44ef, 0xffffca1d, 0xffffca1d 
dw 0xffffecfa, 0xffffecfa, 0xfffffded, 0xfffffded 
dw 0x09a1, 0x09a1, 0xfffff7b5, 0xfffff7b5 
dw 0xfffffe59, 0xfffffe59, 0x011a, 0x011a 
dw 0x01df, 0x01df, 0xfffffee4, 0xfffffee4 
dw 0xffffffff, 0xffffffff, 0x0035, 0x0035 
dw 0x0024, 0x0024, 0xffffffef, 0xffffffef 
dw 0xfffffffd, 0xfffffffd, 0xffffffff, 0xffffffff 
dw 0xffffffff, 0xffffffff, 0x0002, 0x0002 
dw 0x0012, 0x0012, 0x0022, 0x0022 
dw 0x0034, 0x0034, 0xfffffff9, 0xfffffff9 
dw 0x012e, 0x012e, 0x01d3, 0x01d3 
dw 0x00f2, 0x00f2, 0x015b, 0x015b 
dw 0x088c, 0x088c, 0x09b3, 0x09b3 
dw 0xfffffcc7, 0xfffffcc7, 0x1161, 0x1161 
dw 0x3772, 0x3772, 0x440b, 0x440b 
dw 0x440b, 0x440b, 0xffffc88d, 0xffffc88d 
dw 0xffffee9e, 0xffffee9e, 0xfffffcc7, 0xfffffcc7 
dw 0x09b3, 0x09b3, 0xfffff773, 0xfffff773 
dw 0xfffffea5, 0xfffffea5, 0x00f2, 0x00f2 
dw 0x01d3, 0x01d3, 0xfffffed1, 0xfffffed1 
dw 0x0007, 0x0007, 0x0034, 0x0034 
dw 0x0022, 0x0022, 0xffffffee, 0xffffffee 
dw 0xfffffffe, 0xfffffffe, 0xffffffff, 0xffffffff 
dw 0xffffffff, 0xffffffff, 0x0002, 0x0002 
dw 0x0013, 0x0013, 0x0021, 0x0021 
dw 0x0032, 0x0032, 0xfffffff2, 0xfffffff2 
dw 0x0140, 0x0140, 0x01c6, 0x01c6 
dw 0x00c6, 0x00c6, 0x0111, 0x0111 
dw 0x08c9, 0x08c9, 0x09bb, 0x09bb 
dw 0xfffffb93, 0xfffffb93, 0x0fc6, 0x0fc6 
dw 0x38f7, 0x38f7, 0x4315, 0x4315 
dw 0x4315, 0x4315, 0xffffc709, 0xffffc709 
dw 0xfffff039, 0xfffff039, 0xfffffb93, 0xfffffb93 
dw 0x09bb, 0x09bb, 0xfffff736, 0xfffff736 
dw 0xfffffeee, 0xfffffeee, 0x00c6, 0x00c6 
dw 0x01c6, 0x01c6, 0xfffffebf, 0xfffffebf 
dw 0x000e, 0x000e, 0x0032, 0x0032 
dw 0x0021, 0x0021, 0xffffffec, 0xffffffec 
dw 0xfffffffe, 0xfffffffe, 0xffffffff, 0xffffffff 
dw 0xffffffff, 0xffffffff, 0x0001, 0x0001 
dw 0x0015, 0x0015, 0x001f, 0x001f 
dw 0x002f, 0x002f, 0xffffffeb, 0xffffffeb 
dw 0x0153, 0x0153, 0x01b7, 0x01b7 
dw 0x0097, 0x0097, 0x00cb, 0x00cb 
dw 0x0900, 0x0900, 0x09b9, 0x09b9 
dw 0xfffffa51, 0xfffffa51, 0x0e35, 0x0e35 
dw 0x3a6f, 0x3a6f, 0x420b, 0x420b 
dw 0x420b, 0x420b, 0xffffc590, 0xffffc590 
dw 0xfffff1cb, 0xfffff1cb, 0xfffffa51, 0xfffffa51 
dw 0x09b9, 0x09b9, 0xfffff6ff, 0xfffff6ff 
dw 0xffffff34, 0xffffff34, 0x0097, 0x0097 
dw 0x01b7, 0x01b7, 0xfffffead, 0xfffffead 
dw 0x0014, 0x0014, 0x002f, 0x002f 
dw 0x001f, 0x001f, 0xffffffeb, 0xffffffeb 
dw 0xfffffffe, 0xfffffffe, 0xffffffff, 0xffffffff 
dw 0xffffffff, 0xffffffff, 0x0001, 0x0001 
dw 0x0016, 0x0016, 0x001d, 0x001d 
dw 0x002c, 0x002c, 0xffffffe5, 0xffffffe5 
dw 0x0165, 0x0165, 0x01a8, 0x01a8 
dw 0x0064, 0x0064, 0x0088, 0x0088 
dw 0x0932, 0x0932, 0x09af, 0x09af 
dw 0xfffff903, 0xfffff903, 0x0cad, 0x0cad 
dw 0x3bda, 0x3bda, 0x40ef, 0x40ef 
dw 0x40ef, 0x40ef, 0xffffc426, 0xffffc426 
dw 0xfffff353, 0xfffff353, 0xfffff903, 0xfffff903 
dw 0x09af, 0x09af, 0xfffff6ce, 0xfffff6ce 
dw 0xffffff78, 0xffffff78, 0x0064, 0x0064 
dw 0x01a8, 0x01a8, 0xfffffe9b, 0xfffffe9b 
dw 0x001a, 0x001a, 0x002c, 0x002c 
dw 0x001d, 0x001d, 0xffffffe9, 0xffffffe9 
dw 0xfffffffe, 0xfffffffe, 0xffffffff, 0xffffffff 
dw 0xffffffff, 0xffffffff, 0x0001, 0x0001 
dw 0x0018, 0x0018, 0x001b, 0x001b 
dw 0x0028, 0x0028, 0xffffffe0, 0xffffffe0 
dw 0x0176, 0x0176, 0x0198, 0x0198 
dw 0x002e, 0x002e, 0x0048, 0x0048 
dw 0x095c, 0x095c, 0x099b, 0x099b 
dw 0xfffff7a9, 0xfffff7a9, 0x0b2f, 0x0b2f 
dw 0x3d37, 0x3d37, 0x3fc2, 0x3fc2 
dw 0x3fc2, 0x3fc2, 0xffffc2c9, 0xffffc2c9 
dw 0xfffff4d0, 0xfffff4d0, 0xfffff7a9, 0xfffff7a9 
dw 0x099b, 0x099b, 0xfffff6a4, 0xfffff6a4 
dw 0xffffffb8, 0xffffffb8, 0x002e, 0x002e 
dw 0x0198, 0x0198, 0xfffffe89, 0xfffffe89 
dw 0x001f, 0x001f, 0x0028, 0x0028 
dw 0x001b, 0x001b, 0xffffffe8, 0xffffffe8 
dw 0xfffffffe, 0xfffffffe, 0xffffffff, 0xffffffff 

GLOBAL junk
junk:
	times 256 dd 0 

SECTION .text

;	CPolyphaseASM___window_band_s(
;		bufOffset,
;		short_window,
;		&CPolyphase::syn_buf[0][0],
;		CPolyphase::qual,
;		CPolyphase::resl,
;		out_samples
;	);

;void CPolyphaseInt__window_band_s_asm16( int bufOffset, int32 *syn_buf, int32 qual, int16 *out_samples );
;											4                8            12        	16

HAN_SIZE   equ 512

%define STK 16

GLOBAL CPolyphaseInt__window_band_s_asm16
ALIGN 16
CPolyphaseInt__window_band_s_asm16:

		push edi
		push esi
		push ebp
		push ebx

		mov ebx, [esp +4 +STK]		; bufPtr
		mov esi, [esp +8 +STK]		; syn_buf
		mov edx, [esp +16 +STK]		; out
		mov edi, syn_f_window_int

		pxor mm6, mm6				; sum 1
		pxor mm7, mm7				; sum 2
		pxor mm2, mm2
		
		mov ebp, 8
.loop
			movd mm1, [ edi ]						; winPtr[0]
			movq mm0, [ esi + ebx*4 + 32*4 ]		; syn_buf[bufPtr+32]
			psrad mm0, 13
			packssdw mm0, mm2						; syn_buf[bufPtr+32]
			pmulhw mm0, mm1
			paddsw mm6, mm0
	
			add ebx, 64
			and ebx, HAN_SIZE*2 -1
	
			movd mm1, [ edi + 8 ]					; winPtr[2]
			movq mm0, [ esi + ebx*4 + 32*4 ]		; syn_buf[bufPtr+32]
			psrad mm0, 13
			packssdw mm0, mm2						; syn_buf[bufPtr+32]
			pmulhw mm0, mm1
			paddsw mm6, mm0
	
			movd mm1, [ edi + 12 ]					; winPtr[3]
			movq mm0, [ esi + ebx*4 ]				; syn_buf[bufPtr+32]
			psrad mm0, 13
			packssdw mm0, mm2						; syn_buf[bufPtr+32]
			pmulhw mm0, mm1
			paddsw mm7, mm0
	
			add ebx, 64
			and ebx, HAN_SIZE*2 -1
	
			add edi, 16
			dec ebp
			jnz .loop
		
	;	psllw mm6, 2
	;	psllw mm7, 2
		paddsw mm6, mm6
		paddsw mm7, mm7
		paddsw mm6, mm6
		paddsw mm7, mm7

		movd [edx], mm6

		mov ecx, [esp +12 +STK]
		mov eax, 32
		shr eax, cl		
		movd [edx + eax*2], mm7
		

%if 0
pusha
push dword 0
call debugger
pop eax
popa
%endif
		
		mov ebp, 1								; j
.loop2:
			pxor mm6, mm6				; sum 1
			pxor mm7, mm7				; sum 2
	
			mov ebx, [esp +4 +STK]		; bufPtr
			mov eax, 2
			shl eax, cl
			imul eax, ebp
			add ebx, eax				; bufPtr
	
			mov eax, 32 *4
			shl eax, cl
			sub eax, 32 *4
			add edi, eax				; winPtr
			
			mov eax, 8
.loop3:
				movd mm1, [ edi ]						; winPtr[0]
movd [junk+eax*4 +12*4 *0], mm1
				movq mm0, [ esi + ebx*4 + 32*4 ]		; syn_buf[bufPtr+32]
movd [junk+eax*4 +12*4 *1], mm0
				psrad mm0, 13
movd [junk+eax*4 +12*4 *2], mm0
				packssdw mm0, mm2
movd [junk+eax*4 +12*4 *3], mm0
				pmulhw mm0, mm1
movd [junk+eax*4 +12*4 *4], mm0
				paddsw mm6, mm0
movd [junk+eax*4 +12*4 *5], mm6
		
				movd mm1, [ edi + 4 ]					; winPtr[1]
				movq mm0, [ esi + ebx*4 +32*4]			; syn_buf[bufPtr+32]
				psrad mm0, 13
				packssdw mm0, mm2
				pmulhw mm0, mm1
				paddsw mm7, mm0
		
				add ebx, 64
				and ebx, HAN_SIZE*2 -1
		
				movd mm1, [ edi + 8 ]					; winPtr[2]
movd [junk+eax*4 +12*4 *6], mm1
				movq mm0, [ esi + ebx*4 ]				; syn_buf[bufPtr]
movd [junk+eax*4 +12*4 *7], mm0
				psrad mm0, 13
movd [junk+eax*4 +12*4 *8], mm0
				packssdw mm0, mm2
movd [junk+eax*4 +12*4 *9], mm0
				pmulhw mm0, mm1
movd [junk+eax*4 +12*4 *10], mm0
				paddsw mm6, mm0
movd [junk+eax*4 +12*4 *11], mm6
		
				movd mm1, [ edi + 12 ]					; winPtr[3]
				movq mm0, [ esi + ebx*4 ]				; syn_buf[bufPtr]
				psrad mm0, 13
				packssdw mm0, mm2
				pmulhw mm0, mm1
				paddsw mm7, mm0
		
				add ebx, 64
				and ebx, HAN_SIZE*2 -1
		
				add edi, 16
				dec eax
				jnz near .loop3
	
	;		psllw mm6, 2
	;		psllw mm7, 2
			paddsw mm6, mm6
			paddsw mm7, mm7
			paddsw mm6, mm6
			paddsw mm7, mm7
	
			movd [edx + ebp*4], mm6
	
			mov eax, 32
			shr eax, cl
			sub eax, ebp
			movd [edx + eax*4], mm7
		
			inc ebp
			mov eax, 16
			shr eax, cl
			cmp eax, ebp
			jne near .loop2
		
		pop ebx
		pop ebp
		pop esi
		pop edi
		emms
		ret
		
		
		


