annotate libfaad2/sbr_syntax.c @ 11181:ac7b515a4064

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