From 78fc664c0c339c5fa73409fca56126cc65452566 Mon Sep 17 00:00:00 2001
From: Jean-Marc Valin <jmvalin@jmvalin.ca>
Date: Tue, 31 May 2016 17:54:20 -0400
Subject: [PATCH] Boosting the high-band bitrate on transients for hybrid mode

---
 celt/celt_encoder.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/celt/celt_encoder.c b/celt/celt_encoder.c
index 544b7bc32..7c949ccba 100644
--- a/celt/celt_encoder.c
+++ b/celt/celt_encoder.c
@@ -1939,10 +1939,13 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm,
         /* Tonal frames (offset<100) need more bits than noisy (offset>100) ones. */
         if (st->silk_info.offset < 100) target += 12 << BITRES >> (3-LM);
         if (st->silk_info.offset > 100) target -= 18 << BITRES >> (3-LM);
+        /* Boosting bitrate on transients and vowels with significant temporal
+           spikes. */
+        target += MULT16_16_Q14(tf_estimate-QCONST16(.25f,14), (50<<BITRES));
         /* If we have a strong transient, let's make sure it has enough bits to code
            the first two bands, so that it can use folding rather than noise. */
         if (tf_estimate > QCONST16(.7f,14))
-           target = IMAX(base_target, 50<<BITRES);
+           target = IMAX(target, 50<<BITRES);
      }
      /* The current offset is removed from the target and the space used
         so far is added*/
-- 
GitLab