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