annotate libfaad2/filtbank.c @ 11768:4b6dcc5a1d38

lavcodec compile fix
author henry
date Sat, 10 Jan 2004 13:00:42 +0000
parents 3185f64f6350
children 4a370c80fe5c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1 /*
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
3 ** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
4 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
5 ** This program is free software; you can redistribute it and/or modify
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
6 ** it under the terms of the GNU General Public License as published by
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
7 ** the Free Software Foundation; either version 2 of the License, or
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
8 ** (at your option) any later version.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
9 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
10 ** This program is distributed in the hope that it will be useful,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
13 ** GNU General Public License for more details.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
14 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
15 ** You should have received a copy of the GNU General Public License
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
16 ** along with this program; if not, write to the Free Software
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
18 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
19 ** Any non-GPL usage of this software or parts of this software is strictly
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
20 ** forbidden.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
21 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
22 ** Commercial non-GPL licensing of this software is possible.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
24 **
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
25 ** $Id: filtbank.c,v 1.1 2003/08/30 22:30:21 arpi Exp $
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
26 **/
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
27
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
28 #include "common.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
29 #include "structs.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
30
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
31 #include <stdlib.h>
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
32 #include <string.h>
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
33 #ifdef _WIN32_WCE
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
34 #define assert(x)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
35 #else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
36 #include <assert.h>
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
37 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
38
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
39 #include "filtbank.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
40 #include "decoder.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
41 #include "syntax.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
42 #include "kbd_win.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
43 #include "sine_win.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
44 #include "mdct.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
45
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
46
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
47 fb_info *filter_bank_init(uint16_t frame_len)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
48 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
49 uint16_t nshort = frame_len/8;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
50 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
51 uint16_t frame_len_ld = frame_len/2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
52 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
53
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
54 fb_info *fb = (fb_info*)malloc(sizeof(fb_info));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
55 memset(fb, 0, sizeof(fb_info));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
56
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
57 /* normal */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
58 fb->mdct256 = faad_mdct_init(2*nshort);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
59 fb->mdct2048 = faad_mdct_init(2*frame_len);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
60 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
61 /* LD */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
62 fb->mdct1024 = faad_mdct_init(2*frame_len_ld);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
63 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
64
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
65 if (frame_len == 1024)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
66 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
67 fb->long_window[0] = sine_long_1024;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
68 fb->short_window[0] = sine_short_128;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
69 fb->long_window[1] = kbd_long_1024;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
70 fb->short_window[1] = kbd_short_128;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
71 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
72 fb->ld_window[0] = sine_mid_512;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
73 fb->ld_window[1] = ld_mid_512;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
74 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
75 } else /* (frame_len == 960) */ {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
76 fb->long_window[0] = sine_long_960;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
77 fb->short_window[0] = sine_short_120;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
78 fb->long_window[1] = kbd_long_960;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
79 fb->short_window[1] = kbd_short_120;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
80 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
81 fb->ld_window[0] = sine_mid_480;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
82 fb->ld_window[1] = ld_mid_480;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
83 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
84 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
85
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
86 return fb;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
87 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
88
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
89 void filter_bank_end(fb_info *fb)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
90 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
91 if (fb != NULL)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
92 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
93 faad_mdct_end(fb->mdct256);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
94 faad_mdct_end(fb->mdct2048);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
95 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
96 faad_mdct_end(fb->mdct1024);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
97 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
98
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
99 free(fb);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
100 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
101 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
102
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
103 static INLINE void imdct(fb_info *fb, real_t *in_data, real_t *out_data, uint16_t len)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
104 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
105 mdct_info *mdct;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
106
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
107 switch (len)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
108 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
109 case 2048:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
110 case 1920:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
111 mdct = fb->mdct2048;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
112 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
113 case 256:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
114 case 240:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
115 mdct = fb->mdct256;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
116 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
117 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
118 case 1024:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
119 case 960:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
120 mdct = fb->mdct1024;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
121 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
122 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
123 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
124
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
125 faad_imdct(mdct, in_data, out_data);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
126 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
127
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
128 #ifdef LTP_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
129 static INLINE void mdct(fb_info *fb, real_t *in_data, real_t *out_data, uint16_t len)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
130 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
131 mdct_info *mdct;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
132
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
133 switch (len)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
134 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
135 case 2048:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
136 case 1920:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
137 mdct = fb->mdct2048;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
138 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
139 case 256:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
140 case 240:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
141 mdct = fb->mdct256;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
142 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
143 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
144 case 1024:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
145 case 960:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
146 mdct = fb->mdct1024;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
147 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
148 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
149 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
150
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
151 faad_mdct(mdct, in_data, out_data);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
152 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
153 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
154
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
155 void ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
156 uint8_t window_shape_prev, real_t *freq_in,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
157 real_t *time_out, uint8_t object_type, uint16_t frame_len)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
158 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
159 int16_t i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
160 real_t *transf_buf;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
161
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
162 real_t *window_long;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
163 real_t *window_long_prev;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
164 real_t *window_short;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
165 real_t *window_short_prev;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
166
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
167 uint16_t nlong = frame_len;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
168 uint16_t nshort = frame_len/8;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
169 uint16_t trans = nshort/2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
170
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
171 uint16_t nflat_ls = (nlong-nshort)/2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
172
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
173 transf_buf = (real_t*)malloc(2*nlong*sizeof(real_t));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
174
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
175 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
176 if (object_type == LD)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
177 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
178 window_long = fb->ld_window[window_shape];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
179 window_long_prev = fb->ld_window[window_shape_prev];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
180 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
181 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
182 window_long = fb->long_window[window_shape];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
183 window_long_prev = fb->long_window[window_shape_prev];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
184 window_short = fb->short_window[window_shape];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
185 window_short_prev = fb->short_window[window_shape_prev];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
186 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
187 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
188 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
189
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
190 switch (window_sequence)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
191 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
192 case ONLY_LONG_SEQUENCE:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
193 imdct(fb, freq_in, transf_buf, 2*nlong);
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
194 for (i = 0; i < nlong; i+=4)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
195 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
196 time_out[i] = time_out[nlong+i] + MUL_R_C(transf_buf[i],window_long_prev[i]);
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
197 time_out[i+1] = time_out[nlong+i+1] + MUL_R_C(transf_buf[i+1],window_long_prev[i+1]);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
198 time_out[i+2] = time_out[nlong+i+2] + MUL_R_C(transf_buf[i+2],window_long_prev[i+2]);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
199 time_out[i+3] = time_out[nlong+i+3] + MUL_R_C(transf_buf[i+3],window_long_prev[i+3]);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
200 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
201 for (i = 0; i < nlong; i+=4)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
202 {
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
203 time_out[nlong+i] = MUL_R_C(transf_buf[nlong+i],window_long[nlong-1-i]);
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
204 time_out[nlong+i+1] = MUL_R_C(transf_buf[nlong+i+1],window_long[nlong-2-i]);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
205 time_out[nlong+i+2] = MUL_R_C(transf_buf[nlong+i+2],window_long[nlong-3-i]);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
206 time_out[nlong+i+3] = MUL_R_C(transf_buf[nlong+i+3],window_long[nlong-4-i]);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
207 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
208 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
209
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
210 case LONG_START_SEQUENCE:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
211 imdct(fb, freq_in, transf_buf, 2*nlong);
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
212 for (i = 0; i < nlong; i+=4)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
213 {
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
214 time_out[i] = time_out[nlong+i] + MUL_R_C(transf_buf[i],window_long_prev[i]);
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
215 time_out[i+1] = time_out[nlong+i+1] + MUL_R_C(transf_buf[i+1],window_long_prev[i+1]);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
216 time_out[i+2] = time_out[nlong+i+2] + MUL_R_C(transf_buf[i+2],window_long_prev[i+2]);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
217 time_out[i+3] = time_out[nlong+i+3] + MUL_R_C(transf_buf[i+3],window_long_prev[i+3]);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
218 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
219 for (i = 0; i < nflat_ls; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
220 time_out[nlong+i] = transf_buf[nlong+i];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
221 for (i = 0; i < nshort; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
222 time_out[nlong+nflat_ls+i] = MUL_R_C(transf_buf[nlong+nflat_ls+i],window_short[nshort-i-1]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
223 for (i = 0; i < nflat_ls; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
224 time_out[nlong+nflat_ls+nshort+i] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
225 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
226
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
227 case EIGHT_SHORT_SEQUENCE:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
228 imdct(fb, freq_in+0*nshort, transf_buf+2*nshort*0, 2*nshort);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
229 imdct(fb, freq_in+1*nshort, transf_buf+2*nshort*1, 2*nshort);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
230 imdct(fb, freq_in+2*nshort, transf_buf+2*nshort*2, 2*nshort);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
231 imdct(fb, freq_in+3*nshort, transf_buf+2*nshort*3, 2*nshort);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
232 imdct(fb, freq_in+4*nshort, transf_buf+2*nshort*4, 2*nshort);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
233 imdct(fb, freq_in+5*nshort, transf_buf+2*nshort*5, 2*nshort);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
234 imdct(fb, freq_in+6*nshort, transf_buf+2*nshort*6, 2*nshort);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
235 imdct(fb, freq_in+7*nshort, transf_buf+2*nshort*7, 2*nshort);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
236 for (i = 0; i < nflat_ls; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
237 time_out[i] = time_out[nlong+i];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
238 for(i = nshort-1; i >= 0; i--)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
239 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
240 time_out[nflat_ls+ i] = time_out[nlong+nflat_ls+ i] + MUL_R_C(transf_buf[nshort*0+i],window_short_prev[i]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
241 time_out[nflat_ls+1*nshort+i] = time_out[nlong+nflat_ls+nshort*1+i] + MUL_R_C(transf_buf[nshort*1+i],window_short[nshort-1-i]) + MUL_R_C(transf_buf[nshort*2+i],window_short[i]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
242 time_out[nflat_ls+2*nshort+i] = time_out[nlong+nflat_ls+nshort*2+i] + MUL_R_C(transf_buf[nshort*3+i],window_short[nshort-1-i]) + MUL_R_C(transf_buf[nshort*4+i],window_short[i]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
243 time_out[nflat_ls+3*nshort+i] = time_out[nlong+nflat_ls+nshort*3+i] + MUL_R_C(transf_buf[nshort*5+i],window_short[nshort-1-i]) + MUL_R_C(transf_buf[nshort*6+i],window_short[i]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
244 if (i < trans)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
245 time_out[nflat_ls+4*nshort+i] = time_out[nlong+nflat_ls+nshort*4+i] + MUL_R_C(transf_buf[nshort*7+i],window_short[nshort-1-i]) + MUL_R_C(transf_buf[nshort*8+i],window_short[i]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
246 else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
247 time_out[nflat_ls+4*nshort+i] = MUL_R_C(transf_buf[nshort*7+i],window_short[nshort-1-i]) + MUL_R_C(transf_buf[nshort*8+i],window_short[i]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
248 time_out[nflat_ls+5*nshort+i] = MUL_R_C(transf_buf[nshort*9+i],window_short[nshort-1-i]) + MUL_R_C(transf_buf[nshort*10+i],window_short[i]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
249 time_out[nflat_ls+6*nshort+i] = MUL_R_C(transf_buf[nshort*11+i],window_short[nshort-1-i]) + MUL_R_C(transf_buf[nshort*12+i],window_short[i]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
250 time_out[nflat_ls+7*nshort+i] = MUL_R_C(transf_buf[nshort*13+i],window_short[nshort-1-i]) + MUL_R_C(transf_buf[nshort*14+i],window_short[i]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
251 time_out[nflat_ls+8*nshort+i] = MUL_R_C(transf_buf[nshort*15+i],window_short[nshort-1-i]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
252 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
253 for (i = 0; i < nflat_ls; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
254 time_out[nlong+nflat_ls+nshort+i] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
255 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
256
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
257 case LONG_STOP_SEQUENCE:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
258 imdct(fb, freq_in, transf_buf, 2*nlong);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
259 for (i = 0; i < nflat_ls; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
260 time_out[i] = time_out[nlong+i];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
261 for (i = 0; i < nshort; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
262 time_out[nflat_ls+i] = time_out[nlong+nflat_ls+i] + MUL_R_C(transf_buf[nflat_ls+i],window_short_prev[i]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
263 for (i = 0; i < nflat_ls; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
264 time_out[nflat_ls+nshort+i] = time_out[nlong+nflat_ls+nshort+i] + transf_buf[nflat_ls+nshort+i];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
265 for (i = 0; i < nlong; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
266 time_out[nlong+i] = MUL_R_C(transf_buf[nlong+i],window_long[nlong-1-i]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
267 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
268 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
269
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
270 free(transf_buf);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
271 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
272
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
273 #ifdef LTP_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
274 /* only works for LTP -> no overlapping, no short blocks */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
275 void filter_bank_ltp(fb_info *fb, uint8_t window_sequence, uint8_t window_shape,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
276 uint8_t window_shape_prev, real_t *in_data, real_t *out_mdct,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
277 uint8_t object_type, uint16_t frame_len)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
278 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
279 int16_t i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
280 real_t *windowed_buf;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
281
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
282 real_t *window_long;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
283 real_t *window_long_prev;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
284 real_t *window_short;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
285 real_t *window_short_prev;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
286
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
287 uint16_t nlong = frame_len;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
288 uint16_t nshort = frame_len/8;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
289 uint16_t nflat_ls = (nlong-nshort)/2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
290
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
291 assert(window_sequence != EIGHT_SHORT_SEQUENCE);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
292
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
293 windowed_buf = (real_t*)malloc(nlong*2*sizeof(real_t));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
294
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
295 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
296 if (object_type == LD)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
297 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
298 window_long = fb->ld_window[window_shape];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
299 window_long_prev = fb->ld_window[window_shape_prev];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
300 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
301 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
302 window_long = fb->long_window[window_shape];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
303 window_long_prev = fb->long_window[window_shape_prev];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
304 window_short = fb->short_window[window_shape];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
305 window_short_prev = fb->short_window[window_shape_prev];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
306 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
307 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
308 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
309
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
310 switch(window_sequence)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
311 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
312 case ONLY_LONG_SEQUENCE:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
313 for (i = nlong-1; i >= 0; i--)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
314 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
315 windowed_buf[i] = MUL_R_C(in_data[i], window_long_prev[i]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
316 windowed_buf[i+nlong] = MUL_R_C(in_data[i+nlong], window_long[nlong-1-i]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
317 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
318 mdct(fb, windowed_buf, out_mdct, 2*nlong);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
319 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
320
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
321 case LONG_START_SEQUENCE:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
322 for (i = 0; i < nlong; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
323 windowed_buf[i] = MUL_R_C(in_data[i], window_long_prev[i]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
324 for (i = 0; i < nflat_ls; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
325 windowed_buf[i+nlong] = in_data[i+nlong];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
326 for (i = 0; i < nshort; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
327 windowed_buf[i+nlong+nflat_ls] = MUL_R_C(in_data[i+nlong+nflat_ls], window_short[nshort-1-i]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
328 for (i = 0; i < nflat_ls; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
329 windowed_buf[i+nlong+nflat_ls+nshort] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
330 mdct(fb, windowed_buf, out_mdct, 2*nlong);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
331 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
332
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
333 case LONG_STOP_SEQUENCE:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
334 for (i = 0; i < nflat_ls; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
335 windowed_buf[i] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
336 for (i = 0; i < nshort; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
337 windowed_buf[i+nflat_ls] = MUL_R_C(in_data[i+nflat_ls], window_short_prev[i]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
338 for (i = 0; i < nflat_ls; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
339 windowed_buf[i+nflat_ls+nshort] = in_data[i+nflat_ls+nshort];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
340 for (i = 0; i < nlong; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
341 windowed_buf[i+nlong] = MUL_R_C(in_data[i+nlong], window_long[nlong-1-i]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
342 mdct(fb, windowed_buf, out_mdct, 2*nlong);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
343 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
344 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
345
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
346 free(windowed_buf);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
347 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
348 #endif