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

Side by Side Diff: webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc

Issue 1418423010: Pass audio to AudioEncoder::Encode() in an ArrayView (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 years, 1 month 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 size_t AudioEncoderOpus::Max10MsFramesInAPacket() const { 125 size_t AudioEncoderOpus::Max10MsFramesInAPacket() const {
126 return Num10msFramesPerPacket(); 126 return Num10msFramesPerPacket();
127 } 127 }
128 128
129 int AudioEncoderOpus::GetTargetBitrate() const { 129 int AudioEncoderOpus::GetTargetBitrate() const {
130 return config_.bitrate_bps; 130 return config_.bitrate_bps;
131 } 131 }
132 132
133 AudioEncoder::EncodedInfo AudioEncoderOpus::EncodeInternal( 133 AudioEncoder::EncodedInfo AudioEncoderOpus::EncodeInternal(
134 uint32_t rtp_timestamp, 134 uint32_t rtp_timestamp,
135 const int16_t* audio, 135 rtc::ArrayView<const int16_t> audio,
136 size_t max_encoded_bytes, 136 size_t max_encoded_bytes,
137 uint8_t* encoded) { 137 uint8_t* encoded) {
138 if (input_buffer_.empty()) 138 if (input_buffer_.empty())
139 first_timestamp_in_buffer_ = rtp_timestamp; 139 first_timestamp_in_buffer_ = rtp_timestamp;
140 input_buffer_.insert(input_buffer_.end(), audio, 140 RTC_DCHECK_EQ(static_cast<size_t>(SamplesPer10msFrame()), audio.size());
141 audio + SamplesPer10msFrame()); 141 input_buffer_.insert(input_buffer_.end(), audio.cbegin(), audio.cend());
142 if (input_buffer_.size() < 142 if (input_buffer_.size() <
143 (static_cast<size_t>(Num10msFramesPerPacket()) * SamplesPer10msFrame())) { 143 (static_cast<size_t>(Num10msFramesPerPacket()) * SamplesPer10msFrame())) {
144 return EncodedInfo(); 144 return EncodedInfo();
145 } 145 }
146 RTC_CHECK_EQ( 146 RTC_CHECK_EQ(
147 input_buffer_.size(), 147 input_buffer_.size(),
148 static_cast<size_t>(Num10msFramesPerPacket()) * SamplesPer10msFrame()); 148 static_cast<size_t>(Num10msFramesPerPacket()) * SamplesPer10msFrame());
149 int status = WebRtcOpus_Encode( 149 int status = WebRtcOpus_Encode(
150 inst_, &input_buffer_[0], 150 inst_, &input_buffer_[0],
151 rtc::CheckedDivExact(input_buffer_.size(), 151 rtc::CheckedDivExact(input_buffer_.size(),
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 RTC_CHECK_EQ(0, WebRtcOpus_DisableDtx(inst_)); 249 RTC_CHECK_EQ(0, WebRtcOpus_DisableDtx(inst_));
250 } 250 }
251 RTC_CHECK_EQ(0, 251 RTC_CHECK_EQ(0,
252 WebRtcOpus_SetPacketLossRate( 252 WebRtcOpus_SetPacketLossRate(
253 inst_, static_cast<int32_t>(packet_loss_rate_ * 100 + .5))); 253 inst_, static_cast<int32_t>(packet_loss_rate_ * 100 + .5)));
254 config_ = config; 254 config_ = config;
255 return true; 255 return true;
256 } 256 }
257 257
258 } // namespace webrtc 258 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698