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

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

Issue 1230503003: Update a ton of audio code to use size_t more correctly and in general reduce (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Resync Created 5 years, 3 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 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 int AudioEncoderIsacT<T>::NumChannels() const { 116 int AudioEncoderIsacT<T>::NumChannels() const {
117 return 1; 117 return 1;
118 } 118 }
119 119
120 template <typename T> 120 template <typename T>
121 size_t AudioEncoderIsacT<T>::MaxEncodedBytes() const { 121 size_t AudioEncoderIsacT<T>::MaxEncodedBytes() const {
122 return kSufficientEncodeBufferSizeBytes; 122 return kSufficientEncodeBufferSizeBytes;
123 } 123 }
124 124
125 template <typename T> 125 template <typename T>
126 int AudioEncoderIsacT<T>::Num10MsFramesInNextPacket() const { 126 size_t AudioEncoderIsacT<T>::Num10MsFramesInNextPacket() const {
127 const int samples_in_next_packet = T::GetNewFrameLen(isac_state_); 127 const int samples_in_next_packet = T::GetNewFrameLen(isac_state_);
128 return rtc::CheckedDivExact(samples_in_next_packet, 128 return static_cast<size_t>(
129 rtc::CheckedDivExact(SampleRateHz(), 100)); 129 rtc::CheckedDivExact(samples_in_next_packet,
130 rtc::CheckedDivExact(SampleRateHz(), 100)));
130 } 131 }
131 132
132 template <typename T> 133 template <typename T>
133 int AudioEncoderIsacT<T>::Max10MsFramesInAPacket() const { 134 size_t AudioEncoderIsacT<T>::Max10MsFramesInAPacket() const {
134 return 6; // iSAC puts at most 60 ms in a packet. 135 return 6; // iSAC puts at most 60 ms in a packet.
135 } 136 }
136 137
137 template <typename T> 138 template <typename T>
138 int AudioEncoderIsacT<T>::GetTargetBitrate() const { 139 int AudioEncoderIsacT<T>::GetTargetBitrate() const {
139 return target_bitrate_bps_; 140 return target_bitrate_bps_;
140 } 141 }
141 142
142 template <typename T> 143 template <typename T>
143 AudioEncoder::EncodedInfo AudioEncoderIsacT<T>::EncodeInternal( 144 AudioEncoder::EncodedInfo AudioEncoderIsacT<T>::EncodeInternal(
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 if (sample_rate_hz == 48000) 209 if (sample_rate_hz == 48000)
209 sample_rate_hz = 32000; 210 sample_rate_hz = 32000;
210 CHECK(sample_rate_hz == 16000 || sample_rate_hz == 32000) 211 CHECK(sample_rate_hz == 16000 || sample_rate_hz == 32000)
211 << "Unsupported sample rate " << sample_rate_hz; 212 << "Unsupported sample rate " << sample_rate_hz;
212 if (sample_rate_hz != decoder_sample_rate_hz_) { 213 if (sample_rate_hz != decoder_sample_rate_hz_) {
213 CHECK_EQ(0, T::SetDecSampRate(isac_state_, sample_rate_hz)); 214 CHECK_EQ(0, T::SetDecSampRate(isac_state_, sample_rate_hz));
214 decoder_sample_rate_hz_ = sample_rate_hz; 215 decoder_sample_rate_hz_ = sample_rate_hz;
215 } 216 }
216 int16_t temp_type = 1; // Default is speech. 217 int16_t temp_type = 1; // Default is speech.
217 int ret = 218 int ret =
218 T::DecodeInternal(isac_state_, encoded, static_cast<int16_t>(encoded_len), 219 T::DecodeInternal(isac_state_, encoded, encoded_len, decoded, &temp_type);
219 decoded, &temp_type);
220 *speech_type = ConvertSpeechType(temp_type); 220 *speech_type = ConvertSpeechType(temp_type);
221 return ret; 221 return ret;
222 } 222 }
223 223
224 template <typename T> 224 template <typename T>
225 bool AudioDecoderIsacT<T>::HasDecodePlc() const { 225 bool AudioDecoderIsacT<T>::HasDecodePlc() const {
226 return false; 226 return false;
227 } 227 }
228 228
229 template <typename T> 229 template <typename T>
230 int AudioDecoderIsacT<T>::DecodePlc(int num_frames, int16_t* decoded) { 230 size_t AudioDecoderIsacT<T>::DecodePlc(size_t num_frames, int16_t* decoded) {
231 return T::DecodePlc(isac_state_, decoded, num_frames); 231 return T::DecodePlc(isac_state_, decoded, num_frames);
232 } 232 }
233 233
234 template <typename T> 234 template <typename T>
235 int AudioDecoderIsacT<T>::Init() { 235 int AudioDecoderIsacT<T>::Init() {
236 return T::DecoderInit(isac_state_); 236 return T::DecoderInit(isac_state_);
237 } 237 }
238 238
239 template <typename T> 239 template <typename T>
240 int AudioDecoderIsacT<T>::IncomingPacket(const uint8_t* payload, 240 int AudioDecoderIsacT<T>::IncomingPacket(const uint8_t* payload,
241 size_t payload_len, 241 size_t payload_len,
242 uint16_t rtp_sequence_number, 242 uint16_t rtp_sequence_number,
243 uint32_t rtp_timestamp, 243 uint32_t rtp_timestamp,
244 uint32_t arrival_timestamp) { 244 uint32_t arrival_timestamp) {
245 int ret = T::UpdateBwEstimate( 245 int ret = T::UpdateBwEstimate(
246 isac_state_, payload, static_cast<int32_t>(payload_len), 246 isac_state_, payload, payload_len,
247 rtp_sequence_number, rtp_timestamp, arrival_timestamp); 247 rtp_sequence_number, rtp_timestamp, arrival_timestamp);
248 if (bwinfo_) { 248 if (bwinfo_) {
249 IsacBandwidthInfo bwinfo; 249 IsacBandwidthInfo bwinfo;
250 T::GetBandwidthInfo(isac_state_, &bwinfo); 250 T::GetBandwidthInfo(isac_state_, &bwinfo);
251 bwinfo_->Set(bwinfo); 251 bwinfo_->Set(bwinfo);
252 } 252 }
253 return ret; 253 return ret;
254 } 254 }
255 255
256 template <typename T> 256 template <typename T>
257 int AudioDecoderIsacT<T>::ErrorCode() { 257 int AudioDecoderIsacT<T>::ErrorCode() {
258 return T::GetErrorCode(isac_state_); 258 return T::GetErrorCode(isac_state_);
259 } 259 }
260 260
261 template <typename T> 261 template <typename T>
262 size_t AudioDecoderIsacT<T>::Channels() const { 262 size_t AudioDecoderIsacT<T>::Channels() const {
263 return 1; 263 return 1;
264 } 264 }
265 265
266 } // namespace webrtc 266 } // namespace webrtc
267 267
268 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_AUDIO_ENCODER_ISAC_T_IMPL_H_ 268 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_AUDIO_ENCODER_ISAC_T_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698