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-08-10 01:25:16 +0300
committerJean-Marc Valin <jmvalin@amazon.com>2023-08-10 01:25:52 +0300
commitbbe4dcc44373ec2842225022ebbda72bb40e4425 (patch)
tree48190eab9294b71e04a0524f65765deba2c6f4c5
parent0886828eed7a293f556ad45a70d8d7ab04325c9d (diff)
Don't allocate DRED bits if we don't have enough
-rw-r--r--src/opus_encoder.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/opus_encoder.c b/src/opus_encoder.c
index e8be50f4..cb03a1e5 100644
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -570,6 +570,9 @@ static opus_int32 compute_dred_bitrate(OpusEncoder *st, opus_int32 bitrate_bps,
bitrate_offset = st->silk_mode.useInBandFEC ? 18000 : 12000;
target_dred_bitrate = IMAX(0, (int)(dred_frac*(bitrate_bps-bitrate_offset)));
dred_bitrate = IMIN(target_dred_bitrate, max_dred_bitrate);
+ /* If we can't afford enough bits, don't bother with DRED at all. */
+ if (dred_bitrate <= (DRED_MIN_BYTES+DRED_EXPERIMENTAL_BYTES)*8*st->Fs/frame_size)
+ dred_bitrate = 0;
return dred_bitrate;
}
#endif