Remove CELT support from audio_coding.

R=henrik.lundin@webrtc.org, juberti@webrtc.org
TBR=kjellander@webrtc.org
BUG=

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@7864 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
pbos@webrtc.org
2014-12-10 11:49:13 +00:00
parent 8084f9500f
commit d8ca723de7
14 changed files with 3 additions and 623 deletions

View File

@ -14,9 +14,6 @@
#include <string.h> // memmove
#include "webrtc/base/checks.h"
#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
@ -345,50 +342,6 @@ void AudioDecoderG722Stereo::SplitStereoPacket(const uint8_t* encoded,
}
#endif
// CELT
#ifdef WEBRTC_CODEC_CELT
AudioDecoderCelt::AudioDecoderCelt(int num_channels) {
DCHECK(num_channels == 1 || num_channels == 2);
channels_ = num_channels;
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(int num_channels) {
@ -492,10 +445,6 @@ bool CodecSupported(NetEqDecoder codec_type) {
case kDecoderG722:
case kDecoderG722_2ch:
#endif
#ifdef WEBRTC_CODEC_CELT
case kDecoderCELT_32:
case kDecoderCELT_32_2ch:
#endif
#ifdef WEBRTC_CODEC_OPUS
case kDecoderOpus:
case kDecoderOpus_2ch:
@ -553,10 +502,6 @@ int CodecSampleRateHz(NetEqDecoder codec_type) {
#ifdef WEBRTC_CODEC_PCM16
case kDecoderPCM16Bswb32kHz:
case kDecoderPCM16Bswb32kHz_2ch:
#endif
#ifdef WEBRTC_CODEC_CELT
case kDecoderCELT_32:
case kDecoderCELT_32_2ch:
#endif
case kDecoderCNGswb32kHz: {
return 32000;
@ -630,12 +575,6 @@ AudioDecoder* CreateAudioDecoder(NetEqDecoder codec_type) {
case kDecoderG722_2ch:
return new AudioDecoderG722Stereo;
#endif
#ifdef WEBRTC_CODEC_CELT
case kDecoderCELT_32:
return new AudioDecoderCelt(1);
case kDecoderCELT_32_2ch:
return new AudioDecoderCelt(2);
#endif
#ifdef WEBRTC_CODEC_OPUS
case kDecoderOpus:
return new AudioDecoderOpus(1);

View File

@ -216,23 +216,6 @@ class AudioDecoderG722Stereo : public AudioDecoder {
};
#endif
#ifdef WEBRTC_CODEC_CELT
class AudioDecoderCelt : public AudioDecoder {
public:
explicit AudioDecoderCelt(int num_channels);
virtual ~AudioDecoderCelt();
virtual int Decode(const uint8_t* encoded, size_t encoded_len,
int16_t* decoded, SpeechType* speech_type);
virtual int Init();
virtual bool HasDecodePlc() const;
virtual int DecodePlc(int num_frames, int16_t* decoded);
private:
DISALLOW_COPY_AND_ASSIGN(AudioDecoderCelt);
};
#endif
#ifdef WEBRTC_CODEC_OPUS
class AudioDecoderOpus : public AudioDecoder {
public:
@ -309,8 +292,6 @@ enum NetEqDecoder {
kDecoderArbitrary,
kDecoderOpus,
kDecoderOpus_2ch,
kDecoderCELT_32,
kDecoderCELT_32_2ch,
};
// Returns true if |codec_type| is supported.

View File

@ -17,9 +17,6 @@
#include <vector>
#include "testing/gtest/include/gtest/gtest.h"
#ifdef WEBRTC_CODEC_CELT
#include "webrtc/modules/audio_coding/codecs/celt/include/celt_interface.h"
#endif
#include "webrtc/modules/audio_coding/codecs/g711/include/g711_interface.h"
#include "webrtc/modules/audio_coding/codecs/g711/include/audio_encoder_pcm.h"
#include "webrtc/modules/audio_coding/codecs/g722/include/audio_encoder_g722.h"
@ -500,77 +497,6 @@ class AudioDecoderG722StereoTest : public AudioDecoderTest {
}
};
#ifdef WEBRTC_CODEC_CELT
class AudioDecoderCeltTest : public AudioDecoderTest {
protected:
static const int kEncodingRateBitsPerSecond = 64000;
AudioDecoderCeltTest() : AudioDecoderTest(), encoder_(NULL) {
frame_size_ = 640;
data_length_ = 10 * frame_size_;
decoder_ = AudioDecoder::CreateAudioDecoder(kDecoderCELT_32);
assert(decoder_);
WebRtcCelt_CreateEnc(&encoder_, static_cast<int>(channels_));
}
~AudioDecoderCeltTest() {
WebRtcCelt_FreeEnc(encoder_);
}
virtual void InitEncoder() {
assert(encoder_);
ASSERT_EQ(0, WebRtcCelt_EncoderInit(
encoder_, static_cast<int>(channels_), kEncodingRateBitsPerSecond));
}
virtual int EncodeFrame(const int16_t* input, size_t input_len_samples,
uint8_t* output) {
assert(encoder_);
return WebRtcCelt_Encode(encoder_, input, output);
}
CELT_encinst_t* encoder_;
};
class AudioDecoderCeltStereoTest : public AudioDecoderTest {
protected:
static const int kEncodingRateBitsPerSecond = 64000;
AudioDecoderCeltStereoTest() : AudioDecoderTest(), encoder_(NULL) {
channels_ = 2;
frame_size_ = 640;
data_length_ = 10 * frame_size_;
decoder_ = AudioDecoder::CreateAudioDecoder(kDecoderCELT_32_2ch);
assert(decoder_);
stereo_input_ = new int16_t[frame_size_ * channels_];
WebRtcCelt_CreateEnc(&encoder_, static_cast<int>(channels_));
}
~AudioDecoderCeltStereoTest() {
delete [] stereo_input_;
WebRtcCelt_FreeEnc(encoder_);
}
virtual void InitEncoder() {
assert(encoder_);
ASSERT_EQ(0, WebRtcCelt_EncoderInit(
encoder_, static_cast<int>(channels_), kEncodingRateBitsPerSecond));
}
virtual int EncodeFrame(const int16_t* input, size_t input_len_samples,
uint8_t* output) {
assert(encoder_);
assert(stereo_input_);
for (size_t n = 0; n < frame_size_; ++n) {
stereo_input_[n * 2] = stereo_input_[n * 2 + 1] = input[n];
}
return WebRtcCelt_Encode(encoder_, stereo_input_, output);
}
int16_t* stereo_input_;
CELT_encinst_t* encoder_;
};
#endif
class AudioDecoderOpusTest : public AudioDecoderTest {
protected:
AudioDecoderOpusTest() : AudioDecoderTest() {
@ -718,38 +644,6 @@ TEST_F(AudioDecoderOpusStereoTest, EncodeDecode) {
EXPECT_FALSE(decoder_->HasDecodePlc());
}
#ifdef WEBRTC_CODEC_CELT
// In the two following CELT tests, the low amplitude of the test signal allow
// us to have such low error thresholds, i.e. |tolerance|, |mse|. Furthermore,
// in general, stereo signals with identical channels do not result in identical
// encoded channels.
TEST_F(AudioDecoderCeltTest, EncodeDecode) {
int tolerance = 20;
double mse = 17.0;
int delay = 80; // Delay from input to output in samples.
EXPECT_TRUE(CodecSupported(kDecoderCELT_32));
EncodeDecodeTest(1600, tolerance, mse, delay);
ReInitTest();
EXPECT_TRUE(decoder_->HasDecodePlc());
DecodePlcTest();
}
TEST_F(AudioDecoderCeltStereoTest, EncodeDecode) {
int tolerance = 20;
// If both channels are identical, CELT not necessarily decodes identical
// channels. However, for this input this is the case.
int channel_diff_tolerance = 0;
double mse = 20.0;
// Delay from input to output in samples, accounting for stereo.
int delay = 160;
EXPECT_TRUE(CodecSupported(kDecoderCELT_32_2ch));
EncodeDecodeTest(1600, tolerance, mse, delay, channel_diff_tolerance);
ReInitTest();
EXPECT_TRUE(decoder_->HasDecodePlc());
DecodePlcTest();
}
#endif
TEST(AudioDecoder, CodecSampleRateHz) {
EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCMu));
EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCMa));
@ -780,13 +674,6 @@ TEST(AudioDecoder, CodecSampleRateHz) {
// TODO(tlegrand): Change 32000 to 48000 below once ACM has 48 kHz support.
EXPECT_EQ(32000, CodecSampleRateHz(kDecoderCNGswb48kHz));
EXPECT_EQ(-1, CodecSampleRateHz(kDecoderArbitrary));
#ifdef WEBRTC_CODEC_CELT
EXPECT_EQ(32000, CodecSampleRateHz(kDecoderCELT_32));
EXPECT_EQ(32000, CodecSampleRateHz(kDecoderCELT_32_2ch));
#else
EXPECT_EQ(-1, CodecSampleRateHz(kDecoderCELT_32));
EXPECT_EQ(-1, CodecSampleRateHz(kDecoderCELT_32_2ch));
#endif
}
TEST(AudioDecoder, CodecSupported) {
@ -818,13 +705,6 @@ TEST(AudioDecoder, CodecSupported) {
EXPECT_TRUE(CodecSupported(kDecoderArbitrary));
EXPECT_TRUE(CodecSupported(kDecoderOpus));
EXPECT_TRUE(CodecSupported(kDecoderOpus_2ch));
#ifdef WEBRTC_CODEC_CELT
EXPECT_TRUE(CodecSupported(kDecoderCELT_32));
EXPECT_TRUE(CodecSupported(kDecoderCELT_32_2ch));
#else
EXPECT_FALSE(CodecSupported(kDecoderCELT_32));
EXPECT_FALSE(CodecSupported(kDecoderCELT_32_2ch));
#endif
}
} // namespace webrtc

View File

@ -54,7 +54,6 @@
#define NETEQ_CODEC_G729_1_PT 107
#define NETEQ_CODEC_G729D_PT 123
#define NETEQ_CODEC_MELPE_PT 124
#define NETEQ_CODEC_CELT32_PT 114
/* Extra dynamic codepoints */
#define NETEQ_CODEC_AMRWB_PT 120

View File

@ -157,10 +157,6 @@ void stereoInterleave(unsigned char* data, int dataLen, int stride);
#if ((defined CODEC_SPEEX_8)||(defined CODEC_SPEEX_16))
#include "SpeexInterface.h"
#endif
#ifdef CODEC_CELT_32
#include "celt_interface.h"
#endif
/***********************************/
/* Global codec instance variables */
@ -232,10 +228,6 @@ WebRtcVadInst *VAD_inst[2];
#ifdef CODEC_SPEEX_16
SPEEX_encinst_t *SPEEX16enc_inst[2];
#endif
#ifdef CODEC_CELT_32
CELT_encinst_t *CELT32enc_inst[2];
#endif
int main(int argc, char* argv[])
{
@ -373,9 +365,6 @@ int main(int argc, char* argv[])
#ifdef CODEC_SPEEX_16
printf(" : speex16 speex coder (16 kHz)\n");
#endif
#ifdef CODEC_CELT_32
printf(" : celt32 celt coder (32 kHz)\n");
#endif
#ifdef CODEC_RED
#ifdef CODEC_G711
printf(" : red_pcm Redundancy RTP packet with 2*G711A frames\n");
@ -855,11 +844,6 @@ void NetEQTest_GetCodec_and_PT(char * name, webrtc::NetEqDecoder *codec, int *PT
*codec=webrtc::kDecoderISACswb;
*PT=NETEQ_CODEC_ISACSWB_PT;
}
else if(!strcmp(name,"celt32")){
*fs=32000;
*codec=webrtc::kDecoderCELT_32;
*PT=NETEQ_CODEC_CELT32_PT;
}
else if(!strcmp(name,"red_pcm")){
*codec=webrtc::kDecoderPCMa;
*PT=NETEQ_CODEC_PCMA_PT; /* this will be the PT for the sub-headers */
@ -1031,26 +1015,6 @@ int NetEQTest_init_coders(webrtc::NetEqDecoder coder, int enc_frameSize, int bit
}
break;
#endif
#ifdef CODEC_CELT_32
case webrtc::kDecoderCELT_32 :
if (sampfreq==32000) {
if (enc_frameSize==320) {
ok=WebRtcCelt_CreateEnc(&CELT32enc_inst[k], 1 /*mono*/);
if (ok!=0) {
printf("Error: Couldn't allocate memory for Celt encoding instance\n");
exit(0);
}
} else {
printf("\nError: Celt only supports 10 ms!!\n\n");
exit(0);
}
ok=WebRtcCelt_EncoderInit(CELT32enc_inst[k], 1 /*mono*/, 48000 /*bitrate*/);
if (ok!=0) exit(0);
} else {
printf("\nError - Celt32 called with sample frequency other than 32 kHz.\n\n");
}
break;
#endif
#ifdef CODEC_G722_1_16
case webrtc::kDecoderG722_1_16 :
@ -1439,11 +1403,6 @@ int NetEQTest_free_coders(webrtc::NetEqDecoder coder, int numChannels) {
WebRtcSpeex_FreeEnc(SPEEX16enc_inst[k]);
break;
#endif
#ifdef CODEC_CELT_32
case webrtc::kDecoderCELT_32 :
WebRtcCelt_FreeEnc(CELT32enc_inst[k]);
break;
#endif
#ifdef CODEC_G722_1_16
case webrtc::kDecoderG722_1_16 :
@ -1655,21 +1614,6 @@ int NetEQTest_encode(int coder, int16_t *indata, int frameLen, unsigned char * e
}
}
#endif
#ifdef CODEC_CELT_32
else if (coder==webrtc::kDecoderCELT_32) { /* Celt */
int encodedLen = 0;
cdlen = 0;
while (cdlen <= 0) {
cdlen = WebRtcCelt_Encode(CELT32enc_inst[k], &indata[encodedLen], encoded);
encodedLen += 10*32; /* 10 ms */
}
if( (encodedLen != frameLen) || cdlen < 0) {
printf("Error encoding Celt frame!\n");
exit(0);
}
}
#endif
indata += frameLen;
encoded += cdlen;
totalLen += cdlen;