| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 |
| 11 #include "webrtc/modules/audio_coding/codecs/g711/audio_decoder_pcm.h" | 11 #include "webrtc/modules/audio_coding/codecs/g711/audio_decoder_pcm.h" |
| 12 | 12 |
| 13 #include "webrtc/modules/audio_coding/codecs/g711/g711_interface.h" | 13 #include "webrtc/modules/audio_coding/codecs/g711/g711_interface.h" |
| 14 | 14 |
| 15 namespace webrtc { | 15 namespace webrtc { |
| 16 | 16 |
| 17 void AudioDecoderPcmU::Reset() {} | 17 void AudioDecoderPcmU::Reset() {} |
| 18 | 18 |
| 19 int AudioDecoderPcmU::SampleRateHz() const { |
| 20 return 8000; |
| 21 } |
| 22 |
| 19 size_t AudioDecoderPcmU::Channels() const { | 23 size_t AudioDecoderPcmU::Channels() const { |
| 20 return num_channels_; | 24 return num_channels_; |
| 21 } | 25 } |
| 22 | 26 |
| 23 int AudioDecoderPcmU::DecodeInternal(const uint8_t* encoded, | 27 int AudioDecoderPcmU::DecodeInternal(const uint8_t* encoded, |
| 24 size_t encoded_len, | 28 size_t encoded_len, |
| 25 int sample_rate_hz, | 29 int sample_rate_hz, |
| 26 int16_t* decoded, | 30 int16_t* decoded, |
| 27 SpeechType* speech_type) { | 31 SpeechType* speech_type) { |
| 28 RTC_DCHECK_EQ(sample_rate_hz, 8000); | 32 RTC_DCHECK_EQ(SampleRateHz(), sample_rate_hz); |
| 29 int16_t temp_type = 1; // Default is speech. | 33 int16_t temp_type = 1; // Default is speech. |
| 30 size_t ret = WebRtcG711_DecodeU(encoded, encoded_len, decoded, &temp_type); | 34 size_t ret = WebRtcG711_DecodeU(encoded, encoded_len, decoded, &temp_type); |
| 31 *speech_type = ConvertSpeechType(temp_type); | 35 *speech_type = ConvertSpeechType(temp_type); |
| 32 return static_cast<int>(ret); | 36 return static_cast<int>(ret); |
| 33 } | 37 } |
| 34 | 38 |
| 35 int AudioDecoderPcmU::PacketDuration(const uint8_t* encoded, | 39 int AudioDecoderPcmU::PacketDuration(const uint8_t* encoded, |
| 36 size_t encoded_len) const { | 40 size_t encoded_len) const { |
| 37 // One encoded byte per sample per channel. | 41 // One encoded byte per sample per channel. |
| 38 return static_cast<int>(encoded_len / Channels()); | 42 return static_cast<int>(encoded_len / Channels()); |
| 39 } | 43 } |
| 40 | 44 |
| 41 void AudioDecoderPcmA::Reset() {} | 45 void AudioDecoderPcmA::Reset() {} |
| 42 | 46 |
| 47 int AudioDecoderPcmA::SampleRateHz() const { |
| 48 return 8000; |
| 49 } |
| 50 |
| 43 size_t AudioDecoderPcmA::Channels() const { | 51 size_t AudioDecoderPcmA::Channels() const { |
| 44 return num_channels_; | 52 return num_channels_; |
| 45 } | 53 } |
| 46 | 54 |
| 47 int AudioDecoderPcmA::DecodeInternal(const uint8_t* encoded, | 55 int AudioDecoderPcmA::DecodeInternal(const uint8_t* encoded, |
| 48 size_t encoded_len, | 56 size_t encoded_len, |
| 49 int sample_rate_hz, | 57 int sample_rate_hz, |
| 50 int16_t* decoded, | 58 int16_t* decoded, |
| 51 SpeechType* speech_type) { | 59 SpeechType* speech_type) { |
| 52 RTC_DCHECK_EQ(sample_rate_hz, 8000); | 60 RTC_DCHECK_EQ(SampleRateHz(), sample_rate_hz); |
| 53 int16_t temp_type = 1; // Default is speech. | 61 int16_t temp_type = 1; // Default is speech. |
| 54 size_t ret = WebRtcG711_DecodeA(encoded, encoded_len, decoded, &temp_type); | 62 size_t ret = WebRtcG711_DecodeA(encoded, encoded_len, decoded, &temp_type); |
| 55 *speech_type = ConvertSpeechType(temp_type); | 63 *speech_type = ConvertSpeechType(temp_type); |
| 56 return static_cast<int>(ret); | 64 return static_cast<int>(ret); |
| 57 } | 65 } |
| 58 | 66 |
| 59 int AudioDecoderPcmA::PacketDuration(const uint8_t* encoded, | 67 int AudioDecoderPcmA::PacketDuration(const uint8_t* encoded, |
| 60 size_t encoded_len) const { | 68 size_t encoded_len) const { |
| 61 // One encoded byte per sample per channel. | 69 // One encoded byte per sample per channel. |
| 62 return static_cast<int>(encoded_len / Channels()); | 70 return static_cast<int>(encoded_len / Channels()); |
| 63 } | 71 } |
| 64 | 72 |
| 65 } // namespace webrtc | 73 } // namespace webrtc |
| OLD | NEW |