shithub: opus

Download patch

ref: ec249d25f978418907dd6023974b1980a9da669f
parent: fe84c3bceeb9536725d5500cb984c165f52b8b25
author: Jean-Marc Valin <jmvalin@amazon.com>
date: Sun Jul 9 00:16:16 EDT 2023

Make hybrid CBR use VBR SILK

--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -1816,7 +1816,10 @@
         {
            if (st->mode == MODE_HYBRID)
            {
-              st->silk_mode.maxBits = IMIN(st->silk_mode.maxBits, st->silk_mode.bitRate * frame_size / st->Fs);
+              /* Allow SILK to steal up to 25% of the remaining bits */
+              opus_int16 other_bits = IMAX(0, st->silk_mode.maxBits - st->silk_mode.bitRate * frame_size / st->Fs);
+              st->silk_mode.maxBits = IMAX(0, st->silk_mode.maxBits - other_bits*3/4);
+              st->silk_mode.useCBR = 0;
            }
         } else {
            /* Constrained VBR. */
--