diff options
author | Mashiat Sarker Shakkhar <shahriman_ams@yahoo.com> | 2012-02-16 02:11:17 +0600 |
---|---|---|
committer | Mashiat Sarker Shakkhar <shahriman_ams@yahoo.com> | 2012-02-16 02:39:30 +0600 |
commit | d1ea26f6407e8bf52da1e36a99c4d9bbb14fb1fb (patch) | |
tree | 78d523d7a3cb86e147fb15e5a29dbe5adf261327 /libavcodec | |
parent | 59df25effd438ed3120aacc83e74676334adf560 (diff) | |
download | ffmpeg-d1ea26f6407e8bf52da1e36a99c4d9bbb14fb1fb.tar.gz |
Do not try to read residue if ave_mean <= 1
Otherwise, we end up with with log(0) or log(1). av_ceil_log2 simply
assumes the argument is non-zero and returns wrong result when it is.
(Not that there is a proper way of returning an undefined value.)
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/wmalosslessdec.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c index 9b32e7e463..9b54abf465 100644 --- a/libavcodec/wmalosslessdec.c +++ b/libavcodec/wmalosslessdec.c @@ -715,9 +715,14 @@ static int decode_channel_residues(WmallDecodeCtx *s, int ch, int tile_size) quo += get_bits_long(&s->gb, get_bits(&s->gb, 5) + 1); ave_mean = (s->ave_sum[ch] + (1 << s->movave_scaling)) >> (s->movave_scaling + 1); - rem_bits = av_ceil_log2(ave_mean); - rem = rem_bits ? get_bits(&s->gb, rem_bits) : 0; - residue = (quo << rem_bits) + rem; + if (ave_mean <= 1) + residue = quo; + else + { + rem_bits = av_ceil_log2(ave_mean); + rem = rem_bits ? get_bits(&s->gb, rem_bits) : 0; + residue = (quo << rem_bits) + rem; + } s->ave_sum[ch] = residue + s->ave_sum[ch] - (s->ave_sum[ch] >> s->movave_scaling); |