1 --- libfaad2.orig/bits.h 2006-03-16 20:15:04.000000000 +0100
2 +++ libfaad2/bits.h 2006-03-16 20:37:21.000000000 +0100
5 #if defined (_WIN32) && !defined(_WIN32_WCE) && !defined(__MINGW32__)
6 #define BSWAP(a) __asm mov eax,a __asm bswap eax __asm mov a, eax
7 -#elif defined(LINUX) || defined(DJGPP) || defined(__MINGW32__)
8 +#elif defined(LINUX) || defined(DJGPP)
9 #define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) )
12 --- libfaad2.orig/common.h 2006-03-16 20:15:04.000000000 +0100
13 +++ libfaad2/common.h 2006-03-16 20:56:56.000000000 +0100
17 # include "../config.h"
20 +/* Allow build on Cygwin*/
21 +#if defined(__CYGWIN__)
22 +#define __STRICT_ANSI__
25 #define INLINE __inline
26 #if 0 //defined(_WIN32) && !defined(_WIN32_WCE)
27 #define ALIGN __declspec(align(16))
29 /* Use if target platform has address generators with autoincrement */
30 //#define PREFER_POINTERS
33 +#if defined(_WIN32_WCE) || defined(__arm__) || defined(__avr32__)
52 typedef unsigned __int64 uint64_t;
53 typedef unsigned __int32 uint32_t;
54 typedef unsigned __int16 uint16_t;
56 typedef __int32 int32_t;
57 typedef __int16 int16_t;
58 typedef __int8 int8_t;
60 +#include <inttypes.h>
63 typedef float float32_t;
69 -#ifdef WORDS_BIGENDIAN
71 #define ARCH_IS_BIG_ENDIAN
78 - #elif (defined(__i386__) && defined(__GNUC__))
79 + #elif (defined(__i386__) && defined(__GNUC__)) && __STDC_VERSION__ < 199901L
81 // from http://www.stereopsis.com/FPU.html
82 static INLINE int lrintf(float f)
92 # define __USE_ISOC99 1
100 --- libfaad2.orig/output.c 2006-03-16 20:15:04.000000000 +0100
101 +++ libfaad2/output.c 2006-04-18 19:50:26.000000000 +0200
106 -void* output_to_PCM(NeAACDecHandle hDecoder,
107 - real_t **input, void *sample_buffer, uint8_t channels,
108 - uint16_t frame_len, uint8_t format)
109 +static void* output_to_PCM_sux(NeAACDecHandle hDecoder,
110 + real_t **input, void *sample_buffer, uint8_t channels,
111 + uint16_t frame_len, uint8_t format)
116 return sample_buffer;
119 +void* output_to_PCM(NeAACDecHandle hDecoder,
120 + real_t **input, void *sample_buffer, uint8_t channels,
121 + uint16_t frame_len, uint8_t format)
125 + int16_t *short_sample_buffer = (int16_t*)sample_buffer;
126 + real_t *ch0 = input[hDecoder->internal_channel[0]];
127 + real_t *ch1 = input[hDecoder->internal_channel[1]];
128 + real_t *ch2 = input[hDecoder->internal_channel[2]];
129 + real_t *ch3 = input[hDecoder->internal_channel[3]];
130 + real_t *ch4 = input[hDecoder->internal_channel[4]];
132 + if (format != FAAD_FMT_16BIT)
133 + return output_to_PCM_sux(hDecoder, input, sample_buffer, channels, frame_len, format);
135 + if (hDecoder->downMatrix) {
136 + for(i = 0; i < frame_len; i++)
139 + tmp = (ch1[i] + ((ch0[i]+ch3[i])>>1) + ((ch0[i]+ch3[i])>>2) + (1<<(REAL_BITS))) >> (REAL_BITS+1);
140 + if ((tmp+0x8000) & ~0xffff) tmp = ~(tmp>>31)-0x8000;
141 + short_sample_buffer[0] = tmp;
142 + tmp = (ch2[i] + ((ch0[i]+ch4[i])>>1) + ((ch0[i]+ch4[i])>>2) + (1<<(REAL_BITS))) >> (REAL_BITS+1);
143 + if ((tmp+0x8000) & ~0xffff) tmp = ~(tmp>>31)-0x8000;
144 + short_sample_buffer[1] = tmp;
145 + short_sample_buffer += channels;
147 + return sample_buffer;
150 + /* Copy output to a standard PCM buffer */
151 + for(i = 0; i < frame_len; i++)
153 + for (ch = 0; ch < channels; ch++)
155 + int32_t tmp = input[hDecoder->internal_channel[ch]][i];
156 + tmp += (1 << (REAL_BITS-1));
158 + if ((tmp+0x8000) & ~0xffff) tmp = ~(tmp>>31)-0x8000;
159 + *(short_sample_buffer++) = tmp;
163 + return sample_buffer;
167 --- libfaad2.orig/ps_dec.c 2006-03-16 20:15:04.000000000 +0100
168 +++ libfaad2/ps_dec.c 2006-04-18 20:29:38.000000000 +0200
171 /* static function declarations */
172 static void ps_data_decode(ps_info *ps);
173 -static hyb_info *hybrid_init();
174 +static hyb_info *hybrid_init(void);
175 static void channel_filter2(hyb_info *hyb, uint8_t frame_len, const real_t *filter,
176 qmf_t *buffer, qmf_t **X_hybrid);
177 static void INLINE DCT3_4_unscaled(real_t *y, real_t *x);
182 -static hyb_info *hybrid_init()
183 +static hyb_info *hybrid_init(void)
187 @@ -1935,8 +1938,8 @@
188 /* main Parametric Stereo decoding function */
189 uint8_t ps_decode(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64])
191 - qmf_t X_hybrid_left[32][32] = {{0}};
192 - qmf_t X_hybrid_right[32][32] = {{0}};
193 + qmf_t X_hybrid_left[32][32] = {{{0}}};
194 + qmf_t X_hybrid_right[32][32] = {{{0}}};
196 /* delta decoding of the bitstream data */
198 --- libfaad2.orig/sbr_dec.c 2006-03-16 20:15:04.000000000 +0100
199 +++ libfaad2/sbr_dec.c 2006-04-18 20:33:57.000000000 +0200
202 uint8_t dont_process = 0;
204 - ALIGN qmf_t X_left[38][64] = {{0}};
205 - ALIGN qmf_t X_right[38][64] = {{0}}; /* must set this to 0 */
206 + ALIGN qmf_t X_left[38][64] = {{{0}}};
207 + ALIGN qmf_t X_right[38][64] = {{{0}}}; /* must set this to 0 */
211 --- libfaad2.orig/specrec.c 2006-03-16 20:15:04.000000000 +0100
212 +++ libfaad2/specrec.c 2006-04-18 20:38:09.000000000 +0200
213 @@ -673,29 +673,19 @@
214 /* MAIN object type prediction */
215 if (hDecoder->object_type == MAIN)
217 - /* allocate the state only when needed */
218 - if (hDecoder->pred_stat[channel] == NULL)
220 - hDecoder->pred_stat[channel] = (pred_state*)faad_malloc(hDecoder->frameLength * sizeof(pred_state));
221 + hDecoder->pred_stat[channel] = (pred_state*)realloc(hDecoder->pred_stat[channel], hDecoder->frameLength * sizeof(pred_state));
222 reset_all_predictors(hDecoder->pred_stat[channel], hDecoder->frameLength);
228 if (is_ltp_ot(hDecoder->object_type))
230 - /* allocate the state only when needed */
231 - if (hDecoder->lt_pred_stat[channel] == NULL)
233 - hDecoder->lt_pred_stat[channel] = (int16_t*)faad_malloc(hDecoder->frameLength*4 * sizeof(int16_t));
234 + hDecoder->lt_pred_stat[channel] = (int16_t*)realloc(hDecoder->lt_pred_stat[channel], hDecoder->frameLength*4 * sizeof(int16_t));
235 memset(hDecoder->lt_pred_stat[channel], 0, hDecoder->frameLength*4 * sizeof(int16_t));
240 - if (hDecoder->time_out[channel] == NULL)
244 hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 0;
245 @@ -706,41 +696,28 @@
246 hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1;
249 - hDecoder->time_out[channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t));
250 + hDecoder->time_out[channel] = (real_t*)realloc(hDecoder->time_out[channel], mul*hDecoder->frameLength*sizeof(real_t));
251 memset(hDecoder->time_out[channel], 0, mul*hDecoder->frameLength*sizeof(real_t));
253 #if (defined(PS_DEC) || defined(DRM_PS))
254 if (output_channels == 2)
256 - if (hDecoder->time_out[channel+1] == NULL)
258 - hDecoder->time_out[channel+1] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t));
259 + hDecoder->time_out[channel+1] = (real_t*)realloc(hDecoder->time_out[channel+1], mul*hDecoder->frameLength*sizeof(real_t));
260 memset(hDecoder->time_out[channel+1], 0, mul*hDecoder->frameLength*sizeof(real_t));
265 - if (hDecoder->fb_intermed[channel] == NULL)
267 - hDecoder->fb_intermed[channel] = (real_t*)faad_malloc(hDecoder->frameLength*sizeof(real_t));
268 + hDecoder->fb_intermed[channel] = (real_t*)realloc(hDecoder->fb_intermed[channel], hDecoder->frameLength*sizeof(real_t));
269 memset(hDecoder->fb_intermed[channel], 0, hDecoder->frameLength*sizeof(real_t));
273 if (hDecoder->object_type == SSR)
275 - if (hDecoder->ssr_overlap[channel] == NULL)
277 - hDecoder->ssr_overlap[channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
278 - memset(hDecoder->ssr_overlap[channel], 0, 2*hDecoder->frameLength*sizeof(real_t));
280 - if (hDecoder->prev_fmd[channel] == NULL)
283 - hDecoder->prev_fmd[channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
284 + hDecoder->ssr_overlap[channel] = (real_t*)realloc(hDecoder->ssr_overlap[channel], 2*hDecoder->frameLength*sizeof(real_t));
285 + memset(hDecoder->ssr_overlap[channel], 0, 2*hDecoder->frameLength*sizeof(real_t));
286 + hDecoder->prev_fmd[channel] = (real_t*)realloc(hDecoder->prev_fmd[channel], 2*hDecoder->frameLength*sizeof(real_t));
287 for (k = 0; k < 2*hDecoder->frameLength; k++)
288 hDecoder->prev_fmd[channel][k] = REAL_CONST(-1);
293 @@ -865,22 +842,14 @@
295 /* always allocate 2 channels, PS can always "suddenly" turn up */
296 #if (defined(PS_DEC) || defined(DRM_PS))
297 - output_channels = 2;
298 + output_channels = hDecoder->ps_used[hDecoder->fr_ch_ele] ? 2 : 1;
303 - if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 0)
305 - /* element_output_channels not set yet */
306 + if (hDecoder->element_alloced[hDecoder->fr_ch_ele] == 0 ||
307 + hDecoder->element_output_channels[hDecoder->fr_ch_ele] < output_channels) {
308 hDecoder->element_output_channels[hDecoder->fr_ch_ele] = output_channels;
309 - } else if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] != output_channels) {
310 - /* element inconsistency */
314 - if (hDecoder->element_alloced[hDecoder->fr_ch_ele] == 0)
316 retval = allocate_single_channel(hDecoder, sce->channel, output_channels);
319 @@ -1026,11 +995,10 @@
325 /* copy L to R when no PS is used */
326 #if (defined(PS_DEC) || defined(DRM_PS))
327 - if ((hDecoder->ps_used[hDecoder->fr_ch_ele] == 0))
328 + if ((hDecoder->ps_used[hDecoder->fr_ch_ele] == 0) && (output_channels == 2))
330 uint8_t ele = hDecoder->fr_ch_ele;
331 uint8_t ch = sce->channel;
332 @@ -1040,6 +1008,7 @@
333 memcpy(hDecoder->time_out[ch+1], hDecoder->time_out[ch], frame_size);