diff options
author | Jean-Marc Valin <jmvalin@amazon.com> | 2023-07-08 01:24:51 +0300 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@amazon.com> | 2023-07-13 00:06:58 +0300 |
commit | 363275b5b32e5a71fd6528019bad0396c007fcd9 (patch) | |
tree | 15446efce15521e0798003400b42ce408dbbbf33 | |
parent | ec249d25f978418907dd6023974b1980a9da669f (diff) |
Fix DRED failure
We weren't reserving enough bytes for the DRED extension
-rw-r--r-- | src/opus_encoder.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/opus_encoder.c b/src/opus_encoder.c index 081d7bf4..09bdd07b 100644 --- a/src/opus_encoder.c +++ b/src/opus_encoder.c @@ -2209,7 +2209,8 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ int dred_chunks; int dred_bytes_left; dred_chunks = IMIN((st->dred_duration+5)/4, DRED_NUM_REDUNDANCY_FRAMES/2); - dred_bytes_left = IMIN(DRED_MAX_DATA_SIZE, max_data_bytes-ret-2); + /* Remaining space for DRED, accounting for cost the 3 extra bytes for code 3, padding length, and extension number. */ + dred_bytes_left = IMIN(DRED_MAX_DATA_SIZE, max_data_bytes-ret-3); /* Check whether we actually have something to encode. */ if (dred_chunks >= 1 && dred_bytes_left >= DRED_MIN_BYTES+2) { int dred_bytes; |