annotate libfaad2/sbr_syntax.c @ 13458:0562632dc839

synced with 1.49
author paszczi
date Sat, 25 Sep 2004 10:11:16 +0000
parents 6d50ef45a058
children 2ae5ab4331ca
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
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
26 ** $Id: sbr_syntax.c,v 1.4 2004/06/23 13:50:52 diego Exp $
12625
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);
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
52 static uint8_t calc_sbr_tables(sbr_info *sbr, uint8_t start_freq, uint8_t stop_freq,
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
53 uint8_t samplerate_mode, uint8_t freq_scale,
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
54 uint8_t alter_scale, uint8_t xover_band);
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
55 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
56 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
57 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
58 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
59 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
60 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
61 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
62 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
63 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
64
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
65
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
66 static void sbr_reset(sbr_info *sbr)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
67 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
68 #if 0
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
69 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
70 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
71 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
72 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
73 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
74 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
75 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
76
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
77 /* if these are different from the previous frame: Reset = 1 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
78 if ((sbr->bs_start_freq != sbr->bs_start_freq_prev) ||
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
79 (sbr->bs_stop_freq != sbr->bs_stop_freq_prev) ||
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
80 (sbr->bs_freq_scale != sbr->bs_freq_scale_prev) ||
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
81 (sbr->bs_alter_scale != sbr->bs_alter_scale_prev))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
82 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
83 sbr->Reset = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
84 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
85 sbr->Reset = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
86 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
87
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
88 if ((sbr->bs_start_freq != sbr->bs_start_freq_prev) ||
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
89 (sbr->bs_stop_freq != sbr->bs_stop_freq_prev) ||
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
90 (sbr->bs_freq_scale != sbr->bs_freq_scale_prev) ||
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
91 (sbr->bs_alter_scale != sbr->bs_alter_scale_prev) ||
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
92 (sbr->bs_xover_band != sbr->bs_xover_band_prev) ||
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
93 (sbr->bs_noise_bands != sbr->bs_noise_bands_prev))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
94 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
95 sbr->Reset = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
96 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
97 sbr->Reset = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
98 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
99
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
100 sbr->bs_start_freq_prev = sbr->bs_start_freq;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
101 sbr->bs_stop_freq_prev = sbr->bs_stop_freq;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
102 sbr->bs_freq_scale_prev = sbr->bs_freq_scale;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
103 sbr->bs_alter_scale_prev = sbr->bs_alter_scale;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
104 sbr->bs_xover_band_prev = sbr->bs_xover_band;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
105 sbr->bs_noise_bands_prev = sbr->bs_noise_bands;
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
106 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
107
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
108 static uint8_t calc_sbr_tables(sbr_info *sbr, uint8_t start_freq, uint8_t stop_freq,
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
109 uint8_t samplerate_mode, uint8_t freq_scale,
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
110 uint8_t alter_scale, uint8_t xover_band)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
111 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
112 uint8_t result = 0;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
113 uint8_t k2;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
114
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
115 /* calculate the Master Frequency Table */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
116 sbr->k0 = qmf_start_channel(start_freq, samplerate_mode, sbr->sample_rate);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
117 k2 = qmf_stop_channel(stop_freq, sbr->sample_rate, sbr->k0);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
118
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
119 /* check k0 and k2 */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
120 if (sbr->sample_rate >= 48000)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
121 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
122 if ((k2 - sbr->k0) > 32)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
123 result += 1;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
124 } else if (sbr->sample_rate <= 32000) {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
125 if ((k2 - sbr->k0) > 48)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
126 result += 1;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
127 } else { /* (sbr->sample_rate == 44100) */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
128 if ((k2 - sbr->k0) > 45)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
129 result += 1;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
130 }
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
131
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
132 if (freq_scale == 0)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
133 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
134 result += master_frequency_table_fs0(sbr, sbr->k0, k2, alter_scale);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
135 } else {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
136 result += master_frequency_table(sbr, sbr->k0, k2, freq_scale, alter_scale);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
137 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
138 result += derived_frequency_table(sbr, xover_band, k2);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
139
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
140 result = (result > 0) ? 1 : 0;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
141
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
142 return result;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
143 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
144
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
145 /* table 2 */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
146 uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt)
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 uint8_t result = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
149 uint16_t num_align_bits = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
150 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
151
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
152 uint8_t saved_start_freq, saved_samplerate_mode;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
153 uint8_t saved_stop_freq, saved_freq_scale;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
154 uint8_t saved_alter_scale, saved_xover_band;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
155
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
156 #ifdef DRM
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
157 if (!sbr->Is_DRM_SBR)
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
158 #endif
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
159 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
160 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
161 DEBUGVAR(1,198,"sbr_bitstream(): bs_extension_type"));
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
162
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
163 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
164 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
165 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
166 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
167 }
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
168 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
169
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
170 /* save old header values, in case the new ones are corrupted */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
171 saved_start_freq = sbr->bs_start_freq;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
172 saved_samplerate_mode = sbr->bs_samplerate_mode;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
173 saved_stop_freq = sbr->bs_stop_freq;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
174 saved_freq_scale = sbr->bs_freq_scale;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
175 saved_alter_scale = sbr->bs_alter_scale;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
176 saved_xover_band = sbr->bs_xover_band;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
177
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
178 sbr->bs_header_flag = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
179 DEBUGVAR(1,200,"sbr_bitstream(): bs_header_flag"));
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
180
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
181 if (sbr->bs_header_flag)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
182 sbr_header(ld, sbr);
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
183
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
184 /* Reset? */
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
185 sbr_reset(sbr);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
186
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
187 /* first frame should have a header */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
188 //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
189 if (sbr->header_count != 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
190 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
191 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
192 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
193 uint8_t rt = calc_sbr_tables(sbr, sbr->bs_start_freq, sbr->bs_stop_freq,
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
194 sbr->bs_samplerate_mode, sbr->bs_freq_scale,
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
195 sbr->bs_alter_scale, sbr->bs_xover_band);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
196
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
197 /* if an error occured with the new header values revert to the old ones */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
198 if (rt > 0)
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
199 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
200 calc_sbr_tables(sbr, saved_start_freq, saved_stop_freq,
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
201 saved_samplerate_mode, saved_freq_scale,
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
202 saved_alter_scale, saved_xover_band);
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
203 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
204 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
205
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
206 if (result == 0)
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
207 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
208 result = sbr_data(ld, sbr);
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
209
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
210 /* sbr_data() returning an error means that there was an error in
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
211 envelope_time_border_vector().
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
212 In this case the old time border vector is saved and all the previous
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
213 data normally read after sbr_grid() is saved.
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
214 */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
215 /* to be on the safe side, calculate old sbr tables in case of error */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
216 if ((result > 0) &&
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
217 (sbr->Reset || (sbr->bs_header_flag && sbr->just_seeked)))
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
218 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
219 calc_sbr_tables(sbr, saved_start_freq, saved_stop_freq,
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
220 saved_samplerate_mode, saved_freq_scale,
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
221 saved_alter_scale, saved_xover_band);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
222 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
223
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
224 /* we should be able to safely set result to 0 now */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
225 result = 0;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
226 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
227 } else {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
228 result = 1;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
229 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
230
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
231 #ifdef DRM
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
232 if (!sbr->Is_DRM_SBR)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
233 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
234 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
235 num_sbr_bits = (uint16_t)faad_get_processed_bits(ld) - num_sbr_bits;
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
236
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
237 /* check if we read more bits then were available for sbr */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
238 if (8*cnt < num_sbr_bits)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
239 return 1;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
240
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
241 /* -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
242 num_align_bits = 8*cnt /*- 4*/ - num_sbr_bits;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
243
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
244 while (num_align_bits > 7)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
245 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
246 faad_getbits(ld, 8
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
247 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
248 num_align_bits -= 8;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
249 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
250 faad_getbits(ld, num_align_bits
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
251 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
252 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
253
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
254 return result;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
255 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
256
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
257 /* table 3 */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
258 static void sbr_header(bitfile *ld, sbr_info *sbr)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
259 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
260 uint8_t bs_header_extra_1, bs_header_extra_2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
261
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
262 sbr->header_count++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
263
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
264 sbr->bs_amp_res = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
265 DEBUGVAR(1,203,"sbr_header(): bs_amp_res"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
266
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
267 /* bs_start_freq and bs_stop_freq must define a fequency band that does
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
268 not exceed 48 channels */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
269 sbr->bs_start_freq = (uint8_t)faad_getbits(ld, 4
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
270 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
271 sbr->bs_stop_freq = (uint8_t)faad_getbits(ld, 4
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
272 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
273 sbr->bs_xover_band = (uint8_t)faad_getbits(ld, 3
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
274 DEBUGVAR(1,206,"sbr_header(): bs_xover_band"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
275 faad_getbits(ld, 2
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
276 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
277 bs_header_extra_1 = (uint8_t)faad_get1bit(ld
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
278 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
279 bs_header_extra_2 = (uint8_t)faad_get1bit(ld
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
280 DEBUGVAR(1,209,"sbr_header(): bs_header_extra_2"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
281
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
282 if (bs_header_extra_1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
283 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
284 sbr->bs_freq_scale = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
285 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
286 sbr->bs_alter_scale = (uint8_t)faad_get1bit(ld
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
287 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
288 sbr->bs_noise_bands = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
289 DEBUGVAR(1,213,"sbr_header(): bs_noise_bands"));
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
290 } else {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
291 /* Default values */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
292 sbr->bs_freq_scale = 2;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
293 sbr->bs_alter_scale = 1;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
294 sbr->bs_noise_bands = 2;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
295 }
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
296
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
297 if (bs_header_extra_2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
298 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
299 sbr->bs_limiter_bands = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
300 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
301 sbr->bs_limiter_gains = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
302 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
303 sbr->bs_interpol_freq = (uint8_t)faad_get1bit(ld
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
304 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
305 sbr->bs_smoothing_mode = (uint8_t)faad_get1bit(ld
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
306 DEBUGVAR(1,217,"sbr_header(): bs_smoothing_mode"));
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
307 } else {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
308 /* Default values */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
309 sbr->bs_limiter_bands = 2;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
310 sbr->bs_limiter_gains = 2;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
311 sbr->bs_interpol_freq = 1;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
312 sbr->bs_smoothing_mode = 1;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
313 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
314
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
315 #if 0
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
316 /* print the header to screen */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
317 printf("bs_amp_res: %d\n", sbr->bs_amp_res);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
318 printf("bs_start_freq: %d\n", sbr->bs_start_freq);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
319 printf("bs_stop_freq: %d\n", sbr->bs_stop_freq);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
320 printf("bs_xover_band: %d\n", sbr->bs_xover_band);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
321 if (bs_header_extra_1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
322 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
323 printf("bs_freq_scale: %d\n", sbr->bs_freq_scale);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
324 printf("bs_alter_scale: %d\n", sbr->bs_alter_scale);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
325 printf("bs_noise_bands: %d\n", sbr->bs_noise_bands);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
326 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
327 if (bs_header_extra_2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
328 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
329 printf("bs_limiter_bands: %d\n", sbr->bs_limiter_bands);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
330 printf("bs_limiter_gains: %d\n", sbr->bs_limiter_gains);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
331 printf("bs_interpol_freq: %d\n", sbr->bs_interpol_freq);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
332 printf("bs_smoothing_mode: %d\n", sbr->bs_smoothing_mode);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
333 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
334 printf("\n");
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
335 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
336 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
337
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
338 /* table 4 */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
339 static uint8_t sbr_data(bitfile *ld, sbr_info *sbr)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
340 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
341 uint8_t result;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
342 #if 0
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
343 sbr->bs_samplerate_mode = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
344 DEBUGVAR(1,219,"sbr_data(): bs_samplerate_mode"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
345 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
346
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
347 sbr->rate = (sbr->bs_samplerate_mode) ? 2 : 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
348
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
349 switch (sbr->id_aac)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
350 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
351 case ID_SCE:
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
352 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
353 return result;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
354 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
355 case ID_CPE:
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
356 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
357 return result;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
358 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
359 }
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
360
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
361 return 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
362 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
363
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
364 /* table 5 */
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
365 static uint8_t sbr_single_channel_element(bitfile *ld, sbr_info *sbr)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
366 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
367 uint8_t result;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
368
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
369 if (faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
370 DEBUGVAR(1,220,"sbr_single_channel_element(): bs_data_extra")))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
371 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
372 faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
373 DEBUGVAR(1,221,"sbr_single_channel_element(): bs_reserved_bits_data"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
374 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
375
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
376 #ifdef DRM
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
377 /* 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
378 if (sbr->Is_DRM_SBR)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
379 faad_get1bit(ld);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
380 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
381
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
382 if ((result = sbr_grid(ld, sbr, 0)) > 0)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
383 return result;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
384 sbr_dtdf(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
385 invf_mode(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
386 sbr_envelope(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
387 sbr_noise(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
388
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
389 #ifndef FIXED_POINT
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
390 envelope_noise_dequantisation(sbr, 0);
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
391 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
392
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
393 memset(sbr->bs_add_harmonic[0], 0, 64*sizeof(uint8_t));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
394
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
395 sbr->bs_add_harmonic_flag[0] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
396 DEBUGVAR(1,223,"sbr_single_channel_element(): bs_add_harmonic_flag[0]"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
397 if (sbr->bs_add_harmonic_flag[0])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
398 sinusoidal_coding(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
399
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
400 sbr->bs_extended_data = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
401 DEBUGVAR(1,224,"sbr_single_channel_element(): bs_extended_data[0]"));
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
402
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
403 if (sbr->bs_extended_data)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
404 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
405 uint16_t nr_bits_left;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
406 uint16_t cnt = (uint16_t)faad_getbits(ld, 4
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
407 DEBUGVAR(1,225,"sbr_single_channel_element(): bs_extension_size"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
408 if (cnt == 15)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
409 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
410 cnt += (uint16_t)faad_getbits(ld, 8
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
411 DEBUGVAR(1,226,"sbr_single_channel_element(): bs_esc_count"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
412 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
413
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
414 nr_bits_left = 8 * cnt;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
415 while (nr_bits_left > 7)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
416 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
417 uint16_t tmp_nr_bits = 0;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
418
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
419 sbr->bs_extension_id = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
420 DEBUGVAR(1,227,"sbr_single_channel_element(): bs_extension_id"));
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
421 tmp_nr_bits += 2;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
422 tmp_nr_bits += sbr_extension(ld, sbr, sbr->bs_extension_id, nr_bits_left);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
423
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
424 /* check if the data read is bigger than the number of available bits */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
425 if (tmp_nr_bits > nr_bits_left)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
426 return 1;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
427
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
428 nr_bits_left -= tmp_nr_bits;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
429 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
430
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
431 /* Corrigendum */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
432 if (nr_bits_left > 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
433 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
434 faad_getbits(ld, nr_bits_left
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
435 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
436 }
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
437 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
438
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
439 return 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
440 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
441
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
442 /* table 6 */
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
443 static uint8_t sbr_channel_pair_element(bitfile *ld, sbr_info *sbr)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
444 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
445 uint8_t n, result;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
446
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
447 if (faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
448 DEBUGVAR(1,228,"sbr_single_channel_element(): bs_data_extra")))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
449 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
450 faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
451 DEBUGVAR(1,228,"sbr_channel_pair_element(): bs_reserved_bits_data"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
452 faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
453 DEBUGVAR(1,228,"sbr_channel_pair_element(): bs_reserved_bits_data"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
454 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
455
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
456 sbr->bs_coupling = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
457 DEBUGVAR(1,228,"sbr_channel_pair_element(): bs_coupling"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
458
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
459 if (sbr->bs_coupling)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
460 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
461 if ((result = sbr_grid(ld, sbr, 0)) > 0)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
462 return result;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
463
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
464 /* need to copy some data from left to right */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
465 sbr->bs_frame_class[1] = sbr->bs_frame_class[0];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
466 sbr->L_E[1] = sbr->L_E[0];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
467 sbr->L_Q[1] = sbr->L_Q[0];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
468 sbr->bs_pointer[1] = sbr->bs_pointer[0];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
469
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
470 for (n = 0; n <= sbr->L_E[0]; n++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
471 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
472 sbr->t_E[1][n] = sbr->t_E[0][n];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
473 sbr->f[1][n] = sbr->f[0][n];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
474 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
475 for (n = 0; n <= sbr->L_Q[0]; n++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
476 sbr->t_Q[1][n] = sbr->t_Q[0][n];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
477
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
478 sbr_dtdf(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
479 sbr_dtdf(ld, sbr, 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
480 invf_mode(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
481
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
482 /* more copying */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
483 for (n = 0; n < sbr->N_Q; n++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
484 sbr->bs_invf_mode[1][n] = sbr->bs_invf_mode[0][n];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
485
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
486 sbr_envelope(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
487 sbr_noise(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
488 sbr_envelope(ld, sbr, 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
489 sbr_noise(ld, sbr, 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
490
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
491 memset(sbr->bs_add_harmonic[0], 0, 64*sizeof(uint8_t));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
492 memset(sbr->bs_add_harmonic[1], 0, 64*sizeof(uint8_t));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
493
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
494 sbr->bs_add_harmonic_flag[0] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
495 DEBUGVAR(1,231,"sbr_channel_pair_element(): bs_add_harmonic_flag[0]"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
496 if (sbr->bs_add_harmonic_flag[0])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
497 sinusoidal_coding(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
498
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
499 sbr->bs_add_harmonic_flag[1] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
500 DEBUGVAR(1,232,"sbr_channel_pair_element(): bs_add_harmonic_flag[1]"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
501 if (sbr->bs_add_harmonic_flag[1])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
502 sinusoidal_coding(ld, sbr, 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
503 } else {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
504 uint8_t saved_t_E[6] = {0}, saved_t_Q[3] = {0};
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
505 uint8_t saved_L_E = sbr->L_E[0];
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
506 uint8_t saved_L_Q = sbr->L_Q[0];
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
507 uint8_t saved_frame_class = sbr->bs_frame_class[0];
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
508
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
509 for (n = 0; n < saved_L_E; n++)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
510 saved_t_E[n] = sbr->t_E[0][n];
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
511 for (n = 0; n < saved_L_Q; n++)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
512 saved_t_Q[n] = sbr->t_Q[0][n];
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
513
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
514 if ((result = sbr_grid(ld, sbr, 0)) > 0)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
515 return result;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
516 if ((result = sbr_grid(ld, sbr, 1)) > 0)
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
517 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
518 /* restore first channel data as well */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
519 sbr->bs_frame_class[0] = saved_frame_class;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
520 sbr->L_E[0] = saved_L_E;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
521 sbr->L_Q[0] = saved_L_Q;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
522 for (n = 0; n < 6; n++)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
523 sbr->t_E[0][n] = saved_t_E[n];
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
524 for (n = 0; n < 3; n++)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
525 sbr->t_Q[0][n] = saved_t_Q[n];
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
526
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
527 return result;
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
528 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
529 sbr_dtdf(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
530 sbr_dtdf(ld, sbr, 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
531 invf_mode(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
532 invf_mode(ld, sbr, 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
533 sbr_envelope(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
534 sbr_envelope(ld, sbr, 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
535 sbr_noise(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
536 sbr_noise(ld, sbr, 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
537
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
538 memset(sbr->bs_add_harmonic[0], 0, 64*sizeof(uint8_t));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
539 memset(sbr->bs_add_harmonic[1], 0, 64*sizeof(uint8_t));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
540
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
541 sbr->bs_add_harmonic_flag[0] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
542 DEBUGVAR(1,239,"sbr_channel_pair_element(): bs_add_harmonic_flag[0]"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
543 if (sbr->bs_add_harmonic_flag[0])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
544 sinusoidal_coding(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
545
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
546 sbr->bs_add_harmonic_flag[1] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
547 DEBUGVAR(1,240,"sbr_channel_pair_element(): bs_add_harmonic_flag[1]"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
548 if (sbr->bs_add_harmonic_flag[1])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
549 sinusoidal_coding(ld, sbr, 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
550 }
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
551 #ifndef FIXED_POINT
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
552 envelope_noise_dequantisation(sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
553 envelope_noise_dequantisation(sbr, 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
554
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
555 if (sbr->bs_coupling)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
556 unmap_envelope_noise(sbr);
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
557 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
558
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
559 sbr->bs_extended_data = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
560 DEBUGVAR(1,233,"sbr_channel_pair_element(): bs_extended_data[0]"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
561 if (sbr->bs_extended_data)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
562 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
563 uint16_t nr_bits_left;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
564 uint16_t cnt = (uint16_t)faad_getbits(ld, 4
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
565 DEBUGVAR(1,234,"sbr_channel_pair_element(): bs_extension_size"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
566 if (cnt == 15)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
567 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
568 cnt += (uint16_t)faad_getbits(ld, 8
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
569 DEBUGVAR(1,235,"sbr_channel_pair_element(): bs_esc_count"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
570 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
571
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
572 nr_bits_left = 8 * cnt;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
573 while (nr_bits_left > 7)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
574 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
575 uint16_t tmp_nr_bits = 0;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
576
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
577 sbr->bs_extension_id = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
578 DEBUGVAR(1,236,"sbr_channel_pair_element(): bs_extension_id"));
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
579 tmp_nr_bits += 2;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
580 tmp_nr_bits += sbr_extension(ld, sbr, sbr->bs_extension_id, nr_bits_left);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
581
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
582 /* check if the data read is bigger than the number of available bits */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
583 if (tmp_nr_bits > nr_bits_left)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
584 return 1;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
585
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
586 nr_bits_left -= tmp_nr_bits;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
587 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
588
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
589 /* Corrigendum */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
590 if (nr_bits_left > 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
591 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
592 faad_getbits(ld, nr_bits_left
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
593 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
594 }
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
595 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
596
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
597 return 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
598 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
599
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
600 /* 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
601 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
602 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
603 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
604 if (val < 10 && val >= 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
605 return log2tab[val];
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
606 else
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
607 return 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
608 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
609
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
610
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
611 /* table 7 */
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
612 static uint8_t sbr_grid(bitfile *ld, sbr_info *sbr, uint8_t ch)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
613 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
614 uint8_t i, env, rel, result;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
615 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
616 uint8_t bs_num_env = 0;
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
617 uint8_t saved_L_E = sbr->L_E[ch];
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
618 uint8_t saved_L_Q = sbr->L_Q[ch];
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
619 uint8_t saved_frame_class = sbr->bs_frame_class[ch];
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
620
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
621 sbr->bs_frame_class[ch] = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
622 DEBUGVAR(1,248,"sbr_grid(): bs_frame_class"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
623
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
624 switch (sbr->bs_frame_class[ch])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
625 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
626 case FIXFIX:
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
627 i = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
628 DEBUGVAR(1,249,"sbr_grid(): bs_num_env_raw"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
629
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
630 bs_num_env = min(1 << i, 5);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
631
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
632 i = (uint8_t)faad_get1bit(ld
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
633 DEBUGVAR(1,250,"sbr_grid(): bs_freq_res_flag"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
634 for (env = 0; env < bs_num_env; env++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
635 sbr->f[ch][env] = i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
636
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
637 sbr->abs_bord_lead[ch] = 0;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
638 sbr->abs_bord_trail[ch] = sbr->numTimeSlots;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
639 sbr->n_rel_lead[ch] = bs_num_env - 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
640 sbr->n_rel_trail[ch] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
641 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
642
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
643 case FIXVAR:
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
644 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
645 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
646 bs_num_env = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
647 DEBUGVAR(1,252,"sbr_grid(): bs_num_env")) + 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
648
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
649 for (rel = 0; rel < bs_num_env-1; rel++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
650 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
651 sbr->bs_rel_bord[ch][rel] = 2 * (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
652 DEBUGVAR(1,253,"sbr_grid(): bs_rel_bord")) + 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
653 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
654 i = sbr_log2(bs_num_env + 1);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
655 sbr->bs_pointer[ch] = (uint8_t)faad_getbits(ld, i
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
656 DEBUGVAR(1,254,"sbr_grid(): bs_pointer"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
657
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
658 for (env = 0; env < bs_num_env; env++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
659 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
660 sbr->f[ch][bs_num_env - env - 1] = (uint8_t)faad_get1bit(ld
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
661 DEBUGVAR(1,255,"sbr_grid(): bs_freq_res"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
662 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
663
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
664 sbr->abs_bord_lead[ch] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
665 sbr->abs_bord_trail[ch] = bs_abs_bord;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
666 sbr->n_rel_lead[ch] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
667 sbr->n_rel_trail[ch] = bs_num_env - 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
668 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
669
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
670 case VARFIX:
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
671 bs_abs_bord = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
672 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
673 bs_num_env = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
674 DEBUGVAR(1,257,"sbr_grid(): bs_num_env")) + 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
675
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
676 for (rel = 0; rel < bs_num_env-1; rel++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
677 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
678 sbr->bs_rel_bord[ch][rel] = 2 * (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
679 DEBUGVAR(1,258,"sbr_grid(): bs_rel_bord")) + 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
680 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
681 i = sbr_log2(bs_num_env + 1);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
682 sbr->bs_pointer[ch] = (uint8_t)faad_getbits(ld, i
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
683 DEBUGVAR(1,259,"sbr_grid(): bs_pointer"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
684
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
685 for (env = 0; env < bs_num_env; env++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
686 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
687 sbr->f[ch][env] = (uint8_t)faad_get1bit(ld
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
688 DEBUGVAR(1,260,"sbr_grid(): bs_freq_res"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
689 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
690
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
691 sbr->abs_bord_lead[ch] = bs_abs_bord;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
692 sbr->abs_bord_trail[ch] = sbr->numTimeSlots;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
693 sbr->n_rel_lead[ch] = bs_num_env - 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
694 sbr->n_rel_trail[ch] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
695 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
696
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
697 case VARVAR:
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
698 bs_abs_bord = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
699 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
700 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
701 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
702 sbr->bs_num_rel_0[ch] = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
703 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
704 sbr->bs_num_rel_1[ch] = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
705 DEBUGVAR(1,264,"sbr_grid(): bs_num_rel_1"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
706
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
707 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
708
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
709 for (rel = 0; rel < sbr->bs_num_rel_0[ch]; rel++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
710 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
711 sbr->bs_rel_bord_0[ch][rel] = 2 * (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
712 DEBUGVAR(1,265,"sbr_grid(): bs_rel_bord")) + 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
713 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
714 for(rel = 0; rel < sbr->bs_num_rel_1[ch]; rel++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
715 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
716 sbr->bs_rel_bord_1[ch][rel] = 2 * (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
717 DEBUGVAR(1,266,"sbr_grid(): bs_rel_bord")) + 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
718 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
719 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
720 sbr->bs_pointer[ch] = (uint8_t)faad_getbits(ld, i
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
721 DEBUGVAR(1,267,"sbr_grid(): bs_pointer"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
722
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
723 for (env = 0; env < bs_num_env; env++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
724 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
725 sbr->f[ch][env] = (uint8_t)faad_get1bit(ld
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
726 DEBUGVAR(1,268,"sbr_grid(): bs_freq_res"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
727 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
728
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
729 sbr->abs_bord_lead[ch] = bs_abs_bord;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
730 sbr->abs_bord_trail[ch] = bs_abs_bord_1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
731 sbr->n_rel_lead[ch] = sbr->bs_num_rel_0[ch];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
732 sbr->n_rel_trail[ch] = sbr->bs_num_rel_1[ch];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
733 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
734 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
735
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
736 if (sbr->bs_frame_class[ch] == VARVAR)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
737 sbr->L_E[ch] = min(bs_num_env, 5);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
738 else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
739 sbr->L_E[ch] = min(bs_num_env, 4);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
740
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
741 if (sbr->L_E[ch] <= 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
742 return 1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
743
10725
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)
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
751 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
752 sbr->bs_frame_class[ch] = saved_frame_class;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
753 sbr->L_E[ch] = saved_L_E;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
754 sbr->L_Q[ch] = saved_L_Q;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
755 return result;
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
756 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
757 noise_floor_time_border_vector(sbr, ch);
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
758
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
759 #if 0
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
760 for (env = 0; env < bs_num_env; env++)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
761 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
762 printf("freq_res[ch:%d][env:%d]: %d\n", ch, env, sbr->f[ch][env]);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
763 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
764 #endif
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
765
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
766 return 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
767 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
768
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
769 /* table 8 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
770 static void sbr_dtdf(bitfile *ld, sbr_info *sbr, uint8_t ch)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
771 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
772 uint8_t i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
773
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
774 for (i = 0; i < sbr->L_E[ch]; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
775 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
776 sbr->bs_df_env[ch][i] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
777 DEBUGVAR(1,269,"sbr_dtdf(): bs_df_env"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
778 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
779
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
780 for (i = 0; i < sbr->L_Q[ch]; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
781 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
782 sbr->bs_df_noise[ch][i] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
783 DEBUGVAR(1,270,"sbr_dtdf(): bs_df_noise"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
784 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
785 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
786
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
787 /* table 9 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
788 static void invf_mode(bitfile *ld, sbr_info *sbr, uint8_t ch)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
789 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
790 uint8_t n;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
791
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
792 for (n = 0; n < sbr->N_Q; n++)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
793 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
794 sbr->bs_invf_mode[ch][n] = (uint8_t)faad_getbits(ld, 2
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
795 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
796 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
797 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
798
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
799 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
800 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
801 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
802 switch (bs_extension_id)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
803 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
804 #ifdef PS_DEC
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
805 case EXTENSION_ID_PS:
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
806 sbr->ps_used = 1;
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
807 if (!sbr->ps)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
808 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
809 sbr->ps = ps_init(get_sr_index(sbr->sample_rate));
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
810 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
811 return ps_data(sbr->ps, ld);
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
812 #endif
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
813 #ifdef DRM_PS
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
814 case DRM_PARAMETRIC_STEREO:
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
815 sbr->ps_used = 1;
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
816 if (!sbr->drm_ps)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
817 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
818 sbr->drm_ps = drm_ps_init();
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
819 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
820 return drm_ps_data(sbr->drm_ps, ld);
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
821 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
822 default:
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
823 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
824 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
825 return 6;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
826 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
827 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
828
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
829 /* table 12 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
830 static void sinusoidal_coding(bitfile *ld, sbr_info *sbr, uint8_t ch)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
831 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
832 uint8_t n;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
833
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
834 for (n = 0; n < sbr->N_high; n++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
835 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
836 sbr->bs_add_harmonic[ch][n] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
837 DEBUGVAR(1,278,"sinusoidal_coding(): bs_add_harmonic"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
838 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
839 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
840
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
841
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
842 #endif /* SBR_DEC */