| 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/pcm16b/include/audio_decoder_pcm16b
.h" | 11 #include "webrtc/modules/audio_coding/codecs/pcm16b/include/audio_decoder_pcm16b
.h" |
| 12 | 12 |
| 13 #include "webrtc/base/checks.h" | 13 #include "webrtc/base/checks.h" |
| 14 #include "webrtc/modules/audio_coding/codecs/pcm16b/include/pcm16b.h" | 14 #include "webrtc/modules/audio_coding/codecs/pcm16b/include/pcm16b.h" |
| 15 | 15 |
| 16 namespace webrtc { | 16 namespace webrtc { |
| 17 | 17 |
| 18 AudioDecoderPcm16B::AudioDecoderPcm16B() {} | 18 AudioDecoderPcm16B::AudioDecoderPcm16B(size_t num_channels) |
| 19 : num_channels_(num_channels) { |
| 20 RTC_DCHECK_GE(num_channels, 1u); |
| 21 } |
| 19 | 22 |
| 20 void AudioDecoderPcm16B::Reset() {} | 23 void AudioDecoderPcm16B::Reset() {} |
| 21 | 24 |
| 22 size_t AudioDecoderPcm16B::Channels() const { | 25 size_t AudioDecoderPcm16B::Channels() const { |
| 23 return 1; | 26 return num_channels_; |
| 24 } | 27 } |
| 25 | 28 |
| 26 int AudioDecoderPcm16B::DecodeInternal(const uint8_t* encoded, | 29 int AudioDecoderPcm16B::DecodeInternal(const uint8_t* encoded, |
| 27 size_t encoded_len, | 30 size_t encoded_len, |
| 28 int sample_rate_hz, | 31 int sample_rate_hz, |
| 29 int16_t* decoded, | 32 int16_t* decoded, |
| 30 SpeechType* speech_type) { | 33 SpeechType* speech_type) { |
| 31 RTC_DCHECK(sample_rate_hz == 8000 || sample_rate_hz == 16000 || | 34 RTC_DCHECK(sample_rate_hz == 8000 || sample_rate_hz == 16000 || |
| 32 sample_rate_hz == 32000 || sample_rate_hz == 48000) | 35 sample_rate_hz == 32000 || sample_rate_hz == 48000) |
| 33 << "Unsupported sample rate " << sample_rate_hz; | 36 << "Unsupported sample rate " << sample_rate_hz; |
| 34 size_t ret = WebRtcPcm16b_Decode(encoded, encoded_len, decoded); | 37 size_t ret = WebRtcPcm16b_Decode(encoded, encoded_len, decoded); |
| 35 *speech_type = ConvertSpeechType(1); | 38 *speech_type = ConvertSpeechType(1); |
| 36 return static_cast<int>(ret); | 39 return static_cast<int>(ret); |
| 37 } | 40 } |
| 38 | 41 |
| 39 int AudioDecoderPcm16B::PacketDuration(const uint8_t* encoded, | 42 int AudioDecoderPcm16B::PacketDuration(const uint8_t* encoded, |
| 40 size_t encoded_len) const { | 43 size_t encoded_len) const { |
| 41 // Two encoded byte per sample per channel. | 44 // Two encoded byte per sample per channel. |
| 42 return static_cast<int>(encoded_len / (2 * Channels())); | 45 return static_cast<int>(encoded_len / (2 * Channels())); |
| 43 } | 46 } |
| 44 | 47 |
| 45 AudioDecoderPcm16BMultiCh::AudioDecoderPcm16BMultiCh(size_t num_channels) | |
| 46 : channels_(num_channels) { | |
| 47 RTC_DCHECK(num_channels > 0); | |
| 48 } | |
| 49 | |
| 50 size_t AudioDecoderPcm16BMultiCh::Channels() const { | |
| 51 return channels_; | |
| 52 } | |
| 53 | |
| 54 } // namespace webrtc | 48 } // namespace webrtc |
| OLD | NEW |