annotate libfaad2/sbr_syntax.c @ 32127:24299859359f

swscale-test: move conversion from ref to source back to doTest() The source format parameters are kept in static variables and conversion from ref to source is only made when any parameter changes.
author ramiro
date Sun, 12 Sep 2010 18:14:42 +0000
parents e83eef58b30a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1 /*
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
3 ** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
29264
e83eef58b30a Remove all kind of trailing whitespaces from all MPlayer's files.
bircoph
parents: 18141
diff changeset
4 **
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
5 ** This program is free software; you can redistribute it and/or modify
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
6 ** it under the terms of the GNU General Public License as published by
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
7 ** the Free Software Foundation; either version 2 of the License, or
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
8 ** (at your option) any later version.
29264
e83eef58b30a Remove all kind of trailing whitespaces from all MPlayer's files.
bircoph
parents: 18141
diff changeset
9 **
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
10 ** This program is distributed in the hope that it will be useful,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
13 ** GNU General Public License for more details.
29264
e83eef58b30a Remove all kind of trailing whitespaces from all MPlayer's files.
bircoph
parents: 18141
diff changeset
14 **
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
15 ** You should have received a copy of the GNU General Public License
29264
e83eef58b30a Remove all kind of trailing whitespaces from all MPlayer's files.
bircoph
parents: 18141
diff changeset
16 ** along with this program; if not, write to the Free Software
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
18 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
19 ** Any non-GPL usage of this software or parts of this software is strictly
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
20 ** forbidden.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
21 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
22 ** Commercial non-GPL licensing of this software is possible.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
24 **
18141
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
25 ** $Id: sbr_syntax.c,v 1.34 2004/09/04 14:56:28 menno Exp $
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
26 **/
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
27
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
28 #include "common.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
29 #include "structs.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
30
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
31 #ifdef SBR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
32
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
33 #include "sbr_syntax.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
34 #include "syntax.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
35 #include "sbr_huff.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
36 #include "sbr_fbt.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
37 #include "sbr_tf_grid.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
38 #include "sbr_e_nf.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
39 #include "bits.h"
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
40 #ifdef PS_DEC
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
41 #include "ps_dec.h"
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
42 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
43 #ifdef DRM_PS
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
44 #include "drm_dec.h"
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
45 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
46 #include "analysis.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
47
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
48 /* static function declarations */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
49 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
50 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
51 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
52 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
53 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
54 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
55 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
56 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
57 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
58 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
59 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
60 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
61 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
62
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
63
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
64 static void sbr_reset(sbr_info *sbr)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
65 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
66 #if 0
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
67 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
68 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
69 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
70 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
71 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
72 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
73 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
74
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
75 /* if these are different from the previous frame: Reset = 1 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
76 if ((sbr->bs_start_freq != sbr->bs_start_freq_prev) ||
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
77 (sbr->bs_stop_freq != sbr->bs_stop_freq_prev) ||
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
78 (sbr->bs_freq_scale != sbr->bs_freq_scale_prev) ||
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
79 (sbr->bs_alter_scale != sbr->bs_alter_scale_prev) ||
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
80 (sbr->bs_xover_band != sbr->bs_xover_band_prev) ||
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
81 (sbr->bs_noise_bands != sbr->bs_noise_bands_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 sbr->bs_start_freq_prev = sbr->bs_start_freq;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
89 sbr->bs_stop_freq_prev = sbr->bs_stop_freq;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
90 sbr->bs_freq_scale_prev = sbr->bs_freq_scale;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
91 sbr->bs_alter_scale_prev = sbr->bs_alter_scale;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
92 sbr->bs_xover_band_prev = sbr->bs_xover_band;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
93 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
94 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
95
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
96 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
97 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
98 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
99 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
100 uint8_t result = 0;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
101 uint8_t k2;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
102
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
103 /* calculate the Master Frequency Table */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
104 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
105 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
106
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
107 /* check k0 and k2 */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
108 if (sbr->sample_rate >= 48000)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
109 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
110 if ((k2 - sbr->k0) > 32)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
111 result += 1;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
112 } 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
113 if ((k2 - sbr->k0) > 48)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
114 result += 1;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
115 } else { /* (sbr->sample_rate == 44100) */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
116 if ((k2 - sbr->k0) > 45)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
117 result += 1;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
118 }
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
119
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
120 if (freq_scale == 0)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
121 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
122 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
123 } else {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
124 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
125 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
126 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
127
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
128 result = (result > 0) ? 1 : 0;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
129
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
130 return result;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
131 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
132
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
133 /* table 2 */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
134 uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
135 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
136 uint8_t result = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
137 uint16_t num_align_bits = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
138 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
139
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
140 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
141 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
142 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
143
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
144 #ifdef DRM
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
145 if (!sbr->Is_DRM_SBR)
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
146 #endif
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
147 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
148 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
149 DEBUGVAR(1,198,"sbr_bitstream(): bs_extension_type"));
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
150
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
151 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
152 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
153 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
154 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
155 }
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
156 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
157
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
158 /* 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
159 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
160 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
161 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
162 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
163 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
164 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
165
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
166 sbr->bs_header_flag = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
167 DEBUGVAR(1,200,"sbr_bitstream(): bs_header_flag"));
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
168
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
169 if (sbr->bs_header_flag)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
170 sbr_header(ld, sbr);
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
171
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
172 /* Reset? */
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
173 sbr_reset(sbr);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
174
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
175 /* first frame should have a header */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
176 //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
177 if (sbr->header_count != 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
178 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
179 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
180 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
181 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
182 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
183 sbr->bs_alter_scale, sbr->bs_xover_band);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
184
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
185 /* 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
186 if (rt > 0)
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
187 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
188 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
189 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
190 saved_alter_scale, saved_xover_band);
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
191 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
192 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
193
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
194 if (result == 0)
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
195 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
196 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
197
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
198 /* 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
199 envelope_time_border_vector().
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
200 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
201 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
202 */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
203 /* 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
204 if ((result > 0) &&
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
205 (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
206 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
207 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
208 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
209 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
210 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
211
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
212 /* 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
213 result = 0;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
214 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
215 } else {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
216 result = 1;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
217 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
218
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
219 #ifdef DRM
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
220 if (!sbr->Is_DRM_SBR)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
221 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
222 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
223 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
224
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
225 /* 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
226 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
227 return 1;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
228
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
229 /* -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
230 num_align_bits = 8*cnt /*- 4*/ - num_sbr_bits;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
231
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
232 while (num_align_bits > 7)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
233 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
234 faad_getbits(ld, 8
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
235 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
236 num_align_bits -= 8;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
237 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
238 faad_getbits(ld, num_align_bits
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
239 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
240 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
241
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
242 return result;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
243 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
244
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
245 /* table 3 */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
246 static void sbr_header(bitfile *ld, sbr_info *sbr)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
247 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
248 uint8_t bs_header_extra_1, bs_header_extra_2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
249
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
250 sbr->header_count++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
251
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
252 sbr->bs_amp_res = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
253 DEBUGVAR(1,203,"sbr_header(): bs_amp_res"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
254
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
255 /* bs_start_freq and bs_stop_freq must define a fequency band that does
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
256 not exceed 48 channels */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
257 sbr->bs_start_freq = (uint8_t)faad_getbits(ld, 4
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
258 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
259 sbr->bs_stop_freq = (uint8_t)faad_getbits(ld, 4
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
260 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
261 sbr->bs_xover_band = (uint8_t)faad_getbits(ld, 3
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
262 DEBUGVAR(1,206,"sbr_header(): bs_xover_band"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
263 faad_getbits(ld, 2
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
264 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
265 bs_header_extra_1 = (uint8_t)faad_get1bit(ld
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
266 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
267 bs_header_extra_2 = (uint8_t)faad_get1bit(ld
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
268 DEBUGVAR(1,209,"sbr_header(): bs_header_extra_2"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
269
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
270 if (bs_header_extra_1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
271 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
272 sbr->bs_freq_scale = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
273 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
274 sbr->bs_alter_scale = (uint8_t)faad_get1bit(ld
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
275 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
276 sbr->bs_noise_bands = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
277 DEBUGVAR(1,213,"sbr_header(): bs_noise_bands"));
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
278 } else {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
279 /* Default values */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
280 sbr->bs_freq_scale = 2;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
281 sbr->bs_alter_scale = 1;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
282 sbr->bs_noise_bands = 2;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
283 }
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
284
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
285 if (bs_header_extra_2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
286 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
287 sbr->bs_limiter_bands = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
288 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
289 sbr->bs_limiter_gains = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
290 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
291 sbr->bs_interpol_freq = (uint8_t)faad_get1bit(ld
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
292 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
293 sbr->bs_smoothing_mode = (uint8_t)faad_get1bit(ld
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
294 DEBUGVAR(1,217,"sbr_header(): bs_smoothing_mode"));
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
295 } else {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
296 /* Default values */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
297 sbr->bs_limiter_bands = 2;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
298 sbr->bs_limiter_gains = 2;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
299 sbr->bs_interpol_freq = 1;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
300 sbr->bs_smoothing_mode = 1;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
301 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
302
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
303 #if 0
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
304 /* print the header to screen */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
305 printf("bs_amp_res: %d\n", sbr->bs_amp_res);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
306 printf("bs_start_freq: %d\n", sbr->bs_start_freq);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
307 printf("bs_stop_freq: %d\n", sbr->bs_stop_freq);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
308 printf("bs_xover_band: %d\n", sbr->bs_xover_band);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
309 if (bs_header_extra_1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
310 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
311 printf("bs_freq_scale: %d\n", sbr->bs_freq_scale);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
312 printf("bs_alter_scale: %d\n", sbr->bs_alter_scale);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
313 printf("bs_noise_bands: %d\n", sbr->bs_noise_bands);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
314 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
315 if (bs_header_extra_2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
316 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
317 printf("bs_limiter_bands: %d\n", sbr->bs_limiter_bands);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
318 printf("bs_limiter_gains: %d\n", sbr->bs_limiter_gains);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
319 printf("bs_interpol_freq: %d\n", sbr->bs_interpol_freq);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
320 printf("bs_smoothing_mode: %d\n", sbr->bs_smoothing_mode);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
321 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
322 printf("\n");
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
323 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
324 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
325
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
326 /* table 4 */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
327 static uint8_t sbr_data(bitfile *ld, sbr_info *sbr)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
328 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
329 uint8_t result;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
330 #if 0
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
331 sbr->bs_samplerate_mode = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
332 DEBUGVAR(1,219,"sbr_data(): bs_samplerate_mode"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
333 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
334
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
335 sbr->rate = (sbr->bs_samplerate_mode) ? 2 : 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
336
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
337 switch (sbr->id_aac)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
338 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
339 case ID_SCE:
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
340 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
341 return result;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
342 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
343 case ID_CPE:
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
344 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
345 return result;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
346 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
347 }
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
348
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
349 return 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
350 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
351
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
352 /* table 5 */
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
353 static uint8_t sbr_single_channel_element(bitfile *ld, sbr_info *sbr)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
354 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
355 uint8_t result;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
356
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
357 if (faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
358 DEBUGVAR(1,220,"sbr_single_channel_element(): bs_data_extra")))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
359 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
360 faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
361 DEBUGVAR(1,221,"sbr_single_channel_element(): bs_reserved_bits_data"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
362 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
363
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
364 #ifdef DRM
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
365 /* 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
366 if (sbr->Is_DRM_SBR)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
367 faad_get1bit(ld);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
368 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
369
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
370 if ((result = sbr_grid(ld, sbr, 0)) > 0)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
371 return result;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
372 sbr_dtdf(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
373 invf_mode(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
374 sbr_envelope(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
375 sbr_noise(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
376
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
377 #ifndef FIXED_POINT
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
378 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
379 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
380
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
381 memset(sbr->bs_add_harmonic[0], 0, 64*sizeof(uint8_t));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
382
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
383 sbr->bs_add_harmonic_flag[0] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
384 DEBUGVAR(1,223,"sbr_single_channel_element(): bs_add_harmonic_flag[0]"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
385 if (sbr->bs_add_harmonic_flag[0])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
386 sinusoidal_coding(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
387
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
388 sbr->bs_extended_data = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
389 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
390
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
391 if (sbr->bs_extended_data)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
392 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
393 uint16_t nr_bits_left;
18141
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
394 #if (defined(PS_DEC) || defined(DRM_PS))
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
395 uint8_t ps_ext_read = 0;
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
396 #endif
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
397 uint16_t cnt = (uint16_t)faad_getbits(ld, 4
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
398 DEBUGVAR(1,225,"sbr_single_channel_element(): bs_extension_size"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
399 if (cnt == 15)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
400 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
401 cnt += (uint16_t)faad_getbits(ld, 8
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
402 DEBUGVAR(1,226,"sbr_single_channel_element(): bs_esc_count"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
403 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
404
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
405 nr_bits_left = 8 * cnt;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
406 while (nr_bits_left > 7)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
407 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
408 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
409
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
410 sbr->bs_extension_id = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
411 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
412 tmp_nr_bits += 2;
18141
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
413
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
414 /* allow only 1 PS extension element per extension data */
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
415 #if (defined(PS_DEC) || defined(DRM_PS))
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
416 #if (defined(PS_DEC) && defined(DRM_PS))
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
417 if (sbr->bs_extension_id == EXTENSION_ID_PS || sbr->bs_extension_id == DRM_PARAMETRIC_STEREO)
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
418 #else
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
419 #ifdef PS_DEC
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
420 if (sbr->bs_extension_id == EXTENSION_ID_PS)
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
421 #else
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
422 #ifdef DRM_PS
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
423 if (sbr->bs_extension_id == DRM_PARAMETRIC_STEREO)
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
424 #endif
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
425 #endif
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
426 #endif
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
427 {
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
428 if (ps_ext_read == 0)
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
429 {
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
430 ps_ext_read = 1;
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
431 } else {
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
432 /* to be safe make it 3, will switch to "default"
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
433 * in sbr_extension() */
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
434 sbr->bs_extension_id = 3;
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
435 }
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
436 }
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
437 #endif
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
438
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
439 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
440
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
441 /* 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
442 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
443 return 1;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
444
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
445 nr_bits_left -= tmp_nr_bits;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
446 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
447
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
448 /* Corrigendum */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
449 if (nr_bits_left > 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
450 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
451 faad_getbits(ld, nr_bits_left
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
452 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
453 }
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
454 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
455
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
456 return 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
457 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
458
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
459 /* table 6 */
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
460 static uint8_t sbr_channel_pair_element(bitfile *ld, sbr_info *sbr)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
461 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
462 uint8_t n, result;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
463
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
464 if (faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
465 DEBUGVAR(1,228,"sbr_single_channel_element(): bs_data_extra")))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
466 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
467 faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
468 DEBUGVAR(1,228,"sbr_channel_pair_element(): bs_reserved_bits_data"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
469 faad_getbits(ld, 4
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
470 DEBUGVAR(1,228,"sbr_channel_pair_element(): bs_reserved_bits_data"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
471 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
472
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
473 sbr->bs_coupling = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
474 DEBUGVAR(1,228,"sbr_channel_pair_element(): bs_coupling"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
475
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
476 if (sbr->bs_coupling)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
477 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
478 if ((result = sbr_grid(ld, sbr, 0)) > 0)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
479 return result;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
480
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
481 /* need to copy some data from left to right */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
482 sbr->bs_frame_class[1] = sbr->bs_frame_class[0];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
483 sbr->L_E[1] = sbr->L_E[0];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
484 sbr->L_Q[1] = sbr->L_Q[0];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
485 sbr->bs_pointer[1] = sbr->bs_pointer[0];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
486
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
487 for (n = 0; n <= sbr->L_E[0]; n++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
488 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
489 sbr->t_E[1][n] = sbr->t_E[0][n];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
490 sbr->f[1][n] = sbr->f[0][n];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
491 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
492 for (n = 0; n <= sbr->L_Q[0]; n++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
493 sbr->t_Q[1][n] = sbr->t_Q[0][n];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
494
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
495 sbr_dtdf(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
496 sbr_dtdf(ld, sbr, 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
497 invf_mode(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
498
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
499 /* more copying */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
500 for (n = 0; n < sbr->N_Q; n++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
501 sbr->bs_invf_mode[1][n] = sbr->bs_invf_mode[0][n];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
502
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
503 sbr_envelope(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
504 sbr_noise(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
505 sbr_envelope(ld, sbr, 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
506 sbr_noise(ld, sbr, 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
507
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
508 memset(sbr->bs_add_harmonic[0], 0, 64*sizeof(uint8_t));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
509 memset(sbr->bs_add_harmonic[1], 0, 64*sizeof(uint8_t));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
510
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
511 sbr->bs_add_harmonic_flag[0] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
512 DEBUGVAR(1,231,"sbr_channel_pair_element(): bs_add_harmonic_flag[0]"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
513 if (sbr->bs_add_harmonic_flag[0])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
514 sinusoidal_coding(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
515
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
516 sbr->bs_add_harmonic_flag[1] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
517 DEBUGVAR(1,232,"sbr_channel_pair_element(): bs_add_harmonic_flag[1]"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
518 if (sbr->bs_add_harmonic_flag[1])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
519 sinusoidal_coding(ld, sbr, 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
520 } else {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
521 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
522 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
523 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
524 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
525
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
526 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
527 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
528 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
529 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
530
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
531 if ((result = sbr_grid(ld, sbr, 0)) > 0)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
532 return result;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
533 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
534 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
535 /* 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
536 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
537 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
538 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
539 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
540 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
541 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
542 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
543
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
544 return result;
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
545 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
546 sbr_dtdf(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
547 sbr_dtdf(ld, sbr, 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
548 invf_mode(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
549 invf_mode(ld, sbr, 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
550 sbr_envelope(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
551 sbr_envelope(ld, sbr, 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
552 sbr_noise(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
553 sbr_noise(ld, sbr, 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
554
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
555 memset(sbr->bs_add_harmonic[0], 0, 64*sizeof(uint8_t));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
556 memset(sbr->bs_add_harmonic[1], 0, 64*sizeof(uint8_t));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
557
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
558 sbr->bs_add_harmonic_flag[0] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
559 DEBUGVAR(1,239,"sbr_channel_pair_element(): bs_add_harmonic_flag[0]"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
560 if (sbr->bs_add_harmonic_flag[0])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
561 sinusoidal_coding(ld, sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
562
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
563 sbr->bs_add_harmonic_flag[1] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
564 DEBUGVAR(1,240,"sbr_channel_pair_element(): bs_add_harmonic_flag[1]"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
565 if (sbr->bs_add_harmonic_flag[1])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
566 sinusoidal_coding(ld, sbr, 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
567 }
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
568 #ifndef FIXED_POINT
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
569 envelope_noise_dequantisation(sbr, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
570 envelope_noise_dequantisation(sbr, 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
571
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
572 if (sbr->bs_coupling)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
573 unmap_envelope_noise(sbr);
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
574 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
575
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
576 sbr->bs_extended_data = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
577 DEBUGVAR(1,233,"sbr_channel_pair_element(): bs_extended_data[0]"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
578 if (sbr->bs_extended_data)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
579 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
580 uint16_t nr_bits_left;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
581 uint16_t cnt = (uint16_t)faad_getbits(ld, 4
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
582 DEBUGVAR(1,234,"sbr_channel_pair_element(): bs_extension_size"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
583 if (cnt == 15)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
584 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
585 cnt += (uint16_t)faad_getbits(ld, 8
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
586 DEBUGVAR(1,235,"sbr_channel_pair_element(): bs_esc_count"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
587 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
588
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
589 nr_bits_left = 8 * cnt;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
590 while (nr_bits_left > 7)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
591 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
592 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
593
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
594 sbr->bs_extension_id = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
595 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
596 tmp_nr_bits += 2;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
597 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
598
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
599 /* 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
600 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
601 return 1;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
602
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
603 nr_bits_left -= tmp_nr_bits;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
604 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
605
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
606 /* Corrigendum */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
607 if (nr_bits_left > 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 faad_getbits(ld, nr_bits_left
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
610 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
611 }
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
612 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
613
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
614 return 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
615 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
616
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
617 /* 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
618 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
619 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
620 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
621 if (val < 10 && val >= 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
622 return log2tab[val];
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
623 else
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
624 return 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
625 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
626
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
627
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
628 /* table 7 */
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
629 static uint8_t sbr_grid(bitfile *ld, sbr_info *sbr, uint8_t ch)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
630 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
631 uint8_t i, env, rel, result;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
632 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
633 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
634 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
635 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
636 uint8_t saved_frame_class = sbr->bs_frame_class[ch];
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
637
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
638 sbr->bs_frame_class[ch] = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
639 DEBUGVAR(1,248,"sbr_grid(): bs_frame_class"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
640
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
641 switch (sbr->bs_frame_class[ch])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
642 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
643 case FIXFIX:
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
644 i = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
645 DEBUGVAR(1,249,"sbr_grid(): bs_num_env_raw"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
646
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
647 bs_num_env = min(1 << i, 5);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
648
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
649 i = (uint8_t)faad_get1bit(ld
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
650 DEBUGVAR(1,250,"sbr_grid(): bs_freq_res_flag"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
651 for (env = 0; env < bs_num_env; env++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
652 sbr->f[ch][env] = i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
653
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
654 sbr->abs_bord_lead[ch] = 0;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
655 sbr->abs_bord_trail[ch] = sbr->numTimeSlots;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
656 sbr->n_rel_lead[ch] = bs_num_env - 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
657 sbr->n_rel_trail[ch] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
658 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
659
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
660 case FIXVAR:
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
661 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
662 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
663 bs_num_env = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
664 DEBUGVAR(1,252,"sbr_grid(): bs_num_env")) + 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
665
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
666 for (rel = 0; rel < bs_num_env-1; rel++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
667 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
668 sbr->bs_rel_bord[ch][rel] = 2 * (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
669 DEBUGVAR(1,253,"sbr_grid(): bs_rel_bord")) + 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
670 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
671 i = sbr_log2(bs_num_env + 1);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
672 sbr->bs_pointer[ch] = (uint8_t)faad_getbits(ld, i
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
673 DEBUGVAR(1,254,"sbr_grid(): bs_pointer"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
674
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
675 for (env = 0; env < bs_num_env; env++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
676 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
677 sbr->f[ch][bs_num_env - env - 1] = (uint8_t)faad_get1bit(ld
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
678 DEBUGVAR(1,255,"sbr_grid(): bs_freq_res"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
679 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
680
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
681 sbr->abs_bord_lead[ch] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
682 sbr->abs_bord_trail[ch] = bs_abs_bord;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
683 sbr->n_rel_lead[ch] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
684 sbr->n_rel_trail[ch] = bs_num_env - 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
685 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
686
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
687 case VARFIX:
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
688 bs_abs_bord = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
689 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
690 bs_num_env = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
691 DEBUGVAR(1,257,"sbr_grid(): bs_num_env")) + 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
692
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
693 for (rel = 0; rel < bs_num_env-1; rel++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
694 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
695 sbr->bs_rel_bord[ch][rel] = 2 * (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
696 DEBUGVAR(1,258,"sbr_grid(): bs_rel_bord")) + 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
697 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
698 i = sbr_log2(bs_num_env + 1);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
699 sbr->bs_pointer[ch] = (uint8_t)faad_getbits(ld, i
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
700 DEBUGVAR(1,259,"sbr_grid(): bs_pointer"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
701
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
702 for (env = 0; env < bs_num_env; env++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
703 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
704 sbr->f[ch][env] = (uint8_t)faad_get1bit(ld
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
705 DEBUGVAR(1,260,"sbr_grid(): bs_freq_res"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
706 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
707
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
708 sbr->abs_bord_lead[ch] = bs_abs_bord;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
709 sbr->abs_bord_trail[ch] = sbr->numTimeSlots;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
710 sbr->n_rel_lead[ch] = bs_num_env - 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
711 sbr->n_rel_trail[ch] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
712 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
713
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
714 case VARVAR:
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
715 bs_abs_bord = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
716 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
717 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
718 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
719 sbr->bs_num_rel_0[ch] = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
720 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
721 sbr->bs_num_rel_1[ch] = (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
722 DEBUGVAR(1,264,"sbr_grid(): bs_num_rel_1"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
723
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
724 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
725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
726 for (rel = 0; rel < sbr->bs_num_rel_0[ch]; rel++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
727 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
728 sbr->bs_rel_bord_0[ch][rel] = 2 * (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
729 DEBUGVAR(1,265,"sbr_grid(): bs_rel_bord")) + 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
730 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
731 for(rel = 0; rel < sbr->bs_num_rel_1[ch]; rel++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
732 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
733 sbr->bs_rel_bord_1[ch][rel] = 2 * (uint8_t)faad_getbits(ld, 2
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
734 DEBUGVAR(1,266,"sbr_grid(): bs_rel_bord")) + 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
735 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
736 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
737 sbr->bs_pointer[ch] = (uint8_t)faad_getbits(ld, i
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
738 DEBUGVAR(1,267,"sbr_grid(): bs_pointer"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
739
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
740 for (env = 0; env < bs_num_env; env++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
741 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
742 sbr->f[ch][env] = (uint8_t)faad_get1bit(ld
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
743 DEBUGVAR(1,268,"sbr_grid(): bs_freq_res"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
744 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
745
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
746 sbr->abs_bord_lead[ch] = bs_abs_bord;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
747 sbr->abs_bord_trail[ch] = bs_abs_bord_1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
748 sbr->n_rel_lead[ch] = sbr->bs_num_rel_0[ch];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
749 sbr->n_rel_trail[ch] = sbr->bs_num_rel_1[ch];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
750 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
751 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
752
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
753 if (sbr->bs_frame_class[ch] == VARVAR)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
754 sbr->L_E[ch] = min(bs_num_env, 5);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
755 else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
756 sbr->L_E[ch] = min(bs_num_env, 4);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
757
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
758 if (sbr->L_E[ch] <= 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
759 return 1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
760
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
761 if (sbr->L_E[ch] > 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
762 sbr->L_Q[ch] = 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
763 else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
764 sbr->L_Q[ch] = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
765
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
766 /* TODO: this code can probably be integrated into the code above! */
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
767 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
768 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
769 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
770 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
771 sbr->L_Q[ch] = saved_L_Q;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
772 return result;
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
773 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
774 noise_floor_time_border_vector(sbr, ch);
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
775
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
776 #if 0
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
777 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
778 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
779 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
780 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
781 #endif
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
782
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
783 return 0;
10725
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 /* table 8 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
787 static void sbr_dtdf(bitfile *ld, sbr_info *sbr, uint8_t ch)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
788 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
789 uint8_t i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
790
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
791 for (i = 0; i < sbr->L_E[ch]; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
792 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
793 sbr->bs_df_env[ch][i] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
794 DEBUGVAR(1,269,"sbr_dtdf(): bs_df_env"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
795 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
796
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
797 for (i = 0; i < sbr->L_Q[ch]; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
798 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
799 sbr->bs_df_noise[ch][i] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
800 DEBUGVAR(1,270,"sbr_dtdf(): bs_df_noise"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
801 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
802 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
803
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
804 /* table 9 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
805 static void invf_mode(bitfile *ld, sbr_info *sbr, uint8_t ch)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
806 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
807 uint8_t n;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
808
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
809 for (n = 0; n < sbr->N_Q; n++)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
810 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
811 sbr->bs_invf_mode[ch][n] = (uint8_t)faad_getbits(ld, 2
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
812 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
813 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
814 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
815
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
816 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
817 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
818 {
18141
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
819 #ifdef PS_DEC
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
820 uint8_t header;
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
821 uint16_t ret;
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
822 #endif
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
823
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
824 switch (bs_extension_id)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
825 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
826 #ifdef PS_DEC
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
827 case EXTENSION_ID_PS:
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
828 if (!sbr->ps)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
829 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
830 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
831 }
18141
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
832 ret = ps_data(sbr->ps, ld, &header);
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
833
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
834 /* enable PS if and only if: a header has been decoded */
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
835 if (sbr->ps_used == 0 && header == 1)
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
836 {
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
837 sbr->ps_used = 1;
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
838 }
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
839
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
840 return ret;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
841 #endif
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
842 #ifdef DRM_PS
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
843 case DRM_PARAMETRIC_STEREO:
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
844 sbr->ps_used = 1;
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
845 if (!sbr->drm_ps)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
846 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
847 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
848 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
849 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
850 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
851 default:
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
852 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
853 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
854 return 6;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
855 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
856 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
857
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
858 /* table 12 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
859 static void sinusoidal_coding(bitfile *ld, sbr_info *sbr, uint8_t ch)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
860 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
861 uint8_t n;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
862
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
863 for (n = 0; n < sbr->N_high; n++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
864 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
865 sbr->bs_add_harmonic[ch][n] = faad_get1bit(ld
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
866 DEBUGVAR(1,278,"sinusoidal_coding(): bs_add_harmonic"));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
867 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
868 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
869
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
870
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
871 #endif /* SBR_DEC */