Index: apps/codecs/libfaad/bits.c =================================================================== --- apps/codecs/libfaad/bits.c (revision 27165) +++ apps/codecs/libfaad/bits.c (working copy) @@ -33,9 +33,10 @@ #include "bits.h" /* Need to be large enough to fit the largest compressed sample in a file. - * Samples a little larger than 1 KB observed in a 256 kbps file. + * Samples were observed to need up to 1500 bytes (400 kbps nero aac). */ -uint8_t static_buffer[2048]; +#define BUFFER_SIZE 2048 +uint8_t static_buffer[BUFFER_SIZE] IBSS_ATTR; /* initialize buffer, call once before first getbits or showbits */ void faad_initbits(bitfile *ld, const void *_buffer, const uint32_t buffer_size) @@ -47,7 +48,7 @@ memset(ld, 0, sizeof(bitfile)); - if (buffer_size == 0 || _buffer == NULL) + if (buffer_size == 0 || _buffer == NULL || (buffer_size+12)>BUFFER_SIZE) { ld->error = 1; ld->no_more_reading = 1; Index: apps/codecs/libfaad/iq_table.h =================================================================== --- apps/codecs/libfaad/iq_table.h (revision 27165) +++ apps/codecs/libfaad/iq_table.h (working copy) @@ -8243,6 +8243,8 @@ #else +#define BIG_IQ_TABLE /* using BIG_IQ_TABLE creates faster code */ + #ifdef BIG_IQ_TABLE #define IQ_TABLE_SIZE 8192 #else Index: apps/codecs/libfaad/common.h =================================================================== --- apps/codecs/libfaad/common.h (revision 27165) +++ apps/codecs/libfaad/common.h (working copy) @@ -51,6 +51,25 @@ #define LOGF(...) #endif +#if (CONFIG_CPU == MCF5250) || defined(CPU_S5L870X) +/* Enough IRAM but performance suffers with ICODE_ATTR. */ +#define IBSS_ATTR_FAAD_LARGE_IRAM IBSS_ATTR +#define ICODE_ATTR_FAAD_LARGE_IRAM +#define ICONST_ATTR_FAAD_LARGE_IRAM ICONST_ATTR + +#elif (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) +/* Enough IRAM to move additional data and code to it. */ +#define IBSS_ATTR_FAAD_LARGE_IRAM IBSS_ATTR +#define ICODE_ATTR_FAAD_LARGE_IRAM ICODE_ATTR +#define ICONST_ATTR_FAAD_LARGE_IRAM ICONST_ATTR + +#else +/* Not enough IRAM available. */ +#define IBSS_ATTR_FAAD_LARGE_IRAM +#define ICODE_ATTR_FAAD_LARGE_IRAM +#define ICONST_ATTR_FAAD_LARGE_IRAM +#endif + #define INLINE __inline #if 0 //defined(_WIN32) && !defined(_WIN32_WCE) #define ALIGN __declspec(align(16)) Index: apps/codecs/aac.c =================================================================== --- apps/codecs/aac.c (revision 27165) +++ apps/codecs/aac.c (working copy) @@ -27,6 +27,11 @@ CODEC_HEADER +/* Global buffers to be used in the mdct synthesis. This way the arrays can + * be moved to IRAM for some targets */ +ALIGN real_t gb_time_buffer[2][1024] IBSS_ATTR_FAAD_LARGE_IRAM; +ALIGN real_t gb_fb_intermed[2][1024] IBSS_ATTR_FAAD_LARGE_IRAM; + /* this is the codec entry point */ enum codec_status codec_main(void) { @@ -105,6 +110,13 @@ err = CODEC_ERROR; goto done; } + + /* Set pointer to be able to use IRAM an to avoid alloc in decoder. Must + * be called after NeAACDecOpen(). */ + decoder->time_out[0] = &gb_time_buffer[0][0]; + decoder->time_out[1] = &gb_time_buffer[1][0]; + decoder->fb_intermed[0] = &gb_fb_intermed[0][0]; + decoder->fb_intermed[1] = &gb_fb_intermed[1][0]; ci->id3->frequency = s;