From 59d3e367a85f5faa1f8890bc69799e4d3bf2811e Mon Sep 17 00:00:00 2001 From: Fabrice Bellard Date: Tue, 21 May 2002 21:07:47 +0000 Subject: [PATCH] fixed incorrect global gain - slightly increased precision of n^(4/3) table Originally committed as revision 557 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/mpegaudiodec.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c index 9d882c6ff7..97b41ac658 100644 --- a/libavcodec/mpegaudiodec.c +++ b/libavcodec/mpegaudiodec.c @@ -279,12 +279,17 @@ static int int_pow(int i, int *exp_ptr) a = a << 1; eq--; } + /* now POW_FRAC_ONE <= a < 2 * POW_FRAC_ONE */ +#if (POW_FRAC_BITS - 1) > FRAC_BITS + a = (a + (1 << (POW_FRAC_BITS - FRAC_BITS - 1))) >> (POW_FRAC_BITS - FRAC_BITS); + /* correct overflow */ + if (a >= 2 * (1 << FRAC_BITS)) { + a = a >> 1; + eq++; + } +#endif *exp_ptr = eq; -#if POW_FRAC_BITS == FRAC_BITS return a; -#else - return (a + (1 << (POW_FRAC_BITS - FRAC_BITS - 1))) >> (POW_FRAC_BITS - FRAC_BITS); -#endif } static int decode_init(AVCodecContext * avctx) @@ -388,10 +393,6 @@ static int decode_init(AVCodecContext * avctx) for(i=1;i> 1; + e1++; + } #endif e1--; if (m != m1 || e != e1) { @@ -413,9 +416,8 @@ static int decode_init(AVCodecContext * avctx) #endif /* normalized to FRAC_BITS */ table_4_3_value[i] = m; - table_4_3_exp[i] = e - 1; + table_4_3_exp[i] = e; } - for(i=0;i<7;i++) { float f;