shithub: opus

Download patch

ref: 1122d299ab7427c43f6dd7f549d6d39eafe97a86
parent: b33db8f3182e847bfef28360962625a024875d5f
author: Jean-Marc Valin <[email protected]>
date: Wed Dec 12 10:16:27 EST 2012

Makes "stereo savings" less aggressive on mono or near-mono.

The max reduction now depends on intensity threshold too.

--- a/celt/celt_encoder.c
+++ b/celt/celt_encoder.c
@@ -1548,11 +1548,15 @@
      {
         int coded_stereo_bands;
         int coded_stereo_dof;
+        opus_val16 max_frac;
         coded_stereo_bands = IMIN(st->intensity, coded_bands);
         coded_stereo_dof = (eBands[coded_stereo_bands]<<LM)-coded_stereo_bands;
+        /* Maximum fraction of the bits we can save if the signal is mono. */
+        max_frac = DIV32_16(MULT16_16(QCONST16(0.8f, 15), coded_stereo_dof), coded_bins);
         /*printf("%d %d %d ", coded_stereo_dof, coded_bins, tot_boost);*/
-        target -= MIN32(target/3, SHR16(MULT16_16(st->stereo_saving,(coded_stereo_dof<<BITRES)),8));
-        target += MULT16_16_Q15(QCONST16(0.035,15),coded_stereo_dof<<BITRES);
+        target -= MIN32(MULT16_32_Q15(max_frac,target),
+                        SHR16(MULT16_16(st->stereo_saving,(coded_stereo_dof<<BITRES)),8));
+        target += MULT16_16_Q15(QCONST16(0.1f,15),coded_stereo_dof<<BITRES);
      }
      /* Limits starving of other bands when using dynalloc */
      target += tot_boost;