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 11 matching lines...) Expand all Loading... | |
22 #ifdef WEBRTC_CODEC_ILBC | 22 #ifdef WEBRTC_CODEC_ILBC |
23 #include "webrtc/modules/audio_coding/codecs/ilbc/interface/ilbc.h" | 23 #include "webrtc/modules/audio_coding/codecs/ilbc/interface/ilbc.h" |
24 #endif | 24 #endif |
25 #ifdef WEBRTC_CODEC_ISACFX | 25 #ifdef WEBRTC_CODEC_ISACFX |
26 #include "webrtc/modules/audio_coding/codecs/isac/fix/interface/audio_encoder_is acfix.h" | 26 #include "webrtc/modules/audio_coding/codecs/isac/fix/interface/audio_encoder_is acfix.h" |
27 #endif | 27 #endif |
28 #ifdef WEBRTC_CODEC_ISAC | 28 #ifdef WEBRTC_CODEC_ISAC |
29 #include "webrtc/modules/audio_coding/codecs/isac/main/interface/audio_encoder_i sac.h" | 29 #include "webrtc/modules/audio_coding/codecs/isac/main/interface/audio_encoder_i sac.h" |
30 #endif | 30 #endif |
31 #ifdef WEBRTC_CODEC_OPUS | 31 #ifdef WEBRTC_CODEC_OPUS |
32 #include "webrtc/modules/audio_coding/codecs/opus/interface/opus_interface.h" | 32 #include "webrtc/modules/audio_coding/codecs/opus/interface/audio_decoder_opus.h " |
33 #endif | 33 #endif |
34 #ifdef WEBRTC_CODEC_PCM16 | 34 #ifdef WEBRTC_CODEC_PCM16 |
35 #include "webrtc/modules/audio_coding/codecs/pcm16b/include/pcm16b.h" | 35 #include "webrtc/modules/audio_coding/codecs/pcm16b/include/pcm16b.h" |
36 #endif | 36 #endif |
37 | 37 |
38 namespace webrtc { | 38 namespace webrtc { |
39 | 39 |
40 // PCMu | 40 // PCMu |
41 | 41 |
42 void AudioDecoderPcmU::Reset() { | 42 void AudioDecoderPcmU::Reset() { |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
292 // where N is the total number of samples. | 292 // where N is the total number of samples. |
293 for (size_t i = 0; i < encoded_len / 2; i++) { | 293 for (size_t i = 0; i < encoded_len / 2; i++) { |
294 uint8_t right_byte = encoded_deinterleaved[i + 1]; | 294 uint8_t right_byte = encoded_deinterleaved[i + 1]; |
295 memmove(&encoded_deinterleaved[i + 1], &encoded_deinterleaved[i + 2], | 295 memmove(&encoded_deinterleaved[i + 1], &encoded_deinterleaved[i + 2], |
296 encoded_len - i - 2); | 296 encoded_len - i - 2); |
297 encoded_deinterleaved[encoded_len - 1] = right_byte; | 297 encoded_deinterleaved[encoded_len - 1] = right_byte; |
298 } | 298 } |
299 } | 299 } |
300 #endif | 300 #endif |
301 | 301 |
302 // Opus | |
303 #ifdef WEBRTC_CODEC_OPUS | |
hlundin-webrtc
2015/09/15 10:30:45
Did you just lose this conditional compilation of
kwiberg-webrtc
2015/09/15 10:45:07
The entire file I moved it to is conditioned on in
hlundin-webrtc
2015/09/15 10:49:13
Acknowledged.
| |
304 AudioDecoderOpus::AudioDecoderOpus(size_t num_channels) | |
305 : channels_(num_channels) { | |
306 DCHECK(num_channels == 1 || num_channels == 2); | |
307 WebRtcOpus_DecoderCreate(&dec_state_, static_cast<int>(channels_)); | |
308 WebRtcOpus_DecoderInit(dec_state_); | |
309 } | |
310 | |
311 AudioDecoderOpus::~AudioDecoderOpus() { | |
312 WebRtcOpus_DecoderFree(dec_state_); | |
313 } | |
314 | |
315 int AudioDecoderOpus::DecodeInternal(const uint8_t* encoded, | |
316 size_t encoded_len, | |
317 int sample_rate_hz, | |
318 int16_t* decoded, | |
319 SpeechType* speech_type) { | |
320 DCHECK_EQ(sample_rate_hz, 48000); | |
321 int16_t temp_type = 1; // Default is speech. | |
322 int ret = WebRtcOpus_Decode(dec_state_, encoded, encoded_len, decoded, | |
323 &temp_type); | |
324 if (ret > 0) | |
325 ret *= static_cast<int>(channels_); // Return total number of samples. | |
326 *speech_type = ConvertSpeechType(temp_type); | |
327 return ret; | |
328 } | |
329 | |
330 int AudioDecoderOpus::DecodeRedundantInternal(const uint8_t* encoded, | |
331 size_t encoded_len, | |
332 int sample_rate_hz, | |
333 int16_t* decoded, | |
334 SpeechType* speech_type) { | |
335 if (!PacketHasFec(encoded, encoded_len)) { | |
336 // This packet is a RED packet. | |
337 return DecodeInternal(encoded, encoded_len, sample_rate_hz, decoded, | |
338 speech_type); | |
339 } | |
340 | |
341 DCHECK_EQ(sample_rate_hz, 48000); | |
342 int16_t temp_type = 1; // Default is speech. | |
343 int ret = WebRtcOpus_DecodeFec(dec_state_, encoded, encoded_len, decoded, | |
344 &temp_type); | |
345 if (ret > 0) | |
346 ret *= static_cast<int>(channels_); // Return total number of samples. | |
347 *speech_type = ConvertSpeechType(temp_type); | |
348 return ret; | |
349 } | |
350 | |
351 void AudioDecoderOpus::Reset() { | |
352 WebRtcOpus_DecoderInit(dec_state_); | |
353 } | |
354 | |
355 int AudioDecoderOpus::PacketDuration(const uint8_t* encoded, | |
356 size_t encoded_len) const { | |
357 return WebRtcOpus_DurationEst(dec_state_, encoded, encoded_len); | |
358 } | |
359 | |
360 int AudioDecoderOpus::PacketDurationRedundant(const uint8_t* encoded, | |
361 size_t encoded_len) const { | |
362 if (!PacketHasFec(encoded, encoded_len)) { | |
363 // This packet is a RED packet. | |
364 return PacketDuration(encoded, encoded_len); | |
365 } | |
366 | |
367 return WebRtcOpus_FecDurationEst(encoded, encoded_len); | |
368 } | |
369 | |
370 bool AudioDecoderOpus::PacketHasFec(const uint8_t* encoded, | |
371 size_t encoded_len) const { | |
372 int fec; | |
373 fec = WebRtcOpus_PacketHasFec(encoded, encoded_len); | |
374 return (fec == 1); | |
375 } | |
376 | |
377 size_t AudioDecoderOpus::Channels() const { | |
378 return channels_; | |
379 } | |
380 #endif | |
381 | |
382 AudioDecoderCng::AudioDecoderCng() { | 302 AudioDecoderCng::AudioDecoderCng() { |
383 CHECK_EQ(0, WebRtcCng_CreateDec(&dec_state_)); | 303 CHECK_EQ(0, WebRtcCng_CreateDec(&dec_state_)); |
384 WebRtcCng_InitDec(dec_state_); | 304 WebRtcCng_InitDec(dec_state_); |
385 } | 305 } |
386 | 306 |
387 AudioDecoderCng::~AudioDecoderCng() { | 307 AudioDecoderCng::~AudioDecoderCng() { |
388 WebRtcCng_FreeDec(dec_state_); | 308 WebRtcCng_FreeDec(dec_state_); |
389 } | 309 } |
390 | 310 |
391 void AudioDecoderCng::Reset() { | 311 void AudioDecoderCng::Reset() { |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
590 case kDecoderRED: | 510 case kDecoderRED: |
591 case kDecoderAVT: | 511 case kDecoderAVT: |
592 case kDecoderArbitrary: | 512 case kDecoderArbitrary: |
593 default: { | 513 default: { |
594 return NULL; | 514 return NULL; |
595 } | 515 } |
596 } | 516 } |
597 } | 517 } |
598 | 518 |
599 } // namespace webrtc | 519 } // namespace webrtc |
OLD | NEW |