annotate libfaad2/mp4.c @ 12795:ab369fe35121

10l
author faust3
date Sun, 11 Jul 2004 13:43:43 +0000
parents d81145997036
children 6d50ef45a058
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1 /*
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
3 ** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
4 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
5 ** This program is free software; you can redistribute it and/or modify
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
6 ** it under the terms of the GNU General Public License as published by
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
7 ** the Free Software Foundation; either version 2 of the License, or
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
8 ** (at your option) any later version.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
9 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
10 ** This program is distributed in the hope that it will be useful,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
13 ** GNU General Public License for more details.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
14 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
15 ** You should have received a copy of the GNU General Public License
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
16 ** along with this program; if not, write to the Free Software
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
18 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
19 ** Any non-GPL usage of this software or parts of this software is strictly
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
20 ** forbidden.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
21 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
22 ** Commercial non-GPL licensing of this software is possible.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
24 **
12625
d81145997036 More information about modifications to comply more closely with GPL 2a.
diego
parents: 12527
diff changeset
25 ** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
d81145997036 More information about modifications to comply more closely with GPL 2a.
diego
parents: 12527
diff changeset
26 ** $Id: mp4.c,v 1.3 2004/06/02 22:59:03 diego Exp $
d81145997036 More information about modifications to comply more closely with GPL 2a.
diego
parents: 12527
diff changeset
27 ** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
28 **/
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
29
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
30 #include "common.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
31 #include "structs.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
32
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
33 #include <stdlib.h>
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
34
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
35 #include "bits.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
36 #include "mp4.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
37 #include "syntax.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
38
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
39 /* defines if an object type can be decoded by this library or not */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
40 static uint8_t ObjectTypesTable[32] = {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
41 0, /* 0 NULL */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
42 #ifdef MAIN_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
43 1, /* 1 AAC Main */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
44 #else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
45 0, /* 1 AAC Main */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
46 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
47 1, /* 2 AAC LC */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
48 #ifdef SSR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
49 1, /* 3 AAC SSR */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
50 #else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
51 0, /* 3 AAC SSR */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
52 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
53 #ifdef LTP_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
54 1, /* 4 AAC LTP */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
55 #else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
56 0, /* 4 AAC LTP */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
57 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
58 #ifdef SBR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
59 1, /* 5 SBR */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
60 #else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
61 0, /* 5 SBR */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
62 #endif
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
63 #ifdef SCALABLE_DEC
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
64 1, /* 6 AAC Scalable */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
65 #else
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
66 0, /* 6 AAC Scalable */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
67 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
68 0, /* 7 TwinVQ */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
69 0, /* 8 CELP */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
70 0, /* 9 HVXC */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
71 0, /* 10 Reserved */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
72 0, /* 11 Reserved */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
73 0, /* 12 TTSI */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
74 0, /* 13 Main synthetic */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
75 0, /* 14 Wavetable synthesis */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
76 0, /* 15 General MIDI */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
77 0, /* 16 Algorithmic Synthesis and Audio FX */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
78
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
79 /* MPEG-4 Version 2 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
80 #ifdef ERROR_RESILIENCE
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
81 1, /* 17 ER AAC LC */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
82 0, /* 18 (Reserved) */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
83 #ifdef LTP_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
84 1, /* 19 ER AAC LTP */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
85 #else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
86 0, /* 19 ER AAC LTP */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
87 #endif
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
88 #ifdef SCALABLE_DEC
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
89 1, /* 20 ER AAC scalable */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
90 #else
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
91 0, /* 20 ER AAC scalable */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
92 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
93 0, /* 21 ER TwinVQ */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
94 0, /* 22 ER BSAC */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
95 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
96 1, /* 23 ER AAC LD */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
97 #else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
98 0, /* 23 ER AAC LD */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
99 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
100 0, /* 24 ER CELP */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
101 0, /* 25 ER HVXC */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
102 0, /* 26 ER HILN */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
103 0, /* 27 ER Parametric */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
104 #else /* No ER defined */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
105 0, /* 17 ER AAC LC */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
106 0, /* 18 (Reserved) */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
107 0, /* 19 ER AAC LTP */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
108 0, /* 20 ER AAC scalable */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
109 0, /* 21 ER TwinVQ */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
110 0, /* 22 ER BSAC */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
111 0, /* 23 ER AAC LD */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
112 0, /* 24 ER CELP */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
113 0, /* 25 ER HVXC */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
114 0, /* 26 ER HILN */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
115 0, /* 27 ER Parametric */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
116 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
117 0, /* 28 (Reserved) */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
118 0, /* 29 (Reserved) */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
119 0, /* 30 (Reserved) */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
120 0 /* 31 (Reserved) */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
121 };
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
122
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
123 /* Table 1.6.1 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
124 int8_t FAADAPI AudioSpecificConfig(uint8_t *pBuffer,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
125 uint32_t buffer_size,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
126 mp4AudioSpecificConfig *mp4ASC)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
127 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
128 return AudioSpecificConfig2(pBuffer, buffer_size, mp4ASC, NULL);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
129 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
130
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
131 int8_t FAADAPI AudioSpecificConfig2(uint8_t *pBuffer,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
132 uint32_t buffer_size,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
133 mp4AudioSpecificConfig *mp4ASC,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
134 program_config *pce)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
135 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
136 bitfile ld;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
137 int8_t result = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
138 #ifdef SBR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
139 int8_t bits_to_decode = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
140 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
141
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
142 if (pBuffer == NULL)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
143 return -7;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
144 if (mp4ASC == NULL)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
145 return -8;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
146
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
147 memset(mp4ASC, 0, sizeof(mp4AudioSpecificConfig));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
148
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
149 faad_initbits(&ld, pBuffer, buffer_size);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
150 faad_byte_align(&ld);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
151
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
152 mp4ASC->objectTypeIndex = (uint8_t)faad_getbits(&ld, 5
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
153 DEBUGVAR(1,1,"parse_audio_decoder_specific_info(): ObjectTypeIndex"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
154
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
155 mp4ASC->samplingFrequencyIndex = (uint8_t)faad_getbits(&ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
156 DEBUGVAR(1,2,"parse_audio_decoder_specific_info(): SamplingFrequencyIndex"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
157
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
158 mp4ASC->channelsConfiguration = (uint8_t)faad_getbits(&ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
159 DEBUGVAR(1,3,"parse_audio_decoder_specific_info(): ChannelsConfiguration"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
160
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
161 mp4ASC->samplingFrequency = get_sample_rate(mp4ASC->samplingFrequencyIndex);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
162
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
163 if (ObjectTypesTable[mp4ASC->objectTypeIndex] != 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
164 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
165 faad_endbits(&ld);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
166 return -1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
167 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
168
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
169 if (mp4ASC->samplingFrequency == 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
170 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
171 faad_endbits(&ld);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
172 return -2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
173 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
174
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
175 if (mp4ASC->channelsConfiguration > 7)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
176 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
177 faad_endbits(&ld);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
178 return -3;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
179 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
180
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
181 #ifdef SBR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
182 mp4ASC->sbr_present_flag = -1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
183 if (mp4ASC->objectTypeIndex == 5)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
184 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
185 mp4ASC->sbr_present_flag = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
186 mp4ASC->samplingFrequencyIndex = (uint8_t)faad_getbits(&ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
187 DEBUGVAR(1,5,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
188 if (mp4ASC->samplingFrequencyIndex == 15)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
189 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
190 mp4ASC->samplingFrequency = (uint32_t)faad_getbits(&ld, 24
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
191 DEBUGVAR(1,6,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
192 } else {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
193 mp4ASC->samplingFrequency = get_sample_rate(mp4ASC->samplingFrequencyIndex);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
194 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
195 mp4ASC->objectTypeIndex = (uint8_t)faad_getbits(&ld, 5
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
196 DEBUGVAR(1,7,"parse_audio_decoder_specific_info(): ObjectTypeIndex"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
197 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
198 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
199
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
200 /* get GASpecificConfig */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
201 if (mp4ASC->objectTypeIndex == 1 || mp4ASC->objectTypeIndex == 2 ||
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
202 mp4ASC->objectTypeIndex == 3 || mp4ASC->objectTypeIndex == 4 ||
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
203 mp4ASC->objectTypeIndex == 6 || mp4ASC->objectTypeIndex == 7)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
204 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
205 result = GASpecificConfig(&ld, mp4ASC, pce);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
206
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
207 #ifdef ERROR_RESILIENCE
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
208 } else if (mp4ASC->objectTypeIndex >= ER_OBJECT_START) { /* ER */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
209 result = GASpecificConfig(&ld, mp4ASC, pce);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
210 mp4ASC->epConfig = (uint8_t)faad_getbits(&ld, 2
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
211 DEBUGVAR(1,143,"parse_audio_decoder_specific_info(): epConfig"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
212
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
213 if (mp4ASC->epConfig != 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
214 result = -5;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
215 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
216
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
217 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
218 result = -4;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
219 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
220
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
221 #ifdef SSR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
222 /* shorter frames not allowed for SSR */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
223 if ((mp4ASC->objectTypeIndex == 4) && mp4ASC->frameLengthFlag)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
224 return -6;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
225 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
226
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
227
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
228 #ifdef SBR_DEC
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
229 bits_to_decode = (int8_t)(buffer_size*8 - faad_get_processed_bits(&ld));
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
230
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
231 if ((mp4ASC->objectTypeIndex != 5) && (bits_to_decode >= 16))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
232 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
233 int16_t syncExtensionType = (int16_t)faad_getbits(&ld, 11
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
234 DEBUGVAR(1,9,"parse_audio_decoder_specific_info(): syncExtensionType"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
235
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
236 if (syncExtensionType == 0x2b7)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
237 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
238 mp4ASC->objectTypeIndex = (uint8_t)faad_getbits(&ld, 5
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
239 DEBUGVAR(1,10,"parse_audio_decoder_specific_info(): extensionAudioObjectType"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
240
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
241 if (mp4ASC->objectTypeIndex == 5)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
242 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
243 mp4ASC->sbr_present_flag = (uint8_t)faad_get1bit(&ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
244 DEBUGVAR(1,11,"parse_audio_decoder_specific_info(): sbr_present_flag"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
245
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
246 if (mp4ASC->sbr_present_flag)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
247 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
248 mp4ASC->samplingFrequencyIndex = (uint8_t)faad_getbits(&ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
249 DEBUGVAR(1,12,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
250 if (mp4ASC->samplingFrequencyIndex == 15)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
251 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
252 mp4ASC->samplingFrequency = (uint32_t)faad_getbits(&ld, 24
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
253 DEBUGVAR(1,13,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
254 } else {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
255 mp4ASC->samplingFrequency = get_sample_rate(mp4ASC->samplingFrequencyIndex);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
256 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
257 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
258 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
259 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
260 }
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
261
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
262 /* no SBR signalled, this could mean either implicit signalling or no SBR in this file */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
263 /* MPEG specification states: assume SBR on files with samplerate <= 24000 Hz */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
264 if (mp4ASC->sbr_present_flag == -1)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
265 {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
266 if (mp4ASC->samplingFrequency <= 24000)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
267 {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
268 mp4ASC->samplingFrequency *= 2;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
269 mp4ASC->forceUpSampling = 1;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
270 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
271 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
272 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
273
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
274 faad_endbits(&ld);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
275
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
276 return result;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
277 }