Mercurial > mplayer.hg
comparison libfaad2/filtbank.c @ 13453:6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
patch by adland <adland123 at yahoo dot com>
author | diego |
---|---|
date | Fri, 24 Sep 2004 17:31:36 +0000 |
parents | d81145997036 |
children | 2ae5ab4331ca |
comparison
equal
deleted
inserted
replaced
13452:c364b7c13dd8 | 13453:6d50ef45a058 |
---|---|
21 ** | 21 ** |
22 ** Commercial non-GPL licensing of this software is possible. | 22 ** Commercial non-GPL licensing of this software is possible. |
23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
24 ** | 24 ** |
25 ** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30 | 25 ** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30 |
26 ** $Id: filtbank.c,v 1.3 2004/06/02 22:59:02 diego Exp $ | 26 ** $Id: filtbank.c,v 1.4 2004/06/23 13:50:49 diego Exp $ |
27 ** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/ | 27 ** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/ |
28 **/ | 28 **/ |
29 | 29 |
30 #include "common.h" | 30 #include "common.h" |
31 #include "structs.h" | 31 #include "structs.h" |
215 | 215 |
216 #ifdef PROFILE | 216 #ifdef PROFILE |
217 int64_t count = faad_get_ts(); | 217 int64_t count = faad_get_ts(); |
218 #endif | 218 #endif |
219 | 219 |
220 /* select windows of current frame and previous frame (Sine or KBD) */ | |
220 #ifdef LD_DEC | 221 #ifdef LD_DEC |
221 if (object_type == LD) | 222 if (object_type == LD) |
222 { | 223 { |
223 window_long = fb->ld_window[window_shape]; | 224 window_long = fb->ld_window[window_shape]; |
224 window_long_prev = fb->ld_window[window_shape_prev]; | 225 window_long_prev = fb->ld_window[window_shape_prev]; |
230 window_short_prev = fb->short_window[window_shape_prev]; | 231 window_short_prev = fb->short_window[window_shape_prev]; |
231 #ifdef LD_DEC | 232 #ifdef LD_DEC |
232 } | 233 } |
233 #endif | 234 #endif |
234 | 235 |
236 #if 0 | |
237 for (i = 0; i < 1024; i++) | |
238 { | |
239 printf("%d\n", freq_in[i]); | |
240 } | |
241 #endif | |
242 | |
243 #if 0 | |
244 printf("%d %d\n", window_sequence, window_shape); | |
245 #endif | |
235 | 246 |
236 switch (window_sequence) | 247 switch (window_sequence) |
237 { | 248 { |
238 case ONLY_LONG_SEQUENCE: | 249 case ONLY_LONG_SEQUENCE: |
250 /* perform iMDCT */ | |
239 imdct_long(fb, freq_in, transf_buf, 2*nlong); | 251 imdct_long(fb, freq_in, transf_buf, 2*nlong); |
252 | |
253 /* add second half output of previous frame to windowed output of current frame */ | |
240 for (i = 0; i < nlong; i+=4) | 254 for (i = 0; i < nlong; i+=4) |
241 { | 255 { |
242 time_out[i] = overlap[i] + MUL_F(transf_buf[i],window_long_prev[i]); | 256 time_out[i] = overlap[i] + MUL_F(transf_buf[i],window_long_prev[i]); |
243 time_out[i+1] = overlap[i+1] + MUL_F(transf_buf[i+1],window_long_prev[i+1]); | 257 time_out[i+1] = overlap[i+1] + MUL_F(transf_buf[i+1],window_long_prev[i+1]); |
244 time_out[i+2] = overlap[i+2] + MUL_F(transf_buf[i+2],window_long_prev[i+2]); | 258 time_out[i+2] = overlap[i+2] + MUL_F(transf_buf[i+2],window_long_prev[i+2]); |
245 time_out[i+3] = overlap[i+3] + MUL_F(transf_buf[i+3],window_long_prev[i+3]); | 259 time_out[i+3] = overlap[i+3] + MUL_F(transf_buf[i+3],window_long_prev[i+3]); |
246 } | 260 } |
261 | |
262 /* window the second half and save as overlap for next frame */ | |
247 for (i = 0; i < nlong; i+=4) | 263 for (i = 0; i < nlong; i+=4) |
248 { | 264 { |
249 overlap[i] = MUL_F(transf_buf[nlong+i],window_long[nlong-1-i]); | 265 overlap[i] = MUL_F(transf_buf[nlong+i],window_long[nlong-1-i]); |
250 overlap[i+1] = MUL_F(transf_buf[nlong+i+1],window_long[nlong-2-i]); | 266 overlap[i+1] = MUL_F(transf_buf[nlong+i+1],window_long[nlong-2-i]); |
251 overlap[i+2] = MUL_F(transf_buf[nlong+i+2],window_long[nlong-3-i]); | 267 overlap[i+2] = MUL_F(transf_buf[nlong+i+2],window_long[nlong-3-i]); |
252 overlap[i+3] = MUL_F(transf_buf[nlong+i+3],window_long[nlong-4-i]); | 268 overlap[i+3] = MUL_F(transf_buf[nlong+i+3],window_long[nlong-4-i]); |
253 } | 269 } |
254 break; | 270 break; |
255 | 271 |
256 case LONG_START_SEQUENCE: | 272 case LONG_START_SEQUENCE: |
273 /* perform iMDCT */ | |
257 imdct_long(fb, freq_in, transf_buf, 2*nlong); | 274 imdct_long(fb, freq_in, transf_buf, 2*nlong); |
275 | |
276 /* add second half output of previous frame to windowed output of current frame */ | |
258 for (i = 0; i < nlong; i+=4) | 277 for (i = 0; i < nlong; i+=4) |
259 { | 278 { |
260 time_out[i] = overlap[i] + MUL_F(transf_buf[i],window_long_prev[i]); | 279 time_out[i] = overlap[i] + MUL_F(transf_buf[i],window_long_prev[i]); |
261 time_out[i+1] = overlap[i+1] + MUL_F(transf_buf[i+1],window_long_prev[i+1]); | 280 time_out[i+1] = overlap[i+1] + MUL_F(transf_buf[i+1],window_long_prev[i+1]); |
262 time_out[i+2] = overlap[i+2] + MUL_F(transf_buf[i+2],window_long_prev[i+2]); | 281 time_out[i+2] = overlap[i+2] + MUL_F(transf_buf[i+2],window_long_prev[i+2]); |
263 time_out[i+3] = overlap[i+3] + MUL_F(transf_buf[i+3],window_long_prev[i+3]); | 282 time_out[i+3] = overlap[i+3] + MUL_F(transf_buf[i+3],window_long_prev[i+3]); |
264 } | 283 } |
284 | |
285 /* window the second half and save as overlap for next frame */ | |
286 /* construct second half window using padding with 1's and 0's */ | |
265 for (i = 0; i < nflat_ls; i++) | 287 for (i = 0; i < nflat_ls; i++) |
266 overlap[i] = transf_buf[nlong+i]; | 288 overlap[i] = transf_buf[nlong+i]; |
267 for (i = 0; i < nshort; i++) | 289 for (i = 0; i < nshort; i++) |
268 overlap[nflat_ls+i] = MUL_F(transf_buf[nlong+nflat_ls+i],window_short[nshort-i-1]); | 290 overlap[nflat_ls+i] = MUL_F(transf_buf[nlong+nflat_ls+i],window_short[nshort-i-1]); |
269 for (i = 0; i < nflat_ls; i++) | 291 for (i = 0; i < nflat_ls; i++) |
270 overlap[nflat_ls+nshort+i] = 0; | 292 overlap[nflat_ls+nshort+i] = 0; |
271 break; | 293 break; |
272 | 294 |
273 case EIGHT_SHORT_SEQUENCE: | 295 case EIGHT_SHORT_SEQUENCE: |
296 /* perform iMDCT for each short block */ | |
274 faad_imdct(fb->mdct256, freq_in+0*nshort, transf_buf+2*nshort*0); | 297 faad_imdct(fb->mdct256, freq_in+0*nshort, transf_buf+2*nshort*0); |
275 faad_imdct(fb->mdct256, freq_in+1*nshort, transf_buf+2*nshort*1); | 298 faad_imdct(fb->mdct256, freq_in+1*nshort, transf_buf+2*nshort*1); |
276 faad_imdct(fb->mdct256, freq_in+2*nshort, transf_buf+2*nshort*2); | 299 faad_imdct(fb->mdct256, freq_in+2*nshort, transf_buf+2*nshort*2); |
277 faad_imdct(fb->mdct256, freq_in+3*nshort, transf_buf+2*nshort*3); | 300 faad_imdct(fb->mdct256, freq_in+3*nshort, transf_buf+2*nshort*3); |
278 faad_imdct(fb->mdct256, freq_in+4*nshort, transf_buf+2*nshort*4); | 301 faad_imdct(fb->mdct256, freq_in+4*nshort, transf_buf+2*nshort*4); |
279 faad_imdct(fb->mdct256, freq_in+5*nshort, transf_buf+2*nshort*5); | 302 faad_imdct(fb->mdct256, freq_in+5*nshort, transf_buf+2*nshort*5); |
280 faad_imdct(fb->mdct256, freq_in+6*nshort, transf_buf+2*nshort*6); | 303 faad_imdct(fb->mdct256, freq_in+6*nshort, transf_buf+2*nshort*6); |
281 faad_imdct(fb->mdct256, freq_in+7*nshort, transf_buf+2*nshort*7); | 304 faad_imdct(fb->mdct256, freq_in+7*nshort, transf_buf+2*nshort*7); |
305 | |
306 /* add second half output of previous frame to windowed output of current frame */ | |
282 for (i = 0; i < nflat_ls; i++) | 307 for (i = 0; i < nflat_ls; i++) |
283 time_out[i] = overlap[i]; | 308 time_out[i] = overlap[i]; |
284 for(i = 0; i < nshort; i++) | 309 for(i = 0; i < nshort; i++) |
285 { | 310 { |
286 time_out[nflat_ls+ i] = overlap[nflat_ls+ i] + MUL_F(transf_buf[nshort*0+i],window_short_prev[i]); | 311 time_out[nflat_ls+ i] = overlap[nflat_ls+ i] + MUL_F(transf_buf[nshort*0+i],window_short_prev[i]); |
288 time_out[nflat_ls+2*nshort+i] = overlap[nflat_ls+nshort*2+i] + MUL_F(transf_buf[nshort*3+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*4+i],window_short[i]); | 313 time_out[nflat_ls+2*nshort+i] = overlap[nflat_ls+nshort*2+i] + MUL_F(transf_buf[nshort*3+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*4+i],window_short[i]); |
289 time_out[nflat_ls+3*nshort+i] = overlap[nflat_ls+nshort*3+i] + MUL_F(transf_buf[nshort*5+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*6+i],window_short[i]); | 314 time_out[nflat_ls+3*nshort+i] = overlap[nflat_ls+nshort*3+i] + MUL_F(transf_buf[nshort*5+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*6+i],window_short[i]); |
290 if (i < trans) | 315 if (i < trans) |
291 time_out[nflat_ls+4*nshort+i] = overlap[nflat_ls+nshort*4+i] + MUL_F(transf_buf[nshort*7+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*8+i],window_short[i]); | 316 time_out[nflat_ls+4*nshort+i] = overlap[nflat_ls+nshort*4+i] + MUL_F(transf_buf[nshort*7+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*8+i],window_short[i]); |
292 } | 317 } |
318 | |
319 /* window the second half and save as overlap for next frame */ | |
293 for(i = 0; i < nshort; i++) | 320 for(i = 0; i < nshort; i++) |
294 { | 321 { |
295 if (i >= trans) | 322 if (i >= trans) |
296 overlap[nflat_ls+4*nshort+i-nlong] = MUL_F(transf_buf[nshort*7+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*8+i],window_short[i]); | 323 overlap[nflat_ls+4*nshort+i-nlong] = MUL_F(transf_buf[nshort*7+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*8+i],window_short[i]); |
297 overlap[nflat_ls+5*nshort+i-nlong] = MUL_F(transf_buf[nshort*9+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*10+i],window_short[i]); | 324 overlap[nflat_ls+5*nshort+i-nlong] = MUL_F(transf_buf[nshort*9+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*10+i],window_short[i]); |
302 for (i = 0; i < nflat_ls; i++) | 329 for (i = 0; i < nflat_ls; i++) |
303 overlap[nflat_ls+nshort+i] = 0; | 330 overlap[nflat_ls+nshort+i] = 0; |
304 break; | 331 break; |
305 | 332 |
306 case LONG_STOP_SEQUENCE: | 333 case LONG_STOP_SEQUENCE: |
334 /* perform iMDCT */ | |
307 imdct_long(fb, freq_in, transf_buf, 2*nlong); | 335 imdct_long(fb, freq_in, transf_buf, 2*nlong); |
336 | |
337 /* add second half output of previous frame to windowed output of current frame */ | |
338 /* construct first half window using padding with 1's and 0's */ | |
308 for (i = 0; i < nflat_ls; i++) | 339 for (i = 0; i < nflat_ls; i++) |
309 time_out[i] = overlap[i]; | 340 time_out[i] = overlap[i]; |
310 for (i = 0; i < nshort; i++) | 341 for (i = 0; i < nshort; i++) |
311 time_out[nflat_ls+i] = overlap[nflat_ls+i] + MUL_F(transf_buf[nflat_ls+i],window_short_prev[i]); | 342 time_out[nflat_ls+i] = overlap[nflat_ls+i] + MUL_F(transf_buf[nflat_ls+i],window_short_prev[i]); |
312 for (i = 0; i < nflat_ls; i++) | 343 for (i = 0; i < nflat_ls; i++) |
313 time_out[nflat_ls+nshort+i] = overlap[nflat_ls+nshort+i] + transf_buf[nflat_ls+nshort+i]; | 344 time_out[nflat_ls+nshort+i] = overlap[nflat_ls+nshort+i] + transf_buf[nflat_ls+nshort+i]; |
345 | |
346 /* window the second half and save as overlap for next frame */ | |
314 for (i = 0; i < nlong; i++) | 347 for (i = 0; i < nlong; i++) |
315 overlap[i] = MUL_F(transf_buf[nlong+i],window_long[nlong-1-i]); | 348 overlap[i] = MUL_F(transf_buf[nlong+i],window_long[nlong-1-i]); |
316 break; | 349 break; |
317 } | 350 } |
351 | |
352 #if 0 | |
353 for (i = 0; i < 1024; i++) | |
354 { | |
355 //printf("%d\n", time_out[i]); | |
356 printf("0x%.8X\n", time_out[i]); | |
357 } | |
358 #endif | |
359 | |
318 | 360 |
319 #ifdef PROFILE | 361 #ifdef PROFILE |
320 count = faad_get_ts() - count; | 362 count = faad_get_ts() - count; |
321 fb->cycles += count; | 363 fb->cycles += count; |
322 #endif | 364 #endif |