Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/quite/celt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy B. Terriberry <tterribe@xiph.org>2011-01-24 23:50:30 +0300
committerJean-Marc Valin <jean-marc.valin@octasic.com>2011-01-24 23:55:02 +0300
commit68b8d72e6a252e8df691b8ef7d458e256f7b7268 (patch)
tree17a722c85669a3f87c03cebaaa613e2f32ab4ff9 /libcelt/laplace.c
parent495114b755d157f45a48bb8304d9d7f2f9f2bd91 (diff)
Fix off-by-one error in ec_laplace_encode.
di_max was counting the _number_ of code-points remaining, not the largest one that could be used.
Diffstat (limited to 'libcelt/laplace.c')
-rw-r--r--libcelt/laplace.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libcelt/laplace.c b/libcelt/laplace.c
index e43029f..1d458b9 100644
--- a/libcelt/laplace.c
+++ b/libcelt/laplace.c
@@ -75,10 +75,10 @@ void ec_laplace_encode(ec_enc *enc, int *value, int fs, int decay)
if (fs <= 0)
{
int di;
- int di_max;
- di_max = (32768-fl+LAPLACE_MINP-1)>>LAPLACE_LOG_MINP;
- di_max = (di_max-s)>>1;
- di = IMIN(val - i, di_max);
+ int ndi_max;
+ ndi_max = (32768-fl+LAPLACE_MINP-1)>>LAPLACE_LOG_MINP;
+ ndi_max = (ndi_max-s)>>1;
+ di = IMIN(val - i, ndi_max - 1);
fl += (2*di+1+s)*LAPLACE_MINP;
fs = IMIN(LAPLACE_MINP, 32768-fl);
*value = i+di+s^s;