annotate libfaad2/decoder.c @ 32127:24299859359f

swscale-test: move conversion from ref to source back to doTest() The source format parameters are kept in static variables and conversion from ref to source is only made when any parameter changes.
author ramiro
date Sun, 12 Sep 2010 18:14:42 +0000
parents 86888a4c406e
children
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 **
18141
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
25 ** $Id: decoder.c,v 1.107 2004/09/08 09:43:11 gcp Exp $
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
26 **/
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
27
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
28 #include "common.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
29 #include "structs.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
30
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
31 #include <stdlib.h>
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
32 #include <string.h>
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
33
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
34 #include "decoder.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
35 #include "mp4.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
36 #include "syntax.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
37 #include "error.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
38 #include "output.h"
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
39 #include "filtbank.h"
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
40 #include "drc.h"
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
41 #ifdef SBR_DEC
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
42 #include "sbr_dec.h"
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
43 #include "sbr_syntax.h"
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
44 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
45 #ifdef SSR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
46 #include "ssr.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
47 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
48
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
49 #ifdef ANALYSIS
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
50 uint16_t dbg_count;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
51 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
52
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
53 /* static function declarations */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
54 static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo,
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
55 uint8_t *buffer, uint32_t buffer_size,
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
56 void **sample_buffer, uint32_t sample_buffer_size);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
57 static void create_channel_config(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
58
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
59
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
60 char* NEAACDECAPI NeAACDecGetErrorMessage(uint8_t errcode)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
61 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
62 if (errcode >= NUM_ERROR_MESSAGES)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
63 return NULL;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
64 return err_msg[errcode];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
65 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
66
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
67 uint32_t NEAACDECAPI NeAACDecGetCapabilities(void)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
68 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
69 uint32_t cap = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
70
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
71 /* can't do without it */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
72 cap += LC_DEC_CAP;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
73
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
74 #ifdef MAIN_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
75 cap += MAIN_DEC_CAP;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
76 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
77 #ifdef LTP_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
78 cap += LTP_DEC_CAP;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
79 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
80 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
81 cap += LD_DEC_CAP;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
82 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
83 #ifdef ERROR_RESILIENCE
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
84 cap += ERROR_RESILIENCE_CAP;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
85 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
86 #ifdef FIXED_POINT
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
87 cap += FIXED_POINT_CAP;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
88 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
89
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
90 return cap;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
91 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
92
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
93 NeAACDecHandle NEAACDECAPI NeAACDecOpen(void)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
94 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
95 uint8_t i;
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
96 NeAACDecHandle hDecoder = NULL;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
97
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
98 if ((hDecoder = (NeAACDecHandle)faad_malloc(sizeof(NeAACDecStruct))) == NULL)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
99 return NULL;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
100
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
101 memset(hDecoder, 0, sizeof(NeAACDecStruct));
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
102
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
103 hDecoder->config.outputFormat = FAAD_FMT_16BIT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
104 hDecoder->config.defObjectType = MAIN;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
105 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
106 hDecoder->config.downMatrix = 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
107 hDecoder->adts_header_present = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
108 hDecoder->adif_header_present = 0;
25835
645cbba10a57 added AudioSpecificConfigFromBitfile() -that reads from an initizialized
nicodvb
parents: 18141
diff changeset
109 hDecoder->latm_header_present = 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
110 #ifdef ERROR_RESILIENCE
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
111 hDecoder->aacSectionDataResilienceFlag = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
112 hDecoder->aacScalefactorDataResilienceFlag = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
113 hDecoder->aacSpectralDataResilienceFlag = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
114 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
115 hDecoder->frameLength = 1024;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
116
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
117 hDecoder->frame = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
118 hDecoder->sample_buffer = NULL;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
119
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
120 for (i = 0; i < MAX_CHANNELS; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
121 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
122 hDecoder->window_shape_prev[i] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
123 hDecoder->time_out[i] = NULL;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
124 hDecoder->fb_intermed[i] = NULL;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
125 #ifdef SSR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
126 hDecoder->ssr_overlap[i] = NULL;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
127 hDecoder->prev_fmd[i] = NULL;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
128 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
129 #ifdef MAIN_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
130 hDecoder->pred_stat[i] = NULL;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
131 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
132 #ifdef LTP_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
133 hDecoder->ltp_lag[i] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
134 hDecoder->lt_pred_stat[i] = NULL;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
135 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
136 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
137
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
138 #ifdef SBR_DEC
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
139 for (i = 0; i < MAX_SYNTAX_ELEMENTS; i++)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
140 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
141 hDecoder->sbr[i] = NULL;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
142 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
143 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
144
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
145 hDecoder->drc = drc_init(REAL_CONST(1.0), REAL_CONST(1.0));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
146
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
147 return hDecoder;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
148 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
149
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
150 NeAACDecConfigurationPtr NEAACDECAPI NeAACDecGetCurrentConfiguration(NeAACDecHandle hDecoder)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
151 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
152 if (hDecoder)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
153 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
154 NeAACDecConfigurationPtr config = &(hDecoder->config);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
155
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
156 return config;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
157 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
158
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
159 return NULL;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
160 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
161
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
162 uint8_t NEAACDECAPI NeAACDecSetConfiguration(NeAACDecHandle hDecoder,
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
163 NeAACDecConfigurationPtr config)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
164 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
165 if (hDecoder && config)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
166 {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
167 /* check if we can decode this object type */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
168 if (can_decode_ot(config->defObjectType) < 0)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
169 return 0;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
170 hDecoder->config.defObjectType = config->defObjectType;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
171
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
172 /* samplerate: anything but 0 should be possible */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
173 if (config->defSampleRate == 0)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
174 return 0;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
175 hDecoder->config.defSampleRate = config->defSampleRate;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
176
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
177 /* check output format */
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
178 #ifdef FIXED_POINT
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
179 if ((config->outputFormat < 1) || (config->outputFormat > 4))
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
180 return 0;
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
181 #else
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
182 if ((config->outputFormat < 1) || (config->outputFormat > 5))
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
183 return 0;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
184 #endif
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
185 hDecoder->config.outputFormat = config->outputFormat;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
186
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
187 if (config->downMatrix > 1)
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
188 return 0;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
189 hDecoder->config.downMatrix = config->downMatrix;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
190
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
191 /* OK */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
192 return 1;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
193 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
194
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
195 return 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
196 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
197
25836
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
198 static int latmCheck(latm_header *latm, bitfile *ld)
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
199 {
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
200 uint32_t good=0, bad=0, bits, m;
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
201
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
202 while(!ld->error && !ld->no_more_reading)
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
203 {
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
204 bits = faad_latm_frame(latm, ld);
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
205 if(bits==-1U)
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
206 bad++;
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
207 else
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
208 {
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
209 good++;
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
210 while(bits>0)
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
211 {
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
212 m = min(bits, 8);
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
213 faad_getbits(ld, m);
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
214 bits -= m;
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
215 }
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
216 }
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
217 }
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
218
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
219 return (good>0);
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
220 }
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
221
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
222
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
223 int32_t NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder, uint8_t *buffer,
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
224 uint32_t buffer_size,
31477
86888a4c406e Improve LATM recognition.
cehoyos
parents: 29264
diff changeset
225 uint32_t *samplerate, uint8_t *channels, int latm_stream)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
226 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
227 uint32_t bits = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
228 bitfile ld;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
229 adif_header adif;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
230 adts_header adts;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
231
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
232 if ((hDecoder == NULL) || (samplerate == NULL) || (channels == NULL))
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
233 return -1;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
234
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
235 hDecoder->sf_index = get_sr_index(hDecoder->config.defSampleRate);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
236 hDecoder->object_type = hDecoder->config.defObjectType;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
237 *samplerate = get_sample_rate(hDecoder->sf_index);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
238 *channels = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
239
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
240 if (buffer != NULL)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
241 {
25836
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
242 int is_latm;
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
243 latm_header *l = &hDecoder->latm_config;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
244 faad_initbits(&ld, buffer, buffer_size);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
245
25836
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
246 memset(l, 0, sizeof(latm_header));
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
247 is_latm = latmCheck(l, &ld);
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
248 l->inited = 0;
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
249 l->frameLength = 0;
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
250 faad_rewindbits(&ld);
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
251 if(is_latm && l->ASCbits>0)
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
252 {
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
253 int32_t x;
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
254 hDecoder->latm_header_present = 1;
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
255 x = NeAACDecInit2(hDecoder, &l->ASC, (l->ASCbits+7)/8, samplerate, channels);
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
256 if(x!=0)
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
257 hDecoder->latm_header_present = 0;
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
258 return x;
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
259 }
31477
86888a4c406e Improve LATM recognition.
cehoyos
parents: 29264
diff changeset
260 else if (latm_stream) {
86888a4c406e Improve LATM recognition.
cehoyos
parents: 29264
diff changeset
261 return -1;
86888a4c406e Improve LATM recognition.
cehoyos
parents: 29264
diff changeset
262 }
25836
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
263 else
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
264 /* Check if an ADIF header is present */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
265 if ((buffer[0] == 'A') && (buffer[1] == 'D') &&
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
266 (buffer[2] == 'I') && (buffer[3] == 'F'))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
267 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
268 hDecoder->adif_header_present = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
269
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
270 get_adif_header(&adif, &ld);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
271 faad_byte_align(&ld);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
272
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
273 hDecoder->sf_index = adif.pce[0].sf_index;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
274 hDecoder->object_type = adif.pce[0].object_type + 1;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
275
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
276 *samplerate = get_sample_rate(hDecoder->sf_index);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
277 *channels = adif.pce[0].channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
278
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
279 memcpy(&(hDecoder->pce), &(adif.pce[0]), sizeof(program_config));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
280 hDecoder->pce_set = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
281
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
282 bits = bit2byte(faad_get_processed_bits(&ld));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
283
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
284 /* Check if an ADTS header is present */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
285 } else if (faad_showbits(&ld, 12) == 0xfff) {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
286 hDecoder->adts_header_present = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
287
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
288 adts.old_format = hDecoder->config.useOldADTSFormat;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
289 adts_frame(&adts, &ld);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
290
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
291 hDecoder->sf_index = adts.sf_index;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
292 hDecoder->object_type = adts.profile + 1;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
293
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
294 *samplerate = get_sample_rate(hDecoder->sf_index);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
295 *channels = (adts.channel_configuration > 6) ?
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
296 2 : adts.channel_configuration;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
297 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
298
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
299 if (ld.error)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
300 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
301 faad_endbits(&ld);
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 faad_endbits(&ld);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
305 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
306 hDecoder->channelConfiguration = *channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
307
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
308 #if (defined(PS_DEC) || defined(DRM_PS))
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
309 /* check if we have a mono file */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
310 if (*channels == 1)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
311 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
312 /* upMatrix to 2 channels for implicit signalling of PS */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
313 *channels = 2;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
314 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
315 #endif
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
316
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
317 #ifdef SBR_DEC
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
318 /* implicit signalling */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
319 if (*samplerate <= 24000 && !(hDecoder->config.dontUpSampleImplicitSBR))
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
320 {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
321 *samplerate *= 2;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
322 hDecoder->forceUpSampling = 1;
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
323 } else if (*samplerate > 24000 && !(hDecoder->config.dontUpSampleImplicitSBR)) {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
324 hDecoder->downSampledSBR = 1;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
325 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
326 #endif
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
327
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
328 /* must be done before frameLength is divided by 2 for LD */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
329 #ifdef SSR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
330 if (hDecoder->object_type == SSR)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
331 hDecoder->fb = ssr_filter_bank_init(hDecoder->frameLength/SSR_BANDS);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
332 else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
333 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
334 hDecoder->fb = filter_bank_init(hDecoder->frameLength);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
335
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
336 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
337 if (hDecoder->object_type == LD)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
338 hDecoder->frameLength >>= 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
339 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
340
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
341 if (can_decode_ot(hDecoder->object_type) < 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
342 return -1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
343
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
344 return bits;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
345 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
346
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
347 /* Init the library using a DecoderSpecificInfo */
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
348 int8_t NEAACDECAPI NeAACDecInit2(NeAACDecHandle hDecoder, uint8_t *pBuffer,
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
349 uint32_t SizeOfDecoderSpecificInfo,
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
350 uint32_t *samplerate, uint8_t *channels)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
351 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
352 int8_t rc;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
353 mp4AudioSpecificConfig mp4ASC;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
354
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
355 if((hDecoder == NULL)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
356 || (pBuffer == NULL)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
357 || (SizeOfDecoderSpecificInfo < 2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
358 || (samplerate == NULL)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
359 || (channels == NULL))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
360 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
361 return -1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
362 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
363
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
364 hDecoder->adif_header_present = 0;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
365 hDecoder->adts_header_present = 0;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
366
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
367 /* decode the audio specific config */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
368 rc = AudioSpecificConfig2(pBuffer, SizeOfDecoderSpecificInfo, &mp4ASC,
25835
645cbba10a57 added AudioSpecificConfigFromBitfile() -that reads from an initizialized
nicodvb
parents: 18141
diff changeset
369 &(hDecoder->pce), hDecoder->latm_header_present);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
370
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
371 /* copy the relevant info to the decoder handle */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
372 *samplerate = mp4ASC.samplingFrequency;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
373 if (mp4ASC.channelsConfiguration)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
374 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
375 *channels = mp4ASC.channelsConfiguration;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
376 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
377 *channels = hDecoder->pce.channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
378 hDecoder->pce_set = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
379 }
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
380 #if (defined(PS_DEC) || defined(DRM_PS))
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
381 /* check if we have a mono file */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
382 if (*channels == 1)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
383 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
384 /* upMatrix to 2 channels for implicit signalling of PS */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
385 *channels = 2;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
386 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
387 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
388 hDecoder->sf_index = mp4ASC.samplingFrequencyIndex;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
389 hDecoder->object_type = mp4ASC.objectTypeIndex;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
390 #ifdef ERROR_RESILIENCE
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
391 hDecoder->aacSectionDataResilienceFlag = mp4ASC.aacSectionDataResilienceFlag;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
392 hDecoder->aacScalefactorDataResilienceFlag = mp4ASC.aacScalefactorDataResilienceFlag;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
393 hDecoder->aacSpectralDataResilienceFlag = mp4ASC.aacSpectralDataResilienceFlag;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
394 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
395 #ifdef SBR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
396 hDecoder->sbr_present_flag = mp4ASC.sbr_present_flag;
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
397 hDecoder->downSampledSBR = mp4ASC.downSampledSBR;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
398 if (hDecoder->config.dontUpSampleImplicitSBR == 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
399 hDecoder->forceUpSampling = mp4ASC.forceUpSampling;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
400 else
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
401 hDecoder->forceUpSampling = 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
402
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
403 /* AAC core decoder samplerate is 2 times as low */
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
404 if (((hDecoder->sbr_present_flag == 1)&&(!hDecoder->downSampledSBR)) || hDecoder->forceUpSampling == 1)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
405 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
406 hDecoder->sf_index = get_sr_index(mp4ASC.samplingFrequency / 2);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
407 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
408 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
409
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
410 if (rc != 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
411 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
412 return rc;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
413 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
414 hDecoder->channelConfiguration = mp4ASC.channelsConfiguration;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
415 if (mp4ASC.frameLengthFlag)
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
416 #ifdef ALLOW_SMALL_FRAMELENGTH
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
417 hDecoder->frameLength = 960;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
418 #else
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
419 return -1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
420 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
421
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
422 /* must be done before frameLength is divided by 2 for LD */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
423 #ifdef SSR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
424 if (hDecoder->object_type == SSR)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
425 hDecoder->fb = ssr_filter_bank_init(hDecoder->frameLength/SSR_BANDS);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
426 else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
427 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
428 hDecoder->fb = filter_bank_init(hDecoder->frameLength);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
429
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
430 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
431 if (hDecoder->object_type == LD)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
432 hDecoder->frameLength >>= 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
433 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
434
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
435 return 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
436 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
437
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
438 #ifdef DRM
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
439 int8_t NEAACDECAPI NeAACDecInitDRM(NeAACDecHandle *hDecoder, uint32_t samplerate,
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
440 uint8_t channels)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
441 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
442 if (hDecoder == NULL)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
443 return 1; /* error */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
444
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
445 NeAACDecClose(*hDecoder);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
446
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
447 *hDecoder = NeAACDecOpen();
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
448
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
449 /* Special object type defined for DRM */
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
450 (*hDecoder)->config.defObjectType = DRM_ER_LC;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
451
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
452 (*hDecoder)->config.defSampleRate = samplerate;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
453 #ifdef ERROR_RESILIENCE // This shoudl always be defined for DRM
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
454 (*hDecoder)->aacSectionDataResilienceFlag = 1; /* VCB11 */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
455 (*hDecoder)->aacScalefactorDataResilienceFlag = 0; /* no RVLC */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
456 (*hDecoder)->aacSpectralDataResilienceFlag = 1; /* HCR */
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
457 #endif
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
458 (*hDecoder)->frameLength = 960;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
459 (*hDecoder)->sf_index = get_sr_index((*hDecoder)->config.defSampleRate);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
460 (*hDecoder)->object_type = (*hDecoder)->config.defObjectType;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
461
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
462 if ((channels == DRMCH_STEREO) || (channels == DRMCH_SBR_STEREO))
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
463 (*hDecoder)->channelConfiguration = 2;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
464 else
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
465 (*hDecoder)->channelConfiguration = 1;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
466
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
467 #ifdef SBR_DEC
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
468 if ((channels == DRMCH_MONO) || (channels == DRMCH_STEREO))
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
469 (*hDecoder)->sbr_present_flag = 0;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
470 else
29264
e83eef58b30a Remove all kind of trailing whitespaces from all MPlayer's files.
bircoph
parents: 25836
diff changeset
471 (*hDecoder)->sbr_present_flag = 1;
e83eef58b30a Remove all kind of trailing whitespaces from all MPlayer's files.
bircoph
parents: 25836
diff changeset
472 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
473
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
474 (*hDecoder)->fb = filter_bank_init((*hDecoder)->frameLength);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
475
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
476 return 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
477 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
478 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
479
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
480 void NEAACDECAPI NeAACDecClose(NeAACDecHandle hDecoder)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
481 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
482 uint8_t i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
483
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
484 if (hDecoder == NULL)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
485 return;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
486
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
487 #ifdef PROFILE
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
488 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
489 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
490 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
491 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
492 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
493 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
494
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
495 for (i = 0; i < MAX_CHANNELS; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
496 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
497 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
498 if (hDecoder->fb_intermed[i]) faad_free(hDecoder->fb_intermed[i]);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
499 #ifdef SSR_DEC
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
500 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
501 if (hDecoder->prev_fmd[i]) faad_free(hDecoder->prev_fmd[i]);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
502 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
503 #ifdef MAIN_DEC
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
504 if (hDecoder->pred_stat[i]) faad_free(hDecoder->pred_stat[i]);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
505 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
506 #ifdef LTP_DEC
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
507 if (hDecoder->lt_pred_stat[i]) faad_free(hDecoder->lt_pred_stat[i]);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
508 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
509 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
510
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
511 #ifdef SSR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
512 if (hDecoder->object_type == SSR)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
513 ssr_filter_bank_end(hDecoder->fb);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
514 else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
515 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
516 filter_bank_end(hDecoder->fb);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
517
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
518 drc_end(hDecoder->drc);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
519
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
520 if (hDecoder->sample_buffer) faad_free(hDecoder->sample_buffer);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
521
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
522 #ifdef SBR_DEC
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
523 for (i = 0; i < MAX_SYNTAX_ELEMENTS; i++)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
524 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
525 if (hDecoder->sbr[i])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
526 sbrDecodeEnd(hDecoder->sbr[i]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
527 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
528 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
529
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
530 if (hDecoder) faad_free(hDecoder);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
531 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
532
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
533 void NEAACDECAPI NeAACDecPostSeekReset(NeAACDecHandle hDecoder, int32_t frame)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
534 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
535 if (hDecoder)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
536 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
537 hDecoder->postSeekResetFlag = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
538
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
539 if (frame != -1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
540 hDecoder->frame = frame;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
541 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
542 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
543
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
544 static void create_channel_config(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
545 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
546 hInfo->num_front_channels = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
547 hInfo->num_side_channels = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
548 hInfo->num_back_channels = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
549 hInfo->num_lfe_channels = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
550 memset(hInfo->channel_position, 0, MAX_CHANNELS*sizeof(uint8_t));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
551
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
552 if (hDecoder->downMatrix)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
553 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
554 hInfo->num_front_channels = 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
555 hInfo->channel_position[0] = FRONT_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
556 hInfo->channel_position[1] = FRONT_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
557 return;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
558 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
559
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
560 /* check if there is a PCE */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
561 if (hDecoder->pce_set)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
562 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
563 uint8_t i, chpos = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
564 uint8_t chdir, back_center = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
565
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
566 hInfo->num_front_channels = hDecoder->pce.num_front_channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
567 hInfo->num_side_channels = hDecoder->pce.num_side_channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
568 hInfo->num_back_channels = hDecoder->pce.num_back_channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
569 hInfo->num_lfe_channels = hDecoder->pce.num_lfe_channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
570
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
571 chdir = hInfo->num_front_channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
572 if (chdir & 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
573 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
574 hInfo->channel_position[chpos++] = FRONT_CHANNEL_CENTER;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
575 chdir--;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
576 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
577 for (i = 0; i < chdir; i += 2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
578 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
579 hInfo->channel_position[chpos++] = FRONT_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
580 hInfo->channel_position[chpos++] = FRONT_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
581 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
582
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
583 for (i = 0; i < hInfo->num_side_channels; i += 2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
584 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
585 hInfo->channel_position[chpos++] = SIDE_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
586 hInfo->channel_position[chpos++] = SIDE_CHANNEL_RIGHT;
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 chdir = hInfo->num_back_channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
590 if (chdir & 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
591 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
592 back_center = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
593 chdir--;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
594 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
595 for (i = 0; i < chdir; i += 2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
596 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
597 hInfo->channel_position[chpos++] = BACK_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
598 hInfo->channel_position[chpos++] = BACK_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
599 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
600 if (back_center)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
601 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
602 hInfo->channel_position[chpos++] = BACK_CHANNEL_CENTER;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
603 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
604
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
605 for (i = 0; i < hInfo->num_lfe_channels; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
606 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
607 hInfo->channel_position[chpos++] = LFE_CHANNEL;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
608 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
609
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
610 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
611 switch (hDecoder->channelConfiguration)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
612 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
613 case 1:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
614 hInfo->num_front_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 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
617 case 2:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
618 hInfo->num_front_channels = 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
619 hInfo->channel_position[0] = FRONT_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
620 hInfo->channel_position[1] = FRONT_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
621 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
622 case 3:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
623 hInfo->num_front_channels = 3;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
624 hInfo->channel_position[0] = FRONT_CHANNEL_CENTER;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
625 hInfo->channel_position[1] = FRONT_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
626 hInfo->channel_position[2] = FRONT_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
627 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
628 case 4:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
629 hInfo->num_front_channels = 3;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
630 hInfo->num_back_channels = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
631 hInfo->channel_position[0] = FRONT_CHANNEL_CENTER;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
632 hInfo->channel_position[1] = FRONT_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
633 hInfo->channel_position[2] = FRONT_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
634 hInfo->channel_position[3] = BACK_CHANNEL_CENTER;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
635 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
636 case 5:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
637 hInfo->num_front_channels = 3;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
638 hInfo->num_back_channels = 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
639 hInfo->channel_position[0] = FRONT_CHANNEL_CENTER;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
640 hInfo->channel_position[1] = FRONT_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
641 hInfo->channel_position[2] = FRONT_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
642 hInfo->channel_position[3] = BACK_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
643 hInfo->channel_position[4] = BACK_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
644 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
645 case 6:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
646 hInfo->num_front_channels = 3;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
647 hInfo->num_back_channels = 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
648 hInfo->num_lfe_channels = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
649 hInfo->channel_position[0] = FRONT_CHANNEL_CENTER;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
650 hInfo->channel_position[1] = FRONT_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
651 hInfo->channel_position[2] = FRONT_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
652 hInfo->channel_position[3] = BACK_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
653 hInfo->channel_position[4] = BACK_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
654 hInfo->channel_position[5] = LFE_CHANNEL;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
655 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
656 case 7:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
657 hInfo->num_front_channels = 3;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
658 hInfo->num_side_channels = 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
659 hInfo->num_back_channels = 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
660 hInfo->num_lfe_channels = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
661 hInfo->channel_position[0] = FRONT_CHANNEL_CENTER;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
662 hInfo->channel_position[1] = FRONT_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
663 hInfo->channel_position[2] = FRONT_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
664 hInfo->channel_position[3] = SIDE_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
665 hInfo->channel_position[4] = SIDE_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
666 hInfo->channel_position[5] = BACK_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
667 hInfo->channel_position[6] = BACK_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
668 hInfo->channel_position[7] = LFE_CHANNEL;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
669 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
670 default: /* channelConfiguration == 0 || channelConfiguration > 7 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
671 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
672 uint8_t i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
673 uint8_t ch = hDecoder->fr_channels - hDecoder->has_lfe;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
674 if (ch & 1) /* there's either a center front or a center back channel */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
675 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
676 uint8_t ch1 = (ch-1)/2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
677 if (hDecoder->first_syn_ele == ID_SCE)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
678 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
679 hInfo->num_front_channels = ch1 + 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
680 hInfo->num_back_channels = ch1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
681 hInfo->channel_position[0] = FRONT_CHANNEL_CENTER;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
682 for (i = 1; i <= ch1; i+=2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
683 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
684 hInfo->channel_position[i] = FRONT_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
685 hInfo->channel_position[i+1] = FRONT_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
686 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
687 for (i = ch1+1; i < ch; i+=2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
688 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
689 hInfo->channel_position[i] = BACK_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
690 hInfo->channel_position[i+1] = BACK_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
691 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
692 } else {
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 + 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
695 for (i = 0; i < ch1; i+=2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
696 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
697 hInfo->channel_position[i] = FRONT_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
698 hInfo->channel_position[i+1] = FRONT_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
699 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
700 for (i = ch1; i < ch-1; i+=2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
701 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
702 hInfo->channel_position[i] = BACK_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
703 hInfo->channel_position[i+1] = BACK_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
704 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
705 hInfo->channel_position[ch-1] = BACK_CHANNEL_CENTER;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
706 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
707 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
708 uint8_t ch1 = (ch)/2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
709 hInfo->num_front_channels = ch1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
710 hInfo->num_back_channels = ch1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
711 if (ch1 & 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
712 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
713 hInfo->channel_position[0] = FRONT_CHANNEL_CENTER;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
714 for (i = 1; i <= ch1; i+=2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
715 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
716 hInfo->channel_position[i] = FRONT_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
717 hInfo->channel_position[i+1] = FRONT_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
718 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
719 for (i = ch1+1; i < ch-1; i+=2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
720 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
721 hInfo->channel_position[i] = BACK_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
722 hInfo->channel_position[i+1] = BACK_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
723 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
724 hInfo->channel_position[ch-1] = BACK_CHANNEL_CENTER;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
725 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
726 for (i = 0; i < ch1; i+=2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
727 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
728 hInfo->channel_position[i] = FRONT_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
729 hInfo->channel_position[i+1] = FRONT_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
730 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
731 for (i = ch1; i < ch; i+=2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
732 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
733 hInfo->channel_position[i] = BACK_CHANNEL_LEFT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
734 hInfo->channel_position[i+1] = BACK_CHANNEL_RIGHT;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
735 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
736 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
737 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
738 hInfo->num_lfe_channels = hDecoder->has_lfe;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
739 for (i = ch; i < hDecoder->fr_channels; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
740 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
741 hInfo->channel_position[i] = LFE_CHANNEL;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
742 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
743 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
744 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
745 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
746 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
747 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
748
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
749 void* NEAACDECAPI NeAACDecDecode(NeAACDecHandle hDecoder,
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
750 NeAACDecFrameInfo *hInfo,
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
751 uint8_t *buffer, uint32_t buffer_size)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
752 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
753 return aac_frame_decode(hDecoder, hInfo, buffer, buffer_size, NULL, 0);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
754 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
755
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
756 void* NEAACDECAPI NeAACDecDecode2(NeAACDecHandle hDecoder,
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
757 NeAACDecFrameInfo *hInfo,
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
758 uint8_t *buffer, uint32_t buffer_size,
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
759 void **sample_buffer, uint32_t sample_buffer_size)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
760 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
761 if ((sample_buffer == NULL) || (sample_buffer_size == 0))
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
762 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
763 hInfo->error = 27;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
764 return NULL;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
765 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
766
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
767 return aac_frame_decode(hDecoder, hInfo, buffer, buffer_size,
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
768 sample_buffer, sample_buffer_size);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
769 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
770
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
771 static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo,
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
772 uint8_t *buffer, uint32_t buffer_size,
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
773 void **sample_buffer2, uint32_t sample_buffer_size)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
774 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
775 uint8_t channels = 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
776 uint8_t output_channels = 0;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
777 bitfile ld;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
778 uint32_t bitsconsumed;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
779 uint16_t frame_len;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
780 void *sample_buffer;
25836
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
781 uint32_t startbit=0, endbit=0, payload_bits=0;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
782
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
783 #ifdef PROFILE
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
784 int64_t count = faad_get_ts();
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
785 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
786
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
787 /* safety checks */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
788 if ((hDecoder == NULL) || (hInfo == NULL) || (buffer == NULL))
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
789 {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
790 return NULL;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
791 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
792
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
793 #if 0
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
794 printf("%d\n", buffer_size*8);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
795 #endif
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
796
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
797 frame_len = hDecoder->frameLength;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
798
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
799
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
800 memset(hInfo, 0, sizeof(NeAACDecFrameInfo));
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
801 memset(hDecoder->internal_channel, 0, MAX_CHANNELS*sizeof(hDecoder->internal_channel[0]));
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
802
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
803 /* initialize the bitstream */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
804 faad_initbits(&ld, buffer, buffer_size);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
805
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
806 #if 0
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
807 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
808 int i;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
809 for (i = 0; i < ((buffer_size+3)>>2); i++)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
810 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
811 uint8_t *buf;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
812 uint32_t temp = 0;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
813 buf = faad_getbitbuffer(&ld, 32);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
814 //temp = getdword((void*)buf);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
815 temp = *((uint32_t*)buf);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
816 printf("0x%.8X\n", temp);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
817 free(buf);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
818 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
819 faad_endbits(&ld);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
820 faad_initbits(&ld, buffer, buffer_size);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
821 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
822 #endif
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
823
25836
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
824 if(hDecoder->latm_header_present)
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
825 {
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
826 payload_bits = faad_latm_frame(&hDecoder->latm_config, &ld);
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
827 startbit = faad_get_processed_bits(&ld);
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
828 if(payload_bits == -1U)
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
829 {
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
830 hInfo->error = 1;
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
831 goto error;
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
832 }
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
833 }
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
834
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
835 #ifdef DRM
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
836 if (hDecoder->object_type == DRM_ER_LC)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
837 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
838 /* We do not support stereo right now */
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
839 if (0) //(hDecoder->channelConfiguration == 2)
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
840 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
841 hInfo->error = 8; // Throw CRC error
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
842 goto error;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
843 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
844
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
845 faad_getbits(&ld, 8
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
846 DEBUGVAR(1,1,"NeAACDecDecode(): skip CRC"));
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
847 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
848 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
849
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
850 if (hDecoder->adts_header_present)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
851 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
852 adts_header adts;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
853
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
854 adts.old_format = hDecoder->config.useOldADTSFormat;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
855 if ((hInfo->error = adts_frame(&adts, &ld)) > 0)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
856 goto error;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
857
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
858 /* MPEG2 does byte_alignment() here,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
859 * but ADTS header is always multiple of 8 bits in MPEG2
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
860 * so not needed to actually do it.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
861 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
862 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
863
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
864 #ifdef ANALYSIS
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
865 dbg_count = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
866 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
867
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
868 /* decode the complete bitstream */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
869 #ifdef SCALABLE_DEC
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
870 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
871 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
872 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
873 } else {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
874 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
875 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
876 #ifdef SCALABLE_DEC
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
877 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
878 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
879
25836
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
880 if(hDecoder->latm_header_present)
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
881 {
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
882 endbit = faad_get_processed_bits(&ld);
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
883 if(endbit-startbit > payload_bits)
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
884 fprintf(stderr, "\r\nERROR, too many payload bits read: %u > %d. Please. report with a link to a sample\n",
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
885 endbit-startbit, payload_bits);
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
886 if(hDecoder->latm_config.otherDataLenBits > 0)
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
887 faad_getbits(&ld, hDecoder->latm_config.otherDataLenBits);
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
888 faad_byte_align(&ld);
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
889 }
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
890
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
891 channels = hDecoder->fr_channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
892
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
893 if (hInfo->error > 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
894 goto error;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
895
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
896 /* safety check */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
897 if (channels == 0 || channels > MAX_CHANNELS)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
898 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
899 /* invalid number of channels */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
900 hInfo->error = 12;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
901 goto error;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
902 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
903
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
904 /* no more bit reading after this */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
905 bitsconsumed = faad_get_processed_bits(&ld);
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
906 hInfo->bytesconsumed = bit2byte(bitsconsumed);
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
907 if (ld.error)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
908 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
909 hInfo->error = 14;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
910 goto error;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
911 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
912 faad_endbits(&ld);
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
913
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
914
25836
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
915 if (!hDecoder->adts_header_present && !hDecoder->adif_header_present && !hDecoder->latm_header_present)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
916 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
917 if (hDecoder->channelConfiguration == 0)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
918 hDecoder->channelConfiguration = channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
919
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
920 if (channels == 8) /* 7.1 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
921 hDecoder->channelConfiguration = 7;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
922 if (channels == 7) /* not a standard channelConfiguration */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
923 hDecoder->channelConfiguration = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
924 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
925
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
926 if ((channels == 5 || channels == 6) && hDecoder->config.downMatrix)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
927 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
928 hDecoder->downMatrix = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
929 output_channels = 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
930 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
931 output_channels = channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
932 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
933
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
934 #if (defined(PS_DEC) || defined(DRM_PS))
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
935 hDecoder->upMatrix = 0;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
936 /* check if we have a mono file */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
937 if (output_channels == 1)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
938 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
939 /* upMatrix to 2 channels for implicit signalling of PS */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
940 hDecoder->upMatrix = 1;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
941 output_channels = 2;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
942 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
943 #endif
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
944
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
945 /* Make a channel configuration based on either a PCE or a channelConfiguration */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
946 create_channel_config(hDecoder, hInfo);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
947
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
948 /* number of samples in this frame */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
949 hInfo->samples = frame_len*output_channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
950 /* number of channels in this frame */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
951 hInfo->channels = output_channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
952 /* samplerate */
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
953 hInfo->samplerate = get_sample_rate(hDecoder->sf_index);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
954 /* object type */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
955 hInfo->object_type = hDecoder->object_type;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
956 /* sbr */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
957 hInfo->sbr = NO_SBR;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
958 /* header type */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
959 hInfo->header_type = RAW;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
960 if (hDecoder->adif_header_present)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
961 hInfo->header_type = ADIF;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
962 if (hDecoder->adts_header_present)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
963 hInfo->header_type = ADTS;
25836
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
964 if (hDecoder->latm_header_present)
bc425ba00960 added code to check and handle the presence of LATM streams in the init() and decode() functions
nicodvb
parents: 25835
diff changeset
965 hInfo->header_type = LATM;
18141
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
966 #if (defined(PS_DEC) || defined(DRM_PS))
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
967 hInfo->ps = hDecoder->ps_used_global;
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
968 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
969
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
970 /* check if frame has channel elements */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
971 if (channels == 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
972 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
973 hDecoder->frame++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
974 return NULL;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
975 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
976
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
977 /* allocate the buffer for the final samples */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
978 if ((hDecoder->sample_buffer == NULL) ||
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
979 (hDecoder->alloced_channels != output_channels))
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
980 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
981 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
982 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
983 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
984 };
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
985 uint8_t stride = str[hDecoder->config.outputFormat-1];
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
986 #ifdef SBR_DEC
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
987 if (((hDecoder->sbr_present_flag == 1)&&(!hDecoder->downSampledSBR)) || (hDecoder->forceUpSampling == 1))
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
988 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
989 stride = 2 * stride;
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
990 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
991 #endif
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
992 /* check if we want to use internal sample_buffer */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
993 if (sample_buffer_size == 0)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
994 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
995 if (hDecoder->sample_buffer)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
996 faad_free(hDecoder->sample_buffer);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
997 hDecoder->sample_buffer = NULL;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
998 hDecoder->sample_buffer = faad_malloc(frame_len*output_channels*stride);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
999 } else if (sample_buffer_size < frame_len*output_channels*stride) {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
1000 /* provided sample buffer is not big enough */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
1001 hInfo->error = 27;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
1002 return NULL;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
1003 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1004 hDecoder->alloced_channels = output_channels;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1005 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1006
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
1007 if (sample_buffer_size == 0)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
1008 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
1009 sample_buffer = hDecoder->sample_buffer;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
1010 } else {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
1011 sample_buffer = *sample_buffer2;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
1012 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1013
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1014 #ifdef SBR_DEC
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
1015 if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1016 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1017 uint8_t ele;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
1018
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1019 /* this data is different when SBR is used or when the data is upsampled */
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
1020 if (!hDecoder->downSampledSBR)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
1021 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
1022 frame_len *= 2;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
1023 hInfo->samples *= 2;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
1024 hInfo->samplerate *= 2;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
1025 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1026
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1027 /* 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
1028 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
1029 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1030 if (hDecoder->sbr[ele] == NULL)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1031 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1032 hInfo->error = 25;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1033 goto error;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1034 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1035 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1036
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
1037 /* sbr */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
1038 if (hDecoder->sbr_present_flag == 1)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
1039 {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
1040 hInfo->object_type = HE_AAC;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
1041 hInfo->sbr = SBR_UPSAMPLED;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
1042 } else {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
1043 hInfo->sbr = NO_SBR_UPSAMPLED;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
1044 }
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
1045 if (hDecoder->downSampledSBR)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
1046 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
1047 hInfo->sbr = SBR_DOWNSAMPLED;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
1048 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1049 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1050 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1051
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1052 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
1053 output_channels, frame_len, hDecoder->config.outputFormat);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1054
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1055
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1056 hDecoder->postSeekResetFlag = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1057
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1058 hDecoder->frame++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1059 #ifdef LD_DEC
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1060 if (hDecoder->object_type != LD)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1061 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1062 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1063 if (hDecoder->frame <= 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1064 hInfo->samples = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1065 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1066 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1067 /* LD encoders will give lower delay */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1068 if (hDecoder->frame <= 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1069 hInfo->samples = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1070 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1071 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1072
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1073 /* cleanup */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1074 #ifdef ANALYSIS
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1075 fflush(stdout);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1076 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1077
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1078 #ifdef PROFILE
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1079 count = faad_get_ts() - count;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1080 hDecoder->cycles += count;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1081 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1082
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1083 return sample_buffer;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1084
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1085 error:
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1086
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1087 faad_endbits(&ld);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1088
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1089 /* cleanup */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1090 #ifdef ANALYSIS
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1091 fflush(stdout);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1092 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1093
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1094 return NULL;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1095 }