summaryrefslogtreecommitdiff
path: root/apps/codecs/libfaad
diff options
context:
space:
mode:
authorMagnus Holmgren <magnushol@gmail.com>2006-09-24 19:00:29 +0000
committerMagnus Holmgren <magnushol@gmail.com>2006-09-24 19:00:29 +0000
commit3fa5e5f5924306417c05cbc7a7f46a605c670996 (patch)
tree582869c0709cb876cec3f4a3b73a0dd56e6241a5 /apps/codecs/libfaad
parent0e5bd54cbb26768a2059ed5aadd7b2c15974fe6f (diff)
downloadrockbox-3fa5e5f5924306417c05cbc7a7f46a605c670996.zip
rockbox-3fa5e5f5924306417c05cbc7a7f46a605c670996.tar.gz
rockbox-3fa5e5f5924306417c05cbc7a7f46a605c670996.tar.bz2
rockbox-3fa5e5f5924306417c05cbc7a7f46a605c670996.tar.xz
Apply a bunch of simple AAC decoder optimizations. Biggest speedup is on ColdFire targets, but ARM targets benefits too. Allows realtime playback of some AAC files on Iriver targets (H1x0, H3x0). Remove support for some rarely used AAC profiles to reduce code size a bit.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11038 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libfaad')
-rw-r--r--apps/codecs/libfaad/bits.c2
-rw-r--r--apps/codecs/libfaad/cfft.c12
-rw-r--r--apps/codecs/libfaad/cfft_tab.h6
-rw-r--r--apps/codecs/libfaad/common.h2
-rw-r--r--apps/codecs/libfaad/filtbank.c7
-rw-r--r--apps/codecs/libfaad/kbd_win.h4
-rw-r--r--apps/codecs/libfaad/mdct.c2
-rw-r--r--apps/codecs/libfaad/mdct_tab.h4
-rw-r--r--apps/codecs/libfaad/sine_win.h4
-rw-r--r--apps/codecs/libfaad/specrec.c42
-rw-r--r--apps/codecs/libfaad/syntax.c18
11 files changed, 62 insertions, 41 deletions
diff --git a/apps/codecs/libfaad/bits.c b/apps/codecs/libfaad/bits.c
index e2e609e..65f451a 100644
--- a/apps/codecs/libfaad/bits.c
+++ b/apps/codecs/libfaad/bits.c
@@ -32,7 +32,7 @@
#include <string.h>
#include "bits.h"
-uint8_t static_buffer[1024] IBSS_ATTR;
+uint8_t static_buffer[1024];
/* initialize buffer, call once before first getbits or showbits */
void faad_initbits(bitfile *ld, const void *_buffer, const uint32_t buffer_size)
diff --git a/apps/codecs/libfaad/cfft.c b/apps/codecs/libfaad/cfft.c
index 8eec8aa..eecfe4b 100644
--- a/apps/codecs/libfaad/cfft.c
+++ b/apps/codecs/libfaad/cfft.c
@@ -960,7 +960,17 @@ cfft_info *cffti(uint16_t n)
cfft_info *cfft = (cfft_info*)faad_malloc(sizeof(cfft_info));
cfft->n = n;
- cfft->work = (complex_t*)faad_malloc(n*sizeof(complex_t));
+
+ if (n <= 512)
+ {
+ static complex_t work_buf[512] IBSS_ATTR;
+
+ cfft->work = work_buf;
+ }
+ else
+ {
+ cfft->work = (complex_t*)faad_malloc(n*sizeof(complex_t));
+ }
#ifndef FIXED_POINT
cfft->tab = (complex_t*)faad_malloc(n*sizeof(complex_t));
diff --git a/apps/codecs/libfaad/cfft_tab.h b/apps/codecs/libfaad/cfft_tab.h
index 7ab7a11..b26653b 100644
--- a/apps/codecs/libfaad/cfft_tab.h
+++ b/apps/codecs/libfaad/cfft_tab.h
@@ -34,7 +34,7 @@ extern "C" {
#ifdef FIXED_POINT
-ALIGN static const complex_t cfft_tab_512[] =
+ALIGN static const complex_t cfft_tab_512[] ICONST_ATTR =
{
{ FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
{ FRAC_CONST(0.999924719333649), FRAC_CONST(0.012271538376808) },
@@ -1036,7 +1036,7 @@ ALIGN static const complex_t cfft_tab_480[] =
};
#endif
-ALIGN static const complex_t cfft_tab_64[] =
+ALIGN static const complex_t cfft_tab_64[] ICONST_ATTR =
{
{ FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
{ FRAC_CONST(0.995184719562531), FRAC_CONST(0.098017141222954) },
@@ -1680,7 +1680,7 @@ ALIGN static const complex_t cfft_tab_240[] =
#endif
-ALIGN static const complex_t cfft_tab_128[] =
+ALIGN static const complex_t cfft_tab_128[] ICONST_ATTR =
{
{ FRAC_CONST(1.000000000000000), FRAC_CONST(0.000000000000000) },
{ FRAC_CONST(0.998795449733734), FRAC_CONST(0.049067676067352) },
diff --git a/apps/codecs/libfaad/common.h b/apps/codecs/libfaad/common.h
index 7ee0eda..65d2733 100644
--- a/apps/codecs/libfaad/common.h
+++ b/apps/codecs/libfaad/common.h
@@ -113,7 +113,7 @@ extern struct codec_api* ci;
// Define LC_ONLY_DECODER if you want a pure AAC LC decoder (independant of SBR_DEC and PS_DEC)
-//#define LC_ONLY_DECODER
+#define LC_ONLY_DECODER
#ifdef LC_ONLY_DECODER
#undef LD_DEC
#undef LTP_DEC
diff --git a/apps/codecs/libfaad/filtbank.c b/apps/codecs/libfaad/filtbank.c
index 603e02f..9b1bc85 100644
--- a/apps/codecs/libfaad/filtbank.c
+++ b/apps/codecs/libfaad/filtbank.c
@@ -127,6 +127,7 @@ static INLINE void imdct_long(fb_info *fb, real_t *in_data, real_t *out_data, ui
faad_imdct(mdct, in_data, out_data);
#else
+ (void) len;
faad_imdct(fb->mdct2048, in_data, out_data);
#endif
}
@@ -159,7 +160,7 @@ static INLINE void mdct(fb_info *fb, real_t *in_data, real_t *out_data, uint16_t
}
#endif
-ALIGN real_t transf_buf[2*1024] = {0};
+ALIGN real_t transf_buf[2*1024] IBSS_ATTR;
void ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape,
uint8_t window_shape_prev, real_t *freq_in,
@@ -191,6 +192,8 @@ void ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape,
window_long = fb->ld_window[window_shape];
window_long_prev = fb->ld_window[window_shape_prev];
} else {
+#else
+ (void) object_type;
#endif
window_long = fb->long_window[window_shape];
window_long_prev = fb->long_window[window_shape_prev];
@@ -359,6 +362,8 @@ void filter_bank_ltp(fb_info *fb, uint8_t window_sequence, uint8_t window_shape,
window_long = fb->ld_window[window_shape];
window_long_prev = fb->ld_window[window_shape_prev];
} else {
+#else
+ (void) object_type;
#endif
window_long = fb->long_window[window_shape];
window_long_prev = fb->long_window[window_shape_prev];
diff --git a/apps/codecs/libfaad/kbd_win.h b/apps/codecs/libfaad/kbd_win.h
index 933e6c1..1c3fd09 100644
--- a/apps/codecs/libfaad/kbd_win.h
+++ b/apps/codecs/libfaad/kbd_win.h
@@ -37,7 +37,7 @@ extern "C" {
#pragma warning(disable:4244)
#endif
-ALIGN static const real_t kbd_long_1024[] =
+ALIGN static const real_t kbd_long_1024[] ICONST_ATTR =
{
FRAC_CONST(0.00029256153896361),
FRAC_CONST(0.00042998567353047),
@@ -2030,7 +2030,7 @@ ALIGN static const real_t kbd_long_960[] = {
};
#endif
-ALIGN static const real_t kbd_short_128[] =
+ALIGN static const real_t kbd_short_128[] ICONST_ATTR =
{
FRAC_CONST(4.3795702929468881e-005),
FRAC_CONST(0.00011867384265436617),
diff --git a/apps/codecs/libfaad/mdct.c b/apps/codecs/libfaad/mdct.c
index 158ea22..902c3f3 100644
--- a/apps/codecs/libfaad/mdct.c
+++ b/apps/codecs/libfaad/mdct.c
@@ -126,7 +126,7 @@ void faad_imdct(mdct_info *mdct, real_t *X_in, real_t *X_out)
real_t scale = 0, b_scale = 0;
#endif
#endif
- ALIGN static complex_t Z1[512];
+ ALIGN static complex_t Z1[512] IBSS_ATTR;
complex_t *sincos = mdct->sincos;
uint16_t N = mdct->N;
diff --git a/apps/codecs/libfaad/mdct_tab.h b/apps/codecs/libfaad/mdct_tab.h
index ce48535..2442a4e 100644
--- a/apps/codecs/libfaad/mdct_tab.h
+++ b/apps/codecs/libfaad/mdct_tab.h
@@ -35,7 +35,7 @@ extern "C" {
#ifdef FIXED_POINT
/* 256 (N/4) complex twiddle factors */
-ALIGN static const complex_t mdct_tab_2048[] =
+ALIGN static const complex_t mdct_tab_2048[] ICONST_ATTR =
{
{ FRAC_CONST(0.999999926465718), FRAC_CONST(0.000383495187571) },
{ FRAC_CONST(0.999994043728986), FRAC_CONST(0.003451449920136) },
@@ -552,7 +552,7 @@ ALIGN static const complex_t mdct_tab_2048[] =
};
/* 64 (N/4) complex twiddle factors */
-ALIGN static const complex_t mdct_tab_256[] =
+ALIGN static const complex_t mdct_tab_256[] ICONST_ATTR =
{
{ FRAC_CONST(0.999995293809576), FRAC_CONST(0.003067956762966) },
{ FRAC_CONST(0.999618822495179), FRAC_CONST(0.027608145778966) },
diff --git a/apps/codecs/libfaad/sine_win.h b/apps/codecs/libfaad/sine_win.h
index 38cba66..edd3b40 100644
--- a/apps/codecs/libfaad/sine_win.h
+++ b/apps/codecs/libfaad/sine_win.h
@@ -37,7 +37,7 @@ extern "C" {
#pragma warning(disable:4244)
#endif
-ALIGN static const real_t sine_long_1024[] =
+ALIGN static const real_t sine_long_1024[] ICONST_ATTR =
{
FRAC_CONST(0.00076699031874270449),
FRAC_CONST(0.002300969151425805),
@@ -2031,7 +2031,7 @@ ALIGN static const real_t sine_long_960[] =
};
#endif
-ALIGN static const real_t sine_short_128[] =
+ALIGN static const real_t sine_short_128[] ICONST_ATTR =
{
FRAC_CONST(0.0061358846491544753),
FRAC_CONST(0.01840672990580482),
diff --git a/apps/codecs/libfaad/specrec.c b/apps/codecs/libfaad/specrec.c
index 6d74c77..b457f04 100644
--- a/apps/codecs/libfaad/specrec.c
+++ b/apps/codecs/libfaad/specrec.c
@@ -71,34 +71,34 @@ ALIGN static const uint8_t num_swb_480_window[] =
};
#endif
-ALIGN static const uint8_t num_swb_960_window[] =
+ALIGN static const uint8_t num_swb_960_window[] ICONST_ATTR =
{
40, 40, 45, 49, 49, 49, 46, 46, 42, 42, 42, 40
};
-ALIGN static const uint8_t num_swb_1024_window[] =
+ALIGN static const uint8_t num_swb_1024_window[] ICONST_ATTR =
{
41, 41, 47, 49, 49, 51, 47, 47, 43, 43, 43, 40
};
-ALIGN static const uint8_t num_swb_128_window[] =
+ALIGN static const uint8_t num_swb_128_window[] ICONST_ATTR =
{
12, 12, 12, 14, 14, 14, 15, 15, 15, 15, 15, 15
};
-ALIGN static const uint16_t swb_offset_1024_96[] =
+ALIGN static const uint16_t swb_offset_1024_96[] ICONST_ATTR =
{
0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56,
64, 72, 80, 88, 96, 108, 120, 132, 144, 156, 172, 188, 212, 240,
276, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960, 1024
};
-ALIGN static const uint16_t swb_offset_128_96[] =
+ALIGN static const uint16_t swb_offset_128_96[] ICONST_ATTR =
{
0, 4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 92, 128
};
-ALIGN static const uint16_t swb_offset_1024_64[] =
+ALIGN static const uint16_t swb_offset_1024_64[] ICONST_ATTR =
{
0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56,
64, 72, 80, 88, 100, 112, 124, 140, 156, 172, 192, 216, 240, 268,
@@ -106,12 +106,12 @@ ALIGN static const uint16_t swb_offset_1024_64[] =
864, 904, 944, 984, 1024
};
-ALIGN static const uint16_t swb_offset_128_64[] =
+ALIGN static const uint16_t swb_offset_128_64[] ICONST_ATTR =
{
0, 4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 92, 128
};
-ALIGN static const uint16_t swb_offset_1024_48[] =
+ALIGN static const uint16_t swb_offset_1024_48[] ICONST_ATTR =
{
0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 48, 56, 64, 72,
80, 88, 96, 108, 120, 132, 144, 160, 176, 196, 216, 240, 264, 292,
@@ -135,12 +135,12 @@ ALIGN static const uint16_t swb_offset_480_48[] =
};
#endif
-ALIGN static const uint16_t swb_offset_128_48[] =
+ALIGN static const uint16_t swb_offset_128_48[] ICONST_ATTR =
{
0, 4, 8, 12, 16, 20, 28, 36, 44, 56, 68, 80, 96, 112, 128
};
-ALIGN static const uint16_t swb_offset_1024_32[] =
+ALIGN static const uint16_t swb_offset_1024_32[] ICONST_ATTR =
{
0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 48, 56, 64, 72,
80, 88, 96, 108, 120, 132, 144, 160, 176, 196, 216, 240, 264, 292,
@@ -164,7 +164,7 @@ ALIGN static const uint16_t swb_offset_480_32[] =
};
#endif
-ALIGN static const uint16_t swb_offset_1024_24[] =
+ALIGN static const uint16_t swb_offset_1024_24[] ICONST_ATTR =
{
0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 52, 60, 68,
76, 84, 92, 100, 108, 116, 124, 136, 148, 160, 172, 188, 204, 220,
@@ -187,36 +187,36 @@ ALIGN static const uint16_t swb_offset_480_24[] =
};
#endif
-ALIGN static const uint16_t swb_offset_128_24[] =
+ALIGN static const uint16_t swb_offset_128_24[] ICONST_ATTR =
{
0, 4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 64, 76, 92, 108, 128
};
-ALIGN static const uint16_t swb_offset_1024_16[] =
+ALIGN static const uint16_t swb_offset_1024_16[] ICONST_ATTR =
{
0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 100, 112, 124,
136, 148, 160, 172, 184, 196, 212, 228, 244, 260, 280, 300, 320, 344,
368, 396, 424, 456, 492, 532, 572, 616, 664, 716, 772, 832, 896, 960, 1024
};
-ALIGN static const uint16_t swb_offset_128_16[] =
+ALIGN static const uint16_t swb_offset_128_16[] ICONST_ATTR =
{
0, 4, 8, 12, 16, 20, 24, 28, 32, 40, 48, 60, 72, 88, 108, 128
};
-ALIGN static const uint16_t swb_offset_1024_8[] =
+ALIGN static const uint16_t swb_offset_1024_8[] ICONST_ATTR =
{
0, 12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 172,
188, 204, 220, 236, 252, 268, 288, 308, 328, 348, 372, 396, 420, 448,
476, 508, 544, 580, 620, 664, 712, 764, 820, 880, 944, 1024
};
-ALIGN static const uint16_t swb_offset_128_8[] =
+ALIGN static const uint16_t swb_offset_128_8[] ICONST_ATTR =
{
0, 4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 60, 72, 88, 108, 128
};
-ALIGN static const uint16_t *swb_offset_1024_window[] =
+ALIGN static const uint16_t *swb_offset_1024_window[] ICODE_ATTR =
{
swb_offset_1024_96, /* 96000 */
swb_offset_1024_96, /* 88200 */
@@ -266,7 +266,7 @@ ALIGN static const uint16_t *swb_offset_480_window[] =
};
#endif
-ALIGN static const uint16_t *swb_offset_128_window[] =
+ALIGN static const uint16_t *swb_offset_128_window[] ICODE_ATTR =
{
swb_offset_128_96, /* 96000 */
swb_offset_128_96, /* 88200 */
@@ -534,7 +534,7 @@ static uint8_t quant_to_spec(NeAACDecHandle hDecoder,
ic_stream *ics, int16_t *quant_data,
real_t *spec_data, uint16_t frame_len)
{
- ALIGN static const real_t pow2_table[] =
+ ALIGN static const real_t pow2_table[] ICONST_ATTR =
{
COEF_CONST(1.0),
COEF_CONST(1.1892071150027210667174999705605), /* 2^0.25 */
@@ -1049,8 +1049,8 @@ uint8_t reconstruct_channel_pair(NeAACDecHandle hDecoder, ic_stream *ics1, ic_st
element *cpe, int16_t *spec_data1, int16_t *spec_data2)
{
uint8_t retval;
- ALIGN static real_t spec_coef1[1024];
- ALIGN static real_t spec_coef2[1024];
+ ALIGN static real_t spec_coef1[1024] IBSS_ATTR;
+ ALIGN static real_t spec_coef2[1024] IBSS_ATTR;
#ifdef PROFILE
int64_t count = faad_get_ts();
diff --git a/apps/codecs/libfaad/syntax.c b/apps/codecs/libfaad/syntax.c
index 27f9b8a..77a2e88 100644
--- a/apps/codecs/libfaad/syntax.c
+++ b/apps/codecs/libfaad/syntax.c
@@ -559,7 +559,7 @@ void raw_data_block(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo,
/* Table 4.4.4 and */
/* Table 4.4.9 */
ALIGN int16_t spec_data[1024] = {0};
-element sce IBSS_ATTR;
+element sce;
static uint8_t single_lfe_channel_element(NeAACDecHandle hDecoder, bitfile *ld,
uint8_t channel, uint8_t *tag)
{
@@ -603,9 +603,9 @@ static uint8_t single_lfe_channel_element(NeAACDecHandle hDecoder, bitfile *ld,
}
/* Table 4.4.5 */
-ALIGN int16_t spec_data1[1024];
-ALIGN int16_t spec_data2[1024];
-element cpe IBSS_ATTR;
+ALIGN int16_t spec_data1[1024] IBSS_ATTR;
+ALIGN int16_t spec_data2[1024] IBSS_ATTR;
+element cpe;
static uint8_t channel_pair_element(NeAACDecHandle hDecoder, bitfile *ld,
uint8_t channels, uint8_t *tag)
{
@@ -833,6 +833,8 @@ static uint8_t ics_info(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld,
}
#endif
}
+#else
+ (void) common_window;
#endif
}
}
@@ -1166,8 +1168,8 @@ static void gain_control_data(bitfile *ld, ic_stream *ics)
#endif
#ifdef SCALABLE_DEC
-ALIGN int16_t spec_data1[1024] IBSS_ATTR;
-ALIGN int16_t spec_data2[1024] IBSS_ATTR;
+ALIGN int16_t spec_data1[1024];
+ALIGN int16_t spec_data2[1024];
/* Table 4.4.13 ASME */
void aac_scalable_main_element(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo,
bitfile *ld, program_config *pce, drc_info *drc)
@@ -1610,6 +1612,8 @@ static uint8_t section_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld
#ifdef ERROR_RESILIENCE
if (hDecoder->aacSectionDataResilienceFlag)
sect_cb_bits = 5;
+#else
+ (void) hDecoder;
#endif
ics->sect_cb[g][i] = (uint8_t)faad_getbits(ld, sect_cb_bits
@@ -1797,6 +1801,8 @@ static uint8_t scale_factor_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfil
#ifdef ERROR_RESILIENCE
if (!hDecoder->aacScalefactorDataResilienceFlag)
{
+#else
+ (void) hDecoder;
#endif
ret = decode_scale_factors(ics, ld);
#ifdef ERROR_RESILIENCE