OLD | NEW |
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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 int AudioEncoderDecoderIsacT<T>::NumChannels() const { | 112 int AudioEncoderDecoderIsacT<T>::NumChannels() const { |
113 return 1; | 113 return 1; |
114 } | 114 } |
115 | 115 |
116 template <typename T> | 116 template <typename T> |
117 size_t AudioEncoderDecoderIsacT<T>::MaxEncodedBytes() const { | 117 size_t AudioEncoderDecoderIsacT<T>::MaxEncodedBytes() const { |
118 return kSufficientEncodeBufferSizeBytes; | 118 return kSufficientEncodeBufferSizeBytes; |
119 } | 119 } |
120 | 120 |
121 template <typename T> | 121 template <typename T> |
122 int AudioEncoderDecoderIsacT<T>::Num10MsFramesInNextPacket() const { | 122 size_t AudioEncoderDecoderIsacT<T>::Num10MsFramesInNextPacket() const { |
123 CriticalSectionScoped cs(state_lock_.get()); | 123 CriticalSectionScoped cs(state_lock_.get()); |
124 const int samples_in_next_packet = T::GetNewFrameLen(isac_state_); | 124 const int samples_in_next_packet = T::GetNewFrameLen(isac_state_); |
125 return rtc::CheckedDivExact(samples_in_next_packet, | 125 return static_cast<size_t>( |
126 rtc::CheckedDivExact(SampleRateHz(), 100)); | 126 rtc::CheckedDivExact(samples_in_next_packet, |
| 127 rtc::CheckedDivExact(SampleRateHz(), 100))); |
127 } | 128 } |
128 | 129 |
129 template <typename T> | 130 template <typename T> |
130 int AudioEncoderDecoderIsacT<T>::Max10MsFramesInAPacket() const { | 131 size_t AudioEncoderDecoderIsacT<T>::Max10MsFramesInAPacket() const { |
131 return 6; // iSAC puts at most 60 ms in a packet. | 132 return 6; // iSAC puts at most 60 ms in a packet. |
132 } | 133 } |
133 | 134 |
134 template <typename T> | 135 template <typename T> |
135 int AudioEncoderDecoderIsacT<T>::GetTargetBitrate() const { | 136 int AudioEncoderDecoderIsacT<T>::GetTargetBitrate() const { |
136 return target_bitrate_bps_; | 137 return target_bitrate_bps_; |
137 } | 138 } |
138 | 139 |
139 template <typename T> | 140 template <typename T> |
140 AudioEncoder::EncodedInfo AudioEncoderDecoderIsacT<T>::EncodeInternal( | 141 AudioEncoder::EncodedInfo AudioEncoderDecoderIsacT<T>::EncodeInternal( |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 if (sample_rate_hz == 48000) | 186 if (sample_rate_hz == 48000) |
186 sample_rate_hz = 32000; | 187 sample_rate_hz = 32000; |
187 CHECK(sample_rate_hz == 16000 || sample_rate_hz == 32000) | 188 CHECK(sample_rate_hz == 16000 || sample_rate_hz == 32000) |
188 << "Unsupported sample rate " << sample_rate_hz; | 189 << "Unsupported sample rate " << sample_rate_hz; |
189 if (sample_rate_hz != decoder_sample_rate_hz_) { | 190 if (sample_rate_hz != decoder_sample_rate_hz_) { |
190 CHECK_EQ(0, T::SetDecSampRate(isac_state_, sample_rate_hz)); | 191 CHECK_EQ(0, T::SetDecSampRate(isac_state_, sample_rate_hz)); |
191 decoder_sample_rate_hz_ = sample_rate_hz; | 192 decoder_sample_rate_hz_ = sample_rate_hz; |
192 } | 193 } |
193 int16_t temp_type = 1; // Default is speech. | 194 int16_t temp_type = 1; // Default is speech. |
194 int ret = | 195 int ret = |
195 T::DecodeInternal(isac_state_, encoded, static_cast<int16_t>(encoded_len), | 196 T::DecodeInternal(isac_state_, encoded, encoded_len, decoded, &temp_type); |
196 decoded, &temp_type); | |
197 *speech_type = ConvertSpeechType(temp_type); | 197 *speech_type = ConvertSpeechType(temp_type); |
198 return ret; | 198 return ret; |
199 } | 199 } |
200 | 200 |
201 template <typename T> | 201 template <typename T> |
202 bool AudioEncoderDecoderIsacT<T>::HasDecodePlc() const { | 202 bool AudioEncoderDecoderIsacT<T>::HasDecodePlc() const { |
203 return false; | 203 return false; |
204 } | 204 } |
205 | 205 |
206 template <typename T> | 206 template <typename T> |
207 int AudioEncoderDecoderIsacT<T>::DecodePlc(int num_frames, int16_t* decoded) { | 207 size_t AudioEncoderDecoderIsacT<T>::DecodePlc(size_t num_frames, |
| 208 int16_t* decoded) { |
208 CriticalSectionScoped cs(state_lock_.get()); | 209 CriticalSectionScoped cs(state_lock_.get()); |
209 return T::DecodePlc(isac_state_, decoded, num_frames); | 210 return T::DecodePlc(isac_state_, decoded, num_frames); |
210 } | 211 } |
211 | 212 |
212 template <typename T> | 213 template <typename T> |
213 int AudioEncoderDecoderIsacT<T>::Init() { | 214 int AudioEncoderDecoderIsacT<T>::Init() { |
214 CriticalSectionScoped cs(state_lock_.get()); | 215 CriticalSectionScoped cs(state_lock_.get()); |
215 return T::DecoderInit(isac_state_); | 216 return T::DecoderInit(isac_state_); |
216 } | 217 } |
217 | 218 |
218 template <typename T> | 219 template <typename T> |
219 int AudioEncoderDecoderIsacT<T>::IncomingPacket(const uint8_t* payload, | 220 int AudioEncoderDecoderIsacT<T>::IncomingPacket(const uint8_t* payload, |
220 size_t payload_len, | 221 size_t payload_len, |
221 uint16_t rtp_sequence_number, | 222 uint16_t rtp_sequence_number, |
222 uint32_t rtp_timestamp, | 223 uint32_t rtp_timestamp, |
223 uint32_t arrival_timestamp) { | 224 uint32_t arrival_timestamp) { |
224 CriticalSectionScoped cs(state_lock_.get()); | 225 CriticalSectionScoped cs(state_lock_.get()); |
225 return T::UpdateBwEstimate( | 226 return T::UpdateBwEstimate( |
226 isac_state_, payload, static_cast<int32_t>(payload_len), | 227 isac_state_, payload, payload_len, |
227 rtp_sequence_number, rtp_timestamp, arrival_timestamp); | 228 rtp_sequence_number, rtp_timestamp, arrival_timestamp); |
228 } | 229 } |
229 | 230 |
230 template <typename T> | 231 template <typename T> |
231 int AudioEncoderDecoderIsacT<T>::ErrorCode() { | 232 int AudioEncoderDecoderIsacT<T>::ErrorCode() { |
232 CriticalSectionScoped cs(state_lock_.get()); | 233 CriticalSectionScoped cs(state_lock_.get()); |
233 return T::GetErrorCode(isac_state_); | 234 return T::GetErrorCode(isac_state_); |
234 } | 235 } |
235 | 236 |
236 } // namespace webrtc | 237 } // namespace webrtc |
237 | 238 |
238 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_AUDIO_ENCODER_ISAC_T_IMPL_H_ | 239 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_AUDIO_ENCODER_ISAC_T_IMPL_H_ |
OLD | NEW |