| 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 #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_G722_INCLUDE_AUDIO_DECODER_G722_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_G722_INCLUDE_AUDIO_DECODER_G722_H_ |
| 12 #define WEBRTC_MODULES_AUDIO_CODING_CODECS_G722_INCLUDE_AUDIO_DECODER_G722_H_ | 12 #define WEBRTC_MODULES_AUDIO_CODING_CODECS_G722_INCLUDE_AUDIO_DECODER_G722_H_ |
| 13 | 13 |
| 14 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h" | 14 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h" |
| 15 | 15 |
| 16 typedef struct WebRtcG722DecInst G722DecInst; | 16 typedef struct WebRtcG722DecInst G722DecInst; |
| 17 | 17 |
| 18 namespace webrtc { | 18 namespace webrtc { |
| 19 | 19 |
| 20 class AudioDecoderG722 : public AudioDecoder { | 20 class AudioDecoderG722 final : public AudioDecoder { |
| 21 public: | 21 public: |
| 22 AudioDecoderG722(); | 22 AudioDecoderG722(); |
| 23 ~AudioDecoderG722() override; | 23 ~AudioDecoderG722() override; |
| 24 bool HasDecodePlc() const override; | 24 bool HasDecodePlc() const override; |
| 25 void Reset() override; | 25 void Reset() override; |
| 26 int PacketDuration(const uint8_t* encoded, size_t encoded_len) const override; | 26 int PacketDuration(const uint8_t* encoded, size_t encoded_len) const override; |
| 27 size_t Channels() const override; | 27 size_t Channels() const override; |
| 28 | 28 |
| 29 protected: | 29 protected: |
| 30 int DecodeInternal(const uint8_t* encoded, | 30 int DecodeInternal(const uint8_t* encoded, |
| 31 size_t encoded_len, | 31 size_t encoded_len, |
| 32 int sample_rate_hz, | 32 int sample_rate_hz, |
| 33 int16_t* decoded, | 33 int16_t* decoded, |
| 34 SpeechType* speech_type) override; | 34 SpeechType* speech_type) override; |
| 35 | 35 |
| 36 private: | 36 private: |
| 37 G722DecInst* dec_state_; | 37 G722DecInst* dec_state_; |
| 38 RTC_DISALLOW_COPY_AND_ASSIGN(AudioDecoderG722); | 38 RTC_DISALLOW_COPY_AND_ASSIGN(AudioDecoderG722); |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 class AudioDecoderG722Stereo : public AudioDecoder { | 41 class AudioDecoderG722Stereo final : public AudioDecoder { |
| 42 public: | 42 public: |
| 43 AudioDecoderG722Stereo(); | 43 AudioDecoderG722Stereo(); |
| 44 ~AudioDecoderG722Stereo() override; | 44 ~AudioDecoderG722Stereo() override; |
| 45 void Reset() override; | 45 void Reset() override; |
| 46 | 46 |
| 47 protected: | 47 protected: |
| 48 int DecodeInternal(const uint8_t* encoded, | 48 int DecodeInternal(const uint8_t* encoded, |
| 49 size_t encoded_len, | 49 size_t encoded_len, |
| 50 int sample_rate_hz, | 50 int sample_rate_hz, |
| 51 int16_t* decoded, | 51 int16_t* decoded, |
| 52 SpeechType* speech_type) override; | 52 SpeechType* speech_type) override; |
| 53 size_t Channels() const override; | 53 size_t Channels() const override; |
| 54 | 54 |
| 55 private: | 55 private: |
| 56 // Splits the stereo-interleaved payload in |encoded| into separate payloads | 56 // Splits the stereo-interleaved payload in |encoded| into separate payloads |
| 57 // for left and right channels. The separated payloads are written to | 57 // for left and right channels. The separated payloads are written to |
| 58 // |encoded_deinterleaved|, which must hold at least |encoded_len| samples. | 58 // |encoded_deinterleaved|, which must hold at least |encoded_len| samples. |
| 59 // The left channel starts at offset 0, while the right channel starts at | 59 // The left channel starts at offset 0, while the right channel starts at |
| 60 // offset encoded_len / 2 into |encoded_deinterleaved|. | 60 // offset encoded_len / 2 into |encoded_deinterleaved|. |
| 61 void SplitStereoPacket(const uint8_t* encoded, | 61 void SplitStereoPacket(const uint8_t* encoded, |
| 62 size_t encoded_len, | 62 size_t encoded_len, |
| 63 uint8_t* encoded_deinterleaved); | 63 uint8_t* encoded_deinterleaved); |
| 64 | 64 |
| 65 G722DecInst* dec_state_left_; | 65 G722DecInst* dec_state_left_; |
| 66 G722DecInst* dec_state_right_; | 66 G722DecInst* dec_state_right_; |
| 67 | |
| 68 RTC_DISALLOW_COPY_AND_ASSIGN(AudioDecoderG722Stereo); | 67 RTC_DISALLOW_COPY_AND_ASSIGN(AudioDecoderG722Stereo); |
| 69 }; | 68 }; |
| 70 | 69 |
| 71 } // namespace webrtc | 70 } // namespace webrtc |
| 71 |
| 72 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_G722_INCLUDE_AUDIO_DECODER_G722_H_ | 72 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_G722_INCLUDE_AUDIO_DECODER_G722_H_ |
| OLD | NEW |