annotate libfaad2/decoder.c @ 13427:9d0b052c4f74

setting samplesize to 2 in decoders where neccessary. Needed because initialization of sh_audio was moved from dec_audio to demuxer.c, and some demuxers set samplesize incorrect or to 0.
author reimar
date Tue, 21 Sep 2004 20:34:47 +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
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
4 **
10725
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.
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
9 **
10725
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.
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
14 **
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
15 ** You should have received a copy of the GNU General Public License
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
16 ** along with this program; if not, write to the Free Software
10725
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: decoder.c,v 1.3 2004/06/02 22:59:02 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 #include <string.h>
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
35
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
36 #include "decoder.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
37 #include "mp4.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
38 #include "syntax.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
39 #include "error.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
40 #include "output.h"
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
41 #include "filtbank.h"
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
42 #include "drc.h"
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
43 #ifdef SBR_DEC
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
44 #include "sbr_dec.h"
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
45 #include "sbr_syntax.h"
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
46 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
47 #ifdef SSR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
48 #include "ssr.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
49 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
50
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
51 #ifdef ANALYSIS
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
52 uint16_t dbg_count;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
53 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
54
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
55 int8_t* FAADAPI faacDecGetErrorMessage(uint8_t errcode)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
56 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
57 if (errcode >= NUM_ERROR_MESSAGES)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
58 return NULL;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
59 return err_msg[errcode];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
60 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
61
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
62 uint32_t FAADAPI faacDecGetCapabilities(void)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
63 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
64 uint32_t cap = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
65
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
66 /* can't do without it */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
67 cap += LC_DEC_CAP;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
68
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
69 #ifdef MAIN_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
70 cap += MAIN_DEC_CAP;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
71 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
72 #ifdef LTP_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
73 cap += LTP_DEC_CAP;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
74 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
75 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
76 cap += LD_DEC_CAP;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
77 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
78 #ifdef ERROR_RESILIENCE
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
79 cap += ERROR_RESILIENCE_CAP;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
80 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
81 #ifdef FIXED_POINT
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
82 cap += FIXED_POINT_CAP;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
83 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
84
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
85 return cap;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
86 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
87
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
88 faacDecHandle FAADAPI faacDecOpen(void)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
89 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
90 uint8_t i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
91 faacDecHandle hDecoder = NULL;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
92
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
93 if ((hDecoder = (faacDecHandle)faad_malloc(sizeof(faacDecStruct))) == NULL)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
94 return NULL;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
95
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
96 memset(hDecoder, 0, sizeof(faacDecStruct));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
97
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
98 hDecoder->config.outputFormat = FAAD_FMT_16BIT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
99 hDecoder->config.defObjectType = MAIN;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
100 hDecoder->config.defSampleRate = 44100; /* Default: 44.1kHz */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
101 hDecoder->config.downMatrix = 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
102 hDecoder->adts_header_present = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
103 hDecoder->adif_header_present = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
104 #ifdef ERROR_RESILIENCE
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
105 hDecoder->aacSectionDataResilienceFlag = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
106 hDecoder->aacScalefactorDataResilienceFlag = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
107 hDecoder->aacSpectralDataResilienceFlag = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
108 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
109 hDecoder->frameLength = 1024;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
110
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
111 hDecoder->frame = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
112 hDecoder->sample_buffer = NULL;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
113
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
114 for (i = 0; i < MAX_CHANNELS; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
115 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
116 hDecoder->window_shape_prev[i] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
117 hDecoder->time_out[i] = NULL;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
118 hDecoder->fb_intermed[i] = NULL;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
119 #ifdef SSR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
120 hDecoder->ssr_overlap[i] = NULL;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
121 hDecoder->prev_fmd[i] = NULL;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
122 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
123 #ifdef MAIN_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
124 hDecoder->pred_stat[i] = NULL;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
125 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
126 #ifdef LTP_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
127 hDecoder->ltp_lag[i] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
128 hDecoder->lt_pred_stat[i] = NULL;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
129 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
130 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
131
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
132 #ifdef SBR_DEC
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
133 for (i = 0; i < MAX_SYNTAX_ELEMENTS; i++)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
134 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
135 hDecoder->sbr[i] = NULL;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
136 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
137 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
138
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
139 hDecoder->drc = drc_init(REAL_CONST(1.0), REAL_CONST(1.0));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
140
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
141 #ifdef USE_SSE
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
142 if (cpu_has_sse())
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
143 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
144 hDecoder->apply_sf_func = apply_scalefactors_sse;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
145 } else {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
146 hDecoder->apply_sf_func = apply_scalefactors;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
147 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
148 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
149
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
150 return hDecoder;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
151 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
152
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
153 faacDecConfigurationPtr FAADAPI faacDecGetCurrentConfiguration(faacDecHandle hDecoder)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
154 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
155 if (hDecoder)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
156 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
157 faacDecConfigurationPtr config = &(hDecoder->config);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
158
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
159 return config;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
160 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
161
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
162 return NULL;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
163 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
164
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
165 uint8_t FAADAPI faacDecSetConfiguration(faacDecHandle hDecoder,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
166 faacDecConfigurationPtr config)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
167 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
168 if (hDecoder && config)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
169 {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
170 /* check if we can decode this object type */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
171 if (can_decode_ot(config->defObjectType) < 0)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
172 return 0;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
173 hDecoder->config.defObjectType = config->defObjectType;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
174
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
175 /* samplerate: anything but 0 should be possible */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
176 if (config->defSampleRate == 0)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
177 return 0;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
178 hDecoder->config.defSampleRate = config->defSampleRate;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
179
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
180 /* check output format */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
181 if ((config->outputFormat < 1) || (config->outputFormat > 9))
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
182 return 0;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
183 hDecoder->config.outputFormat = config->outputFormat;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
184
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
185 if (config->downMatrix > 1)
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
186 hDecoder->config.downMatrix = config->downMatrix;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
187
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
188 /* OK */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
189 return 1;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
190 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
191
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
192 return 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
193 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
194
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
195 int32_t FAADAPI faacDecInit(faacDecHandle hDecoder, uint8_t *buffer,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
196 uint32_t buffer_size,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
197 uint32_t *samplerate, uint8_t *channels)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
198 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
199 uint32_t bits = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
200 bitfile ld;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
201 adif_header adif;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
202 adts_header adts;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
203
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
204 if ((hDecoder == NULL) || (samplerate == NULL) || (channels == NULL))
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
205 return -1;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
206
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
207 hDecoder->sf_index = get_sr_index(hDecoder->config.defSampleRate);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
208 hDecoder->object_type = hDecoder->config.defObjectType;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
209 *samplerate = get_sample_rate(hDecoder->sf_index);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
210 *channels = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
211
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
212 if (buffer != NULL)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
213 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
214 faad_initbits(&ld, buffer, buffer_size);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
215
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
216 /* Check if an ADIF header is present */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
217 if ((buffer[0] == 'A') && (buffer[1] == 'D') &&
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
218 (buffer[2] == 'I') && (buffer[3] == 'F'))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
219 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
220 hDecoder->adif_header_present = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
221
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
222 get_adif_header(&adif, &ld);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
223 faad_byte_align(&ld);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
224
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
225 hDecoder->sf_index = adif.pce[0].sf_index;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
226 hDecoder->object_type = adif.pce[0].object_type + 1;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
227
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
228 *samplerate = get_sample_rate(hDecoder->sf_index);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
229 *channels = adif.pce[0].channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
230
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
231 memcpy(&(hDecoder->pce), &(adif.pce[0]), sizeof(program_config));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
232 hDecoder->pce_set = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
233
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
234 bits = bit2byte(faad_get_processed_bits(&ld));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
235
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
236 /* Check if an ADTS header is present */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
237 } else if (faad_showbits(&ld, 12) == 0xfff) {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
238 hDecoder->adts_header_present = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
239
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
240 adts.old_format = hDecoder->config.useOldADTSFormat;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
241 adts_frame(&adts, &ld);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
242
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
243 hDecoder->sf_index = adts.sf_index;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
244 hDecoder->object_type = adts.profile + 1;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
245
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
246 *samplerate = get_sample_rate(hDecoder->sf_index);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
247 *channels = (adts.channel_configuration > 6) ?
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
248 2 : adts.channel_configuration;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
249 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
250
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
251 if (ld.error)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
252 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
253 faad_endbits(&ld);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
254 return -1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
255 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
256 faad_endbits(&ld);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
257 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
258 hDecoder->channelConfiguration = *channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
259
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
260 #ifdef SBR_DEC
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
261 /* implicit signalling */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
262 if (*samplerate <= 24000 && !(hDecoder->config.dontUpSampleImplicitSBR))
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
263 {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
264 *samplerate *= 2;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
265 hDecoder->forceUpSampling = 1;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
266 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
267 #endif
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
268
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
269 /* must be done before frameLength is divided by 2 for LD */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
270 #ifdef SSR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
271 if (hDecoder->object_type == SSR)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
272 hDecoder->fb = ssr_filter_bank_init(hDecoder->frameLength/SSR_BANDS);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
273 else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
274 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
275 hDecoder->fb = filter_bank_init(hDecoder->frameLength);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
276
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
277 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
278 if (hDecoder->object_type == LD)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
279 hDecoder->frameLength >>= 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
280 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
281
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
282 if (can_decode_ot(hDecoder->object_type) < 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
283 return -1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
284
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
285 return bits;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
286 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
287
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
288 /* Init the library using a DecoderSpecificInfo */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
289 int8_t FAADAPI faacDecInit2(faacDecHandle hDecoder, uint8_t *pBuffer,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
290 uint32_t SizeOfDecoderSpecificInfo,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
291 uint32_t *samplerate, uint8_t *channels)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
292 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
293 int8_t rc;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
294 mp4AudioSpecificConfig mp4ASC;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
295
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
296 if((hDecoder == NULL)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
297 || (pBuffer == NULL)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
298 || (SizeOfDecoderSpecificInfo < 2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
299 || (samplerate == NULL)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
300 || (channels == NULL))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
301 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
302 return -1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
303 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
304
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
305 hDecoder->adif_header_present = 0;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
306 hDecoder->adts_header_present = 0;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
307
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
308 /* decode the audio specific config */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
309 rc = AudioSpecificConfig2(pBuffer, SizeOfDecoderSpecificInfo, &mp4ASC,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
310 &(hDecoder->pce));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
311
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
312 /* copy the relevant info to the decoder handle */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
313 *samplerate = mp4ASC.samplingFrequency;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
314 if (mp4ASC.channelsConfiguration)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
315 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
316 *channels = mp4ASC.channelsConfiguration;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
317 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
318 *channels = hDecoder->pce.channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
319 hDecoder->pce_set = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
320 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
321 hDecoder->sf_index = mp4ASC.samplingFrequencyIndex;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
322 hDecoder->object_type = mp4ASC.objectTypeIndex;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
323 #ifdef ERROR_RESILIENCE
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
324 hDecoder->aacSectionDataResilienceFlag = mp4ASC.aacSectionDataResilienceFlag;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
325 hDecoder->aacScalefactorDataResilienceFlag = mp4ASC.aacScalefactorDataResilienceFlag;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
326 hDecoder->aacSpectralDataResilienceFlag = mp4ASC.aacSpectralDataResilienceFlag;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
327 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
328 #ifdef SBR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
329 hDecoder->sbr_present_flag = mp4ASC.sbr_present_flag;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
330 if (hDecoder->config.dontUpSampleImplicitSBR == 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
331 hDecoder->forceUpSampling = mp4ASC.forceUpSampling;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
332 else
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
333 hDecoder->forceUpSampling = 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
334
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
335 /* AAC core decoder samplerate is 2 times as low */
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
336 if (hDecoder->sbr_present_flag == 1 || hDecoder->forceUpSampling == 1)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
337 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
338 hDecoder->sf_index = get_sr_index(mp4ASC.samplingFrequency / 2);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
339 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
340 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
341
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
342 if (rc != 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
343 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
344 return rc;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
345 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
346 hDecoder->channelConfiguration = mp4ASC.channelsConfiguration;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
347 if (mp4ASC.frameLengthFlag)
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
348 #ifdef ALLOW_SMALL_FRAMELENGTH
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
349 hDecoder->frameLength = 960;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
350 #else
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
351 return -1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
352 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
353
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
354 /* must be done before frameLength is divided by 2 for LD */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
355 #ifdef SSR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
356 if (hDecoder->object_type == SSR)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
357 hDecoder->fb = ssr_filter_bank_init(hDecoder->frameLength/SSR_BANDS);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
358 else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
359 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
360 hDecoder->fb = filter_bank_init(hDecoder->frameLength);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
361
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
362 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
363 if (hDecoder->object_type == LD)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
364 hDecoder->frameLength >>= 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
365 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
366
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
367 return 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
368 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
369
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
370 #ifdef DRM
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
371 int8_t FAADAPI faacDecInitDRM(faacDecHandle hDecoder, uint32_t samplerate,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
372 uint8_t channels)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
373 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
374 uint8_t i;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
375
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
376 if (hDecoder == NULL)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
377 return 1; /* error */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
378
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
379 /* Special object type defined for DRM */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
380 hDecoder->config.defObjectType = DRM_ER_LC;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
381
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
382 hDecoder->config.defSampleRate = samplerate;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
383 #ifdef ERROR_RESILIENCE // This shoudl always be defined for DRM
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
384 hDecoder->aacSectionDataResilienceFlag = 1; /* VCB11 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
385 hDecoder->aacScalefactorDataResilienceFlag = 0; /* no RVLC */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
386 hDecoder->aacSpectralDataResilienceFlag = 1; /* HCR */
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
387 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
388 hDecoder->frameLength = 960;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
389 hDecoder->sf_index = get_sr_index(hDecoder->config.defSampleRate);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
390 hDecoder->object_type = hDecoder->config.defObjectType;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
391
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
392 if ((channels == DRMCH_STEREO) || (channels == DRMCH_SBR_STEREO))
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
393 hDecoder->channelConfiguration = 2;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
394 else
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
395 hDecoder->channelConfiguration = 1;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
396
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
397 #ifdef SBR_DEC
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
398 if (channels == DRMCH_SBR_LC_STEREO)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
399 hDecoder->lcstereo_flag = 1;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
400 else
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
401 hDecoder->lcstereo_flag = 0;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
402
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
403 if ((channels == DRMCH_MONO) || (channels == DRMCH_STEREO))
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
404 hDecoder->sbr_present_flag = 0;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
405 else
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
406 hDecoder->sbr_present_flag = 1;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
407
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
408 /* Reset sbr for new initialization */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
409 sbrDecodeEnd(hDecoder->sbr[0]);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
410 hDecoder->sbr[0] = NULL;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
411 #endif
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
412
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
413 if (hDecoder->fb) filter_bank_end(hDecoder->fb);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
414 hDecoder->fb = NULL;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
415
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
416 /* Take care of buffers */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
417 if (hDecoder->sample_buffer) faad_free(hDecoder->sample_buffer);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
418 hDecoder->sample_buffer = NULL;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
419 hDecoder->alloced_channels = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
420
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
421 for (i = 0; i < MAX_CHANNELS; i++)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
422 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
423 hDecoder->window_shape_prev[i] = 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
424
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
425 if (hDecoder->time_out[i]) faad_free(hDecoder->time_out[i]);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
426 hDecoder->time_out[i] = NULL;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
427 if (hDecoder->fb_intermed[i]) faad_free(hDecoder->fb_intermed[i]);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
428 hDecoder->fb_intermed[i] = NULL;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
429 #ifdef SSR_DEC
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
430 if (hDecoder->ssr_overlap[i]) faad_free(hDecoder->ssr_overlap[i]);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
431 hDecoder->ssr_overlap[i] = NULL;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
432 if (hDecoder->prev_fmd[i]) faad_free(hDecoder->prev_fmd[i]);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
433 hDecoder->prev_fmd[i] = NULL;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
434 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
435 #ifdef MAIN_DEC
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
436 if (hDecoder->pred_stat[i]) faad_free(hDecoder->pred_stat[i]);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
437 hDecoder->pred_stat[i] = NULL;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
438 #endif
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
439 #ifdef LTP_DEC
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
440 hDecoder->ltp_lag[i] = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
441 if (hDecoder->lt_pred_stat[i]) faad_free(hDecoder->lt_pred_stat[i]);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
442 hDecoder->lt_pred_stat[i] = NULL;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
443 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
444 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
445
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
446 for (i = 0; i < MAX_SYNTAX_ELEMENTS; i++)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
447 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
448 #ifdef SBR_DEC
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
449 if (hDecoder->sbr[i])
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
450 sbrDecodeEnd(hDecoder->sbr[i]);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
451
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
452 hDecoder->sbr_alloced[i] = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
453 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
454 hDecoder->element_alloced[i] = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
455 hDecoder->element_output_channels[i] = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
456 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
457
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
458 hDecoder->fb = filter_bank_init(hDecoder->frameLength);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
459
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
460 return 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
461 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
462 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
463
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
464 void FAADAPI faacDecClose(faacDecHandle hDecoder)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
465 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
466 uint8_t i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
467
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
468 if (hDecoder == NULL)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
469 return;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
470
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
471 #ifdef PROFILE
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
472 printf("AAC decoder total: %I64d cycles\n", hDecoder->cycles);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
473 printf("requant: %I64d cycles\n", hDecoder->requant_cycles);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
474 printf("spectral_data: %I64d cycles\n", hDecoder->spectral_cycles);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
475 printf("scalefactors: %I64d cycles\n", hDecoder->scalefac_cycles);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
476 printf("output: %I64d cycles\n", hDecoder->output_cycles);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
477 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
478
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
479 for (i = 0; i < MAX_CHANNELS; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
480 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
481 if (hDecoder->time_out[i]) faad_free(hDecoder->time_out[i]);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
482 if (hDecoder->fb_intermed[i]) faad_free(hDecoder->fb_intermed[i]);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
483 #ifdef SSR_DEC
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
484 if (hDecoder->ssr_overlap[i]) faad_free(hDecoder->ssr_overlap[i]);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
485 if (hDecoder->prev_fmd[i]) faad_free(hDecoder->prev_fmd[i]);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
486 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
487 #ifdef MAIN_DEC
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
488 if (hDecoder->pred_stat[i]) faad_free(hDecoder->pred_stat[i]);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
489 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
490 #ifdef LTP_DEC
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
491 if (hDecoder->lt_pred_stat[i]) faad_free(hDecoder->lt_pred_stat[i]);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
492 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
493 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
494
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
495 #ifdef SSR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
496 if (hDecoder->object_type == SSR)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
497 ssr_filter_bank_end(hDecoder->fb);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
498 else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
499 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
500 filter_bank_end(hDecoder->fb);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
501
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
502 drc_end(hDecoder->drc);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
503
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
504 if (hDecoder->sample_buffer) faad_free(hDecoder->sample_buffer);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
505
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
506 #ifdef SBR_DEC
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
507 for (i = 0; i < MAX_SYNTAX_ELEMENTS; i++)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
508 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
509 if (hDecoder->sbr[i])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
510 sbrDecodeEnd(hDecoder->sbr[i]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
511 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
512 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
513
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
514 if (hDecoder) faad_free(hDecoder);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
515 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
516
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
517 void FAADAPI faacDecPostSeekReset(faacDecHandle hDecoder, int32_t frame)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
518 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
519 if (hDecoder)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
520 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
521 hDecoder->postSeekResetFlag = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
522
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
523 if (frame != -1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
524 hDecoder->frame = frame;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
525 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
526 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
527
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
528 static void create_channel_config(faacDecHandle hDecoder, faacDecFrameInfo *hInfo)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
529 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
530 hInfo->num_front_channels = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
531 hInfo->num_side_channels = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
532 hInfo->num_back_channels = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
533 hInfo->num_lfe_channels = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
534 memset(hInfo->channel_position, 0, MAX_CHANNELS*sizeof(uint8_t));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
535
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
536 if (hDecoder->downMatrix)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
537 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
538 hInfo->num_front_channels = 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
539 hInfo->channel_position[0] = FRONT_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
540 hInfo->channel_position[1] = FRONT_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
541 return;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
542 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
543
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
544 /* check if there is a PCE */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
545 if (hDecoder->pce_set)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
546 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
547 uint8_t i, chpos = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
548 uint8_t chdir, back_center = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
549
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
550 hInfo->num_front_channels = hDecoder->pce.num_front_channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
551 hInfo->num_side_channels = hDecoder->pce.num_side_channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
552 hInfo->num_back_channels = hDecoder->pce.num_back_channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
553 hInfo->num_lfe_channels = hDecoder->pce.num_lfe_channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
554
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
555 chdir = hInfo->num_front_channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
556 if (chdir & 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
557 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
558 hInfo->channel_position[chpos++] = FRONT_CHANNEL_CENTER;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
559 chdir--;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
560 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
561 for (i = 0; i < chdir; i += 2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
562 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
563 hInfo->channel_position[chpos++] = FRONT_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
564 hInfo->channel_position[chpos++] = FRONT_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
565 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
566
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
567 for (i = 0; i < hInfo->num_side_channels; i += 2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
568 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
569 hInfo->channel_position[chpos++] = SIDE_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
570 hInfo->channel_position[chpos++] = SIDE_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
571 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
572
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
573 chdir = hInfo->num_back_channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
574 if (chdir & 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
575 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
576 back_center = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
577 chdir--;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
578 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
579 for (i = 0; i < chdir; i += 2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
580 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
581 hInfo->channel_position[chpos++] = BACK_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
582 hInfo->channel_position[chpos++] = BACK_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
583 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
584 if (back_center)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
585 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
586 hInfo->channel_position[chpos++] = BACK_CHANNEL_CENTER;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
587 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
588
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
589 for (i = 0; i < hInfo->num_lfe_channels; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
590 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
591 hInfo->channel_position[chpos++] = LFE_CHANNEL;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
592 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
593
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
594 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
595 switch (hDecoder->channelConfiguration)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
596 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
597 case 1:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
598 hInfo->num_front_channels = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
599 hInfo->channel_position[0] = FRONT_CHANNEL_CENTER;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
600 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
601 case 2:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
602 hInfo->num_front_channels = 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
603 hInfo->channel_position[0] = FRONT_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
604 hInfo->channel_position[1] = FRONT_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
605 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
606 case 3:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
607 hInfo->num_front_channels = 3;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
608 hInfo->channel_position[0] = FRONT_CHANNEL_CENTER;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
609 hInfo->channel_position[1] = FRONT_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
610 hInfo->channel_position[2] = FRONT_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
611 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
612 case 4:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
613 hInfo->num_front_channels = 3;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
614 hInfo->num_back_channels = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
615 hInfo->channel_position[0] = FRONT_CHANNEL_CENTER;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
616 hInfo->channel_position[1] = FRONT_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
617 hInfo->channel_position[2] = FRONT_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
618 hInfo->channel_position[3] = BACK_CHANNEL_CENTER;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
619 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
620 case 5:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
621 hInfo->num_front_channels = 3;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
622 hInfo->num_back_channels = 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
623 hInfo->channel_position[0] = FRONT_CHANNEL_CENTER;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
624 hInfo->channel_position[1] = FRONT_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
625 hInfo->channel_position[2] = FRONT_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
626 hInfo->channel_position[3] = BACK_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
627 hInfo->channel_position[4] = BACK_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
628 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
629 case 6:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
630 hInfo->num_front_channels = 3;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
631 hInfo->num_back_channels = 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
632 hInfo->num_lfe_channels = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
633 hInfo->channel_position[0] = FRONT_CHANNEL_CENTER;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
634 hInfo->channel_position[1] = FRONT_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
635 hInfo->channel_position[2] = FRONT_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
636 hInfo->channel_position[3] = BACK_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
637 hInfo->channel_position[4] = BACK_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
638 hInfo->channel_position[5] = LFE_CHANNEL;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
639 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
640 case 7:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
641 hInfo->num_front_channels = 3;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
642 hInfo->num_side_channels = 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
643 hInfo->num_back_channels = 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
644 hInfo->num_lfe_channels = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
645 hInfo->channel_position[0] = FRONT_CHANNEL_CENTER;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
646 hInfo->channel_position[1] = FRONT_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
647 hInfo->channel_position[2] = FRONT_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
648 hInfo->channel_position[3] = SIDE_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
649 hInfo->channel_position[4] = SIDE_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
650 hInfo->channel_position[5] = BACK_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
651 hInfo->channel_position[6] = BACK_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
652 hInfo->channel_position[7] = LFE_CHANNEL;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
653 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
654 default: /* channelConfiguration == 0 || channelConfiguration > 7 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
655 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
656 uint8_t i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
657 uint8_t ch = hDecoder->fr_channels - hDecoder->has_lfe;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
658 if (ch & 1) /* there's either a center front or a center back channel */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
659 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
660 uint8_t ch1 = (ch-1)/2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
661 if (hDecoder->first_syn_ele == ID_SCE)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
662 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
663 hInfo->num_front_channels = ch1 + 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
664 hInfo->num_back_channels = ch1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
665 hInfo->channel_position[0] = FRONT_CHANNEL_CENTER;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
666 for (i = 1; i <= ch1; i+=2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
667 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
668 hInfo->channel_position[i] = FRONT_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
669 hInfo->channel_position[i+1] = FRONT_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
670 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
671 for (i = ch1+1; i < ch; i+=2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
672 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
673 hInfo->channel_position[i] = BACK_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
674 hInfo->channel_position[i+1] = BACK_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
675 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
676 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
677 hInfo->num_front_channels = ch1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
678 hInfo->num_back_channels = ch1 + 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
679 for (i = 0; i < ch1; i+=2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
680 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
681 hInfo->channel_position[i] = FRONT_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
682 hInfo->channel_position[i+1] = FRONT_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
683 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
684 for (i = ch1; i < ch-1; i+=2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
685 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
686 hInfo->channel_position[i] = BACK_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
687 hInfo->channel_position[i+1] = BACK_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
688 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
689 hInfo->channel_position[ch-1] = BACK_CHANNEL_CENTER;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
690 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
691 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
692 uint8_t ch1 = (ch)/2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
693 hInfo->num_front_channels = ch1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
694 hInfo->num_back_channels = ch1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
695 if (ch1 & 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
696 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
697 hInfo->channel_position[0] = FRONT_CHANNEL_CENTER;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
698 for (i = 1; i <= ch1; i+=2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
699 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
700 hInfo->channel_position[i] = FRONT_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
701 hInfo->channel_position[i+1] = FRONT_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
702 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
703 for (i = ch1+1; i < ch-1; i+=2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
704 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
705 hInfo->channel_position[i] = BACK_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
706 hInfo->channel_position[i+1] = BACK_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
707 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
708 hInfo->channel_position[ch-1] = BACK_CHANNEL_CENTER;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
709 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
710 for (i = 0; i < ch1; i+=2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
711 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
712 hInfo->channel_position[i] = FRONT_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
713 hInfo->channel_position[i+1] = FRONT_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
714 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
715 for (i = ch1; i < ch; i+=2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
716 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
717 hInfo->channel_position[i] = BACK_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
718 hInfo->channel_position[i+1] = BACK_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
719 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
720 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
721 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
722 hInfo->num_lfe_channels = hDecoder->has_lfe;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
723 for (i = ch; i < hDecoder->fr_channels; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
724 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
725 hInfo->channel_position[i] = LFE_CHANNEL;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
726 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
727 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
728 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
729 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
730 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
731 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
732
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
733 void* FAADAPI faacDecDecode(faacDecHandle hDecoder,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
734 faacDecFrameInfo *hInfo,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
735 uint8_t *buffer, uint32_t buffer_size)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
736 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
737 uint8_t channels = 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
738 uint8_t output_channels = 0;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
739 bitfile ld;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
740 uint32_t bitsconsumed;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
741 uint16_t frame_len;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
742 void *sample_buffer;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
743
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
744 #ifdef PROFILE
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
745 int64_t count = faad_get_ts();
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
746 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
747
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
748 /* safety checks */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
749 if ((hDecoder == NULL) || (hInfo == NULL) || (buffer == NULL))
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
750 {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
751 return NULL;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
752 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
753
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
754 frame_len = hDecoder->frameLength;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
755
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
756
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
757 memset(hInfo, 0, sizeof(faacDecFrameInfo));
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
758 memset(hDecoder->internal_channel, 0, MAX_CHANNELS*sizeof(hDecoder->internal_channel[0]));
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
759
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
760 /* initialize the bitstream */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
761 faad_initbits(&ld, buffer, buffer_size);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
762
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
763 #ifdef DRM
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
764 if (hDecoder->object_type == DRM_ER_LC)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
765 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
766 /* We do not support stereo right now */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
767 if (hDecoder->channelConfiguration == 2)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
768 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
769 hInfo->error = 8; // Throw CRC error
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
770 goto error;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
771 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
772
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
773 faad_getbits(&ld, 8
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
774 DEBUGVAR(1,1,"faacDecDecode(): skip CRC"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
775 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
776 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
777
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
778 if (hDecoder->adts_header_present)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
779 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
780 adts_header adts;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
781
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
782 adts.old_format = hDecoder->config.useOldADTSFormat;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
783 if ((hInfo->error = adts_frame(&adts, &ld)) > 0)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
784 goto error;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
785
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
786 /* MPEG2 does byte_alignment() here,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
787 * but ADTS header is always multiple of 8 bits in MPEG2
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
788 * so not needed to actually do it.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
789 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
790 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
791
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
792 #ifdef ANALYSIS
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
793 dbg_count = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
794 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
795
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
796 /* decode the complete bitstream */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
797 #ifdef SCALABLE_DEC
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
798 if ((hDecoder->object_type == 6) || (hDecoder->object_type == DRM_ER_LC))
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
799 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
800 aac_scalable_main_element(hDecoder, hInfo, &ld, &hDecoder->pce, hDecoder->drc);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
801 } else {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
802 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
803 raw_data_block(hDecoder, hInfo, &ld, &hDecoder->pce, hDecoder->drc);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
804 #ifdef SCALABLE_DEC
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
805 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
806 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
807
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
808 channels = hDecoder->fr_channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
809
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
810 if (hInfo->error > 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
811 goto error;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
812
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
813 /* safety check */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
814 if (channels == 0 || channels > MAX_CHANNELS)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
815 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
816 /* invalid number of channels */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
817 hInfo->error = 12;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
818 goto error;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
819 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
820
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
821 /* no more bit reading after this */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
822 bitsconsumed = faad_get_processed_bits(&ld);
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
823 hInfo->bytesconsumed = bit2byte(bitsconsumed);
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
824 if (ld.error)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
825 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
826 hInfo->error = 14;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
827 goto error;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
828 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
829 faad_endbits(&ld);
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
830
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
831
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
832 if (!hDecoder->adts_header_present && !hDecoder->adif_header_present)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
833 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
834 if (channels != hDecoder->channelConfiguration)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
835 hDecoder->channelConfiguration = channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
836
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
837 if (channels == 8) /* 7.1 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
838 hDecoder->channelConfiguration = 7;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
839 if (channels == 7) /* not a standard channelConfiguration */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
840 hDecoder->channelConfiguration = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
841 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
842
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
843 if ((channels == 5 || channels == 6) && hDecoder->config.downMatrix)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
844 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
845 hDecoder->downMatrix = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
846 output_channels = 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
847 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
848 output_channels = channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
849 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
850
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
851 /* Make a channel configuration based on either a PCE or a channelConfiguration */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
852 create_channel_config(hDecoder, hInfo);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
853
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
854 /* number of samples in this frame */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
855 hInfo->samples = frame_len*output_channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
856 /* number of channels in this frame */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
857 hInfo->channels = output_channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
858 /* samplerate */
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
859 hInfo->samplerate = get_sample_rate(hDecoder->sf_index);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
860 /* object type */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
861 hInfo->object_type = hDecoder->object_type;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
862 /* sbr */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
863 hInfo->sbr = NO_SBR;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
864 /* header type */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
865 hInfo->header_type = RAW;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
866 if (hDecoder->adif_header_present)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
867 hInfo->header_type = ADIF;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
868 if (hDecoder->adts_header_present)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
869 hInfo->header_type = ADTS;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
870
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
871 /* check if frame has channel elements */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
872 if (channels == 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
873 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
874 hDecoder->frame++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
875 return NULL;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
876 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
877
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
878 /* allocate the buffer for the final samples */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
879 if ((hDecoder->sample_buffer == NULL) ||
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
880 (hDecoder->alloced_channels != output_channels))
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
881 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
882 static const uint8_t str[] = { sizeof(int16_t), sizeof(int32_t), sizeof(int32_t),
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
883 sizeof(float32_t), sizeof(double), sizeof(int16_t), sizeof(int16_t),
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
884 sizeof(int16_t), sizeof(int16_t), 0, 0, 0
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
885 };
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
886 uint8_t stride = str[hDecoder->config.outputFormat-1];
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
887 #ifdef SBR_DEC
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
888 if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
889 stride = 2 * stride;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
890 #endif
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
891 if (hDecoder->sample_buffer)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
892 faad_free(hDecoder->sample_buffer);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
893 hDecoder->sample_buffer = NULL;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
894 hDecoder->sample_buffer = faad_malloc(frame_len*output_channels*stride);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
895 hDecoder->alloced_channels = output_channels;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
896 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
897
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
898 sample_buffer = hDecoder->sample_buffer;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
899
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
900 #ifdef SBR_DEC
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
901 if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
902 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
903 uint8_t ele;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
904
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
905 /* this data is different when SBR is used or when the data is upsampled */
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
906 frame_len *= 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
907 hInfo->samples *= 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
908 hInfo->samplerate *= 2;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
909
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
910 /* check if every element was provided with SBR data */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
911 for (ele = 0; ele < hDecoder->fr_ch_ele; ele++)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
912 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
913 if (hDecoder->sbr[ele] == NULL)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
914 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
915 hInfo->error = 25;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
916 goto error;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
917 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
918 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
919
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
920 /* sbr */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
921 if (hDecoder->sbr_present_flag == 1)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
922 {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
923 hInfo->object_type = HE_AAC;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
924 hInfo->sbr = SBR_UPSAMPLED;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
925 } else {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
926 hInfo->sbr = NO_SBR_UPSAMPLED;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
927 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
928 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
929 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
930
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
931 sample_buffer = output_to_PCM(hDecoder, hDecoder->time_out, sample_buffer,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
932 output_channels, frame_len, hDecoder->config.outputFormat);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
933
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
934
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
935 hDecoder->postSeekResetFlag = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
936
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
937 hDecoder->frame++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
938 #ifdef LD_DEC
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
939 if (hDecoder->object_type != LD)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
940 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
941 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
942 if (hDecoder->frame <= 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
943 hInfo->samples = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
944 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
945 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
946 /* LD encoders will give lower delay */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
947 if (hDecoder->frame <= 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
948 hInfo->samples = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
949 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
950 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
951
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
952 /* cleanup */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
953 #ifdef ANALYSIS
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
954 fflush(stdout);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
955 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
956
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
957 #ifdef PROFILE
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
958 count = faad_get_ts() - count;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
959 hDecoder->cycles += count;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
960 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
961
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
962 return sample_buffer;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
963
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
964 error:
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
965
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
966 faad_endbits(&ld);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
967
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
968 /* cleanup */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
969 #ifdef ANALYSIS
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
970 fflush(stdout);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
971 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
972
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
973 return NULL;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
974 }