shithub: opus

Download patch

ref: 468c5395b43745378a7fff480ab09d9acd5107c7
parent: 6887fb518179a53f37c223986fde6539a2845b55
author: Jean-Marc Valin <[email protected]>
date: Fri Dec 7 04:50:22 EST 2007

More code for laplace decoding (doesn't work)

--- a/libentcode/laplace.c
+++ b/libentcode/laplace.c
@@ -63,15 +63,27 @@
    ec_encode(enc, fl, fs, ft);
 }
 
-void ec_laplace_decode(ec_dec *dec, int decay)
+int ec_laplace_decode(ec_dec *dec, int decay)
 {
+   int val;
    int fl, fh, fs, ft, fm;
    ft = ec_laplace_get_total(decay);
    
    fm = ec_decode(dec, ft);
    printf ("dec: %d/%d\n", fm, ft);
-   //loop on values here to find fl, fh
-   //ec_dec_update(dec, fl, fh, ft);
+   fl = 0;
+   fs = 1<<15;
+   fh = fs;
+   while (fm >= fh)
+   {
+      fl = fh;
+      fs = (fs*decay)>>14;
+      fh += fs*2;
+      val++;
+   }
+   if (fm >= fl+fs)
+      val = -val;
+   ec_dec_update(dec, fl, fh, ft);
 }
 
 #if 0