Index: apps/codecs/libfaad/bits.c =================================================================== --- apps/codecs/libfaad/bits.c (revision 29752) +++ apps/codecs/libfaad/bits.c (working copy) @@ -132,6 +132,7 @@ ld->no_more_reading = 0; } +#ifdef ERROR_RESILIENCE uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits DEBUGDEC) { @@ -139,7 +140,7 @@ 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 +157,7 @@ return buffer; } +#endif #ifdef DRM /* return the original data buffer */ Index: apps/codecs/libfaad/decoder.c =================================================================== --- apps/codecs/libfaad/decoder.c (revision 29752) +++ apps/codecs/libfaad/decoder.c (working copy) @@ -48,14 +48,33 @@ #include "ssr.h" #endif +/* Globals */ #ifdef ANALYSIS uint16_t dbg_count; #endif +/* static variables */ +static NeAACDecStruct g_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 +static real_t s_time_buf_2048[MAX_CHANNELS][2*FRAME_LEN] MEM_ALIGN_ATTR; +#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 +120,21 @@ coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE); #endif - if ((hDecoder = (NeAACDecHandle)faad_malloc(sizeof(NeAACDecStruct))) == NULL) - return NULL; + hDecoder = &g_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 +143,28 @@ 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 +232,7 @@ uint32_t buffer_size, uint32_t *samplerate, uint8_t *channels) { + uint32_t i; uint32_t bits = 0; bitfile ld; adif_header adif; @@ -298,6 +327,24 @@ hDecoder->frameLength >>= 1; #endif + for (i=0; isbr_alloced[hDecoder->fr_ch_ele] = 0; + if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) + { + hDecoder->time_out[i] = s_time_buf_2048[i]; + 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 +357,7 @@ uint32_t *samplerate, uint8_t *channels) { int8_t rc; + uint32_t i; mp4AudioSpecificConfig mp4ASC; if((hDecoder == NULL) @@ -391,6 +439,24 @@ hDecoder->frameLength >>= 1; #endif + for (i=0; isbr_alloced[hDecoder->fr_ch_ele] = 0; + if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) + { + hDecoder->time_out[i] = s_time_buf_2048[i]; + 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; } @@ -437,8 +503,6 @@ void NEAACDECAPI NeAACDecClose(NeAACDecHandle hDecoder) { - uint8_t i; - if (hDecoder == NULL) return; @@ -450,42 +514,15 @@ 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++) + for (int 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) @@ -708,34 +745,17 @@ NeAACDecFrameInfo *hInfo, uint8_t *buffer, uint32_t buffer_size) { - return aac_frame_decode(hDecoder, hInfo, buffer, buffer_size, NULL, 0); + return aac_frame_decode(hDecoder, hInfo, buffer, buffer_size); } -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); -} - 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 +928,11 @@ } /* 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 +971,6 @@ } #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 +998,7 @@ hDecoder->cycles += count; #endif - return sample_buffer; + return hDecoder; /* return void* != NULL */ error: Index: apps/codecs/libfaad/drc.c =================================================================== --- apps/codecs/libfaad/drc.c (revision 29752) +++ apps/codecs/libfaad/drc.c (working copy) @@ -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; @@ -51,7 +54,8 @@ void drc_end(drc_info *drc) { - if (drc) faad_free(drc); + /* do nothing */ + (void)drc; } #ifdef FIXED_POINT Index: apps/codecs/libfaad/decoder.h =================================================================== --- apps/codecs/libfaad/decoder.h (revision 29752) +++ apps/codecs/libfaad/decoder.h (working copy) @@ -106,11 +106,6 @@ 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 Index: apps/codecs/libfaad/filtbank.c =================================================================== --- apps/codecs/libfaad/filtbank.c (revision 29752) +++ apps/codecs/libfaad/filtbank.c (working copy) @@ -196,7 +196,7 @@ } #endif -real_t transf_buf[2*1024] IBSS_ATTR MEM_ALIGN_ATTR; +real_t transf_buf[2*FRAME_LEN] 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, Index: apps/codecs/libfaad/drm_dec.c =================================================================== --- apps/codecs/libfaad/drm_dec.c (revision 29752) +++ apps/codecs/libfaad/drm_dec.c (working copy) @@ -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 @@ { 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); @@ -911,8 +913,7 @@ 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; @@ -920,7 +921,8 @@ void drm_ps_free(drm_ps_info *ps) { - faad_free(ps); + /* do nothing */ + (void)ps; } /* main DRM PS decoding function */ Index: apps/codecs/libfaad/sbr_qmf.c =================================================================== --- apps/codecs/libfaad/sbr_qmf.c (revision 29752) +++ apps/codecs/libfaad/sbr_qmf.c (working copy) @@ -50,29 +50,24 @@ #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)); +/* static variables */ +static qmfa_info s_qmfa_info[2] MEM_ALIGN_ATTR; /* 2 = stereo */ +static qmfs_info s_qmfs_info[2] MEM_ALIGN_ATTR; /* 2 = stereo */ - /* ringbuffer index */ - qmfa->x_index = 0; - qmfa->channels = channels; +qmfa_info *qmfa_init(uint8_t channel) +{ + qmfa_info *qmfa = &s_qmfa_info[channel]; + memset(qmfa, 0, sizeof(qmfa)); return qmfa; } void qmfa_end(qmfa_info *qmfa) { - if (qmfa) - { - if (qmfa->x) faad_free(qmfa->x); - faad_free(qmfa); - } + /* do nothing */ + (void)qmfa; } void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input, @@ -198,28 +193,18 @@ } } -qmfs_info *qmfs_init(uint8_t channels) +qmfs_info *qmfs_init(uint8_t channel) { - qmfs_info *qmfs = (qmfs_info*)faad_malloc(sizeof(qmfs_info)); + qmfs_info *qmfs = &s_qmfs_info[channel]; + memset(qmfs, 0, sizeof(qmfs)); - /* 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); - } + /* do nothing */ + (void)qmfs; } #ifdef SBR_LOW_POWER Index: apps/codecs/libfaad/sbr_qmf.h =================================================================== --- apps/codecs/libfaad/sbr_qmf.h (revision 29752) +++ apps/codecs/libfaad/sbr_qmf.h (working copy) @@ -32,9 +32,9 @@ extern "C" { #endif -qmfa_info *qmfa_init(uint8_t channels); +qmfa_info *qmfa_init(uint8_t channel); void qmfa_end(qmfa_info *qmfa); -qmfs_info *qmfs_init(uint8_t channels); +qmfs_info *qmfs_init(uint8_t channel); void qmfs_end(qmfs_info *qmfs); void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input, Index: apps/codecs/libfaad/structs.h =================================================================== --- apps/codecs/libfaad/structs.h (revision 29752) +++ apps/codecs/libfaad/structs.h (working copy) @@ -37,12 +37,13 @@ #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 @@ */ 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]; Index: apps/codecs/libfaad/sbr_dec.c =================================================================== --- apps/codecs/libfaad/sbr_dec.c (revision 29752) +++ apps/codecs/libfaad/sbr_dec.c (working copy) @@ -42,24 +42,26 @@ #include "sbr_hfadj.h" -/* globals */ +/* static variables */ static qmf_t X_left [MAX_NTSRHFG][64] IBSS_ATTR_FAAD_XLARGE_IRAM MEM_ALIGN_ATTR; static qmf_t X_right[MAX_NTSRHFG][64] IBSS_ATTR_FAAD_XLARGE_IRAM MEM_ALIGN_ATTR; +static sbr_info g_sbr[MAX_SYNTAX_ELEMENTS]; - /* 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; + + sbr_info *sbr = &g_sbr[id_ele]; memset(sbr, 0, sizeof(sbr_info)); /* save id of the parent element */ @@ -110,35 +112,19 @@ 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); + sbr->qmfa[0] = qmfa_init(0); + sbr->qmfa[1] = qmfa_init(1); + sbr->qmfs[0] = qmfs_init(0); + sbr->qmfs[1] = qmfs_init(1); - 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->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->qmfa[0] = qmfa_init(0); + sbr->qmfs[0] = qmfs_init(0); 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)); } @@ -147,8 +133,6 @@ void sbrDecodeEnd(sbr_info *sbr) { - uint8_t j; - if (sbr) { qmfa_end(sbr->qmfa[0]); @@ -159,14 +143,6 @@ 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); @@ -176,8 +152,6 @@ if (sbr->drm_ps != NULL) drm_ps_free(sbr->drm_ps); #endif - - faad_free(sbr); } } @@ -560,7 +534,7 @@ if (sbr->qmfs[1] == NULL) { - sbr->qmfs[1] = qmfs_init((downSampledSBR)?32:64); + sbr->qmfs[1] = qmfs_init(1); } sbr_process_channel(sbr, left_channel, X_left, 0, dont_process, downSampledSBR); Index: apps/codecs/libfaad/sbr_dec.h =================================================================== --- apps/codecs/libfaad/sbr_dec.h (revision 29752) +++ apps/codecs/libfaad/sbr_dec.h (working copy) @@ -49,15 +49,13 @@ #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]; int16_t v_index; - uint8_t channels; } qmfs_info; typedef struct @@ -106,8 +104,8 @@ 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]; @@ -224,7 +222,7 @@ 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 Index: apps/codecs/libfaad/specrec.c =================================================================== --- apps/codecs/libfaad/specrec.c (revision 29752) +++ apps/codecs/libfaad/specrec.c (working copy) @@ -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 @@ #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 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 @@ 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 @@ 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 Index: apps/codecs/libfaad/syntax.c =================================================================== --- apps/codecs/libfaad/syntax.c (revision 29752) +++ apps/codecs/libfaad/syntax.c (working copy) @@ -558,7 +558,7 @@ /* 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 @@ } /* 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 @@ 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 @@ 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 @@ #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) Index: apps/codecs/libfaad/common.c =================================================================== --- apps/codecs/libfaad/common.c (revision 29752) +++ apps/codecs/libfaad/common.c (working copy) @@ -169,25 +169,6 @@ 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, Index: apps/codecs/libfaad/ps_dec.c =================================================================== --- apps/codecs/libfaad/ps_dec.c (revision 29752) +++ apps/codecs/libfaad/ps_dec.c (working copy) @@ -152,19 +152,25 @@ 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 */ +static hyb_info s_hyb_info; +static ps_info s_ps_info; + + /* 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], @@ -191,10 +197,8 @@ static hyb_info *hybrid_init() { - uint8_t i; + hyb_info *hyb = &s_hyb_info; - hyb_info *hyb = (hyb_info*)faad_malloc(sizeof(hyb_info)); - hyb->resolution34[0] = 12; hyb->resolution34[1] = 8; hyb->resolution34[2] = 4; @@ -207,52 +211,16 @@ 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)); + memset(hyb->work , 0, sizeof(hyb->work)); + memset(hyb->buffer, 0, sizeof(hyb->buffer)); + memset(hyb->temp , 0, sizeof(hyb->temp)); - 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)); - } - 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; @@ -286,7 +254,7 @@ /* 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]; @@ -361,7 +329,7 @@ /* 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]; @@ -454,7 +422,7 @@ /* 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]; @@ -1838,10 +1806,8 @@ void ps_free(ps_info *ps) { - /* free hybrid filterbank structures */ - hybrid_free(ps->hyb); - - faad_free(ps); + /* do nothing */ + (void)ps; } ps_info *ps_init(uint8_t sr_index) @@ -1849,7 +1815,7 @@ uint8_t i; uint8_t short_delay_band; - ps_info *ps = (ps_info*)faad_malloc(sizeof(ps_info)); + ps_info *ps = &s_ps_info; memset(ps, 0, sizeof(ps_info)); (void)sr_index; Index: apps/codecs/libfaad/common.h =================================================================== --- apps/codecs/libfaad/common.h (revision 29752) +++ apps/codecs/libfaad/common.h (working copy) @@ -442,8 +442,11 @@ 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); +/* Those should not be defined or used anymore */ +/* +#define faad_malloc(A) malloc(A) +#define faad_free(A) free(A) +*/ //#define PROFILE #ifdef PROFILE Index: apps/codecs/raac.c =================================================================== --- apps/codecs/raac.c (revision 29752) +++ apps/codecs/raac.c (working copy) @@ -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 @@ 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 @@ 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; Index: apps/codecs/aac.c =================================================================== --- apps/codecs/aac.c (revision 29752) +++ apps/codecs/aac.c (working copy) @@ -32,12 +32,6 @@ * 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 @@ 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 @@ 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. */ Index: apps/codecs/lib/codeclib.c =================================================================== --- apps/codecs/lib/codeclib.c (revision 29752) +++ apps/codecs/lib/codeclib.c (working copy) @@ -74,6 +74,8 @@ x=&mallocbuf[mem_ptr]; mem_ptr+=(size+3)&~3; /* Keep memory 32-bit aligned */ + +// printf("alloc: 0x%08x (%d Byte)\n", mem_ptr, mem_ptr); return(x); }