aboutsummaryrefslogtreecommitdiffhomepage
path: root/libfaad2/local_changes.diff
blob: 464f80c26d6bf15b41cc16a1abac3771f468071a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
--- libfaad2.orig/bits.h	2006-03-16 20:15:04.000000000 +0100
+++ libfaad2/bits.h	2006-03-16 20:37:21.000000000 +0100
@@ -22,7 +22,10 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
+** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
 ** $Id: bits.h,v 1.40 2004/09/04 14:56:27 menno Exp $
+** detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
+** local_changes.diff contains the exact changes to this file.
 **/
 
 #ifndef __BITS_H__
@@ -58,7 +61,7 @@
 
 #if defined (_WIN32) && !defined(_WIN32_WCE) && !defined(__MINGW32__)
 #define BSWAP(a) __asm mov eax,a __asm bswap eax __asm mov a, eax
-#elif defined(LINUX) || defined(DJGPP) || defined(__MINGW32__)
+#elif defined(LINUX) || defined(DJGPP)
 #define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) )
 #else
 #define BSWAP(a) \
--- libfaad2.orig/common.h	2006-03-16 20:15:04.000000000 +0100
+++ libfaad2/common.h	2006-03-16 20:56:56.000000000 +0100
@@ -22,7 +22,10 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
+** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
 ** $Id: common.h,v 1.65 2004/09/08 09:43:11 gcp Exp $
+** detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
+** local_changes.diff contains the exact changes to this file.
 **/
 
 #ifndef __COMMON_H__
@@ -32,10 +35,13 @@
 extern "C" {
 #endif
 
-#ifdef HAVE_CONFIG_H
-#  include "../config.h"
+/* Allow build on Cygwin*/
+#if defined(__CYGWIN__)
+#define __STRICT_ANSI__
 #endif
 
+#include "../config.h"
+
 #define INLINE __inline
 #if 0 //defined(_WIN32) && !defined(_WIN32_WCE)
 #define ALIGN __declspec(align(16))
@@ -61,7 +67,7 @@
 /* Use if target platform has address generators with autoincrement */
 //#define PREFER_POINTERS
 
-#ifdef _WIN32_WCE
+#if defined(_WIN32_WCE) || defined(__arm__)
 #define FIXED_POINT
 #endif
 
@@ -117,6 +123,9 @@
 # ifdef MAIN_DEC
 #  undef MAIN_DEC
 # endif
+# ifdef SBR_DEC
+#  undef SBR_DEC
+# endif
 #endif // FIXED_POINT
 
 #ifdef DRM
@@ -151,6 +160,7 @@
 
 #include <stdlib.h>
 
+#if 0
 typedef unsigned __int64 uint64_t;
 typedef unsigned __int32 uint32_t;
 typedef unsigned __int16 uint16_t;
@@ -159,11 +169,31 @@
 typedef __int32 int32_t;
 typedef __int16 int16_t;
 typedef __int8  int8_t;
+#else
+#include <inttypes.h>
+#endif
+
 typedef float float32_t;
 
 
 #else
 
+/* #undef HAVE_FLOAT32_T */
+/* Define if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define if you have the `memcpy' function. */
+#define HAVE_MEMCPY 1
+
+/* Define if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define if you have the `strchr' function. */
+#define HAVE_STRCHR 1
+
+/* Define if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
 #include <stdio.h>
 #if HAVE_SYS_TYPES_H
 # include <sys/types.h>
@@ -289,7 +319,7 @@
   }
 
 
-  #if defined(_WIN32) && !defined(__MINGW32__)
+  #if defined(_WIN32) && !defined(__MINGW32__) && !defined(HAVE_LRINTF)
     #define HAS_LRINTF
     static INLINE int lrintf(float f)
     {
@@ -301,7 +331,7 @@
         }
         return i;
     }
-  #elif (defined(__i386__) && defined(__GNUC__))
+  #elif (defined(__i386__) && defined(__GNUC__)) && !defined(HAVE_LRINTF)
     #define HAS_LRINTF
     // from http://www.stereopsis.com/FPU.html
     static INLINE int lrintf(float f)
@@ -330,6 +360,8 @@
 
   #else
 
+#include <math.h>
+
 #ifdef HAVE_LRINTF
 #  define HAS_LRINTF
 #  define _ISOC9X_SOURCE 1
@@ -338,8 +370,6 @@
 #  define __USE_ISOC99   1
 #endif
 
-    #include <math.h>
-
 #ifdef HAVE_SINF
 #  define sin sinf
 #error
--- libfaad2.orig/output.c	2006-03-16 20:15:04.000000000 +0100
+++ libfaad2/output.c	2006-04-18 19:50:26.000000000 +0200
@@ -19,10 +19,9 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
-**
-** $Id: output.c,v 1.42 2004/09/04 14:56:28 menno Exp $
+** Initially modified for use with MPlayer by Rich Felker on 2005/03/29
+** $Id: output.c,v 1.11 2005/04/05 05:43:41 rfelker Exp $
+** detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
 **/
 
 #include "common.h"
@@ -463,7 +462,7 @@
     }
 }
 
-void* output_to_PCM(NeAACDecHandle hDecoder,
+void* output_to_PCM_sux(NeAACDecHandle hDecoder,
                     real_t **input, void *sample_buffer, uint8_t channels,
                     uint16_t frame_len, uint8_t format)
 {
@@ -554,4 +553,51 @@
     return sample_buffer;
 }
 
+void* output_to_PCM(NeAACDecHandle hDecoder,
+                    real_t **input, void *sample_buffer, uint8_t channels,
+                    uint16_t frame_len, uint8_t format)
+{
+    int ch;
+    int i;
+    int16_t *short_sample_buffer = (int16_t*)sample_buffer;
+    real_t *ch0 = input[hDecoder->internal_channel[0]];
+    real_t *ch1 = input[hDecoder->internal_channel[1]];
+    real_t *ch2 = input[hDecoder->internal_channel[2]];
+    real_t *ch3 = input[hDecoder->internal_channel[3]];
+    real_t *ch4 = input[hDecoder->internal_channel[4]];
+
+    if (format != FAAD_FMT_16BIT)
+        return output_to_PCM_sux(hDecoder, input, sample_buffer, channels, frame_len, format);
+
+    if (hDecoder->downMatrix) {
+        for(i = 0; i < frame_len; i++)
+        {
+	    int32_t tmp;
+	    tmp = (ch1[i] + ((ch0[i]+ch3[i])>>1) + ((ch0[i]+ch3[i])>>2) + (1<<(REAL_BITS))) >> (REAL_BITS+1);
+	    if ((tmp+0x8000) & ~0xffff) tmp = ~(tmp>>31)-0x8000;
+            short_sample_buffer[0] = tmp;
+	    tmp = (ch2[i] + ((ch0[i]+ch4[i])>>1) + ((ch0[i]+ch4[i])>>2) + (1<<(REAL_BITS))) >> (REAL_BITS+1);
+	    if ((tmp+0x8000) & ~0xffff) tmp = ~(tmp>>31)-0x8000;
+            short_sample_buffer[1] = tmp;
+	    short_sample_buffer += channels;
+        }
+        return sample_buffer;
+    }
+
+    /* Copy output to a standard PCM buffer */
+    for(i = 0; i < frame_len; i++)
+    {
+        for (ch = 0; ch < channels; ch++)
+        {
+            int32_t tmp = input[hDecoder->internal_channel[ch]][i];
+            tmp += (1 << (REAL_BITS-1));
+            tmp >>= REAL_BITS;
+	    if ((tmp+0x8000) & ~0xffff) tmp = ~(tmp>>31)-0x8000;
+            *(short_sample_buffer++) = tmp;
+        }
+    }
+
+    return sample_buffer;
+}
+
 #endif
--- libfaad2.orig/ps_dec.c	2006-03-16 20:15:04.000000000 +0100
+++ libfaad2/ps_dec.c	2006-04-18 20:29:38.000000000 +0200
@@ -22,7 +22,10 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
+** Initially modified for use with MPlayer on 2005/12/05
 ** $Id: ps_dec.c,v 1.10 2004/09/04 14:56:28 menno Exp $
+** detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
+** local_changes.diff contains the exact changes to this file.
 **/
 
 #include "common.h"
@@ -159,7 +162,7 @@
 
 /* static function declarations */
 static void ps_data_decode(ps_info *ps);
-static hyb_info *hybrid_init();
+static hyb_info *hybrid_init(void);
 static void channel_filter2(hyb_info *hyb, uint8_t frame_len, const real_t *filter,
                             qmf_t *buffer, qmf_t **X_hybrid);
 static void INLINE DCT3_4_unscaled(real_t *y, real_t *x);
@@ -189,7 +192,7 @@
 /*  */
 
 
-static hyb_info *hybrid_init()
+static hyb_info *hybrid_init(void)
 {
     uint8_t i;
 
@@ -1935,8 +1938,8 @@
 /* main Parametric Stereo decoding function */
 uint8_t ps_decode(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64])
 {
-    qmf_t X_hybrid_left[32][32] = {{0}};
-    qmf_t X_hybrid_right[32][32] = {{0}};
+    qmf_t X_hybrid_left[32][32] = {{{0}}};
+    qmf_t X_hybrid_right[32][32] = {{{0}}};
 
     /* delta decoding of the bitstream data */
     ps_data_decode(ps);
--- libfaad2.orig/sbr_dec.c	2006-03-16 20:15:04.000000000 +0100
+++ libfaad2/sbr_dec.c	2006-04-18 20:33:57.000000000 +0200
@@ -22,7 +22,10 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
+** Initially modified for use with MPlayer on 2005/12/05
 ** $Id: sbr_dec.c,v 1.39 2004/09/04 14:56:28 menno Exp $
+** detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
+** local_changes.diff contains the exact changes to this file.
 **/
 
 
@@ -526,8 +529,8 @@
     uint8_t l, k;
     uint8_t dont_process = 0;
     uint8_t ret = 0;
-    ALIGN qmf_t X_left[38][64] = {{0}};
-    ALIGN qmf_t X_right[38][64] = {{0}}; /* must set this to 0 */
+    ALIGN qmf_t X_left[38][64] = {{{0}}};
+    ALIGN qmf_t X_right[38][64] = {{{0}}}; /* must set this to 0 */
 
     if (sbr == NULL)
         return 20;
--- libfaad2.orig/specrec.c	2006-03-16 20:15:04.000000000 +0100
+++ libfaad2/specrec.c	2006-04-18 20:38:09.000000000 +0200
@@ -19,10 +19,10 @@
 ** Any non-GPL usage of this software or parts of this software is strictly
 ** forbidden.
 **
-** Commercial non-GPL licensing of this software is possible.
-** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
-**
+** Initially modified for use with MPlayer on 2006/04/18
 ** $Id: specrec.c,v 1.56 2004/09/08 09:43:11 gcp Exp $
+** detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
+** local_changes.diff contains the exact changes to this file.
 **/
 
 /*
@@ -673,29 +673,19 @@
     /* MAIN object type prediction */
     if (hDecoder->object_type == MAIN)
     {
-        /* allocate the state only when needed */
-        if (hDecoder->pred_stat[channel] == NULL)
-        {
-            hDecoder->pred_stat[channel] = (pred_state*)faad_malloc(hDecoder->frameLength * sizeof(pred_state));
+            hDecoder->pred_stat[channel] = (pred_state*)realloc(hDecoder->pred_stat[channel], hDecoder->frameLength * sizeof(pred_state));
             reset_all_predictors(hDecoder->pred_stat[channel], hDecoder->frameLength);
-        }
     }
 #endif
 
 #ifdef LTP_DEC
     if (is_ltp_ot(hDecoder->object_type))
     {
-        /* allocate the state only when needed */
-        if (hDecoder->lt_pred_stat[channel] == NULL)
-        {
-            hDecoder->lt_pred_stat[channel] = (int16_t*)faad_malloc(hDecoder->frameLength*4 * sizeof(int16_t));
+            hDecoder->lt_pred_stat[channel] = (int16_t*)realloc(hDecoder->lt_pred_stat[channel], hDecoder->frameLength*4 * sizeof(int16_t));
             memset(hDecoder->lt_pred_stat[channel], 0, hDecoder->frameLength*4 * sizeof(int16_t));
-        }
     }
 #endif
 
-    if (hDecoder->time_out[channel] == NULL)
-    {
         mul = 1;
 #ifdef SBR_DEC
         hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 0;
@@ -706,41 +696,28 @@
             hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1;
         }
 #endif
-        hDecoder->time_out[channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t));
+        hDecoder->time_out[channel] = (real_t*)realloc(hDecoder->time_out[channel], mul*hDecoder->frameLength*sizeof(real_t));
         memset(hDecoder->time_out[channel], 0, mul*hDecoder->frameLength*sizeof(real_t));
-    }
 #if (defined(PS_DEC) || defined(DRM_PS))
     if (output_channels == 2)
     {
-        if (hDecoder->time_out[channel+1] == NULL)
-        {
-            hDecoder->time_out[channel+1] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t));
+            hDecoder->time_out[channel+1] = (real_t*)realloc(hDecoder->time_out[channel+1], mul*hDecoder->frameLength*sizeof(real_t));
             memset(hDecoder->time_out[channel+1], 0, mul*hDecoder->frameLength*sizeof(real_t));
-        }
     }
 #endif
 
-    if (hDecoder->fb_intermed[channel] == NULL)
-    {
-        hDecoder->fb_intermed[channel] = (real_t*)faad_malloc(hDecoder->frameLength*sizeof(real_t));
+        hDecoder->fb_intermed[channel] = (real_t*)realloc(hDecoder->fb_intermed[channel], hDecoder->frameLength*sizeof(real_t));
         memset(hDecoder->fb_intermed[channel], 0, hDecoder->frameLength*sizeof(real_t));
-    }
 
 #ifdef SSR_DEC
     if (hDecoder->object_type == SSR)
     {
-        if (hDecoder->ssr_overlap[channel] == NULL)
-        {
-            hDecoder->ssr_overlap[channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
-            memset(hDecoder->ssr_overlap[channel], 0, 2*hDecoder->frameLength*sizeof(real_t));
-        }
-        if (hDecoder->prev_fmd[channel] == NULL)
-        {
             uint16_t k;
-            hDecoder->prev_fmd[channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
+            hDecoder->ssr_overlap[channel] = (real_t*)realloc(hDecoder->ssr_overlap[channel], 2*hDecoder->frameLength*sizeof(real_t));
+            memset(hDecoder->ssr_overlap[channel], 0, 2*hDecoder->frameLength*sizeof(real_t));
+            hDecoder->prev_fmd[channel] = (real_t*)realloc(hDecoder->prev_fmd[channel], 2*hDecoder->frameLength*sizeof(real_t));
             for (k = 0; k < 2*hDecoder->frameLength; k++)
                 hDecoder->prev_fmd[channel][k] = REAL_CONST(-1);
-        }
     }
 #endif
 
@@ -865,22 +842,13 @@
 
     /* always allocate 2 channels, PS can always "suddenly" turn up */
 #if (defined(PS_DEC) || defined(DRM_PS))
-    output_channels = 2;
+    output_channels = hDecoder->ps_used[hDecoder->fr_ch_ele] ? 2 : 1;
 #else
     output_channels = 1;
 #endif
 
-    if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 0)
-    {
-        /* element_output_channels not set yet */
+    if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] < output_channels) {
         hDecoder->element_output_channels[hDecoder->fr_ch_ele] = output_channels;
-    } else if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] != output_channels) {
-        /* element inconsistency */
-        return 21;
-    }
-
-    if (hDecoder->element_alloced[hDecoder->fr_ch_ele] == 0)
-    {
         retval = allocate_single_channel(hDecoder, sce->channel, output_channels);
         if (retval > 0)
             return retval;
@@ -1026,11 +994,10 @@
     {
         return 23;
     }
-#endif
 
     /* copy L to R when no PS is used */
 #if (defined(PS_DEC) || defined(DRM_PS))
-    if ((hDecoder->ps_used[hDecoder->fr_ch_ele] == 0))
+    if ((hDecoder->ps_used[hDecoder->fr_ch_ele] == 0) && (output_channels == 2))
     {
         uint8_t ele = hDecoder->fr_ch_ele;
         uint8_t ch = sce->channel;
@@ -1040,6 +1007,7 @@
         memcpy(hDecoder->time_out[ch+1], hDecoder->time_out[ch], frame_size);
     }
 #endif
+#endif
 
     return 0;
 }