Mercurial > mplayer.hg
annotate libfaad2/local_changes.diff @ 32251:33cd24340f36
Remove local HAVE_LRINTF hack; it should no longer be necessary.
author | diego |
---|---|
date | Tue, 21 Sep 2010 13:04:05 +0000 |
parents | 1c6faa339f96 |
children | b0ca20e4b5cd |
rev | line source |
---|---|
18141 | 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 | |
14858 | 3 @@ -58,7 +61,7 @@ |
32250 | 4 |
14712 | 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) ) | |
10 #else | |
11 #define BSWAP(a) \ | |
18141 | 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 | |
29400 | 14 @@ -32,8 +37,13 @@ |
32250 | 15 |
24023 | 16 #ifdef HAVE_CONFIG_H |
17 # include "../config.h" | |
14712 | 18 #endif |
24023 | 19 + |
14712 | 20 +/* Allow build on Cygwin*/ |
21 +#if defined(__CYGWIN__) | |
22 +#define __STRICT_ANSI__ | |
24023 | 23 +#endif |
32250 | 24 |
14712 | 25 #define INLINE __inline |
26 #if 0 //defined(_WIN32) && !defined(_WIN32_WCE) | |
27 #define ALIGN __declspec(align(16)) | |
29400 | 28 @@ -61,7 +69,7 @@ |
16249 | 29 /* Use if target platform has address generators with autoincrement */ |
30 //#define PREFER_POINTERS | |
32250 | 31 |
16249 | 32 -#ifdef _WIN32_WCE |
28578 | 33 +#if defined(_WIN32_WCE) || defined(__arm__) || defined(__avr32__) |
16249 | 34 #define FIXED_POINT |
35 #endif | |
32250 | 36 |
29400 | 37 @@ -117,6 +125,9 @@ |
14712 | 38 # ifdef MAIN_DEC |
39 # undef MAIN_DEC | |
40 # endif | |
41 +# ifdef SBR_DEC | |
42 +# undef SBR_DEC | |
43 +# endif | |
44 #endif // FIXED_POINT | |
32250 | 45 |
14712 | 46 #ifdef DRM |
29400 | 47 @@ -151,6 +162,7 @@ |
32250 | 48 |
14712 | 49 #include <stdlib.h> |
32250 | 50 |
14712 | 51 +#if 0 |
52 typedef unsigned __int64 uint64_t; | |
53 typedef unsigned __int32 uint32_t; | |
54 typedef unsigned __int16 uint16_t; | |
29400 | 55 @@ -159,5 +171,9 @@ |
14712 | 56 typedef __int32 int32_t; |
57 typedef __int16 int16_t; | |
58 typedef __int8 int8_t; | |
59 +#else | |
60 +#include <inttypes.h> | |
61 +#endif | |
62 + | |
63 typedef float float32_t; | |
32250 | 64 |
29401
f01023c524c3
Replace WORDS_BIGENDIAN by HAVE_BIGENDIAN in all internal code.
diego
parents:
29400
diff
changeset
|
65 @@ -245,7 +245,7 @@ |
f01023c524c3
Replace WORDS_BIGENDIAN by HAVE_BIGENDIAN in all internal code.
diego
parents:
29400
diff
changeset
|
66 |
f01023c524c3
Replace WORDS_BIGENDIAN by HAVE_BIGENDIAN in all internal code.
diego
parents:
29400
diff
changeset
|
67 #endif |
f01023c524c3
Replace WORDS_BIGENDIAN by HAVE_BIGENDIAN in all internal code.
diego
parents:
29400
diff
changeset
|
68 |
f01023c524c3
Replace WORDS_BIGENDIAN by HAVE_BIGENDIAN in all internal code.
diego
parents:
29400
diff
changeset
|
69 -#ifdef WORDS_BIGENDIAN |
f01023c524c3
Replace WORDS_BIGENDIAN by HAVE_BIGENDIAN in all internal code.
diego
parents:
29400
diff
changeset
|
70 +#if HAVE_BIGENDIAN |
f01023c524c3
Replace WORDS_BIGENDIAN by HAVE_BIGENDIAN in all internal code.
diego
parents:
29400
diff
changeset
|
71 #define ARCH_IS_BIG_ENDIAN |
f01023c524c3
Replace WORDS_BIGENDIAN by HAVE_BIGENDIAN in all internal code.
diego
parents:
29400
diff
changeset
|
72 #endif |
f01023c524c3
Replace WORDS_BIGENDIAN by HAVE_BIGENDIAN in all internal code.
diego
parents:
29400
diff
changeset
|
73 |
32251
33cd24340f36
Remove local HAVE_LRINTF hack; it should no longer be necessary.
diego
parents:
32250
diff
changeset
|
74 @@ -330,5 +346,7 @@ |
32250 | 75 |
14712 | 76 #else |
32250 | 77 |
14712 | 78 +#include <math.h> |
79 + | |
32251
33cd24340f36
Remove local HAVE_LRINTF hack; it should no longer be necessary.
diego
parents:
32250
diff
changeset
|
80 #ifdef HAVE_LRINTF |
14712 | 81 # define HAS_LRINTF |
29400 | 82 @@ -338,8 +356,6 @@ |
14712 | 83 # define __USE_ISOC99 1 |
84 #endif | |
32250 | 85 |
14712 | 86 - #include <math.h> |
87 - | |
88 #ifdef HAVE_SINF | |
89 # define sin sinf | |
90 #error | |
18141 | 91 --- libfaad2.orig/output.c 2006-03-16 20:15:04.000000000 +0100 |
92 +++ libfaad2/output.c 2006-04-18 19:50:26.000000000 +0200 | |
93 @@ -463,7 +462,7 @@ | |
16249 | 94 } |
95 } | |
32250 | 96 |
16249 | 97 -void* output_to_PCM(NeAACDecHandle hDecoder, |
98 +void* output_to_PCM_sux(NeAACDecHandle hDecoder, | |
99 real_t **input, void *sample_buffer, uint8_t channels, | |
100 uint16_t frame_len, uint8_t format) | |
101 { | |
18141 | 102 @@ -554,4 +553,51 @@ |
16249 | 103 return sample_buffer; |
104 } | |
32250 | 105 |
16249 | 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 +{ | |
110 + int ch; | |
111 + int i; | |
112 + int16_t *short_sample_buffer = (int16_t*)sample_buffer; | |
113 + real_t *ch0 = input[hDecoder->internal_channel[0]]; | |
114 + real_t *ch1 = input[hDecoder->internal_channel[1]]; | |
115 + real_t *ch2 = input[hDecoder->internal_channel[2]]; | |
116 + real_t *ch3 = input[hDecoder->internal_channel[3]]; | |
117 + real_t *ch4 = input[hDecoder->internal_channel[4]]; | |
118 + | |
119 + if (format != FAAD_FMT_16BIT) | |
120 + return output_to_PCM_sux(hDecoder, input, sample_buffer, channels, frame_len, format); | |
121 + | |
122 + if (hDecoder->downMatrix) { | |
123 + for(i = 0; i < frame_len; i++) | |
124 + { | |
125 + int32_t tmp; | |
126 + tmp = (ch1[i] + ((ch0[i]+ch3[i])>>1) + ((ch0[i]+ch3[i])>>2) + (1<<(REAL_BITS))) >> (REAL_BITS+1); | |
127 + if ((tmp+0x8000) & ~0xffff) tmp = ~(tmp>>31)-0x8000; | |
128 + short_sample_buffer[0] = tmp; | |
129 + tmp = (ch2[i] + ((ch0[i]+ch4[i])>>1) + ((ch0[i]+ch4[i])>>2) + (1<<(REAL_BITS))) >> (REAL_BITS+1); | |
130 + if ((tmp+0x8000) & ~0xffff) tmp = ~(tmp>>31)-0x8000; | |
131 + short_sample_buffer[1] = tmp; | |
132 + short_sample_buffer += channels; | |
133 + } | |
134 + return sample_buffer; | |
135 + } | |
136 + | |
137 + /* Copy output to a standard PCM buffer */ | |
138 + for(i = 0; i < frame_len; i++) | |
139 + { | |
140 + for (ch = 0; ch < channels; ch++) | |
141 + { | |
18141 | 142 + int32_t tmp = input[hDecoder->internal_channel[ch]][i]; |
16249 | 143 + tmp += (1 << (REAL_BITS-1)); |
144 + tmp >>= REAL_BITS; | |
145 + if ((tmp+0x8000) & ~0xffff) tmp = ~(tmp>>31)-0x8000; | |
146 + *(short_sample_buffer++) = tmp; | |
147 + } | |
148 + } | |
149 + | |
150 + return sample_buffer; | |
151 +} | |
152 + | |
153 #endif | |
18141 | 154 --- libfaad2.orig/ps_dec.c 2006-03-16 20:15:04.000000000 +0100 |
155 +++ libfaad2/ps_dec.c 2006-04-18 20:29:38.000000000 +0200 | |
156 @@ -159,7 +162,7 @@ | |
32250 | 157 |
18141 | 158 /* static function declarations */ |
159 static void ps_data_decode(ps_info *ps); | |
160 -static hyb_info *hybrid_init(); | |
161 +static hyb_info *hybrid_init(void); | |
162 static void channel_filter2(hyb_info *hyb, uint8_t frame_len, const real_t *filter, | |
163 qmf_t *buffer, qmf_t **X_hybrid); | |
164 static void INLINE DCT3_4_unscaled(real_t *y, real_t *x); | |
165 @@ -189,7 +192,7 @@ | |
166 /* */ | |
32250 | 167 |
168 | |
18141 | 169 -static hyb_info *hybrid_init() |
170 +static hyb_info *hybrid_init(void) | |
171 { | |
172 uint8_t i; | |
32250 | 173 |
18141 | 174 @@ -1935,8 +1938,8 @@ |
17136 | 175 /* main Parametric Stereo decoding function */ |
176 uint8_t ps_decode(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64]) | |
177 { | |
178 - qmf_t X_hybrid_left[32][32] = {{0}}; | |
179 - qmf_t X_hybrid_right[32][32] = {{0}}; | |
180 + qmf_t X_hybrid_left[32][32] = {{{0}}}; | |
181 + qmf_t X_hybrid_right[32][32] = {{{0}}}; | |
32250 | 182 |
17136 | 183 /* delta decoding of the bitstream data */ |
184 ps_data_decode(ps); | |
18141 | 185 --- libfaad2.orig/sbr_dec.c 2006-03-16 20:15:04.000000000 +0100 |
186 +++ libfaad2/sbr_dec.c 2006-04-18 20:33:57.000000000 +0200 | |
187 @@ -526,8 +529,8 @@ | |
17137 | 188 uint8_t l, k; |
189 uint8_t dont_process = 0; | |
190 uint8_t ret = 0; | |
191 - ALIGN qmf_t X_left[38][64] = {{0}}; | |
192 - ALIGN qmf_t X_right[38][64] = {{0}}; /* must set this to 0 */ | |
193 + ALIGN qmf_t X_left[38][64] = {{{0}}}; | |
194 + ALIGN qmf_t X_right[38][64] = {{{0}}}; /* must set this to 0 */ | |
32250 | 195 |
17137 | 196 if (sbr == NULL) |
197 return 20; | |
18141 | 198 --- libfaad2.orig/specrec.c 2006-03-16 20:15:04.000000000 +0100 |
199 +++ libfaad2/specrec.c 2006-04-18 20:38:09.000000000 +0200 | |
200 @@ -673,29 +673,19 @@ | |
201 /* MAIN object type prediction */ | |
202 if (hDecoder->object_type == MAIN) | |
203 { | |
204 - /* allocate the state only when needed */ | |
205 - if (hDecoder->pred_stat[channel] == NULL) | |
206 - { | |
207 - hDecoder->pred_stat[channel] = (pred_state*)faad_malloc(hDecoder->frameLength * sizeof(pred_state)); | |
208 + hDecoder->pred_stat[channel] = (pred_state*)realloc(hDecoder->pred_stat[channel], hDecoder->frameLength * sizeof(pred_state)); | |
209 reset_all_predictors(hDecoder->pred_stat[channel], hDecoder->frameLength); | |
210 - } | |
211 } | |
212 #endif | |
32250 | 213 |
18141 | 214 #ifdef LTP_DEC |
215 if (is_ltp_ot(hDecoder->object_type)) | |
216 { | |
217 - /* allocate the state only when needed */ | |
218 - if (hDecoder->lt_pred_stat[channel] == NULL) | |
219 - { | |
220 - hDecoder->lt_pred_stat[channel] = (int16_t*)faad_malloc(hDecoder->frameLength*4 * sizeof(int16_t)); | |
221 + hDecoder->lt_pred_stat[channel] = (int16_t*)realloc(hDecoder->lt_pred_stat[channel], hDecoder->frameLength*4 * sizeof(int16_t)); | |
222 memset(hDecoder->lt_pred_stat[channel], 0, hDecoder->frameLength*4 * sizeof(int16_t)); | |
223 - } | |
224 } | |
225 #endif | |
32250 | 226 |
18141 | 227 - if (hDecoder->time_out[channel] == NULL) |
228 - { | |
229 mul = 1; | |
230 #ifdef SBR_DEC | |
231 hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 0; | |
232 @@ -706,41 +696,28 @@ | |
233 hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1; | |
234 } | |
235 #endif | |
236 - hDecoder->time_out[channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t)); | |
237 + hDecoder->time_out[channel] = (real_t*)realloc(hDecoder->time_out[channel], mul*hDecoder->frameLength*sizeof(real_t)); | |
238 memset(hDecoder->time_out[channel], 0, mul*hDecoder->frameLength*sizeof(real_t)); | |
239 - } | |
240 #if (defined(PS_DEC) || defined(DRM_PS)) | |
241 if (output_channels == 2) | |
242 { | |
243 - if (hDecoder->time_out[channel+1] == NULL) | |
244 - { | |
245 - hDecoder->time_out[channel+1] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t)); | |
246 + hDecoder->time_out[channel+1] = (real_t*)realloc(hDecoder->time_out[channel+1], mul*hDecoder->frameLength*sizeof(real_t)); | |
247 memset(hDecoder->time_out[channel+1], 0, mul*hDecoder->frameLength*sizeof(real_t)); | |
248 - } | |
249 } | |
250 #endif | |
32250 | 251 |
18141 | 252 - if (hDecoder->fb_intermed[channel] == NULL) |
253 - { | |
254 - hDecoder->fb_intermed[channel] = (real_t*)faad_malloc(hDecoder->frameLength*sizeof(real_t)); | |
255 + hDecoder->fb_intermed[channel] = (real_t*)realloc(hDecoder->fb_intermed[channel], hDecoder->frameLength*sizeof(real_t)); | |
256 memset(hDecoder->fb_intermed[channel], 0, hDecoder->frameLength*sizeof(real_t)); | |
257 - } | |
32250 | 258 |
18141 | 259 #ifdef SSR_DEC |
260 if (hDecoder->object_type == SSR) | |
261 { | |
262 - if (hDecoder->ssr_overlap[channel] == NULL) | |
263 - { | |
264 - hDecoder->ssr_overlap[channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t)); | |
265 - memset(hDecoder->ssr_overlap[channel], 0, 2*hDecoder->frameLength*sizeof(real_t)); | |
266 - } | |
267 - if (hDecoder->prev_fmd[channel] == NULL) | |
268 - { | |
269 uint16_t k; | |
270 - hDecoder->prev_fmd[channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t)); | |
271 + hDecoder->ssr_overlap[channel] = (real_t*)realloc(hDecoder->ssr_overlap[channel], 2*hDecoder->frameLength*sizeof(real_t)); | |
272 + memset(hDecoder->ssr_overlap[channel], 0, 2*hDecoder->frameLength*sizeof(real_t)); | |
273 + hDecoder->prev_fmd[channel] = (real_t*)realloc(hDecoder->prev_fmd[channel], 2*hDecoder->frameLength*sizeof(real_t)); | |
274 for (k = 0; k < 2*hDecoder->frameLength; k++) | |
275 hDecoder->prev_fmd[channel][k] = REAL_CONST(-1); | |
276 - } | |
277 } | |
278 #endif | |
32250 | 279 |
28722
5f24919c13ef
Fix a possible NULL-pointer crash introduced by local changes to libfaad2
reimar
parents:
28578
diff
changeset
|
280 @@ -865,22 +842,14 @@ |
32250 | 281 |
18141 | 282 /* always allocate 2 channels, PS can always "suddenly" turn up */ |
283 #if (defined(PS_DEC) || defined(DRM_PS)) | |
284 - output_channels = 2; | |
285 + output_channels = hDecoder->ps_used[hDecoder->fr_ch_ele] ? 2 : 1; | |
286 #else | |
287 output_channels = 1; | |
288 #endif | |
32250 | 289 |
18141 | 290 - if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 0) |
291 - { | |
292 - /* element_output_channels not set yet */ | |
28722
5f24919c13ef
Fix a possible NULL-pointer crash introduced by local changes to libfaad2
reimar
parents:
28578
diff
changeset
|
293 + if (hDecoder->element_alloced[hDecoder->fr_ch_ele] == 0 || |
5f24919c13ef
Fix a possible NULL-pointer crash introduced by local changes to libfaad2
reimar
parents:
28578
diff
changeset
|
294 + hDecoder->element_output_channels[hDecoder->fr_ch_ele] < output_channels) { |
18141 | 295 hDecoder->element_output_channels[hDecoder->fr_ch_ele] = output_channels; |
296 - } else if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] != output_channels) { | |
297 - /* element inconsistency */ | |
298 - return 21; | |
299 - } | |
300 - | |
301 - if (hDecoder->element_alloced[hDecoder->fr_ch_ele] == 0) | |
302 - { | |
303 retval = allocate_single_channel(hDecoder, sce->channel, output_channels); | |
304 if (retval > 0) | |
305 return retval; | |
29400 | 306 @@ -1026,11 +995,10 @@ |
18141 | 307 { |
308 return 23; | |
309 } | |
310 -#endif | |
32250 | 311 |
18141 | 312 /* copy L to R when no PS is used */ |
313 #if (defined(PS_DEC) || defined(DRM_PS)) | |
314 - if ((hDecoder->ps_used[hDecoder->fr_ch_ele] == 0)) | |
315 + if ((hDecoder->ps_used[hDecoder->fr_ch_ele] == 0) && (output_channels == 2)) | |
316 { | |
317 uint8_t ele = hDecoder->fr_ch_ele; | |
318 uint8_t ch = sce->channel; | |
29400 | 319 @@ -1040,6 +1008,7 @@ |
18141 | 320 memcpy(hDecoder->time_out[ch+1], hDecoder->time_out[ch], frame_size); |
321 } | |
322 #endif | |
323 +#endif | |
32250 | 324 |
18141 | 325 return 0; |
326 } |