diff options
author | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-04-24 20:19:05 +0000 |
---|---|---|
committer | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-04-24 20:19:05 +0000 |
commit | a602f46d69d9d18756b7f317470f654f695faa80 (patch) | |
tree | f111cc29197def94d5404d15c7febfd06efed9f7 /apps/codecs | |
parent | 69580a96eb816d9b811c542d38181126243d8563 (diff) | |
download | rockbox-a602f46d69d9d18756b7f317470f654f695faa80.tar.gz rockbox-a602f46d69d9d18756b7f317470f654f695faa80.zip |
Rework of libfaad in several areas. Allow removal of malloc with a new define FAAD_STATIC_ALLOC (in common.h). For now malloc is not fully removed but used by a few arrays needed for AAC-HE SBR+PS only. Reason to keep malloc is to have this amount of memory available for AAC-LC files which might require large m4a tables. The changes make the allocation routines much smaller, better centralized and allow to move duplicated code from aac.c/raa.c to libfaad. The rework includes removal of (now and former) unused code as well.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29778 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs')
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 | |||
32 | * for each frame. */ | 32 | * for each frame. */ |
33 | #define FAAD_BYTE_BUFFER_SIZE (2048-12) | 33 | #define FAAD_BYTE_BUFFER_SIZE (2048-12) |
34 | 34 | ||
35 | /* Global buffers to be used in the mdct synthesis. This way the arrays can | ||
36 | * be moved to IRAM for some targets */ | ||
37 | #define GB_BUF_SIZE 1024 | ||
38 | static real_t gb_time_buffer[2][GB_BUF_SIZE] IBSS_ATTR_FAAD_LARGE_IRAM MEM_ALIGN_ATTR; | ||
39 | static real_t gb_fb_intermed[2][GB_BUF_SIZE] IBSS_ATTR_FAAD_LARGE_IRAM MEM_ALIGN_ATTR; | ||
40 | |||
41 | /* this is the codec entry point */ | 35 | /* this is the codec entry point */ |
42 | enum codec_status codec_main(void) | 36 | enum codec_status codec_main(void) |
43 | { | 37 | { |
@@ -55,7 +49,6 @@ enum codec_status codec_main(void) | |||
55 | int file_offset; | 49 | int file_offset; |
56 | int framelength; | 50 | int framelength; |
57 | int lead_trim = 0; | 51 | int lead_trim = 0; |
58 | int needed_bufsize; | ||
59 | unsigned int i; | 52 | unsigned int i; |
60 | unsigned char* buffer; | 53 | unsigned char* buffer; |
61 | NeAACDecFrameInfo frame_info; | 54 | NeAACDecFrameInfo frame_info; |
@@ -119,34 +112,6 @@ next_track: | |||
119 | err = CODEC_ERROR; | 112 | err = CODEC_ERROR; |
120 | goto done; | 113 | goto done; |
121 | } | 114 | } |
122 | |||
123 | /* Set pointer to be able to use IRAM an to avoid alloc in decoder. Must | ||
124 | * be called after NeAACDecOpen(). */ | ||
125 | /* A buffer of framelength or 2*frameLenght size must be allocated for | ||
126 | * time_out. If frameLength is too big or SBR/forceUpSampling is active, | ||
127 | * we do not use the IRAM buffer and keep faad's internal allocation (see | ||
128 | * specrec.c). */ | ||
129 | needed_bufsize = decoder->frameLength; | ||
130 | #ifdef SBR_DEC | ||
131 | if ((decoder->sbr_present_flag == 1) || (decoder->forceUpSampling == 1)) | ||
132 | { | ||
133 | needed_bufsize *= 2; | ||
134 | } | ||
135 | #endif | ||
136 | if (needed_bufsize <= GB_BUF_SIZE) | ||
137 | { | ||
138 | decoder->time_out[0] = &gb_time_buffer[0][0]; | ||
139 | decoder->time_out[1] = &gb_time_buffer[1][0]; | ||
140 | } | ||
141 | /* A buffer of with frameLength elements must be allocated for fb_intermed. | ||
142 | * If frameLength is too big, we do not use the IRAM buffer and keep faad's | ||
143 | * internal allocation (see specrec.c). */ | ||
144 | needed_bufsize = decoder->frameLength; | ||
145 | if (needed_bufsize <= GB_BUF_SIZE) | ||
146 | { | ||
147 | decoder->fb_intermed[0] = &gb_fb_intermed[0][0]; | ||
148 | decoder->fb_intermed[1] = &gb_fb_intermed[1][0]; | ||
149 | } | ||
150 | 115 | ||
151 | #ifdef SBR_DEC | 116 | #ifdef SBR_DEC |
152 | /* Check for need of special handling for seek/resume and elapsed time. */ | 117 | /* 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 @@ | |||
36 | * Samples were observed to need up to 1500 bytes (400 kbps nero aac). | 36 | * Samples were observed to need up to 1500 bytes (400 kbps nero aac). |
37 | */ | 37 | */ |
38 | #define BUFFER_SIZE 2048 | 38 | #define BUFFER_SIZE 2048 |
39 | uint8_t static_buffer[BUFFER_SIZE] IBSS_ATTR; | 39 | static uint8_t static_buffer[BUFFER_SIZE] IBSS_ATTR; |
40 | 40 | ||
41 | /* initialize buffer, call once before first getbits or showbits */ | 41 | /* initialize buffer, call once before first getbits or showbits */ |
42 | void faad_initbits(bitfile *ld, const void *_buffer, const uint32_t buffer_size) | 42 | void faad_initbits(bitfile *ld, const void *_buffer, const uint32_t buffer_size) |
@@ -111,6 +111,7 @@ uint8_t faad_byte_align(bitfile *ld) | |||
111 | } | 111 | } |
112 | 112 | ||
113 | /* rewind to beginning */ | 113 | /* rewind to beginning */ |
114 | /* not used | ||
114 | void faad_rewindbits(bitfile *ld) | 115 | void faad_rewindbits(bitfile *ld) |
115 | { | 116 | { |
116 | uint32_t tmp; | 117 | uint32_t tmp; |
@@ -131,7 +132,9 @@ void faad_rewindbits(bitfile *ld) | |||
131 | ld->bytes_used = 0; | 132 | ld->bytes_used = 0; |
132 | ld->no_more_reading = 0; | 133 | ld->no_more_reading = 0; |
133 | } | 134 | } |
135 | */ | ||
134 | 136 | ||
137 | #ifdef ERROR_RESILIENCE | ||
135 | uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits | 138 | uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits |
136 | DEBUGDEC) | 139 | DEBUGDEC) |
137 | { | 140 | { |
@@ -139,7 +142,7 @@ uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits | |||
139 | uint8_t temp; | 142 | uint8_t temp; |
140 | uint16_t bytes = (uint16_t)bits / 8; | 143 | uint16_t bytes = (uint16_t)bits / 8; |
141 | uint8_t remainder = (uint8_t)bits % 8; | 144 | uint8_t remainder = (uint8_t)bits % 8; |
142 | 145 | ||
143 | uint8_t *buffer = (uint8_t*)faad_malloc((bytes+1)*sizeof(uint8_t)); | 146 | uint8_t *buffer = (uint8_t*)faad_malloc((bytes+1)*sizeof(uint8_t)); |
144 | 147 | ||
145 | for (i = 0; i < bytes; i++) | 148 | for (i = 0; i < bytes; i++) |
@@ -156,6 +159,7 @@ uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits | |||
156 | 159 | ||
157 | return buffer; | 160 | return buffer; |
158 | } | 161 | } |
162 | #endif | ||
159 | 163 | ||
160 | #ifdef DRM | 164 | #ifdef DRM |
161 | /* return the original data buffer */ | 165 | /* return the original data buffer */ |
@@ -172,6 +176,7 @@ uint32_t faad_origbitbuffer_size(bitfile *ld) | |||
172 | #endif | 176 | #endif |
173 | 177 | ||
174 | /* reversed bit reading routines, used for RVLC and HCR */ | 178 | /* reversed bit reading routines, used for RVLC and HCR */ |
179 | /* not used | ||
175 | void faad_initbits_rev(bitfile *ld, void *buffer, | 180 | void faad_initbits_rev(bitfile *ld, void *buffer, |
176 | uint32_t bits_in_buffer) | 181 | uint32_t bits_in_buffer) |
177 | { | 182 | { |
@@ -200,3 +205,4 @@ void faad_initbits_rev(bitfile *ld, void *buffer, | |||
200 | ld->no_more_reading = 0; | 205 | ld->no_more_reading = 0; |
201 | ld->error = 0; | 206 | ld->error = 0; |
202 | } | 207 | } |
208 | */ | ||
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[] = { | |||
73 | 73 | ||
74 | void faad_initbits(bitfile *ld, const void *buffer, const uint32_t buffer_size); | 74 | void faad_initbits(bitfile *ld, const void *buffer, const uint32_t buffer_size); |
75 | void faad_endbits(bitfile *ld); | 75 | void faad_endbits(bitfile *ld); |
76 | /* not used | ||
76 | void faad_initbits_rev(bitfile *ld, void *buffer, | 77 | void faad_initbits_rev(bitfile *ld, void *buffer, |
77 | uint32_t bits_in_buffer); | 78 | uint32_t bits_in_buffer); |
79 | */ | ||
78 | uint8_t faad_byte_align(bitfile *ld); | 80 | uint8_t faad_byte_align(bitfile *ld); |
79 | uint32_t faad_get_processed_bits(bitfile *ld); | 81 | uint32_t faad_get_processed_bits(bitfile *ld); |
80 | void faad_rewindbits(bitfile *ld); | 82 | 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) | |||
169 | return -1; | 169 | return -1; |
170 | } | 170 | } |
171 | 171 | ||
172 | void *faad_malloc(size_t size) | ||
173 | { | ||
174 | #if 0 // defined(_WIN32) && !defined(_WIN32_WCE) | ||
175 | return _aligned_malloc(size, 16); | ||
176 | #else // #ifdef 0 | ||
177 | return malloc(size); | ||
178 | #endif // #ifdef 0 | ||
179 | } | ||
180 | |||
181 | /* common free function */ | ||
182 | void faad_free(void *b) | ||
183 | { | ||
184 | #if 0 // defined(_WIN32) && !defined(_WIN32_WCE) | ||
185 | _aligned_free(b); | ||
186 | #else | ||
187 | free(b); | ||
188 | } | ||
189 | #endif | ||
190 | |||
191 | static const uint8_t Parity [256] = { // parity | 172 | static const uint8_t Parity [256] = { // parity |
192 | 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, | 173 | 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, |
193 | 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, | 174 | 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; | |||
56 | #define IBSS_ATTR_FAAD_LARGE_IRAM IBSS_ATTR | 56 | #define IBSS_ATTR_FAAD_LARGE_IRAM IBSS_ATTR |
57 | #define ICODE_ATTR_FAAD_LARGE_IRAM | 57 | #define ICODE_ATTR_FAAD_LARGE_IRAM |
58 | #define ICONST_ATTR_FAAD_LARGE_IRAM ICONST_ATTR | 58 | #define ICONST_ATTR_FAAD_LARGE_IRAM ICONST_ATTR |
59 | #define IBSS_ATTR_FAAD_XLARGE_IRAM | ||
60 | 59 | ||
61 | #elif (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) | 60 | #elif (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) |
62 | /* Enough IRAM to move additional data and code to it. */ | 61 | /* Enough IRAM to move additional data and code to it. */ |
63 | #define IBSS_ATTR_FAAD_LARGE_IRAM IBSS_ATTR | 62 | #define IBSS_ATTR_FAAD_LARGE_IRAM IBSS_ATTR |
64 | #define ICODE_ATTR_FAAD_LARGE_IRAM ICODE_ATTR | 63 | #define ICODE_ATTR_FAAD_LARGE_IRAM ICODE_ATTR |
65 | #define ICONST_ATTR_FAAD_LARGE_IRAM ICONST_ATTR | 64 | #define ICONST_ATTR_FAAD_LARGE_IRAM ICONST_ATTR |
66 | #define IBSS_ATTR_FAAD_XLARGE_IRAM | ||
67 | 65 | ||
68 | #elif defined(CPU_S5L870X) | 66 | #elif defined(CPU_S5L870X) |
69 | /* Very large IRAM. Move even more data to it. */ | 67 | /* Very large IRAM. Move even more data to it. */ |
70 | #define IBSS_ATTR_FAAD_LARGE_IRAM IBSS_ATTR | 68 | #define IBSS_ATTR_FAAD_LARGE_IRAM IBSS_ATTR |
71 | #define ICODE_ATTR_FAAD_LARGE_IRAM ICODE_ATTR | 69 | #define ICODE_ATTR_FAAD_LARGE_IRAM ICODE_ATTR |
72 | #define ICONST_ATTR_FAAD_LARGE_IRAM ICONST_ATTR | 70 | #define ICONST_ATTR_FAAD_LARGE_IRAM ICONST_ATTR |
73 | #define IBSS_ATTR_FAAD_XLARGE_IRAM IBSS_ATTR | 71 | #define FAAD_HAVE_XLR_IN_IRAM |
74 | 72 | ||
75 | #else | 73 | #else |
76 | /* Not enough IRAM available. */ | 74 | /* Not enough IRAM available. */ |
77 | #define IBSS_ATTR_FAAD_LARGE_IRAM | 75 | #define IBSS_ATTR_FAAD_LARGE_IRAM |
78 | #define ICODE_ATTR_FAAD_LARGE_IRAM | 76 | #define ICODE_ATTR_FAAD_LARGE_IRAM |
79 | #define ICONST_ATTR_FAAD_LARGE_IRAM | 77 | #define ICONST_ATTR_FAAD_LARGE_IRAM |
80 | #define IBSS_ATTR_FAAD_XLARGE_IRAM | ||
81 | #endif | 78 | #endif |
82 | 79 | ||
80 | /* Used to allocate several SBR + PS arrays and variables statically. */ | ||
81 | //#define FAAD_STATIC_ALLOC | ||
82 | |||
83 | #define INLINE __inline | 83 | #define INLINE __inline |
84 | #if 0 //defined(_WIN32) && !defined(_WIN32_WCE) | 84 | #if 0 //defined(_WIN32) && !defined(_WIN32_WCE) |
85 | #define ALIGN __declspec(align(16)) | 85 | #define ALIGN __declspec(align(16)) |
@@ -442,8 +442,11 @@ uint8_t max_tns_sfb(const uint8_t sr_index, const uint8_t object_type, | |||
442 | uint32_t get_sample_rate(const uint8_t sr_index); | 442 | uint32_t get_sample_rate(const uint8_t sr_index); |
443 | int8_t can_decode_ot(const uint8_t object_type); | 443 | int8_t can_decode_ot(const uint8_t object_type); |
444 | 444 | ||
445 | void *faad_malloc(size_t size); | 445 | #ifndef FAAD_STATIC_ALLOC |
446 | void faad_free(void *b); | 446 | /* Those should not be defined or used anymore */ |
447 | #define faad_malloc(A) malloc(A) | ||
448 | #define faad_free(A) free(A) | ||
449 | #endif | ||
447 | 450 | ||
448 | //#define PROFILE | 451 | //#define PROFILE |
449 | #ifdef PROFILE | 452 | #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 @@ | |||
48 | #include "ssr.h" | 48 | #include "ssr.h" |
49 | #endif | 49 | #endif |
50 | 50 | ||
51 | /* Globals */ | ||
51 | #ifdef ANALYSIS | 52 | #ifdef ANALYSIS |
52 | uint16_t dbg_count; | 53 | uint16_t dbg_count; |
53 | #endif | 54 | #endif |
54 | 55 | ||
56 | /* static variables */ | ||
57 | static NeAACDecStruct s_AACDec; | ||
58 | static real_t s_fb_intermed [MAX_CHANNELS][1*FRAME_LEN] IBSS_ATTR_FAAD_LARGE_IRAM MEM_ALIGN_ATTR; | ||
59 | static real_t s_time_buf_1024[MAX_CHANNELS][1*FRAME_LEN] IBSS_ATTR_FAAD_LARGE_IRAM MEM_ALIGN_ATTR; | ||
60 | #ifdef SBR_DEC | ||
61 | #ifdef FAAD_STATIC_ALLOC | ||
62 | static real_t s_time_buf_2048[MAX_CHANNELS][2*FRAME_LEN] MEM_ALIGN_ATTR; | ||
63 | #endif | ||
64 | #endif | ||
65 | #ifdef SSR_DEC | ||
66 | static real_t s_ssr_overlap [MAX_CHANNELS][2*FRAME_LEN] MEM_ALIGN_ATTR; | ||
67 | static real_t s_prev_fmd [MAX_CHANNELS][2*FRAME_LEN] MEM_ALIGN_ATTR; | ||
68 | #endif | ||
69 | #ifdef MAIN_DEC | ||
70 | static pred_state s_pred_stat[MAX_CHANNELS][1*FRAME_LEN] MEM_ALIGN_ATTR; | ||
71 | #endif | ||
72 | #ifdef LTP_DEC | ||
73 | static int16_t s_lt_pred_stat[MAX_CHANNELS][4*FRAME_LEN] MEM_ALIGN_ATTR; | ||
74 | #endif | ||
75 | |||
76 | |||
55 | /* static function declarations */ | 77 | /* static function declarations */ |
56 | static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, | 78 | static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, |
57 | uint8_t *buffer, uint32_t buffer_size, | 79 | uint8_t *buffer, uint32_t buffer_size); |
58 | void **sample_buffer, int32_t sample_buffer_size); | ||
59 | static void create_channel_config(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo); | 80 | static void create_channel_config(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo); |
60 | 81 | ||
61 | 82 | ||
@@ -101,14 +122,21 @@ NeAACDecHandle NEAACDECAPI NeAACDecOpen(void) | |||
101 | coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE); | 122 | coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE); |
102 | #endif | 123 | #endif |
103 | 124 | ||
104 | if ((hDecoder = (NeAACDecHandle)faad_malloc(sizeof(NeAACDecStruct))) == NULL) | 125 | hDecoder = &s_AACDec; |
105 | return NULL; | ||
106 | 126 | ||
107 | memset(hDecoder, 0, sizeof(NeAACDecStruct)); | 127 | memset(hDecoder , 0, sizeof(NeAACDecStruct)); |
128 | memset(s_fb_intermed, 0, sizeof(s_fb_intermed)); | ||
129 | #ifdef SSR_DEC | ||
130 | memset(s_ssr_overlap, 0, sizeof(s_ssr_overlap)); | ||
131 | memset(s_prev_fmd , 0, sizeof(s_prev_fmd)); | ||
132 | #endif | ||
133 | #ifdef LTP_DEC | ||
134 | memset(s_lt_pred_stat, 0, sizeof(s_s_lt_pred_statpred_stat)); | ||
135 | #endif | ||
108 | 136 | ||
109 | hDecoder->config.outputFormat = FAAD_FMT_16BIT; | 137 | hDecoder->config.outputFormat = FAAD_FMT_16BIT; |
110 | hDecoder->config.defObjectType = MAIN; | 138 | hDecoder->config.defObjectType = MAIN; |
111 | hDecoder->config.defSampleRate = 44100; /* Default: 44.1kHz */ | 139 | hDecoder->config.defSampleRate = 44100; |
112 | hDecoder->config.downMatrix = 0; | 140 | hDecoder->config.downMatrix = 0; |
113 | hDecoder->adts_header_present = 0; | 141 | hDecoder->adts_header_present = 0; |
114 | hDecoder->adif_header_present = 0; | 142 | hDecoder->adif_header_present = 0; |
@@ -117,26 +145,28 @@ NeAACDecHandle NEAACDECAPI NeAACDecOpen(void) | |||
117 | hDecoder->aacScalefactorDataResilienceFlag = 0; | 145 | hDecoder->aacScalefactorDataResilienceFlag = 0; |
118 | hDecoder->aacSpectralDataResilienceFlag = 0; | 146 | hDecoder->aacSpectralDataResilienceFlag = 0; |
119 | #endif | 147 | #endif |
120 | hDecoder->frameLength = 1024; | 148 | hDecoder->frameLength = FRAME_LEN; |
121 | 149 | ||
122 | hDecoder->frame = 0; | 150 | hDecoder->frame = 0; |
123 | hDecoder->sample_buffer = NULL; | ||
124 | 151 | ||
125 | for (i = 0; i < MAX_CHANNELS; i++) | 152 | for (i = 0; i < MAX_CHANNELS; i++) |
126 | { | 153 | { |
127 | hDecoder->window_shape_prev[i] = 0; | 154 | hDecoder->window_shape_prev[i] = 0; |
128 | hDecoder->time_out[i] = NULL; | 155 | hDecoder->time_out[i] = NULL; |
129 | hDecoder->fb_intermed[i] = NULL; | 156 | hDecoder->fb_intermed[i] = s_fb_intermed[i]; |
130 | #ifdef SSR_DEC | 157 | #ifdef SSR_DEC |
131 | hDecoder->ssr_overlap[i] = NULL; | 158 | hDecoder->ssr_overlap[i] = s_ssr_overlap[i]; |
132 | hDecoder->prev_fmd[i] = NULL; | 159 | hDecoder->prev_fmd[i] = s_prev_fmd[i]; |
160 | for (int k = 0; k < 2048; k++) | ||
161 | hDecoder->prev_fmd[i][k] = REAL_CONST(-1); | ||
133 | #endif | 162 | #endif |
134 | #ifdef MAIN_DEC | 163 | #ifdef MAIN_DEC |
135 | hDecoder->pred_stat[i] = NULL; | 164 | hDecoder->pred_stat[i] = s_pred_stat[i]; |
165 | reset_all_predictors(hDecoder->pred_stat[channel], FRAME_LEN); | ||
136 | #endif | 166 | #endif |
137 | #ifdef LTP_DEC | 167 | #ifdef LTP_DEC |
138 | hDecoder->ltp_lag[i] = 0; | 168 | hDecoder->ltp_lag[i] = 0; |
139 | hDecoder->lt_pred_stat[i] = NULL; | 169 | hDecoder->lt_pred_stat[i] = s_lt_pred_stat[i]; |
140 | #endif | 170 | #endif |
141 | } | 171 | } |
142 | 172 | ||
@@ -204,6 +234,7 @@ int32_t NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder, uint8_t *buffer, | |||
204 | uint32_t buffer_size, | 234 | uint32_t buffer_size, |
205 | uint32_t *samplerate, uint8_t *channels) | 235 | uint32_t *samplerate, uint8_t *channels) |
206 | { | 236 | { |
237 | uint32_t i; | ||
207 | uint32_t bits = 0; | 238 | uint32_t bits = 0; |
208 | bitfile ld; | 239 | bitfile ld; |
209 | adif_header adif; | 240 | adif_header adif; |
@@ -298,6 +329,28 @@ int32_t NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder, uint8_t *buffer, | |||
298 | hDecoder->frameLength >>= 1; | 329 | hDecoder->frameLength >>= 1; |
299 | #endif | 330 | #endif |
300 | 331 | ||
332 | for (i=0; i<MAX_CHANNELS; ++i) | ||
333 | { | ||
334 | #ifdef SBR_DEC | ||
335 | hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 0; | ||
336 | if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) | ||
337 | { | ||
338 | #ifdef FAAD_STATIC_ALLOC | ||
339 | hDecoder->time_out[i] = s_time_buf_2048[i]; | ||
340 | #else | ||
341 | hDecoder->time_out[i] = (real_t*)faad_malloc(2*FRAME_LEN*sizeof(real_t)); | ||
342 | #endif | ||
343 | memset(hDecoder->time_out[i], 0, 2*FRAME_LEN); | ||
344 | hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1; | ||
345 | } | ||
346 | else | ||
347 | #endif | ||
348 | { | ||
349 | hDecoder->time_out[i] = s_time_buf_1024[i]; | ||
350 | memset(hDecoder->time_out[i], 0, 1*FRAME_LEN); | ||
351 | } | ||
352 | } | ||
353 | |||
301 | if (can_decode_ot(hDecoder->object_type) < 0) | 354 | if (can_decode_ot(hDecoder->object_type) < 0) |
302 | return -1; | 355 | return -1; |
303 | 356 | ||
@@ -310,6 +363,7 @@ int8_t NEAACDECAPI NeAACDecInit2(NeAACDecHandle hDecoder, uint8_t *pBuffer, | |||
310 | uint32_t *samplerate, uint8_t *channels) | 363 | uint32_t *samplerate, uint8_t *channels) |
311 | { | 364 | { |
312 | int8_t rc; | 365 | int8_t rc; |
366 | uint32_t i; | ||
313 | mp4AudioSpecificConfig mp4ASC; | 367 | mp4AudioSpecificConfig mp4ASC; |
314 | 368 | ||
315 | if((hDecoder == NULL) | 369 | if((hDecoder == NULL) |
@@ -391,6 +445,28 @@ int8_t NEAACDECAPI NeAACDecInit2(NeAACDecHandle hDecoder, uint8_t *pBuffer, | |||
391 | hDecoder->frameLength >>= 1; | 445 | hDecoder->frameLength >>= 1; |
392 | #endif | 446 | #endif |
393 | 447 | ||
448 | for (i=0; i<MAX_CHANNELS; ++i) | ||
449 | { | ||
450 | #ifdef SBR_DEC | ||
451 | hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 0; | ||
452 | if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) | ||
453 | { | ||
454 | #ifdef FAAD_STATIC_ALLOC | ||
455 | hDecoder->time_out[i] = s_time_buf_2048[i]; | ||
456 | #else | ||
457 | hDecoder->time_out[i] = (real_t*)faad_malloc(2*FRAME_LEN*sizeof(real_t)); | ||
458 | #endif | ||
459 | memset(hDecoder->time_out[i], 0, 2*FRAME_LEN); | ||
460 | hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1; | ||
461 | } | ||
462 | else | ||
463 | #endif | ||
464 | { | ||
465 | hDecoder->time_out[i] = s_time_buf_1024[i]; | ||
466 | memset(hDecoder->time_out[i], 0, 1*FRAME_LEN); | ||
467 | } | ||
468 | } | ||
469 | |||
394 | return 0; | 470 | return 0; |
395 | } | 471 | } |
396 | 472 | ||
@@ -401,8 +477,6 @@ int8_t NEAACDECAPI NeAACDecInitDRM(NeAACDecHandle *hDecoder, uint32_t samplerate | |||
401 | if (hDecoder == NULL) | 477 | if (hDecoder == NULL) |
402 | return 1; /* error */ | 478 | return 1; /* error */ |
403 | 479 | ||
404 | NeAACDecClose(*hDecoder); | ||
405 | |||
406 | *hDecoder = NeAACDecOpen(); | 480 | *hDecoder = NeAACDecOpen(); |
407 | 481 | ||
408 | /* Special object type defined for DRM */ | 482 | /* Special object type defined for DRM */ |
@@ -435,59 +509,6 @@ int8_t NEAACDECAPI NeAACDecInitDRM(NeAACDecHandle *hDecoder, uint32_t samplerate | |||
435 | } | 509 | } |
436 | #endif | 510 | #endif |
437 | 511 | ||
438 | void NEAACDECAPI NeAACDecClose(NeAACDecHandle hDecoder) | ||
439 | { | ||
440 | uint8_t i; | ||
441 | |||
442 | if (hDecoder == NULL) | ||
443 | return; | ||
444 | |||
445 | #ifdef PROFILE | ||
446 | printf("AAC decoder total: %I64d cycles\n", hDecoder->cycles); | ||
447 | printf("requant: %I64d cycles\n", hDecoder->requant_cycles); | ||
448 | printf("spectral_data: %I64d cycles\n", hDecoder->spectral_cycles); | ||
449 | printf("scalefactors: %I64d cycles\n", hDecoder->scalefac_cycles); | ||
450 | printf("output: %I64d cycles\n", hDecoder->output_cycles); | ||
451 | #endif | ||
452 | |||
453 | for (i = 0; i < MAX_CHANNELS; i++) | ||
454 | { | ||
455 | if (hDecoder->time_out[i]) faad_free(hDecoder->time_out[i]); | ||
456 | if (hDecoder->fb_intermed[i]) faad_free(hDecoder->fb_intermed[i]); | ||
457 | #ifdef SSR_DEC | ||
458 | if (hDecoder->ssr_overlap[i]) faad_free(hDecoder->ssr_overlap[i]); | ||
459 | if (hDecoder->prev_fmd[i]) faad_free(hDecoder->prev_fmd[i]); | ||
460 | #endif | ||
461 | #ifdef MAIN_DEC | ||
462 | if (hDecoder->pred_stat[i]) faad_free(hDecoder->pred_stat[i]); | ||
463 | #endif | ||
464 | #ifdef LTP_DEC | ||
465 | if (hDecoder->lt_pred_stat[i]) faad_free(hDecoder->lt_pred_stat[i]); | ||
466 | #endif | ||
467 | } | ||
468 | |||
469 | #ifdef SSR_DEC | ||
470 | if (hDecoder->object_type == SSR) | ||
471 | ssr_filter_bank_end(hDecoder->fb); | ||
472 | else | ||
473 | #endif | ||
474 | |||
475 | |||
476 | drc_end(hDecoder->drc); | ||
477 | |||
478 | if (hDecoder->sample_buffer) faad_free(hDecoder->sample_buffer); | ||
479 | |||
480 | #ifdef SBR_DEC | ||
481 | for (i = 0; i < MAX_SYNTAX_ELEMENTS; i++) | ||
482 | { | ||
483 | if (hDecoder->sbr[i]) | ||
484 | sbrDecodeEnd(hDecoder->sbr[i]); | ||
485 | } | ||
486 | #endif | ||
487 | |||
488 | if (hDecoder) faad_free(hDecoder); | ||
489 | } | ||
490 | |||
491 | void NEAACDECAPI NeAACDecPostSeekReset(NeAACDecHandle hDecoder, int32_t frame) | 512 | void NEAACDECAPI NeAACDecPostSeekReset(NeAACDecHandle hDecoder, int32_t frame) |
492 | { | 513 | { |
493 | if (hDecoder) | 514 | if (hDecoder) |
@@ -708,34 +729,17 @@ void* NEAACDECAPI NeAACDecDecode(NeAACDecHandle hDecoder, | |||
708 | NeAACDecFrameInfo *hInfo, | 729 | NeAACDecFrameInfo *hInfo, |
709 | uint8_t *buffer, uint32_t buffer_size) | 730 | uint8_t *buffer, uint32_t buffer_size) |
710 | { | 731 | { |
711 | return aac_frame_decode(hDecoder, hInfo, buffer, buffer_size, NULL, 0); | 732 | return aac_frame_decode(hDecoder, hInfo, buffer, buffer_size); |
712 | } | ||
713 | |||
714 | void* NEAACDECAPI NeAACDecDecode2(NeAACDecHandle hDecoder, | ||
715 | NeAACDecFrameInfo *hInfo, | ||
716 | uint8_t *buffer, uint32_t buffer_size, | ||
717 | void **sample_buffer, uint32_t sample_buffer_size) | ||
718 | { | ||
719 | if ((sample_buffer == NULL) || (sample_buffer_size == 0)) | ||
720 | { | ||
721 | hInfo->error = 27; | ||
722 | return NULL; | ||
723 | } | ||
724 | |||
725 | return aac_frame_decode(hDecoder, hInfo, buffer, buffer_size, | ||
726 | sample_buffer, sample_buffer_size); | ||
727 | } | 733 | } |
728 | 734 | ||
729 | static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, | 735 | static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, |
730 | uint8_t *buffer, uint32_t buffer_size, | 736 | uint8_t *buffer, uint32_t buffer_size) |
731 | void **sample_buffer2, int32_t sample_buffer_size) | ||
732 | { | 737 | { |
733 | uint8_t channels = 0; | 738 | uint8_t channels = 0; |
734 | uint8_t output_channels = 0; | 739 | uint8_t output_channels = 0; |
735 | bitfile ld; | 740 | bitfile ld; |
736 | uint32_t bitsconsumed; | 741 | uint32_t bitsconsumed; |
737 | uint16_t frame_len; | 742 | uint16_t frame_len; |
738 | void *sample_buffer; | ||
739 | 743 | ||
740 | #ifdef PROFILE | 744 | #ifdef PROFILE |
741 | int64_t count = faad_get_ts(); | 745 | int64_t count = faad_get_ts(); |
@@ -908,42 +912,11 @@ static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, | |||
908 | } | 912 | } |
909 | 913 | ||
910 | /* allocate the buffer for the final samples */ | 914 | /* allocate the buffer for the final samples */ |
911 | if ((hDecoder->sample_buffer == NULL) || | 915 | if (hDecoder->alloced_channels != output_channels) |
912 | (hDecoder->alloced_channels != output_channels)) | ||
913 | { | 916 | { |
914 | static const uint8_t str[] = { sizeof(int16_t), sizeof(int32_t), sizeof(int32_t), | ||
915 | sizeof(float32_t), sizeof(double), sizeof(int16_t), sizeof(int16_t), | ||
916 | sizeof(int16_t), sizeof(int16_t), 0, 0, 0 | ||
917 | }; | ||
918 | uint8_t stride = str[hDecoder->config.outputFormat-1]; | ||
919 | #ifdef SBR_DEC | ||
920 | if (((hDecoder->sbr_present_flag == 1)&&(!hDecoder->downSampledSBR)) || (hDecoder->forceUpSampling == 1)) | ||
921 | { | ||
922 | stride = 2 * stride; | ||
923 | } | ||
924 | #endif | ||
925 | /* check if we want to use internal sample_buffer */ | ||
926 | if (sample_buffer_size == 0) | ||
927 | { | ||
928 | if (hDecoder->sample_buffer) | ||
929 | faad_free(hDecoder->sample_buffer); | ||
930 | hDecoder->sample_buffer = NULL; | ||
931 | hDecoder->sample_buffer = faad_malloc(frame_len*output_channels*stride); | ||
932 | } else if (sample_buffer_size < frame_len*output_channels*stride) { | ||
933 | /* provided sample buffer is not big enough */ | ||
934 | hInfo->error = 27; | ||
935 | return NULL; | ||
936 | } | ||
937 | hDecoder->alloced_channels = output_channels; | 917 | hDecoder->alloced_channels = output_channels; |
938 | } | 918 | } |
939 | 919 | ||
940 | if (sample_buffer_size == 0) | ||
941 | { | ||
942 | sample_buffer = hDecoder->sample_buffer; | ||
943 | } else { | ||
944 | sample_buffer = *sample_buffer2; | ||
945 | } | ||
946 | |||
947 | #ifdef SBR_DEC | 920 | #ifdef SBR_DEC |
948 | if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) | 921 | if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) |
949 | { | 922 | { |
@@ -982,11 +955,6 @@ static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, | |||
982 | } | 955 | } |
983 | #endif | 956 | #endif |
984 | 957 | ||
985 | /* we don't need sample conversion in rockbox. | ||
986 | sample_buffer = output_to_PCM(hDecoder, hDecoder->time_out, sample_buffer, | ||
987 | output_channels, frame_len, hDecoder->config.outputFormat); | ||
988 | */ | ||
989 | |||
990 | hDecoder->postSeekResetFlag = 0; | 958 | hDecoder->postSeekResetFlag = 0; |
991 | 959 | ||
992 | hDecoder->frame++; | 960 | hDecoder->frame++; |
@@ -1014,7 +982,7 @@ static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, | |||
1014 | hDecoder->cycles += count; | 982 | hDecoder->cycles += count; |
1015 | #endif | 983 | #endif |
1016 | 984 | ||
1017 | return sample_buffer; | 985 | return hDecoder; /* return void* != NULL */ |
1018 | 986 | ||
1019 | error: | 987 | error: |
1020 | 988 | ||
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" { | |||
72 | 72 | ||
73 | char* NEAACDECAPI NeAACDecGetErrorMessage(uint8_t errcode); | 73 | char* NEAACDECAPI NeAACDecGetErrorMessage(uint8_t errcode); |
74 | 74 | ||
75 | uint32_t NEAACDECAPI NeAACDecGetCapabilities(void); | ||
76 | |||
77 | NeAACDecHandle NEAACDECAPI NeAACDecOpen(void); | 75 | NeAACDecHandle NEAACDECAPI NeAACDecOpen(void); |
78 | 76 | ||
79 | NeAACDecConfigurationPtr NEAACDECAPI NeAACDecGetCurrentConfiguration(NeAACDecHandle hDecoder); | 77 | NeAACDecConfigurationPtr NEAACDECAPI NeAACDecGetCurrentConfiguration(NeAACDecHandle hDecoder); |
@@ -97,8 +95,6 @@ int8_t NEAACDECAPI NeAACDecInit2(NeAACDecHandle hDecoder, uint8_t *pBuffer, | |||
97 | int8_t NEAACDECAPI NeAACDecInitDRM(NeAACDecHandle *hDecoder, uint32_t samplerate, | 95 | int8_t NEAACDECAPI NeAACDecInitDRM(NeAACDecHandle *hDecoder, uint32_t samplerate, |
98 | uint8_t channels); | 96 | uint8_t channels); |
99 | 97 | ||
100 | void NEAACDECAPI NeAACDecClose(NeAACDecHandle hDecoder); | ||
101 | |||
102 | void NEAACDECAPI NeAACDecPostSeekReset(NeAACDecHandle hDecoder, int32_t frame); | 98 | void NEAACDECAPI NeAACDecPostSeekReset(NeAACDecHandle hDecoder, int32_t frame); |
103 | 99 | ||
104 | void* NEAACDECAPI NeAACDecDecode(NeAACDecHandle hDecoder, | 100 | void* NEAACDECAPI NeAACDecDecode(NeAACDecHandle hDecoder, |
@@ -106,11 +102,6 @@ void* NEAACDECAPI NeAACDecDecode(NeAACDecHandle hDecoder, | |||
106 | uint8_t *buffer, | 102 | uint8_t *buffer, |
107 | uint32_t buffer_size); | 103 | uint32_t buffer_size); |
108 | 104 | ||
109 | void* NEAACDECAPI NeAACDecDecode2(NeAACDecHandle hDecoder, | ||
110 | NeAACDecFrameInfo *hInfo, | ||
111 | uint8_t *buffer, uint32_t buffer_size, | ||
112 | void **sample_buffer, uint32_t sample_buffer_size); | ||
113 | |||
114 | #ifdef _WIN32 | 105 | #ifdef _WIN32 |
115 | #pragma pack(pop) | 106 | #pragma pack(pop) |
116 | #endif | 107 | #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 @@ | |||
33 | #include "syntax.h" | 33 | #include "syntax.h" |
34 | #include "drc.h" | 34 | #include "drc.h" |
35 | 35 | ||
36 | /* static variables */ | ||
37 | static drc_info s_drc_info; | ||
38 | |||
36 | drc_info *drc_init(real_t cut, real_t boost) | 39 | drc_info *drc_init(real_t cut, real_t boost) |
37 | { | 40 | { |
38 | drc_info *drc = (drc_info*)faad_malloc(sizeof(drc_info)); | 41 | drc_info *drc = &s_drc_info; |
39 | memset(drc, 0, sizeof(drc_info)); | 42 | memset(drc, 0, sizeof(drc_info)); |
40 | 43 | ||
41 | drc->ctrl1 = cut; | 44 | drc->ctrl1 = cut; |
@@ -49,11 +52,6 @@ drc_info *drc_init(real_t cut, real_t boost) | |||
49 | return drc; | 52 | return drc; |
50 | } | 53 | } |
51 | 54 | ||
52 | void drc_end(drc_info *drc) | ||
53 | { | ||
54 | if (drc) faad_free(drc); | ||
55 | } | ||
56 | |||
57 | #ifdef FIXED_POINT | 55 | #ifdef FIXED_POINT |
58 | static real_t drc_pow2_table[] = | 56 | static real_t drc_pow2_table[] = |
59 | { | 57 | { |
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" { | |||
36 | 36 | ||
37 | 37 | ||
38 | drc_info *drc_init(real_t cut, real_t boost); | 38 | drc_info *drc_init(real_t cut, real_t boost); |
39 | void drc_end(drc_info *drc); | ||
40 | void drc_decode(drc_info *drc, real_t *spec); | 39 | void drc_decode(drc_info *drc, real_t *spec); |
41 | 40 | ||
42 | 41 | ||
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 @@ | |||
41 | #define DECAY_CUTOFF 3 | 41 | #define DECAY_CUTOFF 3 |
42 | #define DECAY_SLOPE 0.05f | 42 | #define DECAY_SLOPE 0.05f |
43 | 43 | ||
44 | /* type definitaions */ | 44 | /* type definitions */ |
45 | typedef const int8_t (*drm_ps_huff_tab)[2]; | 45 | typedef const int8_t (*drm_ps_huff_tab)[2]; |
46 | 46 | ||
47 | 47 | ||
@@ -445,6 +445,8 @@ static const complex_t Phi_Fract_Qmf[] = { | |||
445 | { FRAC_CONST(-0.7396311164), FRAC_CONST(0.6730124950) } | 445 | { FRAC_CONST(-0.7396311164), FRAC_CONST(0.6730124950) } |
446 | }; | 446 | }; |
447 | 447 | ||
448 | /* static variables */ | ||
449 | static drm_ps_info s_drm_ps_info; | ||
448 | 450 | ||
449 | /* static function declarations */ | 451 | /* static function declarations */ |
450 | static void drm_ps_sa_element(drm_ps_info *ps, bitfile *ld); | 452 | 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, | |||
915 | 917 | ||
916 | drm_ps_info *drm_ps_init(void) | 918 | drm_ps_info *drm_ps_init(void) |
917 | { | 919 | { |
918 | drm_ps_info *ps = (drm_ps_info*)faad_malloc(sizeof(drm_ps_info)); | 920 | drm_ps_info *ps = &s_drm_ps_info; |
919 | |||
920 | memset(ps, 0, sizeof(drm_ps_info)); | 921 | memset(ps, 0, sizeof(drm_ps_info)); |
921 | 922 | ||
922 | return ps; | 923 | return ps; |
923 | } | 924 | } |
924 | 925 | ||
925 | void drm_ps_free(drm_ps_info *ps) | ||
926 | { | ||
927 | faad_free(ps); | ||
928 | } | ||
929 | |||
930 | /* main DRM PS decoding function */ | 926 | /* main DRM PS decoding function */ |
931 | uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, uint32_t samplerate, | 927 | uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, uint32_t samplerate, |
932 | qmf_t X_left[MAX_NTSRPS][64], | 928 | 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 | |||
86 | uint16_t drm_ps_data(drm_ps_info *ps, bitfile *ld); | 86 | uint16_t drm_ps_data(drm_ps_info *ps, bitfile *ld); |
87 | 87 | ||
88 | drm_ps_info *drm_ps_init(void); | 88 | drm_ps_info *drm_ps_init(void); |
89 | void drm_ps_free(drm_ps_info *ps); | ||
90 | 89 | ||
91 | uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, uint32_t samplerate, | 90 | uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, uint32_t samplerate, |
92 | qmf_t X_left[MAX_NTSRPS][64], | 91 | 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 @@ | |||
43 | #include "sine_win.h" | 43 | #include "sine_win.h" |
44 | 44 | ||
45 | 45 | ||
46 | /*Windowing functions borrowed from libwmai*/ | 46 | /* static variables */ |
47 | static real_t transf_buf[2*FRAME_LEN] IBSS_ATTR MEM_ALIGN_ATTR; | ||
48 | #ifdef LTP_DEC | ||
49 | static real_t windowed_buf[2*FRAME_LEN] MEM_ALIGN_ATTR = {0}; | ||
50 | #endif | ||
47 | 51 | ||
52 | |||
53 | /*Windowing functions borrowed from libwmai*/ | ||
48 | #ifdef CPU_ARM | 54 | #ifdef CPU_ARM |
49 | static inline | 55 | static inline |
50 | void vector_fmul_add_add(real_t *dst, const real_t *src0, const real_t *src1, const real_t *src2, int len) | 56 | 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 | |||
196 | } | 202 | } |
197 | #endif | 203 | #endif |
198 | 204 | ||
199 | real_t transf_buf[2*1024] IBSS_ATTR MEM_ALIGN_ATTR; | ||
200 | |||
201 | void ifilter_bank(uint8_t window_sequence, uint8_t window_shape, | 205 | void ifilter_bank(uint8_t window_sequence, uint8_t window_shape, |
202 | uint8_t window_shape_prev, real_t *freq_in, | 206 | uint8_t window_shape_prev, real_t *freq_in, |
203 | real_t *time_out, real_t *overlap, | 207 | real_t *time_out, real_t *overlap, |
@@ -403,7 +407,6 @@ void ifilter_bank(uint8_t window_sequence, uint8_t window_shape, | |||
403 | 407 | ||
404 | 408 | ||
405 | #ifdef LTP_DEC | 409 | #ifdef LTP_DEC |
406 | real_t windowed_buf[2*1024] MEM_ALIGN_ATTR = {0}; | ||
407 | /* only works for LTP -> no overlapping, no short blocks */ | 410 | /* only works for LTP -> no overlapping, no short blocks */ |
408 | void filter_bank_ltp(fb_info *fb, uint8_t window_sequence, uint8_t window_shape, | 411 | void filter_bank_ltp(fb_info *fb, uint8_t window_sequence, uint8_t window_shape, |
409 | uint8_t window_shape_prev, real_t *in_data, real_t *out_mdct, | 412 | 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 | |||
152 | uint8_t resolution20[3]; | 152 | uint8_t resolution20[3]; |
153 | uint8_t resolution34[5]; | 153 | uint8_t resolution34[5]; |
154 | 154 | ||
155 | qmf_t *work; | 155 | qmf_t work[32+12]; |
156 | qmf_t **buffer; | 156 | qmf_t buffer[5][32]; |
157 | qmf_t **temp; | 157 | qmf_t temp[32][12]; |
158 | } hyb_info; | 158 | } hyb_info; |
159 | 159 | ||
160 | |||
161 | /* static variables */ | ||
162 | #ifdef FAAD_STATIC_ALLOC | ||
163 | static hyb_info s_hyb_info; | ||
164 | static ps_info s_ps_info; | ||
165 | #endif | ||
166 | |||
160 | /* static function declarations */ | 167 | /* static function declarations */ |
161 | static void ps_data_decode(ps_info *ps); | 168 | static void ps_data_decode(ps_info *ps); |
162 | static hyb_info *hybrid_init(void); | 169 | static hyb_info *hybrid_init(void); |
163 | static void channel_filter2(hyb_info *hyb, uint8_t frame_len, const real_t *filter, | 170 | static void channel_filter2(hyb_info *hyb, uint8_t frame_len, const real_t *filter, |
164 | qmf_t *buffer, qmf_t **X_hybrid); | 171 | qmf_t *buffer, qmf_t X_hybrid[32][12]); |
165 | static INLINE void DCT3_4_unscaled(real_t *y, real_t *x); | 172 | static INLINE void DCT3_4_unscaled(real_t *y, real_t *x); |
166 | static void channel_filter8(hyb_info *hyb, uint8_t frame_len, const real_t *filter, | 173 | static void channel_filter8(hyb_info *hyb, uint8_t frame_len, const real_t *filter, |
167 | qmf_t *buffer, qmf_t **X_hybrid); | 174 | qmf_t *buffer, qmf_t X_hybrid[32][12]); |
168 | static void hybrid_analysis(hyb_info *hyb, qmf_t X[32][64], qmf_t X_hybrid[32][32], | 175 | static void hybrid_analysis(hyb_info *hyb, qmf_t X[32][64], qmf_t X_hybrid[32][32], |
169 | uint8_t use34); | 176 | uint8_t use34); |
170 | static void hybrid_synthesis(hyb_info *hyb, qmf_t X[32][64], qmf_t X_hybrid[32][32], | 177 | 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, | |||
197 | 204 | ||
198 | static hyb_info *hybrid_init() | 205 | static hyb_info *hybrid_init() |
199 | { | 206 | { |
200 | uint8_t i; | 207 | #ifdef FAAD_STATIC_ALLOC |
201 | 208 | hyb_info *hyb = &s_hyb_info; | |
209 | #else | ||
202 | hyb_info *hyb = (hyb_info*)faad_malloc(sizeof(hyb_info)); | 210 | hyb_info *hyb = (hyb_info*)faad_malloc(sizeof(hyb_info)); |
211 | #endif | ||
203 | 212 | ||
204 | hyb->resolution34[0] = 12; | 213 | hyb->resolution34[0] = 12; |
205 | hyb->resolution34[1] = 8; | 214 | hyb->resolution34[1] = 8; |
@@ -213,52 +222,16 @@ static hyb_info *hybrid_init() | |||
213 | 222 | ||
214 | hyb->frame_len = 32; | 223 | hyb->frame_len = 32; |
215 | 224 | ||
216 | hyb->work = (qmf_t*)faad_malloc((hyb->frame_len+12) * sizeof(qmf_t)); | 225 | memset(hyb->work , 0, sizeof(hyb->work)); |
217 | memset(hyb->work, 0, (hyb->frame_len+12) * sizeof(qmf_t)); | 226 | memset(hyb->buffer, 0, sizeof(hyb->buffer)); |
218 | 227 | memset(hyb->temp , 0, sizeof(hyb->temp)); | |
219 | hyb->buffer = (qmf_t**)faad_malloc(5 * sizeof(qmf_t*)); | ||
220 | for (i = 0; i < 5; i++) | ||
221 | { | ||
222 | hyb->buffer[i] = (qmf_t*)faad_malloc(hyb->frame_len * sizeof(qmf_t)); | ||
223 | memset(hyb->buffer[i], 0, hyb->frame_len * sizeof(qmf_t)); | ||
224 | } | ||
225 | |||
226 | hyb->temp = (qmf_t**)faad_malloc(hyb->frame_len * sizeof(qmf_t*)); | ||
227 | for (i = 0; i < hyb->frame_len; i++) | ||
228 | { | ||
229 | hyb->temp[i] = (qmf_t*)faad_malloc(12 /*max*/ * sizeof(qmf_t)); | ||
230 | } | ||
231 | 228 | ||
232 | return hyb; | 229 | return hyb; |
233 | } | 230 | } |
234 | 231 | ||
235 | static void hybrid_free(hyb_info *hyb) | ||
236 | { | ||
237 | uint8_t i; | ||
238 | |||
239 | if (hyb->work) | ||
240 | faad_free(hyb->work); | ||
241 | |||
242 | for (i = 0; i < 5; i++) | ||
243 | { | ||
244 | if (hyb->buffer[i]) | ||
245 | faad_free(hyb->buffer[i]); | ||
246 | } | ||
247 | if (hyb->buffer) | ||
248 | faad_free(hyb->buffer); | ||
249 | |||
250 | for (i = 0; i < hyb->frame_len; i++) | ||
251 | { | ||
252 | if (hyb->temp[i]) | ||
253 | faad_free(hyb->temp[i]); | ||
254 | } | ||
255 | if (hyb->temp) | ||
256 | faad_free(hyb->temp); | ||
257 | } | ||
258 | |||
259 | /* real filter, size 2 */ | 232 | /* real filter, size 2 */ |
260 | static void channel_filter2(hyb_info *hyb, uint8_t frame_len, const real_t *filter, | 233 | static void channel_filter2(hyb_info *hyb, uint8_t frame_len, const real_t *filter, |
261 | qmf_t *buffer, qmf_t **X_hybrid) | 234 | qmf_t *buffer, qmf_t X_hybrid[32][12]) |
262 | { | 235 | { |
263 | uint8_t i; | 236 | uint8_t i; |
264 | 237 | ||
@@ -292,7 +265,7 @@ static void channel_filter2(hyb_info *hyb, uint8_t frame_len, const real_t *filt | |||
292 | 265 | ||
293 | /* complex filter, size 4 */ | 266 | /* complex filter, size 4 */ |
294 | static void channel_filter4(hyb_info *hyb, uint8_t frame_len, const real_t *filter, | 267 | static void channel_filter4(hyb_info *hyb, uint8_t frame_len, const real_t *filter, |
295 | qmf_t *buffer, qmf_t **X_hybrid) | 268 | qmf_t *buffer, qmf_t X_hybrid[32][12]) |
296 | { | 269 | { |
297 | uint8_t i; | 270 | uint8_t i; |
298 | real_t input_re1[2], input_re2[2], input_im1[2], input_im2[2]; | 271 | real_t input_re1[2], input_re2[2], input_im1[2], input_im2[2]; |
@@ -367,7 +340,7 @@ static INLINE void DCT3_4_unscaled(real_t *y, real_t *x) | |||
367 | 340 | ||
368 | /* complex filter, size 8 */ | 341 | /* complex filter, size 8 */ |
369 | static void channel_filter8(hyb_info *hyb, uint8_t frame_len, const real_t *filter, | 342 | static void channel_filter8(hyb_info *hyb, uint8_t frame_len, const real_t *filter, |
370 | qmf_t *buffer, qmf_t **X_hybrid) | 343 | qmf_t *buffer, qmf_t X_hybrid[32][12]) |
371 | { | 344 | { |
372 | uint8_t i, n; | 345 | uint8_t i, n; |
373 | real_t input_re1[4], input_re2[4], input_im1[4], input_im2[4]; | 346 | real_t input_re1[4], input_re2[4], input_im1[4], input_im2[4]; |
@@ -460,7 +433,7 @@ static INLINE void DCT3_6_unscaled(real_t *y, real_t *x) | |||
460 | 433 | ||
461 | /* complex filter, size 12 */ | 434 | /* complex filter, size 12 */ |
462 | static void channel_filter12(hyb_info *hyb, uint8_t frame_len, const real_t *filter, | 435 | static void channel_filter12(hyb_info *hyb, uint8_t frame_len, const real_t *filter, |
463 | qmf_t *buffer, qmf_t **X_hybrid) | 436 | qmf_t *buffer, qmf_t X_hybrid[32][12]) |
464 | { | 437 | { |
465 | uint8_t i, n; | 438 | uint8_t i, n; |
466 | real_t input_re1[6], input_re2[6], input_im1[6], input_im2[6]; | 439 | real_t input_re1[6], input_re2[6], input_im1[6], input_im2[6]; |
@@ -1848,20 +1821,16 @@ static void ps_mix_phase(ps_info *ps, | |||
1848 | } | 1821 | } |
1849 | } | 1822 | } |
1850 | 1823 | ||
1851 | void ps_free(ps_info *ps) | ||
1852 | { | ||
1853 | /* free hybrid filterbank structures */ | ||
1854 | hybrid_free(ps->hyb); | ||
1855 | |||
1856 | faad_free(ps); | ||
1857 | } | ||
1858 | |||
1859 | ps_info *ps_init(uint8_t sr_index) | 1824 | ps_info *ps_init(uint8_t sr_index) |
1860 | { | 1825 | { |
1861 | uint8_t i; | 1826 | uint8_t i; |
1862 | uint8_t short_delay_band; | 1827 | uint8_t short_delay_band; |
1863 | 1828 | ||
1829 | #ifdef FAAD_STATIC_ALLOC | ||
1830 | ps_info *ps = &s_ps_info; | ||
1831 | #else | ||
1864 | ps_info *ps = (ps_info*)faad_malloc(sizeof(ps_info)); | 1832 | ps_info *ps = (ps_info*)faad_malloc(sizeof(ps_info)); |
1833 | #endif | ||
1865 | memset(ps, 0, sizeof(ps_info)); | 1834 | memset(ps, 0, sizeof(ps_info)); |
1866 | 1835 | ||
1867 | (void)sr_index; | 1836 | (void)sr_index; |
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); | |||
138 | 138 | ||
139 | /* ps_dec.c */ | 139 | /* ps_dec.c */ |
140 | ps_info *ps_init(uint8_t sr_index); | 140 | ps_info *ps_init(uint8_t sr_index); |
141 | void ps_free(ps_info *ps); | ||
142 | 141 | ||
143 | uint8_t ps_decode(ps_info *ps, | 142 | uint8_t ps_decode(ps_info *ps, |
144 | qmf_t X_left[MAX_NTSRPS][64], | 143 | 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 = { | |||
1525 | }; | 1525 | }; |
1526 | 1526 | ||
1527 | // Table adapted from codeclib to fit into IRAM | 1527 | // Table adapted from codeclib to fit into IRAM |
1528 | const uint32_t dct4_revtab[32] ICONST_ATTR MEM_ALIGN_ATTR = { | 1528 | static const uint32_t dct4_revtab[32] ICONST_ATTR MEM_ALIGN_ATTR = { |
1529 | 0, 24, 12, 22, 6, 30, 11, 19, 3, 27, 15, 21, 5, 29, 9, 17, | 1529 | 0, 24, 12, 22, 6, 30, 11, 19, 3, 27, 15, 21, 5, 29, 9, 17, |
1530 | 1, 25, 13, 23, 7, 31, 10, 18, 2, 26, 14, 20, 4, 28, 8, 16}; | 1530 | 1, 25, 13, 23, 7, 31, 10, 18, 2, 26, 14, 20, 4, 28, 8, 16}; |
1531 | 1531 | ||
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 @@ | |||
41 | #include "sbr_hfgen.h" | 41 | #include "sbr_hfgen.h" |
42 | #include "sbr_hfadj.h" | 42 | #include "sbr_hfadj.h" |
43 | 43 | ||
44 | 44 | /* type definitons */ | |
45 | /* globals */ | 45 | typedef struct { |
46 | #if (defined(PS_DEC) || defined(DRM_PS)) | 46 | #if (defined(PS_DEC) || defined(DRM_PS)) |
47 | /* In case of PS_DEC or DRM_PS we need larger buffer data when calling | 47 | /* In case of PS_DEC or DRM_PS we need larger buffer data when calling |
48 | * ps_decode() or drm_ps_decode(). */ | 48 | * ps_decode() or drm_ps_decode(). */ |
49 | static qmf_t X_left [MAX_NTSRPS][64] IBSS_ATTR_FAAD_XLARGE_IRAM MEM_ALIGN_ATTR; | 49 | qmf_t X_L[MAX_NTSRPS][64]; |
50 | static qmf_t X_right[MAX_NTSRPS][64] IBSS_ATTR_FAAD_XLARGE_IRAM MEM_ALIGN_ATTR; | 50 | qmf_t X_R[MAX_NTSRPS][64]; |
51 | #else | 51 | #else |
52 | /* No PS functions called. Keep using MAX_NTSR as array size. */ | 52 | /* No PS functions called. Keep using MAX_NTSR as array size. */ |
53 | static qmf_t X_left [MAX_NTSR][64] IBSS_ATTR_FAAD_XLARGE_IRAM MEM_ALIGN_ATTR; | 53 | qmf_t X_L[MAX_NTSR][64]; |
54 | static qmf_t X_right[MAX_NTSR][64] IBSS_ATTR_FAAD_XLARGE_IRAM MEM_ALIGN_ATTR; | 54 | qmf_t X_R[MAX_NTSR][64]; |
55 | #endif | 55 | #endif |
56 | } XLR_t; | ||
56 | 57 | ||
58 | /* static variables */ | ||
59 | static XLR_t *p_XLR = NULL; | ||
60 | #if defined(FAAD_STATIC_ALLOC) || defined(FAAD_HAVE_XLR_IN_IRAM) | ||
61 | static XLR_t s_XLR IBSS_ATTR MEM_ALIGN_ATTR; | ||
62 | #endif | ||
63 | #if defined(FAAD_STATIC_ALLOC) | ||
64 | static sbr_info s_sbr[MAX_SYNTAX_ELEMENTS]; | ||
65 | #endif | ||
66 | #ifdef SBR_LOW_POWER | ||
67 | static real_t deg[64] MEM_ALIGN_ATTR; | ||
68 | #endif | ||
57 | 69 | ||
58 | /* static function declarations */ | 70 | /* static function declarations */ |
59 | static uint8_t sbr_save_prev_data(sbr_info *sbr, uint8_t ch); | 71 | static uint8_t sbr_save_prev_data(sbr_info *sbr, uint8_t ch); |
60 | static void sbr_save_matrix(sbr_info *sbr, uint8_t ch); | 72 | static void sbr_save_matrix(sbr_info *sbr, uint8_t ch); |
61 | 73 | ||
62 | 74 | ||
63 | sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac, | 75 | sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac, uint8_t id_ele, |
64 | uint32_t sample_rate, uint8_t downSampledSBR | 76 | uint32_t sample_rate, uint8_t downSampledSBR |
65 | #ifdef DRM | 77 | #ifdef DRM |
66 | , uint8_t IsDRM | 78 | , uint8_t IsDRM |
67 | #endif | 79 | #endif |
68 | ) | 80 | ) |
69 | { | 81 | { |
70 | sbr_info *sbr = faad_malloc(sizeof(sbr_info)); | 82 | (void)downSampledSBR; |
83 | |||
84 | /* Allocate sbr_info. */ | ||
85 | #if defined(FAAD_STATIC_ALLOC) | ||
86 | sbr_info *sbr = &s_sbr[id_ele]; | ||
87 | #else | ||
88 | (void)id_ele; | ||
89 | sbr_info *sbr =(sbr_info*)faad_malloc(sizeof(sbr_info)); | ||
90 | #endif | ||
71 | memset(sbr, 0, sizeof(sbr_info)); | 91 | memset(sbr, 0, sizeof(sbr_info)); |
92 | |||
93 | /* Allocate XLR temporary variable. Use static allocation if either | ||
94 | * FAAD_STATIC_ALLOC is set or XLR fits to IRAM. */ | ||
95 | #if defined(FAAD_STATIC_ALLOC) || defined(FAAD_HAVE_XLR_IN_IRAM) | ||
96 | p_XLR = &s_XLR; | ||
97 | #else | ||
98 | p_XLR =(XLR_t*)faad_malloc(sizeof(XLR_t)); | ||
99 | #endif | ||
100 | memset(p_XLR, 0, sizeof(XLR_t)); | ||
72 | 101 | ||
73 | /* save id of the parent element */ | 102 | /* save id of the parent element */ |
74 | sbr->id_aac = id_aac; | 103 | sbr->id_aac = id_aac; |
@@ -115,80 +144,15 @@ sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac, | |||
115 | sbr->GQ_ringbuf_index[0] = 0; | 144 | sbr->GQ_ringbuf_index[0] = 0; |
116 | sbr->GQ_ringbuf_index[1] = 0; | 145 | sbr->GQ_ringbuf_index[1] = 0; |
117 | 146 | ||
118 | if (id_aac == ID_CPE) | 147 | memset(sbr->qmfa, 0, 2*sizeof(qmfa_info)); |
119 | { | 148 | memset(sbr->qmfs, 0, 2*sizeof(qmfs_info)); |
120 | /* stereo */ | ||
121 | uint8_t j; | ||
122 | sbr->qmfa[0] = qmfa_init(32); | ||
123 | sbr->qmfa[1] = qmfa_init(32); | ||
124 | sbr->qmfs[0] = qmfs_init((downSampledSBR)?32:64); | ||
125 | sbr->qmfs[1] = qmfs_init((downSampledSBR)?32:64); | ||
126 | |||
127 | for (j = 0; j < 5; j++) | ||
128 | { | ||
129 | sbr->G_temp_prev[0][j] = faad_malloc(64*sizeof(real_t)); | ||
130 | sbr->G_temp_prev[1][j] = faad_malloc(64*sizeof(real_t)); | ||
131 | sbr->Q_temp_prev[0][j] = faad_malloc(64*sizeof(real_t)); | ||
132 | sbr->Q_temp_prev[1][j] = faad_malloc(64*sizeof(real_t)); | ||
133 | } | ||
134 | 149 | ||
135 | memset(sbr->Xsbr[0], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t)); | 150 | memset(sbr->Xsbr[0], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t)); |
136 | memset(sbr->Xsbr[1], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t)); | 151 | memset(sbr->Xsbr[1], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t)); |
137 | } else { | ||
138 | /* mono */ | ||
139 | uint8_t j; | ||
140 | sbr->qmfa[0] = qmfa_init(32); | ||
141 | sbr->qmfs[0] = qmfs_init((downSampledSBR)?32:64); | ||
142 | sbr->qmfs[1] = NULL; | ||
143 | |||
144 | for (j = 0; j < 5; j++) | ||
145 | { | ||
146 | sbr->G_temp_prev[0][j] = faad_malloc(64*sizeof(real_t)); | ||
147 | sbr->Q_temp_prev[0][j] = faad_malloc(64*sizeof(real_t)); | ||
148 | } | ||
149 | |||
150 | memset(sbr->Xsbr[0], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t)); | ||
151 | } | ||
152 | 152 | ||
153 | return sbr; | 153 | return sbr; |
154 | } | 154 | } |
155 | 155 | ||
156 | void sbrDecodeEnd(sbr_info *sbr) | ||
157 | { | ||
158 | uint8_t j; | ||
159 | |||
160 | if (sbr) | ||
161 | { | ||
162 | qmfa_end(sbr->qmfa[0]); | ||
163 | qmfs_end(sbr->qmfs[0]); | ||
164 | if (sbr->qmfs[1] != NULL) | ||
165 | { | ||
166 | qmfa_end(sbr->qmfa[1]); | ||
167 | qmfs_end(sbr->qmfs[1]); | ||
168 | } | ||
169 | |||
170 | for (j = 0; j < 5; j++) | ||
171 | { | ||
172 | if (sbr->G_temp_prev[0][j]) faad_free(sbr->G_temp_prev[0][j]); | ||
173 | if (sbr->Q_temp_prev[0][j]) faad_free(sbr->Q_temp_prev[0][j]); | ||
174 | if (sbr->G_temp_prev[1][j]) faad_free(sbr->G_temp_prev[1][j]); | ||
175 | if (sbr->Q_temp_prev[1][j]) faad_free(sbr->Q_temp_prev[1][j]); | ||
176 | } | ||
177 | |||
178 | #ifdef PS_DEC | ||
179 | if (sbr->ps != NULL) | ||
180 | ps_free(sbr->ps); | ||
181 | #endif | ||
182 | |||
183 | #ifdef DRM_PS | ||
184 | if (sbr->drm_ps != NULL) | ||
185 | drm_ps_free(sbr->drm_ps); | ||
186 | #endif | ||
187 | |||
188 | faad_free(sbr); | ||
189 | } | ||
190 | } | ||
191 | |||
192 | static uint8_t sbr_save_prev_data(sbr_info *sbr, uint8_t ch) | 156 | static uint8_t sbr_save_prev_data(sbr_info *sbr, uint8_t ch) |
193 | { | 157 | { |
194 | uint8_t i; | 158 | uint8_t i; |
@@ -239,10 +203,6 @@ static void sbr_save_matrix(sbr_info *sbr, uint8_t ch) | |||
239 | } | 203 | } |
240 | } | 204 | } |
241 | 205 | ||
242 | #ifdef SBR_LOW_POWER | ||
243 | real_t deg[64] MEM_ALIGN_ATTR; | ||
244 | #endif | ||
245 | |||
246 | static void sbr_process_channel(sbr_info *sbr, real_t *channel_buf, qmf_t X[MAX_NTSR][64], | 206 | static void sbr_process_channel(sbr_info *sbr, real_t *channel_buf, qmf_t X[MAX_NTSR][64], |
247 | uint8_t ch, uint8_t dont_process, | 207 | uint8_t ch, uint8_t dont_process, |
248 | const uint8_t downSampledSBR) | 208 | const uint8_t downSampledSBR) |
@@ -276,9 +236,9 @@ static void sbr_process_channel(sbr_info *sbr, real_t *channel_buf, qmf_t X[MAX_ | |||
276 | 236 | ||
277 | /* subband analysis */ | 237 | /* subband analysis */ |
278 | if (dont_process) | 238 | if (dont_process) |
279 | sbr_qmf_analysis_32(sbr, sbr->qmfa[ch], channel_buf, sbr->Xsbr[ch], sbr->tHFGen, 32); | 239 | sbr_qmf_analysis_32(sbr, &sbr->qmfa[ch], channel_buf, sbr->Xsbr[ch], sbr->tHFGen, 32); |
280 | else | 240 | else |
281 | sbr_qmf_analysis_32(sbr, sbr->qmfa[ch], channel_buf, sbr->Xsbr[ch], sbr->tHFGen, sbr->kx); | 241 | sbr_qmf_analysis_32(sbr, &sbr->qmfa[ch], channel_buf, sbr->Xsbr[ch], sbr->tHFGen, sbr->kx); |
282 | 242 | ||
283 | if (!dont_process) | 243 | if (!dont_process) |
284 | { | 244 | { |
@@ -413,22 +373,22 @@ uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_cha | |||
413 | sbr->just_seeked = 0; | 373 | sbr->just_seeked = 0; |
414 | } | 374 | } |
415 | 375 | ||
416 | sbr_process_channel(sbr, left_chan, X_left, 0, dont_process, downSampledSBR); | 376 | sbr_process_channel(sbr, left_chan, p_XLR->X_L, 0, dont_process, downSampledSBR); |
417 | /* subband synthesis */ | 377 | /* subband synthesis */ |
418 | if (downSampledSBR) | 378 | if (downSampledSBR) |
419 | { | 379 | { |
420 | sbr_qmf_synthesis_32(sbr, sbr->qmfs[0], X_left, left_chan); | 380 | sbr_qmf_synthesis_32(sbr, &sbr->qmfs[0], p_XLR->X_L, left_chan); |
421 | } else { | 381 | } else { |
422 | sbr_qmf_synthesis_64(sbr, sbr->qmfs[0], X_left, left_chan); | 382 | sbr_qmf_synthesis_64(sbr, &sbr->qmfs[0], p_XLR->X_L, left_chan); |
423 | } | 383 | } |
424 | 384 | ||
425 | sbr_process_channel(sbr, right_chan, X_right, 1, dont_process, downSampledSBR); | 385 | sbr_process_channel(sbr, right_chan, p_XLR->X_R, 1, dont_process, downSampledSBR); |
426 | /* subband synthesis */ | 386 | /* subband synthesis */ |
427 | if (downSampledSBR) | 387 | if (downSampledSBR) |
428 | { | 388 | { |
429 | sbr_qmf_synthesis_32(sbr, sbr->qmfs[1], X_right, right_chan); | 389 | sbr_qmf_synthesis_32(sbr, &sbr->qmfs[1], p_XLR->X_R, right_chan); |
430 | } else { | 390 | } else { |
431 | sbr_qmf_synthesis_64(sbr, sbr->qmfs[1], X_right, right_chan); | 391 | sbr_qmf_synthesis_64(sbr, &sbr->qmfs[1], p_XLR->X_R, right_chan); |
432 | } | 392 | } |
433 | 393 | ||
434 | if (sbr->bs_header_flag) | 394 | if (sbr->bs_header_flag) |
@@ -495,13 +455,13 @@ uint8_t sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel, | |||
495 | sbr->just_seeked = 0; | 455 | sbr->just_seeked = 0; |
496 | } | 456 | } |
497 | 457 | ||
498 | sbr_process_channel(sbr, channel, X_left, 0, dont_process, downSampledSBR); | 458 | sbr_process_channel(sbr, channel, p_XLR->X_L, 0, dont_process, downSampledSBR); |
499 | /* subband synthesis */ | 459 | /* subband synthesis */ |
500 | if (downSampledSBR) | 460 | if (downSampledSBR) |
501 | { | 461 | { |
502 | sbr_qmf_synthesis_32(sbr, sbr->qmfs[0], X_left, channel); | 462 | sbr_qmf_synthesis_32(sbr, &sbr->qmfs[0], p_XLR->X_L, channel); |
503 | } else { | 463 | } else { |
504 | sbr_qmf_synthesis_64(sbr, sbr->qmfs[0], X_left, channel); | 464 | sbr_qmf_synthesis_64(sbr, &sbr->qmfs[0], p_XLR->X_L, channel); |
505 | } | 465 | } |
506 | 466 | ||
507 | if (sbr->bs_header_flag) | 467 | if (sbr->bs_header_flag) |
@@ -540,8 +500,8 @@ uint8_t sbrDecodeSingleFramePS(sbr_info *sbr, real_t *left_channel, real_t *righ | |||
540 | uint8_t dont_process = 0; | 500 | uint8_t dont_process = 0; |
541 | uint8_t ret = 0; | 501 | uint8_t ret = 0; |
542 | 502 | ||
543 | memset(X_left,0,sizeof(X_left)); | 503 | memset(p_XLR->X_L, 0, sizeof(*p_XLR->X_L)); |
544 | memset(X_right,0,sizeof(X_right)); | 504 | memset(p_XLR->X_R, 0, sizeof(*p_XLR->X_R)); |
545 | if (sbr == NULL) | 505 | if (sbr == NULL) |
546 | return 20; | 506 | return 20; |
547 | 507 | ||
@@ -566,20 +526,15 @@ uint8_t sbrDecodeSingleFramePS(sbr_info *sbr, real_t *left_channel, real_t *righ | |||
566 | sbr->just_seeked = 0; | 526 | sbr->just_seeked = 0; |
567 | } | 527 | } |
568 | 528 | ||
569 | if (sbr->qmfs[1] == NULL) | 529 | sbr_process_channel(sbr, left_channel, p_XLR->X_L, 0, dont_process, downSampledSBR); |
570 | { | ||
571 | sbr->qmfs[1] = qmfs_init((downSampledSBR)?32:64); | ||
572 | } | ||
573 | |||
574 | sbr_process_channel(sbr, left_channel, X_left, 0, dont_process, downSampledSBR); | ||
575 | 530 | ||
576 | /* copy some extra data for PS */ | 531 | /* copy some extra data for PS */ |
577 | for (l = 32; l < 38; l++) | 532 | for (l = 32; l < 38; l++) |
578 | { | 533 | { |
579 | for (k = 0; k < 5; k++) | 534 | for (k = 0; k < 5; k++) |
580 | { | 535 | { |
581 | QMF_RE(X_left[l][k]) = QMF_RE(sbr->Xsbr[0][sbr->tHFAdj+l][k]); | 536 | QMF_RE(p_XLR->X_L[l][k]) = QMF_RE(sbr->Xsbr[0][sbr->tHFAdj+l][k]); |
582 | QMF_IM(X_left[l][k]) = QMF_IM(sbr->Xsbr[0][sbr->tHFAdj+l][k]); | 537 | QMF_IM(p_XLR->X_L[l][k]) = QMF_IM(sbr->Xsbr[0][sbr->tHFAdj+l][k]); |
583 | } | 538 | } |
584 | } | 539 | } |
585 | 540 | ||
@@ -587,11 +542,11 @@ uint8_t sbrDecodeSingleFramePS(sbr_info *sbr, real_t *left_channel, real_t *righ | |||
587 | #ifdef DRM_PS | 542 | #ifdef DRM_PS |
588 | if (sbr->Is_DRM_SBR) | 543 | if (sbr->Is_DRM_SBR) |
589 | { | 544 | { |
590 | drm_ps_decode(sbr->drm_ps, (sbr->ret > 0), sbr->sample_rate, X_left, X_right); | 545 | drm_ps_decode(sbr->drm_ps, (sbr->ret > 0), sbr->sample_rate, p_XLR->X_L, p_XLR->X_R); |
591 | } else { | 546 | } else { |
592 | #endif | 547 | #endif |
593 | #ifdef PS_DEC | 548 | #ifdef PS_DEC |
594 | ps_decode(sbr->ps, X_left, X_right); | 549 | ps_decode(sbr->ps, p_XLR->X_L, p_XLR->X_R); |
595 | #endif | 550 | #endif |
596 | #ifdef DRM_PS | 551 | #ifdef DRM_PS |
597 | } | 552 | } |
@@ -600,11 +555,11 @@ uint8_t sbrDecodeSingleFramePS(sbr_info *sbr, real_t *left_channel, real_t *righ | |||
600 | /* subband synthesis */ | 555 | /* subband synthesis */ |
601 | if (downSampledSBR) | 556 | if (downSampledSBR) |
602 | { | 557 | { |
603 | sbr_qmf_synthesis_32(sbr, sbr->qmfs[0], X_left, left_channel); | 558 | sbr_qmf_synthesis_32(sbr, &sbr->qmfs[0], p_XLR->X_L, left_channel); |
604 | sbr_qmf_synthesis_32(sbr, sbr->qmfs[1], X_right, right_channel); | 559 | sbr_qmf_synthesis_32(sbr, &sbr->qmfs[1], p_XLR->X_R, right_channel); |
605 | } else { | 560 | } else { |
606 | sbr_qmf_synthesis_64(sbr, sbr->qmfs[0], X_left, left_channel); | 561 | sbr_qmf_synthesis_64(sbr, &sbr->qmfs[0], p_XLR->X_L, left_channel); |
607 | sbr_qmf_synthesis_64(sbr, sbr->qmfs[1], X_right, right_channel); | 562 | sbr_qmf_synthesis_64(sbr, &sbr->qmfs[1], p_XLR->X_R, right_channel); |
608 | } | 563 | } |
609 | 564 | ||
610 | if (sbr->bs_header_flag) | 565 | 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" { | |||
48 | #define MAX_L_E 5 | 48 | #define MAX_L_E 5 |
49 | 49 | ||
50 | typedef struct { | 50 | typedef struct { |
51 | real_t *x; | 51 | real_t x[2*32*10]; |
52 | int16_t x_index; | 52 | int16_t x_index; |
53 | uint8_t channels; | ||
54 | } qmfa_info; | 53 | } qmfa_info; |
55 | 54 | ||
56 | typedef struct { | 55 | typedef struct { |
57 | real_t *v; | 56 | real_t v[2*64*20]; /* Size was "(downSampledSBR)?32:64". We use 64 now. */ |
58 | int16_t v_index; | 57 | int16_t v_index; |
59 | uint8_t channels; | ||
60 | } qmfs_info; | 58 | } qmfs_info; |
61 | 59 | ||
62 | typedef struct | 60 | typedef struct |
@@ -105,8 +103,8 @@ typedef struct | |||
105 | uint8_t f[2][MAX_L_E+1]; | 103 | uint8_t f[2][MAX_L_E+1]; |
106 | uint8_t f_prev[2]; | 104 | uint8_t f_prev[2]; |
107 | 105 | ||
108 | real_t *G_temp_prev[2][5]; | 106 | real_t G_temp_prev[2][5][64]; |
109 | real_t *Q_temp_prev[2][5]; | 107 | real_t Q_temp_prev[2][5][64]; |
110 | int8_t GQ_ringbuf_index[2]; | 108 | int8_t GQ_ringbuf_index[2]; |
111 | 109 | ||
112 | int16_t E[2][64][MAX_L_E]; | 110 | int16_t E[2][64][MAX_L_E]; |
@@ -160,10 +158,10 @@ typedef struct | |||
160 | uint32_t header_count; | 158 | uint32_t header_count; |
161 | 159 | ||
162 | uint8_t id_aac; | 160 | uint8_t id_aac; |
163 | qmfa_info *qmfa[2]; | 161 | qmfa_info qmfa[2] MEM_ALIGN_ATTR; |
164 | qmfs_info *qmfs[2]; | 162 | qmfs_info qmfs[2] MEM_ALIGN_ATTR; |
165 | 163 | ||
166 | qmf_t Xsbr[2][MAX_NTSRHFG][64]; | 164 | qmf_t Xsbr[2][MAX_NTSRHFG][64] MEM_ALIGN_ATTR; |
167 | 165 | ||
168 | #ifdef DRM | 166 | #ifdef DRM |
169 | uint8_t Is_DRM_SBR; | 167 | uint8_t Is_DRM_SBR; |
@@ -223,13 +221,12 @@ typedef struct | |||
223 | uint8_t bs_df_noise[2][3]; | 221 | uint8_t bs_df_noise[2][3]; |
224 | } sbr_info; | 222 | } sbr_info; |
225 | 223 | ||
226 | sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac, | 224 | sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac, uint8_t id_ele, |
227 | uint32_t sample_rate, uint8_t downSampledSBR | 225 | uint32_t sample_rate, uint8_t downSampledSBR |
228 | #ifdef DRM | 226 | #ifdef DRM |
229 | , uint8_t IsDRM | 227 | , uint8_t IsDRM |
230 | #endif | 228 | #endif |
231 | ); | 229 | ); |
232 | void sbrDecodeEnd(sbr_info *sbr); | ||
233 | 230 | ||
234 | uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan, | 231 | uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan, |
235 | const uint8_t just_seeked, const uint8_t downSampledSBR); | 232 | 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] = { | |||
231 | 231 | ||
232 | /* calculates 1/(1+Q) */ | 232 | /* calculates 1/(1+Q) */ |
233 | /* [0..1] */ | 233 | /* [0..1] */ |
234 | real_t calc_Q_div(sbr_info *sbr, uint8_t ch, uint8_t m, uint8_t l) | 234 | static real_t calc_Q_div(sbr_info *sbr, uint8_t ch, uint8_t m, uint8_t l) |
235 | { | 235 | { |
236 | if (sbr->bs_coupling) | 236 | if (sbr->bs_coupling) |
237 | { | 237 | { |
@@ -350,7 +350,7 @@ static const real_t Q_div2_tab_right[31][13] = { | |||
350 | 350 | ||
351 | /* calculates Q/(1+Q) */ | 351 | /* calculates Q/(1+Q) */ |
352 | /* [0..1] */ | 352 | /* [0..1] */ |
353 | real_t calc_Q_div2(sbr_info *sbr, uint8_t ch, uint8_t m, uint8_t l) | 353 | static real_t calc_Q_div2(sbr_info *sbr, uint8_t ch, uint8_t m, uint8_t l) |
354 | { | 354 | { |
355 | if (sbr->bs_coupling) | 355 | if (sbr->bs_coupling) |
356 | { | 356 | { |
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); | |||
50 | static void patch_construction(sbr_info *sbr); | 50 | static void patch_construction(sbr_info *sbr); |
51 | 51 | ||
52 | 52 | ||
53 | void hf_generation(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64], | 53 | void hf_generation(sbr_info *sbr, |
54 | qmf_t Xlow[MAX_NTSRHFG][64], | ||
54 | qmf_t Xhigh[MAX_NTSRHFG][64] | 55 | qmf_t Xhigh[MAX_NTSRHFG][64] |
55 | #ifdef SBR_LOW_POWER | 56 | #ifdef SBR_LOW_POWER |
56 | ,real_t *deg | 57 | ,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 @@ | |||
32 | extern "C" { | 32 | extern "C" { |
33 | #endif | 33 | #endif |
34 | 34 | ||
35 | void hf_generation(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64], | 35 | void hf_generation(sbr_info *sbr, |
36 | qmf_t Xlow[MAX_NTSRHFG][64], | ||
36 | qmf_t Xhigh[MAX_NTSRHFG][64] | 37 | qmf_t Xhigh[MAX_NTSRHFG][64] |
37 | #ifdef SBR_LOW_POWER | 38 | #ifdef SBR_LOW_POWER |
38 | ,real_t *deg | 39 | ,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 @@ | |||
50 | #define FAAD_ANALYSIS_SCALE3(X) ((X)/32.0f) | 50 | #define FAAD_ANALYSIS_SCALE3(X) ((X)/32.0f) |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | qmfa_info *qmfa_init(uint8_t channels) | ||
54 | { | ||
55 | qmfa_info *qmfa = (qmfa_info*)faad_malloc(sizeof(qmfa_info)); | ||
56 | |||
57 | /* x is implemented as double ringbuffer */ | ||
58 | qmfa->x = (real_t*)faad_malloc(2 * channels * 10 * sizeof(real_t)); | ||
59 | memset(qmfa->x, 0, 2 * channels * 10 * sizeof(real_t)); | ||
60 | |||
61 | /* ringbuffer index */ | ||
62 | qmfa->x_index = 0; | ||
63 | |||
64 | qmfa->channels = channels; | ||
65 | |||
66 | return qmfa; | ||
67 | } | ||
68 | |||
69 | void qmfa_end(qmfa_info *qmfa) | ||
70 | { | ||
71 | if (qmfa) | ||
72 | { | ||
73 | if (qmfa->x) faad_free(qmfa->x); | ||
74 | faad_free(qmfa); | ||
75 | } | ||
76 | } | ||
77 | 53 | ||
78 | void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input, | 54 | void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input, |
79 | qmf_t X[MAX_NTSR][64], uint8_t offset, uint8_t kx) | 55 | 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, | |||
198 | } | 174 | } |
199 | } | 175 | } |
200 | 176 | ||
201 | qmfs_info *qmfs_init(uint8_t channels) | ||
202 | { | ||
203 | qmfs_info *qmfs = (qmfs_info*)faad_malloc(sizeof(qmfs_info)); | ||
204 | |||
205 | /* v is a double ringbuffer */ | ||
206 | qmfs->v = (real_t*)faad_malloc(2 * channels * 20 * sizeof(real_t)); | ||
207 | memset(qmfs->v, 0, 2 * channels * 20 * sizeof(real_t)); | ||
208 | |||
209 | qmfs->v_index = 0; | ||
210 | |||
211 | qmfs->channels = channels; | ||
212 | |||
213 | return qmfs; | ||
214 | } | ||
215 | |||
216 | void qmfs_end(qmfs_info *qmfs) | ||
217 | { | ||
218 | if (qmfs) | ||
219 | { | ||
220 | if (qmfs->v) faad_free(qmfs->v); | ||
221 | faad_free(qmfs); | ||
222 | } | ||
223 | } | ||
224 | |||
225 | #ifdef SBR_LOW_POWER | 177 | #ifdef SBR_LOW_POWER |
226 | 178 | ||
227 | void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSR][64], | 179 | 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 @@ | |||
32 | extern "C" { | 32 | extern "C" { |
33 | #endif | 33 | #endif |
34 | 34 | ||
35 | qmfa_info *qmfa_init(uint8_t channels); | ||
36 | void qmfa_end(qmfa_info *qmfa); | ||
37 | qmfs_info *qmfs_init(uint8_t channels); | ||
38 | void qmfs_end(qmfs_info *qmfs); | ||
39 | |||
40 | void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input, | 35 | void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input, |
41 | qmf_t X[MAX_NTSR][64], uint8_t offset, uint8_t kx); | 36 | qmf_t X[MAX_NTSR][64], uint8_t offset, uint8_t kx); |
42 | void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSR][64], | 37 | 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 @@ | |||
53 | #include "ssr_fb.h" | 53 | #include "ssr_fb.h" |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | |||
57 | /* static function declarations */ | 56 | /* static function declarations */ |
58 | static uint8_t quant_to_spec(NeAACDecHandle hDecoder, | 57 | static uint8_t quant_to_spec(NeAACDecHandle hDecoder, |
59 | ic_stream *ics, int16_t *quant_data, | 58 | ic_stream *ics, int16_t *quant_data, |
@@ -284,6 +283,11 @@ static const uint16_t *const swb_offset_128_window[] ICONST_ATTR = | |||
284 | 283 | ||
285 | #define bit_set(A, B) ((A) & (1<<(B))) | 284 | #define bit_set(A, B) ((A) & (1<<(B))) |
286 | 285 | ||
286 | /* static variables */ | ||
287 | /* used by reconstruct_single_channel() and reconstruct_channel_pair() */ | ||
288 | static real_t spec_coef1[FRAME_LEN] IBSS_ATTR MEM_ALIGN_ATTR; | ||
289 | static real_t spec_coef2[FRAME_LEN] IBSS_ATTR MEM_ALIGN_ATTR; | ||
290 | |||
287 | /* 4.5.2.3.4 */ | 291 | /* 4.5.2.3.4 */ |
288 | /* | 292 | /* |
289 | - determine the number of windows in a window_sequence named num_windows | 293 | - determine the number of windows in a window_sequence named num_windows |
@@ -648,197 +652,21 @@ static uint8_t quant_to_spec(NeAACDecHandle hDecoder, | |||
648 | static uint8_t allocate_single_channel(NeAACDecHandle hDecoder, uint8_t channel, | 652 | static uint8_t allocate_single_channel(NeAACDecHandle hDecoder, uint8_t channel, |
649 | uint8_t output_channels) | 653 | uint8_t output_channels) |
650 | { | 654 | { |
651 | uint8_t mul = 1; | 655 | (void)output_channels; |
652 | 656 | (void)hDecoder; | |
653 | #ifdef MAIN_DEC | 657 | (void)channel; |
654 | /* MAIN object type prediction */ | ||
655 | if (hDecoder->object_type == MAIN) | ||
656 | { | ||
657 | /* allocate the state only when needed */ | ||
658 | if (hDecoder->pred_stat[channel] == NULL) | ||
659 | { | ||
660 | hDecoder->pred_stat[channel] = (pred_state*)faad_malloc(hDecoder->frameLength * sizeof(pred_state)); | ||
661 | reset_all_predictors(hDecoder->pred_stat[channel], hDecoder->frameLength); | ||
662 | } | ||
663 | } | ||
664 | #endif | ||
665 | |||
666 | #ifdef LTP_DEC | ||
667 | if (is_ltp_ot(hDecoder->object_type)) | ||
668 | { | ||
669 | /* allocate the state only when needed */ | ||
670 | if (hDecoder->lt_pred_stat[channel] == NULL) | ||
671 | { | ||
672 | hDecoder->lt_pred_stat[channel] = (int16_t*)faad_malloc(hDecoder->frameLength*4 * sizeof(int16_t)); | ||
673 | memset(hDecoder->lt_pred_stat[channel], 0, hDecoder->frameLength*4 * sizeof(int16_t)); | ||
674 | } | ||
675 | } | ||
676 | #endif | ||
677 | |||
678 | if (hDecoder->time_out[channel] == NULL) | ||
679 | { | ||
680 | mul = 1; | ||
681 | #ifdef SBR_DEC | ||
682 | hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 0; | ||
683 | if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) | ||
684 | { | ||
685 | /* SBR requires 2 times as much output data */ | ||
686 | mul = 2; | ||
687 | hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1; | ||
688 | } | ||
689 | #endif | ||
690 | hDecoder->time_out[channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t)); | ||
691 | memset(hDecoder->time_out[channel], 0, mul*hDecoder->frameLength*sizeof(real_t)); | ||
692 | } | ||
693 | #if (defined(PS_DEC) || defined(DRM_PS)) | ||
694 | if (output_channels == 2) | ||
695 | { | ||
696 | if (hDecoder->time_out[channel+1] == NULL) | ||
697 | { | ||
698 | hDecoder->time_out[channel+1] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t)); | ||
699 | memset(hDecoder->time_out[channel+1], 0, mul*hDecoder->frameLength*sizeof(real_t)); | ||
700 | } | ||
701 | } | ||
702 | #else | ||
703 | (void)output_channels; /*silence warning when PS disabled*/ | ||
704 | #endif | ||
705 | |||
706 | if (hDecoder->fb_intermed[channel] == NULL) | ||
707 | { | ||
708 | hDecoder->fb_intermed[channel] = (real_t*)faad_malloc(hDecoder->frameLength*sizeof(real_t)); | ||
709 | memset(hDecoder->fb_intermed[channel], 0, hDecoder->frameLength*sizeof(real_t)); | ||
710 | } | ||
711 | |||
712 | #ifdef SSR_DEC | ||
713 | if (hDecoder->object_type == SSR) | ||
714 | { | ||
715 | if (hDecoder->ssr_overlap[channel] == NULL) | ||
716 | { | ||
717 | hDecoder->ssr_overlap[channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t)); | ||
718 | memset(hDecoder->ssr_overlap[channel], 0, 2*hDecoder->frameLength*sizeof(real_t)); | ||
719 | } | ||
720 | if (hDecoder->prev_fmd[channel] == NULL) | ||
721 | { | ||
722 | uint16_t k; | ||
723 | hDecoder->prev_fmd[channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t)); | ||
724 | for (k = 0; k < 2*hDecoder->frameLength; k++) | ||
725 | hDecoder->prev_fmd[channel][k] = REAL_CONST(-1); | ||
726 | } | ||
727 | } | ||
728 | #endif | ||
729 | |||
730 | return 0; | 658 | return 0; |
731 | } | 659 | } |
732 | 660 | ||
733 | static uint8_t allocate_channel_pair(NeAACDecHandle hDecoder, | 661 | static uint8_t allocate_channel_pair(NeAACDecHandle hDecoder, |
734 | uint8_t channel, uint8_t paired_channel) | 662 | uint8_t channel, uint8_t paired_channel) |
735 | { | 663 | { |
736 | uint8_t mul = 1; | 664 | (void)paired_channel; |
737 | 665 | (void)hDecoder; | |
738 | #ifdef MAIN_DEC | 666 | (void)channel; |
739 | /* MAIN object type prediction */ | ||
740 | if (hDecoder->object_type == MAIN) | ||
741 | { | ||
742 | /* allocate the state only when needed */ | ||
743 | if (hDecoder->pred_stat[channel] == NULL) | ||
744 | { | ||
745 | hDecoder->pred_stat[channel] = (pred_state*)faad_malloc(hDecoder->frameLength * sizeof(pred_state)); | ||
746 | reset_all_predictors(hDecoder->pred_stat[channel], hDecoder->frameLength); | ||
747 | } | ||
748 | if (hDecoder->pred_stat[paired_channel] == NULL) | ||
749 | { | ||
750 | hDecoder->pred_stat[paired_channel] = (pred_state*)faad_malloc(hDecoder->frameLength * sizeof(pred_state)); | ||
751 | reset_all_predictors(hDecoder->pred_stat[paired_channel], hDecoder->frameLength); | ||
752 | } | ||
753 | } | ||
754 | #endif | ||
755 | |||
756 | #ifdef LTP_DEC | ||
757 | if (is_ltp_ot(hDecoder->object_type)) | ||
758 | { | ||
759 | /* allocate the state only when needed */ | ||
760 | if (hDecoder->lt_pred_stat[channel] == NULL) | ||
761 | { | ||
762 | hDecoder->lt_pred_stat[channel] = (int16_t*)faad_malloc(hDecoder->frameLength*4 * sizeof(int16_t)); | ||
763 | memset(hDecoder->lt_pred_stat[channel], 0, hDecoder->frameLength*4 * sizeof(int16_t)); | ||
764 | } | ||
765 | if (hDecoder->lt_pred_stat[paired_channel] == NULL) | ||
766 | { | ||
767 | hDecoder->lt_pred_stat[paired_channel] = (int16_t*)faad_malloc(hDecoder->frameLength*4 * sizeof(int16_t)); | ||
768 | memset(hDecoder->lt_pred_stat[paired_channel], 0, hDecoder->frameLength*4 * sizeof(int16_t)); | ||
769 | } | ||
770 | } | ||
771 | #endif | ||
772 | |||
773 | if (hDecoder->time_out[channel] == NULL) | ||
774 | { | ||
775 | mul = 1; | ||
776 | #ifdef SBR_DEC | ||
777 | hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 0; | ||
778 | if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) | ||
779 | { | ||
780 | /* SBR requires 2 times as much output data */ | ||
781 | mul = 2; | ||
782 | hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1; | ||
783 | } | ||
784 | #endif | ||
785 | hDecoder->time_out[channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t)); | ||
786 | memset(hDecoder->time_out[channel], 0, mul*hDecoder->frameLength*sizeof(real_t)); | ||
787 | } | ||
788 | if (hDecoder->time_out[paired_channel] == NULL) | ||
789 | { | ||
790 | hDecoder->time_out[paired_channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t)); | ||
791 | memset(hDecoder->time_out[paired_channel], 0, mul*hDecoder->frameLength*sizeof(real_t)); | ||
792 | } | ||
793 | |||
794 | if (hDecoder->fb_intermed[channel] == NULL) | ||
795 | { | ||
796 | hDecoder->fb_intermed[channel] = (real_t*)faad_malloc(hDecoder->frameLength*sizeof(real_t)); | ||
797 | memset(hDecoder->fb_intermed[channel], 0, hDecoder->frameLength*sizeof(real_t)); | ||
798 | } | ||
799 | if (hDecoder->fb_intermed[paired_channel] == NULL) | ||
800 | { | ||
801 | hDecoder->fb_intermed[paired_channel] = (real_t*)faad_malloc(hDecoder->frameLength*sizeof(real_t)); | ||
802 | memset(hDecoder->fb_intermed[paired_channel], 0, hDecoder->frameLength*sizeof(real_t)); | ||
803 | } | ||
804 | |||
805 | #ifdef SSR_DEC | ||
806 | if (hDecoder->object_type == SSR) | ||
807 | { | ||
808 | if (hDecoder->ssr_overlap[cpe->channel] == NULL) | ||
809 | { | ||
810 | hDecoder->ssr_overlap[cpe->channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t)); | ||
811 | memset(hDecoder->ssr_overlap[cpe->channel], 0, 2*hDecoder->frameLength*sizeof(real_t)); | ||
812 | } | ||
813 | if (hDecoder->ssr_overlap[cpe->paired_channel] == NULL) | ||
814 | { | ||
815 | hDecoder->ssr_overlap[cpe->paired_channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t)); | ||
816 | memset(hDecoder->ssr_overlap[cpe->paired_channel], 0, 2*hDecoder->frameLength*sizeof(real_t)); | ||
817 | } | ||
818 | if (hDecoder->prev_fmd[cpe->channel] == NULL) | ||
819 | { | ||
820 | uint16_t k; | ||
821 | hDecoder->prev_fmd[cpe->channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t)); | ||
822 | for (k = 0; k < 2*hDecoder->frameLength; k++) | ||
823 | hDecoder->prev_fmd[cpe->channel][k] = REAL_CONST(-1); | ||
824 | } | ||
825 | if (hDecoder->prev_fmd[cpe->paired_channel] == NULL) | ||
826 | { | ||
827 | uint16_t k; | ||
828 | hDecoder->prev_fmd[cpe->paired_channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t)); | ||
829 | for (k = 0; k < 2*hDecoder->frameLength; k++) | ||
830 | hDecoder->prev_fmd[cpe->paired_channel][k] = REAL_CONST(-1); | ||
831 | } | ||
832 | } | ||
833 | #endif | ||
834 | |||
835 | return 0; | 667 | return 0; |
836 | } | 668 | } |
837 | 669 | ||
838 | /* used by reconstruct_single_channel() and reconstruct_channel_pair() */ | ||
839 | static real_t spec_coef1[1024] IBSS_ATTR MEM_ALIGN_ATTR; | ||
840 | static real_t spec_coef2[1024] IBSS_ATTR MEM_ALIGN_ATTR; | ||
841 | |||
842 | uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics, | 670 | uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics, |
843 | element *sce, int16_t *spec_data) | 671 | element *sce, int16_t *spec_data) |
844 | { | 672 | { |
@@ -978,7 +806,8 @@ uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics, | |||
978 | if (hDecoder->sbr[ele] == NULL) | 806 | if (hDecoder->sbr[ele] == NULL) |
979 | { | 807 | { |
980 | hDecoder->sbr[ele] = sbrDecodeInit(hDecoder->frameLength, | 808 | hDecoder->sbr[ele] = sbrDecodeInit(hDecoder->frameLength, |
981 | hDecoder->element_id[ele], 2*get_sample_rate(hDecoder->sf_index), | 809 | hDecoder->element_id[ele], ele, |
810 | 2*get_sample_rate(hDecoder->sf_index), | ||
982 | hDecoder->downSampledSBR | 811 | hDecoder->downSampledSBR |
983 | #ifdef DRM | 812 | #ifdef DRM |
984 | , 0 | 813 | , 0 |
@@ -1227,7 +1056,8 @@ uint8_t reconstruct_channel_pair(NeAACDecHandle hDecoder, ic_stream *ics1, ic_st | |||
1227 | if (hDecoder->sbr[ele] == NULL) | 1056 | if (hDecoder->sbr[ele] == NULL) |
1228 | { | 1057 | { |
1229 | hDecoder->sbr[ele] = sbrDecodeInit(hDecoder->frameLength, | 1058 | hDecoder->sbr[ele] = sbrDecodeInit(hDecoder->frameLength, |
1230 | hDecoder->element_id[ele], 2*get_sample_rate(hDecoder->sf_index), | 1059 | hDecoder->element_id[ele], ele, |
1060 | 2*get_sample_rate(hDecoder->sf_index), | ||
1231 | hDecoder->downSampledSBR | 1061 | hDecoder->downSampledSBR |
1232 | #ifdef DRM | 1062 | #ifdef DRM |
1233 | , 0 | 1063 | , 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" { | |||
37 | #include "sbr_dec.h" | 37 | #include "sbr_dec.h" |
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | #define MAX_CHANNELS 64 | 40 | #define MAX_CHANNELS 2 /* Was 64, but we need to limit RAM usage */ |
41 | #define MAX_SYNTAX_ELEMENTS 48 | 41 | #define MAX_SYNTAX_ELEMENTS 1 /* Was 48, but we need to limit RAM usage */ |
42 | #define MAX_WINDOW_GROUPS 8 | 42 | #define MAX_WINDOW_GROUPS 8 |
43 | #define MAX_SFB 51 | 43 | #define MAX_SFB 51 |
44 | #define MAX_LTP_SFB 40 | 44 | #define MAX_LTP_SFB 40 |
45 | #define MAX_LTP_SFB_S 8 | 45 | #define MAX_LTP_SFB_S 8 |
46 | #define FRAME_LEN 1024 | ||
46 | 47 | ||
47 | /* used to save the prediction state */ | 48 | /* used to save the prediction state */ |
48 | typedef struct { | 49 | typedef struct { |
@@ -407,9 +408,6 @@ typedef struct | |||
407 | */ | 408 | */ |
408 | uint8_t alloced_channels; | 409 | uint8_t alloced_channels; |
409 | 410 | ||
410 | /* output data buffer */ | ||
411 | void *sample_buffer; | ||
412 | |||
413 | uint8_t window_shape_prev[MAX_CHANNELS]; | 411 | uint8_t window_shape_prev[MAX_CHANNELS]; |
414 | #ifdef LTP_DEC | 412 | #ifdef LTP_DEC |
415 | uint16_t ltp_lag[MAX_CHANNELS]; | 413 | 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, | |||
558 | 558 | ||
559 | /* Table 4.4.4 and */ | 559 | /* Table 4.4.4 and */ |
560 | /* Table 4.4.9 */ | 560 | /* Table 4.4.9 */ |
561 | int16_t spec_data[1024] MEM_ALIGN_ATTR = {0}; | 561 | int16_t spec_data[FRAME_LEN] MEM_ALIGN_ATTR = {0}; |
562 | element sce; | 562 | element sce; |
563 | static uint8_t single_lfe_channel_element(NeAACDecHandle hDecoder, bitfile *ld, | 563 | static uint8_t single_lfe_channel_element(NeAACDecHandle hDecoder, bitfile *ld, |
564 | uint8_t channel, uint8_t *tag) | 564 | uint8_t channel, uint8_t *tag) |
@@ -603,8 +603,9 @@ static uint8_t single_lfe_channel_element(NeAACDecHandle hDecoder, bitfile *ld, | |||
603 | } | 603 | } |
604 | 604 | ||
605 | /* Table 4.4.5 */ | 605 | /* Table 4.4.5 */ |
606 | int16_t spec_data1[1024] IBSS_ATTR MEM_ALIGN_ATTR; | 606 | |
607 | int16_t spec_data2[1024] IBSS_ATTR MEM_ALIGN_ATTR; | 607 | int16_t spec_data1[FRAME_LEN] IBSS_ATTR MEM_ALIGN_ATTR; |
608 | int16_t spec_data2[FRAME_LEN] IBSS_ATTR MEM_ALIGN_ATTR; | ||
608 | element cpe; | 609 | element cpe; |
609 | static uint8_t channel_pair_element(NeAACDecHandle hDecoder, bitfile *ld, | 610 | static uint8_t channel_pair_element(NeAACDecHandle hDecoder, bitfile *ld, |
610 | uint8_t channels, uint8_t *tag) | 611 | uint8_t channels, uint8_t *tag) |
@@ -884,7 +885,7 @@ static uint8_t coupling_channel_element(NeAACDecHandle hDecoder, bitfile *ld) | |||
884 | 885 | ||
885 | element el_empty = {0}; | 886 | element el_empty = {0}; |
886 | ic_stream ics_empty = {0}; | 887 | ic_stream ics_empty = {0}; |
887 | static int16_t sh_data[1024]; | 888 | static int16_t sh_data[FRAME_LEN]; |
888 | 889 | ||
889 | c = faad_getbits(ld, LEN_TAG | 890 | c = faad_getbits(ld, LEN_TAG |
890 | DEBUGVAR(1,900,"coupling_channel_element(): element_instance_tag")); | 891 | 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 | |||
1028 | if (!hDecoder->sbr[sbr_ele]) | 1029 | if (!hDecoder->sbr[sbr_ele]) |
1029 | { | 1030 | { |
1030 | hDecoder->sbr[sbr_ele] = sbrDecodeInit(hDecoder->frameLength, | 1031 | hDecoder->sbr[sbr_ele] = sbrDecodeInit(hDecoder->frameLength, |
1031 | hDecoder->element_id[sbr_ele], 2*get_sample_rate(hDecoder->sf_index), | 1032 | hDecoder->element_id[sbr_ele], sbr_ele, |
1033 | 2*get_sample_rate(hDecoder->sf_index), | ||
1032 | hDecoder->downSampledSBR | 1034 | hDecoder->downSampledSBR |
1033 | #ifdef DRM | 1035 | #ifdef DRM |
1034 | , 0 | 1036 | , 0 |
@@ -1170,8 +1172,8 @@ static void gain_control_data(bitfile *ld, ic_stream *ics) | |||
1170 | #endif | 1172 | #endif |
1171 | 1173 | ||
1172 | #ifdef SCALABLE_DEC | 1174 | #ifdef SCALABLE_DEC |
1173 | int16_t spec_data1[1024] MEM_ALIGN_ATTR; | 1175 | int16_t spec_data1[FRAME_LEN] MEM_ALIGN_ATTR; |
1174 | int16_t spec_data2[1024] MEM_ALIGN_ATTR; | 1176 | int16_t spec_data2[FRAME_LEN] MEM_ALIGN_ATTR; |
1175 | /* Table 4.4.13 ASME */ | 1177 | /* Table 4.4.13 ASME */ |
1176 | void aac_scalable_main_element(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, | 1178 | void aac_scalable_main_element(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, |
1177 | bitfile *ld, program_config *pce, drc_info *drc) | 1179 | 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 @@ | |||
28 | 28 | ||
29 | CODEC_HEADER | 29 | CODEC_HEADER |
30 | 30 | ||
31 | /* Global buffers to be used in the mdct synthesis. This way the arrays can | ||
32 | * be moved to IRAM for some targets */ | ||
33 | #define GB_BUF_SIZE 1024 | ||
34 | static ALIGN real_t gb_time_buffer[2][GB_BUF_SIZE] IBSS_ATTR_FAAD_LARGE_IRAM; | ||
35 | static ALIGN real_t gb_fb_intermed[2][GB_BUF_SIZE] IBSS_ATTR_FAAD_LARGE_IRAM; | ||
36 | |||
37 | |||
38 | static void init_rm(RMContext *rmctx) | 31 | static void init_rm(RMContext *rmctx) |
39 | { | 32 | { |
40 | memcpy(rmctx, (void*)(( (intptr_t)ci->id3->id3v2buf + 3 ) &~ 3), sizeof(RMContext)); | 33 | memcpy(rmctx, (void*)(( (intptr_t)ci->id3->id3v2buf + 3 ) &~ 3), sizeof(RMContext)); |
@@ -49,7 +42,6 @@ enum codec_status codec_main(void) | |||
49 | NeAACDecHandle decoder; | 42 | NeAACDecHandle decoder; |
50 | size_t n; | 43 | size_t n; |
51 | void *ret; | 44 | void *ret; |
52 | int needed_bufsize; | ||
53 | unsigned int i; | 45 | unsigned int i; |
54 | unsigned char* buffer; | 46 | unsigned char* buffer; |
55 | int err, consumed, pkt_offset, skipped = 0; | 47 | int err, consumed, pkt_offset, skipped = 0; |
@@ -103,34 +95,6 @@ next_track: | |||
103 | goto done; | 95 | goto done; |
104 | } | 96 | } |
105 | 97 | ||
106 | /* Set pointer to be able to use IRAM an to avoid alloc in decoder. Must | ||
107 | * be called after NeAACDecOpen(). */ | ||
108 | /* A buffer of framelength or 2*frameLenght size must be allocated for | ||
109 | * time_out. If frameLength is too big or SBR/forceUpSampling is active, | ||
110 | * we do not use the IRAM buffer and keep faad's internal allocation (see | ||
111 | * specrec.c). */ | ||
112 | needed_bufsize = decoder->frameLength; | ||
113 | #ifdef SBR_DEC | ||
114 | if ((decoder->sbr_present_flag == 1) || (decoder->forceUpSampling == 1)) | ||
115 | { | ||
116 | needed_bufsize *= 2; | ||
117 | } | ||
118 | #endif | ||
119 | if (needed_bufsize <= GB_BUF_SIZE) | ||
120 | { | ||
121 | decoder->time_out[0] = &gb_time_buffer[0][0]; | ||
122 | decoder->time_out[1] = &gb_time_buffer[1][0]; | ||
123 | } | ||
124 | /* A buffer of with frameLength elements must be allocated for fb_intermed. | ||
125 | * If frameLength is too big, we do not use the IRAM buffer and keep faad's | ||
126 | * internal allocation (see specrec.c). */ | ||
127 | needed_bufsize = decoder->frameLength; | ||
128 | if (needed_bufsize <= GB_BUF_SIZE) | ||
129 | { | ||
130 | decoder->fb_intermed[0] = &gb_fb_intermed[0][0]; | ||
131 | decoder->fb_intermed[1] = &gb_fb_intermed[1][0]; | ||
132 | } | ||
133 | |||
134 | /* check for a mid-track resume and force a seek time accordingly */ | 98 | /* check for a mid-track resume and force a seek time accordingly */ |
135 | if(resume_offset > rmctx.data_offset + DATA_HEADER_SIZE) { | 99 | if(resume_offset > rmctx.data_offset + DATA_HEADER_SIZE) { |
136 | resume_offset -= rmctx.data_offset + DATA_HEADER_SIZE; | 100 | resume_offset -= rmctx.data_offset + DATA_HEADER_SIZE; |