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:
@ -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
|
||||
@ -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_
|
||||
@ -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
|
||||
|
||||
@ -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};
|
||||
|
||||
@ -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',
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user