Fix internal error on DRED

Forgot to account for padding length bytes when DRED payload is large.
This commit is contained in:
Jean-Marc Valin 2024-02-06 15:48:21 -05:00
parent 562587e91b
commit 17922c2a28
No known key found for this signature in database
GPG key ID: 5E5DD9A36F9189C8

View file

@ -2395,6 +2395,8 @@ static opus_int32 opus_encode_frame_native(OpusEncoder *st, const opus_val16 *pc
if (st->use_vbr) dred_chunks = IMIN(dred_chunks, st->dred_target_chunks); if (st->use_vbr) dred_chunks = IMIN(dred_chunks, st->dred_target_chunks);
/* Remaining space for DRED, accounting for cost the 3 extra bytes for code 3, padding length, and extension number. */ /* 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); dred_bytes_left = IMIN(DRED_MAX_DATA_SIZE, max_data_bytes-ret-3);
/* Account for the extra bytes required to signal large padding length. */
dred_bytes_left -= (dred_bytes_left+1+DRED_EXPERIMENTAL_BYTES)/255;
/* Check whether we actually have something to encode. */ /* Check whether we actually have something to encode. */
if (dred_chunks >= 1 && dred_bytes_left >= DRED_MIN_BYTES+DRED_EXPERIMENTAL_BYTES) { if (dred_chunks >= 1 && dred_bytes_left >= DRED_MIN_BYTES+DRED_EXPERIMENTAL_BYTES) {
int dred_bytes; int dred_bytes;