Chromium Code Reviews| Index: webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc |
| diff --git a/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc b/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc |
| index 7ef1ce096bd80221c706962c6a0706f052f5e816..1c0e2e93af67d14962c482184cfc33b04b8feb01 100644 |
| --- a/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc |
| +++ b/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc |
| @@ -55,13 +55,14 @@ int AudioEncoderCopyRed::GetTargetBitrate() const { |
| AudioEncoder::EncodedInfo AudioEncoderCopyRed::EncodeInternal( |
| uint32_t rtp_timestamp, |
| rtc::ArrayView<const int16_t> audio, |
| - size_t max_encoded_bytes, |
| - uint8_t* encoded) { |
| + rtc::Buffer* encoded) { |
| + |
| + size_t primary_offset = encoded->size(); |
|
kwiberg-webrtc
2016/02/25 00:29:04
const
ossu
2016/02/25 10:39:51
Acknowledged.
|
| EncodedInfo info = |
| - speech_encoder_->Encode(rtp_timestamp, audio, max_encoded_bytes, encoded); |
| - RTC_CHECK_GE(max_encoded_bytes, |
| - info.encoded_bytes + secondary_info_.encoded_bytes); |
| + speech_encoder_->Encode(rtp_timestamp, audio, encoded); |
| + |
| RTC_CHECK(info.redundant.empty()) << "Cannot use nested redundant encoders."; |
| + RTC_DCHECK_EQ(encoded->size() - primary_offset, info.encoded_bytes); |
| if (info.encoded_bytes > 0) { |
| // |info| will be implicitly cast to an EncodedInfoLeaf struct, effectively |
| @@ -70,13 +71,13 @@ AudioEncoder::EncodedInfo AudioEncoderCopyRed::EncodeInternal( |
| info.redundant.push_back(info); |
| RTC_DCHECK_EQ(info.redundant.size(), 1u); |
| if (secondary_info_.encoded_bytes > 0) { |
| - memcpy(&encoded[info.encoded_bytes], secondary_encoded_.data(), |
| - secondary_info_.encoded_bytes); |
| + encoded->AppendData(secondary_encoded_); |
| info.redundant.push_back(secondary_info_); |
| RTC_DCHECK_EQ(info.redundant.size(), 2u); |
| } |
| // Save primary to secondary. |
| - secondary_encoded_.SetData(encoded, info.encoded_bytes); |
| + secondary_encoded_.SetData(encoded->data() + primary_offset, |
| + info.encoded_bytes); |
| secondary_info_ = info; |
| RTC_DCHECK_EQ(info.speech, info.redundant[0].speech); |
| } |