Reformat the WebRTC code base

Running clang-format with chromium's style guide.

The goal is n-fold:
 * providing consistency and readability (that's what code guidelines are for)
 * preventing noise with presubmit checks and git cl format
 * building on the previous point: making it easier to automatically fix format issues
 * you name it

Please consider using git-hyper-blame to ignore this commit.

Bug: webrtc:9340
Change-Id: I694567c4cdf8cee2860958cfe82bfaf25848bb87
Reviewed-on: https://webrtc-review.googlesource.com/81185
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23660}
This commit is contained in:
Yves Gerey
2018-06-19 15:03:05 +02:00
parent b602123a5a
commit 665174fdbb
1569 changed files with 30495 additions and 30309 deletions

View File

@ -42,7 +42,7 @@ bool IsILBCRateValid(int rate, int frame_size_samples) {
(rate == 13300)) {
return true;
} else if (((frame_size_samples == 160) || (frame_size_samples == 320)) &&
(rate == 15200)) {
(rate == 15200)) {
return true;
} else {
return false;
@ -62,55 +62,54 @@ bool IsOpusRateValid(int rate) {
const CodecInst ACMCodecDB::database_[] = {
#if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX))
{103, "ISAC", 16000, 480, 1, 32000},
# if (defined(WEBRTC_CODEC_ISAC))
{104, "ISAC", 32000, 960, 1, 56000},
# endif
{103, "ISAC", 16000, 480, 1, 32000},
#if (defined(WEBRTC_CODEC_ISAC))
{104, "ISAC", 32000, 960, 1, 56000},
#endif
// Mono
{107, "L16", 8000, 80, 1, 128000},
{108, "L16", 16000, 160, 1, 256000},
{109, "L16", 32000, 320, 1, 512000},
// Stereo
{111, "L16", 8000, 80, 2, 128000},
{112, "L16", 16000, 160, 2, 256000},
{113, "L16", 32000, 320, 2, 512000},
// G.711, PCM mu-law and A-law.
// Mono
{0, "PCMU", 8000, 160, 1, 64000},
{8, "PCMA", 8000, 160, 1, 64000},
// Stereo
{110, "PCMU", 8000, 160, 2, 64000},
{118, "PCMA", 8000, 160, 2, 64000},
#endif
// Mono
{107, "L16", 8000, 80, 1, 128000},
{108, "L16", 16000, 160, 1, 256000},
{109, "L16", 32000, 320, 1, 512000},
// Stereo
{111, "L16", 8000, 80, 2, 128000},
{112, "L16", 16000, 160, 2, 256000},
{113, "L16", 32000, 320, 2, 512000},
// G.711, PCM mu-law and A-law.
// Mono
{0, "PCMU", 8000, 160, 1, 64000},
{8, "PCMA", 8000, 160, 1, 64000},
// Stereo
{110, "PCMU", 8000, 160, 2, 64000},
{118, "PCMA", 8000, 160, 2, 64000},
#ifdef WEBRTC_CODEC_ILBC
{102, "ILBC", 8000, 240, 1, 13300},
{102, "ILBC", 8000, 240, 1, 13300},
#endif
// Mono
{9, "G722", 16000, 320, 1, 64000},
// Stereo
{119, "G722", 16000, 320, 2, 64000},
// Mono
{9, "G722", 16000, 320, 1, 64000},
// Stereo
{119, "G722", 16000, 320, 2, 64000},
#ifdef WEBRTC_CODEC_OPUS
// Opus internally supports 48, 24, 16, 12, 8 kHz.
// Mono and stereo.
{120, "opus", 48000, 960, 2, 64000},
// Opus internally supports 48, 24, 16, 12, 8 kHz.
// Mono and stereo.
{120, "opus", 48000, 960, 2, 64000},
#endif
// Comfort noise for four different sampling frequencies.
{13, "CN", 8000, 240, 1, 0},
{98, "CN", 16000, 480, 1, 0},
{99, "CN", 32000, 960, 1, 0},
// Comfort noise for four different sampling frequencies.
{13, "CN", 8000, 240, 1, 0},
{98, "CN", 16000, 480, 1, 0},
{99, "CN", 32000, 960, 1, 0},
#ifdef ENABLE_48000_HZ
{100, "CN", 48000, 1440, 1, 0},
{100, "CN", 48000, 1440, 1, 0},
#endif
{106, "telephone-event", 8000, 240, 1, 0},
{114, "telephone-event", 16000, 240, 1, 0},
{115, "telephone-event", 32000, 240, 1, 0},
{116, "telephone-event", 48000, 240, 1, 0},
{106, "telephone-event", 8000, 240, 1, 0},
{114, "telephone-event", 16000, 240, 1, 0},
{115, "telephone-event", 32000, 240, 1, 0},
{116, "telephone-event", 48000, 240, 1, 0},
#ifdef WEBRTC_CODEC_RED
{127, "red", 8000, 0, 1, 0},
{127, "red", 8000, 0, 1, 0},
#endif
// To prevent compile errors due to trailing commas.
{-1, "Null", -1, -1, 0, -1}
};
// To prevent compile errors due to trailing commas.
{-1, "Null", -1, -1, 0, -1}};
// Create database with all codec settings at compile time.
// Each entry needs the following parameters in the given order:
@ -119,9 +118,9 @@ const CodecInst ACMCodecDB::database_[] = {
const ACMCodecDB::CodecSettings ACMCodecDB::codec_settings_[] = {
#if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX))
{2, {480, 960}, 0, 1},
# if (defined(WEBRTC_CODEC_ISAC))
#if (defined(WEBRTC_CODEC_ISAC))
{1, {960}, 0, 1},
# endif
#endif
#endif
// Mono
{4, {80, 160, 240, 320}, 0, 2},
@ -146,9 +145,9 @@ const ACMCodecDB::CodecSettings ACMCodecDB::codec_settings_[] = {
// Stereo
{6, {160, 320, 480, 640, 800, 960}, 0, 2},
#ifdef WEBRTC_CODEC_OPUS
// Opus supports frames shorter than 10ms,
// but it doesn't help us to use them.
// Mono and stereo.
// Opus supports frames shorter than 10ms,
// but it doesn't help us to use them.
// Mono and stereo.
#if WEBRTC_OPUS_SUPPORT_120MS_PTIME
{5, {480, 960, 1920, 2880, 5760}, 0, 2},
#else
@ -171,16 +170,15 @@ const ACMCodecDB::CodecSettings ACMCodecDB::codec_settings_[] = {
{1, {0}, 0, 1},
#endif
// To prevent compile errors due to trailing commas.
{-1, {-1}, -1, 0}
};
{-1, {-1}, -1, 0}};
// Create a database of all NetEQ decoders at compile time.
const NetEqDecoder ACMCodecDB::neteq_decoders_[] = {
#if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX))
NetEqDecoder::kDecoderISAC,
# if (defined(WEBRTC_CODEC_ISAC))
#if (defined(WEBRTC_CODEC_ISAC))
NetEqDecoder::kDecoderISACswb,
# endif
#endif
#endif
// Mono
NetEqDecoder::kDecoderPCM16B, NetEqDecoder::kDecoderPCM16Bwb,
@ -210,10 +208,8 @@ const NetEqDecoder ACMCodecDB::neteq_decoders_[] = {
#ifdef ENABLE_48000_HZ
NetEqDecoder::kDecoderCNGswb48kHz,
#endif
NetEqDecoder::kDecoderAVT,
NetEqDecoder::kDecoderAVT16kHz,
NetEqDecoder::kDecoderAVT32kHz,
NetEqDecoder::kDecoderAVT48kHz,
NetEqDecoder::kDecoderAVT, NetEqDecoder::kDecoderAVT16kHz,
NetEqDecoder::kDecoderAVT32kHz, NetEqDecoder::kDecoderAVT48kHz,
#ifdef WEBRTC_CODEC_RED
NetEqDecoder::kDecoderRED,
#endif
@ -260,8 +256,7 @@ int ACMCodecDB::CodecNumber(const CodecInst& codec_inst) {
int i;
int packet_size_samples;
for (i = 0; i < codec_settings_[codec_id].num_packet_sizes; i++) {
packet_size_samples =
codec_settings_[codec_id].packet_sizes_samples[i];
packet_size_samples = codec_settings_[codec_id].packet_sizes_samples[i];
if (codec_inst.pacsize == packet_size_samples) {
packet_size_ok = true;
break;
@ -282,11 +277,10 @@ int ACMCodecDB::CodecNumber(const CodecInst& codec_inst) {
if (STR_CASE_CMP("isac", codec_inst.plname) == 0) {
return IsISACRateValid(codec_inst.rate) ? codec_id : kInvalidRate;
} else if (STR_CASE_CMP("ilbc", codec_inst.plname) == 0) {
return IsILBCRateValid(codec_inst.rate, codec_inst.pacsize)
? codec_id : kInvalidRate;
return IsILBCRateValid(codec_inst.rate, codec_inst.pacsize) ? codec_id
: kInvalidRate;
} else if (STR_CASE_CMP("opus", codec_inst.plname) == 0) {
return IsOpusRateValid(codec_inst.rate)
? codec_id : kInvalidRate;
return IsOpusRateValid(codec_inst.rate) ? codec_id : kInvalidRate;
}
return database_[codec_id].rate == codec_inst.rate ? codec_id : kInvalidRate;
@ -298,8 +292,7 @@ int ACMCodecDB::CodecNumber(const CodecInst& codec_inst) {
// Does not check other codec settings, such as payload type and packet size.
// Returns the id of the codec, or -1 if no match is found.
int ACMCodecDB::CodecId(const CodecInst& codec_inst) {
return (CodecId(codec_inst.plname, codec_inst.plfreq,
codec_inst.channels));
return (CodecId(codec_inst.plname, codec_inst.plfreq, codec_inst.channels));
}
int ACMCodecDB::CodecId(const char* payload_name,

View File

@ -31,7 +31,7 @@ class ACMCodecDB {
// build.
// kMaxNumPacketSize - Maximum number of allowed packet sizes for one codec.
// These might need to be increased if adding a new codec to the database
static const int kMaxNumCodecs = 50;
static const int kMaxNumCodecs = 50;
static const int kMaxNumPacketSize = 6;
// Codec specific settings

View File

@ -156,8 +156,7 @@ void AcmReceiveTestOldApi::RegisterNetEqTestCodecs() {
continue;
}
if (RemapPltypeAndUseThisCodec(my_codec_param.plname,
my_codec_param.plfreq,
if (RemapPltypeAndUseThisCodec(my_codec_param.plname, my_codec_param.plfreq,
my_codec_param.channels,
&my_codec_param.pltype)) {
ASSERT_EQ(true,
@ -204,8 +203,7 @@ void AcmReceiveTestOldApi::Run() {
EXPECT_EQ(0,
acm_->IncomingPacket(
packet->payload(),
static_cast<int32_t>(packet->payload_length_bytes()),
header))
static_cast<int32_t>(packet->payload_length_bytes()), header))
<< "Failure when inserting packet:" << std::endl
<< " PT = " << static_cast<int>(header.header.payloadType) << std::endl
<< " TS = " << header.header.timestamp << std::endl

View File

@ -11,7 +11,7 @@
#ifndef MODULES_AUDIO_CODING_ACM2_ACM_RECEIVE_TEST_H_
#define MODULES_AUDIO_CODING_ACM2_ACM_RECEIVE_TEST_H_
#include <stddef.h> // for size_t
#include <stddef.h> // for size_t
#include <memory>
#include <string>

View File

@ -231,8 +231,8 @@ int32_t AcmReceiver::AddCodec(int acm_codec_id,
if (!audio_decoder) {
ret_val = neteq_->RegisterPayloadType(neteq_decoder, name, payload_type);
} else {
ret_val = neteq_->RegisterExternalDecoder(
audio_decoder, neteq_decoder, name, payload_type);
ret_val = neteq_->RegisterExternalDecoder(audio_decoder, neteq_decoder,
name, payload_type);
}
if (ret_val != NetEq::kOK) {
RTC_LOG(LERROR) << "AcmReceiver::AddCodec " << acm_codec_id
@ -402,10 +402,9 @@ uint32_t AcmReceiver::NowInTimestamp(int decoder_sampling_rate) const {
// the least significant bits. (32-6) bits cover 2^(32-6) = 67108864 ms.
// We masked 6 most significant bits of 32-bit so there is no overflow in
// the conversion from milliseconds to timestamp.
const uint32_t now_in_ms = static_cast<uint32_t>(
clock_->TimeInMilliseconds() & 0x03ffffff);
return static_cast<uint32_t>(
(decoder_sampling_rate / 1000) * now_in_ms);
const uint32_t now_in_ms =
static_cast<uint32_t>(clock_->TimeInMilliseconds() & 0x03ffffff);
return static_cast<uint32_t>((decoder_sampling_rate / 1000) * now_in_ms);
}
void AcmReceiver::GetDecodingCallStatistics(

View File

@ -30,12 +30,11 @@ namespace acm2 {
namespace {
bool CodecsEqual(const CodecInst& codec_a, const CodecInst& codec_b) {
if (strcmp(codec_a.plname, codec_b.plname) != 0 ||
codec_a.plfreq != codec_b.plfreq ||
codec_a.pltype != codec_b.pltype ||
codec_b.channels != codec_a.channels)
return false;
return true;
if (strcmp(codec_a.plname, codec_b.plname) != 0 ||
codec_a.plfreq != codec_b.plfreq || codec_a.pltype != codec_b.pltype ||
codec_b.channels != codec_a.channels)
return false;
return true;
}
struct CodecIdInst {
@ -115,7 +114,7 @@ class AcmReceiverTestOldApi : public AudioPacketizationCallback,
}
template <size_t N>
void AddSetOfCodecs(const RentACodec::CodecId(&ids)[N]) {
void AddSetOfCodecs(const RentACodec::CodecId (&ids)[N]) {
for (auto id : ids) {
const auto i = RentACodec::CodecIndexFromId(id);
ASSERT_TRUE(i);
@ -186,13 +185,13 @@ TEST_F(AcmReceiverTestOldApi, MAYBE_AddCodecGetCodec) {
CodecInst my_codec;
if (n & 0x1) {
// Codecs with odd index should match the reference.
EXPECT_EQ(0, receiver_->DecoderByPayloadType(codecs_[n].pltype,
&my_codec));
EXPECT_EQ(0,
receiver_->DecoderByPayloadType(codecs_[n].pltype, &my_codec));
EXPECT_TRUE(CodecsEqual(codecs_[n], my_codec));
} else {
// Codecs with even index are not registered.
EXPECT_EQ(-1, receiver_->DecoderByPayloadType(codecs_[n].pltype,
&my_codec));
EXPECT_EQ(-1,
receiver_->DecoderByPayloadType(codecs_[n].pltype, &my_codec));
}
}
}
@ -326,7 +325,8 @@ class AcmReceiverTestFaxModeOldApi : public AcmReceiverTestOldApi {
// Expect the first output timestamp to be 5*fs/8000 samples before the
// first inserted timestamp (because of NetEq's look-ahead). (This value is
// defined in Expand::overlap_length_.)
uint32_t expected_output_ts = last_packet_send_timestamp_ -
uint32_t expected_output_ts =
last_packet_send_timestamp_ -
rtc::CheckedDivExact(5 * output_sample_rate_hz, 8000);
AudioFrame frame;

View File

@ -19,11 +19,9 @@
namespace webrtc {
namespace acm2 {
ACMResampler::ACMResampler() {
}
ACMResampler::ACMResampler() {}
ACMResampler::~ACMResampler() {
}
ACMResampler::~ACMResampler() {}
int ACMResampler::Resample10Msec(const int16_t* in_audio,
int in_freq_hz,

View File

@ -95,10 +95,9 @@ std::unique_ptr<Packet> AcmSendTestOldApi::NextPacket() {
RTC_CHECK(audio_source_->Read(input_block_size_samples_,
input_frame_.mutable_data()));
if (input_frame_.num_channels_ > 1) {
InputAudioFile::DuplicateInterleaved(input_frame_.data(),
input_block_size_samples_,
input_frame_.num_channels_,
input_frame_.mutable_data());
InputAudioFile::DuplicateInterleaved(
input_frame_.data(), input_block_size_samples_,
input_frame_.num_channels_, input_frame_.mutable_data());
}
data_to_send_ = false;
RTC_CHECK_GE(acm_->Add10MsData(input_frame_), 0);
@ -138,7 +137,7 @@ std::unique_ptr<Packet> AcmSendTestOldApi::CreatePacket() {
packet_memory[0] = 0x80;
packet_memory[1] = static_cast<uint8_t>(payload_type_);
packet_memory[2] = (sequence_number_ >> 8) & 0xFF;
packet_memory[3] = (sequence_number_) & 0xFF;
packet_memory[3] = (sequence_number_)&0xFF;
packet_memory[4] = (timestamp_ >> 24) & 0xFF;
packet_memory[5] = (timestamp_ >> 16) & 0xFF;
packet_memory[6] = (timestamp_ >> 8) & 0xFF;
@ -152,8 +151,7 @@ std::unique_ptr<Packet> AcmSendTestOldApi::CreatePacket() {
++sequence_number_;
// Copy the payload data.
memcpy(packet_memory + kRtpHeaderSize,
&last_payload_vec_[0],
memcpy(packet_memory + kRtpHeaderSize, &last_payload_vec_[0],
last_payload_vec_.size());
std::unique_ptr<Packet> packet(
new Packet(packet_memory, allocated_bytes, clock_.TimeInMilliseconds()));

View File

@ -323,9 +323,10 @@ int DownMix(const AudioFrame& frame,
if (!frame.muted()) {
const int16_t* frame_data = frame.data();
for (size_t n = 0; n < frame.samples_per_channel_; ++n) {
out_buff[n] = static_cast<int16_t>(
(static_cast<int32_t>(frame_data[2 * n]) +
static_cast<int32_t>(frame_data[2 * n + 1])) >> 1);
out_buff[n] =
static_cast<int16_t>((static_cast<int32_t>(frame_data[2 * n]) +
static_cast<int32_t>(frame_data[2 * n + 1])) >>
1);
}
} else {
std::fill(out_buff, out_buff + frame.samples_per_channel_, 0);
@ -472,7 +473,7 @@ int32_t AudioCodingModuleImpl::Encode(const InputData& input_data) {
if (!HaveValidEncoder("Process"))
return -1;
if(!first_frame_) {
if (!first_frame_) {
RTC_DCHECK(IsNewerTimestamp(input_data.input_timestamp, last_timestamp_))
<< "Time should not move backwards";
}
@ -493,9 +494,10 @@ int32_t AudioCodingModuleImpl::Encode(const InputData& input_data) {
// Clear the buffer before reuse - encoded data will get appended.
encode_buffer_.Clear();
encoded_info = encoder_stack_->Encode(
rtp_timestamp, rtc::ArrayView<const int16_t>(
input_data.audio, input_data.audio_channel *
input_data.length_per_channel),
rtp_timestamp,
rtc::ArrayView<const int16_t>(
input_data.audio,
input_data.audio_channel * input_data.length_per_channel),
&encode_buffer_);
bitrate_logger_.MaybeLog(encoder_stack_->GetTargetBitrate() / 1000);
@ -767,7 +769,6 @@ int AudioCodingModuleImpl::PreprocessToAddData(const AudioFrame& in_frame,
expected_in_ts_ = in_frame.timestamp_;
}
if (!down_mix && !resample) {
// No pre-processing is required.
if (expected_in_ts_ == expected_codec_ts_) {
@ -793,8 +794,8 @@ int AudioCodingModuleImpl::PreprocessToAddData(const AudioFrame& in_frame,
if (down_mix) {
// If a resampling is required the output of a down-mix is written into a
// local buffer, otherwise, it will be written to the output frame.
int16_t* dest_ptr_audio = resample ?
audio : preprocess_frame_.mutable_data();
int16_t* dest_ptr_audio =
resample ? audio : preprocess_frame_.mutable_data();
if (DownMix(in_frame, WEBRTC_10MS_PCM_AUDIO, dest_ptr_audio) < 0)
return -1;
preprocess_frame_.num_channels_ = 1;
@ -912,7 +913,8 @@ int AudioCodingModuleImpl::SetVAD(bool enable_dtx,
}
// Get VAD/DTX settings.
int AudioCodingModuleImpl::VAD(bool* dtx_enabled, bool* vad_enabled,
int AudioCodingModuleImpl::VAD(bool* dtx_enabled,
bool* vad_enabled,
ACMVADMode* mode) const {
rtc::CritScope lock(&acm_crit_sect_);
const auto* sp = encoder_factory_->codec_manager.GetStackParams();
@ -1229,7 +1231,7 @@ int AudioCodingModuleImpl::LeastRequiredDelayMs() const {
}
void AudioCodingModuleImpl::GetDecodingCallStatistics(
AudioDecodingCallStats* call_stats) const {
AudioDecodingCallStats* call_stats) const {
receiver_.GetDecodingCallStatistics(call_stats);
}

View File

@ -425,19 +425,12 @@ class AudioCodingModuleTestWithComfortNoiseOldApi
const struct {
int ix;
FrameType type;
} expectation[] = {{2, kAudioFrameCN},
{5, kEmptyFrame},
{8, kEmptyFrame},
{11, kAudioFrameCN},
{14, kEmptyFrame},
{17, kEmptyFrame},
{20, kAudioFrameCN},
{23, kEmptyFrame},
{26, kEmptyFrame},
{29, kEmptyFrame},
{32, kAudioFrameCN},
{35, kEmptyFrame},
{38, kEmptyFrame}};
} expectation[] = {
{2, kAudioFrameCN}, {5, kEmptyFrame}, {8, kEmptyFrame},
{11, kAudioFrameCN}, {14, kEmptyFrame}, {17, kEmptyFrame},
{20, kAudioFrameCN}, {23, kEmptyFrame}, {26, kEmptyFrame},
{29, kEmptyFrame}, {32, kAudioFrameCN}, {35, kEmptyFrame},
{38, kEmptyFrame}};
for (int i = 0; i < kLoops; ++i) {
int num_calls_before = packet_cb_.num_calls();
EXPECT_EQ(i / blocks_per_packet, num_calls_before);
@ -686,10 +679,8 @@ class AcmIsacMtTestOldApi : public AudioCodingModuleMtTestOldApi {
last_packet_number_ = num_calls;
}
ASSERT_GT(last_payload_vec_.size(), 0u);
ASSERT_EQ(
0,
acm_->IncomingPacket(
&last_payload_vec_[0], last_payload_vec_.size(), rtp_header_));
ASSERT_EQ(0, acm_->IncomingPacket(&last_payload_vec_[0],
last_payload_vec_.size(), rtp_header_));
}
void InsertAudio() override {
@ -819,9 +810,8 @@ class AcmReRegisterIsacMtTestOldApi : public AudioCodingModuleTestOldApi {
// Encode new frame.
uint32_t input_timestamp = rtp_header_.header.timestamp;
while (info.encoded_bytes == 0) {
info =
isac_encoder_->Encode(input_timestamp, audio_loop_.GetNextBlock(),
&encoded);
info = isac_encoder_->Encode(input_timestamp,
audio_loop_.GetNextBlock(), &encoded);
input_timestamp += 160; // 10 ms at 16 kHz.
}
EXPECT_EQ(rtp_header_.header.timestamp + kPacketSizeSamples,
@ -1094,11 +1084,12 @@ TEST_F(AcmReceiverBitExactnessOldApi, 48kHzOutputExternalDecoder) {
rtc::scoped_refptr<rtc::RefCountedObject<ADFactory>> factory(
new rtc::RefCountedObject<ADFactory>);
Run(48000, PlatformChecksum("5955e31373828969de7fb308fb58a84e",
"83c0eca235b1a806426ff6ca8655cdf7",
"1126a8c03d1ebc6aa7348b9c541e2082",
"bd44bf97e7899186532f91235cef444d",
"9d092dbc96e7ef6870b78c1056e87315"),
Run(48000,
PlatformChecksum("5955e31373828969de7fb308fb58a84e",
"83c0eca235b1a806426ff6ca8655cdf7",
"1126a8c03d1ebc6aa7348b9c541e2082",
"bd44bf97e7899186532f91235cef444d",
"9d092dbc96e7ef6870b78c1056e87315"),
factory, [](AudioCodingModule* acm) {
acm->RegisterReceiveCodec(0, {"MockPCMu", 8000, 1});
});
@ -1154,11 +1145,8 @@ class AcmSenderBitExactnessOldApi : public ::testing::Test,
int frame_size_rtp_timestamps) {
payload_type_ = payload_type;
frame_size_rtp_timestamps_ = frame_size_rtp_timestamps;
return send_test_->RegisterCodec(payload_name,
sampling_freq_hz,
channels,
payload_type,
frame_size_samples);
return send_test_->RegisterCodec(payload_name, sampling_freq_hz, channels,
payload_type, frame_size_samples);
}
bool RegisterExternalSendCodec(AudioEncoder* external_speech_encoder,
@ -1257,11 +1245,8 @@ class AcmSenderBitExactnessOldApi : public ::testing::Test,
int codec_frame_size_samples,
int codec_frame_size_rtp_timestamps) {
ASSERT_TRUE(SetUpSender());
ASSERT_TRUE(RegisterSendCodec(codec_name,
codec_sample_rate_hz,
channels,
payload_type,
codec_frame_size_samples,
ASSERT_TRUE(RegisterSendCodec(codec_name, codec_sample_rate_hz, channels,
payload_type, codec_frame_size_samples,
codec_frame_size_rtp_timestamps));
}
@ -1342,82 +1327,62 @@ TEST_F(AcmSenderBitExactnessOldApi, MAYBE_IsacSwb30ms) {
TEST_F(AcmSenderBitExactnessOldApi, Pcm16_8000khz_10ms) {
ASSERT_NO_FATAL_FAILURE(SetUpTest("L16", 8000, 1, 107, 80, 80));
Run("de4a98e1406f8b798d99cd0704e862e2",
"c1edd36339ce0326cc4550041ad719a0",
100,
test::AcmReceiveTestOldApi::kMonoOutput);
Run("de4a98e1406f8b798d99cd0704e862e2", "c1edd36339ce0326cc4550041ad719a0",
100, test::AcmReceiveTestOldApi::kMonoOutput);
}
TEST_F(AcmSenderBitExactnessOldApi, Pcm16_16000khz_10ms) {
ASSERT_NO_FATAL_FAILURE(SetUpTest("L16", 16000, 1, 108, 160, 160));
Run("ae646d7b68384a1269cc080dd4501916",
"ad786526383178b08d80d6eee06e9bad",
100,
test::AcmReceiveTestOldApi::kMonoOutput);
Run("ae646d7b68384a1269cc080dd4501916", "ad786526383178b08d80d6eee06e9bad",
100, test::AcmReceiveTestOldApi::kMonoOutput);
}
TEST_F(AcmSenderBitExactnessOldApi, Pcm16_32000khz_10ms) {
ASSERT_NO_FATAL_FAILURE(SetUpTest("L16", 32000, 1, 109, 320, 320));
Run("7fe325e8fbaf755e3c5df0b11a4774fb",
"5ef82ea885e922263606c6fdbc49f651",
100,
test::AcmReceiveTestOldApi::kMonoOutput);
Run("7fe325e8fbaf755e3c5df0b11a4774fb", "5ef82ea885e922263606c6fdbc49f651",
100, test::AcmReceiveTestOldApi::kMonoOutput);
}
TEST_F(AcmSenderBitExactnessOldApi, Pcm16_stereo_8000khz_10ms) {
ASSERT_NO_FATAL_FAILURE(SetUpTest("L16", 8000, 2, 111, 80, 80));
Run("fb263b74e7ac3de915474d77e4744ceb",
"62ce5adb0d4965d0a52ec98ae7f98974",
100,
test::AcmReceiveTestOldApi::kStereoOutput);
Run("fb263b74e7ac3de915474d77e4744ceb", "62ce5adb0d4965d0a52ec98ae7f98974",
100, test::AcmReceiveTestOldApi::kStereoOutput);
}
TEST_F(AcmSenderBitExactnessOldApi, Pcm16_stereo_16000khz_10ms) {
ASSERT_NO_FATAL_FAILURE(SetUpTest("L16", 16000, 2, 112, 160, 160));
Run("d09e9239553649d7ac93e19d304281fd",
"41ca8edac4b8c71cd54fd9f25ec14870",
100,
test::AcmReceiveTestOldApi::kStereoOutput);
Run("d09e9239553649d7ac93e19d304281fd", "41ca8edac4b8c71cd54fd9f25ec14870",
100, test::AcmReceiveTestOldApi::kStereoOutput);
}
TEST_F(AcmSenderBitExactnessOldApi, Pcm16_stereo_32000khz_10ms) {
ASSERT_NO_FATAL_FAILURE(SetUpTest("L16", 32000, 2, 113, 320, 320));
Run("5f025d4f390982cc26b3d92fe02e3044",
"50e58502fb04421bf5b857dda4c96879",
100,
test::AcmReceiveTestOldApi::kStereoOutput);
Run("5f025d4f390982cc26b3d92fe02e3044", "50e58502fb04421bf5b857dda4c96879",
100, test::AcmReceiveTestOldApi::kStereoOutput);
}
TEST_F(AcmSenderBitExactnessOldApi, Pcmu_20ms) {
ASSERT_NO_FATAL_FAILURE(SetUpTest("PCMU", 8000, 1, 0, 160, 160));
Run("81a9d4c0bb72e9becc43aef124c981e9",
"8f9b8750bd80fe26b6cbf6659b89f0f9",
50,
test::AcmReceiveTestOldApi::kMonoOutput);
Run("81a9d4c0bb72e9becc43aef124c981e9", "8f9b8750bd80fe26b6cbf6659b89f0f9",
50, test::AcmReceiveTestOldApi::kMonoOutput);
}
TEST_F(AcmSenderBitExactnessOldApi, Pcma_20ms) {
ASSERT_NO_FATAL_FAILURE(SetUpTest("PCMA", 8000, 1, 8, 160, 160));
Run("39611f798969053925a49dc06d08de29",
"6ad745e55aa48981bfc790d0eeef2dd1",
50,
test::AcmReceiveTestOldApi::kMonoOutput);
Run("39611f798969053925a49dc06d08de29", "6ad745e55aa48981bfc790d0eeef2dd1",
50, test::AcmReceiveTestOldApi::kMonoOutput);
}
TEST_F(AcmSenderBitExactnessOldApi, Pcmu_stereo_20ms) {
ASSERT_NO_FATAL_FAILURE(SetUpTest("PCMU", 8000, 2, 110, 160, 160));
Run("437bec032fdc5cbaa0d5175430af7b18",
"60b6f25e8d1e74cb679cfe756dd9bca5",
50,
test::AcmReceiveTestOldApi::kStereoOutput);
Run("437bec032fdc5cbaa0d5175430af7b18", "60b6f25e8d1e74cb679cfe756dd9bca5",
50, test::AcmReceiveTestOldApi::kStereoOutput);
}
TEST_F(AcmSenderBitExactnessOldApi, Pcma_stereo_20ms) {
ASSERT_NO_FATAL_FAILURE(SetUpTest("PCMA", 8000, 2, 118, 160, 160));
Run("a5c6d83c5b7cedbeff734238220a4b0c",
"92b282c83efd20e7eeef52ba40842cf7",
50,
test::AcmReceiveTestOldApi::kStereoOutput);
Run("a5c6d83c5b7cedbeff734238220a4b0c", "92b282c83efd20e7eeef52ba40842cf7",
50, test::AcmReceiveTestOldApi::kStereoOutput);
}
#if defined(WEBRTC_ANDROID)
@ -1740,11 +1705,11 @@ class AcmChangeBitRateOldApi : public AcmSetBitRateOldApi {
if (packet_counter == nr_packets / 2)
send_test_->acm()->SetBitRate(target_bitrate_bps);
if (packet_counter < nr_packets / 2)
nr_bytes_before += rtc::checked_cast<int>(
next_packet->payload_length_bytes());
nr_bytes_before +=
rtc::checked_cast<int>(next_packet->payload_length_bytes());
else
nr_bytes_after += rtc::checked_cast<int>(
next_packet->payload_length_bytes());
nr_bytes_after +=
rtc::checked_cast<int>(next_packet->payload_length_bytes());
packet_counter++;
}
// Check that bitrate is 80-120 percent of expected value.
@ -1811,12 +1776,10 @@ TEST_F(AcmSenderBitExactnessOldApi, External_Pcmu_20ms) {
.WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::GetTargetBitrate));
EXPECT_CALL(mock_encoder, EncodeImpl(_, _, _))
.Times(AtLeast(1))
.WillRepeatedly(Invoke(&encoder,
static_cast<
AudioEncoder::EncodedInfo(AudioEncoder::*)(
uint32_t,
rtc::ArrayView<const int16_t>,
rtc::Buffer*)>(&AudioEncoderPcmU::Encode)));
.WillRepeatedly(Invoke(
&encoder, static_cast<AudioEncoder::EncodedInfo (AudioEncoder::*)(
uint32_t, rtc::ArrayView<const int16_t>, rtc::Buffer*)>(
&AudioEncoderPcmU::Encode)));
EXPECT_CALL(mock_encoder, SetFec(_))
.Times(AtLeast(1))
.WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::SetFec));
@ -1866,11 +1829,7 @@ class AcmSwitchingOutputFrequencyOldApi : public ::testing::Test,
// this class.
test::AudioSinkFork output(this, &output_file);
test::AcmReceiveTestToggleOutputFreqOldApi receive_test(
this,
&output,
output_freq_1,
output_freq_2,
toggle_period_ms,
this, &output, output_freq_1, output_freq_2, toggle_period_ms,
test::AcmReceiveTestOldApi::kMonoOutput);
ASSERT_NO_FATAL_FAILURE(receive_test.RegisterDefaultCodecs());
output_freq_2_ = output_freq_2;

View File

@ -52,6 +52,3 @@ TEST(CallStatisticsTest, AllCalls) {
} // namespace acm2
} // namespace webrtc

View File

@ -54,8 +54,7 @@ class RentACodecTestF : public ::testing::Test {
int expected_send_even_if_empty) {
rtc::Buffer out;
AudioEncoder::EncodedInfo encoded_info;
encoded_info =
encoder_->Encode(timestamp_, kZeroData, &out);
encoded_info = encoder_->Encode(timestamp_, kZeroData, &out);
timestamp_ += kDataLengthSamples;
EXPECT_TRUE(encoded_info.redundant.empty());
EXPECT_EQ(expected_out_length, encoded_info.encoded_bytes);
@ -132,9 +131,8 @@ TEST(RentACodecTest, ExternalEncoder) {
{
::testing::InSequence s;
info.encoded_timestamp = 0;
EXPECT_CALL(
*external_encoder,
EncodeImpl(0, rtc::ArrayView<const int16_t>(audio), &encoded))
EXPECT_CALL(*external_encoder,
EncodeImpl(0, rtc::ArrayView<const int16_t>(audio), &encoded))
.WillOnce(Return(info));
EXPECT_CALL(marker, Mark("A"));
EXPECT_CALL(marker, Mark("B"));

View File

@ -102,8 +102,7 @@ AudioNetworkAdaptorStates CreateAudioNetworkAdaptor() {
config.event_log = states.event_log.get();
// AudioNetworkAdaptorImpl governs the lifetime of controller manager.
states.audio_network_adaptor.reset(new AudioNetworkAdaptorImpl(
config,
std::move(controller_manager), std::move(debug_dump_writer)));
config, std::move(controller_manager), std::move(debug_dump_writer)));
return states;
}

View File

@ -80,9 +80,9 @@ TEST(AnaBitrateControllerTest, ChangeBitrateOnTargetBitrateChanged) {
BitrateController::Config(32000, kInitialFrameLengthMs, 0, 0));
constexpr int kTargetBitrateBps = 48000;
constexpr size_t kOverheadBytesPerPacket = 64;
constexpr int kBitrateBps =
kTargetBitrateBps -
kOverheadBytesPerPacket * 8 * 1000 / kInitialFrameLengthMs;
constexpr int kBitrateBps = kTargetBitrateBps - kOverheadBytesPerPacket * 8 *
1000 /
kInitialFrameLengthMs;
// Frame length unchanged, bitrate changes in accordance with
// |metrics.target_audio_bitrate_bps| and |metrics.overhead_bytes_per_packet|.
UpdateNetworkMetrics(&controller, kTargetBitrateBps, kOverheadBytesPerPacket);
@ -104,9 +104,9 @@ TEST(AnaBitrateControllerTest, UpdateMultipleNetworkMetricsAtOnce) {
BitrateController::Config(32000, kInitialFrameLengthMs, 0, 0));
constexpr int kTargetBitrateBps = 48000;
constexpr size_t kOverheadBytesPerPacket = 64;
constexpr int kBitrateBps =
kTargetBitrateBps -
kOverheadBytesPerPacket * 8 * 1000 / kInitialFrameLengthMs;
constexpr int kBitrateBps = kTargetBitrateBps - kOverheadBytesPerPacket * 8 *
1000 /
kInitialFrameLengthMs;
Controller::NetworkMetrics network_metrics;
network_metrics.target_audio_bitrate_bps = kTargetBitrateBps;
network_metrics.overhead_bytes_per_packet = kOverheadBytesPerPacket;
@ -122,9 +122,9 @@ TEST(AnaBitrateControllerTest, TreatUnknownFrameLengthAsFrameLengthUnchanged) {
BitrateController::Config(32000, kInitialFrameLengthMs, 0, 0));
constexpr int kTargetBitrateBps = 48000;
constexpr size_t kOverheadBytesPerPacket = 64;
constexpr int kBitrateBps =
kTargetBitrateBps -
kOverheadBytesPerPacket * 8 * 1000 / kInitialFrameLengthMs;
constexpr int kBitrateBps = kTargetBitrateBps - kOverheadBytesPerPacket * 8 *
1000 /
kInitialFrameLengthMs;
UpdateNetworkMetrics(&controller, kTargetBitrateBps, kOverheadBytesPerPacket);
CheckDecision(&controller, absl::nullopt, kBitrateBps);
}
@ -138,9 +138,9 @@ TEST(AnaBitrateControllerTest, IncreaseBitrateOnFrameLengthIncreased) {
constexpr int kTargetBitrateBps = 48000;
constexpr size_t kOverheadBytesPerPacket = 64;
constexpr int kBitrateBps =
kTargetBitrateBps -
kOverheadBytesPerPacket * 8 * 1000 / kInitialFrameLengthMs;
constexpr int kBitrateBps = kTargetBitrateBps - kOverheadBytesPerPacket * 8 *
1000 /
kInitialFrameLengthMs;
UpdateNetworkMetrics(&controller, kTargetBitrateBps, kOverheadBytesPerPacket);
CheckDecision(&controller, absl::nullopt, kBitrateBps);
@ -162,9 +162,9 @@ TEST(AnaBitrateControllerTest, DecreaseBitrateOnFrameLengthDecreased) {
constexpr int kTargetBitrateBps = 48000;
constexpr size_t kOverheadBytesPerPacket = 64;
constexpr int kBitrateBps =
kTargetBitrateBps -
kOverheadBytesPerPacket * 8 * 1000 / kInitialFrameLengthMs;
constexpr int kBitrateBps = kTargetBitrateBps - kOverheadBytesPerPacket * 8 *
1000 /
kInitialFrameLengthMs;
UpdateNetworkMetrics(&controller, kTargetBitrateBps, kOverheadBytesPerPacket);
CheckDecision(&controller, absl::nullopt, kBitrateBps);
@ -213,9 +213,9 @@ TEST(AnaBitrateControllerTest, CheckBehaviorOnChangingCondition) {
// Next: change frame length.
frame_length_ms = 60;
current_bitrate += rtc::checked_cast<int>(
overhead_bytes_per_packet * 8 * 1000 / 20 -
overhead_bytes_per_packet * 8 * 1000 / 60);
current_bitrate +=
rtc::checked_cast<int>(overhead_bytes_per_packet * 8 * 1000 / 20 -
overhead_bytes_per_packet * 8 * 1000 / 60);
UpdateNetworkMetrics(&controller, overall_bitrate, overhead_bytes_per_packet);
CheckDecision(&controller, frame_length_ms, current_bitrate);
@ -227,9 +227,9 @@ TEST(AnaBitrateControllerTest, CheckBehaviorOnChangingCondition) {
// Next: change frame length.
frame_length_ms = 20;
current_bitrate -= rtc::checked_cast<int>(
overhead_bytes_per_packet * 8 * 1000 / 20 -
overhead_bytes_per_packet * 8 * 1000 / 60);
current_bitrate -=
rtc::checked_cast<int>(overhead_bytes_per_packet * 8 * 1000 / 20 -
overhead_bytes_per_packet * 8 * 1000 / 60);
UpdateNetworkMetrics(&controller, overall_bitrate, overhead_bytes_per_packet);
CheckDecision(&controller, frame_length_ms, current_bitrate);
@ -237,9 +237,9 @@ TEST(AnaBitrateControllerTest, CheckBehaviorOnChangingCondition) {
overall_bitrate -= 100;
current_bitrate -= 100;
frame_length_ms = 60;
current_bitrate += rtc::checked_cast<int>(
overhead_bytes_per_packet * 8 * 1000 / 20 -
overhead_bytes_per_packet * 8 * 1000 / 60);
current_bitrate +=
rtc::checked_cast<int>(overhead_bytes_per_packet * 8 * 1000 / 20 -
overhead_bytes_per_packet * 8 * 1000 / 60);
UpdateNetworkMetrics(&controller, overall_bitrate, overhead_bytes_per_packet);
CheckDecision(&controller, frame_length_ms, current_bitrate);

View File

@ -296,9 +296,9 @@ std::unique_ptr<ControllerManager> ControllerManagerImpl::Create(
}
if (scoring_points.size() == 0) {
return std::unique_ptr<ControllerManagerImpl>(new ControllerManagerImpl(
ControllerManagerImpl::Config(0, 0), std::move(controllers),
scoring_points));
return std::unique_ptr<ControllerManagerImpl>(
new ControllerManagerImpl(ControllerManagerImpl::Config(0, 0),
std::move(controllers), scoring_points));
} else {
RTC_CHECK(controller_manager_config.has_min_reordering_time_ms());
RTC_CHECK(controller_manager_config.has_min_reordering_squared_distance());

View File

@ -33,7 +33,7 @@ class NullSmoothingFilter final : public SmoothingFilter {
private:
absl::optional<float> last_sample_;
};
}
} // namespace
FecControllerPlrBased::Config::Config(
bool initial_fec_enabled,

View File

@ -209,11 +209,11 @@ TEST(FecControllerRplrBasedTest, EnableFecForMediumBandwidth) {
auto controller = CreateFecControllerRplrBased(false);
constexpr float kRecoverablePacketLoss =
(kEnablingRecoverablePacketLossAtLowBw +
kEnablingRecoverablePacketLossAtHighBw) / 2.0;
UpdateNetworkMetrics(
controller.get(),
(kEnablingBandwidthHigh + kEnablingBandwidthLow) / 2,
kRecoverablePacketLoss);
kEnablingRecoverablePacketLossAtHighBw) /
2.0;
UpdateNetworkMetrics(controller.get(),
(kEnablingBandwidthHigh + kEnablingBandwidthLow) / 2,
kRecoverablePacketLoss);
CheckDecision(controller.get(), true, kRecoverablePacketLoss);
}
@ -274,11 +274,12 @@ TEST(FecControllerRplrBasedTest, DisableFecOnMediumBandwidth) {
auto controller = CreateFecControllerRplrBased(true);
constexpr float kRecoverablePacketLoss =
((kDisablingRecoverablePacketLossAtLowBw +
kDisablingRecoverablePacketLossAtHighBw) / 2.0f) - kEpsilon;
UpdateNetworkMetrics(
controller.get(),
(kDisablingBandwidthHigh + kDisablingBandwidthLow) / 2,
kRecoverablePacketLoss);
kDisablingRecoverablePacketLossAtHighBw) /
2.0f) -
kEpsilon;
UpdateNetworkMetrics(controller.get(),
(kDisablingBandwidthHigh + kDisablingBandwidthLow) / 2,
kRecoverablePacketLoss);
CheckDecision(controller.get(), false, kRecoverablePacketLoss);
}

View File

@ -25,7 +25,7 @@ int OverheadRateBps(size_t overhead_bytes_per_packet, int frame_length_ms) {
return static_cast<int>(overhead_bytes_per_packet * 8 * 1000 /
frame_length_ms);
}
}
} // namespace
FrameLengthController::Config::Config(
const std::vector<int>& encoder_frame_lengths_ms,

View File

@ -11,8 +11,8 @@
#include "modules/audio_coding/codecs/cng/audio_encoder_cng.h"
#include <algorithm>
#include <memory>
#include <limits>
#include <memory>
#include <utility>
namespace webrtc {
@ -158,9 +158,8 @@ void AudioEncoderCng::Reset() {
rtp_timestamps_.clear();
last_frame_active_ = true;
vad_->Reset();
cng_encoder_.reset(
new ComfortNoiseEncoder(SampleRateHz(), sid_frame_interval_ms_,
num_cng_coefficients_));
cng_encoder_.reset(new ComfortNoiseEncoder(
SampleRateHz(), sid_frame_interval_ms_, num_cng_coefficients_));
}
bool AudioEncoderCng::SetFec(bool enable) {
@ -217,11 +216,10 @@ AudioEncoder::EncodedInfo AudioEncoderCng::EncodePassive(
// that value, in which case we don't want to overwrite any value from
// an earlier iteration.
size_t encoded_bytes_tmp =
cng_encoder_->Encode(
rtc::ArrayView<const int16_t>(
&speech_buffer_[i * samples_per_10ms_frame],
samples_per_10ms_frame),
force_sid, encoded);
cng_encoder_->Encode(rtc::ArrayView<const int16_t>(
&speech_buffer_[i * samples_per_10ms_frame],
samples_per_10ms_frame),
force_sid, encoded);
if (encoded_bytes_tmp > 0) {
RTC_CHECK(!output_produced);
@ -238,9 +236,8 @@ AudioEncoder::EncodedInfo AudioEncoderCng::EncodePassive(
return info;
}
AudioEncoder::EncodedInfo AudioEncoderCng::EncodeActive(
size_t frames_to_encode,
rtc::Buffer* encoded) {
AudioEncoder::EncodedInfo AudioEncoderCng::EncodeActive(size_t frames_to_encode,
rtc::Buffer* encoded) {
const size_t samples_per_10ms_frame = SamplesPer10msFrame();
AudioEncoder::EncodedInfo info;
for (size_t i = 0; i < frames_to_encode; ++i) {

View File

@ -30,7 +30,7 @@ namespace {
static const size_t kMaxNumSamples = 48 * 10 * 2; // 10 ms @ 48 kHz stereo.
static const size_t kMockReturnEncodedBytes = 17;
static const int kCngPayloadType = 18;
}
} // namespace
class AudioEncoderCngTest : public ::testing::Test {
protected:
@ -94,8 +94,7 @@ class AudioEncoderCngTest : public ::testing::Test {
InSequence s;
AudioEncoder::EncodedInfo info;
for (size_t j = 0; j < num_calls - 1; ++j) {
EXPECT_CALL(*mock_encoder_, EncodeImpl(_, _, _))
.WillOnce(Return(info));
EXPECT_CALL(*mock_encoder_, EncodeImpl(_, _, _)).WillOnce(Return(info));
}
info.encoded_bytes = kMockReturnEncodedBytes;
EXPECT_CALL(*mock_encoder_, EncodeImpl(_, _, _))
@ -155,12 +154,14 @@ class AudioEncoderCngTest : public ::testing::Test {
EXPECT_CALL(
*mock_vad_,
VoiceActivity(_, expected_first_block_size_ms * sample_rate_hz_ / 1000,
sample_rate_hz_)).WillOnce(Return(Vad::kPassive));
sample_rate_hz_))
.WillOnce(Return(Vad::kPassive));
if (expected_second_block_size_ms > 0) {
EXPECT_CALL(*mock_vad_,
VoiceActivity(
_, expected_second_block_size_ms * sample_rate_hz_ / 1000,
sample_rate_hz_)).WillOnce(Return(Vad::kPassive));
sample_rate_hz_))
.WillOnce(Return(Vad::kPassive));
}
// With this call to Encode(), |mock_vad_| should be called according to the
@ -429,9 +430,7 @@ class AudioEncoderCngDeathTest : public AudioEncoderCngTest {
// Override AudioEncoderCngTest::TearDown, since that one expects a call to
// the destructor of |mock_vad_|. In this case, that object is already
// deleted.
void TearDown() override {
cng_.reset();
}
void TearDown() override { cng_.reset(); }
AudioEncoderCng::Config MakeCngConfig() {
// Don't provide a Vad mock object, since it would leak when the test dies.

View File

@ -29,10 +29,7 @@ enum : size_t {
kCNGNumParamsTooHigh = WEBRTC_CNG_MAX_LPC_ORDER + 1
};
enum {
kNoSid,
kForceSid
};
enum { kNoSid, kForceSid };
class CngTest : public ::testing::Test {
protected:
@ -46,11 +43,11 @@ class CngTest : public ::testing::Test {
void CngTest::SetUp() {
FILE* input_file;
const std::string file_name =
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
input_file = fopen(file_name.c_str(), "rb");
ASSERT_TRUE(input_file != NULL);
ASSERT_EQ(640, static_cast<int32_t>(fread(speech_data_, sizeof(int16_t),
640, input_file)));
ASSERT_EQ(640, static_cast<int32_t>(
fread(speech_data_, sizeof(int16_t), 640, input_file)));
fclose(input_file);
input_file = NULL;
}
@ -74,11 +71,18 @@ void CngTest::TestCngEncode(int sample_rate_hz, int quality) {
// Create CNG encoder, init with faulty values, free CNG encoder.
TEST_F(CngTest, CngInitFail) {
// Call with too few parameters.
EXPECT_DEATH({ ComfortNoiseEncoder(8000, kSidNormalIntervalUpdate,
kCNGNumParamsLow); }, "");
EXPECT_DEATH(
{
ComfortNoiseEncoder(8000, kSidNormalIntervalUpdate, kCNGNumParamsLow);
},
"");
// Call with too many parameters.
EXPECT_DEATH({ ComfortNoiseEncoder(8000, kSidNormalIntervalUpdate,
kCNGNumParamsTooHigh); }, "");
EXPECT_DEATH(
{
ComfortNoiseEncoder(8000, kSidNormalIntervalUpdate,
kCNGNumParamsTooHigh);
},
"");
}
// Encode Cng with too long input vector.
@ -209,13 +213,15 @@ TEST_F(CngTest, CngAutoSid) {
// Normal Encode, 100 msec, where no SID data should be generated.
for (int i = 0; i < 10; i++) {
EXPECT_EQ(0U, cng_encoder.Encode(
rtc::ArrayView<const int16_t>(speech_data_, 160), kNoSid, &sid_data));
EXPECT_EQ(
0U, cng_encoder.Encode(rtc::ArrayView<const int16_t>(speech_data_, 160),
kNoSid, &sid_data));
}
// We have reached 100 msec, and SID data should be generated.
EXPECT_EQ(kCNGNumParamsNormal + 1, cng_encoder.Encode(
rtc::ArrayView<const int16_t>(speech_data_, 160), kNoSid, &sid_data));
EXPECT_EQ(kCNGNumParamsNormal + 1,
cng_encoder.Encode(rtc::ArrayView<const int16_t>(speech_data_, 160),
kNoSid, &sid_data));
}
// Test automatic SID, with very short interval.
@ -228,13 +234,16 @@ TEST_F(CngTest, CngAutoSidShort) {
ComfortNoiseDecoder cng_decoder;
// First call will never generate SID, unless forced to.
EXPECT_EQ(0U, cng_encoder.Encode(
rtc::ArrayView<const int16_t>(speech_data_, 160), kNoSid, &sid_data));
EXPECT_EQ(0U,
cng_encoder.Encode(rtc::ArrayView<const int16_t>(speech_data_, 160),
kNoSid, &sid_data));
// Normal Encode, 100 msec, SID data should be generated all the time.
for (int i = 0; i < 10; i++) {
EXPECT_EQ(kCNGNumParamsNormal + 1, cng_encoder.Encode(
rtc::ArrayView<const int16_t>(speech_data_, 160), kNoSid, &sid_data));
EXPECT_EQ(
kCNGNumParamsNormal + 1,
cng_encoder.Encode(rtc::ArrayView<const int16_t>(speech_data_, 160),
kNoSid, &sid_data));
}
}

View File

@ -25,28 +25,26 @@ const size_t kCngMaxOutsizeOrder = 640;
void WebRtcCng_K2a16(int16_t* k, int useOrder, int16_t* a);
const int32_t WebRtcCng_kDbov[94] = {
1081109975, 858756178, 682134279, 541838517, 430397633, 341876992,
271562548, 215709799, 171344384, 136103682, 108110997, 85875618,
68213428, 54183852, 43039763, 34187699, 27156255, 21570980,
17134438, 13610368, 10811100, 8587562, 6821343, 5418385,
4303976, 3418770, 2715625, 2157098, 1713444, 1361037,
1081110, 858756, 682134, 541839, 430398, 341877,
271563, 215710, 171344, 136104, 108111, 85876,
68213, 54184, 43040, 34188, 27156, 21571,
17134, 13610, 10811, 8588, 6821, 5418,
4304, 3419, 2716, 2157, 1713, 1361,
1081, 859, 682, 542, 430, 342,
272, 216, 171, 136, 108, 86,
68, 54, 43, 34, 27, 22,
17, 14, 11, 9, 7, 5,
4, 3, 3, 2, 2, 1,
1, 1, 1, 1
};
1081109975, 858756178, 682134279, 541838517, 430397633, 341876992,
271562548, 215709799, 171344384, 136103682, 108110997, 85875618,
68213428, 54183852, 43039763, 34187699, 27156255, 21570980,
17134438, 13610368, 10811100, 8587562, 6821343, 5418385,
4303976, 3418770, 2715625, 2157098, 1713444, 1361037,
1081110, 858756, 682134, 541839, 430398, 341877,
271563, 215710, 171344, 136104, 108111, 85876,
68213, 54184, 43040, 34188, 27156, 21571,
17134, 13610, 10811, 8588, 6821, 5418,
4304, 3419, 2716, 2157, 1713, 1361,
1081, 859, 682, 542, 430, 342,
272, 216, 171, 136, 108, 86,
68, 54, 43, 34, 27, 22,
17, 14, 11, 9, 7, 5,
4, 3, 3, 2, 2, 1,
1, 1, 1, 1};
const int16_t WebRtcCng_kCorrWindow[WEBRTC_CNG_MAX_LPC_ORDER] = {
32702, 32636, 32570, 32505, 32439, 32374,
32309, 32244, 32179, 32114, 32049, 31985
};
32702, 32636, 32570, 32505, 32439, 32374,
32309, 32244, 32179, 32114, 32049, 31985};
} // namespace
@ -57,7 +55,7 @@ ComfortNoiseDecoder::ComfortNoiseDecoder() {
}
void ComfortNoiseDecoder::Reset() {
dec_seed_ = 7777; /* For debugging only. */
dec_seed_ = 7777; /* For debugging only. */
dec_target_energy_ = 0;
dec_used_energy_ = 0;
for (auto& c : dec_target_reflCoefs_)
@ -115,11 +113,11 @@ bool ComfortNoiseDecoder::Generate(rtc::ArrayView<int16_t> out_data,
int16_t excitation[kCngMaxOutsizeOrder];
int16_t low[kCngMaxOutsizeOrder];
int16_t lpPoly[WEBRTC_CNG_MAX_LPC_ORDER + 1];
int16_t ReflBetaStd = 26214; /* 0.8 in q15. */
int16_t ReflBetaCompStd = 6553; /* 0.2 in q15. */
int16_t ReflBetaNewP = 19661; /* 0.6 in q15. */
int16_t ReflBetaCompNewP = 13107; /* 0.4 in q15. */
int16_t Beta, BetaC; /* These are in Q15. */
int16_t ReflBetaStd = 26214; /* 0.8 in q15. */
int16_t ReflBetaCompStd = 6553; /* 0.2 in q15. */
int16_t ReflBetaNewP = 19661; /* 0.6 in q15. */
int16_t ReflBetaCompNewP = 13107; /* 0.4 in q15. */
int16_t Beta, BetaC; /* These are in Q15. */
int32_t targetEnergy;
int16_t En;
int16_t temp16;
@ -139,30 +137,28 @@ bool ComfortNoiseDecoder::Generate(rtc::ArrayView<int16_t> out_data,
}
/* Calculate new scale factor in Q13 */
dec_used_scale_factor_ =
rtc::checked_cast<int16_t>(
WEBRTC_SPL_MUL_16_16_RSFT(dec_used_scale_factor_, Beta >> 2, 13) +
WEBRTC_SPL_MUL_16_16_RSFT(dec_target_scale_factor_, BetaC >> 2, 13));
dec_used_scale_factor_ = rtc::checked_cast<int16_t>(
WEBRTC_SPL_MUL_16_16_RSFT(dec_used_scale_factor_, Beta >> 2, 13) +
WEBRTC_SPL_MUL_16_16_RSFT(dec_target_scale_factor_, BetaC >> 2, 13));
dec_used_energy_ = dec_used_energy_ >> 1;
dec_used_energy_ = dec_used_energy_ >> 1;
dec_used_energy_ += dec_target_energy_ >> 1;
/* Do the same for the reflection coeffs, albeit in Q15. */
for (size_t i = 0; i < WEBRTC_CNG_MAX_LPC_ORDER; i++) {
dec_used_reflCoefs_[i] = (int16_t) WEBRTC_SPL_MUL_16_16_RSFT(
dec_used_reflCoefs_[i], Beta, 15);
dec_used_reflCoefs_[i] += (int16_t) WEBRTC_SPL_MUL_16_16_RSFT(
dec_target_reflCoefs_[i], BetaC, 15);
dec_used_reflCoefs_[i] =
(int16_t)WEBRTC_SPL_MUL_16_16_RSFT(dec_used_reflCoefs_[i], Beta, 15);
dec_used_reflCoefs_[i] +=
(int16_t)WEBRTC_SPL_MUL_16_16_RSFT(dec_target_reflCoefs_[i], BetaC, 15);
}
/* Compute the polynomial coefficients. */
WebRtcCng_K2a16(dec_used_reflCoefs_, WEBRTC_CNG_MAX_LPC_ORDER, lpPoly);
targetEnergy = dec_used_energy_;
/* Calculate scaling factor based on filter energy. */
En = 8192; /* 1.0 in Q13. */
En = 8192; /* 1.0 in Q13. */
for (size_t i = 0; i < (WEBRTC_CNG_MAX_LPC_ORDER); i++) {
/* Floating point value for reference.
E *= 1.0 - (dec_used_reflCoefs_[i] / 32768.0) *
@ -171,11 +167,11 @@ bool ComfortNoiseDecoder::Generate(rtc::ArrayView<int16_t> out_data,
/* Same in fixed point. */
/* K(i).^2 in Q15. */
temp16 = (int16_t) WEBRTC_SPL_MUL_16_16_RSFT(
dec_used_reflCoefs_[i], dec_used_reflCoefs_[i], 15);
temp16 = (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(dec_used_reflCoefs_[i],
dec_used_reflCoefs_[i], 15);
/* 1 - K(i).^2 in Q15. */
temp16 = 0x7fff - temp16;
En = (int16_t) WEBRTC_SPL_MUL_16_16_RSFT(En, temp16, 15);
En = (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(En, temp16, 15);
}
/* float scaling= sqrt(E * dec_target_energy_ / (1 << 24)); */
@ -183,8 +179,8 @@ bool ComfortNoiseDecoder::Generate(rtc::ArrayView<int16_t> out_data,
/* Calculate sqrt(En * target_energy / excitation energy) */
targetEnergy = WebRtcSpl_Sqrt(dec_used_energy_);
En = (int16_t) WebRtcSpl_Sqrt(En) << 6;
En = (En * 3) >> 1; /* 1.5 estimates sqrt(2). */
En = (int16_t)WebRtcSpl_Sqrt(En) << 6;
En = (En * 3) >> 1; /* 1.5 estimates sqrt(2). */
dec_used_scale_factor_ = (int16_t)((En * targetEnergy) >> 12);
/* Generate excitation. */
@ -217,7 +213,7 @@ ComfortNoiseEncoder::ComfortNoiseEncoder(int fs, int interval, int quality)
enc_Energy_(0),
enc_reflCoefs_{0},
enc_corrVector_{0},
enc_seed_(7777) /* For debugging only. */ {
enc_seed_(7777) /* For debugging only. */ {
RTC_CHECK_GT(quality, 0);
RTC_CHECK_LE(quality, WEBRTC_CNG_MAX_LPC_ORDER);
/* Needed to get the right function pointers in SPLIB. */
@ -236,7 +232,7 @@ void ComfortNoiseEncoder::Reset(int fs, int interval, int quality) {
c = 0;
for (auto& c : enc_corrVector_)
c = 0;
enc_seed_ = 7777; /* For debugging only. */
enc_seed_ = 7777; /* For debugging only. */
}
size_t ComfortNoiseEncoder::Encode(rtc::ArrayView<const int16_t> speech,
@ -312,20 +308,19 @@ size_t ComfortNoiseEncoder::Encode(rtc::ArrayView<const int16_t> speech,
if (negate)
*bptr = -*bptr;
blo = (int32_t) * aptr * (*bptr & 0xffff);
bhi = ((blo >> 16) & 0xffff)
+ ((int32_t)(*aptr++) * ((*bptr >> 16) & 0xffff));
blo = (int32_t)*aptr * (*bptr & 0xffff);
bhi = ((blo >> 16) & 0xffff) +
((int32_t)(*aptr++) * ((*bptr >> 16) & 0xffff));
blo = (blo & 0xffff) | ((bhi & 0xffff) << 16);
*bptr = (((bhi >> 16) & 0x7fff) << 17) | ((uint32_t) blo >> 15);
*bptr = (((bhi >> 16) & 0x7fff) << 17) | ((uint32_t)blo >> 15);
if (negate)
*bptr = -*bptr;
bptr++;
}
/* End of bandwidth expansion. */
stab = WebRtcSpl_LevinsonDurbin(corrVector, arCoefs, refCs,
enc_nrOfCoefs_);
stab = WebRtcSpl_LevinsonDurbin(corrVector, arCoefs, refCs, enc_nrOfCoefs_);
if (!stab) {
/* Disregard from this frame */
@ -345,13 +340,12 @@ size_t ComfortNoiseEncoder::Encode(rtc::ArrayView<const int16_t> speech,
} else {
/* Average history with new values. */
for (i = 0; i < enc_nrOfCoefs_; i++) {
enc_reflCoefs_[i] = (int16_t) WEBRTC_SPL_MUL_16_16_RSFT(
enc_reflCoefs_[i], ReflBeta, 15);
enc_reflCoefs_[i] =
(int16_t)WEBRTC_SPL_MUL_16_16_RSFT(enc_reflCoefs_[i], ReflBeta, 15);
enc_reflCoefs_[i] +=
(int16_t) WEBRTC_SPL_MUL_16_16_RSFT(refCs[i], ReflBetaComp, 15);
(int16_t)WEBRTC_SPL_MUL_16_16_RSFT(refCs[i], ReflBetaComp, 15);
}
enc_Energy_ =
(outEnergy >> 2) + (enc_Energy_ >> 1) + (enc_Energy_ >> 2);
enc_Energy_ = (outEnergy >> 2) + (enc_Energy_ >> 1) + (enc_Energy_ >> 2);
}
if (enc_Energy_ < 1) {
@ -372,25 +366,25 @@ size_t ComfortNoiseEncoder::Encode(rtc::ArrayView<const int16_t> speech,
index = 94;
const size_t output_coefs = enc_nrOfCoefs_ + 1;
output->AppendData(output_coefs, [&] (rtc::ArrayView<uint8_t> output) {
output[0] = (uint8_t)index;
output->AppendData(output_coefs, [&](rtc::ArrayView<uint8_t> output) {
output[0] = (uint8_t)index;
/* Quantize coefficients with tweak for WebRtc implementation of
* RFC3389. */
if (enc_nrOfCoefs_ == WEBRTC_CNG_MAX_LPC_ORDER) {
for (i = 0; i < enc_nrOfCoefs_; i++) {
/* Q15 to Q7 with rounding. */
output[i + 1] = ((enc_reflCoefs_[i] + 128) >> 8);
}
} else {
for (i = 0; i < enc_nrOfCoefs_; i++) {
/* Q15 to Q7 with rounding. */
output[i + 1] = (127 + ((enc_reflCoefs_[i] + 128) >> 8));
}
/* Quantize coefficients with tweak for WebRtc implementation of
* RFC3389. */
if (enc_nrOfCoefs_ == WEBRTC_CNG_MAX_LPC_ORDER) {
for (i = 0; i < enc_nrOfCoefs_; i++) {
/* Q15 to Q7 with rounding. */
output[i + 1] = ((enc_reflCoefs_[i] + 128) >> 8);
}
} else {
for (i = 0; i < enc_nrOfCoefs_; i++) {
/* Q15 to Q7 with rounding. */
output[i + 1] = (127 + ((enc_reflCoefs_[i] + 128) >> 8));
}
}
return output_coefs;
});
return output_coefs;
});
enc_msSinceSid_ =
static_cast<int16_t>((1000 * num_samples) / enc_sampfreq_);

View File

@ -8,7 +8,6 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_AUDIO_CODING_CODECS_CNG_WEBRTC_CNG_H_
#define MODULES_AUDIO_CODING_CODECS_CNG_WEBRTC_CNG_H_
@ -54,8 +53,8 @@ class ComfortNoiseDecoder {
int16_t dec_filtstate_[WEBRTC_CNG_MAX_LPC_ORDER + 1];
int16_t dec_filtstateLow_[WEBRTC_CNG_MAX_LPC_ORDER + 1];
uint16_t dec_order_;
int16_t dec_target_scale_factor_; /* Q29 */
int16_t dec_used_scale_factor_; /* Q29 */
int16_t dec_target_scale_factor_; /* Q29 */
int16_t dec_used_scale_factor_; /* Q29 */
};
class ComfortNoiseEncoder {

View File

@ -10,8 +10,8 @@
#include "modules/audio_coding/codecs/g711/audio_decoder_pcm.h"
#include "modules/audio_coding/codecs/legacy_encoded_audio_frame.h"
#include "modules/audio_coding/codecs/g711/g711_interface.h"
#include "modules/audio_coding/codecs/legacy_encoded_audio_frame.h"
namespace webrtc {

View File

@ -42,8 +42,8 @@ AudioEncoderPcm::AudioEncoderPcm(const Config& config, int sample_rate_hz)
payload_type_(config.payload_type),
num_10ms_frames_per_packet_(
static_cast<size_t>(config.frame_size_ms / 10)),
full_frame_samples_(
config.num_channels * config.frame_size_ms * sample_rate_hz / 1000),
full_frame_samples_(config.num_channels * config.frame_size_ms *
sample_rate_hz / 1000),
first_timestamp_in_buffer_(0) {
RTC_CHECK_GT(sample_rate_hz, 0) << "Sample rate must be larger than 0 Hz";
RTC_CHECK_EQ(config.frame_size_ms % 10, 0)
@ -70,8 +70,8 @@ size_t AudioEncoderPcm::Max10MsFramesInAPacket() const {
}
int AudioEncoderPcm::GetTargetBitrate() const {
return static_cast<int>(
8 * BytesPerSample() * SampleRateHz() * NumChannels());
return static_cast<int>(8 * BytesPerSample() * SampleRateHz() *
NumChannels());
}
AudioEncoder::EncodedInfo AudioEncoderPcm::EncodeImpl(
@ -89,13 +89,12 @@ AudioEncoder::EncodedInfo AudioEncoderPcm::EncodeImpl(
EncodedInfo info;
info.encoded_timestamp = first_timestamp_in_buffer_;
info.payload_type = payload_type_;
info.encoded_bytes =
encoded->AppendData(full_frame_samples_ * BytesPerSample(),
[&] (rtc::ArrayView<uint8_t> encoded) {
return EncodeCall(&speech_buffer_[0],
full_frame_samples_,
encoded.data());
});
info.encoded_bytes = encoded->AppendData(
full_frame_samples_ * BytesPerSample(),
[&](rtc::ArrayView<uint8_t> encoded) {
return EncodeCall(&speech_buffer_[0], full_frame_samples_,
encoded.data());
});
speech_buffer_.clear();
info.encoder_type = GetCodecType();
return info;

View File

@ -17,7 +17,8 @@
* Modifications for WebRtc, 2011/04/28, by tlegrand:
* -Changed to use WebRtc types
* -Changed __inline__ to __inline
* -Two changes to make implementation bitexact with ITU-T reference implementation
* -Two changes to make implementation bitexact with ITU-T reference
* implementation
*/
/*! \page g711_page A-law and mu-law handling
@ -58,10 +59,11 @@ extern "C" {
static __inline__ int top_bit(unsigned int bits) {
int res;
__asm__ __volatile__(" movl $-1,%%edx;\n"
" bsrl %%eax,%%edx;\n"
: "=d" (res)
: "a" (bits));
__asm__ __volatile__(
" movl $-1,%%edx;\n"
" bsrl %%eax,%%edx;\n"
: "=d"(res)
: "a"(bits));
return res;
}
@ -71,30 +73,33 @@ static __inline__ int top_bit(unsigned int bits) {
static __inline__ int bottom_bit(unsigned int bits) {
int res;
__asm__ __volatile__(" movl $-1,%%edx;\n"
" bsfl %%eax,%%edx;\n"
: "=d" (res)
: "a" (bits));
__asm__ __volatile__(
" movl $-1,%%edx;\n"
" bsfl %%eax,%%edx;\n"
: "=d"(res)
: "a"(bits));
return res;
}
#elif defined(__x86_64__)
static __inline__ int top_bit(unsigned int bits) {
int res;
__asm__ __volatile__(" movq $-1,%%rdx;\n"
" bsrq %%rax,%%rdx;\n"
: "=d" (res)
: "a" (bits));
__asm__ __volatile__(
" movq $-1,%%rdx;\n"
" bsrq %%rax,%%rdx;\n"
: "=d"(res)
: "a"(bits));
return res;
}
static __inline__ int bottom_bit(unsigned int bits) {
int res;
__asm__ __volatile__(" movq $-1,%%rdx;\n"
" bsfq %%rax,%%rdx;\n"
: "=d" (res)
: "a" (bits));
__asm__ __volatile__(
" movq $-1,%%rdx;\n"
" bsfq %%rax,%%rdx;\n"
: "=d"(res)
: "a"(bits));
return res;
}
#else
@ -166,8 +171,8 @@ static __inline int bottom_bit(unsigned int bits) {
* linear sound like peanuts these days, and shouldn't an array lookup be
* real fast? No! When the cache sloshes as badly as this one will, a tight
* calculation may be better. The messiest part is normally finding the
* segment, but a little inline assembly can fix that on an i386, x86_64 and
* many other modern processors.
* segment, but a little inline assembly can fix that on an i386, x86_64
* and many other modern processors.
*/
/*
@ -196,8 +201,9 @@ static __inline int bottom_bit(unsigned int bits) {
* John Wiley & Sons, pps 98-111 and 472-476.
*/
//#define ULAW_ZEROTRAP /* turn on the trap as per the MIL-STD */
#define ULAW_BIAS 0x84 /* Bias for linear code. */
//#define ULAW_ZEROTRAP /* turn on the trap as per the MIL-STD
//*/
#define ULAW_BIAS 0x84 /* Bias for linear code. */
/*! \brief Encode a linear sample to u-law
\param linear The sample to encode.
@ -249,7 +255,7 @@ static __inline int16_t ulaw_to_linear(uint8_t ulaw) {
* Extract and bias the quantization bits. Then
* shift up by the segment number and subtract out the bias.
*/
t = (((ulaw & 0x0F) << 3) + ULAW_BIAS) << (((int) ulaw & 0x70) >> 4);
t = (((ulaw & 0x0F) << 3) + ULAW_BIAS) << (((int)ulaw & 0x70) >> 4);
return (int16_t)((ulaw & 0x80) ? (ULAW_BIAS - t) : (t - ULAW_BIAS));
}
@ -317,7 +323,7 @@ static __inline int16_t alaw_to_linear(uint8_t alaw) {
alaw ^= ALAW_AMI_MASK;
i = ((alaw & 0x0F) << 4);
seg = (((int) alaw & 0x70) >> 4);
seg = (((int)alaw & 0x70) >> 4);
if (seg)
i = (i + 0x108) << (seg - 1);
else

View File

@ -112,19 +112,19 @@ size_t WebRtcG711_DecodeU(const uint8_t* encoded,
int16_t* speechType);
/**********************************************************************
* WebRtcG711_Version(...)
*
* This function gives the version string of the G.711 codec.
*
* Input:
* - lenBytes: the size of Allocated space (in Bytes) where
* the version number is written to (in string format).
*
* Output:
* - version: Pointer to a buffer where the version number is
* written to.
*
*/
* WebRtcG711_Version(...)
*
* This function gives the version string of the G.711 codec.
*
* Input:
* - lenBytes: the size of Allocated space (in Bytes) where
* the version number is written to (in string format).
*
* Output:
* - version: Pointer to a buffer where the version number is
* written to.
*
*/
int16_t WebRtcG711_Version(char* version, int16_t lenBytes);

View File

@ -69,7 +69,6 @@ int main(int argc, char* argv[]) {
printf("outfile : Speech output file\n\n");
printf("outbits : Output bitstream file [optional]\n\n");
exit(0);
}
/* Get version and print */
@ -80,8 +79,8 @@ int main(int argc, char* argv[]) {
/* Get frame length */
int framelength_int = atoi(argv[1]);
if (framelength_int < 0) {
printf(" G.722: Invalid framelength %d.\n", framelength_int);
exit(1);
printf(" G.722: Invalid framelength %d.\n", framelength_int);
exit(1);
}
framelength = static_cast<size_t>(framelength_int);
@ -112,7 +111,7 @@ int main(int argc, char* argv[]) {
printf("\nBitfile: %s\n", bitname);
}
starttime = clock() / (double) CLOCKS_PER_SEC_G711; /* Runtime statistics */
starttime = clock() / (double)CLOCKS_PER_SEC_G711; /* Runtime statistics */
/* Initialize encoder and decoder */
framecnt = 0;
@ -155,11 +154,10 @@ int main(int argc, char* argv[]) {
}
}
runtime = (double)(clock() / (double) CLOCKS_PER_SEC_G711 - starttime);
length_file = ((double) framecnt * (double) framelength / 8000);
runtime = (double)(clock() / (double)CLOCKS_PER_SEC_G711 - starttime);
length_file = ((double)framecnt * (double)framelength / 8000);
printf("\n\nLength of speech file: %.1f s\n", length_file);
printf("Time to run G.711: %.2f s (%.2f %% of realtime)\n\n",
runtime,
printf("Time to run G.711: %.2f s (%.2f %% of realtime)\n\n", runtime,
(100 * runtime / length_file));
printf("---------------------END----------------------\n");

View File

@ -123,7 +123,7 @@ AudioEncoder::EncodedInfo AudioEncoderG722Impl::EncodeImpl(
const size_t bytes_to_encode = samples_per_channel / 2 * num_channels_;
EncodedInfo info;
info.encoded_bytes = encoded->AppendData(
bytes_to_encode, [&] (rtc::ArrayView<uint8_t> encoded) {
bytes_to_encode, [&](rtc::ArrayView<uint8_t> encoded) {
// Interleave the encoded bytes of the different channels. Each separate
// channel and the interleaved stream encodes two samples per byte, most
// significant half first.

View File

@ -46,8 +46,8 @@ class AudioEncoderG722Impl final : public AudioEncoder {
// The encoder state for one channel.
struct EncoderState {
G722EncInst* encoder;
std::unique_ptr<int16_t[]> speech_buffer; // Queued up for encoding.
rtc::Buffer encoded_buffer; // Already encoded.
std::unique_ptr<int16_t[]> speech_buffer; // Queued up for encoding.
rtc::Buffer encoded_buffer; // Already encoded.
EncoderState();
~EncoderState();
};

View File

@ -7,7 +7,7 @@
*
* Copyright (C) 2005 Steve Underwood
*
* Despite my general liking of the GPL, I place my own contributions
* Despite my general liking of the GPL, I place my own contributions
* to this code in the public domain for the benefit of all mankind -
* even the slimy ones who might try to proprietize my work and use it
* to my detriment.
@ -25,7 +25,6 @@
* -Added new defines for minimum and maximum values of short int
*/
/*! \file */
#if !defined(_G722_ENC_DEC_H_)
@ -35,12 +34,14 @@
/*! \page g722_page G.722 encoding and decoding
\section g722_page_sec_1 What does it do?
The G.722 module is a bit exact implementation of the ITU G.722 specification for all three
specified bit rates - 64000bps, 56000bps and 48000bps. It passes the ITU tests.
The G.722 module is a bit exact implementation of the ITU G.722 specification
for all three specified bit rates - 64000bps, 56000bps and 48000bps. It passes
the ITU tests.
To allow fast and flexible interworking with narrow band telephony, the encoder and decoder
support an option for the linear audio to be an 8k samples/second stream. In this mode the
codec is considerably faster, and still fully compatible with wideband terminals using G.722.
To allow fast and flexible interworking with narrow band telephony, the encoder
and decoder support an option for the linear audio to be an 8k samples/second
stream. In this mode the codec is considerably faster, and still fully
compatible with wideband terminals using G.722.
\section g722_page_sec_2 How does it work?
???.
@ -49,86 +50,78 @@ codec is considerably faster, and still fully compatible with wideband terminals
#define WEBRTC_INT16_MAX 32767
#define WEBRTC_INT16_MIN -32768
enum
{
G722_SAMPLE_RATE_8000 = 0x0001,
G722_PACKED = 0x0002
};
enum { G722_SAMPLE_RATE_8000 = 0x0001, G722_PACKED = 0x0002 };
typedef struct
{
/*! TRUE if the operating in the special ITU test mode, with the band split filters
disabled. */
int itu_test_mode;
/*! TRUE if the G.722 data is packed */
int packed;
/*! TRUE if encode from 8k samples/second */
int eight_k;
/*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */
int bits_per_sample;
typedef struct {
/*! TRUE if the operating in the special ITU test mode, with the band split
filters disabled. */
int itu_test_mode;
/*! TRUE if the G.722 data is packed */
int packed;
/*! TRUE if encode from 8k samples/second */
int eight_k;
/*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */
int bits_per_sample;
/*! Signal history for the QMF */
int x[24];
/*! Signal history for the QMF */
int x[24];
struct
{
int s;
int sp;
int sz;
int r[3];
int a[3];
int ap[3];
int p[3];
int d[7];
int b[7];
int bp[7];
int sg[7];
int nb;
int det;
} band[2];
struct {
int s;
int sp;
int sz;
int r[3];
int a[3];
int ap[3];
int p[3];
int d[7];
int b[7];
int bp[7];
int sg[7];
int nb;
int det;
} band[2];
unsigned int in_buffer;
int in_bits;
unsigned int out_buffer;
int out_bits;
unsigned int in_buffer;
int in_bits;
unsigned int out_buffer;
int out_bits;
} G722EncoderState;
typedef struct
{
/*! TRUE if the operating in the special ITU test mode, with the band split filters
disabled. */
int itu_test_mode;
/*! TRUE if the G.722 data is packed */
int packed;
/*! TRUE if decode to 8k samples/second */
int eight_k;
/*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */
int bits_per_sample;
typedef struct {
/*! TRUE if the operating in the special ITU test mode, with the band split
filters disabled. */
int itu_test_mode;
/*! TRUE if the G.722 data is packed */
int packed;
/*! TRUE if decode to 8k samples/second */
int eight_k;
/*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */
int bits_per_sample;
/*! Signal history for the QMF */
int x[24];
/*! Signal history for the QMF */
int x[24];
struct
{
int s;
int sp;
int sz;
int r[3];
int a[3];
int ap[3];
int p[3];
int d[7];
int b[7];
int bp[7];
int sg[7];
int nb;
int det;
} band[2];
unsigned int in_buffer;
int in_bits;
unsigned int out_buffer;
int out_bits;
struct {
int s;
int sp;
int sz;
int r[3];
int a[3];
int ap[3];
int p[3];
int d[7];
int b[7];
int bp[7];
int sg[7];
int nb;
int det;
} band[2];
unsigned int in_buffer;
int in_bits;
unsigned int out_buffer;
int out_bits;
} G722DecoderState;
#ifdef __cplusplus
@ -138,8 +131,8 @@ extern "C" {
G722EncoderState* WebRtc_g722_encode_init(G722EncoderState* s,
int rate,
int options);
int WebRtc_g722_encode_release(G722EncoderState *s);
size_t WebRtc_g722_encode(G722EncoderState *s,
int WebRtc_g722_encode_release(G722EncoderState* s);
size_t WebRtc_g722_encode(G722EncoderState* s,
uint8_t g722_data[],
const int16_t amp[],
size_t len);
@ -147,8 +140,8 @@ size_t WebRtc_g722_encode(G722EncoderState *s,
G722DecoderState* WebRtc_g722_decode_init(G722DecoderState* s,
int rate,
int options);
int WebRtc_g722_decode_release(G722DecoderState *s);
size_t WebRtc_g722_decode(G722DecoderState *s,
int WebRtc_g722_decode_release(G722DecoderState* s);
size_t WebRtc_g722_decode(G722DecoderState* s,
int16_t amp[],
const uint8_t g722_data[],
size_t len);

View File

@ -17,21 +17,20 @@
* Solution to support multiple instances
*/
typedef struct WebRtcG722EncInst G722EncInst;
typedef struct WebRtcG722DecInst G722DecInst;
typedef struct WebRtcG722EncInst G722EncInst;
typedef struct WebRtcG722DecInst G722DecInst;
/*
* Comfort noise constants
*/
#define G722_WEBRTC_SPEECH 1
#define G722_WEBRTC_CNG 2
#define G722_WEBRTC_SPEECH 1
#define G722_WEBRTC_CNG 2
#ifdef __cplusplus
extern "C" {
#endif
/****************************************************************************
* WebRtcG722_CreateEncoder(...)
*
@ -43,8 +42,7 @@ extern "C" {
* Return value : 0 - Ok
* -1 - Error
*/
int16_t WebRtcG722_CreateEncoder(G722EncInst **G722enc_inst);
int16_t WebRtcG722_CreateEncoder(G722EncInst** G722enc_inst);
/****************************************************************************
* WebRtcG722_EncoderInit(...)
@ -59,8 +57,7 @@ int16_t WebRtcG722_CreateEncoder(G722EncInst **G722enc_inst);
* -1 - Error
*/
int16_t WebRtcG722_EncoderInit(G722EncInst *G722enc_inst);
int16_t WebRtcG722_EncoderInit(G722EncInst* G722enc_inst);
/****************************************************************************
* WebRtcG722_FreeEncoder(...)
@ -73,9 +70,7 @@ int16_t WebRtcG722_EncoderInit(G722EncInst *G722enc_inst);
* Return value : 0 - Ok
* -1 - Error
*/
int WebRtcG722_FreeEncoder(G722EncInst *G722enc_inst);
int WebRtcG722_FreeEncoder(G722EncInst* G722enc_inst);
/****************************************************************************
* WebRtcG722_Encode(...)
@ -99,7 +94,6 @@ size_t WebRtcG722_Encode(G722EncInst* G722enc_inst,
size_t len,
uint8_t* encoded);
/****************************************************************************
* WebRtcG722_CreateDecoder(...)
*
@ -111,7 +105,7 @@ size_t WebRtcG722_Encode(G722EncInst* G722enc_inst,
* Return value : 0 - Ok
* -1 - Error
*/
int16_t WebRtcG722_CreateDecoder(G722DecInst **G722dec_inst);
int16_t WebRtcG722_CreateDecoder(G722DecInst** G722dec_inst);
/****************************************************************************
* WebRtcG722_DecoderInit(...)
@ -136,8 +130,7 @@ void WebRtcG722_DecoderInit(G722DecInst* inst);
* -1 - Error
*/
int WebRtcG722_FreeDecoder(G722DecInst *G722dec_inst);
int WebRtcG722_FreeDecoder(G722DecInst* G722dec_inst);
/****************************************************************************
* WebRtcG722_Decode(...)
@ -159,11 +152,11 @@ int WebRtcG722_FreeDecoder(G722DecInst *G722dec_inst);
* Return value : Samples in decoded vector
*/
size_t WebRtcG722_Decode(G722DecInst *G722dec_inst,
size_t WebRtcG722_Decode(G722DecInst* G722dec_inst,
const uint8_t* encoded,
size_t len,
int16_t *decoded,
int16_t *speechType);
int16_t* decoded,
int16_t* speechType);
/****************************************************************************
* WebRtcG722_Version(...)
@ -171,12 +164,10 @@ size_t WebRtcG722_Decode(G722DecInst *G722dec_inst,
* Get a string with the current version of the codec
*/
int16_t WebRtcG722_Version(char *versionStr, short len);
int16_t WebRtcG722_Version(char* versionStr, short len);
#ifdef __cplusplus
}
#endif
#endif /* MODULES_AUDIO_CODING_CODECS_G722_G722_INTERFACE_H_ */

View File

@ -22,137 +22,135 @@
/* Runtime statistics */
#include <time.h>
#define CLOCKS_PER_SEC_G722 100000
#define CLOCKS_PER_SEC_G722 100000
// Forward declaration
typedef struct WebRtcG722EncInst G722EncInst;
typedef struct WebRtcG722DecInst G722DecInst;
typedef struct WebRtcG722EncInst G722EncInst;
typedef struct WebRtcG722DecInst G722DecInst;
/* function for reading audio data from PCM file */
bool readframe(int16_t *data, FILE *inp, size_t length)
{
size_t rlen = fread(data, sizeof(int16_t), length, inp);
if (rlen >= length)
return false;
memset(data + rlen, 0, (length - rlen) * sizeof(int16_t));
return true;
bool readframe(int16_t* data, FILE* inp, size_t length) {
size_t rlen = fread(data, sizeof(int16_t), length, inp);
if (rlen >= length)
return false;
memset(data + rlen, 0, (length - rlen) * sizeof(int16_t));
return true;
}
int main(int argc, char* argv[])
{
char inname[60], outbit[40], outname[40];
FILE *inp, *outbitp, *outp;
int main(int argc, char* argv[]) {
char inname[60], outbit[40], outname[40];
FILE *inp, *outbitp, *outp;
int framecnt;
bool endfile;
size_t framelength = 160;
G722EncInst *G722enc_inst;
G722DecInst *G722dec_inst;
int framecnt;
bool endfile;
size_t framelength = 160;
G722EncInst* G722enc_inst;
G722DecInst* G722dec_inst;
/* Runtime statistics */
double starttime;
double runtime = 0;
double length_file;
/* Runtime statistics */
double starttime;
double runtime = 0;
double length_file;
size_t stream_len = 0;
int16_t shortdata[960];
int16_t decoded[960];
uint8_t streamdata[80 * 6];
int16_t speechType[1];
size_t stream_len = 0;
int16_t shortdata[960];
int16_t decoded[960];
uint8_t streamdata[80 * 6];
int16_t speechType[1];
/* handling wrong input arguments in the command line */
if (argc!=5) {
printf("\n\nWrong number of arguments or flag values.\n\n");
/* handling wrong input arguments in the command line */
if (argc != 5) {
printf("\n\nWrong number of arguments or flag values.\n\n");
printf("\n");
printf("Usage:\n\n");
printf("./testG722.exe framelength infile outbitfile outspeechfile \n\n");
printf("with:\n");
printf("framelength : Framelength in samples.\n\n");
printf("infile : Normal speech input file\n\n");
printf("outbitfile : Bitstream output file\n\n");
printf("outspeechfile: Speech output file\n\n");
exit(0);
printf("\n");
printf("Usage:\n\n");
printf("./testG722.exe framelength infile outbitfile outspeechfile \n\n");
printf("with:\n");
printf("framelength : Framelength in samples.\n\n");
printf("infile : Normal speech input file\n\n");
printf("outbitfile : Bitstream output file\n\n");
printf("outspeechfile: Speech output file\n\n");
exit(0);
}
/* Get frame length */
int framelength_int = atoi(argv[1]);
if (framelength_int < 0) {
printf(" G.722: Invalid framelength %d.\n", framelength_int);
exit(1);
}
framelength = static_cast<size_t>(framelength_int);
/* Get Input and Output files */
sscanf(argv[2], "%s", inname);
sscanf(argv[3], "%s", outbit);
sscanf(argv[4], "%s", outname);
if ((inp = fopen(inname, "rb")) == NULL) {
printf(" G.722: Cannot read file %s.\n", inname);
exit(1);
}
if ((outbitp = fopen(outbit, "wb")) == NULL) {
printf(" G.722: Cannot write file %s.\n", outbit);
exit(1);
}
if ((outp = fopen(outname, "wb")) == NULL) {
printf(" G.722: Cannot write file %s.\n", outname);
exit(1);
}
printf("\nInput:%s\nOutput bitstream:%s\nOutput:%s\n", inname, outbit,
outname);
/* Create and init */
WebRtcG722_CreateEncoder((G722EncInst**)&G722enc_inst);
WebRtcG722_CreateDecoder((G722DecInst**)&G722dec_inst);
WebRtcG722_EncoderInit((G722EncInst*)G722enc_inst);
WebRtcG722_DecoderInit((G722DecInst*)G722dec_inst);
/* Initialize encoder and decoder */
framecnt = 0;
endfile = false;
while (!endfile) {
framecnt++;
/* Read speech block */
endfile = readframe(shortdata, inp, framelength);
/* Start clock before call to encoder and decoder */
starttime = clock() / (double)CLOCKS_PER_SEC_G722;
/* G.722 encoding + decoding */
stream_len = WebRtcG722_Encode((G722EncInst*)G722enc_inst, shortdata,
framelength, streamdata);
WebRtcG722_Decode(G722dec_inst, streamdata, stream_len, decoded,
speechType);
/* Stop clock after call to encoder and decoder */
runtime += (double)((clock() / (double)CLOCKS_PER_SEC_G722) - starttime);
/* Write coded bits to file */
if (fwrite(streamdata, sizeof(short), stream_len / 2, outbitp) !=
stream_len / 2) {
return -1;
}
/* Get frame length */
int framelength_int = atoi(argv[1]);
if (framelength_int < 0) {
printf(" G.722: Invalid framelength %d.\n", framelength_int);
exit(1);
/* Write coded speech to file */
if (fwrite(decoded, sizeof(short), framelength, outp) != framelength) {
return -1;
}
framelength = static_cast<size_t>(framelength_int);
}
/* Get Input and Output files */
sscanf(argv[2], "%s", inname);
sscanf(argv[3], "%s", outbit);
sscanf(argv[4], "%s", outname);
WebRtcG722_FreeEncoder((G722EncInst*)G722enc_inst);
WebRtcG722_FreeDecoder((G722DecInst*)G722dec_inst);
if ((inp = fopen(inname,"rb")) == NULL) {
printf(" G.722: Cannot read file %s.\n", inname);
exit(1);
}
if ((outbitp = fopen(outbit,"wb")) == NULL) {
printf(" G.722: Cannot write file %s.\n", outbit);
exit(1);
}
if ((outp = fopen(outname,"wb")) == NULL) {
printf(" G.722: Cannot write file %s.\n", outname);
exit(1);
}
printf("\nInput:%s\nOutput bitstream:%s\nOutput:%s\n", inname, outbit, outname);
length_file = ((double)framecnt * (double)framelength / 16000);
printf("\n\nLength of speech file: %.1f s\n", length_file);
printf("Time to run G.722: %.2f s (%.2f %% of realtime)\n\n", runtime,
(100 * runtime / length_file));
printf("---------------------END----------------------\n");
/* Create and init */
WebRtcG722_CreateEncoder((G722EncInst **)&G722enc_inst);
WebRtcG722_CreateDecoder((G722DecInst **)&G722dec_inst);
WebRtcG722_EncoderInit((G722EncInst *)G722enc_inst);
WebRtcG722_DecoderInit((G722DecInst *)G722dec_inst);
fclose(inp);
fclose(outbitp);
fclose(outp);
/* Initialize encoder and decoder */
framecnt = 0;
endfile = false;
while (!endfile) {
framecnt++;
/* Read speech block */
endfile = readframe(shortdata, inp, framelength);
/* Start clock before call to encoder and decoder */
starttime = clock()/(double)CLOCKS_PER_SEC_G722;
/* G.722 encoding + decoding */
stream_len = WebRtcG722_Encode((G722EncInst *)G722enc_inst, shortdata, framelength, streamdata);
WebRtcG722_Decode(G722dec_inst, streamdata, stream_len, decoded,
speechType);
/* Stop clock after call to encoder and decoder */
runtime += (double)((clock()/(double)CLOCKS_PER_SEC_G722)-starttime);
/* Write coded bits to file */
if (fwrite(streamdata, sizeof(short), stream_len / 2, outbitp) !=
stream_len / 2) {
return -1;
}
/* Write coded speech to file */
if (fwrite(decoded, sizeof(short), framelength, outp) !=
framelength) {
return -1;
}
}
WebRtcG722_FreeEncoder((G722EncInst *)G722enc_inst);
WebRtcG722_FreeDecoder((G722DecInst *)G722dec_inst);
length_file = ((double)framecnt*(double)framelength/16000);
printf("\n\nLength of speech file: %.1f s\n", length_file);
printf("Time to run G.722: %.2f s (%.2f %% of realtime)\n\n", runtime, (100*runtime/length_file));
printf("---------------------END----------------------\n");
fclose(inp);
fclose(outbitp);
fclose(outp);
return 0;
return 0;
}

View File

@ -27,13 +27,13 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_AbsQuant(
IlbcEncoder *iLBCenc_inst,
IlbcEncoder* iLBCenc_inst,
/* (i) Encoder instance */
iLBC_bits *iLBC_encbits, /* (i/o) Encoded bits (outputs idxForMax
iLBC_bits* iLBC_encbits, /* (i/o) Encoded bits (outputs idxForMax
and idxVec, uses state_first as
input) */
int16_t *in, /* (i) vector to encode */
int16_t *weightDenum /* (i) denominator of synthesis filter */
);
int16_t* in, /* (i) vector to encode */
int16_t* weightDenum /* (i) denominator of synthesis filter */
);
#endif

View File

@ -26,8 +26,10 @@
* (subrutine for WebRtcIlbcfix_StateSearch)
*---------------------------------------------------------------*/
void WebRtcIlbcfix_AbsQuantLoop(int16_t *syntOutIN, int16_t *in_weightedIN,
int16_t *weightDenumIN, size_t *quantLenIN,
int16_t *idxVecIN);
void WebRtcIlbcfix_AbsQuantLoop(int16_t* syntOutIN,
int16_t* in_weightedIN,
int16_t* weightDenumIN,
size_t* quantLenIN,
int16_t* idxVecIN);
#endif

View File

@ -33,10 +33,10 @@ bool AudioDecoderIlbcImpl::HasDecodePlc() const {
}
int AudioDecoderIlbcImpl::DecodeInternal(const uint8_t* encoded,
size_t encoded_len,
int sample_rate_hz,
int16_t* decoded,
SpeechType* speech_type) {
size_t encoded_len,
int sample_rate_hz,
int16_t* decoded,
SpeechType* speech_type) {
RTC_DCHECK_EQ(sample_rate_hz, 8000);
int16_t temp_type = 1; // Default is speech.
int ret = WebRtcIlbcfix_Decode(dec_state_, encoded, encoded_len, decoded,
@ -86,10 +86,9 @@ std::vector<AudioDecoder::ParseResult> AudioDecoderIlbcImpl::ParsePayload(
} else {
size_t byte_offset;
uint32_t timestamp_offset;
for (byte_offset = 0, timestamp_offset = 0;
byte_offset < payload.size();
for (byte_offset = 0, timestamp_offset = 0; byte_offset < payload.size();
byte_offset += bytes_per_frame,
timestamp_offset += timestamps_per_frame) {
timestamp_offset += timestamps_per_frame) {
std::unique_ptr<EncodedAudioFrame> frame(new LegacyEncodedAudioFrame(
this, rtc::Buffer(payload.data() + byte_offset, bytes_per_frame)));
results.emplace_back(timestamp + timestamp_offset, 0, std::move(frame));

View File

@ -89,7 +89,6 @@ AudioEncoder::EncodedInfo AudioEncoderIlbcImpl::EncodeImpl(
uint32_t rtp_timestamp,
rtc::ArrayView<const int16_t> audio,
rtc::Buffer* encoded) {
// Save timestamp if starting a new packet.
if (num_10ms_frames_buffered_ == 0)
first_timestamp_in_buffer_ = rtp_timestamp;
@ -107,19 +106,15 @@ AudioEncoder::EncodedInfo AudioEncoderIlbcImpl::EncodeImpl(
// Encode buffered input.
RTC_DCHECK_EQ(num_10ms_frames_buffered_, num_10ms_frames_per_packet_);
num_10ms_frames_buffered_ = 0;
size_t encoded_bytes =
encoded->AppendData(
RequiredOutputSizeBytes(),
[&] (rtc::ArrayView<uint8_t> encoded) {
const int r = WebRtcIlbcfix_Encode(
encoder_,
input_buffer_,
kSampleRateHz / 100 * num_10ms_frames_per_packet_,
encoded.data());
RTC_CHECK_GE(r, 0);
size_t encoded_bytes = encoded->AppendData(
RequiredOutputSizeBytes(), [&](rtc::ArrayView<uint8_t> encoded) {
const int r = WebRtcIlbcfix_Encode(
encoder_, input_buffer_,
kSampleRateHz / 100 * num_10ms_frames_per_packet_, encoded.data());
RTC_CHECK_GE(r, 0);
return static_cast<size_t>(r);
});
return static_cast<size_t>(r);
});
RTC_DCHECK_EQ(encoded_bytes, RequiredOutputSizeBytes());
@ -135,20 +130,24 @@ void AudioEncoderIlbcImpl::Reset() {
if (encoder_)
RTC_CHECK_EQ(0, WebRtcIlbcfix_EncoderFree(encoder_));
RTC_CHECK_EQ(0, WebRtcIlbcfix_EncoderCreate(&encoder_));
const int encoder_frame_size_ms = frame_size_ms_ > 30
? frame_size_ms_ / 2
: frame_size_ms_;
const int encoder_frame_size_ms =
frame_size_ms_ > 30 ? frame_size_ms_ / 2 : frame_size_ms_;
RTC_CHECK_EQ(0, WebRtcIlbcfix_EncoderInit(encoder_, encoder_frame_size_ms));
num_10ms_frames_buffered_ = 0;
}
size_t AudioEncoderIlbcImpl::RequiredOutputSizeBytes() const {
switch (num_10ms_frames_per_packet_) {
case 2: return 38;
case 3: return 50;
case 4: return 2 * 38;
case 6: return 2 * 50;
default: FATAL();
case 2:
return 38;
case 3:
return 50;
case 4:
return 2 * 38;
case 6:
return 2 * 50;
default:
FATAL();
}
}

View File

@ -26,16 +26,16 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_AugmentedCbCorr(
int16_t *target, /* (i) Target vector */
int16_t *buffer, /* (i) Memory buffer */
int16_t *interpSamples, /* (i) buffer with
int16_t* target, /* (i) Target vector */
int16_t* buffer, /* (i) Memory buffer */
int16_t* interpSamples, /* (i) buffer with
interpolated samples */
int32_t *crossDot, /* (o) The cross correlation between
the target and the Augmented
vector */
size_t low, /* (i) Lag to start from (typically
20) */
size_t high, /* (i) Lag to end at (typically 39 */
int scale); /* (i) Scale factor to use for the crossDot */
int32_t* crossDot, /* (o) The cross correlation between
the target and the Augmented
vector */
size_t low, /* (i) Lag to start from (typically
20) */
size_t high, /* (i) Lag to end at (typically 39 */
int scale); /* (i) Scale factor to use for the crossDot */
#endif

View File

@ -26,11 +26,11 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_BwExpand(
int16_t *out, /* (o) the bandwidth expanded lpc coefficients */
int16_t *in, /* (i) the lpc coefficients before bandwidth
expansion */
int16_t *coef, /* (i) the bandwidth expansion factor Q15 */
int16_t* out, /* (o) the bandwidth expanded lpc coefficients */
int16_t* in, /* (i) the lpc coefficients before bandwidth
expansion */
int16_t* coef, /* (i) the bandwidth expansion factor Q15 */
int16_t length /* (i) the length of lpc coefficient vectors */
);
);
#endif

View File

@ -21,14 +21,14 @@
void WebRtcIlbcfix_CbMemEnergy(
size_t range,
int16_t *CB, /* (i) The CB memory (1:st section) */
int16_t *filteredCB, /* (i) The filtered CB memory (2:nd section) */
size_t lMem, /* (i) Length of the CB memory */
size_t lTarget, /* (i) Length of the target vector */
int16_t *energyW16, /* (o) Energy in the CB vectors */
int16_t *energyShifts, /* (o) Shift value of the energy */
int scale, /* (i) The scaling of all energy values */
size_t base_size /* (i) Index to where energy values should be stored */
);
int16_t* CB, /* (i) The CB memory (1:st section) */
int16_t* filteredCB, /* (i) The filtered CB memory (2:nd section) */
size_t lMem, /* (i) Length of the CB memory */
size_t lTarget, /* (i) Length of the target vector */
int16_t* energyW16, /* (o) Energy in the CB vectors */
int16_t* energyShifts, /* (o) Shift value of the energy */
int scale, /* (i) The scaling of all energy values */
size_t base_size /* (i) Index to where energy values should be stored */
);
#endif

View File

@ -20,12 +20,12 @@
#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_MEM_ENERGY_AUGMENTATION_H_
void WebRtcIlbcfix_CbMemEnergyAugmentation(
int16_t *interpSamples, /* (i) The interpolated samples */
int16_t *CBmem, /* (i) The CB memory */
int scale, /* (i) The scaling of all energy values */
size_t base_size, /* (i) Index to where energy values should be stored */
int16_t *energyW16, /* (o) Energy in the CB vectors */
int16_t *energyShifts /* (o) Shift value of the energy */
);
int16_t* interpSamples, /* (i) The interpolated samples */
int16_t* CBmem, /* (i) The CB memory */
int scale, /* (i) The scaling of all energy values */
size_t base_size, /* (i) Index to where energy values should be stored */
int16_t* energyW16, /* (o) Energy in the CB vectors */
int16_t* energyShifts /* (o) Shift value of the energy */
);
#endif

View File

@ -20,14 +20,14 @@
#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_MEM_ENERGY_CALC_H_
void WebRtcIlbcfix_CbMemEnergyCalc(
int32_t energy, /* (i) input start energy */
size_t range, /* (i) number of iterations */
int16_t *ppi, /* (i) input pointer 1 */
int16_t *ppo, /* (i) input pointer 2 */
int16_t *energyW16, /* (o) Energy in the CB vectors */
int16_t *energyShifts, /* (o) Shift value of the energy */
int scale, /* (i) The scaling of all energy values */
size_t base_size /* (i) Index to where energy values should be stored */
);
int32_t energy, /* (i) input start energy */
size_t range, /* (i) number of iterations */
int16_t* ppi, /* (i) input pointer 1 */
int16_t* ppo, /* (i) input pointer 2 */
int16_t* energyW16, /* (o) Energy in the CB vectors */
int16_t* energyShifts, /* (o) Shift value of the energy */
int scale, /* (i) The scaling of all energy values */
size_t base_size /* (i) Index to where energy values should be stored */
);
#endif

View File

@ -20,16 +20,16 @@
#define MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_SEARCH_H_
void WebRtcIlbcfix_CbSearch(
IlbcEncoder *iLBCenc_inst,
IlbcEncoder* iLBCenc_inst,
/* (i) the encoder state structure */
int16_t *index, /* (o) Codebook indices */
int16_t *gain_index, /* (o) Gain quantization indices */
int16_t *intarget, /* (i) Target vector for encoding */
int16_t *decResidual,/* (i) Decoded residual for codebook construction */
size_t lMem, /* (i) Length of buffer */
size_t lTarget, /* (i) Length of vector */
int16_t *weightDenum,/* (i) weighting filter coefficients in Q12 */
size_t block /* (i) the subblock number */
);
int16_t* index, /* (o) Codebook indices */
int16_t* gain_index, /* (o) Gain quantization indices */
int16_t* intarget, /* (i) Target vector for encoding */
int16_t* decResidual, /* (i) Decoded residual for codebook construction */
size_t lMem, /* (i) Length of buffer */
size_t lTarget, /* (i) Length of vector */
int16_t* weightDenum, /* (i) weighting filter coefficients in Q12 */
size_t block /* (i) the subblock number */
);
#endif

View File

@ -22,19 +22,19 @@
#include "modules/audio_coding/codecs/ilbc/defines.h"
void WebRtcIlbcfix_CbSearchCore(
int32_t *cDot, /* (i) Cross Correlation */
size_t range, /* (i) Search range */
int16_t stage, /* (i) Stage of this search */
int16_t *inverseEnergy, /* (i) Inversed energy */
int16_t *inverseEnergyShift, /* (i) Shifts of inversed energy
int32_t* cDot, /* (i) Cross Correlation */
size_t range, /* (i) Search range */
int16_t stage, /* (i) Stage of this search */
int16_t* inverseEnergy, /* (i) Inversed energy */
int16_t* inverseEnergyShift, /* (i) Shifts of inversed energy
with the offset 2*16-29 */
int32_t *Crit, /* (o) The criteria */
size_t *bestIndex, /* (o) Index that corresponds to
maximum criteria (in this
vector) */
int32_t *bestCrit, /* (o) Value of critera for the
chosen index */
int16_t *bestCritSh); /* (o) The domain of the chosen
criteria */
int32_t* Crit, /* (o) The criteria */
size_t* bestIndex, /* (o) Index that corresponds to
maximum criteria (in this
vector) */
int32_t* bestCrit, /* (o) Value of critera for the
chosen index */
int16_t* bestCritSh); /* (o) The domain of the chosen
criteria */
#endif

View File

@ -22,17 +22,17 @@
#include "modules/audio_coding/codecs/ilbc/defines.h"
void WebRtcIlbcfix_CbUpdateBestIndex(
int32_t CritNew, /* (i) New Potentially best Criteria */
int16_t CritNewSh, /* (i) Shift value of above Criteria */
size_t IndexNew, /* (i) Index of new Criteria */
int32_t cDotNew, /* (i) Cross dot of new index */
int16_t invEnergyNew, /* (i) Inversed energy new index */
int16_t energyShiftNew, /* (i) Energy shifts of new index */
int32_t *CritMax, /* (i/o) Maximum Criteria (so far) */
int16_t *shTotMax, /* (i/o) Shifts of maximum criteria */
size_t *bestIndex, /* (i/o) Index that corresponds to
maximum criteria */
int16_t *bestGain); /* (i/o) Gain in Q14 that corresponds
to maximum criteria */
int32_t CritNew, /* (i) New Potentially best Criteria */
int16_t CritNewSh, /* (i) Shift value of above Criteria */
size_t IndexNew, /* (i) Index of new Criteria */
int32_t cDotNew, /* (i) Cross dot of new index */
int16_t invEnergyNew, /* (i) Inversed energy new index */
int16_t energyShiftNew, /* (i) Energy shifts of new index */
int32_t* CritMax, /* (i/o) Maximum Criteria (so far) */
int16_t* shTotMax, /* (i/o) Shifts of maximum criteria */
size_t* bestIndex, /* (i/o) Index that corresponds to
maximum criteria */
int16_t* bestGain); /* (i/o) Gain in Q14 that corresponds
to maximum criteria */
#endif

View File

@ -30,8 +30,8 @@
int16_t WebRtcIlbcfix_Chebyshev(
/* (o) Result of C(x) */
int16_t x, /* (i) Value to the Chevyshev polynomial */
int16_t *f /* (i) The coefficients in the polynomial */
);
int16_t x, /* (i) Value to the Chevyshev polynomial */
int16_t* f /* (i) The coefficients in the polynomial */
);
#endif

View File

@ -26,14 +26,13 @@
* of last subframe at given lag.
*---------------------------------------------------------------*/
void WebRtcIlbcfix_CompCorr(
int32_t *corr, /* (o) cross correlation */
int32_t *ener, /* (o) energy */
int16_t *buffer, /* (i) signal buffer */
size_t lag, /* (i) pitch lag */
size_t bLen, /* (i) length of buffer */
size_t sRange, /* (i) correlation search length */
int16_t scale /* (i) number of rightshifts to use */
void WebRtcIlbcfix_CompCorr(int32_t* corr, /* (o) cross correlation */
int32_t* ener, /* (o) energy */
int16_t* buffer, /* (i) signal buffer */
size_t lag, /* (i) pitch lag */
size_t bLen, /* (i) length of buffer */
size_t sRange, /* (i) correlation search length */
int16_t scale /* (i) number of rightshifts to use */
);
#endif

View File

@ -79,7 +79,8 @@ extern const int16_t WebRtcIlbcfix_kAlpha[];
/* enhancer definitions */
extern const int16_t WebRtcIlbcfix_kEnhPolyPhaser[ENH_UPS0][ENH_FLO_MULT2_PLUS1];
extern const int16_t WebRtcIlbcfix_kEnhPolyPhaser[ENH_UPS0]
[ENH_FLO_MULT2_PLUS1];
extern const int16_t WebRtcIlbcfix_kEnhWt[];
extern const size_t WebRtcIlbcfix_kEnhPlocs[];

View File

@ -27,8 +27,8 @@
*----------------------------------------------------------------*/
void WebRtcIlbcfix_CreateAugmentedVec(
size_t index, /* (i) Index for the augmented vector to be
created */
size_t index, /* (i) Index for the augmented vector to be
created */
const int16_t* buffer, /* (i) Pointer to the end of the codebook memory
that is used for creation of the augmented
codebook */

View File

@ -31,8 +31,8 @@ int WebRtcIlbcfix_DecodeImpl(
const uint16_t* bytes, /* (i) encoded signal bits */
IlbcDecoder* iLBCdec_inst, /* (i/o) the decoder state
structure */
int16_t mode /* (i) 0: bad packet, PLC,
1: normal */
int16_t mode /* (i) 0: bad packet, PLC,
1: normal */
) RTC_WARN_UNUSED_RESULT;
#endif

View File

@ -26,13 +26,13 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_DecoderInterpolateLsp(
int16_t *syntdenum, /* (o) synthesis filter coefficients */
int16_t *weightdenum, /* (o) weighting denumerator
int16_t* syntdenum, /* (o) synthesis filter coefficients */
int16_t* weightdenum, /* (o) weighting denumerator
coefficients */
int16_t *lsfdeq, /* (i) dequantized lsf coefficients */
int16_t length, /* (i) length of lsf coefficient vector */
IlbcDecoder *iLBCdec_inst
int16_t* lsfdeq, /* (i) dequantized lsf coefficients */
int16_t length, /* (i) length of lsf coefficient vector */
IlbcDecoder* iLBCdec_inst
/* (i) the decoder state structure */
);
);
#endif

View File

@ -25,103 +25,109 @@
/* general codec settings */
#define FS 8000
#define BLOCKL_20MS 160
#define BLOCKL_30MS 240
#define BLOCKL_MAX 240
#define NSUB_20MS 4
#define NSUB_30MS 6
#define NSUB_MAX 6
#define NASUB_20MS 2
#define NASUB_30MS 4
#define NASUB_MAX 4
#define SUBL 40
#define STATE_LEN 80
#define STATE_SHORT_LEN_30MS 58
#define STATE_SHORT_LEN_20MS 57
#define FS 8000
#define BLOCKL_20MS 160
#define BLOCKL_30MS 240
#define BLOCKL_MAX 240
#define NSUB_20MS 4
#define NSUB_30MS 6
#define NSUB_MAX 6
#define NASUB_20MS 2
#define NASUB_30MS 4
#define NASUB_MAX 4
#define SUBL 40
#define STATE_LEN 80
#define STATE_SHORT_LEN_30MS 58
#define STATE_SHORT_LEN_20MS 57
/* LPC settings */
#define LPC_FILTERORDER 10
#define LPC_LOOKBACK 60
#define LPC_N_20MS 1
#define LPC_N_30MS 2
#define LPC_N_MAX 2
#define LPC_ASYMDIFF 20
#define LSF_NSPLIT 3
#define LSF_NUMBER_OF_STEPS 4
#define LPC_HALFORDER 5
#define LPC_FILTERORDER 10
#define LPC_LOOKBACK 60
#define LPC_N_20MS 1
#define LPC_N_30MS 2
#define LPC_N_MAX 2
#define LPC_ASYMDIFF 20
#define LSF_NSPLIT 3
#define LSF_NUMBER_OF_STEPS 4
#define LPC_HALFORDER 5
#define COS_GRID_POINTS 60
/* cb settings */
#define CB_NSTAGES 3
#define CB_EXPAND 2
#define CB_MEML 147
#define CB_FILTERLEN (2*4)
#define CB_HALFFILTERLEN 4
#define CB_RESRANGE 34
#define CB_MAXGAIN_FIXQ6 83 /* error = -0.24% */
#define CB_MAXGAIN_FIXQ14 21299
#define CB_NSTAGES 3
#define CB_EXPAND 2
#define CB_MEML 147
#define CB_FILTERLEN (2 * 4)
#define CB_HALFFILTERLEN 4
#define CB_RESRANGE 34
#define CB_MAXGAIN_FIXQ6 83 /* error = -0.24% */
#define CB_MAXGAIN_FIXQ14 21299
/* enhancer */
#define ENH_BLOCKL 80 /* block length */
#define ENH_BLOCKL_HALF (ENH_BLOCKL/2)
#define ENH_HL 3 /* 2*ENH_HL+1 is number blocks
in said second sequence */
#define ENH_SLOP 2 /* max difference estimated and
correct pitch period */
#define ENH_PLOCSL 8 /* pitch-estimates and
pitch-locations buffer length */
#define ENH_OVERHANG 2
#define ENH_UPS0 4 /* upsampling rate */
#define ENH_FL0 3 /* 2*FLO+1 is the length of each filter */
#define ENH_FLO_MULT2_PLUS1 7
#define ENH_VECTL (ENH_BLOCKL+2*ENH_FL0)
#define ENH_CORRDIM (2*ENH_SLOP+1)
#define ENH_NBLOCKS (BLOCKL/ENH_BLOCKL)
#define ENH_NBLOCKS_EXTRA 5
#define ENH_NBLOCKS_TOT 8 /* ENH_NBLOCKS+ENH_NBLOCKS_EXTRA */
#define ENH_BUFL (ENH_NBLOCKS_TOT)*ENH_BLOCKL
#define ENH_BUFL_FILTEROVERHEAD 3
#define ENH_A0 819 /* Q14 */
#define ENH_A0_MINUS_A0A0DIV4 848256041 /* Q34 */
#define ENH_A0DIV2 26843546 /* Q30 */
#define ENH_BLOCKL 80 /* block length */
#define ENH_BLOCKL_HALF (ENH_BLOCKL / 2)
#define ENH_HL \
3 /* 2*ENH_HL+1 is number blocks \
in said second \
sequence */
#define ENH_SLOP \
2 /* max difference estimated and \
correct pitch period */
#define ENH_PLOCSL \
8 /* pitch-estimates and \
pitch-locations buffer \
length */
#define ENH_OVERHANG 2
#define ENH_UPS0 4 /* upsampling rate */
#define ENH_FL0 3 /* 2*FLO+1 is the length of each filter */
#define ENH_FLO_MULT2_PLUS1 7
#define ENH_VECTL (ENH_BLOCKL + 2 * ENH_FL0)
#define ENH_CORRDIM (2 * ENH_SLOP + 1)
#define ENH_NBLOCKS (BLOCKL / ENH_BLOCKL)
#define ENH_NBLOCKS_EXTRA 5
#define ENH_NBLOCKS_TOT 8 /* ENH_NBLOCKS+ENH_NBLOCKS_EXTRA */
#define ENH_BUFL (ENH_NBLOCKS_TOT) * ENH_BLOCKL
#define ENH_BUFL_FILTEROVERHEAD 3
#define ENH_A0 819 /* Q14 */
#define ENH_A0_MINUS_A0A0DIV4 848256041 /* Q34 */
#define ENH_A0DIV2 26843546 /* Q30 */
/* PLC */
/* Down sampling */
#define FILTERORDER_DS_PLUS1 7
#define DELAY_DS 3
#define FACTOR_DS 2
#define FILTERORDER_DS_PLUS1 7
#define DELAY_DS 3
#define FACTOR_DS 2
/* bit stream defs */
#define NO_OF_BYTES_20MS 38
#define NO_OF_BYTES_30MS 50
#define NO_OF_WORDS_20MS 19
#define NO_OF_WORDS_30MS 25
#define STATE_BITS 3
#define BYTE_LEN 8
#define ULP_CLASSES 3
#define NO_OF_BYTES_20MS 38
#define NO_OF_BYTES_30MS 50
#define NO_OF_WORDS_20MS 19
#define NO_OF_WORDS_30MS 25
#define STATE_BITS 3
#define BYTE_LEN 8
#define ULP_CLASSES 3
/* help parameters */
#define TWO_PI_FIX 25736 /* Q12 */
#define TWO_PI_FIX 25736 /* Q12 */
/* Constants for codebook search and creation */
#define ST_MEM_L_TBL 85
#define MEM_LF_TBL 147
#define ST_MEM_L_TBL 85
#define MEM_LF_TBL 147
/* Struct for the bits */
typedef struct iLBC_bits_t_ {
int16_t lsf[LSF_NSPLIT*LPC_N_MAX];
int16_t cb_index[CB_NSTAGES*(NASUB_MAX+1)]; /* First CB_NSTAGES values contains extra CB index */
int16_t gain_index[CB_NSTAGES*(NASUB_MAX+1)]; /* First CB_NSTAGES values contains extra CB gain */
int16_t lsf[LSF_NSPLIT * LPC_N_MAX];
int16_t cb_index[CB_NSTAGES * (NASUB_MAX + 1)]; /* First CB_NSTAGES values
contains extra CB index */
int16_t gain_index[CB_NSTAGES * (NASUB_MAX + 1)]; /* First CB_NSTAGES values
contains extra CB gain */
size_t idxForMax;
int16_t state_first;
int16_t idxVec[STATE_SHORT_LEN_30MS];
@ -131,7 +137,6 @@ typedef struct iLBC_bits_t_ {
/* type definition encoder instance */
typedef struct IlbcEncoder_ {
/* flag for frame size mode */
int16_t mode;
@ -172,7 +177,6 @@ typedef struct IlbcEncoder_ {
/* type definition decoder instance */
typedef struct IlbcDecoder_ {
/* flag for frame size mode */
int16_t mode;
@ -199,13 +203,13 @@ typedef struct IlbcDecoder_ {
int16_t prevScale, prevPLI;
size_t prevLag;
int16_t prevLpc[LPC_FILTERORDER+1];
int16_t prevResidual[NSUB_MAX*SUBL];
int16_t prevLpc[LPC_FILTERORDER + 1];
int16_t prevResidual[NSUB_MAX * SUBL];
int16_t seed;
/* previous synthesis filter parameters */
int16_t old_syntdenum[(LPC_FILTERORDER + 1)*NSUB_MAX];
int16_t old_syntdenum[(LPC_FILTERORDER + 1) * NSUB_MAX];
/* state of output HP filter */
int16_t hpimemx[2];
@ -213,7 +217,7 @@ typedef struct IlbcDecoder_ {
/* enhancer state information */
int use_enhancer;
int16_t enh_buf[ENH_BUFL+ENH_BUFL_FILTEROVERHEAD];
int16_t enh_buf[ENH_BUFL + ENH_BUFL_FILTEROVERHEAD];
size_t enh_period[ENH_NBLOCKS_TOT];
} IlbcDecoder;

View File

@ -27,15 +27,15 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_DoThePlc(
int16_t *PLCresidual, /* (o) concealed residual */
int16_t *PLClpc, /* (o) concealed LP parameters */
int16_t PLI, /* (i) packet loss indicator
0 - no PL, 1 = PL */
int16_t *decresidual, /* (i) decoded residual */
int16_t *lpc, /* (i) decoded LPC (only used for no PL) */
size_t inlag, /* (i) pitch lag */
IlbcDecoder *iLBCdec_inst
int16_t* PLCresidual, /* (o) concealed residual */
int16_t* PLClpc, /* (o) concealed LP parameters */
int16_t PLI, /* (i) packet loss indicator
0 - no PL, 1 = PL */
int16_t* decresidual, /* (i) decoded residual */
int16_t* lpc, /* (i) decoded LPC (only used for no PL) */
size_t inlag, /* (i) pitch lag */
IlbcDecoder* iLBCdec_inst
/* (i/o) decoder instance */
);
);
#endif

View File

@ -26,10 +26,10 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_EncodeImpl(
uint16_t *bytes, /* (o) encoded data bits iLBC */
const int16_t *block, /* (i) speech vector to encode */
IlbcEncoder *iLBCenc_inst /* (i/o) the general encoder
uint16_t* bytes, /* (o) encoded data bits iLBC */
const int16_t* block, /* (i) speech vector to encode */
IlbcEncoder* iLBCenc_inst /* (i/o) the general encoder
state */
);
);
#endif

View File

@ -24,9 +24,10 @@
/* Inverses the in vector in into Q29 domain */
void WebRtcIlbcfix_EnergyInverse(
int16_t *energy, /* (i/o) Energy and inverse
energy (in Q29) */
size_t noOfEnergies); /* (i) The length of the energy
vector */
int16_t*
energy, /* (i/o) Energy and inverse
energy (in Q29) */
size_t noOfEnergies); /* (i) The length of the energy
vector */
#endif

View File

@ -26,8 +26,8 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_EnhUpsample(
int32_t *useq1, /* (o) upsampled output sequence */
int16_t *seq1 /* (i) unupsampled sequence */
);
int32_t* useq1, /* (o) upsampled output sequence */
int16_t* seq1 /* (i) unupsampled sequence */
);
#endif

View File

@ -27,13 +27,13 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_Enhancer(
int16_t *odata, /* (o) smoothed block, dimension blockl */
int16_t *idata, /* (i) data buffer used for enhancing */
size_t idatal, /* (i) dimension idata */
int16_t* odata, /* (o) smoothed block, dimension blockl */
int16_t* idata, /* (i) data buffer used for enhancing */
size_t idatal, /* (i) dimension idata */
size_t centerStartPos, /* (i) first sample current block within idata */
size_t *period, /* (i) pitch period array (pitch bward-in time) */
const size_t *plocs, /* (i) locations where period array values valid */
size_t periodl /* (i) dimension of period and plocs */
);
size_t* period, /* (i) pitch period array (pitch bward-in time) */
const size_t* plocs, /* (i) locations where period array values valid */
size_t periodl /* (i) dimension of period and plocs */
);
#endif

View File

@ -26,9 +26,8 @@
*---------------------------------------------------------------*/
size_t // (o) Estimated lag in end of in[]
WebRtcIlbcfix_EnhancerInterface(
int16_t* out, // (o) enhanced signal
const int16_t* in, // (i) unenhanced signal
IlbcDecoder* iLBCdec_inst); // (i) buffers etc
WebRtcIlbcfix_EnhancerInterface(int16_t* out, // (o) enhanced signal
const int16_t* in, // (i) unenhanced signal
IlbcDecoder* iLBCdec_inst); // (i) buffers etc
#endif

View File

@ -28,11 +28,11 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_FilteredCbVecs(
int16_t *cbvectors, /* (o) Codebook vector for the higher section */
int16_t *CBmem, /* (i) Codebook memory that is filtered to create a
second CB section */
size_t lMem, /* (i) Length of codebook memory */
size_t samples /* (i) Number of samples to filter */
);
int16_t* cbvectors, /* (o) Codebook vector for the higher section */
int16_t* CBmem, /* (i) Codebook memory that is filtered to create a
second CB section */
size_t lMem, /* (i) Length of codebook memory */
size_t samples /* (i) Number of samples to filter */
);
#endif

View File

@ -21,9 +21,9 @@
size_t WebRtcIlbcfix_FrameClassify(
/* (o) Index to the max-energy sub frame */
IlbcEncoder *iLBCenc_inst,
IlbcEncoder* iLBCenc_inst,
/* (i/o) the encoder state structure */
int16_t *residualFIX /* (i) lpc residual signal */
);
int16_t* residualFIX /* (i) lpc residual signal */
);
#endif

View File

@ -30,7 +30,7 @@ int16_t WebRtcIlbcfix_GainDequant(
/* (o) quantized gain value (Q14) */
int16_t index, /* (i) quantization index */
int16_t maxIn, /* (i) maximum of unquantized gain (Q14) */
int16_t stage /* (i) The stage of the search */
);
int16_t stage /* (i) The stage of the search */
);
#endif

View File

@ -25,11 +25,12 @@
* quantizer for the gain in the gain-shape coding of residual
*---------------------------------------------------------------*/
int16_t WebRtcIlbcfix_GainQuant( /* (o) quantized gain value */
int16_t gain, /* (i) gain value Q14 */
int16_t maxIn, /* (i) maximum of gain value Q14 */
int16_t stage, /* (i) The stage of the search */
int16_t *index /* (o) quantization index */
);
int16_t
WebRtcIlbcfix_GainQuant( /* (o) quantized gain value */
int16_t gain, /* (i) gain value Q14 */
int16_t maxIn, /* (i) maximum of gain value Q14 */
int16_t stage, /* (i) The stage of the search */
int16_t* index /* (o) quantization index */
);
#endif

View File

@ -40,8 +40,7 @@
* }
*---------------------------------------------------------------*/
void WebRtcIlbcfix_GetLspPoly(
int16_t *lsp, /* (i) LSP in Q15 */
int32_t *f); /* (o) polonymial in Q24 */
void WebRtcIlbcfix_GetLspPoly(int16_t* lsp, /* (i) LSP in Q15 */
int32_t* f); /* (o) polonymial in Q24 */
#endif

View File

@ -26,15 +26,15 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_GetSyncSeq(
int16_t *idata, /* (i) original data */
size_t idatal, /* (i) dimension of data */
int16_t* idata, /* (i) original data */
size_t idatal, /* (i) dimension of data */
size_t centerStartPos, /* (i) where current block starts */
size_t *period, /* (i) rough-pitch-period array (Q-2) */
const size_t *plocs, /* (i) where periods of period array are taken (Q-2) */
size_t periodl, /* (i) dimension period array */
size_t hl, /* (i) 2*hl+1 is the number of sequences */
int16_t *surround /* (i/o) The contribution from this sequence
summed with earlier contributions */
);
size_t* period, /* (i) rough-pitch-period array (Q-2) */
const size_t* plocs, /* (i) where periods of period array are taken (Q-2) */
size_t periodl, /* (i) dimension period array */
size_t hl, /* (i) 2*hl+1 is the number of sequences */
int16_t* surround /* (i/o) The contribution from this sequence
summed with earlier contributions */
);
#endif

View File

@ -22,13 +22,13 @@
#include "modules/audio_coding/codecs/ilbc/defines.h"
void WebRtcIlbcfix_HpInput(
int16_t *signal, /* (i/o) signal vector */
int16_t *ba, /* (i) B- and A-coefficients (2:nd order)
{b[0] b[1] b[2] -a[1] -a[2]} a[0]
is assumed to be 1.0 */
int16_t *y, /* (i/o) Filter state yhi[n-1] ylow[n-1]
yhi[n-2] ylow[n-2] */
int16_t *x, /* (i/o) Filter state x[n-1] x[n-2] */
int16_t* signal, /* (i/o) signal vector */
int16_t* ba, /* (i) B- and A-coefficients (2:nd order)
{b[0] b[1] b[2] -a[1] -a[2]}
a[0] is assumed to be 1.0 */
int16_t* y, /* (i/o) Filter state yhi[n-1] ylow[n-1]
yhi[n-2] ylow[n-2] */
int16_t* x, /* (i/o) Filter state x[n-1] x[n-2] */
size_t len); /* (i) Number of samples to filter */
#endif

View File

@ -22,13 +22,13 @@
#include "modules/audio_coding/codecs/ilbc/defines.h"
void WebRtcIlbcfix_HpOutput(
int16_t *signal, /* (i/o) signal vector */
int16_t *ba, /* (i) B- and A-coefficients (2:nd order)
{b[0] b[1] b[2] -a[1] -a[2]} a[0]
is assumed to be 1.0 */
int16_t *y, /* (i/o) Filter state yhi[n-1] ylow[n-1]
int16_t* signal, /* (i/o) signal vector */
int16_t* ba, /* (i) B- and A-coefficients (2:nd order)
{b[0] b[1] b[2] -a[1] -a[2]} a[0]
is assumed to be 1.0 */
int16_t* y, /* (i/o) Filter state yhi[n-1] ylow[n-1]
yhi[n-2] ylow[n-2] */
int16_t *x, /* (i/o) Filter state x[n-1] x[n-2] */
size_t len); /* (i) Number of samples to filter */
int16_t* x, /* (i/o) Filter state x[n-1] x[n-2] */
size_t len); /* (i) Number of samples to filter */
#endif

View File

@ -40,216 +40,214 @@ typedef struct iLBC_decinst_t_ IlbcDecoderInstance;
*/
#define ILBC_SPEECH 1
#define ILBC_CNG 2
#define ILBC_CNG 2
#ifdef __cplusplus
extern "C" {
#endif
/****************************************************************************
* WebRtcIlbcfix_XxxAssign(...)
*
* These functions assigns the encoder/decoder instance to the specified
* memory location
*
* Input:
* - XXX_xxxinst : Pointer to created instance that should be
* assigned
* - ILBCXXX_inst_Addr : Pointer to the desired memory space
* - size : The size that this structure occupies (in Word16)
*
* Return value : 0 - Ok
* -1 - Error
*/
/****************************************************************************
* WebRtcIlbcfix_XxxAssign(...)
*
* These functions assigns the encoder/decoder instance to the specified
* memory location
*
* Input:
* - XXX_xxxinst : Pointer to created instance that should be
* assigned
* - ILBCXXX_inst_Addr : Pointer to the desired memory space
* - size : The size that this structure occupies (in Word16)
*
* Return value : 0 - Ok
* -1 - Error
*/
int16_t WebRtcIlbcfix_EncoderAssign(IlbcEncoderInstance **iLBC_encinst,
int16_t *ILBCENC_inst_Addr,
int16_t *size);
int16_t WebRtcIlbcfix_DecoderAssign(IlbcDecoderInstance **iLBC_decinst,
int16_t *ILBCDEC_inst_Addr,
int16_t *size);
int16_t WebRtcIlbcfix_EncoderAssign(IlbcEncoderInstance** iLBC_encinst,
int16_t* ILBCENC_inst_Addr,
int16_t* size);
int16_t WebRtcIlbcfix_DecoderAssign(IlbcDecoderInstance** iLBC_decinst,
int16_t* ILBCDEC_inst_Addr,
int16_t* size);
/****************************************************************************
* WebRtcIlbcfix_XxxAssign(...)
*
* These functions create a instance to the specified structure
*
* Input:
* - XXX_inst : Pointer to created instance that should be created
*
* Return value : 0 - Ok
* -1 - Error
*/
/****************************************************************************
* WebRtcIlbcfix_XxxAssign(...)
*
* These functions create a instance to the specified structure
*
* Input:
* - XXX_inst : Pointer to created instance that should be created
*
* Return value : 0 - Ok
* -1 - Error
*/
int16_t WebRtcIlbcfix_EncoderCreate(IlbcEncoderInstance** iLBC_encinst);
int16_t WebRtcIlbcfix_DecoderCreate(IlbcDecoderInstance** iLBC_decinst);
int16_t WebRtcIlbcfix_EncoderCreate(IlbcEncoderInstance **iLBC_encinst);
int16_t WebRtcIlbcfix_DecoderCreate(IlbcDecoderInstance **iLBC_decinst);
/****************************************************************************
* WebRtcIlbcfix_XxxFree(...)
*
* These functions frees the dynamic memory of a specified instance
*
* Input:
* - XXX_inst : Pointer to created instance that should be freed
*
* Return value : 0 - Ok
* -1 - Error
*/
/****************************************************************************
* WebRtcIlbcfix_XxxFree(...)
*
* These functions frees the dynamic memory of a specified instance
*
* Input:
* - XXX_inst : Pointer to created instance that should be freed
*
* Return value : 0 - Ok
* -1 - Error
*/
int16_t WebRtcIlbcfix_EncoderFree(IlbcEncoderInstance* iLBC_encinst);
int16_t WebRtcIlbcfix_DecoderFree(IlbcDecoderInstance* iLBC_decinst);
int16_t WebRtcIlbcfix_EncoderFree(IlbcEncoderInstance *iLBC_encinst);
int16_t WebRtcIlbcfix_DecoderFree(IlbcDecoderInstance *iLBC_decinst);
/****************************************************************************
* WebRtcIlbcfix_EncoderInit(...)
*
* This function initializes a iLBC instance
*
* Input:
* - iLBCenc_inst : iLBC instance, i.e. the user that should receive
* be initialized
* - frameLen : The frame length of the codec 20/30 (ms)
*
* Return value : 0 - Ok
* -1 - Error
*/
int16_t WebRtcIlbcfix_EncoderInit(IlbcEncoderInstance* iLBCenc_inst,
int16_t frameLen);
/****************************************************************************
* WebRtcIlbcfix_EncoderInit(...)
*
* This function initializes a iLBC instance
*
* Input:
* - iLBCenc_inst : iLBC instance, i.e. the user that should receive
* be initialized
* - frameLen : The frame length of the codec 20/30 (ms)
*
* Return value : 0 - Ok
* -1 - Error
*/
/****************************************************************************
* WebRtcIlbcfix_Encode(...)
*
* This function encodes one iLBC frame. Input speech length has be a
* multiple of the frame length.
*
* Input:
* - iLBCenc_inst : iLBC instance, i.e. the user that should encode
* a package
* - speechIn : Input speech vector
* - len : Samples in speechIn (160, 240, 320 or 480)
*
* Output:
* - encoded : The encoded data vector
*
* Return value : >0 - Length (in bytes) of coded data
* -1 - Error
*/
int16_t WebRtcIlbcfix_EncoderInit(IlbcEncoderInstance *iLBCenc_inst,
int16_t frameLen);
int WebRtcIlbcfix_Encode(IlbcEncoderInstance* iLBCenc_inst,
const int16_t* speechIn,
size_t len,
uint8_t* encoded);
/****************************************************************************
* WebRtcIlbcfix_Encode(...)
*
* This function encodes one iLBC frame. Input speech length has be a
* multiple of the frame length.
*
* Input:
* - iLBCenc_inst : iLBC instance, i.e. the user that should encode
* a package
* - speechIn : Input speech vector
* - len : Samples in speechIn (160, 240, 320 or 480)
*
* Output:
* - encoded : The encoded data vector
*
* Return value : >0 - Length (in bytes) of coded data
* -1 - Error
*/
/****************************************************************************
* WebRtcIlbcfix_DecoderInit(...)
*
* This function initializes a iLBC instance with either 20 or 30 ms frames
* Alternatively the WebRtcIlbcfix_DecoderInit_XXms can be used. Then it's
* not needed to specify the frame length with a variable.
*
* Input:
* - IlbcDecoderInstance : iLBC decoder instance
* - frameLen : The frame length of the codec 20/30 (ms)
*
* Return value : 0 - Ok
* -1 - Error
*/
int WebRtcIlbcfix_Encode(IlbcEncoderInstance *iLBCenc_inst,
const int16_t *speechIn,
size_t len,
uint8_t* encoded);
int16_t WebRtcIlbcfix_DecoderInit(IlbcDecoderInstance* iLBCdec_inst,
int16_t frameLen);
void WebRtcIlbcfix_DecoderInit20Ms(IlbcDecoderInstance* iLBCdec_inst);
void WebRtcIlbcfix_Decoderinit30Ms(IlbcDecoderInstance* iLBCdec_inst);
/****************************************************************************
* WebRtcIlbcfix_DecoderInit(...)
*
* This function initializes a iLBC instance with either 20 or 30 ms frames
* Alternatively the WebRtcIlbcfix_DecoderInit_XXms can be used. Then it's
* not needed to specify the frame length with a variable.
*
* Input:
* - IlbcDecoderInstance : iLBC decoder instance
* - frameLen : The frame length of the codec 20/30 (ms)
*
* Return value : 0 - Ok
* -1 - Error
*/
/****************************************************************************
* WebRtcIlbcfix_Decode(...)
*
* This function decodes a packet with iLBC frame(s). Output speech length
* will be a multiple of 160 or 240 samples ((160 or 240)*frames/packet).
*
* Input:
* - iLBCdec_inst : iLBC instance, i.e. the user that should decode
* a packet
* - encoded : Encoded iLBC frame(s)
* - len : Bytes in encoded vector
*
* Output:
* - decoded : The decoded vector
* - speechType : 1 normal, 2 CNG
*
* Return value : >0 - Samples in decoded vector
* -1 - Error
*/
int16_t WebRtcIlbcfix_DecoderInit(IlbcDecoderInstance *iLBCdec_inst,
int16_t frameLen);
void WebRtcIlbcfix_DecoderInit20Ms(IlbcDecoderInstance* iLBCdec_inst);
void WebRtcIlbcfix_Decoderinit30Ms(IlbcDecoderInstance* iLBCdec_inst);
int WebRtcIlbcfix_Decode(IlbcDecoderInstance* iLBCdec_inst,
const uint8_t* encoded,
size_t len,
int16_t* decoded,
int16_t* speechType);
int WebRtcIlbcfix_Decode20Ms(IlbcDecoderInstance* iLBCdec_inst,
const uint8_t* encoded,
size_t len,
int16_t* decoded,
int16_t* speechType);
int WebRtcIlbcfix_Decode30Ms(IlbcDecoderInstance* iLBCdec_inst,
const uint8_t* encoded,
size_t len,
int16_t* decoded,
int16_t* speechType);
/****************************************************************************
* WebRtcIlbcfix_Decode(...)
*
* This function decodes a packet with iLBC frame(s). Output speech length
* will be a multiple of 160 or 240 samples ((160 or 240)*frames/packet).
*
* Input:
* - iLBCdec_inst : iLBC instance, i.e. the user that should decode
* a packet
* - encoded : Encoded iLBC frame(s)
* - len : Bytes in encoded vector
*
* Output:
* - decoded : The decoded vector
* - speechType : 1 normal, 2 CNG
*
* Return value : >0 - Samples in decoded vector
* -1 - Error
*/
/****************************************************************************
* WebRtcIlbcfix_DecodePlc(...)
*
* This function conducts PLC for iLBC frame(s). Output speech length
* will be a multiple of 160 or 240 samples.
*
* Input:
* - iLBCdec_inst : iLBC instance, i.e. the user that should perform
* a PLC
* - noOfLostFrames : Number of PLC frames to produce
*
* Output:
* - decoded : The "decoded" vector
*
* Return value : Samples in decoded PLC vector
*/
int WebRtcIlbcfix_Decode(IlbcDecoderInstance* iLBCdec_inst,
const uint8_t* encoded,
size_t len,
int16_t* decoded,
int16_t* speechType);
int WebRtcIlbcfix_Decode20Ms(IlbcDecoderInstance* iLBCdec_inst,
const uint8_t* encoded,
size_t len,
size_t WebRtcIlbcfix_DecodePlc(IlbcDecoderInstance* iLBCdec_inst,
int16_t* decoded,
int16_t* speechType);
int WebRtcIlbcfix_Decode30Ms(IlbcDecoderInstance* iLBCdec_inst,
const uint8_t* encoded,
size_t len,
int16_t* decoded,
int16_t* speechType);
size_t noOfLostFrames);
/****************************************************************************
* WebRtcIlbcfix_DecodePlc(...)
*
* This function conducts PLC for iLBC frame(s). Output speech length
* will be a multiple of 160 or 240 samples.
*
* Input:
* - iLBCdec_inst : iLBC instance, i.e. the user that should perform
* a PLC
* - noOfLostFrames : Number of PLC frames to produce
*
* Output:
* - decoded : The "decoded" vector
*
* Return value : Samples in decoded PLC vector
*/
/****************************************************************************
* WebRtcIlbcfix_NetEqPlc(...)
*
* This function updates the decoder when a packet loss has occured, but it
* does not produce any PLC data. Function can be used if another PLC method
* is used (i.e NetEq).
*
* Input:
* - iLBCdec_inst : iLBC instance that should be updated
* - noOfLostFrames : Number of lost frames
*
* Output:
* - decoded : The "decoded" vector (nothing in this case)
*
* Return value : Samples in decoded PLC vector
*/
size_t WebRtcIlbcfix_DecodePlc(IlbcDecoderInstance *iLBCdec_inst,
int16_t *decoded,
size_t noOfLostFrames);
size_t WebRtcIlbcfix_NetEqPlc(IlbcDecoderInstance* iLBCdec_inst,
int16_t* decoded,
size_t noOfLostFrames);
/****************************************************************************
* WebRtcIlbcfix_NetEqPlc(...)
*
* This function updates the decoder when a packet loss has occured, but it
* does not produce any PLC data. Function can be used if another PLC method
* is used (i.e NetEq).
*
* Input:
* - iLBCdec_inst : iLBC instance that should be updated
* - noOfLostFrames : Number of lost frames
*
* Output:
* - decoded : The "decoded" vector (nothing in this case)
*
* Return value : Samples in decoded PLC vector
*/
/****************************************************************************
* WebRtcIlbcfix_version(...)
*
* This function returns the version number of iLBC
*
* Output:
* - version : Version number of iLBC (maximum 20 char)
*/
size_t WebRtcIlbcfix_NetEqPlc(IlbcDecoderInstance *iLBCdec_inst,
int16_t *decoded,
size_t noOfLostFrames);
/****************************************************************************
* WebRtcIlbcfix_version(...)
*
* This function returns the version number of iLBC
*
* Output:
* - version : Version number of iLBC (maximum 20 char)
*/
void WebRtcIlbcfix_version(char *version);
void WebRtcIlbcfix_version(char* version);
#ifdef __cplusplus
}

View File

@ -71,7 +71,7 @@ class SplitIlbcTest : public ::testing::TestWithParam<std::pair<int, int> > {
TEST_P(SplitIlbcTest, NumFrames) {
AudioDecoderIlbcImpl decoder;
const size_t frame_length_samples = frame_length_ms_ * 8;
const auto generate_payload = [] (size_t payload_length_bytes) {
const auto generate_payload = [](size_t payload_length_bytes) {
rtc::Buffer payload(payload_length_bytes);
// Fill payload with increasing integers {0, 1, 2, ...}.
for (size_t i = 0; i < payload.size(); ++i) {
@ -104,7 +104,8 @@ TEST_P(SplitIlbcTest, NumFrames) {
// The maximum is defined by the largest payload length that can be uniquely
// resolved to a frame size of either 38 bytes (20 ms) or 50 bytes (30 ms).
INSTANTIATE_TEST_CASE_P(
IlbcTest, SplitIlbcTest,
IlbcTest,
SplitIlbcTest,
::testing::Values(std::pair<int, int>(1, 20), // 1 frame, 20 ms.
std::pair<int, int>(2, 20), // 2 frames, 20 ms.
std::pair<int, int>(3, 20), // And so on.

View File

@ -21,8 +21,7 @@
#include "modules/audio_coding/codecs/ilbc/defines.h"
void WebRtcIlbcfix_IndexConvDec(
int16_t *index /* (i/o) Codebook indexes */
void WebRtcIlbcfix_IndexConvDec(int16_t* index /* (i/o) Codebook indexes */
);
#endif

View File

@ -25,8 +25,7 @@
* Convert the codebook indexes to make the search easier
*---------------------------------------------------------------*/
void WebRtcIlbcfix_IndexConvEnc(
int16_t *index /* (i/o) Codebook indexes */
void WebRtcIlbcfix_IndexConvEnc(int16_t* index /* (i/o) Codebook indexes */
);
#endif

View File

@ -25,11 +25,12 @@
* Initiation of decoder instance.
*---------------------------------------------------------------*/
int WebRtcIlbcfix_InitDecode( /* (o) Number of decoded samples */
IlbcDecoder *iLBCdec_inst, /* (i/o) Decoder instance */
int16_t mode, /* (i) frame size mode */
int use_enhancer /* (i) 1 to use enhancer
0 to run without enhancer */
);
int WebRtcIlbcfix_InitDecode(/* (o) Number of decoded samples */
IlbcDecoder*
iLBCdec_inst, /* (i/o) Decoder instance */
int16_t mode, /* (i) frame size mode */
int use_enhancer /* (i) 1 to use enhancer
0 to run without enhancer */
);
#endif

View File

@ -25,9 +25,10 @@
* Initiation of encoder instance.
*---------------------------------------------------------------*/
int WebRtcIlbcfix_InitEncode( /* (o) Number of bytes encoded */
IlbcEncoder *iLBCenc_inst, /* (i/o) Encoder instance */
int16_t mode /* (i) frame size mode */
);
int WebRtcIlbcfix_InitEncode(/* (o) Number of bytes encoded */
IlbcEncoder*
iLBCenc_inst, /* (i/o) Encoder instance */
int16_t mode /* (i) frame size mode */
);
#endif

View File

@ -26,10 +26,10 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_Interpolate(
int16_t *out, /* (o) output vector */
int16_t *in1, /* (i) first input vector */
int16_t *in2, /* (i) second input vector */
int16_t coef, /* (i) weight coefficient in Q14 */
int16_t* out, /* (o) output vector */
int16_t* in1, /* (i) first input vector */
int16_t* in2, /* (i) second input vector */
int16_t coef, /* (i) weight coefficient in Q14 */
int16_t length); /* (i) number of sample is vectors */
#endif

View File

@ -26,9 +26,9 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_InterpolateSamples(
int16_t *interpSamples, /* (o) The interpolated samples */
int16_t *CBmem, /* (i) The CB memory */
size_t lMem /* (i) Length of the CB memory */
);
int16_t* interpSamples, /* (o) The interpolated samples */
int16_t* CBmem, /* (i) The CB memory */
size_t lMem /* (i) Length of the CB memory */
);
#endif

View File

@ -26,14 +26,14 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_LpcEncode(
int16_t *syntdenum, /* (i/o) synthesis filter coefficients
before/after encoding */
int16_t *weightdenum, /* (i/o) weighting denumerator coefficients
int16_t* syntdenum, /* (i/o) synthesis filter coefficients
before/after encoding */
int16_t *lsf_index, /* (o) lsf quantization index */
int16_t *data, /* (i) Speech to do LPC analysis on */
IlbcEncoder *iLBCenc_inst
int16_t* weightdenum, /* (i/o) weighting denumerator coefficients
before/after encoding */
int16_t* lsf_index, /* (o) lsf quantization index */
int16_t* data, /* (i) Speech to do LPC analysis on */
IlbcEncoder* iLBCenc_inst
/* (i/o) the encoder state structure */
);
);
#endif

View File

@ -25,9 +25,8 @@
* check for stability of lsf coefficients
*---------------------------------------------------------------*/
int WebRtcIlbcfix_LsfCheck(
int16_t *lsf, /* LSF parameters */
int dim, /* dimension of LSF */
int NoAn); /* No of analysis per frame */
int WebRtcIlbcfix_LsfCheck(int16_t* lsf, /* LSF parameters */
int dim, /* dimension of LSF */
int NoAn); /* No of analysis per frame */
#endif

View File

@ -26,12 +26,12 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_LspInterpolate2PolyDec(
int16_t *a, /* (o) lpc coefficients Q12 */
int16_t *lsf1, /* (i) first set of lsf coefficients Q13 */
int16_t *lsf2, /* (i) second set of lsf coefficients Q13 */
int16_t* a, /* (o) lpc coefficients Q12 */
int16_t* lsf1, /* (i) first set of lsf coefficients Q13 */
int16_t* lsf2, /* (i) second set of lsf coefficients Q13 */
int16_t coef, /* (i) weighting coefficient to use between
lsf1 and lsf2 Q14 */
int16_t length /* (i) length of coefficient vectors */
);
int16_t length /* (i) length of coefficient vectors */
);
#endif

View File

@ -27,12 +27,12 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_LsfInterpolate2PloyEnc(
int16_t *a, /* (o) lpc coefficients Q12 */
int16_t *lsf1, /* (i) first set of lsf coefficients Q13 */
int16_t *lsf2, /* (i) second set of lsf coefficients Q13 */
int16_t coef, /* (i) weighting coefficient to use between
lsf1 and lsf2 Q14 */
int16_t* a, /* (o) lpc coefficients Q12 */
int16_t* lsf1, /* (i) first set of lsf coefficients Q13 */
int16_t* lsf2, /* (i) second set of lsf coefficients Q13 */
int16_t coef, /* (i) weighting coefficient to use between
lsf1 and lsf2 Q14 */
int16_t length /* (i) length of coefficient vectors */
);
);
#endif

View File

@ -26,9 +26,9 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_Lsf2Lsp(
int16_t *lsf, /* (i) lsf in Q13 values between 0 and pi */
int16_t *lsp, /* (o) lsp in Q15 values between -1 and 1 */
int16_t* lsf, /* (i) lsf in Q13 values between 0 and pi */
int16_t* lsp, /* (o) lsp in Q15 values between -1 and 1 */
int16_t m /* (i) number of coefficients */
);
);
#endif

View File

@ -26,8 +26,8 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_Lsf2Poly(
int16_t *a, /* (o) predictor coefficients (order = 10) in Q12 */
int16_t *lsf /* (i) line spectral frequencies in Q13 */
);
int16_t* a, /* (o) predictor coefficients (order = 10) in Q12 */
int16_t* lsf /* (i) line spectral frequencies in Q13 */
);
#endif

View File

@ -26,10 +26,10 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_Lsp2Lsf(
int16_t *lsp, /* (i) lsp vector -1...+1 in Q15 */
int16_t *lsf, /* (o) Lsf vector 0...Pi in Q13
int16_t* lsp, /* (i) lsp vector -1...+1 in Q15 */
int16_t* lsf, /* (o) Lsf vector 0...Pi in Q13
(ordered, so that lsf[i]<lsf[i+1]) */
int16_t m /* (i) Number of coefficients */
);
int16_t m /* (i) Number of coefficients */
);
#endif

View File

@ -25,12 +25,11 @@
* compute cross correlation between sequences
*---------------------------------------------------------------*/
void WebRtcIlbcfix_MyCorr(
int32_t* corr, /* (o) correlation of seq1 and seq2 */
const int16_t* seq1, /* (i) first sequence */
size_t dim1, /* (i) dimension first seq1 */
const int16_t* seq2, /* (i) second sequence */
size_t dim2 /* (i) dimension seq2 */
void WebRtcIlbcfix_MyCorr(int32_t* corr, /* (o) correlation of seq1 and seq2 */
const int16_t* seq1, /* (i) first sequence */
size_t dim1, /* (i) dimension first seq1 */
const int16_t* seq2, /* (i) second sequence */
size_t dim2 /* (i) dimension seq2 */
);
#endif

View File

@ -27,10 +27,10 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_NearestNeighbor(
size_t* index, /* (o) index of array element closest to value */
size_t* index, /* (o) index of array element closest to value */
const size_t* array, /* (i) data array (Q2) */
size_t value, /* (i) value (Q2) */
size_t arlength /* (i) dimension of data array (==ENH_NBLOCKS_TOT) */
);
size_t value, /* (i) value (Q2) */
size_t arlength /* (i) dimension of data array (==ENH_NBLOCKS_TOT) */
);
#endif

View File

@ -25,10 +25,10 @@
* unpacking of bits from bitstream, i.e., vector of bytes
*---------------------------------------------------------------*/
void WebRtcIlbcfix_PackBits(
uint16_t *bitstream, /* (o) The packetized bitstream */
iLBC_bits *enc_bits, /* (i) Encoded bits */
int16_t mode /* (i) Codec mode (20 or 30) */
);
void WebRtcIlbcfix_PackBits(
uint16_t* bitstream, /* (o) The packetized bitstream */
iLBC_bits* enc_bits, /* (i) Encoded bits */
int16_t mode /* (i) Codec mode (20 or 30) */
);
#endif

View File

@ -25,9 +25,8 @@
* conversion from lpc coefficients to lsf coefficients
*---------------------------------------------------------------*/
void WebRtcIlbcfix_Poly2Lsf(
int16_t *lsf, /* (o) lsf coefficients (Q13) */
int16_t *a /* (i) A coefficients (Q12) */
void WebRtcIlbcfix_Poly2Lsf(int16_t* lsf, /* (o) lsf coefficients (Q13) */
int16_t* a /* (i) A coefficients (Q12) */
);
#endif

View File

@ -27,10 +27,10 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_Poly2Lsp(
int16_t *a, /* (o) A coefficients in Q12 */
int16_t *lsp, /* (i) LSP coefficients in Q15 */
int16_t *old_lsp /* (i) old LSP coefficients that are used if the new
int16_t* a, /* (o) A coefficients in Q12 */
int16_t* lsp, /* (i) LSP coefficients in Q15 */
int16_t* old_lsp /* (i) old LSP coefficients that are used if the new
coefficients turn out to be unstable */
);
);
#endif

View File

@ -30,14 +30,14 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_Refiner(
size_t *updStartPos, /* (o) updated start point (Q-2) */
int16_t *idata, /* (i) original data buffer */
size_t idatal, /* (i) dimension of idata */
size_t* updStartPos, /* (o) updated start point (Q-2) */
int16_t* idata, /* (i) original data buffer */
size_t idatal, /* (i) dimension of idata */
size_t centerStartPos, /* (i) beginning center segment */
size_t estSegPos, /* (i) estimated beginning other segment (Q-2) */
int16_t *surround, /* (i/o) The contribution from this sequence
summed with earlier contributions */
int16_t gain /* (i) Gain to use for this sequence */
);
size_t estSegPos, /* (i) estimated beginning other segment (Q-2) */
int16_t* surround, /* (i/o) The contribution from this sequence
summed with earlier contributions */
int16_t gain /* (i) Gain to use for this sequence */
);
#endif

View File

@ -26,21 +26,21 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_SimpleInterpolateLsf(
int16_t *syntdenum, /* (o) the synthesis filter denominator
resulting from the quantized
interpolated lsf Q12 */
int16_t *weightdenum, /* (o) the weighting filter denominator
int16_t* syntdenum, /* (o) the synthesis filter denominator
resulting from the quantized
interpolated lsf Q12 */
int16_t* weightdenum, /* (o) the weighting filter denominator
resulting from the unquantized
interpolated lsf Q12 */
int16_t *lsf, /* (i) the unquantized lsf coefficients Q13 */
int16_t *lsfdeq, /* (i) the dequantized lsf coefficients Q13 */
int16_t *lsfold, /* (i) the unquantized lsf coefficients of
the previous signal frame Q13 */
int16_t *lsfdeqold, /* (i) the dequantized lsf coefficients of the
previous signal frame Q13 */
int16_t length, /* (i) should equate FILTERORDER */
IlbcEncoder *iLBCenc_inst
int16_t* lsf, /* (i) the unquantized lsf coefficients Q13 */
int16_t* lsfdeq, /* (i) the dequantized lsf coefficients Q13 */
int16_t* lsfold, /* (i) the unquantized lsf coefficients of
the previous signal frame Q13 */
int16_t* lsfdeqold, /* (i) the dequantized lsf coefficients of the
previous signal frame Q13 */
int16_t length, /* (i) should equate FILTERORDER */
IlbcEncoder* iLBCenc_inst
/* (i/o) the encoder state structure */
);
);
#endif

View File

@ -26,10 +26,10 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_SimpleLpcAnalysis(
int16_t *lsf, /* (o) lsf coefficients */
int16_t *data, /* (i) new block of speech */
IlbcEncoder *iLBCenc_inst
int16_t* lsf, /* (o) lsf coefficients */
int16_t* data, /* (i) new block of speech */
IlbcEncoder* iLBCenc_inst
/* (i/o) the encoder state structure */
);
);
#endif

View File

@ -26,9 +26,9 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_SimpleLsfDeQ(
int16_t *lsfdeq, /* (o) dequantized lsf coefficients */
int16_t *index, /* (i) quantization index */
int16_t lpc_n /* (i) number of LPCs */
);
int16_t* lsfdeq, /* (o) dequantized lsf coefficients */
int16_t* index, /* (i) quantization index */
int16_t lpc_n /* (i) number of LPCs */
);
#endif

View File

@ -26,12 +26,12 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_SimpleLsfQ(
int16_t *lsfdeq, /* (o) dequantized lsf coefficients
int16_t* lsfdeq, /* (o) dequantized lsf coefficients
(dimension FILTERORDER) Q13 */
int16_t *index, /* (o) quantization index */
int16_t *lsf, /* (i) the lsf coefficient vector to be
quantized (dimension FILTERORDER) Q13 */
int16_t lpc_n /* (i) number of lsf sets to quantize */
);
int16_t* index, /* (o) quantization index */
int16_t* lsf, /* (i) the lsf coefficient vector to be
quantized (dimension FILTERORDER) Q13 */
int16_t lpc_n /* (i) number of lsf sets to quantize */
);
#endif

View File

@ -25,12 +25,11 @@
* find the smoothed output data
*---------------------------------------------------------------*/
void WebRtcIlbcfix_Smooth(
int16_t *odata, /* (o) smoothed output */
int16_t *current, /* (i) the un enhanced residual for
this block */
int16_t *surround /* (i) The approximation from the
surrounding sequences */
void WebRtcIlbcfix_Smooth(int16_t* odata, /* (o) smoothed output */
int16_t* current, /* (i) the un enhanced residual for
this block */
int16_t* surround /* (i) The approximation from the
surrounding sequences */
);
#endif

View File

@ -25,11 +25,9 @@
* help function to WebRtcIlbcfix_Smooth()
*---------------------------------------------------------------*/
int32_t WebRtcIlbcfix_Smooth_odata(
int16_t *odata,
int16_t *psseq,
int16_t *surround,
int16_t C);
int32_t WebRtcIlbcfix_Smooth_odata(int16_t* odata,
int16_t* psseq,
int16_t* surround,
int16_t C);
#endif

View File

@ -26,11 +26,11 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_SortSq(
int16_t *xq, /* (o) the quantized value */
int16_t *index, /* (o) the quantization index */
int16_t x, /* (i) the value to quantize */
const int16_t *cb, /* (i) the quantization codebook */
int16_t cb_size /* (i) the size of the quantization codebook */
);
int16_t* xq, /* (o) the quantized value */
int16_t* index, /* (o) the quantization index */
int16_t x, /* (i) the value to quantize */
const int16_t* cb, /* (i) the quantization codebook */
int16_t cb_size /* (i) the size of the quantization codebook */
);
#endif

View File

@ -26,13 +26,13 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_SplitVq(
int16_t *qX, /* (o) the quantized vector in Q13 */
int16_t *index, /* (o) a vector of indexes for all vector
int16_t* qX, /* (o) the quantized vector in Q13 */
int16_t* index, /* (o) a vector of indexes for all vector
codebooks in the split */
int16_t *X, /* (i) the vector to quantize */
int16_t *CB, /* (i) the quantizer codebook in Q13 */
int16_t *dim, /* (i) the dimension of X and qX */
int16_t *cbsize /* (i) the number of vectors in the codebook */
);
int16_t* X, /* (i) the vector to quantize */
int16_t* CB, /* (i) the quantizer codebook in Q13 */
int16_t* dim, /* (i) the dimension of X and qX */
int16_t* cbsize /* (i) the number of vectors in the codebook */
);
#endif

View File

@ -26,10 +26,10 @@
void WebRtcIlbcfix_StateConstruct(
size_t idxForMax, /* (i) 6-bit index for the quantization of
max amplitude */
int16_t *idxVec, /* (i) vector of quantization indexes */
int16_t *syntDenum, /* (i) synthesis filter denumerator */
int16_t *Out_fix, /* (o) the decoded state vector */
size_t len /* (i) length of a state vector */
);
int16_t* idxVec, /* (i) vector of quantization indexes */
int16_t* syntDenum, /* (i) synthesis filter denumerator */
int16_t* Out_fix, /* (o) the decoded state vector */
size_t len /* (i) length of a state vector */
);
#endif

View File

@ -26,13 +26,13 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_StateSearch(
IlbcEncoder *iLBCenc_inst,
IlbcEncoder* iLBCenc_inst,
/* (i) Encoder instance */
iLBC_bits *iLBC_encbits,/* (i/o) Encoded bits (output idxForMax
and idxVec, input state_first) */
int16_t *residual, /* (i) target residual vector */
int16_t *syntDenum, /* (i) lpc synthesis filter */
int16_t *weightDenum /* (i) weighting filter denuminator */
);
iLBC_bits* iLBC_encbits, /* (i/o) Encoded bits (output idxForMax
and idxVec, input state_first) */
int16_t* residual, /* (i) target residual vector */
int16_t* syntDenum, /* (i) lpc synthesis filter */
int16_t* weightDenum /* (i) weighting filter denuminator */
);
#endif

View File

@ -26,9 +26,9 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_SwapBytes(
const uint16_t* input, /* (i) the sequence to swap */
size_t wordLength, /* (i) number or uint16_t to swap */
uint16_t* output /* (o) the swapped sequence */
);
const uint16_t* input, /* (i) the sequence to swap */
size_t wordLength, /* (i) number or uint16_t to swap */
uint16_t* output /* (o) the swapped sequence */
);
#endif

View File

@ -25,10 +25,13 @@
* unpacking of bits from bitstream, i.e., vector of bytes
*---------------------------------------------------------------*/
int16_t WebRtcIlbcfix_UnpackBits( /* (o) "Empty" frame indicator */
const uint16_t *bitstream, /* (i) The packatized bitstream */
iLBC_bits *enc_bits, /* (o) Paramerers from bitstream */
int16_t mode /* (i) Codec mode (20 or 30) */
);
int16_t
WebRtcIlbcfix_UnpackBits(/* (o) "Empty" frame indicator */
const uint16_t*
bitstream, /* (i) The packatized bitstream */
iLBC_bits*
enc_bits, /* (o) Paramerers from bitstream */
int16_t mode /* (i) Codec mode (20 or 30) */
);
#endif

View File

@ -26,11 +26,11 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_Vq3(
int16_t *Xq, /* (o) the quantized vector (Q13) */
int16_t *index, /* (o) the quantization index */
int16_t *CB, /* (i) the vector quantization codebook (Q13) */
int16_t *X, /* (i) the vector to quantize (Q13) */
int16_t n_cb /* (i) the number of vectors in the codebook */
);
int16_t* Xq, /* (o) the quantized vector (Q13) */
int16_t* index, /* (o) the quantization index */
int16_t* CB, /* (i) the vector quantization codebook (Q13) */
int16_t* X, /* (i) the vector to quantize (Q13) */
int16_t n_cb /* (i) the number of vectors in the codebook */
);
#endif

Some files were not shown because too many files have changed in this diff Show More