demux_mkv: seek: fix bogus audio packet from earlier position
[mplayer.git] / libfaad2 / local_changes.diff
blobce0d14078f71525585b0cc6d230eef151d44c1c3
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
3 @@ -58,7 +61,7 @@
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) \
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
14 @@ -32,8 +37,13 @@
16 #ifdef HAVE_CONFIG_H
17 # include "../config.h"
18 #endif
20 +/* Allow build on Cygwin*/
21 +#if defined(__CYGWIN__)
22 +#define __STRICT_ANSI__
23 +#endif
25 #define INLINE __inline
26 #if 0 //defined(_WIN32) && !defined(_WIN32_WCE)
27 #define ALIGN __declspec(align(16))
28 @@ -61,7 +69,7 @@
29 /* Use if target platform has address generators with autoincrement */
30 //#define PREFER_POINTERS
32 -#ifdef _WIN32_WCE
33 +#if defined(_WIN32_WCE) || defined(__arm__) || defined(__avr32__)
34 #define FIXED_POINT
35 #endif
37 @@ -117,6 +125,9 @@
38 # ifdef MAIN_DEC
39 # undef MAIN_DEC
40 # endif
41 +# ifdef SBR_DEC
42 +# undef SBR_DEC
43 +# endif
44 #endif // FIXED_POINT
46 #ifdef DRM
47 @@ -151,6 +162,7 @@
49 #include <stdlib.h>
51 +#if 0
52 typedef unsigned __int64 uint64_t;
53 typedef unsigned __int32 uint32_t;
54 typedef unsigned __int16 uint16_t;
55 @@ -159,6 +171,10 @@
56 typedef __int32 int32_t;
57 typedef __int16 int16_t;
58 typedef __int8 int8_t;
59 +#else
60 +#include <inttypes.h>
61 +#endif
63 typedef float float32_t;
66 @@ -245,7 +245,7 @@
68 #endif
70 -#ifdef WORDS_BIGENDIAN
71 +#if HAVE_BIGENDIAN
72 #define ARCH_IS_BIG_ENDIAN
73 #endif
75 @@ -317,7 +317,7 @@
77 return i;
79 - #elif (defined(__i386__) && defined(__GNUC__))
80 + #elif (defined(__i386__) && defined(__GNUC__)) && __STDC_VERSION__ < 199901L
81 #define HAS_LRINTF
82 // from http://www.stereopsis.com/FPU.html
83 static INLINE int lrintf(float f)
84 @@ -330,6 +346,8 @@
86 #else
88 +#include <math.h>
90 #ifdef HAVE_LRINTF
91 # define HAS_LRINTF
92 # define _ISOC9X_SOURCE 1
93 @@ -338,8 +356,6 @@
94 # define __USE_ISOC99 1
95 #endif
97 - #include <math.h>
99 #ifdef HAVE_SINF
100 # define sin sinf
101 #error
102 --- libfaad2.orig/output.c 2006-03-16 20:15:04.000000000 +0100
103 +++ libfaad2/output.c 2006-04-18 19:50:26.000000000 +0200
104 @@ -463,9 +462,9 @@
108 -void* output_to_PCM(NeAACDecHandle hDecoder,
109 - real_t **input, void *sample_buffer, uint8_t channels,
110 - uint16_t frame_len, uint8_t format)
111 +static void* output_to_PCM_sux(NeAACDecHandle hDecoder,
112 + real_t **input, void *sample_buffer, uint8_t channels,
113 + uint16_t frame_len, uint8_t format)
115 uint8_t ch;
116 uint16_t i;
117 @@ -554,4 +553,51 @@
118 return sample_buffer;
121 +void* output_to_PCM(NeAACDecHandle hDecoder,
122 + real_t **input, void *sample_buffer, uint8_t channels,
123 + uint16_t frame_len, uint8_t format)
125 + int ch;
126 + int i;
127 + int16_t *short_sample_buffer = (int16_t*)sample_buffer;
128 + real_t *ch0 = input[hDecoder->internal_channel[0]];
129 + real_t *ch1 = input[hDecoder->internal_channel[1]];
130 + real_t *ch2 = input[hDecoder->internal_channel[2]];
131 + real_t *ch3 = input[hDecoder->internal_channel[3]];
132 + real_t *ch4 = input[hDecoder->internal_channel[4]];
134 + if (format != FAAD_FMT_16BIT)
135 + return output_to_PCM_sux(hDecoder, input, sample_buffer, channels, frame_len, format);
137 + if (hDecoder->downMatrix) {
138 + for(i = 0; i < frame_len; i++)
140 + int32_t tmp;
141 + tmp = (ch1[i] + ((ch0[i]+ch3[i])>>1) + ((ch0[i]+ch3[i])>>2) + (1<<(REAL_BITS))) >> (REAL_BITS+1);
142 + if ((tmp+0x8000) & ~0xffff) tmp = ~(tmp>>31)-0x8000;
143 + short_sample_buffer[0] = tmp;
144 + tmp = (ch2[i] + ((ch0[i]+ch4[i])>>1) + ((ch0[i]+ch4[i])>>2) + (1<<(REAL_BITS))) >> (REAL_BITS+1);
145 + if ((tmp+0x8000) & ~0xffff) tmp = ~(tmp>>31)-0x8000;
146 + short_sample_buffer[1] = tmp;
147 + short_sample_buffer += channels;
149 + return sample_buffer;
152 + /* Copy output to a standard PCM buffer */
153 + for(i = 0; i < frame_len; i++)
155 + for (ch = 0; ch < channels; ch++)
157 + int32_t tmp = input[hDecoder->internal_channel[ch]][i];
158 + tmp += (1 << (REAL_BITS-1));
159 + tmp >>= REAL_BITS;
160 + if ((tmp+0x8000) & ~0xffff) tmp = ~(tmp>>31)-0x8000;
161 + *(short_sample_buffer++) = tmp;
165 + return sample_buffer;
168 #endif
169 --- libfaad2.orig/ps_dec.c 2006-03-16 20:15:04.000000000 +0100
170 +++ libfaad2/ps_dec.c 2006-04-18 20:29:38.000000000 +0200
171 @@ -159,7 +162,7 @@
173 /* static function declarations */
174 static void ps_data_decode(ps_info *ps);
175 -static hyb_info *hybrid_init();
176 +static hyb_info *hybrid_init(void);
177 static void channel_filter2(hyb_info *hyb, uint8_t frame_len, const real_t *filter,
178 qmf_t *buffer, qmf_t **X_hybrid);
179 static void INLINE DCT3_4_unscaled(real_t *y, real_t *x);
180 @@ -189,7 +192,7 @@
181 /* */
184 -static hyb_info *hybrid_init()
185 +static hyb_info *hybrid_init(void)
187 uint8_t i;
189 @@ -1935,8 +1938,8 @@
190 /* main Parametric Stereo decoding function */
191 uint8_t ps_decode(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64])
193 - qmf_t X_hybrid_left[32][32] = {{0}};
194 - qmf_t X_hybrid_right[32][32] = {{0}};
195 + qmf_t X_hybrid_left[32][32] = {{{0}}};
196 + qmf_t X_hybrid_right[32][32] = {{{0}}};
198 /* delta decoding of the bitstream data */
199 ps_data_decode(ps);
200 --- libfaad2.orig/sbr_dec.c 2006-03-16 20:15:04.000000000 +0100
201 +++ libfaad2/sbr_dec.c 2006-04-18 20:33:57.000000000 +0200
202 @@ -526,8 +529,8 @@
203 uint8_t l, k;
204 uint8_t dont_process = 0;
205 uint8_t ret = 0;
206 - ALIGN qmf_t X_left[38][64] = {{0}};
207 - ALIGN qmf_t X_right[38][64] = {{0}}; /* must set this to 0 */
208 + ALIGN qmf_t X_left[38][64] = {{{0}}};
209 + ALIGN qmf_t X_right[38][64] = {{{0}}}; /* must set this to 0 */
211 if (sbr == NULL)
212 return 20;
213 --- libfaad2.orig/specrec.c 2006-03-16 20:15:04.000000000 +0100
214 +++ libfaad2/specrec.c 2006-04-18 20:38:09.000000000 +0200
215 @@ -673,29 +673,19 @@
216 /* MAIN object type prediction */
217 if (hDecoder->object_type == MAIN)
219 - /* allocate the state only when needed */
220 - if (hDecoder->pred_stat[channel] == NULL)
222 - hDecoder->pred_stat[channel] = (pred_state*)faad_malloc(hDecoder->frameLength * sizeof(pred_state));
223 + hDecoder->pred_stat[channel] = (pred_state*)realloc(hDecoder->pred_stat[channel], hDecoder->frameLength * sizeof(pred_state));
224 reset_all_predictors(hDecoder->pred_stat[channel], hDecoder->frameLength);
227 #endif
229 #ifdef LTP_DEC
230 if (is_ltp_ot(hDecoder->object_type))
232 - /* allocate the state only when needed */
233 - if (hDecoder->lt_pred_stat[channel] == NULL)
235 - hDecoder->lt_pred_stat[channel] = (int16_t*)faad_malloc(hDecoder->frameLength*4 * sizeof(int16_t));
236 + hDecoder->lt_pred_stat[channel] = (int16_t*)realloc(hDecoder->lt_pred_stat[channel], hDecoder->frameLength*4 * sizeof(int16_t));
237 memset(hDecoder->lt_pred_stat[channel], 0, hDecoder->frameLength*4 * sizeof(int16_t));
240 #endif
242 - if (hDecoder->time_out[channel] == NULL)
244 mul = 1;
245 #ifdef SBR_DEC
246 hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 0;
247 @@ -706,41 +696,28 @@
248 hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1;
250 #endif
251 - hDecoder->time_out[channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t));
252 + hDecoder->time_out[channel] = (real_t*)realloc(hDecoder->time_out[channel], mul*hDecoder->frameLength*sizeof(real_t));
253 memset(hDecoder->time_out[channel], 0, mul*hDecoder->frameLength*sizeof(real_t));
255 #if (defined(PS_DEC) || defined(DRM_PS))
256 if (output_channels == 2)
258 - if (hDecoder->time_out[channel+1] == NULL)
260 - hDecoder->time_out[channel+1] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t));
261 + hDecoder->time_out[channel+1] = (real_t*)realloc(hDecoder->time_out[channel+1], mul*hDecoder->frameLength*sizeof(real_t));
262 memset(hDecoder->time_out[channel+1], 0, mul*hDecoder->frameLength*sizeof(real_t));
265 #endif
267 - if (hDecoder->fb_intermed[channel] == NULL)
269 - hDecoder->fb_intermed[channel] = (real_t*)faad_malloc(hDecoder->frameLength*sizeof(real_t));
270 + hDecoder->fb_intermed[channel] = (real_t*)realloc(hDecoder->fb_intermed[channel], hDecoder->frameLength*sizeof(real_t));
271 memset(hDecoder->fb_intermed[channel], 0, hDecoder->frameLength*sizeof(real_t));
274 #ifdef SSR_DEC
275 if (hDecoder->object_type == SSR)
277 - if (hDecoder->ssr_overlap[channel] == NULL)
279 - hDecoder->ssr_overlap[channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
280 - memset(hDecoder->ssr_overlap[channel], 0, 2*hDecoder->frameLength*sizeof(real_t));
282 - if (hDecoder->prev_fmd[channel] == NULL)
284 uint16_t k;
285 - hDecoder->prev_fmd[channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
286 + hDecoder->ssr_overlap[channel] = (real_t*)realloc(hDecoder->ssr_overlap[channel], 2*hDecoder->frameLength*sizeof(real_t));
287 + memset(hDecoder->ssr_overlap[channel], 0, 2*hDecoder->frameLength*sizeof(real_t));
288 + hDecoder->prev_fmd[channel] = (real_t*)realloc(hDecoder->prev_fmd[channel], 2*hDecoder->frameLength*sizeof(real_t));
289 for (k = 0; k < 2*hDecoder->frameLength; k++)
290 hDecoder->prev_fmd[channel][k] = REAL_CONST(-1);
293 #endif
295 @@ -865,22 +842,14 @@
297 /* always allocate 2 channels, PS can always "suddenly" turn up */
298 #if (defined(PS_DEC) || defined(DRM_PS))
299 - output_channels = 2;
300 + output_channels = hDecoder->ps_used[hDecoder->fr_ch_ele] ? 2 : 1;
301 #else
302 output_channels = 1;
303 #endif
305 - if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 0)
307 - /* element_output_channels not set yet */
308 + if (hDecoder->element_alloced[hDecoder->fr_ch_ele] == 0 ||
309 + hDecoder->element_output_channels[hDecoder->fr_ch_ele] < output_channels) {
310 hDecoder->element_output_channels[hDecoder->fr_ch_ele] = output_channels;
311 - } else if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] != output_channels) {
312 - /* element inconsistency */
313 - return 21;
316 - if (hDecoder->element_alloced[hDecoder->fr_ch_ele] == 0)
318 retval = allocate_single_channel(hDecoder, sce->channel, output_channels);
319 if (retval > 0)
320 return retval;
321 @@ -1026,11 +995,10 @@
323 return 23;
325 -#endif
327 /* copy L to R when no PS is used */
328 #if (defined(PS_DEC) || defined(DRM_PS))
329 - if ((hDecoder->ps_used[hDecoder->fr_ch_ele] == 0))
330 + if ((hDecoder->ps_used[hDecoder->fr_ch_ele] == 0) && (output_channels == 2))
332 uint8_t ele = hDecoder->fr_ch_ele;
333 uint8_t ch = sce->channel;
334 @@ -1040,6 +1008,7 @@
335 memcpy(hDecoder->time_out[ch+1], hDecoder->time_out[ch], frame_size);
337 #endif
338 +#endif
340 return 0;