shithub: opus

Download patch

ref: 363275b5b32e5a71fd6528019bad0396c007fcd9
parent: ec249d25f978418907dd6023974b1980a9da669f
author: Jean-Marc Valin <jmvalin@amazon.com>
date: Fri Jul 7 14:24:51 EDT 2023

Fix DRED failure

We weren't reserving enough bytes for the DRED extension

--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -2209,7 +2209,8 @@
        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;
--