shithub: opus

Download patch

ref: 9dff02188c03bdeabda9e6131d579e8208e769fd
parent: 9edb7b4213c583fee49c05ae815ffffc66532a0a
author: Jean-Marc Valin <[email protected]>
date: Mon Jun 15 18:40:06 EDT 2009

Minor stuff: preventing float underflow in celt_exp2(), preventing the use of
intra energy for low bitrates, and a bit of very high bitrate tuning

--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -670,15 +670,7 @@
                   freq[i] = (1./(1<<mdct_weight_shift))*freq[i];
       }
 #endif
-      /*printf ("%f\n", short_ratio);*/
-      /*if (short_ratio < 1)
-         short_ratio = 1;
-      short_ratio = 1<<(int)floor(.5+log2(short_ratio));
-      if (short_ratio>4)
-         short_ratio = 4;*/
-   }/* else if (transient_shift)
-      printf ("8\n");
-      else printf ("1\n");*/
+   }
 
    compute_band_energies(st->mode, freq, bandE);
    for (i=0;i<st->mode->nbEBands*C;i++)
@@ -689,6 +681,10 @@
       st->delayedIntra = 1;
    else
       st->delayedIntra = 0;
+   /* Don't use intra energy when we're operating at low bit-rate */
+   if (nbCompressedBytes < 20)
+      intra_ener = 0;
+
    /* Pitch analysis: we do it early to save on the peak stack space */
    /* Don't use pitch if there isn't enough data available yet, 
       or if we're using shortBlocks */
--- a/libcelt/mathops.h
+++ b/libcelt/mathops.h
@@ -144,6 +144,8 @@
       celt_uint32_t i;
    } res;
    integer = floor(x);
+   if (integer < -50)
+      return 0;
    frac = x-integer;
    /* K0 = 1, K1 = log(2), K2 = 3-4*log(2), K3 = 3*log(2) - 2 */
    res.f = 1.f + frac * (0.696147f + frac * (0.224411f + 0.079442f*frac));
--- a/libcelt/modes.c
+++ b/libcelt/modes.c
@@ -122,8 +122,8 @@
       5,  5,  5,  5,  5,  5,  5,  6,  6,  6,  8,  8, 10, 12, 12, 11, 11, 17, 12, 15, 15, 20, 18, 10,  1,
       8,  7,  7,  7,  7,  7,  8,  8,  9, 10, 11, 12, 14, 17, 18, 21, 22, 27, 29, 39, 37, 38, 40, 35,  1,
       7,  7,  7,  7,  7,  7, 10, 10, 10, 13, 14, 18, 20, 24, 28, 32, 32, 35, 38, 38, 42, 50, 59, 54, 31,
-      8,  8,  8,  8,  8,  9, 10, 12, 14, 20, 22, 25, 28, 30, 35, 42, 46, 50, 55, 60, 62, 62, 62, 62, 62,
-     12, 12, 12, 12, 12, 13, 15, 18, 22, 30, 32, 35, 40, 45, 55, 62, 66, 70, 85, 90, 92, 92, 92, 92, 92,
+      8,  8,  8,  8,  8,  9, 10, 12, 14, 20, 22, 25, 28, 30, 35, 42, 46, 50, 55, 60, 62, 62, 72, 82, 62,
+      9,  9,  9, 10, 12, 13, 15, 18, 22, 30, 32, 35, 40, 45, 55, 62, 66, 70, 85, 90, 92, 92, 92,102, 92,
    };
 #endif