Support for CELT in NetEq4.

BUG=1359
R=henrik.lundin@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/2291004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4876 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
turaj@webrtc.org
2013-09-28 16:31:25 +00:00
parent ad81ab8861
commit a20a22a0bd
4 changed files with 206 additions and 7 deletions

View File

@ -13,6 +13,9 @@
#include <assert.h>
#include <string.h> // memmove
#ifdef WEBRTC_CODEC_CELT
#include "webrtc/modules/audio_coding/codecs/celt/include/celt_interface.h"
#endif
#include "webrtc/modules/audio_coding/codecs/cng/include/webrtc_cng.h"
#include "webrtc/modules/audio_coding/codecs/g711/include/g711_interface.h"
#ifdef WEBRTC_CODEC_G722
@ -377,6 +380,55 @@ void AudioDecoderG722Stereo::SplitStereoPacket(const uint8_t* encoded,
}
#endif
// CELT
#ifdef WEBRTC_CODEC_CELT
AudioDecoderCelt::AudioDecoderCelt(enum NetEqDecoder type)
: AudioDecoder(type) {
assert(type == kDecoderCELT_32 || type == kDecoderCELT_32_2ch);
if (type == kDecoderCELT_32) {
channels_ = 1;
} else {
channels_ = 2;
}
WebRtcCelt_CreateDec(reinterpret_cast<CELT_decinst_t**>(&state_),
static_cast<int>(channels_));
}
AudioDecoderCelt::~AudioDecoderCelt() {
WebRtcCelt_FreeDec(static_cast<CELT_decinst_t*>(state_));
}
int AudioDecoderCelt::Decode(const uint8_t* encoded, size_t encoded_len,
int16_t* decoded, SpeechType* speech_type) {
int16_t temp_type = 1; // Default to speech.
int ret = WebRtcCelt_DecodeUniversal(static_cast<CELT_decinst_t*>(state_),
encoded, static_cast<int>(encoded_len),
decoded, &temp_type);
*speech_type = ConvertSpeechType(temp_type);
if (ret < 0) {
return -1;
}
// Return the total number of samples.
return ret * static_cast<int>(channels_);
}
int AudioDecoderCelt::Init() {
return WebRtcCelt_DecoderInit(static_cast<CELT_decinst_t*>(state_));
}
bool AudioDecoderCelt::HasDecodePlc() const { return true; }
int AudioDecoderCelt::DecodePlc(int num_frames, int16_t* decoded) {
int ret = WebRtcCelt_DecodePlc(static_cast<CELT_decinst_t*>(state_),
decoded, num_frames);
if (ret < 0) {
return -1;
}
// Return the total number of samples.
return ret * static_cast<int>(channels_);
}
#endif
// Opus
#ifdef WEBRTC_CODEC_OPUS
AudioDecoderOpus::AudioDecoderOpus(enum NetEqDecoder type)