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

@ -22,8 +22,6 @@ source_set("audio_coding") {
"main/acm2/acm_amr.h",
"main/acm2/acm_amrwb.cc",
"main/acm2/acm_amrwb.h",
"main/acm2/acm_celt.cc",
"main/acm2/acm_celt.h",
"main/acm2/acm_cng.cc",
"main/acm2/acm_cng.h",
"main/acm2/acm_codec_database.cc",

View File

@ -1,184 +0,0 @@
/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "webrtc/modules/audio_coding/main/acm2/acm_celt.h"
#ifdef WEBRTC_CODEC_CELT
// NOTE! Celt is not included in the open-source package. Modify this file or
// your codec API to match the function call and name of used CELT API file.
#include "webrtc/modules/audio_coding/codecs/celt/include/celt_interface.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
#include "webrtc/system_wrappers/interface/trace.h"
#endif
namespace webrtc {
namespace acm2 {
#ifndef WEBRTC_CODEC_CELT
ACMCELT::ACMCELT(int16_t /* codec_id */)
: enc_inst_ptr_(NULL),
sampling_freq_(0),
bitrate_(0),
channels_(1) {
return;
}
ACMCELT::~ACMCELT() {
return;
}
int16_t ACMCELT::InternalEncode(uint8_t* /* bitstream */,
int16_t* /* bitstream_len_byte */) {
return -1;
}
int16_t ACMCELT::InternalInitEncoder(WebRtcACMCodecParams* /* codec_params */) {
return -1;
}
ACMGenericCodec* ACMCELT::CreateInstance(void) {
return NULL;
}
int16_t ACMCELT::InternalCreateEncoder() {
return -1;
}
void ACMCELT::DestructEncoderSafe() {
return;
}
int16_t ACMCELT::SetBitRateSafe(const int32_t /*rate*/) {
return -1;
}
#else //===================== Actual Implementation =======================
ACMCELT::ACMCELT(int16_t codec_id)
: enc_inst_ptr_(NULL),
sampling_freq_(32000), // Default sampling frequency.
bitrate_(64000), // Default rate.
channels_(1) { // Default send mono.
// TODO(tlegrand): remove later when ACMGenericCodec has a new constructor.
codec_id_ = codec_id;
return;
}
ACMCELT::~ACMCELT() {
if (enc_inst_ptr_ != NULL) {
WebRtcCelt_FreeEnc(enc_inst_ptr_);
enc_inst_ptr_ = NULL;
}
return;
}
int16_t ACMCELT::InternalEncode(uint8_t* bitstream,
int16_t* bitstream_len_byte) {
*bitstream_len_byte = 0;
// Call Encoder.
*bitstream_len_byte = WebRtcCelt_Encode(enc_inst_ptr_,
&in_audio_[in_audio_ix_read_],
bitstream);
// Increment the read index this tell the caller that how far
// we have gone forward in reading the audio buffer.
in_audio_ix_read_ += frame_len_smpl_ * channels_;
if (*bitstream_len_byte < 0) {
// Error reported from the encoder.
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalEncode: Encode error for Celt");
*bitstream_len_byte = 0;
return -1;
}
return *bitstream_len_byte;
}
int16_t ACMCELT::InternalInitEncoder(WebRtcACMCodecParams* codec_params) {
// Set bitrate and check that it is within the valid range.
int16_t status = SetBitRateSafe((codec_params->codec_inst).rate);
if (status < 0) {
return -1;
}
// If number of channels changed we need to re-create memory.
if (codec_params->codec_inst.channels != channels_) {
WebRtcCelt_FreeEnc(enc_inst_ptr_);
enc_inst_ptr_ = NULL;
// Store new number of channels.
channels_ = codec_params->codec_inst.channels;
if (WebRtcCelt_CreateEnc(&enc_inst_ptr_, channels_) < 0) {
return -1;
}
}
// Initiate encoder.
if (WebRtcCelt_EncoderInit(enc_inst_ptr_, channels_, bitrate_) >= 0) {
return 0;
} else {
return -1;
}
}
ACMGenericCodec* ACMCELT::CreateInstance(void) {
return NULL;
}
int16_t ACMCELT::InternalCreateEncoder() {
if (WebRtcCelt_CreateEnc(&enc_inst_ptr_, num_channels_) < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"InternalCreateEncoder: create encoder failed for Celt");
return -1;
}
channels_ = num_channels_;
return 0;
}
void ACMCELT::DestructEncoderSafe() {
encoder_exist_ = false;
encoder_initialized_ = false;
if (enc_inst_ptr_ != NULL) {
WebRtcCelt_FreeEnc(enc_inst_ptr_);
enc_inst_ptr_ = NULL;
}
}
int16_t ACMCELT::SetBitRateSafe(const int32_t rate) {
// Check that rate is in the valid range.
if ((rate >= 48000) && (rate <= 128000)) {
// Store new rate.
bitrate_ = rate;
// Initiate encoder with new rate.
if (WebRtcCelt_EncoderInit(enc_inst_ptr_, channels_, bitrate_) >= 0) {
return 0;
} else {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"SetBitRateSafe: Failed to initiate Celt with rate %d",
rate);
return -1;
}
} else {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"SetBitRateSafe: Invalid rate Celt, %d", rate);
return -1;
}
}
#endif
} // namespace acm2
} // namespace webrtc

View File

@ -1,52 +0,0 @@
/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_CELT_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_CELT_H_
#include "webrtc/modules/audio_coding/main/acm2/acm_generic_codec.h"
// forward declaration
struct CELT_encinst_t_;
struct CELT_decinst_t_;
namespace webrtc {
namespace acm2 {
class ACMCELT : public ACMGenericCodec {
public:
explicit ACMCELT(int16_t codec_id);
~ACMCELT();
ACMGenericCodec* CreateInstance(void);
int16_t InternalEncode(uint8_t* bitstream, int16_t* bitstream_len_byte);
int16_t InternalInitEncoder(WebRtcACMCodecParams *codec_params);
protected:
void DestructEncoderSafe();
int16_t InternalCreateEncoder();
int16_t SetBitRateSafe(const int32_t rate);
CELT_encinst_t_* enc_inst_ptr_;
uint16_t sampling_freq_;
int32_t bitrate_;
uint16_t channels_;
};
} // namespace acm2
} // namespace webrtc
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_CELT_H_

View File

@ -56,10 +56,6 @@
#include "webrtc/modules/audio_coding/codecs/amrwb/include/amrwb_interface.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_amrwb.h"
#endif
#ifdef WEBRTC_CODEC_CELT
#include "webrtc/modules/audio_coding/codecs/celt/include/celt_interface.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_celt.h"
#endif
#ifdef WEBRTC_CODEC_G722
#include "webrtc/modules/audio_coding/codecs/g722/include/g722_interface.h"
#include "webrtc/modules/audio_coding/main/acm2/acm_g722.h"
@ -141,12 +137,6 @@ const CodecInst ACMCodecDB::database_[] = {
#ifdef WEBRTC_CODEC_AMRWB
{115, "AMR-WB", 16000, 320, 1, 20000},
#endif
#ifdef WEBRTC_CODEC_CELT
// Mono
{116, "CELT", 32000, 640, 1, 64000},
// Stereo
{117, "CELT", 32000, 640, 2, 64000},
#endif
#ifdef WEBRTC_CODEC_G722
// Mono
{9, "G722", 16000, 320, 1, 64000},
@ -236,12 +226,6 @@ const ACMCodecDB::CodecSettings ACMCodecDB::codec_settings_[] = {
#ifdef WEBRTC_CODEC_AMRWB
{3, {320, 640, 960}, 0, 1, true},
#endif
#ifdef WEBRTC_CODEC_CELT
// Mono
{1, {640}, 0, 2, false},
// Stereo
{1, {640}, 0, 2, false},
#endif
#ifdef WEBRTC_CODEC_G722
// Mono
{6, {160, 320, 480, 640, 800, 960}, 0, 2, false},
@ -329,12 +313,6 @@ const NetEqDecoder ACMCodecDB::neteq_decoders_[] = {
#ifdef WEBRTC_CODEC_AMRWB
kDecoderAMRWB,
#endif
#ifdef WEBRTC_CODEC_CELT
// Mono
kDecoderCELT_32,
// Stereo
kDecoderCELT_32_2ch,
#endif
#ifdef WEBRTC_CODEC_G722
// Mono
kDecoderG722,
@ -618,14 +596,6 @@ ACMGenericCodec* ACMCodecDB::CreateCodecInstance(const CodecInst& codec_inst) {
} else if (!STR_CASE_CMP(codec_inst.plname, "AMR-WB")) {
#ifdef WEBRTC_CODEC_AMRWB
return new ACMAMRwb(kGSMAMRWB);
#endif
} else if (!STR_CASE_CMP(codec_inst.plname, "CELT")) {
#ifdef WEBRTC_CODEC_CELT
if (codec_inst.channels == 1) {
return new ACMCELT(kCELT32);
} else {
return new ACMCELT(kCELT32_2ch);
}
#endif
} else if (!STR_CASE_CMP(codec_inst.plname, "G722")) {
#ifdef WEBRTC_CODEC_G722

View File

@ -63,12 +63,6 @@ class ACMCodecDB {
#ifdef WEBRTC_CODEC_AMRWB
, kGSMAMRWB
#endif
#ifdef WEBRTC_CODEC_CELT
// Mono
, kCELT32
// Stereo
, kCELT32_2ch
#endif
#ifdef WEBRTC_CODEC_G722
// Mono
, kG722
@ -146,12 +140,6 @@ class ACMCodecDB {
#ifndef WEBRTC_CODEC_AMRWB
enum {kGSMAMRWB = -1};
#endif
#ifndef WEBRTC_CODEC_CELT
// Mono
enum {kCELT32 = -1};
// Stereo
enum {kCELT32_2ch = -1};
#endif
#ifndef WEBRTC_CODEC_G722
// Mono
enum {kG722 = -1};

View File

@ -57,8 +57,6 @@
'acm_amr.h',
'acm_amrwb.cc',
'acm_amrwb.h',
'acm_celt.cc',
'acm_celt.h',
'acm_cng.cc',
'acm_cng.h',
'acm_codec_database.cc',

View File

@ -594,21 +594,6 @@ void TestAllCodecs::Perform() {
Run(channel_a_to_b_);
outfile_b_.Close();
#endif
#ifdef WEBRTC_CODEC_CELT
if (test_mode_ != 0) {
printf("===============================================================\n");
}
test_count_++;
OpenOutFile(test_count_);
char codec_celt[] = "CELT";
RegisterSendCodec('A', codec_celt, 32000, 48000, 640, 0);
Run(channel_a_to_b_);
RegisterSendCodec('A', codec_celt, 32000, 64000, 640, 0);
Run(channel_a_to_b_);
RegisterSendCodec('A', codec_celt, 32000, 128000, 640, 0);
Run(channel_a_to_b_);
outfile_b_.Close();
#endif
#ifdef WEBRTC_CODEC_OPUS
if (test_mode_ != 0) {
printf("===============================================================\n");

View File

@ -127,9 +127,6 @@ TestStereo::TestStereo(int test_mode)
, pcma_pltype_(-1)
, pcmu_pltype_(-1)
#endif
#ifdef WEBRTC_CODEC_CELT
, celt_pltype_(-1)
#endif
#ifdef WEBRTC_CODEC_OPUS
, opus_pltype_(-1)
#endif
@ -388,29 +385,6 @@ void TestStereo::Perform() {
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
#endif
#ifdef WEBRTC_CODEC_CELT
if (test_mode_ != 0) {
printf("===========================================================\n");
printf("Test number: %d\n", test_cntr_ + 1);
printf("Test type: Stereo-to-stereo\n");
}
channel_a2b_->set_codec_mode(kStereo);
audio_channels = 2;
codec_channels = 2;
test_cntr_++;
OpenOutFile(test_cntr_);
char codec_celt[] = "CELT";
RegisterSendCodec('A', codec_celt, 32000, 48000, 640, codec_channels,
celt_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
RegisterSendCodec('A', codec_celt, 32000, 64000, 640, codec_channels,
celt_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
RegisterSendCodec('A', codec_celt, 32000, 128000, 640, codec_channels,
celt_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
#endif
#ifdef WEBRTC_CODEC_OPUS
if (test_mode_ != 0) {
printf("===========================================================\n");
@ -522,20 +496,6 @@ void TestStereo::Perform() {
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
#endif
#ifdef WEBRTC_CODEC_CELT
if (test_mode_ != 0) {
printf("===============================================================\n");
printf("Test number: %d\n", test_cntr_ + 1);
printf("Test type: Mono-to-stereo\n");
}
test_cntr_++;
channel_a2b_->set_codec_mode(kStereo);
OpenOutFile(test_cntr_);
RegisterSendCodec('A', codec_celt, 32000, 64000, 640, codec_channels,
celt_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
#endif
#ifdef WEBRTC_CODEC_OPUS
if (test_mode_ != 0) {
printf("===============================================================\n");
@ -637,19 +597,6 @@ void TestStereo::Perform() {
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
#endif
#ifdef WEBRTC_CODEC_CELT
if (test_mode_ != 0) {
printf("===============================================================\n");
printf("Test number: %d\n", test_cntr_ + 1);
printf("Test type: Stereo-to-mono\n");
}
test_cntr_++;
OpenOutFile(test_cntr_);
RegisterSendCodec('A', codec_celt, 32000, 64000, 640, codec_channels,
celt_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
#endif
#ifdef WEBRTC_CODEC_OPUS
if (test_mode_ != 0) {
printf("===============================================================\n");
@ -727,9 +674,6 @@ void TestStereo::Perform() {
printf(" PCM16\n");
#endif
printf(" G.711\n");
#ifdef WEBRTC_CODEC_CELT
printf(" CELT\n");
#endif
#ifdef WEBRTC_CODEC_OPUS
printf(" Opus\n");
#endif
@ -767,16 +711,9 @@ void TestStereo::RegisterSendCodec(char side, char* codec_name,
// Store the expected packet size in bytes, used to validate the received
// packet. Add 0.875 to always round up to a whole byte.
// For Celt the packet size in bytes is already counting the stereo part.
if (!strcmp(codec_name, "CELT")) {
pack_size_bytes_ = (uint16_t)(
static_cast<float>(pack_size * rate) /
static_cast<float>(sampling_freq_hz * 8) + 0.875) / channels;
} else {
pack_size_bytes_ = (uint16_t)(
static_cast<float>(pack_size * rate) /
static_cast<float>(sampling_freq_hz * 8) + 0.875);
}
pack_size_bytes_ = (uint16_t)(static_cast<float>(pack_size * rate) /
static_cast<float>(sampling_freq_hz * 8) +
0.875);
// Set pointer to the ACM where to register the codec
AudioCodingModule* my_acm = NULL;

View File

@ -109,9 +109,6 @@ class TestStereo : public ACMTest {
int pcma_pltype_;
int pcmu_pltype_;
#endif
#ifdef WEBRTC_CODEC_CELT
int celt_pltype_;
#endif
#ifdef WEBRTC_CODEC_OPUS
int opus_pltype_;
#endif

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;