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-07-12 00:48:11 +0300
committerJean-Marc Valin <jmvalin@amazon.com>2023-07-13 00:06:59 +0300
commit9fdc489c359b8723902a8e440d6efa89ba929862 (patch)
treee0a1927207a3e2c32b4a3a08fb8100d14a3c08dd
parent1736ae3f5e3a2772190f72f8ad29778b20235304 (diff)
Fix a CELT encoder CBR corner case
If configuring CELT for CBR but controlling the bitrate with OPUS_SET_BITRATE rather than nbCompressedBytes, then the range coder buffer would never get resized. AFAICT this could never be triggered in Opus because CBR was also controlled by nbCompressedBytes.
-rw-r--r--celt/celt_encoder.c3
-rw-r--r--src/opus_encoder.c2
2 files changed, 4 insertions, 1 deletions
diff --git a/celt/celt_encoder.c b/celt/celt_encoder.c
index d8df7e78..219dc73f 100644
--- a/celt/celt_encoder.c
+++ b/celt/celt_encoder.c
@@ -1567,8 +1567,11 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm,
if (tell>1)
tmp += tell*mode->Fs;
if (st->bitrate!=OPUS_BITRATE_MAX)
+ {
nbCompressedBytes = IMAX(2, IMIN(nbCompressedBytes,
(tmp+4*mode->Fs)/(8*mode->Fs)-!!st->signalling));
+ ec_enc_shrink(enc, nbCompressedBytes);
+ }
effectiveBytes = nbCompressedBytes - nbFilledBytes;
}
equiv_rate = ((opus_int32)nbCompressedBytes*8*50 << (3-LM)) - (40*C+20)*((400>>LM) - 50);
diff --git a/src/opus_encoder.c b/src/opus_encoder.c
index 71d66629..8b365d21 100644
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -2129,7 +2129,7 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_
if (redundancy && celt_to_silk && st->mode==MODE_HYBRID && st->use_vbr)
{
OPUS_MOVE(data+ret, data+nb_compr_bytes, redundancy_bytes);
- nb_compr_bytes = nb_compr_bytes+redundancy_bytes;
+ nb_compr_bytes = ret+redundancy_bytes;
}
}
}