summaryrefslogtreecommitdiff
path: root/apps/codecs/libfaad/filtbank.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libfaad/filtbank.c')
-rw-r--r--apps/codecs/libfaad/filtbank.c127
1 files changed, 20 insertions, 107 deletions
diff --git a/apps/codecs/libfaad/filtbank.c b/apps/codecs/libfaad/filtbank.c
index 333bad6c70..e5c1bd3870 100644
--- a/apps/codecs/libfaad/filtbank.c
+++ b/apps/codecs/libfaad/filtbank.c
@@ -41,7 +41,7 @@
41#include "syntax.h" 41#include "syntax.h"
42#include "kbd_win.h" 42#include "kbd_win.h"
43#include "sine_win.h" 43#include "sine_win.h"
44#include "mdct.h" 44
45 45
46/*Windowing functions borrowed from libwmai*/ 46/*Windowing functions borrowed from libwmai*/
47 47
@@ -169,95 +169,6 @@ static inline void vector_fmul_reverse(real_t *dst, const real_t *src0, const re
169} 169}
170#endif 170#endif
171 171
172fb_info *filter_bank_init(uint16_t frame_len)
173{
174 uint16_t nshort = frame_len/8;
175#ifdef LD_DEC
176 uint16_t frame_len_ld = frame_len/2;
177#endif
178
179 fb_info *fb = (fb_info*)faad_malloc(sizeof(fb_info));
180 memset(fb, 0, sizeof(fb_info));
181
182 /* normal */
183 fb->mdct256 = faad_mdct_init(2*nshort);
184 fb->mdct2048 = faad_mdct_init(2*frame_len);
185#ifdef LD_DEC
186 /* LD */
187 fb->mdct1024 = faad_mdct_init(2*frame_len_ld);
188#endif
189
190#ifdef ALLOW_SMALL_FRAMELENGTH
191 if (frame_len == 1024)
192 {
193#endif
194 fb->long_window[0] = sine_long_1024;
195 fb->short_window[0] = sine_short_128;
196 fb->long_window[1] = kbd_long_1024;
197 fb->short_window[1] = kbd_short_128;
198#ifdef LD_DEC
199 fb->ld_window[0] = sine_mid_512;
200 fb->ld_window[1] = ld_mid_512;
201#endif
202#ifdef ALLOW_SMALL_FRAMELENGTH
203 } else /* (frame_len == 960) */ {
204 fb->long_window[0] = sine_long_960;
205 fb->short_window[0] = sine_short_120;
206 fb->long_window[1] = kbd_long_960;
207 fb->short_window[1] = kbd_short_120;
208#ifdef LD_DEC
209 fb->ld_window[0] = sine_mid_480;
210 fb->ld_window[1] = ld_mid_480;
211#endif
212 }
213#endif
214
215 return fb;
216}
217
218void filter_bank_end(fb_info *fb)
219{
220 if (fb != NULL)
221 {
222#ifdef PROFILE
223 printf("FB: %I64d cycles\n", fb->cycles);
224#endif
225
226 faad_mdct_end(fb->mdct256);
227 faad_mdct_end(fb->mdct2048);
228#ifdef LD_DEC
229 faad_mdct_end(fb->mdct1024);
230#endif
231
232 faad_free(fb);
233 }
234}
235
236static INLINE void imdct_long(fb_info *fb, real_t *in_data, real_t *out_data, uint16_t len)
237{
238#ifdef LD_DEC
239 mdct_info *mdct = NULL;
240
241 switch (len)
242 {
243 case 2048:
244 case 1920:
245 mdct = fb->mdct2048;
246 break;
247 case 1024:
248 case 960:
249 mdct = fb->mdct1024;
250 break;
251 }
252
253 faad_imdct(mdct, in_data, out_data);
254#else
255 (void) len;
256 faad_imdct(fb->mdct2048, in_data, out_data);
257#endif
258}
259
260
261#ifdef LTP_DEC 172#ifdef LTP_DEC
262static INLINE void mdct(fb_info *fb, real_t *in_data, real_t *out_data, uint16_t len) 173static INLINE void mdct(fb_info *fb, real_t *in_data, real_t *out_data, uint16_t len)
263{ 174{
@@ -287,8 +198,8 @@ static INLINE void mdct(fb_info *fb, real_t *in_data, real_t *out_data, uint16_t
287 198
288ALIGN real_t transf_buf[2*1024] IBSS_ATTR; 199ALIGN real_t transf_buf[2*1024] IBSS_ATTR;
289 200
290void ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape, 201void ifilter_bank(uint8_t window_sequence,
291 uint8_t window_shape_prev, real_t *freq_in, 202 real_t *freq_in,
292 real_t *time_out, real_t *overlap, 203 real_t *time_out, real_t *overlap,
293 uint8_t object_type, uint16_t frame_len) 204 uint8_t object_type, uint16_t frame_len)
294{ 205{
@@ -320,10 +231,12 @@ void ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape,
320#else 231#else
321 (void) object_type; 232 (void) object_type;
322#endif 233#endif
323 window_long = fb->long_window[window_shape]; 234
324 window_long_prev = fb->long_window[window_shape_prev]; 235 window_long = sine_long_1024;
325 window_short = fb->short_window[window_shape]; 236 window_long_prev = kbd_long_1024;
326 window_short_prev = fb->short_window[window_shape_prev]; 237 window_short = sine_short_128;
238 window_short_prev = kbd_short_128;
239
327#ifdef LD_DEC 240#ifdef LD_DEC
328 } 241 }
329#endif 242#endif
@@ -342,7 +255,7 @@ void ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape,
342 { 255 {
343 case ONLY_LONG_SEQUENCE: 256 case ONLY_LONG_SEQUENCE:
344 /* perform iMDCT */ 257 /* perform iMDCT */
345 imdct_long(fb, freq_in, transf_buf, 2*nlong); 258 mdct_backward(2048, freq_in, transf_buf);
346 259
347 /* add second half output of previous frame to windowed output of current frame */ 260 /* add second half output of previous frame to windowed output of current frame */
348 vector_fmul_add_add(time_out, transf_buf, window_long_prev, overlap, nlong); 261 vector_fmul_add_add(time_out, transf_buf, window_long_prev, overlap, nlong);
@@ -354,7 +267,7 @@ void ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape,
354 267
355 case LONG_START_SEQUENCE: 268 case LONG_START_SEQUENCE:
356 /* perform iMDCT */ 269 /* perform iMDCT */
357 imdct_long(fb, freq_in, transf_buf, 2*nlong); 270 mdct_backward(2048, freq_in, transf_buf);
358 271
359 /* add second half output of previous frame to windowed output of current frame */ 272 /* add second half output of previous frame to windowed output of current frame */
360 vector_fmul_add_add(time_out, transf_buf, window_long_prev, overlap, nlong); 273 vector_fmul_add_add(time_out, transf_buf, window_long_prev, overlap, nlong);
@@ -373,14 +286,14 @@ void ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape,
373 /*this could be assemblerized too, but this case is extremely uncommon*/ 286 /*this could be assemblerized too, but this case is extremely uncommon*/
374 287
375 /* perform iMDCT for each short block */ 288 /* perform iMDCT for each short block */
376 faad_imdct(fb->mdct256, freq_in+0*nshort, transf_buf+2*nshort*0); 289 mdct_backward(256, freq_in+0*nshort, transf_buf+2*nshort*0);
377 faad_imdct(fb->mdct256, freq_in+1*nshort, transf_buf+2*nshort*1); 290 mdct_backward(256, freq_in+1*nshort, transf_buf+2*nshort*1);
378 faad_imdct(fb->mdct256, freq_in+2*nshort, transf_buf+2*nshort*2); 291 mdct_backward(256, freq_in+2*nshort, transf_buf+2*nshort*2);
379 faad_imdct(fb->mdct256, freq_in+3*nshort, transf_buf+2*nshort*3); 292 mdct_backward(256, freq_in+3*nshort, transf_buf+2*nshort*3);
380 faad_imdct(fb->mdct256, freq_in+4*nshort, transf_buf+2*nshort*4); 293 mdct_backward(256, freq_in+4*nshort, transf_buf+2*nshort*4);
381 faad_imdct(fb->mdct256, freq_in+5*nshort, transf_buf+2*nshort*5); 294 mdct_backward(256, freq_in+5*nshort, transf_buf+2*nshort*5);
382 faad_imdct(fb->mdct256, freq_in+6*nshort, transf_buf+2*nshort*6); 295 mdct_backward(256, freq_in+6*nshort, transf_buf+2*nshort*6);
383 faad_imdct(fb->mdct256, freq_in+7*nshort, transf_buf+2*nshort*7); 296 mdct_backward(256, freq_in+7*nshort, transf_buf+2*nshort*7);
384 297
385 /* add second half output of previous frame to windowed output of current frame */ 298 /* add second half output of previous frame to windowed output of current frame */
386 for (i = 0; i < nflat_ls; i++) 299 for (i = 0; i < nflat_ls; i++)
@@ -411,7 +324,7 @@ void ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape,
411 324
412 case LONG_STOP_SEQUENCE: 325 case LONG_STOP_SEQUENCE:
413 /* perform iMDCT */ 326 /* perform iMDCT */
414 imdct_long(fb, freq_in, transf_buf, 2*nlong); 327 mdct_backward(2048, freq_in, transf_buf);
415 328
416 /* add second half output of previous frame to windowed output of current frame */ 329 /* add second half output of previous frame to windowed output of current frame */
417 /* construct first half window using padding with 1's and 0's */ 330 /* construct first half window using padding with 1's and 0's */