comparison libfaad2/mp4.c @ 13453:6d50ef45a058

Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12. patch by adland <adland123 at yahoo dot com>
author diego
date Fri, 24 Sep 2004 17:31:36 +0000
parents d81145997036
children 2ae5ab4331ca
comparison
equal deleted inserted replaced
13452:c364b7c13dd8 13453:6d50ef45a058
21 ** 21 **
22 ** Commercial non-GPL licensing of this software is possible. 22 ** Commercial non-GPL licensing of this software is possible.
23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. 23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
24 ** 24 **
25 ** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30 25 ** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
26 ** $Id: mp4.c,v 1.3 2004/06/02 22:59:03 diego Exp $ 26 ** $Id: mp4.c,v 1.4 2004/06/23 13:50:51 diego Exp $
27 ** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/ 27 ** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
28 **/ 28 **/
29 29
30 #include "common.h" 30 #include "common.h"
31 #include "structs.h" 31 #include "structs.h"
119 0, /* 30 (Reserved) */ 119 0, /* 30 (Reserved) */
120 0 /* 31 (Reserved) */ 120 0 /* 31 (Reserved) */
121 }; 121 };
122 122
123 /* Table 1.6.1 */ 123 /* Table 1.6.1 */
124 int8_t FAADAPI AudioSpecificConfig(uint8_t *pBuffer, 124 int8_t NEAACDECAPI NeAACDecAudioSpecificConfig(uint8_t *pBuffer,
125 uint32_t buffer_size, 125 uint32_t buffer_size,
126 mp4AudioSpecificConfig *mp4ASC) 126 mp4AudioSpecificConfig *mp4ASC)
127 { 127 {
128 return AudioSpecificConfig2(pBuffer, buffer_size, mp4ASC, NULL); 128 return AudioSpecificConfig2(pBuffer, buffer_size, mp4ASC, NULL);
129 } 129 }
130 130
131 int8_t FAADAPI AudioSpecificConfig2(uint8_t *pBuffer, 131 int8_t AudioSpecificConfig2(uint8_t *pBuffer,
132 uint32_t buffer_size, 132 uint32_t buffer_size,
133 mp4AudioSpecificConfig *mp4ASC, 133 mp4AudioSpecificConfig *mp4ASC,
134 program_config *pce) 134 program_config *pce)
135 { 135 {
136 bitfile ld; 136 bitfile ld;
137 int8_t result = 0; 137 int8_t result = 0;
138 #ifdef SBR_DEC 138 #ifdef SBR_DEC
139 int8_t bits_to_decode = 0; 139 int8_t bits_to_decode = 0;
176 { 176 {
177 faad_endbits(&ld); 177 faad_endbits(&ld);
178 return -3; 178 return -3;
179 } 179 }
180 180
181 #if (defined(PS_DEC) || defined(DRM_PS))
182 /* check if we have a mono file */
183 if (mp4ASC->channelsConfiguration == 1)
184 {
185 /* upMatrix to 2 channels for implicit signalling of PS */
186 mp4ASC->channelsConfiguration = 2;
187 }
188 #endif
189
181 #ifdef SBR_DEC 190 #ifdef SBR_DEC
182 mp4ASC->sbr_present_flag = -1; 191 mp4ASC->sbr_present_flag = -1;
183 if (mp4ASC->objectTypeIndex == 5) 192 if (mp4ASC->objectTypeIndex == 5)
184 { 193 {
194 uint8_t tmp;
195
185 mp4ASC->sbr_present_flag = 1; 196 mp4ASC->sbr_present_flag = 1;
186 mp4ASC->samplingFrequencyIndex = (uint8_t)faad_getbits(&ld, 4 197 tmp = (uint8_t)faad_getbits(&ld, 4
187 DEBUGVAR(1,5,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex")); 198 DEBUGVAR(1,5,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex"));
199 /* check for downsampled SBR */
200 if (tmp == mp4ASC->samplingFrequencyIndex)
201 mp4ASC->downSampledSBR = 1;
202 mp4ASC->samplingFrequencyIndex = tmp;
188 if (mp4ASC->samplingFrequencyIndex == 15) 203 if (mp4ASC->samplingFrequencyIndex == 15)
189 { 204 {
190 mp4ASC->samplingFrequency = (uint32_t)faad_getbits(&ld, 24 205 mp4ASC->samplingFrequency = (uint32_t)faad_getbits(&ld, 24
191 DEBUGVAR(1,6,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex")); 206 DEBUGVAR(1,6,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex"));
192 } else { 207 } else {
243 mp4ASC->sbr_present_flag = (uint8_t)faad_get1bit(&ld 258 mp4ASC->sbr_present_flag = (uint8_t)faad_get1bit(&ld
244 DEBUGVAR(1,11,"parse_audio_decoder_specific_info(): sbr_present_flag")); 259 DEBUGVAR(1,11,"parse_audio_decoder_specific_info(): sbr_present_flag"));
245 260
246 if (mp4ASC->sbr_present_flag) 261 if (mp4ASC->sbr_present_flag)
247 { 262 {
248 mp4ASC->samplingFrequencyIndex = (uint8_t)faad_getbits(&ld, 4 263 uint8_t tmp;
264 tmp = (uint8_t)faad_getbits(&ld, 4
249 DEBUGVAR(1,12,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex")); 265 DEBUGVAR(1,12,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex"));
266
267 /* check for downsampled SBR */
268 if (tmp == mp4ASC->samplingFrequencyIndex)
269 mp4ASC->downSampledSBR = 1;
270 mp4ASC->samplingFrequencyIndex = tmp;
271
250 if (mp4ASC->samplingFrequencyIndex == 15) 272 if (mp4ASC->samplingFrequencyIndex == 15)
251 { 273 {
252 mp4ASC->samplingFrequency = (uint32_t)faad_getbits(&ld, 24 274 mp4ASC->samplingFrequency = (uint32_t)faad_getbits(&ld, 24
253 DEBUGVAR(1,13,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex")); 275 DEBUGVAR(1,13,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex"));
254 } else { 276 } else {
265 { 287 {
266 if (mp4ASC->samplingFrequency <= 24000) 288 if (mp4ASC->samplingFrequency <= 24000)
267 { 289 {
268 mp4ASC->samplingFrequency *= 2; 290 mp4ASC->samplingFrequency *= 2;
269 mp4ASC->forceUpSampling = 1; 291 mp4ASC->forceUpSampling = 1;
292 } else /* > 24000*/ {
293 mp4ASC->downSampledSBR = 1;
270 } 294 }
271 } 295 }
272 #endif 296 #endif
273 297
274 faad_endbits(&ld); 298 faad_endbits(&ld);