[FFmpeg-cvslog] g723_1: clip argument for 15-bit version of normalize_bits()
Kostya Shishkov
git at videolan.org
Thu Aug 9 01:02:23 CEST 2012
ffmpeg | branch: master | Kostya Shishkov <kostya.shishkov at gmail.com> | Tue Aug 7 19:32:20 2012 +0200| [e78e6c37efc98189c4c3d89acd3265d7a7ba6d05] | committer: Kostya Shishkov
g723_1: clip argument for 15-bit version of normalize_bits()
It expects maximum value to be 32767 but calculations in scale_vector()
which uses this function can give it ABS(-32768) which leads to wrong
result and thus clipping is needed.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e78e6c37efc98189c4c3d89acd3265d7a7ba6d05
---
libavcodec/g723_1.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/libavcodec/g723_1.c b/libavcodec/g723_1.c
index aabb03d..e917f5a 100644
--- a/libavcodec/g723_1.c
+++ b/libavcodec/g723_1.c
@@ -290,6 +290,7 @@ static int scale_vector(int16_t *vector, int length)
for (i = 0; i < length; i++)
max = FFMAX(max, FFABS(vector[i]));
+ max = FFMIN(max, 0x7FFF);
bits = normalize_bits(max, 15);
scale = (bits == 15) ? 0x7FFF : (1 << bits);
More information about the ffmpeg-cvslog
mailing list