OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 30 matching lines...) Expand all Loading... |
41 } | 41 } |
42 size_t AudioDecoderPcmU::Channels() const { | 42 size_t AudioDecoderPcmU::Channels() const { |
43 return 1; | 43 return 1; |
44 } | 44 } |
45 | 45 |
46 int AudioDecoderPcmU::DecodeInternal(const uint8_t* encoded, | 46 int AudioDecoderPcmU::DecodeInternal(const uint8_t* encoded, |
47 size_t encoded_len, | 47 size_t encoded_len, |
48 int sample_rate_hz, | 48 int sample_rate_hz, |
49 int16_t* decoded, | 49 int16_t* decoded, |
50 SpeechType* speech_type) { | 50 SpeechType* speech_type) { |
51 DCHECK_EQ(sample_rate_hz, 8000); | 51 RTC_DCHECK_EQ(sample_rate_hz, 8000); |
52 int16_t temp_type = 1; // Default is speech. | 52 int16_t temp_type = 1; // Default is speech. |
53 size_t ret = WebRtcG711_DecodeU(encoded, encoded_len, decoded, &temp_type); | 53 size_t ret = WebRtcG711_DecodeU(encoded, encoded_len, decoded, &temp_type); |
54 *speech_type = ConvertSpeechType(temp_type); | 54 *speech_type = ConvertSpeechType(temp_type); |
55 return static_cast<int>(ret); | 55 return static_cast<int>(ret); |
56 } | 56 } |
57 | 57 |
58 int AudioDecoderPcmU::PacketDuration(const uint8_t* encoded, | 58 int AudioDecoderPcmU::PacketDuration(const uint8_t* encoded, |
59 size_t encoded_len) const { | 59 size_t encoded_len) const { |
60 // One encoded byte per sample per channel. | 60 // One encoded byte per sample per channel. |
61 return static_cast<int>(encoded_len / Channels()); | 61 return static_cast<int>(encoded_len / Channels()); |
62 } | 62 } |
63 | 63 |
64 size_t AudioDecoderPcmUMultiCh::Channels() const { | 64 size_t AudioDecoderPcmUMultiCh::Channels() const { |
65 return channels_; | 65 return channels_; |
66 } | 66 } |
67 | 67 |
68 // PCMa | 68 // PCMa |
69 | 69 |
70 void AudioDecoderPcmA::Reset() { | 70 void AudioDecoderPcmA::Reset() { |
71 } | 71 } |
72 size_t AudioDecoderPcmA::Channels() const { | 72 size_t AudioDecoderPcmA::Channels() const { |
73 return 1; | 73 return 1; |
74 } | 74 } |
75 | 75 |
76 int AudioDecoderPcmA::DecodeInternal(const uint8_t* encoded, | 76 int AudioDecoderPcmA::DecodeInternal(const uint8_t* encoded, |
77 size_t encoded_len, | 77 size_t encoded_len, |
78 int sample_rate_hz, | 78 int sample_rate_hz, |
79 int16_t* decoded, | 79 int16_t* decoded, |
80 SpeechType* speech_type) { | 80 SpeechType* speech_type) { |
81 DCHECK_EQ(sample_rate_hz, 8000); | 81 RTC_DCHECK_EQ(sample_rate_hz, 8000); |
82 int16_t temp_type = 1; // Default is speech. | 82 int16_t temp_type = 1; // Default is speech. |
83 size_t ret = WebRtcG711_DecodeA(encoded, encoded_len, decoded, &temp_type); | 83 size_t ret = WebRtcG711_DecodeA(encoded, encoded_len, decoded, &temp_type); |
84 *speech_type = ConvertSpeechType(temp_type); | 84 *speech_type = ConvertSpeechType(temp_type); |
85 return static_cast<int>(ret); | 85 return static_cast<int>(ret); |
86 } | 86 } |
87 | 87 |
88 int AudioDecoderPcmA::PacketDuration(const uint8_t* encoded, | 88 int AudioDecoderPcmA::PacketDuration(const uint8_t* encoded, |
89 size_t encoded_len) const { | 89 size_t encoded_len) const { |
90 // One encoded byte per sample per channel. | 90 // One encoded byte per sample per channel. |
91 return static_cast<int>(encoded_len / Channels()); | 91 return static_cast<int>(encoded_len / Channels()); |
(...skipping 16 matching lines...) Expand all Loading... |
108 | 108 |
109 bool AudioDecoderG722::HasDecodePlc() const { | 109 bool AudioDecoderG722::HasDecodePlc() const { |
110 return false; | 110 return false; |
111 } | 111 } |
112 | 112 |
113 int AudioDecoderG722::DecodeInternal(const uint8_t* encoded, | 113 int AudioDecoderG722::DecodeInternal(const uint8_t* encoded, |
114 size_t encoded_len, | 114 size_t encoded_len, |
115 int sample_rate_hz, | 115 int sample_rate_hz, |
116 int16_t* decoded, | 116 int16_t* decoded, |
117 SpeechType* speech_type) { | 117 SpeechType* speech_type) { |
118 DCHECK_EQ(sample_rate_hz, 16000); | 118 RTC_DCHECK_EQ(sample_rate_hz, 16000); |
119 int16_t temp_type = 1; // Default is speech. | 119 int16_t temp_type = 1; // Default is speech. |
120 size_t ret = | 120 size_t ret = |
121 WebRtcG722_Decode(dec_state_, encoded, encoded_len, decoded, &temp_type); | 121 WebRtcG722_Decode(dec_state_, encoded, encoded_len, decoded, &temp_type); |
122 *speech_type = ConvertSpeechType(temp_type); | 122 *speech_type = ConvertSpeechType(temp_type); |
123 return static_cast<int>(ret); | 123 return static_cast<int>(ret); |
124 } | 124 } |
125 | 125 |
126 void AudioDecoderG722::Reset() { | 126 void AudioDecoderG722::Reset() { |
127 WebRtcG722_DecoderInit(dec_state_); | 127 WebRtcG722_DecoderInit(dec_state_); |
128 } | 128 } |
(...skipping 18 matching lines...) Expand all Loading... |
147 AudioDecoderG722Stereo::~AudioDecoderG722Stereo() { | 147 AudioDecoderG722Stereo::~AudioDecoderG722Stereo() { |
148 WebRtcG722_FreeDecoder(dec_state_left_); | 148 WebRtcG722_FreeDecoder(dec_state_left_); |
149 WebRtcG722_FreeDecoder(dec_state_right_); | 149 WebRtcG722_FreeDecoder(dec_state_right_); |
150 } | 150 } |
151 | 151 |
152 int AudioDecoderG722Stereo::DecodeInternal(const uint8_t* encoded, | 152 int AudioDecoderG722Stereo::DecodeInternal(const uint8_t* encoded, |
153 size_t encoded_len, | 153 size_t encoded_len, |
154 int sample_rate_hz, | 154 int sample_rate_hz, |
155 int16_t* decoded, | 155 int16_t* decoded, |
156 SpeechType* speech_type) { | 156 SpeechType* speech_type) { |
157 DCHECK_EQ(sample_rate_hz, 16000); | 157 RTC_DCHECK_EQ(sample_rate_hz, 16000); |
158 int16_t temp_type = 1; // Default is speech. | 158 int16_t temp_type = 1; // Default is speech. |
159 // De-interleave the bit-stream into two separate payloads. | 159 // De-interleave the bit-stream into two separate payloads. |
160 uint8_t* encoded_deinterleaved = new uint8_t[encoded_len]; | 160 uint8_t* encoded_deinterleaved = new uint8_t[encoded_len]; |
161 SplitStereoPacket(encoded, encoded_len, encoded_deinterleaved); | 161 SplitStereoPacket(encoded, encoded_len, encoded_deinterleaved); |
162 // Decode left and right. | 162 // Decode left and right. |
163 size_t decoded_len = WebRtcG722_Decode(dec_state_left_, encoded_deinterleaved, | 163 size_t decoded_len = WebRtcG722_Decode(dec_state_left_, encoded_deinterleaved, |
164 encoded_len / 2, decoded, &temp_type); | 164 encoded_len / 2, decoded, &temp_type); |
165 size_t ret = WebRtcG722_Decode( | 165 size_t ret = WebRtcG722_Decode( |
166 dec_state_right_, &encoded_deinterleaved[encoded_len / 2], | 166 dec_state_right_, &encoded_deinterleaved[encoded_len / 2], |
167 encoded_len / 2, &decoded[decoded_len], &temp_type); | 167 encoded_len / 2, &decoded[decoded_len], &temp_type); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 for (size_t i = 0; i < encoded_len / 2; i++) { | 211 for (size_t i = 0; i < encoded_len / 2; i++) { |
212 uint8_t right_byte = encoded_deinterleaved[i + 1]; | 212 uint8_t right_byte = encoded_deinterleaved[i + 1]; |
213 memmove(&encoded_deinterleaved[i + 1], &encoded_deinterleaved[i + 2], | 213 memmove(&encoded_deinterleaved[i + 1], &encoded_deinterleaved[i + 2], |
214 encoded_len - i - 2); | 214 encoded_len - i - 2); |
215 encoded_deinterleaved[encoded_len - 1] = right_byte; | 215 encoded_deinterleaved[encoded_len - 1] = right_byte; |
216 } | 216 } |
217 } | 217 } |
218 #endif | 218 #endif |
219 | 219 |
220 AudioDecoderCng::AudioDecoderCng() { | 220 AudioDecoderCng::AudioDecoderCng() { |
221 CHECK_EQ(0, WebRtcCng_CreateDec(&dec_state_)); | 221 RTC_CHECK_EQ(0, WebRtcCng_CreateDec(&dec_state_)); |
222 WebRtcCng_InitDec(dec_state_); | 222 WebRtcCng_InitDec(dec_state_); |
223 } | 223 } |
224 | 224 |
225 AudioDecoderCng::~AudioDecoderCng() { | 225 AudioDecoderCng::~AudioDecoderCng() { |
226 WebRtcCng_FreeDec(dec_state_); | 226 WebRtcCng_FreeDec(dec_state_); |
227 } | 227 } |
228 | 228 |
229 void AudioDecoderCng::Reset() { | 229 void AudioDecoderCng::Reset() { |
230 WebRtcCng_InitDec(dec_state_); | 230 WebRtcCng_InitDec(dec_state_); |
231 } | 231 } |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 case kDecoderRED: | 416 case kDecoderRED: |
417 case kDecoderAVT: | 417 case kDecoderAVT: |
418 case kDecoderArbitrary: | 418 case kDecoderArbitrary: |
419 default: { | 419 default: { |
420 return NULL; | 420 return NULL; |
421 } | 421 } |
422 } | 422 } |
423 } | 423 } |
424 | 424 |
425 } // namespace webrtc | 425 } // namespace webrtc |
OLD | NEW |