summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/codecs/aac.c35
-rw-r--r--apps/codecs/libfaad/bits.c10
-rw-r--r--apps/codecs/libfaad/bits.h2
-rw-r--r--apps/codecs/libfaad/common.c19
-rw-r--r--apps/codecs/libfaad/common.h15
-rw-r--r--apps/codecs/libfaad/decoder.c218
-rw-r--r--apps/codecs/libfaad/decoder.h9
-rw-r--r--apps/codecs/libfaad/drc.c10
-rw-r--r--apps/codecs/libfaad/drc.h1
-rw-r--r--apps/codecs/libfaad/drm_dec.c12
-rw-r--r--apps/codecs/libfaad/drm_dec.h1
-rw-r--r--apps/codecs/libfaad/filtbank.c11
-rw-r--r--apps/codecs/libfaad/ps_dec.c85
-rw-r--r--apps/codecs/libfaad/ps_dec.h1
-rw-r--r--apps/codecs/libfaad/sbr_dct.c2
-rw-r--r--apps/codecs/libfaad/sbr_dec.c177
-rw-r--r--apps/codecs/libfaad/sbr_dec.h19
-rw-r--r--apps/codecs/libfaad/sbr_e_nf.c4
-rw-r--r--apps/codecs/libfaad/sbr_hfgen.c3
-rw-r--r--apps/codecs/libfaad/sbr_hfgen.h3
-rw-r--r--apps/codecs/libfaad/sbr_qmf.c48
-rw-r--r--apps/codecs/libfaad/sbr_qmf.h5
-rw-r--r--apps/codecs/libfaad/specrec.c200
-rw-r--r--apps/codecs/libfaad/structs.h8
-rw-r--r--apps/codecs/libfaad/syntax.c16
-rw-r--r--apps/codecs/raac.c36
26 files changed, 262 insertions, 688 deletions
diff --git a/apps/codecs/aac.c b/apps/codecs/aac.c
index 6fd4e44000..5638dc49a9 100644
--- a/apps/codecs/aac.c
+++ b/apps/codecs/aac.c
@@ -32,12 +32,6 @@ CODEC_HEADER
* for each frame. */
#define FAAD_BYTE_BUFFER_SIZE (2048-12)
-/* Global buffers to be used in the mdct synthesis. This way the arrays can
- * be moved to IRAM for some targets */
-#define GB_BUF_SIZE 1024
-static real_t gb_time_buffer[2][GB_BUF_SIZE] IBSS_ATTR_FAAD_LARGE_IRAM MEM_ALIGN_ATTR;
-static real_t gb_fb_intermed[2][GB_BUF_SIZE] IBSS_ATTR_FAAD_LARGE_IRAM MEM_ALIGN_ATTR;
-
/* this is the codec entry point */
enum codec_status codec_main(void)
{
@@ -55,7 +49,6 @@ enum codec_status codec_main(void)
int file_offset;
int framelength;
int lead_trim = 0;
- int needed_bufsize;
unsigned int i;
unsigned char* buffer;
NeAACDecFrameInfo frame_info;
@@ -119,34 +112,6 @@ next_track:
err = CODEC_ERROR;
goto done;
}
-
- /* Set pointer to be able to use IRAM an to avoid alloc in decoder. Must
- * be called after NeAACDecOpen(). */
- /* A buffer of framelength or 2*frameLenght size must be allocated for
- * time_out. If frameLength is too big or SBR/forceUpSampling is active,
- * we do not use the IRAM buffer and keep faad's internal allocation (see
- * specrec.c). */
- needed_bufsize = decoder->frameLength;
-#ifdef SBR_DEC
- if ((decoder->sbr_present_flag == 1) || (decoder->forceUpSampling == 1))
- {
- needed_bufsize *= 2;
- }
-#endif
- if (needed_bufsize <= GB_BUF_SIZE)
- {
- decoder->time_out[0] = &gb_time_buffer[0][0];
- decoder->time_out[1] = &gb_time_buffer[1][0];
- }
- /* A buffer of with frameLength elements must be allocated for fb_intermed.
- * If frameLength is too big, we do not use the IRAM buffer and keep faad's
- * internal allocation (see specrec.c). */
- needed_bufsize = decoder->frameLength;
- if (needed_bufsize <= GB_BUF_SIZE)
- {
- decoder->fb_intermed[0] = &gb_fb_intermed[0][0];
- decoder->fb_intermed[1] = &gb_fb_intermed[1][0];
- }
#ifdef SBR_DEC
/* Check for need of special handling for seek/resume and elapsed time. */
diff --git a/apps/codecs/libfaad/bits.c b/apps/codecs/libfaad/bits.c
index 781eb4feaa..a3640077d8 100644
--- a/apps/codecs/libfaad/bits.c
+++ b/apps/codecs/libfaad/bits.c
@@ -36,7 +36,7 @@
* Samples were observed to need up to 1500 bytes (400 kbps nero aac).
*/
#define BUFFER_SIZE 2048
-uint8_t static_buffer[BUFFER_SIZE] IBSS_ATTR;
+static 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)
@@ -111,6 +111,7 @@ uint8_t faad_byte_align(bitfile *ld)
}
/* rewind to beginning */
+/* not used
void faad_rewindbits(bitfile *ld)
{
uint32_t tmp;
@@ -131,7 +132,9 @@ void faad_rewindbits(bitfile *ld)
ld->bytes_used = 0;
ld->no_more_reading = 0;
}
+*/
+#ifdef ERROR_RESILIENCE
uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits
DEBUGDEC)
{
@@ -139,7 +142,7 @@ uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits
uint8_t temp;
uint16_t bytes = (uint16_t)bits / 8;
uint8_t remainder = (uint8_t)bits % 8;
-
+
uint8_t *buffer = (uint8_t*)faad_malloc((bytes+1)*sizeof(uint8_t));
for (i = 0; i < bytes; i++)
@@ -156,6 +159,7 @@ uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits
return buffer;
}
+#endif
#ifdef DRM
/* return the original data buffer */
@@ -172,6 +176,7 @@ uint32_t faad_origbitbuffer_size(bitfile *ld)
#endif
/* reversed bit reading routines, used for RVLC and HCR */
+/* not used
void faad_initbits_rev(bitfile *ld, void *buffer,
uint32_t bits_in_buffer)
{
@@ -200,3 +205,4 @@ void faad_initbits_rev(bitfile *ld, void *buffer,
ld->no_more_reading = 0;
ld->error = 0;
}
+*/
diff --git a/apps/codecs/libfaad/bits.h b/apps/codecs/libfaad/bits.h
index c5540a07d0..f9417b8670 100644
--- a/apps/codecs/libfaad/bits.h
+++ b/apps/codecs/libfaad/bits.h
@@ -73,8 +73,10 @@ static uint32_t bitmask[] = {
void faad_initbits(bitfile *ld, const void *buffer, const uint32_t buffer_size);
void faad_endbits(bitfile *ld);
+/* not used
void faad_initbits_rev(bitfile *ld, void *buffer,
uint32_t bits_in_buffer);
+*/
uint8_t faad_byte_align(bitfile *ld);
uint32_t faad_get_processed_bits(bitfile *ld);
void faad_rewindbits(bitfile *ld);
diff --git a/apps/codecs/libfaad/common.c b/apps/codecs/libfaad/common.c
index a8b32d7d00..bedf56a212 100644
--- a/apps/codecs/libfaad/common.c
+++ b/apps/codecs/libfaad/common.c
@@ -169,25 +169,6 @@ int8_t can_decode_ot(const uint8_t object_type)
return -1;
}
-void *faad_malloc(size_t size)
-{
-#if 0 // defined(_WIN32) && !defined(_WIN32_WCE)
- return _aligned_malloc(size, 16);
-#else // #ifdef 0
- return malloc(size);
-#endif // #ifdef 0
-}
-
-/* common free function */
-void faad_free(void *b)
-{
-#if 0 // defined(_WIN32) && !defined(_WIN32_WCE)
- _aligned_free(b);
-#else
- free(b);
-}
-#endif
-
static const uint8_t Parity [256] = { // parity
0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,
1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,
diff --git a/apps/codecs/libfaad/common.h b/apps/codecs/libfaad/common.h
index 9179a6e21c..08f4c7ab53 100644
--- a/apps/codecs/libfaad/common.h
+++ b/apps/codecs/libfaad/common.h
@@ -56,30 +56,30 @@ extern struct codec_api* ci;
#define IBSS_ATTR_FAAD_LARGE_IRAM IBSS_ATTR
#define ICODE_ATTR_FAAD_LARGE_IRAM
#define ICONST_ATTR_FAAD_LARGE_IRAM ICONST_ATTR
-#define IBSS_ATTR_FAAD_XLARGE_IRAM
#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
-#define IBSS_ATTR_FAAD_XLARGE_IRAM
#elif defined(CPU_S5L870X)
/* Very large IRAM. Move even more data 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
-#define IBSS_ATTR_FAAD_XLARGE_IRAM IBSS_ATTR
+#define FAAD_HAVE_XLR_IN_IRAM
#else
/* Not enough IRAM available. */
#define IBSS_ATTR_FAAD_LARGE_IRAM
#define ICODE_ATTR_FAAD_LARGE_IRAM
#define ICONST_ATTR_FAAD_LARGE_IRAM
-#define IBSS_ATTR_FAAD_XLARGE_IRAM
#endif
+/* Used to allocate several SBR + PS arrays and variables statically. */
+//#define FAAD_STATIC_ALLOC
+
#define INLINE __inline
#if 0 //defined(_WIN32) && !defined(_WIN32_WCE)
#define ALIGN __declspec(align(16))
@@ -442,8 +442,11 @@ uint8_t max_tns_sfb(const uint8_t sr_index, const uint8_t object_type,
uint32_t get_sample_rate(const uint8_t sr_index);
int8_t can_decode_ot(const uint8_t object_type);
-void *faad_malloc(size_t size);
-void faad_free(void *b);
+#ifndef FAAD_STATIC_ALLOC
+/* Those should not be defined or used anymore */
+#define faad_malloc(A) malloc(A)
+#define faad_free(A) free(A)
+#endif
//#define PROFILE
#ifdef PROFILE
diff --git a/apps/codecs/libfaad/decoder.c b/apps/codecs/libfaad/decoder.c
index eb810de59e..c374ad3284 100644
--- a/apps/codecs/libfaad/decoder.c
+++ b/apps/codecs/libfaad/decoder.c
@@ -48,14 +48,35 @@
#include "ssr.h"
#endif
+/* Globals */
#ifdef ANALYSIS
uint16_t dbg_count;
#endif
+/* static variables */
+static NeAACDecStruct s_AACDec;
+static real_t s_fb_intermed [MAX_CHANNELS][1*FRAME_LEN] IBSS_ATTR_FAAD_LARGE_IRAM MEM_ALIGN_ATTR;
+static real_t s_time_buf_1024[MAX_CHANNELS][1*FRAME_LEN] IBSS_ATTR_FAAD_LARGE_IRAM MEM_ALIGN_ATTR;
+#ifdef SBR_DEC
+#ifdef FAAD_STATIC_ALLOC
+static real_t s_time_buf_2048[MAX_CHANNELS][2*FRAME_LEN] MEM_ALIGN_ATTR;
+#endif
+#endif
+#ifdef SSR_DEC
+static real_t s_ssr_overlap [MAX_CHANNELS][2*FRAME_LEN] MEM_ALIGN_ATTR;
+static real_t s_prev_fmd [MAX_CHANNELS][2*FRAME_LEN] MEM_ALIGN_ATTR;
+#endif
+#ifdef MAIN_DEC
+static pred_state s_pred_stat[MAX_CHANNELS][1*FRAME_LEN] MEM_ALIGN_ATTR;
+#endif
+#ifdef LTP_DEC
+static int16_t s_lt_pred_stat[MAX_CHANNELS][4*FRAME_LEN] MEM_ALIGN_ATTR;
+#endif
+
+
/* static function declarations */
static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo,
- uint8_t *buffer, uint32_t buffer_size,
- void **sample_buffer, int32_t sample_buffer_size);
+ uint8_t *buffer, uint32_t buffer_size);
static void create_channel_config(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo);
@@ -101,14 +122,21 @@ NeAACDecHandle NEAACDECAPI NeAACDecOpen(void)
coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE);
#endif
- if ((hDecoder = (NeAACDecHandle)faad_malloc(sizeof(NeAACDecStruct))) == NULL)
- return NULL;
+ hDecoder = &s_AACDec;
- memset(hDecoder, 0, sizeof(NeAACDecStruct));
+ memset(hDecoder , 0, sizeof(NeAACDecStruct));
+ memset(s_fb_intermed, 0, sizeof(s_fb_intermed));
+#ifdef SSR_DEC
+ memset(s_ssr_overlap, 0, sizeof(s_ssr_overlap));
+ memset(s_prev_fmd , 0, sizeof(s_prev_fmd));
+#endif
+#ifdef LTP_DEC
+ memset(s_lt_pred_stat, 0, sizeof(s_s_lt_pred_statpred_stat));
+#endif
hDecoder->config.outputFormat = FAAD_FMT_16BIT;
hDecoder->config.defObjectType = MAIN;
- hDecoder->config.defSampleRate = 44100; /* Default: 44.1kHz */
+ hDecoder->config.defSampleRate = 44100;
hDecoder->config.downMatrix = 0;
hDecoder->adts_header_present = 0;
hDecoder->adif_header_present = 0;
@@ -117,26 +145,28 @@ NeAACDecHandle NEAACDECAPI NeAACDecOpen(void)
hDecoder->aacScalefactorDataResilienceFlag = 0;
hDecoder->aacSpectralDataResilienceFlag = 0;
#endif
- hDecoder->frameLength = 1024;
+ hDecoder->frameLength = FRAME_LEN;
hDecoder->frame = 0;
- hDecoder->sample_buffer = NULL;
for (i = 0; i < MAX_CHANNELS; i++)
{
hDecoder->window_shape_prev[i] = 0;
hDecoder->time_out[i] = NULL;
- hDecoder->fb_intermed[i] = NULL;
+ hDecoder->fb_intermed[i] = s_fb_intermed[i];
#ifdef SSR_DEC
- hDecoder->ssr_overlap[i] = NULL;
- hDecoder->prev_fmd[i] = NULL;
+ hDecoder->ssr_overlap[i] = s_ssr_overlap[i];
+ hDecoder->prev_fmd[i] = s_prev_fmd[i];
+ for (int k = 0; k < 2048; k++)
+ hDecoder->prev_fmd[i][k] = REAL_CONST(-1);
#endif
#ifdef MAIN_DEC
- hDecoder->pred_stat[i] = NULL;
+ hDecoder->pred_stat[i] = s_pred_stat[i];
+ reset_all_predictors(hDecoder->pred_stat[channel], FRAME_LEN);
#endif
#ifdef LTP_DEC
hDecoder->ltp_lag[i] = 0;
- hDecoder->lt_pred_stat[i] = NULL;
+ hDecoder->lt_pred_stat[i] = s_lt_pred_stat[i];
#endif
}
@@ -204,6 +234,7 @@ int32_t NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder, uint8_t *buffer,
uint32_t buffer_size,
uint32_t *samplerate, uint8_t *channels)
{
+ uint32_t i;
uint32_t bits = 0;
bitfile ld;
adif_header adif;
@@ -298,6 +329,28 @@ int32_t NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder, uint8_t *buffer,
hDecoder->frameLength >>= 1;
#endif
+ for (i=0; i<MAX_CHANNELS; ++i)
+ {
+#ifdef SBR_DEC
+ hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 0;
+ if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))
+ {
+#ifdef FAAD_STATIC_ALLOC
+ hDecoder->time_out[i] = s_time_buf_2048[i];
+#else
+ hDecoder->time_out[i] = (real_t*)faad_malloc(2*FRAME_LEN*sizeof(real_t));
+#endif
+ memset(hDecoder->time_out[i], 0, 2*FRAME_LEN);
+ hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1;
+ }
+ else
+#endif
+ {
+ hDecoder->time_out[i] = s_time_buf_1024[i];
+ memset(hDecoder->time_out[i], 0, 1*FRAME_LEN);
+ }
+ }
+
if (can_decode_ot(hDecoder->object_type) < 0)
return -1;
@@ -310,6 +363,7 @@ int8_t NEAACDECAPI NeAACDecInit2(NeAACDecHandle hDecoder, uint8_t *pBuffer,
uint32_t *samplerate, uint8_t *channels)
{
int8_t rc;
+ uint32_t i;
mp4AudioSpecificConfig mp4ASC;
if((hDecoder == NULL)
@@ -391,6 +445,28 @@ int8_t NEAACDECAPI NeAACDecInit2(NeAACDecHandle hDecoder, uint8_t *pBuffer,
hDecoder->frameLength >>= 1;
#endif
+ for (i=0; i<MAX_CHANNELS; ++i)
+ {
+#ifdef SBR_DEC
+ hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 0;
+ if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))
+ {
+#ifdef FAAD_STATIC_ALLOC
+ hDecoder->time_out[i] = s_time_buf_2048[i];
+#else
+ hDecoder->time_out[i] = (real_t*)faad_malloc(2*FRAME_LEN*sizeof(real_t));
+#endif
+ memset(hDecoder->time_out[i], 0, 2*FRAME_LEN);
+ hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1;
+ }
+ else
+#endif
+ {
+ hDecoder->time_out[i] = s_time_buf_1024[i];
+ memset(hDecoder->time_out[i], 0, 1*FRAME_LEN);
+ }
+ }
+
return 0;
}
@@ -401,8 +477,6 @@ int8_t NEAACDECAPI NeAACDecInitDRM(NeAACDecHandle *hDecoder, uint32_t samplerate
if (hDecoder == NULL)
return 1; /* error */
- NeAACDecClose(*hDecoder);
-
*hDecoder = NeAACDecOpen();
/* Special object type defined for DRM */
@@ -435,59 +509,6 @@ int8_t NEAACDECAPI NeAACDecInitDRM(NeAACDecHandle *hDecoder, uint32_t samplerate
}
#endif
-void NEAACDECAPI NeAACDecClose(NeAACDecHandle hDecoder)
-{
- uint8_t i;
-
- if (hDecoder == NULL)
- return;
-
-#ifdef PROFILE
- printf("AAC decoder total: %I64d cycles\n", hDecoder->cycles);
- printf("requant: %I64d cycles\n", hDecoder->requant_cycles);
- printf("spectral_data: %I64d cycles\n", hDecoder->spectral_cycles);
- printf("scalefactors: %I64d cycles\n", hDecoder->scalefac_cycles);
- printf("output: %I64d cycles\n", hDecoder->output_cycles);
-#endif
-
- for (i = 0; i < MAX_CHANNELS; i++)
- {
- if (hDecoder->time_out[i]) faad_free(hDecoder->time_out[i]);
- if (hDecoder->fb_intermed[i]) faad_free(hDecoder->fb_intermed[i]);
-#ifdef SSR_DEC
- if (hDecoder->ssr_overlap[i]) faad_free(hDecoder->ssr_overlap[i]);
- if (hDecoder->prev_fmd[i]) faad_free(hDecoder->prev_fmd[i]);
-#endif
-#ifdef MAIN_DEC
- if (hDecoder->pred_stat[i]) faad_free(hDecoder->pred_stat[i]);
-#endif
-#ifdef LTP_DEC
- if (hDecoder->lt_pred_stat[i]) faad_free(hDecoder->lt_pred_stat[i]);
-#endif
- }
-
-#ifdef SSR_DEC
- if (hDecoder->object_type == SSR)
- ssr_filter_bank_end(hDecoder->fb);
- else
-#endif
-
-
- drc_end(hDecoder->drc);
-
- if (hDecoder->sample_buffer) faad_free(hDecoder->sample_buffer);
-
-#ifdef SBR_DEC
- for (i = 0; i < MAX_SYNTAX_ELEMENTS; i++)
- {
- if (hDecoder->sbr[i])
- sbrDecodeEnd(hDecoder->sbr[i]);
- }
-#endif
-
- if (hDecoder) faad_free(hDecoder);
-}
-
void NEAACDECAPI NeAACDecPostSeekReset(NeAACDecHandle hDecoder, int32_t frame)
{
if (hDecoder)
@@ -708,34 +729,17 @@ void* NEAACDECAPI NeAACDecDecode(NeAACDecHandle hDecoder,
NeAACDecFrameInfo *hInfo,
uint8_t *buffer, uint32_t buffer_size)
{
- return aac_frame_decode(hDecoder, hInfo, buffer, buffer_size, NULL, 0);
-}
-
-void* NEAACDECAPI NeAACDecDecode2(NeAACDecHandle hDecoder,
- NeAACDecFrameInfo *hInfo,
- uint8_t *buffer, uint32_t buffer_size,
- void **sample_buffer, uint32_t sample_buffer_size)
-{
- if ((sample_buffer == NULL) || (sample_buffer_size == 0))
- {
- hInfo->error = 27;
- return NULL;
- }
-
- return aac_frame_decode(hDecoder, hInfo, buffer, buffer_size,
- sample_buffer, sample_buffer_size);
+ return aac_frame_decode(hDecoder, hInfo, buffer, buffer_size);
}
static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo,
- uint8_t *buffer, uint32_t buffer_size,
- void **sample_buffer2, int32_t sample_buffer_size)
+ uint8_t *buffer, uint32_t buffer_size)
{
uint8_t channels = 0;
uint8_t output_channels = 0;
bitfile ld;
uint32_t bitsconsumed;
uint16_t frame_len;
- void *sample_buffer;
#ifdef PROFILE
int64_t count = faad_get_ts();
@@ -908,42 +912,11 @@ static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo,
}
/* allocate the buffer for the final samples */
- if ((hDecoder->sample_buffer == NULL) ||
- (hDecoder->alloced_channels != output_channels))
+ if (hDecoder->alloced_channels != output_channels)
{
- static const uint8_t str[] = { sizeof(int16_t), sizeof(int32_t), sizeof(int32_t),
- sizeof(float32_t), sizeof(double), sizeof(int16_t), sizeof(int16_t),
- sizeof(int16_t), sizeof(int16_t), 0, 0, 0
- };
- uint8_t stride = str[hDecoder->config.outputFormat-1];
-#ifdef SBR_DEC
- if (((hDecoder->sbr_present_flag == 1)&&(!hDecoder->downSampledSBR)) || (hDecoder->forceUpSampling == 1))
- {
- stride = 2 * stride;
- }
-#endif
- /* check if we want to use internal sample_buffer */
- if (sample_buffer_size == 0)
- {
- if (hDecoder->sample_buffer)
- faad_free(hDecoder->sample_buffer);
- hDecoder->sample_buffer = NULL;
- hDecoder->sample_buffer = faad_malloc(frame_len*output_channels*stride);
- } else if (sample_buffer_size < frame_len*output_channels*stride) {
- /* provided sample buffer is not big enough */
- hInfo->error = 27;
- return NULL;
- }
hDecoder->alloced_channels = output_channels;
}
- if (sample_buffer_size == 0)
- {
- sample_buffer = hDecoder->sample_buffer;
- } else {
- sample_buffer = *sample_buffer2;
- }
-
#ifdef SBR_DEC
if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))
{
@@ -982,11 +955,6 @@ static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo,
}
#endif
- /* we don't need sample conversion in rockbox.
- sample_buffer = output_to_PCM(hDecoder, hDecoder->time_out, sample_buffer,
- output_channels, frame_len, hDecoder->config.outputFormat);
- */
-
hDecoder->postSeekResetFlag = 0;
hDecoder->frame++;
@@ -1014,7 +982,7 @@ static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo,
hDecoder->cycles += count;
#endif
- return sample_buffer;
+ return hDecoder; /* return void* != NULL */
error:
diff --git a/apps/codecs/libfaad/decoder.h b/apps/codecs/libfaad/decoder.h
index 2b2eb8bc0c..f5c477e186 100644
--- a/apps/codecs/libfaad/decoder.h
+++ b/apps/codecs/libfaad/decoder.h
@@ -72,8 +72,6 @@ extern "C" {
char* NEAACDECAPI NeAACDecGetErrorMessage(uint8_t errcode);
-uint32_t NEAACDECAPI NeAACDecGetCapabilities(void);
-
NeAACDecHandle NEAACDECAPI NeAACDecOpen(void);
NeAACDecConfigurationPtr NEAACDECAPI NeAACDecGetCurrentConfiguration(NeAACDecHandle hDecoder);
@@ -97,8 +95,6 @@ int8_t NEAACDECAPI NeAACDecInit2(NeAACDecHandle hDecoder, uint8_t *pBuffer,
int8_t NEAACDECAPI NeAACDecInitDRM(NeAACDecHandle *hDecoder, uint32_t samplerate,
uint8_t channels);
-void NEAACDECAPI NeAACDecClose(NeAACDecHandle hDecoder);
-
void NEAACDECAPI NeAACDecPostSeekReset(NeAACDecHandle hDecoder, int32_t frame);
void* NEAACDECAPI NeAACDecDecode(NeAACDecHandle hDecoder,
@@ -106,11 +102,6 @@ void* NEAACDECAPI NeAACDecDecode(NeAACDecHandle hDecoder,
uint8_t *buffer,
uint32_t buffer_size);
-void* NEAACDECAPI NeAACDecDecode2(NeAACDecHandle hDecoder,
- NeAACDecFrameInfo *hInfo,
- uint8_t *buffer, uint32_t buffer_size,
- void **sample_buffer, uint32_t sample_buffer_size);
-
#ifdef _WIN32
#pragma pack(pop)
#endif
diff --git a/apps/codecs/libfaad/drc.c b/apps/codecs/libfaad/drc.c
index 7530d2d053..6e081489aa 100644
--- a/apps/codecs/libfaad/drc.c
+++ b/apps/codecs/libfaad/drc.c
@@ -33,9 +33,12 @@
#include "syntax.h"
#include "drc.h"
+/* static variables */
+static drc_info s_drc_info;
+
drc_info *drc_init(real_t cut, real_t boost)
{
- drc_info *drc = (drc_info*)faad_malloc(sizeof(drc_info));
+ drc_info *drc = &s_drc_info;
memset(drc, 0, sizeof(drc_info));
drc->ctrl1 = cut;
@@ -49,11 +52,6 @@ drc_info *drc_init(real_t cut, real_t boost)
return drc;
}
-void drc_end(drc_info *drc)
-{
- if (drc) faad_free(drc);
-}
-
#ifdef FIXED_POINT
static real_t drc_pow2_table[] =
{
diff --git a/apps/codecs/libfaad/drc.h b/apps/codecs/libfaad/drc.h
index 31d3db67ae..38037a1a12 100644
--- a/apps/codecs/libfaad/drc.h
+++ b/apps/codecs/libfaad/drc.h
@@ -36,7 +36,6 @@ extern "C" {
drc_info *drc_init(real_t cut, real_t boost);
-void drc_end(drc_info *drc);
void drc_decode(drc_info *drc, real_t *spec);
diff --git a/apps/codecs/libfaad/drm_dec.c b/apps/codecs/libfaad/drm_dec.c
index 0cf40df23b..f0b0f01f2b 100644
--- a/apps/codecs/libfaad/drm_dec.c
+++ b/apps/codecs/libfaad/drm_dec.c
@@ -41,7 +41,7 @@
#define DECAY_CUTOFF 3
#define DECAY_SLOPE 0.05f
-/* type definitaions */
+/* type definitions */
typedef const int8_t (*drm_ps_huff_tab)[2];
@@ -445,6 +445,8 @@ static const complex_t Phi_Fract_Qmf[] = {
{ FRAC_CONST(-0.7396311164), FRAC_CONST(0.6730124950) }
};
+/* static variables */
+static drm_ps_info s_drm_ps_info;
/* static function declarations */
static void drm_ps_sa_element(drm_ps_info *ps, bitfile *ld);
@@ -915,18 +917,12 @@ static void drm_add_pan(drm_ps_info *ps, uint8_t rateselect,
drm_ps_info *drm_ps_init(void)
{
- drm_ps_info *ps = (drm_ps_info*)faad_malloc(sizeof(drm_ps_info));
-
+ drm_ps_info *ps = &s_drm_ps_info;
memset(ps, 0, sizeof(drm_ps_info));
return ps;
}
-void drm_ps_free(drm_ps_info *ps)
-{
- faad_free(ps);
-}
-
/* main DRM PS decoding function */
uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, uint32_t samplerate,
qmf_t X_left[MAX_NTSRPS][64],
diff --git a/apps/codecs/libfaad/drm_dec.h b/apps/codecs/libfaad/drm_dec.h
index 34923c6431..d7ae9d0166 100644
--- a/apps/codecs/libfaad/drm_dec.h
+++ b/apps/codecs/libfaad/drm_dec.h
@@ -86,7 +86,6 @@ typedef struct
uint16_t drm_ps_data(drm_ps_info *ps, bitfile *ld);
drm_ps_info *drm_ps_init(void);
-void drm_ps_free(drm_ps_info *ps);
uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, uint32_t samplerate,
qmf_t X_left[MAX_NTSRPS][64],
diff --git a/apps/codecs/libfaad/filtbank.c b/apps/codecs/libfaad/filtbank.c
index 906af9e1a9..fd7a4dc91f 100644
--- a/apps/codecs/libfaad/filtbank.c
+++ b/apps/codecs/libfaad/filtbank.c
@@ -43,8 +43,14 @@
#include "sine_win.h"
-/*Windowing functions borrowed from libwmai*/
+/* static variables */
+static real_t transf_buf[2*FRAME_LEN] IBSS_ATTR MEM_ALIGN_ATTR;
+#ifdef LTP_DEC
+static real_t windowed_buf[2*FRAME_LEN] MEM_ALIGN_ATTR = {0};
+#endif
+
+/*Windowing functions borrowed from libwmai*/
#ifdef CPU_ARM
static inline
void vector_fmul_add_add(real_t *dst, const real_t *src0, const real_t *src1, const real_t *src2, int len)
@@ -196,8 +202,6 @@ static INLINE void mdct(fb_info *fb, real_t *in_data, real_t *out_data, uint16_t
}
#endif
-real_t transf_buf[2*1024] IBSS_ATTR MEM_ALIGN_ATTR;
-
void ifilter_bank(uint8_t window_sequence, uint8_t window_shape,
uint8_t window_shape_prev, real_t *freq_in,
real_t *time_out, real_t *overlap,
@@ -403,7 +407,6 @@ void ifilter_bank(uint8_t window_sequence, uint8_t window_shape,
#ifdef LTP_DEC
-real_t windowed_buf[2*1024] MEM_ALIGN_ATTR = {0};
/* only works for LTP -> no overlapping, no short blocks */
void filter_bank_ltp(fb_info *fb, uint8_t window_sequence, uint8_t window_shape,
uint8_t window_shape_prev, real_t *in_data, real_t *out_mdct,
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
uint8_t resolution20[3];
uint8_t resolution34[5];
- qmf_t *work;
- qmf_t **buffer;
- qmf_t **temp;
+ qmf_t work[32+12];
+ qmf_t buffer[5][32];
+ qmf_t temp[32][12];
} hyb_info;
+
+/* static variables */
+#ifdef FAAD_STATIC_ALLOC
+static hyb_info s_hyb_info;
+static ps_info s_ps_info;
+#endif
+
/* static function declarations */
static void ps_data_decode(ps_info *ps);
static hyb_info *hybrid_init(void);
static void channel_filter2(hyb_info *hyb, uint8_t frame_len, const real_t *filter,
- qmf_t *buffer, qmf_t **X_hybrid);
+ qmf_t *buffer, qmf_t X_hybrid[32][12]);
static INLINE void DCT3_4_unscaled(real_t *y, real_t *x);
static void channel_filter8(hyb_info *hyb, uint8_t frame_len, const real_t *filter,
- qmf_t *buffer, qmf_t **X_hybrid);
+ qmf_t *buffer, qmf_t X_hybrid[32][12]);
static void hybrid_analysis(hyb_info *hyb, qmf_t X[32][64], qmf_t X_hybrid[32][32],
uint8_t use34);
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,
static hyb_info *hybrid_init()
{
- uint8_t i;
-
+#ifdef FAAD_STATIC_ALLOC
+ hyb_info *hyb = &s_hyb_info;
+#else
hyb_info *hyb = (hyb_info*)faad_malloc(sizeof(hyb_info));
+#endif
hyb->resolution34[0] = 12;
hyb->resolution34[1] = 8;
@@ -213,52 +222,16 @@ static hyb_info *hybrid_init()
hyb->frame_len = 32;
- hyb->work = (qmf_t*)faad_malloc((hyb->frame_len+12) * sizeof(qmf_t));
- memset(hyb->work, 0, (hyb->frame_len+12) * sizeof(qmf_t));
-
- hyb->buffer = (qmf_t**)faad_malloc(5 * sizeof(qmf_t*));
- for (i = 0; i < 5; i++)
- {
- hyb->buffer[i] = (qmf_t*)faad_malloc(hyb->frame_len * sizeof(qmf_t));
- memset(hyb->buffer[i], 0, hyb->frame_len * sizeof(qmf_t));
- }
-
- hyb->temp = (qmf_t**)faad_malloc(hyb->frame_len * sizeof(qmf_t*));
- for (i = 0; i < hyb->frame_len; i++)
- {
- hyb->temp[i] = (qmf_t*)faad_malloc(12 /*max*/ * sizeof(qmf_t));
- }
+ memset(hyb->work , 0, sizeof(hyb->work));
+ memset(hyb->buffer, 0, sizeof(hyb->buffer));
+ memset(hyb->temp , 0, sizeof(hyb->temp));
return hyb;
}
-static void hybrid_free(hyb_info *hyb)
-{
- uint8_t i;
-
- if (hyb->work)
- faad_free(hyb->work);
-
- for (i = 0; i < 5; i++)
- {
- if (hyb->buffer[i])
- faad_free(hyb->buffer[i]);
- }
- if (hyb->buffer)
- faad_free(hyb->buffer);
-
- for (i = 0; i < hyb->frame_len; i++)
- {
- if (hyb->temp[i])
- faad_free(hyb->temp[i]);
- }
- if (hyb->temp)
- faad_free(hyb->temp);
-}
-
/* real filter, size 2 */
static void channel_filter2(hyb_info *hyb, uint8_t frame_len, const real_t *filter,
- qmf_t *buffer, qmf_t **X_hybrid)
+ qmf_t *buffer, qmf_t X_hybrid[32][12])
{
uint8_t i;
@@ -292,7 +265,7 @@ static void channel_filter2(hyb_info *hyb, uint8_t frame_len, const real_t *filt
/* complex filter, size 4 */
static void channel_filter4(hyb_info *hyb, uint8_t frame_len, const real_t *filter,
- qmf_t *buffer, qmf_t **X_hybrid)
+ qmf_t *buffer, qmf_t X_hybrid[32][12])
{
uint8_t i;
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)
/* complex filter, size 8 */
static void channel_filter8(hyb_info *hyb, uint8_t frame_len, const real_t *filter,
- qmf_t *buffer, qmf_t **X_hybrid)
+ qmf_t *buffer, qmf_t X_hybrid[32][12])
{
uint8_t i, n;
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)
/* complex filter, size 12 */
static void channel_filter12(hyb_info *hyb, uint8_t frame_len, const real_t *filter,
- qmf_t *buffer, qmf_t **X_hybrid)
+ qmf_t *buffer, qmf_t X_hybrid[32][12])
{
uint8_t i, n;
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,
}
}
-void ps_free(ps_info *ps)
-{
- /* free hybrid filterbank structures */
- hybrid_free(ps->hyb);
-
- faad_free(ps);
-}
-
ps_info *ps_init(uint8_t sr_index)
{
uint8_t i;
uint8_t short_delay_band;
+#ifdef FAAD_STATIC_ALLOC
+ ps_info *ps = &s_ps_info;
+#else
ps_info *ps = (ps_info*)faad_malloc(sizeof(ps_info));
+#endif
memset(ps, 0, sizeof(ps_info));
(void)sr_index;
diff --git a/apps/codecs/libfaad/ps_dec.h b/apps/codecs/libfaad/ps_dec.h
index 03cefd6fcd..9c51e6b4ad 100644
--- a/apps/codecs/libfaad/ps_dec.h
+++ b/apps/codecs/libfaad/ps_dec.h
@@ -138,7 +138,6 @@ uint16_t ps_data(ps_info *ps, bitfile *ld, uint8_t *header);
/* ps_dec.c */
ps_info *ps_init(uint8_t sr_index);
-void ps_free(ps_info *ps);
uint8_t ps_decode(ps_info *ps,
qmf_t X_left[MAX_NTSRPS][64],
diff --git a/apps/codecs/libfaad/sbr_dct.c b/apps/codecs/libfaad/sbr_dct.c
index da0e5e1f59..e9c56c3a18 100644
--- a/apps/codecs/libfaad/sbr_dct.c
+++ b/apps/codecs/libfaad/sbr_dct.c
@@ -1525,7 +1525,7 @@ static const real_t dct4_post_tab[] ICONST_ATTR MEM_ALIGN_ATTR = {
};
// Table adapted from codeclib to fit into IRAM
-const uint32_t dct4_revtab[32] ICONST_ATTR MEM_ALIGN_ATTR = {
+static const uint32_t dct4_revtab[32] ICONST_ATTR MEM_ALIGN_ATTR = {
0, 24, 12, 22, 6, 30, 11, 19, 3, 27, 15, 21, 5, 29, 9, 17,
1, 25, 13, 23, 7, 31, 10, 18, 2, 26, 14, 20, 4, 28, 8, 16};
diff --git a/apps/codecs/libfaad/sbr_dec.c b/apps/codecs/libfaad/sbr_dec.c
index c460be0c02..7f6a9bbffe 100644
--- a/apps/codecs/libfaad/sbr_dec.c
+++ b/apps/codecs/libfaad/sbr_dec.c
@@ -41,34 +41,63 @@
#include "sbr_hfgen.h"
#include "sbr_hfadj.h"
-
-/* globals */
+/* type definitons */
+typedef struct {
#if (defined(PS_DEC) || defined(DRM_PS))
-/* In case of PS_DEC or DRM_PS we need larger buffer data when calling
- * ps_decode() or drm_ps_decode(). */
-static qmf_t X_left [MAX_NTSRPS][64] IBSS_ATTR_FAAD_XLARGE_IRAM MEM_ALIGN_ATTR;
-static qmf_t X_right[MAX_NTSRPS][64] IBSS_ATTR_FAAD_XLARGE_IRAM MEM_ALIGN_ATTR;
+ /* In case of PS_DEC or DRM_PS we need larger buffer data when calling
+ * ps_decode() or drm_ps_decode(). */
+ qmf_t X_L[MAX_NTSRPS][64];
+ qmf_t X_R[MAX_NTSRPS][64];
#else
-/* No PS functions called. Keep using MAX_NTSR as array size. */
-static qmf_t X_left [MAX_NTSR][64] IBSS_ATTR_FAAD_XLARGE_IRAM MEM_ALIGN_ATTR;
-static qmf_t X_right[MAX_NTSR][64] IBSS_ATTR_FAAD_XLARGE_IRAM MEM_ALIGN_ATTR;
+ /* No PS functions called. Keep using MAX_NTSR as array size. */
+ qmf_t X_L[MAX_NTSR][64];
+ qmf_t X_R[MAX_NTSR][64];
#endif
+} XLR_t;
+/* static variables */
+static XLR_t *p_XLR = NULL;
+#if defined(FAAD_STATIC_ALLOC) || defined(FAAD_HAVE_XLR_IN_IRAM)
+static XLR_t s_XLR IBSS_ATTR MEM_ALIGN_ATTR;
+#endif
+#if defined(FAAD_STATIC_ALLOC)
+static sbr_info s_sbr[MAX_SYNTAX_ELEMENTS];
+#endif
+#ifdef SBR_LOW_POWER
+static real_t deg[64] MEM_ALIGN_ATTR;
+#endif
/* static function declarations */
static uint8_t sbr_save_prev_data(sbr_info *sbr, uint8_t ch);
static void sbr_save_matrix(sbr_info *sbr, uint8_t ch);
-sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac,
+sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac, uint8_t id_ele,
uint32_t sample_rate, uint8_t downSampledSBR
#ifdef DRM
, uint8_t IsDRM
#endif
)
{
- sbr_info *sbr = faad_malloc(sizeof(sbr_info));
+ (void)downSampledSBR;
+
+ /* Allocate sbr_info. */
+#if defined(FAAD_STATIC_ALLOC)
+ sbr_info *sbr = &s_sbr[id_ele];
+#else
+ (void)id_ele;
+ sbr_info *sbr =(sbr_info*)faad_malloc(sizeof(sbr_info));
+#endif
memset(sbr, 0, sizeof(sbr_info));
+
+ /* Allocate XLR temporary variable. Use static allocation if either
+ * FAAD_STATIC_ALLOC is set or XLR fits to IRAM. */
+#if defined(FAAD_STATIC_ALLOC) || defined(FAAD_HAVE_XLR_IN_IRAM)
+ p_XLR = &s_XLR;
+#else
+ p_XLR =(XLR_t*)faad_malloc(sizeof(XLR_t));
+#endif
+ memset(p_XLR, 0, sizeof(XLR_t));
/* save id of the parent element */
sbr->id_aac = id_aac;
@@ -115,80 +144,15 @@ sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac,
sbr->GQ_ringbuf_index[0] = 0;
sbr->GQ_ringbuf_index[1] = 0;
- if (id_aac == ID_CPE)
- {
- /* stereo */
- uint8_t j;
- sbr->qmfa[0] = qmfa_init(32);
- sbr->qmfa[1] = qmfa_init(32);
- sbr->qmfs[0] = qmfs_init((downSampledSBR)?32:64);
- sbr->qmfs[1] = qmfs_init((downSampledSBR)?32:64);
-
- for (j = 0; j < 5; j++)
- {
- sbr->G_temp_prev[0][j] = faad_malloc(64*sizeof(real_t));
- sbr->G_temp_prev[1][j] = faad_malloc(64*sizeof(real_t));
- sbr->Q_temp_prev[0][j] = faad_malloc(64*sizeof(real_t));
- sbr->Q_temp_prev[1][j] = faad_malloc(64*sizeof(real_t));
- }
+ memset(sbr->qmfa, 0, 2*sizeof(qmfa_info));
+ memset(sbr->qmfs, 0, 2*sizeof(qmfs_info));
- memset(sbr->Xsbr[0], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t));
- memset(sbr->Xsbr[1], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t));
- } else {
- /* mono */
- uint8_t j;
- sbr->qmfa[0] = qmfa_init(32);
- sbr->qmfs[0] = qmfs_init((downSampledSBR)?32:64);
- sbr->qmfs[1] = NULL;
-
- for (j = 0; j < 5; j++)
- {
- sbr->G_temp_prev[0][j] = faad_malloc(64*sizeof(real_t));
- sbr->Q_temp_prev[0][j] = faad_malloc(64*sizeof(real_t));
- }
-
- memset(sbr->Xsbr[0], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t));
- }
+ memset(sbr->Xsbr[0], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t));
+ memset(sbr->Xsbr[1], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t));
return sbr;
}
-void sbrDecodeEnd(sbr_info *sbr)
-{
- uint8_t j;
-
- if (sbr)
- {
- qmfa_end(sbr->qmfa[0]);
- qmfs_end(sbr->qmfs[0]);
- if (sbr->qmfs[1] != NULL)
- {
- qmfa_end(sbr->qmfa[1]);
- qmfs_end(sbr->qmfs[1]);
- }
-
- for (j = 0; j < 5; j++)
- {
- if (sbr->G_temp_prev[0][j]) faad_free(sbr->G_temp_prev[0][j]);
- if (sbr->Q_temp_prev[0][j]) faad_free(sbr->Q_temp_prev[0][j]);
- if (sbr->G_temp_prev[1][j]) faad_free(sbr->G_temp_prev[1][j]);
- if (sbr->Q_temp_prev[1][j]) faad_free(sbr->Q_temp_prev[1][j]);
- }
-
-#ifdef PS_DEC
- if (sbr->ps != NULL)
- ps_free(sbr->ps);
-#endif
-
-#ifdef DRM_PS
- if (sbr->drm_ps != NULL)
- drm_ps_free(sbr->drm_ps);
-#endif
-
- faad_free(sbr);
- }
-}
-
static uint8_t sbr_save_prev_data(sbr_info *sbr, uint8_t ch)
{
uint8_t i;
@@ -239,10 +203,6 @@ static void sbr_save_matrix(sbr_info *sbr, uint8_t ch)
}
}
-#ifdef SBR_LOW_POWER
- real_t deg[64] MEM_ALIGN_ATTR;
-#endif
-
static void sbr_process_channel(sbr_info *sbr, real_t *channel_buf, qmf_t X[MAX_NTSR][64],
uint8_t ch, uint8_t dont_process,
const uint8_t downSampledSBR)
@@ -276,9 +236,9 @@ static void sbr_process_channel(sbr_info *sbr, real_t *channel_buf, qmf_t X[MAX_
/* subband analysis */
if (dont_process)
- sbr_qmf_analysis_32(sbr, sbr->qmfa[ch], channel_buf, sbr->Xsbr[ch], sbr->tHFGen, 32);
+ sbr_qmf_analysis_32(sbr, &sbr->qmfa[ch], channel_buf, sbr->Xsbr[ch], sbr->tHFGen, 32);
else
- sbr_qmf_analysis_32(sbr, sbr->qmfa[ch], channel_buf, sbr->Xsbr[ch], sbr->tHFGen, sbr->kx);
+ sbr_qmf_analysis_32(sbr, &sbr->qmfa[ch], channel_buf, sbr->Xsbr[ch], sbr->tHFGen, sbr->kx);
if (!dont_process)
{
@@ -413,22 +373,22 @@ uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_cha
sbr->just_seeked = 0;
}
- sbr_process_channel(sbr, left_chan, X_left, 0, dont_process, downSampledSBR);
+ sbr_process_channel(sbr, left_chan, p_XLR->X_L, 0, dont_process, downSampledSBR);
/* subband synthesis */
if (downSampledSBR)
{
- sbr_qmf_synthesis_32(sbr, sbr->qmfs[0], X_left, left_chan);
+ sbr_qmf_synthesis_32(sbr, &sbr->qmfs[0], p_XLR->X_L, left_chan);
} else {
- sbr_qmf_synthesis_64(sbr, sbr->qmfs[0], X_left, left_chan);
+ sbr_qmf_synthesis_64(sbr, &sbr->qmfs[0], p_XLR->X_L, left_chan);
}
- sbr_process_channel(sbr, right_chan, X_right, 1, dont_process, downSampledSBR);
+ sbr_process_channel(sbr, right_chan, p_XLR->X_R, 1, dont_process, downSampledSBR);
/* subband synthesis */
if (downSampledSBR)
{
- sbr_qmf_synthesis_32(sbr, sbr->qmfs[1], X_right, right_chan);
+ sbr_qmf_synthesis_32(sbr, &sbr->qmfs[1], p_XLR->X_R, right_chan);
} else {
- sbr_qmf_synthesis_64(sbr, sbr->qmfs[1], X_right, right_chan);
+ sbr_qmf_synthesis_64(sbr, &sbr->qmfs[1], p_XLR->X_R, right_chan);
}
if (sbr->bs_header_flag)
@@ -495,13 +455,13 @@ uint8_t sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel,
sbr->just_seeked = 0;
}
- sbr_process_channel(sbr, channel, X_left, 0, dont_process, downSampledSBR);
+ sbr_process_channel(sbr, channel, p_XLR->X_L, 0, dont_process, downSampledSBR);
/* subband synthesis */
if (downSampledSBR)
{
- sbr_qmf_synthesis_32(sbr, sbr->qmfs[0], X_left, channel);
+ sbr_qmf_synthesis_32(sbr, &sbr->qmfs[0], p_XLR->X_L, channel);
} else {
- sbr_qmf_synthesis_64(sbr, sbr->qmfs[0], X_left, channel);
+ sbr_qmf_synthesis_64(sbr, &sbr->qmfs[0], p_XLR->X_L, channel);
}
if (sbr->bs_header_flag)
@@ -540,8 +500,8 @@ uint8_t sbrDecodeSingleFramePS(sbr_info *sbr, real_t *left_channel, real_t *righ
uint8_t dont_process = 0;
uint8_t ret = 0;
- memset(X_left,0,sizeof(X_left));
- memset(X_right,0,sizeof(X_right));
+ memset(p_XLR->X_L, 0, sizeof(*p_XLR->X_L));
+ memset(p_XLR->X_R, 0, sizeof(*p_XLR->X_R));
if (sbr == NULL)
return 20;
@@ -566,20 +526,15 @@ uint8_t sbrDecodeSingleFramePS(sbr_info *sbr, real_t *left_channel, real_t *righ
sbr->just_seeked = 0;
}
- if (sbr->qmfs[1] == NULL)
- {
- sbr->qmfs[1] = qmfs_init((downSampledSBR)?32:64);
- }
-
- sbr_process_channel(sbr, left_channel, X_left, 0, dont_process, downSampledSBR);
+ sbr_process_channel(sbr, left_channel, p_XLR->X_L, 0, dont_process, downSampledSBR);
/* copy some extra data for PS */
for (l = 32; l < 38; l++)
{
for (k = 0; k < 5; k++)
{
- QMF_RE(X_left[l][k]) = QMF_RE(sbr->Xsbr[0][sbr->tHFAdj+l][k]);
- QMF_IM(X_left[l][k]) = QMF_IM(sbr->Xsbr[0][sbr->tHFAdj+l][k]);
+ QMF_RE(p_XLR->X_L[l][k]) = QMF_RE(sbr->Xsbr[0][sbr->tHFAdj+l][k]);
+ QMF_IM(p_XLR->X_L[l][k]) = QMF_IM(sbr->Xsbr[0][sbr->tHFAdj+l][k]);
}
}
@@ -587,11 +542,11 @@ uint8_t sbrDecodeSingleFramePS(sbr_info *sbr, real_t *left_channel, real_t *righ
#ifdef DRM_PS
if (sbr->Is_DRM_SBR)
{
- drm_ps_decode(sbr->drm_ps, (sbr->ret > 0), sbr->sample_rate, X_left, X_right);
+ drm_ps_decode(sbr->drm_ps, (sbr->ret > 0), sbr->sample_rate, p_XLR->X_L, p_XLR->X_R);
} else {
#endif
#ifdef PS_DEC
- ps_decode(sbr->ps, X_left, X_right);
+ ps_decode(sbr->ps, p_XLR->X_L, p_XLR->X_R);
#endif
#ifdef DRM_PS
}
@@ -600,11 +555,11 @@ uint8_t sbrDecodeSingleFramePS(sbr_info *sbr, real_t *left_channel, real_t *righ
/* subband synthesis */
if (downSampledSBR)
{
- sbr_qmf_synthesis_32(sbr, sbr->qmfs[0], X_left, left_channel);
- sbr_qmf_synthesis_32(sbr, sbr->qmfs[1], X_right, right_channel);
+ sbr_qmf_synthesis_32(sbr, &sbr->qmfs[0], p_XLR->X_L, left_channel);
+ sbr_qmf_synthesis_32(sbr, &sbr->qmfs[1], p_XLR->X_R, right_channel);
} else {
- sbr_qmf_synthesis_64(sbr, sbr->qmfs[0], X_left, left_channel);
- sbr_qmf_synthesis_64(sbr, sbr->qmfs[1], X_right, right_channel);
+ sbr_qmf_synthesis_64(sbr, &sbr->qmfs[0], p_XLR->X_L, left_channel);
+ sbr_qmf_synthesis_64(sbr, &sbr->qmfs[1], p_XLR->X_R, right_channel);
}
if (sbr->bs_header_flag)
diff --git a/apps/codecs/libfaad/sbr_dec.h b/apps/codecs/libfaad/sbr_dec.h
index aa145fe34a..81dac32946 100644
--- a/apps/codecs/libfaad/sbr_dec.h
+++ b/apps/codecs/libfaad/sbr_dec.h
@@ -48,15 +48,13 @@ extern "C" {
#define MAX_L_E 5
typedef struct {
- real_t *x;
+ real_t x[2*32*10];
int16_t x_index;
- uint8_t channels;
} qmfa_info;
typedef struct {
- real_t *v;
+ real_t v[2*64*20]; /* Size was "(downSampledSBR)?32:64". We use 64 now. */
int16_t v_index;
- uint8_t channels;
} qmfs_info;
typedef struct
@@ -105,8 +103,8 @@ typedef struct
uint8_t f[2][MAX_L_E+1];
uint8_t f_prev[2];
- real_t *G_temp_prev[2][5];
- real_t *Q_temp_prev[2][5];
+ real_t G_temp_prev[2][5][64];
+ real_t Q_temp_prev[2][5][64];
int8_t GQ_ringbuf_index[2];
int16_t E[2][64][MAX_L_E];
@@ -160,10 +158,10 @@ typedef struct
uint32_t header_count;
uint8_t id_aac;
- qmfa_info *qmfa[2];
- qmfs_info *qmfs[2];
+ qmfa_info qmfa[2] MEM_ALIGN_ATTR;
+ qmfs_info qmfs[2] MEM_ALIGN_ATTR;
- qmf_t Xsbr[2][MAX_NTSRHFG][64];
+ qmf_t Xsbr[2][MAX_NTSRHFG][64] MEM_ALIGN_ATTR;
#ifdef DRM
uint8_t Is_DRM_SBR;
@@ -223,13 +221,12 @@ typedef struct
uint8_t bs_df_noise[2][3];
} sbr_info;
-sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac,
+sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac, uint8_t id_ele,
uint32_t sample_rate, uint8_t downSampledSBR
#ifdef DRM
, uint8_t IsDRM
#endif
);
-void sbrDecodeEnd(sbr_info *sbr);
uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan,
const uint8_t just_seeked, const uint8_t downSampledSBR);
diff --git a/apps/codecs/libfaad/sbr_e_nf.c b/apps/codecs/libfaad/sbr_e_nf.c
index 60532cbd76..ea2cbb8e35 100644
--- a/apps/codecs/libfaad/sbr_e_nf.c
+++ b/apps/codecs/libfaad/sbr_e_nf.c
@@ -231,7 +231,7 @@ static const real_t Q_div_tab_right[31][13] = {
/* calculates 1/(1+Q) */
/* [0..1] */
-real_t calc_Q_div(sbr_info *sbr, uint8_t ch, uint8_t m, uint8_t l)
+static real_t calc_Q_div(sbr_info *sbr, uint8_t ch, uint8_t m, uint8_t l)
{
if (sbr->bs_coupling)
{
@@ -350,7 +350,7 @@ static const real_t Q_div2_tab_right[31][13] = {
/* calculates Q/(1+Q) */
/* [0..1] */
-real_t calc_Q_div2(sbr_info *sbr, uint8_t ch, uint8_t m, uint8_t l)
+static real_t calc_Q_div2(sbr_info *sbr, uint8_t ch, uint8_t m, uint8_t l)
{
if (sbr->bs_coupling)
{
diff --git a/apps/codecs/libfaad/sbr_hfgen.c b/apps/codecs/libfaad/sbr_hfgen.c
index bdc7d5a0a2..3a5b250aa7 100644
--- a/apps/codecs/libfaad/sbr_hfgen.c
+++ b/apps/codecs/libfaad/sbr_hfgen.c
@@ -50,7 +50,8 @@ static void calc_chirp_factors(sbr_info *sbr, uint8_t ch);
static void patch_construction(sbr_info *sbr);
-void hf_generation(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64],
+void hf_generation(sbr_info *sbr,
+ qmf_t Xlow[MAX_NTSRHFG][64],
qmf_t Xhigh[MAX_NTSRHFG][64]
#ifdef SBR_LOW_POWER
,real_t *deg
diff --git a/apps/codecs/libfaad/sbr_hfgen.h b/apps/codecs/libfaad/sbr_hfgen.h
index 8510004f63..a69e53e47d 100644
--- a/apps/codecs/libfaad/sbr_hfgen.h
+++ b/apps/codecs/libfaad/sbr_hfgen.h
@@ -32,7 +32,8 @@
extern "C" {
#endif
-void hf_generation(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64],
+void hf_generation(sbr_info *sbr,
+ qmf_t Xlow[MAX_NTSRHFG][64],
qmf_t Xhigh[MAX_NTSRHFG][64]
#ifdef SBR_LOW_POWER
,real_t *deg
diff --git a/apps/codecs/libfaad/sbr_qmf.c b/apps/codecs/libfaad/sbr_qmf.c
index 7cb62c241a..5f8203e5b1 100644
--- a/apps/codecs/libfaad/sbr_qmf.c
+++ b/apps/codecs/libfaad/sbr_qmf.c
@@ -50,30 +50,6 @@
#define FAAD_ANALYSIS_SCALE3(X) ((X)/32.0f)
#endif
-qmfa_info *qmfa_init(uint8_t channels)
-{
- qmfa_info *qmfa = (qmfa_info*)faad_malloc(sizeof(qmfa_info));
-
- /* x is implemented as double ringbuffer */
- qmfa->x = (real_t*)faad_malloc(2 * channels * 10 * sizeof(real_t));
- memset(qmfa->x, 0, 2 * channels * 10 * sizeof(real_t));
-
- /* ringbuffer index */
- qmfa->x_index = 0;
-
- qmfa->channels = channels;
-
- return qmfa;
-}
-
-void qmfa_end(qmfa_info *qmfa)
-{
- if (qmfa)
- {
- if (qmfa->x) faad_free(qmfa->x);
- faad_free(qmfa);
- }
-}
void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input,
qmf_t X[MAX_NTSR][64], uint8_t offset, uint8_t kx)
@@ -198,30 +174,6 @@ void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input,
}
}
-qmfs_info *qmfs_init(uint8_t channels)
-{
- qmfs_info *qmfs = (qmfs_info*)faad_malloc(sizeof(qmfs_info));
-
- /* v is a double ringbuffer */
- qmfs->v = (real_t*)faad_malloc(2 * channels * 20 * sizeof(real_t));
- memset(qmfs->v, 0, 2 * channels * 20 * sizeof(real_t));
-
- qmfs->v_index = 0;
-
- qmfs->channels = channels;
-
- return qmfs;
-}
-
-void qmfs_end(qmfs_info *qmfs)
-{
- if (qmfs)
- {
- if (qmfs->v) faad_free(qmfs->v);
- faad_free(qmfs);
- }
-}
-
#ifdef SBR_LOW_POWER
void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSR][64],
diff --git a/apps/codecs/libfaad/sbr_qmf.h b/apps/codecs/libfaad/sbr_qmf.h
index 5ed8ff85df..87bfe5a9ef 100644
--- a/apps/codecs/libfaad/sbr_qmf.h
+++ b/apps/codecs/libfaad/sbr_qmf.h
@@ -32,11 +32,6 @@
extern "C" {
#endif
-qmfa_info *qmfa_init(uint8_t channels);
-void qmfa_end(qmfa_info *qmfa);
-qmfs_info *qmfs_init(uint8_t channels);
-void qmfs_end(qmfs_info *qmfs);
-
void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input,
qmf_t X[MAX_NTSR][64], uint8_t offset, uint8_t kx);
void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSR][64],
diff --git a/apps/codecs/libfaad/specrec.c b/apps/codecs/libfaad/specrec.c
index d537125d55..b5c8305237 100644
--- a/apps/codecs/libfaad/specrec.c
+++ b/apps/codecs/libfaad/specrec.c
@@ -53,7 +53,6 @@
#include "ssr_fb.h"
#endif
-
/* static function declarations */
static uint8_t quant_to_spec(NeAACDecHandle hDecoder,
ic_stream *ics, int16_t *quant_data,
@@ -284,6 +283,11 @@ static const uint16_t *const swb_offset_128_window[] ICONST_ATTR =
#define bit_set(A, B) ((A) & (1<<(B)))
+/* static variables */
+/* used by reconstruct_single_channel() and reconstruct_channel_pair() */
+static real_t spec_coef1[FRAME_LEN] IBSS_ATTR MEM_ALIGN_ATTR;
+static real_t spec_coef2[FRAME_LEN] IBSS_ATTR MEM_ALIGN_ATTR;
+
/* 4.5.2.3.4 */
/*
- determine the number of windows in a window_sequence named num_windows
@@ -648,197 +652,21 @@ static uint8_t quant_to_spec(NeAACDecHandle hDecoder,
static uint8_t allocate_single_channel(NeAACDecHandle hDecoder, uint8_t channel,
uint8_t output_channels)
{
- uint8_t mul = 1;
-
-#ifdef MAIN_DEC
- /* MAIN object type prediction */
- if (hDecoder->object_type == MAIN)
- {
- /* allocate the state only when needed */
- if (hDecoder->pred_stat[channel] == NULL)
- {
- hDecoder->pred_stat[channel] = (pred_state*)faad_malloc(hDecoder->frameLength * sizeof(pred_state));
- reset_all_predictors(hDecoder->pred_stat[channel], hDecoder->frameLength);
- }
- }
-#endif
-
-#ifdef LTP_DEC
- if (is_ltp_ot(hDecoder->object_type))
- {
- /* allocate the state only when needed */
- if (hDecoder->lt_pred_stat[channel] == NULL)
- {
- hDecoder->lt_pred_stat[channel] = (int16_t*)faad_malloc(hDecoder->frameLength*4 * sizeof(int16_t));
- memset(hDecoder->lt_pred_stat[channel], 0, hDecoder->frameLength*4 * sizeof(int16_t));
- }
- }
-#endif
-
- if (hDecoder->time_out[channel] == NULL)
- {
- mul = 1;
-#ifdef SBR_DEC
- hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 0;
- if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))
- {
- /* SBR requires 2 times as much output data */
- mul = 2;
- hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1;
- }
-#endif
- hDecoder->time_out[channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t));
- memset(hDecoder->time_out[channel], 0, mul*hDecoder->frameLength*sizeof(real_t));
- }
-#if (defined(PS_DEC) || defined(DRM_PS))
- if (output_channels == 2)
- {
- if (hDecoder->time_out[channel+1] == NULL)
- {
- hDecoder->time_out[channel+1] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t));
- memset(hDecoder->time_out[channel+1], 0, mul*hDecoder->frameLength*sizeof(real_t));
- }
- }
-#else
- (void)output_channels; /*silence warning when PS disabled*/
-#endif
-
- if (hDecoder->fb_intermed[channel] == NULL)
- {
- hDecoder->fb_intermed[channel] = (real_t*)faad_malloc(hDecoder->frameLength*sizeof(real_t));
- memset(hDecoder->fb_intermed[channel], 0, hDecoder->frameLength*sizeof(real_t));
- }
-
-#ifdef SSR_DEC
- if (hDecoder->object_type == SSR)
- {
- if (hDecoder->ssr_overlap[channel] == NULL)
- {
- hDecoder->ssr_overlap[channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
- memset(hDecoder->ssr_overlap[channel], 0, 2*hDecoder->frameLength*sizeof(real_t));
- }
- if (hDecoder->prev_fmd[channel] == NULL)
- {
- uint16_t k;
- hDecoder->prev_fmd[channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
- for (k = 0; k < 2*hDecoder->frameLength; k++)
- hDecoder->prev_fmd[channel][k] = REAL_CONST(-1);
- }
- }
-#endif
-
+ (void)output_channels;
+ (void)hDecoder;
+ (void)channel;
return 0;
}
static uint8_t allocate_channel_pair(NeAACDecHandle hDecoder,
uint8_t channel, uint8_t paired_channel)
{
- uint8_t mul = 1;
-
-#ifdef MAIN_DEC
- /* MAIN object type prediction */
- if (hDecoder->object_type == MAIN)
- {
- /* allocate the state only when needed */
- if (hDecoder->pred_stat[channel] == NULL)
- {
- hDecoder->pred_stat[channel] = (pred_state*)faad_malloc(hDecoder->frameLength * sizeof(pred_state));
- reset_all_predictors(hDecoder->pred_stat[channel], hDecoder->frameLength);
- }
- if (hDecoder->pred_stat[paired_channel] == NULL)
- {
- hDecoder->pred_stat[paired_channel] = (pred_state*)faad_malloc(hDecoder->frameLength * sizeof(pred_state));
- reset_all_predictors(hDecoder->pred_stat[paired_channel], hDecoder->frameLength);
- }
- }
-#endif
-
-#ifdef LTP_DEC
- if (is_ltp_ot(hDecoder->object_type))
- {
- /* allocate the state only when needed */
- if (hDecoder->lt_pred_stat[channel] == NULL)
- {
- hDecoder->lt_pred_stat[channel] = (int16_t*)faad_malloc(hDecoder->frameLength*4 * sizeof(int16_t));
- memset(hDecoder->lt_pred_stat[channel], 0, hDecoder->frameLength*4 * sizeof(int16_t));
- }
- if (hDecoder->lt_pred_stat[paired_channel] == NULL)
- {
- hDecoder->lt_pred_stat[paired_channel] = (int16_t*)faad_malloc(hDecoder->frameLength*4 * sizeof(int16_t));
- memset(hDecoder->lt_pred_stat[paired_channel], 0, hDecoder->frameLength*4 * sizeof(int16_t));
- }
- }
-#endif
-
- if (hDecoder->time_out[channel] == NULL)
- {
- mul = 1;
-#ifdef SBR_DEC
- hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 0;
- if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))
- {
- /* SBR requires 2 times as much output data */
- mul = 2;
- hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1;
- }
-#endif
- hDecoder->time_out[channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t));
- memset(hDecoder->time_out[channel], 0, mul*hDecoder->frameLength*sizeof(real_t));
- }
- if (hDecoder->time_out[paired_channel] == NULL)
- {
- hDecoder->time_out[paired_channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t));
- memset(hDecoder->time_out[paired_channel], 0, mul*hDecoder->frameLength*sizeof(real_t));
- }
-
- if (hDecoder->fb_intermed[channel] == NULL)
- {
- hDecoder->fb_intermed[channel] = (real_t*)faad_malloc(hDecoder->frameLength*sizeof(real_t));
- memset(hDecoder->fb_intermed[channel], 0, hDecoder->frameLength*sizeof(real_t));
- }
- if (hDecoder->fb_intermed[paired_channel] == NULL)
- {
- hDecoder->fb_intermed[paired_channel] = (real_t*)faad_malloc(hDecoder->frameLength*sizeof(real_t));
- memset(hDecoder->fb_intermed[paired_channel], 0, hDecoder->frameLength*sizeof(real_t));
- }
-
-#ifdef SSR_DEC
- if (hDecoder->object_type == SSR)
- {
- if (hDecoder->ssr_overlap[cpe->channel] == NULL)
- {
- hDecoder->ssr_overlap[cpe->channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
- memset(hDecoder->ssr_overlap[cpe->channel], 0, 2*hDecoder->frameLength*sizeof(real_t));
- }
- if (hDecoder->ssr_overlap[cpe->paired_channel] == NULL)
- {
- hDecoder->ssr_overlap[cpe->paired_channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
- memset(hDecoder->ssr_overlap[cpe->paired_channel], 0, 2*hDecoder->frameLength*sizeof(real_t));
- }
- if (hDecoder->prev_fmd[cpe->channel] == NULL)
- {
- uint16_t k;
- hDecoder->prev_fmd[cpe->channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
- for (k = 0; k < 2*hDecoder->frameLength; k++)
- hDecoder->prev_fmd[cpe->channel][k] = REAL_CONST(-1);
- }
- if (hDecoder->prev_fmd[cpe->paired_channel] == NULL)
- {
- uint16_t k;
- hDecoder->prev_fmd[cpe->paired_channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
- for (k = 0; k < 2*hDecoder->frameLength; k++)
- hDecoder->prev_fmd[cpe->paired_channel][k] = REAL_CONST(-1);
- }
- }
-#endif
-
+ (void)paired_channel;
+ (void)hDecoder;
+ (void)channel;
return 0;
}
-/* used by reconstruct_single_channel() and reconstruct_channel_pair() */
-static real_t spec_coef1[1024] IBSS_ATTR MEM_ALIGN_ATTR;
-static real_t spec_coef2[1024] IBSS_ATTR MEM_ALIGN_ATTR;
-
uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics,
element *sce, int16_t *spec_data)
{
@@ -978,7 +806,8 @@ uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics,
if (hDecoder->sbr[ele] == NULL)
{
hDecoder->sbr[ele] = sbrDecodeInit(hDecoder->frameLength,
- hDecoder->element_id[ele], 2*get_sample_rate(hDecoder->sf_index),
+ hDecoder->element_id[ele], ele,
+ 2*get_sample_rate(hDecoder->sf_index),
hDecoder->downSampledSBR
#ifdef DRM
, 0
@@ -1227,7 +1056,8 @@ uint8_t reconstruct_channel_pair(NeAACDecHandle hDecoder, ic_stream *ics1, ic_st
if (hDecoder->sbr[ele] == NULL)
{
hDecoder->sbr[ele] = sbrDecodeInit(hDecoder->frameLength,
- hDecoder->element_id[ele], 2*get_sample_rate(hDecoder->sf_index),
+ hDecoder->element_id[ele], ele,
+ 2*get_sample_rate(hDecoder->sf_index),
hDecoder->downSampledSBR
#ifdef DRM
, 0
diff --git a/apps/codecs/libfaad/structs.h b/apps/codecs/libfaad/structs.h
index 05a2b52280..c241cc41f3 100644
--- a/apps/codecs/libfaad/structs.h
+++ b/apps/codecs/libfaad/structs.h
@@ -37,12 +37,13 @@ extern "C" {
#include "sbr_dec.h"
#endif
-#define MAX_CHANNELS 64
-#define MAX_SYNTAX_ELEMENTS 48
+#define MAX_CHANNELS 2 /* Was 64, but we need to limit RAM usage */
+#define MAX_SYNTAX_ELEMENTS 1 /* Was 48, but we need to limit RAM usage */
#define MAX_WINDOW_GROUPS 8
#define MAX_SFB 51
#define MAX_LTP_SFB 40
#define MAX_LTP_SFB_S 8
+#define FRAME_LEN 1024
/* used to save the prediction state */
typedef struct {
@@ -407,9 +408,6 @@ typedef struct
*/
uint8_t alloced_channels;
- /* output data buffer */
- void *sample_buffer;
-
uint8_t window_shape_prev[MAX_CHANNELS];
#ifdef LTP_DEC
uint16_t ltp_lag[MAX_CHANNELS];
diff --git a/apps/codecs/libfaad/syntax.c b/apps/codecs/libfaad/syntax.c
index 545163e85b..4c7baab274 100644
--- a/apps/codecs/libfaad/syntax.c
+++ b/apps/codecs/libfaad/syntax.c
@@ -558,7 +558,7 @@ void raw_data_block(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo,
/* Table 4.4.4 and */
/* Table 4.4.9 */
-int16_t spec_data[1024] MEM_ALIGN_ATTR = {0};
+int16_t spec_data[FRAME_LEN] MEM_ALIGN_ATTR = {0};
element sce;
static uint8_t single_lfe_channel_element(NeAACDecHandle hDecoder, bitfile *ld,
uint8_t channel, uint8_t *tag)
@@ -603,8 +603,9 @@ static uint8_t single_lfe_channel_element(NeAACDecHandle hDecoder, bitfile *ld,
}
/* Table 4.4.5 */
-int16_t spec_data1[1024] IBSS_ATTR MEM_ALIGN_ATTR;
-int16_t spec_data2[1024] IBSS_ATTR MEM_ALIGN_ATTR;
+
+int16_t spec_data1[FRAME_LEN] IBSS_ATTR MEM_ALIGN_ATTR;
+int16_t spec_data2[FRAME_LEN] IBSS_ATTR MEM_ALIGN_ATTR;
element cpe;
static uint8_t channel_pair_element(NeAACDecHandle hDecoder, bitfile *ld,
uint8_t channels, uint8_t *tag)
@@ -884,7 +885,7 @@ static uint8_t coupling_channel_element(NeAACDecHandle hDecoder, bitfile *ld)
element el_empty = {0};
ic_stream ics_empty = {0};
- static int16_t sh_data[1024];
+ static int16_t sh_data[FRAME_LEN];
c = faad_getbits(ld, LEN_TAG
DEBUGVAR(1,900,"coupling_channel_element(): element_instance_tag"));
@@ -1028,7 +1029,8 @@ static uint8_t fill_element(NeAACDecHandle hDecoder, bitfile *ld, drc_info *drc
if (!hDecoder->sbr[sbr_ele])
{
hDecoder->sbr[sbr_ele] = sbrDecodeInit(hDecoder->frameLength,
- hDecoder->element_id[sbr_ele], 2*get_sample_rate(hDecoder->sf_index),
+ hDecoder->element_id[sbr_ele], sbr_ele,
+ 2*get_sample_rate(hDecoder->sf_index),
hDecoder->downSampledSBR
#ifdef DRM
, 0
@@ -1170,8 +1172,8 @@ static void gain_control_data(bitfile *ld, ic_stream *ics)
#endif
#ifdef SCALABLE_DEC
-int16_t spec_data1[1024] MEM_ALIGN_ATTR;
-int16_t spec_data2[1024] MEM_ALIGN_ATTR;
+int16_t spec_data1[FRAME_LEN] MEM_ALIGN_ATTR;
+int16_t spec_data2[FRAME_LEN] MEM_ALIGN_ATTR;
/* Table 4.4.13 ASME */
void aac_scalable_main_element(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo,
bitfile *ld, program_config *pce, drc_info *drc)
diff --git a/apps/codecs/raac.c b/apps/codecs/raac.c
index e3ad2b5dd8..b322ae7df3 100644
--- a/apps/codecs/raac.c
+++ b/apps/codecs/raac.c
@@ -28,13 +28,6 @@
CODEC_HEADER
-/* Global buffers to be used in the mdct synthesis. This way the arrays can
- * be moved to IRAM for some targets */
-#define GB_BUF_SIZE 1024
-static ALIGN real_t gb_time_buffer[2][GB_BUF_SIZE] IBSS_ATTR_FAAD_LARGE_IRAM;
-static ALIGN real_t gb_fb_intermed[2][GB_BUF_SIZE] IBSS_ATTR_FAAD_LARGE_IRAM;
-
-
static void init_rm(RMContext *rmctx)
{
memcpy(rmctx, (void*)(( (intptr_t)ci->id3->id3v2buf + 3 ) &~ 3), sizeof(RMContext));
@@ -49,7 +42,6 @@ enum codec_status codec_main(void)
NeAACDecHandle decoder;
size_t n;
void *ret;
- int needed_bufsize;
unsigned int i;
unsigned char* buffer;
int err, consumed, pkt_offset, skipped = 0;
@@ -103,34 +95,6 @@ next_track:
goto done;
}
- /* Set pointer to be able to use IRAM an to avoid alloc in decoder. Must
- * be called after NeAACDecOpen(). */
- /* A buffer of framelength or 2*frameLenght size must be allocated for
- * time_out. If frameLength is too big or SBR/forceUpSampling is active,
- * we do not use the IRAM buffer and keep faad's internal allocation (see
- * specrec.c). */
- needed_bufsize = decoder->frameLength;
-#ifdef SBR_DEC
- if ((decoder->sbr_present_flag == 1) || (decoder->forceUpSampling == 1))
- {
- needed_bufsize *= 2;
- }
-#endif
- if (needed_bufsize <= GB_BUF_SIZE)
- {
- decoder->time_out[0] = &gb_time_buffer[0][0];
- decoder->time_out[1] = &gb_time_buffer[1][0];
- }
- /* A buffer of with frameLength elements must be allocated for fb_intermed.
- * If frameLength is too big, we do not use the IRAM buffer and keep faad's
- * internal allocation (see specrec.c). */
- needed_bufsize = decoder->frameLength;
- if (needed_bufsize <= GB_BUF_SIZE)
- {
- decoder->fb_intermed[0] = &gb_fb_intermed[0][0];
- decoder->fb_intermed[1] = &gb_fb_intermed[1][0];
- }
-
/* check for a mid-track resume and force a seek time accordingly */
if(resume_offset > rmctx.data_offset + DATA_HEADER_SIZE) {
resume_offset -= rmctx.data_offset + DATA_HEADER_SIZE;