Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.xiph.org/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@amazon.com>2023-07-09 11:16:16 +0300
committerJean-Marc Valin <jmvalin@amazon.com>2023-07-13 00:06:57 +0300
commitec249d25f978418907dd6023974b1980a9da669f (patch)
treea9fbae1518b414f8e60cabf182f3234e31de28df
parentfe84c3bceeb9536725d5500cb984c165f52b8b25 (diff)
Make hybrid CBR use VBR SILK
-rw-r--r--src/opus_encoder.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/opus_encoder.c b/src/opus_encoder.c
index 2701488d..081d7bf4 100644
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -1816,7 +1816,10 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_
{
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. */