Reformatting ACM. All changes are bit-exact in this CL.
TEST=VoE auto-test, audio_coding_module_test; only 15 ms of teststereo_out_1.pcm is not bit-exact with output file of the head revision Review URL: https://webrtc-codereview.appspot.com/937035 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3287 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -8,13 +8,14 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "acm_g7221c.h"
|
||||
#include "acm_codec_database.h"
|
||||
#include "acm_common_defs.h"
|
||||
#include "acm_neteq.h"
|
||||
#include "webrtc_neteq.h"
|
||||
#include "webrtc_neteq_help_macros.h"
|
||||
#include "trace.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_g7221c.h"
|
||||
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
|
||||
#ifdef WEBRTC_CODEC_G722_1C
|
||||
// NOTE! G.722.1C is not included in the open-source package. The following
|
||||
@ -24,62 +25,63 @@
|
||||
//
|
||||
// The API in the header file should match the one below.
|
||||
//
|
||||
// int16_t WebRtcG7221C_CreateEnc24(G722_1C_24_encinst_t_** encInst);
|
||||
// int16_t WebRtcG7221C_CreateEnc32(G722_1C_32_encinst_t_** encInst);
|
||||
// int16_t WebRtcG7221C_CreateEnc48(G722_1C_48_encinst_t_** encInst);
|
||||
// int16_t WebRtcG7221C_CreateDec24(G722_1C_24_decinst_t_** decInst);
|
||||
// int16_t WebRtcG7221C_CreateDec32(G722_1C_32_decinst_t_** decInst);
|
||||
// int16_t WebRtcG7221C_CreateDec48(G722_1C_48_decinst_t_** decInst);
|
||||
|
||||
// int16_t WebRtcG7221C_CreateEnc24(G722_1C_24_encinst_t_** enc_inst);
|
||||
// int16_t WebRtcG7221C_CreateEnc32(G722_1C_32_encinst_t_** enc_inst);
|
||||
// int16_t WebRtcG7221C_CreateEnc48(G722_1C_48_encinst_t_** enc_inst);
|
||||
// int16_t WebRtcG7221C_CreateDec24(G722_1C_24_decinst_t_** dec_inst);
|
||||
// int16_t WebRtcG7221C_CreateDec32(G722_1C_32_decinst_t_** dec_inst);
|
||||
// int16_t WebRtcG7221C_CreateDec48(G722_1C_48_decinst_t_** dec_inst);
|
||||
//
|
||||
// int16_t WebRtcG7221C_FreeEnc24(G722_1C_24_encinst_t_** encInst);
|
||||
// int16_t WebRtcG7221C_FreeEnc32(G722_1C_32_encinst_t_** encInst);
|
||||
// int16_t WebRtcG7221C_FreeEnc48(G722_1C_48_encinst_t_** encInst);
|
||||
// int16_t WebRtcG7221C_FreeDec24(G722_1C_24_decinst_t_** decInst);
|
||||
// int16_t WebRtcG7221C_FreeDec32(G722_1C_32_decinst_t_** decInst);
|
||||
// int16_t WebRtcG7221C_FreeDec48(G722_1C_48_decinst_t_** decInst);
|
||||
// int16_t WebRtcG7221C_FreeEnc24(G722_1C_24_encinst_t_** enc_inst);
|
||||
// int16_t WebRtcG7221C_FreeEnc32(G722_1C_32_encinst_t_** enc_inst);
|
||||
// int16_t WebRtcG7221C_FreeEnc48(G722_1C_48_encinst_t_** enc_inst);
|
||||
// int16_t WebRtcG7221C_FreeDec24(G722_1C_24_decinst_t_** dec_inst);
|
||||
// int16_t WebRtcG7221C_FreeDec32(G722_1C_32_decinst_t_** dec_inst);
|
||||
// int16_t WebRtcG7221C_FreeDec48(G722_1C_48_decinst_t_** dec_inst);
|
||||
//
|
||||
// int16_t WebRtcG7221C_EncoderInit24(G722_1C_24_encinst_t_* encInst);
|
||||
// int16_t WebRtcG7221C_EncoderInit32(G722_1C_32_encinst_t_* encInst);
|
||||
// int16_t WebRtcG7221C_EncoderInit48(G722_1C_48_encinst_t_* encInst);
|
||||
// int16_t WebRtcG7221C_DecoderInit24(G722_1C_24_decinst_t_* decInst);
|
||||
// int16_t WebRtcG7221C_DecoderInit32(G722_1C_32_decinst_t_* decInst);
|
||||
// int16_t WebRtcG7221C_DecoderInit48(G722_1C_48_decinst_t_* decInst);
|
||||
// int16_t WebRtcG7221C_EncoderInit24(G722_1C_24_encinst_t_* enc_inst);
|
||||
// int16_t WebRtcG7221C_EncoderInit32(G722_1C_32_encinst_t_* enc_inst);
|
||||
// int16_t WebRtcG7221C_EncoderInit48(G722_1C_48_encinst_t_* enc_inst);
|
||||
// int16_t WebRtcG7221C_DecoderInit24(G722_1C_24_decinst_t_* dec_inst);
|
||||
// int16_t WebRtcG7221C_DecoderInit32(G722_1C_32_decinst_t_* dec_inst);
|
||||
// int16_t WebRtcG7221C_DecoderInit48(G722_1C_48_decinst_t_* dec_inst);
|
||||
//
|
||||
// int16_t WebRtcG7221C_Encode24(G722_1C_24_encinst_t_* encInst,
|
||||
// int16_t WebRtcG7221C_Encode24(G722_1C_24_encinst_t_* enc_inst,
|
||||
// int16_t* input,
|
||||
// int16_t len,
|
||||
// int16_t* output);
|
||||
// int16_t WebRtcG7221C_Encode32(G722_1C_32_encinst_t_* encInst,
|
||||
// int16_t WebRtcG7221C_Encode32(G722_1C_32_encinst_t_* enc_inst,
|
||||
// int16_t* input,
|
||||
// int16_t len,
|
||||
// int16_t* output);
|
||||
// int16_t WebRtcG7221C_Encode48(G722_1C_48_encinst_t_* encInst,
|
||||
// int16_t WebRtcG7221C_Encode48(G722_1C_48_encinst_t_* enc_inst,
|
||||
// int16_t* input,
|
||||
// int16_t len,
|
||||
// int16_t* output);
|
||||
//
|
||||
// int16_t WebRtcG7221C_Decode24(G722_1C_24_decinst_t_* decInst,
|
||||
// int16_t WebRtcG7221C_Decode24(G722_1C_24_decinst_t_* dec_inst,
|
||||
// int16_t* bitstream,
|
||||
// int16_t len,
|
||||
// int16_t* output);
|
||||
// int16_t WebRtcG7221C_Decode32(G722_1C_32_decinst_t_* decInst,
|
||||
// int16_t WebRtcG7221C_Decode32(G722_1C_32_decinst_t_* dec_inst,
|
||||
// int16_t* bitstream,
|
||||
// int16_t len,
|
||||
// int16_t* output);
|
||||
// int16_t WebRtcG7221C_Decode48(G722_1C_48_decinst_t_* decInst,
|
||||
// int16_t WebRtcG7221C_Decode48(G722_1C_48_decinst_t_* dec_inst,
|
||||
// int16_t* bitstream,
|
||||
// int16_t len,
|
||||
// int16_t* output);
|
||||
//
|
||||
// int16_t WebRtcG7221C_DecodePlc24(G722_1C_24_decinst_t_* decInst,
|
||||
// int16_t WebRtcG7221C_DecodePlc24(G722_1C_24_decinst_t_* dec_inst,
|
||||
// int16_t* output,
|
||||
// int16_t nrLostFrames);
|
||||
// int16_t WebRtcG7221C_DecodePlc32(G722_1C_32_decinst_t_* decInst,
|
||||
// int16_t nr_lost_frames);
|
||||
// int16_t WebRtcG7221C_DecodePlc32(G722_1C_32_decinst_t_* dec_inst,
|
||||
// int16_t* output,
|
||||
// int16_t nrLostFrames);
|
||||
// int16_t WebRtcG7221C_DecodePlc48(G722_1C_48_decinst_t_* decInst,
|
||||
// int16_t nr_lost_frames);
|
||||
// int16_t WebRtcG7221C_DecodePlc48(G722_1C_48_decinst_t_* dec_inst,
|
||||
// int16_t* output,
|
||||
// int16_t nrLostFrames);
|
||||
// int16_t nr_lost_frames);
|
||||
#include "g7221c_interface.h"
|
||||
#endif
|
||||
|
||||
@ -87,20 +89,20 @@ namespace webrtc {
|
||||
|
||||
#ifndef WEBRTC_CODEC_G722_1C
|
||||
|
||||
ACMG722_1C::ACMG722_1C(WebRtc_Word16 /* codecID */)
|
||||
: _operationalRate(-1),
|
||||
_encoderInstPtr(NULL),
|
||||
_encoderInstPtrRight(NULL),
|
||||
_decoderInstPtr(NULL),
|
||||
_encoderInst24Ptr(NULL),
|
||||
_encoderInst24PtrR(NULL),
|
||||
_encoderInst32Ptr(NULL),
|
||||
_encoderInst32PtrR(NULL),
|
||||
_encoderInst48Ptr(NULL),
|
||||
_encoderInst48PtrR(NULL),
|
||||
_decoderInst24Ptr(NULL),
|
||||
_decoderInst32Ptr(NULL),
|
||||
_decoderInst48Ptr(NULL) {
|
||||
ACMG722_1C::ACMG722_1C(WebRtc_Word16 /* codec_id */)
|
||||
: operational_rate_(-1),
|
||||
encoder_inst_ptr_(NULL),
|
||||
encoder_inst_ptr_right_(NULL),
|
||||
decoder_inst_ptr_(NULL),
|
||||
encoder_inst24_ptr_(NULL),
|
||||
encoder_inst24_ptr_right_(NULL),
|
||||
encoder_inst32_ptr_(NULL),
|
||||
encoder_inst32_ptr_right_(NULL),
|
||||
encoder_inst48_ptr_(NULL),
|
||||
encoder_inst48_ptr_right_(NULL),
|
||||
decoder_inst24_ptr_(NULL),
|
||||
decoder_inst32_ptr_(NULL),
|
||||
decoder_inst48_ptr_(NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -109,31 +111,31 @@ ACMG722_1C::~ACMG722_1C() {
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722_1C::InternalEncode(
|
||||
WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */) {
|
||||
WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16* /* bitstream_len_byte */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722_1C::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
WebRtc_Word16 ACMG722_1C::DecodeSafe(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16 /* bitstream_len_byte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722_1C::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722_1C::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMG722_1C::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||
const CodecInst& /* codecInst */) {
|
||||
WebRtc_Word32 ACMG722_1C::CodecDef(WebRtcNetEQ_CodecDef& /* codec_def */,
|
||||
const CodecInst& /* codec_inst */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -157,66 +159,74 @@ void ACMG722_1C::DestructDecoderSafe() {
|
||||
return;
|
||||
}
|
||||
|
||||
void ACMG722_1C::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||
void ACMG722_1C::InternalDestructEncoderInst(void* /* ptr_inst */) {
|
||||
return;
|
||||
}
|
||||
|
||||
#else //===================== Actual Implementation =======================
|
||||
ACMG722_1C::ACMG722_1C(WebRtc_Word16 codecID) :
|
||||
_encoderInstPtr(NULL), _encoderInstPtrRight(NULL), _decoderInstPtr(NULL),
|
||||
_encoderInst24Ptr(NULL), _encoderInst24PtrR(NULL), _encoderInst32Ptr(NULL),
|
||||
_encoderInst32PtrR(NULL), _encoderInst48Ptr(NULL), _encoderInst48PtrR(NULL),
|
||||
_decoderInst24Ptr(NULL), _decoderInst32Ptr(NULL), _decoderInst48Ptr(NULL) {
|
||||
_codecID = codecID;
|
||||
if (_codecID == ACMCodecDB::kG722_1C_24) {
|
||||
_operationalRate = 24000;
|
||||
} else if (_codecID == ACMCodecDB::kG722_1C_32) {
|
||||
_operationalRate = 32000;
|
||||
} else if (_codecID == ACMCodecDB::kG722_1C_48) {
|
||||
_operationalRate = 48000;
|
||||
ACMG722_1C::ACMG722_1C(WebRtc_Word16 codec_id)
|
||||
: encoder_inst_ptr_(NULL),
|
||||
encoder_inst_ptr_right_(NULL),
|
||||
decoder_inst_ptr_(NULL),
|
||||
encoder_inst24_ptr_(NULL),
|
||||
encoder_inst24_ptr_right_(NULL),
|
||||
encoder_inst32_ptr_(NULL),
|
||||
encoder_inst32_ptr_right_(NULL),
|
||||
encoder_inst48_ptr_(NULL),
|
||||
encoder_inst48_ptr_right_(NULL),
|
||||
decoder_inst24_ptr_(NULL),
|
||||
decoder_inst32_ptr_(NULL),
|
||||
decoder_inst48_ptr_(NULL) {
|
||||
codec_id_ = codec_id;
|
||||
if (codec_id_ == ACMCodecDB::kG722_1C_24) {
|
||||
operational_rate_ = 24000;
|
||||
} else if (codec_id_ == ACMCodecDB::kG722_1C_32) {
|
||||
operational_rate_ = 32000;
|
||||
} else if (codec_id_ == ACMCodecDB::kG722_1C_48) {
|
||||
operational_rate_ = 48000;
|
||||
} else {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"Wrong codec id for G722_1c.");
|
||||
_operationalRate = -1;
|
||||
operational_rate_ = -1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
ACMG722_1C::~ACMG722_1C() {
|
||||
if (_encoderInstPtr != NULL) {
|
||||
delete _encoderInstPtr;
|
||||
_encoderInstPtr = NULL;
|
||||
if (encoder_inst_ptr_ != NULL) {
|
||||
delete encoder_inst_ptr_;
|
||||
encoder_inst_ptr_ = NULL;
|
||||
}
|
||||
if (_encoderInstPtrRight != NULL) {
|
||||
delete _encoderInstPtrRight;
|
||||
_encoderInstPtrRight = NULL;
|
||||
if (encoder_inst_ptr_right_ != NULL) {
|
||||
delete encoder_inst_ptr_right_;
|
||||
encoder_inst_ptr_right_ = NULL;
|
||||
}
|
||||
if (_decoderInstPtr != NULL) {
|
||||
delete _decoderInstPtr;
|
||||
_decoderInstPtr = NULL;
|
||||
if (decoder_inst_ptr_ != NULL) {
|
||||
delete decoder_inst_ptr_;
|
||||
decoder_inst_ptr_ = NULL;
|
||||
}
|
||||
|
||||
switch (_operationalRate) {
|
||||
switch (operational_rate_) {
|
||||
case 24000: {
|
||||
_encoderInst24Ptr = NULL;
|
||||
_encoderInst24PtrR = NULL;
|
||||
_decoderInst24Ptr = NULL;
|
||||
encoder_inst24_ptr_ = NULL;
|
||||
encoder_inst24_ptr_right_ = NULL;
|
||||
decoder_inst24_ptr_ = NULL;
|
||||
break;
|
||||
}
|
||||
case 32000: {
|
||||
_encoderInst32Ptr = NULL;
|
||||
_encoderInst32PtrR = NULL;
|
||||
_decoderInst32Ptr = NULL;
|
||||
encoder_inst32_ptr_ = NULL;
|
||||
encoder_inst32_ptr_right_ = NULL;
|
||||
decoder_inst32_ptr_ = NULL;
|
||||
break;
|
||||
}
|
||||
case 48000: {
|
||||
_encoderInst48Ptr = NULL;
|
||||
_encoderInst48PtrR = NULL;
|
||||
_decoderInst48Ptr = NULL;
|
||||
encoder_inst48_ptr_ = NULL;
|
||||
encoder_inst48_ptr_right_ = NULL;
|
||||
decoder_inst48_ptr_ = NULL;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"Wrong rate for G722_1c.");
|
||||
break;
|
||||
}
|
||||
@ -224,104 +234,107 @@ ACMG722_1C::~ACMG722_1C() {
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722_1C::InternalEncode(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte) {
|
||||
WebRtc_Word16 leftChannel[640];
|
||||
WebRtc_Word16 rightChannel[640];
|
||||
WebRtc_Word16 lenInBytes;
|
||||
WebRtc_Word16 outB[240];
|
||||
WebRtc_Word16 ACMG722_1C::InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitstream_len_byte) {
|
||||
WebRtc_Word16 left_channel[640];
|
||||
WebRtc_Word16 right_channel[640];
|
||||
WebRtc_Word16 len_in_bytes;
|
||||
WebRtc_Word16 out_bits[240];
|
||||
|
||||
// If stereo, split input signal in left and right channel before encoding
|
||||
if (_noChannels == 2) {
|
||||
for (int i = 0, j = 0; i < _frameLenSmpl * 2; i += 2, j++) {
|
||||
leftChannel[j] = _inAudio[_inAudioIxRead + i];
|
||||
rightChannel[j] = _inAudio[_inAudioIxRead + i + 1];
|
||||
if (num_channels_ == 2) {
|
||||
for (int i = 0, j = 0; i < frame_len_smpl_ * 2; i += 2, j++) {
|
||||
left_channel[j] = in_audio_[in_audio_ix_read_ + i];
|
||||
right_channel[j] = in_audio_[in_audio_ix_read_ + i + 1];
|
||||
}
|
||||
} else {
|
||||
memcpy(leftChannel, &_inAudio[_inAudioIxRead], 640);
|
||||
memcpy(left_channel, &in_audio_[in_audio_ix_read_], 640);
|
||||
}
|
||||
|
||||
switch (_operationalRate) {
|
||||
switch (operational_rate_) {
|
||||
case 24000: {
|
||||
lenInBytes = WebRtcG7221C_Encode24(_encoderInst24Ptr, leftChannel, 640,
|
||||
&outB[0]);
|
||||
if (_noChannels == 2) {
|
||||
lenInBytes += WebRtcG7221C_Encode24(_encoderInst24PtrR, rightChannel,
|
||||
640, &outB[lenInBytes / 2]);
|
||||
len_in_bytes = WebRtcG7221C_Encode24(encoder_inst24_ptr_, left_channel,
|
||||
640, &out_bits[0]);
|
||||
if (num_channels_ == 2) {
|
||||
len_in_bytes += WebRtcG7221C_Encode24(encoder_inst24_ptr_right_,
|
||||
right_channel, 640,
|
||||
&out_bits[len_in_bytes / 2]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 32000: {
|
||||
lenInBytes = WebRtcG7221C_Encode32(_encoderInst32Ptr, leftChannel, 640,
|
||||
&outB[0]);
|
||||
if (_noChannels == 2) {
|
||||
lenInBytes += WebRtcG7221C_Encode32(_encoderInst32PtrR, rightChannel,
|
||||
640, &outB[lenInBytes / 2]);
|
||||
len_in_bytes = WebRtcG7221C_Encode32(encoder_inst32_ptr_, left_channel,
|
||||
640, &out_bits[0]);
|
||||
if (num_channels_ == 2) {
|
||||
len_in_bytes += WebRtcG7221C_Encode32(encoder_inst32_ptr_right_,
|
||||
right_channel, 640,
|
||||
&out_bits[len_in_bytes / 2]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 48000: {
|
||||
lenInBytes = WebRtcG7221C_Encode48(_encoderInst48Ptr, leftChannel, 640,
|
||||
&outB[0]);
|
||||
if (_noChannels == 2) {
|
||||
lenInBytes += WebRtcG7221C_Encode48(_encoderInst48PtrR, rightChannel,
|
||||
640, &outB[lenInBytes / 2]);
|
||||
len_in_bytes = WebRtcG7221C_Encode48(encoder_inst48_ptr_, left_channel,
|
||||
640, &out_bits[0]);
|
||||
if (num_channels_ == 2) {
|
||||
len_in_bytes += WebRtcG7221C_Encode48(encoder_inst48_ptr_right_,
|
||||
right_channel, 640,
|
||||
&out_bits[len_in_bytes / 2]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalEncode: Wrong rate for G722_1c.");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(bitStream, outB, lenInBytes);
|
||||
*bitStreamLenByte = lenInBytes;
|
||||
memcpy(bitstream, out_bits, len_in_bytes);
|
||||
*bitstream_len_byte = len_in_bytes;
|
||||
|
||||
// increment the read index this tell the caller that how far
|
||||
// we have gone forward in reading the audio buffer
|
||||
_inAudioIxRead += 640 * _noChannels;
|
||||
in_audio_ix_read_ += 640 * num_channels_;
|
||||
|
||||
return *bitStreamLenByte;
|
||||
return *bitstream_len_byte;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722_1C::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMG722_1C::DecodeSafe(WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16 /* bitstream_len_byte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
WebRtc_Word16* /* audio_samples */,
|
||||
WebRtc_Word8* /* speech_type */) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722_1C::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* codecParams) {
|
||||
WebRtcACMCodecParams* codec_params) {
|
||||
WebRtc_Word16 ret;
|
||||
|
||||
switch (_operationalRate) {
|
||||
switch (operational_rate_) {
|
||||
case 24000: {
|
||||
ret = WebRtcG7221C_EncoderInit24(_encoderInst24PtrR);
|
||||
ret = WebRtcG7221C_EncoderInit24(encoder_inst24_ptr_right_);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
return WebRtcG7221C_EncoderInit24(_encoderInst24Ptr);
|
||||
return WebRtcG7221C_EncoderInit24(encoder_inst24_ptr_);
|
||||
}
|
||||
case 32000: {
|
||||
ret = WebRtcG7221C_EncoderInit32(_encoderInst32PtrR);
|
||||
ret = WebRtcG7221C_EncoderInit32(encoder_inst32_ptr_right_);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
return WebRtcG7221C_EncoderInit32(_encoderInst32Ptr);
|
||||
return WebRtcG7221C_EncoderInit32(encoder_inst32_ptr_);
|
||||
}
|
||||
case 48000: {
|
||||
ret = WebRtcG7221C_EncoderInit48(_encoderInst48PtrR);
|
||||
ret = WebRtcG7221C_EncoderInit48(encoder_inst48_ptr_right_);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
return WebRtcG7221C_EncoderInit48(_encoderInst48Ptr);
|
||||
return WebRtcG7221C_EncoderInit48(encoder_inst48_ptr_);
|
||||
}
|
||||
default: {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalInitEncode: Wrong rate for G722_1c.");
|
||||
return -1;
|
||||
}
|
||||
@ -329,30 +342,29 @@ WebRtc_Word16 ACMG722_1C::InternalInitEncoder(
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722_1C::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
switch (_operationalRate) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
switch (operational_rate_) {
|
||||
case 24000: {
|
||||
return WebRtcG7221C_DecoderInit24(_decoderInst24Ptr);
|
||||
return WebRtcG7221C_DecoderInit24(decoder_inst24_ptr_);
|
||||
}
|
||||
case 32000: {
|
||||
return WebRtcG7221C_DecoderInit32(_decoderInst32Ptr);
|
||||
return WebRtcG7221C_DecoderInit32(decoder_inst32_ptr_);
|
||||
}
|
||||
case 48000: {
|
||||
return WebRtcG7221C_DecoderInit48(_decoderInst48Ptr);
|
||||
return WebRtcG7221C_DecoderInit48(decoder_inst48_ptr_);
|
||||
}
|
||||
default: {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalInitDecoder: Wrong rate for G722_1c.");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMG722_1C::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst) {
|
||||
|
||||
if (!_decoderInitialized) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WebRtc_Word32 ACMG722_1C::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst) {
|
||||
if (!decoder_initialized_) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"CodeDef: decoder not initialized for G722_1c");
|
||||
return -1;
|
||||
}
|
||||
@ -364,27 +376,27 @@ WebRtc_Word32 ACMG722_1C::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
// "SET_CODEC_PAR" & "SET_G722_1_XX_FUNCTION."
|
||||
// Then return the structure back to NetEQ to add the codec to it's
|
||||
// database.
|
||||
switch (_operationalRate) {
|
||||
switch (operational_rate_) {
|
||||
case 24000: {
|
||||
SET_CODEC_PAR((codecDef), kDecoderG722_1C_24, codecInst.pltype,
|
||||
_decoderInst24Ptr, 32000);
|
||||
SET_G722_1C_24_FUNCTIONS((codecDef));
|
||||
SET_CODEC_PAR((codec_def), kDecoderG722_1C_24, codec_inst.pltype,
|
||||
decoder_inst24_ptr_, 32000);
|
||||
SET_G722_1C_24_FUNCTIONS((codec_def));
|
||||
break;
|
||||
}
|
||||
case 32000: {
|
||||
SET_CODEC_PAR((codecDef), kDecoderG722_1C_32, codecInst.pltype,
|
||||
_decoderInst32Ptr, 32000);
|
||||
SET_G722_1C_32_FUNCTIONS((codecDef));
|
||||
SET_CODEC_PAR((codec_def), kDecoderG722_1C_32, codec_inst.pltype,
|
||||
decoder_inst32_ptr_, 32000);
|
||||
SET_G722_1C_32_FUNCTIONS((codec_def));
|
||||
break;
|
||||
}
|
||||
case 48000: {
|
||||
SET_CODEC_PAR((codecDef), kDecoderG722_1C_32, codecInst.pltype,
|
||||
_decoderInst48Ptr, 32000);
|
||||
SET_G722_1C_48_FUNCTIONS((codecDef));
|
||||
SET_CODEC_PAR((codec_def), kDecoderG722_1C_32, codec_inst.pltype,
|
||||
decoder_inst48_ptr_, 32000);
|
||||
SET_G722_1C_48_FUNCTIONS((codec_def));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"CodeDef: Wrong rate for G722_1c.");
|
||||
return -1;
|
||||
}
|
||||
@ -398,27 +410,27 @@ ACMG722_1C::CreateInstance(void) {
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722_1C::InternalCreateEncoder() {
|
||||
if ((_encoderInstPtr == NULL) || (_encoderInstPtrRight == NULL)) {
|
||||
if ((encoder_inst_ptr_ == NULL) || (encoder_inst_ptr_right_ == NULL)) {
|
||||
return -1;
|
||||
}
|
||||
switch (_operationalRate) {
|
||||
switch (operational_rate_) {
|
||||
case 24000: {
|
||||
WebRtcG7221C_CreateEnc24(&_encoderInst24Ptr);
|
||||
WebRtcG7221C_CreateEnc24(&_encoderInst24PtrR);
|
||||
WebRtcG7221C_CreateEnc24(&encoder_inst24_ptr_);
|
||||
WebRtcG7221C_CreateEnc24(&encoder_inst24_ptr_right_);
|
||||
break;
|
||||
}
|
||||
case 32000: {
|
||||
WebRtcG7221C_CreateEnc32(&_encoderInst32Ptr);
|
||||
WebRtcG7221C_CreateEnc32(&_encoderInst32PtrR);
|
||||
WebRtcG7221C_CreateEnc32(&encoder_inst32_ptr_);
|
||||
WebRtcG7221C_CreateEnc32(&encoder_inst32_ptr_right_);
|
||||
break;
|
||||
}
|
||||
case 48000: {
|
||||
WebRtcG7221C_CreateEnc48(&_encoderInst48Ptr);
|
||||
WebRtcG7221C_CreateEnc48(&_encoderInst48PtrR);
|
||||
WebRtcG7221C_CreateEnc48(&encoder_inst48_ptr_);
|
||||
WebRtcG7221C_CreateEnc48(&encoder_inst48_ptr_right_);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalCreateEncoder: Wrong rate for G722_1c.");
|
||||
return -1;
|
||||
}
|
||||
@ -427,42 +439,42 @@ WebRtc_Word16 ACMG722_1C::InternalCreateEncoder() {
|
||||
}
|
||||
|
||||
void ACMG722_1C::DestructEncoderSafe() {
|
||||
_encoderExist = false;
|
||||
_encoderInitialized = false;
|
||||
if (_encoderInstPtr != NULL) {
|
||||
delete _encoderInstPtr;
|
||||
_encoderInstPtr = NULL;
|
||||
encoder_exist_ = false;
|
||||
encoder_initialized_ = false;
|
||||
if (encoder_inst_ptr_ != NULL) {
|
||||
delete encoder_inst_ptr_;
|
||||
encoder_inst_ptr_ = NULL;
|
||||
}
|
||||
if (_encoderInstPtrRight != NULL) {
|
||||
delete _encoderInstPtrRight;
|
||||
_encoderInstPtrRight = NULL;
|
||||
if (encoder_inst_ptr_right_ != NULL) {
|
||||
delete encoder_inst_ptr_right_;
|
||||
encoder_inst_ptr_right_ = NULL;
|
||||
}
|
||||
_encoderInst24Ptr = NULL;
|
||||
_encoderInst32Ptr = NULL;
|
||||
_encoderInst48Ptr = NULL;
|
||||
encoder_inst24_ptr_ = NULL;
|
||||
encoder_inst32_ptr_ = NULL;
|
||||
encoder_inst48_ptr_ = NULL;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMG722_1C::InternalCreateDecoder() {
|
||||
if (_decoderInstPtr == NULL) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
if (decoder_inst_ptr_ == NULL) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalCreateEncoder: cannot create decoder");
|
||||
return -1;
|
||||
}
|
||||
switch (_operationalRate) {
|
||||
switch (operational_rate_) {
|
||||
case 24000: {
|
||||
WebRtcG7221C_CreateDec24(&_decoderInst24Ptr);
|
||||
WebRtcG7221C_CreateDec24(&decoder_inst24_ptr_);
|
||||
break;
|
||||
}
|
||||
case 32000: {
|
||||
WebRtcG7221C_CreateDec32(&_decoderInst32Ptr);
|
||||
WebRtcG7221C_CreateDec32(&decoder_inst32_ptr_);
|
||||
break;
|
||||
}
|
||||
case 48000: {
|
||||
WebRtcG7221C_CreateDec48(&_decoderInst48Ptr);
|
||||
WebRtcG7221C_CreateDec48(&decoder_inst48_ptr_);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
|
||||
"InternalCreateEncoder: Wrong rate for G722_1c.");
|
||||
return -1;
|
||||
}
|
||||
@ -471,24 +483,24 @@ WebRtc_Word16 ACMG722_1C::InternalCreateDecoder() {
|
||||
}
|
||||
|
||||
void ACMG722_1C::DestructDecoderSafe() {
|
||||
_decoderExist = false;
|
||||
_decoderInitialized = false;
|
||||
if (_decoderInstPtr != NULL) {
|
||||
delete _decoderInstPtr;
|
||||
_decoderInstPtr = NULL;
|
||||
decoder_exist_ = false;
|
||||
decoder_initialized_ = false;
|
||||
if (decoder_inst_ptr_ != NULL) {
|
||||
delete decoder_inst_ptr_;
|
||||
decoder_inst_ptr_ = NULL;
|
||||
}
|
||||
_decoderInst24Ptr = NULL;
|
||||
_decoderInst32Ptr = NULL;
|
||||
_decoderInst48Ptr = NULL;
|
||||
decoder_inst24_ptr_ = NULL;
|
||||
decoder_inst32_ptr_ = NULL;
|
||||
decoder_inst48_ptr_ = NULL;
|
||||
}
|
||||
|
||||
void ACMG722_1C::InternalDestructEncoderInst(void* ptrInst) {
|
||||
if (ptrInst != NULL) {
|
||||
delete ptrInst;
|
||||
void ACMG722_1C::InternalDestructEncoderInst(void* ptr_inst) {
|
||||
if (ptr_inst != NULL) {
|
||||
delete ptr_inst;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace webrtc
|
||||
} // namespace webrtc
|
||||
|
||||
Reference in New Issue
Block a user