shithub: opus

Download patch

ref: 356437048f0a7f34062354a846f7cebe1619f0b5
parent: c9cc6d3e346e1bbf6b3f656f314c6099586487b1
author: Jean-Marc Valin <[email protected]>
date: Wed Feb 13 07:12:16 EST 2008

scales down even further in bit-rate

--- a/libcelt/quant_bands.c
+++ b/libcelt/quant_bands.c
@@ -66,7 +66,10 @@
       //   qi = -2;
       //ec_laplace_encode(enc, qi, i==0?11192:6192);
       //ec_laplace_encode(enc, qi, 8500-i*200);
-      ec_laplace_encode(enc, qi, 6000-i*200);
+      if (ec_enc_tell(enc, 0) - bits > budget)
+         qi = -1;
+      else
+         ec_laplace_encode(enc, qi, 6000-i*200);
       q = qi*res;
       error[i] = f - qi;
       
@@ -121,7 +124,10 @@
       float res;
       float mean = (1-coef)*eMeans[i];
       res = 6.;
-      qi = ec_laplace_decode(dec, 6000-i*200);
+      if (ec_dec_tell(dec, 0) - bits > budget)
+         qi = -1;
+      else
+         qi = ec_laplace_decode(dec, 6000-i*200);
       q = qi*res;
       
       oldEBands[i] = mean+coef*oldEBands[i]+prev+q;
--- a/libcelt/testcelt.c
+++ b/libcelt/testcelt.c
@@ -67,7 +67,7 @@
    }
    
    bytes_per_packet = atoi(argv[2]);
-   if (bytes_per_packet < 15 || bytes_per_packet > 120)
+   if (bytes_per_packet < 12 || bytes_per_packet > 120)
    {
       fprintf (stderr, "bytes per packet must be between 15 and 120\n");
       return 1;