summaryrefslogtreecommitdiff
path: root/apps/codecs/libfaad/ps_dec.c
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2011-04-24 20:19:05 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2011-04-24 20:19:05 +0000
commita602f46d69d9d18756b7f317470f654f695faa80 (patch)
treef111cc29197def94d5404d15c7febfd06efed9f7 /apps/codecs/libfaad/ps_dec.c
parent69580a96eb816d9b811c542d38181126243d8563 (diff)
downloadrockbox-a602f46d69d9d18756b7f317470f654f695faa80.tar.gz
rockbox-a602f46d69d9d18756b7f317470f654f695faa80.zip
Rework of libfaad in several areas. Allow removal of malloc with a new define FAAD_STATIC_ALLOC (in common.h). For now malloc is not fully removed but used by a few arrays needed for AAC-HE SBR+PS only. Reason to keep malloc is to have this amount of memory available for AAC-LC files which might require large m4a tables. The changes make the allocation routines much smaller, better centralized and allow to move duplicated code from aac.c/raa.c to libfaad. The rework includes removal of (now and former) unused code as well.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29778 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libfaad/ps_dec.c')
-rw-r--r--apps/codecs/libfaad/ps_dec.c85
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
163static hyb_info s_hyb_info;
164static ps_info s_ps_info;
165#endif
166
160/* static function declarations */ 167/* static function declarations */
161static void ps_data_decode(ps_info *ps); 168static void ps_data_decode(ps_info *ps);
162static hyb_info *hybrid_init(void); 169static hyb_info *hybrid_init(void);
163static void channel_filter2(hyb_info *hyb, uint8_t frame_len, const real_t *filter, 170static 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]);
165static INLINE void DCT3_4_unscaled(real_t *y, real_t *x); 172static INLINE void DCT3_4_unscaled(real_t *y, real_t *x);
166static void channel_filter8(hyb_info *hyb, uint8_t frame_len, const real_t *filter, 173static 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]);
168static void hybrid_analysis(hyb_info *hyb, qmf_t X[32][64], qmf_t X_hybrid[32][32], 175static 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);
170static void hybrid_synthesis(hyb_info *hyb, qmf_t X[32][64], qmf_t X_hybrid[32][32], 177static 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
198static hyb_info *hybrid_init() 205static 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
235static 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 */
260static void channel_filter2(hyb_info *hyb, uint8_t frame_len, const real_t *filter, 233static 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 */
294static void channel_filter4(hyb_info *hyb, uint8_t frame_len, const real_t *filter, 267static 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 */
369static void channel_filter8(hyb_info *hyb, uint8_t frame_len, const real_t *filter, 342static 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 */
462static void channel_filter12(hyb_info *hyb, uint8_t frame_len, const real_t *filter, 435static 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
1851void ps_free(ps_info *ps)
1852{
1853 /* free hybrid filterbank structures */
1854 hybrid_free(ps->hyb);
1855
1856 faad_free(ps);
1857}
1858
1859ps_info *ps_init(uint8_t sr_index) 1824ps_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;