annotate libfaad2/sbr_syntax.c @ 13190:8be7dbcea0be

AVC (fourcc avc1) in mp4 support
author rtognimp
date Sun, 29 Aug 2004 13:52:19 +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: sbr_syntax.c,v 1.3 2004/06/02 22:59:03 diego Exp $
d81145997036 More information about modifications to comply more closely with GPL 2a.
diego
parents: 12527
diff changeset
27 ** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
28 **/
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
29
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
30 #include "common.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
31 #include "structs.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
32
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
33 #ifdef SBR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
34
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
35 #include "sbr_syntax.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
36 #include "syntax.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
37 #include "sbr_huff.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
38 #include "sbr_fbt.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
39 #include "sbr_tf_grid.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
40 #include "sbr_e_nf.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
41 #include "bits.h"
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
42 #ifdef PS_DEC
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
43 #include "ps_dec.h"
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
44 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
45 #ifdef DRM_PS
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
46 #include "drm_dec.h"
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
47 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
48 #include "analysis.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
49
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
50 /* static function declarations */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
51 static void sbr_header(bitfile *ld, sbr_info *sbr);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
52 static uint8_t sbr_data(bitfile *ld, sbr_info *sbr);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
53 static uint16_t sbr_extension(bitfile *ld, sbr_info *sbr,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
54 uint8_t bs_extension_id, uint16_t num_bits_left);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
55 static uint8_t sbr_single_channel_element(bitfile *ld, sbr_info *sbr);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
56 static uint8_t sbr_channel_pair_element(bitfile *ld, sbr_info *sbr);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
57 static uint8_t sbr_grid(bitfile *ld, sbr_info *sbr, uint8_t ch);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
58 static void sbr_dtdf(bitfile *ld, sbr_info *sbr, uint8_t ch);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
59 static void invf_mode(bitfile *ld, sbr_info *sbr, uint8_t ch);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
60 static void sinusoidal_coding(bitfile *ld, sbr_info *sbr, uint8_t ch);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
61
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
62
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
63 static void sbr_reset(sbr_info *sbr)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
64 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
65 #if 0
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
66 printf("%d\n", sbr->bs_start_freq_prev);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
67 printf("%d\n", sbr->bs_stop_freq_prev);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
68 printf("%d\n", sbr->bs_freq_scale_prev);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
69 printf("%d\n", sbr->bs_alter_scale_prev);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
70 printf("%d\n", sbr->bs_xover_band_prev);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
71 printf("%d\n\n", sbr->bs_noise_bands_prev);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
72 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
73
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
74 /* if these are different from the previous frame: Reset = 1 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
75 if ((sbr->bs_start_freq != sbr->bs_start_freq_prev) ||
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
76 (sbr->bs_stop_freq != sbr->bs_stop_freq_prev) ||
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
77 (sbr->bs_freq_scale != sbr->bs_freq_scale_prev) ||
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
78 (sbr->bs_alter_scale != sbr->bs_alter_scale_prev))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
79 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
80 sbr->Reset = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
81 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
82 sbr->Reset = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
83 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
84
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
85 if ((sbr->bs_start_freq != sbr->bs_start_freq_prev) ||
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
86 (sbr->bs_stop_freq != sbr->bs_stop_freq_prev) ||
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
87 (sbr->bs_freq_scale != sbr->bs_freq_scale_prev) ||
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
88 (sbr->bs_alter_scale != sbr->bs_alter_scale_prev) ||
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
89 (sbr->bs_xover_band != sbr->bs_xover_band_prev) ||
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
90 (sbr->bs_noise_bands != sbr->bs_noise_bands_prev))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
91 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
92 sbr->Reset = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
93 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
94 sbr->Reset = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
95 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
96
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
97 sbr->bs_start_freq_prev = sbr->bs_start_freq;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
98 sbr->bs_stop_freq_prev = sbr->bs_stop_freq;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
99 sbr->bs_freq_scale_prev = sbr->bs_freq_scale;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
100 sbr->bs_alter_scale_prev = sbr->bs_alter_scale;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
101 sbr->bs_xover_band_prev = sbr->bs_xover_band;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
102 sbr->bs_noise_bands_prev = sbr->bs_noise_bands;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
103
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
104 if (sbr->frame == 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
105 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
106 sbr->Reset = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
107 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
108 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
109
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
110 /* table 2 */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
111 uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
112 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
113 uint8_t result = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
114 uint16_t num_align_bits = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
115 uint16_t num_sbr_bits = (uint16_t)faad_get_processed_bits(ld);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
116
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
117 #ifdef DRM
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
118 if (!sbr->Is_DRM_SBR)
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
119 #endif
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
120 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
121 uint8_t bs_extension_type = (uint8_t)faad_getbits(ld, 4
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
122 DEBUGVAR(1,198,"sbr_bitstream(): bs_extension_type"));
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
123
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
124 if (bs_extension_type == EXT_SBR_DATA_CRC)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
125 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
126 sbr->bs_sbr_crc_bits = (uint16_t)faad_getbits(ld, 10
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
127 DEBUGVAR(1,199,"sbr_bitstream(): bs_sbr_crc_bits"));
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
128 }
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
129 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
130
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
131 sbr->bs_header_flag = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
132 DEBUGVAR(1,200,"sbr_bitstream(): bs_header_flag"));
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
133
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
134 if (sbr->bs_header_flag)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
135 sbr_header(ld, sbr);
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
136
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
137 /* Reset? */
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
138 sbr_reset(sbr);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
139
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
140 /* first frame should have a header */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
141 //if (!(sbr->frame == 0 && sbr->bs_header_flag == 0))
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
142 if (sbr->header_count != 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
143 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
144 if (sbr->Reset || (sbr->bs_header_flag && sbr->just_seeked))
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
145 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
146 uint8_t k2;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
147
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
148 /* calculate the Master Frequency Table */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
149 sbr->k0 = qmf_start_channel(sbr->bs_start_freq, sbr->bs_samplerate_mode,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
150 sbr->sample_rate);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
151 k2 = qmf_stop_channel(sbr->bs_stop_freq, sbr->sample_rate, sbr->k0);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
152
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
153 /* check k0 and k2 */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
154 if (sbr->sample_rate >= 48000)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
155 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
156 if ((k2 - sbr->k0) > 32)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
157 result += 1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
158 } else if (sbr->sample_rate <= 32000) {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
159 if ((k2 - sbr->k0) > 48)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
160 result += 1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
161 } else { /* (sbr->sample_rate == 44100) */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
162 if ((k2 - sbr->k0) > 45)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
163 result += 1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
164 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
165
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
166 if (sbr->bs_freq_scale == 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
167 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
168 result += master_frequency_table_fs0(sbr, sbr->k0, k2,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
169 sbr->bs_alter_scale);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
170 } else {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
171 result += master_frequency_table(sbr, sbr->k0, k2, sbr->bs_freq_scale,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
172 sbr->bs_alter_scale);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
173 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
174 result += derived_frequency_table(sbr, sbr->bs_xover_band, k2);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
175
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
176 result = (result > 0) ? 1 : 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
177 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
178
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
179 if (result == 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
180 result = sbr_data(ld, sbr);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
181 } else {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
182 result = 1;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
183 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
184
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
185 #ifdef DRM
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
186 if (!sbr->Is_DRM_SBR)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
187 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
188 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
189 num_sbr_bits = (uint16_t)faad_get_processed_bits(ld) - num_sbr_bits;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
190 /* -4 does not apply, bs_extension_type is re-read in this function */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
191 num_align_bits = 8*cnt /*- 4*/ - num_sbr_bits;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
192
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
193 while (num_align_bits > 7)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
194 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
195 faad_getbits(ld, 8
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
196 DEBUGVAR(1,999,"sbr_bitstream(): num_align_bits"));
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
197 num_align_bits -= 8;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
198 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
199 faad_getbits(ld, num_align_bits
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
200 DEBUGVAR(1,999,"sbr_bitstream(): num_align_bits"));
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
201 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
202
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
203 return result;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
204 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
205
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
206 /* table 3 */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
207 static void sbr_header(bitfile *ld, sbr_info *sbr)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
208 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
209 uint8_t bs_header_extra_1, bs_header_extra_2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
210
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
211 sbr->header_count++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
212
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
213 sbr->bs_amp_res = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
214 DEBUGVAR(1,203,"sbr_header(): bs_amp_res"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
215
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
216 /* bs_start_freq and bs_stop_freq must define a fequency band that does
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
217 not exceed 48 channels */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
218 sbr->bs_start_freq = (uint8_t)faad_getbits(ld, 4
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
219 DEBUGVAR(1,204,"sbr_header(): bs_start_freq"));
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
220 sbr->bs_stop_freq = (uint8_t)faad_getbits(ld, 4
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
221 DEBUGVAR(1,205,"sbr_header(): bs_stop_freq"));
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
222 sbr->bs_xover_band = (uint8_t)faad_getbits(ld, 3
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
223 DEBUGVAR(1,206,"sbr_header(): bs_xover_band"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
224 faad_getbits(ld, 2
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
225 DEBUGVAR(1,207,"sbr_header(): bs_reserved_bits_hdr"));
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
226 bs_header_extra_1 = (uint8_t)faad_get1bit(ld
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
227 DEBUGVAR(1,208,"sbr_header(): bs_header_extra_1"));
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
228 bs_header_extra_2 = (uint8_t)faad_get1bit(ld
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
229 DEBUGVAR(1,209,"sbr_header(): bs_header_extra_2"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
230
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
231 if (bs_header_extra_1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
232 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
233 sbr->bs_freq_scale = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
234 DEBUGVAR(1,211,"sbr_header(): bs_freq_scale"));
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
235 sbr->bs_alter_scale = (uint8_t)faad_get1bit(ld
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
236 DEBUGVAR(1,212,"sbr_header(): bs_alter_scale"));
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
237 sbr->bs_noise_bands = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
238 DEBUGVAR(1,213,"sbr_header(): bs_noise_bands"));
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
239 } else {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
240 /* Default values */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
241 sbr->bs_freq_scale = 2;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
242 sbr->bs_alter_scale = 1;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
243 sbr->bs_noise_bands = 2;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
244 }
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
245
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
246 if (bs_header_extra_2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
247 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
248 sbr->bs_limiter_bands = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
249 DEBUGVAR(1,214,"sbr_header(): bs_limiter_bands"));
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
250 sbr->bs_limiter_gains = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
251 DEBUGVAR(1,215,"sbr_header(): bs_limiter_gains"));
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
252 sbr->bs_interpol_freq = (uint8_t)faad_get1bit(ld
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
253 DEBUGVAR(1,216,"sbr_header(): bs_interpol_freq"));
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
254 sbr->bs_smoothing_mode = (uint8_t)faad_get1bit(ld
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
255 DEBUGVAR(1,217,"sbr_header(): bs_smoothing_mode"));
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
256 } else {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
257 /* Default values */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
258 sbr->bs_limiter_bands = 2;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
259 sbr->bs_limiter_gains = 2;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
260 sbr->bs_interpol_freq = 1;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
261 sbr->bs_smoothing_mode = 1;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
262 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
263
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
264 #if 0
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
265 /* print the header to screen */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
266 printf("bs_amp_res: %d\n", sbr->bs_amp_res);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
267 printf("bs_start_freq: %d\n", sbr->bs_start_freq);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
268 printf("bs_stop_freq: %d\n", sbr->bs_stop_freq);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
269 printf("bs_xover_band: %d\n", sbr->bs_xover_band);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
270 if (bs_header_extra_1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
271 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
272 printf("bs_freq_scale: %d\n", sbr->bs_freq_scale);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
273 printf("bs_alter_scale: %d\n", sbr->bs_alter_scale);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
274 printf("bs_noise_bands: %d\n", sbr->bs_noise_bands);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
275 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
276 if (bs_header_extra_2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
277 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
278 printf("bs_limiter_bands: %d\n", sbr->bs_limiter_bands);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
279 printf("bs_limiter_gains: %d\n", sbr->bs_limiter_gains);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
280 printf("bs_interpol_freq: %d\n", sbr->bs_interpol_freq);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
281 printf("bs_smoothing_mode: %d\n", sbr->bs_smoothing_mode);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
282 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
283 printf("\n");
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
284 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
285 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
286
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
287 /* table 4 */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
288 static uint8_t sbr_data(bitfile *ld, sbr_info *sbr)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
289 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
290 uint8_t result;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
291 #if 0
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
292 sbr->bs_samplerate_mode = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
293 DEBUGVAR(1,219,"sbr_data(): bs_samplerate_mode"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
294 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
295
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
296 sbr->rate = (sbr->bs_samplerate_mode) ? 2 : 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
297
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
298 switch (sbr->id_aac)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
299 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
300 case ID_SCE:
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
301 if ((result = sbr_single_channel_element(ld, sbr)) > 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
302 return result;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
303 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
304 case ID_CPE:
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
305 if ((result = sbr_channel_pair_element(ld, sbr)) > 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
306 return result;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
307 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
308 }
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
309
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
310 return 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
311 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
312
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
313 /* table 5 */
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
314 static uint8_t sbr_single_channel_element(bitfile *ld, sbr_info *sbr)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
315 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
316 uint8_t result;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
317
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
318 if (faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
319 DEBUGVAR(1,220,"sbr_single_channel_element(): bs_data_extra")))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
320 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
321 faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
322 DEBUGVAR(1,221,"sbr_single_channel_element(): bs_reserved_bits_data"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
323 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
324
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
325 #ifdef DRM
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
326 /* bs_coupling, from sbr_channel_pair_base_element(bs_amp_res) */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
327 if (sbr->Is_DRM_SBR)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
328 faad_get1bit(ld);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
329 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
330
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
331 if ((result = sbr_grid(ld, sbr, 0)) > 0)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
332 return result;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
333 sbr_dtdf(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
334 invf_mode(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
335 sbr_envelope(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
336 sbr_noise(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
337
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
338 envelope_noise_dequantisation(sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
339
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
340 memset(sbr->bs_add_harmonic[0], 0, 64*sizeof(uint8_t));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
341
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
342 sbr->bs_add_harmonic_flag[0] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
343 DEBUGVAR(1,223,"sbr_single_channel_element(): bs_add_harmonic_flag[0]"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
344 if (sbr->bs_add_harmonic_flag[0])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
345 sinusoidal_coding(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
346
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
347 sbr->bs_extended_data = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
348 DEBUGVAR(1,224,"sbr_single_channel_element(): bs_extended_data[0]"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
349 if (sbr->bs_extended_data)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
350 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
351 uint16_t nr_bits_left;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
352 uint16_t cnt = (uint16_t)faad_getbits(ld, 4
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
353 DEBUGVAR(1,225,"sbr_single_channel_element(): bs_extension_size"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
354 if (cnt == 15)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
355 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
356 cnt += (uint16_t)faad_getbits(ld, 8
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
357 DEBUGVAR(1,226,"sbr_single_channel_element(): bs_esc_count"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
358 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
359
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
360 nr_bits_left = 8 * cnt;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
361 while (nr_bits_left > 7)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
362 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
363 sbr->bs_extension_id = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
364 DEBUGVAR(1,227,"sbr_single_channel_element(): bs_extension_id"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
365 nr_bits_left -= 2;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
366 nr_bits_left -= sbr_extension(ld, sbr, sbr->bs_extension_id, nr_bits_left);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
367 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
368
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
369 /* Corrigendum */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
370 if (nr_bits_left > 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
371 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
372 faad_getbits(ld, nr_bits_left
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
373 DEBUGVAR(1,280,"sbr_single_channel_element(): nr_bits_left"));
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
374 }
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
375 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
376
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
377 return 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
378 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
379
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
380 /* table 6 */
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
381 static uint8_t sbr_channel_pair_element(bitfile *ld, sbr_info *sbr)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
382 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
383 uint8_t n, result;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
384
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
385 if (faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
386 DEBUGVAR(1,228,"sbr_single_channel_element(): bs_data_extra")))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
387 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
388 faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
389 DEBUGVAR(1,228,"sbr_channel_pair_element(): bs_reserved_bits_data"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
390 faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
391 DEBUGVAR(1,228,"sbr_channel_pair_element(): bs_reserved_bits_data"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
392 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
393
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
394 sbr->bs_coupling = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
395 DEBUGVAR(1,228,"sbr_channel_pair_element(): bs_coupling"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
396
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
397 if (sbr->bs_coupling)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
398 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
399 if ((result = sbr_grid(ld, sbr, 0)) > 0)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
400 return result;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
401
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
402 /* need to copy some data from left to right */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
403 sbr->bs_frame_class[1] = sbr->bs_frame_class[0];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
404 sbr->L_E[1] = sbr->L_E[0];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
405 sbr->L_Q[1] = sbr->L_Q[0];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
406 sbr->bs_pointer[1] = sbr->bs_pointer[0];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
407
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
408 for (n = 0; n <= sbr->L_E[0]; n++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
409 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
410 sbr->t_E[1][n] = sbr->t_E[0][n];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
411 sbr->f[1][n] = sbr->f[0][n];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
412 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
413 for (n = 0; n <= sbr->L_Q[0]; n++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
414 sbr->t_Q[1][n] = sbr->t_Q[0][n];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
415
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
416 sbr_dtdf(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
417 sbr_dtdf(ld, sbr, 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
418 invf_mode(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
419
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
420 /* more copying */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
421 for (n = 0; n < sbr->N_Q; n++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
422 sbr->bs_invf_mode[1][n] = sbr->bs_invf_mode[0][n];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
423
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
424 sbr_envelope(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
425 sbr_noise(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
426 sbr_envelope(ld, sbr, 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
427 sbr_noise(ld, sbr, 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
428
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
429 memset(sbr->bs_add_harmonic[0], 0, 64*sizeof(uint8_t));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
430 memset(sbr->bs_add_harmonic[1], 0, 64*sizeof(uint8_t));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
431
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
432 sbr->bs_add_harmonic_flag[0] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
433 DEBUGVAR(1,231,"sbr_channel_pair_element(): bs_add_harmonic_flag[0]"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
434 if (sbr->bs_add_harmonic_flag[0])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
435 sinusoidal_coding(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
436
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
437 sbr->bs_add_harmonic_flag[1] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
438 DEBUGVAR(1,232,"sbr_channel_pair_element(): bs_add_harmonic_flag[1]"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
439 if (sbr->bs_add_harmonic_flag[1])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
440 sinusoidal_coding(ld, sbr, 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
441 } else {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
442 if ((result = sbr_grid(ld, sbr, 0)) > 0)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
443 return result;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
444 if ((result = sbr_grid(ld, sbr, 1)) > 0)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
445 return result;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
446 sbr_dtdf(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
447 sbr_dtdf(ld, sbr, 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
448 invf_mode(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
449 invf_mode(ld, sbr, 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
450 sbr_envelope(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
451 sbr_envelope(ld, sbr, 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
452 sbr_noise(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
453 sbr_noise(ld, sbr, 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
454
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
455 memset(sbr->bs_add_harmonic[0], 0, 64*sizeof(uint8_t));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
456 memset(sbr->bs_add_harmonic[1], 0, 64*sizeof(uint8_t));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
457
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
458 sbr->bs_add_harmonic_flag[0] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
459 DEBUGVAR(1,239,"sbr_channel_pair_element(): bs_add_harmonic_flag[0]"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
460 if (sbr->bs_add_harmonic_flag[0])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
461 sinusoidal_coding(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
462
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
463 sbr->bs_add_harmonic_flag[1] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
464 DEBUGVAR(1,240,"sbr_channel_pair_element(): bs_add_harmonic_flag[1]"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
465 if (sbr->bs_add_harmonic_flag[1])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
466 sinusoidal_coding(ld, sbr, 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
467 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
468 envelope_noise_dequantisation(sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
469 envelope_noise_dequantisation(sbr, 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
470
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
471 if (sbr->bs_coupling)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
472 unmap_envelope_noise(sbr);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
473
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
474 sbr->bs_extended_data = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
475 DEBUGVAR(1,233,"sbr_channel_pair_element(): bs_extended_data[0]"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
476 if (sbr->bs_extended_data)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
477 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
478 uint16_t nr_bits_left;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
479 uint16_t cnt = (uint16_t)faad_getbits(ld, 4
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
480 DEBUGVAR(1,234,"sbr_channel_pair_element(): bs_extension_size"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
481 if (cnt == 15)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
482 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
483 cnt += (uint16_t)faad_getbits(ld, 8
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
484 DEBUGVAR(1,235,"sbr_channel_pair_element(): bs_esc_count"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
485 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
486
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
487 nr_bits_left = 8 * cnt;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
488 while (nr_bits_left > 7)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
489 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
490 sbr->bs_extension_id = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
491 DEBUGVAR(1,236,"sbr_channel_pair_element(): bs_extension_id"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
492 nr_bits_left -= 2;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
493 sbr_extension(ld, sbr, sbr->bs_extension_id, nr_bits_left);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
494 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
495
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
496 /* Corrigendum */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
497 if (nr_bits_left > 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
498 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
499 faad_getbits(ld, nr_bits_left
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
500 DEBUGVAR(1,280,"sbr_channel_pair_element(): nr_bits_left"));
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
501 }
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
502 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
503
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
504 return 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
505 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
506
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
507 /* integer log[2](x): input range [0,10) */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
508 static int8_t sbr_log2(const int8_t val)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
509 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
510 int8_t log2tab[] = { 0, 0, 1, 2, 2, 3, 3, 3, 3, 4 };
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
511 if (val < 10 && val >= 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
512 return log2tab[val];
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
513 else
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
514 return 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
515 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
516
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
517
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
518 /* table 7 */
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
519 static uint8_t sbr_grid(bitfile *ld, sbr_info *sbr, uint8_t ch)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
520 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
521 uint8_t i, env, rel, result;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
522 uint8_t bs_abs_bord, bs_abs_bord_1;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
523 uint8_t bs_num_env = 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
524
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
525 sbr->bs_frame_class[ch] = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
526 DEBUGVAR(1,248,"sbr_grid(): bs_frame_class"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
527
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
528 switch (sbr->bs_frame_class[ch])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
529 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
530 case FIXFIX:
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
531 i = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
532 DEBUGVAR(1,249,"sbr_grid(): bs_num_env_raw"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
533
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
534 bs_num_env = min(1 << i, 5);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
535
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
536 i = (uint8_t)faad_get1bit(ld
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
537 DEBUGVAR(1,250,"sbr_grid(): bs_freq_res_flag"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
538 for (env = 0; env < bs_num_env; env++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
539 sbr->f[ch][env] = i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
540
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
541 sbr->abs_bord_lead[ch] = 0;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
542 sbr->abs_bord_trail[ch] = sbr->numTimeSlots;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
543 sbr->n_rel_lead[ch] = bs_num_env - 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
544 sbr->n_rel_trail[ch] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
545 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
546
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
547 case FIXVAR:
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
548 bs_abs_bord = (uint8_t)faad_getbits(ld, 2
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
549 DEBUGVAR(1,251,"sbr_grid(): bs_abs_bord")) + sbr->numTimeSlots;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
550 bs_num_env = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
551 DEBUGVAR(1,252,"sbr_grid(): bs_num_env")) + 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
552
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
553 for (rel = 0; rel < bs_num_env-1; rel++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
554 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
555 sbr->bs_rel_bord[ch][rel] = 2 * (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
556 DEBUGVAR(1,253,"sbr_grid(): bs_rel_bord")) + 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
557 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
558 i = sbr_log2(bs_num_env + 1);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
559 sbr->bs_pointer[ch] = (uint8_t)faad_getbits(ld, i
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
560 DEBUGVAR(1,254,"sbr_grid(): bs_pointer"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
561
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
562 for (env = 0; env < bs_num_env; env++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
563 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
564 sbr->f[ch][bs_num_env - env - 1] = (uint8_t)faad_get1bit(ld
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
565 DEBUGVAR(1,255,"sbr_grid(): bs_freq_res"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
566 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
567
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
568 sbr->abs_bord_lead[ch] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
569 sbr->abs_bord_trail[ch] = bs_abs_bord;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
570 sbr->n_rel_lead[ch] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
571 sbr->n_rel_trail[ch] = bs_num_env - 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
572 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
573
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
574 case VARFIX:
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
575 bs_abs_bord = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
576 DEBUGVAR(1,256,"sbr_grid(): bs_abs_bord"));
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
577 bs_num_env = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
578 DEBUGVAR(1,257,"sbr_grid(): bs_num_env")) + 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
579
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
580 for (rel = 0; rel < bs_num_env-1; rel++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
581 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
582 sbr->bs_rel_bord[ch][rel] = 2 * (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
583 DEBUGVAR(1,258,"sbr_grid(): bs_rel_bord")) + 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
584 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
585 i = sbr_log2(bs_num_env + 1);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
586 sbr->bs_pointer[ch] = (uint8_t)faad_getbits(ld, i
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
587 DEBUGVAR(1,259,"sbr_grid(): bs_pointer"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
588
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
589 for (env = 0; env < bs_num_env; env++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
590 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
591 sbr->f[ch][env] = (uint8_t)faad_get1bit(ld
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
592 DEBUGVAR(1,260,"sbr_grid(): bs_freq_res"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
593 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
594
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
595 sbr->abs_bord_lead[ch] = bs_abs_bord;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
596 sbr->abs_bord_trail[ch] = sbr->numTimeSlots;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
597 sbr->n_rel_lead[ch] = bs_num_env - 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
598 sbr->n_rel_trail[ch] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
599 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
600
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
601 case VARVAR:
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
602 bs_abs_bord = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
603 DEBUGVAR(1,261,"sbr_grid(): bs_abs_bord_0"));
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
604 bs_abs_bord_1 = (uint8_t)faad_getbits(ld, 2
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
605 DEBUGVAR(1,262,"sbr_grid(): bs_abs_bord_1")) + sbr->numTimeSlots;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
606 sbr->bs_num_rel_0[ch] = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
607 DEBUGVAR(1,263,"sbr_grid(): bs_num_rel_0"));
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
608 sbr->bs_num_rel_1[ch] = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
609 DEBUGVAR(1,264,"sbr_grid(): bs_num_rel_1"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
610
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
611 bs_num_env = min(5, sbr->bs_num_rel_0[ch] + sbr->bs_num_rel_1[ch] + 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
612
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
613 for (rel = 0; rel < sbr->bs_num_rel_0[ch]; rel++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
614 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
615 sbr->bs_rel_bord_0[ch][rel] = 2 * (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
616 DEBUGVAR(1,265,"sbr_grid(): bs_rel_bord")) + 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
617 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
618 for(rel = 0; rel < sbr->bs_num_rel_1[ch]; rel++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
619 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
620 sbr->bs_rel_bord_1[ch][rel] = 2 * (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
621 DEBUGVAR(1,266,"sbr_grid(): bs_rel_bord")) + 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
622 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
623 i = sbr_log2(sbr->bs_num_rel_0[ch] + sbr->bs_num_rel_1[ch] + 2);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
624 sbr->bs_pointer[ch] = (uint8_t)faad_getbits(ld, i
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
625 DEBUGVAR(1,267,"sbr_grid(): bs_pointer"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
626
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
627 for (env = 0; env < bs_num_env; env++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
628 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
629 sbr->f[ch][env] = (uint8_t)faad_get1bit(ld
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
630 DEBUGVAR(1,268,"sbr_grid(): bs_freq_res"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
631 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
632
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
633 sbr->abs_bord_lead[ch] = bs_abs_bord;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
634 sbr->abs_bord_trail[ch] = bs_abs_bord_1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
635 sbr->n_rel_lead[ch] = sbr->bs_num_rel_0[ch];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
636 sbr->n_rel_trail[ch] = sbr->bs_num_rel_1[ch];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
637 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
638 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
639
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
640 if (sbr->bs_frame_class[ch] == VARVAR)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
641 sbr->L_E[ch] = min(bs_num_env, 5);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
642 else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
643 sbr->L_E[ch] = min(bs_num_env, 4);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
644
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
645 if (sbr->L_E[ch] <= 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
646 return 1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
647
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
648 if (sbr->L_E[ch] > 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
649 sbr->L_Q[ch] = 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
650 else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
651 sbr->L_Q[ch] = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
652
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
653 /* TODO: this code can probably be integrated into the code above! */
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
654 if ((result = envelope_time_border_vector(sbr, ch)) > 0)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
655 return result;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
656 noise_floor_time_border_vector(sbr, ch);
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
657
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
658 return 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
659 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
660
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
661 /* table 8 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
662 static void sbr_dtdf(bitfile *ld, sbr_info *sbr, uint8_t ch)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
663 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
664 uint8_t i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
665
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
666 for (i = 0; i < sbr->L_E[ch]; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
667 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
668 sbr->bs_df_env[ch][i] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
669 DEBUGVAR(1,269,"sbr_dtdf(): bs_df_env"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
670 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
671
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
672 for (i = 0; i < sbr->L_Q[ch]; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
673 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
674 sbr->bs_df_noise[ch][i] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
675 DEBUGVAR(1,270,"sbr_dtdf(): bs_df_noise"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
676 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
677 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
678
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
679 /* table 9 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
680 static void invf_mode(bitfile *ld, sbr_info *sbr, uint8_t ch)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
681 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
682 uint8_t n;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
683
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
684 for (n = 0; n < sbr->N_Q; n++)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
685 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
686 sbr->bs_invf_mode[ch][n] = (uint8_t)faad_getbits(ld, 2
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
687 DEBUGVAR(1,271,"invf_mode(): bs_invf_mode"));
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
688 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
689 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
690
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
691 static uint16_t sbr_extension(bitfile *ld, sbr_info *sbr,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
692 uint8_t bs_extension_id, uint16_t num_bits_left)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
693 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
694 switch (bs_extension_id)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
695 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
696 #ifdef PS_DEC
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
697 case EXTENSION_ID_PS:
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
698 sbr->ps_used = 1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
699 return ps_data(&(sbr->ps), ld);
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
700 #endif
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
701 #ifdef DRM_PS
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
702 case DRM_PARAMETRIC_STEREO:
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
703 sbr->ps_used = 1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
704 return drm_ps_data(&(sbr->drm_ps), ld);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
705 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
706 default:
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
707 sbr->bs_extension_data = (uint8_t)faad_getbits(ld, 6
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
708 DEBUGVAR(1,279,"sbr_single_channel_element(): bs_extension_data"));
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
709 return 6;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
710 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
711 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
712
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
713 /* table 12 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
714 static void sinusoidal_coding(bitfile *ld, sbr_info *sbr, uint8_t ch)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
715 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
716 uint8_t n;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
717
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
718 for (n = 0; n < sbr->N_high; n++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
719 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
720 sbr->bs_add_harmonic[ch][n] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
721 DEBUGVAR(1,278,"sinusoidal_coding(): bs_add_harmonic"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
722 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
723 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
724
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
725
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
726 #endif /* SBR_DEC */