1 2; for new GOGO-no-coda (1999/09) 3; Copyright (C) 1999 shigeo 4; special thanks to Keiichi SAKAI, URURI 5%include "nasm.h" 6 7 globaldef fht_3DN 8 globaldef fht 9 externdef costab_fft 10 externdef sintab_fft 11 externdef gray_index 12 13 segment_data 14 align 16 15D_MSB1_0 dd 0 ,0x80000000 16D_SQRT2 dd 1.414213562,1.414213562 17t_s0 dd 0 ;[ t_c:t_s] 18t_c0 dd 0 19t_c1 dd 0 ;[-t_s:t_c] 20t_s1 dd 0 21D_s1c1 dd 0, 0 22D_Mc1s1 dd 0, 0 23D_s2c2 dd 0, 0 24D_Mc2s2 dd 0, 0 25D_0_1 dd 1.0, 0.0 26S_05 DD 0.5 27S_00005 DD 0.0005 28fht dd 0 ;�ؿ��ݥ��� 29 30 segment_code 31 32;************************************************************************ 33 34; by shigeo 35; 99/08/16 36; 23000clk �ɤ��ä��� 37; 18500clk bit reversal from gogo1 by URURI 38 39;void fht(float *fz, int n); 40 align 16 41fht_3DN: 42 push ebx 43 push esi 44 push edi 45 push ebp 46%assign _P 4*4 47 ;�ޤ��ǽ�Υ롼��... ��fht()�γ��ذ�ư 48 49 mov esi,[esp+_P+4] ;esi=fz 50 mov ecx,[esp+_P+8] ;ecx=n 51 52 ;�ᥤ��롼�� 53 movq mm7,[D_MSB1_0] ;mm7=[1<<31:0] 54 55%assign LOCAL_STACK 16 56 sub esp,LOCAL_STACK 57%assign _P (_P+LOCAL_STACK) 58 xor eax,eax 59 mov [esp],eax ;k=0 60%define k dword [esp] 61%define kx dword [esp+4] 62%define fn dword [esp+8] 63 64.lp30: ;k=0; do{ 65 mov ecx,k 66 add ecx,2 67 mov k,ecx 68 mov eax,1 69 shl eax,cl ;eax=k1 = 1<<k 70 lea ebx,[eax+eax] ;ebx=k2 = k1*2 71 lea ecx,[eax+eax*2] ;ecx=k3 = k2 + k1 = k1*3 72 lea edx,[ebx+ebx] ;edx=k4 = k1*4 73 mov esi,eax 74 shr esi,1 ;esi=kx=k1>>1 75 mov kx,esi ;��¸(��ǻȤ�) 76 mov edi,[esp+_P+4] ;edi=fi=fz 77 lea ebp,[edi+esi*4] ;ebp=gi=fz+kx 78 mov esi,[esp+_P+8] ;esi=n 79 lea esi,[edi+esi*4] ;esi=fn=fz+n 80 movq mm6,[D_SQRT2] ;mm6=[��2:��2] 81 82.lp31: ;fn=fz+n; do{ FLOAT g0,f0,f1,... 83 movd mm0,[edi] ;mm0=[0:fi[ 0]] 84 movd mm1,[edi+eax*4] ;mm1=[0:fi[k1]] 85 punpckldq mm0,mm0 ;mm0=[fi_0 :fi_0 ] 86 punpckldq mm1,mm1 ;mm1=[fi_k1:fi_k1] 87 movd mm2,[edi+ebx*4] 88 movd mm3,[edi+ecx*4] 89 punpckldq mm2,mm2 ;mm2=[fi_k2:fi_k2] 90 punpckldq mm3,mm3 ;mm3=[fi_k3:fi_k3] 91 pxor mm1,mm7 ;mm1=[-fi_k1:fi_k1] 92 pxor mm3,mm7 ;mm3=[-fi_k3:fi_k3] 93 pfadd mm0,mm1 ;mm0=[f1:f0]=[fi_0 -fi_k1 : fi_0 +fi_k1] 94 pfadd mm2,mm3 ;mm2=[f3:f2]=[fi_k2-fi_k3 : fi_k2+fi_k3] 95 movq mm3,mm0 ;mm3=[f1:f0] 96 pfadd mm0,mm2 ;mm0=[f1+f3:f0+f2] 97 movd [edi],mm0 ;fi[0]=f0+f2 98 psrlq mm0,32 ;mm0=[0:f1+f3] 99 pfsub mm3,mm2 ;mm3=[f1-f3:f0-f2] 100 movd [edi+eax*4],mm0 ;fi[k1]=f1+f3 101 movd [edi+ebx*4],mm3 ;fi[k2]=f0-f2 102 psrlq mm3,32 ;mm3=[0:f1-f3] 103 movd [edi+ecx*4],mm3 ;fi[k3]=f1-f3 104 105 movd mm0,[ebp] ;mm0=[0:gi_0] 106 movd mm1,[ebp+eax*4] ;mm1=[0:gi_k1] 107 punpckldq mm0,mm0 ;mm0=[gi_0 :gi_0 ] 108 punpckldq mm1,mm1 ;mm1=[gi_k1:gi_k1] 109 movd mm2,[ebp+ebx*4] ;mm2=[0:gi_k2] 110 pxor mm1,mm7 ;mm1=[-gi_k1:gi_k1] 111 punpckldq mm2,[ebp+ecx*4] ;mm2=[gi_k3:gi_k2] 112 pfadd mm0,mm1 ;mm0=[g1:g0]=[gi_0 -gi_k1:gi_0 +gi_k1] 113 pfmul mm2,mm6 ;mm2=[g3:g2]=sqrt2 * [gi_k3:gi_k2] 114 movq mm1,mm0 ;mm1=[g1:g0] 115 pfadd mm0,mm2 ;mm0=[g1+g3:g0+g2] 116 movd [ebp],mm0 ;gi[0]=g0+g2 117 psrlq mm0,32 ;mm0=[0:g1+g3] 118 pfsub mm1,mm2 ;mm1=[g1-g3:g0-g2] 119 movd [ebp+eax*4],mm0 ;gi[k1]=g1+g3 120 movd [ebp+ebx*4],mm1 ;gi[k2]=g0-g2 121 psrlq mm1,32 ;mm1=[0:g1-g3] 122 movd [ebp+ecx*4],mm1 ;gi[k3]=g1-g3 123 lea edi,[edi+edx*4] ;fi += k4 124 lea ebp,[ebp+edx*4] ;gi += k4 125 cmp edi,esi 126 jc near .lp31 ;}while(fi<fn); 127 128; �����ޤǤ�¿ʬO.K. 129 130 mov fn,esi ;fn=fz+n 131 ;�����ͤϰ���³���Ȥ� 132 ;eax=k1,ebx=k2,ecx=k3,edx=k4 133 134 mov edi,k 135 lea ebp,[costab_fft+edi*4] 136 mov ebp,[ebp] ;ebp=t_c 137 mov [t_c0],ebp 138 mov [t_c1],ebp ;t_c 139 lea ebp,[sintab_fft+edi*4] 140 mov ebp,[ebp] ;ebx=t_s 141 mov [t_s0],ebp 142 xor ebp,0x80000000 143 mov [t_s1],ebp ;-t_s 144 145 movq mm1,[D_0_1] ;mm1=[0:1] 146 movq [D_s1c1],mm1 ;mm1=[s1:c1] 147 mov esi,1 ;esi=i=1 148 149.lp32: ; for(i=1;i<kx;i++){ 150 movq mm0,[D_s1c1] ;mm1=[s1:t]=[s1:c1] 151 movq mm2,mm0 152 pfmul mm0,[t_c1] ;mm0=[-s1*t_s: t*t_c] 153 pfmul mm2,[t_s0] ;mm2=[ s1*t_c: t*t_s] 154 pfacc mm0,mm2 ;mm0=[s1:c1]=[ s1*t_c+t*t_s:-s1*t_s+t*t_c] 155 movq mm2,mm0 ;mm2=[s1:c1] 156 movq [D_s1c1],mm0 ;��¸ 157 movq mm6,mm2 158 punpckldq mm5,mm6 159 punpckhdq mm6,mm5 ;mm6=[ c1:s1] 160 pxor mm6,mm7 ;mm6=[-c1:s1] 161 movq [D_Mc1s1],mm6 ;��¸ 162 pfmul mm2,mm2 ;mm2=[s1*s1:c1*c1] 163 movq mm3,mm0 ;mm3=[s1:c1] 164 pxor mm2,mm7 ;mm2=[-s1*s1:c1*c1] 165 psrlq mm3,32 ;mm3=[ 0:s1] 166 pfacc mm2,mm2 ;mm2=[c2:c2]=[c1*c1-s1*s1:<] 167 pfmul mm0,mm3 ;mm0=[ 0:c1*s1] 168 pfadd mm0,mm0 ;mm0=[0:s2]=[ 0:2*c1*s1] 169 punpckldq mm2,mm0 ;mm2=[s2:c2] 170 movq [D_s2c2],mm2 ;��¸ 171 172 punpckldq mm0,mm2 173 punpckhdq mm2,mm0 ;mm2=[c2:s2] 174 pxor mm2,mm7 ;mm2=[-c2:s2] 175 movq [D_Mc2s2],mm2 ;��¸ 176 177 mov edi,[esp+_P+4] ;edi=fz 178 lea edi,[edi+esi*4] ;edi=fz+i 179 180 mov ebp,[esp+_P+4] ;ebp=fz 181 neg esi ;esi=-i 182 lea ebp,[ebp+eax*4] ;ebp=fz+k1 183 lea ebp,[ebp+esi*4] ;ebp=gi=fz+k1-i 184 neg esi ;esi=i 185 186.lp33: ; do{ FLOAT a,b,g0,f0,f1,g1,f2,g2,f3,g3; 187 188 movd mm0,[edi+eax*4] ;mm0=[0:fi_k1] 189 punpckldq mm0,[ebp+eax*4] ;mm0=[gi_k1:fi_k1] 190 movq mm1,mm0 191 pfmul mm0,[D_s2c2] ;mm0=[ s2*gi_k1:c2*fi_k1] 192 pfmul mm1,[D_Mc2s2] ;mm1=[-c2*gi_k1:s2*fi_k1] 193 pfacc mm0,mm1 ;mm0=[b:a] 194 movd mm4,[edi] ;mm4=[0:fi_0] 195 movq mm3,mm0 ;mm3=[b:a] 196 punpckldq mm4,[ebp] ;mm4=[gi_0:fi_0] 197 pfadd mm3,mm4 ;mm3=[g0:f0]=[gi_0+b:fi_0+a] 198 pfsub mm4,mm0 ;mm4=[g1:f1]=[gi_0-b:fi_0-a] 199 200 movd mm0,[edi+ecx*4] ;mm0=[0:fi_k3] 201 punpckldq mm0,[ebp+ecx*4] ;mm0=[gi_k3:fi_k3] 202 movq mm1,mm0 203 pfmul mm0,[D_s2c2] ;mm0=[ s2*gi_k3:c2*fi_k3] 204 pfmul mm1,[D_Mc2s2] ;mm1=[-c2*gi_k3:s2*fi_k3] 205 pfacc mm0,mm1 ;mm0=[b:a] 206 movd mm5,[edi+ebx*4] ;mm5=[0:fi_k2] 207 movq mm6,mm0 ;mm6=[b:a] 208 punpckldq mm5,[ebp+ebx*4] ;mm5=[gi_k2:fi_k2] 209 pfadd mm6,mm5 ;mm6=[g2:f2]=[gi_k2+b:fi_k2+a] 210 pfsub mm5,mm0 ;mm5=[g3:f3]=[gi_k2-b:fi_k2-a] 211 212 punpckldq mm1,mm6 ;mm1=[f2:*] 213 movq mm0,[D_s1c1] ;mm0=[s1:c1] 214 punpckhdq mm1,mm5 ;mm1=[g3:f2] 215 pfmul mm0,mm1 ;mm0=[ s1*g3:c1*f2] 216 movq mm2,[D_Mc1s1] ;mm2=[-c1:s1] 217 pfmul mm2,mm1 ;mm2=[-c1*g3:s1*f2] 218 pfacc mm0,mm2 ;mm0=[b:a] 219 220 punpckldq mm1,mm3 ;mm1=[f0:*] 221 punpckhdq mm1,mm4 ;mm1=[g1:f0] 222 movq mm2,mm0 ;mm2=[b:a] 223 pfadd mm0,mm1 ;mm0=[g1+b:f0+a] 224 pfsubr mm2,mm1 ;mm2=[g1-b:f0-a] 225 movd [edi],mm0 ;fi[0]=f0+a 226 psrlq mm0,32 ;mm0=[0:g1+b] 227 movd [edi+ebx*4],mm2 ;fi[k2]=f0-a 228 psrlq mm2,32 ;mm2=[0:g1-b] 229 movd [ebp+eax*4],mm0 ;gi[k1]=g1+b 230 movd [ebp+ecx*4],mm2 ;gi[k3]=g1-b 231 psrlq mm6,32 ;mm6=[0:g2] 232 movq mm0,[D_s1c1] ;mm0=[s1:c1] 233 punpckldq mm5,mm6 ;mm5=[g2:f3] 234 pfmul mm0,mm5 ;mm0=[g2* s1:f3*c1] 235 pfmul mm5,[D_Mc1s1] ;mm5=[g2*-c1:f3*s1] 236 pfacc mm0,mm5 ;mm0=[-b:a] 237 psrlq mm3,32 ;mm3=[0:g0] 238 movq mm1,mm0 ;mm1=[-b:a] 239 punpckldq mm3,mm4 ;mm3=[f1:g0] 240 pfadd mm0,mm3 ;mm0=[f1-b:g0+a] 241 pfsubr mm1,mm3 ;mm1=[f1+b:g0-a] 242 movd [ebp],mm0 ;gi[0]=g0+a 243 psrlq mm0,32 ;mm0=[0:f1-b] 244 movd [ebp+ebx*4],mm1 ;gi[k2]=g0-a 245 psrlq mm1,32 ;mm1=[0:f1+b] 246 movd [edi+ecx*4],mm0 ;fi[k3]=f1-b 247 movd [edi+eax*4],mm1 ;fi[k1]=f1+b 248 249 lea edi,[edi+edx*4] ;fi += k4 250 lea ebp,[ebp+edx*4] ;gi += k4 251 cmp edi,fn 252 jc near .lp33 ;}while(fi<fn) 253 inc esi 254 cmp esi,kx 255 jnz near .lp32 ;} 256 cmp edx,[esp+_P+8] 257 jnz near .lp30 ;}while(k4<n) 258 259 260.exit: 261 add esp,LOCAL_STACK 262 femms 263 pop ebp 264 pop edi 265 pop esi 266 pop ebx 267 ret 268