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-11-21 09:13:30 +0300
committerJean-Marc Valin <jmvalin@amazon.com>2023-11-21 09:13:30 +0300
commitc066af1bf155c5157aa67f355d808be119d79fd1 (patch)
tree8a5a91624f81dd03fc998dcf607c9d8cb31bb16f
parent6f99a3382d241c83a53709ab9dd3308aa11efbb1 (diff)
Use SILK VBR when using CBR with DRED
DRED will absorb the bitrate variation
-rw-r--r--src/opus_encoder.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/opus_encoder.c b/src/opus_encoder.c
index 69197494..3ec8c5ca 100644
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -1844,7 +1844,14 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_
}
if (st->silk_mode.useCBR)
{
+ /* When we're in CBR mode, but we have non-SILK data to encode, switch SILK to VBR with cap to
+ save on complexity. Any variations will be absorbed by CELT and/or DRED and we can still
+ produce a constant bitrate without wasting bits. */
+#ifdef ENABLE_DRED
+ if (st->mode == MODE_HYBRID || dred_bitrate_bps > 0)
+#else
if (st->mode == MODE_HYBRID)
+#endif
{
/* 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);