Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: webrtc/modules/audio_coding/neteq/audio_decoder_impl.cc

Issue 1348613003: Move AudioDecoderPcm* next to AudioEncoderPcm* (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@dmove-pcm16
Patch Set: rebase Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 #include "webrtc/modules/audio_coding/neteq/audio_decoder_impl.h" 11 #include "webrtc/modules/audio_coding/neteq/audio_decoder_impl.h"
12 12
13 #include <assert.h> 13 #include <assert.h>
14 14
15 #include "webrtc/base/checks.h" 15 #include "webrtc/base/checks.h"
16 #include "webrtc/modules/audio_coding/codecs/cng/include/webrtc_cng.h" 16 #include "webrtc/modules/audio_coding/codecs/cng/include/webrtc_cng.h"
17 #include "webrtc/modules/audio_coding/codecs/g711/include/g711_interface.h" 17 #include "webrtc/modules/audio_coding/codecs/g711/include/audio_decoder_pcm.h"
18 #ifdef WEBRTC_CODEC_G722 18 #ifdef WEBRTC_CODEC_G722
19 #include "webrtc/modules/audio_coding/codecs/g722/include/audio_decoder_g722.h" 19 #include "webrtc/modules/audio_coding/codecs/g722/include/audio_decoder_g722.h"
20 #endif 20 #endif
21 #ifdef WEBRTC_CODEC_ILBC 21 #ifdef WEBRTC_CODEC_ILBC
22 #include "webrtc/modules/audio_coding/codecs/ilbc/interface/audio_decoder_ilbc.h " 22 #include "webrtc/modules/audio_coding/codecs/ilbc/interface/audio_decoder_ilbc.h "
23 #endif 23 #endif
24 #ifdef WEBRTC_CODEC_ISACFX 24 #ifdef WEBRTC_CODEC_ISACFX
25 #include "webrtc/modules/audio_coding/codecs/isac/fix/interface/audio_encoder_is acfix.h" 25 #include "webrtc/modules/audio_coding/codecs/isac/fix/interface/audio_encoder_is acfix.h"
26 #endif 26 #endif
27 #ifdef WEBRTC_CODEC_ISAC 27 #ifdef WEBRTC_CODEC_ISAC
28 #include "webrtc/modules/audio_coding/codecs/isac/main/interface/audio_encoder_i sac.h" 28 #include "webrtc/modules/audio_coding/codecs/isac/main/interface/audio_encoder_i sac.h"
29 #endif 29 #endif
30 #ifdef WEBRTC_CODEC_OPUS 30 #ifdef WEBRTC_CODEC_OPUS
31 #include "webrtc/modules/audio_coding/codecs/opus/interface/audio_decoder_opus.h " 31 #include "webrtc/modules/audio_coding/codecs/opus/interface/audio_decoder_opus.h "
32 #endif 32 #endif
33 #include "webrtc/modules/audio_coding/codecs/pcm16b/include/audio_decoder_pcm16b .h" 33 #include "webrtc/modules/audio_coding/codecs/pcm16b/include/audio_decoder_pcm16b .h"
34 34
35 namespace webrtc { 35 namespace webrtc {
36 36
37 // PCMu
38
39 void AudioDecoderPcmU::Reset() {
40 }
41 size_t AudioDecoderPcmU::Channels() const {
42 return 1;
43 }
44
45 int AudioDecoderPcmU::DecodeInternal(const uint8_t* encoded,
46 size_t encoded_len,
47 int sample_rate_hz,
48 int16_t* decoded,
49 SpeechType* speech_type) {
50 RTC_DCHECK_EQ(sample_rate_hz, 8000);
51 int16_t temp_type = 1; // Default is speech.
52 size_t ret = WebRtcG711_DecodeU(encoded, encoded_len, decoded, &temp_type);
53 *speech_type = ConvertSpeechType(temp_type);
54 return static_cast<int>(ret);
55 }
56
57 int AudioDecoderPcmU::PacketDuration(const uint8_t* encoded,
58 size_t encoded_len) const {
59 // One encoded byte per sample per channel.
60 return static_cast<int>(encoded_len / Channels());
61 }
62
63 size_t AudioDecoderPcmUMultiCh::Channels() const {
64 return channels_;
65 }
66
67 // PCMa
68
69 void AudioDecoderPcmA::Reset() {
70 }
71 size_t AudioDecoderPcmA::Channels() const {
72 return 1;
73 }
74
75 int AudioDecoderPcmA::DecodeInternal(const uint8_t* encoded,
76 size_t encoded_len,
77 int sample_rate_hz,
78 int16_t* decoded,
79 SpeechType* speech_type) {
80 RTC_DCHECK_EQ(sample_rate_hz, 8000);
81 int16_t temp_type = 1; // Default is speech.
82 size_t ret = WebRtcG711_DecodeA(encoded, encoded_len, decoded, &temp_type);
83 *speech_type = ConvertSpeechType(temp_type);
84 return static_cast<int>(ret);
85 }
86
87 int AudioDecoderPcmA::PacketDuration(const uint8_t* encoded,
88 size_t encoded_len) const {
89 // One encoded byte per sample per channel.
90 return static_cast<int>(encoded_len / Channels());
91 }
92
93 size_t AudioDecoderPcmAMultiCh::Channels() const {
94 return channels_;
95 }
96
97 AudioDecoderCng::AudioDecoderCng() { 37 AudioDecoderCng::AudioDecoderCng() {
98 RTC_CHECK_EQ(0, WebRtcCng_CreateDec(&dec_state_)); 38 RTC_CHECK_EQ(0, WebRtcCng_CreateDec(&dec_state_));
99 WebRtcCng_InitDec(dec_state_); 39 WebRtcCng_InitDec(dec_state_);
100 } 40 }
101 41
102 AudioDecoderCng::~AudioDecoderCng() { 42 AudioDecoderCng::~AudioDecoderCng() {
103 WebRtcCng_FreeDec(dec_state_); 43 WebRtcCng_FreeDec(dec_state_);
104 } 44 }
105 45
106 void AudioDecoderCng::Reset() { 46 void AudioDecoderCng::Reset() {
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 case kDecoderRED: 233 case kDecoderRED:
294 case kDecoderAVT: 234 case kDecoderAVT:
295 case kDecoderArbitrary: 235 case kDecoderArbitrary:
296 default: { 236 default: {
297 return NULL; 237 return NULL;
298 } 238 }
299 } 239 }
300 } 240 }
301 241
302 } // namespace webrtc 242 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/audio_decoder_impl.h ('k') | webrtc/modules/audio_coding/neteq/audio_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698