From: Fabrice Bellard Date: Sun, 16 Sep 2001 21:52:58 +0000 (+0000) Subject: fixed symetric quantization (better quality!) X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=8d67072fea31e3b97e0a527e2a94e418745ba02a;p=ffmpeg fixed symetric quantization (better quality!) Originally committed as revision 130 to svn://svn.ffmpeg.org/ffmpeg/trunk --- diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 0754c865708..d44347396b2 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -842,10 +842,12 @@ static inline int sym_quant(int c, int e, int levels) int v; if (c >= 0) { - v = (levels * (c << e)) >> 25; + v = (levels * (c << e)) >> 24; + v = (v + 1) >> 1; v = (levels >> 1) + v; } else { - v = (levels * ((-c) << e)) >> 25; + v = (levels * ((-c) << e)) >> 24; + v = (v + 1) >> 1; v = (levels >> 1) - v; } assert (v >= 0 && v < levels);