annotate libfaad2/pns.c @ 25141:fba022abe464

100l in play_tree_parser_get_line, check that there actually is a previous character before comparing it against '\r'. Fixes a possible crash on playlist file that is empty or starts with an empty line.
author reimar
date Mon, 26 Nov 2007 20:35:27 +0000
parents 59b6fa5b4201
children e83eef58b30a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1 /*
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
3 ** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
4 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
5 ** This program is free software; you can redistribute it and/or modify
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
6 ** it under the terms of the GNU General Public License as published by
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
7 ** the Free Software Foundation; either version 2 of the License, or
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
8 ** (at your option) any later version.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
9 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
10 ** This program is distributed in the hope that it will be useful,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
13 ** GNU General Public License for more details.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
14 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
15 ** You should have received a copy of the GNU General Public License
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
16 ** along with this program; if not, write to the Free Software
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
18 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
19 ** Any non-GPL usage of this software or parts of this software is strictly
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
20 ** forbidden.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
21 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
22 ** Commercial non-GPL licensing of this software is possible.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
24 **
18141
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 14727
diff changeset
25 ** $Id: pns.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 #include "pns.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
32
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
33
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
34 /* static function declarations */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
35 static void gen_rand_vector(real_t *spec, int16_t scale_factor, uint16_t size,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
36 uint8_t sub);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
37
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
38
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
39 #ifdef FIXED_POINT
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
40
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
41 #define DIV(A, B) (((int64_t)A << REAL_BITS)/B)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
42
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
43 #define step(shift) \
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
44 if ((0x40000000l >> shift) + root <= value) \
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
45 { \
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
46 value -= (0x40000000l >> shift) + root; \
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
47 root = (root >> 1) | (0x40000000l >> shift); \
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
48 } else { \
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
49 root = root >> 1; \
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
50 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
51
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
52 /* fixed point square root approximation */
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
53 /* !!!! ONLY WORKS FOR EVEN %REAL_BITS% !!!! */
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
54 real_t fp_sqrt(real_t value)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
55 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
56 real_t root = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
57
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
58 step( 0); step( 2); step( 4); step( 6);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
59 step( 8); step(10); step(12); step(14);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
60 step(16); step(18); step(20); step(22);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
61 step(24); step(26); step(28); step(30);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
62
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
63 if (root < value)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
64 ++root;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
65
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
66 root <<= (REAL_BITS/2);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
67
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
68 return root;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
69 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
70
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
71 static real_t pow2_table[] =
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
72 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
73 COEF_CONST(1.0),
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
74 COEF_CONST(1.18920711500272),
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
75 COEF_CONST(1.41421356237310),
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
76 COEF_CONST(1.68179283050743)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
77 };
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
78 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
79
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
80 /* The function gen_rand_vector(addr, size) generates a vector of length
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
81 <size> with signed random values of average energy MEAN_NRG per random
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
82 value. A suitable random number generator can be realized using one
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
83 multiplication/accumulation per random value.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
84 */
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
85 static INLINE void gen_rand_vector(real_t *spec, int16_t scale_factor, uint16_t size,
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
86 uint8_t sub)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
87 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
88 #ifndef FIXED_POINT
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
89 uint16_t i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
90 real_t energy = 0.0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
91
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
92 real_t scale = (real_t)1.0/(real_t)size;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
93
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
94 for (i = 0; i < size; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
95 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
96 real_t tmp = scale*(real_t)(int32_t)random_int();
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
97 spec[i] = tmp;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
98 energy += tmp*tmp;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
99 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
100
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
101 scale = (real_t)1.0/(real_t)sqrt(energy);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
102 scale *= (real_t)pow(2.0, 0.25 * scale_factor);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
103 for (i = 0; i < size; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
104 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
105 spec[i] *= scale;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
106 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
107 #else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
108 uint16_t i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
109 real_t energy = 0, scale;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
110 int32_t exp, frac;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
111
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
112 for (i = 0; i < size; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
113 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
114 /* this can be replaced by a 16 bit random generator!!!! */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
115 real_t tmp = (int32_t)random_int();
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
116 if (tmp < 0)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
117 tmp = -(tmp & ((1<<(REAL_BITS-1))-1));
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
118 else
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
119 tmp = (tmp & ((1<<(REAL_BITS-1))-1));
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
120
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
121 energy += MUL_R(tmp,tmp);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
122
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
123 spec[i] = tmp;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
124 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
125
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
126 energy = fp_sqrt(energy);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
127 if (energy > 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
128 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
129 scale = DIV(REAL_CONST(1),energy);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
130
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
131 exp = scale_factor >> 2;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
132 frac = scale_factor & 3;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
133
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
134 /* IMDCT pre-scaling */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
135 exp -= sub;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
136
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
137 if (exp < 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
138 scale >>= -exp;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
139 else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
140 scale <<= exp;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
141
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
142 if (frac)
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
143 scale = MUL_C(scale, pow2_table[frac]);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
144
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
145 for (i = 0; i < size; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
146 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
147 spec[i] = MUL_R(spec[i], scale);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
148 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
149 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
150 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
151 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
152
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
153 void pns_decode(ic_stream *ics_left, ic_stream *ics_right,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
154 real_t *spec_left, real_t *spec_right, uint16_t frame_len,
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
155 uint8_t channel_pair, uint8_t object_type)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
156 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
157 uint8_t g, sfb, b;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
158 uint16_t size, offs;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
159
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
160 uint8_t group = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
161 uint16_t nshort = frame_len >> 3;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
162
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
163 uint8_t sub = 0;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
164
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
165 #ifdef FIXED_POINT
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
166 /* IMDCT scaling */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
167 if (object_type == LD)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
168 {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
169 sub = 9 /*9*/;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
170 } else {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
171 if (ics_left->window_sequence == EIGHT_SHORT_SEQUENCE)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
172 sub = 7 /*7*/;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
173 else
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
174 sub = 10 /*10*/;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
175 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
176 #endif
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
177
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
178 for (g = 0; g < ics_left->num_window_groups; g++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
179 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
180 /* Do perceptual noise substitution decoding */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
181 for (b = 0; b < ics_left->window_group_length[g]; b++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
182 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
183 for (sfb = 0; sfb < ics_left->max_sfb; sfb++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
184 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
185 if (is_noise(ics_left, g, sfb))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
186 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
187 #ifdef LTP_DEC
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
188 /* Simultaneous use of LTP and PNS is not prevented in the
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
189 syntax. If both LTP, and PNS are enabled on the same
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
190 scalefactor band, PNS takes precedence, and no prediction
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
191 is applied to this band.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
192 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
193 ics_left->ltp.long_used[sfb] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
194 ics_left->ltp2.long_used[sfb] = 0;
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
195 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
196
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
197 #ifdef MAIN_DEC
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
198 /* For scalefactor bands coded using PNS the corresponding
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
199 predictors are switched to "off".
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
200 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
201 ics_left->pred.prediction_used[sfb] = 0;
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
202 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
203
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
204 offs = ics_left->swb_offset[sfb];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
205 size = ics_left->swb_offset[sfb+1] - offs;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
206
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
207 /* Generate random vector */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
208 gen_rand_vector(&spec_left[(group*nshort)+offs],
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
209 ics_left->scale_factors[g][sfb], size, sub);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
210 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
211
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
212 /* From the spec:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
213 If the same scalefactor band and group is coded by perceptual noise
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
214 substitution in both channels of a channel pair, the correlation of
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
215 the noise signal can be controlled by means of the ms_used field: While
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
216 the default noise generation process works independently for each channel
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
217 (separate generation of random vectors), the same random vector is used
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
218 for both channels if ms_used[] is set for a particular scalefactor band
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
219 and group. In this case, no M/S stereo coding is carried out (because M/S
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
220 stereo coding and noise substitution coding are mutually exclusive).
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
221 If the same scalefactor band and group is coded by perceptual noise
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
222 substitution in only one channel of a channel pair the setting of ms_used[]
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
223 is not evaluated.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
224 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
225 if (channel_pair)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
226 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
227 if (is_noise(ics_right, g, sfb))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
228 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
229 if (((ics_left->ms_mask_present == 1) &&
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
230 (ics_left->ms_used[g][sfb])) ||
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
231 (ics_left->ms_mask_present == 2))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
232 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
233 uint16_t c;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
234
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
235 offs = ics_right->swb_offset[sfb];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
236 size = ics_right->swb_offset[sfb+1] - offs;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
237
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
238 for (c = 0; c < size; c++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
239 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
240 spec_right[(group*nshort) + offs + c] =
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
241 spec_left[(group*nshort) + offs + c];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
242 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
243 } else /*if (ics_left->ms_mask_present == 0)*/ {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
244 #ifdef LTP_DEC
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
245 ics_right->ltp.long_used[sfb] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
246 ics_right->ltp2.long_used[sfb] = 0;
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
247 #endif
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
248 #ifdef MAIN_DEC
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
249 ics_right->pred.prediction_used[sfb] = 0;
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
250 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
251
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
252 offs = ics_right->swb_offset[sfb];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
253 size = ics_right->swb_offset[sfb+1] - offs;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
254
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
255 /* Generate random vector */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
256 gen_rand_vector(&spec_right[(group*nshort)+offs],
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
257 ics_right->scale_factors[g][sfb], size, sub);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
258 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
259 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
260 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
261 } /* sfb */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
262 group++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
263 } /* b */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
264 } /* g */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
265 }