Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1446)

Unified Diff: webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc

Issue 1725143003: Changed AudioEncoder::Encode to take an rtc::Buffer* instead of uint8_t* and a maximum size. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Added more fixes for override hiding in AudioEncoder implementations. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..1dde49d1ba7d3dc9cfe2c400341571ac63920e97 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) {
+
+ const size_t primary_offset = encoded->size();
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);
}

Powered by Google App Engine
This is Rietveld 408576698