summaryrefslogtreecommitdiff
path: root/libavcodec/g723_1.c
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2012-08-07 19:32:20 +0200
committerKostya Shishkov <kostya.shishkov@gmail.com>2012-08-08 13:24:19 +0200
commite78e6c37efc98189c4c3d89acd3265d7a7ba6d05 (patch)
treec2fc21b7182765edbbdef4b30f219ddd40bfa428 /libavcodec/g723_1.c
parentf86b2f36612debf10a07300acadba08f7b092bcb (diff)
downloadffmpeg-e78e6c37efc98189c4c3d89acd3265d7a7ba6d05.tar.gz
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.
Diffstat (limited to 'libavcodec/g723_1.c')
-rw-r--r--libavcodec/g723_1.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/libavcodec/g723_1.c b/libavcodec/g723_1.c
index aabb03d447..e917f5a50c 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);