diff options
author | Jean-Marc Valin <jmvalin@amazon.com> | 2023-12-16 21:01:20 +0300 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2024-01-22 21:59:56 +0300 |
commit | fe3a944ea19b141c45842165fe44fc05d68ba088 (patch) | |
tree | fbc20da1dd7559d5a9cae5d5f0b109bdc9511457 | |
parent | 5719c871b832bab21c4fcd61b7e0bb3e436b068c (diff) |
divide max payload too
-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 d20fb4ab..03da08e8 100644 --- a/src/opus_encoder.c +++ b/src/opus_encoder.c @@ -1611,8 +1611,9 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ frame_to_celt = to_celt && i==nb_frames-1; frame_redundancy = redundancy && (frame_to_celt || (!to_celt && i==0)); - curr_max = 3*st->bitrate_bps/(3*8*st->Fs/enc_frame_size); + curr_max = IMIN(3*st->bitrate_bps/(3*8*st->Fs/enc_frame_size), max_len_sum/nb_frames); #ifdef ENABLE_DRED + curr_max = IMIN(curr_max, (max_len_sum-3*dred_bitrate_bps/(3*8*st->Fs/frame_size))/nb_frames); if (first_frame) curr_max += 3*dred_bitrate_bps/(3*8*st->Fs/frame_size); #endif curr_max = IMIN(max_len_sum-tot_size, curr_max); |