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