Mercurial > libavcodec.hg
comparison mpegaudiodec.c @ 407:c3aebacf546e libavcodec
fixed incorrect global gain - slightly increased precision of n^(4/3) table
author | glantau |
---|---|
date | Tue, 21 May 2002 21:07:47 +0000 |
parents | 29dc52c127c6 |
children | 718a22dc121f |
comparison
equal
deleted
inserted
replaced
406:62b311619b44 | 407:c3aebacf546e |
---|---|
277 /* convert to float */ | 277 /* convert to float */ |
278 while (a < POW_FRAC_ONE) { | 278 while (a < POW_FRAC_ONE) { |
279 a = a << 1; | 279 a = a << 1; |
280 eq--; | 280 eq--; |
281 } | 281 } |
282 /* now POW_FRAC_ONE <= a < 2 * POW_FRAC_ONE */ | |
283 #if (POW_FRAC_BITS - 1) > FRAC_BITS | |
284 a = (a + (1 << (POW_FRAC_BITS - FRAC_BITS - 1))) >> (POW_FRAC_BITS - FRAC_BITS); | |
285 /* correct overflow */ | |
286 if (a >= 2 * (1 << FRAC_BITS)) { | |
287 a = a >> 1; | |
288 eq++; | |
289 } | |
290 #endif | |
282 *exp_ptr = eq; | 291 *exp_ptr = eq; |
283 #if POW_FRAC_BITS == FRAC_BITS | |
284 return a; | 292 return a; |
285 #else | |
286 return (a + (1 << (POW_FRAC_BITS - FRAC_BITS - 1))) >> (POW_FRAC_BITS - FRAC_BITS); | |
287 #endif | |
288 } | 293 } |
289 | 294 |
290 static int decode_init(AVCodecContext * avctx) | 295 static int decode_init(AVCodecContext * avctx) |
291 { | 296 { |
292 MPADecodeContext *s = avctx->priv_data; | 297 MPADecodeContext *s = avctx->priv_data; |
386 | 391 |
387 int_pow_init(); | 392 int_pow_init(); |
388 for(i=1;i<TABLE_4_3_SIZE;i++) { | 393 for(i=1;i<TABLE_4_3_SIZE;i++) { |
389 int e, m; | 394 int e, m; |
390 m = int_pow(i, &e); | 395 m = int_pow(i, &e); |
391 #if FRAC_BITS <= 15 | |
392 if ((unsigned short)m != m) | |
393 m = 65535; | |
394 #endif | |
395 #if 0 | 396 #if 0 |
396 /* test code */ | 397 /* test code */ |
397 { | 398 { |
398 double f, fm; | 399 double f, fm; |
399 int e1, m1; | 400 int e1, m1; |
400 f = pow((double)i, 4.0 / 3.0); | 401 f = pow((double)i, 4.0 / 3.0); |
401 fm = frexp(f, &e1); | 402 fm = frexp(f, &e1); |
402 m1 = FIXR(2 * fm); | 403 m1 = FIXR(2 * fm); |
403 #if FRAC_BITS <= 15 | 404 #if FRAC_BITS <= 15 |
404 if ((unsigned short)m1 != m1) | 405 if ((unsigned short)m1 != m1) { |
405 m1 = 65535; | 406 m1 = m1 >> 1; |
407 e1++; | |
408 } | |
406 #endif | 409 #endif |
407 e1--; | 410 e1--; |
408 if (m != m1 || e != e1) { | 411 if (m != m1 || e != e1) { |
409 printf("%4d: m=%x m1=%x e=%d e1=%d\n", | 412 printf("%4d: m=%x m1=%x e=%d e1=%d\n", |
410 i, m, m1, e, e1); | 413 i, m, m1, e, e1); |
411 } | 414 } |
412 } | 415 } |
413 #endif | 416 #endif |
414 /* normalized to FRAC_BITS */ | 417 /* normalized to FRAC_BITS */ |
415 table_4_3_value[i] = m; | 418 table_4_3_value[i] = m; |
416 table_4_3_exp[i] = e - 1; | 419 table_4_3_exp[i] = e; |
417 } | 420 } |
418 | |
419 | 421 |
420 for(i=0;i<7;i++) { | 422 for(i=0;i<7;i++) { |
421 float f; | 423 float f; |
422 int v; | 424 int v; |
423 if (i != 6) { | 425 if (i != 6) { |