| Index: webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
|
| diff --git a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
|
| index a599e291d479b0ba3926e0d8d7e14e5dbaf5f75c..799d122fe8347eeb54ca963e8c50372f00961c6e 100644
|
| --- a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
|
| +++ b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
|
| @@ -100,16 +100,6 @@ AudioEncoderOpus::~AudioEncoderOpus() {
|
| RTC_CHECK_EQ(0, WebRtcOpus_EncoderFree(inst_));
|
| }
|
|
|
| -size_t AudioEncoderOpus::MaxEncodedBytes() const {
|
| - // Calculate the number of bytes we expect the encoder to produce,
|
| - // then multiply by two to give a wide margin for error.
|
| - const size_t bytes_per_millisecond =
|
| - static_cast<size_t>(config_.bitrate_bps / (1000 * 8) + 1);
|
| - const size_t approx_encoded_bytes =
|
| - Num10msFramesPerPacket() * 10 * bytes_per_millisecond;
|
| - return 2 * approx_encoded_bytes;
|
| -}
|
| -
|
| int AudioEncoderOpus::SampleRateHz() const {
|
| return kSampleRateHz;
|
| }
|
| @@ -198,7 +188,7 @@ AudioEncoder::EncodedInfo AudioEncoderOpus::EncodeImpl(
|
| RTC_CHECK_EQ(input_buffer_.size(),
|
| Num10msFramesPerPacket() * SamplesPer10msFrame());
|
|
|
| - const size_t max_encoded_bytes = MaxEncodedBytes();
|
| + const size_t max_encoded_bytes = SufficientOutputBufferSize();
|
| EncodedInfo info;
|
| info.encoded_bytes =
|
| encoded->AppendData(
|
| @@ -231,6 +221,16 @@ size_t AudioEncoderOpus::SamplesPer10msFrame() const {
|
| return rtc::CheckedDivExact(kSampleRateHz, 100) * config_.num_channels;
|
| }
|
|
|
| +size_t AudioEncoderOpus::SufficientOutputBufferSize() const {
|
| + // Calculate the number of bytes we expect the encoder to produce,
|
| + // then multiply by two to give a wide margin for error.
|
| + const size_t bytes_per_millisecond =
|
| + static_cast<size_t>(config_.bitrate_bps / (1000 * 8) + 1);
|
| + const size_t approx_encoded_bytes =
|
| + Num10msFramesPerPacket() * 10 * bytes_per_millisecond;
|
| + return 2 * approx_encoded_bytes;
|
| +}
|
| +
|
| // If the given config is OK, recreate the Opus encoder instance with those
|
| // settings, save the config, and return true. Otherwise, do nothing and return
|
| // false.
|
|
|