annotate libfaad2/syntax.c @ 13030:99d386a5c122

credits for Robert Kesterson
author diego
date Mon, 16 Aug 2004 00:18:30 +0000
parents d81145997036
children 6d50ef45a058
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1 /*
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
3 ** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
4 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
5 ** This program is free software; you can redistribute it and/or modify
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
6 ** it under the terms of the GNU General Public License as published by
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
7 ** the Free Software Foundation; either version 2 of the License, or
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
8 ** (at your option) any later version.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
9 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
10 ** This program is distributed in the hope that it will be useful,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
13 ** GNU General Public License for more details.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
14 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
15 ** You should have received a copy of the GNU General Public License
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
16 ** along with this program; if not, write to the Free Software
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
18 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
19 ** Any non-GPL usage of this software or parts of this software is strictly
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
20 ** forbidden.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
21 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
22 ** Commercial non-GPL licensing of this software is possible.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
24 **
12625
d81145997036 More information about modifications to comply more closely with GPL 2a.
diego
parents: 12527
diff changeset
25 ** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
d81145997036 More information about modifications to comply more closely with GPL 2a.
diego
parents: 12527
diff changeset
26 ** $Id: syntax.c,v 1.3 2004/06/02 22:59:04 diego Exp $
d81145997036 More information about modifications to comply more closely with GPL 2a.
diego
parents: 12527
diff changeset
27 ** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
28 **/
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
29
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
30 /*
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
31 Reads the AAC bitstream as defined in 14496-3 (MPEG-4 Audio)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
32 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
33
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
34 #include "common.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
35 #include "structs.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
36
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
37 #include <stdlib.h>
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
38 #include <string.h>
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
39
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
40 #include "decoder.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
41 #include "syntax.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
42 #include "specrec.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
43 #include "huffman.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
44 #include "bits.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
45 #include "pulse.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
46 #include "analysis.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
47 #include "drc.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
48 #ifdef ERROR_RESILIENCE
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
49 #include "rvlc.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
50 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
51 #ifdef SBR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
52 #include "sbr_syntax.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
53 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
54
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
55
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
56 /* static function declarations */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
57 static void decode_sce_lfe(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, bitfile *ld,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
58 uint8_t id_syn_ele);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
59 static void decode_cpe(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, bitfile *ld,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
60 uint8_t id_syn_ele);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
61 static uint8_t single_lfe_channel_element(faacDecHandle hDecoder, bitfile *ld,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
62 uint8_t channel, uint8_t *tag);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
63 static uint8_t channel_pair_element(faacDecHandle hDecoder, bitfile *ld,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
64 uint8_t channel, uint8_t *tag);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
65 #ifdef COUPLING_DEC
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
66 static uint8_t coupling_channel_element(faacDecHandle hDecoder, bitfile *ld);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
67 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
68 static uint16_t data_stream_element(faacDecHandle hDecoder, bitfile *ld);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
69 static uint8_t program_config_element(program_config *pce, bitfile *ld);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
70 static uint8_t fill_element(faacDecHandle hDecoder, bitfile *ld, drc_info *drc
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
71 #ifdef SBR_DEC
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
72 ,uint8_t sbr_ele
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
73 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
74 );
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
75 static uint8_t individual_channel_stream(faacDecHandle hDecoder, element *ele,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
76 bitfile *ld, ic_stream *ics, uint8_t scal_flag,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
77 int16_t *spec_data);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
78 static uint8_t ics_info(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
79 uint8_t common_window);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
80 static uint8_t section_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
81 static uint8_t scale_factor_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
82 #ifdef SSR_DEC
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
83 static void gain_control_data(bitfile *ld, ic_stream *ics);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
84 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
85 static uint8_t spectral_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
86 int16_t *spectral_data);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
87 static uint16_t extension_payload(bitfile *ld, drc_info *drc, uint16_t count);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
88 static uint8_t pulse_data(ic_stream *ics, pulse_info *pul, bitfile *ld);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
89 static void tns_data(ic_stream *ics, tns_info *tns, bitfile *ld);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
90 static uint8_t ltp_data(faacDecHandle hDecoder, ic_stream *ics, ltp_info *ltp, bitfile *ld);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
91 static uint8_t adts_fixed_header(adts_header *adts, bitfile *ld);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
92 static void adts_variable_header(adts_header *adts, bitfile *ld);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
93 static void adts_error_check(adts_header *adts, bitfile *ld);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
94 static uint8_t dynamic_range_info(bitfile *ld, drc_info *drc);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
95 static uint8_t excluded_channels(bitfile *ld, drc_info *drc);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
96 #ifdef SCALABLE_DEC
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
97 static int8_t aac_scalable_main_header(faacDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
98 bitfile *ld, uint8_t this_layer_stereo);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
99 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
100
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
101
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
102 /* Table 4.4.1 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
103 int8_t GASpecificConfig(bitfile *ld, mp4AudioSpecificConfig *mp4ASC,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
104 program_config *pce_out)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
105 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
106 program_config pce;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
107
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
108 /* 1024 or 960 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
109 mp4ASC->frameLengthFlag = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
110 DEBUGVAR(1,138,"GASpecificConfig(): FrameLengthFlag"));
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
111 #ifndef ALLOW_SMALL_FRAMELENGTH
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
112 if (mp4ASC->frameLengthFlag == 1)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
113 return -3;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
114 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
115
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
116 mp4ASC->dependsOnCoreCoder = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
117 DEBUGVAR(1,139,"GASpecificConfig(): DependsOnCoreCoder"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
118 if (mp4ASC->dependsOnCoreCoder == 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
119 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
120 mp4ASC->coreCoderDelay = (uint16_t)faad_getbits(ld, 14
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
121 DEBUGVAR(1,140,"GASpecificConfig(): CoreCoderDelay"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
122 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
123
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
124 mp4ASC->extensionFlag = faad_get1bit(ld DEBUGVAR(1,141,"GASpecificConfig(): ExtensionFlag"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
125 if (mp4ASC->channelsConfiguration == 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
126 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
127 if (program_config_element(&pce, ld))
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
128 return -3;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
129 //mp4ASC->channelsConfiguration = pce.channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
130
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
131 if (pce_out != NULL)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
132 memcpy(pce_out, &pce, sizeof(program_config));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
133
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
134 /*
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
135 if (pce.num_valid_cc_elements)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
136 return -3;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
137 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
138 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
139
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
140 #ifdef ERROR_RESILIENCE
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
141 if (mp4ASC->extensionFlag == 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
142 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
143 /* Error resilience not supported yet */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
144 if (mp4ASC->objectTypeIndex >= ER_OBJECT_START)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
145 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
146 mp4ASC->aacSectionDataResilienceFlag = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
147 DEBUGVAR(1,144,"GASpecificConfig(): aacSectionDataResilienceFlag"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
148 mp4ASC->aacScalefactorDataResilienceFlag = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
149 DEBUGVAR(1,145,"GASpecificConfig(): aacScalefactorDataResilienceFlag"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
150 mp4ASC->aacSpectralDataResilienceFlag = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
151 DEBUGVAR(1,146,"GASpecificConfig(): aacSpectralDataResilienceFlag"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
152
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
153 /* 1 bit: extensionFlag3 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
154 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
155 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
156 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
157
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
158 return 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
159 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
160
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
161 /* Table 4.4.2 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
162 /* An MPEG-4 Audio decoder is only required to follow the Program
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
163 Configuration Element in GASpecificConfig(). The decoder shall ignore
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
164 any Program Configuration Elements that may occur in raw data blocks.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
165 PCEs transmitted in raw data blocks cannot be used to convey decoder
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
166 configuration information.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
167 */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
168 static uint8_t program_config_element(program_config *pce, bitfile *ld)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
169 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
170 uint8_t i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
171
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
172 memset(pce, 0, sizeof(program_config));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
173
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
174 pce->channels = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
175
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
176 pce->element_instance_tag = (uint8_t)faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
177 DEBUGVAR(1,10,"program_config_element(): element_instance_tag"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
178
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
179 pce->object_type = (uint8_t)faad_getbits(ld, 2
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
180 DEBUGVAR(1,11,"program_config_element(): object_type"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
181 pce->sf_index = (uint8_t)faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
182 DEBUGVAR(1,12,"program_config_element(): sf_index"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
183 pce->num_front_channel_elements = (uint8_t)faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
184 DEBUGVAR(1,13,"program_config_element(): num_front_channel_elements"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
185 pce->num_side_channel_elements = (uint8_t)faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
186 DEBUGVAR(1,14,"program_config_element(): num_side_channel_elements"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
187 pce->num_back_channel_elements = (uint8_t)faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
188 DEBUGVAR(1,15,"program_config_element(): num_back_channel_elements"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
189 pce->num_lfe_channel_elements = (uint8_t)faad_getbits(ld, 2
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
190 DEBUGVAR(1,16,"program_config_element(): num_lfe_channel_elements"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
191 pce->num_assoc_data_elements = (uint8_t)faad_getbits(ld, 3
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
192 DEBUGVAR(1,17,"program_config_element(): num_assoc_data_elements"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
193 pce->num_valid_cc_elements = (uint8_t)faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
194 DEBUGVAR(1,18,"program_config_element(): num_valid_cc_elements"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
195
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
196 pce->mono_mixdown_present = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
197 DEBUGVAR(1,19,"program_config_element(): mono_mixdown_present"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
198 if (pce->mono_mixdown_present == 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
199 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
200 pce->mono_mixdown_element_number = (uint8_t)faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
201 DEBUGVAR(1,20,"program_config_element(): mono_mixdown_element_number"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
202 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
203
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
204 pce->stereo_mixdown_present = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
205 DEBUGVAR(1,21,"program_config_element(): stereo_mixdown_present"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
206 if (pce->stereo_mixdown_present == 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
207 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
208 pce->stereo_mixdown_element_number = (uint8_t)faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
209 DEBUGVAR(1,22,"program_config_element(): stereo_mixdown_element_number"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
210 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
211
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
212 pce->matrix_mixdown_idx_present = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
213 DEBUGVAR(1,23,"program_config_element(): matrix_mixdown_idx_present"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
214 if (pce->matrix_mixdown_idx_present == 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
215 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
216 pce->matrix_mixdown_idx = (uint8_t)faad_getbits(ld, 2
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
217 DEBUGVAR(1,24,"program_config_element(): matrix_mixdown_idx"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
218 pce->pseudo_surround_enable = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
219 DEBUGVAR(1,25,"program_config_element(): pseudo_surround_enable"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
220 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
221
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
222 for (i = 0; i < pce->num_front_channel_elements; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
223 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
224 pce->front_element_is_cpe[i] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
225 DEBUGVAR(1,26,"program_config_element(): front_element_is_cpe"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
226 pce->front_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
227 DEBUGVAR(1,27,"program_config_element(): front_element_tag_select"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
228
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
229 if (pce->front_element_is_cpe[i] & 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
230 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
231 pce->cpe_channel[pce->front_element_tag_select[i]] = pce->channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
232 pce->num_front_channels += 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
233 pce->channels += 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
234 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
235 pce->sce_channel[pce->front_element_tag_select[i]] = pce->channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
236 pce->num_front_channels++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
237 pce->channels++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
238 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
239 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
240
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
241 for (i = 0; i < pce->num_side_channel_elements; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
242 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
243 pce->side_element_is_cpe[i] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
244 DEBUGVAR(1,28,"program_config_element(): side_element_is_cpe"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
245 pce->side_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
246 DEBUGVAR(1,29,"program_config_element(): side_element_tag_select"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
247
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
248 if (pce->side_element_is_cpe[i] & 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
249 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
250 pce->cpe_channel[pce->side_element_tag_select[i]] = pce->channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
251 pce->num_side_channels += 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
252 pce->channels += 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
253 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
254 pce->sce_channel[pce->side_element_tag_select[i]] = pce->channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
255 pce->num_side_channels++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
256 pce->channels++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
257 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
258 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
259
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
260 for (i = 0; i < pce->num_back_channel_elements; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
261 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
262 pce->back_element_is_cpe[i] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
263 DEBUGVAR(1,30,"program_config_element(): back_element_is_cpe"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
264 pce->back_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
265 DEBUGVAR(1,31,"program_config_element(): back_element_tag_select"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
266
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
267 if (pce->back_element_is_cpe[i] & 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
268 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
269 pce->cpe_channel[pce->back_element_tag_select[i]] = pce->channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
270 pce->channels += 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
271 pce->num_back_channels += 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
272 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
273 pce->sce_channel[pce->back_element_tag_select[i]] = pce->channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
274 pce->num_back_channels++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
275 pce->channels++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
276 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
277 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
278
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
279 for (i = 0; i < pce->num_lfe_channel_elements; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
280 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
281 pce->lfe_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
282 DEBUGVAR(1,32,"program_config_element(): lfe_element_tag_select"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
283
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
284 pce->sce_channel[pce->lfe_element_tag_select[i]] = pce->channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
285 pce->num_lfe_channels++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
286 pce->channels++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
287 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
288
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
289 for (i = 0; i < pce->num_assoc_data_elements; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
290 pce->assoc_data_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
291 DEBUGVAR(1,33,"program_config_element(): assoc_data_element_tag_select"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
292
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
293 for (i = 0; i < pce->num_valid_cc_elements; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
294 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
295 pce->cc_element_is_ind_sw[i] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
296 DEBUGVAR(1,34,"program_config_element(): cc_element_is_ind_sw"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
297 pce->valid_cc_element_tag_select[i] = (uint8_t)faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
298 DEBUGVAR(1,35,"program_config_element(): valid_cc_element_tag_select"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
299 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
300
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
301 faad_byte_align(ld);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
302
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
303 pce->comment_field_bytes = (uint8_t)faad_getbits(ld, 8
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
304 DEBUGVAR(1,36,"program_config_element(): comment_field_bytes"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
305
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
306 for (i = 0; i < pce->comment_field_bytes; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
307 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
308 pce->comment_field_data[i] = (uint8_t)faad_getbits(ld, 8
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
309 DEBUGVAR(1,37,"program_config_element(): comment_field_data"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
310 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
311 pce->comment_field_data[i] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
312
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
313 if (pce->channels > MAX_CHANNELS)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
314 return 22;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
315
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
316 return 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
317 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
318
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
319 static void decode_sce_lfe(faacDecHandle hDecoder,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
320 faacDecFrameInfo *hInfo, bitfile *ld,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
321 uint8_t id_syn_ele)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
322 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
323 uint8_t channels = hDecoder->fr_channels;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
324 uint8_t tag = 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
325
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
326 if (channels+1 > MAX_CHANNELS)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
327 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
328 hInfo->error = 12;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
329 return;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
330 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
331 if (hDecoder->fr_ch_ele+1 > MAX_SYNTAX_ELEMENTS)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
332 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
333 hInfo->error = 13;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
334 return;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
335 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
336
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
337 /* for SCE hDecoder->element_output_channels[] is not set here because this
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
338 can become 2 when some form of Parametric Stereo coding is used
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
339 */
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
340
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
341 /* save the syntax element id */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
342 hDecoder->element_id[hDecoder->fr_ch_ele] = id_syn_ele;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
343
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
344 /* decode the element */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
345 hInfo->error = single_lfe_channel_element(hDecoder, ld, channels, &tag);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
346
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
347 /* map output channels position to internal data channels */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
348 if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 2)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
349 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
350 /* this might be faulty when pce_set is true */
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
351 hDecoder->internal_channel[channels] = channels;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
352 hDecoder->internal_channel[channels+1] = channels+1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
353 } else {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
354 if (hDecoder->pce_set)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
355 hDecoder->internal_channel[hDecoder->pce.sce_channel[tag]] = channels;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
356 else
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
357 hDecoder->internal_channel[channels] = channels;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
358 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
359
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
360 hDecoder->fr_channels += hDecoder->element_output_channels[hDecoder->fr_ch_ele];
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
361 hDecoder->fr_ch_ele++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
362 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
363
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
364 static void decode_cpe(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, bitfile *ld,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
365 uint8_t id_syn_ele)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
366 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
367 uint8_t channels = hDecoder->fr_channels;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
368 uint8_t tag = 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
369
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
370 if (channels+2 > MAX_CHANNELS)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
371 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
372 hInfo->error = 12;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
373 return;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
374 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
375 if (hDecoder->fr_ch_ele+1 > MAX_SYNTAX_ELEMENTS)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
376 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
377 hInfo->error = 13;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
378 return;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
379 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
380
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
381 /* for CPE the number of output channels is always 2 */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
382 if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
383 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
384 /* element_output_channels not set yet */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
385 hDecoder->element_output_channels[hDecoder->fr_ch_ele] = 2;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
386 } else if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] != 2) {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
387 /* element inconsistency */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
388 hInfo->error = 21;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
389 return;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
390 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
391
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
392 /* save the syntax element id */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
393 hDecoder->element_id[hDecoder->fr_ch_ele] = id_syn_ele;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
394
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
395 /* decode the element */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
396 hInfo->error = channel_pair_element(hDecoder, ld, channels, &tag);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
397
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
398 /* map output channel position to internal data channels */
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
399 if (hDecoder->pce_set)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
400 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
401 hDecoder->internal_channel[hDecoder->pce.cpe_channel[tag]] = channels;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
402 hDecoder->internal_channel[hDecoder->pce.cpe_channel[tag]+1] = channels+1;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
403 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
404 hDecoder->internal_channel[channels] = channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
405 hDecoder->internal_channel[channels+1] = channels+1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
406 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
407
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
408 hDecoder->fr_channels += 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
409 hDecoder->fr_ch_ele++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
410 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
411
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
412 void raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
413 bitfile *ld, program_config *pce, drc_info *drc)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
414 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
415 uint8_t id_syn_ele;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
416
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
417 hDecoder->fr_channels = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
418 hDecoder->fr_ch_ele = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
419 hDecoder->first_syn_ele = 25;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
420 hDecoder->has_lfe = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
421
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
422 #ifdef ERROR_RESILIENCE
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
423 if (hDecoder->object_type < ER_OBJECT_START)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
424 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
425 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
426 /* Table 4.4.3: raw_data_block() */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
427 while ((id_syn_ele = (uint8_t)faad_getbits(ld, LEN_SE_ID
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
428 DEBUGVAR(1,4,"faacDecDecode(): id_syn_ele"))) != ID_END)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
429 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
430 switch (id_syn_ele) {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
431 case ID_SCE:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
432 if (hDecoder->first_syn_ele == 25) hDecoder->first_syn_ele = id_syn_ele;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
433 decode_sce_lfe(hDecoder, hInfo, ld, id_syn_ele);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
434 if (hInfo->error > 0)
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
435 return;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
436 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
437 case ID_CPE:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
438 if (hDecoder->first_syn_ele == 25) hDecoder->first_syn_ele = id_syn_ele;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
439 decode_cpe(hDecoder, hInfo, ld, id_syn_ele);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
440 if (hInfo->error > 0)
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
441 return;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
442 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
443 case ID_LFE:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
444 hDecoder->has_lfe++;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
445 decode_sce_lfe(hDecoder, hInfo, ld, id_syn_ele);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
446 if (hInfo->error > 0)
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
447 return;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
448 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
449 case ID_CCE: /* not implemented yet, but skip the bits */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
450 #ifdef COUPLING_DEC
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
451 hInfo->error = coupling_channel_element(hDecoder, ld);
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
452 #else
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
453 hInfo->error = 6;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
454 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
455 if (hInfo->error > 0)
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
456 return;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
457 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
458 case ID_DSE:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
459 data_stream_element(hDecoder, ld);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
460 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
461 case ID_PCE:
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
462 /* 14496-4: 5.6.4.1.2.1.3: */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
463 /* program_configuration_element()'s in access units shall be ignored */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
464 program_config_element(pce, ld);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
465 //if ((hInfo->error = program_config_element(pce, ld)) > 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
466 // return;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
467 //hDecoder->pce_set = 1;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
468 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
469 case ID_FIL:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
470 /* one sbr_info describes a channel_element not a channel! */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
471 /* if we encounter SBR data here: error */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
472 /* SBR data will be read directly in the SCE/LFE/CPE element */
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
473 if ((hInfo->error = fill_element(hDecoder, ld, drc
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
474 #ifdef SBR_DEC
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
475 , INVALID_SBR_ELEMENT
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
476 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
477 )) > 0)
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
478 return;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
479 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
480 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
481 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
482 #ifdef ERROR_RESILIENCE
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
483 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
484 /* Table 262: er_raw_data_block() */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
485 switch (hDecoder->channelConfiguration)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
486 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
487 case 1:
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
488 decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
489 if (hInfo->error > 0)
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
490 return;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
491 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
492 case 2:
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
493 decode_cpe(hDecoder, hInfo, ld, ID_CPE);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
494 if (hInfo->error > 0)
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
495 return;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
496 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
497 case 3:
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
498 decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
499 decode_cpe(hDecoder, hInfo, ld, ID_CPE);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
500 if (hInfo->error > 0)
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
501 return;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
502 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
503 case 4:
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
504 decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
505 decode_cpe(hDecoder, hInfo, ld, ID_CPE);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
506 decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
507 if (hInfo->error > 0)
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
508 return;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
509 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
510 case 5:
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
511 decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
512 decode_cpe(hDecoder, hInfo, ld, ID_CPE);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
513 decode_cpe(hDecoder, hInfo, ld, ID_CPE);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
514 if (hInfo->error > 0)
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
515 return;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
516 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
517 case 6:
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
518 decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
519 decode_cpe(hDecoder, hInfo, ld, ID_CPE);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
520 decode_cpe(hDecoder, hInfo, ld, ID_CPE);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
521 decode_sce_lfe(hDecoder, hInfo, ld, ID_LFE);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
522 if (hInfo->error > 0)
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
523 return;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
524 break;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
525 case 7: /* 8 channels */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
526 decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
527 decode_cpe(hDecoder, hInfo, ld, ID_CPE);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
528 decode_cpe(hDecoder, hInfo, ld, ID_CPE);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
529 decode_cpe(hDecoder, hInfo, ld, ID_CPE);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
530 decode_sce_lfe(hDecoder, hInfo, ld, ID_LFE);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
531 if (hInfo->error > 0)
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
532 return;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
533 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
534 default:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
535 hInfo->error = 7;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
536 return;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
537 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
538 #if 0
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
539 cnt = bits_to_decode() / 8;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
540 while (cnt >= 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
541 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
542 cnt -= extension_payload(cnt);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
543 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
544 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
545 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
546 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
547
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
548 /* new in corrigendum 14496-3:2002 */
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
549 #ifdef DRM
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
550 if (hDecoder->object_type != DRM_ER_LC)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
551 #endif
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
552 {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
553 faad_byte_align(ld);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
554 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
555
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
556 return;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
557 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
558
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
559 /* Table 4.4.4 and */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
560 /* Table 4.4.9 */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
561 static uint8_t single_lfe_channel_element(faacDecHandle hDecoder, bitfile *ld,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
562 uint8_t channel, uint8_t *tag)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
563 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
564 uint8_t retval = 0;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
565 element sce = {0};
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
566 ic_stream *ics = &(sce.ics1);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
567 ALIGN int16_t spec_data[1024] = {0};
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
568
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
569 sce.element_instance_tag = (uint8_t)faad_getbits(ld, LEN_TAG
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
570 DEBUGVAR(1,38,"single_lfe_channel_element(): element_instance_tag"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
571
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
572 *tag = sce.element_instance_tag;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
573 sce.channel = channel;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
574 sce.paired_channel = -1;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
575
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
576 retval = individual_channel_stream(hDecoder, &sce, ld, ics, 0, spec_data);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
577 if (retval > 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
578 return retval;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
579
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
580 #ifdef SBR_DEC
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
581 /* check if next bitstream element is a fill element */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
582 /* if so, read it now so SBR decoding can be done in case of a file with SBR */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
583 if (faad_showbits(ld, LEN_SE_ID) == ID_FIL)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
584 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
585 faad_flushbits(ld, LEN_SE_ID);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
586
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
587 /* one sbr_info describes a channel_element not a channel! */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
588 if ((retval = fill_element(hDecoder, ld, hDecoder->drc, hDecoder->fr_ch_ele)) > 0)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
589 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
590 return retval;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
591 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
592 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
593 #endif
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
594
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
595 /* noiseless coding is done, spectral reconstruction is done now */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
596 retval = reconstruct_single_channel(hDecoder, ics, &sce, spec_data);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
597 if (retval > 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
598 return retval;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
599
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
600 return 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
601 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
602
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
603 /* Table 4.4.5 */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
604 static uint8_t channel_pair_element(faacDecHandle hDecoder, bitfile *ld,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
605 uint8_t channels, uint8_t *tag)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
606 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
607 ALIGN int16_t spec_data1[1024] = {0};
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
608 ALIGN int16_t spec_data2[1024] = {0};
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
609 element cpe = {0};
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
610 ic_stream *ics1 = &(cpe.ics1);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
611 ic_stream *ics2 = &(cpe.ics2);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
612 uint8_t result;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
613
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
614 cpe.channel = channels;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
615 cpe.paired_channel = channels+1;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
616
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
617 cpe.element_instance_tag = (uint8_t)faad_getbits(ld, LEN_TAG
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
618 DEBUGVAR(1,39,"channel_pair_element(): element_instance_tag"));
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
619 *tag = cpe.element_instance_tag;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
620
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
621 if ((cpe.common_window = faad_get1bit(ld
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
622 DEBUGVAR(1,40,"channel_pair_element(): common_window"))) & 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
623 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
624 /* both channels have common ics information */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
625 if ((result = ics_info(hDecoder, ics1, ld, cpe.common_window)) > 0)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
626 return result;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
627
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
628 ics1->ms_mask_present = (uint8_t)faad_getbits(ld, 2
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
629 DEBUGVAR(1,41,"channel_pair_element(): ms_mask_present"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
630 if (ics1->ms_mask_present == 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
631 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
632 uint8_t g, sfb;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
633 for (g = 0; g < ics1->num_window_groups; g++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
634 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
635 for (sfb = 0; sfb < ics1->max_sfb; sfb++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
636 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
637 ics1->ms_used[g][sfb] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
638 DEBUGVAR(1,42,"channel_pair_element(): faad_get1bit"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
639 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
640 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
641 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
642
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
643 #ifdef ERROR_RESILIENCE
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
644 if ((hDecoder->object_type >= ER_OBJECT_START) && (ics1->predictor_data_present))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
645 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
646 if ((ics1->ltp.data_present = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
647 DEBUGVAR(1,50,"channel_pair_element(): ltp.data_present"))) & 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
648 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
649 if ((result = ltp_data(hDecoder, ics1, &(ics1->ltp), ld)) > 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
650 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
651 return result;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
652 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
653 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
654 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
655 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
656
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
657 memcpy(ics2, ics1, sizeof(ic_stream));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
658 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
659 ics1->ms_mask_present = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
660 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
661
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
662 if ((result = individual_channel_stream(hDecoder, &cpe, ld, ics1,
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
663 0, spec_data1)) > 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
664 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
665 return result;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
666 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
667
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
668 #ifdef ERROR_RESILIENCE
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
669 if (cpe.common_window && (hDecoder->object_type >= ER_OBJECT_START) &&
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
670 (ics1->predictor_data_present))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
671 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
672 if ((ics1->ltp2.data_present = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
673 DEBUGVAR(1,50,"channel_pair_element(): ltp.data_present"))) & 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
674 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
675 if ((result = ltp_data(hDecoder, ics1, &(ics1->ltp2), ld)) > 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
676 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
677 return result;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
678 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
679 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
680 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
681 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
682
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
683 if ((result = individual_channel_stream(hDecoder, &cpe, ld, ics2,
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
684 0, spec_data2)) > 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
685 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
686 return result;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
687 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
688
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
689 #ifdef SBR_DEC
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
690 /* check if next bitstream element is a fill element */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
691 /* if so, read it now so SBR decoding can be done in case of a file with SBR */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
692 if (faad_showbits(ld, LEN_SE_ID) == ID_FIL)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
693 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
694 faad_flushbits(ld, LEN_SE_ID);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
695
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
696 /* one sbr_info describes a channel_element not a channel! */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
697 if ((result = fill_element(hDecoder, ld, hDecoder->drc, hDecoder->fr_ch_ele)) > 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
698 {
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
699 return result;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
700 }
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
701 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
702 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
703
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
704 /* noiseless coding is done, spectral reconstruction is done now */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
705 if ((result = reconstruct_channel_pair(hDecoder, ics1, ics2, &cpe,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
706 spec_data1, spec_data2)) > 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
707 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
708 return result;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
709 }
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
710
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
711 return 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
712 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
713
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
714 /* Table 4.4.6 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
715 static uint8_t ics_info(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
716 uint8_t common_window)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
717 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
718 uint8_t retval = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
719
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
720 /* ics->ics_reserved_bit = */ faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
721 DEBUGVAR(1,43,"ics_info(): ics_reserved_bit"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
722 ics->window_sequence = (uint8_t)faad_getbits(ld, 2
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
723 DEBUGVAR(1,44,"ics_info(): window_sequence"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
724 ics->window_shape = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
725 DEBUGVAR(1,45,"ics_info(): window_shape"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
726
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
727 if (ics->window_sequence == EIGHT_SHORT_SEQUENCE)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
728 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
729 ics->max_sfb = (uint8_t)faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
730 DEBUGVAR(1,46,"ics_info(): max_sfb (short)"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
731 ics->scale_factor_grouping = (uint8_t)faad_getbits(ld, 7
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
732 DEBUGVAR(1,47,"ics_info(): scale_factor_grouping"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
733 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
734 ics->max_sfb = (uint8_t)faad_getbits(ld, 6
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
735 DEBUGVAR(1,48,"ics_info(): max_sfb (long)"));
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 /* get the grouping information */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
739 if ((retval = window_grouping_info(hDecoder, ics)) > 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
740 return retval;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
741
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
742 /* should be an error */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
743 /* check the range of max_sfb */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
744 if (ics->max_sfb > ics->num_swb)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
745 return 16;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
746
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
747 if (ics->window_sequence != EIGHT_SHORT_SEQUENCE)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
748 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
749 if ((ics->predictor_data_present = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
750 DEBUGVAR(1,49,"ics_info(): predictor_data_present"))) & 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
751 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
752 if (hDecoder->object_type == MAIN) /* MPEG2 style AAC predictor */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
753 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
754 uint8_t sfb;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
755
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
756 ics->pred.limit = min(ics->max_sfb, max_pred_sfb(hDecoder->sf_index));
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
757
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
758 if ((ics->pred.predictor_reset = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
759 DEBUGVAR(1,53,"ics_info(): pred.predictor_reset"))) & 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
760 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
761 ics->pred.predictor_reset_group_number = (uint8_t)faad_getbits(ld, 5
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
762 DEBUGVAR(1,54,"ics_info(): pred.predictor_reset_group_number"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
763 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
764
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
765 for (sfb = 0; sfb < ics->pred.limit; sfb++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
766 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
767 ics->pred.prediction_used[sfb] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
768 DEBUGVAR(1,55,"ics_info(): pred.prediction_used"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
769 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
770 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
771 #ifdef LTP_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
772 else { /* Long Term Prediction */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
773 if (hDecoder->object_type < ER_OBJECT_START)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
774 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
775 if ((ics->ltp.data_present = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
776 DEBUGVAR(1,50,"ics_info(): ltp.data_present"))) & 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
777 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
778 if ((retval = ltp_data(hDecoder, ics, &(ics->ltp), ld)) > 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
779 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
780 return retval;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
781 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
782 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
783 if (common_window)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
784 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
785 if ((ics->ltp2.data_present = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
786 DEBUGVAR(1,51,"ics_info(): ltp2.data_present"))) & 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
787 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
788 if ((retval = ltp_data(hDecoder, ics, &(ics->ltp2), ld)) > 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
789 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
790 return retval;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
791 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
792 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
793 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
794 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
795 #ifdef ERROR_RESILIENCE
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
796 if (!common_window && (hDecoder->object_type >= ER_OBJECT_START))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
797 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
798 if ((ics->ltp.data_present = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
799 DEBUGVAR(1,50,"ics_info(): ltp.data_present"))) & 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
800 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
801 ltp_data(hDecoder, ics, &(ics->ltp), ld);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
802 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
803 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
804 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
805 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
806 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
807 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
808 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
809
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
810 return retval;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
811 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
812
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
813 /* Table 4.4.7 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
814 static uint8_t pulse_data(ic_stream *ics, pulse_info *pul, bitfile *ld)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
815 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
816 uint8_t i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
817
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
818 pul->number_pulse = (uint8_t)faad_getbits(ld, 2
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
819 DEBUGVAR(1,56,"pulse_data(): number_pulse"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
820 pul->pulse_start_sfb = (uint8_t)faad_getbits(ld, 6
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
821 DEBUGVAR(1,57,"pulse_data(): pulse_start_sfb"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
822
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
823 /* check the range of pulse_start_sfb */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
824 if (pul->pulse_start_sfb > ics->num_swb)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
825 return 16;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
826
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
827 for (i = 0; i < pul->number_pulse+1; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
828 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
829 pul->pulse_offset[i] = (uint8_t)faad_getbits(ld, 5
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
830 DEBUGVAR(1,58,"pulse_data(): pulse_offset"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
831 pul->pulse_amp[i] = (uint8_t)faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
832 DEBUGVAR(1,59,"pulse_data(): pulse_amp"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
833 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
834
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
835 return 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
836 }
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 #ifdef COUPLING_DEC
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
839 /* Table 4.4.8: Currently just for skipping the bits... */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
840 static uint8_t coupling_channel_element(faacDecHandle hDecoder, bitfile *ld)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
841 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
842 uint8_t c, result = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
843 uint8_t ind_sw_cce_flag = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
844 uint8_t num_gain_element_lists = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
845 uint8_t num_coupled_elements = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
846
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
847 element el_empty = {0};
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
848 ic_stream ics_empty = {0};
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
849 int16_t sh_data[1024];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
850
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
851 c = faad_getbits(ld, LEN_TAG
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
852 DEBUGVAR(1,900,"coupling_channel_element(): element_instance_tag"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
853
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
854 ind_sw_cce_flag = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
855 DEBUGVAR(1,901,"coupling_channel_element(): ind_sw_cce_flag"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
856 num_coupled_elements = faad_getbits(ld, 3
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
857 DEBUGVAR(1,902,"coupling_channel_element(): num_coupled_elements"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
858
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
859 for (c = 0; c < num_coupled_elements + 1; c++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
860 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
861 uint8_t cc_target_is_cpe, cc_target_tag_select;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
862
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
863 num_gain_element_lists++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
864
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
865 cc_target_is_cpe = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
866 DEBUGVAR(1,903,"coupling_channel_element(): cc_target_is_cpe"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
867 cc_target_tag_select = faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
868 DEBUGVAR(1,904,"coupling_channel_element(): cc_target_tag_select"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
869
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
870 if (cc_target_is_cpe)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
871 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
872 uint8_t cc_l = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
873 DEBUGVAR(1,905,"coupling_channel_element(): cc_l"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
874 uint8_t cc_r = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
875 DEBUGVAR(1,906,"coupling_channel_element(): cc_r"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
876
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
877 if (cc_l && cc_r)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
878 num_gain_element_lists++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
879 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
880 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
881
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
882 faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
883 DEBUGVAR(1,907,"coupling_channel_element(): cc_domain"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
884 faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
885 DEBUGVAR(1,908,"coupling_channel_element(): gain_element_sign"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
886 faad_getbits(ld, 2
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
887 DEBUGVAR(1,909,"coupling_channel_element(): gain_element_scale"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
888
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
889 if ((result = individual_channel_stream(hDecoder, &el_empty, ld, &ics_empty,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
890 0, sh_data)) > 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
891 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
892 return result;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
893 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
894
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
895 for (c = 1; c < num_gain_element_lists; c++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
896 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
897 uint8_t cge;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
898
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
899 if (ind_sw_cce_flag)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
900 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
901 cge = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
902 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
903 cge = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
904 DEBUGVAR(1,910,"coupling_channel_element(): common_gain_element_present"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
905 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
906
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
907 if (cge)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
908 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
909 huffman_scale_factor(ld);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
910 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
911 uint8_t g, sfb;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
912
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
913 for (g = 0; g < ics_empty.num_window_groups; g++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
914 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
915 for (sfb = 0; sfb < ics_empty.max_sfb; sfb++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
916 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
917 if (ics_empty.sfb_cb[g][sfb] != ZERO_HCB)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
918 huffman_scale_factor(ld);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
919 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
920 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
921 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
922 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
923
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
924 return 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
925 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
926 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
927
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
928 /* Table 4.4.10 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
929 static uint16_t data_stream_element(faacDecHandle hDecoder, bitfile *ld)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
930 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
931 uint8_t byte_aligned;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
932 uint16_t i, count;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
933
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
934 /* element_instance_tag = */ faad_getbits(ld, LEN_TAG
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
935 DEBUGVAR(1,60,"data_stream_element(): element_instance_tag"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
936 byte_aligned = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
937 DEBUGVAR(1,61,"data_stream_element(): byte_aligned"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
938 count = (uint16_t)faad_getbits(ld, 8
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
939 DEBUGVAR(1,62,"data_stream_element(): count"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
940 if (count == 255)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
941 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
942 count += (uint16_t)faad_getbits(ld, 8
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
943 DEBUGVAR(1,63,"data_stream_element(): extra count"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
944 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
945 if (byte_aligned)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
946 faad_byte_align(ld);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
947
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
948 for (i = 0; i < count; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
949 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
950 faad_getbits(ld, LEN_BYTE
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
951 DEBUGVAR(1,64,"data_stream_element(): data_stream_byte"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
952 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
953
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
954 return count;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
955 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
956
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
957 /* Table 4.4.11 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
958 static uint8_t fill_element(faacDecHandle hDecoder, bitfile *ld, drc_info *drc
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
959 #ifdef SBR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
960 ,uint8_t sbr_ele
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
961 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
962 )
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
963 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
964 uint16_t count;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
965 #ifdef SBR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
966 uint8_t bs_extension_type;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
967 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
968
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
969 count = (uint16_t)faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
970 DEBUGVAR(1,65,"fill_element(): count"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
971 if (count == 15)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
972 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
973 count += (uint16_t)faad_getbits(ld, 8
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
974 DEBUGVAR(1,66,"fill_element(): extra count")) - 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
975 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
976
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
977 if (count > 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
978 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
979 #ifdef SBR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
980 bs_extension_type = (uint8_t)faad_showbits(ld, 4);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
981
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
982 if ((bs_extension_type == EXT_SBR_DATA) ||
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
983 (bs_extension_type == EXT_SBR_DATA_CRC))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
984 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
985 if (sbr_ele == INVALID_SBR_ELEMENT)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
986 return 24;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
987
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
988 if (!hDecoder->sbr[sbr_ele])
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
989 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
990 hDecoder->sbr[sbr_ele] = sbrDecodeInit(hDecoder->frameLength,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
991 hDecoder->element_id[sbr_ele], 2*get_sample_rate(hDecoder->sf_index)
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
992 #ifdef DRM
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
993 , 0
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
994 #endif
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
995 );
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
996 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
997
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
998 hDecoder->sbr_present_flag = 1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
999
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1000 /* parse the SBR data */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1001 hDecoder->sbr[sbr_ele]->ret = sbr_extension_data(ld, hDecoder->sbr[sbr_ele], count);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1002 #if (defined(PS_DEC) || defined(DRM_PS))
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1003 if (hDecoder->sbr[sbr_ele]->ps_used)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1004 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1005 hDecoder->ps_used[sbr_ele] = 1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1006 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1007 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1008 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1009 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1010 while (count > 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1011 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1012 count -= extension_payload(ld, drc, count);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1013 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1014 #ifdef SBR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1015 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1016 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1017 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1018
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1019 return 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1020 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1021
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1022 /* Table 4.4.12 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1023 #ifdef SSR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1024 static void gain_control_data(bitfile *ld, ic_stream *ics)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1025 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1026 uint8_t bd, wd, ad;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1027 ssr_info *ssr = &(ics->ssr);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1028
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1029 ssr->max_band = (uint8_t)faad_getbits(ld, 2
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1030 DEBUGVAR(1,1000,"gain_control_data(): max_band"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1031
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1032 if (ics->window_sequence == ONLY_LONG_SEQUENCE)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1033 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1034 for (bd = 1; bd <= ssr->max_band; bd++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1035 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1036 for (wd = 0; wd < 1; wd++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1037 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1038 ssr->adjust_num[bd][wd] = (uint8_t)faad_getbits(ld, 3
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1039 DEBUGVAR(1,1001,"gain_control_data(): adjust_num"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1040
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1041 for (ad = 0; ad < ssr->adjust_num[bd][wd]; ad++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1042 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1043 ssr->alevcode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1044 DEBUGVAR(1,1002,"gain_control_data(): alevcode"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1045 ssr->aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 5
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1046 DEBUGVAR(1,1003,"gain_control_data(): aloccode"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1047 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1048 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1049 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1050 } else if (ics->window_sequence == LONG_START_SEQUENCE) {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1051 for (bd = 1; bd <= ssr->max_band; bd++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1052 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1053 for (wd = 0; wd < 2; wd++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1054 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1055 ssr->adjust_num[bd][wd] = (uint8_t)faad_getbits(ld, 3
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1056 DEBUGVAR(1,1001,"gain_control_data(): adjust_num"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1057
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1058 for (ad = 0; ad < ssr->adjust_num[bd][wd]; ad++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1059 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1060 ssr->alevcode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1061 DEBUGVAR(1,1002,"gain_control_data(): alevcode"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1062 if (wd == 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1063 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1064 ssr->aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1065 DEBUGVAR(1,1003,"gain_control_data(): aloccode"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1066 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1067 ssr->aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 2
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1068 DEBUGVAR(1,1003,"gain_control_data(): aloccode"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1069 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1070 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1071 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1072 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1073 } else if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1074 for (bd = 1; bd <= ssr->max_band; bd++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1075 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1076 for (wd = 0; wd < 8; wd++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1077 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1078 ssr->adjust_num[bd][wd] = (uint8_t)faad_getbits(ld, 3
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1079 DEBUGVAR(1,1001,"gain_control_data(): adjust_num"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1080
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1081 for (ad = 0; ad < ssr->adjust_num[bd][wd]; ad++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1082 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1083 ssr->alevcode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1084 DEBUGVAR(1,1002,"gain_control_data(): alevcode"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1085 ssr->aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 2
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1086 DEBUGVAR(1,1003,"gain_control_data(): aloccode"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1087 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1088 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1089 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1090 } else if (ics->window_sequence == LONG_STOP_SEQUENCE) {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1091 for (bd = 1; bd <= ssr->max_band; bd++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1092 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1093 for (wd = 0; wd < 2; wd++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1094 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1095 ssr->adjust_num[bd][wd] = (uint8_t)faad_getbits(ld, 3
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1096 DEBUGVAR(1,1001,"gain_control_data(): adjust_num"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1097
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1098 for (ad = 0; ad < ssr->adjust_num[bd][wd]; ad++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1099 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1100 ssr->alevcode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1101 DEBUGVAR(1,1002,"gain_control_data(): alevcode"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1102
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1103 if (wd == 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1104 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1105 ssr->aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1106 DEBUGVAR(1,1003,"gain_control_data(): aloccode"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1107 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1108 ssr->aloccode[bd][wd][ad] = (uint8_t)faad_getbits(ld, 5
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1109 DEBUGVAR(1,1003,"gain_control_data(): aloccode"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1110 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1111 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1112 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1113 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1114 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1115 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1116 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1117
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1118 #ifdef SCALABLE_DEC
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1119 /* Table 4.4.13 ASME */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1120 void aac_scalable_main_element(faacDecHandle hDecoder, faacDecFrameInfo *hInfo,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1121 bitfile *ld, program_config *pce, drc_info *drc)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1122 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1123 uint8_t retval = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1124 uint8_t channels = hDecoder->fr_channels = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1125 uint8_t ch;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1126 uint8_t this_layer_stereo = (hDecoder->channelConfiguration > 1) ? 1 : 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1127 element cpe = {0};
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1128 ic_stream *ics1 = &(cpe.ics1);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1129 ic_stream *ics2 = &(cpe.ics2);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1130 int16_t *spec_data;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1131 ALIGN int16_t spec_data1[1024] = {0};
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1132 ALIGN int16_t spec_data2[1024] = {0};
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1133
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1134 hDecoder->fr_ch_ele = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1135
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1136 hInfo->error = aac_scalable_main_header(hDecoder, ics1, ics2, ld, this_layer_stereo);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1137 if (hInfo->error > 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1138 return;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1139
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1140 cpe.common_window = 1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1141 if (this_layer_stereo)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1142 cpe.ele_id = ID_CPE;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1143 else
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1144 cpe.ele_id = ID_SCE;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1145
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1146 hDecoder->element_output_channels[hDecoder->fr_ch_ele] = (this_layer_stereo ? 2 : 0);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1147
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1148 for (ch = 0; ch < (this_layer_stereo ? 2 : 1); ch++)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1149 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1150 ic_stream *ics;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1151 if (ch == 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1152 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1153 ics = ics1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1154 spec_data = spec_data1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1155 } else {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1156 ics = ics2;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1157 spec_data = spec_data2;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1158 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1159
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1160 hInfo->error = individual_channel_stream(hDecoder, &cpe, ld, ics, 1, spec_data);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1161 if (hInfo->error > 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1162 return;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1163 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1164
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1165 #ifdef DRM
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1166 #ifdef SBR_DEC
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1167 /* In case of DRM we need to read the SBR info before channel reconstruction */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1168 if ((hDecoder->sbr_present_flag == 1) && (hDecoder->object_type == DRM_ER_LC))
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1169 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1170 bitfile ld_sbr = {0};
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1171 uint32_t i;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1172 uint16_t count = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1173 uint8_t *revbuffer;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1174 uint8_t *prevbufstart;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1175 uint8_t *pbufend;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1176
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1177 /* all forward bitreading should be finished at this point */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1178 uint32_t bitsconsumed = faad_get_processed_bits(ld);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1179 uint32_t buffer_size = faad_origbitbuffer_size(ld);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1180 uint8_t *buffer = (uint8_t*)faad_origbitbuffer(ld);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1181
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1182 if (bitsconsumed + 8 > buffer_size*8)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1183 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1184 hInfo->error = 14;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1185 return;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1186 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1187
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1188 if (!hDecoder->sbr[0])
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1189 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1190 hDecoder->sbr[0] = sbrDecodeInit(hDecoder->frameLength, cpe.ele_id,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1191 2*get_sample_rate(hDecoder->sf_index), 1);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1192 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1193
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1194 /* Reverse bit reading of SBR data in DRM audio frame */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1195 revbuffer = (uint8_t*)faad_malloc(buffer_size*sizeof(uint8_t));
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1196 prevbufstart = revbuffer;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1197 pbufend = &buffer[buffer_size - 1];
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1198 for (i = 0; i < buffer_size; i++)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1199 *prevbufstart++ = tabFlipbits[*pbufend--];
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1200
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1201 /* Set SBR data */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1202 /* consider 8 bits from AAC-CRC */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1203 count = (uint16_t)bit2byte(buffer_size*8 - bitsconsumed);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1204 faad_initbits(&ld_sbr, revbuffer, count);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1205
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1206 hDecoder->sbr[0]->lcstereo_flag = hDecoder->lcstereo_flag;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1207
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1208 hDecoder->sbr[0]->sample_rate = get_sample_rate(hDecoder->sf_index);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1209 hDecoder->sbr[0]->sample_rate *= 2;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1210
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1211 faad_getbits(&ld_sbr, 8); /* Skip 8-bit CRC */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1212
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1213 hDecoder->sbr[0]->ret = sbr_extension_data(&ld_sbr, hDecoder->sbr[0], count);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1214 #if (defined(PS_DEC) || defined(DRM_PS))
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1215 if (hDecoder->sbr[0]->ps_used)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1216 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1217 hDecoder->ps_used[0] = 1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1218 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1219 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1220
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1221 /* check CRC */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1222 /* no need to check it if there was already an error */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1223 if (hDecoder->sbr[0]->ret == 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1224 hDecoder->sbr[0]->ret = faad_check_CRC(&ld_sbr, faad_get_processed_bits(&ld_sbr) - 8);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1225
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1226 faad_endbits(&ld_sbr);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1227
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1228 if (revbuffer)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1229 faad_free(revbuffer);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1230 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1231 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1232 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1233
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1234 if (this_layer_stereo)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1235 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1236 hInfo->error = reconstruct_channel_pair(hDecoder, ics1, ics2, &cpe, spec_data1, spec_data2);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1237 if (hInfo->error > 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1238 return;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1239 } else {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1240 hInfo->error = reconstruct_single_channel(hDecoder, ics1, &cpe, spec_data1);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1241 if (hInfo->error > 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1242 return;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1243 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1244
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1245 /* map output channels position to internal data channels */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1246 if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 2)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1247 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1248 /* this might be faulty when pce_set is true */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1249 hDecoder->internal_channel[channels] = channels;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1250 hDecoder->internal_channel[channels+1] = channels+1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1251 } else {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1252 hDecoder->internal_channel[channels] = channels;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1253 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1254
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1255 hDecoder->element_id[hDecoder->fr_ch_ele] = cpe.ele_id;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1256
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1257 hDecoder->fr_channels += hDecoder->element_output_channels[hDecoder->fr_ch_ele];
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1258 hDecoder->fr_ch_ele++;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1259
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1260 return;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1261 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1262
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1263 /* Table 4.4.15 */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1264 static int8_t aac_scalable_main_header(faacDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1265 bitfile *ld, uint8_t this_layer_stereo)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1266 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1267 uint8_t retval = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1268 uint8_t ch;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1269 ic_stream *ics;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1270
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1271 /* ics1->ics_reserved_bit = */ faad_get1bit(ld
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1272 DEBUGVAR(1,300,"aac_scalable_main_header(): ics_reserved_bits"));
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1273 ics1->window_sequence = (uint8_t)faad_getbits(ld, 2
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1274 DEBUGVAR(1,301,"aac_scalable_main_header(): window_sequence"));
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1275 ics1->window_shape = faad_get1bit(ld
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1276 DEBUGVAR(1,302,"aac_scalable_main_header(): window_shape"));
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1277
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1278 if (ics1->window_sequence == EIGHT_SHORT_SEQUENCE)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1279 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1280 ics1->max_sfb = (uint8_t)faad_getbits(ld, 4
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1281 DEBUGVAR(1,303,"aac_scalable_main_header(): max_sfb (short)"));
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1282 ics1->scale_factor_grouping = (uint8_t)faad_getbits(ld, 7
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1283 DEBUGVAR(1,304,"aac_scalable_main_header(): scale_factor_grouping"));
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1284 } else {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1285 ics1->max_sfb = (uint8_t)faad_getbits(ld, 6
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1286 DEBUGVAR(1,305,"aac_scalable_main_header(): max_sfb (long)"));
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1287 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1288
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1289 /* get the grouping information */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1290 if ((retval = window_grouping_info(hDecoder, ics1)) > 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1291 return retval;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1292
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1293 /* should be an error */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1294 /* check the range of max_sfb */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1295 if (ics1->max_sfb > ics1->num_swb)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1296 return 16;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1297
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1298 if (this_layer_stereo)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1299 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1300 ics1->ms_mask_present = (uint8_t)faad_getbits(ld, 2
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1301 DEBUGVAR(1,306,"aac_scalable_main_header(): ms_mask_present"));
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1302 if (ics1->ms_mask_present == 1)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1303 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1304 uint8_t g, sfb;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1305 for (g = 0; g < ics1->num_window_groups; g++)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1306 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1307 for (sfb = 0; sfb < ics1->max_sfb; sfb++)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1308 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1309 ics1->ms_used[g][sfb] = faad_get1bit(ld
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1310 DEBUGVAR(1,307,"aac_scalable_main_header(): faad_get1bit"));
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1311 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1312 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1313 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1314
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1315 memcpy(ics2, ics1, sizeof(ic_stream));
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1316 } else {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1317 ics1->ms_mask_present = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1318 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1319
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1320 if (0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1321 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1322 faad_get1bit(ld
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1323 DEBUGVAR(1,308,"aac_scalable_main_header(): tns_channel_mono_layer"));
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1324 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1325
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1326 for (ch = 0; ch < (this_layer_stereo ? 2 : 1); ch++)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1327 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1328 if (ch == 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1329 ics = ics1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1330 else
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1331 ics = ics2;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1332
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1333 if ( 1 /*!tvq_layer_pesent || (tns_aac_tvq_en[ch] == 1)*/)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1334 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1335 if ((ics->tns_data_present = faad_get1bit(ld
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1336 DEBUGVAR(1,309,"aac_scalable_main_header(): tns_data_present"))) & 1)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1337 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1338 #ifdef DRM
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1339 /* different order of data units in DRM */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1340 if (hDecoder->object_type != DRM_ER_LC)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1341 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1342 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1343 tns_data(ics, &(ics->tns), ld);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1344 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1345 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1346 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1347 #if 0
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1348 if (0 /*core_flag || tvq_layer_pesent*/)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1349 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1350 if ((ch==0) || ((ch==1) && (core_stereo || tvq_stereo))
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1351 diff_control_data();
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1352 if (mono_stereo_flag)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1353 diff_control_data_lr();
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1354 } else {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1355 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1356 if ((ics->ltp.data_present = faad_get1bit(ld
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1357 DEBUGVAR(1,310,"aac_scalable_main_header(): ltp.data_present"))) & 1)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1358 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1359 if ((retval = ltp_data(hDecoder, ics, &(ics->ltp), ld)) > 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1360 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1361 return retval;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1362 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1363 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1364 #if 0
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1365 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1366 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1367 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1368
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1369 return 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1370 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1371 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1372
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1373 /* Table 4.4.24 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1374 static uint8_t individual_channel_stream(faacDecHandle hDecoder, element *ele,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1375 bitfile *ld, ic_stream *ics, uint8_t scal_flag,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1376 int16_t *spec_data)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1377 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1378 uint8_t result;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1379
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1380 ics->global_gain = (uint8_t)faad_getbits(ld, 8
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1381 DEBUGVAR(1,67,"individual_channel_stream(): global_gain"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1382
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1383 if (!ele->common_window && !scal_flag)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1384 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1385 if ((result = ics_info(hDecoder, ics, ld, ele->common_window)) > 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1386 return result;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1387 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1388
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1389 if ((result = section_data(hDecoder, ics, ld)) > 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1390 return result;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1391
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1392 if ((result = scale_factor_data(hDecoder, ics, ld)) > 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1393 return result;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1394
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1395 if (!scal_flag)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1396 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1397 /**
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1398 ** NOTE: It could be that pulse data is available in scalable AAC too,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1399 ** as said in Amendment 1, this could be only the case for ER AAC,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1400 ** though. (have to check this out later)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1401 **/
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1402 /* get pulse data */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1403 if ((ics->pulse_data_present = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1404 DEBUGVAR(1,68,"individual_channel_stream(): pulse_data_present"))) & 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1405 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1406 if ((result = pulse_data(ics, &(ics->pul), ld)) > 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1407 return result;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1408 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1409
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1410 /* get tns data */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1411 if ((ics->tns_data_present = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1412 DEBUGVAR(1,69,"individual_channel_stream(): tns_data_present"))) & 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1413 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1414 #ifdef ERROR_RESILIENCE
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1415 if (hDecoder->object_type < ER_OBJECT_START)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1416 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1417 tns_data(ics, &(ics->tns), ld);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1418 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1419
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1420 /* get gain control data */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1421 if ((ics->gain_control_data_present = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1422 DEBUGVAR(1,70,"individual_channel_stream(): gain_control_data_present"))) & 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1423 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1424 #ifdef SSR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1425 if (hDecoder->object_type != SSR)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1426 return 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1427 else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1428 gain_control_data(ld, ics);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1429 #else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1430 return 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1431 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1432 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1433 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1434
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1435 #ifdef ERROR_RESILIENCE
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1436 if (hDecoder->aacSpectralDataResilienceFlag)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1437 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1438 ics->length_of_reordered_spectral_data = (uint16_t)faad_getbits(ld, 14
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1439 DEBUGVAR(1,147,"individual_channel_stream(): length_of_reordered_spectral_data"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1440
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1441 if (hDecoder->channelConfiguration == 2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1442 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1443 if (ics->length_of_reordered_spectral_data > 6144)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1444 ics->length_of_reordered_spectral_data = 6144;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1445 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1446 if (ics->length_of_reordered_spectral_data > 12288)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1447 ics->length_of_reordered_spectral_data = 12288;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1448 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1449
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1450 ics->length_of_longest_codeword = (uint8_t)faad_getbits(ld, 6
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1451 DEBUGVAR(1,148,"individual_channel_stream(): length_of_longest_codeword"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1452 if (ics->length_of_longest_codeword >= 49)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1453 ics->length_of_longest_codeword = 49;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1454 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1455
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1456 /* RVLC spectral data is put here */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1457 if (hDecoder->aacScalefactorDataResilienceFlag)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1458 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1459 if ((result = rvlc_decode_scale_factors(ics, ld)) > 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1460 return result;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1461 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1462
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1463 if (hDecoder->object_type >= ER_OBJECT_START)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1464 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1465 if (ics->tns_data_present)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1466 tns_data(ics, &(ics->tns), ld);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1467 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1468
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1469 #ifdef DRM
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1470 /* CRC check */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1471 if (hDecoder->object_type == DRM_ER_LC)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1472 if ((result = faad_check_CRC(ld, faad_get_processed_bits(ld) - 8)) > 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1473 return result;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1474 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1475
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1476 if (hDecoder->aacSpectralDataResilienceFlag)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1477 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1478 /* error resilient spectral data decoding */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1479 if ((result = reordered_spectral_data(hDecoder, ics, ld, spec_data)) > 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1480 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1481 return result;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1482 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1483 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1484 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1485 /* decode the spectral data */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1486 if ((result = spectral_data(hDecoder, ics, ld, spec_data)) > 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1487 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1488 return result;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1489 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1490 #ifdef ERROR_RESILIENCE
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1491 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1492 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1493
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1494 /* pulse coding reconstruction */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1495 if (ics->pulse_data_present)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1496 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1497 if (ics->window_sequence != EIGHT_SHORT_SEQUENCE)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1498 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1499 if ((result = pulse_decode(ics, spec_data, hDecoder->frameLength)) > 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1500 return result;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1501 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1502 return 2; /* pulse coding not allowed for short blocks */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1503 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1504 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1505
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1506 return 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1507 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1508
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1509 /* Table 4.4.25 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1510 static uint8_t section_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1511 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1512 uint8_t g;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1513 uint8_t sect_esc_val, sect_bits;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1514
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1515 if (ics->window_sequence == EIGHT_SHORT_SEQUENCE)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1516 sect_bits = 3;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1517 else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1518 sect_bits = 5;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1519 sect_esc_val = (1<<sect_bits) - 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1520
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1521 #if 0
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1522 printf("\ntotal sfb %d\n", ics->max_sfb);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1523 printf(" sect top cb\n");
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1524 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1525
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1526 for (g = 0; g < ics->num_window_groups; g++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1527 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1528 uint8_t k = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1529 uint8_t i = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1530
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1531 while (k < ics->max_sfb)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1532 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1533 #ifdef ERROR_RESILIENCE
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1534 uint8_t vcb11 = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1535 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1536 uint8_t sfb;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1537 uint8_t sect_len_incr;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1538 uint16_t sect_len = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1539 uint8_t sect_cb_bits = 4;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1540
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1541 /* if "faad_getbits" detects error and returns "0", "k" is never
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1542 incremented and we cannot leave the while loop */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1543 if ((ld->error != 0) || (ld->no_more_reading))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1544 return 14;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1545
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1546 #ifdef ERROR_RESILIENCE
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1547 if (hDecoder->aacSectionDataResilienceFlag)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1548 sect_cb_bits = 5;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1549 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1550
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1551 ics->sect_cb[g][i] = (uint8_t)faad_getbits(ld, sect_cb_bits
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1552 DEBUGVAR(1,71,"section_data(): sect_cb"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1553
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1554 if (ics->sect_cb[g][i] == NOISE_HCB)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1555 ics->noise_used = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1556
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1557 #ifdef ERROR_RESILIENCE
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1558 if (hDecoder->aacSectionDataResilienceFlag)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1559 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1560 if ((ics->sect_cb[g][i] == 11) ||
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1561 ((ics->sect_cb[g][i] >= 16) && (ics->sect_cb[g][i] <= 32)))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1562 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1563 vcb11 = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1564 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1565 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1566 if (vcb11)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1567 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1568 sect_len_incr = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1569 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1570 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1571 sect_len_incr = (uint8_t)faad_getbits(ld, sect_bits
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1572 DEBUGVAR(1,72,"section_data(): sect_len_incr"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1573 #ifdef ERROR_RESILIENCE
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1574 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1575 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1576 while ((sect_len_incr == sect_esc_val) /* &&
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1577 (k+sect_len < ics->max_sfb)*/)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1578 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1579 sect_len += sect_len_incr;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1580 sect_len_incr = (uint8_t)faad_getbits(ld, sect_bits
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1581 DEBUGVAR(1,72,"section_data(): sect_len_incr"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1582 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1583
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1584 sect_len += sect_len_incr;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1585
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1586 ics->sect_start[g][i] = k;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1587 ics->sect_end[g][i] = k + sect_len;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1588
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1589 if (k + sect_len >= 8*15)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1590 return 15;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1591 if (i >= 8*15)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1592 return 15;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1593
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1594 for (sfb = k; sfb < k + sect_len; sfb++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1595 ics->sfb_cb[g][sfb] = ics->sect_cb[g][i];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1596
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1597 #if 0
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1598 printf(" %6d %6d %6d\n",
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1599 i,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1600 ics->sect_end[g][i],
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1601 ics->sect_cb[g][i]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1602 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1603
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1604 k += sect_len;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1605 i++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1606 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1607 ics->num_sec[g] = i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1608 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1609
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1610 #if 0
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1611 printf("\n");
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1612 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1613
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1614 return 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1615 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1616
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1617 /*
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1618 * decode_scale_factors()
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1619 * decodes the scalefactors from the bitstream
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1620 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1621 /*
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1622 * All scalefactors (and also the stereo positions and pns energies) are
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1623 * transmitted using Huffman coded DPCM relative to the previous active
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1624 * scalefactor (respectively previous stereo position or previous pns energy,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1625 * see subclause 4.6.2 and 4.6.3). The first active scalefactor is
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1626 * differentially coded relative to the global gain.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1627 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1628 static uint8_t decode_scale_factors(ic_stream *ics, bitfile *ld)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1629 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1630 uint8_t g, sfb;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1631 int16_t t;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1632 int8_t noise_pcm_flag = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1633
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1634 int16_t scale_factor = ics->global_gain;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1635 int16_t is_position = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1636 int16_t noise_energy = ics->global_gain - 90;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1637
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1638 for (g = 0; g < ics->num_window_groups; g++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1639 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1640 for (sfb = 0; sfb < ics->max_sfb; sfb++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1641 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1642 switch (ics->sfb_cb[g][sfb])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1643 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1644 case ZERO_HCB: /* zero book */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1645 ics->scale_factors[g][sfb] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1646 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1647 case INTENSITY_HCB: /* intensity books */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1648 case INTENSITY_HCB2:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1649
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1650 /* decode intensity position */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1651 t = huffman_scale_factor(ld);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1652 is_position += (t - 60);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1653 ics->scale_factors[g][sfb] = is_position;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1654
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1655 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1656 case NOISE_HCB: /* noise books */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1657
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1658 /* decode noise energy */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1659 if (noise_pcm_flag)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1660 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1661 noise_pcm_flag = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1662 t = (int16_t)faad_getbits(ld, 9
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1663 DEBUGVAR(1,73,"scale_factor_data(): first noise")) - 256;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1664 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1665 t = huffman_scale_factor(ld);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1666 t -= 60;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1667 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1668 noise_energy += t;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1669 ics->scale_factors[g][sfb] = noise_energy;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1670
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1671 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1672 default: /* spectral books */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1673
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1674 /* ics->scale_factors[g][sfb] must be between 0 and 255 */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1675
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1676 ics->scale_factors[g][sfb] = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1677
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1678 /* decode scale factor */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1679 t = huffman_scale_factor(ld);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1680 scale_factor += (t - 60);
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1681 if (scale_factor < 0 || scale_factor > 255)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1682 return 4;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1683 ics->scale_factors[g][sfb] = scale_factor;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1684
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1685 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1686 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1687 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1688 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1689
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1690 return 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1691 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1692
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1693 /* Table 4.4.26 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1694 static uint8_t scale_factor_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1695 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1696 uint8_t ret = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1697 #ifdef PROFILE
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1698 int64_t count = faad_get_ts();
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1699 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1700
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1701 #ifdef ERROR_RESILIENCE
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1702 if (!hDecoder->aacScalefactorDataResilienceFlag)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1703 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1704 #endif
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1705 ret = decode_scale_factors(ics, ld);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1706 #ifdef ERROR_RESILIENCE
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1707 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1708 /* In ER AAC the parameters for RVLC are seperated from the actual
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1709 data that holds the scale_factors.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1710 Strangely enough, 2 parameters for HCR are put inbetween them.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1711 */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1712 ret = rvlc_scale_factor_data(ics, ld);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1713 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1714 #endif
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1715
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1716 #ifdef PROFILE
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1717 count = faad_get_ts() - count;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1718 hDecoder->scalefac_cycles += count;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1719 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1720
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1721 return ret;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1722 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1723
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1724 /* Table 4.4.27 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1725 static void tns_data(ic_stream *ics, tns_info *tns, bitfile *ld)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1726 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1727 uint8_t w, filt, i, start_coef_bits, coef_bits;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1728 uint8_t n_filt_bits = 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1729 uint8_t length_bits = 6;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1730 uint8_t order_bits = 5;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1731
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1732 if (ics->window_sequence == EIGHT_SHORT_SEQUENCE)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1733 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1734 n_filt_bits = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1735 length_bits = 4;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1736 order_bits = 3;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1737 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1738
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1739 for (w = 0; w < ics->num_windows; w++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1740 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1741 tns->n_filt[w] = (uint8_t)faad_getbits(ld, n_filt_bits
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1742 DEBUGVAR(1,74,"tns_data(): n_filt"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1743
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1744 if (tns->n_filt[w])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1745 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1746 if ((tns->coef_res[w] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1747 DEBUGVAR(1,75,"tns_data(): coef_res"))) & 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1748 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1749 start_coef_bits = 4;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1750 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1751 start_coef_bits = 3;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1752 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1753 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1754
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1755 for (filt = 0; filt < tns->n_filt[w]; filt++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1756 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1757 tns->length[w][filt] = (uint8_t)faad_getbits(ld, length_bits
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1758 DEBUGVAR(1,76,"tns_data(): length"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1759 tns->order[w][filt] = (uint8_t)faad_getbits(ld, order_bits
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1760 DEBUGVAR(1,77,"tns_data(): order"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1761 if (tns->order[w][filt])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1762 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1763 tns->direction[w][filt] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1764 DEBUGVAR(1,78,"tns_data(): direction"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1765 tns->coef_compress[w][filt] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1766 DEBUGVAR(1,79,"tns_data(): coef_compress"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1767
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1768 coef_bits = start_coef_bits - tns->coef_compress[w][filt];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1769 for (i = 0; i < tns->order[w][filt]; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1770 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1771 tns->coef[w][filt][i] = (uint8_t)faad_getbits(ld, coef_bits
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1772 DEBUGVAR(1,80,"tns_data(): coef"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1773 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1774 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1775 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1776 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1777 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1778
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1779 #ifdef LTP_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1780 /* Table 4.4.28 */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1781 static uint8_t ltp_data(faacDecHandle hDecoder, ic_stream *ics, ltp_info *ltp, bitfile *ld)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1782 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1783 uint8_t sfb, w;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1784
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1785 ltp->lag = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1786
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1787 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1788 if (hDecoder->object_type == LD)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1789 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1790 ltp->lag_update = (uint8_t)faad_getbits(ld, 1
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1791 DEBUGVAR(1,142,"ltp_data(): lag_update"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1792
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1793 if (ltp->lag_update)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1794 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1795 ltp->lag = (uint16_t)faad_getbits(ld, 10
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1796 DEBUGVAR(1,81,"ltp_data(): lag"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1797 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1798 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1799 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1800 ltp->lag = (uint16_t)faad_getbits(ld, 11
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1801 DEBUGVAR(1,81,"ltp_data(): lag"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1802 #ifdef LD_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1803 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1804 #endif
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1805
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1806 /* Check length of lag */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1807 if (ltp->lag > (hDecoder->frameLength << 1))
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1808 return 18;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1809
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1810 ltp->coef = (uint8_t)faad_getbits(ld, 3
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1811 DEBUGVAR(1,82,"ltp_data(): coef"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1812
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1813 if (ics->window_sequence == EIGHT_SHORT_SEQUENCE)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1814 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1815 for (w = 0; w < ics->num_windows; w++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1816 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1817 if ((ltp->short_used[w] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1818 DEBUGVAR(1,83,"ltp_data(): short_used"))) & 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1819 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1820 ltp->short_lag_present[w] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1821 DEBUGVAR(1,84,"ltp_data(): short_lag_present"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1822 if (ltp->short_lag_present[w])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1823 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1824 ltp->short_lag[w] = (uint8_t)faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1825 DEBUGVAR(1,85,"ltp_data(): short_lag"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1826 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1827 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1828 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1829 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1830 ltp->last_band = (ics->max_sfb < MAX_LTP_SFB ? ics->max_sfb : MAX_LTP_SFB);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1831
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1832 for (sfb = 0; sfb < ltp->last_band; sfb++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1833 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1834 ltp->long_used[sfb] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1835 DEBUGVAR(1,86,"ltp_data(): long_used"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1836 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1837 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1838
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1839 return 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1840 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1841 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1842
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1843 /* Table 4.4.29 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1844 static uint8_t spectral_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1845 int16_t *spectral_data)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1846 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1847 int8_t i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1848 uint8_t g;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1849 uint16_t inc, k, p = 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1850 uint8_t groups = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1851 uint8_t sect_cb;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1852 uint8_t result;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1853 uint16_t nshort = hDecoder->frameLength/8;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1854
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1855 #ifdef PROFILE
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1856 int64_t count = faad_get_ts();
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1857 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1858
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1859 for(g = 0; g < ics->num_window_groups; g++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1860 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1861 p = groups*nshort;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1862
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1863 for (i = 0; i < ics->num_sec[g]; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1864 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1865 sect_cb = ics->sect_cb[g][i];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1866
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1867 inc = (sect_cb >= FIRST_PAIR_HCB) ? 2 : 4;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1868
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1869 switch (sect_cb)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1870 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1871 case ZERO_HCB:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1872 case NOISE_HCB:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1873 case INTENSITY_HCB:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1874 case INTENSITY_HCB2:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1875 p += (ics->sect_sfb_offset[g][ics->sect_end[g][i]] -
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1876 ics->sect_sfb_offset[g][ics->sect_start[g][i]]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1877 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1878 default:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1879 for (k = ics->sect_sfb_offset[g][ics->sect_start[g][i]];
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1880 k < ics->sect_sfb_offset[g][ics->sect_end[g][i]]; k += inc)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1881 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1882 if ((result = huffman_spectral_data(sect_cb, ld, &spectral_data[p])) > 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1883 return result;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1884 p += inc;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1885 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1886 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1887 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1888 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1889 groups += ics->window_group_length[g];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1890 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1891
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1892 #ifdef PROFILE
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1893 count = faad_get_ts() - count;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1894 hDecoder->spectral_cycles += count;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1895 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1896
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1897 return 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1898 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1899
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1900 /* Table 4.4.30 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1901 static uint16_t extension_payload(bitfile *ld, drc_info *drc, uint16_t count)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1902 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1903 uint16_t i, n, dataElementLength;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1904 uint8_t dataElementLengthPart;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1905 uint8_t align = 4, data_element_version, loopCounter;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1906
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1907 uint8_t extension_type = (uint8_t)faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1908 DEBUGVAR(1,87,"extension_payload(): extension_type"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1909
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1910 switch (extension_type)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1911 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1912 case EXT_DYNAMIC_RANGE:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1913 drc->present = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1914 n = dynamic_range_info(ld, drc);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1915 return n;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1916 case EXT_FILL_DATA:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1917 /* fill_nibble = */ faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1918 DEBUGVAR(1,136,"extension_payload(): fill_nibble")); /* must be ‘0000’ */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1919 for (i = 0; i < count-1; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1920 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1921 /* fill_byte[i] = */ faad_getbits(ld, 8
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1922 DEBUGVAR(1,88,"extension_payload(): fill_byte")); /* must be ‘10100101’ */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1923 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1924 return count;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1925 case EXT_DATA_ELEMENT:
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1926 data_element_version = (uint8_t)faad_getbits(ld, 4
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1927 DEBUGVAR(1,400,"extension_payload(): data_element_version"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1928 switch (data_element_version)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1929 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1930 case ANC_DATA:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1931 loopCounter = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1932 dataElementLength = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1933 do {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
1934 dataElementLengthPart = (uint8_t)faad_getbits(ld, 8
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1935 DEBUGVAR(1,401,"extension_payload(): dataElementLengthPart"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1936 dataElementLength += dataElementLengthPart;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1937 loopCounter++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1938 } while (dataElementLengthPart == 255);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1939
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1940 for (i = 0; i < dataElementLength; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1941 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1942 /* data_element_byte[i] = */ faad_getbits(ld, 8
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1943 DEBUGVAR(1,402,"extension_payload(): data_element_byte"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1944 return (dataElementLength+loopCounter+1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1945 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1946 default:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1947 align = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1948 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1949 case EXT_FIL:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1950 default:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1951 faad_getbits(ld, align
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1952 DEBUGVAR(1,88,"extension_payload(): fill_nibble"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1953 for (i = 0; i < count-1; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1954 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1955 /* other_bits[i] = */ faad_getbits(ld, 8
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1956 DEBUGVAR(1,89,"extension_payload(): fill_bit"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1957 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1958 return count;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1959 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1960 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1961
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1962 /* Table 4.4.31 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1963 static uint8_t dynamic_range_info(bitfile *ld, drc_info *drc)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1964 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1965 uint8_t i, n = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1966 uint8_t band_incr;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1967
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1968 drc->num_bands = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1969
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1970 if (faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1971 DEBUGVAR(1,90,"dynamic_range_info(): has instance_tag")) & 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1972 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1973 drc->pce_instance_tag = (uint8_t)faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1974 DEBUGVAR(1,91,"dynamic_range_info(): pce_instance_tag"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1975 /* drc->drc_tag_reserved_bits = */ faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1976 DEBUGVAR(1,92,"dynamic_range_info(): drc_tag_reserved_bits"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1977 n++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1978 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1979
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1980 drc->excluded_chns_present = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1981 DEBUGVAR(1,93,"dynamic_range_info(): excluded_chns_present"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1982 if (drc->excluded_chns_present == 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1983 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1984 n += excluded_channels(ld, drc);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1985 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1986
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1987 if (faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1988 DEBUGVAR(1,94,"dynamic_range_info(): has bands data")) & 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1989 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1990 band_incr = (uint8_t)faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1991 DEBUGVAR(1,95,"dynamic_range_info(): band_incr"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1992 /* drc->drc_bands_reserved_bits = */ faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1993 DEBUGVAR(1,96,"dynamic_range_info(): drc_bands_reserved_bits"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1994 n++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1995 drc->num_bands += band_incr;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1996
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1997 for (i = 0; i < drc->num_bands; i++);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1998 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1999 drc->band_top[i] = (uint8_t)faad_getbits(ld, 8
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2000 DEBUGVAR(1,97,"dynamic_range_info(): band_top"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2001 n++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2002 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2003 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2004
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2005 if (faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2006 DEBUGVAR(1,98,"dynamic_range_info(): has prog_ref_level")) & 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2007 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2008 drc->prog_ref_level = (uint8_t)faad_getbits(ld, 7
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2009 DEBUGVAR(1,99,"dynamic_range_info(): prog_ref_level"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2010 /* drc->prog_ref_level_reserved_bits = */ faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2011 DEBUGVAR(1,100,"dynamic_range_info(): prog_ref_level_reserved_bits"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2012 n++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2013 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2014
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2015 for (i = 0; i < drc->num_bands; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2016 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2017 drc->dyn_rng_sgn[i] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2018 DEBUGVAR(1,101,"dynamic_range_info(): dyn_rng_sgn"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2019 drc->dyn_rng_ctl[i] = (uint8_t)faad_getbits(ld, 7
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2020 DEBUGVAR(1,102,"dynamic_range_info(): dyn_rng_ctl"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2021 n++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2022 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2023
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2024 return n;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2025 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2026
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2027 /* Table 4.4.32 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2028 static uint8_t excluded_channels(bitfile *ld, drc_info *drc)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2029 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2030 uint8_t i, n = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2031 uint8_t num_excl_chan = 7;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2032
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2033 for (i = 0; i < 7; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2034 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2035 drc->exclude_mask[i] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2036 DEBUGVAR(1,103,"excluded_channels(): exclude_mask"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2037 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2038 n++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2039
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2040 while ((drc->additional_excluded_chns[n-1] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2041 DEBUGVAR(1,104,"excluded_channels(): additional_excluded_chns"))) == 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2042 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2043 for (i = num_excl_chan; i < num_excl_chan+7; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2044 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2045 drc->exclude_mask[i] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2046 DEBUGVAR(1,105,"excluded_channels(): exclude_mask"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2047 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2048 n++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2049 num_excl_chan += 7;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2050 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2051
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2052 return n;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2053 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2054
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2055 /* Annex A: Audio Interchange Formats */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2056
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2057 /* Table 1.A.2 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2058 void get_adif_header(adif_header *adif, bitfile *ld)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2059 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2060 uint8_t i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2061
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2062 /* adif_id[0] = */ faad_getbits(ld, 8
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2063 DEBUGVAR(1,106,"get_adif_header(): adif_id[0]"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2064 /* adif_id[1] = */ faad_getbits(ld, 8
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2065 DEBUGVAR(1,107,"get_adif_header(): adif_id[1]"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2066 /* adif_id[2] = */ faad_getbits(ld, 8
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2067 DEBUGVAR(1,108,"get_adif_header(): adif_id[2]"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2068 /* adif_id[3] = */ faad_getbits(ld, 8
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2069 DEBUGVAR(1,109,"get_adif_header(): adif_id[3]"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2070 adif->copyright_id_present = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2071 DEBUGVAR(1,110,"get_adif_header(): copyright_id_present"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2072 if(adif->copyright_id_present)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2073 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2074 for (i = 0; i < 72/8; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2075 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2076 adif->copyright_id[i] = (int8_t)faad_getbits(ld, 8
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2077 DEBUGVAR(1,111,"get_adif_header(): copyright_id"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2078 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2079 adif->copyright_id[i] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2080 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2081 adif->original_copy = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2082 DEBUGVAR(1,112,"get_adif_header(): original_copy"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2083 adif->home = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2084 DEBUGVAR(1,113,"get_adif_header(): home"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2085 adif->bitstream_type = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2086 DEBUGVAR(1,114,"get_adif_header(): bitstream_type"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2087 adif->bitrate = faad_getbits(ld, 23
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2088 DEBUGVAR(1,115,"get_adif_header(): bitrate"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2089 adif->num_program_config_elements = (uint8_t)faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2090 DEBUGVAR(1,116,"get_adif_header(): num_program_config_elements"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2091
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2092 for (i = 0; i < adif->num_program_config_elements + 1; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2093 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2094 if(adif->bitstream_type == 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2095 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2096 adif->adif_buffer_fullness = faad_getbits(ld, 20
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2097 DEBUGVAR(1,117,"get_adif_header(): adif_buffer_fullness"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2098 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2099 adif->adif_buffer_fullness = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2100 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2101
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2102 program_config_element(&adif->pce[i], ld);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2103 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2104 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2105
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2106 /* Table 1.A.5 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2107 uint8_t adts_frame(adts_header *adts, bitfile *ld)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2108 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2109 /* faad_byte_align(ld); */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2110 if (adts_fixed_header(adts, ld))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2111 return 5;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2112 adts_variable_header(adts, ld);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2113 adts_error_check(adts, ld);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2114
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2115 return 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2116 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2117
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2118 /* Table 1.A.6 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2119 static uint8_t adts_fixed_header(adts_header *adts, bitfile *ld)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2120 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2121 uint16_t i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2122 uint8_t sync_err = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2123
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2124 /* try to recover from sync errors */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2125 for (i = 0; i < 768; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2126 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2127 adts->syncword = (uint16_t)faad_showbits(ld, 12);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2128 if (adts->syncword != 0xFFF)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2129 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2130 faad_getbits(ld, 8
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2131 DEBUGVAR(0,0,""));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2132 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2133 sync_err = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2134 faad_getbits(ld, 12
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2135 DEBUGVAR(1,118,"adts_fixed_header(): syncword"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2136 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2137 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2138 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2139 if (sync_err)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2140 return 5;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2141
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2142 adts->id = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2143 DEBUGVAR(1,119,"adts_fixed_header(): id"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2144 adts->layer = (uint8_t)faad_getbits(ld, 2
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2145 DEBUGVAR(1,120,"adts_fixed_header(): layer"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2146 adts->protection_absent = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2147 DEBUGVAR(1,121,"adts_fixed_header(): protection_absent"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2148 adts->profile = (uint8_t)faad_getbits(ld, 2
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2149 DEBUGVAR(1,122,"adts_fixed_header(): profile"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2150 adts->sf_index = (uint8_t)faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2151 DEBUGVAR(1,123,"adts_fixed_header(): sf_index"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2152 adts->private_bit = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2153 DEBUGVAR(1,124,"adts_fixed_header(): private_bit"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2154 adts->channel_configuration = (uint8_t)faad_getbits(ld, 3
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2155 DEBUGVAR(1,125,"adts_fixed_header(): channel_configuration"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2156 adts->original = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2157 DEBUGVAR(1,126,"adts_fixed_header(): original"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2158 adts->home = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2159 DEBUGVAR(1,127,"adts_fixed_header(): home"));
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
2160
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
2161 if (adts->old_format == 1)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
2162 {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
2163 /* Removed in corrigendum 14496-3:2002 */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
2164 if (adts->id == 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
2165 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
2166 adts->emphasis = (uint8_t)faad_getbits(ld, 2
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
2167 DEBUGVAR(1,128,"adts_fixed_header(): emphasis"));
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
2168 }
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
2169 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2170
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2171 return 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2172 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2173
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2174 /* Table 1.A.7 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2175 static void adts_variable_header(adts_header *adts, bitfile *ld)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2176 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2177 adts->copyright_identification_bit = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2178 DEBUGVAR(1,129,"adts_variable_header(): copyright_identification_bit"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2179 adts->copyright_identification_start = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2180 DEBUGVAR(1,130,"adts_variable_header(): copyright_identification_start"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2181 adts->aac_frame_length = (uint16_t)faad_getbits(ld, 13
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2182 DEBUGVAR(1,131,"adts_variable_header(): aac_frame_length"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2183 adts->adts_buffer_fullness = (uint16_t)faad_getbits(ld, 11
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2184 DEBUGVAR(1,132,"adts_variable_header(): adts_buffer_fullness"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2185 adts->no_raw_data_blocks_in_frame = (uint8_t)faad_getbits(ld, 2
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2186 DEBUGVAR(1,133,"adts_variable_header(): no_raw_data_blocks_in_frame"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2187 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2188
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2189 /* Table 1.A.8 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2190 static void adts_error_check(adts_header *adts, bitfile *ld)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2191 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2192 if (adts->protection_absent == 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2193 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2194 adts->crc_check = (uint16_t)faad_getbits(ld, 16
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2195 DEBUGVAR(1,134,"adts_error_check(): crc_check"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2196 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2197 }