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

Side by Side Diff: webrtc/modules/audio_coding/codecs/isac/audio_encoder_isac_t_impl.h

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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 template <typename T> 108 template <typename T>
109 int AudioEncoderIsacT<T>::GetTargetBitrate() const { 109 int AudioEncoderIsacT<T>::GetTargetBitrate() const {
110 if (config_.adaptive_mode) 110 if (config_.adaptive_mode)
111 return -1; 111 return -1;
112 return config_.bit_rate == 0 ? kDefaultBitRate : config_.bit_rate; 112 return config_.bit_rate == 0 ? kDefaultBitRate : config_.bit_rate;
113 } 113 }
114 114
115 template <typename T> 115 template <typename T>
116 AudioEncoder::EncodedInfo AudioEncoderIsacT<T>::EncodeInternal( 116 AudioEncoder::EncodedInfo AudioEncoderIsacT<T>::EncodeInternal(
117 uint32_t rtp_timestamp, 117 uint32_t rtp_timestamp,
118 const int16_t* audio, 118 rtc::ArrayView<const int16_t> audio,
119 size_t max_encoded_bytes, 119 size_t max_encoded_bytes,
120 uint8_t* encoded) { 120 uint8_t* encoded) {
121 if (!packet_in_progress_) { 121 if (!packet_in_progress_) {
122 // Starting a new packet; remember the timestamp for later. 122 // Starting a new packet; remember the timestamp for later.
123 packet_in_progress_ = true; 123 packet_in_progress_ = true;
124 packet_timestamp_ = rtp_timestamp; 124 packet_timestamp_ = rtp_timestamp;
125 } 125 }
126 if (bwinfo_) { 126 if (bwinfo_) {
127 IsacBandwidthInfo bwinfo = bwinfo_->Get(); 127 IsacBandwidthInfo bwinfo = bwinfo_->Get();
128 T::SetBandwidthInfo(isac_state_, &bwinfo); 128 T::SetBandwidthInfo(isac_state_, &bwinfo);
129 } 129 }
130 int r = T::Encode(isac_state_, audio, encoded); 130 int r = T::Encode(isac_state_, audio.data(), encoded);
131 RTC_CHECK_GE(r, 0) << "Encode failed (error code " 131 RTC_CHECK_GE(r, 0) << "Encode failed (error code "
132 << T::GetErrorCode(isac_state_) << ")"; 132 << T::GetErrorCode(isac_state_) << ")";
133 133
134 // T::Encode doesn't allow us to tell it the size of the output 134 // T::Encode doesn't allow us to tell it the size of the output
135 // buffer. All we can do is check for an overrun after the fact. 135 // buffer. All we can do is check for an overrun after the fact.
136 RTC_CHECK_LE(static_cast<size_t>(r), max_encoded_bytes); 136 RTC_CHECK_LE(static_cast<size_t>(r), max_encoded_bytes);
137 137
138 if (r == 0) 138 if (r == 0)
139 return EncodedInfo(); 139 return EncodedInfo();
140 140
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 // we get an encoding that isn't bit-for-bit identical with what a combined 181 // we get an encoding that isn't bit-for-bit identical with what a combined
182 // encoder+decoder object produces. 182 // encoder+decoder object produces.
183 RTC_CHECK_EQ(0, T::SetDecSampRate(isac_state_, config.sample_rate_hz)); 183 RTC_CHECK_EQ(0, T::SetDecSampRate(isac_state_, config.sample_rate_hz));
184 184
185 config_ = config; 185 config_ = config;
186 } 186 }
187 187
188 } // namespace webrtc 188 } // namespace webrtc
189 189
190 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_AUDIO_ENCODER_ISAC_T_IMPL_H_ 190 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_AUDIO_ENCODER_ISAC_T_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698