From e774c41cab765f5d12ecfb31e5fa30df41230de0 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov <kostya.shishkov@gmail.com> Date: Wed, 24 Sep 2008 12:45:28 +0000 Subject: [PATCH] Correct wrong lower limit and condition used in APE decoder Originally committed as revision 15396 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/apedec.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c index 0489ab49dd2..82d567f4cfc 100644 --- a/libavcodec/apedec.c +++ b/libavcodec/apedec.c @@ -358,11 +358,10 @@ static inline int range_get_symbol(APEContext * ctx, static inline void update_rice(APERice *rice, int x) { + int lim = rice->k ? (1 << (rice->k + 4)) : 0; rice->ksum += ((x + 1) / 2) - ((rice->ksum + 16) >> 5); - if (rice->k == 0) - rice->k = 1; - else if (rice->ksum < (1 << (rice->k + 4))) + if (rice->ksum < lim) rice->k--; else if (rice->ksum >= (1 << (rice->k + 5))) rice->k++; -- GitLab