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,24 +8,24 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "acm_pcm16b.h"
|
||||
#include "webrtc/modules/audio_coding/main/source/acm_pcm16b.h"
|
||||
|
||||
#include "acm_codec_database.h"
|
||||
#include "acm_common_defs.h"
|
||||
#include "acm_neteq.h"
|
||||
#include "trace.h"
|
||||
#include "webrtc_neteq.h"
|
||||
#include "webrtc_neteq_help_macros.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_PCM16
|
||||
#include "pcm16b.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/pcm16b/include/pcm16b.h"
|
||||
#endif
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
#ifndef WEBRTC_CODEC_PCM16
|
||||
|
||||
ACMPCM16B::ACMPCM16B(WebRtc_Word16 /* codecID */) {
|
||||
ACMPCM16B::ACMPCM16B(WebRtc_Word16 /* codec_id */) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -33,31 +33,32 @@ ACMPCM16B::~ACMPCM16B() {
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMPCM16B::InternalEncode(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */) {
|
||||
WebRtc_Word16 ACMPCM16B::InternalEncode(
|
||||
WebRtc_UWord8* /* bitstream */,
|
||||
WebRtc_Word16* /* bitstream_len_byte */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMPCM16B::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMPCM16B::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 -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMPCM16B::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMPCM16B::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMPCM16B::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||
const CodecInst& /* codecInst */) {
|
||||
WebRtc_Word32 ACMPCM16B::CodecDef(WebRtcNetEQ_CodecDef& /* codec_def */,
|
||||
const CodecInst& /* codec_inst */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -73,7 +74,7 @@ WebRtc_Word16 ACMPCM16B::InternalCreateDecoder() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
void ACMPCM16B::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||
void ACMPCM16B::InternalDestructEncoderInst(void* /* ptr_inst */) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -90,67 +91,67 @@ void ACMPCM16B::SplitStereoPacket(uint8_t* /*payload*/,
|
||||
}
|
||||
|
||||
#else //===================== Actual Implementation =======================
|
||||
ACMPCM16B::ACMPCM16B(WebRtc_Word16 codecID) {
|
||||
_codecID = codecID;
|
||||
_samplingFreqHz = ACMCodecDB::CodecFreq(_codecID);
|
||||
ACMPCM16B::ACMPCM16B(WebRtc_Word16 codec_id) {
|
||||
codec_id_ = codec_id;
|
||||
sampling_freq_hz_ = ACMCodecDB::CodecFreq(codec_id_);
|
||||
}
|
||||
|
||||
ACMPCM16B::~ACMPCM16B() {
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMPCM16B::InternalEncode(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte) {
|
||||
*bitStreamLenByte = WebRtcPcm16b_Encode(&_inAudio[_inAudioIxRead],
|
||||
_frameLenSmpl * _noChannels,
|
||||
bitStream);
|
||||
WebRtc_Word16 ACMPCM16B::InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitstream_len_byte) {
|
||||
*bitstream_len_byte = WebRtcPcm16b_Encode(&in_audio_[in_audio_ix_read_],
|
||||
frame_len_smpl_ * num_channels_,
|
||||
bitstream);
|
||||
// Increment the read index to tell the caller that how far
|
||||
// we have gone forward in reading the audio buffer.
|
||||
_inAudioIxRead += _frameLenSmpl * _noChannels;
|
||||
return *bitStreamLenByte;
|
||||
in_audio_ix_read_ += frame_len_smpl_ * num_channels_;
|
||||
return *bitstream_len_byte;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMPCM16B::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16 ACMPCM16B::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 ACMPCM16B::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
// This codec does not need initialization, PCM has no instance.
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16 ACMPCM16B::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtcACMCodecParams* /* codec_params */) {
|
||||
// This codec does not need initialization, PCM has no instance.
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word32 ACMPCM16B::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst) {
|
||||
WebRtc_Word32 ACMPCM16B::CodecDef(WebRtcNetEQ_CodecDef& codec_def,
|
||||
const CodecInst& codec_inst) {
|
||||
// Fill up the structure by calling "SET_CODEC_PAR" & "SET_PCMU_FUNCTION".
|
||||
// Then call NetEQ to add the codec to it's database.
|
||||
if (codecInst.channels == 1) {
|
||||
switch(_samplingFreqHz) {
|
||||
if (codec_inst.channels == 1) {
|
||||
switch (sampling_freq_hz_) {
|
||||
case 8000: {
|
||||
SET_CODEC_PAR(codecDef, kDecoderPCM16B, codecInst.pltype, NULL, 8000);
|
||||
SET_PCM16B_FUNCTIONS(codecDef);
|
||||
SET_CODEC_PAR(codec_def, kDecoderPCM16B, codec_inst.pltype, NULL, 8000);
|
||||
SET_PCM16B_FUNCTIONS(codec_def);
|
||||
break;
|
||||
}
|
||||
case 16000: {
|
||||
SET_CODEC_PAR(codecDef, kDecoderPCM16Bwb, codecInst.pltype, NULL,
|
||||
16000);
|
||||
SET_PCM16B_WB_FUNCTIONS(codecDef);
|
||||
SET_CODEC_PAR(codec_def, kDecoderPCM16Bwb, codec_inst.pltype, NULL,
|
||||
16000);
|
||||
SET_PCM16B_WB_FUNCTIONS(codec_def);
|
||||
break;
|
||||
}
|
||||
case 32000: {
|
||||
SET_CODEC_PAR(codecDef, kDecoderPCM16Bswb32kHz, codecInst.pltype,
|
||||
NULL, 32000);
|
||||
SET_PCM16B_SWB32_FUNCTIONS(codecDef);
|
||||
SET_CODEC_PAR(codec_def, kDecoderPCM16Bswb32kHz, codec_inst.pltype,
|
||||
NULL, 32000);
|
||||
SET_PCM16B_SWB32_FUNCTIONS(codec_def);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@ -158,23 +159,23 @@ WebRtc_Word32 ACMPCM16B::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch(_samplingFreqHz) {
|
||||
switch (sampling_freq_hz_) {
|
||||
case 8000: {
|
||||
SET_CODEC_PAR(codecDef, kDecoderPCM16B_2ch, codecInst.pltype, NULL,
|
||||
8000);
|
||||
SET_PCM16B_FUNCTIONS(codecDef);
|
||||
SET_CODEC_PAR(codec_def, kDecoderPCM16B_2ch, codec_inst.pltype, NULL,
|
||||
8000);
|
||||
SET_PCM16B_FUNCTIONS(codec_def);
|
||||
break;
|
||||
}
|
||||
case 16000: {
|
||||
SET_CODEC_PAR(codecDef, kDecoderPCM16Bwb_2ch, codecInst.pltype,
|
||||
NULL, 16000);
|
||||
SET_PCM16B_WB_FUNCTIONS(codecDef);
|
||||
SET_CODEC_PAR(codec_def, kDecoderPCM16Bwb_2ch, codec_inst.pltype,
|
||||
NULL, 16000);
|
||||
SET_PCM16B_WB_FUNCTIONS(codec_def);
|
||||
break;
|
||||
}
|
||||
case 32000: {
|
||||
SET_CODEC_PAR(codecDef, kDecoderPCM16Bswb32kHz_2ch, codecInst.pltype,
|
||||
NULL, 32000);
|
||||
SET_PCM16B_SWB32_FUNCTIONS(codecDef);
|
||||
SET_CODEC_PAR(codec_def, kDecoderPCM16Bswb32kHz_2ch, codec_inst.pltype,
|
||||
NULL, 32000);
|
||||
SET_PCM16B_SWB32_FUNCTIONS(codec_def);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@ -199,22 +200,22 @@ WebRtc_Word16 ACMPCM16B::InternalCreateDecoder() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ACMPCM16B::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||
void ACMPCM16B::InternalDestructEncoderInst(void* /* ptr_inst */) {
|
||||
// PCM has no instance.
|
||||
return;
|
||||
}
|
||||
|
||||
void ACMPCM16B::DestructEncoderSafe() {
|
||||
// PCM has no instance.
|
||||
_encoderExist = false;
|
||||
_encoderInitialized = false;
|
||||
encoder_exist_ = false;
|
||||
encoder_initialized_ = false;
|
||||
return;
|
||||
}
|
||||
|
||||
void ACMPCM16B::DestructDecoderSafe() {
|
||||
// PCM has no instance.
|
||||
_decoderExist = false;
|
||||
_decoderInitialized = false;
|
||||
decoder_exist_ = false;
|
||||
decoder_initialized_ = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user