comparison libfaad2/pns.c @ 13453:6d50ef45a058

Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12. patch by adland <adland123 at yahoo dot com>
author diego
date Fri, 24 Sep 2004 17:31:36 +0000
parents d81145997036
children 2ae5ab4331ca
comparison
equal deleted inserted replaced
13452:c364b7c13dd8 13453:6d50ef45a058
21 ** 21 **
22 ** Commercial non-GPL licensing of this software is possible. 22 ** Commercial non-GPL licensing of this software is possible.
23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. 23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
24 ** 24 **
25 ** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30 25 ** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
26 ** $Id: pns.c,v 1.3 2004/06/02 22:59:03 diego Exp $ 26 ** $Id: pns.c,v 1.4 2004/06/23 13:50:51 diego Exp $
27 ** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/ 27 ** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
28 **/ 28 **/
29 29
30 #include "common.h" 30 #include "common.h"
31 #include "structs.h" 31 #include "structs.h"
70 return root; 70 return root;
71 } 71 }
72 72
73 static real_t pow2_table[] = 73 static real_t pow2_table[] =
74 { 74 {
75 COEF_CONST(0.59460355750136),
76 COEF_CONST(0.70710678118655),
77 COEF_CONST(0.84089641525371),
78 COEF_CONST(1.0), 75 COEF_CONST(1.0),
79 COEF_CONST(1.18920711500272), 76 COEF_CONST(1.18920711500272),
80 COEF_CONST(1.41421356237310), 77 COEF_CONST(1.41421356237310),
81 COEF_CONST(1.68179283050743) 78 COEF_CONST(1.68179283050743)
82 }; 79 };
131 energy = fp_sqrt(energy); 128 energy = fp_sqrt(energy);
132 if (energy > 0) 129 if (energy > 0)
133 { 130 {
134 scale = DIV(REAL_CONST(1),energy); 131 scale = DIV(REAL_CONST(1),energy);
135 132
136 exp = scale_factor / 4; 133 exp = scale_factor >> 2;
137 frac = scale_factor % 4; 134 frac = scale_factor & 3;
138 135
139 /* IMDCT pre-scaling */ 136 /* IMDCT pre-scaling */
140 exp -= sub; 137 exp -= sub;
141 138
142 if (exp < 0) 139 if (exp < 0)
143 scale >>= -exp; 140 scale >>= -exp;
144 else 141 else
145 scale <<= exp; 142 scale <<= exp;
146 143
147 if (frac) 144 if (frac)
148 scale = MUL_C(scale, pow2_table[frac + 3]); 145 scale = MUL_C(scale, pow2_table[frac]);
149 146
150 for (i = 0; i < size; i++) 147 for (i = 0; i < size; i++)
151 { 148 {
152 spec[i] = MUL_R(spec[i], scale); 149 spec[i] = MUL_R(spec[i], scale);
153 } 150 }
187 { 184 {
188 for (sfb = 0; sfb < ics_left->max_sfb; sfb++) 185 for (sfb = 0; sfb < ics_left->max_sfb; sfb++)
189 { 186 {
190 if (is_noise(ics_left, g, sfb)) 187 if (is_noise(ics_left, g, sfb))
191 { 188 {
189 #ifdef LTP_DEC
192 /* Simultaneous use of LTP and PNS is not prevented in the 190 /* Simultaneous use of LTP and PNS is not prevented in the
193 syntax. If both LTP, and PNS are enabled on the same 191 syntax. If both LTP, and PNS are enabled on the same
194 scalefactor band, PNS takes precedence, and no prediction 192 scalefactor band, PNS takes precedence, and no prediction
195 is applied to this band. 193 is applied to this band.
196 */ 194 */
197 ics_left->ltp.long_used[sfb] = 0; 195 ics_left->ltp.long_used[sfb] = 0;
198 ics_left->ltp2.long_used[sfb] = 0; 196 ics_left->ltp2.long_used[sfb] = 0;
199 197 #endif
198
199 #ifdef MAIN_DEC
200 /* For scalefactor bands coded using PNS the corresponding 200 /* For scalefactor bands coded using PNS the corresponding
201 predictors are switched to "off". 201 predictors are switched to "off".
202 */ 202 */
203 ics_left->pred.prediction_used[sfb] = 0; 203 ics_left->pred.prediction_used[sfb] = 0;
204 #endif
204 205
205 offs = ics_left->swb_offset[sfb]; 206 offs = ics_left->swb_offset[sfb];
206 size = ics_left->swb_offset[sfb+1] - offs; 207 size = ics_left->swb_offset[sfb+1] - offs;
207 208
208 /* Generate random vector */ 209 /* Generate random vector */
240 { 241 {
241 spec_right[(group*nshort) + offs + c] = 242 spec_right[(group*nshort) + offs + c] =
242 spec_left[(group*nshort) + offs + c]; 243 spec_left[(group*nshort) + offs + c];
243 } 244 }
244 } else /*if (ics_left->ms_mask_present == 0)*/ { 245 } else /*if (ics_left->ms_mask_present == 0)*/ {
246 #ifdef LTP_DEC
245 ics_right->ltp.long_used[sfb] = 0; 247 ics_right->ltp.long_used[sfb] = 0;
246 ics_right->ltp2.long_used[sfb] = 0; 248 ics_right->ltp2.long_used[sfb] = 0;
249 #endif
250 #ifdef MAIN_DEC
247 ics_right->pred.prediction_used[sfb] = 0; 251 ics_right->pred.prediction_used[sfb] = 0;
252 #endif
248 253
249 offs = ics_right->swb_offset[sfb]; 254 offs = ics_right->swb_offset[sfb];
250 size = ics_right->swb_offset[sfb+1] - offs; 255 size = ics_right->swb_offset[sfb+1] - offs;
251 256
252 /* Generate random vector */ 257 /* Generate random vector */