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

Side by Side Diff: webrtc/modules/audio_coding/codecs/isac/audio_decoder_isac_t_impl.h

Issue 1339253003: Move AudioDecoderIsac* to its own files (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 years, 2 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
(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 #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_AUDIO_DECODER_ISAC_T_IMPL_H_
12 #define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_AUDIO_DECODER_ISAC_T_IMPL_H_
13
14 #include "webrtc/modules/audio_coding/codecs/isac/main/interface/audio_decoder_i sac.h"
15
16 #include "webrtc/base/checks.h"
17
18 namespace webrtc {
19
20 template <typename T>
21 AudioDecoderIsacT<T>::AudioDecoderIsacT()
22 : AudioDecoderIsacT(nullptr) {}
23
24 template <typename T>
25 AudioDecoderIsacT<T>::AudioDecoderIsacT(LockedIsacBandwidthInfo* bwinfo)
26 : bwinfo_(bwinfo), decoder_sample_rate_hz_(-1) {
27 RTC_CHECK_EQ(0, T::Create(&isac_state_));
28 T::DecoderInit(isac_state_);
29 if (bwinfo_) {
30 IsacBandwidthInfo bi;
31 T::GetBandwidthInfo(isac_state_, &bi);
32 bwinfo_->Set(bi);
33 }
34 }
35
36 template <typename T>
37 AudioDecoderIsacT<T>::~AudioDecoderIsacT() {
38 RTC_CHECK_EQ(0, T::Free(isac_state_));
39 }
40
41 template <typename T>
42 int AudioDecoderIsacT<T>::DecodeInternal(const uint8_t* encoded,
43 size_t encoded_len,
44 int sample_rate_hz,
45 int16_t* decoded,
46 SpeechType* speech_type) {
47 // We want to crate the illusion that iSAC supports 48000 Hz decoding, while
48 // in fact it outputs 32000 Hz. This is the iSAC fullband mode.
49 if (sample_rate_hz == 48000)
50 sample_rate_hz = 32000;
51 RTC_CHECK(sample_rate_hz == 16000 || sample_rate_hz == 32000)
52 << "Unsupported sample rate " << sample_rate_hz;
53 if (sample_rate_hz != decoder_sample_rate_hz_) {
54 RTC_CHECK_EQ(0, T::SetDecSampRate(isac_state_, sample_rate_hz));
55 decoder_sample_rate_hz_ = sample_rate_hz;
56 }
57 int16_t temp_type = 1; // Default is speech.
58 int ret =
59 T::DecodeInternal(isac_state_, encoded, encoded_len, decoded, &temp_type);
60 *speech_type = ConvertSpeechType(temp_type);
61 return ret;
62 }
63
64 template <typename T>
65 bool AudioDecoderIsacT<T>::HasDecodePlc() const {
66 return false;
67 }
68
69 template <typename T>
70 size_t AudioDecoderIsacT<T>::DecodePlc(size_t num_frames, int16_t* decoded) {
71 return T::DecodePlc(isac_state_, decoded, num_frames);
72 }
73
74 template <typename T>
75 void AudioDecoderIsacT<T>::Reset() {
76 T::DecoderInit(isac_state_);
77 }
78
79 template <typename T>
80 int AudioDecoderIsacT<T>::IncomingPacket(const uint8_t* payload,
81 size_t payload_len,
82 uint16_t rtp_sequence_number,
83 uint32_t rtp_timestamp,
84 uint32_t arrival_timestamp) {
85 int ret = T::UpdateBwEstimate(isac_state_, payload, payload_len,
86 rtp_sequence_number, rtp_timestamp,
87 arrival_timestamp);
88 if (bwinfo_) {
89 IsacBandwidthInfo bwinfo;
90 T::GetBandwidthInfo(isac_state_, &bwinfo);
91 bwinfo_->Set(bwinfo);
92 }
93 return ret;
94 }
95
96 template <typename T>
97 int AudioDecoderIsacT<T>::ErrorCode() {
98 return T::GetErrorCode(isac_state_);
99 }
100
101 template <typename T>
102 size_t AudioDecoderIsacT<T>::Channels() const {
103 return 1;
104 }
105
106 } // namespace webrtc
107
108 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_AUDIO_DECODER_ISAC_T_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698