diff options
Diffstat (limited to 'apps/codecs/libfaad/ps_dec.c')
-rw-r--r-- | apps/codecs/libfaad/ps_dec.c | 85 |
1 files changed, 27 insertions, 58 deletions
diff --git a/apps/codecs/libfaad/ps_dec.c b/apps/codecs/libfaad/ps_dec.c index 9a176235d0..335dac7b1c 100644 --- a/apps/codecs/libfaad/ps_dec.c +++ b/apps/codecs/libfaad/ps_dec.c | |||
@@ -152,19 +152,26 @@ typedef struct | |||
152 | uint8_t resolution20[3]; | 152 | uint8_t resolution20[3]; |
153 | uint8_t resolution34[5]; | 153 | uint8_t resolution34[5]; |
154 | 154 | ||
155 | qmf_t *work; | 155 | qmf_t work[32+12]; |
156 | qmf_t **buffer; | 156 | qmf_t buffer[5][32]; |
157 | qmf_t **temp; | 157 | qmf_t temp[32][12]; |
158 | } hyb_info; | 158 | } hyb_info; |
159 | 159 | ||
160 | |||
161 | /* static variables */ | ||
162 | #ifdef FAAD_STATIC_ALLOC | ||
163 | static hyb_info s_hyb_info; | ||
164 | static ps_info s_ps_info; | ||
165 | #endif | ||
166 | |||
160 | /* static function declarations */ | 167 | /* static function declarations */ |
161 | static void ps_data_decode(ps_info *ps); | 168 | static void ps_data_decode(ps_info *ps); |
162 | static hyb_info *hybrid_init(void); | 169 | static hyb_info *hybrid_init(void); |
163 | static void channel_filter2(hyb_info *hyb, uint8_t frame_len, const real_t *filter, | 170 | static void channel_filter2(hyb_info *hyb, uint8_t frame_len, const real_t *filter, |
164 | qmf_t *buffer, qmf_t **X_hybrid); | 171 | qmf_t *buffer, qmf_t X_hybrid[32][12]); |
165 | static INLINE void DCT3_4_unscaled(real_t *y, real_t *x); | 172 | static INLINE void DCT3_4_unscaled(real_t *y, real_t *x); |
166 | static void channel_filter8(hyb_info *hyb, uint8_t frame_len, const real_t *filter, | 173 | static void channel_filter8(hyb_info *hyb, uint8_t frame_len, const real_t *filter, |
167 | qmf_t *buffer, qmf_t **X_hybrid); | 174 | qmf_t *buffer, qmf_t X_hybrid[32][12]); |
168 | static void hybrid_analysis(hyb_info *hyb, qmf_t X[32][64], qmf_t X_hybrid[32][32], | 175 | static void hybrid_analysis(hyb_info *hyb, qmf_t X[32][64], qmf_t X_hybrid[32][32], |
169 | uint8_t use34); | 176 | uint8_t use34); |
170 | static void hybrid_synthesis(hyb_info *hyb, qmf_t X[32][64], qmf_t X_hybrid[32][32], | 177 | static void hybrid_synthesis(hyb_info *hyb, qmf_t X[32][64], qmf_t X_hybrid[32][32], |
@@ -197,9 +204,11 @@ static void ps_mix_phase(ps_info *ps, | |||
197 | 204 | ||
198 | static hyb_info *hybrid_init() | 205 | static hyb_info *hybrid_init() |
199 | { | 206 | { |
200 | uint8_t i; | 207 | #ifdef FAAD_STATIC_ALLOC |
201 | 208 | hyb_info *hyb = &s_hyb_info; | |
209 | #else | ||
202 | hyb_info *hyb = (hyb_info*)faad_malloc(sizeof(hyb_info)); | 210 | hyb_info *hyb = (hyb_info*)faad_malloc(sizeof(hyb_info)); |
211 | #endif | ||
203 | 212 | ||
204 | hyb->resolution34[0] = 12; | 213 | hyb->resolution34[0] = 12; |
205 | hyb->resolution34[1] = 8; | 214 | hyb->resolution34[1] = 8; |
@@ -213,52 +222,16 @@ static hyb_info *hybrid_init() | |||
213 | 222 | ||
214 | hyb->frame_len = 32; | 223 | hyb->frame_len = 32; |
215 | 224 | ||
216 | hyb->work = (qmf_t*)faad_malloc((hyb->frame_len+12) * sizeof(qmf_t)); | 225 | memset(hyb->work , 0, sizeof(hyb->work)); |
217 | memset(hyb->work, 0, (hyb->frame_len+12) * sizeof(qmf_t)); | 226 | memset(hyb->buffer, 0, sizeof(hyb->buffer)); |
218 | 227 | memset(hyb->temp , 0, sizeof(hyb->temp)); | |
219 | hyb->buffer = (qmf_t**)faad_malloc(5 * sizeof(qmf_t*)); | ||
220 | for (i = 0; i < 5; i++) | ||
221 | { | ||
222 | hyb->buffer[i] = (qmf_t*)faad_malloc(hyb->frame_len * sizeof(qmf_t)); | ||
223 | memset(hyb->buffer[i], 0, hyb->frame_len * sizeof(qmf_t)); | ||
224 | } | ||
225 | |||
226 | hyb->temp = (qmf_t**)faad_malloc(hyb->frame_len * sizeof(qmf_t*)); | ||
227 | for (i = 0; i < hyb->frame_len; i++) | ||
228 | { | ||
229 | hyb->temp[i] = (qmf_t*)faad_malloc(12 /*max*/ * sizeof(qmf_t)); | ||
230 | } | ||
231 | 228 | ||
232 | return hyb; | 229 | return hyb; |
233 | } | 230 | } |
234 | 231 | ||
235 | static void hybrid_free(hyb_info *hyb) | ||
236 | { | ||
237 | uint8_t i; | ||
238 | |||
239 | if (hyb->work) | ||
240 | faad_free(hyb->work); | ||
241 | |||
242 | for (i = 0; i < 5; i++) | ||
243 | { | ||
244 | if (hyb->buffer[i]) | ||
245 | faad_free(hyb->buffer[i]); | ||
246 | } | ||
247 | if (hyb->buffer) | ||
248 | faad_free(hyb->buffer); | ||
249 | |||
250 | for (i = 0; i < hyb->frame_len; i++) | ||
251 | { | ||
252 | if (hyb->temp[i]) | ||
253 | faad_free(hyb->temp[i]); | ||
254 | } | ||
255 | if (hyb->temp) | ||
256 | faad_free(hyb->temp); | ||
257 | } | ||
258 | |||
259 | /* real filter, size 2 */ | 232 | /* real filter, size 2 */ |
260 | static void channel_filter2(hyb_info *hyb, uint8_t frame_len, const real_t *filter, | 233 | static void channel_filter2(hyb_info *hyb, uint8_t frame_len, const real_t *filter, |
261 | qmf_t *buffer, qmf_t **X_hybrid) | 234 | qmf_t *buffer, qmf_t X_hybrid[32][12]) |
262 | { | 235 | { |
263 | uint8_t i; | 236 | uint8_t i; |
264 | 237 | ||
@@ -292,7 +265,7 @@ static void channel_filter2(hyb_info *hyb, uint8_t frame_len, const real_t *filt | |||
292 | 265 | ||
293 | /* complex filter, size 4 */ | 266 | /* complex filter, size 4 */ |
294 | static void channel_filter4(hyb_info *hyb, uint8_t frame_len, const real_t *filter, | 267 | static void channel_filter4(hyb_info *hyb, uint8_t frame_len, const real_t *filter, |
295 | qmf_t *buffer, qmf_t **X_hybrid) | 268 | qmf_t *buffer, qmf_t X_hybrid[32][12]) |
296 | { | 269 | { |
297 | uint8_t i; | 270 | uint8_t i; |
298 | real_t input_re1[2], input_re2[2], input_im1[2], input_im2[2]; | 271 | real_t input_re1[2], input_re2[2], input_im1[2], input_im2[2]; |
@@ -367,7 +340,7 @@ static INLINE void DCT3_4_unscaled(real_t *y, real_t *x) | |||
367 | 340 | ||
368 | /* complex filter, size 8 */ | 341 | /* complex filter, size 8 */ |
369 | static void channel_filter8(hyb_info *hyb, uint8_t frame_len, const real_t *filter, | 342 | static void channel_filter8(hyb_info *hyb, uint8_t frame_len, const real_t *filter, |
370 | qmf_t *buffer, qmf_t **X_hybrid) | 343 | qmf_t *buffer, qmf_t X_hybrid[32][12]) |
371 | { | 344 | { |
372 | uint8_t i, n; | 345 | uint8_t i, n; |
373 | real_t input_re1[4], input_re2[4], input_im1[4], input_im2[4]; | 346 | real_t input_re1[4], input_re2[4], input_im1[4], input_im2[4]; |
@@ -460,7 +433,7 @@ static INLINE void DCT3_6_unscaled(real_t *y, real_t *x) | |||
460 | 433 | ||
461 | /* complex filter, size 12 */ | 434 | /* complex filter, size 12 */ |
462 | static void channel_filter12(hyb_info *hyb, uint8_t frame_len, const real_t *filter, | 435 | static void channel_filter12(hyb_info *hyb, uint8_t frame_len, const real_t *filter, |
463 | qmf_t *buffer, qmf_t **X_hybrid) | 436 | qmf_t *buffer, qmf_t X_hybrid[32][12]) |
464 | { | 437 | { |
465 | uint8_t i, n; | 438 | uint8_t i, n; |
466 | real_t input_re1[6], input_re2[6], input_im1[6], input_im2[6]; | 439 | real_t input_re1[6], input_re2[6], input_im1[6], input_im2[6]; |
@@ -1848,20 +1821,16 @@ static void ps_mix_phase(ps_info *ps, | |||
1848 | } | 1821 | } |
1849 | } | 1822 | } |
1850 | 1823 | ||
1851 | void ps_free(ps_info *ps) | ||
1852 | { | ||
1853 | /* free hybrid filterbank structures */ | ||
1854 | hybrid_free(ps->hyb); | ||
1855 | |||
1856 | faad_free(ps); | ||
1857 | } | ||
1858 | |||
1859 | ps_info *ps_init(uint8_t sr_index) | 1824 | ps_info *ps_init(uint8_t sr_index) |
1860 | { | 1825 | { |
1861 | uint8_t i; | 1826 | uint8_t i; |
1862 | uint8_t short_delay_band; | 1827 | uint8_t short_delay_band; |
1863 | 1828 | ||
1829 | #ifdef FAAD_STATIC_ALLOC | ||
1830 | ps_info *ps = &s_ps_info; | ||
1831 | #else | ||
1864 | ps_info *ps = (ps_info*)faad_malloc(sizeof(ps_info)); | 1832 | ps_info *ps = (ps_info*)faad_malloc(sizeof(ps_info)); |
1833 | #endif | ||
1865 | memset(ps, 0, sizeof(ps_info)); | 1834 | memset(ps, 0, sizeof(ps_info)); |
1866 | 1835 | ||
1867 | (void)sr_index; | 1836 | (void)sr_index; |