# HG changeset patch # User kostya # Date 1222260328 0 # Node ID c15b1e83d27d415197f3c86bd365b3854d4f7636 # Parent 3551c55a7ccb9feae0e24dce91f701f4c84707af Correct wrong lower limit and condition used in APE decoder diff -r 3551c55a7ccb -r c15b1e83d27d apedec.c --- a/apedec.c Tue Sep 23 23:16:48 2008 +0000 +++ b/apedec.c Wed Sep 24 12:45:28 2008 +0000 @@ -358,11 +358,10 @@ 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++;