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}
diff --git a/modules/audio_coding/acm2/acm_codec_database.cc b/modules/audio_coding/acm2/acm_codec_database.cc
index 4553b52..a322c95 100644
--- a/modules/audio_coding/acm2/acm_codec_database.cc
+++ b/modules/audio_coding/acm2/acm_codec_database.cc
@@ -42,7 +42,7 @@
(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 @@
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 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 @@
// 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 @@
{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 @@
#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 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 @@
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 @@
// 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,
diff --git a/modules/audio_coding/acm2/acm_codec_database.h b/modules/audio_coding/acm2/acm_codec_database.h
index 81cd4be..8b7c68a 100644
--- a/modules/audio_coding/acm2/acm_codec_database.h
+++ b/modules/audio_coding/acm2/acm_codec_database.h
@@ -31,7 +31,7 @@
// 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
diff --git a/modules/audio_coding/acm2/acm_receive_test.cc b/modules/audio_coding/acm2/acm_receive_test.cc
index 473b651..6afc161 100644
--- a/modules/audio_coding/acm2/acm_receive_test.cc
+++ b/modules/audio_coding/acm2/acm_receive_test.cc
@@ -156,8 +156,7 @@
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 @@
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
diff --git a/modules/audio_coding/acm2/acm_receive_test.h b/modules/audio_coding/acm2/acm_receive_test.h
index c7e7da6..83ffcb3 100644
--- a/modules/audio_coding/acm2/acm_receive_test.h
+++ b/modules/audio_coding/acm2/acm_receive_test.h
@@ -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>
diff --git a/modules/audio_coding/acm2/acm_receiver.cc b/modules/audio_coding/acm2/acm_receiver.cc
index b61099c..0a88e70 100644
--- a/modules/audio_coding/acm2/acm_receiver.cc
+++ b/modules/audio_coding/acm2/acm_receiver.cc
@@ -231,8 +231,8 @@
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 @@
// 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(
diff --git a/modules/audio_coding/acm2/acm_receiver_unittest.cc b/modules/audio_coding/acm2/acm_receiver_unittest.cc
index 7877821..350183b 100644
--- a/modules/audio_coding/acm2/acm_receiver_unittest.cc
+++ b/modules/audio_coding/acm2/acm_receiver_unittest.cc
@@ -30,12 +30,11 @@
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 @@
}
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 @@
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 @@
// 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;
diff --git a/modules/audio_coding/acm2/acm_resampler.cc b/modules/audio_coding/acm2/acm_resampler.cc
index b97ced2..c0b2064 100644
--- a/modules/audio_coding/acm2/acm_resampler.cc
+++ b/modules/audio_coding/acm2/acm_resampler.cc
@@ -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,
diff --git a/modules/audio_coding/acm2/acm_send_test.cc b/modules/audio_coding/acm2/acm_send_test.cc
index 09a6c80..b1a3e98 100644
--- a/modules/audio_coding/acm2/acm_send_test.cc
+++ b/modules/audio_coding/acm2/acm_send_test.cc
@@ -95,10 +95,9 @@
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 @@
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 @@
++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()));
diff --git a/modules/audio_coding/acm2/audio_coding_module.cc b/modules/audio_coding/acm2/audio_coding_module.cc
index 2d8827c..7f652a2 100644
--- a/modules/audio_coding/acm2/audio_coding_module.cc
+++ b/modules/audio_coding/acm2/audio_coding_module.cc
@@ -323,9 +323,10 @@
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 @@
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 @@
// 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 @@
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 @@
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 @@
}
// 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 @@
}
void AudioCodingModuleImpl::GetDecodingCallStatistics(
- AudioDecodingCallStats* call_stats) const {
+ AudioDecodingCallStats* call_stats) const {
receiver_.GetDecodingCallStatistics(call_stats);
}
diff --git a/modules/audio_coding/acm2/audio_coding_module_unittest.cc b/modules/audio_coding/acm2/audio_coding_module_unittest.cc
index e16d54a..7592300 100644
--- a/modules/audio_coding/acm2/audio_coding_module_unittest.cc
+++ b/modules/audio_coding/acm2/audio_coding_module_unittest.cc
@@ -425,19 +425,12 @@
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 @@
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 @@
// 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 @@
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 @@
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 @@
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, 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 @@
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 @@
.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 @@
// 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;
diff --git a/modules/audio_coding/acm2/call_statistics_unittest.cc b/modules/audio_coding/acm2/call_statistics_unittest.cc
index 77c3863..528708f 100644
--- a/modules/audio_coding/acm2/call_statistics_unittest.cc
+++ b/modules/audio_coding/acm2/call_statistics_unittest.cc
@@ -52,6 +52,3 @@
} // namespace acm2
} // namespace webrtc
-
-
-
diff --git a/modules/audio_coding/acm2/rent_a_codec_unittest.cc b/modules/audio_coding/acm2/rent_a_codec_unittest.cc
index ca469e7..fd3329c 100644
--- a/modules/audio_coding/acm2/rent_a_codec_unittest.cc
+++ b/modules/audio_coding/acm2/rent_a_codec_unittest.cc
@@ -54,8 +54,7 @@
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 @@
{
::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"));
diff --git a/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl_unittest.cc b/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl_unittest.cc
index 2872219..5948ac3 100644
--- a/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl_unittest.cc
+++ b/modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl_unittest.cc
@@ -102,8 +102,7 @@
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;
}
diff --git a/modules/audio_coding/audio_network_adaptor/bitrate_controller_unittest.cc b/modules/audio_coding/audio_network_adaptor/bitrate_controller_unittest.cc
index 98abede..f077357 100644
--- a/modules/audio_coding/audio_network_adaptor/bitrate_controller_unittest.cc
+++ b/modules/audio_coding/audio_network_adaptor/bitrate_controller_unittest.cc
@@ -80,9 +80,9 @@
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 @@
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 @@
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 @@
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 @@
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 @@
// 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 @@
// 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 @@
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);
diff --git a/modules/audio_coding/audio_network_adaptor/controller_manager.cc b/modules/audio_coding/audio_network_adaptor/controller_manager.cc
index 80255ea..32f9fcb 100644
--- a/modules/audio_coding/audio_network_adaptor/controller_manager.cc
+++ b/modules/audio_coding/audio_network_adaptor/controller_manager.cc
@@ -296,9 +296,9 @@
}
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());
diff --git a/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.cc b/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.cc
index 7409721..7ab72c9 100644
--- a/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.cc
+++ b/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.cc
@@ -33,7 +33,7 @@
private:
absl::optional<float> last_sample_;
};
-}
+} // namespace
FecControllerPlrBased::Config::Config(
bool initial_fec_enabled,
diff --git a/modules/audio_coding/audio_network_adaptor/fec_controller_rplr_based_unittest.cc b/modules/audio_coding/audio_network_adaptor/fec_controller_rplr_based_unittest.cc
index 538a3e0..8e8704e 100644
--- a/modules/audio_coding/audio_network_adaptor/fec_controller_rplr_based_unittest.cc
+++ b/modules/audio_coding/audio_network_adaptor/fec_controller_rplr_based_unittest.cc
@@ -209,11 +209,11 @@
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 @@
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);
}
diff --git a/modules/audio_coding/audio_network_adaptor/frame_length_controller.cc b/modules/audio_coding/audio_network_adaptor/frame_length_controller.cc
index 6c3cae0..40e97cb 100644
--- a/modules/audio_coding/audio_network_adaptor/frame_length_controller.cc
+++ b/modules/audio_coding/audio_network_adaptor/frame_length_controller.cc
@@ -25,7 +25,7 @@
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,
diff --git a/modules/audio_coding/codecs/cng/audio_encoder_cng.cc b/modules/audio_coding/codecs/cng/audio_encoder_cng.cc
index 91c07a9..4cda340 100644
--- a/modules/audio_coding/codecs/cng/audio_encoder_cng.cc
+++ b/modules/audio_coding/codecs/cng/audio_encoder_cng.cc
@@ -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 @@
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 @@
// 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 @@
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) {
diff --git a/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc b/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc
index c582b44..a76dcbd 100644
--- a/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc
+++ b/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc
@@ -30,7 +30,7 @@
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 @@
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 @@
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 @@
// 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.
diff --git a/modules/audio_coding/codecs/cng/cng_unittest.cc b/modules/audio_coding/codecs/cng/cng_unittest.cc
index 54e5189..81688b1 100644
--- a/modules/audio_coding/codecs/cng/cng_unittest.cc
+++ b/modules/audio_coding/codecs/cng/cng_unittest.cc
@@ -29,10 +29,7 @@
kCNGNumParamsTooHigh = WEBRTC_CNG_MAX_LPC_ORDER + 1
};
-enum {
- kNoSid,
- kForceSid
-};
+enum { kNoSid, kForceSid };
class CngTest : public ::testing::Test {
protected:
@@ -46,11 +43,11 @@
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 @@
// 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 @@
// 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 @@
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));
}
}
diff --git a/modules/audio_coding/codecs/cng/webrtc_cng.cc b/modules/audio_coding/codecs/cng/webrtc_cng.cc
index bd17a61..a07b093 100644
--- a/modules/audio_coding/codecs/cng/webrtc_cng.cc
+++ b/modules/audio_coding/codecs/cng/webrtc_cng.cc
@@ -25,28 +25,26 @@
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 @@
}
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 @@
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 @@
}
/* 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 @@
/* 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 @@
/* 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 @@
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 @@
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 @@
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 @@
} 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 @@
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_);
diff --git a/modules/audio_coding/codecs/cng/webrtc_cng.h b/modules/audio_coding/codecs/cng/webrtc_cng.h
index 5e21b8f..684480a 100644
--- a/modules/audio_coding/codecs/cng/webrtc_cng.h
+++ b/modules/audio_coding/codecs/cng/webrtc_cng.h
@@ -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 @@
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 {
diff --git a/modules/audio_coding/codecs/g711/audio_decoder_pcm.cc b/modules/audio_coding/codecs/g711/audio_decoder_pcm.cc
index a620a3e..25f495f 100644
--- a/modules/audio_coding/codecs/g711/audio_decoder_pcm.cc
+++ b/modules/audio_coding/codecs/g711/audio_decoder_pcm.cc
@@ -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 {
diff --git a/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc b/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc
index 9fb94fd..c14287e 100644
--- a/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc
+++ b/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc
@@ -42,8 +42,8 @@
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 @@
}
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 @@
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;
diff --git a/modules/audio_coding/codecs/g711/g711.h b/modules/audio_coding/codecs/g711/g711.h
index 8b1fc81..365f31b 100644
--- a/modules/audio_coding/codecs/g711/g711.h
+++ b/modules/audio_coding/codecs/g711/g711.h
@@ -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 @@
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 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 @@
* 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 @@
* 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 @@
* 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 @@
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
diff --git a/modules/audio_coding/codecs/g711/g711_interface.h b/modules/audio_coding/codecs/g711/g711_interface.h
index 1f23da6..f206f30 100644
--- a/modules/audio_coding/codecs/g711/g711_interface.h
+++ b/modules/audio_coding/codecs/g711/g711_interface.h
@@ -112,19 +112,19 @@
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);
diff --git a/modules/audio_coding/codecs/g711/test/testG711.cc b/modules/audio_coding/codecs/g711/test/testG711.cc
index 98f3925..f3a42f5 100644
--- a/modules/audio_coding/codecs/g711/test/testG711.cc
+++ b/modules/audio_coding/codecs/g711/test/testG711.cc
@@ -69,7 +69,6 @@
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 @@
/* 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 @@
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 @@
}
}
- 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");
diff --git a/modules/audio_coding/codecs/g722/audio_encoder_g722.cc b/modules/audio_coding/codecs/g722/audio_encoder_g722.cc
index ec97ee3..cb96c3c 100644
--- a/modules/audio_coding/codecs/g722/audio_encoder_g722.cc
+++ b/modules/audio_coding/codecs/g722/audio_encoder_g722.cc
@@ -123,7 +123,7 @@
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.
diff --git a/modules/audio_coding/codecs/g722/audio_encoder_g722.h b/modules/audio_coding/codecs/g722/audio_encoder_g722.h
index 1f4b943..3cf1439 100644
--- a/modules/audio_coding/codecs/g722/audio_encoder_g722.h
+++ b/modules/audio_coding/codecs/g722/audio_encoder_g722.h
@@ -46,8 +46,8 @@
// 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();
};
diff --git a/modules/audio_coding/codecs/g722/g722_enc_dec.h b/modules/audio_coding/codecs/g722/g722_enc_dec.h
index ccda09b..24f238d 100644
--- a/modules/audio_coding/codecs/g722/g722_enc_dec.h
+++ b/modules/audio_coding/codecs/g722/g722_enc_dec.h
@@ -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 @@
#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 @@
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 @@
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);
diff --git a/modules/audio_coding/codecs/g722/g722_interface.h b/modules/audio_coding/codecs/g722/g722_interface.h
index d957223..3b73f85 100644
--- a/modules/audio_coding/codecs/g722/g722_interface.h
+++ b/modules/audio_coding/codecs/g722/g722_interface.h
@@ -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 @@
* 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 @@
* -1 - Error
*/
-int16_t WebRtcG722_EncoderInit(G722EncInst *G722enc_inst);
-
+int16_t WebRtcG722_EncoderInit(G722EncInst* G722enc_inst);
/****************************************************************************
* WebRtcG722_FreeEncoder(...)
@@ -73,9 +70,7 @@
* 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 len,
uint8_t* encoded);
-
/****************************************************************************
* WebRtcG722_CreateDecoder(...)
*
@@ -111,7 +105,7 @@
* 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 @@
* -1 - Error
*/
-int WebRtcG722_FreeDecoder(G722DecInst *G722dec_inst);
-
+int WebRtcG722_FreeDecoder(G722DecInst* G722dec_inst);
/****************************************************************************
* WebRtcG722_Decode(...)
@@ -159,11 +152,11 @@
* 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 @@
* 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_ */
diff --git a/modules/audio_coding/codecs/g722/test/testG722.cc b/modules/audio_coding/codecs/g722/test/testG722.cc
index e0281f2..ada56ab 100644
--- a/modules/audio_coding/codecs/g722/test/testG722.cc
+++ b/modules/audio_coding/codecs/g722/test/testG722.cc
@@ -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;
}
diff --git a/modules/audio_coding/codecs/ilbc/abs_quant.h b/modules/audio_coding/codecs/ilbc/abs_quant.h
index 3a98a6e..331921c 100644
--- a/modules/audio_coding/codecs/ilbc/abs_quant.h
+++ b/modules/audio_coding/codecs/ilbc/abs_quant.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/abs_quant_loop.h b/modules/audio_coding/codecs/ilbc/abs_quant_loop.h
index 5116bfd..a193a07 100644
--- a/modules/audio_coding/codecs/ilbc/abs_quant_loop.h
+++ b/modules/audio_coding/codecs/ilbc/abs_quant_loop.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.cc b/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.cc
index 08d21f4..9e58ce0 100644
--- a/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.cc
+++ b/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.cc
@@ -33,10 +33,10 @@
}
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 @@
} 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));
diff --git a/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc b/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc
index 6ddc078..84695e3 100644
--- a/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc
+++ b/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc
@@ -89,7 +89,6 @@
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 @@
// 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 @@
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();
}
}
diff --git a/modules/audio_coding/codecs/ilbc/augmented_cb_corr.h b/modules/audio_coding/codecs/ilbc/augmented_cb_corr.h
index 581f0d6..646e564 100644
--- a/modules/audio_coding/codecs/ilbc/augmented_cb_corr.h
+++ b/modules/audio_coding/codecs/ilbc/augmented_cb_corr.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/bw_expand.h b/modules/audio_coding/codecs/ilbc/bw_expand.h
index ee9e45a..d25325c 100644
--- a/modules/audio_coding/codecs/ilbc/bw_expand.h
+++ b/modules/audio_coding/codecs/ilbc/bw_expand.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/cb_mem_energy.h b/modules/audio_coding/codecs/ilbc/cb_mem_energy.h
index e8e2fe9..894f5d0 100644
--- a/modules/audio_coding/codecs/ilbc/cb_mem_energy.h
+++ b/modules/audio_coding/codecs/ilbc/cb_mem_energy.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.h b/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.h
index 00eb017..b7b972f 100644
--- a/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.h
+++ b/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.h b/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.h
index af8e658..5511ef1 100644
--- a/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.h
+++ b/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/cb_search.h b/modules/audio_coding/codecs/ilbc/cb_search.h
index c8626c5..393a2de 100644
--- a/modules/audio_coding/codecs/ilbc/cb_search.h
+++ b/modules/audio_coding/codecs/ilbc/cb_search.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/cb_search_core.h b/modules/audio_coding/codecs/ilbc/cb_search_core.h
index 3210668..af5a1db 100644
--- a/modules/audio_coding/codecs/ilbc/cb_search_core.h
+++ b/modules/audio_coding/codecs/ilbc/cb_search_core.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/cb_update_best_index.h b/modules/audio_coding/codecs/ilbc/cb_update_best_index.h
index a4a4cde..3f57d48 100644
--- a/modules/audio_coding/codecs/ilbc/cb_update_best_index.h
+++ b/modules/audio_coding/codecs/ilbc/cb_update_best_index.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/chebyshev.h b/modules/audio_coding/codecs/ilbc/chebyshev.h
index 46eef6b..64b2f49 100644
--- a/modules/audio_coding/codecs/ilbc/chebyshev.h
+++ b/modules/audio_coding/codecs/ilbc/chebyshev.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/comp_corr.h b/modules/audio_coding/codecs/ilbc/comp_corr.h
index f54dca2..1e6b296 100644
--- a/modules/audio_coding/codecs/ilbc/comp_corr.h
+++ b/modules/audio_coding/codecs/ilbc/comp_corr.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/constants.h b/modules/audio_coding/codecs/ilbc/constants.h
index 6864f16..3c32c62 100644
--- a/modules/audio_coding/codecs/ilbc/constants.h
+++ b/modules/audio_coding/codecs/ilbc/constants.h
@@ -79,7 +79,8 @@
/* 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[];
diff --git a/modules/audio_coding/codecs/ilbc/create_augmented_vec.h b/modules/audio_coding/codecs/ilbc/create_augmented_vec.h
index ca8b371..28c9400 100644
--- a/modules/audio_coding/codecs/ilbc/create_augmented_vec.h
+++ b/modules/audio_coding/codecs/ilbc/create_augmented_vec.h
@@ -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 */
diff --git a/modules/audio_coding/codecs/ilbc/decode.h b/modules/audio_coding/codecs/ilbc/decode.h
index ecc968e..c5f35f4 100644
--- a/modules/audio_coding/codecs/ilbc/decode.h
+++ b/modules/audio_coding/codecs/ilbc/decode.h
@@ -31,8 +31,8 @@
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
diff --git a/modules/audio_coding/codecs/ilbc/decoder_interpolate_lsf.h b/modules/audio_coding/codecs/ilbc/decoder_interpolate_lsf.h
index 416fc36..48d43ec 100644
--- a/modules/audio_coding/codecs/ilbc/decoder_interpolate_lsf.h
+++ b/modules/audio_coding/codecs/ilbc/decoder_interpolate_lsf.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/defines.h b/modules/audio_coding/codecs/ilbc/defines.h
index 6100801..9a4a196 100644
--- a/modules/audio_coding/codecs/ilbc/defines.h
+++ b/modules/audio_coding/codecs/ilbc/defines.h
@@ -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 @@
/* type definition encoder instance */
typedef struct IlbcEncoder_ {
-
/* flag for frame size mode */
int16_t mode;
@@ -172,7 +177,6 @@
/* type definition decoder instance */
typedef struct IlbcDecoder_ {
-
/* flag for frame size mode */
int16_t mode;
@@ -199,13 +203,13 @@
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 @@
/* 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;
diff --git a/modules/audio_coding/codecs/ilbc/do_plc.h b/modules/audio_coding/codecs/ilbc/do_plc.h
index 37af305..2fbae1d 100644
--- a/modules/audio_coding/codecs/ilbc/do_plc.h
+++ b/modules/audio_coding/codecs/ilbc/do_plc.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/encode.h b/modules/audio_coding/codecs/ilbc/encode.h
index 8a3928c..db00e2c 100644
--- a/modules/audio_coding/codecs/ilbc/encode.h
+++ b/modules/audio_coding/codecs/ilbc/encode.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/energy_inverse.h b/modules/audio_coding/codecs/ilbc/energy_inverse.h
index 0404f7d..359a9e2 100644
--- a/modules/audio_coding/codecs/ilbc/energy_inverse.h
+++ b/modules/audio_coding/codecs/ilbc/energy_inverse.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/enh_upsample.h b/modules/audio_coding/codecs/ilbc/enh_upsample.h
index e9a68f4..b427eca 100644
--- a/modules/audio_coding/codecs/ilbc/enh_upsample.h
+++ b/modules/audio_coding/codecs/ilbc/enh_upsample.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/enhancer.h b/modules/audio_coding/codecs/ilbc/enhancer.h
index 7e20eb1..1a6131b 100644
--- a/modules/audio_coding/codecs/ilbc/enhancer.h
+++ b/modules/audio_coding/codecs/ilbc/enhancer.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/enhancer_interface.h b/modules/audio_coding/codecs/ilbc/enhancer_interface.h
index e305161..de45715 100644
--- a/modules/audio_coding/codecs/ilbc/enhancer_interface.h
+++ b/modules/audio_coding/codecs/ilbc/enhancer_interface.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/filtered_cb_vecs.h b/modules/audio_coding/codecs/ilbc/filtered_cb_vecs.h
index f57e9c4..c51ac39 100644
--- a/modules/audio_coding/codecs/ilbc/filtered_cb_vecs.h
+++ b/modules/audio_coding/codecs/ilbc/filtered_cb_vecs.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/frame_classify.h b/modules/audio_coding/codecs/ilbc/frame_classify.h
index 60b3249..43c6e57 100644
--- a/modules/audio_coding/codecs/ilbc/frame_classify.h
+++ b/modules/audio_coding/codecs/ilbc/frame_classify.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/gain_dequant.h b/modules/audio_coding/codecs/ilbc/gain_dequant.h
index 6989372..86cc787 100644
--- a/modules/audio_coding/codecs/ilbc/gain_dequant.h
+++ b/modules/audio_coding/codecs/ilbc/gain_dequant.h
@@ -30,7 +30,7 @@
/* (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
diff --git a/modules/audio_coding/codecs/ilbc/gain_quant.h b/modules/audio_coding/codecs/ilbc/gain_quant.h
index bc5a936..51c0bc9 100644
--- a/modules/audio_coding/codecs/ilbc/gain_quant.h
+++ b/modules/audio_coding/codecs/ilbc/gain_quant.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/get_lsp_poly.h b/modules/audio_coding/codecs/ilbc/get_lsp_poly.h
index 1351b8b..d469409 100644
--- a/modules/audio_coding/codecs/ilbc/get_lsp_poly.h
+++ b/modules/audio_coding/codecs/ilbc/get_lsp_poly.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/get_sync_seq.h b/modules/audio_coding/codecs/ilbc/get_sync_seq.h
index 5c72956..2281b06 100644
--- a/modules/audio_coding/codecs/ilbc/get_sync_seq.h
+++ b/modules/audio_coding/codecs/ilbc/get_sync_seq.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/hp_input.h b/modules/audio_coding/codecs/ilbc/hp_input.h
index f354dd9..ac0d26b 100644
--- a/modules/audio_coding/codecs/ilbc/hp_input.h
+++ b/modules/audio_coding/codecs/ilbc/hp_input.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/hp_output.h b/modules/audio_coding/codecs/ilbc/hp_output.h
index a060a9d..88ecdb5 100644
--- a/modules/audio_coding/codecs/ilbc/hp_output.h
+++ b/modules/audio_coding/codecs/ilbc/hp_output.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/ilbc.h b/modules/audio_coding/codecs/ilbc/ilbc.h
index 7836489..4c12665 100644
--- a/modules/audio_coding/codecs/ilbc/ilbc.h
+++ b/modules/audio_coding/codecs/ilbc/ilbc.h
@@ -40,216 +40,214 @@
*/
#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
}
diff --git a/modules/audio_coding/codecs/ilbc/ilbc_unittest.cc b/modules/audio_coding/codecs/ilbc/ilbc_unittest.cc
index b8d3c7c..5ec1219 100644
--- a/modules/audio_coding/codecs/ilbc/ilbc_unittest.cc
+++ b/modules/audio_coding/codecs/ilbc/ilbc_unittest.cc
@@ -71,7 +71,7 @@
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 @@
// 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.
diff --git a/modules/audio_coding/codecs/ilbc/index_conv_dec.h b/modules/audio_coding/codecs/ilbc/index_conv_dec.h
index 03a721b..4f08ce0 100644
--- a/modules/audio_coding/codecs/ilbc/index_conv_dec.h
+++ b/modules/audio_coding/codecs/ilbc/index_conv_dec.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/index_conv_enc.h b/modules/audio_coding/codecs/ilbc/index_conv_enc.h
index 9938448..f899499 100644
--- a/modules/audio_coding/codecs/ilbc/index_conv_enc.h
+++ b/modules/audio_coding/codecs/ilbc/index_conv_enc.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/init_decode.h b/modules/audio_coding/codecs/ilbc/init_decode.h
index 49bd61c..fdcf9f0 100644
--- a/modules/audio_coding/codecs/ilbc/init_decode.h
+++ b/modules/audio_coding/codecs/ilbc/init_decode.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/init_encode.h b/modules/audio_coding/codecs/ilbc/init_encode.h
index d9b2971..f91a9b0 100644
--- a/modules/audio_coding/codecs/ilbc/init_encode.h
+++ b/modules/audio_coding/codecs/ilbc/init_encode.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/interpolate.h b/modules/audio_coding/codecs/ilbc/interpolate.h
index fc360b4..9f03236 100644
--- a/modules/audio_coding/codecs/ilbc/interpolate.h
+++ b/modules/audio_coding/codecs/ilbc/interpolate.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/interpolate_samples.h b/modules/audio_coding/codecs/ilbc/interpolate_samples.h
index f522f93..264a101 100644
--- a/modules/audio_coding/codecs/ilbc/interpolate_samples.h
+++ b/modules/audio_coding/codecs/ilbc/interpolate_samples.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/lpc_encode.h b/modules/audio_coding/codecs/ilbc/lpc_encode.h
index 7255705..256fa49 100644
--- a/modules/audio_coding/codecs/ilbc/lpc_encode.h
+++ b/modules/audio_coding/codecs/ilbc/lpc_encode.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/lsf_check.h b/modules/audio_coding/codecs/ilbc/lsf_check.h
index f92e0cc..d367c1d 100644
--- a/modules/audio_coding/codecs/ilbc/lsf_check.h
+++ b/modules/audio_coding/codecs/ilbc/lsf_check.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_dec.h b/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_dec.h
index 4a6c0d5..016897a 100644
--- a/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_dec.h
+++ b/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_dec.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_enc.h b/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_enc.h
index 74863c6..9cb0dd9 100644
--- a/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_enc.h
+++ b/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_enc.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/lsf_to_lsp.h b/modules/audio_coding/codecs/ilbc/lsf_to_lsp.h
index 80c0798..921101a 100644
--- a/modules/audio_coding/codecs/ilbc/lsf_to_lsp.h
+++ b/modules/audio_coding/codecs/ilbc/lsf_to_lsp.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/lsf_to_poly.h b/modules/audio_coding/codecs/ilbc/lsf_to_poly.h
index 68c4dd0..e551836 100644
--- a/modules/audio_coding/codecs/ilbc/lsf_to_poly.h
+++ b/modules/audio_coding/codecs/ilbc/lsf_to_poly.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/lsp_to_lsf.h b/modules/audio_coding/codecs/ilbc/lsp_to_lsf.h
index 666a99a..358786e 100644
--- a/modules/audio_coding/codecs/ilbc/lsp_to_lsf.h
+++ b/modules/audio_coding/codecs/ilbc/lsp_to_lsf.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/my_corr.h b/modules/audio_coding/codecs/ilbc/my_corr.h
index 7c6eb19..21deea5 100644
--- a/modules/audio_coding/codecs/ilbc/my_corr.h
+++ b/modules/audio_coding/codecs/ilbc/my_corr.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/nearest_neighbor.h b/modules/audio_coding/codecs/ilbc/nearest_neighbor.h
index d541fb7..68b5c59 100644
--- a/modules/audio_coding/codecs/ilbc/nearest_neighbor.h
+++ b/modules/audio_coding/codecs/ilbc/nearest_neighbor.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/pack_bits.h b/modules/audio_coding/codecs/ilbc/pack_bits.h
index 8ae3013..8dcf41c 100644
--- a/modules/audio_coding/codecs/ilbc/pack_bits.h
+++ b/modules/audio_coding/codecs/ilbc/pack_bits.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/poly_to_lsf.h b/modules/audio_coding/codecs/ilbc/poly_to_lsf.h
index f930c45..8a68d07 100644
--- a/modules/audio_coding/codecs/ilbc/poly_to_lsf.h
+++ b/modules/audio_coding/codecs/ilbc/poly_to_lsf.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/poly_to_lsp.h b/modules/audio_coding/codecs/ilbc/poly_to_lsp.h
index e53aa20..76378f2 100644
--- a/modules/audio_coding/codecs/ilbc/poly_to_lsp.h
+++ b/modules/audio_coding/codecs/ilbc/poly_to_lsp.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/refiner.h b/modules/audio_coding/codecs/ilbc/refiner.h
index 707be7f..87d0de7 100644
--- a/modules/audio_coding/codecs/ilbc/refiner.h
+++ b/modules/audio_coding/codecs/ilbc/refiner.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/simple_interpolate_lsf.h b/modules/audio_coding/codecs/ilbc/simple_interpolate_lsf.h
index 61a5625..317f613 100644
--- a/modules/audio_coding/codecs/ilbc/simple_interpolate_lsf.h
+++ b/modules/audio_coding/codecs/ilbc/simple_interpolate_lsf.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/simple_lpc_analysis.h b/modules/audio_coding/codecs/ilbc/simple_lpc_analysis.h
index 5eaa3d7..3b0548d 100644
--- a/modules/audio_coding/codecs/ilbc/simple_lpc_analysis.h
+++ b/modules/audio_coding/codecs/ilbc/simple_lpc_analysis.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/simple_lsf_dequant.h b/modules/audio_coding/codecs/ilbc/simple_lsf_dequant.h
index d78d714..ee18486 100644
--- a/modules/audio_coding/codecs/ilbc/simple_lsf_dequant.h
+++ b/modules/audio_coding/codecs/ilbc/simple_lsf_dequant.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/simple_lsf_quant.h b/modules/audio_coding/codecs/ilbc/simple_lsf_quant.h
index 5e4e6f1..74fb0be 100644
--- a/modules/audio_coding/codecs/ilbc/simple_lsf_quant.h
+++ b/modules/audio_coding/codecs/ilbc/simple_lsf_quant.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/smooth.h b/modules/audio_coding/codecs/ilbc/smooth.h
index a8d1706..52e7ff9 100644
--- a/modules/audio_coding/codecs/ilbc/smooth.h
+++ b/modules/audio_coding/codecs/ilbc/smooth.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/smooth_out_data.h b/modules/audio_coding/codecs/ilbc/smooth_out_data.h
index 6370d10..df946e3 100644
--- a/modules/audio_coding/codecs/ilbc/smooth_out_data.h
+++ b/modules/audio_coding/codecs/ilbc/smooth_out_data.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/sort_sq.h b/modules/audio_coding/codecs/ilbc/sort_sq.h
index f3c01ef..1fe7fbf 100644
--- a/modules/audio_coding/codecs/ilbc/sort_sq.h
+++ b/modules/audio_coding/codecs/ilbc/sort_sq.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/split_vq.h b/modules/audio_coding/codecs/ilbc/split_vq.h
index a758159..6bc2db6 100644
--- a/modules/audio_coding/codecs/ilbc/split_vq.h
+++ b/modules/audio_coding/codecs/ilbc/split_vq.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/state_construct.h b/modules/audio_coding/codecs/ilbc/state_construct.h
index 9339f65..0dadf48 100644
--- a/modules/audio_coding/codecs/ilbc/state_construct.h
+++ b/modules/audio_coding/codecs/ilbc/state_construct.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/state_search.h b/modules/audio_coding/codecs/ilbc/state_search.h
index 976edca..1ad27ce 100644
--- a/modules/audio_coding/codecs/ilbc/state_search.h
+++ b/modules/audio_coding/codecs/ilbc/state_search.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/swap_bytes.h b/modules/audio_coding/codecs/ilbc/swap_bytes.h
index 63930d4..381b73a 100644
--- a/modules/audio_coding/codecs/ilbc/swap_bytes.h
+++ b/modules/audio_coding/codecs/ilbc/swap_bytes.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/unpack_bits.h b/modules/audio_coding/codecs/ilbc/unpack_bits.h
index b2e622f..4fd0a80 100644
--- a/modules/audio_coding/codecs/ilbc/unpack_bits.h
+++ b/modules/audio_coding/codecs/ilbc/unpack_bits.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/vq3.h b/modules/audio_coding/codecs/ilbc/vq3.h
index 6d3dc3a..ceaff8d 100644
--- a/modules/audio_coding/codecs/ilbc/vq3.h
+++ b/modules/audio_coding/codecs/ilbc/vq3.h
@@ -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
diff --git a/modules/audio_coding/codecs/ilbc/vq4.h b/modules/audio_coding/codecs/ilbc/vq4.h
index c7f5271..8dbedc9 100644
--- a/modules/audio_coding/codecs/ilbc/vq4.h
+++ b/modules/audio_coding/codecs/ilbc/vq4.h
@@ -26,11 +26,11 @@
*---------------------------------------------------------------*/
void WebRtcIlbcfix_Vq4(
- 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
diff --git a/modules/audio_coding/codecs/ilbc/window32_w32.h b/modules/audio_coding/codecs/ilbc/window32_w32.h
index c348d1d..0cef084 100644
--- a/modules/audio_coding/codecs/ilbc/window32_w32.h
+++ b/modules/audio_coding/codecs/ilbc/window32_w32.h
@@ -25,11 +25,10 @@
* window multiplication
*---------------------------------------------------------------*/
-void WebRtcIlbcfix_Window32W32(
- int32_t *z, /* Output */
- int32_t *x, /* Input (same domain as Output)*/
- const int32_t *y, /* Q31 Window */
- size_t N /* length to process */
+void WebRtcIlbcfix_Window32W32(int32_t* z, /* Output */
+ int32_t* x, /* Input (same domain as Output)*/
+ const int32_t* y, /* Q31 Window */
+ size_t N /* length to process */
);
#endif
diff --git a/modules/audio_coding/codecs/ilbc/xcorr_coef.h b/modules/audio_coding/codecs/ilbc/xcorr_coef.h
index cd58b60..e6c3d3f 100644
--- a/modules/audio_coding/codecs/ilbc/xcorr_coef.h
+++ b/modules/audio_coding/codecs/ilbc/xcorr_coef.h
@@ -27,12 +27,12 @@
*---------------------------------------------------------------*/
size_t WebRtcIlbcfix_XcorrCoef(
- int16_t *target, /* (i) first array */
- int16_t *regressor, /* (i) second array */
- size_t subl, /* (i) dimension arrays */
- size_t searchLen, /* (i) the search lenght */
- size_t offset, /* (i) samples offset between arrays */
- int16_t step /* (i) +1 or -1 */
- );
+ int16_t* target, /* (i) first array */
+ int16_t* regressor, /* (i) second array */
+ size_t subl, /* (i) dimension arrays */
+ size_t searchLen, /* (i) the search lenght */
+ size_t offset, /* (i) samples offset between arrays */
+ int16_t step /* (i) +1 or -1 */
+ );
#endif
diff --git a/modules/audio_coding/codecs/isac/audio_encoder_isac_t_impl.h b/modules/audio_coding/codecs/isac/audio_encoder_isac_t_impl.h
index 696b799..cbf15fc 100644
--- a/modules/audio_coding/codecs/isac/audio_encoder_isac_t_impl.h
+++ b/modules/audio_coding/codecs/isac/audio_encoder_isac_t_impl.h
@@ -90,9 +90,8 @@
template <typename T>
size_t AudioEncoderIsacT<T>::Num10MsFramesInNextPacket() const {
const int samples_in_next_packet = T::GetNewFrameLen(isac_state_);
- return static_cast<size_t>(
- rtc::CheckedDivExact(samples_in_next_packet,
- rtc::CheckedDivExact(SampleRateHz(), 100)));
+ return static_cast<size_t>(rtc::CheckedDivExact(
+ samples_in_next_packet, rtc::CheckedDivExact(SampleRateHz(), 100)));
}
template <typename T>
@@ -123,8 +122,7 @@
}
size_t encoded_bytes = encoded->AppendData(
- kSufficientEncodeBufferSizeBytes,
- [&] (rtc::ArrayView<uint8_t> encoded) {
+ kSufficientEncodeBufferSizeBytes, [&](rtc::ArrayView<uint8_t> encoded) {
int r = T::Encode(isac_state_, audio.data(), encoded.data());
RTC_CHECK_GE(r, 0) << "Encode failed (error code "
diff --git a/modules/audio_coding/codecs/isac/fix/include/isacfix.h b/modules/audio_coding/codecs/isac/fix/include/isacfix.h
index ef194ca..626b3c7 100644
--- a/modules/audio_coding/codecs/isac/fix/include/isacfix.h
+++ b/modules/audio_coding/codecs/isac/fix/include/isacfix.h
@@ -16,622 +16,591 @@
#include "modules/audio_coding/codecs/isac/bandwidth_info.h"
#include "typedefs.h" // NOLINT(build/include)
-typedef struct {
- void *dummy;
-} ISACFIX_MainStruct;
-
+typedef struct { void* dummy; } ISACFIX_MainStruct;
#if defined(__cplusplus)
extern "C" {
#endif
+/**************************************************************************
+ * WebRtcIsacfix_AssignSize(...)
+ *
+ * Functions used when malloc is not allowed
+ * Output the number of bytes needed to allocate for iSAC struct.
+ *
+ */
- /**************************************************************************
- * WebRtcIsacfix_AssignSize(...)
- *
- * Functions used when malloc is not allowed
- * Output the number of bytes needed to allocate for iSAC struct.
- *
- */
+int16_t WebRtcIsacfix_AssignSize(int* sizeinbytes);
- int16_t WebRtcIsacfix_AssignSize(int *sizeinbytes);
+/**************************************************************************
+ * WebRtcIsacfix_Assign(...)
+ *
+ * Functions used when malloc is not allowed, it
+ * places a struct at the given address.
+ *
+ * Input:
+ * - *ISAC_main_inst : a pointer to the coder instance.
+ * - ISACFIX_inst_Addr : address of the memory where a space is
+ * for iSAC structure.
+ *
+ * Return value : 0 - Ok
+ * -1 - Error
+ */
- /**************************************************************************
- * WebRtcIsacfix_Assign(...)
- *
- * Functions used when malloc is not allowed, it
- * places a struct at the given address.
- *
- * Input:
- * - *ISAC_main_inst : a pointer to the coder instance.
- * - ISACFIX_inst_Addr : address of the memory where a space is
- * for iSAC structure.
- *
- * Return value : 0 - Ok
- * -1 - Error
- */
+int16_t WebRtcIsacfix_Assign(ISACFIX_MainStruct** inst,
+ void* ISACFIX_inst_Addr);
- int16_t WebRtcIsacfix_Assign(ISACFIX_MainStruct **inst,
- void *ISACFIX_inst_Addr);
+/****************************************************************************
+ * WebRtcIsacfix_Create(...)
+ *
+ * This function creates an ISAC instance, which will contain the state
+ * information for one coding/decoding channel.
+ *
+ * Input:
+ * - *ISAC_main_inst : a pointer to the coder instance.
+ *
+ * Return value : 0 - Ok
+ * -1 - Error
+ */
- /****************************************************************************
- * WebRtcIsacfix_Create(...)
- *
- * This function creates an ISAC instance, which will contain the state
- * information for one coding/decoding channel.
- *
- * Input:
- * - *ISAC_main_inst : a pointer to the coder instance.
- *
- * Return value : 0 - Ok
- * -1 - Error
- */
+int16_t WebRtcIsacfix_Create(ISACFIX_MainStruct** ISAC_main_inst);
- int16_t WebRtcIsacfix_Create(ISACFIX_MainStruct **ISAC_main_inst);
+/****************************************************************************
+ * WebRtcIsacfix_Free(...)
+ *
+ * This function frees the ISAC instance created at the beginning.
+ *
+ * Input:
+ * - ISAC_main_inst : a ISAC instance.
+ *
+ * Return value : 0 - Ok
+ * -1 - Error
+ */
+int16_t WebRtcIsacfix_Free(ISACFIX_MainStruct* ISAC_main_inst);
- /****************************************************************************
- * WebRtcIsacfix_Free(...)
- *
- * This function frees the ISAC instance created at the beginning.
- *
- * Input:
- * - ISAC_main_inst : a ISAC instance.
- *
- * Return value : 0 - Ok
- * -1 - Error
- */
+/****************************************************************************
+ * WebRtcIsacfix_EncoderInit(...)
+ *
+ * This function initializes an ISAC instance prior to the encoder calls.
+ *
+ * Input:
+ * - ISAC_main_inst : ISAC instance.
+ * - CodingMode : 0 - Bit rate and frame length are automatically
+ * adjusted to available bandwidth on
+ * transmission channel.
+ * 1 - User sets a frame length and a target bit
+ * rate which is taken as the maximum short-term
+ * average bit rate.
+ *
+ * Return value : 0 - Ok
+ * -1 - Error
+ */
- int16_t WebRtcIsacfix_Free(ISACFIX_MainStruct *ISAC_main_inst);
+int16_t WebRtcIsacfix_EncoderInit(ISACFIX_MainStruct* ISAC_main_inst,
+ int16_t CodingMode);
+/****************************************************************************
+ * WebRtcIsacfix_Encode(...)
+ *
+ * This function encodes 10ms frame(s) and inserts it into a package.
+ * Input speech length has to be 160 samples (10ms). The encoder buffers those
+ * 10ms frames until it reaches the chosen Framesize (480 or 960 samples
+ * corresponding to 30 or 60 ms frames), and then proceeds to the encoding.
+ *
+ * Input:
+ * - ISAC_main_inst : ISAC instance.
+ * - speechIn : input speech vector.
+ *
+ * Output:
+ * - encoded : the encoded data vector
+ *
+ * Return value : >0 - Length (in bytes) of coded data
+ * 0 - The buffer didn't reach the chosen framesize
+ * so it keeps buffering speech samples.
+ * -1 - Error
+ */
- /****************************************************************************
- * WebRtcIsacfix_EncoderInit(...)
- *
- * This function initializes an ISAC instance prior to the encoder calls.
- *
- * Input:
- * - ISAC_main_inst : ISAC instance.
- * - CodingMode : 0 - Bit rate and frame length are automatically
- * adjusted to available bandwidth on
- * transmission channel.
- * 1 - User sets a frame length and a target bit
- * rate which is taken as the maximum short-term
- * average bit rate.
- *
- * Return value : 0 - Ok
- * -1 - Error
- */
+int WebRtcIsacfix_Encode(ISACFIX_MainStruct* ISAC_main_inst,
+ const int16_t* speechIn,
+ uint8_t* encoded);
- int16_t WebRtcIsacfix_EncoderInit(ISACFIX_MainStruct *ISAC_main_inst,
- int16_t CodingMode);
-
-
- /****************************************************************************
- * WebRtcIsacfix_Encode(...)
- *
- * This function encodes 10ms frame(s) and inserts it into a package.
- * Input speech length has to be 160 samples (10ms). The encoder buffers those
- * 10ms frames until it reaches the chosen Framesize (480 or 960 samples
- * corresponding to 30 or 60 ms frames), and then proceeds to the encoding.
- *
- * Input:
- * - ISAC_main_inst : ISAC instance.
- * - speechIn : input speech vector.
- *
- * Output:
- * - encoded : the encoded data vector
- *
- * Return value : >0 - Length (in bytes) of coded data
- * 0 - The buffer didn't reach the chosen framesize
- * so it keeps buffering speech samples.
- * -1 - Error
- */
-
- int WebRtcIsacfix_Encode(ISACFIX_MainStruct *ISAC_main_inst,
- const int16_t *speechIn,
- uint8_t* encoded);
-
-
-
- /****************************************************************************
- * WebRtcIsacfix_EncodeNb(...)
- *
- * This function encodes 10ms narrow band (8 kHz sampling) frame(s) and inserts
- * it into a package. Input speech length has to be 80 samples (10ms). The encoder
- * interpolates into wide-band (16 kHz sampling) buffers those
- * 10ms frames until it reaches the chosen Framesize (480 or 960 wide-band samples
- * corresponding to 30 or 60 ms frames), and then proceeds to the encoding.
- *
- * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined
- *
- * Input:
- * - ISAC_main_inst : ISAC instance.
- * - speechIn : input speech vector.
- *
- * Output:
- * - encoded : the encoded data vector
- *
- * Return value : >0 - Length (in bytes) of coded data
- * 0 - The buffer didn't reach the chosen framesize
- * so it keeps buffering speech samples.
- * -1 - Error
- */
-
+/****************************************************************************
+ * WebRtcIsacfix_EncodeNb(...)
+ *
+ * This function encodes 10ms narrow band (8 kHz sampling) frame(s) and inserts
+ * it into a package. Input speech length has to be 80 samples (10ms). The
+ * encoder interpolates into wide-band (16 kHz sampling) buffers those 10ms
+ * frames until it reaches the chosen Framesize (480 or 960 wide-band samples
+ * corresponding to 30 or 60 ms frames), and then proceeds to the encoding.
+ *
+ * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined
+ *
+ * Input:
+ * - ISAC_main_inst : ISAC instance.
+ * - speechIn : input speech vector.
+ *
+ * Output:
+ * - encoded : the encoded data vector
+ *
+ * Return value : >0 - Length (in bytes) of coded data
+ * 0 - The buffer didn't reach the chosen framesize
+ * so it keeps buffering speech samples.
+ * -1 - Error
+ */
#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
- int16_t WebRtcIsacfix_EncodeNb(ISACFIX_MainStruct *ISAC_main_inst,
- const int16_t *speechIn,
- int16_t *encoded);
-#endif // WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
+int16_t WebRtcIsacfix_EncodeNb(ISACFIX_MainStruct* ISAC_main_inst,
+ const int16_t* speechIn,
+ int16_t* encoded);
+#endif // WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
+/****************************************************************************
+ * WebRtcIsacfix_DecoderInit(...)
+ *
+ * This function initializes an ISAC instance prior to the decoder calls.
+ *
+ * Input:
+ * - ISAC_main_inst : ISAC instance.
+ */
+void WebRtcIsacfix_DecoderInit(ISACFIX_MainStruct* ISAC_main_inst);
- /****************************************************************************
- * WebRtcIsacfix_DecoderInit(...)
- *
- * This function initializes an ISAC instance prior to the decoder calls.
- *
- * Input:
- * - ISAC_main_inst : ISAC instance.
- */
+/****************************************************************************
+ * WebRtcIsacfix_UpdateBwEstimate1(...)
+ *
+ * This function updates the estimate of the bandwidth.
+ *
+ * Input:
+ * - ISAC_main_inst : ISAC instance.
+ * - encoded : encoded ISAC frame(s).
+ * - packet_size : size of the packet in bytes.
+ * - rtp_seq_number : the RTP number of the packet.
+ * - arr_ts : the arrival time of the packet (from NetEq)
+ * in samples.
+ *
+ * Return value : 0 - Ok
+ * -1 - Error
+ */
- void WebRtcIsacfix_DecoderInit(ISACFIX_MainStruct* ISAC_main_inst);
+int16_t WebRtcIsacfix_UpdateBwEstimate1(ISACFIX_MainStruct* ISAC_main_inst,
+ const uint8_t* encoded,
+ size_t packet_size,
+ uint16_t rtp_seq_number,
+ uint32_t arr_ts);
- /****************************************************************************
- * WebRtcIsacfix_UpdateBwEstimate1(...)
- *
- * This function updates the estimate of the bandwidth.
- *
- * Input:
- * - ISAC_main_inst : ISAC instance.
- * - encoded : encoded ISAC frame(s).
- * - packet_size : size of the packet in bytes.
- * - rtp_seq_number : the RTP number of the packet.
- * - arr_ts : the arrival time of the packet (from NetEq)
- * in samples.
- *
- * Return value : 0 - Ok
- * -1 - Error
- */
+/****************************************************************************
+ * WebRtcIsacfix_UpdateBwEstimate(...)
+ *
+ * This function updates the estimate of the bandwidth.
+ *
+ * Input:
+ * - ISAC_main_inst : ISAC instance.
+ * - encoded : encoded ISAC frame(s).
+ * - packet_size : size of the packet in bytes.
+ * - rtp_seq_number : the RTP number of the packet.
+ * - send_ts : the send time of the packet from RTP header,
+ * in samples.
+ * - arr_ts : the arrival time of the packet (from NetEq)
+ * in samples.
+ *
+ * Return value : 0 - Ok
+ * -1 - Error
+ */
- int16_t WebRtcIsacfix_UpdateBwEstimate1(ISACFIX_MainStruct *ISAC_main_inst,
- const uint8_t* encoded,
- size_t packet_size,
- uint16_t rtp_seq_number,
- uint32_t arr_ts);
+int16_t WebRtcIsacfix_UpdateBwEstimate(ISACFIX_MainStruct* ISAC_main_inst,
+ const uint8_t* encoded,
+ size_t packet_size,
+ uint16_t rtp_seq_number,
+ uint32_t send_ts,
+ uint32_t arr_ts);
- /****************************************************************************
- * WebRtcIsacfix_UpdateBwEstimate(...)
- *
- * This function updates the estimate of the bandwidth.
- *
- * Input:
- * - ISAC_main_inst : ISAC instance.
- * - encoded : encoded ISAC frame(s).
- * - packet_size : size of the packet in bytes.
- * - rtp_seq_number : the RTP number of the packet.
- * - send_ts : the send time of the packet from RTP header,
- * in samples.
- * - arr_ts : the arrival time of the packet (from NetEq)
- * in samples.
- *
- * Return value : 0 - Ok
- * -1 - Error
- */
+/****************************************************************************
+ * WebRtcIsacfix_Decode(...)
+ *
+ * This function decodes an ISAC frame. Output speech length
+ * will be a multiple of 480 samples: 480 or 960 samples,
+ * depending on the framesize (30 or 60 ms).
+ *
+ * Input:
+ * - ISAC_main_inst : ISAC instance.
+ * - encoded : encoded ISAC frame(s)
+ * - len : bytes in encoded vector
+ *
+ * Output:
+ * - decoded : The decoded vector
+ *
+ * Return value : >0 - number of samples in decoded vector
+ * -1 - Error
+ */
- int16_t WebRtcIsacfix_UpdateBwEstimate(ISACFIX_MainStruct *ISAC_main_inst,
- const uint8_t* encoded,
- size_t packet_size,
- uint16_t rtp_seq_number,
- uint32_t send_ts,
- uint32_t arr_ts);
+int WebRtcIsacfix_Decode(ISACFIX_MainStruct* ISAC_main_inst,
+ const uint8_t* encoded,
+ size_t len,
+ int16_t* decoded,
+ int16_t* speechType);
- /****************************************************************************
- * WebRtcIsacfix_Decode(...)
- *
- * This function decodes an ISAC frame. Output speech length
- * will be a multiple of 480 samples: 480 or 960 samples,
- * depending on the framesize (30 or 60 ms).
- *
- * Input:
- * - ISAC_main_inst : ISAC instance.
- * - encoded : encoded ISAC frame(s)
- * - len : bytes in encoded vector
- *
- * Output:
- * - decoded : The decoded vector
- *
- * Return value : >0 - number of samples in decoded vector
- * -1 - Error
- */
+/****************************************************************************
+ * WebRtcIsacfix_DecodeNb(...)
+ *
+ * This function decodes a ISAC frame in narrow-band (8 kHz sampling).
+ * Output speech length will be a multiple of 240 samples: 240 or 480 samples,
+ * depending on the framesize (30 or 60 ms).
+ *
+ * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined
+ *
+ * Input:
+ * - ISAC_main_inst : ISAC instance.
+ * - encoded : encoded ISAC frame(s)
+ * - len : bytes in encoded vector
+ *
+ * Output:
+ * - decoded : The decoded vector
+ *
+ * Return value : >0 - number of samples in decoded vector
+ * -1 - Error
+ */
- int WebRtcIsacfix_Decode(ISACFIX_MainStruct *ISAC_main_inst,
- const uint8_t* encoded,
+#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
+int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct* ISAC_main_inst,
+ const uint16_t* encoded,
size_t len,
- int16_t *decoded,
- int16_t *speechType);
+ int16_t* decoded,
+ int16_t* speechType);
+#endif // WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
-
- /****************************************************************************
- * WebRtcIsacfix_DecodeNb(...)
- *
- * This function decodes a ISAC frame in narrow-band (8 kHz sampling).
- * Output speech length will be a multiple of 240 samples: 240 or 480 samples,
- * depending on the framesize (30 or 60 ms).
- *
- * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined
- *
- * Input:
- * - ISAC_main_inst : ISAC instance.
- * - encoded : encoded ISAC frame(s)
- * - len : bytes in encoded vector
- *
- * Output:
- * - decoded : The decoded vector
- *
- * Return value : >0 - number of samples in decoded vector
- * -1 - Error
- */
+/****************************************************************************
+ * WebRtcIsacfix_DecodePlcNb(...)
+ *
+ * This function conducts PLC for ISAC frame(s) in narrow-band (8kHz sampling).
+ * Output speech length will be "240*noOfLostFrames" samples
+ * that equevalent of "30*noOfLostFrames" millisecond.
+ *
+ * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined
+ *
+ * Input:
+ * - ISAC_main_inst : ISAC instance.
+ * - noOfLostFrames : Number of PLC frames (240 sample=30ms) to produce
+ * NOTE! Maximum number is 2 (480 samples = 60ms)
+ *
+ * Output:
+ * - decoded : The decoded vector
+ *
+ * Return value : Number of samples in decoded PLC vector
+ */
#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
- int WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst,
- const uint16_t *encoded,
- size_t len,
- int16_t *decoded,
- int16_t *speechType);
-#endif // WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
+size_t WebRtcIsacfix_DecodePlcNb(ISACFIX_MainStruct* ISAC_main_inst,
+ int16_t* decoded,
+ size_t noOfLostFrames);
+#endif // WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
+/****************************************************************************
+ * WebRtcIsacfix_DecodePlc(...)
+ *
+ * This function conducts PLC for ISAC frame(s) in wide-band (16kHz sampling).
+ * Output speech length will be "480*noOfLostFrames" samples
+ * that is equevalent of "30*noOfLostFrames" millisecond.
+ *
+ * Input:
+ * - ISAC_main_inst : ISAC instance.
+ * - noOfLostFrames : Number of PLC frames (480sample = 30ms)
+ * to produce
+ * NOTE! Maximum number is 2 (960 samples = 60ms)
+ *
+ * Output:
+ * - decoded : The decoded vector
+ *
+ * Return value : Number of samples in decoded PLC vector
+ */
- /****************************************************************************
- * WebRtcIsacfix_DecodePlcNb(...)
- *
- * This function conducts PLC for ISAC frame(s) in narrow-band (8kHz sampling).
- * Output speech length will be "240*noOfLostFrames" samples
- * that equevalent of "30*noOfLostFrames" millisecond.
- *
- * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined
- *
- * Input:
- * - ISAC_main_inst : ISAC instance.
- * - noOfLostFrames : Number of PLC frames (240 sample=30ms) to produce
- * NOTE! Maximum number is 2 (480 samples = 60ms)
- *
- * Output:
- * - decoded : The decoded vector
- *
- * Return value : Number of samples in decoded PLC vector
- */
+size_t WebRtcIsacfix_DecodePlc(ISACFIX_MainStruct* ISAC_main_inst,
+ int16_t* decoded,
+ size_t noOfLostFrames);
-#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
- size_t WebRtcIsacfix_DecodePlcNb(ISACFIX_MainStruct *ISAC_main_inst,
- int16_t *decoded,
- size_t noOfLostFrames);
-#endif // WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
+/****************************************************************************
+ * WebRtcIsacfix_ReadFrameLen(...)
+ *
+ * This function returns the length of the frame represented in the packet.
+ *
+ * Input:
+ * - encoded : Encoded bitstream
+ * - encoded_len_bytes : Length of the bitstream in bytes.
+ *
+ * Output:
+ * - frameLength : Length of frame in packet (in samples)
+ *
+ */
+int16_t WebRtcIsacfix_ReadFrameLen(const uint8_t* encoded,
+ size_t encoded_len_bytes,
+ size_t* frameLength);
+/****************************************************************************
+ * WebRtcIsacfix_Control(...)
+ *
+ * This function sets the limit on the short-term average bit rate and the
+ * frame length. Should be used only in Instantaneous mode.
+ *
+ * Input:
+ * - ISAC_main_inst : ISAC instance.
+ * - rate : limit on the short-term average bit rate,
+ * in bits/second (between 10000 and 32000)
+ * - framesize : number of milliseconds per frame (30 or 60)
+ *
+ * Return value : 0 - ok
+ * -1 - Error
+ */
+int16_t WebRtcIsacfix_Control(ISACFIX_MainStruct* ISAC_main_inst,
+ int16_t rate,
+ int framesize);
- /****************************************************************************
- * WebRtcIsacfix_DecodePlc(...)
- *
- * This function conducts PLC for ISAC frame(s) in wide-band (16kHz sampling).
- * Output speech length will be "480*noOfLostFrames" samples
- * that is equevalent of "30*noOfLostFrames" millisecond.
- *
- * Input:
- * - ISAC_main_inst : ISAC instance.
- * - noOfLostFrames : Number of PLC frames (480sample = 30ms)
- * to produce
- * NOTE! Maximum number is 2 (960 samples = 60ms)
- *
- * Output:
- * - decoded : The decoded vector
- *
- * Return value : Number of samples in decoded PLC vector
- */
+void WebRtcIsacfix_SetInitialBweBottleneck(ISACFIX_MainStruct* ISAC_main_inst,
+ int bottleneck_bits_per_second);
- size_t WebRtcIsacfix_DecodePlc(ISACFIX_MainStruct *ISAC_main_inst,
- int16_t *decoded,
- size_t noOfLostFrames );
+/****************************************************************************
+ * WebRtcIsacfix_ControlBwe(...)
+ *
+ * This function sets the initial values of bottleneck and frame-size if
+ * iSAC is used in channel-adaptive mode. Through this API, users can
+ * enforce a frame-size for all values of bottleneck. Then iSAC will not
+ * automatically change the frame-size.
+ *
+ *
+ * Input:
+ * - ISAC_main_inst : ISAC instance.
+ * - rateBPS : initial value of bottleneck in bits/second
+ * 10000 <= rateBPS <= 32000 is accepted
+ * - frameSizeMs : number of milliseconds per frame (30 or 60)
+ * - enforceFrameSize : 1 to enforce the given frame-size through out
+ * the adaptation process, 0 to let iSAC change
+ * the frame-size if required.
+ *
+ * Return value : 0 - ok
+ * -1 - Error
+ */
+int16_t WebRtcIsacfix_ControlBwe(ISACFIX_MainStruct* ISAC_main_inst,
+ int16_t rateBPS,
+ int frameSizeMs,
+ int16_t enforceFrameSize);
- /****************************************************************************
- * WebRtcIsacfix_ReadFrameLen(...)
- *
- * This function returns the length of the frame represented in the packet.
- *
- * Input:
- * - encoded : Encoded bitstream
- * - encoded_len_bytes : Length of the bitstream in bytes.
- *
- * Output:
- * - frameLength : Length of frame in packet (in samples)
- *
- */
+/****************************************************************************
+ * WebRtcIsacfix_version(...)
+ *
+ * This function returns the version number.
+ *
+ * Output:
+ * - version : Pointer to character string
+ *
+ */
- int16_t WebRtcIsacfix_ReadFrameLen(const uint8_t* encoded,
- size_t encoded_len_bytes,
- size_t* frameLength);
+void WebRtcIsacfix_version(char* version);
- /****************************************************************************
- * WebRtcIsacfix_Control(...)
- *
- * This function sets the limit on the short-term average bit rate and the
- * frame length. Should be used only in Instantaneous mode.
- *
- * Input:
- * - ISAC_main_inst : ISAC instance.
- * - rate : limit on the short-term average bit rate,
- * in bits/second (between 10000 and 32000)
- * - framesize : number of milliseconds per frame (30 or 60)
- *
- * Return value : 0 - ok
- * -1 - Error
- */
+/****************************************************************************
+ * WebRtcIsacfix_GetErrorCode(...)
+ *
+ * This function can be used to check the error code of an iSAC instance. When
+ * a function returns -1 a error code will be set for that instance. The
+ * function below extract the code of the last error that occured in the
+ * specified instance.
+ *
+ * Input:
+ * - ISAC_main_inst : ISAC instance
+ *
+ * Return value : Error code
+ */
- int16_t WebRtcIsacfix_Control(ISACFIX_MainStruct *ISAC_main_inst,
- int16_t rate,
- int framesize);
+int16_t WebRtcIsacfix_GetErrorCode(ISACFIX_MainStruct* ISAC_main_inst);
- void WebRtcIsacfix_SetInitialBweBottleneck(ISACFIX_MainStruct* ISAC_main_inst,
- int bottleneck_bits_per_second);
+/****************************************************************************
+ * WebRtcIsacfix_GetUplinkBw(...)
+ *
+ * This function return iSAC send bitrate
+ *
+ * Input:
+ * - ISAC_main_inst : iSAC instance
+ *
+ * Return value : <0 Error code
+ * else bitrate
+ */
- /****************************************************************************
- * WebRtcIsacfix_ControlBwe(...)
- *
- * This function sets the initial values of bottleneck and frame-size if
- * iSAC is used in channel-adaptive mode. Through this API, users can
- * enforce a frame-size for all values of bottleneck. Then iSAC will not
- * automatically change the frame-size.
- *
- *
- * Input:
- * - ISAC_main_inst : ISAC instance.
- * - rateBPS : initial value of bottleneck in bits/second
- * 10000 <= rateBPS <= 32000 is accepted
- * - frameSizeMs : number of milliseconds per frame (30 or 60)
- * - enforceFrameSize : 1 to enforce the given frame-size through out
- * the adaptation process, 0 to let iSAC change
- * the frame-size if required.
- *
- * Return value : 0 - ok
- * -1 - Error
- */
+int32_t WebRtcIsacfix_GetUplinkBw(ISACFIX_MainStruct* ISAC_main_inst);
- int16_t WebRtcIsacfix_ControlBwe(ISACFIX_MainStruct *ISAC_main_inst,
- int16_t rateBPS,
- int frameSizeMs,
- int16_t enforceFrameSize);
+/****************************************************************************
+ * WebRtcIsacfix_SetMaxPayloadSize(...)
+ *
+ * This function sets a limit for the maximum payload size of iSAC. The same
+ * value is used both for 30 and 60 msec packets.
+ * The absolute max will be valid until next time the function is called.
+ * NOTE! This function may override the function WebRtcIsacfix_SetMaxRate()
+ *
+ * Input:
+ * - ISAC_main_inst : iSAC instance
+ * - maxPayloadBytes : maximum size of the payload in bytes
+ * valid values are between 100 and 400 bytes
+ *
+ *
+ * Return value : 0 if sucessful
+ * -1 if error happens
+ */
+int16_t WebRtcIsacfix_SetMaxPayloadSize(ISACFIX_MainStruct* ISAC_main_inst,
+ int16_t maxPayloadBytes);
+/****************************************************************************
+ * WebRtcIsacfix_SetMaxRate(...)
+ *
+ * This function sets the maximum rate which the codec may not exceed for a
+ * singel packet. The maximum rate is set in bits per second.
+ * The codec has an absolute maximum rate of 53400 bits per second (200 bytes
+ * per 30 msec).
+ * It is possible to set a maximum rate between 32000 and 53400 bits per second.
+ *
+ * The rate limit is valid until next time the function is called.
+ *
+ * NOTE! Packet size will never go above the value set if calling
+ * WebRtcIsacfix_SetMaxPayloadSize() (default max packet size is 400 bytes).
+ *
+ * Input:
+ * - ISAC_main_inst : iSAC instance
+ * - maxRateInBytes : maximum rate in bits per second,
+ * valid values are 32000 to 53400 bits
+ *
+ * Return value : 0 if sucessful
+ * -1 if error happens
+ */
- /****************************************************************************
- * WebRtcIsacfix_version(...)
- *
- * This function returns the version number.
- *
- * Output:
- * - version : Pointer to character string
- *
- */
+int16_t WebRtcIsacfix_SetMaxRate(ISACFIX_MainStruct* ISAC_main_inst,
+ int32_t maxRate);
- void WebRtcIsacfix_version(char *version);
+/****************************************************************************
+ * WebRtcIsacfix_CreateInternal(...)
+ *
+ * This function creates the memory that is used to store data in the encoder
+ *
+ * Input:
+ * - *ISAC_main_inst : a pointer to the coder instance.
+ *
+ * Return value : 0 - Ok
+ * -1 - Error
+ */
+int16_t WebRtcIsacfix_CreateInternal(ISACFIX_MainStruct* ISAC_main_inst);
- /****************************************************************************
- * WebRtcIsacfix_GetErrorCode(...)
- *
- * This function can be used to check the error code of an iSAC instance. When
- * a function returns -1 a error code will be set for that instance. The
- * function below extract the code of the last error that occured in the
- * specified instance.
- *
- * Input:
- * - ISAC_main_inst : ISAC instance
- *
- * Return value : Error code
- */
+/****************************************************************************
+ * WebRtcIsacfix_FreeInternal(...)
+ *
+ * This function frees the internal memory for storing encoder data.
+ *
+ * Input:
+ * - ISAC_main_inst : an ISAC instance.
+ *
+ * Return value : 0 - Ok
+ * -1 - Error
+ */
- int16_t WebRtcIsacfix_GetErrorCode(ISACFIX_MainStruct *ISAC_main_inst);
+int16_t WebRtcIsacfix_FreeInternal(ISACFIX_MainStruct* ISAC_main_inst);
+/****************************************************************************
+ * WebRtcIsacfix_GetNewBitStream(...)
+ *
+ * This function returns encoded data, with the recieved bwe-index in the
+ * stream. It should always return a complete packet, i.e. only called once
+ * even for 60 msec frames
+ *
+ * Input:
+ * - ISAC_main_inst : ISAC instance.
+ * - bweIndex : index of bandwidth estimate to put in new
+ * bitstream - scale : factor for rate change (0.4 ~=> half the
+ * rate, 1 no change).
+ *
+ * Output:
+ * - encoded : the encoded data vector
+ *
+ * Return value : >0 - Length (in bytes) of coded data
+ * -1 - Error
+ */
- /****************************************************************************
- * WebRtcIsacfix_GetUplinkBw(...)
- *
- * This function return iSAC send bitrate
- *
- * Input:
- * - ISAC_main_inst : iSAC instance
- *
- * Return value : <0 Error code
- * else bitrate
- */
+int16_t WebRtcIsacfix_GetNewBitStream(ISACFIX_MainStruct* ISAC_main_inst,
+ int16_t bweIndex,
+ float scale,
+ uint8_t* encoded);
- int32_t WebRtcIsacfix_GetUplinkBw(ISACFIX_MainStruct *ISAC_main_inst);
+/****************************************************************************
+ * WebRtcIsacfix_GetDownLinkBwIndex(...)
+ *
+ * This function returns index representing the Bandwidth estimate from
+ * other side to this side.
+ *
+ * Input:
+ * - ISAC_main_inst : iSAC struct
+ *
+ * Output:
+ * - rateIndex : Bandwidth estimate to transmit to other side.
+ *
+ */
+int16_t WebRtcIsacfix_GetDownLinkBwIndex(ISACFIX_MainStruct* ISAC_main_inst,
+ int16_t* rateIndex);
- /****************************************************************************
- * WebRtcIsacfix_SetMaxPayloadSize(...)
- *
- * This function sets a limit for the maximum payload size of iSAC. The same
- * value is used both for 30 and 60 msec packets.
- * The absolute max will be valid until next time the function is called.
- * NOTE! This function may override the function WebRtcIsacfix_SetMaxRate()
- *
- * Input:
- * - ISAC_main_inst : iSAC instance
- * - maxPayloadBytes : maximum size of the payload in bytes
- * valid values are between 100 and 400 bytes
- *
- *
- * Return value : 0 if sucessful
- * -1 if error happens
- */
+/****************************************************************************
+ * WebRtcIsacfix_UpdateUplinkBw(...)
+ *
+ * This function takes an index representing the Bandwidth estimate from
+ * this side to other side and updates BWE.
+ *
+ * Input:
+ * - ISAC_main_inst : iSAC struct
+ * - rateIndex : Bandwidth estimate from other side.
+ *
+ */
- int16_t WebRtcIsacfix_SetMaxPayloadSize(ISACFIX_MainStruct *ISAC_main_inst,
- int16_t maxPayloadBytes);
+int16_t WebRtcIsacfix_UpdateUplinkBw(ISACFIX_MainStruct* ISAC_main_inst,
+ int16_t rateIndex);
+/****************************************************************************
+ * WebRtcIsacfix_ReadBwIndex(...)
+ *
+ * This function returns the index of the Bandwidth estimate from the bitstream.
+ *
+ * Input:
+ * - encoded : Encoded bitstream
+ * - encoded_len_bytes : Length of the bitstream in bytes.
+ *
+ * Output:
+ * - rateIndex : Bandwidth estimate in bitstream
+ *
+ */
- /****************************************************************************
- * WebRtcIsacfix_SetMaxRate(...)
- *
- * This function sets the maximum rate which the codec may not exceed for a
- * singel packet. The maximum rate is set in bits per second.
- * The codec has an absolute maximum rate of 53400 bits per second (200 bytes
- * per 30 msec).
- * It is possible to set a maximum rate between 32000 and 53400 bits per second.
- *
- * The rate limit is valid until next time the function is called.
- *
- * NOTE! Packet size will never go above the value set if calling
- * WebRtcIsacfix_SetMaxPayloadSize() (default max packet size is 400 bytes).
- *
- * Input:
- * - ISAC_main_inst : iSAC instance
- * - maxRateInBytes : maximum rate in bits per second,
- * valid values are 32000 to 53400 bits
- *
- * Return value : 0 if sucessful
- * -1 if error happens
- */
+int16_t WebRtcIsacfix_ReadBwIndex(const uint8_t* encoded,
+ size_t encoded_len_bytes,
+ int16_t* rateIndex);
- int16_t WebRtcIsacfix_SetMaxRate(ISACFIX_MainStruct *ISAC_main_inst,
- int32_t maxRate);
+/****************************************************************************
+ * WebRtcIsacfix_GetNewFrameLen(...)
+ *
+ * This function return the next frame length (in samples) of iSAC.
+ *
+ * Input:
+ * -ISAC_main_inst : iSAC instance
+ *
+ * Return value : frame lenght in samples
+ */
- /****************************************************************************
- * WebRtcIsacfix_CreateInternal(...)
- *
- * This function creates the memory that is used to store data in the encoder
- *
- * Input:
- * - *ISAC_main_inst : a pointer to the coder instance.
- *
- * Return value : 0 - Ok
- * -1 - Error
- */
+int16_t WebRtcIsacfix_GetNewFrameLen(ISACFIX_MainStruct* ISAC_main_inst);
- int16_t WebRtcIsacfix_CreateInternal(ISACFIX_MainStruct *ISAC_main_inst);
+/* Fills in an IsacBandwidthInfo struct. */
+void WebRtcIsacfix_GetBandwidthInfo(ISACFIX_MainStruct* ISAC_main_inst,
+ IsacBandwidthInfo* bwinfo);
-
- /****************************************************************************
- * WebRtcIsacfix_FreeInternal(...)
- *
- * This function frees the internal memory for storing encoder data.
- *
- * Input:
- * - ISAC_main_inst : an ISAC instance.
- *
- * Return value : 0 - Ok
- * -1 - Error
- */
-
- int16_t WebRtcIsacfix_FreeInternal(ISACFIX_MainStruct *ISAC_main_inst);
-
-
- /****************************************************************************
- * WebRtcIsacfix_GetNewBitStream(...)
- *
- * This function returns encoded data, with the recieved bwe-index in the
- * stream. It should always return a complete packet, i.e. only called once
- * even for 60 msec frames
- *
- * Input:
- * - ISAC_main_inst : ISAC instance.
- * - bweIndex : index of bandwidth estimate to put in new bitstream
- * - scale : factor for rate change (0.4 ~=> half the rate, 1 no change).
- *
- * Output:
- * - encoded : the encoded data vector
- *
- * Return value : >0 - Length (in bytes) of coded data
- * -1 - Error
- */
-
- int16_t WebRtcIsacfix_GetNewBitStream(ISACFIX_MainStruct *ISAC_main_inst,
- int16_t bweIndex,
- float scale,
- uint8_t* encoded);
-
-
- /****************************************************************************
- * WebRtcIsacfix_GetDownLinkBwIndex(...)
- *
- * This function returns index representing the Bandwidth estimate from
- * other side to this side.
- *
- * Input:
- * - ISAC_main_inst : iSAC struct
- *
- * Output:
- * - rateIndex : Bandwidth estimate to transmit to other side.
- *
- */
-
- int16_t WebRtcIsacfix_GetDownLinkBwIndex(ISACFIX_MainStruct* ISAC_main_inst,
- int16_t* rateIndex);
-
-
- /****************************************************************************
- * WebRtcIsacfix_UpdateUplinkBw(...)
- *
- * This function takes an index representing the Bandwidth estimate from
- * this side to other side and updates BWE.
- *
- * Input:
- * - ISAC_main_inst : iSAC struct
- * - rateIndex : Bandwidth estimate from other side.
- *
- */
-
- int16_t WebRtcIsacfix_UpdateUplinkBw(ISACFIX_MainStruct* ISAC_main_inst,
- int16_t rateIndex);
-
-
- /****************************************************************************
- * WebRtcIsacfix_ReadBwIndex(...)
- *
- * This function returns the index of the Bandwidth estimate from the bitstream.
- *
- * Input:
- * - encoded : Encoded bitstream
- * - encoded_len_bytes : Length of the bitstream in bytes.
- *
- * Output:
- * - rateIndex : Bandwidth estimate in bitstream
- *
- */
-
- int16_t WebRtcIsacfix_ReadBwIndex(const uint8_t* encoded,
- size_t encoded_len_bytes,
- int16_t* rateIndex);
-
-
- /****************************************************************************
- * WebRtcIsacfix_GetNewFrameLen(...)
- *
- * This function return the next frame length (in samples) of iSAC.
- *
- * Input:
- * -ISAC_main_inst : iSAC instance
- *
- * Return value : frame lenght in samples
- */
-
- int16_t WebRtcIsacfix_GetNewFrameLen(ISACFIX_MainStruct *ISAC_main_inst);
-
- /* Fills in an IsacBandwidthInfo struct. */
- void WebRtcIsacfix_GetBandwidthInfo(ISACFIX_MainStruct* ISAC_main_inst,
- IsacBandwidthInfo* bwinfo);
-
- /* Uses the values from an IsacBandwidthInfo struct. */
- void WebRtcIsacfix_SetBandwidthInfo(ISACFIX_MainStruct* ISAC_main_inst,
- const IsacBandwidthInfo* bwinfo);
+/* Uses the values from an IsacBandwidthInfo struct. */
+void WebRtcIsacfix_SetBandwidthInfo(ISACFIX_MainStruct* ISAC_main_inst,
+ const IsacBandwidthInfo* bwinfo);
#if defined(__cplusplus)
}
#endif
-
-
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_INCLUDE_ISACFIX_H_ */
diff --git a/modules/audio_coding/codecs/isac/fix/source/arith_routins.h b/modules/audio_coding/codecs/isac/fix/source/arith_routins.h
index 25eeecf..cc4ed55 100644
--- a/modules/audio_coding/codecs/isac/fix/source/arith_routins.h
+++ b/modules/audio_coding/codecs/isac/fix/source/arith_routins.h
@@ -35,12 +35,10 @@
* Return value : 0 if ok,
* <0 otherwise.
*/
-int WebRtcIsacfix_EncLogisticMulti2(
- Bitstr_enc *streamData,
- int16_t *dataQ7,
- const uint16_t *env,
- const int16_t lenData);
-
+int WebRtcIsacfix_EncLogisticMulti2(Bitstr_enc* streamData,
+ int16_t* dataQ7,
+ const uint16_t* env,
+ const int16_t lenData);
/****************************************************************************
* WebRtcIsacfix_EncTerminate(...)
@@ -53,8 +51,7 @@
*
* Return value : number of bytes in the stream
*/
-int16_t WebRtcIsacfix_EncTerminate(Bitstr_enc *streamData);
-
+int16_t WebRtcIsacfix_EncTerminate(Bitstr_enc* streamData);
/****************************************************************************
* WebRtcIsacfix_DecLogisticMulti2(...)
@@ -73,12 +70,10 @@
* Return value : number of bytes in the stream so far
* <0 if error detected
*/
-int WebRtcIsacfix_DecLogisticMulti2(
- int16_t *data,
- Bitstr_dec *streamData,
- const int32_t *env,
- const int16_t lenData);
-
+int WebRtcIsacfix_DecLogisticMulti2(int16_t* data,
+ Bitstr_dec* streamData,
+ const int32_t* env,
+ const int16_t lenData);
/****************************************************************************
* WebRtcIsacfix_EncHistMulti(...)
@@ -94,12 +89,10 @@
* Return value : 0 if ok
* <0 if error detected
*/
-int WebRtcIsacfix_EncHistMulti(
- Bitstr_enc *streamData,
- const int16_t *data,
- const uint16_t *const *cdf,
- const int16_t lenData);
-
+int WebRtcIsacfix_EncHistMulti(Bitstr_enc* streamData,
+ const int16_t* data,
+ const uint16_t* const* cdf,
+ const int16_t lenData);
/****************************************************************************
* WebRtcIsacfix_DecHistBisectMulti(...)
@@ -121,13 +114,11 @@
* Return value : number of bytes in the stream
* <0 if error detected
*/
-int16_t WebRtcIsacfix_DecHistBisectMulti(
- int16_t *data,
- Bitstr_dec *streamData,
- const uint16_t *const *cdf,
- const uint16_t *cdfSize,
- const int16_t lenData);
-
+int16_t WebRtcIsacfix_DecHistBisectMulti(int16_t* data,
+ Bitstr_dec* streamData,
+ const uint16_t* const* cdf,
+ const uint16_t* cdfSize,
+ const int16_t lenData);
/****************************************************************************
* WebRtcIsacfix_DecHistOneStepMulti(...)
@@ -149,11 +140,10 @@
* Return value : number of bytes in original stream
* <0 if error detected
*/
-int16_t WebRtcIsacfix_DecHistOneStepMulti(
- int16_t *data,
- Bitstr_dec *streamData,
- const uint16_t *const *cdf,
- const uint16_t *initIndex,
- const int16_t lenData);
+int16_t WebRtcIsacfix_DecHistOneStepMulti(int16_t* data,
+ Bitstr_dec* streamData,
+ const uint16_t* const* cdf,
+ const uint16_t* initIndex,
+ const int16_t lenData);
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_ARITH_ROUTINS_H_ */
diff --git a/modules/audio_coding/codecs/isac/fix/source/bandwidth_estimator.h b/modules/audio_coding/codecs/isac/fix/source/bandwidth_estimator.h
index 67f8d07..f8ac1ef 100644
--- a/modules/audio_coding/codecs/isac/fix/source/bandwidth_estimator.h
+++ b/modules/audio_coding/codecs/isac/fix/source/bandwidth_estimator.h
@@ -32,8 +32,7 @@
* Return value : 0
*/
-int32_t WebRtcIsacfix_InitBandwidthEstimator(BwEstimatorstr *bwest_str);
-
+int32_t WebRtcIsacfix_InitBandwidthEstimator(BwEstimatorstr* bwest_str);
/****************************************************************************
* WebRtcIsacfix_UpdateUplinkBwImpl(...)
@@ -56,16 +55,17 @@
* -1 otherwise
*/
-int32_t WebRtcIsacfix_UpdateUplinkBwImpl(BwEstimatorstr *bwest_str,
- const uint16_t rtp_number,
- const int16_t frameSize,
- const uint32_t send_ts,
- const uint32_t arr_ts,
- const size_t pksize,
- const uint16_t Index);
+int32_t WebRtcIsacfix_UpdateUplinkBwImpl(BwEstimatorstr* bwest_str,
+ const uint16_t rtp_number,
+ const int16_t frameSize,
+ const uint32_t send_ts,
+ const uint32_t arr_ts,
+ const size_t pksize,
+ const uint16_t Index);
-/* Update receiving estimates. Used when we only receive BWE index, no iSAC data packet. */
-int16_t WebRtcIsacfix_UpdateUplinkBwRec(BwEstimatorstr *bwest_str,
+/* Update receiving estimates. Used when we only receive BWE index, no iSAC data
+ * packet. */
+int16_t WebRtcIsacfix_UpdateUplinkBwRec(BwEstimatorstr* bwest_str,
const int16_t Index);
/****************************************************************************
@@ -80,19 +80,19 @@
* Return:
* bandwith and jitter index (0..23)
*/
-uint16_t WebRtcIsacfix_GetDownlinkBwIndexImpl(BwEstimatorstr *bwest_str);
+uint16_t WebRtcIsacfix_GetDownlinkBwIndexImpl(BwEstimatorstr* bwest_str);
/* Returns the bandwidth estimation (in bps) */
-uint16_t WebRtcIsacfix_GetDownlinkBandwidth(const BwEstimatorstr *bwest_str);
+uint16_t WebRtcIsacfix_GetDownlinkBandwidth(const BwEstimatorstr* bwest_str);
/* Returns the bandwidth that iSAC should send with in bps */
-int16_t WebRtcIsacfix_GetUplinkBandwidth(const BwEstimatorstr *bwest_str);
+int16_t WebRtcIsacfix_GetUplinkBandwidth(const BwEstimatorstr* bwest_str);
/* Returns the max delay (in ms) */
-int16_t WebRtcIsacfix_GetDownlinkMaxDelay(const BwEstimatorstr *bwest_str);
+int16_t WebRtcIsacfix_GetDownlinkMaxDelay(const BwEstimatorstr* bwest_str);
/* Returns the max delay value from the other side in ms */
-int16_t WebRtcIsacfix_GetUplinkMaxDelay(const BwEstimatorstr *bwest_str);
+int16_t WebRtcIsacfix_GetUplinkMaxDelay(const BwEstimatorstr* bwest_str);
/* Fills in an IsacExternalBandwidthInfo struct. */
void WebRtcIsacfixBw_GetBandwidthInfo(BwEstimatorstr* bwest_str,
@@ -106,29 +106,31 @@
* update amount of data in bottle neck buffer and burst handling
* returns minimum payload size (bytes)
*/
-uint16_t WebRtcIsacfix_GetMinBytes(RateModel *State,
- int16_t StreamSize, /* bytes in bitstream */
- const int16_t FrameLen, /* ms per frame */
- const int16_t BottleNeck, /* bottle neck rate; excl headers (bps) */
- const int16_t DelayBuildUp); /* max delay from bottle neck buffering (ms) */
+uint16_t WebRtcIsacfix_GetMinBytes(
+ RateModel* State,
+ int16_t StreamSize, /* bytes in bitstream */
+ const int16_t FrameLen, /* ms per frame */
+ const int16_t BottleNeck, /* bottle neck rate; excl headers (bps) */
+ const int16_t DelayBuildUp); /* max delay from bottle neck buffering (ms) */
/*
* update long-term average bitrate and amount of data in buffer
*/
-void WebRtcIsacfix_UpdateRateModel(RateModel *State,
- int16_t StreamSize, /* bytes in bitstream */
- const int16_t FrameSamples, /* samples per frame */
- const int16_t BottleNeck); /* bottle neck rate; excl headers (bps) */
+void WebRtcIsacfix_UpdateRateModel(
+ RateModel* State,
+ int16_t StreamSize, /* bytes in bitstream */
+ const int16_t FrameSamples, /* samples per frame */
+ const int16_t BottleNeck); /* bottle neck rate; excl headers (bps) */
-
-void WebRtcIsacfix_InitRateModel(RateModel *State);
+void WebRtcIsacfix_InitRateModel(RateModel* State);
/* Returns the new framelength value (input argument: bottle_neck) */
-int16_t WebRtcIsacfix_GetNewFrameLength(int16_t bottle_neck, int16_t current_framelength);
+int16_t WebRtcIsacfix_GetNewFrameLength(int16_t bottle_neck,
+ int16_t current_framelength);
/* Returns the new SNR value (input argument: bottle_neck) */
-//returns snr in Q10
+// returns snr in Q10
int16_t WebRtcIsacfix_GetSnr(int16_t bottle_neck, int16_t framesamples);
-
-#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_BANDWIDTH_ESTIMATOR_H_ */
+#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_BANDWIDTH_ESTIMATOR_H_ \
+ */
diff --git a/modules/audio_coding/codecs/isac/fix/source/codec.h b/modules/audio_coding/codecs/isac/fix/source/codec.h
index 9876bd6..c95b53f 100644
--- a/modules/audio_coding/codecs/isac/fix/source/codec.h
+++ b/modules/audio_coding/codecs/isac/fix/source/codec.h
@@ -38,7 +38,7 @@
void WebRtcIsacfix_DecodePlcImpl(int16_t* decoded,
IsacFixDecoderInstance* ISACdec_obj,
- size_t* current_framesample );
+ size_t* current_framesample);
int WebRtcIsacfix_EncodeImpl(int16_t* in,
IsacFixEncoderInstance* ISACenc_obj,
@@ -64,7 +64,6 @@
void WebRtcIsacfix_InitPlc(PLCstr* State);
-
/* transform functions */
void WebRtcIsacfix_InitTransform(void);
diff --git a/modules/audio_coding/codecs/isac/fix/source/entropy_coding.h b/modules/audio_coding/codecs/isac/fix/source/entropy_coding.h
index ba7bcde..b4251ce 100644
--- a/modules/audio_coding/codecs/isac/fix/source/entropy_coding.h
+++ b/modules/audio_coding/codecs/isac/fix/source/entropy_coding.h
@@ -22,91 +22,79 @@
#include "modules/audio_coding/codecs/isac/fix/source/structs.h"
/* decode complex spectrum (return number of bytes in stream) */
-int WebRtcIsacfix_DecodeSpec(Bitstr_dec *streamdata,
- int16_t *frQ7,
- int16_t *fiQ7,
+int WebRtcIsacfix_DecodeSpec(Bitstr_dec* streamdata,
+ int16_t* frQ7,
+ int16_t* fiQ7,
int16_t AvgPitchGain_Q12);
/* encode complex spectrum */
-int WebRtcIsacfix_EncodeSpec(const int16_t *fr,
- const int16_t *fi,
- Bitstr_enc *streamdata,
+int WebRtcIsacfix_EncodeSpec(const int16_t* fr,
+ const int16_t* fi,
+ Bitstr_enc* streamdata,
int16_t AvgPitchGain_Q12);
-
/* decode & dequantize LPC Coef */
-int WebRtcIsacfix_DecodeLpcCoef(Bitstr_dec *streamdata,
- int32_t *LPCCoefQ17,
- int32_t *gain_lo_hiQ17,
- int16_t *outmodel);
+int WebRtcIsacfix_DecodeLpcCoef(Bitstr_dec* streamdata,
+ int32_t* LPCCoefQ17,
+ int32_t* gain_lo_hiQ17,
+ int16_t* outmodel);
-int WebRtcIsacfix_DecodeLpc(int32_t *gain_lo_hiQ17,
- int16_t *LPCCoef_loQ15,
- int16_t *LPCCoef_hiQ15,
- Bitstr_dec *streamdata,
- int16_t *outmodel);
+int WebRtcIsacfix_DecodeLpc(int32_t* gain_lo_hiQ17,
+ int16_t* LPCCoef_loQ15,
+ int16_t* LPCCoef_hiQ15,
+ Bitstr_dec* streamdata,
+ int16_t* outmodel);
/* quantize & code LPC Coef */
-int WebRtcIsacfix_EncodeLpc(int32_t *gain_lo_hiQ17,
- int16_t *LPCCoef_loQ15,
- int16_t *LPCCoef_hiQ15,
- int16_t *model,
- int32_t *sizeQ11,
- Bitstr_enc *streamdata,
+int WebRtcIsacfix_EncodeLpc(int32_t* gain_lo_hiQ17,
+ int16_t* LPCCoef_loQ15,
+ int16_t* LPCCoef_hiQ15,
+ int16_t* model,
+ int32_t* sizeQ11,
+ Bitstr_enc* streamdata,
IsacSaveEncoderData* encData,
- transcode_obj *transcodeParam);
+ transcode_obj* transcodeParam);
-int WebRtcIsacfix_EstCodeLpcGain(int32_t *gain_lo_hiQ17,
- Bitstr_enc *streamdata,
+int WebRtcIsacfix_EstCodeLpcGain(int32_t* gain_lo_hiQ17,
+ Bitstr_enc* streamdata,
IsacSaveEncoderData* encData);
/* decode & dequantize RC */
-int WebRtcIsacfix_DecodeRcCoef(Bitstr_dec *streamdata,
- int16_t *RCQ15);
+int WebRtcIsacfix_DecodeRcCoef(Bitstr_dec* streamdata, int16_t* RCQ15);
/* quantize & code RC */
-int WebRtcIsacfix_EncodeRcCoef(int16_t *RCQ15,
- Bitstr_enc *streamdata);
+int WebRtcIsacfix_EncodeRcCoef(int16_t* RCQ15, Bitstr_enc* streamdata);
/* decode & dequantize squared Gain */
-int WebRtcIsacfix_DecodeGain2(Bitstr_dec *streamdata,
- int32_t *Gain2);
+int WebRtcIsacfix_DecodeGain2(Bitstr_dec* streamdata, int32_t* Gain2);
/* quantize & code squared Gain (input is squared gain) */
-int WebRtcIsacfix_EncodeGain2(int32_t *gain2,
- Bitstr_enc *streamdata);
+int WebRtcIsacfix_EncodeGain2(int32_t* gain2, Bitstr_enc* streamdata);
-int WebRtcIsacfix_EncodePitchGain(int16_t *PitchGains_Q12,
- Bitstr_enc *streamdata,
+int WebRtcIsacfix_EncodePitchGain(int16_t* PitchGains_Q12,
+ Bitstr_enc* streamdata,
IsacSaveEncoderData* encData);
-int WebRtcIsacfix_EncodePitchLag(int16_t *PitchLagQ7,
- int16_t *PitchGain_Q12,
- Bitstr_enc *streamdata,
+int WebRtcIsacfix_EncodePitchLag(int16_t* PitchLagQ7,
+ int16_t* PitchGain_Q12,
+ Bitstr_enc* streamdata,
IsacSaveEncoderData* encData);
-int WebRtcIsacfix_DecodePitchGain(Bitstr_dec *streamdata,
- int16_t *PitchGain_Q12);
+int WebRtcIsacfix_DecodePitchGain(Bitstr_dec* streamdata,
+ int16_t* PitchGain_Q12);
-int WebRtcIsacfix_DecodePitchLag(Bitstr_dec *streamdata,
- int16_t *PitchGain_Q12,
- int16_t *PitchLagQ7);
+int WebRtcIsacfix_DecodePitchLag(Bitstr_dec* streamdata,
+ int16_t* PitchGain_Q12,
+ int16_t* PitchLagQ7);
-int WebRtcIsacfix_DecodeFrameLen(Bitstr_dec *streamdata,
- size_t *framelength);
+int WebRtcIsacfix_DecodeFrameLen(Bitstr_dec* streamdata, size_t* framelength);
+int WebRtcIsacfix_EncodeFrameLen(int16_t framelength, Bitstr_enc* streamdata);
-int WebRtcIsacfix_EncodeFrameLen(int16_t framelength,
- Bitstr_enc *streamdata);
+int WebRtcIsacfix_DecodeSendBandwidth(Bitstr_dec* streamdata, int16_t* BWno);
-int WebRtcIsacfix_DecodeSendBandwidth(Bitstr_dec *streamdata,
- int16_t *BWno);
+int WebRtcIsacfix_EncodeReceiveBandwidth(int16_t* BWno, Bitstr_enc* streamdata);
-
-int WebRtcIsacfix_EncodeReceiveBandwidth(int16_t *BWno,
- Bitstr_enc *streamdata);
-
-void WebRtcIsacfix_TranscodeLpcCoef(int32_t *tmpcoeffs_gQ6,
- int16_t *index_gQQ);
+void WebRtcIsacfix_TranscodeLpcCoef(int32_t* tmpcoeffs_gQ6, int16_t* index_gQQ);
// Pointer functions for LPC transforms.
diff --git a/modules/audio_coding/codecs/isac/fix/source/fft.h b/modules/audio_coding/codecs/isac/fix/source/fft.h
index 61ec515..4fe9b96 100644
--- a/modules/audio_coding/codecs/isac/fix/source/fft.h
+++ b/modules/audio_coding/codecs/isac/fix/source/fft.h
@@ -32,8 +32,8 @@
#include "modules/audio_coding/codecs/isac/fix/source/structs.h"
-int16_t WebRtcIsacfix_FftRadix16Fastest(int16_t RexQx[], int16_t ImxQx[], int16_t iSign);
-
-
+int16_t WebRtcIsacfix_FftRadix16Fastest(int16_t RexQx[],
+ int16_t ImxQx[],
+ int16_t iSign);
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_FFT_H_ */
diff --git a/modules/audio_coding/codecs/isac/fix/source/filterbank_internal.h b/modules/audio_coding/codecs/isac/fix/source/filterbank_internal.h
index 1c34969..8d97347 100644
--- a/modules/audio_coding/codecs/isac/fix/source/filterbank_internal.h
+++ b/modules/audio_coding/codecs/isac/fix/source/filterbank_internal.h
@@ -42,44 +42,41 @@
#endif
typedef void (*AllpassFilter2FixDec16)(
- int16_t *data_ch1, // Input and output in channel 1, in Q0
- int16_t *data_ch2, // Input and output in channel 2, in Q0
- const int16_t *factor_ch1, // Scaling factor for channel 1, in Q15
- const int16_t *factor_ch2, // Scaling factor for channel 2, in Q15
+ int16_t* data_ch1, // Input and output in channel 1, in Q0
+ int16_t* data_ch2, // Input and output in channel 2, in Q0
+ const int16_t* factor_ch1, // Scaling factor for channel 1, in Q15
+ const int16_t* factor_ch2, // Scaling factor for channel 2, in Q15
const int length, // Length of the data buffers
- int32_t *filter_state_ch1, // Filter state for channel 1, in Q16
- int32_t *filter_state_ch2); // Filter state for channel 2, in Q16
+ int32_t* filter_state_ch1, // Filter state for channel 1, in Q16
+ int32_t* filter_state_ch2); // Filter state for channel 2, in Q16
extern AllpassFilter2FixDec16 WebRtcIsacfix_AllpassFilter2FixDec16;
-void WebRtcIsacfix_AllpassFilter2FixDec16C(
- int16_t *data_ch1,
- int16_t *data_ch2,
- const int16_t *factor_ch1,
- const int16_t *factor_ch2,
- const int length,
- int32_t *filter_state_ch1,
- int32_t *filter_state_ch2);
+void WebRtcIsacfix_AllpassFilter2FixDec16C(int16_t* data_ch1,
+ int16_t* data_ch2,
+ const int16_t* factor_ch1,
+ const int16_t* factor_ch2,
+ const int length,
+ int32_t* filter_state_ch1,
+ int32_t* filter_state_ch2);
#if defined(WEBRTC_HAS_NEON)
-void WebRtcIsacfix_AllpassFilter2FixDec16Neon(
- int16_t *data_ch1,
- int16_t *data_ch2,
- const int16_t *factor_ch1,
- const int16_t *factor_ch2,
- const int length,
- int32_t *filter_state_ch1,
- int32_t *filter_state_ch2);
+void WebRtcIsacfix_AllpassFilter2FixDec16Neon(int16_t* data_ch1,
+ int16_t* data_ch2,
+ const int16_t* factor_ch1,
+ const int16_t* factor_ch2,
+ const int length,
+ int32_t* filter_state_ch1,
+ int32_t* filter_state_ch2);
#endif
#if defined(MIPS_DSP_R1_LE)
-void WebRtcIsacfix_AllpassFilter2FixDec16MIPS(
- int16_t *data_ch1,
- int16_t *data_ch2,
- const int16_t *factor_ch1,
- const int16_t *factor_ch2,
- const int length,
- int32_t *filter_state_ch1,
- int32_t *filter_state_ch2);
+void WebRtcIsacfix_AllpassFilter2FixDec16MIPS(int16_t* data_ch1,
+ int16_t* data_ch2,
+ const int16_t* factor_ch1,
+ const int16_t* factor_ch2,
+ const int length,
+ int32_t* filter_state_ch1,
+ int32_t* filter_state_ch2);
#endif
#if defined(__cplusplus) || defined(c_plusplus)
diff --git a/modules/audio_coding/codecs/isac/fix/source/filterbanks_unittest.cc b/modules/audio_coding/codecs/isac/fix/source/filterbanks_unittest.cc
index d17f4a5..0727d58 100644
--- a/modules/audio_coding/codecs/isac/fix/source/filterbanks_unittest.cc
+++ b/modules/audio_coding/codecs/isac/fix/source/filterbanks_unittest.cc
@@ -21,8 +21,8 @@
protected:
// Pass a function pointer to the Tester function.
void RTC_NO_SANITIZE("signed-integer-overflow") // bugs.webrtc.org/5513
- CalculateResidualEnergyTester(AllpassFilter2FixDec16
- AllpassFilter2FixDec16Function) {
+ CalculateResidualEnergyTester(
+ AllpassFilter2FixDec16 AllpassFilter2FixDec16Function) {
const int kSamples = QLOOKAHEAD;
const int kState = 2;
int16_t data_ch1[kSamples] = {0};
@@ -31,12 +31,14 @@
int32_t state_ch2[kState] = {0};
const int32_t out_state_ch1[kState] = {-809122714, 1645972152};
const int32_t out_state_ch2[kState] = {428019288, 1057309936};
- const int32_t out_data_ch1[kSamples] = {0, 0, 347, 10618, 16718, -7089,
- 32767, 16913, 27042, 8377, -22973, -28372, -27603, -14804, 398, -25332,
- -11200, 18044, 25223, -6839, 1116, -23984, 32717, 7364};
- const int32_t out_data_ch2[kSamples] = {0, 0, 3010, 22351, 21106, 16969,
- -2095, -664, 3513, -30980, 32767, -23839, 13335, 20289, -6831, 339,
- -17207, 32767, 4959, 6177, 32767, 16599, -4747, 20504};
+ const int32_t out_data_ch1[kSamples] = {
+ 0, 0, 347, 10618, 16718, -7089, 32767, 16913,
+ 27042, 8377, -22973, -28372, -27603, -14804, 398, -25332,
+ -11200, 18044, 25223, -6839, 1116, -23984, 32717, 7364};
+ const int32_t out_data_ch2[kSamples] = {
+ 0, 0, 3010, 22351, 21106, 16969, -2095, -664,
+ 3513, -30980, 32767, -23839, 13335, 20289, -6831, 339,
+ -17207, 32767, 4959, 6177, 32767, 16599, -4747, 20504};
int sign = 1;
for (int i = 0; i < kSamples; i++) {
@@ -46,13 +48,9 @@
// UBSan: -1 * -2147483648 cannot be represented in type 'int'
};
- AllpassFilter2FixDec16Function(data_ch1,
- data_ch2,
- WebRtcIsacfix_kUpperApFactorsQ15,
- WebRtcIsacfix_kLowerApFactorsQ15,
- kSamples,
- state_ch1,
- state_ch2);
+ AllpassFilter2FixDec16Function(
+ data_ch1, data_ch2, WebRtcIsacfix_kUpperApFactorsQ15,
+ WebRtcIsacfix_kLowerApFactorsQ15, kSamples, state_ch1, state_ch2);
for (int i = 0; i < kSamples; i++) {
EXPECT_EQ(out_data_ch1[i], data_ch1[i]);
@@ -77,13 +75,13 @@
int16_t in[kSamples];
int32_t state[2] = {12345, 987654};
#ifdef WEBRTC_ARCH_ARM_V7
- int32_t out[kSamples] = {-1040, -1035, -22875, -1397, -27604, 20018, 7917,
- -1279, -8552, -14494, -7558, -23537, -27258, -30554, -32768, -3432, -32768,
- 25215, -27536, 22436};
+ int32_t out[kSamples] = {-1040, -1035, -22875, -1397, -27604, 20018, 7917,
+ -1279, -8552, -14494, -7558, -23537, -27258, -30554,
+ -32768, -3432, -32768, 25215, -27536, 22436};
#else
- int32_t out[kSamples] = {-1040, -1035, -22875, -1397, -27604, 20017, 7915,
- -1280, -8554, -14496, -7561, -23541, -27263, -30560, -32768, -3441, -32768,
- 25203, -27550, 22419};
+ int32_t out[kSamples] = {-1040, -1035, -22875, -1397, -27604, 20017, 7915,
+ -1280, -8554, -14496, -7561, -23541, -27263, -30560,
+ -32768, -3441, -32768, 25203, -27550, 22419};
#endif
HighpassFilterFixDec32 WebRtcIsacfix_HighpassFilterFixDec32;
#if defined(MIPS_DSP_R1_LE)
@@ -98,7 +96,7 @@
}
WebRtcIsacfix_HighpassFilterFixDec32(in, kSamples,
- WebRtcIsacfix_kHPStCoeffOut1Q30, state);
+ WebRtcIsacfix_kHPStCoeffOut1Q30, state);
for (int i = 0; i < kSamples; i++) {
EXPECT_EQ(out[i], in[i]);
diff --git a/modules/audio_coding/codecs/isac/fix/source/filters_unittest.cc b/modules/audio_coding/codecs/isac/fix/source/filters_unittest.cc
index fa52986..2ab8d6a 100644
--- a/modules/audio_coding/codecs/isac/fix/source/filters_unittest.cc
+++ b/modules/audio_coding/codecs/isac/fix/source/filters_unittest.cc
@@ -23,34 +23,37 @@
int32_t r_buffer[kOrder + 2] = {0};
// Test an overflow case.
- const int16_t x_buffer_0[kBuffer] = {0, 0, 3010, 22351, 21106, 16969, -2095,
- -664, 3513, -30980, 32767, -23839, 13335, 20289, -6831, 339, -17207,
- 32767, 4959, 6177, 32767, 16599, -4747, 20504, 3513, -30980, 32767,
- -23839, 13335, 20289, 0, -16969, -2095, -664, 3513, 31981, 32767,
- -13839, 23336, 30281};
- const int32_t r_expected_0[kOrder + 2] = {1872498461, -224288754, 203789985,
- 483400487, -208272635, 2436500, 137785322, 266600814, -208486262,
- 329510080, 137949184, -161738972, -26894267, 237630192};
+ const int16_t x_buffer_0[kBuffer] = {
+ 0, 0, 3010, 22351, 21106, 16969, -2095, -664,
+ 3513, -30980, 32767, -23839, 13335, 20289, -6831, 339,
+ -17207, 32767, 4959, 6177, 32767, 16599, -4747, 20504,
+ 3513, -30980, 32767, -23839, 13335, 20289, 0, -16969,
+ -2095, -664, 3513, 31981, 32767, -13839, 23336, 30281};
+ const int32_t r_expected_0[kOrder + 2] = {
+ 1872498461, -224288754, 203789985, 483400487, -208272635,
+ 2436500, 137785322, 266600814, -208486262, 329510080,
+ 137949184, -161738972, -26894267, 237630192};
- WebRtcIsacfix_AutocorrFixFunction(r_buffer, x_buffer_0,
- kBuffer, kOrder + 1, &scale);
+ WebRtcIsacfix_AutocorrFixFunction(r_buffer, x_buffer_0, kBuffer, kOrder + 1,
+ &scale);
for (int i = 0; i < kOrder + 2; i++) {
EXPECT_EQ(r_expected_0[i], r_buffer[i]);
}
EXPECT_EQ(3, scale);
// Test a no-overflow case.
- const int16_t x_buffer_1[kBuffer] = {0, 0, 300, 21, 206, 169, -295,
- -664, 3513, -300, 327, -29, 15, 289, -6831, 339, -107,
- 37, 59, 6177, 327, 169, -4747, 204, 313, -980, 767,
- -9, 135, 289, 0, -6969, -2095, -664, 0, 1, 7,
- -39, 236, 281};
- const int32_t r_expected_1[kOrder + 2] = {176253864, 8126617, 1983287,
- -26196788, -3487363, -42839676, -24644043, 3469813, 30559879, 31905045,
- 5101567, 29328896, -55787438, -13163978};
+ const int16_t x_buffer_1[kBuffer] = {
+ 0, 0, 300, 21, 206, 169, -295, -664, 3513, -300,
+ 327, -29, 15, 289, -6831, 339, -107, 37, 59, 6177,
+ 327, 169, -4747, 204, 313, -980, 767, -9, 135, 289,
+ 0, -6969, -2095, -664, 0, 1, 7, -39, 236, 281};
+ const int32_t r_expected_1[kOrder + 2] = {
+ 176253864, 8126617, 1983287, -26196788, -3487363,
+ -42839676, -24644043, 3469813, 30559879, 31905045,
+ 5101567, 29328896, -55787438, -13163978};
- WebRtcIsacfix_AutocorrFixFunction(r_buffer, x_buffer_1,
- kBuffer, kOrder + 1, &scale);
+ WebRtcIsacfix_AutocorrFixFunction(r_buffer, x_buffer_1, kBuffer, kOrder + 1,
+ &scale);
for (int i = 0; i < kOrder + 2; i++) {
EXPECT_EQ(r_expected_1[i], r_buffer[i]);
}
diff --git a/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model.h b/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model.h
index d6d1e8f..40a99e8 100644
--- a/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model.h
+++ b/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model.h
@@ -24,19 +24,19 @@
#include "modules/audio_coding/codecs/isac/fix/source/structs.h"
-void WebRtcIsacfix_GetVars(const int16_t *input,
- const int16_t *pitchGains_Q12,
- uint32_t *oldEnergy,
- int16_t *varscale);
+void WebRtcIsacfix_GetVars(const int16_t* input,
+ const int16_t* pitchGains_Q12,
+ uint32_t* oldEnergy,
+ int16_t* varscale);
-void WebRtcIsacfix_GetLpcCoef(int16_t *inLoQ0,
- int16_t *inHiQ0,
- MaskFiltstr_enc *maskdata,
+void WebRtcIsacfix_GetLpcCoef(int16_t* inLoQ0,
+ int16_t* inHiQ0,
+ MaskFiltstr_enc* maskdata,
int16_t snrQ10,
- const int16_t *pitchGains_Q12,
- int32_t *gain_lo_hiQ17,
- int16_t *lo_coeffQ15,
- int16_t *hi_coeffQ15);
+ const int16_t* pitchGains_Q12,
+ int32_t* gain_lo_hiQ17,
+ int16_t* lo_coeffQ15,
+ int16_t* hi_coeffQ15);
typedef int32_t (*CalculateResidualEnergy)(int lpc_order,
int32_t q_val_corr,
diff --git a/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model_unittest.cc b/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model_unittest.cc
index 1604cc4..dbcf420 100644
--- a/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model_unittest.cc
+++ b/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model_unittest.cc
@@ -16,21 +16,21 @@
class LpcMaskingModelTest : public testing::Test {
protected:
// Pass a function pointer to the Tester function.
- void CalculateResidualEnergyTester(CalculateResidualEnergy
- CalculateResidualEnergyFunction) {
+ void CalculateResidualEnergyTester(
+ CalculateResidualEnergy CalculateResidualEnergyFunction) {
const int kIntOrder = 10;
const int32_t kInt32QDomain = 5;
const int kIntShift = 11;
- int16_t a[kIntOrder + 1] = {32760, 122, 7, 0, -32760, -3958,
- -48, 18745, 498, 9, 23456};
- int32_t corr[kIntOrder + 1] = {11443647, -27495, 0,
- 98745, -11443600, 1, 1, 498, 9, 888, 23456};
+ int16_t a[kIntOrder + 1] = {32760, 122, 7, 0, -32760, -3958,
+ -48, 18745, 498, 9, 23456};
+ int32_t corr[kIntOrder + 1] = {11443647, -27495, 0, 98745, -11443600, 1,
+ 1, 498, 9, 888, 23456};
int q_shift_residual = 0;
int32_t residual_energy = 0;
// Test the code path where (residual_energy >= 0x10000).
- residual_energy = CalculateResidualEnergyFunction(kIntOrder,
- kInt32QDomain, kIntShift, a, corr, &q_shift_residual);
+ residual_energy = CalculateResidualEnergyFunction(
+ kIntOrder, kInt32QDomain, kIntShift, a, corr, &q_shift_residual);
EXPECT_EQ(1789023310, residual_energy);
EXPECT_EQ(2, q_shift_residual);
@@ -40,8 +40,8 @@
a[i] = 24575 >> i;
corr[i] = i;
}
- residual_energy = CalculateResidualEnergyFunction(kIntOrder,
- kInt32QDomain, kIntShift, a, corr, &q_shift_residual);
+ residual_energy = CalculateResidualEnergyFunction(
+ kIntOrder, kInt32QDomain, kIntShift, a, corr, &q_shift_residual);
EXPECT_EQ(1595279092, residual_energy);
EXPECT_EQ(26, q_shift_residual);
@@ -49,8 +49,8 @@
for (int i = 0; i < kIntOrder + 1; i++) {
a[i] = 2457 >> i;
}
- residual_energy = CalculateResidualEnergyFunction(kIntOrder,
- kInt32QDomain, kIntShift, a, corr, &q_shift_residual);
+ residual_energy = CalculateResidualEnergyFunction(
+ kIntOrder, kInt32QDomain, kIntShift, a, corr, &q_shift_residual);
EXPECT_EQ(2029266944, residual_energy);
EXPECT_EQ(33, q_shift_residual);
}
diff --git a/modules/audio_coding/codecs/isac/fix/source/lpc_tables.h b/modules/audio_coding/codecs/isac/fix/source/lpc_tables.h
index 05c53dd..c51f2ca 100644
--- a/modules/audio_coding/codecs/isac/fix/source/lpc_tables.h
+++ b/modules/audio_coding/codecs/isac/fix/source/lpc_tables.h
@@ -26,10 +26,10 @@
extern const uint16_t WebRtcIsacfix_kSelIndShape[108];
/* cdf array for model indicator */
-extern const uint16_t WebRtcIsacfix_kModelCdf[KLT_NUM_MODELS+1];
+extern const uint16_t WebRtcIsacfix_kModelCdf[KLT_NUM_MODELS + 1];
/* pointer to cdf array for model indicator */
-extern const uint16_t *WebRtcIsacfix_kModelCdfPtr[1];
+extern const uint16_t* WebRtcIsacfix_kModelCdfPtr[1];
/* initial cdf index for decoder of model indicator */
extern const uint16_t WebRtcIsacfix_kModelInitIndex[1];
@@ -70,9 +70,9 @@
extern const uint16_t WebRtcIsacfix_kCdfShape[2059];
/* pointers to cdf tables for quantizer indices */
-extern const uint16_t *WebRtcIsacfix_kCdfGainPtr[KLT_NUM_MODELS][12];
+extern const uint16_t* WebRtcIsacfix_kCdfGainPtr[KLT_NUM_MODELS][12];
-extern const uint16_t *WebRtcIsacfix_kCdfShapePtr[KLT_NUM_MODELS][108];
+extern const uint16_t* WebRtcIsacfix_kCdfShapePtr[KLT_NUM_MODELS][108];
/* code length for all coefficients using different models */
extern const int16_t WebRtcIsacfix_kCodeLenGainQ11[392];
diff --git a/modules/audio_coding/codecs/isac/fix/source/pitch_estimator.h b/modules/audio_coding/codecs/isac/fix/source/pitch_estimator.h
index 994cce7..4303c82 100644
--- a/modules/audio_coding/codecs/isac/fix/source/pitch_estimator.h
+++ b/modules/audio_coding/codecs/isac/fix/source/pitch_estimator.h
@@ -20,21 +20,22 @@
#include "modules/audio_coding/codecs/isac/fix/source/structs.h"
-void WebRtcIsacfix_PitchAnalysis(const int16_t *in, /* PITCH_FRAME_LEN samples */
- int16_t *outQ0, /* PITCH_FRAME_LEN+QLOOKAHEAD samples */
- PitchAnalysisStruct *State,
- int16_t *lagsQ7,
- int16_t *PitchGains_Q12);
+void WebRtcIsacfix_PitchAnalysis(
+ const int16_t* in, /* PITCH_FRAME_LEN samples */
+ int16_t* outQ0, /* PITCH_FRAME_LEN+QLOOKAHEAD samples */
+ PitchAnalysisStruct* State,
+ int16_t* lagsQ7,
+ int16_t* PitchGains_Q12);
-void WebRtcIsacfix_InitialPitch(const int16_t *in,
- PitchAnalysisStruct *State,
- int16_t *qlags);
+void WebRtcIsacfix_InitialPitch(const int16_t* in,
+ PitchAnalysisStruct* State,
+ int16_t* qlags);
-void WebRtcIsacfix_PitchFilter(int16_t *indatFix,
- int16_t *outdatQQ,
- PitchFiltstr *pfp,
- int16_t *lagsQ7,
- int16_t *gainsQ12,
+void WebRtcIsacfix_PitchFilter(int16_t* indatFix,
+ int16_t* outdatQQ,
+ PitchFiltstr* pfp,
+ int16_t* lagsQ7,
+ int16_t* gainsQ12,
int16_t type);
void WebRtcIsacfix_PitchFilterCore(int loopNumber,
@@ -48,17 +49,18 @@
int16_t* outputBuf,
int* index2);
-void WebRtcIsacfix_PitchFilterGains(const int16_t *indatQ0,
- PitchFiltstr *pfp,
- int16_t *lagsQ7,
- int16_t *gainsQ12);
+void WebRtcIsacfix_PitchFilterGains(const int16_t* indatQ0,
+ PitchFiltstr* pfp,
+ int16_t* lagsQ7,
+ int16_t* gainsQ12);
-void WebRtcIsacfix_DecimateAllpass32(const int16_t *in,
- int32_t *state_in, /* array of size: 2*ALLPASSSECTIONS+1 */
- int16_t N, /* number of input samples */
- int16_t *out); /* array of size N/2 */
+void WebRtcIsacfix_DecimateAllpass32(
+ const int16_t* in,
+ int32_t* state_in, /* array of size: 2*ALLPASSSECTIONS+1 */
+ int16_t N, /* number of input samples */
+ int16_t* out); /* array of size N/2 */
-int32_t WebRtcIsacfix_Log2Q8( uint32_t x );
+int32_t WebRtcIsacfix_Log2Q8(uint32_t x);
void WebRtcIsacfix_PCorr2Q32(const int16_t* in, int32_t* logcorQ8);
diff --git a/modules/audio_coding/codecs/isac/fix/source/pitch_gain_tables.h b/modules/audio_coding/codecs/isac/fix/source/pitch_gain_tables.h
index fe4d288..2b5f54e 100644
--- a/modules/audio_coding/codecs/isac/fix/source/pitch_gain_tables.h
+++ b/modules/audio_coding/codecs/isac/fix/source/pitch_gain_tables.h
@@ -11,7 +11,8 @@
/*
* pitch_gain_tables.h
*
- * This file contains tables for the pitch filter side-info in the entropy coder.
+ * This file contains tables for the pitch filter side-info in the entropy
+ * coder.
*
*/
@@ -20,7 +21,8 @@
#include "typedefs.h" // NOLINT(build/include)
-/********************* Pitch Filter Gain Coefficient Tables ************************/
+/********************* Pitch Filter Gain Coefficient Tables
+ * ************************/
/* cdf for quantized pitch filter gains */
extern const uint16_t WebRtcIsacfix_kPitchGainCdf[255];
diff --git a/modules/audio_coding/codecs/isac/fix/source/pitch_lag_tables.h b/modules/audio_coding/codecs/isac/fix/source/pitch_lag_tables.h
index a8c0c3a..f834eab 100644
--- a/modules/audio_coding/codecs/isac/fix/source/pitch_lag_tables.h
+++ b/modules/audio_coding/codecs/isac/fix/source/pitch_lag_tables.h
@@ -11,7 +11,8 @@
/*
* pitch_lag_tables.h
*
- * This file contains tables for the pitch filter side-info in the entropy coder.
+ * This file contains tables for the pitch filter side-info in the entropy
+ * coder.
*
*/
@@ -20,7 +21,8 @@
#include "typedefs.h" // NOLINT(build/include)
-/********************* Pitch Filter Lag Coefficient Tables ************************/
+/********************* Pitch Filter Lag Coefficient Tables
+ * ************************/
/* tables for use with small pitch gain */
@@ -30,7 +32,7 @@
extern const uint16_t WebRtcIsacfix_kPitchLagCdf3Lo[2];
extern const uint16_t WebRtcIsacfix_kPitchLagCdf4Lo[10];
-extern const uint16_t *WebRtcIsacfix_kPitchLagPtrLo[4];
+extern const uint16_t* WebRtcIsacfix_kPitchLagPtrLo[4];
/* size of first cdf table */
extern const uint16_t WebRtcIsacfix_kPitchLagSizeLo[1];
@@ -46,8 +48,6 @@
extern const int16_t WebRtcIsacfix_kMeanLag2Lo[19];
extern const int16_t WebRtcIsacfix_kMeanLag4Lo[9];
-
-
/* tables for use with medium pitch gain */
/* cdfs for quantized pitch lags */
@@ -56,7 +56,7 @@
extern const uint16_t WebRtcIsacfix_kPitchLagCdf3Mid[2];
extern const uint16_t WebRtcIsacfix_kPitchLagCdf4Mid[20];
-extern const uint16_t *WebRtcIsacfix_kPitchLagPtrMid[4];
+extern const uint16_t* WebRtcIsacfix_kPitchLagPtrMid[4];
/* size of first cdf table */
extern const uint16_t WebRtcIsacfix_kPitchLagSizeMid[1];
@@ -72,7 +72,6 @@
extern const int16_t WebRtcIsacfix_kMeanLag2Mid[35];
extern const int16_t WebRtcIsacfix_kMeanLag4Mid[19];
-
/* tables for use with large pitch gain */
/* cdfs for quantized pitch lags */
@@ -81,7 +80,7 @@
extern const uint16_t WebRtcIsacfix_kPitchLagCdf3Hi[2];
extern const uint16_t WebRtcIsacfix_kPitchLagCdf4Hi[35];
-extern const uint16_t *WebRtcIsacfix_kPitchLagPtrHi[4];
+extern const uint16_t* WebRtcIsacfix_kPitchLagPtrHi[4];
/* size of first cdf table */
extern const uint16_t WebRtcIsacfix_kPitchLagSizeHi[1];
@@ -97,5 +96,4 @@
extern const int16_t WebRtcIsacfix_kMeanLag2Hi[67];
extern const int16_t WebRtcIsacfix_kMeanLag4Hi[34];
-
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_PITCH_LAG_TABLES_H_ */
diff --git a/modules/audio_coding/codecs/isac/fix/source/settings.h b/modules/audio_coding/codecs/isac/fix/source/settings.h
index 34c0efe..03a2d05 100644
--- a/modules/audio_coding/codecs/isac/fix/source/settings.h
+++ b/modules/audio_coding/codecs/isac/fix/source/settings.h
@@ -18,84 +18,82 @@
#ifndef MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_SETTINGS_H_
#define MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_SETTINGS_H_
-
/* sampling frequency (Hz) */
-#define FS 16000
+#define FS 16000
/* 1.5 times Sampling frequency */
-#define FS_1_HALF (uint32_t) 24000
+#define FS_1_HALF (uint32_t)24000
/* Three times Sampling frequency */
-#define FS3 (uint32_t) 48000
+#define FS3 (uint32_t)48000
/* Eight times Sampling frequency */
-#define FS8 (uint32_t) 128000
+#define FS8 (uint32_t)128000
/* number of samples per frame (either 480 (30ms) or 960 (60ms)) */
-#define INITIAL_FRAMESAMPLES 960
+#define INITIAL_FRAMESAMPLES 960
/* miliseconds */
-#define FRAMESIZE 30
+#define FRAMESIZE 30
/* number of samples per frame processed in the encoder (30ms) */
-#define FRAMESAMPLES 480 /* ((FRAMESIZE*FS)/1000) */
-#define FRAMESAMPLES_HALF 240
+#define FRAMESAMPLES 480 /* ((FRAMESIZE*FS)/1000) */
+#define FRAMESAMPLES_HALF 240
/* max number of samples per frame (= 60 ms frame) */
-#define MAX_FRAMESAMPLES 960
+#define MAX_FRAMESAMPLES 960
/* number of samples per 10ms frame */
-#define FRAMESAMPLES_10ms 160 /* ((10*FS)/1000) */
+#define FRAMESAMPLES_10ms 160 /* ((10*FS)/1000) */
/* Number of samples per 1 ms */
-#define SAMPLES_PER_MSEC 16
+#define SAMPLES_PER_MSEC 16
/* number of subframes */
-#define SUBFRAMES 6
+#define SUBFRAMES 6
/* length of a subframe */
-#define UPDATE 80
+#define UPDATE 80
/* length of half a subframe (low/high band) */
-#define HALF_SUBFRAMELEN 40 /* (UPDATE/2) */
-/* samples of look ahead (in a half-band, so actually half the samples of look ahead @ FS) */
-#define QLOOKAHEAD 24 /* 3 ms */
+#define HALF_SUBFRAMELEN 40 /* (UPDATE/2) */
+/* samples of look ahead (in a half-band, so actually half the samples of look
+ * ahead @ FS) */
+#define QLOOKAHEAD 24 /* 3 ms */
/* order of AR model in spectral entropy coder */
-#define AR_ORDER 6
-#define MAX_ORDER 13
-#define LEVINSON_MAX_ORDER 12
+#define AR_ORDER 6
+#define MAX_ORDER 13
+#define LEVINSON_MAX_ORDER 12
/* window length (masking analysis) */
-#define WINLEN 256
+#define WINLEN 256
/* order of low-band pole filter used to approximate masking curve */
-#define ORDERLO 12
+#define ORDERLO 12
/* order of hi-band pole filter used to approximate masking curve */
-#define ORDERHI 6
+#define ORDERHI 6
-#define KLT_NUM_AVG_GAIN 0
-#define KLT_NUM_AVG_SHAPE 0
-#define KLT_NUM_MODELS 3
-#define LPC_SHAPE_ORDER 18 /* (ORDERLO + ORDERHI) */
+#define KLT_NUM_AVG_GAIN 0
+#define KLT_NUM_AVG_SHAPE 0
+#define KLT_NUM_MODELS 3
+#define LPC_SHAPE_ORDER 18 /* (ORDERLO + ORDERHI) */
-#define KLT_ORDER_GAIN 12 /* (2 * SUBFRAMES) */
-#define KLT_ORDER_SHAPE 108 /* (LPC_SHAPE_ORDER * SUBFRAMES) */
-
-
+#define KLT_ORDER_GAIN 12 /* (2 * SUBFRAMES) */
+#define KLT_ORDER_SHAPE 108 /* (LPC_SHAPE_ORDER * SUBFRAMES) */
/* order for post_filter_bank */
-#define POSTQORDER 3
+#define POSTQORDER 3
/* order for pre-filterbank */
-#define QORDER 3
+#define QORDER 3
/* for decimator */
-#define ALLPASSSECTIONS 2
+#define ALLPASSSECTIONS 2
/* The number of composite all-pass filter factors */
-#define NUMBEROFCOMPOSITEAPSECTIONS 4
+#define NUMBEROFCOMPOSITEAPSECTIONS 4
/* The number of all-pass filter factors in an upper or lower channel*/
-#define NUMBEROFCHANNELAPSECTIONS 2
+#define NUMBEROFCHANNELAPSECTIONS 2
-
-
-#define DPMIN_Q10 -10240 /* -10.00 in Q10 */
-#define DPMAX_Q10 10240 /* 10.00 in Q10 */
-#define MINBITS_Q10 10240 /* 10.0 in Q10 */
-
+#define DPMIN_Q10 -10240 /* -10.00 in Q10 */
+#define DPMAX_Q10 10240 /* 10.00 in Q10 */
+#define MINBITS_Q10 10240 /* 10.0 in Q10 */
/* array size for byte stream in number of Word16. */
-#define STREAM_MAXW16 300 /* The old maximum size still needed for the decoding */
-#define STREAM_MAXW16_30MS 100 /* 100 Word16 = 200 bytes = 53.4 kbit/s @ 30 ms.framelength */
-#define STREAM_MAXW16_60MS 200 /* 200 Word16 = 400 bytes = 53.4 kbit/s @ 60 ms.framelength */
+#define STREAM_MAXW16 \
+ 300 /* The old maximum size still needed for the decoding */
+#define STREAM_MAXW16_30MS \
+ 100 /* 100 Word16 = 200 bytes = 53.4 kbit/s @ 30 ms.framelength */
+#define STREAM_MAXW16_60MS \
+ 200 /* 200 Word16 = 400 bytes = 53.4 kbit/s @ 60 ms.framelength */
/* This is used only at the decoder bit-stream struct.
* - The encoder and decoder bitstream containers are of different size because
* old iSAC limited the encoded bitstream to 600 bytes. But newer versions
@@ -110,106 +108,104 @@
/* storage size for bit counts */
//#define BIT_COUNTER_SIZE 30
/* maximum order of any AR model or filter */
-#define MAX_AR_MODEL_ORDER 12
+#define MAX_AR_MODEL_ORDER 12
/* Maximum number of iterations allowed to limit payload size */
-#define MAX_PAYLOAD_LIMIT_ITERATION 1
+#define MAX_PAYLOAD_LIMIT_ITERATION 1
/* Bandwidth estimator */
-#define MIN_ISAC_BW 10000 /* Minimum bandwidth in bits per sec */
-#define MAX_ISAC_BW 32000 /* Maxmum bandwidth in bits per sec */
-#define MIN_ISAC_MD 5 /* Minimum Max Delay in ?? */
-#define MAX_ISAC_MD 25 /* Maxmum Max Delay in ?? */
-#define DELAY_CORRECTION_MAX 717
-#define DELAY_CORRECTION_MED 819
-#define Thld_30_60 18000
-#define Thld_60_30 27000
+#define MIN_ISAC_BW 10000 /* Minimum bandwidth in bits per sec */
+#define MAX_ISAC_BW 32000 /* Maxmum bandwidth in bits per sec */
+#define MIN_ISAC_MD 5 /* Minimum Max Delay in ?? */
+#define MAX_ISAC_MD 25 /* Maxmum Max Delay in ?? */
+#define DELAY_CORRECTION_MAX 717
+#define DELAY_CORRECTION_MED 819
+#define Thld_30_60 18000
+#define Thld_60_30 27000
-/* assumed header size; we don't know the exact number (header compression may be used) */
-#define HEADER_SIZE 35 /* bytes */
-#define INIT_FRAME_LEN 60
-#define INIT_BN_EST 20000
-#define INIT_BN_EST_Q7 2560000 /* 20 kbps in Q7 */
-#define INIT_REC_BN_EST_Q5 789312 /* INIT_BN_EST + INIT_HDR_RATE in Q5 */
+/* assumed header size; we don't know the exact number (header compression may
+ * be used) */
+#define HEADER_SIZE 35 /* bytes */
+#define INIT_FRAME_LEN 60
+#define INIT_BN_EST 20000
+#define INIT_BN_EST_Q7 2560000 /* 20 kbps in Q7 */
+#define INIT_REC_BN_EST_Q5 789312 /* INIT_BN_EST + INIT_HDR_RATE in Q5 */
/* 8738 in Q18 is ~ 1/30 */
-/* #define INIT_HDR_RATE (((HEADER_SIZE * 8 * 1000) * 8738) >> NUM_BITS_TO_SHIFT (INIT_FRAME_LEN)) */
-#define INIT_HDR_RATE 4666
+/* #define INIT_HDR_RATE (((HEADER_SIZE * 8 * 1000) * 8738) >> NUM_BITS_TO_SHIFT
+ * (INIT_FRAME_LEN)) */
+#define INIT_HDR_RATE 4666
/* number of packets in a row for a high rate burst */
-#define BURST_LEN 3
+#define BURST_LEN 3
/* ms, max time between two full bursts */
-#define BURST_INTERVAL 800
+#define BURST_INTERVAL 800
/* number of packets in a row for initial high rate burst */
-#define INIT_BURST_LEN 5
+#define INIT_BURST_LEN 5
/* bits/s, rate for the first BURST_LEN packets */
-#define INIT_RATE 10240000 /* INIT_BN_EST in Q9 */
-
+#define INIT_RATE 10240000 /* INIT_BN_EST in Q9 */
/* For pitch analysis */
-#define PITCH_FRAME_LEN 240 /* (FRAMESAMPLES/2) 30 ms */
-#define PITCH_MAX_LAG 140 /* 57 Hz */
-#define PITCH_MIN_LAG 20 /* 400 Hz */
-#define PITCH_MIN_LAG_Q8 5120 /* 256 * PITCH_MIN_LAG */
-#define OFFSET_Q8 768 /* 256 * 3 */
+#define PITCH_FRAME_LEN 240 /* (FRAMESAMPLES/2) 30 ms */
+#define PITCH_MAX_LAG 140 /* 57 Hz */
+#define PITCH_MIN_LAG 20 /* 400 Hz */
+#define PITCH_MIN_LAG_Q8 5120 /* 256 * PITCH_MIN_LAG */
+#define OFFSET_Q8 768 /* 256 * 3 */
-#define PITCH_MAX_GAIN_Q12 1843 /* 0.45 */
-#define PITCH_LAG_SPAN2 65 /* (PITCH_MAX_LAG/2-PITCH_MIN_LAG/2+5) */
-#define PITCH_CORR_LEN2 60 /* 15 ms */
-#define PITCH_CORR_STEP2 60 /* (PITCH_FRAME_LEN/4) */
-#define PITCH_SUBFRAMES 4
-#define PITCH_SUBFRAME_LEN 60 /* (PITCH_FRAME_LEN/PITCH_SUBFRAMES) */
+#define PITCH_MAX_GAIN_Q12 1843 /* 0.45 */
+#define PITCH_LAG_SPAN2 65 /* (PITCH_MAX_LAG/2-PITCH_MIN_LAG/2+5) */
+#define PITCH_CORR_LEN2 60 /* 15 ms */
+#define PITCH_CORR_STEP2 60 /* (PITCH_FRAME_LEN/4) */
+#define PITCH_SUBFRAMES 4
+#define PITCH_SUBFRAME_LEN 60 /* (PITCH_FRAME_LEN/PITCH_SUBFRAMES) */
/* For pitch filter */
-#define PITCH_BUFFSIZE 190 /* (PITCH_MAX_LAG + 50) Extra 50 for fraction and LP filters */
-#define PITCH_INTBUFFSIZE 430 /* (PITCH_FRAME_LEN+PITCH_BUFFSIZE) */
-#define PITCH_FRACS 8
-#define PITCH_FRACORDER 9
-#define PITCH_DAMPORDER 5
-
+#define PITCH_BUFFSIZE \
+ 190 /* (PITCH_MAX_LAG + 50) Extra 50 for fraction and LP filters */
+#define PITCH_INTBUFFSIZE 430 /* (PITCH_FRAME_LEN+PITCH_BUFFSIZE) */
+#define PITCH_FRACS 8
+#define PITCH_FRACORDER 9
+#define PITCH_DAMPORDER 5
/* Order of high pass filter */
-#define HPORDER 2
-
+#define HPORDER 2
/* PLC */
-#define DECAY_RATE 10 /* Q15, 20% of decay every lost frame apllied linearly sample by sample*/
-#define PLC_WAS_USED 1
-#define PLC_NOT_USED 3
-#define RECOVERY_OVERLAP 80
-#define RESAMP_RES 256
-#define RESAMP_RES_BIT 8
-
-
+#define DECAY_RATE \
+ 10 /* Q15, 20% of decay every lost frame apllied linearly sample by sample*/
+#define PLC_WAS_USED 1
+#define PLC_NOT_USED 3
+#define RECOVERY_OVERLAP 80
+#define RESAMP_RES 256
+#define RESAMP_RES_BIT 8
/* Define Error codes */
/* 6000 General */
-#define ISAC_MEMORY_ALLOCATION_FAILED 6010
-#define ISAC_MODE_MISMATCH 6020
-#define ISAC_DISALLOWED_BOTTLENECK 6030
-#define ISAC_DISALLOWED_FRAME_LENGTH 6040
+#define ISAC_MEMORY_ALLOCATION_FAILED 6010
+#define ISAC_MODE_MISMATCH 6020
+#define ISAC_DISALLOWED_BOTTLENECK 6030
+#define ISAC_DISALLOWED_FRAME_LENGTH 6040
/* 6200 Bandwidth estimator */
-#define ISAC_RANGE_ERROR_BW_ESTIMATOR 6240
+#define ISAC_RANGE_ERROR_BW_ESTIMATOR 6240
/* 6400 Encoder */
-#define ISAC_ENCODER_NOT_INITIATED 6410
-#define ISAC_DISALLOWED_CODING_MODE 6420
-#define ISAC_DISALLOWED_FRAME_MODE_ENCODER 6430
-#define ISAC_DISALLOWED_BITSTREAM_LENGTH 6440
-#define ISAC_PAYLOAD_LARGER_THAN_LIMIT 6450
+#define ISAC_ENCODER_NOT_INITIATED 6410
+#define ISAC_DISALLOWED_CODING_MODE 6420
+#define ISAC_DISALLOWED_FRAME_MODE_ENCODER 6430
+#define ISAC_DISALLOWED_BITSTREAM_LENGTH 6440
+#define ISAC_PAYLOAD_LARGER_THAN_LIMIT 6450
/* 6600 Decoder */
-#define ISAC_DECODER_NOT_INITIATED 6610
-#define ISAC_EMPTY_PACKET 6620
+#define ISAC_DECODER_NOT_INITIATED 6610
+#define ISAC_EMPTY_PACKET 6620
#define ISAC_PACKET_TOO_SHORT 6625
-#define ISAC_DISALLOWED_FRAME_MODE_DECODER 6630
-#define ISAC_RANGE_ERROR_DECODE_FRAME_LENGTH 6640
-#define ISAC_RANGE_ERROR_DECODE_BANDWIDTH 6650
-#define ISAC_RANGE_ERROR_DECODE_PITCH_GAIN 6660
-#define ISAC_RANGE_ERROR_DECODE_PITCH_LAG 6670
-#define ISAC_RANGE_ERROR_DECODE_LPC 6680
-#define ISAC_RANGE_ERROR_DECODE_SPECTRUM 6690
-#define ISAC_LENGTH_MISMATCH 6730
+#define ISAC_DISALLOWED_FRAME_MODE_DECODER 6630
+#define ISAC_RANGE_ERROR_DECODE_FRAME_LENGTH 6640
+#define ISAC_RANGE_ERROR_DECODE_BANDWIDTH 6650
+#define ISAC_RANGE_ERROR_DECODE_PITCH_GAIN 6660
+#define ISAC_RANGE_ERROR_DECODE_PITCH_LAG 6670
+#define ISAC_RANGE_ERROR_DECODE_LPC 6680
+#define ISAC_RANGE_ERROR_DECODE_SPECTRUM 6690
+#define ISAC_LENGTH_MISMATCH 6730
/* 6800 Call setup formats */
-#define ISAC_INCOMPATIBLE_FORMATS 6810
-
+#define ISAC_INCOMPATIBLE_FORMATS 6810
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_SETTINGS_H_ */
diff --git a/modules/audio_coding/codecs/isac/fix/source/spectrum_ar_model_tables.h b/modules/audio_coding/codecs/isac/fix/source/spectrum_ar_model_tables.h
index 04fddf5..4ac5c0b 100644
--- a/modules/audio_coding/codecs/isac/fix/source/spectrum_ar_model_tables.h
+++ b/modules/audio_coding/codecs/isac/fix/source/spectrum_ar_model_tables.h
@@ -62,15 +62,15 @@
/* quantization boundary levels for reflection coefficients */
extern const int16_t WebRtcIsacfix_kRcBound[12];
-/* initial indices for AR reflection coefficient quantizer and cdf table search */
+/* initial indices for AR reflection coefficient quantizer and cdf table search
+ */
extern const uint16_t WebRtcIsacfix_kRcInitInd[AR_ORDER];
/* pointers to AR cdf tables */
-extern const uint16_t *WebRtcIsacfix_kRcCdfPtr[AR_ORDER];
+extern const uint16_t* WebRtcIsacfix_kRcCdfPtr[AR_ORDER];
/* pointers to AR representation levels tables */
-extern const int16_t *WebRtcIsacfix_kRcLevPtr[AR_ORDER];
-
+extern const int16_t* WebRtcIsacfix_kRcLevPtr[AR_ORDER];
/******************** GAIN Coefficient Tables ***********************/
/* cdf for Gain coefficient */
@@ -83,7 +83,7 @@
extern const int32_t WebRtcIsacfix_kGain2Bound[19];
/* pointer to Gain cdf table */
-extern const uint16_t *WebRtcIsacfix_kGainPtr[1];
+extern const uint16_t* WebRtcIsacfix_kGainPtr[1];
/* Gain initial index for gain quantizer and cdf table search */
extern const uint16_t WebRtcIsacfix_kGainInitInd[1];
@@ -92,4 +92,5 @@
/* Cosine table */
extern const int16_t WebRtcIsacfix_kCos[6][60];
-#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_SPECTRUM_AR_MODEL_TABLES_H_ */
+#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_SPECTRUM_AR_MODEL_TABLES_H_ \
+ */
diff --git a/modules/audio_coding/codecs/isac/fix/source/structs.h b/modules/audio_coding/codecs/isac/fix/source/structs.h
index 7a14e5c..352eef0 100644
--- a/modules/audio_coding/codecs/isac/fix/source/structs.h
+++ b/modules/audio_coding/codecs/isac/fix/source/structs.h
@@ -18,7 +18,6 @@
#ifndef MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_STRUCTS_H_
#define MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_STRUCTS_H_
-
#include "common_audio/signal_processing/include/signal_processing_library.h"
#include "modules/audio_coding/codecs/isac/bandwidth_info.h"
#include "modules/audio_coding/codecs/isac/fix/source/settings.h"
@@ -26,72 +25,58 @@
/* Bitstream struct for decoder */
typedef struct Bitstreamstruct_dec {
-
- uint16_t stream[INTERNAL_STREAM_SIZE_W16]; /* Array bytestream to decode */
- uint32_t W_upper; /* Upper boundary of interval W */
- uint32_t streamval;
- uint16_t stream_index; /* Index to the current position in bytestream */
- int16_t full; /* 0 - first byte in memory filled, second empty*/
+ uint16_t stream[INTERNAL_STREAM_SIZE_W16]; /* Array bytestream to decode */
+ uint32_t W_upper; /* Upper boundary of interval W */
+ uint32_t streamval;
+ uint16_t stream_index; /* Index to the current position in bytestream */
+ int16_t full; /* 0 - first byte in memory filled, second empty*/
/* 1 - both bytes are empty (we just filled the previous memory */
- size_t stream_size; /* The size of stream in bytes. */
+ size_t stream_size; /* The size of stream in bytes. */
} Bitstr_dec;
/* Bitstream struct for encoder */
typedef struct Bitstreamstruct_enc {
-
- uint16_t stream[STREAM_MAXW16_60MS]; /* Vector for adding encoded bytestream */
- uint32_t W_upper; /* Upper boundary of interval W */
- uint32_t streamval;
- uint16_t stream_index; /* Index to the current position in bytestream */
- int16_t full; /* 0 - first byte in memory filled, second empty*/
+ uint16_t
+ stream[STREAM_MAXW16_60MS]; /* Vector for adding encoded bytestream */
+ uint32_t W_upper; /* Upper boundary of interval W */
+ uint32_t streamval;
+ uint16_t stream_index; /* Index to the current position in bytestream */
+ int16_t full; /* 0 - first byte in memory filled, second empty*/
/* 1 - both bytes are empty (we just filled the previous memory */
} Bitstr_enc;
-
typedef struct {
-
int16_t DataBufferLoQ0[WINLEN];
int16_t DataBufferHiQ0[WINLEN];
- int32_t CorrBufLoQQ[ORDERLO+1];
- int32_t CorrBufHiQQ[ORDERHI+1];
+ int32_t CorrBufLoQQ[ORDERLO + 1];
+ int32_t CorrBufHiQQ[ORDERHI + 1];
- int16_t CorrBufLoQdom[ORDERLO+1];
- int16_t CorrBufHiQdom[ORDERHI+1];
+ int16_t CorrBufLoQdom[ORDERLO + 1];
+ int16_t CorrBufHiQdom[ORDERHI + 1];
- int32_t PreStateLoGQ15[ORDERLO+1];
- int32_t PreStateHiGQ15[ORDERHI+1];
+ int32_t PreStateLoGQ15[ORDERLO + 1];
+ int32_t PreStateHiGQ15[ORDERHI + 1];
uint32_t OldEnergy;
} MaskFiltstr_enc;
-
-
typedef struct {
-
- int16_t PostStateLoGQ0[ORDERLO+1];
- int16_t PostStateHiGQ0[ORDERHI+1];
+ int16_t PostStateLoGQ0[ORDERLO + 1];
+ int16_t PostStateHiGQ0[ORDERHI + 1];
uint32_t OldEnergy;
} MaskFiltstr_dec;
-
-
-
-
-
-
-
typedef struct {
+ // state vectors for each of the two analysis filters
- //state vectors for each of the two analysis filters
-
- int32_t INSTAT1_fix[2*(QORDER-1)];
- int32_t INSTAT2_fix[2*(QORDER-1)];
+ int32_t INSTAT1_fix[2 * (QORDER - 1)];
+ int32_t INSTAT2_fix[2 * (QORDER - 1)];
int16_t INLABUF1_fix[QLOOKAHEAD];
int16_t INLABUF2_fix[QLOOKAHEAD];
@@ -100,12 +85,10 @@
} PreFiltBankstr;
-
typedef struct {
-
- //state vectors for each of the two analysis filters
- int32_t STATE_0_LOWER_fix[2*POSTQORDER];
- int32_t STATE_0_UPPER_fix[2*POSTQORDER];
+ // state vectors for each of the two analysis filters
+ int32_t STATE_0_LOWER_fix[2 * POSTQORDER];
+ int32_t STATE_0_UPPER_fix[2 * POSTQORDER];
/* High pass filter */
@@ -115,8 +98,6 @@
} PostFiltBankstr;
typedef struct {
-
-
/* data buffer for pitch filter */
int16_t ubufQQ[PITCH_BUFFSIZE];
@@ -129,42 +110,35 @@
} PitchFiltstr;
-
-
typedef struct {
+ // for inital estimator
+ int16_t dec_buffer16[PITCH_CORR_LEN2 + PITCH_CORR_STEP2 + PITCH_MAX_LAG / 2 -
+ PITCH_FRAME_LEN / 2 + 2];
+ int32_t decimator_state32[2 * ALLPASSSECTIONS + 1];
+ int16_t inbuf[QLOOKAHEAD];
- //for inital estimator
- int16_t dec_buffer16[PITCH_CORR_LEN2+PITCH_CORR_STEP2+PITCH_MAX_LAG/2-PITCH_FRAME_LEN/2+2];
- int32_t decimator_state32[2*ALLPASSSECTIONS+1];
- int16_t inbuf[QLOOKAHEAD];
-
- PitchFiltstr PFstr_wght;
- PitchFiltstr PFstr;
-
+ PitchFiltstr PFstr_wght;
+ PitchFiltstr PFstr;
} PitchAnalysisStruct;
-
typedef struct {
/* Parameters used in PLC to avoid re-computation */
/* --- residual signals --- */
- int16_t prevPitchInvIn[FRAMESAMPLES/2];
- int16_t prevPitchInvOut[PITCH_MAX_LAG + 10]; // [FRAMESAMPLES/2]; save 90
- int32_t prevHP[PITCH_MAX_LAG + 10]; // [FRAMESAMPLES/2]; save 90
-
+ int16_t prevPitchInvIn[FRAMESAMPLES / 2];
+ int16_t prevPitchInvOut[PITCH_MAX_LAG + 10]; // [FRAMESAMPLES/2]; save 90
+ int32_t prevHP[PITCH_MAX_LAG + 10]; // [FRAMESAMPLES/2]; save 90
int16_t decayCoeffPriodic; /* how much to supress a sample */
int16_t decayCoeffNoise;
- int16_t used; /* if PLC is used */
+ int16_t used; /* if PLC is used */
-
- int16_t *lastPitchLP; // [FRAMESAMPLES/2]; saved 240;
-
+ int16_t* lastPitchLP; // [FRAMESAMPLES/2]; saved 240;
/* --- LPC side info --- */
- int16_t lofilt_coefQ15[ ORDERLO ];
- int16_t hifilt_coefQ15[ ORDERHI ];
+ int16_t lofilt_coefQ15[ORDERLO];
+ int16_t hifilt_coefQ15[ORDERHI];
int32_t gain_lo_hiQ17[2];
/* --- LTP side info --- */
@@ -173,95 +147,101 @@
int16_t lastPitchLag_Q7;
/* --- Add-overlap in recovery packet --- */
- int16_t overlapLP[ RECOVERY_OVERLAP ]; // [FRAMESAMPLES/2]; saved 160
+ int16_t overlapLP[RECOVERY_OVERLAP]; // [FRAMESAMPLES/2]; saved 160
int16_t pitchCycles;
int16_t A;
int16_t B;
size_t pitchIndex;
size_t stretchLag;
- int16_t *prevPitchLP; // [ FRAMESAMPLES/2 ]; saved 240
+ int16_t* prevPitchLP; // [ FRAMESAMPLES/2 ]; saved 240
int16_t seed;
int16_t std;
} PLCstr;
-
-
/* Have instance of struct together with other iSAC structs */
typedef struct {
-
- int16_t prevFrameSizeMs; /* Previous frame size (in ms) */
- uint16_t prevRtpNumber; /* Previous RTP timestamp from received packet */
+ int16_t prevFrameSizeMs; /* Previous frame size (in ms) */
+ uint16_t prevRtpNumber; /* Previous RTP timestamp from received packet */
/* (in samples relative beginning) */
- uint32_t prevSendTime; /* Send time for previous packet, from RTP header */
- uint32_t prevArrivalTime; /* Arrival time for previous packet (in ms using timeGetTime()) */
- uint16_t prevRtpRate; /* rate of previous packet, derived from RTP timestamps (in bits/s) */
- uint32_t lastUpdate; /* Time since the last update of the Bottle Neck estimate (in samples) */
- uint32_t lastReduction; /* Time sinse the last reduction (in samples) */
- int32_t countUpdates; /* How many times the estimate was update in the beginning */
+ uint32_t prevSendTime; /* Send time for previous packet, from RTP header */
+ uint32_t prevArrivalTime; /* Arrival time for previous packet (in ms using
+ timeGetTime()) */
+ uint16_t
+ prevRtpRate; /* rate of previous packet, derived from RTP timestamps (in
+ bits/s) */
+ uint32_t
+ lastUpdate; /* Time since the last update of the Bottle Neck estimate (in
+ samples) */
+ uint32_t lastReduction; /* Time sinse the last reduction (in samples) */
+ int32_t countUpdates; /* How many times the estimate was update in the
+ beginning */
- /* The estimated bottle neck rate from there to here (in bits/s) */
- uint32_t recBw;
- uint32_t recBwInv;
- uint32_t recBwAvg;
- uint32_t recBwAvgQ;
+ /* The estimated bottle neck rate from there to here (in bits/s) */
+ uint32_t recBw;
+ uint32_t recBwInv;
+ uint32_t recBwAvg;
+ uint32_t recBwAvgQ;
- uint32_t minBwInv;
- uint32_t maxBwInv;
+ uint32_t minBwInv;
+ uint32_t maxBwInv;
- /* The estimated mean absolute jitter value, as seen on this side (in ms) */
- int32_t recJitter;
- int32_t recJitterShortTerm;
- int32_t recJitterShortTermAbs;
- int32_t recMaxDelay;
- int32_t recMaxDelayAvgQ;
+ /* The estimated mean absolute jitter value, as seen on this side (in ms) */
+ int32_t recJitter;
+ int32_t recJitterShortTerm;
+ int32_t recJitterShortTermAbs;
+ int32_t recMaxDelay;
+ int32_t recMaxDelayAvgQ;
+ int16_t recHeaderRate; /* (assumed) bitrate for headers (bps) */
- int16_t recHeaderRate; /* (assumed) bitrate for headers (bps) */
+ uint32_t sendBwAvg; /* The estimated bottle neck rate from here to there (in
+ bits/s) */
+ int32_t
+ sendMaxDelayAvg; /* The estimated mean absolute jitter value, as seen on
+ the other siee (in ms) */
- uint32_t sendBwAvg; /* The estimated bottle neck rate from here to there (in bits/s) */
- int32_t sendMaxDelayAvg; /* The estimated mean absolute jitter value, as seen on the other siee (in ms) */
-
-
- int16_t countRecPkts; /* number of packets received since last update */
- int16_t highSpeedRec; /* flag for marking that a high speed network has been detected downstream */
+ int16_t countRecPkts; /* number of packets received since last update */
+ int16_t highSpeedRec; /* flag for marking that a high speed network has been
+ detected downstream */
/* number of consecutive pkts sent during which the bwe estimate has
- remained at a value greater than the downstream threshold for determining highspeed network */
- int16_t countHighSpeedRec;
+ remained at a value greater than the downstream threshold for determining
+ highspeed network */
+ int16_t countHighSpeedRec;
- /* flag indicating bwe should not adjust down immediately for very late pckts */
- int16_t inWaitPeriod;
+ /* flag indicating bwe should not adjust down immediately for very late pckts
+ */
+ int16_t inWaitPeriod;
/* variable holding the time of the start of a window of time when
bwe should not adjust down immediately for very late pckts */
- uint32_t startWaitPeriod;
+ uint32_t startWaitPeriod;
/* number of consecutive pkts sent during which the bwe estimate has
- remained at a value greater than the upstream threshold for determining highspeed network */
- int16_t countHighSpeedSent;
+ remained at a value greater than the upstream threshold for determining
+ highspeed network */
+ int16_t countHighSpeedSent;
- /* flag indicated the desired number of packets over threshold rate have been sent and
- bwe will assume the connection is over broadband network */
- int16_t highSpeedSend;
+ /* flag indicated the desired number of packets over threshold rate have been
+ sent and bwe will assume the connection is over broadband network */
+ int16_t highSpeedSend;
IsacBandwidthInfo external_bw_info;
} BwEstimatorstr;
-
typedef struct {
-
/* boolean, flags if previous packet exceeded B.N. */
- int16_t PrevExceed;
+ int16_t PrevExceed;
/* ms */
- int16_t ExceedAgo;
+ int16_t ExceedAgo;
/* packets left to send in current burst */
- int16_t BurstCounter;
+ int16_t BurstCounter;
/* packets */
- int16_t InitCounter;
+ int16_t InitCounter;
/* ms remaining in buffer when next packet will be sent */
- int16_t StillBuffered;
+ int16_t StillBuffered;
} RateModel;
@@ -271,112 +251,107 @@
handle 60 ms of data.
*/
typedef struct {
-
/* Used to keep track of if it is first or second part of 60 msec packet */
- int startIdx;
+ int startIdx;
/* Frame length in samples */
- int16_t framelength;
+ int16_t framelength;
/* Pitch Gain */
- int16_t pitchGain_index[2];
+ int16_t pitchGain_index[2];
/* Pitch Lag */
- int32_t meanGain[2];
- int16_t pitchIndex[PITCH_SUBFRAMES*2];
+ int32_t meanGain[2];
+ int16_t pitchIndex[PITCH_SUBFRAMES * 2];
/* LPC */
- int32_t LPCcoeffs_g[12*2]; /* KLT_ORDER_GAIN = 12 */
- int16_t LPCindex_s[108*2]; /* KLT_ORDER_SHAPE = 108 */
- int16_t LPCindex_g[12*2]; /* KLT_ORDER_GAIN = 12 */
+ int32_t LPCcoeffs_g[12 * 2]; /* KLT_ORDER_GAIN = 12 */
+ int16_t LPCindex_s[108 * 2]; /* KLT_ORDER_SHAPE = 108 */
+ int16_t LPCindex_g[12 * 2]; /* KLT_ORDER_GAIN = 12 */
/* Encode Spec */
- int16_t fre[FRAMESAMPLES];
- int16_t fim[FRAMESAMPLES];
- int16_t AvgPitchGain[2];
+ int16_t fre[FRAMESAMPLES];
+ int16_t fim[FRAMESAMPLES];
+ int16_t AvgPitchGain[2];
/* Used in adaptive mode only */
- int minBytes;
+ int minBytes;
} IsacSaveEncoderData;
typedef struct {
-
- Bitstr_enc bitstr_obj;
- MaskFiltstr_enc maskfiltstr_obj;
- PreFiltBankstr prefiltbankstr_obj;
- PitchFiltstr pitchfiltstr_obj;
+ Bitstr_enc bitstr_obj;
+ MaskFiltstr_enc maskfiltstr_obj;
+ PreFiltBankstr prefiltbankstr_obj;
+ PitchFiltstr pitchfiltstr_obj;
PitchAnalysisStruct pitchanalysisstr_obj;
- RateModel rate_data_obj;
+ RateModel rate_data_obj;
- int16_t buffer_index;
- int16_t current_framesamples;
+ int16_t buffer_index;
+ int16_t current_framesamples;
- int16_t data_buffer_fix[FRAMESAMPLES]; // the size was MAX_FRAMESAMPLES
+ int16_t data_buffer_fix[FRAMESAMPLES]; // the size was MAX_FRAMESAMPLES
- int16_t frame_nb;
- int16_t BottleNeck;
- int16_t MaxDelay;
- int16_t new_framelength;
- int16_t s2nr;
- uint16_t MaxBits;
+ int16_t frame_nb;
+ int16_t BottleNeck;
+ int16_t MaxDelay;
+ int16_t new_framelength;
+ int16_t s2nr;
+ uint16_t MaxBits;
- int16_t bitstr_seed;
+ int16_t bitstr_seed;
#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
- PostFiltBankstr interpolatorstr_obj;
+ PostFiltBankstr interpolatorstr_obj;
#endif
- IsacSaveEncoderData *SaveEnc_ptr;
- int16_t payloadLimitBytes30; /* Maximum allowed number of bits for a 30 msec packet */
- int16_t payloadLimitBytes60; /* Maximum allowed number of bits for a 30 msec packet */
- int16_t maxPayloadBytes; /* Maximum allowed number of bits for both 30 and 60 msec packet */
- int16_t maxRateInBytes; /* Maximum allowed rate in bytes per 30 msec packet */
- int16_t enforceFrameSize; /* If set iSAC will never change packet size */
+ IsacSaveEncoderData* SaveEnc_ptr;
+ int16_t payloadLimitBytes30; /* Maximum allowed number of bits for a 30 msec
+ packet */
+ int16_t payloadLimitBytes60; /* Maximum allowed number of bits for a 30 msec
+ packet */
+ int16_t maxPayloadBytes; /* Maximum allowed number of bits for both 30 and 60
+ msec packet */
+ int16_t maxRateInBytes; /* Maximum allowed rate in bytes per 30 msec packet */
+ int16_t enforceFrameSize; /* If set iSAC will never change packet size */
} IsacFixEncoderInstance;
-
typedef struct {
-
- Bitstr_dec bitstr_obj;
- MaskFiltstr_dec maskfiltstr_obj;
- PostFiltBankstr postfiltbankstr_obj;
- PitchFiltstr pitchfiltstr_obj;
- PLCstr plcstr_obj; /* TS; for packet loss concealment */
+ Bitstr_dec bitstr_obj;
+ MaskFiltstr_dec maskfiltstr_obj;
+ PostFiltBankstr postfiltbankstr_obj;
+ PitchFiltstr pitchfiltstr_obj;
+ PLCstr plcstr_obj; /* TS; for packet loss concealment */
#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
- PreFiltBankstr decimatorstr_obj;
+ PreFiltBankstr decimatorstr_obj;
#endif
} IsacFixDecoderInstance;
-
-
typedef struct {
-
IsacFixEncoderInstance ISACenc_obj;
IsacFixDecoderInstance ISACdec_obj;
- BwEstimatorstr bwestimator_obj;
- int16_t CodingMode; /* 0 = adaptive; 1 = instantaneous */
- int16_t errorcode;
- int16_t initflag; /* 0 = nothing initiated; 1 = encoder or decoder */
+ BwEstimatorstr bwestimator_obj;
+ int16_t CodingMode; /* 0 = adaptive; 1 = instantaneous */
+ int16_t errorcode;
+ int16_t initflag; /* 0 = nothing initiated; 1 = encoder or decoder */
/* not initiated; 2 = all initiated */
} ISACFIX_SubStruct;
-
typedef struct {
- int32_t lpcGains[12]; /* 6 lower-band & 6 upper-band we may need to double it for 60*/
+ int32_t lpcGains
+ [12]; /* 6 lower-band & 6 upper-band we may need to double it for 60*/
/* */
- uint32_t W_upper; /* Upper boundary of interval W */
- uint32_t streamval;
- uint16_t stream_index; /* Index to the current position in bytestream */
- int16_t full; /* 0 - first byte in memory filled, second empty*/
+ uint32_t W_upper; /* Upper boundary of interval W */
+ uint32_t streamval;
+ uint16_t stream_index; /* Index to the current position in bytestream */
+ int16_t full; /* 0 - first byte in memory filled, second empty*/
/* 1 - both bytes are empty (we just filled the previous memory */
- uint16_t beforeLastWord;
- uint16_t lastWord;
+ uint16_t beforeLastWord;
+ uint16_t lastWord;
} transcode_obj;
+// Bitstr_enc myBitStr;
-//Bitstr_enc myBitStr;
-
-#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_STRUCTS_H_ */
+#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_STRUCTS_H_ */
diff --git a/modules/audio_coding/codecs/isac/fix/source/transform_unittest.cc b/modules/audio_coding/codecs/isac/fix/source/transform_unittest.cc
index 347b049..a058530 100644
--- a/modules/audio_coding/codecs/isac/fix/source/transform_unittest.cc
+++ b/modules/audio_coding/codecs/isac/fix/source/transform_unittest.cc
@@ -12,147 +12,156 @@
#include "system_wrappers/include/cpu_features_wrapper.h"
#include "test/gtest.h"
-static const int kSamples = FRAMESAMPLES/2;
+static const int kSamples = FRAMESAMPLES / 2;
static const int32_t spec2time_out_expected_1[kSamples] = {
- -3366470, -2285227,
- -3415765, -2310215, -3118030, -2222470, -3030254, -2192091, -3423170,
- -2216041, -3305541, -2171936, -3195767, -2095779, -3153304, -2157560,
- -3071167, -2032108, -3101190, -1972016, -3103824, -2089118, -3139811,
- -1898337, -3102801, -2055082, -3029665, -1854140, -2962586, -1966454,
- -3071167, -1894588, -2851743, -1917315, -2848087, -1594932, -2799242,
- -1462184, -2845887, -1437599, -2691776, -1329637, -2770659, -1268491,
- -2625161, -1578991, -2460299, -1186385, -2365613, -1039354, -2322608,
- -958518, -2271749, -789860, -2254538, -850308, -2384436, -850959, -2133734,
- -587678, -2093316, -495115, -1973364, -475177, -1801282, -173507,
- -1848516, -158015, -1792018, -62648, -1643313, 214746, -1500758, 267077,
- -1450193, 560521, -1521579, 675283, -1345408, 857559, -1300822, 1116332,
- -1294533, 1241117, -1070027, 1263503, -983816, 1529821, -1019586,
- 1910421, -955420, 2073688, -836459, 2401105, -653905, 2690474, -731425,
- 2930131, -935234, 3299500, -875978, 3523432, -878906, 3924822, -1081630,
- 4561267, -1203023, 5105274, -1510983, 6052762, -2294646, 7021597,
- -3108053, 8826736, -4935222, 11678789, -8442713, 18725700, -21526692,
- 25420577, 19589811, -28108666, 12634054, -14483066, 6263217, -9979706,
- 3665661, -7909736, 2531530, -6434896, 1700772, -5525393, 1479473,
- -4894262, 1231760, -4353044, 1032940, -3786590, 941152, -3331614,
- 665090, -2851619, 830696, -2762201, 958007, -2483118, 788233, -2184965,
- 804825, -1967306, 1007255, -1862474, 920889, -1457506, 755406, -1405841,
- 890230, -1302124, 1161599, -701867, 1154163, -1083366, 1204743, -513581,
- 1547264, -650636, 1493384, -285543, 1771863, -277906, 1841343, -9078,
- 1751863, 230222, 1819578, 207170, 1978972, 398137, 2106468, 552155,
- 1997624, 685213, 2129520, 601078, 2238736, 944591, 2441879, 1194178,
- 2355280, 986124, 2393328, 1049005, 2417944, 1208368, 2489516, 1352023,
- 2572118, 1445283, 2856081, 1532997, 2742279, 1615877, 2915274, 1808036,
- 2856871, 1806936, 3241747, 1622461, 2978558, 1841297, 3010378, 1923666,
- 3271367, 2126700, 3070935, 1956958, 3107588, 2128405, 3288872, 2114911,
- 3315952, 2406651, 3344038, 2370199, 3368980, 2144361, 3305030, 2183803,
- 3401450, 2523102, 3405463, 2452475, 3463355, 2421678, 3551968, 2431949,
- 3477251, 2148125, 3244489, 2174090};
+ -3366470, -2285227, -3415765, -2310215, -3118030, -2222470, -3030254,
+ -2192091, -3423170, -2216041, -3305541, -2171936, -3195767, -2095779,
+ -3153304, -2157560, -3071167, -2032108, -3101190, -1972016, -3103824,
+ -2089118, -3139811, -1898337, -3102801, -2055082, -3029665, -1854140,
+ -2962586, -1966454, -3071167, -1894588, -2851743, -1917315, -2848087,
+ -1594932, -2799242, -1462184, -2845887, -1437599, -2691776, -1329637,
+ -2770659, -1268491, -2625161, -1578991, -2460299, -1186385, -2365613,
+ -1039354, -2322608, -958518, -2271749, -789860, -2254538, -850308,
+ -2384436, -850959, -2133734, -587678, -2093316, -495115, -1973364,
+ -475177, -1801282, -173507, -1848516, -158015, -1792018, -62648,
+ -1643313, 214746, -1500758, 267077, -1450193, 560521, -1521579,
+ 675283, -1345408, 857559, -1300822, 1116332, -1294533, 1241117,
+ -1070027, 1263503, -983816, 1529821, -1019586, 1910421, -955420,
+ 2073688, -836459, 2401105, -653905, 2690474, -731425, 2930131,
+ -935234, 3299500, -875978, 3523432, -878906, 3924822, -1081630,
+ 4561267, -1203023, 5105274, -1510983, 6052762, -2294646, 7021597,
+ -3108053, 8826736, -4935222, 11678789, -8442713, 18725700, -21526692,
+ 25420577, 19589811, -28108666, 12634054, -14483066, 6263217, -9979706,
+ 3665661, -7909736, 2531530, -6434896, 1700772, -5525393, 1479473,
+ -4894262, 1231760, -4353044, 1032940, -3786590, 941152, -3331614,
+ 665090, -2851619, 830696, -2762201, 958007, -2483118, 788233,
+ -2184965, 804825, -1967306, 1007255, -1862474, 920889, -1457506,
+ 755406, -1405841, 890230, -1302124, 1161599, -701867, 1154163,
+ -1083366, 1204743, -513581, 1547264, -650636, 1493384, -285543,
+ 1771863, -277906, 1841343, -9078, 1751863, 230222, 1819578,
+ 207170, 1978972, 398137, 2106468, 552155, 1997624, 685213,
+ 2129520, 601078, 2238736, 944591, 2441879, 1194178, 2355280,
+ 986124, 2393328, 1049005, 2417944, 1208368, 2489516, 1352023,
+ 2572118, 1445283, 2856081, 1532997, 2742279, 1615877, 2915274,
+ 1808036, 2856871, 1806936, 3241747, 1622461, 2978558, 1841297,
+ 3010378, 1923666, 3271367, 2126700, 3070935, 1956958, 3107588,
+ 2128405, 3288872, 2114911, 3315952, 2406651, 3344038, 2370199,
+ 3368980, 2144361, 3305030, 2183803, 3401450, 2523102, 3405463,
+ 2452475, 3463355, 2421678, 3551968, 2431949, 3477251, 2148125,
+ 3244489, 2174090};
static const int32_t spec2time_out_expected_2[kSamples] = {
- 1691694, -2499988, -2035547,
- 1060469, 988634, -2044502, -306271, 2041000, 201454, -2289456, 93694,
- 2129427, -369152, -1887834, 860796, 2089102, -929424, -1673956, 1395291,
- 1785651, -1619673, -1380109, 1963449, 1093311, -2111007, -840456,
- 2372786, 578119, -2242702, 89774, 2463304, -132717, -2121480, 643634,
- 2277636, -1125999, -1995858, 1543748, 2227861, -1483779, -1495491,
- 2102642, 1833876, -1920568, -958378, 2485101, 772261, -2454257, -24942,
- 2918714, 136838, -2500453, 816118, 3039735, -746560, -2365815, 1586396,
- 2714951, -1511696, -1942334, 2571792, 2182827, -2325335, -1311543,
- 3055970, 1367220, -2737182, -110626, 3889222, 631008, -3280879, 853066,
- 4122279, -706638, -3334449, 2148311, 3993512, -1846301, -3004894,
- 3426779, 3329522, -3165264, -2242423, 4756866, 2557711, -4131280,
- -805259, 5702711, 1120592, -4852821, 743664, 6476444, -621186, -5465828,
- 2815787, 6768835, -3017442, -5338409, 5658126, 6838454, -5492288,
- -4682382, 8874947, 6153814, -8832561, -2649251, 12817398, 4237692,
- -13000247, 1190661, 18986363, -115738, -19693978, 9908367, 30660381,
- -10632635, -37962068, 47022884, 89744622, -42087632, 40279224,
- -88869341, -47542383, 38572364, 10441576, -30339718, -9926740, 19896578,
- 28009, -18886612, -1124047, 13232498, -4150304, -12770551, 2637074,
- 9051831, -6162211, -8713972, 4557937, 5489716, -6862312, -5532349,
- 5415449, 2791310, -6999367, -2790102, 5375806, 546222, -6486452,
- -821261, 4994973, -1278840, -5645501, 1060484, 3996285, -2503954,
- -4653629, 2220549, 3036977, -3282133, -3318585, 2780636, 1789880,
- -4004589, -2041031, 3105373, 574819, -3992722, -971004, 3001703,
- -676739, -3841508, 417284, 2897970, -1427018, -3058480, 1189948,
- 2210960, -2268992, -2603272, 1949785, 1576172, -2720404, -1891738,
- 2309456, 769178, -2975646, -707150, 2424652, -88039, -2966660, -65452,
- 2320780, -957557, -2798978, 744640, 1879794, -1672081, -2365319,
- 1253309, 1366383, -2204082, -1544367, 1801452, 613828, -2531994,
- -983847, 2064842, 118326, -2613790, -203220, 2219635, -730341, -2641861,
- 563557, 1765434, -1329916, -2272927, 1037138, 1266725, -1939220,
- -1588643, 1754528, 816552, -2376303, -1099167, 1864999, 122477,
- -2422762, -400027, 1889228, -579916, -2490353, 287139, 2011318,
- -1176657, -2502978, 812896, 1116502, -1940211};
+ 1691694, -2499988, -2035547, 1060469, 988634, -2044502, -306271,
+ 2041000, 201454, -2289456, 93694, 2129427, -369152, -1887834,
+ 860796, 2089102, -929424, -1673956, 1395291, 1785651, -1619673,
+ -1380109, 1963449, 1093311, -2111007, -840456, 2372786, 578119,
+ -2242702, 89774, 2463304, -132717, -2121480, 643634, 2277636,
+ -1125999, -1995858, 1543748, 2227861, -1483779, -1495491, 2102642,
+ 1833876, -1920568, -958378, 2485101, 772261, -2454257, -24942,
+ 2918714, 136838, -2500453, 816118, 3039735, -746560, -2365815,
+ 1586396, 2714951, -1511696, -1942334, 2571792, 2182827, -2325335,
+ -1311543, 3055970, 1367220, -2737182, -110626, 3889222, 631008,
+ -3280879, 853066, 4122279, -706638, -3334449, 2148311, 3993512,
+ -1846301, -3004894, 3426779, 3329522, -3165264, -2242423, 4756866,
+ 2557711, -4131280, -805259, 5702711, 1120592, -4852821, 743664,
+ 6476444, -621186, -5465828, 2815787, 6768835, -3017442, -5338409,
+ 5658126, 6838454, -5492288, -4682382, 8874947, 6153814, -8832561,
+ -2649251, 12817398, 4237692, -13000247, 1190661, 18986363, -115738,
+ -19693978, 9908367, 30660381, -10632635, -37962068, 47022884, 89744622,
+ -42087632, 40279224, -88869341, -47542383, 38572364, 10441576, -30339718,
+ -9926740, 19896578, 28009, -18886612, -1124047, 13232498, -4150304,
+ -12770551, 2637074, 9051831, -6162211, -8713972, 4557937, 5489716,
+ -6862312, -5532349, 5415449, 2791310, -6999367, -2790102, 5375806,
+ 546222, -6486452, -821261, 4994973, -1278840, -5645501, 1060484,
+ 3996285, -2503954, -4653629, 2220549, 3036977, -3282133, -3318585,
+ 2780636, 1789880, -4004589, -2041031, 3105373, 574819, -3992722,
+ -971004, 3001703, -676739, -3841508, 417284, 2897970, -1427018,
+ -3058480, 1189948, 2210960, -2268992, -2603272, 1949785, 1576172,
+ -2720404, -1891738, 2309456, 769178, -2975646, -707150, 2424652,
+ -88039, -2966660, -65452, 2320780, -957557, -2798978, 744640,
+ 1879794, -1672081, -2365319, 1253309, 1366383, -2204082, -1544367,
+ 1801452, 613828, -2531994, -983847, 2064842, 118326, -2613790,
+ -203220, 2219635, -730341, -2641861, 563557, 1765434, -1329916,
+ -2272927, 1037138, 1266725, -1939220, -1588643, 1754528, 816552,
+ -2376303, -1099167, 1864999, 122477, -2422762, -400027, 1889228,
+ -579916, -2490353, 287139, 2011318, -1176657, -2502978, 812896,
+ 1116502, -1940211};
static const int16_t time2spec_out_expected_1[kSamples] = {
- 20342, 23889, -10063, -9419,
- 3242, 7280, -2012, -5029, 332, 4478, -97, -3244, -891, 3117, 773, -2204,
- -1335, 2009, 1236, -1469, -1562, 1277, 1366, -815, -1619, 599, 1449, -177,
- -1507, 116, 1294, 263, -1338, -244, 1059, 553, -1045, -549, 829, 826,
- -731, -755, 516, 909, -427, -853, 189, 1004, -184, -828, -108, 888, 72,
- -700, -280, 717, 342, -611, -534, 601, 534, -374, -646, 399, 567, -171,
- -720, 234, 645, -11, -712, -26, 593, 215, -643, -172, 536, 361, -527,
- -403, 388, 550, -361, -480, 208, 623, -206, -585, 41, 578, 12, -504,
- -182, 583, 218, -437, -339, 499, 263, -354, -450, 347, 456, -193, -524,
- 212, 475, -74, -566, 94, 511, 112, -577, -201, 408, 217, -546, -295, 338,
- 387, -13, 4, -46, 2, -76, 103, -83, 108, -55, 100, -150, 131, -156, 141,
- -171, 179, -190, 128, -227, 172, -214, 215, -189, 265, -244, 322, -335,
- 337, -352, 358, -368, 362, -355, 366, -381, 403, -395, 411, -392, 446,
- -458, 504, -449, 507, -464, 452, -491, 481, -534, 486, -516, 560, -535,
- 525, -537, 559, -554, 570, -616, 591, -585, 627, -509, 588, -584, 547,
- -610, 580, -614, 635, -620, 655, -554, 546, -591, 642, -590, 660, -656,
- 629, -604, 620, -580, 617, -645, 648, -573, 612, -604, 584, -571, 597,
- -562, 627, -550, 560, -606, 529, -584, 568, -503, 532, -463, 512, -440,
- 399, -457, 437, -349, 278, -317, 257, -220, 163, -8, -61, 18, -161, 367,
- -1306};
+ 20342, 23889, -10063, -9419, 3242, 7280, -2012, -5029, 332, 4478,
+ -97, -3244, -891, 3117, 773, -2204, -1335, 2009, 1236, -1469,
+ -1562, 1277, 1366, -815, -1619, 599, 1449, -177, -1507, 116,
+ 1294, 263, -1338, -244, 1059, 553, -1045, -549, 829, 826,
+ -731, -755, 516, 909, -427, -853, 189, 1004, -184, -828,
+ -108, 888, 72, -700, -280, 717, 342, -611, -534, 601,
+ 534, -374, -646, 399, 567, -171, -720, 234, 645, -11,
+ -712, -26, 593, 215, -643, -172, 536, 361, -527, -403,
+ 388, 550, -361, -480, 208, 623, -206, -585, 41, 578,
+ 12, -504, -182, 583, 218, -437, -339, 499, 263, -354,
+ -450, 347, 456, -193, -524, 212, 475, -74, -566, 94,
+ 511, 112, -577, -201, 408, 217, -546, -295, 338, 387,
+ -13, 4, -46, 2, -76, 103, -83, 108, -55, 100,
+ -150, 131, -156, 141, -171, 179, -190, 128, -227, 172,
+ -214, 215, -189, 265, -244, 322, -335, 337, -352, 358,
+ -368, 362, -355, 366, -381, 403, -395, 411, -392, 446,
+ -458, 504, -449, 507, -464, 452, -491, 481, -534, 486,
+ -516, 560, -535, 525, -537, 559, -554, 570, -616, 591,
+ -585, 627, -509, 588, -584, 547, -610, 580, -614, 635,
+ -620, 655, -554, 546, -591, 642, -590, 660, -656, 629,
+ -604, 620, -580, 617, -645, 648, -573, 612, -604, 584,
+ -571, 597, -562, 627, -550, 560, -606, 529, -584, 568,
+ -503, 532, -463, 512, -440, 399, -457, 437, -349, 278,
+ -317, 257, -220, 163, -8, -61, 18, -161, 367, -1306};
static const int16_t time2spec_out_expected_2[kSamples] = {
- 14283, -11552, -15335, 6626,
- 7554, -2150, -6309, 1307, 4523, -4, -3908, -314, 3001, 914, -2715, -1042,
- 2094, 1272, -1715, -1399, 1263, 1508, -1021, -1534, 735, 1595, -439, -1447,
- 155, 1433, 22, -1325, -268, 1205, 424, -1030, -608, 950, 643, -733, -787,
- 661, 861, -502, -888, 331, 852, -144, -849, 19, 833, 99, -826, -154,
- 771, 368, -735, -459, 645, 513, -491, -604, 431, 630, -314, -598, 183,
- 622, -78, -612, -48, 641, 154, -645, -257, 610, 281, -529, -444, 450,
- 441, -327, -506, 274, 476, -232, -570, 117, 554, -86, -531, -21, 572,
- 151, -606, -221, 496, 322, -407, -388, 407, 394, -268, -428, 280, 505,
- -115, -588, 19, 513, -29, -539, -109, 468, 173, -501, -242, 442, 278,
- -478, -680, 656, -659, 656, -669, 602, -688, 612, -667, 612, -642, 627,
- -648, 653, -676, 596, -680, 655, -649, 678, -672, 587, -608, 637, -645,
- 637, -620, 556, -580, 553, -635, 518, -599, 583, -501, 536, -544, 473,
- -552, 583, -511, 541, -532, 563, -486, 461, -453, 486, -388, 424, -416,
- 432, -374, 399, -462, 364, -346, 293, -329, 331, -313, 281, -247, 309,
- -337, 241, -190, 207, -194, 179, -163, 155, -156, 117, -135, 107, -126,
- 29, -22, 81, -8, 17, -61, -10, 8, -37, 80, -44, 72, -88, 65, -89, 130,
- -114, 181, -215, 189, -245, 260, -288, 294, -339, 344, -396, 407, -429,
- 438, -439, 485, -556, 629, -612, 637, -645, 661, -737, 829, -830, 831,
- -1041};
+ 14283, -11552, -15335, 6626, 7554, -2150, -6309, 1307, 4523, -4,
+ -3908, -314, 3001, 914, -2715, -1042, 2094, 1272, -1715, -1399,
+ 1263, 1508, -1021, -1534, 735, 1595, -439, -1447, 155, 1433,
+ 22, -1325, -268, 1205, 424, -1030, -608, 950, 643, -733,
+ -787, 661, 861, -502, -888, 331, 852, -144, -849, 19,
+ 833, 99, -826, -154, 771, 368, -735, -459, 645, 513,
+ -491, -604, 431, 630, -314, -598, 183, 622, -78, -612,
+ -48, 641, 154, -645, -257, 610, 281, -529, -444, 450,
+ 441, -327, -506, 274, 476, -232, -570, 117, 554, -86,
+ -531, -21, 572, 151, -606, -221, 496, 322, -407, -388,
+ 407, 394, -268, -428, 280, 505, -115, -588, 19, 513,
+ -29, -539, -109, 468, 173, -501, -242, 442, 278, -478,
+ -680, 656, -659, 656, -669, 602, -688, 612, -667, 612,
+ -642, 627, -648, 653, -676, 596, -680, 655, -649, 678,
+ -672, 587, -608, 637, -645, 637, -620, 556, -580, 553,
+ -635, 518, -599, 583, -501, 536, -544, 473, -552, 583,
+ -511, 541, -532, 563, -486, 461, -453, 486, -388, 424,
+ -416, 432, -374, 399, -462, 364, -346, 293, -329, 331,
+ -313, 281, -247, 309, -337, 241, -190, 207, -194, 179,
+ -163, 155, -156, 117, -135, 107, -126, 29, -22, 81,
+ -8, 17, -61, -10, 8, -37, 80, -44, 72, -88,
+ 65, -89, 130, -114, 181, -215, 189, -245, 260, -288,
+ 294, -339, 344, -396, 407, -429, 438, -439, 485, -556,
+ 629, -612, 637, -645, 661, -737, 829, -830, 831, -1041};
class TransformTest : public testing::Test {
protected:
- TransformTest() {
- WebRtcSpl_Init();
- }
+ TransformTest() { WebRtcSpl_Init(); }
- // Pass a function pointer to the Tester function.
- void Time2SpecTester(Time2Spec Time2SpecFunction) {
- // WebRtcIsacfix_Time2Spec functions hard coded the buffer lengths. It's a
- // large buffer but we have to test it here.
- int16_t data_in_1[kSamples] = {0};
- int16_t data_in_2[kSamples] = {0};
- int16_t data_out_1[kSamples] = {0};
- int16_t data_out_2[kSamples] = {0};
+ // Pass a function pointer to the Tester function.
+ void Time2SpecTester(Time2Spec Time2SpecFunction) {
+ // WebRtcIsacfix_Time2Spec functions hard coded the buffer lengths. It's a
+ // large buffer but we have to test it here.
+ int16_t data_in_1[kSamples] = {0};
+ int16_t data_in_2[kSamples] = {0};
+ int16_t data_out_1[kSamples] = {0};
+ int16_t data_out_2[kSamples] = {0};
- for(int i = 0; i < kSamples; i++) {
- data_in_1[i] = i * i + 1777;
- data_in_2[i] = WEBRTC_SPL_WORD16_MAX / (i + 1) + 17;
- }
+ for (int i = 0; i < kSamples; i++) {
+ data_in_1[i] = i * i + 1777;
+ data_in_2[i] = WEBRTC_SPL_WORD16_MAX / (i + 1) + 17;
+ }
- Time2SpecFunction(data_in_1, data_in_2, data_out_1, data_out_2);
+ Time2SpecFunction(data_in_1, data_in_2, data_out_1, data_out_2);
- for (int i = 0; i < kSamples; i++) {
- // We don't require bit-exact for ARM assembly code.
- EXPECT_LE(abs(time2spec_out_expected_1[i] - data_out_1[i]), 1);
- EXPECT_LE(abs(time2spec_out_expected_2[i] - data_out_2[i]), 1);
- }
- }
+ for (int i = 0; i < kSamples; i++) {
+ // We don't require bit-exact for ARM assembly code.
+ EXPECT_LE(abs(time2spec_out_expected_1[i] - data_out_1[i]), 1);
+ EXPECT_LE(abs(time2spec_out_expected_2[i] - data_out_2[i]), 1);
+ }
+ }
// Pass a function pointer to the Tester function.
void Spec2TimeTester(Spec2Time Spec2TimeFunction) {
@@ -162,7 +171,7 @@
int16_t data_in_2[kSamples] = {0};
int32_t data_out_1[kSamples] = {0};
int32_t data_out_2[kSamples] = {0};
- for(int i = 0; i < kSamples; i++) {
+ for (int i = 0; i < kSamples; i++) {
data_in_1[i] = i * i + 1777;
data_in_2[i] = WEBRTC_SPL_WORD16_MAX / (i + 1) + 17;
}
@@ -175,7 +184,6 @@
EXPECT_LE(abs(spec2time_out_expected_2[i] - data_out_2[i]), 16);
}
}
-
};
TEST_F(TransformTest, Time2SpecTest) {
diff --git a/modules/audio_coding/codecs/isac/fix/test/isac_speed_test.cc b/modules/audio_coding/codecs/isac/fix/test/isac_speed_test.cc
index fc779d8..aeca2e8 100644
--- a/modules/audio_coding/codecs/isac/fix/test/isac_speed_test.cc
+++ b/modules/audio_coding/codecs/isac/fix/test/isac_speed_test.cc
@@ -25,19 +25,21 @@
IsacSpeedTest();
void SetUp() override;
void TearDown() override;
- float EncodeABlock(int16_t* in_data, uint8_t* bit_stream,
- size_t max_bytes, size_t* encoded_bytes) override;
- float DecodeABlock(const uint8_t* bit_stream, size_t encoded_bytes,
+ float EncodeABlock(int16_t* in_data,
+ uint8_t* bit_stream,
+ size_t max_bytes,
+ size_t* encoded_bytes) override;
+ float DecodeABlock(const uint8_t* bit_stream,
+ size_t encoded_bytes,
int16_t* out_data) override;
- ISACFIX_MainStruct *ISACFIX_main_inst_;
+ ISACFIX_MainStruct* ISACFIX_main_inst_;
};
IsacSpeedTest::IsacSpeedTest()
: AudioCodecSpeedTest(kIsacBlockDurationMs,
kIsacInputSamplingKhz,
kIsacOutputSamplingKhz),
- ISACFIX_main_inst_(NULL) {
-}
+ ISACFIX_main_inst_(NULL) {}
void IsacSpeedTest::SetUp() {
AudioCodecSpeedTest::SetUp();
@@ -60,8 +62,10 @@
EXPECT_EQ(0, WebRtcIsacfix_Free(ISACFIX_main_inst_));
}
-float IsacSpeedTest::EncodeABlock(int16_t* in_data, uint8_t* bit_stream,
- size_t max_bytes, size_t* encoded_bytes) {
+float IsacSpeedTest::EncodeABlock(int16_t* in_data,
+ uint8_t* bit_stream,
+ size_t max_bytes,
+ size_t* encoded_bytes) {
// ISAC takes 10 ms everycall
const int subblocks = block_duration_ms_ / 10;
const int subblock_length = 10 * input_sampling_khz_;
@@ -70,8 +74,8 @@
clock_t clocks = clock();
size_t pointer = 0;
for (int idx = 0; idx < subblocks; idx++, pointer += subblock_length) {
- value = WebRtcIsacfix_Encode(ISACFIX_main_inst_, &in_data[pointer],
- bit_stream);
+ value =
+ WebRtcIsacfix_Encode(ISACFIX_main_inst_, &in_data[pointer], bit_stream);
if (idx == subblocks - 1)
EXPECT_GT(value, 0);
else
@@ -108,7 +112,6 @@
string("pcm"),
true)};
-INSTANTIATE_TEST_CASE_P(AllTest, IsacSpeedTest,
- ::testing::ValuesIn(param_set));
+INSTANTIATE_TEST_CASE_P(AllTest, IsacSpeedTest, ::testing::ValuesIn(param_set));
} // namespace webrtc
diff --git a/modules/audio_coding/codecs/isac/fix/test/kenny.cc b/modules/audio_coding/codecs/isac/fix/test/kenny.cc
index 4251627..fb64a2b 100644
--- a/modules/audio_coding/codecs/isac/fix/test/kenny.cc
+++ b/modules/audio_coding/codecs/isac/fix/test/kenny.cc
@@ -8,11 +8,11 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
-#include <ctype.h>
#include "modules/audio_coding/codecs/isac/fix/include/isacfix.h"
#include "test/gtest.h"
@@ -22,14 +22,16 @@
// separate encoder and decoder.
/* Defines */
-#define SEED_FILE "randseed.txt" /* Used when running decoder on garbage data */
-#define MAX_FRAMESAMPLES 960 /* max number of samples per frame (= 60 ms frame) */
-#define FRAMESAMPLES_10ms 160 /* number of samples per 10ms frame */
-#define FS 16000 /* sampling frequency (Hz) */
+#define SEED_FILE \
+ "randseed.txt" /* Used when running decoder on garbage data \
+ */
+#define MAX_FRAMESAMPLES \
+ 960 /* max number of samples per frame (= 60 ms frame) */
+#define FRAMESAMPLES_10ms 160 /* number of samples per 10ms frame */
+#define FS 16000 /* sampling frequency (Hz) */
/* Function for reading audio data from PCM file */
-int readframe(int16_t *data, FILE *inp, int length) {
-
+int readframe(int16_t* data, FILE* inp, int length) {
short k, rlen, status = 0;
rlen = fread(data, sizeof(int16_t), length, inp);
@@ -45,25 +47,24 @@
// Globals needed because gtest does not provide access to argv.
// This should be reworked to use flags.
static int global_argc;
-static char **global_argv;
+static char** global_argv;
/* Struct for bottleneck model */
typedef struct {
- uint32_t send_time; /* samples */
- uint32_t arrival_time; /* samples */
- uint32_t sample_count; /* samples */
+ uint32_t send_time; /* samples */
+ uint32_t arrival_time; /* samples */
+ uint32_t sample_count; /* samples */
uint16_t rtp_number;
} BottleNeckModel;
-void get_arrival_time(int current_framesamples, /* samples */
- size_t packet_size, /* bytes */
- int bottleneck, /* excluding headers; bits/s */
- BottleNeckModel *BN_data)
-{
+void get_arrival_time(int current_framesamples, /* samples */
+ size_t packet_size, /* bytes */
+ int bottleneck, /* excluding headers; bits/s */
+ BottleNeckModel* BN_data) {
const int HeaderSize = 35;
int HeaderRate;
- HeaderRate = HeaderSize * 8 * FS / current_framesamples; /* bits/s */
+ HeaderRate = HeaderSize * 8 * FS / current_framesamples; /* bits/s */
/* everything in samples */
BN_data->sample_count = BN_data->sample_count + current_framesamples;
@@ -80,29 +81,27 @@
void get_arrival_time2(int current_framesamples,
int current_delay,
- BottleNeckModel *BN_data)
-{
+ BottleNeckModel* BN_data) {
if (current_delay == -1)
- //dropped packet
+ // dropped packet
{
BN_data->arrival_time += current_framesamples;
- }
- else if (current_delay != -2)
- {
+ } else if (current_delay != -2) {
//
- BN_data->arrival_time += (current_framesamples + ((FS/1000) * current_delay));
+ BN_data->arrival_time +=
+ (current_framesamples + ((FS / 1000) * current_delay));
}
- //else
- //current packet has same timestamp as previous packet
+ // else
+ // current packet has same timestamp as previous packet
BN_data->rtp_number++;
}
TEST(IsacFixTest, Kenny) {
int argc = global_argc;
- char **argv = global_argv;
+ char** argv = global_argv;
- char inname[100], outname[100], outbitsname[100], bottleneck_file[100];
+ char inname[100], outname[100], outbitsname[100], bottleneck_file[100];
FILE *inp, *outp, *f_bn, *outbits;
int endfile;
@@ -112,7 +111,7 @@
int errtype, h = 0, k, packetLossPercent = 0;
int16_t CodingMode;
int16_t bottleneck;
- int framesize = 30; /* ms */
+ int framesize = 30; /* ms */
int cur_framesmpls, err = 0, lostPackets = 0;
/* Runtime statistics */
@@ -133,16 +132,16 @@
int32_t payloadRate = 0;
int setControlBWE = 0;
int readLoss;
- FILE *plFile = NULL;
+ FILE* plFile = NULL;
char version_number[20];
char tmpBit[5] = ".bit";
- int totalbits =0;
- int totalsmpls =0;
+ int totalbits = 0;
+ int totalsmpls = 0;
int16_t testNum, testCE;
- FILE *fp_gns = NULL;
+ FILE* fp_gns = NULL;
int gns = 0;
int cur_delay = 0;
char gns_file[100];
@@ -151,20 +150,20 @@
int16_t lostFrame;
float scale = (float)0.7;
/* only one structure used for ISAC encoder */
- ISACFIX_MainStruct *ISAC_main_inst = NULL;
+ ISACFIX_MainStruct* ISAC_main_inst = NULL;
/* For fault test 10, garbage data */
- FILE *seedfile;
- unsigned int random_seed = (unsigned int) time(NULL);//1196764538
+ FILE* seedfile;
+ unsigned int random_seed = (unsigned int)time(NULL); // 1196764538
- BottleNeckModel BN_data;
- f_bn = NULL;
+ BottleNeckModel BN_data;
+ f_bn = NULL;
readLoss = 0;
packetLossPercent = 0;
/* Handling wrong input arguments in the command line */
- if ((argc<3) || (argc>22)) {
+ if ((argc < 3) || (argc > 22)) {
printf("\n\nWrong number of arguments or flag values.\n\n");
printf("\n");
@@ -182,61 +181,75 @@
printf(" read from a file (e.g. bottleneck.txt)\n\n");
printf("infile :Normal speech input file\n\n");
printf("outfile :Speech output file\n\n");
- printf("[-INITRATE num] :Set a new value for initial rate. Note! Only used"
- " in adaptive mode.\n\n");
- printf("[-FL num] :Set (initial) frame length in msec. Valid length"
- " are 30 and 60 msec.\n\n");
+ printf(
+ "[-INITRATE num] :Set a new value for initial rate. Note! Only used"
+ " in adaptive mode.\n\n");
+ printf(
+ "[-FL num] :Set (initial) frame length in msec. Valid length"
+ " are 30 and 60 msec.\n\n");
printf("[-FIXED_FL] :Frame length to be fixed to initial value.\n\n");
- printf("[-MAX num] :Set the limit for the payload size of iSAC"
- " in bytes. \n");
+ printf(
+ "[-MAX num] :Set the limit for the payload size of iSAC"
+ " in bytes. \n");
printf(" Minimum 100, maximum 400.\n\n");
printf("[-MAXRATE num] :Set the maxrate for iSAC in bits per second. \n");
printf(" Minimum 32000, maximum 53400.\n\n");
printf("[-F num] :if -F option is specified, the test function\n");
- printf(" will run the iSAC API fault scenario specified"
- " by the\n");
+ printf(
+ " will run the iSAC API fault scenario specified"
+ " by the\n");
printf(" supplied number.\n");
printf(" F 1 - Call encoder prior to init encoder call\n");
printf(" F 2 - Call decoder prior to init decoder call\n");
printf(" F 3 - Call decoder prior to encoder call\n");
- printf(" F 4 - Call decoder with a too short coded"
- " sequence\n");
- printf(" F 5 - Call decoder with a too long coded"
- " sequence\n");
+ printf(
+ " F 4 - Call decoder with a too short coded"
+ " sequence\n");
+ printf(
+ " F 5 - Call decoder with a too long coded"
+ " sequence\n");
printf(" F 6 - Call decoder with random bit stream\n");
- printf(" F 7 - Call init encoder/decoder at random"
- " during a call\n");
- printf(" F 8 - Call encoder/decoder without having"
- " allocated memory for \n");
+ printf(
+ " F 7 - Call init encoder/decoder at random"
+ " during a call\n");
+ printf(
+ " F 8 - Call encoder/decoder without having"
+ " allocated memory for \n");
printf(" encoder/decoder instance\n");
printf(" F 9 - Call decodeB without calling decodeA\n");
printf(" F 10 - Call decodeB with garbage data\n");
- printf("[-PL num] :if -PL option is specified 0<num<100 will "
- "specify the\n");
+ printf(
+ "[-PL num] :if -PL option is specified 0<num<100 will "
+ "specify the\n");
printf(" percentage of packet loss\n\n");
- printf("[-G file] :if -G option is specified the file given is"
- " a .gns file\n");
+ printf(
+ "[-G file] :if -G option is specified the file given is"
+ " a .gns file\n");
printf(" that represents a network profile\n\n");
printf("[-NB num] :if -NB option, use the narrowband interfaces\n");
- printf(" num=1 => encode with narrowband encoder"
- " (infile is narrowband)\n");
- printf(" num=2 => decode with narrowband decoder"
- " (outfile is narrowband)\n\n");
+ printf(
+ " num=1 => encode with narrowband encoder"
+ " (infile is narrowband)\n");
+ printf(
+ " num=2 => decode with narrowband decoder"
+ " (outfile is narrowband)\n\n");
printf("[-CE num] :Test of APIs used by Conference Engine.\n");
- printf(" CE 1 - createInternal, freeInternal,"
- " getNewBitstream \n");
+ printf(
+ " CE 1 - createInternal, freeInternal,"
+ " getNewBitstream \n");
printf(" CE 2 - transcode, getBWE \n");
printf(" CE 3 - getSendBWE, setSendBWE. \n\n");
- printf("[-RTP_INIT num] :if -RTP_INIT option is specified num will be"
- " the initial\n");
+ printf(
+ "[-RTP_INIT num] :if -RTP_INIT option is specified num will be"
+ " the initial\n");
printf(" value of the rtp sequence number.\n\n");
printf("[--isolated-script-test-perf-output=file]\n");
- printf(" :If this option is specified, perf values will be"
- " written to this file in a JSON format.\n\n");
+ printf(
+ " :If this option is specified, perf values will be"
+ " written to this file in a JSON format.\n\n");
printf("Example usage :\n\n");
printf("%s -I bottleneck.txt speechIn.pcm speechOut.pcm\n\n", argv[0]);
exit(1);
-
}
/* Print version number */
@@ -250,7 +263,7 @@
i = 1;
/* Instantaneous mode */
- if (!strcmp ("-I", argv[i])) {
+ if (!strcmp("-I", argv[i])) {
printf("\nInstantaneous BottleNeck\n");
CodingMode = 1;
i++;
@@ -265,7 +278,7 @@
for (; i < argc; i++) {
/* Set (initial) bottleneck value */
- if (!strcmp ("-INITRATE", argv[i])) {
+ if (!strcmp("-INITRATE", argv[i])) {
if (i + 1 >= argc) {
printf("-INITRATE requires a parameter.\n");
exit(1);
@@ -273,8 +286,10 @@
rateBPS = atoi(argv[i + 1]);
setControlBWE = 1;
if ((rateBPS < 10000) || (rateBPS > 32000)) {
- printf("\n%d is not a initial rate. "
- "Valid values are in the range 10000 to 32000.\n", rateBPS);
+ printf(
+ "\n%d is not a initial rate. "
+ "Valid values are in the range 10000 to 32000.\n",
+ rateBPS);
exit(1);
}
printf("\nNew initial rate: %d\n", rateBPS);
@@ -282,15 +297,17 @@
}
/* Set (initial) framelength */
- if (!strcmp ("-FL", argv[i])) {
+ if (!strcmp("-FL", argv[i])) {
if (i + 1 >= argc) {
printf("-FL requires a parameter.\n");
exit(1);
}
framesize = atoi(argv[i + 1]);
if ((framesize != 30) && (framesize != 60)) {
- printf("\n%d is not a valid frame length. "
- "Valid length are 30 and 60 msec.\n", framesize);
+ printf(
+ "\n%d is not a valid frame length. "
+ "Valid length are 30 and 60 msec.\n",
+ framesize);
exit(1);
}
printf("\nFrame Length: %d\n", framesize);
@@ -298,13 +315,13 @@
}
/* Fixed frame length */
- if (!strcmp ("-FIXED_FL", argv[i])) {
+ if (!strcmp("-FIXED_FL", argv[i])) {
fixedFL = 1;
setControlBWE = 1;
}
/* Set maximum allowed payload size in bytes */
- if (!strcmp ("-MAX", argv[i])) {
+ if (!strcmp("-MAX", argv[i])) {
if (i + 1 >= argc) {
printf("-MAX requires a parameter.\n");
exit(1);
@@ -315,7 +332,7 @@
}
/* Set maximum rate in bytes */
- if (!strcmp ("-MAXRATE", argv[i])) {
+ if (!strcmp("-MAXRATE", argv[i])) {
if (i + 1 >= argc) {
printf("-MAXRATE requires a parameter.\n");
exit(1);
@@ -326,7 +343,7 @@
}
/* Test of fault scenarious */
- if (!strcmp ("-F", argv[i])) {
+ if (!strcmp("-F", argv[i])) {
if (i + 1 >= argc) {
printf("-F requires a parameter.");
exit(1);
@@ -334,59 +351,63 @@
testNum = atoi(argv[i + 1]);
printf("\nFault test: %d\n", testNum);
if (testNum < 1 || testNum > 10) {
- printf("\n%d is not a valid Fault Scenario number."
- " Valid Fault Scenarios are numbered 1-10.\n", testNum);
+ printf(
+ "\n%d is not a valid Fault Scenario number."
+ " Valid Fault Scenarios are numbered 1-10.\n",
+ testNum);
exit(1);
}
i++;
}
/* Packet loss test */
- if (!strcmp ("-PL", argv[i])) {
+ if (!strcmp("-PL", argv[i])) {
if (i + 1 >= argc) {
printf("-PL requires a parameter.\n");
exit(1);
}
- if( isdigit( *argv[i+1] ) ) {
- packetLossPercent = atoi( argv[i+1] );
- if( (packetLossPercent < 0) | (packetLossPercent > 100) ) {
- printf( "\nInvalid packet loss perentage \n" );
- exit( 1 );
+ if (isdigit(*argv[i + 1])) {
+ packetLossPercent = atoi(argv[i + 1]);
+ if ((packetLossPercent < 0) | (packetLossPercent > 100)) {
+ printf("\nInvalid packet loss perentage \n");
+ exit(1);
}
- if( packetLossPercent > 0 ) {
- printf( "\nSimulating %d %% of independent packet loss\n",
- packetLossPercent );
+ if (packetLossPercent > 0) {
+ printf("\nSimulating %d %% of independent packet loss\n",
+ packetLossPercent);
} else {
- printf( "\nNo Packet Loss Is Simulated \n" );
+ printf("\nNo Packet Loss Is Simulated \n");
}
readLoss = 0;
} else {
readLoss = 1;
- plFile = fopen( argv[i+1], "rb" );
- if( plFile == NULL ) {
- FAIL() << "Couldn't open the frameloss file: " << argv[i+1];
+ plFile = fopen(argv[i + 1], "rb");
+ if (plFile == NULL) {
+ FAIL() << "Couldn't open the frameloss file: " << argv[i + 1];
}
- printf( "\nSimulating packet loss through the given "
- "channel file: %s\n", argv[i+1] );
+ printf(
+ "\nSimulating packet loss through the given "
+ "channel file: %s\n",
+ argv[i + 1]);
}
i++;
}
/* Random packetlosses */
- if (!strcmp ("-rnd", argv[i])) {
- srand(time(NULL) );
- printf( "\n Random pattern in lossed packets \n" );
+ if (!strcmp("-rnd", argv[i])) {
+ srand(time(NULL));
+ printf("\n Random pattern in lossed packets \n");
}
/* Use gns file */
- if (!strcmp ("-G", argv[i])) {
+ if (!strcmp("-G", argv[i])) {
if (i + 1 >= argc) {
printf("-G requires a parameter.\n");
exit(1);
}
sscanf(argv[i + 1], "%s", gns_file);
fp_gns = fopen(gns_file, "rb");
- if (fp_gns == NULL) {
+ if (fp_gns == NULL) {
FAIL() << "Cannot read file " << gns_file << ".";
}
gns = 1;
@@ -394,7 +415,7 @@
}
/* Run Narrowband interfaces (either encoder or decoder) */
- if (!strcmp ("-NB", argv[i])) {
+ if (!strcmp("-NB", argv[i])) {
if (i + 1 >= argc) {
printf("-NB requires a parameter.\n");
exit(1);
@@ -404,25 +425,27 @@
}
/* Run Conference Engine APIs */
- if (!strcmp ("-CE", argv[i])) {
+ if (!strcmp("-CE", argv[i])) {
if (i + 1 >= argc) {
printf("-CE requires a parameter.\n");
exit(1);
}
testCE = atoi(argv[i + 1]);
- if (testCE==1 || testCE==2) {
+ if (testCE == 1 || testCE == 2) {
i++;
- scale = (float)atof( argv[i+1] );
+ scale = (float)atof(argv[i + 1]);
} else if (testCE < 1 || testCE > 3) {
- printf("\n%d is not a valid CE-test number, valid Fault "
- "Scenarios are numbered 1-3\n", testCE);
+ printf(
+ "\n%d is not a valid CE-test number, valid Fault "
+ "Scenarios are numbered 1-3\n",
+ testCE);
exit(1);
}
i++;
}
/* Set initial RTP number */
- if (!strcmp ("-RTP_INIT", argv[i])) {
+ if (!strcmp("-RTP_INIT", argv[i])) {
if (i + 1 >= argc) {
printf("-RTP_INIT requires a parameter.\n");
exit(1);
@@ -442,16 +465,16 @@
/* Get Bottleneck value */
/* Gns files and bottleneck should not and can not be used simultaneously */
- bottleneck = atoi(argv[CodingMode+1]);
+ bottleneck = atoi(argv[CodingMode + 1]);
if (bottleneck == 0 && gns == 0) {
- sscanf(argv[CodingMode+1], "%s", bottleneck_file);
+ sscanf(argv[CodingMode + 1], "%s", bottleneck_file);
f_bn = fopen(bottleneck_file, "rb");
- if (f_bn == NULL) {
+ if (f_bn == NULL) {
printf("No value provided for BottleNeck\n");
FAIL() << "Cannot read file " << bottleneck_file;
} else {
int aux_var;
- printf("reading bottleneck rates from file %s\n\n",bottleneck_file);
+ printf("reading bottleneck rates from file %s\n\n", bottleneck_file);
if (fscanf(f_bn, "%d", &aux_var) == EOF) {
/* Set pointer to beginning of file */
fseek(f_bn, 0L, SEEK_SET);
@@ -481,18 +504,18 @@
outbitsname[h] = outname[h];
h++;
}
- for (k=0; k<5; k++) {
+ for (k = 0; k < 5; k++) {
outbitsname[h] = tmpBit[k];
h++;
}
- if ((inp = fopen(inname,"rb")) == NULL) {
+ if ((inp = fopen(inname, "rb")) == NULL) {
FAIL() << " iSAC: Cannot read file " << inname;
}
- if ((outp = fopen(outname,"wb")) == NULL) {
+ if ((outp = fopen(outname, "wb")) == NULL) {
FAIL() << " iSAC: Cannot write file " << outname;
}
- if ((outbits = fopen(outbitsname,"wb")) == NULL) {
+ if ((outbits = fopen(outbitsname, "wb")) == NULL) {
FAIL() << " iSAC: Cannot write file " << outbitsname;
}
printf("\nInput:%s\nOutput:%s\n\n", inname, outname);
@@ -502,30 +525,28 @@
/* Test to run decoder with garbage data */
srand(random_seed);
- if ( (seedfile = fopen(SEED_FILE, "a+t") ) == NULL ) {
+ if ((seedfile = fopen(SEED_FILE, "a+t")) == NULL) {
printf("Error: Could not open file %s\n", SEED_FILE);
- }
- else {
+ } else {
fprintf(seedfile, "%u\n", random_seed);
fclose(seedfile);
}
}
/* Runtime statistics */
- starttime = clock()/(double)CLOCKS_PER_SEC;
+ starttime = clock() / (double)CLOCKS_PER_SEC;
/* Initialize the ISAC and BN structs */
- if (testNum != 8)
- {
- if(1){
- err =WebRtcIsacfix_Create(&ISAC_main_inst);
- }else{
+ if (testNum != 8) {
+ if (1) {
+ err = WebRtcIsacfix_Create(&ISAC_main_inst);
+ } else {
/* Test the Assign functions */
int sss;
- void *ppp;
- err =WebRtcIsacfix_AssignSize(&sss);
- ppp=malloc(sss);
- err =WebRtcIsacfix_Assign(&ISAC_main_inst,ppp);
+ void* ppp;
+ err = WebRtcIsacfix_AssignSize(&sss);
+ ppp = malloc(sss);
+ err = WebRtcIsacfix_Assign(&ISAC_main_inst, ppp);
}
/* Error check */
if (err < 0) {
@@ -541,13 +562,13 @@
}
/* Init of bandwidth data */
- BN_data.send_time = 0;
- BN_data.arrival_time = 0;
- BN_data.sample_count = 0;
- BN_data.rtp_number = 0;
+ BN_data.send_time = 0;
+ BN_data.arrival_time = 0;
+ BN_data.sample_count = 0;
+ BN_data.rtp_number = 0;
/* Initialize encoder and decoder */
- framecnt= 0;
+ framecnt = 0;
endfile = 0;
if (testNum != 1) {
WebRtcIsacfix_EncoderInit(ISAC_main_inst, CodingMode);
@@ -560,10 +581,10 @@
err = WebRtcIsacfix_Control(ISAC_main_inst, bottleneck, framesize);
if (err < 0) {
/* exit if returned with error */
- errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
+ errtype = WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
printf("\n\n Error in control: %d.\n\n", errtype);
}
- } else if(setControlBWE == 1) {
+ } else if (setControlBWE == 1) {
err = WebRtcIsacfix_ControlBwe(ISAC_main_inst, rateBPS, framesize, fixedFL);
}
@@ -571,7 +592,7 @@
err = WebRtcIsacfix_SetMaxPayloadSize(ISAC_main_inst, payloadSize);
if (err < 0) {
/* exit if returned with error */
- errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
+ errtype = WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
FAIL() << "Error in SetMaxPayloadSize: " << errtype;
}
}
@@ -579,35 +600,32 @@
err = WebRtcIsacfix_SetMaxRate(ISAC_main_inst, payloadRate);
if (err < 0) {
/* exit if returned with error */
- errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
+ errtype = WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
FAIL() << "Error in SetMaxRateInBytes: " << errtype;
}
}
*speechType = 1;
-
while (endfile == 0) {
-
- if(testNum == 7 && (rand()%2 == 0)) {
+ if (testNum == 7 && (rand() % 2 == 0)) {
err = WebRtcIsacfix_EncoderInit(ISAC_main_inst, CodingMode);
/* Error check */
if (err < 0) {
- errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
+ errtype = WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
printf("\n\n Error in encoderinit: %d.\n\n", errtype);
}
WebRtcIsacfix_DecoderInit(ISAC_main_inst);
}
-
cur_framesmpls = 0;
while (1) {
/* Read 10 ms speech block */
if (nbTest != 1) {
endfile = readframe(shortdata, inp, FRAMESAMPLES_10ms);
} else {
- endfile = readframe(shortdata, inp, (FRAMESAMPLES_10ms/2));
+ endfile = readframe(shortdata, inp, (FRAMESAMPLES_10ms / 2));
}
if (testNum == 7) {
@@ -620,22 +638,18 @@
short bwe;
/* Encode */
- stream_len_int = WebRtcIsacfix_Encode(ISAC_main_inst,
- shortdata,
+ stream_len_int = WebRtcIsacfix_Encode(ISAC_main_inst, shortdata,
(uint8_t*)streamdata);
/* If packet is ready, and CE testing, call the different API
functions from the internal API. */
- if (stream_len_int>0) {
+ if (stream_len_int > 0) {
if (testCE == 1) {
err = WebRtcIsacfix_ReadBwIndex(
reinterpret_cast<const uint8_t*>(streamdata),
- static_cast<size_t>(stream_len_int),
- &bwe);
+ static_cast<size_t>(stream_len_int), &bwe);
stream_len_int = WebRtcIsacfix_GetNewBitStream(
- ISAC_main_inst,
- bwe,
- scale,
+ ISAC_main_inst, bwe, scale,
reinterpret_cast<uint8_t*>(streamdata));
} else if (testCE == 2) {
/* transcode function not supported */
@@ -646,37 +660,33 @@
err = WebRtcIsacfix_GetDownLinkBwIndex(ISAC_main_inst, &bwe);
/* Error Check */
if (err < 0) {
- errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
+ errtype = WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
printf("\nError in getSendBWE: %d.\n", errtype);
}
err = WebRtcIsacfix_UpdateUplinkBw(ISAC_main_inst, bwe);
/* Error Check */
if (err < 0) {
- errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
+ errtype = WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
printf("\nError in setBWE: %d.\n", errtype);
}
-
}
}
} else {
#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
- stream_len_int = WebRtcIsacfix_EncodeNb(ISAC_main_inst,
- shortdata,
- streamdata);
+ stream_len_int =
+ WebRtcIsacfix_EncodeNb(ISAC_main_inst, shortdata, streamdata);
#else
stream_len_int = -1;
#endif
}
- }
- else
- {
+ } else {
break;
}
if (stream_len_int < 0 || err < 0) {
/* exit if returned with error */
- errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
+ errtype = WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
printf("\nError in encoder: %d.\n", errtype);
} else {
stream_len = static_cast<size_t>(stream_len_int);
@@ -705,7 +715,8 @@
}
/* exit encoder loop if the encoder returned a bitstream */
- if (stream_len != 0) break;
+ if (stream_len != 0)
+ break;
}
/* make coded sequence to short be inreasing */
@@ -722,7 +733,7 @@
if (testNum == 6) {
srand(time(NULL));
- for (i = 0; i < static_cast<int>(stream_len); i++ ) {
+ for (i = 0; i < static_cast<int>(stream_len); i++) {
streamdata[i] = rand();
}
}
@@ -740,8 +751,7 @@
/* simulate packet handling through NetEq and the modem */
if (!(testNum == 3 && framecnt == 0)) {
if (gns == 0) {
- get_arrival_time(cur_framesmpls, stream_len, bottleneck,
- &BN_data);
+ get_arrival_time(cur_framesmpls, stream_len, bottleneck, &BN_data);
} else {
get_arrival_time2(cur_framesmpls, cur_delay, &BN_data);
}
@@ -749,44 +759,38 @@
/* packet not dropped */
if (cur_delay != -1) {
-
/* Error test number 10, garbage data */
if (testNum == 10) {
- for ( i = 0; i < static_cast<int>(stream_len); i++) {
- streamdata[i] = (short) (streamdata[i] + (short) rand());
+ for (i = 0; i < static_cast<int>(stream_len); i++) {
+ streamdata[i] = (short)(streamdata[i] + (short)rand());
}
}
if (testNum != 9) {
err = WebRtcIsacfix_UpdateBwEstimate(
- ISAC_main_inst,
- reinterpret_cast<const uint8_t*>(streamdata),
- stream_len,
- BN_data.rtp_number,
- BN_data.send_time,
+ ISAC_main_inst, reinterpret_cast<const uint8_t*>(streamdata),
+ stream_len, BN_data.rtp_number, BN_data.send_time,
BN_data.arrival_time);
if (err < 0) {
/* exit if returned with error */
- errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
+ errtype = WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
printf("\nError in decoder: %d.\n", errtype);
}
}
- if( readLoss == 1 ) {
- if( fread( &lostFrame, sizeof(int16_t), 1, plFile ) != 1 ) {
- rewind( plFile );
+ if (readLoss == 1) {
+ if (fread(&lostFrame, sizeof(int16_t), 1, plFile) != 1) {
+ rewind(plFile);
}
lostFrame = !lostFrame;
} else {
- lostFrame = (rand()%100 < packetLossPercent);
+ lostFrame = (rand() % 100 < packetLossPercent);
}
-
-
/* iSAC decoding */
- if( lostFrame && framecnt > 0) {
- if (nbTest !=2) {
+ if (lostFrame && framecnt > 0) {
+ if (nbTest != 2) {
declen = static_cast<int>(
WebRtcIsacfix_DecodePlc(ISAC_main_inst, decoded, prevFrameSize));
} else {
@@ -799,32 +803,29 @@
}
lostPackets++;
} else {
- if (nbTest !=2 ) {
+ if (nbTest != 2) {
size_t FL;
/* Call getFramelen, only used here for function test */
err = WebRtcIsacfix_ReadFrameLen(
reinterpret_cast<const uint8_t*>(streamdata), stream_len, &FL);
declen = WebRtcIsacfix_Decode(
- ISAC_main_inst,
- reinterpret_cast<const uint8_t*>(streamdata),
- stream_len,
- decoded,
- speechType);
+ ISAC_main_inst, reinterpret_cast<const uint8_t*>(streamdata),
+ stream_len, decoded, speechType);
/* Error check */
if (err < 0 || declen < 0 || FL != static_cast<size_t>(declen)) {
- errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
+ errtype = WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
printf(
"\nError %d in ReadFrameLen (%s), Decode (%s), with FL %zu and "
"declen %d.\n",
errtype, err < 0 ? "yes" : "no", declen < 0 ? "yes" : "no", FL,
declen);
}
- prevFrameSize = static_cast<size_t>(declen/480);
+ prevFrameSize = static_cast<size_t>(declen / 480);
} else {
#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
- declen = WebRtcIsacfix_DecodeNb( ISAC_main_inst, streamdata,
- stream_len, decoded, speechType );
+ declen = WebRtcIsacfix_DecodeNb(ISAC_main_inst, streamdata,
+ stream_len, decoded, speechType);
#else
declen = -1;
#endif
@@ -834,13 +835,12 @@
if (declen <= 0) {
/* exit if returned with error */
- errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
+ errtype = WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
printf("\nError in decoder: %d.\n", errtype);
}
/* Write decoded speech frame to file */
- if (fwrite(decoded, sizeof(int16_t),
- declen, outp) != (size_t)declen) {
+ if (fwrite(decoded, sizeof(int16_t), declen, outp) != (size_t)declen) {
FAIL();
}
// fprintf( ratefile, "%f \n", stream_len / ( ((double)declen)/
@@ -855,30 +855,28 @@
/* Error test number 10, garbage data */
if (testNum == 10) {
- if ( (seedfile = fopen(SEED_FILE, "a+t") ) == NULL ) {
- printf( "Error: Could not open file %s\n", SEED_FILE);
- }
- else {
+ if ((seedfile = fopen(SEED_FILE, "a+t")) == NULL) {
+ printf("Error: Could not open file %s\n", SEED_FILE);
+ } else {
fprintf(seedfile, "ok\n\n");
fclose(seedfile);
}
}
}
printf("\nLost Frames %d ~ %4.1f%%\n", lostPackets,
- (double)lostPackets/(double)framecnt*100.0 );
+ (double)lostPackets / (double)framecnt * 100.0);
printf("\n\ntotal bits = %d bits", totalbits);
printf("\nmeasured average bitrate = %0.3f kbits/s",
- (double)totalbits *(FS/1000) / totalsmpls);
+ (double)totalbits * (FS / 1000) / totalsmpls);
printf("\n");
/* Runtime statistics */
-
- runtime = (double)(((double)clock()/(double)CLOCKS_PER_SEC)-starttime);
- length_file = ((double)framecnt*(double)declen/FS);
+ runtime = (double)(((double)clock() / (double)CLOCKS_PER_SEC) - starttime);
+ length_file = ((double)framecnt * (double)declen / FS);
printf("\n\nLength of speech file: %.1f s\n", length_file);
- printf("Time to run iSAC: %.2f s (%.2f %% of realtime)\n\n",
- runtime, (100*runtime/length_file));
+ printf("Time to run iSAC: %.2f s (%.2f %% of realtime)\n\n", runtime,
+ (100 * runtime / length_file));
printf("\n\n_______________________________________________\n");
// Record the results with Perf test tools.
@@ -893,7 +891,7 @@
fclose(outp);
fclose(outbits);
- if ( testCE == 1) {
+ if (testCE == 1) {
WebRtcIsacfix_FreeInternal(ISAC_main_inst);
}
WebRtcIsacfix_Free(ISAC_main_inst);
diff --git a/modules/audio_coding/codecs/isac/main/include/isac.h b/modules/audio_coding/codecs/isac/main/include/isac.h
index e1ee818..1d7e075 100644
--- a/modules/audio_coding/codecs/isac/main/include/isac.h
+++ b/modules/audio_coding/codecs/isac/main/include/isac.h
@@ -16,709 +16,647 @@
#include "modules/audio_coding/codecs/isac/bandwidth_info.h"
#include "typedefs.h" // NOLINT(build/include)
-typedef struct WebRtcISACStruct ISACStruct;
+typedef struct WebRtcISACStruct ISACStruct;
#if defined(__cplusplus)
extern "C" {
#endif
- /******************************************************************************
- * WebRtcIsac_AssignSize(...)
- *
- * This function returns the size of the ISAC instance, so that the instance
- * can be created outside iSAC.
- *
- * Input:
- * - samplingRate : sampling rate of the input/output audio.
- *
- * Output:
- * - sizeinbytes : number of bytes needed to allocate for the
- * instance.
- *
- * Return value : 0 - Ok
- * -1 - Error
- */
+/******************************************************************************
+ * WebRtcIsac_AssignSize(...)
+ *
+ * This function returns the size of the ISAC instance, so that the instance
+ * can be created outside iSAC.
+ *
+ * Input:
+ * - samplingRate : sampling rate of the input/output audio.
+ *
+ * Output:
+ * - sizeinbytes : number of bytes needed to allocate for the
+ * instance.
+ *
+ * Return value : 0 - Ok
+ * -1 - Error
+ */
- int16_t WebRtcIsac_AssignSize(
- int* sizeinbytes);
+int16_t WebRtcIsac_AssignSize(int* sizeinbytes);
+/******************************************************************************
+ * WebRtcIsac_Assign(...)
+ *
+ * This function assignes the memory already created to the ISAC instance.
+ *
+ * Input:
+ * - *ISAC_main_inst : a pointer to the coder instance.
+ * - samplingRate : sampling rate of the input/output audio.
+ * - ISAC_inst_Addr : the already allocated memory, where we put the
+ * iSAC structure.
+ *
+ * Return value : 0 - Ok
+ * -1 - Error
+ */
- /******************************************************************************
- * WebRtcIsac_Assign(...)
- *
- * This function assignes the memory already created to the ISAC instance.
- *
- * Input:
- * - *ISAC_main_inst : a pointer to the coder instance.
- * - samplingRate : sampling rate of the input/output audio.
- * - ISAC_inst_Addr : the already allocated memory, where we put the
- * iSAC structure.
- *
- * Return value : 0 - Ok
- * -1 - Error
- */
+int16_t WebRtcIsac_Assign(ISACStruct** ISAC_main_inst, void* ISAC_inst_Addr);
- int16_t WebRtcIsac_Assign(
- ISACStruct** ISAC_main_inst,
- void* ISAC_inst_Addr);
+/******************************************************************************
+ * WebRtcIsac_Create(...)
+ *
+ * This function creates an ISAC instance, which will contain the state
+ * information for one coding/decoding channel.
+ *
+ * Input:
+ * - *ISAC_main_inst : a pointer to the coder instance.
+ *
+ * Return value : 0 - Ok
+ * -1 - Error
+ */
+int16_t WebRtcIsac_Create(ISACStruct** ISAC_main_inst);
- /******************************************************************************
- * WebRtcIsac_Create(...)
- *
- * This function creates an ISAC instance, which will contain the state
- * information for one coding/decoding channel.
- *
- * Input:
- * - *ISAC_main_inst : a pointer to the coder instance.
- *
- * Return value : 0 - Ok
- * -1 - Error
- */
+/******************************************************************************
+ * WebRtcIsac_Free(...)
+ *
+ * This function frees the ISAC instance created at the beginning.
+ *
+ * Input:
+ * - ISAC_main_inst : an ISAC instance.
+ *
+ * Return value : 0 - Ok
+ * -1 - Error
+ */
- int16_t WebRtcIsac_Create(
- ISACStruct** ISAC_main_inst);
+int16_t WebRtcIsac_Free(ISACStruct* ISAC_main_inst);
+/******************************************************************************
+ * WebRtcIsac_EncoderInit(...)
+ *
+ * This function initializes an ISAC instance prior to the encoder calls.
+ *
+ * Input:
+ * - ISAC_main_inst : ISAC instance.
+ * - CodingMode : 0 -> Bit rate and frame length are
+ * automatically adjusted to available bandwidth
+ * on transmission channel, just valid if codec
+ * is created to work in wideband mode.
+ * 1 -> User sets a frame length and a target bit
+ * rate which is taken as the maximum
+ * short-term average bit rate.
+ *
+ * Return value : 0 - Ok
+ * -1 - Error
+ */
- /******************************************************************************
- * WebRtcIsac_Free(...)
- *
- * This function frees the ISAC instance created at the beginning.
- *
- * Input:
- * - ISAC_main_inst : an ISAC instance.
- *
- * Return value : 0 - Ok
- * -1 - Error
- */
+int16_t WebRtcIsac_EncoderInit(ISACStruct* ISAC_main_inst, int16_t CodingMode);
- int16_t WebRtcIsac_Free(
- ISACStruct* ISAC_main_inst);
+/******************************************************************************
+ * WebRtcIsac_Encode(...)
+ *
+ * This function encodes 10ms audio blocks and inserts it into a package.
+ * Input speech length has 160 samples if operating at 16 kHz sampling
+ * rate, or 320 if operating at 32 kHz sampling rate. The encoder buffers the
+ * input audio until the whole frame is buffered then proceeds with encoding.
+ *
+ *
+ * Input:
+ * - ISAC_main_inst : ISAC instance.
+ * - speechIn : input speech vector.
+ *
+ * Output:
+ * - encoded : the encoded data vector
+ *
+ * Return value:
+ * : >0 - Length (in bytes) of coded data
+ * : 0 - The buffer didn't reach the chosen
+ * frame-size so it keeps buffering speech
+ * samples.
+ * : -1 - Error
+ */
+int WebRtcIsac_Encode(ISACStruct* ISAC_main_inst,
+ const int16_t* speechIn,
+ uint8_t* encoded);
- /******************************************************************************
- * WebRtcIsac_EncoderInit(...)
- *
- * This function initializes an ISAC instance prior to the encoder calls.
- *
- * Input:
- * - ISAC_main_inst : ISAC instance.
- * - CodingMode : 0 -> Bit rate and frame length are
- * automatically adjusted to available bandwidth
- * on transmission channel, just valid if codec
- * is created to work in wideband mode.
- * 1 -> User sets a frame length and a target bit
- * rate which is taken as the maximum
- * short-term average bit rate.
- *
- * Return value : 0 - Ok
- * -1 - Error
- */
+/******************************************************************************
+ * WebRtcIsac_DecoderInit(...)
+ *
+ * This function initializes an ISAC instance prior to the decoder calls.
+ *
+ * Input:
+ * - ISAC_main_inst : ISAC instance.
+ */
- int16_t WebRtcIsac_EncoderInit(
- ISACStruct* ISAC_main_inst,
- int16_t CodingMode);
+void WebRtcIsac_DecoderInit(ISACStruct* ISAC_main_inst);
+/******************************************************************************
+ * WebRtcIsac_UpdateBwEstimate(...)
+ *
+ * This function updates the estimate of the bandwidth.
+ *
+ * Input:
+ * - ISAC_main_inst : ISAC instance.
+ * - encoded : encoded ISAC frame(s).
+ * - packet_size : size of the packet.
+ * - rtp_seq_number : the RTP number of the packet.
+ * - send_ts : the RTP send timestamp, given in samples
+ * - arr_ts : the arrival time of the packet (from NetEq)
+ * in samples.
+ *
+ * Return value : 0 - Ok
+ * -1 - Error
+ */
- /******************************************************************************
- * WebRtcIsac_Encode(...)
- *
- * This function encodes 10ms audio blocks and inserts it into a package.
- * Input speech length has 160 samples if operating at 16 kHz sampling
- * rate, or 320 if operating at 32 kHz sampling rate. The encoder buffers the
- * input audio until the whole frame is buffered then proceeds with encoding.
- *
- *
- * Input:
- * - ISAC_main_inst : ISAC instance.
- * - speechIn : input speech vector.
- *
- * Output:
- * - encoded : the encoded data vector
- *
- * Return value:
- * : >0 - Length (in bytes) of coded data
- * : 0 - The buffer didn't reach the chosen
- * frame-size so it keeps buffering speech
- * samples.
- * : -1 - Error
- */
+int16_t WebRtcIsac_UpdateBwEstimate(ISACStruct* ISAC_main_inst,
+ const uint8_t* encoded,
+ size_t packet_size,
+ uint16_t rtp_seq_number,
+ uint32_t send_ts,
+ uint32_t arr_ts);
- int WebRtcIsac_Encode(
- ISACStruct* ISAC_main_inst,
- const int16_t* speechIn,
- uint8_t* encoded);
+/******************************************************************************
+ * WebRtcIsac_Decode(...)
+ *
+ * This function decodes an ISAC frame. At 16 kHz sampling rate, the length
+ * of the output audio could be either 480 or 960 samples, equivalent to
+ * 30 or 60 ms respectively. At 32 kHz sampling rate, the length of the
+ * output audio is 960 samples, which is 30 ms.
+ *
+ * Input:
+ * - ISAC_main_inst : ISAC instance.
+ * - encoded : encoded ISAC frame(s).
+ * - len : bytes in encoded vector.
+ *
+ * Output:
+ * - decoded : The decoded vector.
+ *
+ * Return value : >0 - number of samples in decoded vector.
+ * -1 - Error.
+ */
+int WebRtcIsac_Decode(ISACStruct* ISAC_main_inst,
+ const uint8_t* encoded,
+ size_t len,
+ int16_t* decoded,
+ int16_t* speechType);
- /******************************************************************************
- * WebRtcIsac_DecoderInit(...)
- *
- * This function initializes an ISAC instance prior to the decoder calls.
- *
- * Input:
- * - ISAC_main_inst : ISAC instance.
- */
+/******************************************************************************
+ * WebRtcIsac_DecodePlc(...)
+ *
+ * This function conducts PLC for ISAC frame(s). Output speech length
+ * will be a multiple of frames, i.e. multiples of 30 ms audio. Therefore,
+ * the output is multiple of 480 samples if operating at 16 kHz and multiple
+ * of 960 if operating at 32 kHz.
+ *
+ * Input:
+ * - ISAC_main_inst : ISAC instance.
+ * - noOfLostFrames : Number of PLC frames to produce.
+ *
+ * Output:
+ * - decoded : The decoded vector.
+ *
+ * Return value : Number of samples in decoded PLC vector
+ */
- void WebRtcIsac_DecoderInit(ISACStruct* ISAC_main_inst);
+size_t WebRtcIsac_DecodePlc(ISACStruct* ISAC_main_inst,
+ int16_t* decoded,
+ size_t noOfLostFrames);
- /******************************************************************************
- * WebRtcIsac_UpdateBwEstimate(...)
- *
- * This function updates the estimate of the bandwidth.
- *
- * Input:
- * - ISAC_main_inst : ISAC instance.
- * - encoded : encoded ISAC frame(s).
- * - packet_size : size of the packet.
- * - rtp_seq_number : the RTP number of the packet.
- * - send_ts : the RTP send timestamp, given in samples
- * - arr_ts : the arrival time of the packet (from NetEq)
- * in samples.
- *
- * Return value : 0 - Ok
- * -1 - Error
- */
+/******************************************************************************
+ * WebRtcIsac_Control(...)
+ *
+ * This function sets the limit on the short-term average bit-rate and the
+ * frame length. Should be used only in Instantaneous mode. At 16 kHz sampling
+ * rate, an average bit-rate between 10000 to 32000 bps is valid and a
+ * frame-size of 30 or 60 ms is acceptable. At 32 kHz, an average bit-rate
+ * between 10000 to 56000 is acceptable, and the valid frame-size is 30 ms.
+ *
+ * Input:
+ * - ISAC_main_inst : ISAC instance.
+ * - rate : limit on the short-term average bit rate,
+ * in bits/second.
+ * - framesize : frame-size in millisecond.
+ *
+ * Return value : 0 - ok
+ * -1 - Error
+ */
- int16_t WebRtcIsac_UpdateBwEstimate(
- ISACStruct* ISAC_main_inst,
- const uint8_t* encoded,
- size_t packet_size,
- uint16_t rtp_seq_number,
- uint32_t send_ts,
- uint32_t arr_ts);
+int16_t WebRtcIsac_Control(ISACStruct* ISAC_main_inst,
+ int32_t rate,
+ int framesize);
+void WebRtcIsac_SetInitialBweBottleneck(ISACStruct* ISAC_main_inst,
+ int bottleneck_bits_per_second);
- /******************************************************************************
- * WebRtcIsac_Decode(...)
- *
- * This function decodes an ISAC frame. At 16 kHz sampling rate, the length
- * of the output audio could be either 480 or 960 samples, equivalent to
- * 30 or 60 ms respectively. At 32 kHz sampling rate, the length of the
- * output audio is 960 samples, which is 30 ms.
- *
- * Input:
- * - ISAC_main_inst : ISAC instance.
- * - encoded : encoded ISAC frame(s).
- * - len : bytes in encoded vector.
- *
- * Output:
- * - decoded : The decoded vector.
- *
- * Return value : >0 - number of samples in decoded vector.
- * -1 - Error.
- */
+/******************************************************************************
+ * WebRtcIsac_ControlBwe(...)
+ *
+ * This function sets the initial values of bottleneck and frame-size if
+ * iSAC is used in channel-adaptive mode. Therefore, this API is not
+ * applicable if the codec is created to operate in super-wideband mode.
+ *
+ * Through this API, users can enforce a frame-size for all values of
+ * bottleneck. Then iSAC will not automatically change the frame-size.
+ *
+ *
+ * Input:
+ * - ISAC_main_inst : ISAC instance.
+ * - rateBPS : initial value of bottleneck in bits/second
+ * 10000 <= rateBPS <= 56000 is accepted
+ * For default bottleneck set rateBPS = 0
+ * - frameSizeMs : number of milliseconds per frame (30 or 60)
+ * - enforceFrameSize : 1 to enforce the given frame-size through
+ * out the adaptation process, 0 to let iSAC
+ * change the frame-size if required.
+ *
+ * Return value : 0 - ok
+ * -1 - Error
+ */
- int WebRtcIsac_Decode(
- ISACStruct* ISAC_main_inst,
- const uint8_t* encoded,
- size_t len,
- int16_t* decoded,
- int16_t* speechType);
+int16_t WebRtcIsac_ControlBwe(ISACStruct* ISAC_main_inst,
+ int32_t rateBPS,
+ int frameSizeMs,
+ int16_t enforceFrameSize);
+/******************************************************************************
+ * WebRtcIsac_ReadFrameLen(...)
+ *
+ * This function returns the length of the frame represented in the packet.
+ *
+ * Input:
+ * - encoded : Encoded bit-stream
+ *
+ * Output:
+ * - frameLength : Length of frame in packet (in samples)
+ *
+ */
- /******************************************************************************
- * WebRtcIsac_DecodePlc(...)
- *
- * This function conducts PLC for ISAC frame(s). Output speech length
- * will be a multiple of frames, i.e. multiples of 30 ms audio. Therefore,
- * the output is multiple of 480 samples if operating at 16 kHz and multiple
- * of 960 if operating at 32 kHz.
- *
- * Input:
- * - ISAC_main_inst : ISAC instance.
- * - noOfLostFrames : Number of PLC frames to produce.
- *
- * Output:
- * - decoded : The decoded vector.
- *
- * Return value : Number of samples in decoded PLC vector
- */
+int16_t WebRtcIsac_ReadFrameLen(ISACStruct* ISAC_main_inst,
+ const uint8_t* encoded,
+ int16_t* frameLength);
- size_t WebRtcIsac_DecodePlc(
- ISACStruct* ISAC_main_inst,
- int16_t* decoded,
- size_t noOfLostFrames);
+/******************************************************************************
+ * WebRtcIsac_version(...)
+ *
+ * This function returns the version number.
+ *
+ * Output:
+ * - version : Pointer to character string
+ *
+ */
+void WebRtcIsac_version(char* version);
- /******************************************************************************
- * WebRtcIsac_Control(...)
- *
- * This function sets the limit on the short-term average bit-rate and the
- * frame length. Should be used only in Instantaneous mode. At 16 kHz sampling
- * rate, an average bit-rate between 10000 to 32000 bps is valid and a
- * frame-size of 30 or 60 ms is acceptable. At 32 kHz, an average bit-rate
- * between 10000 to 56000 is acceptable, and the valid frame-size is 30 ms.
- *
- * Input:
- * - ISAC_main_inst : ISAC instance.
- * - rate : limit on the short-term average bit rate,
- * in bits/second.
- * - framesize : frame-size in millisecond.
- *
- * Return value : 0 - ok
- * -1 - Error
- */
+/******************************************************************************
+ * WebRtcIsac_GetErrorCode(...)
+ *
+ * This function can be used to check the error code of an iSAC instance. When
+ * a function returns -1 a error code will be set for that instance. The
+ * function below extract the code of the last error that occurred in the
+ * specified instance.
+ *
+ * Input:
+ * - ISAC_main_inst : ISAC instance
+ *
+ * Return value : Error code
+ */
- int16_t WebRtcIsac_Control(
- ISACStruct* ISAC_main_inst,
- int32_t rate,
- int framesize);
+int16_t WebRtcIsac_GetErrorCode(ISACStruct* ISAC_main_inst);
- void WebRtcIsac_SetInitialBweBottleneck(ISACStruct* ISAC_main_inst,
- int bottleneck_bits_per_second);
+/****************************************************************************
+ * WebRtcIsac_GetUplinkBw(...)
+ *
+ * This function outputs the target bottleneck of the codec. In
+ * channel-adaptive mode, the target bottleneck is specified through in-band
+ * signalling retreived by bandwidth estimator.
+ * In channel-independent, also called instantaneous mode, the target
+ * bottleneck is provided to the encoder by calling xxx_control(...). If
+ * xxx_control is never called the default values is returned. The default
+ * value for bottleneck at 16 kHz encoder sampling rate is 32000 bits/sec,
+ * and it is 56000 bits/sec for 32 kHz sampling rate.
+ * Note that the output is the iSAC internal operating bottleneck which might
+ * differ slightly from the one provided through xxx_control().
+ *
+ * Input:
+ * - ISAC_main_inst : iSAC instance
+ *
+ * Output:
+ * - *bottleneck : bottleneck in bits/sec
+ *
+ * Return value : -1 if error happens
+ * 0 bit-rates computed correctly.
+ */
- /******************************************************************************
- * WebRtcIsac_ControlBwe(...)
- *
- * This function sets the initial values of bottleneck and frame-size if
- * iSAC is used in channel-adaptive mode. Therefore, this API is not
- * applicable if the codec is created to operate in super-wideband mode.
- *
- * Through this API, users can enforce a frame-size for all values of
- * bottleneck. Then iSAC will not automatically change the frame-size.
- *
- *
- * Input:
- * - ISAC_main_inst : ISAC instance.
- * - rateBPS : initial value of bottleneck in bits/second
- * 10000 <= rateBPS <= 56000 is accepted
- * For default bottleneck set rateBPS = 0
- * - frameSizeMs : number of milliseconds per frame (30 or 60)
- * - enforceFrameSize : 1 to enforce the given frame-size through
- * out the adaptation process, 0 to let iSAC
- * change the frame-size if required.
- *
- * Return value : 0 - ok
- * -1 - Error
- */
+int16_t WebRtcIsac_GetUplinkBw(ISACStruct* ISAC_main_inst, int32_t* bottleneck);
- int16_t WebRtcIsac_ControlBwe(
- ISACStruct* ISAC_main_inst,
- int32_t rateBPS,
- int frameSizeMs,
- int16_t enforceFrameSize);
+/******************************************************************************
+ * WebRtcIsac_SetMaxPayloadSize(...)
+ *
+ * This function sets a limit for the maximum payload size of iSAC. The same
+ * value is used both for 30 and 60 ms packets. If the encoder sampling rate
+ * is 16 kHz the maximum payload size is between 120 and 400 bytes. If the
+ * encoder sampling rate is 32 kHz the maximum payload size is between 120
+ * and 600 bytes.
+ *
+ * If an out of range limit is used, the function returns -1, but the closest
+ * valid value will be applied.
+ *
+ * ---------------
+ * IMPORTANT NOTES
+ * ---------------
+ * The size of a packet is limited to the minimum of 'max-payload-size' and
+ * 'max-rate.' For instance, let's assume the max-payload-size is set to
+ * 170 bytes, and max-rate is set to 40 kbps. Note that a limit of 40 kbps
+ * translates to 150 bytes for 30ms frame-size & 300 bytes for 60ms
+ * frame-size. Then a packet with a frame-size of 30 ms is limited to 150,
+ * i.e. min(170, 150), and a packet with 60 ms frame-size is limited to
+ * 170 bytes, i.e. min(170, 300).
+ *
+ * Input:
+ * - ISAC_main_inst : iSAC instance
+ * - maxPayloadBytes : maximum size of the payload in bytes
+ * valid values are between 120 and 400 bytes
+ * if encoder sampling rate is 16 kHz. For
+ * 32 kHz encoder sampling rate valid values
+ * are between 120 and 600 bytes.
+ *
+ * Return value : 0 if successful
+ * -1 if error happens
+ */
+int16_t WebRtcIsac_SetMaxPayloadSize(ISACStruct* ISAC_main_inst,
+ int16_t maxPayloadBytes);
- /******************************************************************************
- * WebRtcIsac_ReadFrameLen(...)
- *
- * This function returns the length of the frame represented in the packet.
- *
- * Input:
- * - encoded : Encoded bit-stream
- *
- * Output:
- * - frameLength : Length of frame in packet (in samples)
- *
- */
-
- int16_t WebRtcIsac_ReadFrameLen(
- ISACStruct* ISAC_main_inst,
- const uint8_t* encoded,
- int16_t* frameLength);
-
-
- /******************************************************************************
- * WebRtcIsac_version(...)
- *
- * This function returns the version number.
- *
- * Output:
- * - version : Pointer to character string
- *
- */
-
- void WebRtcIsac_version(
- char *version);
-
-
- /******************************************************************************
- * WebRtcIsac_GetErrorCode(...)
- *
- * This function can be used to check the error code of an iSAC instance. When
- * a function returns -1 a error code will be set for that instance. The
- * function below extract the code of the last error that occurred in the
- * specified instance.
- *
- * Input:
- * - ISAC_main_inst : ISAC instance
- *
- * Return value : Error code
- */
-
- int16_t WebRtcIsac_GetErrorCode(
- ISACStruct* ISAC_main_inst);
-
-
- /****************************************************************************
- * WebRtcIsac_GetUplinkBw(...)
- *
- * This function outputs the target bottleneck of the codec. In
- * channel-adaptive mode, the target bottleneck is specified through in-band
- * signalling retreived by bandwidth estimator.
- * In channel-independent, also called instantaneous mode, the target
- * bottleneck is provided to the encoder by calling xxx_control(...). If
- * xxx_control is never called the default values is returned. The default
- * value for bottleneck at 16 kHz encoder sampling rate is 32000 bits/sec,
- * and it is 56000 bits/sec for 32 kHz sampling rate.
- * Note that the output is the iSAC internal operating bottleneck which might
- * differ slightly from the one provided through xxx_control().
- *
- * Input:
- * - ISAC_main_inst : iSAC instance
- *
- * Output:
- * - *bottleneck : bottleneck in bits/sec
- *
- * Return value : -1 if error happens
- * 0 bit-rates computed correctly.
- */
-
- int16_t WebRtcIsac_GetUplinkBw(
- ISACStruct* ISAC_main_inst,
- int32_t* bottleneck);
-
-
- /******************************************************************************
- * WebRtcIsac_SetMaxPayloadSize(...)
- *
- * This function sets a limit for the maximum payload size of iSAC. The same
- * value is used both for 30 and 60 ms packets. If the encoder sampling rate
- * is 16 kHz the maximum payload size is between 120 and 400 bytes. If the
- * encoder sampling rate is 32 kHz the maximum payload size is between 120
- * and 600 bytes.
- *
- * If an out of range limit is used, the function returns -1, but the closest
- * valid value will be applied.
- *
- * ---------------
- * IMPORTANT NOTES
- * ---------------
- * The size of a packet is limited to the minimum of 'max-payload-size' and
- * 'max-rate.' For instance, let's assume the max-payload-size is set to
- * 170 bytes, and max-rate is set to 40 kbps. Note that a limit of 40 kbps
- * translates to 150 bytes for 30ms frame-size & 300 bytes for 60ms
- * frame-size. Then a packet with a frame-size of 30 ms is limited to 150,
- * i.e. min(170, 150), and a packet with 60 ms frame-size is limited to
- * 170 bytes, i.e. min(170, 300).
- *
- * Input:
- * - ISAC_main_inst : iSAC instance
- * - maxPayloadBytes : maximum size of the payload in bytes
- * valid values are between 120 and 400 bytes
- * if encoder sampling rate is 16 kHz. For
- * 32 kHz encoder sampling rate valid values
- * are between 120 and 600 bytes.
- *
- * Return value : 0 if successful
- * -1 if error happens
- */
-
- int16_t WebRtcIsac_SetMaxPayloadSize(
- ISACStruct* ISAC_main_inst,
- int16_t maxPayloadBytes);
-
-
- /******************************************************************************
- * WebRtcIsac_SetMaxRate(...)
- *
- * This function sets the maximum rate which the codec may not exceed for
- * any signal packet. The maximum rate is defined and payload-size per
- * frame-size in bits per second.
- *
- * The codec has a maximum rate of 53400 bits per second (200 bytes per 30
- * ms) if the encoder sampling rate is 16kHz, and 160 kbps (600 bytes/30 ms)
- * if the encoder sampling rate is 32 kHz.
- *
- * It is possible to set a maximum rate between 32000 and 53400 bits/sec
- * in wideband mode, and 32000 to 160000 bits/sec in super-wideband mode.
- *
- * If an out of range limit is used, the function returns -1, but the closest
- * valid value will be applied.
- *
- * ---------------
- * IMPORTANT NOTES
- * ---------------
- * The size of a packet is limited to the minimum of 'max-payload-size' and
- * 'max-rate.' For instance, let's assume the max-payload-size is set to
- * 170 bytes, and max-rate is set to 40 kbps. Note that a limit of 40 kbps
- * translates to 150 bytes for 30ms frame-size & 300 bytes for 60ms
- * frame-size. Then a packet with a frame-size of 30 ms is limited to 150,
- * i.e. min(170, 150), and a packet with 60 ms frame-size is limited to
- * 170 bytes, min(170, 300).
- *
- * Input:
- * - ISAC_main_inst : iSAC instance
- * - maxRate : maximum rate in bits per second,
- * valid values are 32000 to 53400 bits/sec in
- * wideband mode, and 32000 to 160000 bits/sec in
- * super-wideband mode.
- *
- * Return value : 0 if successful
- * -1 if error happens
- */
-
- int16_t WebRtcIsac_SetMaxRate(
- ISACStruct* ISAC_main_inst,
- int32_t maxRate);
-
-
- /******************************************************************************
- * WebRtcIsac_DecSampRate()
- * Return the sampling rate of the decoded audio.
- *
- * Input:
- * - ISAC_main_inst : iSAC instance
- *
- * Return value : sampling frequency in Hertz.
- *
- */
-
- uint16_t WebRtcIsac_DecSampRate(ISACStruct* ISAC_main_inst);
-
-
- /******************************************************************************
- * WebRtcIsac_EncSampRate()
- *
- * Input:
- * - ISAC_main_inst : iSAC instance
- *
- * Return value : sampling rate in Hertz.
- *
- */
-
- uint16_t WebRtcIsac_EncSampRate(ISACStruct* ISAC_main_inst);
-
-
- /******************************************************************************
- * WebRtcIsac_SetDecSampRate()
- * Set the sampling rate of the decoder. Initialization of the decoder WILL
- * NOT overwrite the sampling rate of the encoder. The default value is 16 kHz
- * which is set when the instance is created.
- *
- * Input:
- * - ISAC_main_inst : iSAC instance
- * - sampRate : sampling rate in Hertz.
- *
- * Return value : 0 if successful
- * -1 if failed.
- */
-
- int16_t WebRtcIsac_SetDecSampRate(ISACStruct* ISAC_main_inst,
- uint16_t samp_rate_hz);
-
-
- /******************************************************************************
- * WebRtcIsac_SetEncSampRate()
- * Set the sampling rate of the encoder. Initialization of the encoder WILL
- * NOT overwrite the sampling rate of the encoder. The default value is 16 kHz
- * which is set when the instance is created. The encoding-mode and the
- * bottleneck remain unchanged by this call, however, the maximum rate and
- * maximum payload-size will reset to their default value.
- *
- * Input:
- * - ISAC_main_inst : iSAC instance
- * - sampRate : sampling rate in Hertz.
- *
- * Return value : 0 if successful
- * -1 if failed.
- */
-
- int16_t WebRtcIsac_SetEncSampRate(ISACStruct* ISAC_main_inst,
- uint16_t sample_rate_hz);
-
+/******************************************************************************
+ * WebRtcIsac_SetMaxRate(...)
+ *
+ * This function sets the maximum rate which the codec may not exceed for
+ * any signal packet. The maximum rate is defined and payload-size per
+ * frame-size in bits per second.
+ *
+ * The codec has a maximum rate of 53400 bits per second (200 bytes per 30
+ * ms) if the encoder sampling rate is 16kHz, and 160 kbps (600 bytes/30 ms)
+ * if the encoder sampling rate is 32 kHz.
+ *
+ * It is possible to set a maximum rate between 32000 and 53400 bits/sec
+ * in wideband mode, and 32000 to 160000 bits/sec in super-wideband mode.
+ *
+ * If an out of range limit is used, the function returns -1, but the closest
+ * valid value will be applied.
+ *
+ * ---------------
+ * IMPORTANT NOTES
+ * ---------------
+ * The size of a packet is limited to the minimum of 'max-payload-size' and
+ * 'max-rate.' For instance, let's assume the max-payload-size is set to
+ * 170 bytes, and max-rate is set to 40 kbps. Note that a limit of 40 kbps
+ * translates to 150 bytes for 30ms frame-size & 300 bytes for 60ms
+ * frame-size. Then a packet with a frame-size of 30 ms is limited to 150,
+ * i.e. min(170, 150), and a packet with 60 ms frame-size is limited to
+ * 170 bytes, min(170, 300).
+ *
+ * Input:
+ * - ISAC_main_inst : iSAC instance
+ * - maxRate : maximum rate in bits per second,
+ * valid values are 32000 to 53400 bits/sec in
+ * wideband mode, and 32000 to 160000 bits/sec in
+ * super-wideband mode.
+ *
+ * Return value : 0 if successful
+ * -1 if error happens
+ */
+int16_t WebRtcIsac_SetMaxRate(ISACStruct* ISAC_main_inst, int32_t maxRate);
- /******************************************************************************
- * WebRtcIsac_GetNewBitStream(...)
- *
- * This function returns encoded data, with the recieved bwe-index in the
- * stream. If the rate is set to a value less than bottleneck of codec
- * the new bistream will be re-encoded with the given target rate.
- * It should always return a complete packet, i.e. only called once
- * even for 60 msec frames.
- *
- * NOTE 1! This function does not write in the ISACStruct, it is not allowed.
- * NOTE 2! Currently not implemented for SWB mode.
- * NOTE 3! Rates larger than the bottleneck of the codec will be limited
- * to the current bottleneck.
- *
- * Input:
- * - ISAC_main_inst : ISAC instance.
- * - bweIndex : Index of bandwidth estimate to put in new
- * bitstream
- * - rate : target rate of the transcoder is bits/sec.
- * Valid values are the accepted rate in iSAC,
- * i.e. 10000 to 56000.
- * - isRCU : if the new bit-stream is an RCU stream.
- * Note that the rate parameter always indicates
- * the target rate of the main payload, regardless
- * of 'isRCU' value.
- *
- * Output:
- * - encoded : The encoded data vector
- *
- * Return value : >0 - Length (in bytes) of coded data
- * -1 - Error or called in SWB mode
- * NOTE! No error code is written to
- * the struct since it is only allowed to read
- * the struct.
- */
- int16_t WebRtcIsac_GetNewBitStream(
- ISACStruct* ISAC_main_inst,
- int16_t bweIndex,
- int16_t jitterInfo,
- int32_t rate,
- uint8_t* encoded,
- int16_t isRCU);
+/******************************************************************************
+ * WebRtcIsac_DecSampRate()
+ * Return the sampling rate of the decoded audio.
+ *
+ * Input:
+ * - ISAC_main_inst : iSAC instance
+ *
+ * Return value : sampling frequency in Hertz.
+ *
+ */
+uint16_t WebRtcIsac_DecSampRate(ISACStruct* ISAC_main_inst);
+/******************************************************************************
+ * WebRtcIsac_EncSampRate()
+ *
+ * Input:
+ * - ISAC_main_inst : iSAC instance
+ *
+ * Return value : sampling rate in Hertz.
+ *
+ */
- /****************************************************************************
- * WebRtcIsac_GetDownLinkBwIndex(...)
- *
- * This function returns index representing the Bandwidth estimate from
- * other side to this side.
- *
- * Input:
- * - ISAC_main_inst : iSAC struct
- *
- * Output:
- * - bweIndex : Bandwidth estimate to transmit to other side.
- *
- */
+uint16_t WebRtcIsac_EncSampRate(ISACStruct* ISAC_main_inst);
- int16_t WebRtcIsac_GetDownLinkBwIndex(
- ISACStruct* ISAC_main_inst,
- int16_t* bweIndex,
- int16_t* jitterInfo);
+/******************************************************************************
+ * WebRtcIsac_SetDecSampRate()
+ * Set the sampling rate of the decoder. Initialization of the decoder WILL
+ * NOT overwrite the sampling rate of the encoder. The default value is 16 kHz
+ * which is set when the instance is created.
+ *
+ * Input:
+ * - ISAC_main_inst : iSAC instance
+ * - sampRate : sampling rate in Hertz.
+ *
+ * Return value : 0 if successful
+ * -1 if failed.
+ */
+int16_t WebRtcIsac_SetDecSampRate(ISACStruct* ISAC_main_inst,
+ uint16_t samp_rate_hz);
- /****************************************************************************
- * WebRtcIsac_UpdateUplinkBw(...)
- *
- * This function takes an index representing the Bandwidth estimate from
- * this side to other side and updates BWE.
- *
- * Input:
- * - ISAC_main_inst : iSAC struct
- * - bweIndex : Bandwidth estimate from other side.
- *
- */
+/******************************************************************************
+ * WebRtcIsac_SetEncSampRate()
+ * Set the sampling rate of the encoder. Initialization of the encoder WILL
+ * NOT overwrite the sampling rate of the encoder. The default value is 16 kHz
+ * which is set when the instance is created. The encoding-mode and the
+ * bottleneck remain unchanged by this call, however, the maximum rate and
+ * maximum payload-size will reset to their default value.
+ *
+ * Input:
+ * - ISAC_main_inst : iSAC instance
+ * - sampRate : sampling rate in Hertz.
+ *
+ * Return value : 0 if successful
+ * -1 if failed.
+ */
- int16_t WebRtcIsac_UpdateUplinkBw(
- ISACStruct* ISAC_main_inst,
- int16_t bweIndex);
+int16_t WebRtcIsac_SetEncSampRate(ISACStruct* ISAC_main_inst,
+ uint16_t sample_rate_hz);
+/******************************************************************************
+ * WebRtcIsac_GetNewBitStream(...)
+ *
+ * This function returns encoded data, with the recieved bwe-index in the
+ * stream. If the rate is set to a value less than bottleneck of codec
+ * the new bistream will be re-encoded with the given target rate.
+ * It should always return a complete packet, i.e. only called once
+ * even for 60 msec frames.
+ *
+ * NOTE 1! This function does not write in the ISACStruct, it is not allowed.
+ * NOTE 2! Currently not implemented for SWB mode.
+ * NOTE 3! Rates larger than the bottleneck of the codec will be limited
+ * to the current bottleneck.
+ *
+ * Input:
+ * - ISAC_main_inst : ISAC instance.
+ * - bweIndex : Index of bandwidth estimate to put in new
+ * bitstream
+ * - rate : target rate of the transcoder is bits/sec.
+ * Valid values are the accepted rate in iSAC,
+ * i.e. 10000 to 56000.
+ * - isRCU : if the new bit-stream is an RCU
+ * stream. Note that the rate parameter always indicates the target rate of the
+ * main payload, regardless of 'isRCU' value.
+ *
+ * Output:
+ * - encoded : The encoded data vector
+ *
+ * Return value : >0 - Length (in bytes) of coded data
+ * -1 - Error or called in SWB mode
+ * NOTE! No error code is written to
+ * the struct since it is only allowed to read
+ * the struct.
+ */
+int16_t WebRtcIsac_GetNewBitStream(ISACStruct* ISAC_main_inst,
+ int16_t bweIndex,
+ int16_t jitterInfo,
+ int32_t rate,
+ uint8_t* encoded,
+ int16_t isRCU);
- /****************************************************************************
- * WebRtcIsac_ReadBwIndex(...)
- *
- * This function returns the index of the Bandwidth estimate from the bitstream.
- *
- * Input:
- * - encoded : Encoded bitstream
- *
- * Output:
- * - frameLength : Length of frame in packet (in samples)
- * - bweIndex : Bandwidth estimate in bitstream
- *
- */
+/****************************************************************************
+ * WebRtcIsac_GetDownLinkBwIndex(...)
+ *
+ * This function returns index representing the Bandwidth estimate from
+ * other side to this side.
+ *
+ * Input:
+ * - ISAC_main_inst : iSAC struct
+ *
+ * Output:
+ * - bweIndex : Bandwidth estimate to transmit to other side.
+ *
+ */
- int16_t WebRtcIsac_ReadBwIndex(
- const uint8_t* encoded,
- int16_t* bweIndex);
+int16_t WebRtcIsac_GetDownLinkBwIndex(ISACStruct* ISAC_main_inst,
+ int16_t* bweIndex,
+ int16_t* jitterInfo);
+/****************************************************************************
+ * WebRtcIsac_UpdateUplinkBw(...)
+ *
+ * This function takes an index representing the Bandwidth estimate from
+ * this side to other side and updates BWE.
+ *
+ * Input:
+ * - ISAC_main_inst : iSAC struct
+ * - bweIndex : Bandwidth estimate from other side.
+ *
+ */
+int16_t WebRtcIsac_UpdateUplinkBw(ISACStruct* ISAC_main_inst, int16_t bweIndex);
- /*******************************************************************************
- * WebRtcIsac_GetNewFrameLen(...)
- *
- * returns the frame lenght (in samples) of the next packet. In the case of channel-adaptive
- * mode, iSAC decides on its frame lenght based on the estimated bottleneck
- * this allows a user to prepare for the next packet (at the encoder)
- *
- * The primary usage is in CE to make the iSAC works in channel-adaptive mode
- *
- * Input:
- * - ISAC_main_inst : iSAC struct
- *
- * Return Value : frame lenght in samples
- *
- */
+/****************************************************************************
+ * WebRtcIsac_ReadBwIndex(...)
+ *
+ * This function returns the index of the Bandwidth estimate from the bitstream.
+ *
+ * Input:
+ * - encoded : Encoded bitstream
+ *
+ * Output:
+ * - frameLength : Length of frame in packet (in samples)
+ * - bweIndex : Bandwidth estimate in bitstream
+ *
+ */
- int16_t WebRtcIsac_GetNewFrameLen(
- ISACStruct* ISAC_main_inst);
+int16_t WebRtcIsac_ReadBwIndex(const uint8_t* encoded, int16_t* bweIndex);
+/*******************************************************************************
+ * WebRtcIsac_GetNewFrameLen(...)
+ *
+ * returns the frame lenght (in samples) of the next packet. In the case of
+ * channel-adaptive mode, iSAC decides on its frame lenght based on the
+ * estimated bottleneck this allows a user to prepare for the next packet (at
+ * the encoder)
+ *
+ * The primary usage is in CE to make the iSAC works in channel-adaptive mode
+ *
+ * Input:
+ * - ISAC_main_inst : iSAC struct
+ *
+ * Return Value : frame lenght in samples
+ *
+ */
- /****************************************************************************
- * WebRtcIsac_GetRedPayload(...)
- *
- * Populates "encoded" with the redundant payload of the recently encoded
- * frame. This function has to be called once that WebRtcIsac_Encode(...)
- * returns a positive value. Regardless of the frame-size this function will
- * be called only once after encoding is completed.
- *
- * Input:
- * - ISAC_main_inst : iSAC struct
- *
- * Output:
- * - encoded : the encoded data vector
- *
- *
- * Return value:
- * : >0 - Length (in bytes) of coded data
- * : -1 - Error
- *
- *
- */
- int16_t WebRtcIsac_GetRedPayload(
- ISACStruct* ISAC_main_inst,
- uint8_t* encoded);
+int16_t WebRtcIsac_GetNewFrameLen(ISACStruct* ISAC_main_inst);
+/****************************************************************************
+ * WebRtcIsac_GetRedPayload(...)
+ *
+ * Populates "encoded" with the redundant payload of the recently encoded
+ * frame. This function has to be called once that WebRtcIsac_Encode(...)
+ * returns a positive value. Regardless of the frame-size this function will
+ * be called only once after encoding is completed.
+ *
+ * Input:
+ * - ISAC_main_inst : iSAC struct
+ *
+ * Output:
+ * - encoded : the encoded data vector
+ *
+ *
+ * Return value:
+ * : >0 - Length (in bytes) of coded data
+ * : -1 - Error
+ *
+ *
+ */
+int16_t WebRtcIsac_GetRedPayload(ISACStruct* ISAC_main_inst, uint8_t* encoded);
- /****************************************************************************
- * WebRtcIsac_DecodeRcu(...)
- *
- * This function decodes a redundant (RCU) iSAC frame. Function is called in
- * NetEq with a stored RCU payload i case of packet loss. Output speech length
- * will be a multiple of 480 samples: 480 or 960 samples,
- * depending on the framesize (30 or 60 ms).
- *
- * Input:
- * - ISAC_main_inst : ISAC instance.
- * - encoded : encoded ISAC RCU frame(s)
- * - len : bytes in encoded vector
- *
- * Output:
- * - decoded : The decoded vector
- *
- * Return value : >0 - number of samples in decoded vector
- * -1 - Error
- */
- int WebRtcIsac_DecodeRcu(
- ISACStruct* ISAC_main_inst,
- const uint8_t* encoded,
- size_t len,
- int16_t* decoded,
- int16_t* speechType);
+/****************************************************************************
+ * WebRtcIsac_DecodeRcu(...)
+ *
+ * This function decodes a redundant (RCU) iSAC frame. Function is called in
+ * NetEq with a stored RCU payload i case of packet loss. Output speech length
+ * will be a multiple of 480 samples: 480 or 960 samples,
+ * depending on the framesize (30 or 60 ms).
+ *
+ * Input:
+ * - ISAC_main_inst : ISAC instance.
+ * - encoded : encoded ISAC RCU frame(s)
+ * - len : bytes in encoded vector
+ *
+ * Output:
+ * - decoded : The decoded vector
+ *
+ * Return value : >0 - number of samples in decoded vector
+ * -1 - Error
+ */
+int WebRtcIsac_DecodeRcu(ISACStruct* ISAC_main_inst,
+ const uint8_t* encoded,
+ size_t len,
+ int16_t* decoded,
+ int16_t* speechType);
- /* Fills in an IsacBandwidthInfo struct. |inst| should be a decoder. */
- void WebRtcIsac_GetBandwidthInfo(ISACStruct* inst, IsacBandwidthInfo* bwinfo);
+/* Fills in an IsacBandwidthInfo struct. |inst| should be a decoder. */
+void WebRtcIsac_GetBandwidthInfo(ISACStruct* inst, IsacBandwidthInfo* bwinfo);
- /* Uses the values from an IsacBandwidthInfo struct. |inst| should be an
- encoder. */
- void WebRtcIsac_SetBandwidthInfo(ISACStruct* inst,
- const IsacBandwidthInfo* bwinfo);
+/* Uses the values from an IsacBandwidthInfo struct. |inst| should be an
+ encoder. */
+void WebRtcIsac_SetBandwidthInfo(ISACStruct* inst,
+ const IsacBandwidthInfo* bwinfo);
- /* If |inst| is a decoder but not an encoder: tell it what sample rate the
- encoder is using, for bandwidth estimation purposes. */
- void WebRtcIsac_SetEncSampRateInDecoder(ISACStruct* inst, int sample_rate_hz);
+/* If |inst| is a decoder but not an encoder: tell it what sample rate the
+ encoder is using, for bandwidth estimation purposes. */
+void WebRtcIsac_SetEncSampRateInDecoder(ISACStruct* inst, int sample_rate_hz);
#if defined(__cplusplus)
}
#endif
-
-
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_INCLUDE_ISAC_H_ */
diff --git a/modules/audio_coding/codecs/isac/main/source/arith_routines.h b/modules/audio_coding/codecs/isac/main/source/arith_routines.h
index d001c68..6e7ea1d 100644
--- a/modules/audio_coding/codecs/isac/main/source/arith_routines.h
+++ b/modules/audio_coding/codecs/isac/main/source/arith_routines.h
@@ -21,42 +21,47 @@
#include "modules/audio_coding/codecs/isac/main/source/structs.h"
int WebRtcIsac_EncLogisticMulti2(
- Bitstr *streamdata, /* in-/output struct containing bitstream */
- int16_t *dataQ7, /* input: data vector */
- const uint16_t *env, /* input: side info vector defining the width of the pdf */
- const int N, /* input: data vector length */
+ Bitstr* streamdata, /* in-/output struct containing bitstream */
+ int16_t* dataQ7, /* input: data vector */
+ const uint16_t*
+ env, /* input: side info vector defining the width of the pdf */
+ const int N, /* input: data vector length */
const int16_t isSWB12kHz); /* if the codec is working in 12kHz bandwidth */
/* returns the number of bytes in the stream */
-int WebRtcIsac_EncTerminate(Bitstr *streamdata); /* in-/output struct containing bitstream */
+int WebRtcIsac_EncTerminate(
+ Bitstr* streamdata); /* in-/output struct containing bitstream */
/* returns the number of bytes in the stream so far */
int WebRtcIsac_DecLogisticMulti2(
- int16_t *data, /* output: data vector */
- Bitstr *streamdata, /* in-/output struct containing bitstream */
- const uint16_t *env, /* input: side info vector defining the width of the pdf */
- const int16_t *dither, /* input: dither vector */
- const int N, /* input: data vector length */
+ int16_t* data, /* output: data vector */
+ Bitstr* streamdata, /* in-/output struct containing bitstream */
+ const uint16_t*
+ env, /* input: side info vector defining the width of the pdf */
+ const int16_t* dither, /* input: dither vector */
+ const int N, /* input: data vector length */
const int16_t isSWB12kHz); /* if the codec is working in 12kHz bandwidth */
void WebRtcIsac_EncHistMulti(
- Bitstr *streamdata, /* in-/output struct containing bitstream */
- const int *data, /* input: data vector */
- const uint16_t *const *cdf, /* input: array of cdf arrays */
+ Bitstr* streamdata, /* in-/output struct containing bitstream */
+ const int* data, /* input: data vector */
+ const uint16_t* const* cdf, /* input: array of cdf arrays */
const int N); /* input: data vector length */
int WebRtcIsac_DecHistBisectMulti(
- int *data, /* output: data vector */
- Bitstr *streamdata, /* in-/output struct containing bitstream */
- const uint16_t *const *cdf, /* input: array of cdf arrays */
- const uint16_t *cdf_size, /* input: array of cdf table sizes+1 (power of two: 2^k) */
- const int N); /* input: data vector length */
+ int* data, /* output: data vector */
+ Bitstr* streamdata, /* in-/output struct containing bitstream */
+ const uint16_t* const* cdf, /* input: array of cdf arrays */
+ const uint16_t*
+ cdf_size, /* input: array of cdf table sizes+1 (power of two: 2^k) */
+ const int N); /* input: data vector length */
int WebRtcIsac_DecHistOneStepMulti(
- int *data, /* output: data vector */
- Bitstr *streamdata, /* in-/output struct containing bitstream */
- const uint16_t *const *cdf, /* input: array of cdf arrays */
- const uint16_t *init_index,/* input: vector of initial cdf table search entries */
- const int N); /* input: data vector length */
+ int* data, /* output: data vector */
+ Bitstr* streamdata, /* in-/output struct containing bitstream */
+ const uint16_t* const* cdf, /* input: array of cdf arrays */
+ const uint16_t*
+ init_index, /* input: vector of initial cdf table search entries */
+ const int N); /* input: data vector length */
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_ARITH_ROUTINES_H_ */
diff --git a/modules/audio_coding/codecs/isac/main/source/audio_encoder_isac_unittest.cc b/modules/audio_coding/codecs/isac/main/source/audio_encoder_isac_unittest.cc
index 333ab52..87ae0e0 100644
--- a/modules/audio_coding/codecs/isac/main/source/audio_encoder_isac_unittest.cc
+++ b/modules/audio_coding/codecs/isac/main/source/audio_encoder_isac_unittest.cc
@@ -29,7 +29,11 @@
// Wrap subroutine calls that test things in this, so that the error messages
// will be accompanied by stack traces that make it possible to tell which
// subroutine invocation caused the failure.
-#define S(x) do { SCOPED_TRACE(#x); x; } while (0)
+#define S(x) \
+ do { \
+ SCOPED_TRACE(#x); \
+ x; \
+ } while (0)
} // namespace
diff --git a/modules/audio_coding/codecs/isac/main/source/bandwidth_estimator.h b/modules/audio_coding/codecs/isac/main/source/bandwidth_estimator.h
index fbeb849..d80ff73 100644
--- a/modules/audio_coding/codecs/isac/main/source/bandwidth_estimator.h
+++ b/modules/audio_coding/codecs/isac/main/source/bandwidth_estimator.h
@@ -24,162 +24,151 @@
#include "modules/audio_coding/codecs/isac/main/source/settings.h"
#include "modules/audio_coding/codecs/isac/main/source/structs.h"
-#define MIN_ISAC_BW 10000
-#define MIN_ISAC_BW_LB 10000
-#define MIN_ISAC_BW_UB 25000
+#define MIN_ISAC_BW 10000
+#define MIN_ISAC_BW_LB 10000
+#define MIN_ISAC_BW_UB 25000
-#define MAX_ISAC_BW 56000
-#define MAX_ISAC_BW_UB 32000
-#define MAX_ISAC_BW_LB 32000
+#define MAX_ISAC_BW 56000
+#define MAX_ISAC_BW_UB 32000
+#define MAX_ISAC_BW_LB 32000
-#define MIN_ISAC_MD 5
-#define MAX_ISAC_MD 25
+#define MIN_ISAC_MD 5
+#define MAX_ISAC_MD 25
// assumed header size, in bytes; we don't know the exact number
// (header compression may be used)
-#define HEADER_SIZE 35
+#define HEADER_SIZE 35
// Initial Frame-Size, in ms, for Wideband & Super-Wideband Mode
-#define INIT_FRAME_LEN_WB 60
+#define INIT_FRAME_LEN_WB 60
#define INIT_FRAME_LEN_SWB 30
// Initial Bottleneck Estimate, in bits/sec, for
// Wideband & Super-wideband mode
-#define INIT_BN_EST_WB 20e3f
-#define INIT_BN_EST_SWB 56e3f
+#define INIT_BN_EST_WB 20e3f
+#define INIT_BN_EST_SWB 56e3f
// Initial Header rate (header rate depends on frame-size),
// in bits/sec, for Wideband & Super-Wideband mode.
-#define INIT_HDR_RATE_WB \
+#define INIT_HDR_RATE_WB \
((float)HEADER_SIZE * 8.0f * 1000.0f / (float)INIT_FRAME_LEN_WB)
-#define INIT_HDR_RATE_SWB \
+#define INIT_HDR_RATE_SWB \
((float)HEADER_SIZE * 8.0f * 1000.0f / (float)INIT_FRAME_LEN_SWB)
// number of packets in a row for a high rate burst
-#define BURST_LEN 3
+#define BURST_LEN 3
// ms, max time between two full bursts
-#define BURST_INTERVAL 500
+#define BURST_INTERVAL 500
// number of packets in a row for initial high rate burst
-#define INIT_BURST_LEN 5
+#define INIT_BURST_LEN 5
// bits/s, rate for the first BURST_LEN packets
-#define INIT_RATE_WB INIT_BN_EST_WB
-#define INIT_RATE_SWB INIT_BN_EST_SWB
-
+#define INIT_RATE_WB INIT_BN_EST_WB
+#define INIT_RATE_SWB INIT_BN_EST_SWB
#if defined(__cplusplus)
extern "C" {
#endif
- /* This function initializes the struct */
- /* to be called before using the struct for anything else */
- /* returns 0 if everything went fine, -1 otherwise */
- int32_t WebRtcIsac_InitBandwidthEstimator(
- BwEstimatorstr* bwest_str,
- enum IsacSamplingRate encoderSampRate,
- enum IsacSamplingRate decoderSampRate);
+/* This function initializes the struct */
+/* to be called before using the struct for anything else */
+/* returns 0 if everything went fine, -1 otherwise */
+int32_t WebRtcIsac_InitBandwidthEstimator(
+ BwEstimatorstr* bwest_str,
+ enum IsacSamplingRate encoderSampRate,
+ enum IsacSamplingRate decoderSampRate);
- /* This function updates the receiving estimate */
- /* Parameters: */
- /* rtp_number - value from RTP packet, from NetEq */
- /* frame length - length of signal frame in ms, from iSAC decoder */
- /* send_ts - value in RTP header giving send time in samples */
- /* arr_ts - value given by timeGetTime() time of arrival in samples of packet from NetEq */
- /* pksize - size of packet in bytes, from NetEq */
- /* Index - integer (range 0...23) indicating bottle neck & jitter as estimated by other side */
- /* returns 0 if everything went fine, -1 otherwise */
- int16_t WebRtcIsac_UpdateBandwidthEstimator(
- BwEstimatorstr* bwest_str,
- const uint16_t rtp_number,
- const int32_t frame_length,
- const uint32_t send_ts,
- const uint32_t arr_ts,
- const size_t pksize);
+/* This function updates the receiving estimate */
+/* Parameters: */
+/* rtp_number - value from RTP packet, from NetEq */
+/* frame length - length of signal frame in ms, from iSAC decoder */
+/* send_ts - value in RTP header giving send time in samples */
+/* arr_ts - value given by timeGetTime() time of arrival in samples of
+ * packet from NetEq */
+/* pksize - size of packet in bytes, from NetEq */
+/* Index - integer (range 0...23) indicating bottle neck & jitter as
+ * estimated by other side */
+/* returns 0 if everything went fine, -1 otherwise */
+int16_t WebRtcIsac_UpdateBandwidthEstimator(BwEstimatorstr* bwest_str,
+ const uint16_t rtp_number,
+ const int32_t frame_length,
+ const uint32_t send_ts,
+ const uint32_t arr_ts,
+ const size_t pksize);
- /* Update receiving estimates. Used when we only receive BWE index, no iSAC data packet. */
- int16_t WebRtcIsac_UpdateUplinkBwImpl(
- BwEstimatorstr* bwest_str,
- int16_t Index,
- enum IsacSamplingRate encoderSamplingFreq);
+/* Update receiving estimates. Used when we only receive BWE index, no iSAC data
+ * packet. */
+int16_t WebRtcIsac_UpdateUplinkBwImpl(
+ BwEstimatorstr* bwest_str,
+ int16_t Index,
+ enum IsacSamplingRate encoderSamplingFreq);
- /* Returns the bandwidth/jitter estimation code (integer 0...23) to put in the sending iSAC payload */
- void WebRtcIsac_GetDownlinkBwJitIndexImpl(
- BwEstimatorstr* bwest_str,
- int16_t* bottleneckIndex,
- int16_t* jitterInfo,
- enum IsacSamplingRate decoderSamplingFreq);
+/* Returns the bandwidth/jitter estimation code (integer 0...23) to put in the
+ * sending iSAC payload */
+void WebRtcIsac_GetDownlinkBwJitIndexImpl(
+ BwEstimatorstr* bwest_str,
+ int16_t* bottleneckIndex,
+ int16_t* jitterInfo,
+ enum IsacSamplingRate decoderSamplingFreq);
- /* Returns the bandwidth estimation (in bps) */
- int32_t WebRtcIsac_GetDownlinkBandwidth(
- const BwEstimatorstr *bwest_str);
+/* Returns the bandwidth estimation (in bps) */
+int32_t WebRtcIsac_GetDownlinkBandwidth(const BwEstimatorstr* bwest_str);
- /* Returns the max delay (in ms) */
- int32_t WebRtcIsac_GetDownlinkMaxDelay(
- const BwEstimatorstr *bwest_str);
+/* Returns the max delay (in ms) */
+int32_t WebRtcIsac_GetDownlinkMaxDelay(const BwEstimatorstr* bwest_str);
- /* Returns the bandwidth that iSAC should send with in bps */
- int32_t WebRtcIsac_GetUplinkBandwidth(const BwEstimatorstr* bwest_str);
+/* Returns the bandwidth that iSAC should send with in bps */
+int32_t WebRtcIsac_GetUplinkBandwidth(const BwEstimatorstr* bwest_str);
- /* Returns the max delay value from the other side in ms */
- int32_t WebRtcIsac_GetUplinkMaxDelay(
- const BwEstimatorstr *bwest_str);
+/* Returns the max delay value from the other side in ms */
+int32_t WebRtcIsac_GetUplinkMaxDelay(const BwEstimatorstr* bwest_str);
- /* Fills in an IsacExternalBandwidthInfo struct. */
- void WebRtcIsacBw_GetBandwidthInfo(
- BwEstimatorstr* bwest_str,
- enum IsacSamplingRate decoder_sample_rate_hz,
- IsacBandwidthInfo* bwinfo);
+/* Fills in an IsacExternalBandwidthInfo struct. */
+void WebRtcIsacBw_GetBandwidthInfo(BwEstimatorstr* bwest_str,
+ enum IsacSamplingRate decoder_sample_rate_hz,
+ IsacBandwidthInfo* bwinfo);
- /* Uses the values from an IsacExternalBandwidthInfo struct. */
- void WebRtcIsacBw_SetBandwidthInfo(BwEstimatorstr* bwest_str,
- const IsacBandwidthInfo* bwinfo);
+/* Uses the values from an IsacExternalBandwidthInfo struct. */
+void WebRtcIsacBw_SetBandwidthInfo(BwEstimatorstr* bwest_str,
+ const IsacBandwidthInfo* bwinfo);
- /*
- * update amount of data in bottle neck buffer and burst handling
- * returns minimum payload size (bytes)
- */
- int WebRtcIsac_GetMinBytes(
- RateModel* State,
- int StreamSize, /* bytes in bitstream */
- const int FrameLen, /* ms per frame */
- const double BottleNeck, /* bottle neck rate; excl headers (bps) */
- const double DelayBuildUp, /* max delay from bottleneck buffering (ms) */
- enum ISACBandwidth bandwidth
- /*,int16_t frequentLargePackets*/);
+/*
+ * update amount of data in bottle neck buffer and burst handling
+ * returns minimum payload size (bytes)
+ */
+int WebRtcIsac_GetMinBytes(
+ RateModel* State,
+ int StreamSize, /* bytes in bitstream */
+ const int FrameLen, /* ms per frame */
+ const double BottleNeck, /* bottle neck rate; excl headers (bps) */
+ const double DelayBuildUp, /* max delay from bottleneck buffering (ms) */
+ enum ISACBandwidth bandwidth
+ /*,int16_t frequentLargePackets*/);
- /*
- * update long-term average bitrate and amount of data in buffer
- */
- void WebRtcIsac_UpdateRateModel(
- RateModel* State,
- int StreamSize, /* bytes in bitstream */
- const int FrameSamples, /* samples per frame */
- const double BottleNeck); /* bottle neck rate; excl headers (bps) */
+/*
+ * update long-term average bitrate and amount of data in buffer
+ */
+void WebRtcIsac_UpdateRateModel(
+ RateModel* State,
+ int StreamSize, /* bytes in bitstream */
+ const int FrameSamples, /* samples per frame */
+ const double BottleNeck); /* bottle neck rate; excl headers (bps) */
+void WebRtcIsac_InitRateModel(RateModel* State);
- void WebRtcIsac_InitRateModel(
- RateModel *State);
+/* Returns the new framelength value (input argument: bottle_neck) */
+int WebRtcIsac_GetNewFrameLength(double bottle_neck, int current_framelength);
- /* Returns the new framelength value (input argument: bottle_neck) */
- int WebRtcIsac_GetNewFrameLength(
- double bottle_neck,
- int current_framelength);
+/* Returns the new SNR value (input argument: bottle_neck) */
+double WebRtcIsac_GetSnr(double bottle_neck, int new_framelength);
- /* Returns the new SNR value (input argument: bottle_neck) */
- double WebRtcIsac_GetSnr(
- double bottle_neck,
- int new_framelength);
-
-
- int16_t WebRtcIsac_UpdateUplinkJitter(
- BwEstimatorstr* bwest_str,
- int32_t index);
+int16_t WebRtcIsac_UpdateUplinkJitter(BwEstimatorstr* bwest_str, int32_t index);
#if defined(__cplusplus)
}
#endif
-
-#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_BANDWIDTH_ESTIMATOR_H_ */
+#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_BANDWIDTH_ESTIMATOR_H_ \
+ */
diff --git a/modules/audio_coding/codecs/isac/main/source/codec.h b/modules/audio_coding/codecs/isac/main/source/codec.h
index 96118ad..c386704 100644
--- a/modules/audio_coding/codecs/isac/main/source/codec.h
+++ b/modules/audio_coding/codecs/isac/main/source/codec.h
@@ -25,10 +25,12 @@
void WebRtcIsac_ResetBitstream(Bitstr* bit_stream);
-int WebRtcIsac_EstimateBandwidth(BwEstimatorstr* bwest_str, Bitstr* streamdata,
+int WebRtcIsac_EstimateBandwidth(BwEstimatorstr* bwest_str,
+ Bitstr* streamdata,
size_t packet_size,
uint16_t rtp_seq_number,
- uint32_t send_ts, uint32_t arr_ts,
+ uint32_t send_ts,
+ uint32_t arr_ts,
enum IsacSamplingRate encoderSampRate,
enum IsacSamplingRate decoderSampRate);
@@ -38,7 +40,8 @@
int16_t* current_framesamples,
int16_t isRCUPayload);
-int WebRtcIsac_DecodeRcuLb(float* signal_out, ISACLBDecStruct* ISACdec_obj,
+int WebRtcIsac_DecodeRcuLb(float* signal_out,
+ ISACLBDecStruct* ISACdec_obj,
int16_t* current_framesamples);
int WebRtcIsac_EncodeLb(const TransformTables* transform_tables,
@@ -48,15 +51,20 @@
int16_t bottleneckIndex);
int WebRtcIsac_EncodeStoredDataLb(const IsacSaveEncoderData* ISACSavedEnc_obj,
- Bitstr* ISACBitStr_obj, int BWnumber,
+ Bitstr* ISACBitStr_obj,
+ int BWnumber,
float scale);
int WebRtcIsac_EncodeStoredDataUb(
- const ISACUBSaveEncDataStruct* ISACSavedEnc_obj, Bitstr* bitStream,
- int32_t jitterInfo, float scale, enum ISACBandwidth bandwidth);
+ const ISACUBSaveEncDataStruct* ISACSavedEnc_obj,
+ Bitstr* bitStream,
+ int32_t jitterInfo,
+ float scale,
+ enum ISACBandwidth bandwidth);
int16_t WebRtcIsac_GetRedPayloadUb(
- const ISACUBSaveEncDataStruct* ISACSavedEncObj, Bitstr* bitStreamObj,
+ const ISACUBSaveEncDataStruct* ISACSavedEncObj,
+ Bitstr* bitStreamObj,
enum ISACBandwidth bandwidth);
/******************************************************************************
@@ -82,7 +90,6 @@
double* rateUBBitPerSec,
enum ISACBandwidth* bandwidthKHz);
-
/******************************************************************************
* WebRtcIsac_DecodeUb16()
*
@@ -169,7 +176,6 @@
void WebRtcIsac_InitPostFilterbank(PostFiltBankstr* postfiltdata);
-
/**************************** transform functions ****************************/
void WebRtcIsac_InitTransform(TransformTables* tables);
@@ -190,18 +196,25 @@
/***************************** filterbank functions **************************/
-void WebRtcIsac_FilterAndCombineFloat(float* InLP, float* InHP, float* Out,
+void WebRtcIsac_FilterAndCombineFloat(float* InLP,
+ float* InHP,
+ float* Out,
PostFiltBankstr* postfiltdata);
-
/************************* normalized lattice filters ************************/
-void WebRtcIsac_NormLatticeFilterMa(int orderCoef, float* stateF, float* stateG,
- float* lat_in, double* filtcoeflo,
+void WebRtcIsac_NormLatticeFilterMa(int orderCoef,
+ float* stateF,
+ float* stateG,
+ float* lat_in,
+ double* filtcoeflo,
double* lat_out);
-void WebRtcIsac_NormLatticeFilterAr(int orderCoef, float* stateF, float* stateG,
- double* lat_in, double* lo_filt_coef,
+void WebRtcIsac_NormLatticeFilterAr(int orderCoef,
+ float* stateF,
+ float* stateG,
+ double* lat_in,
+ double* lo_filt_coef,
float* lat_out);
void WebRtcIsac_Dir2Lat(double* a, int orderCoef, float* sth, float* cth);
diff --git a/modules/audio_coding/codecs/isac/main/source/crc.h b/modules/audio_coding/codecs/isac/main/source/crc.h
index b3197a1..19adbda 100644
--- a/modules/audio_coding/codecs/isac/main/source/crc.h
+++ b/modules/audio_coding/codecs/isac/main/source/crc.h
@@ -36,11 +36,6 @@
* -1 - Error
*/
-int WebRtcIsac_GetCrc(
- const int16_t* encoded,
- int no_of_word8s,
- uint32_t* crc);
-
-
+int WebRtcIsac_GetCrc(const int16_t* encoded, int no_of_word8s, uint32_t* crc);
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_CRC_H_ */
diff --git a/modules/audio_coding/codecs/isac/main/source/encode_lpc_swb.h b/modules/audio_coding/codecs/isac/main/source/encode_lpc_swb.h
index 2fa1c71..b8d918b 100644
--- a/modules/audio_coding/codecs/isac/main/source/encode_lpc_swb.h
+++ b/modules/audio_coding/codecs/isac/main/source/encode_lpc_swb.h
@@ -39,9 +39,7 @@
*
*
*/
-int16_t WebRtcIsac_RemoveLarMean(
- double* lar,
- int16_t bandwidth);
+int16_t WebRtcIsac_RemoveLarMean(double* lar, int16_t bandwidth);
/******************************************************************************
* WebRtcIsac_DecorrelateIntraVec()
@@ -59,11 +57,9 @@
* Output:
* -out : decorrelated LAR vectors.
*/
-int16_t WebRtcIsac_DecorrelateIntraVec(
- const double* inLAR,
- double* out,
- int16_t bandwidth);
-
+int16_t WebRtcIsac_DecorrelateIntraVec(const double* inLAR,
+ double* out,
+ int16_t bandwidth);
/******************************************************************************
* WebRtcIsac_DecorrelateInterVec()
@@ -82,11 +78,9 @@
* Output:
* -out : decorrelated LAR vectors.
*/
-int16_t WebRtcIsac_DecorrelateInterVec(
- const double* data,
- double* out,
- int16_t bandwidth);
-
+int16_t WebRtcIsac_DecorrelateInterVec(const double* data,
+ double* out,
+ int16_t bandwidth);
/******************************************************************************
* WebRtcIsac_QuantizeUncorrLar()
@@ -102,11 +96,7 @@
* -data : quantized version of the input.
* -idx : pointer to quantization indices.
*/
-double WebRtcIsac_QuantizeUncorrLar(
- double* data,
- int* idx,
- int16_t bandwidth);
-
+double WebRtcIsac_QuantizeUncorrLar(double* data, int* idx, int16_t bandwidth);
/******************************************************************************
* WebRtcIsac_CorrelateIntraVec()
@@ -121,11 +111,9 @@
* Output:
* -out : correlated parametrs.
*/
-int16_t WebRtcIsac_CorrelateIntraVec(
- const double* data,
- double* out,
- int16_t bandwidth);
-
+int16_t WebRtcIsac_CorrelateIntraVec(const double* data,
+ double* out,
+ int16_t bandwidth);
/******************************************************************************
* WebRtcIsac_CorrelateInterVec()
@@ -140,17 +128,15 @@
* Output:
* -out : correlated parametrs.
*/
-int16_t WebRtcIsac_CorrelateInterVec(
- const double* data,
- double* out,
- int16_t bandwidth);
-
+int16_t WebRtcIsac_CorrelateInterVec(const double* data,
+ double* out,
+ int16_t bandwidth);
/******************************************************************************
* WebRtcIsac_AddLarMean()
*
* This is the inverse of WebRtcIsac_RemoveLarMean()
- *
+ *
* Input:
* -data : pointer to mean-removed LAR:s.
* -bandwidth : indicates if the given LAR vectors belong
@@ -159,10 +145,7 @@
* Output:
* -data : pointer to LARs.
*/
-int16_t WebRtcIsac_AddLarMean(
- double* data,
- int16_t bandwidth);
-
+int16_t WebRtcIsac_AddLarMean(double* data, int16_t bandwidth);
/******************************************************************************
* WebRtcIsac_DequantizeLpcParam()
@@ -177,11 +160,9 @@
* Output:
* -out : pointer to quantized values.
*/
-int16_t WebRtcIsac_DequantizeLpcParam(
- const int* idx,
- double* out,
- int16_t bandwidth);
-
+int16_t WebRtcIsac_DequantizeLpcParam(const int* idx,
+ double* out,
+ int16_t bandwidth);
/******************************************************************************
* WebRtcIsac_ToLogDomainRemoveMean()
@@ -194,9 +175,7 @@
* Output:
* -lpcGain : mean-removed in log domain.
*/
-int16_t WebRtcIsac_ToLogDomainRemoveMean(
- double* lpGains);
-
+int16_t WebRtcIsac_ToLogDomainRemoveMean(double* lpGains);
/******************************************************************************
* WebRtcIsac_DecorrelateLPGain()
@@ -210,16 +189,13 @@
* Output:
* -out : decorrelated parameters.
*/
-int16_t WebRtcIsac_DecorrelateLPGain(
- const double* data,
- double* out);
-
+int16_t WebRtcIsac_DecorrelateLPGain(const double* data, double* out);
/******************************************************************************
* WebRtcIsac_QuantizeLpcGain()
*
* Quantize the decorrelated log-domain gains.
- *
+ *
* Input:
* -lpcGain : uncorrelated LPC gains.
*
@@ -227,10 +203,7 @@
* -idx : quantization indices
* -lpcGain : quantized value of the inpt.
*/
-double WebRtcIsac_QuantizeLpcGain(
- double* lpGains,
- int* idx);
-
+double WebRtcIsac_QuantizeLpcGain(double* lpGains, int* idx);
/******************************************************************************
* WebRtcIsac_DequantizeLpcGain()
@@ -243,10 +216,7 @@
* Output:
* -lpcGains : quantized values of the given parametes.
*/
-int16_t WebRtcIsac_DequantizeLpcGain(
- const int* idx,
- double* lpGains);
-
+int16_t WebRtcIsac_DequantizeLpcGain(const int* idx, double* lpGains);
/******************************************************************************
* WebRtcIsac_CorrelateLpcGain()
@@ -259,10 +229,7 @@
* Output:
* -out : correlated parameters.
*/
-int16_t WebRtcIsac_CorrelateLpcGain(
- const double* data,
- double* out);
-
+int16_t WebRtcIsac_CorrelateLpcGain(const double* data, double* out);
/******************************************************************************
* WebRtcIsac_AddMeanToLinearDomain()
@@ -275,8 +242,6 @@
* Output:
* -lpcGain : LPC gain in normal domain.
*/
-int16_t WebRtcIsac_AddMeanToLinearDomain(
- double* lpcGains);
-
+int16_t WebRtcIsac_AddMeanToLinearDomain(double* lpcGains);
#endif // MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_ENCODE_LPC_SWB_H_
diff --git a/modules/audio_coding/codecs/isac/main/source/entropy_coding.h b/modules/audio_coding/codecs/isac/main/source/entropy_coding.h
index 7224ad0..6c2b8d3 100644
--- a/modules/audio_coding/codecs/isac/main/source/entropy_coding.h
+++ b/modules/audio_coding/codecs/isac/main/source/entropy_coding.h
@@ -46,8 +46,11 @@
* Return value : < 0 if an error occures
* 0 if succeeded.
*/
-int WebRtcIsac_DecodeSpec(Bitstr* streamdata, int16_t AvgPitchGain_Q12,
- enum ISACBand band, double* fr, double* fi);
+int WebRtcIsac_DecodeSpec(Bitstr* streamdata,
+ int16_t AvgPitchGain_Q12,
+ enum ISACBand band,
+ double* fr,
+ double* fi);
/******************************************************************************
* WebRtcIsac_EncodeSpec()
@@ -72,24 +75,31 @@
* Return value : < 0 if an error occures
* 0 if succeeded.
*/
-int WebRtcIsac_EncodeSpec(const int16_t* fr, const int16_t* fi,
- int16_t AvgPitchGain_Q12, enum ISACBand band,
+int WebRtcIsac_EncodeSpec(const int16_t* fr,
+ const int16_t* fi,
+ int16_t AvgPitchGain_Q12,
+ enum ISACBand band,
Bitstr* streamdata);
/* decode & dequantize LPC Coef */
int WebRtcIsac_DecodeLpcCoef(Bitstr* streamdata, double* LPCCoef);
-int WebRtcIsac_DecodeLpcCoefUB(Bitstr* streamdata, double* lpcVecs,
+int WebRtcIsac_DecodeLpcCoefUB(Bitstr* streamdata,
+ double* lpcVecs,
double* percepFilterGains,
int16_t bandwidth);
-int WebRtcIsac_DecodeLpc(Bitstr* streamdata, double* LPCCoef_lo,
+int WebRtcIsac_DecodeLpc(Bitstr* streamdata,
+ double* LPCCoef_lo,
double* LPCCoef_hi);
/* quantize & code LPC Coef */
-void WebRtcIsac_EncodeLpcLb(double* LPCCoef_lo, double* LPCCoef_hi,
- Bitstr* streamdata, IsacSaveEncoderData* encData);
+void WebRtcIsac_EncodeLpcLb(double* LPCCoef_lo,
+ double* LPCCoef_hi,
+ Bitstr* streamdata,
+ IsacSaveEncoderData* encData);
-void WebRtcIsac_EncodeLpcGainLb(double* LPCCoef_lo, double* LPCCoef_hi,
+void WebRtcIsac_EncodeLpcGainLb(double* LPCCoef_lo,
+ double* LPCCoef_hi,
Bitstr* streamdata,
IsacSaveEncoderData* encData);
@@ -126,7 +136,8 @@
* Return value : 0 if encoding is successful,
* <0 if failed to encode.
*/
-int16_t WebRtcIsac_EncodeLpcUB(double* lpcCoeff, Bitstr* streamdata,
+int16_t WebRtcIsac_EncodeLpcUB(double* lpcCoeff,
+ Bitstr* streamdata,
double* interpolLPCCoeff,
int16_t bandwidth,
ISACUBSaveEncDataStruct* encData);
@@ -184,9 +195,9 @@
Bitstr* streamdata,
IsacSaveEncoderData* encData);
-int WebRtcIsac_DecodePitchGain(Bitstr* streamdata,
- int16_t* PitchGain_Q12);
-int WebRtcIsac_DecodePitchLag(Bitstr* streamdata, int16_t* PitchGain_Q12,
+int WebRtcIsac_DecodePitchGain(Bitstr* streamdata, int16_t* PitchGain_Q12);
+int WebRtcIsac_DecodePitchLag(Bitstr* streamdata,
+ int16_t* PitchGain_Q12,
double* PitchLag);
int WebRtcIsac_DecodeFrameLen(Bitstr* streamdata, int16_t* framelength);
@@ -200,10 +211,10 @@
/* Step-up */
void WebRtcIsac_Rc2Poly(double* RC, int N, double* a);
-void WebRtcIsac_TranscodeLPCCoef(double* LPCCoef_lo, double* LPCCoef_hi,
+void WebRtcIsac_TranscodeLPCCoef(double* LPCCoef_lo,
+ double* LPCCoef_hi,
int* index_g);
-
/******************************************************************************
* WebRtcIsac_EncodeLpcGainUb()
* Encode LPC gains of sub-Frames.
@@ -220,10 +231,10 @@
* - lpcGainIndex : quantization indices for lpc gains, these will
* be stored to be used for FEC.
*/
-void WebRtcIsac_EncodeLpcGainUb(double* lpGains, Bitstr* streamdata,
+void WebRtcIsac_EncodeLpcGainUb(double* lpGains,
+ Bitstr* streamdata,
int* lpcGainIndex);
-
/******************************************************************************
* WebRtcIsac_EncodeLpcGainUb()
* Store LPC gains of sub-Frames in 'streamdata'.
@@ -239,7 +250,6 @@
*/
void WebRtcIsac_StoreLpcGainUb(double* lpGains, Bitstr* streamdata);
-
/******************************************************************************
* WebRtcIsac_DecodeLpcGainUb()
* Decode the LPC gain of sub-frames.
@@ -257,7 +267,6 @@
*/
int16_t WebRtcIsac_DecodeLpcGainUb(double* lpGains, Bitstr* streamdata);
-
/******************************************************************************
* WebRtcIsac_EncodeBandwidth()
* Encode if the bandwidth of encoded audio is 0-12 kHz or 0-16 kHz.
@@ -277,7 +286,6 @@
int16_t WebRtcIsac_EncodeBandwidth(enum ISACBandwidth bandwidth,
Bitstr* streamData);
-
/******************************************************************************
* WebRtcIsac_DecodeBandwidth()
* Decode the bandwidth of the encoded audio, i.e. if the bandwidth is 0-12 kHz
@@ -298,7 +306,6 @@
int16_t WebRtcIsac_DecodeBandwidth(Bitstr* streamData,
enum ISACBandwidth* bandwidth);
-
/******************************************************************************
* WebRtcIsac_EncodeJitterInfo()
* Decode the jitter information.
@@ -316,9 +323,7 @@
* Return value : 0 if succeeded.
* <0 if failed.
*/
-int16_t WebRtcIsac_EncodeJitterInfo(int32_t jitterIndex,
- Bitstr* streamData);
-
+int16_t WebRtcIsac_EncodeJitterInfo(int32_t jitterIndex, Bitstr* streamData);
/******************************************************************************
* WebRtcIsac_DecodeJitterInfo()
@@ -337,7 +342,6 @@
* Return value : 0 if succeeded.
* <0 if failed.
*/
-int16_t WebRtcIsac_DecodeJitterInfo(Bitstr* streamData,
- int32_t* jitterInfo);
+int16_t WebRtcIsac_DecodeJitterInfo(Bitstr* streamData, int32_t* jitterInfo);
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_ENTROPY_CODING_H_ */
diff --git a/modules/audio_coding/codecs/isac/main/source/fft.h b/modules/audio_coding/codecs/isac/main/source/fft.h
index 9750153..34e5f94 100644
--- a/modules/audio_coding/codecs/isac/main/source/fft.h
+++ b/modules/audio_coding/codecs/isac/main/source/fft.h
@@ -34,10 +34,12 @@
/* double precision routine */
-
-int WebRtcIsac_Fftns (unsigned int ndim, const int dims[], double Re[], double Im[],
- int isign, double scaling, FFTstr *fftstate);
-
-
+int WebRtcIsac_Fftns(unsigned int ndim,
+ const int dims[],
+ double Re[],
+ double Im[],
+ int isign,
+ double scaling,
+ FFTstr* fftstate);
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_FFT_H_ */
diff --git a/modules/audio_coding/codecs/isac/main/source/isac_unittest.cc b/modules/audio_coding/codecs/isac/main/source/isac_unittest.cc
index 727f0f6..3ec28cc 100644
--- a/modules/audio_coding/codecs/isac/main/source/isac_unittest.cc
+++ b/modules/audio_coding/codecs/isac/main/source/isac_unittest.cc
@@ -35,15 +35,13 @@
uint8_t bitstream_small_[7]; // Simulate sync packets.
};
-IsacTest::IsacTest()
- : isac_codec_(NULL) {
-}
+IsacTest::IsacTest() : isac_codec_(NULL) {}
void IsacTest::SetUp() {
// Read some samples from a speech file, to be used in the encode test.
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(kIsacNumberOfSamples,
@@ -69,7 +67,8 @@
TEST_F(IsacTest, IsacCreateFree) {
EXPECT_EQ(0, WebRtcIsac_Create(&isac_codec_));
EXPECT_TRUE(isac_codec_ != NULL);
- EXPECT_EQ(0, WebRtcIsac_Free(isac_codec_));}
+ EXPECT_EQ(0, WebRtcIsac_Free(isac_codec_));
+}
TEST_F(IsacTest, IsacUpdateBWE) {
// Create encoder memory.
@@ -86,17 +85,17 @@
12345, 56789));
// Encode 60 ms of data (needed to create a first packet).
- encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_);
+ encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_);
EXPECT_EQ(0, encoded_bytes);
- encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_);
+ encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_);
EXPECT_EQ(0, encoded_bytes);
- encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_);
+ encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_);
EXPECT_EQ(0, encoded_bytes);
- encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_);
+ encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_);
EXPECT_EQ(0, encoded_bytes);
- encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_);
+ encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_);
EXPECT_EQ(0, encoded_bytes);
- encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_);
+ encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_);
EXPECT_GT(encoded_bytes, 0);
// Call to update bandwidth estimator with real data.
diff --git a/modules/audio_coding/codecs/isac/main/source/lpc_analysis.h b/modules/audio_coding/codecs/isac/main/source/lpc_analysis.h
index 30f9153..5503e2d 100644
--- a/modules/audio_coding/codecs/isac/main/source/lpc_analysis.h
+++ b/modules/audio_coding/codecs/isac/main/source/lpc_analysis.h
@@ -21,24 +21,26 @@
#include "modules/audio_coding/codecs/isac/main/source/settings.h"
#include "modules/audio_coding/codecs/isac/main/source/structs.h"
-void WebRtcIsac_GetLpcCoefLb(double *inLo, double *inHi, MaskFiltstr *maskdata,
- double signal_noise_ratio, const int16_t *pitchGains_Q12,
- double *lo_coeff, double *hi_coeff);
+void WebRtcIsac_GetLpcCoefLb(double* inLo,
+ double* inHi,
+ MaskFiltstr* maskdata,
+ double signal_noise_ratio,
+ const int16_t* pitchGains_Q12,
+ double* lo_coeff,
+ double* hi_coeff);
-void WebRtcIsac_GetLpcGain(
- double signal_noise_ratio,
- const double* filtCoeffVecs,
- int numVecs,
- double* gain,
- double corrLo[][UB_LPC_ORDER + 1],
- const double* varscale);
+void WebRtcIsac_GetLpcGain(double signal_noise_ratio,
+ const double* filtCoeffVecs,
+ int numVecs,
+ double* gain,
+ double corrLo[][UB_LPC_ORDER + 1],
+ const double* varscale);
-void WebRtcIsac_GetLpcCoefUb(
- double* inSignal,
- MaskFiltstr* maskdata,
- double* lpCoeff,
- double corr[][UB_LPC_ORDER + 1],
- double* varscale,
- int16_t bandwidth);
+void WebRtcIsac_GetLpcCoefUb(double* inSignal,
+ MaskFiltstr* maskdata,
+ double* lpCoeff,
+ double corr[][UB_LPC_ORDER + 1],
+ double* varscale,
+ int16_t bandwidth);
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_ANALYIS_H_ */
diff --git a/modules/audio_coding/codecs/isac/main/source/lpc_gain_swb_tables.h b/modules/audio_coding/codecs/isac/main/source/lpc_gain_swb_tables.h
index 7a5abfd..84913dd 100644
--- a/modules/audio_coding/codecs/isac/main/source/lpc_gain_swb_tables.h
+++ b/modules/audio_coding/codecs/isac/main/source/lpc_gain_swb_tables.h
@@ -46,4 +46,4 @@
extern const double WebRtcIsac_kLpcGainDecorrMat[SUBFRAMES][SUBFRAMES];
-#endif // MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_GAIN_SWB_TABLES_H_
+#endif // MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_GAIN_SWB_TABLES_H_
diff --git a/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb12_tables.h b/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb12_tables.h
index 7bae096..e21e15a 100644
--- a/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb12_tables.h
+++ b/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb12_tables.h
@@ -26,22 +26,22 @@
extern const double WebRtcIsac_kMeanLpcGain;
-extern const double WebRtcIsac_kIntraVecDecorrMatUb12[UB_LPC_ORDER][UB_LPC_ORDER];
+extern const double WebRtcIsac_kIntraVecDecorrMatUb12[UB_LPC_ORDER]
+ [UB_LPC_ORDER];
-extern const double WebRtcIsac_kInterVecDecorrMatUb12
-[UB_LPC_VEC_PER_FRAME][UB_LPC_VEC_PER_FRAME];
+extern const double WebRtcIsac_kInterVecDecorrMatUb12[UB_LPC_VEC_PER_FRAME]
+ [UB_LPC_VEC_PER_FRAME];
extern const double WebRtcIsac_kLpcShapeQStepSizeUb12;
-extern const double WebRtcIsac_kLpcShapeLeftRecPointUb12
-[UB_LPC_ORDER*UB_LPC_VEC_PER_FRAME];
+extern const double
+ WebRtcIsac_kLpcShapeLeftRecPointUb12[UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME];
+extern const int16_t
+ WebRtcIsac_kLpcShapeNumRecPointUb12[UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME];
-extern const int16_t WebRtcIsac_kLpcShapeNumRecPointUb12
-[UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME];
-
-extern const uint16_t WebRtcIsac_kLpcShapeEntropySearchUb12
-[UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME];
+extern const uint16_t
+ WebRtcIsac_kLpcShapeEntropySearchUb12[UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME];
extern const uint16_t WebRtcIsac_kLpcShapeCdfVec0Ub12[14];
@@ -59,7 +59,7 @@
extern const uint16_t WebRtcIsac_kLpcShapeCdfVec7Ub12[49];
-extern const uint16_t* WebRtcIsac_kLpcShapeCdfMatUb12
-[UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME];
+extern const uint16_t*
+ WebRtcIsac_kLpcShapeCdfMatUb12[UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME];
-#endif // MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_SHAPE_SWB12_TABLES_H_
+#endif // MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_SHAPE_SWB12_TABLES_H_
diff --git a/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb16_tables.h b/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb16_tables.h
index d828b83..4d5403d 100644
--- a/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb16_tables.h
+++ b/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb16_tables.h
@@ -24,10 +24,11 @@
extern const double WebRtcIsac_kMeanLarUb16[UB_LPC_ORDER];
-extern const double WebRtcIsac_kIintraVecDecorrMatUb16[UB_LPC_ORDER][UB_LPC_ORDER];
+extern const double WebRtcIsac_kIintraVecDecorrMatUb16[UB_LPC_ORDER]
+ [UB_LPC_ORDER];
-extern const double WebRtcIsac_kInterVecDecorrMatUb16
-[UB16_LPC_VEC_PER_FRAME][UB16_LPC_VEC_PER_FRAME];
+extern const double WebRtcIsac_kInterVecDecorrMatUb16[UB16_LPC_VEC_PER_FRAME]
+ [UB16_LPC_VEC_PER_FRAME];
extern const uint16_t WebRtcIsac_kLpcShapeCdfVec01Ub16[14];
@@ -61,18 +62,19 @@
extern const uint16_t WebRtcIsac_kLpcShapeCdfVec01Ub166[71];
-extern const uint16_t* WebRtcIsac_kLpcShapeCdfMatUb16
-[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME];
+extern const uint16_t*
+ WebRtcIsac_kLpcShapeCdfMatUb16[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME];
-extern const double WebRtcIsac_kLpcShapeLeftRecPointUb16
-[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME];
+extern const double
+ WebRtcIsac_kLpcShapeLeftRecPointUb16[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME];
-extern const int16_t WebRtcIsac_kLpcShapeNumRecPointUb16
-[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME];
+extern const int16_t
+ WebRtcIsac_kLpcShapeNumRecPointUb16[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME];
-extern const uint16_t WebRtcIsac_kLpcShapeEntropySearchUb16
-[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME];
+extern const uint16_t
+ WebRtcIsac_kLpcShapeEntropySearchUb16[UB_LPC_ORDER *
+ UB16_LPC_VEC_PER_FRAME];
extern const double WebRtcIsac_kLpcShapeQStepSizeUb16;
-#endif // MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_SHAPE_SWB16_TABLES_H_
+#endif // MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_SHAPE_SWB16_TABLES_H_
diff --git a/modules/audio_coding/codecs/isac/main/source/lpc_tables.h b/modules/audio_coding/codecs/isac/main/source/lpc_tables.h
index 2b02557..2d92dfa 100644
--- a/modules/audio_coding/codecs/isac/main/source/lpc_tables.h
+++ b/modules/audio_coding/codecs/isac/main/source/lpc_tables.h
@@ -22,27 +22,27 @@
#include "modules/audio_coding/codecs/isac/main/source/settings.h"
-#define KLT_STEPSIZE 1.00000000
-#define KLT_NUM_AVG_GAIN 0
-#define KLT_NUM_AVG_SHAPE 0
-#define KLT_NUM_MODELS 3
-#define LPC_GAIN_SCALE 4.000f
-#define LPC_LOBAND_SCALE 2.100f
-#define LPC_LOBAND_ORDER ORDERLO
-#define LPC_HIBAND_SCALE 0.450f
-#define LPC_HIBAND_ORDER ORDERHI
-#define LPC_GAIN_ORDER 2
+#define KLT_STEPSIZE 1.00000000
+#define KLT_NUM_AVG_GAIN 0
+#define KLT_NUM_AVG_SHAPE 0
+#define KLT_NUM_MODELS 3
+#define LPC_GAIN_SCALE 4.000f
+#define LPC_LOBAND_SCALE 2.100f
+#define LPC_LOBAND_ORDER ORDERLO
+#define LPC_HIBAND_SCALE 0.450f
+#define LPC_HIBAND_ORDER ORDERHI
+#define LPC_GAIN_ORDER 2
-#define LPC_SHAPE_ORDER (LPC_LOBAND_ORDER + LPC_HIBAND_ORDER)
+#define LPC_SHAPE_ORDER (LPC_LOBAND_ORDER + LPC_HIBAND_ORDER)
-#define KLT_ORDER_GAIN (LPC_GAIN_ORDER * SUBFRAMES)
-#define KLT_ORDER_SHAPE (LPC_SHAPE_ORDER * SUBFRAMES)
+#define KLT_ORDER_GAIN (LPC_GAIN_ORDER * SUBFRAMES)
+#define KLT_ORDER_SHAPE (LPC_SHAPE_ORDER * SUBFRAMES)
/* cdf array for model indicator */
-extern const uint16_t WebRtcIsac_kQKltModelCdf[KLT_NUM_MODELS+1];
+extern const uint16_t WebRtcIsac_kQKltModelCdf[KLT_NUM_MODELS + 1];
/* pointer to cdf array for model indicator */
-extern const uint16_t *WebRtcIsac_kQKltModelCdfPtr[1];
+extern const uint16_t* WebRtcIsac_kQKltModelCdfPtr[1];
/* initial cdf index for decoder of model indicator */
extern const uint16_t WebRtcIsac_kQKltModelInitIndex[1];
@@ -78,9 +78,9 @@
extern const uint16_t WebRtcIsac_kQKltCdfShape[686];
/* pointers to cdf tables for quantizer indices */
-extern const uint16_t *WebRtcIsac_kQKltCdfPtrGain[12];
+extern const uint16_t* WebRtcIsac_kQKltCdfPtrGain[12];
-extern const uint16_t *WebRtcIsac_kQKltCdfPtrShape[108];
+extern const uint16_t* WebRtcIsac_kQKltCdfPtrShape[108];
/* left KLT transforms */
extern const double WebRtcIsac_kKltT1Gain[4];
diff --git a/modules/audio_coding/codecs/isac/main/source/os_specific_inline.h b/modules/audio_coding/codecs/isac/main/source/os_specific_inline.h
index 597dc21..f72236d 100644
--- a/modules/audio_coding/codecs/isac/main/source/os_specific_inline.h
+++ b/modules/audio_coding/codecs/isac/main/source/os_specific_inline.h
@@ -8,7 +8,6 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-
#ifndef MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_OS_SPECIFIC_INLINE_H_
#define MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_OS_SPECIFIC_INLINE_H_
@@ -24,11 +23,12 @@
__asm {
fld x_dbl
fistp x_int
- };
+ }
+ ;
return x_int;
}
-#else // Do a slow but correct implementation of lrint
+#else // Do a slow but correct implementation of lrint
static __inline long int WebRtcIsac_lrint(double x_dbl) {
long int x_int;
diff --git a/modules/audio_coding/codecs/isac/main/source/pitch_estimator.h b/modules/audio_coding/codecs/isac/main/source/pitch_estimator.h
index c03ce62..4ab78c2 100644
--- a/modules/audio_coding/codecs/isac/main/source/pitch_estimator.h
+++ b/modules/audio_coding/codecs/isac/main/source/pitch_estimator.h
@@ -22,10 +22,11 @@
#include "modules/audio_coding/codecs/isac/main/source/structs.h"
-void WebRtcIsac_PitchAnalysis(const double *in, /* PITCH_FRAME_LEN samples */
- double *out, /* PITCH_FRAME_LEN+QLOOKAHEAD samples */
- PitchAnalysisStruct *State,
- double *lags,
- double *gains);
+void WebRtcIsac_PitchAnalysis(
+ const double* in, /* PITCH_FRAME_LEN samples */
+ double* out, /* PITCH_FRAME_LEN+QLOOKAHEAD samples */
+ PitchAnalysisStruct* State,
+ double* lags,
+ double* gains);
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_PITCH_ESTIMATOR_H_ */
diff --git a/modules/audio_coding/codecs/isac/main/source/pitch_gain_tables.h b/modules/audio_coding/codecs/isac/main/source/pitch_gain_tables.h
index fe506ee..891bcef 100644
--- a/modules/audio_coding/codecs/isac/main/source/pitch_gain_tables.h
+++ b/modules/audio_coding/codecs/isac/main/source/pitch_gain_tables.h
@@ -11,7 +11,8 @@
/*
* pitch_gain_tables.h
*
- * This file contains tables for the pitch filter side-info in the entropy coder.
+ * This file contains tables for the pitch filter side-info in the entropy
+ * coder.
*
*/
@@ -20,8 +21,10 @@
#include "typedefs.h" // NOLINT(build/include)
-/* header file for coding tables for the pitch filter side-info in the entropy coder */
-/********************* Pitch Filter Gain Coefficient Tables ************************/
+/* header file for coding tables for the pitch filter side-info in the entropy
+ * coder */
+/********************* Pitch Filter Gain Coefficient Tables
+ * ************************/
/* cdf for quantized pitch filter gains */
extern const uint16_t WebRtcIsac_kQPitchGainCdf[255];
diff --git a/modules/audio_coding/codecs/isac/main/source/pitch_lag_tables.h b/modules/audio_coding/codecs/isac/main/source/pitch_lag_tables.h
index 6a57c87..b662ab5 100644
--- a/modules/audio_coding/codecs/isac/main/source/pitch_lag_tables.h
+++ b/modules/audio_coding/codecs/isac/main/source/pitch_lag_tables.h
@@ -11,7 +11,8 @@
/*
* pitch_lag_tables.h
*
- * This file contains tables for the pitch filter side-info in the entropy coder.
+ * This file contains tables for the pitch filter side-info in the entropy
+ * coder.
*
*/
@@ -19,8 +20,10 @@
#define MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_PITCH_LAG_TABLES_H_
#include "typedefs.h" // NOLINT(build/include)
-/* header file for coding tables for the pitch filter side-info in the entropy coder */
-/********************* Pitch Filter Lag Coefficient Tables ************************/
+/* header file for coding tables for the pitch filter side-info in the entropy
+ * coder */
+/********************* Pitch Filter Lag Coefficient Tables
+ * ************************/
/* tables for use with small pitch gain */
@@ -30,7 +33,7 @@
extern const uint16_t WebRtcIsac_kQPitchLagCdf3Lo[2];
extern const uint16_t WebRtcIsac_kQPitchLagCdf4Lo[10];
-extern const uint16_t *WebRtcIsac_kQPitchLagCdfPtrLo[4];
+extern const uint16_t* WebRtcIsac_kQPitchLagCdfPtrLo[4];
/* size of first cdf table */
extern const uint16_t WebRtcIsac_kQPitchLagCdfSizeLo[1];
@@ -49,7 +52,6 @@
extern const double WebRtcIsac_kQPitchLagStepsizeLo;
-
/* tables for use with medium pitch gain */
/* cdfs for quantized pitch lags */
@@ -58,7 +60,7 @@
extern const uint16_t WebRtcIsac_kQPitchLagCdf3Mid[2];
extern const uint16_t WebRtcIsac_kQPitchLagCdf4Mid[20];
-extern const uint16_t *WebRtcIsac_kQPitchLagCdfPtrMid[4];
+extern const uint16_t* WebRtcIsac_kQPitchLagCdfPtrMid[4];
/* size of first cdf table */
extern const uint16_t WebRtcIsac_kQPitchLagCdfSizeMid[1];
@@ -77,7 +79,6 @@
extern const double WebRtcIsac_kQPitchLagStepsizeMid;
-
/* tables for use with large pitch gain */
/* cdfs for quantized pitch lags */
@@ -86,7 +87,7 @@
extern const uint16_t WebRtcIsac_kQPitchLagCdf3Hi[2];
extern const uint16_t WebRtcIsac_kQPitchLagCdf4Hi[35];
-extern const uint16_t *WebRtcIsac_kQPitchLagCdfPtrHi[4];
+extern const uint16_t* WebRtcIsac_kQPitchLagCdfPtrHi[4];
/* size of first cdf table */
extern const uint16_t WebRtcIsac_kQPitchLagCdfSizeHi[1];
diff --git a/modules/audio_coding/codecs/isac/main/source/settings.h b/modules/audio_coding/codecs/isac/main/source/settings.h
index c08d72f..14a5be8 100644
--- a/modules/audio_coding/codecs/isac/main/source/settings.h
+++ b/modules/audio_coding/codecs/isac/main/source/settings.h
@@ -19,187 +19,181 @@
#define MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_SETTINGS_H_
/* sampling frequency (Hz) */
-#define FS 16000
+#define FS 16000
/* number of samples per frame (either 320 (20ms), 480 (30ms) or 960 (60ms)) */
-#define INITIAL_FRAMESAMPLES 960
-
+#define INITIAL_FRAMESAMPLES 960
#define MAXFFTSIZE 2048
#define NFACTOR 11
-
-
/* do not modify the following; this will have to be modified if we
* have a 20ms framesize option */
/**********************************************************************/
/* miliseconds */
-#define FRAMESIZE 30
+#define FRAMESIZE 30
/* number of samples per frame processed in the encoder, 480 */
-#define FRAMESAMPLES 480 /* ((FRAMESIZE*FS)/1000) */
-#define FRAMESAMPLES_HALF 240
-#define FRAMESAMPLES_QUARTER 120
+#define FRAMESAMPLES 480 /* ((FRAMESIZE*FS)/1000) */
+#define FRAMESAMPLES_HALF 240
+#define FRAMESAMPLES_QUARTER 120
/**********************************************************************/
-
-
/* max number of samples per frame (= 60 ms frame) */
-#define MAX_FRAMESAMPLES 960
-#define MAX_SWBFRAMESAMPLES (MAX_FRAMESAMPLES * 2)
+#define MAX_FRAMESAMPLES 960
+#define MAX_SWBFRAMESAMPLES (MAX_FRAMESAMPLES * 2)
/* number of samples per 10ms frame */
-#define FRAMESAMPLES_10ms ((10*FS)/1000)
-#define SWBFRAMESAMPLES_10ms (FRAMESAMPLES_10ms * 2)
+#define FRAMESAMPLES_10ms ((10 * FS) / 1000)
+#define SWBFRAMESAMPLES_10ms (FRAMESAMPLES_10ms * 2)
/* number of samples in 30 ms frame */
-#define FRAMESAMPLES_30ms 480
+#define FRAMESAMPLES_30ms 480
/* number of subframes */
-#define SUBFRAMES 6
+#define SUBFRAMES 6
/* length of a subframe */
-#define UPDATE 80
+#define UPDATE 80
/* length of half a subframe (low/high band) */
-#define HALF_SUBFRAMELEN (UPDATE/2)
+#define HALF_SUBFRAMELEN (UPDATE / 2)
/* samples of look ahead (in a half-band, so actually
* half the samples of look ahead @ FS) */
-#define QLOOKAHEAD 24 /* 3 ms */
+#define QLOOKAHEAD 24 /* 3 ms */
/* order of AR model in spectral entropy coder */
-#define AR_ORDER 6
+#define AR_ORDER 6
/* order of LP model in spectral entropy coder */
-#define LP_ORDER 0
+#define LP_ORDER 0
/* window length (masking analysis) */
-#define WINLEN 256
+#define WINLEN 256
/* order of low-band pole filter used to approximate masking curve */
-#define ORDERLO 12
+#define ORDERLO 12
/* order of hi-band pole filter used to approximate masking curve */
-#define ORDERHI 6
+#define ORDERHI 6
-#define UB_LPC_ORDER 4
-#define UB_LPC_VEC_PER_FRAME 2
-#define UB16_LPC_VEC_PER_FRAME 4
-#define UB_ACTIVE_SUBFRAMES 2
-#define UB_MAX_LPC_ORDER 6
-#define UB_INTERPOL_SEGMENTS 1
-#define UB16_INTERPOL_SEGMENTS 3
-#define LB_TOTAL_DELAY_SAMPLES 48
-enum ISACBandwidth {isac8kHz = 8, isac12kHz = 12, isac16kHz = 16};
-enum ISACBand {kIsacLowerBand = 0, kIsacUpperBand12 = 1, kIsacUpperBand16 = 2};
-enum IsacSamplingRate {kIsacWideband = 16, kIsacSuperWideband = 32};
-#define UB_LPC_GAIN_DIM SUBFRAMES
-#define FB_STATE_SIZE_WORD32 6
-
+#define UB_LPC_ORDER 4
+#define UB_LPC_VEC_PER_FRAME 2
+#define UB16_LPC_VEC_PER_FRAME 4
+#define UB_ACTIVE_SUBFRAMES 2
+#define UB_MAX_LPC_ORDER 6
+#define UB_INTERPOL_SEGMENTS 1
+#define UB16_INTERPOL_SEGMENTS 3
+#define LB_TOTAL_DELAY_SAMPLES 48
+enum ISACBandwidth { isac8kHz = 8, isac12kHz = 12, isac16kHz = 16 };
+enum ISACBand {
+ kIsacLowerBand = 0,
+ kIsacUpperBand12 = 1,
+ kIsacUpperBand16 = 2
+};
+enum IsacSamplingRate { kIsacWideband = 16, kIsacSuperWideband = 32 };
+#define UB_LPC_GAIN_DIM SUBFRAMES
+#define FB_STATE_SIZE_WORD32 6
/* order for post_filter_bank */
-#define POSTQORDER 3
+#define POSTQORDER 3
/* order for pre-filterbank */
-#define QORDER 3
+#define QORDER 3
/* another order */
-#define QORDER_ALL (POSTQORDER+QORDER-1)
+#define QORDER_ALL (POSTQORDER + QORDER - 1)
/* for decimator */
-#define ALLPASSSECTIONS 2
-
+#define ALLPASSSECTIONS 2
/* array size for byte stream in number of bytes. */
/* The old maximum size still needed for the decoding */
-#define STREAM_SIZE_MAX 600
-#define STREAM_SIZE_MAX_30 200 /* 200 bytes=53.4 kbps @ 30 ms.framelength */
-#define STREAM_SIZE_MAX_60 400 /* 400 bytes=53.4 kbps @ 60 ms.framelength */
+#define STREAM_SIZE_MAX 600
+#define STREAM_SIZE_MAX_30 200 /* 200 bytes=53.4 kbps @ 30 ms.framelength */
+#define STREAM_SIZE_MAX_60 400 /* 400 bytes=53.4 kbps @ 60 ms.framelength */
/* storage size for bit counts */
-#define BIT_COUNTER_SIZE 30
+#define BIT_COUNTER_SIZE 30
/* maximum order of any AR model or filter */
-#define MAX_AR_MODEL_ORDER 12//50
-
+#define MAX_AR_MODEL_ORDER 12 // 50
/* For pitch analysis */
-#define PITCH_FRAME_LEN (FRAMESAMPLES_HALF) /* 30 ms */
-#define PITCH_MAX_LAG 140 /* 57 Hz */
-#define PITCH_MIN_LAG 20 /* 400 Hz */
-#define PITCH_MAX_GAIN 0.45
-#define PITCH_MAX_GAIN_06 0.27 /* PITCH_MAX_GAIN*0.6 */
-#define PITCH_MAX_GAIN_Q12 1843
-#define PITCH_LAG_SPAN2 (PITCH_MAX_LAG/2-PITCH_MIN_LAG/2+5)
-#define PITCH_CORR_LEN2 60 /* 15 ms */
-#define PITCH_CORR_STEP2 (PITCH_FRAME_LEN/4)
-#define PITCH_BW 11 /* half the band width of correlation surface */
-#define PITCH_SUBFRAMES 4
-#define PITCH_GRAN_PER_SUBFRAME 5
-#define PITCH_SUBFRAME_LEN (PITCH_FRAME_LEN/PITCH_SUBFRAMES)
-#define PITCH_UPDATE (PITCH_SUBFRAME_LEN/PITCH_GRAN_PER_SUBFRAME)
+#define PITCH_FRAME_LEN (FRAMESAMPLES_HALF) /* 30 ms */
+#define PITCH_MAX_LAG 140 /* 57 Hz */
+#define PITCH_MIN_LAG 20 /* 400 Hz */
+#define PITCH_MAX_GAIN 0.45
+#define PITCH_MAX_GAIN_06 0.27 /* PITCH_MAX_GAIN*0.6 */
+#define PITCH_MAX_GAIN_Q12 1843
+#define PITCH_LAG_SPAN2 (PITCH_MAX_LAG / 2 - PITCH_MIN_LAG / 2 + 5)
+#define PITCH_CORR_LEN2 60 /* 15 ms */
+#define PITCH_CORR_STEP2 (PITCH_FRAME_LEN / 4)
+#define PITCH_BW 11 /* half the band width of correlation surface */
+#define PITCH_SUBFRAMES 4
+#define PITCH_GRAN_PER_SUBFRAME 5
+#define PITCH_SUBFRAME_LEN (PITCH_FRAME_LEN / PITCH_SUBFRAMES)
+#define PITCH_UPDATE (PITCH_SUBFRAME_LEN / PITCH_GRAN_PER_SUBFRAME)
/* maximum number of peaks to be examined in correlation surface */
-#define PITCH_MAX_NUM_PEAKS 10
-#define PITCH_PEAK_DECAY 0.85
+#define PITCH_MAX_NUM_PEAKS 10
+#define PITCH_PEAK_DECAY 0.85
/* For weighting filter */
-#define PITCH_WLPCORDER 6
-#define PITCH_WLPCWINLEN PITCH_FRAME_LEN
-#define PITCH_WLPCASYM 0.3 /* asymmetry parameter */
-#define PITCH_WLPCBUFLEN PITCH_WLPCWINLEN
+#define PITCH_WLPCORDER 6
+#define PITCH_WLPCWINLEN PITCH_FRAME_LEN
+#define PITCH_WLPCASYM 0.3 /* asymmetry parameter */
+#define PITCH_WLPCBUFLEN PITCH_WLPCWINLEN
/* For pitch filter */
/* Extra 50 for fraction and LP filters */
-#define PITCH_BUFFSIZE (PITCH_MAX_LAG + 50)
-#define PITCH_INTBUFFSIZE (PITCH_FRAME_LEN+PITCH_BUFFSIZE)
+#define PITCH_BUFFSIZE (PITCH_MAX_LAG + 50)
+#define PITCH_INTBUFFSIZE (PITCH_FRAME_LEN + PITCH_BUFFSIZE)
/* Max rel. step for interpolation */
-#define PITCH_UPSTEP 1.5
+#define PITCH_UPSTEP 1.5
/* Max rel. step for interpolation */
-#define PITCH_DOWNSTEP 0.67
-#define PITCH_FRACS 8
-#define PITCH_FRACORDER 9
-#define PITCH_DAMPORDER 5
-#define PITCH_FILTDELAY 1.5f
+#define PITCH_DOWNSTEP 0.67
+#define PITCH_FRACS 8
+#define PITCH_FRACORDER 9
+#define PITCH_DAMPORDER 5
+#define PITCH_FILTDELAY 1.5f
/* stepsize for quantization of the pitch Gain */
-#define PITCH_GAIN_STEPSIZE 0.125
-
-
+#define PITCH_GAIN_STEPSIZE 0.125
/* Order of high pass filter */
-#define HPORDER 2
+#define HPORDER 2
/* some mathematical constants */
/* log2(exp) */
-#define LOG2EXP 1.44269504088896
-#define PI 3.14159265358979
+#define LOG2EXP 1.44269504088896
+#define PI 3.14159265358979
/* Maximum number of iterations allowed to limit payload size */
-#define MAX_PAYLOAD_LIMIT_ITERATION 5
+#define MAX_PAYLOAD_LIMIT_ITERATION 5
/* Redundant Coding */
-#define RCU_BOTTLENECK_BPS 16000
-#define RCU_TRANSCODING_SCALE 0.40f
-#define RCU_TRANSCODING_SCALE_INVERSE 2.5f
+#define RCU_BOTTLENECK_BPS 16000
+#define RCU_TRANSCODING_SCALE 0.40f
+#define RCU_TRANSCODING_SCALE_INVERSE 2.5f
-#define RCU_TRANSCODING_SCALE_UB 0.50f
-#define RCU_TRANSCODING_SCALE_UB_INVERSE 2.0f
+#define RCU_TRANSCODING_SCALE_UB 0.50f
+#define RCU_TRANSCODING_SCALE_UB_INVERSE 2.0f
/* Define Error codes */
/* 6000 General */
-#define ISAC_MEMORY_ALLOCATION_FAILED 6010
-#define ISAC_MODE_MISMATCH 6020
-#define ISAC_DISALLOWED_BOTTLENECK 6030
-#define ISAC_DISALLOWED_FRAME_LENGTH 6040
-#define ISAC_UNSUPPORTED_SAMPLING_FREQUENCY 6050
+#define ISAC_MEMORY_ALLOCATION_FAILED 6010
+#define ISAC_MODE_MISMATCH 6020
+#define ISAC_DISALLOWED_BOTTLENECK 6030
+#define ISAC_DISALLOWED_FRAME_LENGTH 6040
+#define ISAC_UNSUPPORTED_SAMPLING_FREQUENCY 6050
/* 6200 Bandwidth estimator */
-#define ISAC_RANGE_ERROR_BW_ESTIMATOR 6240
+#define ISAC_RANGE_ERROR_BW_ESTIMATOR 6240
/* 6400 Encoder */
-#define ISAC_ENCODER_NOT_INITIATED 6410
-#define ISAC_DISALLOWED_CODING_MODE 6420
-#define ISAC_DISALLOWED_FRAME_MODE_ENCODER 6430
-#define ISAC_DISALLOWED_BITSTREAM_LENGTH 6440
-#define ISAC_PAYLOAD_LARGER_THAN_LIMIT 6450
-#define ISAC_DISALLOWED_ENCODER_BANDWIDTH 6460
+#define ISAC_ENCODER_NOT_INITIATED 6410
+#define ISAC_DISALLOWED_CODING_MODE 6420
+#define ISAC_DISALLOWED_FRAME_MODE_ENCODER 6430
+#define ISAC_DISALLOWED_BITSTREAM_LENGTH 6440
+#define ISAC_PAYLOAD_LARGER_THAN_LIMIT 6450
+#define ISAC_DISALLOWED_ENCODER_BANDWIDTH 6460
/* 6600 Decoder */
-#define ISAC_DECODER_NOT_INITIATED 6610
-#define ISAC_EMPTY_PACKET 6620
-#define ISAC_DISALLOWED_FRAME_MODE_DECODER 6630
-#define ISAC_RANGE_ERROR_DECODE_FRAME_LENGTH 6640
-#define ISAC_RANGE_ERROR_DECODE_BANDWIDTH 6650
-#define ISAC_RANGE_ERROR_DECODE_PITCH_GAIN 6660
-#define ISAC_RANGE_ERROR_DECODE_PITCH_LAG 6670
-#define ISAC_RANGE_ERROR_DECODE_LPC 6680
-#define ISAC_RANGE_ERROR_DECODE_SPECTRUM 6690
-#define ISAC_LENGTH_MISMATCH 6730
-#define ISAC_RANGE_ERROR_DECODE_BANDWITH 6740
-#define ISAC_DISALLOWED_BANDWIDTH_MODE_DECODER 6750
-#define ISAC_DISALLOWED_LPC_MODEL 6760
+#define ISAC_DECODER_NOT_INITIATED 6610
+#define ISAC_EMPTY_PACKET 6620
+#define ISAC_DISALLOWED_FRAME_MODE_DECODER 6630
+#define ISAC_RANGE_ERROR_DECODE_FRAME_LENGTH 6640
+#define ISAC_RANGE_ERROR_DECODE_BANDWIDTH 6650
+#define ISAC_RANGE_ERROR_DECODE_PITCH_GAIN 6660
+#define ISAC_RANGE_ERROR_DECODE_PITCH_LAG 6670
+#define ISAC_RANGE_ERROR_DECODE_LPC 6680
+#define ISAC_RANGE_ERROR_DECODE_SPECTRUM 6690
+#define ISAC_LENGTH_MISMATCH 6730
+#define ISAC_RANGE_ERROR_DECODE_BANDWITH 6740
+#define ISAC_DISALLOWED_BANDWIDTH_MODE_DECODER 6750
+#define ISAC_DISALLOWED_LPC_MODEL 6760
/* 6800 Call setup formats */
-#define ISAC_INCOMPATIBLE_FORMATS 6810
+#define ISAC_INCOMPATIBLE_FORMATS 6810
#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_SETTINGS_H_ */
diff --git a/modules/audio_coding/codecs/isac/main/source/spectrum_ar_model_tables.h b/modules/audio_coding/codecs/isac/main/source/spectrum_ar_model_tables.h
index 1e656eb..d272be0 100644
--- a/modules/audio_coding/codecs/isac/main/source/spectrum_ar_model_tables.h
+++ b/modules/audio_coding/codecs/isac/main/source/spectrum_ar_model_tables.h
@@ -11,7 +11,7 @@
/*
* spectrum_ar_model_tables.h
*
- * This file contains definitions of tables with AR coefficients,
+ * This file contains definitions of tables with AR coefficients,
* Gain coefficients and cosine tables.
*
*/
@@ -45,15 +45,15 @@
/* quantization boundary levels for reflection coefficients */
extern const int16_t WebRtcIsac_kQArBoundaryLevels[NUM_AR_RC_QUANT_BAUNDARY];
-/* initial indices for AR reflection coefficient quantizer and cdf table search */
+/* initial indices for AR reflection coefficient quantizer and cdf table search
+ */
extern const uint16_t WebRtcIsac_kQArRcInitIndex[AR_ORDER];
/* pointers to AR cdf tables */
-extern const uint16_t *WebRtcIsac_kQArRcCdfPtr[AR_ORDER];
+extern const uint16_t* WebRtcIsac_kQArRcCdfPtr[AR_ORDER];
/* pointers to AR representation levels tables */
-extern const int16_t *WebRtcIsac_kQArRcLevelsPtr[AR_ORDER];
-
+extern const int16_t* WebRtcIsac_kQArRcLevelsPtr[AR_ORDER];
/******************** GAIN Coefficient Tables ***********************/
/* cdf for Gain coefficient */
@@ -66,7 +66,7 @@
extern const int32_t WebRtcIsac_kQGain2BoundaryLevels[19];
/* pointer to Gain cdf table */
-extern const uint16_t *WebRtcIsac_kQGainCdf_ptr[1];
+extern const uint16_t* WebRtcIsac_kQGainCdf_ptr[1];
/* Gain initial index for gain quantizer and cdf table search */
extern const uint16_t WebRtcIsac_kQGainInitIndex[1];
@@ -75,4 +75,5 @@
/* Cosine table */
extern const int16_t WebRtcIsac_kCos[6][60];
-#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_SPECTRUM_AR_MODEL_TABLES_H_ */
+#endif /* MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_SPECTRUM_AR_MODEL_TABLES_H_ \
+ */
diff --git a/modules/audio_coding/codecs/isac/main/source/structs.h b/modules/audio_coding/codecs/isac/main/source/structs.h
index 8197d55..f8ac9c7 100644
--- a/modules/audio_coding/codecs/isac/main/source/structs.h
+++ b/modules/audio_coding/codecs/isac/main/source/structs.h
@@ -23,178 +23,166 @@
#include "typedefs.h" // NOLINT(build/include)
typedef struct Bitstreamstruct {
-
- uint8_t stream[STREAM_SIZE_MAX];
- uint32_t W_upper;
- uint32_t streamval;
- uint32_t stream_index;
+ uint8_t stream[STREAM_SIZE_MAX];
+ uint32_t W_upper;
+ uint32_t streamval;
+ uint32_t stream_index;
} Bitstr;
typedef struct {
+ double DataBufferLo[WINLEN];
+ double DataBufferHi[WINLEN];
- double DataBufferLo[WINLEN];
- double DataBufferHi[WINLEN];
+ double CorrBufLo[ORDERLO + 1];
+ double CorrBufHi[ORDERHI + 1];
- double CorrBufLo[ORDERLO+1];
- double CorrBufHi[ORDERHI+1];
+ float PreStateLoF[ORDERLO + 1];
+ float PreStateLoG[ORDERLO + 1];
+ float PreStateHiF[ORDERHI + 1];
+ float PreStateHiG[ORDERHI + 1];
+ float PostStateLoF[ORDERLO + 1];
+ float PostStateLoG[ORDERLO + 1];
+ float PostStateHiF[ORDERHI + 1];
+ float PostStateHiG[ORDERHI + 1];
- float PreStateLoF[ORDERLO+1];
- float PreStateLoG[ORDERLO+1];
- float PreStateHiF[ORDERHI+1];
- float PreStateHiG[ORDERHI+1];
- float PostStateLoF[ORDERLO+1];
- float PostStateLoG[ORDERLO+1];
- float PostStateHiF[ORDERHI+1];
- float PostStateHiG[ORDERHI+1];
-
- double OldEnergy;
+ double OldEnergy;
} MaskFiltstr;
-
typedef struct {
+ // state vectors for each of the two analysis filters
+ double INSTAT1[2 * (QORDER - 1)];
+ double INSTAT2[2 * (QORDER - 1)];
+ double INSTATLA1[2 * (QORDER - 1)];
+ double INSTATLA2[2 * (QORDER - 1)];
+ double INLABUF1[QLOOKAHEAD];
+ double INLABUF2[QLOOKAHEAD];
- //state vectors for each of the two analysis filters
- double INSTAT1[2*(QORDER-1)];
- double INSTAT2[2*(QORDER-1)];
- double INSTATLA1[2*(QORDER-1)];
- double INSTATLA2[2*(QORDER-1)];
- double INLABUF1[QLOOKAHEAD];
- double INLABUF2[QLOOKAHEAD];
-
- float INSTAT1_float[2*(QORDER-1)];
- float INSTAT2_float[2*(QORDER-1)];
- float INSTATLA1_float[2*(QORDER-1)];
- float INSTATLA2_float[2*(QORDER-1)];
- float INLABUF1_float[QLOOKAHEAD];
- float INLABUF2_float[QLOOKAHEAD];
+ float INSTAT1_float[2 * (QORDER - 1)];
+ float INSTAT2_float[2 * (QORDER - 1)];
+ float INSTATLA1_float[2 * (QORDER - 1)];
+ float INSTATLA2_float[2 * (QORDER - 1)];
+ float INLABUF1_float[QLOOKAHEAD];
+ float INLABUF2_float[QLOOKAHEAD];
/* High pass filter */
- double HPstates[HPORDER];
- float HPstates_float[HPORDER];
+ double HPstates[HPORDER];
+ float HPstates_float[HPORDER];
} PreFiltBankstr;
-
typedef struct {
-
- //state vectors for each of the two analysis filters
- double STATE_0_LOWER[2*POSTQORDER];
- double STATE_0_UPPER[2*POSTQORDER];
+ // state vectors for each of the two analysis filters
+ double STATE_0_LOWER[2 * POSTQORDER];
+ double STATE_0_UPPER[2 * POSTQORDER];
/* High pass filter */
- double HPstates1[HPORDER];
- double HPstates2[HPORDER];
+ double HPstates1[HPORDER];
+ double HPstates2[HPORDER];
- float STATE_0_LOWER_float[2*POSTQORDER];
- float STATE_0_UPPER_float[2*POSTQORDER];
+ float STATE_0_LOWER_float[2 * POSTQORDER];
+ float STATE_0_UPPER_float[2 * POSTQORDER];
- float HPstates1_float[HPORDER];
- float HPstates2_float[HPORDER];
+ float HPstates1_float[HPORDER];
+ float HPstates2_float[HPORDER];
} PostFiltBankstr;
typedef struct {
+ // data buffer for pitch filter
+ double ubuf[PITCH_BUFFSIZE];
- //data buffer for pitch filter
- double ubuf[PITCH_BUFFSIZE];
+ // low pass state vector
+ double ystate[PITCH_DAMPORDER];
- //low pass state vector
- double ystate[PITCH_DAMPORDER];
-
- //old lag and gain
- double oldlagp[1];
- double oldgainp[1];
+ // old lag and gain
+ double oldlagp[1];
+ double oldgainp[1];
} PitchFiltstr;
typedef struct {
+ // data buffer
+ double buffer[PITCH_WLPCBUFLEN];
- //data buffer
- double buffer[PITCH_WLPCBUFLEN];
+ // state vectors
+ double istate[PITCH_WLPCORDER];
+ double weostate[PITCH_WLPCORDER];
+ double whostate[PITCH_WLPCORDER];
- //state vectors
- double istate[PITCH_WLPCORDER];
- double weostate[PITCH_WLPCORDER];
- double whostate[PITCH_WLPCORDER];
-
- //LPC window -> should be a global array because constant
- double window[PITCH_WLPCWINLEN];
+ // LPC window -> should be a global array because constant
+ double window[PITCH_WLPCWINLEN];
} WeightFiltstr;
typedef struct {
+ // for inital estimator
+ double dec_buffer[PITCH_CORR_LEN2 + PITCH_CORR_STEP2 + PITCH_MAX_LAG / 2 -
+ PITCH_FRAME_LEN / 2 + 2];
+ double decimator_state[2 * ALLPASSSECTIONS + 1];
+ double hp_state[2];
- //for inital estimator
- double dec_buffer[PITCH_CORR_LEN2 + PITCH_CORR_STEP2 +
- PITCH_MAX_LAG/2 - PITCH_FRAME_LEN/2+2];
- double decimator_state[2*ALLPASSSECTIONS+1];
- double hp_state[2];
+ double whitened_buf[QLOOKAHEAD];
- double whitened_buf[QLOOKAHEAD];
+ double inbuf[QLOOKAHEAD];
- double inbuf[QLOOKAHEAD];
-
- PitchFiltstr PFstr_wght;
- PitchFiltstr PFstr;
+ PitchFiltstr PFstr_wght;
+ PitchFiltstr PFstr;
WeightFiltstr Wghtstr;
} PitchAnalysisStruct;
-
-
/* Have instance of struct together with other iSAC structs */
typedef struct {
-
/* Previous frame length (in ms) */
- int32_t prev_frame_length;
+ int32_t prev_frame_length;
/* Previous RTP timestamp from received
packet (in samples relative beginning) */
- int32_t prev_rec_rtp_number;
+ int32_t prev_rec_rtp_number;
/* Send timestamp for previous packet (in ms using timeGetTime()) */
- uint32_t prev_rec_send_ts;
+ uint32_t prev_rec_send_ts;
/* Arrival time for previous packet (in ms using timeGetTime()) */
- uint32_t prev_rec_arr_ts;
+ uint32_t prev_rec_arr_ts;
/* rate of previous packet, derived from RTP timestamps (in bits/s) */
- float prev_rec_rtp_rate;
+ float prev_rec_rtp_rate;
/* Time sinse the last update of the BN estimate (in ms) */
- uint32_t last_update_ts;
+ uint32_t last_update_ts;
/* Time sinse the last reduction (in ms) */
- uint32_t last_reduction_ts;
+ uint32_t last_reduction_ts;
/* How many times the estimate was update in the beginning */
- int32_t count_tot_updates_rec;
+ int32_t count_tot_updates_rec;
/* The estimated bottle neck rate from there to here (in bits/s) */
- int32_t rec_bw;
- float rec_bw_inv;
- float rec_bw_avg;
- float rec_bw_avg_Q;
+ int32_t rec_bw;
+ float rec_bw_inv;
+ float rec_bw_avg;
+ float rec_bw_avg_Q;
/* The estimated mean absolute jitter value,
as seen on this side (in ms) */
- float rec_jitter;
- float rec_jitter_short_term;
- float rec_jitter_short_term_abs;
- float rec_max_delay;
- float rec_max_delay_avg_Q;
+ float rec_jitter;
+ float rec_jitter_short_term;
+ float rec_jitter_short_term_abs;
+ float rec_max_delay;
+ float rec_max_delay_avg_Q;
/* (assumed) bitrate for headers (bps) */
- float rec_header_rate;
+ float rec_header_rate;
/* The estimated bottle neck rate from here to there (in bits/s) */
- float send_bw_avg;
+ float send_bw_avg;
/* The estimated mean absolute jitter value, as seen on
the other siee (in ms) */
- float send_max_delay_avg;
+ float send_max_delay_avg;
// number of packets received since last update
int num_pkts_rec;
@@ -217,35 +205,31 @@
int change_to_WB;
- uint32_t senderTimestamp;
- uint32_t receiverTimestamp;
- //enum IsacSamplingRate incomingStreamSampFreq;
- uint16_t numConsecLatePkts;
- float consecLatency;
- int16_t inWaitLatePkts;
+ uint32_t senderTimestamp;
+ uint32_t receiverTimestamp;
+ // enum IsacSamplingRate incomingStreamSampFreq;
+ uint16_t numConsecLatePkts;
+ float consecLatency;
+ int16_t inWaitLatePkts;
IsacBandwidthInfo external_bw_info;
} BwEstimatorstr;
-
typedef struct {
-
/* boolean, flags if previous packet exceeded B.N. */
- int PrevExceed;
+ int PrevExceed;
/* ms */
- int ExceedAgo;
+ int ExceedAgo;
/* packets left to send in current burst */
- int BurstCounter;
+ int BurstCounter;
/* packets */
- int InitCounter;
+ int InitCounter;
/* ms remaining in buffer when next packet will be sent */
double StillBuffered;
} RateModel;
-
typedef struct {
-
unsigned int SpaceAlloced;
unsigned int MaxPermAlloced;
double Tmp0[MAXFFTSIZE];
@@ -253,36 +237,34 @@
double Tmp2[MAXFFTSIZE];
double Tmp3[MAXFFTSIZE];
int Perm[MAXFFTSIZE];
- int factor [NFACTOR];
+ int factor[NFACTOR];
} FFTstr;
-
/* The following strutc is used to store data from encoding, to make it
fast and easy to construct a new bitstream with a different Bandwidth
estimate. All values (except framelength and minBytes) is double size to
handle 60 ms of data.
*/
typedef struct {
-
/* Used to keep track of if it is first or second part of 60 msec packet */
- int startIdx;
+ int startIdx;
/* Frame length in samples */
int16_t framelength;
/* Pitch Gain */
- int pitchGain_index[2];
+ int pitchGain_index[2];
/* Pitch Lag */
- double meanGain[2];
- int pitchIndex[PITCH_SUBFRAMES*2];
+ double meanGain[2];
+ int pitchIndex[PITCH_SUBFRAMES * 2];
/* LPC */
- int LPCindex_s[108*2]; /* KLT_ORDER_SHAPE = 108 */
- int LPCindex_g[12*2]; /* KLT_ORDER_GAIN = 12 */
- double LPCcoeffs_lo[(ORDERLO+1)*SUBFRAMES*2];
- double LPCcoeffs_hi[(ORDERHI+1)*SUBFRAMES*2];
+ int LPCindex_s[108 * 2]; /* KLT_ORDER_SHAPE = 108 */
+ int LPCindex_g[12 * 2]; /* KLT_ORDER_GAIN = 12 */
+ double LPCcoeffs_lo[(ORDERLO + 1) * SUBFRAMES * 2];
+ double LPCcoeffs_hi[(ORDERHI + 1) * SUBFRAMES * 2];
/* Encode Spec */
int16_t fre[FRAMESAMPLES];
@@ -290,59 +272,54 @@
int16_t AvgPitchGain[2];
/* Used in adaptive mode only */
- int minBytes;
+ int minBytes;
} IsacSaveEncoderData;
-
typedef struct {
+ int indexLPCShape[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME];
+ double lpcGain[SUBFRAMES << 1];
+ int lpcGainIndex[SUBFRAMES << 1];
- int indexLPCShape[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME];
- double lpcGain[SUBFRAMES<<1];
- int lpcGainIndex[SUBFRAMES<<1];
-
- Bitstr bitStreamObj;
+ Bitstr bitStreamObj;
int16_t realFFT[FRAMESAMPLES_HALF];
int16_t imagFFT[FRAMESAMPLES_HALF];
} ISACUBSaveEncDataStruct;
-
-
typedef struct {
-
- Bitstr bitstr_obj;
- MaskFiltstr maskfiltstr_obj;
- PreFiltBankstr prefiltbankstr_obj;
- PitchFiltstr pitchfiltstr_obj;
+ Bitstr bitstr_obj;
+ MaskFiltstr maskfiltstr_obj;
+ PreFiltBankstr prefiltbankstr_obj;
+ PitchFiltstr pitchfiltstr_obj;
PitchAnalysisStruct pitchanalysisstr_obj;
- FFTstr fftstr_obj;
+ FFTstr fftstr_obj;
IsacSaveEncoderData SaveEnc_obj;
- int buffer_index;
- int16_t current_framesamples;
+ int buffer_index;
+ int16_t current_framesamples;
- float data_buffer_float[FRAMESAMPLES_30ms];
+ float data_buffer_float[FRAMESAMPLES_30ms];
- int frame_nb;
- double bottleneck;
- int16_t new_framelength;
- double s2nr;
+ int frame_nb;
+ double bottleneck;
+ int16_t new_framelength;
+ double s2nr;
/* Maximum allowed number of bits for a 30 msec packet */
- int16_t payloadLimitBytes30;
+ int16_t payloadLimitBytes30;
/* Maximum allowed number of bits for a 30 msec packet */
- int16_t payloadLimitBytes60;
+ int16_t payloadLimitBytes60;
/* Maximum allowed number of bits for both 30 and 60 msec packet */
- int16_t maxPayloadBytes;
+ int16_t maxPayloadBytes;
/* Maximum allowed rate in bytes per 30 msec packet */
- int16_t maxRateInBytes;
+ int16_t maxRateInBytes;
/*---
If set to 1 iSAC will not addapt the frame-size, if used in
channel-adaptive mode. The initial value will be used for all rates.
---*/
- int16_t enforceFrameSize;
+ int16_t enforceFrameSize;
/*-----
This records the BWE index the encoder injected into the bit-stream.
@@ -351,64 +328,53 @@
a recursive procedure (WebRtcIsac_GetDownlinkBwJitIndexImpl) and has to be
called only once per each encode.
-----*/
- int16_t lastBWIdx;
+ int16_t lastBWIdx;
} ISACLBEncStruct;
typedef struct {
-
- Bitstr bitstr_obj;
- MaskFiltstr maskfiltstr_obj;
- PreFiltBankstr prefiltbankstr_obj;
- FFTstr fftstr_obj;
+ Bitstr bitstr_obj;
+ MaskFiltstr maskfiltstr_obj;
+ PreFiltBankstr prefiltbankstr_obj;
+ FFTstr fftstr_obj;
ISACUBSaveEncDataStruct SaveEnc_obj;
- int buffer_index;
- float data_buffer_float[MAX_FRAMESAMPLES +
- LB_TOTAL_DELAY_SAMPLES];
- double bottleneck;
+ int buffer_index;
+ float data_buffer_float[MAX_FRAMESAMPLES + LB_TOTAL_DELAY_SAMPLES];
+ double bottleneck;
/* Maximum allowed number of bits for a 30 msec packet */
- //int16_t payloadLimitBytes30;
+ // int16_t payloadLimitBytes30;
/* Maximum allowed number of bits for both 30 and 60 msec packet */
- //int16_t maxPayloadBytes;
- int16_t maxPayloadSizeBytes;
+ // int16_t maxPayloadBytes;
+ int16_t maxPayloadSizeBytes;
- double lastLPCVec[UB_LPC_ORDER];
- int16_t numBytesUsed;
- int16_t lastJitterInfo;
+ double lastLPCVec[UB_LPC_ORDER];
+ int16_t numBytesUsed;
+ int16_t lastJitterInfo;
} ISACUBEncStruct;
-
-
typedef struct {
-
- Bitstr bitstr_obj;
- MaskFiltstr maskfiltstr_obj;
+ Bitstr bitstr_obj;
+ MaskFiltstr maskfiltstr_obj;
PostFiltBankstr postfiltbankstr_obj;
- PitchFiltstr pitchfiltstr_obj;
- FFTstr fftstr_obj;
+ PitchFiltstr pitchfiltstr_obj;
+ FFTstr fftstr_obj;
} ISACLBDecStruct;
typedef struct {
-
- Bitstr bitstr_obj;
- MaskFiltstr maskfiltstr_obj;
+ Bitstr bitstr_obj;
+ MaskFiltstr maskfiltstr_obj;
PostFiltBankstr postfiltbankstr_obj;
- FFTstr fftstr_obj;
+ FFTstr fftstr_obj;
} ISACUBDecStruct;
-
-
typedef struct {
-
ISACLBEncStruct ISACencLB_obj;
ISACLBDecStruct ISACdecLB_obj;
} ISACLBStruct;
-
typedef struct {
-
ISACUBEncStruct ISACencUB_obj;
ISACUBDecStruct ISACdecUB_obj;
} ISACUBStruct;
@@ -420,14 +386,14 @@
*/
typedef struct {
/* 6 lower-band & 6 upper-band */
- double loFiltGain[SUBFRAMES];
- double hiFiltGain[SUBFRAMES];
+ double loFiltGain[SUBFRAMES];
+ double hiFiltGain[SUBFRAMES];
/* Upper boundary of interval W */
uint32_t W_upper;
uint32_t streamval;
/* Index to the current position in bytestream */
uint32_t stream_index;
- uint8_t stream[3];
+ uint8_t stream[3];
} transcode_obj;
typedef struct {
@@ -443,46 +409,46 @@
typedef struct {
// lower-band codec instance
- ISACLBStruct instLB;
+ ISACLBStruct instLB;
// upper-band codec instance
- ISACUBStruct instUB;
+ ISACUBStruct instUB;
// Bandwidth Estimator and model for the rate.
- BwEstimatorstr bwestimator_obj;
- RateModel rate_data_obj;
- double MaxDelay;
+ BwEstimatorstr bwestimator_obj;
+ RateModel rate_data_obj;
+ double MaxDelay;
/* 0 = adaptive; 1 = instantaneous */
- int16_t codingMode;
+ int16_t codingMode;
// overall bottleneck of the codec
- int32_t bottleneck;
+ int32_t bottleneck;
// QMF Filter state
- int32_t analysisFBState1[FB_STATE_SIZE_WORD32];
- int32_t analysisFBState2[FB_STATE_SIZE_WORD32];
- int32_t synthesisFBState1[FB_STATE_SIZE_WORD32];
- int32_t synthesisFBState2[FB_STATE_SIZE_WORD32];
+ int32_t analysisFBState1[FB_STATE_SIZE_WORD32];
+ int32_t analysisFBState2[FB_STATE_SIZE_WORD32];
+ int32_t synthesisFBState1[FB_STATE_SIZE_WORD32];
+ int32_t synthesisFBState2[FB_STATE_SIZE_WORD32];
// Error Code
- int16_t errorCode;
+ int16_t errorCode;
// bandwidth of the encoded audio 8, 12 or 16 kHz
- enum ISACBandwidth bandwidthKHz;
+ enum ISACBandwidth bandwidthKHz;
// Sampling rate of audio, encoder and decode, 8 or 16 kHz
enum IsacSamplingRate encoderSamplingRateKHz;
enum IsacSamplingRate decoderSamplingRateKHz;
// Flag to keep track of initializations, lower & upper-band
// encoder and decoder.
- int16_t initFlag;
+ int16_t initFlag;
// Flag to to indicate signal bandwidth switch
- int16_t resetFlag_8kHz;
+ int16_t resetFlag_8kHz;
// Maximum allowed rate, measured in Bytes per 30 ms.
- int16_t maxRateBytesPer30Ms;
+ int16_t maxRateBytesPer30Ms;
// Maximum allowed payload-size, measured in Bytes.
- int16_t maxPayloadSizeBytes;
+ int16_t maxPayloadSizeBytes;
/* The expected sampling rate of the input signal. Valid values are 16000
* and 32000. This is not the operation sampling rate of the codec. */
uint16_t in_sample_rate_hz;
diff --git a/modules/audio_coding/codecs/isac/main/test/ReleaseTest-API/ReleaseTest-API.cc b/modules/audio_coding/codecs/isac/main/test/ReleaseTest-API/ReleaseTest-API.cc
index cedcb9d..35a8832 100644
--- a/modules/audio_coding/codecs/isac/main/test/ReleaseTest-API/ReleaseTest-API.cc
+++ b/modules/audio_coding/codecs/isac/main/test/ReleaseTest-API/ReleaseTest-API.cc
@@ -11,11 +11,11 @@
// ReleaseTest-API.cpp : Defines the entry point for the console application.
//
+#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
-#include <ctype.h>
#include <iostream>
/* include API */
@@ -24,10 +24,13 @@
#include "rtc_base/format_macros.h"
/* Defines */
-#define SEED_FILE "randseed.txt" /* Used when running decoder on garbage data */
-#define MAX_FRAMESAMPLES 960 /* max number of samples per frame
- (= 60 ms frame & 16 kHz) or
- (= 30 ms frame & 32 kHz) */
+#define SEED_FILE \
+ "randseed.txt" /* Used when running decoder on garbage data \
+ */
+#define MAX_FRAMESAMPLES \
+ 960 /* max number of samples per frame \
+ (= 60 ms frame & 16 kHz) or \
+ (= 30 ms frame & 32 kHz) */
#define FRAMESAMPLES_10ms 160 /* number of samples per 10ms frame */
#define SWBFRAMESAMPLES_10ms 320
//#define FS 16000 /* sampling frequency (Hz) */
@@ -42,7 +45,7 @@
int main(int argc, char* argv[]) {
char inname[100], outname[100], bottleneck_file[100], vadfile[100];
- FILE* inp, *outp, * f_bn = NULL, * vadp = NULL, *bandwidthp;
+ FILE *inp, *outp, *f_bn = NULL, *vadp = NULL, *bandwidthp;
int framecnt, endfile;
size_t i;
@@ -230,8 +233,10 @@
rateBPS = atoi(argv[i + 1]);
setControlBWE = 1;
if ((rateBPS < 10000) || (rateBPS > 32000)) {
- printf("\n%d is not a initial rate. Valid values are in the range "
- "10000 to 32000.\n", rateBPS);
+ printf(
+ "\n%d is not a initial rate. Valid values are in the range "
+ "10000 to 32000.\n",
+ rateBPS);
exit(0);
}
printf("New initial rate: %d\n", rateBPS);
@@ -242,8 +247,10 @@
if (!strcmp("-FL", argv[i])) {
framesize = atoi(argv[i + 1]);
if ((framesize != 30) && (framesize != 60)) {
- printf("\n%d is not a valid frame length. Valid length are 30 and 60 "
- "msec.\n", framesize);
+ printf(
+ "\n%d is not a valid frame length. Valid length are 30 and 60 "
+ "msec.\n",
+ framesize);
exit(0);
}
setControlBWE = 1;
@@ -277,8 +284,10 @@
testNum = atoi(argv[i + 1]);
printf("Fault test: %d\n", testNum);
if (testNum < 1 || testNum > 10) {
- printf("\n%d is not a valid Fault Scenario number. Valid Fault "
- "Scenarios are numbered 1-10.\n", testNum);
+ printf(
+ "\n%d is not a valid Fault Scenario number. Valid Fault "
+ "Scenarios are numbered 1-10.\n",
+ testNum);
exit(0);
}
i++;
@@ -336,8 +345,10 @@
sscanf(argv[i], "%s", bottleneck_file);
f_bn = fopen(bottleneck_file, "rb");
if (f_bn == NULL) {
- printf("Error No value provided for BottleNeck and cannot read file "
- "%s.\n", bottleneck_file);
+ printf(
+ "Error No value provided for BottleNeck and cannot read file "
+ "%s.\n",
+ bottleneck_file);
exit(0);
} else {
printf("reading bottleneck rates from file %s\n\n", bottleneck_file);
@@ -637,8 +648,8 @@
}
if (fwrite(streamDataTransCoding, sizeof(uint8_t),
- streamLenTransCoding, transcodingBitstream) !=
- streamLenTransCoding) {
+ streamLenTransCoding,
+ transcodingBitstream) != streamLenTransCoding) {
return -1;
}
@@ -718,8 +729,7 @@
fprintf(stderr, "Error in RED trans-coding\n");
exit(0);
}
- streamLenTransCoding =
- static_cast<size_t>(streamLenTransCoding_int);
+ streamLenTransCoding = static_cast<size_t>(streamLenTransCoding_int);
}
}
diff --git a/modules/audio_coding/codecs/isac/main/test/SwitchingSampRate/SwitchingSampRate.cc b/modules/audio_coding/codecs/isac/main/test/SwitchingSampRate/SwitchingSampRate.cc
index 23de079..59a3ade 100644
--- a/modules/audio_coding/codecs/isac/main/test/SwitchingSampRate/SwitchingSampRate.cc
+++ b/modules/audio_coding/codecs/isac/main/test/SwitchingSampRate/SwitchingSampRate.cc
@@ -18,16 +18,14 @@
#include "modules/audio_coding/codecs/isac/main/include/isac.h"
#include "modules/audio_coding/codecs/isac/main/util/utility.h"
-#define MAX_FILE_NAME 500
+#define MAX_FILE_NAME 500
#define MAX_NUM_CLIENTS 2
-
#define NUM_CLIENTS 2
using namespace std;
-int main(int argc, char* argv[])
-{
+int main(int argc, char* argv[]) {
char fileNameWB[MAX_FILE_NAME];
char fileNameSWB[MAX_FILE_NAME];
@@ -68,21 +66,18 @@
printf(" iSAC-swb version %s\n", versionNumber);
printf("____________________________________________\n");
-
- fileNameWB[0] = '\0';
+ fileNameWB[0] = '\0';
fileNameSWB[0] = '\0';
char myFlag[20];
strcpy(myFlag, "-wb");
// READ THE WIDEBAND AND SUPER-WIDEBAND FILE NAMES
- if(readParamString(argc, argv, myFlag, fileNameWB, MAX_FILE_NAME) <= 0)
- {
+ if (readParamString(argc, argv, myFlag, fileNameWB, MAX_FILE_NAME) <= 0) {
printf("No wideband file is specified");
}
strcpy(myFlag, "-swb");
- if(readParamString(argc, argv, myFlag, fileNameSWB, MAX_FILE_NAME) <= 0)
- {
+ if (readParamString(argc, argv, myFlag, fileNameSWB, MAX_FILE_NAME) <= 0) {
printf("No super-wideband file is specified");
}
@@ -97,16 +92,15 @@
strcpy(myFlag, "-I");
short codingMode = readSwitch(argc, argv, myFlag);
- for(clientCntr = 0; clientCntr < NUM_CLIENTS; clientCntr++)
- {
+ for (clientCntr = 0; clientCntr < NUM_CLIENTS; clientCntr++) {
codecInstance[clientCntr] = NULL;
printf("\n");
printf("Client %d\n", clientCntr + 1);
printf("---------\n");
- printf("Starting %s",
- (encoderSampRate[clientCntr] == 16000)
- ? "wideband":"super-wideband");
+ printf("Starting %s", (encoderSampRate[clientCntr] == 16000)
+ ? "wideband"
+ : "super-wideband");
// Open output File Name
OPEN_FILE_WB(outFile[clientCntr], outFileName[clientCntr]);
@@ -114,30 +108,27 @@
samplesIn10ms[clientCntr] = encoderSampRate[clientCntr] * 10;
- if(codingMode == 1)
- {
- bottleneck[clientCntr] = (clientCntr)? bnSWB:bnWB;
- }
- else
- {
- bottleneck[clientCntr] = (clientCntr)? minBn:maxBn;
+ if (codingMode == 1) {
+ bottleneck[clientCntr] = (clientCntr) ? bnSWB : bnWB;
+ } else {
+ bottleneck[clientCntr] = (clientCntr) ? minBn : maxBn;
}
printf("Bottleneck....................... %0.3f kbits/sec \n",
bottleneck[clientCntr] / 1000.0);
// coding-mode
- printf("Encoding Mode.................... %s\n",
- (codingMode == 1)? "Channel-Independent (Instantaneous)":"Adaptive");
+ printf(
+ "Encoding Mode.................... %s\n",
+ (codingMode == 1) ? "Channel-Independent (Instantaneous)" : "Adaptive");
lenEncodedInBytes[clientCntr] = 0;
lenAudioIn10ms[clientCntr] = 0;
lenEncodedInBytesTmp[clientCntr] = 0;
lenAudioIn10msTmp[clientCntr] = 0;
- packetData[clientCntr] = (BottleNeckModel*)new(BottleNeckModel);
- if(packetData[clientCntr] == NULL)
- {
+ packetData[clientCntr] = (BottleNeckModel*)new (BottleNeckModel);
+ if (packetData[clientCntr] == NULL) {
printf("Could not allocate memory for packetData \n");
return -1;
}
@@ -145,24 +136,22 @@
memset(resamplerState[clientCntr], 0, sizeof(int32_t) * 8);
}
- for(clientCntr = 0; clientCntr < NUM_CLIENTS; clientCntr++)
- {
+ for (clientCntr = 0; clientCntr < NUM_CLIENTS; clientCntr++) {
// Create
- if(WebRtcIsac_Create(&codecInstance[clientCntr]))
- {
+ if (WebRtcIsac_Create(&codecInstance[clientCntr])) {
printf("Could not creat client %d\n", clientCntr + 1);
return -1;
}
- WebRtcIsac_SetEncSampRate(codecInstance[clientCntr], encoderSampRate[clientCntr]);
+ WebRtcIsac_SetEncSampRate(codecInstance[clientCntr],
+ encoderSampRate[clientCntr]);
- WebRtcIsac_SetDecSampRate(codecInstance[clientCntr],
- encoderSampRate[clientCntr + (1 - ((clientCntr & 1)<<1))]);
+ WebRtcIsac_SetDecSampRate(
+ codecInstance[clientCntr],
+ encoderSampRate[clientCntr + (1 - ((clientCntr & 1) << 1))]);
// Initialize Encoder
- if(WebRtcIsac_EncoderInit(codecInstance[clientCntr],
- codingMode) < 0)
- {
+ if (WebRtcIsac_EncoderInit(codecInstance[clientCntr], codingMode) < 0) {
printf("Could not initialize client, %d\n", clientCntr + 1);
return -1;
}
@@ -170,12 +159,10 @@
WebRtcIsac_DecoderInit(codecInstance[clientCntr]);
// setup Rate if in Instantaneous mode
- if(codingMode != 0)
- {
+ if (codingMode != 0) {
// ONLY Clients who are not in Adaptive mode
- if(WebRtcIsac_Control(codecInstance[clientCntr],
- bottleneck[clientCntr], 30) < 0)
- {
+ if (WebRtcIsac_Control(codecInstance[clientCntr], bottleneck[clientCntr],
+ 30) < 0) {
printf("Could not setup bottleneck and frame-size for client %d\n",
clientCntr + 1);
return -1;
@@ -183,7 +170,6 @@
}
}
-
size_t streamLen;
short numSamplesRead;
size_t lenDecodedAudio;
@@ -192,7 +178,7 @@
printf("\n");
short num10ms[MAX_NUM_CLIENTS];
- memset(num10ms, 0, sizeof(short)*MAX_NUM_CLIENTS);
+ memset(num10ms, 0, sizeof(short) * MAX_NUM_CLIENTS);
FILE* arrivalTimeFile1 = fopen("arrivalTime1.dat", "wb");
FILE* arrivalTimeFile2 = fopen("arrivalTime2.dat", "wb");
short numPrint[MAX_NUM_CLIENTS];
@@ -205,61 +191,60 @@
short audioBuff60ms[60 * 32];
short resampledAudio60ms[60 * 32];
- unsigned short bitStream[600+600];
+ unsigned short bitStream[600 + 600];
short speechType[1];
short numSampFreqChanged = 0;
- while(numSampFreqChanged < 10)
- {
- for(clientCntr = 0; clientCntr < NUM_CLIENTS; clientCntr++)
- {
+ while (numSampFreqChanged < 10) {
+ for (clientCntr = 0; clientCntr < NUM_CLIENTS; clientCntr++) {
// Encoding/decoding for this pair of clients, if there is
// audio for any of them
- //if(audioLeft[clientCntr] || audioLeft[clientCntr + 1])
+ // if(audioLeft[clientCntr] || audioLeft[clientCntr + 1])
//{
- //for(pairCntr = 0; pairCntr < 2; pairCntr++)
+ // for(pairCntr = 0; pairCntr < 2; pairCntr++)
//{
- senderIdx = clientCntr; // + pairCntr;
- receiverIdx = 1 - clientCntr;// + (1 - pairCntr);
+ senderIdx = clientCntr; // + pairCntr;
+ receiverIdx = 1 - clientCntr; // + (1 - pairCntr);
- //if(num10ms[senderIdx] > 6)
+ // if(num10ms[senderIdx] > 6)
//{
// printf("Too many frames read for client %d",
// senderIdx + 1);
// return -1;
//}
- numSamplesRead = (short)fread(audioBuff10ms, sizeof(short),
- samplesIn10ms[senderIdx], inFile[senderIdx]);
- if(numSamplesRead != samplesIn10ms[senderIdx])
- {
+ numSamplesRead =
+ (short)fread(audioBuff10ms, sizeof(short), samplesIn10ms[senderIdx],
+ inFile[senderIdx]);
+ if (numSamplesRead != samplesIn10ms[senderIdx]) {
// file finished switch encoder sampling frequency.
- printf("Changing Encoder Sampling frequency in client %d to ", senderIdx+1);
+ printf("Changing Encoder Sampling frequency in client %d to ",
+ senderIdx + 1);
fclose(inFile[senderIdx]);
numSampFreqChanged++;
- if(encoderSampRate[senderIdx] == 16000)
- {
+ if (encoderSampRate[senderIdx] == 16000) {
printf("super-wideband.\n");
OPEN_FILE_RB(inFile[senderIdx], fileNameSWB);
encoderSampRate[senderIdx] = 32000;
- }
- else
- {
+ } else {
printf("wideband.\n");
OPEN_FILE_RB(inFile[senderIdx], fileNameWB);
encoderSampRate[senderIdx] = 16000;
}
- WebRtcIsac_SetEncSampRate(codecInstance[senderIdx], encoderSampRate[senderIdx]);
- WebRtcIsac_SetDecSampRate(codecInstance[receiverIdx], encoderSampRate[senderIdx]);
+ WebRtcIsac_SetEncSampRate(codecInstance[senderIdx],
+ encoderSampRate[senderIdx]);
+ WebRtcIsac_SetDecSampRate(codecInstance[receiverIdx],
+ encoderSampRate[senderIdx]);
samplesIn10ms[clientCntr] = encoderSampRate[clientCntr] * 10;
- numSamplesRead = (short)fread(audioBuff10ms, sizeof(short),
- samplesIn10ms[senderIdx], inFile[senderIdx]);
- if(numSamplesRead != samplesIn10ms[senderIdx])
- {
+ numSamplesRead =
+ (short)fread(audioBuff10ms, sizeof(short), samplesIn10ms[senderIdx],
+ inFile[senderIdx]);
+ if (numSamplesRead != samplesIn10ms[senderIdx]) {
printf(" File %s for client %d has not enough audio\n",
- (encoderSampRate[senderIdx]==16000)? "wideband":"super-wideband",
+ (encoderSampRate[senderIdx] == 16000) ? "wideband"
+ : "super-wideband",
senderIdx + 1);
return -1;
}
@@ -267,39 +252,34 @@
num10ms[senderIdx]++;
// sanity check
- //if(num10ms[senderIdx] > 6)
+ // if(num10ms[senderIdx] > 6)
//{
- // printf("Client %d has got more than 60 ms audio and encoded no packet.\n",
+ // printf("Client %d has got more than 60 ms audio and encoded no
+ // packet.\n",
// senderIdx);
// return -1;
//}
// Encode
-
int streamLen_int = WebRtcIsac_Encode(codecInstance[senderIdx],
- audioBuff10ms,
- (uint8_t*)bitStream);
+ audioBuff10ms, (uint8_t*)bitStream);
int16_t ggg;
if (streamLen_int > 0) {
if ((WebRtcIsac_ReadFrameLen(
codecInstance[receiverIdx],
- reinterpret_cast<const uint8_t*>(bitStream),
- &ggg)) < 0)
+ reinterpret_cast<const uint8_t*>(bitStream), &ggg)) < 0)
printf("ERROR\n");
}
// Sanity check
- if(streamLen_int < 0)
- {
+ if (streamLen_int < 0) {
printf(" Encoder error in client %d \n", senderIdx + 1);
return -1;
}
streamLen = static_cast<size_t>(streamLen_int);
-
- if(streamLen > 0)
- {
+ if (streamLen > 0) {
// Packet generated; model sending through a channel, do bandwidth
// estimation at the receiver and decode.
lenEncodedInBytes[senderIdx] += streamLen;
@@ -308,32 +288,30 @@
lenAudioIn10msTmp[senderIdx] += (unsigned int)num10ms[senderIdx];
// Print after ~5 sec.
- if(lenAudioIn10msTmp[senderIdx] >= 100)
- {
+ if (lenAudioIn10msTmp[senderIdx] >= 100) {
numPrint[senderIdx]++;
- printf(" %d, %6.3f => %6.3f ", senderIdx+1,
+ printf(" %d, %6.3f => %6.3f ", senderIdx + 1,
bottleneck[senderIdx] / 1000.0,
lenEncodedInBytesTmp[senderIdx] * 0.8 /
- lenAudioIn10msTmp[senderIdx]);
+ lenAudioIn10msTmp[senderIdx]);
- if(codingMode == 0)
- {
+ if (codingMode == 0) {
int32_t bn;
WebRtcIsac_GetUplinkBw(codecInstance[senderIdx], &bn);
printf("[%d] ", bn);
}
- //int16_t rateIndexLB;
- //int16_t rateIndexUB;
- //WebRtcIsac_GetDownLinkBwIndex(codecInstance[receiverIdx],
+ // int16_t rateIndexLB;
+ // int16_t rateIndexUB;
+ // WebRtcIsac_GetDownLinkBwIndex(codecInstance[receiverIdx],
// &rateIndexLB, &rateIndexUB);
- //printf(" (%2d, %2d) ", rateIndexLB, rateIndexUB);
+ // printf(" (%2d, %2d) ", rateIndexLB, rateIndexUB);
cout << flush;
lenEncodedInBytesTmp[senderIdx] = 0;
- lenAudioIn10msTmp[senderIdx] = 0;
- //if(senderIdx == (NUM_CLIENTS - 1))
+ lenAudioIn10msTmp[senderIdx] = 0;
+ // if(senderIdx == (NUM_CLIENTS - 1))
//{
- printf(" %0.1f \n", lenAudioIn10ms[senderIdx] * 10. /1000);
+ printf(" %0.1f \n", lenAudioIn10ms[senderIdx] * 10. / 1000);
//}
// After ~20 sec change the bottleneck.
@@ -385,23 +363,20 @@
// model a channel of given bottleneck, to get the receive timestamp
get_arrival_time(num10ms[senderIdx] * samplesIn10ms[senderIdx],
- streamLen, bottleneck[senderIdx], packetData[senderIdx],
- encoderSampRate[senderIdx]*1000, encoderSampRate[senderIdx]*1000);
+ streamLen, bottleneck[senderIdx],
+ packetData[senderIdx],
+ encoderSampRate[senderIdx] * 1000,
+ encoderSampRate[senderIdx] * 1000);
// Write the arrival time.
- if(senderIdx == 0)
- {
+ if (senderIdx == 0) {
if (fwrite(&(packetData[senderIdx]->arrival_time),
- sizeof(unsigned int),
- 1, arrivalTimeFile1) != 1) {
+ sizeof(unsigned int), 1, arrivalTimeFile1) != 1) {
return -1;
}
- }
- else
- {
+ } else {
if (fwrite(&(packetData[senderIdx]->arrival_time),
- sizeof(unsigned int),
- 1, arrivalTimeFile2) != 1) {
+ sizeof(unsigned int), 1, arrivalTimeFile2) != 1) {
return -1;
}
}
@@ -409,8 +384,7 @@
// BWE
if (WebRtcIsac_UpdateBwEstimate(
codecInstance[receiverIdx],
- reinterpret_cast<const uint8_t*>(bitStream),
- streamLen,
+ reinterpret_cast<const uint8_t*>(bitStream), streamLen,
packetData[senderIdx]->rtp_number,
packetData[senderIdx]->sample_count,
packetData[senderIdx]->arrival_time) < 0) {
@@ -419,34 +393,27 @@
}
/**/
// Decode
- int lenDecodedAudio_int = WebRtcIsac_Decode(
- codecInstance[receiverIdx],
- reinterpret_cast<const uint8_t*>(bitStream),
- streamLen,
- audioBuff60ms,
- speechType);
- if(lenDecodedAudio_int < 0)
- {
+ int lenDecodedAudio_int =
+ WebRtcIsac_Decode(codecInstance[receiverIdx],
+ reinterpret_cast<const uint8_t*>(bitStream),
+ streamLen, audioBuff60ms, speechType);
+ if (lenDecodedAudio_int < 0) {
printf(" Decoder error in client %d \n", receiverIdx + 1);
return -1;
}
lenDecodedAudio = static_cast<size_t>(lenDecodedAudio_int);
- if(encoderSampRate[senderIdx] == 16000)
- {
- WebRtcSpl_UpsampleBy2(audioBuff60ms, lenDecodedAudio, resampledAudio60ms,
+ if (encoderSampRate[senderIdx] == 16000) {
+ WebRtcSpl_UpsampleBy2(audioBuff60ms, lenDecodedAudio,
+ resampledAudio60ms,
resamplerState[receiverIdx]);
if (fwrite(resampledAudio60ms, sizeof(short), lenDecodedAudio << 1,
- outFile[receiverIdx]) !=
- lenDecodedAudio << 1) {
+ outFile[receiverIdx]) != lenDecodedAudio << 1) {
return -1;
}
- }
- else
- {
+ } else {
if (fwrite(audioBuff60ms, sizeof(short), lenDecodedAudio,
- outFile[receiverIdx]) !=
- lenDecodedAudio) {
+ outFile[receiverIdx]) != lenDecodedAudio) {
return -1;
}
}
diff --git a/modules/audio_coding/codecs/isac/main/util/utility.h b/modules/audio_coding/codecs/isac/main/util/utility.h
index b5882a5..1acc542 100644
--- a/modules/audio_coding/codecs/isac/main/util/utility.h
+++ b/modules/audio_coding/codecs/isac/main/util/utility.h
@@ -11,134 +11,98 @@
#ifndef MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_UTIL_UTILITY_H_
#define MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_UTIL_UTILITY_H_
-#include <stdlib.h>
#include <stdio.h>
+#include <stdlib.h>
#if defined(__cplusplus)
extern "C" {
#endif
-#define OPEN_FILE_WB(filePtr, fullPath) \
- do \
- { \
- if(fullPath != NULL) \
- { \
- filePtr = fopen(fullPath, "wb"); \
- if(filePtr == NULL) \
- { \
- printf("could not open %s to write to.", fullPath); \
- return -1; \
- } \
- } \
- else \
- { \
- filePtr = NULL; \
- } \
- }while(0)
+#define OPEN_FILE_WB(filePtr, fullPath) \
+ do { \
+ if (fullPath != NULL) { \
+ filePtr = fopen(fullPath, "wb"); \
+ if (filePtr == NULL) { \
+ printf("could not open %s to write to.", fullPath); \
+ return -1; \
+ } \
+ } else { \
+ filePtr = NULL; \
+ } \
+ } while (0)
-#define OPEN_FILE_AB(filePtr, fullPath) \
- do \
- { \
- if(fullPath != NULL) \
- { \
- filePtr = fopen(fullPath, "ab"); \
- if(filePtr == NULL) \
- { \
- printf("could not open %s to write to.", fullPath); \
- return -1; \
- } \
- } \
- else \
- { \
- filePtr = NULL; \
- } \
- }while(0)
+#define OPEN_FILE_AB(filePtr, fullPath) \
+ do { \
+ if (fullPath != NULL) { \
+ filePtr = fopen(fullPath, "ab"); \
+ if (filePtr == NULL) { \
+ printf("could not open %s to write to.", fullPath); \
+ return -1; \
+ } \
+ } else { \
+ filePtr = NULL; \
+ } \
+ } while (0)
-#define OPEN_FILE_RB(filePtr, fullPath) \
- do \
- { \
- if(fullPath != NULL) \
- { \
- filePtr = fopen(fullPath, "rb"); \
- if(filePtr == NULL) \
- { \
- printf("could not open %s to read from.", fullPath); \
- return -1; \
- } \
- } \
- else \
- { \
- filePtr = NULL; \
- } \
- }while(0)
+#define OPEN_FILE_RB(filePtr, fullPath) \
+ do { \
+ if (fullPath != NULL) { \
+ filePtr = fopen(fullPath, "rb"); \
+ if (filePtr == NULL) { \
+ printf("could not open %s to read from.", fullPath); \
+ return -1; \
+ } \
+ } else { \
+ filePtr = NULL; \
+ } \
+ } while (0)
-#define WRITE_FILE_D(bufferPtr, len, filePtr) \
- do \
- { \
- if(filePtr != NULL) \
- { \
- double dummy[1000]; \
- int cntr; \
- for(cntr = 0; cntr < (len); cntr++) \
- { \
- dummy[cntr] = (double)bufferPtr[cntr]; \
- } \
- fwrite(dummy, sizeof(double), len, filePtr); \
- fflush(filePtr); \
- } \
- } while(0)
+#define WRITE_FILE_D(bufferPtr, len, filePtr) \
+ do { \
+ if (filePtr != NULL) { \
+ double dummy[1000]; \
+ int cntr; \
+ for (cntr = 0; cntr < (len); cntr++) { \
+ dummy[cntr] = (double)bufferPtr[cntr]; \
+ } \
+ fwrite(dummy, sizeof(double), len, filePtr); \
+ fflush(filePtr); \
+ } \
+ } while (0)
- typedef struct {
- unsigned int whenPackGeneratedMs;
- unsigned int whenPrevPackLeftMs;
- unsigned int sendTimeMs ; /* milisecond */
- unsigned int arrival_time; /* samples */
- unsigned int sample_count; /* samples, also used as "send time stamp" */
- unsigned int rtp_number;
- } BottleNeckModel;
+typedef struct {
+ unsigned int whenPackGeneratedMs;
+ unsigned int whenPrevPackLeftMs;
+ unsigned int sendTimeMs; /* milisecond */
+ unsigned int arrival_time; /* samples */
+ unsigned int sample_count; /* samples, also used as "send time stamp" */
+ unsigned int rtp_number;
+} BottleNeckModel;
- void get_arrival_time(
- int current_framesamples, /* samples */
- size_t packet_size, /* bytes */
- int bottleneck, /* excluding headers; bits/s */
- BottleNeckModel* BN_data,
- short senderSampFreqHz,
- short receiverSampFreqHz);
+void get_arrival_time(int current_framesamples, /* samples */
+ size_t packet_size, /* bytes */
+ int bottleneck, /* excluding headers; bits/s */
+ BottleNeckModel* BN_data,
+ short senderSampFreqHz,
+ short receiverSampFreqHz);
- /* function for reading audio data from PCM file */
- int readframe(
- short* data,
- FILE* inp,
- int length);
+/* function for reading audio data from PCM file */
+int readframe(short* data, FILE* inp, int length);
- short readSwitch(
- int argc,
- char* argv[],
- char* strID);
+short readSwitch(int argc, char* argv[], char* strID);
- double readParamDouble(
- int argc,
- char* argv[],
- char* strID,
- double defaultVal);
+double readParamDouble(int argc, char* argv[], char* strID, double defaultVal);
- int readParamInt(
- int argc,
- char* argv[],
- char* strID,
- int defaultVal);
+int readParamInt(int argc, char* argv[], char* strID, int defaultVal);
- int readParamString(
- int argc,
- char* argv[],
- char* strID,
- char* stringParam,
- int maxSize);
+int readParamString(int argc,
+ char* argv[],
+ char* strID,
+ char* stringParam,
+ int maxSize);
#if defined(__cplusplus)
}
#endif
-
-
#endif
diff --git a/modules/audio_coding/codecs/legacy_encoded_audio_frame.cc b/modules/audio_coding/codecs/legacy_encoded_audio_frame.cc
index 6d322a8..0bf3b19 100644
--- a/modules/audio_coding/codecs/legacy_encoded_audio_frame.cc
+++ b/modules/audio_coding/codecs/legacy_encoded_audio_frame.cc
@@ -68,10 +68,9 @@
split_size_bytes * timestamps_per_ms / bytes_per_ms);
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 += split_size_bytes,
- timestamp_offset += timestamps_per_chunk) {
+ timestamp_offset += timestamps_per_chunk) {
split_size_bytes =
std::min(split_size_bytes, payload.size() - byte_offset);
rtc::Buffer new_payload(payload.data() + byte_offset, split_size_bytes);
diff --git a/modules/audio_coding/codecs/legacy_encoded_audio_frame_unittest.cc b/modules/audio_coding/codecs/legacy_encoded_audio_frame_unittest.cc
index e2dd445..9079bcd 100644
--- a/modules/audio_coding/codecs/legacy_encoded_audio_frame_unittest.cc
+++ b/modules/audio_coding/codecs/legacy_encoded_audio_frame_unittest.cc
@@ -97,20 +97,15 @@
// 40 ms -> 20 + 20 ms
// 50 ms -> 25 + 25 ms
// 60 ms -> 30 + 30 ms
- ExpectedSplit expected_splits[] = {
- {10, 1, {10}},
- {20, 1, {20}},
- {30, 1, {30}},
- {40, 2, {20, 20}},
- {50, 2, {25, 25}},
- {60, 2, {30, 30}}
- };
+ ExpectedSplit expected_splits[] = {{10, 1, {10}}, {20, 1, {20}},
+ {30, 1, {30}}, {40, 2, {20, 20}},
+ {50, 2, {25, 25}}, {60, 2, {30, 30}}};
for (const auto& expected_split : expected_splits) {
// The payload values are set to steadily increase (modulo 256), so that the
// resulting frames can be checked and we can be reasonably certain no
// sample was missed or repeated.
- const auto generate_payload = [] (size_t num_bytes) {
+ const auto generate_payload = [](size_t num_bytes) {
rtc::Buffer payload(num_bytes);
uint8_t value = 0;
// Allow wrap-around of value in counter below.
diff --git a/modules/audio_coding/codecs/opus/audio_encoder_opus.cc b/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
index fc6d544..05d3b72 100644
--- a/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
+++ b/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
@@ -613,20 +613,17 @@
const size_t max_encoded_bytes = SufficientOutputBufferSize();
EncodedInfo info;
- info.encoded_bytes =
- encoded->AppendData(
- max_encoded_bytes, [&] (rtc::ArrayView<uint8_t> encoded) {
- int status = WebRtcOpus_Encode(
- inst_, &input_buffer_[0],
- rtc::CheckedDivExact(input_buffer_.size(),
- config_.num_channels),
- rtc::saturated_cast<int16_t>(max_encoded_bytes),
- encoded.data());
+ info.encoded_bytes = encoded->AppendData(
+ max_encoded_bytes, [&](rtc::ArrayView<uint8_t> encoded) {
+ int status = WebRtcOpus_Encode(
+ inst_, &input_buffer_[0],
+ rtc::CheckedDivExact(input_buffer_.size(), config_.num_channels),
+ rtc::saturated_cast<int16_t>(max_encoded_bytes), encoded.data());
- RTC_CHECK_GE(status, 0); // Fails only if fed invalid data.
+ RTC_CHECK_GE(status, 0); // Fails only if fed invalid data.
- return static_cast<size_t>(status);
- });
+ return static_cast<size_t>(status);
+ });
input_buffer_.clear();
bool dtx_frame = (info.encoded_bytes <= 2);
diff --git a/modules/audio_coding/codecs/opus/audio_encoder_opus_unittest.cc b/modules/audio_coding/codecs/opus/audio_encoder_opus_unittest.cc
index c4d37da..dde2090 100644
--- a/modules/audio_coding/codecs/opus/audio_encoder_opus_unittest.cc
+++ b/modules/audio_coding/codecs/opus/audio_encoder_opus_unittest.cc
@@ -753,8 +753,8 @@
EXPECT_EQ(8000, config.max_playback_rate_hz);
EXPECT_EQ(12000, config.bitrate_bps);
- config = CreateConfigWithParameters({{"maxplaybackrate", "8000"},
- {"stereo", "1"}});
+ config = CreateConfigWithParameters(
+ {{"maxplaybackrate", "8000"}, {"stereo", "1"}});
EXPECT_EQ(8000, config.max_playback_rate_hz);
EXPECT_EQ(24000, config.bitrate_bps);
}
@@ -765,8 +765,8 @@
EXPECT_EQ(8001, config.max_playback_rate_hz);
EXPECT_EQ(20000, config.bitrate_bps);
- config = CreateConfigWithParameters({{"maxplaybackrate", "8001"},
- {"stereo", "1"}});
+ config = CreateConfigWithParameters(
+ {{"maxplaybackrate", "8001"}, {"stereo", "1"}});
EXPECT_EQ(8001, config.max_playback_rate_hz);
EXPECT_EQ(40000, config.bitrate_bps);
}
@@ -777,8 +777,8 @@
EXPECT_EQ(12001, config.max_playback_rate_hz);
EXPECT_EQ(20000, config.bitrate_bps);
- config = CreateConfigWithParameters({{"maxplaybackrate", "12001"},
- {"stereo", "1"}});
+ config = CreateConfigWithParameters(
+ {{"maxplaybackrate", "12001"}, {"stereo", "1"}});
EXPECT_EQ(12001, config.max_playback_rate_hz);
EXPECT_EQ(40000, config.bitrate_bps);
}
@@ -789,8 +789,8 @@
EXPECT_EQ(16001, config.max_playback_rate_hz);
EXPECT_EQ(32000, config.bitrate_bps);
- config = CreateConfigWithParameters({{"maxplaybackrate", "16001"},
- {"stereo", "1"}});
+ config = CreateConfigWithParameters(
+ {{"maxplaybackrate", "16001"}, {"stereo", "1"}});
EXPECT_EQ(16001, config.max_playback_rate_hz);
EXPECT_EQ(64000, config.bitrate_bps);
}
@@ -801,8 +801,8 @@
EXPECT_EQ(24001, config.max_playback_rate_hz);
EXPECT_EQ(32000, config.bitrate_bps);
- config = CreateConfigWithParameters({{"maxplaybackrate", "24001"},
- {"stereo", "1"}});
+ config = CreateConfigWithParameters(
+ {{"maxplaybackrate", "24001"}, {"stereo", "1"}});
EXPECT_EQ(24001, config.max_playback_rate_hz);
EXPECT_EQ(64000, config.bitrate_bps);
}
diff --git a/modules/audio_coding/codecs/opus/opus_fec_test.cc b/modules/audio_coding/codecs/opus/opus_fec_test.cc
index 4e0a17e..f1983ae 100644
--- a/modules/audio_coding/codecs/opus/opus_fec_test.cc
+++ b/modules/audio_coding/codecs/opus/opus_fec_test.cc
@@ -83,8 +83,8 @@
rewind(fp);
// Allocate memory to contain the whole file.
- in_data_.reset(new int16_t[loop_length_samples_ +
- block_length_sample_ * channels_]);
+ in_data_.reset(
+ new int16_t[loop_length_samples_ + block_length_sample_ * channels_]);
// Copy the file into the buffer.
ASSERT_EQ(fread(&in_data_[0], sizeof(int16_t), loop_length_samples_, fp),
@@ -130,14 +130,12 @@
max_bytes_(0),
encoded_bytes_(0),
opus_encoder_(NULL),
- opus_decoder_(NULL) {
-}
+ opus_decoder_(NULL) {}
void OpusFecTest::EncodeABlock() {
- int value = WebRtcOpus_Encode(opus_encoder_,
- &in_data_[data_pointer_],
- block_length_sample_,
- max_bytes_, &bit_stream_[0]);
+ int value =
+ WebRtcOpus_Encode(opus_encoder_, &in_data_[data_pointer_],
+ block_length_sample_, max_bytes_, &bit_stream_[0]);
EXPECT_GT(value, 0);
encoded_bytes_ = static_cast<size_t>(value);
@@ -151,9 +149,9 @@
// Decode previous frame.
if (!lost_current &&
WebRtcOpus_PacketHasFec(&bit_stream_[0], encoded_bytes_) == 1) {
- value_1 = WebRtcOpus_DecodeFec(opus_decoder_, &bit_stream_[0],
- encoded_bytes_, &out_data_[0],
- &audio_type);
+ value_1 =
+ WebRtcOpus_DecodeFec(opus_decoder_, &bit_stream_[0], encoded_bytes_,
+ &out_data_[0], &audio_type);
} else {
value_1 = WebRtcOpus_DecodePlc(opus_decoder_, &out_data_[0], 1);
}
@@ -173,16 +171,14 @@
int time_now_ms, fec_frames;
int actual_packet_loss_rate;
bool lost_current, lost_previous;
- mode mode_set[3] = {{true, 0},
- {false, 0},
- {true, 50}};
+ mode mode_set[3] = {{true, 0}, {false, 0}, {true, 50}};
lost_current = false;
for (int i = 0; i < 3; i++) {
if (mode_set[i].fec) {
EXPECT_EQ(0, WebRtcOpus_EnableFec(opus_encoder_));
- EXPECT_EQ(0, WebRtcOpus_SetPacketLossRate(opus_encoder_,
- mode_set[i].target_packet_loss_rate));
+ EXPECT_EQ(0, WebRtcOpus_SetPacketLossRate(
+ opus_encoder_, mode_set[i].target_packet_loss_rate));
printf("FEC is ON, target at packet loss rate %d percent.\n",
mode_set[i].target_packet_loss_rate);
} else {
@@ -218,7 +214,7 @@
// |data_pointer_| is incremented and wrapped across
// |loop_length_samples_|.
data_pointer_ = (data_pointer_ + block_length_sample_ * channels_) %
- loop_length_samples_;
+ loop_length_samples_;
}
if (mode_set[i].fec) {
printf("%.2f percent frames has FEC.\n",
@@ -242,7 +238,6 @@
string("pcm"))};
// 64 kbps, stereo
-INSTANTIATE_TEST_CASE_P(AllTest, OpusFecTest,
- ::testing::ValuesIn(param_set));
+INSTANTIATE_TEST_CASE_P(AllTest, OpusFecTest, ::testing::ValuesIn(param_set));
} // namespace webrtc
diff --git a/modules/audio_coding/codecs/opus/opus_inst.h b/modules/audio_coding/codecs/opus/opus_inst.h
index 066fa22..2473a5c 100644
--- a/modules/audio_coding/codecs/opus/opus_inst.h
+++ b/modules/audio_coding/codecs/opus/opus_inst.h
@@ -32,5 +32,4 @@
int in_dtx_mode;
};
-
#endif // MODULES_AUDIO_CODING_CODECS_OPUS_OPUS_INST_H_
diff --git a/modules/audio_coding/codecs/opus/opus_interface.h b/modules/audio_coding/codecs/opus/opus_interface.h
index 4b8e892..0b1c64d 100644
--- a/modules/audio_coding/codecs/opus/opus_interface.h
+++ b/modules/audio_coding/codecs/opus/opus_interface.h
@@ -318,8 +318,10 @@
* Return value : >0 - Samples per channel in decoded vector
* -1 - Error
*/
-int WebRtcOpus_Decode(OpusDecInst* inst, const uint8_t* encoded,
- size_t encoded_bytes, int16_t* decoded,
+int WebRtcOpus_Decode(OpusDecInst* inst,
+ const uint8_t* encoded,
+ size_t encoded_bytes,
+ int16_t* decoded,
int16_t* audio_type);
/****************************************************************************
@@ -336,7 +338,8 @@
* Return value : >0 - number of samples in decoded PLC vector
* -1 - Error
*/
-int WebRtcOpus_DecodePlc(OpusDecInst* inst, int16_t* decoded,
+int WebRtcOpus_DecodePlc(OpusDecInst* inst,
+ int16_t* decoded,
int number_of_lost_frames);
/****************************************************************************
@@ -357,8 +360,10 @@
* 0 - No FEC data in the packet
* -1 - Error
*/
-int WebRtcOpus_DecodeFec(OpusDecInst* inst, const uint8_t* encoded,
- size_t encoded_bytes, int16_t* decoded,
+int WebRtcOpus_DecodeFec(OpusDecInst* inst,
+ const uint8_t* encoded,
+ size_t encoded_bytes,
+ int16_t* decoded,
int16_t* audio_type);
/****************************************************************************
diff --git a/modules/audio_coding/codecs/opus/opus_speed_test.cc b/modules/audio_coding/codecs/opus/opus_speed_test.cc
index ca46aa1..03b59ed 100644
--- a/modules/audio_coding/codecs/opus/opus_speed_test.cc
+++ b/modules/audio_coding/codecs/opus/opus_speed_test.cc
@@ -23,9 +23,12 @@
OpusSpeedTest();
void SetUp() override;
void TearDown() override;
- float EncodeABlock(int16_t* in_data, uint8_t* bit_stream,
- size_t max_bytes, size_t* encoded_bytes) override;
- float DecodeABlock(const uint8_t* bit_stream, size_t encoded_bytes,
+ float EncodeABlock(int16_t* in_data,
+ uint8_t* bit_stream,
+ size_t max_bytes,
+ size_t* encoded_bytes) override;
+ float DecodeABlock(const uint8_t* bit_stream,
+ size_t encoded_bytes,
int16_t* out_data) override;
WebRtcOpusEncInst* opus_encoder_;
WebRtcOpusDecInst* opus_decoder_;
@@ -36,8 +39,7 @@
kOpusSamplingKhz,
kOpusSamplingKhz),
opus_encoder_(NULL),
- opus_decoder_(NULL) {
-}
+ opus_decoder_(NULL) {}
void OpusSpeedTest::SetUp() {
AudioCodecSpeedTest::SetUp();
@@ -57,12 +59,13 @@
EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_decoder_));
}
-float OpusSpeedTest::EncodeABlock(int16_t* in_data, uint8_t* bit_stream,
- size_t max_bytes, size_t* encoded_bytes) {
+float OpusSpeedTest::EncodeABlock(int16_t* in_data,
+ uint8_t* bit_stream,
+ size_t max_bytes,
+ size_t* encoded_bytes) {
clock_t clocks = clock();
- int value = WebRtcOpus_Encode(opus_encoder_, in_data,
- input_length_sample_, max_bytes,
- bit_stream);
+ int value = WebRtcOpus_Encode(opus_encoder_, in_data, input_length_sample_,
+ max_bytes, bit_stream);
clocks = clock() - clocks;
EXPECT_GT(value, 0);
*encoded_bytes = static_cast<size_t>(value);
@@ -70,7 +73,8 @@
}
float OpusSpeedTest::DecodeABlock(const uint8_t* bit_stream,
- size_t encoded_bytes, int16_t* out_data) {
+ size_t encoded_bytes,
+ int16_t* out_data) {
int value;
int16_t audio_type;
clock_t clocks = clock();
@@ -84,13 +88,13 @@
/* Test audio length in second. */
constexpr size_t kDurationSec = 400;
-#define ADD_TEST(complexity) \
-TEST_P(OpusSpeedTest, OpusSetComplexityTest##complexity) { \
- /* Set complexity. */ \
- printf("Setting complexity to %d ...\n", complexity); \
- EXPECT_EQ(0, WebRtcOpus_SetComplexity(opus_encoder_, complexity)); \
- EncodeDecode(kDurationSec); \
-}
+#define ADD_TEST(complexity) \
+ TEST_P(OpusSpeedTest, OpusSetComplexityTest##complexity) { \
+ /* Set complexity. */ \
+ printf("Setting complexity to %d ...\n", complexity); \
+ EXPECT_EQ(0, WebRtcOpus_SetComplexity(opus_encoder_, complexity)); \
+ EncodeDecode(kDurationSec); \
+ }
ADD_TEST(10);
ADD_TEST(9);
@@ -136,7 +140,6 @@
string("pcm"),
true)};
-INSTANTIATE_TEST_CASE_P(AllTest, OpusSpeedTest,
- ::testing::ValuesIn(param_set));
+INSTANTIATE_TEST_CASE_P(AllTest, OpusSpeedTest, ::testing::ValuesIn(param_set));
} // namespace webrtc
diff --git a/modules/audio_coding/codecs/opus/opus_unittest.cc b/modules/audio_coding/codecs/opus/opus_unittest.cc
index 12a1585..034f8cd 100644
--- a/modules/audio_coding/codecs/opus/opus_unittest.cc
+++ b/modules/audio_coding/codecs/opus/opus_unittest.cc
@@ -58,9 +58,12 @@
int16_t* audio_type);
void SetMaxPlaybackRate(WebRtcOpusEncInst* encoder,
- opus_int32 expect, int32_t set);
+ opus_int32 expect,
+ int32_t set);
- void CheckAudioBounded(const int16_t* audio, size_t samples, size_t channels,
+ void CheckAudioBounded(const int16_t* audio,
+ size_t samples,
+ size_t channels,
uint16_t bound) const;
WebRtcOpusEncInst* opus_encoder_;
@@ -78,15 +81,15 @@
opus_decoder_(NULL),
encoded_bytes_(0),
channels_(static_cast<size_t>(::testing::get<0>(GetParam()))),
- application_(::testing::get<1>(GetParam())) {
-}
+ application_(::testing::get<1>(GetParam())) {}
-void OpusTest::PrepareSpeechData(size_t channel, int block_length_ms,
+void OpusTest::PrepareSpeechData(size_t channel,
+ int block_length_ms,
int loop_length_ms) {
- const std::string file_name =
- webrtc::test::ResourcePath((channel == 1) ?
- "audio_coding/testfile32kHz" :
- "audio_coding/teststereo32kHz", "pcm");
+ const std::string file_name = webrtc::test::ResourcePath(
+ (channel == 1) ? "audio_coding/testfile32kHz"
+ : "audio_coding/teststereo32kHz",
+ "pcm");
if (loop_length_ms < block_length_ms) {
loop_length_ms = block_length_ms;
}
@@ -100,13 +103,14 @@
int32_t set) {
opus_int32 bandwidth;
EXPECT_EQ(0, WebRtcOpus_SetMaxPlaybackRate(opus_encoder_, set));
- opus_encoder_ctl(opus_encoder_->encoder,
- OPUS_GET_MAX_BANDWIDTH(&bandwidth));
+ opus_encoder_ctl(opus_encoder_->encoder, OPUS_GET_MAX_BANDWIDTH(&bandwidth));
EXPECT_EQ(expect, bandwidth);
}
-void OpusTest::CheckAudioBounded(const int16_t* audio, size_t samples,
- size_t channels, uint16_t bound) const {
+void OpusTest::CheckAudioBounded(const int16_t* audio,
+ size_t samples,
+ size_t channels,
+ uint16_t bound) const {
for (size_t i = 0; i < samples; ++i) {
for (size_t c = 0; c < channels; ++c) {
ASSERT_GE(audio[i * channels + c], -bound);
@@ -120,16 +124,15 @@
WebRtcOpusDecInst* decoder,
int16_t* output_audio,
int16_t* audio_type) {
- int encoded_bytes_int = WebRtcOpus_Encode(
- encoder, input_audio.data(),
- rtc::CheckedDivExact(input_audio.size(), channels_),
- kMaxBytes, bitstream_);
+ int encoded_bytes_int =
+ WebRtcOpus_Encode(encoder, input_audio.data(),
+ rtc::CheckedDivExact(input_audio.size(), channels_),
+ kMaxBytes, bitstream_);
EXPECT_GE(encoded_bytes_int, 0);
encoded_bytes_ = static_cast<size_t>(encoded_bytes_int);
int est_len = WebRtcOpus_DurationEst(decoder, bitstream_, encoded_bytes_);
- int act_len = WebRtcOpus_Decode(decoder, bitstream_,
- encoded_bytes_, output_audio,
- audio_type);
+ int act_len = WebRtcOpus_Decode(decoder, bitstream_, encoded_bytes_,
+ output_audio, audio_type);
EXPECT_EQ(est_len, act_len);
return act_len;
}
@@ -141,30 +144,28 @@
const size_t samples = kOpusRateKhz * block_length_ms;
// Create encoder memory.
- EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_,
- channels_,
- application_));
+ EXPECT_EQ(0,
+ WebRtcOpus_EncoderCreate(&opus_encoder_, channels_, application_));
EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, channels_));
// Set bitrate.
- EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_encoder_,
- channels_ == 1 ? 32000 : 64000));
+ EXPECT_EQ(
+ 0, WebRtcOpus_SetBitRate(opus_encoder_, channels_ == 1 ? 32000 : 64000));
// Set input audio as silence.
std::vector<int16_t> silence(samples * channels_, 0);
// Setting DTX.
- EXPECT_EQ(0, dtx ? WebRtcOpus_EnableDtx(opus_encoder_) :
- WebRtcOpus_DisableDtx(opus_encoder_));
+ EXPECT_EQ(0, dtx ? WebRtcOpus_EnableDtx(opus_encoder_)
+ : WebRtcOpus_DisableDtx(opus_encoder_));
int16_t audio_type;
int16_t* output_data_decode = new int16_t[samples * channels_];
for (int i = 0; i < 100; ++i) {
- EXPECT_EQ(samples,
- static_cast<size_t>(EncodeDecode(
- opus_encoder_, speech_data_.GetNextBlock(), opus_decoder_,
- output_data_decode, &audio_type)));
+ EXPECT_EQ(samples, static_cast<size_t>(EncodeDecode(
+ opus_encoder_, speech_data_.GetNextBlock(),
+ opus_decoder_, output_data_decode, &audio_type)));
// If not DTX, it should never enter DTX mode. If DTX, we do not care since
// whether it enters DTX depends on the signal type.
if (!dtx) {
@@ -178,10 +179,9 @@
// We input some silent segments. In DTX mode, the encoder will stop sending.
// However, DTX may happen after a while.
for (int i = 0; i < 30; ++i) {
- EXPECT_EQ(samples,
- static_cast<size_t>(EncodeDecode(
- opus_encoder_, silence, opus_decoder_, output_data_decode,
- &audio_type)));
+ EXPECT_EQ(samples, static_cast<size_t>(
+ EncodeDecode(opus_encoder_, silence, opus_decoder_,
+ output_data_decode, &audio_type)));
if (!dtx) {
EXPECT_GT(encoded_bytes_, 1U);
EXPECT_EQ(0, opus_encoder_->in_dtx_mode);
@@ -227,10 +227,9 @@
int i = 0;
for (; i < max_dtx_frames; ++i) {
time += block_length_ms;
- EXPECT_EQ(samples,
- static_cast<size_t>(EncodeDecode(
- opus_encoder_, silence, opus_decoder_, output_data_decode,
- &audio_type)));
+ EXPECT_EQ(samples, static_cast<size_t>(
+ EncodeDecode(opus_encoder_, silence, opus_decoder_,
+ output_data_decode, &audio_type)));
if (dtx) {
if (encoded_bytes_ > 1)
break;
@@ -263,10 +262,9 @@
// Enters DTX again immediately.
time += block_length_ms;
- EXPECT_EQ(samples,
- static_cast<size_t>(EncodeDecode(
- opus_encoder_, silence, opus_decoder_, output_data_decode,
- &audio_type)));
+ EXPECT_EQ(samples, static_cast<size_t>(
+ EncodeDecode(opus_encoder_, silence, opus_decoder_,
+ output_data_decode, &audio_type)));
if (dtx) {
EXPECT_EQ(1U, encoded_bytes_); // Send 1 byte.
EXPECT_EQ(1, opus_encoder_->in_dtx_mode);
@@ -287,10 +285,9 @@
silence[0] = 10000;
if (dtx) {
// Verify that encoder/decoder can jump out from DTX mode.
- EXPECT_EQ(samples,
- static_cast<size_t>(EncodeDecode(
- opus_encoder_, silence, opus_decoder_, output_data_decode,
- &audio_type)));
+ EXPECT_EQ(samples, static_cast<size_t>(
+ EncodeDecode(opus_encoder_, silence, opus_decoder_,
+ output_data_decode, &audio_type)));
EXPECT_GT(encoded_bytes_, 1U);
EXPECT_EQ(0, opus_encoder_->in_dtx_mode);
EXPECT_EQ(0, opus_decoder_->in_dtx_mode);
@@ -375,9 +372,8 @@
// Test normal Create and Free.
TEST_P(OpusTest, OpusCreateFree) {
- EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_,
- channels_,
- application_));
+ EXPECT_EQ(0,
+ WebRtcOpus_EncoderCreate(&opus_encoder_, channels_, application_));
EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, channels_));
EXPECT_TRUE(opus_encoder_ != NULL);
EXPECT_TRUE(opus_decoder_ != NULL);
@@ -390,23 +386,20 @@
PrepareSpeechData(channels_, 20, 20);
// Create encoder memory.
- EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_,
- channels_,
- application_));
- EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_,
- channels_));
+ EXPECT_EQ(0,
+ WebRtcOpus_EncoderCreate(&opus_encoder_, channels_, application_));
+ EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, channels_));
// Set bitrate.
- EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_encoder_,
- channels_ == 1 ? 32000 : 64000));
+ EXPECT_EQ(
+ 0, WebRtcOpus_SetBitRate(opus_encoder_, channels_ == 1 ? 32000 : 64000));
// Check number of channels for decoder.
EXPECT_EQ(channels_, WebRtcOpus_DecoderChannels(opus_decoder_));
// Check application mode.
opus_int32 app;
- opus_encoder_ctl(opus_encoder_->encoder,
- OPUS_GET_APPLICATION(&app));
+ opus_encoder_ctl(opus_encoder_->encoder, OPUS_GET_APPLICATION(&app));
EXPECT_EQ(application_ == 0 ? OPUS_APPLICATION_VOIP : OPUS_APPLICATION_AUDIO,
app);
@@ -429,9 +422,8 @@
EXPECT_EQ(-1, WebRtcOpus_SetBitRate(opus_encoder_, 60000));
// Create encoder memory, try with different bitrates.
- EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_,
- channels_,
- application_));
+ EXPECT_EQ(0,
+ WebRtcOpus_EncoderCreate(&opus_encoder_, channels_, application_));
EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_encoder_, 30000));
EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_encoder_, 60000));
EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_encoder_, 300000));
@@ -446,9 +438,8 @@
EXPECT_EQ(-1, WebRtcOpus_SetComplexity(opus_encoder_, 9));
// Create encoder memory, try with different complexities.
- EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_,
- channels_,
- application_));
+ EXPECT_EQ(0,
+ WebRtcOpus_EncoderCreate(&opus_encoder_, channels_, application_));
EXPECT_EQ(0, WebRtcOpus_SetComplexity(opus_encoder_, 0));
EXPECT_EQ(0, WebRtcOpus_SetComplexity(opus_encoder_, 10));
@@ -524,9 +515,8 @@
PrepareSpeechData(channels_, 20, 20);
// Create encoder memory.
- EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_,
- channels_,
- application_));
+ EXPECT_EQ(0,
+ WebRtcOpus_EncoderCreate(&opus_encoder_, channels_, application_));
EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, channels_));
// Encode & decode.
@@ -540,9 +530,9 @@
WebRtcOpus_DecoderInit(opus_decoder_);
EXPECT_EQ(kOpus20msFrameSamples,
- static_cast<size_t>(WebRtcOpus_Decode(
- opus_decoder_, bitstream_, encoded_bytes_, output_data_decode,
- &audio_type)));
+ static_cast<size_t>(
+ WebRtcOpus_Decode(opus_decoder_, bitstream_, encoded_bytes_,
+ output_data_decode, &audio_type)));
// Free memory.
delete[] output_data_decode;
@@ -556,9 +546,8 @@
EXPECT_EQ(-1, WebRtcOpus_DisableFec(opus_encoder_));
// Create encoder memory.
- EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_,
- channels_,
- application_));
+ EXPECT_EQ(0,
+ WebRtcOpus_EncoderCreate(&opus_encoder_, channels_, application_));
EXPECT_EQ(0, WebRtcOpus_EnableFec(opus_encoder_));
EXPECT_EQ(0, WebRtcOpus_DisableFec(opus_encoder_));
@@ -573,30 +562,25 @@
EXPECT_EQ(-1, WebRtcOpus_DisableDtx(opus_encoder_));
// Create encoder memory.
- EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_,
- channels_,
- application_));
+ EXPECT_EQ(0,
+ WebRtcOpus_EncoderCreate(&opus_encoder_, channels_, application_));
opus_int32 dtx;
// DTX is off by default.
- opus_encoder_ctl(opus_encoder_->encoder,
- OPUS_GET_DTX(&dtx));
+ opus_encoder_ctl(opus_encoder_->encoder, OPUS_GET_DTX(&dtx));
EXPECT_EQ(0, dtx);
// Test to enable DTX.
EXPECT_EQ(0, WebRtcOpus_EnableDtx(opus_encoder_));
- opus_encoder_ctl(opus_encoder_->encoder,
- OPUS_GET_DTX(&dtx));
+ opus_encoder_ctl(opus_encoder_->encoder, OPUS_GET_DTX(&dtx));
EXPECT_EQ(1, dtx);
// Test to disable DTX.
EXPECT_EQ(0, WebRtcOpus_DisableDtx(opus_encoder_));
- opus_encoder_ctl(opus_encoder_->encoder,
- OPUS_GET_DTX(&dtx));
+ opus_encoder_ctl(opus_encoder_->encoder, OPUS_GET_DTX(&dtx));
EXPECT_EQ(0, dtx);
-
// Free memory.
EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_));
}
@@ -630,9 +614,8 @@
EXPECT_EQ(-1, WebRtcOpus_SetPacketLossRate(opus_encoder_, 50));
// Create encoder memory.
- EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_,
- channels_,
- application_));
+ EXPECT_EQ(0,
+ WebRtcOpus_EncoderCreate(&opus_encoder_, channels_, application_));
EXPECT_EQ(0, WebRtcOpus_SetPacketLossRate(opus_encoder_, 50));
EXPECT_EQ(-1, WebRtcOpus_SetPacketLossRate(opus_encoder_, -1));
@@ -647,9 +630,8 @@
EXPECT_EQ(-1, WebRtcOpus_SetMaxPlaybackRate(opus_encoder_, 20000));
// Create encoder memory.
- EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_,
- channels_,
- application_));
+ EXPECT_EQ(0,
+ WebRtcOpus_EncoderCreate(&opus_encoder_, channels_, application_));
SetMaxPlaybackRate(opus_encoder_, OPUS_BANDWIDTH_FULLBAND, 48000);
SetMaxPlaybackRate(opus_encoder_, OPUS_BANDWIDTH_FULLBAND, 24001);
@@ -671,14 +653,13 @@
PrepareSpeechData(channels_, 20, 20);
// Create encoder memory.
- EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_,
- channels_,
- application_));
+ EXPECT_EQ(0,
+ WebRtcOpus_EncoderCreate(&opus_encoder_, channels_, application_));
EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, channels_));
// Set bitrate.
- EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_encoder_,
- channels_== 1 ? 32000 : 64000));
+ EXPECT_EQ(
+ 0, WebRtcOpus_SetBitRate(opus_encoder_, channels_ == 1 ? 32000 : 64000));
// Check number of channels for decoder.
EXPECT_EQ(channels_, WebRtcOpus_DecoderChannels(opus_decoder_));
@@ -693,9 +674,8 @@
// Call decoder PLC.
int16_t* plc_buffer = new int16_t[kOpus20msFrameSamples * channels_];
- EXPECT_EQ(kOpus20msFrameSamples,
- static_cast<size_t>(WebRtcOpus_DecodePlc(
- opus_decoder_, plc_buffer, 1)));
+ EXPECT_EQ(kOpus20msFrameSamples, static_cast<size_t>(WebRtcOpus_DecodePlc(
+ opus_decoder_, plc_buffer, 1)));
// Free memory.
delete[] plc_buffer;
@@ -709,34 +689,33 @@
PrepareSpeechData(channels_, 20, 20);
// Create.
- EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_,
- channels_,
- application_));
+ EXPECT_EQ(0,
+ WebRtcOpus_EncoderCreate(&opus_encoder_, channels_, application_));
EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, channels_));
// 10 ms. We use only first 10 ms of a 20 ms block.
auto speech_block = speech_data_.GetNextBlock();
int encoded_bytes_int = WebRtcOpus_Encode(
opus_encoder_, speech_block.data(),
- rtc::CheckedDivExact(speech_block.size(), 2 * channels_),
- kMaxBytes, bitstream_);
+ rtc::CheckedDivExact(speech_block.size(), 2 * channels_), kMaxBytes,
+ bitstream_);
EXPECT_GE(encoded_bytes_int, 0);
- EXPECT_EQ(kOpus10msFrameSamples,
- static_cast<size_t>(WebRtcOpus_DurationEst(
- opus_decoder_, bitstream_,
- static_cast<size_t>(encoded_bytes_int))));
+ EXPECT_EQ(
+ kOpus10msFrameSamples,
+ static_cast<size_t>(WebRtcOpus_DurationEst(
+ opus_decoder_, bitstream_, static_cast<size_t>(encoded_bytes_int))));
// 20 ms
speech_block = speech_data_.GetNextBlock();
- encoded_bytes_int = WebRtcOpus_Encode(
- opus_encoder_, speech_block.data(),
- rtc::CheckedDivExact(speech_block.size(), channels_),
- kMaxBytes, bitstream_);
+ encoded_bytes_int =
+ WebRtcOpus_Encode(opus_encoder_, speech_block.data(),
+ rtc::CheckedDivExact(speech_block.size(), channels_),
+ kMaxBytes, bitstream_);
EXPECT_GE(encoded_bytes_int, 0);
- EXPECT_EQ(kOpus20msFrameSamples,
- static_cast<size_t>(WebRtcOpus_DurationEst(
- opus_decoder_, bitstream_,
- static_cast<size_t>(encoded_bytes_int))));
+ EXPECT_EQ(
+ kOpus20msFrameSamples,
+ static_cast<size_t>(WebRtcOpus_DurationEst(
+ opus_decoder_, bitstream_, static_cast<size_t>(encoded_bytes_int))));
// Free memory.
EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_encoder_));
@@ -749,15 +728,13 @@
PrepareSpeechData(channels_, 20, 20 * kPackets);
// Create encoder memory.
- ASSERT_EQ(0, WebRtcOpus_EncoderCreate(&opus_encoder_,
- channels_,
- application_));
- ASSERT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_,
- channels_));
+ ASSERT_EQ(0,
+ WebRtcOpus_EncoderCreate(&opus_encoder_, channels_, application_));
+ ASSERT_EQ(0, WebRtcOpus_DecoderCreate(&opus_decoder_, channels_));
// Set bitrate.
- EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_encoder_,
- channels_ == 1 ? 32000 : 64000));
+ EXPECT_EQ(
+ 0, WebRtcOpus_SetBitRate(opus_encoder_, channels_ == 1 ? 32000 : 64000));
// Check number of channels for decoder.
EXPECT_EQ(channels_, WebRtcOpus_DecoderChannels(opus_decoder_));
@@ -776,9 +753,9 @@
WebRtcOpus_Encode(opus_encoder_, speech_block.data(),
rtc::CheckedDivExact(speech_block.size(), channels_),
kMaxBytes, bitstream_);
- if (opus_repacketizer_cat(
- rp, bitstream_,
- rtc::checked_cast<opus_int32>(encoded_bytes_)) == OPUS_OK) {
+ if (opus_repacketizer_cat(rp, bitstream_,
+ rtc::checked_cast<opus_int32>(encoded_bytes_)) ==
+ OPUS_OK) {
++num_packets;
if (num_packets == kPackets) {
break;
@@ -798,9 +775,9 @@
opus_decoder_, bitstream_, encoded_bytes_)));
EXPECT_EQ(kOpus20msFrameSamples * kPackets,
- static_cast<size_t>(WebRtcOpus_Decode(
- opus_decoder_, bitstream_, encoded_bytes_,
- output_data_decode.get(), &audio_type)));
+ static_cast<size_t>(
+ WebRtcOpus_Decode(opus_decoder_, bitstream_, encoded_bytes_,
+ output_data_decode.get(), &audio_type)));
// Free memory.
opus_repacketizer_destroy(rp);
@@ -812,5 +789,4 @@
OpusTest,
Combine(Values(1, 2), Values(0, 1)));
-
} // namespace webrtc
diff --git a/modules/audio_coding/codecs/pcm16b/pcm16b.h b/modules/audio_coding/codecs/pcm16b/pcm16b.h
index 041701a..9a3bfe9 100644
--- a/modules/audio_coding/codecs/pcm16b/pcm16b.h
+++ b/modules/audio_coding/codecs/pcm16b/pcm16b.h
@@ -38,9 +38,7 @@
* Always equal to twice the len input parameter.
*/
-size_t WebRtcPcm16b_Encode(const int16_t* speech,
- size_t len,
- uint8_t* encoded);
+size_t WebRtcPcm16b_Encode(const int16_t* speech, size_t len, uint8_t* encoded);
/****************************************************************************
* WebRtcPcm16b_Decode(...)
@@ -57,9 +55,7 @@
* Returned value : Samples in speech
*/
-size_t WebRtcPcm16b_Decode(const uint8_t* encoded,
- size_t len,
- int16_t* speech);
+size_t WebRtcPcm16b_Decode(const uint8_t* encoded, size_t len, int16_t* speech);
#ifdef __cplusplus
}
diff --git a/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc b/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc
index cd62069..2601f26 100644
--- a/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc
+++ b/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc
@@ -58,10 +58,8 @@
uint32_t rtp_timestamp,
rtc::ArrayView<const int16_t> audio,
rtc::Buffer* encoded) {
-
const size_t primary_offset = encoded->size();
- EncodedInfo info =
- speech_encoder_->Encode(rtp_timestamp, audio, encoded);
+ EncodedInfo info = speech_encoder_->Encode(rtp_timestamp, audio, encoded);
RTC_CHECK(info.redundant.empty()) << "Cannot use nested redundant encoders.";
RTC_DCHECK_EQ(encoded->size() - primary_offset, info.encoded_bytes);
diff --git a/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc b/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc
index 890ac22..0f5a811 100644
--- a/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc
+++ b/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc
@@ -48,9 +48,7 @@
.WillRepeatedly(Return(sample_rate_hz_));
}
- void TearDown() override {
- red_.reset();
- }
+ void TearDown() override { red_.reset(); }
void Encode() {
ASSERT_TRUE(red_.get() != NULL);
@@ -73,8 +71,7 @@
const int red_payload_type_;
};
-TEST_F(AudioEncoderCopyRedTest, CreateAndDestroy) {
-}
+TEST_F(AudioEncoderCopyRedTest, CreateAndDestroy) {}
TEST_F(AudioEncoderCopyRedTest, CheckSampleRatePropagation) {
EXPECT_CALL(*mock_encoder_, SampleRateHz()).WillOnce(Return(17));
diff --git a/modules/audio_coding/codecs/tools/audio_codec_speed_test.cc b/modules/audio_coding/codecs/tools/audio_codec_speed_test.cc
index d3749c1..c539152 100644
--- a/modules/audio_coding/codecs/tools/audio_codec_speed_test.cc
+++ b/modules/audio_coding/codecs/tools/audio_codec_speed_test.cc
@@ -34,8 +34,7 @@
encoded_bytes_(0),
encoding_time_ms_(0.0),
decoding_time_ms_(0.0),
- out_file_(NULL) {
-}
+ out_file_(NULL) {}
void AudioCodecSpeedTest::SetUp() {
channels_ = get<0>(GetParam());
@@ -52,8 +51,8 @@
rewind(fp);
// Allocate memory to contain the whole file.
- in_data_.reset(new int16_t[loop_length_samples_ +
- input_length_sample_ * channels_]);
+ in_data_.reset(
+ new int16_t[loop_length_samples_ + input_length_sample_ * channels_]);
data_pointer_ = 0;
@@ -111,11 +110,11 @@
time_ms = DecodeABlock(&bit_stream_[0], encoded_bytes_, &out_data_[0]);
decoding_time_ms_ += time_ms;
if (save_out_data_) {
- fwrite(&out_data_[0], sizeof(int16_t),
- output_length_sample_ * channels_, out_file_);
+ fwrite(&out_data_[0], sizeof(int16_t), output_length_sample_ * channels_,
+ out_file_);
}
data_pointer_ = (data_pointer_ + input_length_sample_ * channels_) %
- loop_length_samples_;
+ loop_length_samples_;
time_now_ms += block_duration_ms_;
}
diff --git a/modules/audio_coding/codecs/tools/audio_codec_speed_test.h b/modules/audio_coding/codecs/tools/audio_codec_speed_test.h
index 9e616e7..0214a7d 100644
--- a/modules/audio_coding/codecs/tools/audio_codec_speed_test.h
+++ b/modules/audio_coding/codecs/tools/audio_codec_speed_test.h
@@ -36,15 +36,18 @@
// 2. save the bit stream to |bit_stream| of |max_bytes| bytes in size,
// 3. assign |encoded_bytes| with the length of the bit stream (in bytes),
// 4. return the cost of time (in millisecond) spent on actual encoding.
- virtual float EncodeABlock(int16_t* in_data, uint8_t* bit_stream,
- size_t max_bytes, size_t* encoded_bytes) = 0;
+ virtual float EncodeABlock(int16_t* in_data,
+ uint8_t* bit_stream,
+ size_t max_bytes,
+ size_t* encoded_bytes) = 0;
// DecodeABlock(...) does the following:
// 1. decodes the bit stream in |bit_stream| with a length of |encoded_bytes|
// (in bytes),
// 2. save the decoded audio in |out_data|,
// 3. return the cost of time (in millisecond) spent on actual decoding.
- virtual float DecodeABlock(const uint8_t* bit_stream, size_t encoded_bytes,
+ virtual float DecodeABlock(const uint8_t* bit_stream,
+ size_t encoded_bytes,
int16_t* out_data) = 0;
// Encoding and decode an audio of |audio_duration| (in seconds) and
diff --git a/modules/audio_coding/include/audio_coding_module.h b/modules/audio_coding/include/audio_coding_module.h
index dfbe459..a5ad4ff 100644
--- a/modules/audio_coding/include/audio_coding_module.h
+++ b/modules/audio_coding/include/audio_coding_module.h
@@ -127,8 +127,10 @@
// -1 if no codec matches the given parameters.
// 0 if succeeded.
//
- static int Codec(const char* payload_name, CodecInst* codec,
- int sampling_freq_hz, size_t channels);
+ static int Codec(const char* payload_name,
+ CodecInst* codec,
+ int sampling_freq_hz,
+ size_t channels);
///////////////////////////////////////////////////////////////////////////
// int32_t Codec()
@@ -146,7 +148,8 @@
// if the codec is found, the index of the codec in the list,
// -1 if the codec is not found.
//
- static int Codec(const char* payload_name, int sampling_freq_hz,
+ static int Codec(const char* payload_name,
+ int sampling_freq_hz,
size_t channels);
///////////////////////////////////////////////////////////////////////////
@@ -398,8 +401,8 @@
// 0 if succeeded.
//
virtual int32_t SetVAD(const bool enable_dtx = true,
- const bool enable_vad = false,
- const ACMVADMode vad_mode = VADNormal) = 0;
+ const bool enable_vad = false,
+ const ACMVADMode vad_mode = VADNormal) = 0;
///////////////////////////////////////////////////////////////////////////
// int32_t VAD()
@@ -416,8 +419,9 @@
// -1 if fails to retrieve the setting of DTX/VAD,
// 0 if succeeded.
//
- virtual int32_t VAD(bool* dtx_enabled, bool* vad_enabled,
- ACMVADMode* vad_mode) const = 0;
+ virtual int32_t VAD(bool* dtx_enabled,
+ bool* vad_enabled,
+ ACMVADMode* vad_mode) const = 0;
///////////////////////////////////////////////////////////////////////////
// int32_t RegisterVADCallback()
@@ -527,8 +531,7 @@
// -1 if fails to unregister.
// 0 if the given codec is successfully unregistered.
//
- virtual int UnregisterReceiveCodec(
- uint8_t payload_type) = 0;
+ virtual int UnregisterReceiveCodec(uint8_t payload_type) = 0;
///////////////////////////////////////////////////////////////////////////
// int32_t ReceiveCodec()
diff --git a/modules/audio_coding/include/audio_coding_module_typedefs.h b/modules/audio_coding/include/audio_coding_module_typedefs.h
index 85a6bf9..e8f80dc 100644
--- a/modules/audio_coding/include/audio_coding_module_typedefs.h
+++ b/modules/audio_coding/include/audio_coding_module_typedefs.h
@@ -41,8 +41,8 @@
// kAudio : optimized for non-voice signals like music.
//
enum OpusApplicationMode {
- kVoip = 0,
- kAudio = 1,
+ kVoip = 0,
+ kAudio = 1,
};
} // namespace webrtc
diff --git a/modules/audio_coding/neteq/accelerate.h b/modules/audio_coding/neteq/accelerate.h
index bf4f0f7..6d5b115 100644
--- a/modules/audio_coding/neteq/accelerate.h
+++ b/modules/audio_coding/neteq/accelerate.h
@@ -29,10 +29,10 @@
// Accelerate are implemented.
class Accelerate : public TimeStretch {
public:
- Accelerate(int sample_rate_hz, size_t num_channels,
+ Accelerate(int sample_rate_hz,
+ size_t num_channels,
const BackgroundNoise& background_noise)
- : TimeStretch(sample_rate_hz, num_channels, background_noise) {
- }
+ : TimeStretch(sample_rate_hz, num_channels, background_noise) {}
// This method performs the actual Accelerate operation. The samples are
// read from |input|, of length |input_length| elements, and are written to
diff --git a/modules/audio_coding/neteq/audio_decoder_unittest.cc b/modules/audio_coding/neteq/audio_decoder_unittest.cc
index e8f7a4a..54ede6f 100644
--- a/modules/audio_coding/neteq/audio_decoder_unittest.cc
+++ b/modules/audio_coding/neteq/audio_decoder_unittest.cc
@@ -114,7 +114,7 @@
decoder_ = NULL;
}
- virtual void InitEncoder() { }
+ virtual void InitEncoder() {}
// TODO(henrik.lundin) Change return type to size_t once most/all overriding
// implementations are gone.
@@ -136,12 +136,13 @@
samples_per_10ms, channels_,
interleaved_input.get());
- encoded_info = audio_encoder_->Encode(
- 0, rtc::ArrayView<const int16_t>(interleaved_input.get(),
- audio_encoder_->NumChannels() *
- audio_encoder_->SampleRateHz() /
- 100),
- output);
+ encoded_info =
+ audio_encoder_->Encode(0,
+ rtc::ArrayView<const int16_t>(
+ interleaved_input.get(),
+ audio_encoder_->NumChannels() *
+ audio_encoder_->SampleRateHz() / 100),
+ output);
}
EXPECT_EQ(payload_type_, encoded_info.payload_type);
return static_cast<int>(encoded_info.encoded_bytes);
@@ -152,11 +153,14 @@
// with |mse|. The encoded stream should contain |expected_bytes|. For stereo
// audio, the absolute difference between the two channels is compared vs
// |channel_diff_tolerance|.
- void EncodeDecodeTest(size_t expected_bytes, int tolerance, double mse,
- int delay = 0, int channel_diff_tolerance = 0) {
+ void EncodeDecodeTest(size_t expected_bytes,
+ int tolerance,
+ double mse,
+ int delay = 0,
+ int channel_diff_tolerance = 0) {
ASSERT_GE(tolerance, 0) << "Test must define a tolerance >= 0";
- ASSERT_GE(channel_diff_tolerance, 0) <<
- "Test must define a channel_diff_tolerance >= 0";
+ ASSERT_GE(channel_diff_tolerance, 0)
+ << "Test must define a channel_diff_tolerance >= 0";
size_t processed_samples = 0u;
rtc::Buffer encoded;
size_t encoded_bytes = 0u;
@@ -168,10 +172,10 @@
input.resize(input.size() + frame_size_, 0);
// Read from input file.
ASSERT_GE(input.size() - processed_samples, frame_size_);
- ASSERT_TRUE(input_audio_.Read(
- frame_size_, codec_input_rate_hz_, &input[processed_samples]));
- size_t enc_len = EncodeFrame(
- &input[processed_samples], frame_size_, &encoded);
+ ASSERT_TRUE(input_audio_.Read(frame_size_, codec_input_rate_hz_,
+ &input[processed_samples]));
+ size_t enc_len =
+ EncodeFrame(&input[processed_samples], frame_size_, &encoded);
// Make sure that frame_size_ * channels_ samples are allocated and free.
decoded.resize((processed_samples + frame_size_) * channels_, 0);
AudioDecoder::SpeechType speech_type;
@@ -189,11 +193,11 @@
if (expected_bytes) {
EXPECT_EQ(expected_bytes, encoded_bytes);
}
- CompareInputOutput(
- input, decoded, processed_samples, channels_, tolerance, delay);
+ CompareInputOutput(input, decoded, processed_samples, channels_, tolerance,
+ delay);
if (channels_ == 2)
- CompareTwoChannels(
- decoded, processed_samples, channels_, channel_diff_tolerance);
+ CompareTwoChannels(decoded, processed_samples, channels_,
+ channel_diff_tolerance);
EXPECT_LE(
MseInputOutput(input, decoded, processed_samples, channels_, delay),
mse);
@@ -242,10 +246,9 @@
AudioDecoder::SpeechType speech_type;
decoder_->Reset();
std::unique_ptr<int16_t[]> output(new int16_t[frame_size_ * channels_]);
- size_t dec_len = decoder_->Decode(encoded.data(), enc_len,
- codec_input_rate_hz_,
- frame_size_ * channels_ * sizeof(int16_t),
- output.get(), &speech_type);
+ size_t dec_len = decoder_->Decode(
+ encoded.data(), enc_len, codec_input_rate_hz_,
+ frame_size_ * channels_ * sizeof(int16_t), output.get(), &speech_type);
EXPECT_EQ(frame_size_ * channels_, dec_len);
// Call DecodePlc and verify that we get one frame of data.
// (Overwrite the output from the above Decode call, but that does not
@@ -332,10 +335,9 @@
AudioDecoder::SpeechType speech_type;
decoder_->Reset();
std::unique_ptr<int16_t[]> output(new int16_t[frame_size_ * channels_]);
- size_t dec_len = decoder_->Decode(encoded.data(), enc_len,
- codec_input_rate_hz_,
- frame_size_ * channels_ * sizeof(int16_t),
- output.get(), &speech_type);
+ size_t dec_len = decoder_->Decode(
+ encoded.data(), enc_len, codec_input_rate_hz_,
+ frame_size_ * channels_ * sizeof(int16_t), output.get(), &speech_type);
EXPECT_EQ(frame_size_, dec_len);
// Simply call DecodePlc and verify that we get 0 as return value.
EXPECT_EQ(0U, decoder_->DecodePlc(1, output.get()));
diff --git a/modules/audio_coding/neteq/audio_multi_vector.cc b/modules/audio_coding/neteq/audio_multi_vector.cc
index c3e623f..fee37cb 100644
--- a/modules/audio_coding/neteq/audio_multi_vector.cc
+++ b/modules/audio_coding/neteq/audio_multi_vector.cc
@@ -21,7 +21,8 @@
AudioMultiVector::AudioMultiVector(size_t N) {
assert(N > 0);
- if (N < 1) N = 1;
+ if (N < 1)
+ N = 1;
for (size_t n = 0; n < N; ++n) {
channels_.push_back(new AudioVector);
}
@@ -30,7 +31,8 @@
AudioMultiVector::AudioMultiVector(size_t N, size_t initial_size) {
assert(N > 0);
- if (N < 1) N = 1;
+ if (N < 1)
+ N = 1;
for (size_t n = 0; n < N; ++n) {
channels_.push_back(new AudioVector(initial_size));
}
@@ -86,7 +88,7 @@
}
channels_[channel]->PushBack(temp_array, length_per_channel);
}
- delete [] temp_array;
+ delete[] temp_array;
}
void AudioMultiVector::PushBack(const AudioMultiVector& append_this) {
diff --git a/modules/audio_coding/neteq/audio_multi_vector_unittest.cc b/modules/audio_coding/neteq/audio_multi_vector_unittest.cc
index f05aee0..7272dc2 100644
--- a/modules/audio_coding/neteq/audio_multi_vector_unittest.cc
+++ b/modules/audio_coding/neteq/audio_multi_vector_unittest.cc
@@ -37,9 +37,7 @@
array_interleaved_ = new int16_t[num_channels_ * array_length()];
}
- ~AudioMultiVectorTest() {
- delete [] array_interleaved_;
- }
+ ~AudioMultiVectorTest() { delete[] array_interleaved_; }
virtual void SetUp() {
// Populate test arrays.
@@ -58,9 +56,7 @@
}
}
- size_t array_length() const {
- return sizeof(array_) / sizeof(array_[0]);
- }
+ size_t array_length() const { return sizeof(array_) / sizeof(array_[0]); }
const size_t num_channels_;
size_t interleaved_length_;
@@ -168,8 +164,9 @@
ASSERT_EQ(2u, vec2.Size());
for (size_t channel = 0; channel < num_channels_; ++channel) {
for (size_t i = 0; i < 2; ++i) {
- EXPECT_EQ(array_interleaved_[channel + num_channels_ *
- (array_length() - 2 + i)], vec2[channel][i]);
+ EXPECT_EQ(array_interleaved_[channel +
+ num_channels_ * (array_length() - 2 + i)],
+ vec2[channel][i]);
}
}
}
@@ -206,7 +203,7 @@
EXPECT_EQ(0,
memcmp(array_interleaved_, output, read_samples * sizeof(int16_t)));
- delete [] output;
+ delete[] output;
}
// Test the PopFront method.
diff --git a/modules/audio_coding/neteq/audio_vector.cc b/modules/audio_coding/neteq/audio_vector.cc
index 93cd1fb..0486416 100644
--- a/modules/audio_coding/neteq/audio_vector.cc
+++ b/modules/audio_coding/neteq/audio_vector.cc
@@ -20,8 +20,7 @@
namespace webrtc {
-AudioVector::AudioVector()
- : AudioVector(kDefaultInitialSize) {
+AudioVector::AudioVector() : AudioVector(kDefaultInitialSize) {
Clear();
}
@@ -47,16 +46,15 @@
copy_to->end_index_ = Size();
}
-void AudioVector::CopyTo(
- size_t length, size_t position, int16_t* copy_to) const {
+void AudioVector::CopyTo(size_t length,
+ size_t position,
+ int16_t* copy_to) const {
if (length == 0)
return;
length = std::min(length, Size() - position);
const size_t copy_index = (begin_index_ + position) % capacity_;
- const size_t first_chunk_length =
- std::min(length, capacity_ - copy_index);
- memcpy(copy_to, &array_[copy_index],
- first_chunk_length * sizeof(int16_t));
+ const size_t first_chunk_length = std::min(length, capacity_ - copy_index);
+ memcpy(copy_to, &array_[copy_index], first_chunk_length * sizeof(int16_t));
const size_t remaining_length = length - first_chunk_length;
if (remaining_length > 0) {
memcpy(©_to[first_chunk_length], array_.get(),
@@ -102,8 +100,9 @@
PushBack(append_this, append_this.Size(), 0);
}
-void AudioVector::PushBack(
- const AudioVector& append_this, size_t length, size_t position) {
+void AudioVector::PushBack(const AudioVector& append_this,
+ size_t length,
+ size_t position) {
RTC_DCHECK_LE(position, append_this.Size());
RTC_DCHECK_LE(length, append_this.Size() - position);
@@ -116,8 +115,8 @@
const size_t start_index =
(append_this.begin_index_ + position) % append_this.capacity_;
- const size_t first_chunk_length = std::min(
- length, append_this.capacity_ - start_index);
+ const size_t first_chunk_length =
+ std::min(length, append_this.capacity_ - start_index);
PushBack(&append_this.array_[start_index], first_chunk_length);
const size_t remaining_length = length - first_chunk_length;
@@ -179,8 +178,7 @@
}
}
-void AudioVector::InsertZerosAt(size_t length,
- size_t position) {
+void AudioVector::InsertZerosAt(size_t length, size_t position) {
if (length == 0)
return;
// Cap the insert position at the current array length.
@@ -265,7 +263,8 @@
alpha -= alpha_step;
array_[(position + i) % capacity_] =
(alpha * array_[(position + i) % capacity_] +
- (16384 - alpha) * append_this[i] + 8192) >> 14;
+ (16384 - alpha) * append_this[i] + 8192) >>
+ 14;
}
assert(alpha >= 0); // Verify that the slope was correct.
// Append what is left of |append_this|.
@@ -319,8 +318,8 @@
}
void AudioVector::InsertByPushFront(const int16_t* insert_this,
- size_t length,
- size_t position) {
+ size_t length,
+ size_t position) {
std::unique_ptr<int16_t[]> temp_array(nullptr);
if (position > 0) {
// TODO(minyue): see if it is possible to avoid copying to a buffer.
@@ -335,8 +334,7 @@
PushFront(temp_array.get(), position);
}
-void AudioVector::InsertZerosByPushBack(size_t length,
- size_t position) {
+void AudioVector::InsertZerosByPushBack(size_t length, size_t position) {
const size_t move_chunk_length = Size() - position;
std::unique_ptr<int16_t[]> temp_array(nullptr);
if (move_chunk_length > 0) {
@@ -359,8 +357,7 @@
PushBack(temp_array.get(), move_chunk_length);
}
-void AudioVector::InsertZerosByPushFront(size_t length,
- size_t position) {
+void AudioVector::InsertZerosByPushFront(size_t length, size_t position) {
std::unique_ptr<int16_t[]> temp_array(nullptr);
if (position > 0) {
temp_array.reset(new int16_t[position]);
diff --git a/modules/audio_coding/neteq/audio_vector.h b/modules/audio_coding/neteq/audio_vector.h
index 754a9fd..65939ce 100644
--- a/modules/audio_coding/neteq/audio_vector.h
+++ b/modules/audio_coding/neteq/audio_vector.h
@@ -75,7 +75,8 @@
// them at |position|. The length of the AudioVector is increased by |length|.
// |position| = 0 means that the new values are prepended to the vector.
// |position| = Size() means that the new values are appended to the vector.
- virtual void InsertAt(const int16_t* insert_this, size_t length,
+ virtual void InsertAt(const int16_t* insert_this,
+ size_t length,
size_t position);
// Like InsertAt, but inserts |length| zero elements at |position|.
@@ -140,10 +141,12 @@
void Reserve(size_t n);
- void InsertByPushBack(const int16_t* insert_this, size_t length,
+ void InsertByPushBack(const int16_t* insert_this,
+ size_t length,
size_t position);
- void InsertByPushFront(const int16_t* insert_this, size_t length,
+ void InsertByPushFront(const int16_t* insert_this,
+ size_t length,
size_t position);
void InsertZerosByPushBack(size_t length, size_t position);
diff --git a/modules/audio_coding/neteq/audio_vector_unittest.cc b/modules/audio_coding/neteq/audio_vector_unittest.cc
index 1b54abc..e70178c 100644
--- a/modules/audio_coding/neteq/audio_vector_unittest.cc
+++ b/modules/audio_coding/neteq/audio_vector_unittest.cc
@@ -30,9 +30,7 @@
}
}
- size_t array_length() const {
- return sizeof(array_) / sizeof(array_[0]);
- }
+ size_t array_length() const { return sizeof(array_) / sizeof(array_[0]); }
int16_t array_[10];
};
@@ -283,8 +281,8 @@
for (int i = 0; i < kNewLength; ++i) {
new_array[i] = 100 + i;
}
- int insert_position = rtc::checked_cast<int>(
- array_length() + 10); // Too large.
+ int insert_position =
+ rtc::checked_cast<int>(array_length() + 10); // Too large.
vec.InsertAt(new_array, kNewLength, insert_position);
// Verify that the vector looks as follows:
// {0, 1, ..., kLength - 1, 100, 101, ..., 100 + kNewLength - 1 }.
@@ -375,7 +373,7 @@
EXPECT_EQ(0, vec1[i]);
}
// Check mixing zone.
- for (size_t i = 0 ; i < kFadeLength; ++i) {
+ for (size_t i = 0; i < kFadeLength; ++i) {
EXPECT_NEAR((i + 1) * 100 / (kFadeLength + 1),
vec1[kLength - kFadeLength + i], 1);
}
diff --git a/modules/audio_coding/neteq/background_noise.cc b/modules/audio_coding/neteq/background_noise.cc
index 50ffa86..08c278e 100644
--- a/modules/audio_coding/neteq/background_noise.cc
+++ b/modules/audio_coding/neteq/background_noise.cc
@@ -58,11 +58,11 @@
int16_t temp_signal_array[kVecLen + kMaxLpcOrder] = {0};
int16_t* temp_signal = &temp_signal_array[kMaxLpcOrder];
input[channel_ix].CopyTo(kVecLen, input.Size() - kVecLen, temp_signal);
- int32_t sample_energy = CalculateAutoCorrelation(temp_signal, kVecLen,
- auto_correlation);
+ int32_t sample_energy =
+ CalculateAutoCorrelation(temp_signal, kVecLen, auto_correlation);
if ((!vad.running() &&
- sample_energy < parameters.energy_update_threshold) ||
+ sample_energy < parameters.energy_update_threshold) ||
(vad.running() && !vad.active_speech())) {
// Generate LPC coefficients.
if (auto_correlation[0] > 0) {
@@ -91,10 +91,8 @@
WebRtcSpl_FilterMAFastQ12(temp_signal + kVecLen - kResidualLength,
fiter_output, lpc_coefficients,
kMaxLpcOrder + 1, kResidualLength);
- int32_t residual_energy = WebRtcSpl_DotProductWithScale(fiter_output,
- fiter_output,
- kResidualLength,
- 0);
+ int32_t residual_energy = WebRtcSpl_DotProductWithScale(
+ fiter_output, fiter_output, kResidualLength, 0);
// Check spectral flatness.
// Comparing the residual variance with the input signal variance tells
@@ -146,7 +144,8 @@
return channel_parameters_[channel].filter_state;
}
-void BackgroundNoise::SetFilterState(size_t channel, const int16_t* input,
+void BackgroundNoise::SetFilterState(size_t channel,
+ const int16_t* input,
size_t length) {
assert(channel < num_channels_);
length = std::min(length, kMaxLpcOrder);
@@ -164,7 +163,9 @@
}
int32_t BackgroundNoise::CalculateAutoCorrelation(
- const int16_t* signal, size_t length, int32_t* auto_correlation) const {
+ const int16_t* signal,
+ size_t length,
+ int32_t* auto_correlation) const {
static const int kCorrelationStep = -1;
const int correlation_scale =
CrossCorrelationWithAutoShift(signal, signal, length, kMaxLpcOrder + 1,
@@ -185,15 +186,16 @@
assert(channel < num_channels_);
ChannelParameters& parameters = channel_parameters_[channel];
int32_t temp_energy =
- (kThresholdIncrement * parameters.low_energy_update_threshold) >> 16;
- temp_energy += kThresholdIncrement *
- (parameters.energy_update_threshold & 0xFF);
- temp_energy += (kThresholdIncrement *
- ((parameters.energy_update_threshold>>8) & 0xFF)) << 8;
+ (kThresholdIncrement * parameters.low_energy_update_threshold) >> 16;
+ temp_energy +=
+ kThresholdIncrement * (parameters.energy_update_threshold & 0xFF);
+ temp_energy +=
+ (kThresholdIncrement * ((parameters.energy_update_threshold >> 8) & 0xFF))
+ << 8;
parameters.low_energy_update_threshold += temp_energy;
- parameters.energy_update_threshold += kThresholdIncrement *
- (parameters.energy_update_threshold>>16);
+ parameters.energy_update_threshold +=
+ kThresholdIncrement * (parameters.energy_update_threshold >> 16);
parameters.energy_update_threshold +=
parameters.low_energy_update_threshold >> 16;
parameters.low_energy_update_threshold =
@@ -201,8 +203,7 @@
// Update maximum energy.
// Decrease by a factor 1/1024 each time.
- parameters.max_energy = parameters.max_energy -
- (parameters.max_energy >> 10);
+ parameters.max_energy = parameters.max_energy - (parameters.max_energy >> 10);
if (sample_energy > parameters.max_energy) {
parameters.max_energy = sample_energy;
}
@@ -223,9 +224,8 @@
assert(channel < num_channels_);
ChannelParameters& parameters = channel_parameters_[channel];
memcpy(parameters.filter, lpc_coefficients,
- (kMaxLpcOrder+1) * sizeof(int16_t));
- memcpy(parameters.filter_state, filter_state,
- kMaxLpcOrder * sizeof(int16_t));
+ (kMaxLpcOrder + 1) * sizeof(int16_t));
+ memcpy(parameters.filter_state, filter_state, kMaxLpcOrder * sizeof(int16_t));
// Save energy level and update energy threshold levels.
// Never get under 1.0 in average sample energy.
parameters.energy = std::max(sample_energy, 1);
diff --git a/modules/audio_coding/neteq/background_noise.h b/modules/audio_coding/neteq/background_noise.h
index a6f1395..26d42b5 100644
--- a/modules/audio_coding/neteq/background_noise.h
+++ b/modules/audio_coding/neteq/background_noise.h
@@ -38,8 +38,7 @@
// Updates the parameter estimates based on the signal currently in the
// |sync_buffer|, and on the latest decision in |vad| if it is running.
- void Update(const AudioMultiVector& sync_buffer,
- const PostDecodeVad& vad);
+ void Update(const AudioMultiVector& sync_buffer, const PostDecodeVad& vad);
// Returns |energy_| for |channel|.
int32_t Energy(size_t channel) const;
@@ -78,9 +77,7 @@
struct ChannelParameters {
// Constructor.
- ChannelParameters() {
- Reset();
- }
+ ChannelParameters() { Reset(); }
void Reset() {
energy = 2500;
diff --git a/modules/audio_coding/neteq/buffer_level_filter.cc b/modules/audio_coding/neteq/buffer_level_filter.cc
index 6005de6..4d015b6 100644
--- a/modules/audio_coding/neteq/buffer_level_filter.cc
+++ b/modules/audio_coding/neteq/buffer_level_filter.cc
@@ -31,7 +31,8 @@
// (1 - |level_factor_|) * |buffer_size_packets|
// |level_factor_| and |filtered_current_level_| are in Q8.
// |buffer_size_packets| is in Q0.
- filtered_current_level_ = ((level_factor_ * filtered_current_level_) >> 8) +
+ filtered_current_level_ =
+ ((level_factor_ * filtered_current_level_) >> 8) +
((256 - level_factor_) * static_cast<int>(buffer_size_packets));
// Account for time-scale operations (accelerate and pre-emptive expand).
diff --git a/modules/audio_coding/neteq/buffer_level_filter.h b/modules/audio_coding/neteq/buffer_level_filter.h
index 7a48c72..c8d27dc 100644
--- a/modules/audio_coding/neteq/buffer_level_filter.h
+++ b/modules/audio_coding/neteq/buffer_level_filter.h
@@ -28,7 +28,8 @@
// corresponding number of packets, and is subtracted from the filtered
// value (thus bypassing the filter operation). |packet_len_samples| is the
// number of audio samples carried in each incoming packet.
- virtual void Update(size_t buffer_size_packets, int time_stretched_samples,
+ virtual void Update(size_t buffer_size_packets,
+ int time_stretched_samples,
size_t packet_len_samples);
// Set the current target buffer level (obtained from
diff --git a/modules/audio_coding/neteq/buffer_level_filter_unittest.cc b/modules/audio_coding/neteq/buffer_level_filter_unittest.cc
index 72c8727..b6dcd2a 100644
--- a/modules/audio_coding/neteq/buffer_level_filter_unittest.cc
+++ b/modules/audio_coding/neteq/buffer_level_filter_unittest.cc
@@ -39,8 +39,7 @@
}
// Expect the filtered value to be (theoretically)
// (1 - (251/256) ^ |times|) * |value|.
- double expected_value_double =
- (1 - pow(251.0 / 256.0, times)) * value;
+ double expected_value_double = (1 - pow(251.0 / 256.0, times)) * value;
int expected_value = static_cast<int>(expected_value_double);
// filtered_current_level() returns the value in Q8.
// The actual value may differ slightly from the expected value due to
@@ -94,7 +93,6 @@
EXPECT_EQ(expected_value, filter.filtered_current_level() >> 8);
}
-
TEST(BufferLevelFilter, TimeStretchedSamples) {
BufferLevelFilter filter;
filter.SetTargetBufferLevel(1); // Makes filter coefficient 251/256.
diff --git a/modules/audio_coding/neteq/comfort_noise.cc b/modules/audio_coding/neteq/comfort_noise.cc
index 5e0a875..b341acd 100644
--- a/modules/audio_coding/neteq/comfort_noise.cc
+++ b/modules/audio_coding/neteq/comfort_noise.cc
@@ -35,10 +35,9 @@
return kOK;
}
-int ComfortNoise::Generate(size_t requested_length,
- AudioMultiVector* output) {
+int ComfortNoise::Generate(size_t requested_length, AudioMultiVector* output) {
// TODO(hlundin): Change to an enumerator and skip assert.
- assert(fs_hz_ == 8000 || fs_hz_ == 16000 || fs_hz_ == 32000 ||
+ assert(fs_hz_ == 8000 || fs_hz_ == 16000 || fs_hz_ == 32000 ||
fs_hz_ == 48000);
// Not adapted for multi-channel yet.
if (output->Channels() != 1) {
@@ -63,8 +62,7 @@
std::unique_ptr<int16_t[]> temp(new int16_t[number_of_samples]);
if (!cng_decoder->Generate(
- rtc::ArrayView<int16_t>(temp.get(), number_of_samples),
- new_period)) {
+ rtc::ArrayView<int16_t>(temp.get(), number_of_samples), new_period)) {
// Error returned.
output->Zeros(requested_length);
RTC_LOG(LS_ERROR)
@@ -75,9 +73,9 @@
if (first_call_) {
// Set tapering window parameters. Values are in Q15.
- int16_t muting_window; // Mixing factor for overlap data.
- int16_t muting_window_increment; // Mixing factor increment (negative).
- int16_t unmuting_window; // Mixing factor for comfort noise.
+ int16_t muting_window; // Mixing factor for overlap data.
+ int16_t muting_window_increment; // Mixing factor increment (negative).
+ int16_t unmuting_window; // Mixing factor for comfort noise.
int16_t unmuting_window_increment; // Mixing factor increment.
if (fs_hz_ == 8000) {
muting_window = DspHelper::kMuteFactorStart8kHz;
@@ -109,7 +107,8 @@
// channel.
(*sync_buffer_)[0][start_ix + i] =
(((*sync_buffer_)[0][start_ix + i] * muting_window) +
- ((*output)[0][i] * unmuting_window) + 16384) >> 15;
+ ((*output)[0][i] * unmuting_window) + 16384) >>
+ 15;
muting_window += muting_window_increment;
unmuting_window += unmuting_window_increment;
}
diff --git a/modules/audio_coding/neteq/comfort_noise.h b/modules/audio_coding/neteq/comfort_noise.h
index 18800ad..c8cc64a 100644
--- a/modules/audio_coding/neteq/comfort_noise.h
+++ b/modules/audio_coding/neteq/comfort_noise.h
@@ -32,14 +32,14 @@
kMultiChannelNotSupported
};
- ComfortNoise(int fs_hz, DecoderDatabase* decoder_database,
+ ComfortNoise(int fs_hz,
+ DecoderDatabase* decoder_database,
SyncBuffer* sync_buffer)
: fs_hz_(fs_hz),
first_call_(true),
overlap_length_(5 * fs_hz_ / 8000),
decoder_database_(decoder_database),
- sync_buffer_(sync_buffer) {
- }
+ sync_buffer_(sync_buffer) {}
// Resets the state. Should be called before each new comfort noise period.
void Reset();
diff --git a/modules/audio_coding/neteq/cross_correlation.cc b/modules/audio_coding/neteq/cross_correlation.cc
index da9c913..2a03d4a 100644
--- a/modules/audio_coding/neteq/cross_correlation.cc
+++ b/modules/audio_coding/neteq/cross_correlation.cc
@@ -48,8 +48,9 @@
// There are some corner cases that 2) is not satisfied, e.g.,
// max_1 = 17, max_2 = 30848, sequence_1_length = 4095, in such case,
// optimal scaling is 0, while the following calculation results in 1.
- const int32_t factor = (max_1 * max_2) / (std::numeric_limits<int32_t>::max()
- / static_cast<int32_t>(sequence_1_length));
+ const int32_t factor =
+ (max_1 * max_2) / (std::numeric_limits<int32_t>::max() /
+ static_cast<int32_t>(sequence_1_length));
const int scaling = factor == 0 ? 0 : 31 - WebRtcSpl_NormW32(factor);
WebRtcSpl_CrossCorrelation(cross_correlation, sequence_1, sequence_2,
diff --git a/modules/audio_coding/neteq/decision_logic.cc b/modules/audio_coding/neteq/decision_logic.cc
index 279a9e6..cc58f04 100644
--- a/modules/audio_coding/neteq/decision_logic.cc
+++ b/modules/audio_coding/neteq/decision_logic.cc
@@ -95,7 +95,7 @@
void DecisionLogic::SetSampleRate(int fs_hz, size_t output_size_samples) {
// TODO(hlundin): Change to an enumerator and skip assert.
- assert(fs_hz == 8000 || fs_hz == 16000 || fs_hz == 32000 || fs_hz == 48000);
+ assert(fs_hz == 8000 || fs_hz == 16000 || fs_hz == 32000 || fs_hz == 48000);
fs_mult_ = fs_hz / 8000;
output_size_samples_ = output_size_samples;
}
@@ -122,11 +122,11 @@
const size_t cur_size_samples =
samples_left + packet_buffer_.NumSamplesInBuffer(decoder_frame_length);
- prev_time_scale_ = prev_time_scale_ &&
- (prev_mode == kModeAccelerateSuccess ||
- prev_mode == kModeAccelerateLowEnergy ||
- prev_mode == kModePreemptiveExpandSuccess ||
- prev_mode == kModePreemptiveExpandLowEnergy);
+ prev_time_scale_ =
+ prev_time_scale_ && (prev_mode == kModeAccelerateSuccess ||
+ prev_mode == kModeAccelerateLowEnergy ||
+ prev_mode == kModePreemptiveExpandSuccess ||
+ prev_mode == kModePreemptiveExpandLowEnergy);
FilterBufferLevel(cur_size_samples, prev_mode);
diff --git a/modules/audio_coding/neteq/decision_logic.h b/modules/audio_coding/neteq/decision_logic.h
index 9d88c4d..d23aa74 100644
--- a/modules/audio_coding/neteq/decision_logic.h
+++ b/modules/audio_coding/neteq/decision_logic.h
@@ -97,9 +97,7 @@
virtual void ExpandDecision(Operations operation);
// Adds |value| to |sample_memory_|.
- void AddSampleMemory(int32_t value) {
- sample_memory_ += value;
- }
+ void AddSampleMemory(int32_t value) { sample_memory_ += value; }
// Accessors and mutators.
void set_sample_memory(int32_t value) { sample_memory_ = value; }
@@ -115,11 +113,7 @@
// The value 5 sets maximum time-stretch rate to about 100 ms/s.
static const int kMinTimescaleInterval = 5;
- enum CngState {
- kCngOff,
- kCngRfc3389On,
- kCngInternalOn
- };
+ enum CngState { kCngOff, kCngRfc3389On, kCngInternalOn };
// Returns the operation that should be done next. |sync_buffer| and |expand|
// are provided for reference. |decoder_frame_length| is the number of samples
diff --git a/modules/audio_coding/neteq/decision_logic_fax.cc b/modules/audio_coding/neteq/decision_logic_fax.cc
index 22d36ce..0f904bb 100644
--- a/modules/audio_coding/neteq/decision_logic_fax.cc
+++ b/modules/audio_coding/neteq/decision_logic_fax.cc
@@ -39,8 +39,8 @@
decoder_database_->IsComfortNoise(next_packet->payload_type);
}
if (is_cng_packet) {
- if (static_cast<int32_t>((generated_noise_samples + target_timestamp)
- - available_timestamp) >= 0) {
+ if (static_cast<int32_t>((generated_noise_samples + target_timestamp) -
+ available_timestamp) >= 0) {
// Time to play this packet now.
return kRfc3389Cng;
} else {
@@ -72,8 +72,8 @@
} else if (target_timestamp == available_timestamp) {
return kNormal;
} else {
- if (static_cast<int32_t>((generated_noise_samples + target_timestamp)
- - available_timestamp) >= 0) {
+ if (static_cast<int32_t>((generated_noise_samples + target_timestamp) -
+ available_timestamp) >= 0) {
return kNormal;
} else {
// If currently playing comfort noise, continue with that. Do not
@@ -100,5 +100,4 @@
}
}
-
} // namespace webrtc
diff --git a/modules/audio_coding/neteq/decision_logic_normal.cc b/modules/audio_coding/neteq/decision_logic_normal.cc
index c163999..a683b8c 100644
--- a/modules/audio_coding/neteq/decision_logic_normal.cc
+++ b/modules/audio_coding/neteq/decision_logic_normal.cc
@@ -79,8 +79,8 @@
// Note that the MuteFactor is in Q14, so a value of 16384 corresponds to 1.
if (postpone_decoding_after_expand_ && prev_mode == kModeExpand &&
!packet_buffer_.ContainsDtxOrCngPacket(decoder_database_) &&
- cur_size_samples < static_cast<size_t>(delay_manager_->TargetLevel() *
- packet_length_samples_) >> 8 &&
+ cur_size_samples<static_cast<size_t>(delay_manager_->TargetLevel() *
+ packet_length_samples_)>> 8 &&
expand.MuteFactor(0) < 16384 / 2) {
return kExpand;
}
@@ -92,10 +92,9 @@
return ExpectedPacketAvailable(prev_mode, play_dtmf);
} else if (!PacketBuffer::IsObsoleteTimestamp(
available_timestamp, target_timestamp, five_seconds_samples)) {
- return FuturePacketAvailable(sync_buffer, expand, decoder_frame_length,
- prev_mode, target_timestamp,
- available_timestamp, play_dtmf,
- generated_noise_samples);
+ return FuturePacketAvailable(
+ sync_buffer, expand, decoder_frame_length, prev_mode, target_timestamp,
+ available_timestamp, play_dtmf, generated_noise_samples);
} else {
// This implies that available_timestamp < target_timestamp, which can
// happen when a new stream or codec is received. Signal for a reset.
@@ -183,10 +182,8 @@
// Check if we should continue with an ongoing expand because the new packet
// is too far into the future.
uint32_t timestamp_leap = available_timestamp - target_timestamp;
- if ((prev_mode == kModeExpand) &&
- !ReinitAfterExpands(timestamp_leap) &&
- !MaxWaitForPacket() &&
- PacketTooEarly(timestamp_leap) &&
+ if ((prev_mode == kModeExpand) && !ReinitAfterExpands(timestamp_leap) &&
+ !MaxWaitForPacket() && PacketTooEarly(timestamp_leap) &&
UnderTargetLevel()) {
if (play_dtmf) {
// Still have DTMF to play, so do not do expand.
@@ -199,12 +196,11 @@
const size_t samples_left =
sync_buffer.FutureLength() - expand.overlap_length();
- const size_t cur_size_samples = samples_left +
- packet_buffer_.NumPacketsInBuffer() * decoder_frame_length;
+ const size_t cur_size_samples =
+ samples_left + packet_buffer_.NumPacketsInBuffer() * decoder_frame_length;
// If previous was comfort noise, then no merge is needed.
- if (prev_mode == kModeRfc3389Cng ||
- prev_mode == kModeCodecInternalCng) {
+ if (prev_mode == kModeRfc3389Cng || prev_mode == kModeCodecInternalCng) {
// Keep the same delay as before the CNG, but make sure that the number of
// samples in buffer is no higher than 4 times the optimal level. (Note that
// TargetLevel() is in Q8.)
@@ -212,7 +208,7 @@
available_timestamp ||
cur_size_samples >
((delay_manager_->TargetLevel() * packet_length_samples_) >> 8) *
- 4) {
+ 4) {
// Time to play this new packet.
return kNormal;
} else {
@@ -237,17 +233,17 @@
bool DecisionLogicNormal::UnderTargetLevel() const {
return buffer_level_filter_->filtered_current_level() <=
- delay_manager_->TargetLevel();
+ delay_manager_->TargetLevel();
}
bool DecisionLogicNormal::ReinitAfterExpands(uint32_t timestamp_leap) const {
return timestamp_leap >=
- static_cast<uint32_t>(output_size_samples_ * kReinitAfterExpands);
+ static_cast<uint32_t>(output_size_samples_ * kReinitAfterExpands);
}
bool DecisionLogicNormal::PacketTooEarly(uint32_t timestamp_leap) const {
return timestamp_leap >
- static_cast<uint32_t>(output_size_samples_ * num_consecutive_expands_);
+ static_cast<uint32_t>(output_size_samples_ * num_consecutive_expands_);
}
bool DecisionLogicNormal::MaxWaitForPacket() const {
diff --git a/modules/audio_coding/neteq/decision_logic_normal.h b/modules/audio_coding/neteq/decision_logic_normal.h
index a718f99..ed2ea39 100644
--- a/modules/audio_coding/neteq/decision_logic_normal.h
+++ b/modules/audio_coding/neteq/decision_logic_normal.h
@@ -58,15 +58,14 @@
// Returns the operation to do given that the expected packet is not
// available, but a packet further into the future is at hand.
- virtual Operations FuturePacketAvailable(
- const SyncBuffer& sync_buffer,
- const Expand& expand,
- size_t decoder_frame_length,
- Modes prev_mode,
- uint32_t target_timestamp,
- uint32_t available_timestamp,
- bool play_dtmf,
- size_t generated_noise_samples);
+ virtual Operations FuturePacketAvailable(const SyncBuffer& sync_buffer,
+ const Expand& expand,
+ size_t decoder_frame_length,
+ Modes prev_mode,
+ uint32_t target_timestamp,
+ uint32_t available_timestamp,
+ bool play_dtmf,
+ size_t generated_noise_samples);
// Returns the operation to do given that the expected packet is available.
virtual Operations ExpectedPacketAvailable(Modes prev_mode, bool play_dtmf);
diff --git a/modules/audio_coding/neteq/decoder_database.cc b/modules/audio_coding/neteq/decoder_database.cc
index 72c0376..1fd8c03 100644
--- a/modules/audio_coding/neteq/decoder_database.cc
+++ b/modules/audio_coding/neteq/decoder_database.cc
@@ -134,9 +134,13 @@
return Subtype::kNormal;
}
-bool DecoderDatabase::Empty() const { return decoders_.empty(); }
+bool DecoderDatabase::Empty() const {
+ return decoders_.empty();
+}
-int DecoderDatabase::Size() const { return static_cast<int>(decoders_.size()); }
+int DecoderDatabase::Size() const {
+ return static_cast<int>(decoders_.size());
+}
void DecoderDatabase::Reset() {
decoders_.clear();
@@ -276,7 +280,7 @@
int DecoderDatabase::SetActiveDecoder(uint8_t rtp_payload_type,
bool* new_decoder) {
// Check that |rtp_payload_type| exists in the database.
- const DecoderInfo *info = GetDecoderInfo(rtp_payload_type);
+ const DecoderInfo* info = GetDecoderInfo(rtp_payload_type);
if (!info) {
// Decoder not found.
return kDecoderNotFound;
@@ -289,7 +293,7 @@
*new_decoder = true;
} else if (active_decoder_type_ != rtp_payload_type) {
// Moving from one active decoder to another. Delete the first one.
- const DecoderInfo *old_info = GetDecoderInfo(active_decoder_type_);
+ const DecoderInfo* old_info = GetDecoderInfo(active_decoder_type_);
RTC_DCHECK(old_info);
old_info->DropDecoder();
*new_decoder = true;
@@ -308,7 +312,7 @@
int DecoderDatabase::SetActiveCngDecoder(uint8_t rtp_payload_type) {
// Check that |rtp_payload_type| exists in the database.
- const DecoderInfo *info = GetDecoderInfo(rtp_payload_type);
+ const DecoderInfo* info = GetDecoderInfo(rtp_payload_type);
if (!info) {
// Decoder not found.
return kDecoderNotFound;
@@ -335,7 +339,7 @@
}
AudioDecoder* DecoderDatabase::GetDecoder(uint8_t rtp_payload_type) const {
- const DecoderInfo *info = GetDecoderInfo(rtp_payload_type);
+ const DecoderInfo* info = GetDecoderInfo(rtp_payload_type);
return info ? info->GetDecoder() : nullptr;
}
@@ -350,17 +354,17 @@
}
bool DecoderDatabase::IsComfortNoise(uint8_t rtp_payload_type) const {
- const DecoderInfo *info = GetDecoderInfo(rtp_payload_type);
+ const DecoderInfo* info = GetDecoderInfo(rtp_payload_type);
return info && info->IsComfortNoise();
}
bool DecoderDatabase::IsDtmf(uint8_t rtp_payload_type) const {
- const DecoderInfo *info = GetDecoderInfo(rtp_payload_type);
+ const DecoderInfo* info = GetDecoderInfo(rtp_payload_type);
return info && info->IsDtmf();
}
bool DecoderDatabase::IsRed(uint8_t rtp_payload_type) const {
- const DecoderInfo *info = GetDecoderInfo(rtp_payload_type);
+ const DecoderInfo* info = GetDecoderInfo(rtp_payload_type);
return info && info->IsRed();
}
diff --git a/modules/audio_coding/neteq/decoder_database.h b/modules/audio_coding/neteq/decoder_database.h
index 6b388dd..107d2f3 100644
--- a/modules/audio_coding/neteq/decoder_database.h
+++ b/modules/audio_coding/neteq/decoder_database.h
@@ -88,14 +88,10 @@
}
// Returns true if the decoder's format is DTMF.
- bool IsDtmf() const {
- return subtype_ == Subtype::kDtmf;
- }
+ bool IsDtmf() const { return subtype_ == Subtype::kDtmf; }
// Returns true if the decoder's format is RED.
- bool IsRed() const {
- return subtype_ == Subtype::kRed;
- }
+ bool IsRed() const { return subtype_ == Subtype::kRed; }
// Returns true if the decoder's format is named |name|.
bool IsType(const char* name) const;
@@ -125,12 +121,7 @@
};
const absl::optional<CngDecoder> cng_decoder_;
- enum class Subtype : int8_t {
- kNormal,
- kComfortNoise,
- kDtmf,
- kRed
- };
+ enum class Subtype : int8_t { kNormal, kComfortNoise, kDtmf, kRed };
static Subtype SubtypeFromFormat(const SdpAudioFormat& format);
diff --git a/modules/audio_coding/neteq/decoder_database_unittest.cc b/modules/audio_coding/neteq/decoder_database_unittest.cc
index afd10ae..10043e0 100644
--- a/modules/audio_coding/neteq/decoder_database_unittest.cc
+++ b/modules/audio_coding/neteq/decoder_database_unittest.cc
@@ -110,7 +110,7 @@
EXPECT_EQ(kCodecName, info->get_name());
EXPECT_EQ(decoder, db.GetDecoder(kPayloadType));
info = db.GetDecoderInfo(kPayloadType + 1); // Other payload type.
- EXPECT_TRUE(info == NULL); // Should not be found.
+ EXPECT_TRUE(info == NULL); // Should not be found.
}
TEST(DecoderDatabase, GetDecoder) {
@@ -292,7 +292,6 @@
// Try to set non-existing codecs as active.
EXPECT_EQ(DecoderDatabase::kDecoderNotFound,
db.SetActiveDecoder(17, &changed));
- EXPECT_EQ(DecoderDatabase::kDecoderNotFound,
- db.SetActiveCngDecoder(17));
+ EXPECT_EQ(DecoderDatabase::kDecoderNotFound, db.SetActiveCngDecoder(17));
}
} // namespace webrtc
diff --git a/modules/audio_coding/neteq/delay_manager.cc b/modules/audio_coding/neteq/delay_manager.cc
index b70131d..a945cdc 100644
--- a/modules/audio_coding/neteq/delay_manager.cc
+++ b/modules/audio_coding/neteq/delay_manager.cc
@@ -155,8 +155,9 @@
(packet_iat_stopwatch_->ElapsedMs() << 8) / packet_len_ms;
// Calculate cumulative sum IAT with sequence number compensation. The sum
// is zero if there is no clock-drift.
- iat_cumulative_sum_ += (iat_packets_q8 -
- (static_cast<int>(sequence_number - last_seq_no_) << 8));
+ iat_cumulative_sum_ +=
+ (iat_packets_q8 -
+ (static_cast<int>(sequence_number - last_seq_no_) << 8));
// Subtract drift term.
iat_cumulative_sum_ -= kCumulativeSumDrift;
// Ensure not negative.
@@ -189,8 +190,8 @@
assert(iat_packets < iat_vector_.size());
int vector_sum = 0; // Sum up the vector elements as they are processed.
// Multiply each element in |iat_vector_| with |iat_factor_|.
- for (IATVector::iterator it = iat_vector_.begin();
- it != iat_vector_.end(); ++it) {
+ for (IATVector::iterator it = iat_vector_.begin(); it != iat_vector_.end();
+ ++it) {
*it = (static_cast<int64_t>(*it) * iat_factor_) >> 15;
vector_sum += *it;
}
@@ -236,7 +237,7 @@
least_required_delay_ms_ = (target_level_ * packet_len_ms_) >> 8;
if (packet_len_ms_ > 0 && minimum_delay_ms_ > 0) {
- int minimum_delay_packet_q8 = (minimum_delay_ms_ << 8) / packet_len_ms_;
+ int minimum_delay_packet_q8 = (minimum_delay_ms_ << 8) / packet_len_ms_;
target_level_ = std::max(target_level_, minimum_delay_packet_q8);
}
@@ -269,8 +270,8 @@
// (in Q30) by definition, and since the solution is often a low value for
// |iat_index|, it is more efficient to start with |sum| = 1 and subtract
// elements from the start of the histogram.
- size_t index = 0; // Start from the beginning of |iat_vector_|.
- int sum = 1 << 30; // Assign to 1 in Q30.
+ size_t index = 0; // Start from the beginning of |iat_vector_|.
+ int sum = 1 << 30; // Assign to 1 in Q30.
sum -= iat_vector_[index]; // Ensure that target level is >= 1.
do {
@@ -313,13 +314,12 @@
return 0;
}
-
void DelayManager::Reset() {
packet_len_ms_ = 0; // Packet size unknown.
streaming_mode_ = false;
peak_detector_.Reset();
ResetHistogram(); // Resets target levels too.
- iat_factor_ = 0; // Adapt the histogram faster for the first few packets.
+ iat_factor_ = 0; // Adapt the histogram faster for the first few packets.
packet_iat_stopwatch_ = tick_timer_->GetNewStopwatch();
max_iat_stopwatch_ = tick_timer_->GetNewStopwatch();
iat_cumulative_sum_ = 0;
@@ -471,8 +471,12 @@
return least_required_delay_ms_;
}
-int DelayManager::base_target_level() const { return base_target_level_; }
-void DelayManager::set_streaming_mode(bool value) { streaming_mode_ = value; }
+int DelayManager::base_target_level() const {
+ return base_target_level_;
+}
+void DelayManager::set_streaming_mode(bool value) {
+ streaming_mode_ = value;
+}
int DelayManager::last_pack_cng_or_dtmf() const {
return last_pack_cng_or_dtmf_;
}
diff --git a/modules/audio_coding/neteq/delay_manager.h b/modules/audio_coding/neteq/delay_manager.h
index 0d082c8..08004ea 100644
--- a/modules/audio_coding/neteq/delay_manager.h
+++ b/modules/audio_coding/neteq/delay_manager.h
@@ -117,9 +117,9 @@
virtual void set_last_pack_cng_or_dtmf(int value);
private:
- static const int kLimitProbability = 53687091; // 1/20 in Q30.
+ static const int kLimitProbability = 53687091; // 1/20 in Q30.
static const int kLimitProbabilityStreaming = 536871; // 1/2000 in Q30.
- static const int kMaxStreamingPeakPeriodMs = 600000; // 10 minutes in ms.
+ static const int kMaxStreamingPeakPeriodMs = 600000; // 10 minutes in ms.
static const int kCumulativeSumDrift = 2; // Drift term for cumulative sum
// |iat_cumulative_sum_|.
// Steady-state forgetting factor for |iat_vector_|, 0.9993 in Q15.
@@ -146,28 +146,29 @@
bool first_packet_received_;
const size_t max_packets_in_buffer_; // Capacity of the packet buffer.
- IATVector iat_vector_; // Histogram of inter-arrival times.
+ IATVector iat_vector_; // Histogram of inter-arrival times.
int iat_factor_; // Forgetting factor for updating the IAT histogram (Q15).
const TickTimer* tick_timer_;
// Time elapsed since last packet.
std::unique_ptr<TickTimer::Stopwatch> packet_iat_stopwatch_;
- int base_target_level_; // Currently preferred buffer level before peak
- // detection and streaming mode (Q0).
+ int base_target_level_; // Currently preferred buffer level before peak
+ // detection and streaming mode (Q0).
// TODO(turajs) change the comment according to the implementation of
// minimum-delay.
- int target_level_; // Currently preferred buffer level in (fractions)
- // of packets (Q8), before adding any extra delay.
+ int target_level_; // Currently preferred buffer level in (fractions)
+ // of packets (Q8), before adding any extra delay.
int packet_len_ms_; // Length of audio in each incoming packet [ms].
bool streaming_mode_;
- uint16_t last_seq_no_; // Sequence number for last received packet.
- uint32_t last_timestamp_; // Timestamp for the last received packet.
- int minimum_delay_ms_; // Externally set minimum delay.
+ uint16_t last_seq_no_; // Sequence number for last received packet.
+ uint32_t last_timestamp_; // Timestamp for the last received packet.
+ int minimum_delay_ms_; // Externally set minimum delay.
int least_required_delay_ms_; // Smallest preferred buffer level (same unit
- // as |target_level_|), before applying
- // |minimum_delay_ms_| and/or |maximum_delay_ms_|.
- int maximum_delay_ms_; // Externally set maximum allowed delay.
- int iat_cumulative_sum_; // Cumulative sum of delta inter-arrival times.
- int max_iat_cumulative_sum_; // Max of |iat_cumulative_sum_|.
+ // as |target_level_|), before applying
+ // |minimum_delay_ms_| and/or
+ // |maximum_delay_ms_|.
+ int maximum_delay_ms_; // Externally set maximum allowed delay.
+ int iat_cumulative_sum_; // Cumulative sum of delta inter-arrival times.
+ int max_iat_cumulative_sum_; // Max of |iat_cumulative_sum_|.
// Time elapsed since maximum was observed.
std::unique_ptr<TickTimer::Stopwatch> max_iat_stopwatch_;
DelayPeakDetector& peak_detector_;
diff --git a/modules/audio_coding/neteq/delay_manager_unittest.cc b/modules/audio_coding/neteq/delay_manager_unittest.cc
index 953bc6b..f9c5680 100644
--- a/modules/audio_coding/neteq/delay_manager_unittest.cc
+++ b/modules/audio_coding/neteq/delay_manager_unittest.cc
@@ -49,8 +49,7 @@
: dm_(NULL), detector_(&tick_timer_), seq_no_(0x1234), ts_(0x12345678) {}
void DelayManagerTest::SetUp() {
- EXPECT_CALL(detector_, Reset())
- .Times(1);
+ EXPECT_CALL(detector_, Reset()).Times(1);
dm_ = new DelayManager(kMaxNumberOfPackets, &detector_, &tick_timer_);
}
@@ -94,8 +93,7 @@
TEST_F(DelayManagerTest, SetPacketAudioLength) {
const int kLengthMs = 30;
// Expect DelayManager to pass on the new length to the detector object.
- EXPECT_CALL(detector_, SetPacketAudioLength(kLengthMs))
- .Times(1);
+ EXPECT_CALL(detector_, SetPacketAudioLength(kLengthMs)).Times(1);
EXPECT_EQ(0, dm_->SetPacketAudioLength(kLengthMs));
EXPECT_EQ(-1, dm_->SetPacketAudioLength(-1)); // Illegal parameter value.
}
@@ -121,8 +119,7 @@
// Expect detector update method to be called once with inter-arrival time
// equal to 1 packet, and (base) target level equal to 1 as well.
// Return false to indicate no peaks found.
- EXPECT_CALL(detector_, Update(1, 1))
- .WillOnce(Return(false));
+ EXPECT_CALL(detector_, Update(1, 1)).WillOnce(Return(false));
InsertNextPacket();
EXPECT_EQ(1 << 8, dm_->TargetLevel()); // In Q8.
EXPECT_EQ(1, dm_->base_target_level());
@@ -145,8 +142,7 @@
// Expect detector update method to be called once with inter-arrival time
// equal to 1 packet, and (base) target level equal to 1 as well.
// Return false to indicate no peaks found.
- EXPECT_CALL(detector_, Update(2, 2))
- .WillOnce(Return(false));
+ EXPECT_CALL(detector_, Update(2, 2)).WillOnce(Return(false));
InsertNextPacket();
EXPECT_EQ(2 << 8, dm_->TargetLevel()); // In Q8.
EXPECT_EQ(2, dm_->base_target_level());
@@ -169,10 +165,8 @@
// Expect detector update method to be called once with inter-arrival time
// equal to 1 packet, and (base) target level equal to 1 as well.
// Return true to indicate that peaks are found. Let the peak height be 5.
- EXPECT_CALL(detector_, Update(1, 1))
- .WillOnce(Return(true));
- EXPECT_CALL(detector_, MaxPeakHeight())
- .WillOnce(Return(5));
+ EXPECT_CALL(detector_, Update(1, 1)).WillOnce(Return(true));
+ EXPECT_CALL(detector_, MaxPeakHeight()).WillOnce(Return(5));
InsertNextPacket();
EXPECT_EQ(5 << 8, dm_->TargetLevel());
EXPECT_EQ(1, dm_->base_target_level()); // Base target level is w/o peaks.
@@ -193,8 +187,7 @@
// Expect detector update method to be called once with inter-arrival time
// equal to 1 packet, and (base) target level equal to 1 as well.
// Return false to indicate no peaks found.
- EXPECT_CALL(detector_, Update(1, 1))
- .WillOnce(Return(false));
+ EXPECT_CALL(detector_, Update(1, 1)).WillOnce(Return(false));
InsertNextPacket();
const int kExpectedTarget = 1;
EXPECT_EQ(kExpectedTarget << 8, dm_->TargetLevel()); // In Q8.
diff --git a/modules/audio_coding/neteq/delay_peak_detector_unittest.cc b/modules/audio_coding/neteq/delay_peak_detector_unittest.cc
index 058ba66..fd4dded 100644
--- a/modules/audio_coding/neteq/delay_peak_detector_unittest.cc
+++ b/modules/audio_coding/neteq/delay_peak_detector_unittest.cc
@@ -65,8 +65,8 @@
int next = 1; // Start with the second packet to get a proper IAT.
while (next < kNumPackets) {
while (next < kNumPackets && arrival_times_ms[next] <= time) {
- int iat_packets = (arrival_times_ms[next] - arrival_times_ms[next - 1]) /
- kPacketSizeMs;
+ int iat_packets =
+ (arrival_times_ms[next] - arrival_times_ms[next - 1]) / kPacketSizeMs;
const int kTargetBufferLevel = 1; // Define peaks to be iat > 2.
if (time < peak_mode_start_ms || time > peak_mode_end_ms) {
EXPECT_FALSE(detector.Update(iat_packets, kTargetBufferLevel));
@@ -112,8 +112,8 @@
int next = 1; // Start with the second packet to get a proper IAT.
while (next < kNumPackets) {
while (next < kNumPackets && arrival_times_ms[next] <= time) {
- int iat_packets = (arrival_times_ms[next] - arrival_times_ms[next - 1]) /
- kPacketSizeMs;
+ int iat_packets =
+ (arrival_times_ms[next] - arrival_times_ms[next - 1]) / kPacketSizeMs;
const int kTargetBufferLevel = 2; // Define peaks to be iat > 4.
EXPECT_FALSE(detector.Update(iat_packets, kTargetBufferLevel));
++next;
diff --git a/modules/audio_coding/neteq/dsp_helper.cc b/modules/audio_coding/neteq/dsp_helper.cc
index 2a1d81b..05b0f70 100644
--- a/modules/audio_coding/neteq/dsp_helper.cc
+++ b/modules/audio_coding/neteq/dsp_helper.cc
@@ -21,41 +21,29 @@
// Table of constants used in method DspHelper::ParabolicFit().
const int16_t DspHelper::kParabolaCoefficients[17][3] = {
- { 120, 32, 64 },
- { 140, 44, 75 },
- { 150, 50, 80 },
- { 160, 57, 85 },
- { 180, 72, 96 },
- { 200, 89, 107 },
- { 210, 98, 112 },
- { 220, 108, 117 },
- { 240, 128, 128 },
- { 260, 150, 139 },
- { 270, 162, 144 },
- { 280, 174, 149 },
- { 300, 200, 160 },
- { 320, 228, 171 },
- { 330, 242, 176 },
- { 340, 257, 181 },
- { 360, 288, 192 } };
+ {120, 32, 64}, {140, 44, 75}, {150, 50, 80}, {160, 57, 85},
+ {180, 72, 96}, {200, 89, 107}, {210, 98, 112}, {220, 108, 117},
+ {240, 128, 128}, {260, 150, 139}, {270, 162, 144}, {280, 174, 149},
+ {300, 200, 160}, {320, 228, 171}, {330, 242, 176}, {340, 257, 181},
+ {360, 288, 192}};
// Filter coefficients used when downsampling from the indicated sample rates
// (8, 16, 32, 48 kHz) to 4 kHz. Coefficients are in Q12. The corresponding Q0
// values are provided in the comments before each array.
// Q0 values: {0.3, 0.4, 0.3}.
-const int16_t DspHelper::kDownsample8kHzTbl[3] = { 1229, 1638, 1229 };
+const int16_t DspHelper::kDownsample8kHzTbl[3] = {1229, 1638, 1229};
// Q0 values: {0.15, 0.2, 0.3, 0.2, 0.15}.
-const int16_t DspHelper::kDownsample16kHzTbl[5] = { 614, 819, 1229, 819, 614 };
+const int16_t DspHelper::kDownsample16kHzTbl[5] = {614, 819, 1229, 819, 614};
// Q0 values: {0.1425, 0.1251, 0.1525, 0.1628, 0.1525, 0.1251, 0.1425}.
-const int16_t DspHelper::kDownsample32kHzTbl[7] = {
- 584, 512, 625, 667, 625, 512, 584 };
+const int16_t DspHelper::kDownsample32kHzTbl[7] = {584, 512, 625, 667,
+ 625, 512, 584};
// Q0 values: {0.2487, 0.0952, 0.1042, 0.1074, 0.1042, 0.0952, 0.2487}.
-const int16_t DspHelper::kDownsample48kHzTbl[7] = {
- 1019, 390, 427, 440, 427, 390, 1019 };
+const int16_t DspHelper::kDownsample48kHzTbl[7] = {1019, 390, 427, 440,
+ 427, 390, 1019};
int DspHelper::RampSignal(const int16_t* input,
size_t length,
@@ -115,9 +103,12 @@
return end_factor;
}
-void DspHelper::PeakDetection(int16_t* data, size_t data_length,
- size_t num_peaks, int fs_mult,
- size_t* peak_index, int16_t* peak_value) {
+void DspHelper::PeakDetection(int16_t* data,
+ size_t data_length,
+ size_t num_peaks,
+ int fs_mult,
+ size_t* peak_index,
+ int16_t* peak_value) {
size_t min_index = 0;
size_t max_index = 0;
@@ -163,8 +154,10 @@
}
}
-void DspHelper::ParabolicFit(int16_t* signal_points, int fs_mult,
- size_t* peak_index, int16_t* peak_value) {
+void DspHelper::ParabolicFit(int16_t* signal_points,
+ int fs_mult,
+ size_t* peak_index,
+ int16_t* peak_value) {
uint16_t fit_index[13];
if (fs_mult == 1) {
fit_index[0] = 0;
@@ -204,23 +197,26 @@
// num = -3 * signal_points[0] + 4 * signal_points[1] - signal_points[2];
// den = signal_points[0] - 2 * signal_points[1] + signal_points[2];
- int32_t num = (signal_points[0] * -3) + (signal_points[1] * 4)
- - signal_points[2];
+ int32_t num =
+ (signal_points[0] * -3) + (signal_points[1] * 4) - signal_points[2];
int32_t den = signal_points[0] + (signal_points[1] * -2) + signal_points[2];
int32_t temp = num * 120;
int flag = 1;
- int16_t stp = kParabolaCoefficients[fit_index[fs_mult]][0]
- - kParabolaCoefficients[fit_index[fs_mult - 1]][0];
- int16_t strt = (kParabolaCoefficients[fit_index[fs_mult]][0]
- + kParabolaCoefficients[fit_index[fs_mult - 1]][0]) / 2;
+ int16_t stp = kParabolaCoefficients[fit_index[fs_mult]][0] -
+ kParabolaCoefficients[fit_index[fs_mult - 1]][0];
+ int16_t strt = (kParabolaCoefficients[fit_index[fs_mult]][0] +
+ kParabolaCoefficients[fit_index[fs_mult - 1]][0]) /
+ 2;
int16_t lmt;
if (temp < -den * strt) {
lmt = strt - stp;
while (flag) {
if ((flag == fs_mult) || (temp > -den * lmt)) {
- *peak_value = (den * kParabolaCoefficients[fit_index[fs_mult - flag]][1]
- + num * kParabolaCoefficients[fit_index[fs_mult - flag]][2]
- + signal_points[0] * 256) / 256;
+ *peak_value =
+ (den * kParabolaCoefficients[fit_index[fs_mult - flag]][1] +
+ num * kParabolaCoefficients[fit_index[fs_mult - flag]][2] +
+ signal_points[0] * 256) /
+ 256;
*peak_index = *peak_index * 2 * fs_mult - flag;
flag = 0;
} else {
@@ -233,9 +229,9 @@
while (flag) {
if ((flag == fs_mult) || (temp < -den * lmt)) {
int32_t temp_term_1 =
- den * kParabolaCoefficients[fit_index[fs_mult+flag]][1];
+ den * kParabolaCoefficients[fit_index[fs_mult + flag]][1];
int32_t temp_term_2 =
- num * kParabolaCoefficients[fit_index[fs_mult+flag]][2];
+ num * kParabolaCoefficients[fit_index[fs_mult + flag]][2];
int32_t temp_term_3 = signal_points[0] * 256;
*peak_value = (temp_term_1 + temp_term_2 + temp_term_3) / 256;
*peak_index = *peak_index * 2 * fs_mult + flag;
@@ -251,8 +247,10 @@
}
}
-size_t DspHelper::MinDistortion(const int16_t* signal, size_t min_lag,
- size_t max_lag, size_t length,
+size_t DspHelper::MinDistortion(const int16_t* signal,
+ size_t min_lag,
+ size_t max_lag,
+ size_t length,
int32_t* distortion_value) {
size_t best_index = 0;
int32_t min_distortion = WEBRTC_SPL_WORD32_MAX;
@@ -273,9 +271,12 @@
return best_index;
}
-void DspHelper::CrossFade(const int16_t* input1, const int16_t* input2,
- size_t length, int16_t* mix_factor,
- int16_t factor_decrement, int16_t* output) {
+void DspHelper::CrossFade(const int16_t* input1,
+ const int16_t* input2,
+ size_t length,
+ int16_t* mix_factor,
+ int16_t factor_decrement,
+ int16_t* output) {
int16_t factor = *mix_factor;
int16_t complement_factor = 16384 - factor;
for (size_t i = 0; i < length; i++) {
@@ -287,8 +288,10 @@
*mix_factor = factor;
}
-void DspHelper::UnmuteSignal(const int16_t* input, size_t length,
- int16_t* factor, int increment,
+void DspHelper::UnmuteSignal(const int16_t* input,
+ size_t length,
+ int16_t* factor,
+ int increment,
int16_t* output) {
uint16_t factor_16b = *factor;
int32_t factor_32b = (static_cast<int32_t>(factor_16b) << 6) + 32;
@@ -308,17 +311,20 @@
}
}
-int DspHelper::DownsampleTo4kHz(const int16_t* input, size_t input_length,
- size_t output_length, int input_rate_hz,
- bool compensate_delay, int16_t* output) {
+int DspHelper::DownsampleTo4kHz(const int16_t* input,
+ size_t input_length,
+ size_t output_length,
+ int input_rate_hz,
+ bool compensate_delay,
+ int16_t* output) {
// Set filter parameters depending on input frequency.
// NOTE: The phase delay values are wrong compared to the true phase delay
// of the filters. However, the error is preserved (through the +1 term) for
// consistency.
const int16_t* filter_coefficients; // Filter coefficients.
- size_t filter_length; // Number of coefficients.
- size_t filter_delay; // Phase delay in samples.
- int16_t factor; // Conversion rate (inFsHz / 8000).
+ size_t filter_length; // Number of coefficients.
+ size_t filter_delay; // Phase delay in samples.
+ int16_t factor; // Conversion rate (inFsHz / 8000).
switch (input_rate_hz) {
case 8000: {
filter_length = 3;
diff --git a/modules/audio_coding/neteq/dsp_helper.h b/modules/audio_coding/neteq/dsp_helper.h
index 7ceb66f..8940acd 100644
--- a/modules/audio_coding/neteq/dsp_helper.h
+++ b/modules/audio_coding/neteq/dsp_helper.h
@@ -85,9 +85,12 @@
// locations and values are written to the arrays |peak_index| and
// |peak_value|, respectively. Both arrays must hold at least |num_peaks|
// elements.
- static void PeakDetection(int16_t* data, size_t data_length,
- size_t num_peaks, int fs_mult,
- size_t* peak_index, int16_t* peak_value);
+ static void PeakDetection(int16_t* data,
+ size_t data_length,
+ size_t num_peaks,
+ int fs_mult,
+ size_t* peak_index,
+ int16_t* peak_value);
// Estimates the height and location of a maximum. The three values in the
// array |signal_points| are used as basis for a parabolic fit, which is then
@@ -95,30 +98,40 @@
// assumed to be from a 4 kHz signal, while the maximum, written to
// |peak_index| and |peak_value| is given in the full sample rate, as
// indicated by the sample rate multiplier |fs_mult|.
- static void ParabolicFit(int16_t* signal_points, int fs_mult,
- size_t* peak_index, int16_t* peak_value);
+ static void ParabolicFit(int16_t* signal_points,
+ int fs_mult,
+ size_t* peak_index,
+ int16_t* peak_value);
// Calculates the sum-abs-diff for |signal| when compared to a displaced
// version of itself. Returns the displacement lag that results in the minimum
// distortion. The resulting distortion is written to |distortion_value|.
// The values of |min_lag| and |max_lag| are boundaries for the search.
- static size_t MinDistortion(const int16_t* signal, size_t min_lag,
- size_t max_lag, size_t length,
- int32_t* distortion_value);
+ static size_t MinDistortion(const int16_t* signal,
+ size_t min_lag,
+ size_t max_lag,
+ size_t length,
+ int32_t* distortion_value);
// Mixes |length| samples from |input1| and |input2| together and writes the
// result to |output|. The gain for |input1| starts at |mix_factor| (Q14) and
// is decreased by |factor_decrement| (Q14) for each sample. The gain for
// |input2| is the complement 16384 - mix_factor.
- static void CrossFade(const int16_t* input1, const int16_t* input2,
- size_t length, int16_t* mix_factor,
- int16_t factor_decrement, int16_t* output);
+ static void CrossFade(const int16_t* input1,
+ const int16_t* input2,
+ size_t length,
+ int16_t* mix_factor,
+ int16_t factor_decrement,
+ int16_t* output);
// Scales |input| with an increasing gain. Applies |factor| (Q14) to the first
// sample and increases the gain by |increment| (Q20) for each sample. The
// result is written to |output|. |length| samples are processed.
- static void UnmuteSignal(const int16_t* input, size_t length, int16_t* factor,
- int increment, int16_t* output);
+ static void UnmuteSignal(const int16_t* input,
+ size_t length,
+ int16_t* factor,
+ int increment,
+ int16_t* output);
// Starts at unity gain and gradually fades out |signal|. For each sample,
// the gain is reduced by |mute_slope| (Q14). |length| samples are processed.
@@ -129,9 +142,12 @@
// samples to |output|. Compensates for the phase delay of the downsampling
// filters if |compensate_delay| is true. Returns -1 if the input is too short
// to produce |output_length| samples, otherwise 0.
- static int DownsampleTo4kHz(const int16_t* input, size_t input_length,
- size_t output_length, int input_rate_hz,
- bool compensate_delay, int16_t* output);
+ static int DownsampleTo4kHz(const int16_t* input,
+ size_t input_length,
+ size_t output_length,
+ int input_rate_hz,
+ bool compensate_delay,
+ int16_t* output);
private:
// Table of constants used in method DspHelper::ParabolicFit().
diff --git a/modules/audio_coding/neteq/dsp_helper_unittest.cc b/modules/audio_coding/neteq/dsp_helper_unittest.cc
index 98ae2a2..9d5da5d 100644
--- a/modules/audio_coding/neteq/dsp_helper_unittest.cc
+++ b/modules/audio_coding/neteq/dsp_helper_unittest.cc
@@ -30,8 +30,8 @@
int increment = (16384 << 6) / kLen;
// Test first method.
- int stop_factor = DspHelper::RampSignal(input, kLen, start_factor, increment,
- output);
+ int stop_factor =
+ DspHelper::RampSignal(input, kLen, start_factor, increment, output);
EXPECT_EQ(16383, stop_factor); // Almost reach 1 in Q14.
for (int i = 0; i < kLen; ++i) {
EXPECT_EQ(1000 * i / kLen, output[i]);
@@ -63,8 +63,8 @@
// Q20, while the factor is in Q14, hence the shift by 6.
int increment = (16384 << 6) / kLen;
- int stop_factor = DspHelper::RampSignal(&input, start_index, kLen,
- start_factor, increment);
+ int stop_factor =
+ DspHelper::RampSignal(&input, start_index, kLen, start_factor, increment);
EXPECT_EQ(16383, stop_factor); // Almost reach 1 in Q14.
// Verify that the first |kLen| samples are left untouched.
int i;
diff --git a/modules/audio_coding/neteq/dtmf_buffer.cc b/modules/audio_coding/neteq/dtmf_buffer.cc
index 370de42..656cff9 100644
--- a/modules/audio_coding/neteq/dtmf_buffer.cc
+++ b/modules/audio_coding/neteq/dtmf_buffer.cc
@@ -98,9 +98,8 @@
// already in the buffer. If so, the new event is simply merged with the
// existing one.
int DtmfBuffer::InsertEvent(const DtmfEvent& event) {
- if (event.event_no < 0 || event.event_no > 15 ||
- event.volume < 0 || event.volume > 63 ||
- event.duration <= 0 || event.duration > 65535) {
+ if (event.event_no < 0 || event.event_no > 15 || event.volume < 0 ||
+ event.volume > 63 || event.duration <= 0 || event.duration > 65535) {
RTC_LOG(LS_WARNING) << "InsertEvent invalid parameters";
return kInvalidEventParameters;
}
@@ -142,8 +141,8 @@
#endif
}
}
- if (current_timestamp >= it->timestamp
- && current_timestamp <= event_end) { // TODO(hlundin): Change to <.
+ if (current_timestamp >= it->timestamp &&
+ current_timestamp <= event_end) { // TODO(hlundin): Change to <.
// Found a matching event.
if (event) {
event->event_no = it->event_no;
@@ -153,16 +152,15 @@
event->timestamp = it->timestamp;
}
#ifdef LEGACY_BITEXACT
- if (it->end_bit &&
- current_timestamp + frame_len_samples_ >= event_end) {
+ if (it->end_bit && current_timestamp + frame_len_samples_ >= event_end) {
// We are done playing this. Erase the event.
buffer_.erase(it);
}
#endif
return true;
} else if (current_timestamp > event_end) { // TODO(hlundin): Change to >=.
- // Erase old event. Operation returns a valid pointer to the next element
- // in the list.
+// Erase old event. Operation returns a valid pointer to the next element
+// in the list.
#ifdef LEGACY_BITEXACT
if (!next_available) {
if (event) {
@@ -196,10 +194,7 @@
}
int DtmfBuffer::SetSampleRate(int fs_hz) {
- if (fs_hz != 8000 &&
- fs_hz != 16000 &&
- fs_hz != 32000 &&
- fs_hz != 48000) {
+ if (fs_hz != 8000 && fs_hz != 16000 && fs_hz != 32000 && fs_hz != 48000) {
return kInvalidSampleRate;
}
max_extrapolation_samples_ = 7 * fs_hz / 100;
diff --git a/modules/audio_coding/neteq/dtmf_buffer.h b/modules/audio_coding/neteq/dtmf_buffer.h
index 87a5655..1035e87 100644
--- a/modules/audio_coding/neteq/dtmf_buffer.h
+++ b/modules/audio_coding/neteq/dtmf_buffer.h
@@ -28,19 +28,9 @@
// Constructors
DtmfEvent()
- : timestamp(0),
- event_no(0),
- volume(0),
- duration(0),
- end_bit(false) {
- }
+ : timestamp(0), event_no(0), volume(0), duration(0), end_bit(false) {}
DtmfEvent(uint32_t ts, int ev, int vol, int dur, bool end)
- : timestamp(ts),
- event_no(ev),
- volume(vol),
- duration(dur),
- end_bit(end) {
- }
+ : timestamp(ts), event_no(ev), volume(vol), duration(dur), end_bit(end) {}
};
// This is the buffer holding DTMF events while waiting for them to be played.
diff --git a/modules/audio_coding/neteq/dtmf_buffer_unittest.cc b/modules/audio_coding/neteq/dtmf_buffer_unittest.cc
index 7bcf1e0..607a5ec 100644
--- a/modules/audio_coding/neteq/dtmf_buffer_unittest.cc
+++ b/modules/audio_coding/neteq/dtmf_buffer_unittest.cc
@@ -31,11 +31,11 @@
static uint32_t MakeDtmfPayload(int event, bool end, int volume, int duration) {
uint32_t payload = 0;
-// 0 1 2 3
-// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-// | event |E|R| volume | duration |
-// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // 0 1 2 3
+ // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // | event |E|R| volume | duration |
+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
payload |= (event & 0x00FF) << 24;
payload |= (end ? 0x00800000 : 0x00000000);
payload |= (volume & 0x003F) << 16;
@@ -44,13 +44,10 @@
return payload;
}
-static bool EqualEvents(const DtmfEvent& a,
- const DtmfEvent& b) {
- return (a.duration == b.duration
- && a.end_bit == b.end_bit
- && a.event_no == b.event_no
- && a.timestamp == b.timestamp
- && a.volume == b.volume);
+static bool EqualEvents(const DtmfEvent& a, const DtmfEvent& b) {
+ return (a.duration == b.duration && a.end_bit == b.end_bit &&
+ a.event_no == b.event_no && a.timestamp == b.timestamp &&
+ a.volume == b.volume);
}
TEST(DtmfBuffer, CreateAndDestroy) {
@@ -68,9 +65,8 @@
uint32_t payload = MakeDtmfPayload(event_no, end_bit, volume, duration);
uint8_t* payload_ptr = reinterpret_cast<uint8_t*>(&payload);
DtmfEvent event;
- EXPECT_EQ(DtmfBuffer::kOK,
- DtmfBuffer::ParseEvent(timestamp, payload_ptr, sizeof(payload),
- &event));
+ EXPECT_EQ(DtmfBuffer::kOK, DtmfBuffer::ParseEvent(timestamp, payload_ptr,
+ sizeof(payload), &event));
EXPECT_EQ(duration, event.duration);
EXPECT_EQ(end_bit, event.end_bit);
EXPECT_EQ(event_no, event.event_no);
@@ -107,7 +103,7 @@
EXPECT_TRUE(EqualEvents(event, out_event));
EXPECT_EQ(1u, buffer.Length());
EXPECT_FALSE(buffer.Empty());
- // Give a "current" timestamp after the event has ended.
+// Give a "current" timestamp after the event has ended.
#ifdef LEGACY_BITEXACT
EXPECT_TRUE(buffer.GetEvent(timestamp + duration + 10, &out_event));
#endif
@@ -171,17 +167,17 @@
// Expect to get the long event.
EXPECT_TRUE(buffer.GetEvent(timestamp, &out_event));
EXPECT_TRUE(EqualEvents(long_event, out_event));
- // Expect no more events.
+// Expect no more events.
#ifdef LEGACY_BITEXACT
- EXPECT_TRUE(buffer.GetEvent(timestamp + long_event.duration + 10,
- &out_event));
+ EXPECT_TRUE(
+ buffer.GetEvent(timestamp + long_event.duration + 10, &out_event));
EXPECT_TRUE(EqualEvents(long_event, out_event));
- EXPECT_TRUE(buffer.GetEvent(timestamp + long_event.duration + 10,
- &out_event));
+ EXPECT_TRUE(
+ buffer.GetEvent(timestamp + long_event.duration + 10, &out_event));
EXPECT_TRUE(EqualEvents(short_event, out_event));
#else
- EXPECT_FALSE(buffer.GetEvent(timestamp + long_event.duration + 10,
- &out_event));
+ EXPECT_FALSE(
+ buffer.GetEvent(timestamp + long_event.duration + 10, &out_event));
#endif
EXPECT_TRUE(buffer.Empty());
}
diff --git a/modules/audio_coding/neteq/dtmf_tone_generator.cc b/modules/audio_coding/neteq/dtmf_tone_generator.cc
index b848c60..6fdb95a 100644
--- a/modules/audio_coding/neteq/dtmf_tone_generator.cc
+++ b/modules/audio_coding/neteq/dtmf_tone_generator.cc
@@ -39,72 +39,69 @@
// sample rates fs = {8000, 16000, 32000, 48000} Hz, and events 0 through 15.
// Values are in Q14.
const int DtmfToneGenerator::kCoeff1[4][16] = {
- { 24219, 27980, 27980, 27980, 26956, 26956, 26956, 25701, 25701, 25701,
- 24219, 24219, 27980, 26956, 25701, 24219 },
- { 30556, 31548, 31548, 31548, 31281, 31281, 31281, 30951, 30951, 30951,
- 30556, 30556, 31548, 31281, 30951, 30556 },
- { 32210, 32462, 32462, 32462, 32394, 32394, 32394, 32311, 32311, 32311,
- 32210, 32210, 32462, 32394, 32311, 32210 },
- { 32520, 32632, 32632, 32632, 32602, 32602, 32602, 32564, 32564, 32564,
- 32520, 32520, 32632, 32602, 32564, 32520 } };
+ {24219, 27980, 27980, 27980, 26956, 26956, 26956, 25701, 25701, 25701,
+ 24219, 24219, 27980, 26956, 25701, 24219},
+ {30556, 31548, 31548, 31548, 31281, 31281, 31281, 30951, 30951, 30951,
+ 30556, 30556, 31548, 31281, 30951, 30556},
+ {32210, 32462, 32462, 32462, 32394, 32394, 32394, 32311, 32311, 32311,
+ 32210, 32210, 32462, 32394, 32311, 32210},
+ {32520, 32632, 32632, 32632, 32602, 32602, 32602, 32564, 32564, 32564,
+ 32520, 32520, 32632, 32602, 32564, 32520}};
// The filter coefficient a = 2*cos(2*pi*f/fs) for the high frequency tone, for
// sample rates fs = {8000, 16000, 32000, 48000} Hz, and events 0 through 15.
// Values are in Q14.
const int DtmfToneGenerator::kCoeff2[4][16] = {
- { 16325, 19073, 16325, 13085, 19073, 16325, 13085, 19073, 16325, 13085,
- 19073, 13085, 9315, 9315, 9315, 9315},
- { 28361, 29144, 28361, 27409, 29144, 28361, 27409, 29144, 28361, 27409,
- 29144, 27409, 26258, 26258, 26258, 26258},
- { 31647, 31849, 31647, 31400, 31849, 31647, 31400, 31849, 31647, 31400,
- 31849, 31400, 31098, 31098, 31098, 31098},
- { 32268, 32359, 32268, 32157, 32359, 32268, 32157, 32359, 32268, 32157,
- 32359, 32157, 32022, 32022, 32022, 32022} };
+ {16325, 19073, 16325, 13085, 19073, 16325, 13085, 19073, 16325, 13085,
+ 19073, 13085, 9315, 9315, 9315, 9315},
+ {28361, 29144, 28361, 27409, 29144, 28361, 27409, 29144, 28361, 27409,
+ 29144, 27409, 26258, 26258, 26258, 26258},
+ {31647, 31849, 31647, 31400, 31849, 31647, 31400, 31849, 31647, 31400,
+ 31849, 31400, 31098, 31098, 31098, 31098},
+ {32268, 32359, 32268, 32157, 32359, 32268, 32157, 32359, 32268, 32157,
+ 32359, 32157, 32022, 32022, 32022, 32022}};
// The initialization value x[-2] = sin(2*pi*f/fs) for the low frequency tone,
// for sample rates fs = {8000, 16000, 32000, 48000} Hz, and events 0-15.
// Values are in Q14.
const int DtmfToneGenerator::kInitValue1[4][16] = {
- { 11036, 8528, 8528, 8528, 9315, 9315, 9315, 10163, 10163, 10163, 11036,
- 11036, 8528, 9315, 10163, 11036},
- { 5918, 4429, 4429, 4429, 4879, 4879, 4879, 5380, 5380, 5380, 5918, 5918,
- 4429, 4879, 5380, 5918},
- { 3010, 2235, 2235, 2235, 2468, 2468, 2468, 2728, 2728, 2728, 3010, 3010,
- 2235, 2468, 2728, 3010},
- { 2013, 1493, 1493, 1493, 1649, 1649, 1649, 1823, 1823, 1823, 2013, 2013,
- 1493, 1649, 1823, 2013 } };
+ {11036, 8528, 8528, 8528, 9315, 9315, 9315, 10163, 10163, 10163, 11036,
+ 11036, 8528, 9315, 10163, 11036},
+ {5918, 4429, 4429, 4429, 4879, 4879, 4879, 5380, 5380, 5380, 5918, 5918,
+ 4429, 4879, 5380, 5918},
+ {3010, 2235, 2235, 2235, 2468, 2468, 2468, 2728, 2728, 2728, 3010, 3010,
+ 2235, 2468, 2728, 3010},
+ {2013, 1493, 1493, 1493, 1649, 1649, 1649, 1823, 1823, 1823, 2013, 2013,
+ 1493, 1649, 1823, 2013}};
// The initialization value x[-2] = sin(2*pi*f/fs) for the high frequency tone,
// for sample rates fs = {8000, 16000, 32000, 48000} Hz, and events 0-15.
// Values are in Q14.
const int DtmfToneGenerator::kInitValue2[4][16] = {
- { 14206, 13323, 14206, 15021, 13323, 14206, 15021, 13323, 14206, 15021,
- 13323, 15021, 15708, 15708, 15708, 15708},
- { 8207, 7490, 8207, 8979, 7490, 8207, 8979, 7490, 8207, 8979, 7490, 8979,
- 9801, 9801, 9801, 9801},
- { 4249, 3853, 4249, 4685, 3853, 4249, 4685, 3853, 4249, 4685, 3853, 4685,
- 5164, 5164, 5164, 5164},
- { 2851, 2582, 2851, 3148, 2582, 2851, 3148, 2582, 2851, 3148, 2582, 3148,
- 3476, 3476, 3476, 3476} };
+ {14206, 13323, 14206, 15021, 13323, 14206, 15021, 13323, 14206, 15021,
+ 13323, 15021, 15708, 15708, 15708, 15708},
+ {8207, 7490, 8207, 8979, 7490, 8207, 8979, 7490, 8207, 8979, 7490, 8979,
+ 9801, 9801, 9801, 9801},
+ {4249, 3853, 4249, 4685, 3853, 4249, 4685, 3853, 4249, 4685, 3853, 4685,
+ 5164, 5164, 5164, 5164},
+ {2851, 2582, 2851, 3148, 2582, 2851, 3148, 2582, 2851, 3148, 2582, 3148,
+ 3476, 3476, 3476, 3476}};
// Amplitude multipliers for volume values 0 through 63, corresponding to
// 0 dBm0 through -63 dBm0. Values are in Q14.
// for a in range(0, 64):
// print round(16141.0 * 10**(-float(a)/20))
const int DtmfToneGenerator::kAmplitude[64] = {
- 16141, 14386, 12821, 11427, 10184, 9077, 8090, 7210, 6426, 5727, 5104, 4549,
- 4054, 3614, 3221, 2870, 2558, 2280, 2032, 1811, 1614, 1439, 1282, 1143,
- 1018, 908, 809, 721, 643, 573, 510, 455, 405, 361, 322, 287, 256, 228, 203,
- 181, 161, 144, 128, 114, 102, 91, 81, 72, 64, 57, 51, 45, 41, 36, 32, 29,
- 26, 23, 20, 18, 16, 14, 13, 11 };
+ 16141, 14386, 12821, 11427, 10184, 9077, 8090, 7210, 6426, 5727, 5104,
+ 4549, 4054, 3614, 3221, 2870, 2558, 2280, 2032, 1811, 1614, 1439,
+ 1282, 1143, 1018, 908, 809, 721, 643, 573, 510, 455, 405,
+ 361, 322, 287, 256, 228, 203, 181, 161, 144, 128, 114,
+ 102, 91, 81, 72, 64, 57, 51, 45, 41, 36, 32,
+ 29, 26, 23, 20, 18, 16, 14, 13, 11};
// Constructor.
DtmfToneGenerator::DtmfToneGenerator()
- : initialized_(false),
- coeff1_(0),
- coeff2_(0),
- amplitude_(0) {
-}
+ : initialized_(false), coeff1_(0), coeff2_(0), amplitude_(0) {}
// Initialize the DTMF generator with sample rate fs Hz (8000, 16000, 32000,
// 48000), event (0-15) and attenuation (0-36 dB).
@@ -170,8 +167,7 @@
}
// Generate num_samples of DTMF signal and write to |output|.
-int DtmfToneGenerator::Generate(size_t num_samples,
- AudioMultiVector* output) {
+int DtmfToneGenerator::Generate(size_t num_samples, AudioMultiVector* output) {
if (!initialized_) {
return kNotInitialized;
}
@@ -183,10 +179,10 @@
output->AssertSize(num_samples);
for (size_t i = 0; i < num_samples; ++i) {
// Use recursion formula y[n] = a * y[n - 1] - y[n - 2].
- int16_t temp_val_low = ((coeff1_ * sample_history1_[1] + 8192) >> 14)
- - sample_history1_[0];
- int16_t temp_val_high = ((coeff2_ * sample_history2_[1] + 8192) >> 14)
- - sample_history2_[0];
+ int16_t temp_val_low =
+ ((coeff1_ * sample_history1_[1] + 8192) >> 14) - sample_history1_[0];
+ int16_t temp_val_high =
+ ((coeff2_ * sample_history2_[1] + 8192) >> 14) - sample_history2_[0];
// Update recursion memory.
sample_history1_[0] = sample_history1_[1];
diff --git a/modules/audio_coding/neteq/dtmf_tone_generator.h b/modules/audio_coding/neteq/dtmf_tone_generator.h
index faad6a2..b91d221 100644
--- a/modules/audio_coding/neteq/dtmf_tone_generator.h
+++ b/modules/audio_coding/neteq/dtmf_tone_generator.h
@@ -37,7 +37,7 @@
static const int kCoeff2[4][16]; // 2nd oscillator model coefficient table.
static const int kInitValue1[4][16]; // Initialization for 1st oscillator.
static const int kInitValue2[4][16]; // Initialization for 2nd oscillator.
- static const int kAmplitude[64]; // Amplitude for 0 through -63 dBm0.
+ static const int kAmplitude[64]; // Amplitude for 0 through -63 dBm0.
static const int16_t kAmpMultiplier = 23171; // 3 dB attenuation (in Q15).
bool initialized_; // True if generator is initialized properly.
diff --git a/modules/audio_coding/neteq/dtmf_tone_generator_unittest.cc b/modules/audio_coding/neteq/dtmf_tone_generator_unittest.cc
index 8c22fe5..11a0ac6 100644
--- a/modules/audio_coding/neteq/dtmf_tone_generator_unittest.cc
+++ b/modules/audio_coding/neteq/dtmf_tone_generator_unittest.cc
@@ -84,8 +84,7 @@
// Verify that the attenuation is correct.
for (int channel = 0; channel < channels; ++channel) {
EXPECT_NEAR(attenuation_factor * ref_signal[channel][n],
- signal[channel][n],
- 2);
+ signal[channel][n], 2);
}
}
diff --git a/modules/audio_coding/neteq/expand.cc b/modules/audio_coding/neteq/expand.cc
index 73e8d07..5f671ad 100644
--- a/modules/audio_coding/neteq/expand.cc
+++ b/modules/audio_coding/neteq/expand.cc
@@ -14,7 +14,7 @@
#include <string.h> // memset
#include <algorithm> // min, max
-#include <limits> // numeric_limits<T>
+#include <limits> // numeric_limits<T>
#include "common_audio/signal_processing/include/signal_processing_library.h"
#include "modules/audio_coding/neteq/background_noise.h"
@@ -94,7 +94,6 @@
GenerateRandomVector(2, rand_length, random_vector);
}
-
// Generate signal.
UpdateLagIndex();
@@ -103,8 +102,8 @@
size_t expansion_vector_length = max_lag_ + overlap_length_;
size_t current_lag = expand_lags_[current_lag_index_];
// Copy lag+overlap data.
- size_t expansion_vector_position = expansion_vector_length - current_lag -
- overlap_length_;
+ size_t expansion_vector_position =
+ expansion_vector_length - current_lag - overlap_length_;
size_t temp_length = current_lag + overlap_length_;
for (size_t channel_ix = 0; channel_ix < num_channels_; ++channel_ix) {
ChannelParameters& parameters = channel_parameters_[channel_ix];
@@ -175,8 +174,10 @@
// Do overlap add between new vector and overlap.
(*sync_buffer_)[channel_ix][start_ix + i] =
(((*sync_buffer_)[channel_ix][start_ix + i] * muting_window) +
- (((parameters.mute_factor * voiced_vector_storage[i]) >> 14) *
- unmuting_window) + 16384) >> 15;
+ (((parameters.mute_factor * voiced_vector_storage[i]) >> 14) *
+ unmuting_window) +
+ 16384) >>
+ 15;
muting_window += muting_window_increment;
unmuting_window += unmuting_window_increment;
}
@@ -188,10 +189,10 @@
// parameters.expand_vector0 and parameters.expand_vector1 no longer
// match with expand_lags_, causing invalid reads and writes. Is it a good
// idea to enable this again, and solve the vector size problem?
-// max_lag_ = fs_mult * 120;
-// expand_lags_[0] = fs_mult * 120;
-// expand_lags_[1] = fs_mult * 120;
-// expand_lags_[2] = fs_mult * 120;
+ // max_lag_ = fs_mult * 120;
+ // expand_lags_[0] = fs_mult * 120;
+ // expand_lags_[1] = fs_mult * 120;
+ // expand_lags_[2] = fs_mult * 120;
}
// Unvoiced part.
@@ -204,8 +205,7 @@
}
WebRtcSpl_AffineTransformVector(scaled_random_vector, random_vector,
parameters.ar_gain, add_constant,
- parameters.ar_gain_scale,
- current_lag);
+ parameters.ar_gain_scale, current_lag);
WebRtcSpl_FilterARFastQ12(scaled_random_vector, unvoiced_vector,
parameters.ar_filter, kUnvoicedLpcOrder + 1,
current_lag);
@@ -230,8 +230,9 @@
// Create combined signal by shifting in more and more of unvoiced part.
temp_shift = 8 - temp_shift; // = getbits(mix_factor_increment).
- size_t temp_length = (parameters.current_voice_mix_factor -
- parameters.voice_mix_factor) >> temp_shift;
+ size_t temp_length =
+ (parameters.current_voice_mix_factor - parameters.voice_mix_factor) >>
+ temp_shift;
temp_length = std::min(temp_length, current_lag);
DspHelper::CrossFade(voiced_vector, unvoiced_vector, temp_length,
¶meters.current_voice_mix_factor,
@@ -266,9 +267,8 @@
// Mute segment according to slope value.
if ((consecutive_expands_ != 0) || !parameters.onset) {
// Mute to the previous level, then continue with the muting.
- WebRtcSpl_AffineTransformVector(temp_data, temp_data,
- parameters.mute_factor, 8192,
- 14, current_lag);
+ WebRtcSpl_AffineTransformVector(
+ temp_data, temp_data, parameters.mute_factor, 8192, 14, current_lag);
if (!stop_muting_) {
DspHelper::MuteSignal(temp_data, parameters.mute_slope, current_lag);
@@ -276,8 +276,8 @@
// Shift by 6 to go from Q20 to Q14.
// TODO(hlundin): Adding 8192 before shifting 6 steps seems wrong.
// Legacy.
- int16_t gain = static_cast<int16_t>(16384 -
- (((current_lag * parameters.mute_slope) + 8192) >> 6));
+ int16_t gain = static_cast<int16_t>(
+ 16384 - (((current_lag * parameters.mute_slope) + 8192) >> 6));
gain = ((gain * parameters.mute_factor) + 8192) >> 14;
// Guard against getting stuck with very small (but sometimes audible)
@@ -291,12 +291,9 @@
}
// Background noise part.
- GenerateBackgroundNoise(random_vector,
- channel_ix,
- channel_parameters_[channel_ix].mute_slope,
- TooManyExpands(),
- current_lag,
- unvoiced_array_memory);
+ GenerateBackgroundNoise(
+ random_vector, channel_ix, channel_parameters_[channel_ix].mute_slope,
+ TooManyExpands(), current_lag, unvoiced_array_memory);
// Add background noise to the combined voiced-unvoiced signal.
for (size_t i = 0; i < current_lag; i++) {
@@ -311,8 +308,9 @@
}
// Increase call number and cap it.
- consecutive_expands_ = consecutive_expands_ >= kMaxConsecutiveExpands ?
- kMaxConsecutiveExpands : consecutive_expands_ + 1;
+ consecutive_expands_ = consecutive_expands_ >= kMaxConsecutiveExpands
+ ? kMaxConsecutiveExpands
+ : consecutive_expands_ + 1;
expand_duration_samples_ += output->Size();
// Clamp the duration counter at 2 seconds.
expand_duration_samples_ = std::min(expand_duration_samples_,
@@ -329,7 +327,7 @@
}
void Expand::SetParametersForMergeAfterExpand() {
- current_lag_index_ = -1; /* out of the 3 possible ones */
+ current_lag_index_ = -1; /* out of the 3 possible ones */
lag_index_direction_ = 1; /* make sure we get the "optimal" lag */
stop_muting_ = true;
}
@@ -357,7 +355,7 @@
consecutive_expands_ = 0;
for (size_t ix = 0; ix < num_channels_; ++ix) {
channel_parameters_[ix].current_voice_mix_factor = 16384; // 1.0 in Q14.
- channel_parameters_[ix].mute_factor = 16384; // 1.0 in Q14.
+ channel_parameters_[ix].mute_factor = 16384; // 1.0 in Q14.
// Start with 0 gain for background noise.
background_noise_->SetMuteFactor(ix, 0);
}
@@ -420,10 +418,10 @@
// Calculate distortion around the |kNumCorrelationCandidates| best lags.
int distortion_scale = 0;
for (size_t i = 0; i < kNumCorrelationCandidates; i++) {
- size_t min_index = std::max(fs_mult_20,
- best_correlation_index[i] - fs_mult_4);
- size_t max_index = std::min(fs_mult_120 - 1,
- best_correlation_index[i] + fs_mult_4);
+ size_t min_index =
+ std::max(fs_mult_20, best_correlation_index[i] - fs_mult_4);
+ size_t max_index =
+ std::min(fs_mult_120 - 1, best_correlation_index[i] + fs_mult_4);
best_distortion_index[i] = DspHelper::MinDistortion(
&(audio_history[signal_length - fs_mult_dist_len]), min_index,
max_index, fs_mult_dist_len, &best_distortion_w32[i]);
@@ -459,23 +457,23 @@
// Calculate the exact best correlation in the range between
// |correlation_lag| and |distortion_lag|.
- correlation_length =
- std::max(std::min(distortion_lag + 10, fs_mult_120),
- static_cast<size_t>(60 * fs_mult));
+ correlation_length = std::max(std::min(distortion_lag + 10, fs_mult_120),
+ static_cast<size_t>(60 * fs_mult));
size_t start_index = std::min(distortion_lag, correlation_lag);
size_t correlation_lags = static_cast<size_t>(
- WEBRTC_SPL_ABS_W16((distortion_lag-correlation_lag)) + 1);
+ WEBRTC_SPL_ABS_W16((distortion_lag - correlation_lag)) + 1);
assert(correlation_lags <= static_cast<size_t>(99 * fs_mult + 1));
for (size_t channel_ix = 0; channel_ix < num_channels_; ++channel_ix) {
ChannelParameters& parameters = channel_parameters_[channel_ix];
// Calculate suitable scaling.
int16_t signal_max = WebRtcSpl_MaxAbsValueW16(
- &audio_history[signal_length - correlation_length - start_index
- - correlation_lags],
- correlation_length + start_index + correlation_lags - 1);
- int correlation_scale = (31 - WebRtcSpl_NormW32(signal_max * signal_max)) +
+ &audio_history[signal_length - correlation_length - start_index -
+ correlation_lags],
+ correlation_length + start_index + correlation_lags - 1);
+ int correlation_scale =
+ (31 - WebRtcSpl_NormW32(signal_max * signal_max)) +
(31 - WebRtcSpl_NormW32(static_cast<int32_t>(correlation_length))) - 31;
correlation_scale = std::max(0, correlation_scale);
@@ -520,8 +518,8 @@
// Calculate max_correlation / sqrt(energy1 * energy2) in Q14.
int cc_shift = 14 - (energy1_scale + energy2_scale) / 2;
max_correlation = WEBRTC_SPL_SHIFT_W32(max_correlation, cc_shift);
- corr_coefficient = WebRtcSpl_DivW32W16(max_correlation,
- sqrt_energy_product);
+ corr_coefficient =
+ WebRtcSpl_DivW32W16(max_correlation, sqrt_energy_product);
// Cap at 1.0 in Q14.
corr_coefficient = std::min(16384, corr_coefficient);
} else {
@@ -547,9 +545,9 @@
int32_t scaled_energy2 = std::max(16 - WebRtcSpl_NormW32(energy2), 0);
int32_t scaled_energy1 = scaled_energy2 - 13;
// Calculate scaled_energy1 / scaled_energy2 in Q13.
- int32_t energy_ratio = WebRtcSpl_DivW32W16(
- WEBRTC_SPL_SHIFT_W32(energy1, -scaled_energy1),
- static_cast<int16_t>(energy2 >> scaled_energy2));
+ int32_t energy_ratio =
+ WebRtcSpl_DivW32W16(WEBRTC_SPL_SHIFT_W32(energy1, -scaled_energy1),
+ static_cast<int16_t>(energy2 >> scaled_energy2));
// Calculate sqrt ratio in Q13 (sqrt of en1/en2 in Q26).
amplitude_ratio =
static_cast<int16_t>(WebRtcSpl_SqrtFloor(energy_ratio << 13));
@@ -558,16 +556,13 @@
parameters.expand_vector0.PushBack(vector1, expansion_length);
parameters.expand_vector1.Clear();
if (parameters.expand_vector1.Size() < expansion_length) {
- parameters.expand_vector1.Extend(
- expansion_length - parameters.expand_vector1.Size());
+ parameters.expand_vector1.Extend(expansion_length -
+ parameters.expand_vector1.Size());
}
std::unique_ptr<int16_t[]> temp_1(new int16_t[expansion_length]);
- WebRtcSpl_AffineTransformVector(temp_1.get(),
- const_cast<int16_t*>(vector2),
- amplitude_ratio,
- 4096,
- 13,
- expansion_length);
+ WebRtcSpl_AffineTransformVector(
+ temp_1.get(), const_cast<int16_t*>(vector2), amplitude_ratio, 4096,
+ 13, expansion_length);
parameters.expand_vector1.OverwriteAt(temp_1.get(), expansion_length, 0);
} else {
// Energy change constraint not fulfilled. Only use last vector.
@@ -606,11 +601,11 @@
// Calculate the LPC and the gain of the filters.
// Calculate kUnvoicedLpcOrder + 1 lags of the auto-correlation function.
- size_t temp_index = signal_length - fs_mult_lpc_analysis_len -
- kUnvoicedLpcOrder;
+ size_t temp_index =
+ signal_length - fs_mult_lpc_analysis_len - kUnvoicedLpcOrder;
// Copy signal to temporary vector to be able to pad with leading zeros.
- int16_t* temp_signal = new int16_t[fs_mult_lpc_analysis_len
- + kUnvoicedLpcOrder];
+ int16_t* temp_signal =
+ new int16_t[fs_mult_lpc_analysis_len + kUnvoicedLpcOrder];
memset(temp_signal, 0,
sizeof(int16_t) * (fs_mult_lpc_analysis_len + kUnvoicedLpcOrder));
memcpy(&temp_signal[kUnvoicedLpcOrder],
@@ -619,16 +614,15 @@
CrossCorrelationWithAutoShift(
&temp_signal[kUnvoicedLpcOrder], &temp_signal[kUnvoicedLpcOrder],
fs_mult_lpc_analysis_len, kUnvoicedLpcOrder + 1, -1, auto_correlation);
- delete [] temp_signal;
+ delete[] temp_signal;
// Verify that variance is positive.
if (auto_correlation[0] > 0) {
// Estimate AR filter parameters using Levinson-Durbin algorithm;
// kUnvoicedLpcOrder + 1 filter coefficients.
- int16_t stability = WebRtcSpl_LevinsonDurbin(auto_correlation,
- parameters.ar_filter,
- reflection_coeff,
- kUnvoicedLpcOrder);
+ int16_t stability =
+ WebRtcSpl_LevinsonDurbin(auto_correlation, parameters.ar_filter,
+ reflection_coeff, kUnvoicedLpcOrder);
// Keep filter parameters only if filter is stable.
if (stability != 1) {
@@ -671,10 +665,8 @@
&(audio_history[signal_length - 128 - kUnvoicedLpcOrder]),
sizeof(int16_t) * kUnvoicedLpcOrder);
WebRtcSpl_FilterMAFastQ12(&audio_history[signal_length - 128],
- unvoiced_vector,
- parameters.ar_filter,
- kUnvoicedLpcOrder + 1,
- 128);
+ unvoiced_vector, parameters.ar_filter,
+ kUnvoicedLpcOrder + 1, 128);
const int unvoiced_max_abs = [&] {
const int16_t max_abs = WebRtcSpl_MaxAbsValueW16(unvoiced_vector, 128);
// Since WebRtcSpl_MaxAbsValueW16 returns 2^15 - 1 when the input contains
@@ -689,10 +681,8 @@
int unvoiced_prescale =
std::max(0, 2 * WebRtcSpl_GetSizeInBits(unvoiced_max_abs) - 24);
- int32_t unvoiced_energy = WebRtcSpl_DotProductWithScale(unvoiced_vector,
- unvoiced_vector,
- 128,
- unvoiced_prescale);
+ int32_t unvoiced_energy = WebRtcSpl_DotProductWithScale(
+ unvoiced_vector, unvoiced_vector, 128, unvoiced_prescale);
// Normalize |unvoiced_energy| to 28 or 29 bits to preserve sqrt() accuracy.
int16_t unvoiced_scale = WebRtcSpl_NormW32(unvoiced_energy) - 3;
@@ -703,8 +693,8 @@
unvoiced_energy = WEBRTC_SPL_SHIFT_W32(unvoiced_energy, unvoiced_scale);
int16_t unvoiced_gain =
static_cast<int16_t>(WebRtcSpl_SqrtFloor(unvoiced_energy));
- parameters.ar_gain_scale = 13
- + (unvoiced_scale + 7 - unvoiced_prescale) / 2;
+ parameters.ar_gain_scale =
+ 13 + (unvoiced_scale + 7 - unvoiced_prescale) / 2;
parameters.ar_gain = unvoiced_gain;
// Calculate voice_mix_factor from corr_coefficient.
@@ -717,17 +707,17 @@
int16_t x1, x2, x3;
// |corr_coefficient| is in Q14.
x1 = static_cast<int16_t>(corr_coefficient);
- x2 = (x1 * x1) >> 14; // Shift 14 to keep result in Q14.
+ x2 = (x1 * x1) >> 14; // Shift 14 to keep result in Q14.
x3 = (x1 * x2) >> 14;
- static const int kCoefficients[4] = { -5179, 19931, -16422, 5776 };
+ static const int kCoefficients[4] = {-5179, 19931, -16422, 5776};
int32_t temp_sum = kCoefficients[0] * 16384;
temp_sum += kCoefficients[1] * x1;
temp_sum += kCoefficients[2] * x2;
temp_sum += kCoefficients[3] * x3;
parameters.voice_mix_factor =
static_cast<int16_t>(std::min(temp_sum / 4096, 16384));
- parameters.voice_mix_factor = std::max(parameters.voice_mix_factor,
- static_cast<int16_t>(0));
+ parameters.voice_mix_factor =
+ std::max(parameters.voice_mix_factor, static_cast<int16_t>(0));
} else {
parameters.voice_mix_factor = 0;
}
@@ -816,8 +806,8 @@
static const size_t kNumCorrelationLags = 54;
static const size_t kCorrelationLength = 60;
// Downsample to 4 kHz sample rate.
- static const size_t kDownsampledLength = kCorrelationStartLag
- + kNumCorrelationLags + kCorrelationLength;
+ static const size_t kDownsampledLength =
+ kCorrelationStartLag + kNumCorrelationLags + kCorrelationLength;
int16_t downsampled_input[kDownsampledLength];
static const size_t kFilterDelay = 0;
WebRtcSpl_DownsampleFast(
@@ -827,8 +817,8 @@
downsampling_factor, kFilterDelay);
// Normalize |downsampled_input| to using all 16 bits.
- int16_t max_value = WebRtcSpl_MaxAbsValueW16(downsampled_input,
- kDownsampledLength);
+ int16_t max_value =
+ WebRtcSpl_MaxAbsValueW16(downsampled_input, kDownsampledLength);
int16_t norm_shift = 16 - WebRtcSpl_NormW32(max_value);
WebRtcSpl_VectorBitShiftW16(downsampled_input, kDownsampledLength,
downsampled_input, norm_shift);
@@ -836,13 +826,13 @@
int32_t correlation[kNumCorrelationLags];
CrossCorrelationWithAutoShift(
&downsampled_input[kDownsampledLength - kCorrelationLength],
- &downsampled_input[kDownsampledLength - kCorrelationLength
- - kCorrelationStartLag],
+ &downsampled_input[kDownsampledLength - kCorrelationLength -
+ kCorrelationStartLag],
kCorrelationLength, kNumCorrelationLags, -1, correlation);
// Normalize and move data from 32-bit to 16-bit vector.
- int32_t max_correlation = WebRtcSpl_MaxAbsValueW32(correlation,
- kNumCorrelationLags);
+ int32_t max_correlation =
+ WebRtcSpl_MaxAbsValueW32(correlation, kNumCorrelationLags);
int16_t norm_shift2 = static_cast<int16_t>(
std::max(18 - WebRtcSpl_NormW32(max_correlation), 0));
WebRtcSpl_VectorBitShiftW32ToW16(output, kNumCorrelationLags, correlation,
@@ -894,19 +884,15 @@
// Scale random vector to correct energy level.
WebRtcSpl_AffineTransformVector(
- scaled_random_vector, random_vector,
- background_noise_->Scale(channel), dc_offset,
- background_noise_->ScaleShift(channel),
- num_noise_samples);
+ scaled_random_vector, random_vector, background_noise_->Scale(channel),
+ dc_offset, background_noise_->ScaleShift(channel), num_noise_samples);
WebRtcSpl_FilterARFastQ12(scaled_random_vector, noise_samples,
background_noise_->Filter(channel),
- kNoiseLpcOrder + 1,
- num_noise_samples);
+ kNoiseLpcOrder + 1, num_noise_samples);
background_noise_->SetFilterState(
- channel,
- &(noise_samples[num_noise_samples - kNoiseLpcOrder]),
+ channel, &(noise_samples[num_noise_samples - kNoiseLpcOrder]),
kNoiseLpcOrder);
// Unmute the background noise.
diff --git a/modules/audio_coding/neteq/expand.h b/modules/audio_coding/neteq/expand.h
index 4060bd7..2fd4fae 100644
--- a/modules/audio_coding/neteq/expand.h
+++ b/modules/audio_coding/neteq/expand.h
@@ -114,7 +114,7 @@
int16_t ar_filter_state[kUnvoicedLpcOrder];
int16_t ar_gain;
int16_t ar_gain_scale;
- int16_t voice_mix_factor; /* Q14 */
+ int16_t voice_mix_factor; /* Q14 */
int16_t current_voice_mix_factor; /* Q14 */
AudioVector expand_vector0;
AudioVector expand_vector1;
diff --git a/modules/audio_coding/neteq/include/neteq.h b/modules/audio_coding/neteq/include/neteq.h
index 6288aeb..273979b 100644
--- a/modules/audio_coding/neteq/include/neteq.h
+++ b/modules/audio_coding/neteq/include/neteq.h
@@ -33,25 +33,25 @@
class AudioDecoderFactory;
struct NetEqNetworkStatistics {
- uint16_t current_buffer_size_ms; // Current jitter buffer size in ms.
+ uint16_t current_buffer_size_ms; // Current jitter buffer size in ms.
uint16_t preferred_buffer_size_ms; // Target buffer size in ms.
- uint16_t jitter_peaks_found; // 1 if adding extra delay due to peaky
- // jitter; 0 otherwise.
- uint16_t packet_loss_rate; // Loss rate (network + late) in Q14.
- uint16_t expand_rate; // Fraction (of original stream) of synthesized
- // audio inserted through expansion (in Q14).
+ uint16_t jitter_peaks_found; // 1 if adding extra delay due to peaky
+ // jitter; 0 otherwise.
+ uint16_t packet_loss_rate; // Loss rate (network + late) in Q14.
+ uint16_t expand_rate; // Fraction (of original stream) of synthesized
+ // audio inserted through expansion (in Q14).
uint16_t speech_expand_rate; // Fraction (of original stream) of synthesized
// speech inserted through expansion (in Q14).
- uint16_t preemptive_rate; // Fraction of data inserted through pre-emptive
- // expansion (in Q14).
- uint16_t accelerate_rate; // Fraction of data removed through acceleration
- // (in Q14).
- uint16_t secondary_decoded_rate; // Fraction of data coming from FEC/RED
- // decoding (in Q14).
+ uint16_t preemptive_rate; // Fraction of data inserted through pre-emptive
+ // expansion (in Q14).
+ uint16_t accelerate_rate; // Fraction of data removed through acceleration
+ // (in Q14).
+ uint16_t secondary_decoded_rate; // Fraction of data coming from FEC/RED
+ // decoding (in Q14).
uint16_t secondary_discarded_rate; // Fraction of discarded FEC/RED data (in
// Q14).
- int32_t clockdrift_ppm; // Average clock-drift in parts-per-million
- // (positive or negative).
+ int32_t clockdrift_ppm; // Average clock-drift in parts-per-million
+ // (positive or negative).
size_t added_zero_samples; // Number of zero samples added in "off" mode.
// Statistics for packet waiting times, i.e., the time between a packet
// arrives until it is decoded.
@@ -104,11 +104,7 @@
absl::optional<AudioCodecPairId> codec_pair_id;
};
- enum ReturnCodes {
- kOK = 0,
- kFail = -1,
- kNotImplemented = -2
- };
+ enum ReturnCodes { kOK = 0, kFail = -1, kNotImplemented = -2 };
// Creates a new NetEq object, with parameters set in |config|. The |config|
// object will only have to be valid for the duration of the call to this
diff --git a/modules/audio_coding/neteq/merge.cc b/modules/audio_coding/neteq/merge.cc
index fb0bb0d..3c9ad19 100644
--- a/modules/audio_coding/neteq/merge.cc
+++ b/modules/audio_coding/neteq/merge.cc
@@ -43,10 +43,11 @@
Merge::~Merge() = default;
-size_t Merge::Process(int16_t* input, size_t input_length,
+size_t Merge::Process(int16_t* input,
+ size_t input_length,
AudioMultiVector* output) {
// TODO(hlundin): Change to an enumerator and skip assert.
- assert(fs_hz_ == 8000 || fs_hz_ == 16000 || fs_hz_ == 32000 ||
+ assert(fs_hz_ == 8000 || fs_hz_ == 16000 || fs_hz_ == 32000 ||
fs_hz_ == 48000);
assert(fs_hz_ <= kMaxSampleRate); // Should not be possible.
@@ -68,8 +69,8 @@
new int16_t[input_length_per_channel]);
std::unique_ptr<int16_t[]> expanded_channel(new int16_t[expanded_length]);
for (size_t channel = 0; channel < num_channels_; ++channel) {
- input_vector[channel].CopyTo(
- input_length_per_channel, 0, input_channel.get());
+ input_vector[channel].CopyTo(input_length_per_channel, 0,
+ input_channel.get());
expanded_[channel].CopyTo(expanded_length, 0, expanded_channel.get());
const int16_t new_mute_factor = std::min<int16_t>(
@@ -93,11 +94,11 @@
// Mute the new decoded data if needed (and unmute it linearly).
// This is the overlapping part of expanded_signal.
- size_t interpolation_length = std::min(
- kMaxCorrelationLength * fs_mult_,
- expanded_length - best_correlation_index);
- interpolation_length = std::min(interpolation_length,
- input_length_per_channel);
+ size_t interpolation_length =
+ std::min(kMaxCorrelationLength * fs_mult_,
+ expanded_length - best_correlation_index);
+ interpolation_length =
+ std::min(interpolation_length, input_length_per_channel);
RTC_DCHECK_LE(new_mute_factor, 16384);
int16_t mute_factor =
@@ -203,30 +204,28 @@
return required_length;
}
-int16_t Merge::SignalScaling(const int16_t* input, size_t input_length,
+int16_t Merge::SignalScaling(const int16_t* input,
+ size_t input_length,
const int16_t* expanded_signal) const {
// Adjust muting factor if new vector is more or less of the BGN energy.
const auto mod_input_length = rtc::SafeMin<size_t>(
64 * rtc::dchecked_cast<size_t>(fs_mult_), input_length);
const int16_t expanded_max =
WebRtcSpl_MaxAbsValueW16(expanded_signal, mod_input_length);
- int32_t factor = (expanded_max * expanded_max) /
- (std::numeric_limits<int32_t>::max() /
- static_cast<int32_t>(mod_input_length));
+ int32_t factor =
+ (expanded_max * expanded_max) / (std::numeric_limits<int32_t>::max() /
+ static_cast<int32_t>(mod_input_length));
const int expanded_shift = factor == 0 ? 0 : 31 - WebRtcSpl_NormW32(factor);
- int32_t energy_expanded = WebRtcSpl_DotProductWithScale(expanded_signal,
- expanded_signal,
- mod_input_length,
- expanded_shift);
+ int32_t energy_expanded = WebRtcSpl_DotProductWithScale(
+ expanded_signal, expanded_signal, mod_input_length, expanded_shift);
// Calculate energy of input signal.
const int16_t input_max = WebRtcSpl_MaxAbsValueW16(input, mod_input_length);
factor = (input_max * input_max) / (std::numeric_limits<int32_t>::max() /
- static_cast<int32_t>(mod_input_length));
+ static_cast<int32_t>(mod_input_length));
const int input_shift = factor == 0 ? 0 : 31 - WebRtcSpl_NormW32(factor);
- int32_t energy_input = WebRtcSpl_DotProductWithScale(input, input,
- mod_input_length,
- input_shift);
+ int32_t energy_input = WebRtcSpl_DotProductWithScale(
+ input, input, mod_input_length, input_shift);
// Align to the same Q-domain.
if (input_shift > expanded_shift) {
@@ -257,8 +256,10 @@
// TODO(hlundin): There are some parameter values in this method that seem
// strange. Compare with Expand::Correlation.
-void Merge::Downsample(const int16_t* input, size_t input_length,
- const int16_t* expanded_signal, size_t expanded_length) {
+void Merge::Downsample(const int16_t* input,
+ size_t input_length,
+ const int16_t* expanded_signal,
+ size_t expanded_length) {
const int16_t* filter_coefficients;
size_t num_coefficients;
int decimation_factor = fs_hz_ / 4000;
@@ -278,11 +279,10 @@
num_coefficients = 7;
}
size_t signal_offset = num_coefficients - 1;
- WebRtcSpl_DownsampleFast(&expanded_signal[signal_offset],
- expanded_length - signal_offset,
- expanded_downsampled_, kExpandDownsampLength,
- filter_coefficients, num_coefficients,
- decimation_factor, kCompensateDelay);
+ WebRtcSpl_DownsampleFast(
+ &expanded_signal[signal_offset], expanded_length - signal_offset,
+ expanded_downsampled_, kExpandDownsampLength, filter_coefficients,
+ num_coefficients, decimation_factor, kCompensateDelay);
if (input_length <= length_limit) {
// Not quite long enough, so we have to cheat a bit.
// If the input is really short, we'll just use the input length as is, and
@@ -301,15 +301,15 @@
memset(&input_downsampled_[downsamp_temp_len], 0,
sizeof(int16_t) * (kInputDownsampLength - downsamp_temp_len));
} else {
- WebRtcSpl_DownsampleFast(&input[signal_offset],
- input_length - signal_offset, input_downsampled_,
- kInputDownsampLength, filter_coefficients,
- num_coefficients, decimation_factor,
- kCompensateDelay);
+ WebRtcSpl_DownsampleFast(
+ &input[signal_offset], input_length - signal_offset, input_downsampled_,
+ kInputDownsampLength, filter_coefficients, num_coefficients,
+ decimation_factor, kCompensateDelay);
}
}
-size_t Merge::CorrelateAndPeakSearch(size_t start_position, size_t input_length,
+size_t Merge::CorrelateAndPeakSearch(size_t start_position,
+ size_t input_length,
size_t expand_period) const {
// Calculate correlation without any normalization.
const size_t max_corr_length = kMaxCorrelationLength;
@@ -328,8 +328,8 @@
new int16_t[correlation_buffer_size]);
memset(correlation16.get(), 0, correlation_buffer_size * sizeof(int16_t));
int16_t* correlation_ptr = &correlation16[pad_length];
- int32_t max_correlation = WebRtcSpl_MaxAbsValueW32(correlation,
- stop_position_downsamp);
+ int32_t max_correlation =
+ WebRtcSpl_MaxAbsValueW32(correlation, stop_position_downsamp);
int norm_shift = std::max(0, 17 - WebRtcSpl_NormW32(max_correlation));
WebRtcSpl_VectorBitShiftW32ToW16(correlation_ptr, stop_position_downsamp,
correlation, norm_shift);
@@ -366,7 +366,7 @@
while (((best_correlation_index + input_length) <
(timestamps_per_call_ + expand_->overlap_length())) ||
((best_correlation_index + input_length) < start_position)) {
- assert(false); // Should never happen.
+ assert(false); // Should never happen.
best_correlation_index += expand_period; // Jump one lag ahead.
}
return best_correlation_index;
@@ -376,5 +376,4 @@
return fs_hz_ / 100 * num_channels_; // 10 ms.
}
-
} // namespace webrtc
diff --git a/modules/audio_coding/neteq/merge.h b/modules/audio_coding/neteq/merge.h
index 6da0b4f..017e824 100644
--- a/modules/audio_coding/neteq/merge.h
+++ b/modules/audio_coding/neteq/merge.h
@@ -44,7 +44,8 @@
// (interleaved). The result is written to |output|. The number of channels
// allocated in |output| defines the number of channels that will be used when
// de-interleaving |input|.
- virtual size_t Process(int16_t* input, size_t input_length,
+ virtual size_t Process(int16_t* input,
+ size_t input_length,
AudioMultiVector* output);
virtual size_t RequiredFutureSamples();
@@ -68,19 +69,23 @@
// Analyzes |input| and |expanded_signal| and returns muting factor (Q14) to
// be used on the new data.
- int16_t SignalScaling(const int16_t* input, size_t input_length,
+ int16_t SignalScaling(const int16_t* input,
+ size_t input_length,
const int16_t* expanded_signal) const;
// Downsamples |input| (|input_length| samples) and |expanded_signal| to
// 4 kHz sample rate. The downsampled signals are written to
// |input_downsampled_| and |expanded_downsampled_|, respectively.
- void Downsample(const int16_t* input, size_t input_length,
- const int16_t* expanded_signal, size_t expanded_length);
+ void Downsample(const int16_t* input,
+ size_t input_length,
+ const int16_t* expanded_signal,
+ size_t expanded_length);
// Calculates cross-correlation between |input_downsampled_| and
// |expanded_downsampled_|, and finds the correlation maximum. The maximizing
// lag is returned.
- size_t CorrelateAndPeakSearch(size_t start_position, size_t input_length,
+ size_t CorrelateAndPeakSearch(size_t start_position,
+ size_t input_length,
size_t expand_period) const;
const int fs_mult_; // fs_hz_ / 8000.
diff --git a/modules/audio_coding/neteq/mock/mock_buffer_level_filter.h b/modules/audio_coding/neteq/mock/mock_buffer_level_filter.h
index f662fb6..bf9fd59 100644
--- a/modules/audio_coding/neteq/mock/mock_buffer_level_filter.h
+++ b/modules/audio_coding/neteq/mock/mock_buffer_level_filter.h
@@ -20,17 +20,14 @@
class MockBufferLevelFilter : public BufferLevelFilter {
public:
virtual ~MockBufferLevelFilter() { Die(); }
- MOCK_METHOD0(Die,
- void());
- MOCK_METHOD0(Reset,
- void());
+ MOCK_METHOD0(Die, void());
+ MOCK_METHOD0(Reset, void());
MOCK_METHOD3(Update,
- void(size_t buffer_size_packets, int time_stretched_samples,
- size_t packet_len_samples));
- MOCK_METHOD1(SetTargetBufferLevel,
- void(int target_buffer_level));
- MOCK_CONST_METHOD0(filtered_current_level,
- int());
+ void(size_t buffer_size_packets,
+ int time_stretched_samples,
+ size_t packet_len_samples));
+ MOCK_METHOD1(SetTargetBufferLevel, void(int target_buffer_level));
+ MOCK_CONST_METHOD0(filtered_current_level, int());
};
} // namespace webrtc
diff --git a/modules/audio_coding/neteq/mock/mock_decoder_database.h b/modules/audio_coding/neteq/mock/mock_decoder_database.h
index 3d57edd..b1d8151 100644
--- a/modules/audio_coding/neteq/mock/mock_decoder_database.h
+++ b/modules/audio_coding/neteq/mock/mock_decoder_database.h
@@ -26,15 +26,13 @@
: DecoderDatabase(factory, absl::nullopt) {}
virtual ~MockDecoderDatabase() { Die(); }
MOCK_METHOD0(Die, void());
- MOCK_CONST_METHOD0(Empty,
- bool());
- MOCK_CONST_METHOD0(Size,
- int());
- MOCK_METHOD0(Reset,
- void());
+ MOCK_CONST_METHOD0(Empty, bool());
+ MOCK_CONST_METHOD0(Size, int());
+ MOCK_METHOD0(Reset, void());
MOCK_METHOD3(RegisterPayload,
- int(uint8_t rtp_payload_type, NetEqDecoder codec_type,
- const std::string& name));
+ int(uint8_t rtp_payload_type,
+ NetEqDecoder codec_type,
+ const std::string& name));
MOCK_METHOD2(RegisterPayload,
int(int rtp_payload_type, const SdpAudioFormat& audio_format));
MOCK_METHOD4(InsertExternal,
@@ -42,19 +40,15 @@
NetEqDecoder codec_type,
const std::string& codec_name,
AudioDecoder* decoder));
- MOCK_METHOD1(Remove,
- int(uint8_t rtp_payload_type));
+ MOCK_METHOD1(Remove, int(uint8_t rtp_payload_type));
MOCK_METHOD0(RemoveAll, void());
MOCK_CONST_METHOD1(GetDecoderInfo,
- const DecoderInfo*(uint8_t rtp_payload_type));
+ const DecoderInfo*(uint8_t rtp_payload_type));
MOCK_METHOD2(SetActiveDecoder,
- int(uint8_t rtp_payload_type, bool* new_decoder));
- MOCK_CONST_METHOD0(GetActiveDecoder,
- AudioDecoder*());
- MOCK_METHOD1(SetActiveCngDecoder,
- int(uint8_t rtp_payload_type));
- MOCK_CONST_METHOD0(GetActiveCngDecoder,
- ComfortNoiseDecoder*());
+ int(uint8_t rtp_payload_type, bool* new_decoder));
+ MOCK_CONST_METHOD0(GetActiveDecoder, AudioDecoder*());
+ MOCK_METHOD1(SetActiveCngDecoder, int(uint8_t rtp_payload_type));
+ MOCK_CONST_METHOD0(GetActiveCngDecoder, ComfortNoiseDecoder*());
};
} // namespace webrtc
diff --git a/modules/audio_coding/neteq/mock/mock_delay_manager.h b/modules/audio_coding/neteq/mock/mock_delay_manager.h
index 61f209d..9b2ed49 100644
--- a/modules/audio_coding/neteq/mock/mock_delay_manager.h
+++ b/modules/audio_coding/neteq/mock/mock_delay_manager.h
@@ -25,37 +25,25 @@
: DelayManager(max_packets_in_buffer, peak_detector, tick_timer) {}
virtual ~MockDelayManager() { Die(); }
MOCK_METHOD0(Die, void());
- MOCK_CONST_METHOD0(iat_vector,
- const IATVector&());
+ MOCK_CONST_METHOD0(iat_vector, const IATVector&());
MOCK_METHOD3(Update,
- int(uint16_t sequence_number, uint32_t timestamp, int sample_rate_hz));
- MOCK_METHOD1(CalculateTargetLevel,
- int(int iat_packets));
- MOCK_METHOD1(SetPacketAudioLength,
- int(int length_ms));
- MOCK_METHOD0(Reset,
- void());
- MOCK_CONST_METHOD0(PeakFound,
- bool());
- MOCK_METHOD1(UpdateCounters,
- void(int elapsed_time_ms));
- MOCK_METHOD0(ResetPacketIatCount,
- void());
- MOCK_CONST_METHOD2(BufferLimits,
- void(int* lower_limit, int* higher_limit));
- MOCK_CONST_METHOD0(TargetLevel,
- int());
+ int(uint16_t sequence_number,
+ uint32_t timestamp,
+ int sample_rate_hz));
+ MOCK_METHOD1(CalculateTargetLevel, int(int iat_packets));
+ MOCK_METHOD1(SetPacketAudioLength, int(int length_ms));
+ MOCK_METHOD0(Reset, void());
+ MOCK_CONST_METHOD0(PeakFound, bool());
+ MOCK_METHOD1(UpdateCounters, void(int elapsed_time_ms));
+ MOCK_METHOD0(ResetPacketIatCount, void());
+ MOCK_CONST_METHOD2(BufferLimits, void(int* lower_limit, int* higher_limit));
+ MOCK_CONST_METHOD0(TargetLevel, int());
MOCK_METHOD0(RegisterEmptyPacket, void());
- MOCK_METHOD1(set_extra_delay_ms,
- void(int16_t delay));
- MOCK_CONST_METHOD0(base_target_level,
- int());
- MOCK_METHOD1(set_streaming_mode,
- void(bool value));
- MOCK_CONST_METHOD0(last_pack_cng_or_dtmf,
- int());
- MOCK_METHOD1(set_last_pack_cng_or_dtmf,
- void(int value));
+ MOCK_METHOD1(set_extra_delay_ms, void(int16_t delay));
+ MOCK_CONST_METHOD0(base_target_level, int());
+ MOCK_METHOD1(set_streaming_mode, void(bool value));
+ MOCK_CONST_METHOD0(last_pack_cng_or_dtmf, int());
+ MOCK_METHOD1(set_last_pack_cng_or_dtmf, void(int value));
};
} // namespace webrtc
diff --git a/modules/audio_coding/neteq/mock/mock_dtmf_buffer.h b/modules/audio_coding/neteq/mock/mock_dtmf_buffer.h
index 153a4d7..11b571f 100644
--- a/modules/audio_coding/neteq/mock/mock_dtmf_buffer.h
+++ b/modules/audio_coding/neteq/mock/mock_dtmf_buffer.h
@@ -22,16 +22,11 @@
MockDtmfBuffer(int fs) : DtmfBuffer(fs) {}
virtual ~MockDtmfBuffer() { Die(); }
MOCK_METHOD0(Die, void());
- MOCK_METHOD0(Flush,
- void());
- MOCK_METHOD1(InsertEvent,
- int(const DtmfEvent& event));
- MOCK_METHOD2(GetEvent,
- bool(uint32_t current_timestamp, DtmfEvent* event));
- MOCK_CONST_METHOD0(Length,
- size_t());
- MOCK_CONST_METHOD0(Empty,
- bool());
+ MOCK_METHOD0(Flush, void());
+ MOCK_METHOD1(InsertEvent, int(const DtmfEvent& event));
+ MOCK_METHOD2(GetEvent, bool(uint32_t current_timestamp, DtmfEvent* event));
+ MOCK_CONST_METHOD0(Length, size_t());
+ MOCK_CONST_METHOD0(Empty, bool());
};
} // namespace webrtc
diff --git a/modules/audio_coding/neteq/mock/mock_dtmf_tone_generator.h b/modules/audio_coding/neteq/mock/mock_dtmf_tone_generator.h
index 2cb5980..be4b7b5 100644
--- a/modules/audio_coding/neteq/mock/mock_dtmf_tone_generator.h
+++ b/modules/audio_coding/neteq/mock/mock_dtmf_tone_generator.h
@@ -21,14 +21,10 @@
public:
virtual ~MockDtmfToneGenerator() { Die(); }
MOCK_METHOD0(Die, void());
- MOCK_METHOD3(Init,
- int(int fs, int event, int attenuation));
- MOCK_METHOD0(Reset,
- void());
- MOCK_METHOD2(Generate,
- int(size_t num_samples, AudioMultiVector* output));
- MOCK_CONST_METHOD0(initialized,
- bool());
+ MOCK_METHOD3(Init, int(int fs, int event, int attenuation));
+ MOCK_METHOD0(Reset, void());
+ MOCK_METHOD2(Generate, int(size_t num_samples, AudioMultiVector* output));
+ MOCK_CONST_METHOD0(initialized, bool());
};
} // namespace webrtc
diff --git a/modules/audio_coding/neteq/mock/mock_expand.h b/modules/audio_coding/neteq/mock/mock_expand.h
index 05fdaec..aed0164 100644
--- a/modules/audio_coding/neteq/mock/mock_expand.h
+++ b/modules/audio_coding/neteq/mock/mock_expand.h
@@ -33,16 +33,11 @@
num_channels) {}
virtual ~MockExpand() { Die(); }
MOCK_METHOD0(Die, void());
- MOCK_METHOD0(Reset,
- void());
- MOCK_METHOD1(Process,
- int(AudioMultiVector* output));
- MOCK_METHOD0(SetParametersForNormalAfterExpand,
- void());
- MOCK_METHOD0(SetParametersForMergeAfterExpand,
- void());
- MOCK_CONST_METHOD0(overlap_length,
- size_t());
+ MOCK_METHOD0(Reset, void());
+ MOCK_METHOD1(Process, int(AudioMultiVector* output));
+ MOCK_METHOD0(SetParametersForNormalAfterExpand, void());
+ MOCK_METHOD0(SetParametersForMergeAfterExpand, void());
+ MOCK_CONST_METHOD0(overlap_length, size_t());
};
} // namespace webrtc
diff --git a/modules/audio_coding/neteq/mock/mock_external_decoder_pcm16b.h b/modules/audio_coding/neteq/mock/mock_external_decoder_pcm16b.h
index b315240..5aed6a9 100644
--- a/modules/audio_coding/neteq/mock/mock_external_decoder_pcm16b.h
+++ b/modules/audio_coding/neteq/mock/mock_external_decoder_pcm16b.h
@@ -75,17 +75,16 @@
int sample_rate_hz,
int16_t* decoded,
SpeechType* speech_type));
- MOCK_CONST_METHOD0(HasDecodePlc,
- bool());
- MOCK_METHOD2(DecodePlc,
- size_t(size_t num_frames, int16_t* decoded));
+ MOCK_CONST_METHOD0(HasDecodePlc, bool());
+ MOCK_METHOD2(DecodePlc, size_t(size_t num_frames, int16_t* decoded));
MOCK_METHOD0(Reset, void());
MOCK_METHOD5(IncomingPacket,
- int(const uint8_t* payload, size_t payload_len,
- uint16_t rtp_sequence_number, uint32_t rtp_timestamp,
- uint32_t arrival_timestamp));
- MOCK_METHOD0(ErrorCode,
- int());
+ int(const uint8_t* payload,
+ size_t payload_len,
+ uint16_t rtp_sequence_number,
+ uint32_t rtp_timestamp,
+ uint32_t arrival_timestamp));
+ MOCK_METHOD0(ErrorCode, int());
int SampleRateHz() const /* override */ { return real_.SampleRateHz(); }
size_t Channels() const /* override */ { return real_.Channels(); }
diff --git a/modules/audio_coding/neteq/nack_tracker.h b/modules/audio_coding/neteq/nack_tracker.h
index 66383ce..1936a94 100644
--- a/modules/audio_coding/neteq/nack_tracker.h
+++ b/modules/audio_coding/neteq/nack_tracker.h
@@ -11,8 +11,8 @@
#ifndef MODULES_AUDIO_CODING_NETEQ_NACK_TRACKER_H_
#define MODULES_AUDIO_CODING_NETEQ_NACK_TRACKER_H_
-#include <vector>
#include <map>
+#include <vector>
#include "modules/audio_coding/include/audio_coding_module_typedefs.h"
#include "modules/include/module_common_types.h"
diff --git a/modules/audio_coding/neteq/neteq.cc b/modules/audio_coding/neteq/neteq.cc
index db12589..55af23e 100644
--- a/modules/audio_coding/neteq/neteq.cc
+++ b/modules/audio_coding/neteq/neteq.cc
@@ -27,14 +27,12 @@
std::string NetEq::Config::ToString() const {
char buf[1024];
rtc::SimpleStringBuilder ss(buf);
- ss << "sample_rate_hz=" << sample_rate_hz
- << ", enable_post_decode_vad="
+ ss << "sample_rate_hz=" << sample_rate_hz << ", enable_post_decode_vad="
<< (enable_post_decode_vad ? "true" : "false")
<< ", max_packets_in_buffer=" << max_packets_in_buffer
- << ", playout_mode=" << playout_mode
- << ", enable_fast_accelerate="
- << (enable_fast_accelerate ? " true": "false")
- << ", enable_muted_state=" << (enable_muted_state ? " true": "false");
+ << ", playout_mode=" << playout_mode << ", enable_fast_accelerate="
+ << (enable_fast_accelerate ? " true" : "false")
+ << ", enable_muted_state=" << (enable_muted_state ? " true" : "false");
return ss.str();
}
diff --git a/modules/audio_coding/neteq/neteq_external_decoder_unittest.cc b/modules/audio_coding/neteq/neteq_external_decoder_unittest.cc
index 03f5aa3..5c350bb 100644
--- a/modules/audio_coding/neteq/neteq_external_decoder_unittest.cc
+++ b/modules/audio_coding/neteq/neteq_external_decoder_unittest.cc
@@ -55,8 +55,8 @@
}
virtual ~NetEqExternalDecoderUnitTest() {
- delete [] input_;
- delete [] encoded_;
+ delete[] input_;
+ delete[] encoded_;
// ~NetEqExternalDecoderTest() will delete |external_decoder_|, so expecting
// Die() to be called.
EXPECT_CALL(*external_decoder_, Die()).Times(1);
@@ -75,8 +75,8 @@
if (!input_file_->Read(frame_size_samples_, input_)) {
return -1;
}
- payload_size_bytes_ = WebRtcPcm16b_Encode(input_, frame_size_samples_,
- encoded_);
+ payload_size_bytes_ =
+ WebRtcPcm16b_Encode(input_, frame_size_samples_, encoded_);
int next_send_time = rtp_generator_->GetRtpHeader(
kPayloadType, frame_size_samples_, &rtp_header_);
@@ -111,9 +111,10 @@
uint32_t time_now = 0;
for (int k = 0; k < num_loops; ++k) {
while (time_now >= next_arrival_time) {
- InsertPacket(rtp_header_, rtc::ArrayView<const uint8_t>(
- encoded_, payload_size_bytes_),
- next_arrival_time);
+ InsertPacket(
+ rtp_header_,
+ rtc::ArrayView<const uint8_t>(encoded_, payload_size_bytes_),
+ next_arrival_time);
// Get next input packet.
do {
next_send_time = GetNewPacket();
@@ -148,6 +149,7 @@
}
int samples_per_ms() const { return samples_per_ms_; }
+
private:
std::unique_ptr<MockExternalPcm16B> external_decoder_;
int samples_per_ms_;
@@ -337,11 +339,9 @@
static_cast<uint32_t>(kJumpToTimestamp - kJumpFromTimestamp) > 0x7FFFFFFF,
"jump should be larger than half range");
// Replace the default RTP generator with one that jumps in timestamp.
- ResetRtpGenerator(new test::TimestampJumpRtpGenerator(samples_per_ms(),
- kStartSeqeunceNumber,
- kStartTimestamp,
- kJumpFromTimestamp,
- kJumpToTimestamp));
+ ResetRtpGenerator(new test::TimestampJumpRtpGenerator(
+ samples_per_ms(), kStartSeqeunceNumber, kStartTimestamp,
+ kJumpFromTimestamp, kJumpToTimestamp));
RunTest(130); // Run 130 laps @ 10 ms each in the test loop.
EXPECT_EQ(kRecovered, test_state_);
@@ -361,11 +361,9 @@
static_cast<uint32_t>(kJumpToTimestamp - kJumpFromTimestamp) > 0x7FFFFFFF,
"jump should be larger than half range");
// Replace the default RTP generator with one that jumps in timestamp.
- ResetRtpGenerator(new test::TimestampJumpRtpGenerator(samples_per_ms(),
- kStartSeqeunceNumber,
- kStartTimestamp,
- kJumpFromTimestamp,
- kJumpToTimestamp));
+ ResetRtpGenerator(new test::TimestampJumpRtpGenerator(
+ samples_per_ms(), kStartSeqeunceNumber, kStartTimestamp,
+ kJumpFromTimestamp, kJumpToTimestamp));
RunTest(130); // Run 130 laps @ 10 ms each in the test loop.
EXPECT_EQ(kRecovered, test_state_);
@@ -420,11 +418,9 @@
static_cast<uint32_t>(kJumpToTimestamp - kJumpFromTimestamp) < 0x7FFFFFFF,
"jump should be smaller than half range");
// Replace the default RTP generator with one that jumps in timestamp.
- ResetRtpGenerator(new test::TimestampJumpRtpGenerator(samples_per_ms(),
- kStartSeqeunceNumber,
- kStartTimestamp,
- kJumpFromTimestamp,
- kJumpToTimestamp));
+ ResetRtpGenerator(new test::TimestampJumpRtpGenerator(
+ samples_per_ms(), kStartSeqeunceNumber, kStartTimestamp,
+ kJumpFromTimestamp, kJumpToTimestamp));
RunTest(130); // Run 130 laps @ 10 ms each in the test loop.
EXPECT_EQ(kRecovered, test_state_);
@@ -444,11 +440,9 @@
static_cast<uint32_t>(kJumpToTimestamp - kJumpFromTimestamp) < 0x7FFFFFFF,
"jump should be smaller than half range");
// Replace the default RTP generator with one that jumps in timestamp.
- ResetRtpGenerator(new test::TimestampJumpRtpGenerator(samples_per_ms(),
- kStartSeqeunceNumber,
- kStartTimestamp,
- kJumpFromTimestamp,
- kJumpToTimestamp));
+ ResetRtpGenerator(new test::TimestampJumpRtpGenerator(
+ samples_per_ms(), kStartSeqeunceNumber, kStartTimestamp,
+ kJumpFromTimestamp, kJumpToTimestamp));
RunTest(130); // Run 130 laps @ 10 ms each in the test loop.
EXPECT_EQ(kRecovered, test_state_);
diff --git a/modules/audio_coding/neteq/neteq_impl.cc b/modules/audio_coding/neteq/neteq_impl.cc
index 40eae1b..afc15bf 100644
--- a/modules/audio_coding/neteq/neteq_impl.cc
+++ b/modules/audio_coding/neteq/neteq_impl.cc
@@ -681,8 +681,7 @@
decoder->IncomingPacket(packet_list.front().payload.data(),
packet_list.front().payload.size(),
packet_list.front().sequence_number,
- packet_list.front().timestamp,
- receive_timestamp);
+ packet_list.front().timestamp, receive_timestamp);
}
PacketList parsed_packet_list;
@@ -703,7 +702,7 @@
const auto sequence_number = packet.sequence_number;
const auto payload_type = packet.payload_type;
const Packet::Priority original_priority = packet.priority;
- auto packet_from_result = [&] (AudioDecoder::ParseResult& result) {
+ auto packet_from_result = [&](AudioDecoder::ParseResult& result) {
Packet new_packet;
new_packet.sequence_number = sequence_number;
new_packet.payload_type = payload_type;
@@ -788,8 +787,7 @@
assert(decoder_info);
if (decoder_info->SampleRateHz() != fs_hz_ ||
channels != algorithm_buffer_->Channels()) {
- SetSampleRateAndChannels(decoder_info->SampleRateHz(),
- channels);
+ SetSampleRateAndChannels(decoder_info->SampleRateHz(), channels);
}
if (nack_enabled_) {
RTC_DCHECK(nack_);
@@ -866,8 +864,8 @@
return 0;
}
- int return_value = GetDecision(&operation, &packet_list, &dtmf_event,
- &play_dtmf);
+ int return_value =
+ GetDecision(&operation, &packet_list, &dtmf_event, &play_dtmf);
if (return_value != 0) {
last_mode_ = kModeError;
return return_value;
@@ -876,12 +874,11 @@
AudioDecoder::SpeechType speech_type;
int length = 0;
const size_t start_num_packets = packet_list.size();
- int decode_return_value = Decode(&packet_list, &operation,
- &length, &speech_type);
+ int decode_return_value =
+ Decode(&packet_list, &operation, &length, &speech_type);
assert(vad_.get());
- bool sid_frame_available =
- (operation == kRfc3389Cng && !packet_list.empty());
+ bool sid_frame_available = (operation == kRfc3389Cng && !packet_list.empty());
vad_->Update(decoded_buffer_.get(), static_cast<size_t>(length), speech_type,
sid_frame_available, fs_hz_);
@@ -1033,8 +1030,7 @@
// Update the background noise parameters if last operation wrote data
// straight from the decoder to the |sync_buffer_|. That is, none of the
// operations that modify the signal can be followed by a parameter update.
- if ((last_mode_ == kModeNormal) ||
- (last_mode_ == kModeAccelerateFail) ||
+ if ((last_mode_ == kModeNormal) || (last_mode_ == kModeAccelerateFail) ||
(last_mode_ == kModePreemptiveExpandFail) ||
(last_mode_ == kModeRfc3389Cng) ||
(last_mode_ == kModeCodecInternalCng)) {
@@ -1051,7 +1047,8 @@
// If last operation was not expand, calculate the |playout_timestamp_| from
// the |sync_buffer_|. However, do not update the |playout_timestamp_| if it
// would be moved "backwards".
- uint32_t temp_timestamp = sync_buffer_->end_timestamp() -
+ uint32_t temp_timestamp =
+ sync_buffer_->end_timestamp() -
static_cast<uint32_t>(sync_buffer_->FutureLength());
if (static_cast<int32_t>(temp_timestamp - playout_timestamp_) > 0) {
playout_timestamp_ = temp_timestamp;
@@ -1070,13 +1067,13 @@
: timestamp_scaler_->ToExternal(playout_timestamp_) -
static_cast<uint32_t>(audio_frame->samples_per_channel_);
- if (!(last_mode_ == kModeRfc3389Cng ||
- last_mode_ == kModeCodecInternalCng ||
- last_mode_ == kModeExpand)) {
+ if (!(last_mode_ == kModeRfc3389Cng || last_mode_ == kModeCodecInternalCng ||
+ last_mode_ == kModeExpand)) {
generated_noise_stopwatch_.reset();
}
- if (decode_return_value) return decode_return_value;
+ if (decode_return_value)
+ return decode_return_value;
return return_value;
}
@@ -1100,11 +1097,10 @@
RTC_DCHECK(!generated_noise_stopwatch_ ||
generated_noise_stopwatch_->ElapsedTicks() >= 1);
uint64_t generated_noise_samples =
- generated_noise_stopwatch_
- ? (generated_noise_stopwatch_->ElapsedTicks() - 1) *
- output_size_samples_ +
- decision_logic_->noise_fast_forward()
- : 0;
+ generated_noise_stopwatch_ ? (generated_noise_stopwatch_->ElapsedTicks() -
+ 1) * output_size_samples_ +
+ decision_logic_->noise_fast_forward()
+ : 0;
if (decision_logic_->CngRfc3389On() || last_mode_ == kModeRfc3389Cng) {
// Because of timestamp peculiarities, we have to "manually" disallow using
@@ -1127,7 +1123,7 @@
assert(expand_.get());
const int samples_left = static_cast<int>(sync_buffer_->FutureLength() -
- expand_->overlap_length());
+ expand_->overlap_length());
if (last_mode_ == kModeAccelerateSuccess ||
last_mode_ == kModeAccelerateLowEnergy ||
last_mode_ == kModePreemptiveExpandSuccess ||
@@ -1139,9 +1135,8 @@
// Check if it is time to play a DTMF event.
if (dtmf_buffer_->GetEvent(
- static_cast<uint32_t>(
- end_timestamp + generated_noise_samples),
- dtmf_event)) {
+ static_cast<uint32_t>(end_timestamp + generated_noise_samples),
+ dtmf_event)) {
*play_dtmf = true;
}
@@ -1243,12 +1238,12 @@
decision_logic_->set_prev_time_scale(true);
return 0;
} else if (samples_left >= static_cast<int>(samples_10_ms) &&
- decoder_frame_length_ >= samples_30_ms) {
+ decoder_frame_length_ >= samples_30_ms) {
// Avoid decoding more data as it might overflow the playout buffer.
*operation = kNormal;
return 0;
} else if (samples_left < static_cast<int>(samples_20_ms) &&
- decoder_frame_length_ < samples_30_ms) {
+ decoder_frame_length_ < samples_30_ms) {
// Build up decoded data by decoding at least 20 ms of audio data. Do
// not perform accelerate yet, but wait until we only need to do one
// decoding.
@@ -1267,7 +1262,7 @@
// audio data.
if ((samples_left >= static_cast<int>(samples_30_ms)) ||
(samples_left >= static_cast<int>(samples_10_ms) &&
- decoder_frame_length_ >= samples_30_ms)) {
+ decoder_frame_length_ >= samples_30_ms)) {
// Already have enough data, so we do not need to extract any more.
// Or, avoid decoding more data as it might overflow the playout buffer.
// Still try preemptive expand, though.
@@ -1339,7 +1334,8 @@
return 0;
}
-int NetEqImpl::Decode(PacketList* packet_list, Operations* operation,
+int NetEqImpl::Decode(PacketList* packet_list,
+ Operations* operation,
int* decoded_length,
AudioDecoder::SpeechType* speech_type) {
*speech_type = AudioDecoder::kSpeech;
@@ -1364,8 +1360,8 @@
decoder_database_->SetActiveDecoder(payload_type, &decoder_changed);
if (decoder_changed) {
// We have a new decoder. Re-init some values.
- const DecoderDatabase::DecoderInfo* decoder_info = decoder_database_
- ->GetDecoderInfo(payload_type);
+ const DecoderDatabase::DecoderInfo* decoder_info =
+ decoder_database_->GetDecoderInfo(payload_type);
assert(decoder_info);
if (!decoder_info) {
RTC_LOG(LS_WARNING)
@@ -1411,8 +1407,8 @@
RTC_DCHECK(packet_list->empty());
return_value = DecodeCng(decoder, decoded_length, speech_type);
} else {
- return_value = DecodeLoop(packet_list, *operation, decoder,
- decoded_length, speech_type);
+ return_value = DecodeLoop(packet_list, *operation, decoder, decoded_length,
+ speech_type);
}
if (*decoded_length < 0) {
@@ -1446,7 +1442,8 @@
return return_value;
}
-int NetEqImpl::DecodeCng(AudioDecoder* decoder, int* decoded_length,
+int NetEqImpl::DecodeCng(AudioDecoder* decoder,
+ int* decoded_length,
AudioDecoder::SpeechType* speech_type) {
if (!decoder) {
// This happens when active decoder is not defined.
@@ -1456,9 +1453,9 @@
while (*decoded_length < rtc::dchecked_cast<int>(output_size_samples_)) {
const int length = decoder->Decode(
- nullptr, 0, fs_hz_,
- (decoded_buffer_length_ - *decoded_length) * sizeof(int16_t),
- &decoded_buffer_[*decoded_length], speech_type);
+ nullptr, 0, fs_hz_,
+ (decoded_buffer_length_ - *decoded_length) * sizeof(int16_t),
+ &decoded_buffer_[*decoded_length], speech_type);
if (length > 0) {
*decoded_length += length;
} else {
@@ -1476,15 +1473,16 @@
return 0;
}
-int NetEqImpl::DecodeLoop(PacketList* packet_list, const Operations& operation,
- AudioDecoder* decoder, int* decoded_length,
+int NetEqImpl::DecodeLoop(PacketList* packet_list,
+ const Operations& operation,
+ AudioDecoder* decoder,
+ int* decoded_length,
AudioDecoder::SpeechType* speech_type) {
RTC_DCHECK(last_decoded_timestamps_.empty());
// Do decoding.
- while (
- !packet_list->empty() &&
- !decoder_database_->IsComfortNoise(packet_list->front().payload_type)) {
+ while (!packet_list->empty() && !decoder_database_->IsComfortNoise(
+ packet_list->front().payload_type)) {
assert(decoder); // At this point, we must have a decoder object.
// The number of channels in the |sync_buffer_| should be the same as the
// number decoder channels.
@@ -1526,15 +1524,16 @@
// If the list is not empty at this point, either a decoding error terminated
// the while-loop, or list must hold exactly one CNG packet.
- assert(
- packet_list->empty() || *decoded_length < 0 ||
- (packet_list->size() == 1 &&
- decoder_database_->IsComfortNoise(packet_list->front().payload_type)));
+ assert(packet_list->empty() || *decoded_length < 0 ||
+ (packet_list->size() == 1 && decoder_database_->IsComfortNoise(
+ packet_list->front().payload_type)));
return 0;
}
-void NetEqImpl::DoNormal(const int16_t* decoded_buffer, size_t decoded_length,
- AudioDecoder::SpeechType speech_type, bool play_dtmf) {
+void NetEqImpl::DoNormal(const int16_t* decoded_buffer,
+ size_t decoded_length,
+ AudioDecoder::SpeechType speech_type,
+ bool play_dtmf) {
assert(normal_.get());
normal_->Process(decoded_buffer, decoded_length, last_mode_,
algorithm_buffer_.get());
@@ -1543,9 +1542,8 @@
}
// If last packet was decoded as an inband CNG, set mode to CNG instead.
- if ((speech_type == AudioDecoder::kComfortNoise)
- || ((last_mode_ == kModeCodecInternalCng)
- && (decoded_length == 0))) {
+ if ((speech_type == AudioDecoder::kComfortNoise) ||
+ ((last_mode_ == kModeCodecInternalCng) && (decoded_length == 0))) {
// TODO(hlundin): Remove second part of || statement above.
last_mode_ = kModeCodecInternalCng;
}
@@ -1555,11 +1553,13 @@
}
}
-void NetEqImpl::DoMerge(int16_t* decoded_buffer, size_t decoded_length,
- AudioDecoder::SpeechType speech_type, bool play_dtmf) {
+void NetEqImpl::DoMerge(int16_t* decoded_buffer,
+ size_t decoded_length,
+ AudioDecoder::SpeechType speech_type,
+ bool play_dtmf) {
assert(merge_.get());
- size_t new_length = merge_->Process(decoded_buffer, decoded_length,
- algorithm_buffer_.get());
+ size_t new_length =
+ merge_->Process(decoded_buffer, decoded_length, algorithm_buffer_.get());
// Correction can be negative.
int expand_length_correction =
rtc::dchecked_cast<int>(new_length) -
@@ -1587,7 +1587,7 @@
int NetEqImpl::DoExpand(bool play_dtmf) {
while ((sync_buffer_->FutureLength() - expand_->overlap_length()) <
- output_size_samples_) {
+ output_size_samples_) {
algorithm_buffer_->Clear();
int return_value = expand_->Process(algorithm_buffer_.get());
size_t length = algorithm_buffer_->Size();
@@ -1635,11 +1635,10 @@
size_t decoded_length_per_channel = decoded_length / num_channels;
if (decoded_length_per_channel < required_samples) {
// Must move data from the |sync_buffer_| in order to get 30 ms.
- borrowed_samples_per_channel = static_cast<int>(required_samples -
- decoded_length_per_channel);
+ borrowed_samples_per_channel =
+ static_cast<int>(required_samples - decoded_length_per_channel);
memmove(&decoded_buffer[borrowed_samples_per_channel * num_channels],
- decoded_buffer,
- sizeof(int16_t) * decoded_length);
+ decoded_buffer, sizeof(int16_t) * decoded_length);
sync_buffer_->ReadInterleavedFromEnd(borrowed_samples_per_channel,
decoded_buffer);
decoded_length = required_samples * num_channels;
@@ -1672,17 +1671,16 @@
if (length < borrowed_samples_per_channel) {
// This destroys the beginning of the buffer, but will not cause any
// problems.
- sync_buffer_->ReplaceAtIndex(*algorithm_buffer_,
- sync_buffer_->Size() -
- borrowed_samples_per_channel);
+ sync_buffer_->ReplaceAtIndex(
+ *algorithm_buffer_,
+ sync_buffer_->Size() - borrowed_samples_per_channel);
sync_buffer_->PushFrontZeros(borrowed_samples_per_channel - length);
algorithm_buffer_->PopFront(length);
assert(algorithm_buffer_->Empty());
} else {
- sync_buffer_->ReplaceAtIndex(*algorithm_buffer_,
- borrowed_samples_per_channel,
- sync_buffer_->Size() -
- borrowed_samples_per_channel);
+ sync_buffer_->ReplaceAtIndex(
+ *algorithm_buffer_, borrowed_samples_per_channel,
+ sync_buffer_->Size() - borrowed_samples_per_channel);
algorithm_buffer_->PopFront(borrowed_samples_per_channel);
}
}
@@ -1714,11 +1712,11 @@
required_samples - decoded_length_per_channel;
// Calculate how many of these were already played out.
old_borrowed_samples_per_channel =
- (borrowed_samples_per_channel > sync_buffer_->FutureLength()) ?
- (borrowed_samples_per_channel - sync_buffer_->FutureLength()) : 0;
+ (borrowed_samples_per_channel > sync_buffer_->FutureLength())
+ ? (borrowed_samples_per_channel - sync_buffer_->FutureLength())
+ : 0;
memmove(&decoded_buffer[borrowed_samples_per_channel * num_channels],
- decoded_buffer,
- sizeof(int16_t) * decoded_length);
+ decoded_buffer, sizeof(int16_t) * decoded_length);
sync_buffer_->ReadInterleavedFromEnd(borrowed_samples_per_channel,
decoded_buffer);
decoded_length = required_samples * num_channels;
@@ -1726,8 +1724,7 @@
size_t samples_added;
PreemptiveExpand::ReturnCodes return_code = preemptive_expand_->Process(
- decoded_buffer, decoded_length,
- old_borrowed_samples_per_channel,
+ decoded_buffer, decoded_length, old_borrowed_samples_per_channel,
algorithm_buffer_.get(), &samples_added);
stats_.PreemptiveExpandedSamples(samples_added);
switch (return_code) {
@@ -1780,8 +1777,8 @@
return -comfort_noise_->internal_error_code();
}
}
- int cn_return = comfort_noise_->Generate(output_size_samples_,
- algorithm_buffer_.get());
+ int cn_return =
+ comfort_noise_->Generate(output_size_samples_, algorithm_buffer_.get());
expand_->Reset();
last_mode_ = kModeRfc3389Cng;
if (!play_dtmf) {
@@ -1909,16 +1906,17 @@
expand_->Reset();
}
-int NetEqImpl::DtmfOverdub(const DtmfEvent& dtmf_event, size_t num_channels,
+int NetEqImpl::DtmfOverdub(const DtmfEvent& dtmf_event,
+ size_t num_channels,
int16_t* output) const {
size_t out_index = 0;
size_t overdub_length = output_size_samples_; // Default value.
if (sync_buffer_->dtmf_index() > sync_buffer_->next_index()) {
// Special operation for transition from "DTMF only" to "DTMF overdub".
- out_index = std::min(
- sync_buffer_->dtmf_index() - sync_buffer_->next_index(),
- output_size_samples_);
+ out_index =
+ std::min(sync_buffer_->dtmf_index() - sync_buffer_->next_index(),
+ output_size_samples_);
overdub_length = output_size_samples_ - out_index;
}
@@ -1929,8 +1927,8 @@
dtmf_event.volume);
}
if (dtmf_return_value == 0) {
- dtmf_return_value = dtmf_tone_generator_->Generate(overdub_length,
- &dtmf_output);
+ dtmf_return_value =
+ dtmf_tone_generator_->Generate(overdub_length, &dtmf_output);
assert(overdub_length == dtmf_output.Size());
}
dtmf_output.ReadInterleaved(overdub_length, &output[out_index]);
@@ -2051,7 +2049,7 @@
RTC_LOG(LS_VERBOSE) << "SetSampleRateAndChannels " << fs_hz << " "
<< channels;
// TODO(hlundin): Change to an enumerator and skip assert.
- assert(fs_hz == 8000 || fs_hz == 16000 || fs_hz == 32000 || fs_hz == 48000);
+ assert(fs_hz == 8000 || fs_hz == 16000 || fs_hz == 32000 || fs_hz == 48000);
assert(channels > 0);
fs_hz_ = fs_hz;
@@ -2085,7 +2083,7 @@
// Move index so that we create a small set of future samples (all 0).
sync_buffer_->set_next_index(sync_buffer_->next_index() -
- expand_->overlap_length());
+ expand_->overlap_length());
normal_.reset(new Normal(fs_hz, decoder_database_.get(), *background_noise_,
expand_.get()));
@@ -2095,8 +2093,8 @@
fs_hz, channels, *background_noise_, expand_->overlap_length()));
// Delete ComfortNoise object and create a new one.
- comfort_noise_.reset(new ComfortNoise(fs_hz, decoder_database_.get(),
- sync_buffer_.get()));
+ comfort_noise_.reset(
+ new ComfortNoise(fs_hz, decoder_database_.get(), sync_buffer_.get()));
// Verify that |decoded_buffer_| is long enough.
if (decoded_buffer_length_ < kMaxFrameSize * channels) {
diff --git a/modules/audio_coding/neteq/neteq_network_stats_unittest.cc b/modules/audio_coding/neteq/neteq_network_stats_unittest.cc
index 585fd8f..57fc682 100644
--- a/modules/audio_coding/neteq/neteq_network_stats_unittest.cc
+++ b/modules/audio_coding/neteq/neteq_network_stats_unittest.cc
@@ -86,8 +86,8 @@
return kPacketDuration;
}
- bool PacketHasFec(
- const uint8_t* encoded, size_t encoded_len) const /* override */ {
+ bool PacketHasFec(const uint8_t* encoded, size_t encoded_len) const
+ /* override */ {
ADD_FAILURE() << "Since going through ParsePayload, PacketHasFec should "
"never get called.";
return fec_enabled_;
@@ -123,40 +123,40 @@
static const int kPayloadSizeByte = 30;
static const int kFrameSizeMs = 20;
-enum logic {
- kIgnore,
- kEqual,
- kSmallerThan,
- kLargerThan,
-};
+ enum logic {
+ kIgnore,
+ kEqual,
+ kSmallerThan,
+ kLargerThan,
+ };
-struct NetEqNetworkStatsCheck {
- logic current_buffer_size_ms;
- logic preferred_buffer_size_ms;
- logic jitter_peaks_found;
- logic packet_loss_rate;
- logic expand_rate;
- logic speech_expand_rate;
- logic preemptive_rate;
- logic accelerate_rate;
- logic secondary_decoded_rate;
- logic secondary_discarded_rate;
- logic clockdrift_ppm;
- logic added_zero_samples;
- NetEqNetworkStatistics stats_ref;
-};
+ struct NetEqNetworkStatsCheck {
+ logic current_buffer_size_ms;
+ logic preferred_buffer_size_ms;
+ logic jitter_peaks_found;
+ logic packet_loss_rate;
+ logic expand_rate;
+ logic speech_expand_rate;
+ logic preemptive_rate;
+ logic accelerate_rate;
+ logic secondary_decoded_rate;
+ logic secondary_discarded_rate;
+ logic clockdrift_ppm;
+ logic added_zero_samples;
+ NetEqNetworkStatistics stats_ref;
+ };
-NetEqNetworkStatsTest(NetEqDecoder codec,
- int sample_rate_hz,
- MockAudioDecoder* decoder)
- : NetEqExternalDecoderTest(codec, sample_rate_hz, decoder),
- external_decoder_(decoder),
- samples_per_ms_(sample_rate_hz / 1000),
- frame_size_samples_(kFrameSizeMs * samples_per_ms_),
- rtp_generator_(new test::RtpGenerator(samples_per_ms_)),
- last_lost_time_(0),
- packet_loss_interval_(0xffffffff) {
- Init();
+ NetEqNetworkStatsTest(NetEqDecoder codec,
+ int sample_rate_hz,
+ MockAudioDecoder* decoder)
+ : NetEqExternalDecoderTest(codec, sample_rate_hz, decoder),
+ external_decoder_(decoder),
+ samples_per_ms_(sample_rate_hz / 1000),
+ frame_size_samples_(kFrameSizeMs * samples_per_ms_),
+ rtp_generator_(new test::RtpGenerator(samples_per_ms_)),
+ last_lost_time_(0),
+ packet_loss_interval_(0xffffffff) {
+ Init();
}
bool Lost(uint32_t send_time) {
@@ -168,8 +168,9 @@
}
void SetPacketLossRate(double loss_rate) {
- packet_loss_interval_ = (loss_rate >= 1e-3 ?
- static_cast<double>(kFrameSizeMs) / loss_rate : 0xffffffff);
+ packet_loss_interval_ =
+ (loss_rate >= 1e-3 ? static_cast<double>(kFrameSizeMs) / loss_rate
+ : 0xffffffff);
}
// |stats_ref|
@@ -181,19 +182,19 @@
NetEqNetworkStatistics stats;
neteq()->NetworkStatistics(&stats);
-#define CHECK_NETEQ_NETWORK_STATS(x)\
- switch (expects.x) {\
- case kEqual:\
- EXPECT_EQ(stats.x, expects.stats_ref.x);\
- break;\
- case kSmallerThan:\
- EXPECT_LT(stats.x, expects.stats_ref.x);\
- break;\
- case kLargerThan:\
- EXPECT_GT(stats.x, expects.stats_ref.x);\
- break;\
- default:\
- break;\
+#define CHECK_NETEQ_NETWORK_STATS(x) \
+ switch (expects.x) { \
+ case kEqual: \
+ EXPECT_EQ(stats.x, expects.stats_ref.x); \
+ break; \
+ case kSmallerThan: \
+ EXPECT_LT(stats.x, expects.stats_ref.x); \
+ break; \
+ case kLargerThan: \
+ EXPECT_GT(stats.x, expects.stats_ref.x); \
+ break; \
+ default: \
+ break; \
}
CHECK_NETEQ_NETWORK_STATS(current_buffer_size_ms);
@@ -220,15 +221,13 @@
uint32_t next_send_time;
// Initiate |last_lost_time_|.
- time_now = next_send_time = last_lost_time_ =
- rtp_generator_->GetRtpHeader(kPayloadType, frame_size_samples_,
- &rtp_header_);
+ time_now = next_send_time = last_lost_time_ = rtp_generator_->GetRtpHeader(
+ kPayloadType, frame_size_samples_, &rtp_header_);
for (int k = 0; k < num_loops; ++k) {
// Delay by one frame such that the FEC can come in.
while (time_now + kFrameSizeMs >= next_send_time) {
- next_send_time = rtp_generator_->GetRtpHeader(kPayloadType,
- frame_size_samples_,
- &rtp_header_);
+ next_send_time = rtp_generator_->GetRtpHeader(
+ kPayloadType, frame_size_samples_, &rtp_header_);
if (!Lost(next_send_time)) {
static const uint8_t payload[kPayloadSizeByte] = {0};
InsertPacket(rtp_header_, payload, next_send_time);
@@ -243,21 +242,19 @@
void DecodeFecTest() {
external_decoder_->set_fec_enabled(false);
- NetEqNetworkStatsCheck expects = {
- kIgnore, // current_buffer_size_ms
- kIgnore, // preferred_buffer_size_ms
- kIgnore, // jitter_peaks_found
- kEqual, // packet_loss_rate
- kEqual, // expand_rate
- kEqual, // voice_expand_rate
- kIgnore, // preemptive_rate
- kEqual, // accelerate_rate
- kEqual, // decoded_fec_rate
- kEqual, // discarded_fec_rate
- kIgnore, // clockdrift_ppm
- kEqual, // added_zero_samples
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
- };
+ NetEqNetworkStatsCheck expects = {kIgnore, // current_buffer_size_ms
+ kIgnore, // preferred_buffer_size_ms
+ kIgnore, // jitter_peaks_found
+ kEqual, // packet_loss_rate
+ kEqual, // expand_rate
+ kEqual, // voice_expand_rate
+ kIgnore, // preemptive_rate
+ kEqual, // accelerate_rate
+ kEqual, // decoded_fec_rate
+ kEqual, // discarded_fec_rate
+ kIgnore, // clockdrift_ppm
+ kEqual, // added_zero_samples
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
RunTest(50, expects);
// Next we introduce packet losses.
@@ -277,21 +274,19 @@
}
void NoiseExpansionTest() {
- NetEqNetworkStatsCheck expects = {
- kIgnore, // current_buffer_size_ms
- kIgnore, // preferred_buffer_size_ms
- kIgnore, // jitter_peaks_found
- kEqual, // packet_loss_rate
- kEqual, // expand_rate
- kEqual, // speech_expand_rate
- kIgnore, // preemptive_rate
- kEqual, // accelerate_rate
- kEqual, // decoded_fec_rate
- kEqual, // discard_fec_rate
- kIgnore, // clockdrift_ppm
- kEqual, // added_zero_samples
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
- };
+ NetEqNetworkStatsCheck expects = {kIgnore, // current_buffer_size_ms
+ kIgnore, // preferred_buffer_size_ms
+ kIgnore, // jitter_peaks_found
+ kEqual, // packet_loss_rate
+ kEqual, // expand_rate
+ kEqual, // speech_expand_rate
+ kIgnore, // preemptive_rate
+ kEqual, // accelerate_rate
+ kEqual, // decoded_fec_rate
+ kEqual, // discard_fec_rate
+ kIgnore, // clockdrift_ppm
+ kEqual, // added_zero_samples
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
RunTest(50, expects);
SetPacketLossRate(1);
diff --git a/modules/audio_coding/neteq/neteq_stereo_unittest.cc b/modules/audio_coding/neteq/neteq_stereo_unittest.cc
index 49facdd..ef4c235 100644
--- a/modules/audio_coding/neteq/neteq_stereo_unittest.cc
+++ b/modules/audio_coding/neteq/neteq_stereo_unittest.cc
@@ -11,9 +11,9 @@
// Test to verify correct stereo and multi-channel operation.
#include <algorithm>
+#include <list>
#include <memory>
#include <string>
-#include <list>
#include "api/audio/audio_frame.h"
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
@@ -72,17 +72,17 @@
input_ = new int16_t[frame_size_samples_];
encoded_ = new uint8_t[2 * frame_size_samples_];
input_multi_channel_ = new int16_t[frame_size_samples_ * num_channels_];
- encoded_multi_channel_ = new uint8_t[frame_size_samples_ * 2 *
- num_channels_];
+ encoded_multi_channel_ =
+ new uint8_t[frame_size_samples_ * 2 * num_channels_];
}
~NetEqStereoTest() {
delete neteq_mono_;
delete neteq_;
- delete [] input_;
- delete [] encoded_;
- delete [] input_multi_channel_;
- delete [] encoded_multi_channel_;
+ delete[] input_;
+ delete[] encoded_;
+ delete[] input_multi_channel_;
+ delete[] encoded_multi_channel_;
}
virtual void SetUp() {
@@ -142,17 +142,15 @@
if (!input_file_->Read(frame_size_samples_, input_)) {
return -1;
}
- payload_size_bytes_ = WebRtcPcm16b_Encode(input_, frame_size_samples_,
- encoded_);
+ payload_size_bytes_ =
+ WebRtcPcm16b_Encode(input_, frame_size_samples_, encoded_);
if (frame_size_samples_ * 2 != payload_size_bytes_) {
return -1;
}
- int next_send_time = rtp_generator_mono_.GetRtpHeader(kPayloadTypeMono,
- frame_size_samples_,
- &rtp_header_mono_);
- test::InputAudioFile::DuplicateInterleaved(input_, frame_size_samples_,
- num_channels_,
- input_multi_channel_);
+ int next_send_time = rtp_generator_mono_.GetRtpHeader(
+ kPayloadTypeMono, frame_size_samples_, &rtp_header_mono_);
+ test::InputAudioFile::DuplicateInterleaved(
+ input_, frame_size_samples_, num_channels_, input_multi_channel_);
multi_payload_size_bytes_ = WebRtcPcm16b_Encode(
input_multi_channel_, frame_size_samples_ * num_channels_,
encoded_multi_channel_);
@@ -267,8 +265,7 @@
class NetEqStereoTestNoJitter : public NetEqStereoTest {
protected:
- NetEqStereoTestNoJitter()
- : NetEqStereoTest() {
+ NetEqStereoTestNoJitter() : NetEqStereoTest() {
// Start the sender 100 ms before the receiver to pre-fill the buffer.
// This is to avoid doing preemptive expand early in the test.
// TODO(hlundin): Mock the decision making instead to control the modes.
@@ -282,17 +279,15 @@
class NetEqStereoTestPositiveDrift : public NetEqStereoTest {
protected:
- NetEqStereoTestPositiveDrift()
- : NetEqStereoTest(),
- drift_factor(0.9) {
+ NetEqStereoTestPositiveDrift() : NetEqStereoTest(), drift_factor(0.9) {
// Start the sender 100 ms before the receiver to pre-fill the buffer.
// This is to avoid doing preemptive expand early in the test.
// TODO(hlundin): Mock the decision making instead to control the modes.
last_arrival_time_ = -100;
}
virtual int GetArrivalTime(int send_time) {
- int arrival_time = last_arrival_time_ +
- drift_factor * (send_time - last_send_time_);
+ int arrival_time =
+ last_arrival_time_ + drift_factor * (send_time - last_send_time_);
last_send_time_ = send_time;
last_arrival_time_ = arrival_time;
return arrival_time;
@@ -307,8 +302,7 @@
class NetEqStereoTestNegativeDrift : public NetEqStereoTestPositiveDrift {
protected:
- NetEqStereoTestNegativeDrift()
- : NetEqStereoTestPositiveDrift() {
+ NetEqStereoTestNegativeDrift() : NetEqStereoTestPositiveDrift() {
drift_factor = 1.1;
last_arrival_time_ = 0;
}
@@ -322,10 +316,7 @@
protected:
static const int kDelayInterval = 10;
static const int kDelay = 1000;
- NetEqStereoTestDelays()
- : NetEqStereoTest(),
- frame_index_(0) {
- }
+ NetEqStereoTestDelays() : NetEqStereoTest(), frame_index_(0) {}
virtual int GetArrivalTime(int send_time) {
// Deliver immediately, unless we have a back-log.
@@ -349,22 +340,16 @@
class NetEqStereoTestLosses : public NetEqStereoTest {
protected:
static const int kLossInterval = 10;
- NetEqStereoTestLosses()
- : NetEqStereoTest(),
- frame_index_(0) {
- }
+ NetEqStereoTestLosses() : NetEqStereoTest(), frame_index_(0) {}
- virtual bool Lost() {
- return (++frame_index_) % kLossInterval == 0;
- }
+ virtual bool Lost() { return (++frame_index_) % kLossInterval == 0; }
// TODO(hlundin): NetEq is not giving bitexact results for these cases.
virtual void VerifyOutput(size_t num_samples) {
for (size_t i = 0; i < num_samples; ++i) {
const int16_t* output_data = output_.data();
const int16_t* output_multi_channel_data = output_multi_channel_.data();
- auto first_channel_sample =
- output_multi_channel_data[i * num_channels_];
+ auto first_channel_sample = output_multi_channel_data[i * num_channels_];
for (size_t j = 0; j < num_channels_; ++j) {
const int kErrorMargin = 200;
EXPECT_NEAR(output_data[i],
@@ -384,7 +369,6 @@
RunTest(100);
}
-
// Creates a list of parameter sets.
std::list<TestParameters> GetTestParameters() {
std::list<TestParameters> l;
@@ -412,9 +396,9 @@
// Pretty-printing the test parameters in case of an error.
void PrintTo(const TestParameters& p, ::std::ostream* os) {
- *os << "{frame_size = " << p.frame_size <<
- ", num_channels = " << p.num_channels <<
- ", sample_rate = " << p.sample_rate << "}";
+ *os << "{frame_size = " << p.frame_size
+ << ", num_channels = " << p.num_channels
+ << ", sample_rate = " << p.sample_rate << "}";
}
// Instantiate the tests. Each test is instantiated using the function above,
diff --git a/modules/audio_coding/neteq/neteq_unittest.cc b/modules/audio_coding/neteq/neteq_unittest.cc
index 6239985..4ed7a6b 100644
--- a/modules/audio_coding/neteq/neteq_unittest.cc
+++ b/modules/audio_coding/neteq/neteq_unittest.cc
@@ -61,17 +61,17 @@
const std::string& checksum_win_32,
const std::string& checksum_win_64) {
#if defined(WEBRTC_ANDROID)
- #ifdef WEBRTC_ARCH_64_BITS
- return checksum_android_64;
- #else
- return checksum_android_32;
- #endif // WEBRTC_ARCH_64_BITS
+#ifdef WEBRTC_ARCH_64_BITS
+ return checksum_android_64;
+#else
+ return checksum_android_32;
+#endif // WEBRTC_ARCH_64_BITS
#elif defined(WEBRTC_WIN)
- #ifdef WEBRTC_ARCH_64_BITS
- return checksum_win_64;
- #else
- return checksum_win_32;
- #endif // WEBRTC_ARCH_64_BITS
+#ifdef WEBRTC_ARCH_64_BITS
+ return checksum_win_64;
+#else
+ return checksum_win_32;
+#endif // WEBRTC_ARCH_64_BITS
#else
return checksum_general;
#endif // WEBRTC_WIN
@@ -107,7 +107,8 @@
stats->set_jitter(stats_raw.jitter);
}
-void AddMessage(FILE* file, rtc::MessageDigest* digest,
+void AddMessage(FILE* file,
+ rtc::MessageDigest* digest,
const std::string& message) {
int32_t size = message.length();
if (file)
@@ -164,7 +165,8 @@
explicit ResultSink(const std::string& output_file);
~ResultSink();
- template<typename T> void AddResult(const T* test_results, size_t length);
+ template <typename T>
+ void AddResult(const T* test_results, size_t length);
void AddResult(const NetEqNetworkStatistics& stats);
void AddResult(const RtcpStatistics& stats);
@@ -190,7 +192,7 @@
fclose(output_fp_);
}
-template<typename T>
+template <typename T>
void ResultSink::AddResult(const T* test_results, size_t length) {
if (output_fp_) {
ASSERT_EQ(length, fwrite(test_results, sizeof(T), length, output_fp_));
@@ -247,7 +249,7 @@
virtual void SetUp();
virtual void TearDown();
void SelectDecoders(NetEqDecoder* used_codec);
- void OpenInputFile(const std::string &rtp_file);
+ void OpenInputFile(const std::string& rtp_file);
void Process();
void DecodeAndCompare(const std::string& rtp_file,
@@ -265,9 +267,11 @@
uint8_t* payload,
size_t* payload_len);
- void WrapTest(uint16_t start_seq_no, uint32_t start_timestamp,
+ void WrapTest(uint16_t start_seq_no,
+ uint32_t start_timestamp,
const std::set<uint16_t>& drop_seq_numbers,
- bool expect_seq_no_wrap, bool expect_timestamp_wrap);
+ bool expect_seq_no_wrap,
+ bool expect_timestamp_wrap);
void LongCngWithClockDrift(double drift_factor,
double network_freeze_ms,
@@ -316,7 +320,7 @@
delete neteq_;
}
-void NetEqDecodingTest::OpenInputFile(const std::string &rtp_file) {
+void NetEqDecodingTest::OpenInputFile(const std::string& rtp_file) {
rtp_source_.reset(test::RtpFileSource::Create(rtp_file));
}
@@ -384,8 +388,8 @@
ss << "Lap number " << i++ << " in DecodeAndCompare while loop";
SCOPED_TRACE(ss.str()); // Print out the parameter values on failure.
ASSERT_NO_FATAL_FAILURE(Process());
- ASSERT_NO_FATAL_FAILURE(output.AddResult(
- out_frame_.data(), out_frame_.samples_per_channel_));
+ ASSERT_NO_FATAL_FAILURE(
+ output.AddResult(out_frame_.data(), out_frame_.samples_per_channel_));
// Query the network statistics API once per second
if (sim_clock_ % 1000 == 0) {
@@ -447,7 +451,7 @@
rtp_info->ssrc = 0x1234; // Just an arbitrary SSRC.
rtp_info->payloadType = 98; // WB CNG.
rtp_info->markerBit = 0;
- payload[0] = 64; // Noise level -64 dBov, quite arbitrarily chosen.
+ payload[0] = 64; // Noise level -64 dBov, quite arbitrarily chosen.
*payload_len = 1; // Only noise level, no spectral parameters.
}
@@ -462,36 +466,29 @@
const std::string input_rtp_file =
webrtc::test::ResourcePath("audio_coding/neteq_universal_new", "rtp");
- const std::string output_checksum = PlatformChecksum(
- "0c6dc227f781c81a229970f8fceda1a012498cba",
- "15c4a2202877a414515e218bdb7992f0ad53e5af",
- "not used",
- "0c6dc227f781c81a229970f8fceda1a012498cba",
- "25fc4c863caa499aa447a5b8d059f5452cbcc500");
+ const std::string output_checksum =
+ PlatformChecksum("0c6dc227f781c81a229970f8fceda1a012498cba",
+ "15c4a2202877a414515e218bdb7992f0ad53e5af", "not used",
+ "0c6dc227f781c81a229970f8fceda1a012498cba",
+ "25fc4c863caa499aa447a5b8d059f5452cbcc500");
const std::string network_stats_checksum =
PlatformChecksum("4b2370f5c794741d2a46be5c7935c66ef3fb53e9",
- "e339cb2adf5ab3dfc21cb7205d670a34751e8336",
- "not used",
+ "e339cb2adf5ab3dfc21cb7205d670a34751e8336", "not used",
"4b2370f5c794741d2a46be5c7935c66ef3fb53e9",
"4b2370f5c794741d2a46be5c7935c66ef3fb53e9");
- const std::string rtcp_stats_checksum = PlatformChecksum(
- "b8880bf9fed2487efbddcb8d94b9937a29ae521d",
- "f3f7b3d3e71d7e635240b5373b57df6a7e4ce9d4",
- "not used",
- "b8880bf9fed2487efbddcb8d94b9937a29ae521d",
- "b8880bf9fed2487efbddcb8d94b9937a29ae521d");
+ const std::string rtcp_stats_checksum =
+ PlatformChecksum("b8880bf9fed2487efbddcb8d94b9937a29ae521d",
+ "f3f7b3d3e71d7e635240b5373b57df6a7e4ce9d4", "not used",
+ "b8880bf9fed2487efbddcb8d94b9937a29ae521d",
+ "b8880bf9fed2487efbddcb8d94b9937a29ae521d");
- DecodeAndCompare(input_rtp_file,
- output_checksum,
- network_stats_checksum,
- rtcp_stats_checksum,
- FLAG_gen_ref);
+ DecodeAndCompare(input_rtp_file, output_checksum, network_stats_checksum,
+ rtcp_stats_checksum, FLAG_gen_ref);
}
-#if !defined(WEBRTC_IOS) && \
- defined(WEBRTC_NETEQ_UNITTEST_BITEXACT) && \
+#if !defined(WEBRTC_IOS) && defined(WEBRTC_NETEQ_UNITTEST_BITEXACT) && \
defined(WEBRTC_CODEC_OPUS)
#define MAYBE_TestOpusBitExactness TestOpusBitExactness
#else
@@ -501,12 +498,12 @@
const std::string input_rtp_file =
webrtc::test::ResourcePath("audio_coding/neteq_opus", "rtp");
- const std::string output_checksum = PlatformChecksum(
- "14a63b3c7b925c82296be4bafc71bec85f2915c2",
- "b7b7ed802b0e18ee416973bf3b9ae98599b0181d",
- "5876e52dda90d5ca433c3726555b907b97c86374",
- "14a63b3c7b925c82296be4bafc71bec85f2915c2",
- "14a63b3c7b925c82296be4bafc71bec85f2915c2");
+ const std::string output_checksum =
+ PlatformChecksum("14a63b3c7b925c82296be4bafc71bec85f2915c2",
+ "b7b7ed802b0e18ee416973bf3b9ae98599b0181d",
+ "5876e52dda90d5ca433c3726555b907b97c86374",
+ "14a63b3c7b925c82296be4bafc71bec85f2915c2",
+ "14a63b3c7b925c82296be4bafc71bec85f2915c2");
const std::string network_stats_checksum =
PlatformChecksum("adb3272498e436d1c019cbfd71610e9510c54497",
@@ -515,22 +512,18 @@
"adb3272498e436d1c019cbfd71610e9510c54497",
"adb3272498e436d1c019cbfd71610e9510c54497");
- const std::string rtcp_stats_checksum = PlatformChecksum(
- "e37c797e3de6a64dda88c9ade7a013d022a2e1e0",
- "e37c797e3de6a64dda88c9ade7a013d022a2e1e0",
- "e37c797e3de6a64dda88c9ade7a013d022a2e1e0",
- "e37c797e3de6a64dda88c9ade7a013d022a2e1e0",
- "e37c797e3de6a64dda88c9ade7a013d022a2e1e0");
+ const std::string rtcp_stats_checksum =
+ PlatformChecksum("e37c797e3de6a64dda88c9ade7a013d022a2e1e0",
+ "e37c797e3de6a64dda88c9ade7a013d022a2e1e0",
+ "e37c797e3de6a64dda88c9ade7a013d022a2e1e0",
+ "e37c797e3de6a64dda88c9ade7a013d022a2e1e0",
+ "e37c797e3de6a64dda88c9ade7a013d022a2e1e0");
- DecodeAndCompare(input_rtp_file,
- output_checksum,
- network_stats_checksum,
- rtcp_stats_checksum,
- FLAG_gen_ref);
+ DecodeAndCompare(input_rtp_file, output_checksum, network_stats_checksum,
+ rtcp_stats_checksum, FLAG_gen_ref);
}
-#if !defined(WEBRTC_IOS) && \
- defined(WEBRTC_NETEQ_UNITTEST_BITEXACT) && \
+#if !defined(WEBRTC_IOS) && defined(WEBRTC_NETEQ_UNITTEST_BITEXACT) && \
defined(WEBRTC_CODEC_OPUS)
#define MAYBE_TestOpusDtxBitExactness TestOpusDtxBitExactness
#else
@@ -805,10 +798,8 @@
const bool kGetAudioDuringFreezeRecovery = false;
const int kDelayToleranceMs = 20;
const int kMaxTimeToSpeechMs = 100;
- LongCngWithClockDrift(kDriftFactor,
- kNetworkFreezeTimeMs,
- kGetAudioDuringFreezeRecovery,
- kDelayToleranceMs,
+ LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs,
+ kGetAudioDuringFreezeRecovery, kDelayToleranceMs,
kMaxTimeToSpeechMs);
}
@@ -819,10 +810,8 @@
const bool kGetAudioDuringFreezeRecovery = false;
const int kDelayToleranceMs = 20;
const int kMaxTimeToSpeechMs = 100;
- LongCngWithClockDrift(kDriftFactor,
- kNetworkFreezeTimeMs,
- kGetAudioDuringFreezeRecovery,
- kDelayToleranceMs,
+ LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs,
+ kGetAudioDuringFreezeRecovery, kDelayToleranceMs,
kMaxTimeToSpeechMs);
}
@@ -833,10 +822,8 @@
const bool kGetAudioDuringFreezeRecovery = false;
const int kDelayToleranceMs = 50;
const int kMaxTimeToSpeechMs = 200;
- LongCngWithClockDrift(kDriftFactor,
- kNetworkFreezeTimeMs,
- kGetAudioDuringFreezeRecovery,
- kDelayToleranceMs,
+ LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs,
+ kGetAudioDuringFreezeRecovery, kDelayToleranceMs,
kMaxTimeToSpeechMs);
}
@@ -847,10 +834,8 @@
const bool kGetAudioDuringFreezeRecovery = false;
const int kDelayToleranceMs = 20;
const int kMaxTimeToSpeechMs = 100;
- LongCngWithClockDrift(kDriftFactor,
- kNetworkFreezeTimeMs,
- kGetAudioDuringFreezeRecovery,
- kDelayToleranceMs,
+ LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs,
+ kGetAudioDuringFreezeRecovery, kDelayToleranceMs,
kMaxTimeToSpeechMs);
}
@@ -861,10 +846,8 @@
const bool kGetAudioDuringFreezeRecovery = true;
const int kDelayToleranceMs = 20;
const int kMaxTimeToSpeechMs = 100;
- LongCngWithClockDrift(kDriftFactor,
- kNetworkFreezeTimeMs,
- kGetAudioDuringFreezeRecovery,
- kDelayToleranceMs,
+ LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs,
+ kGetAudioDuringFreezeRecovery, kDelayToleranceMs,
kMaxTimeToSpeechMs);
}
@@ -874,10 +857,8 @@
const bool kGetAudioDuringFreezeRecovery = false;
const int kDelayToleranceMs = 10;
const int kMaxTimeToSpeechMs = 50;
- LongCngWithClockDrift(kDriftFactor,
- kNetworkFreezeTimeMs,
- kGetAudioDuringFreezeRecovery,
- kDelayToleranceMs,
+ LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs,
+ kGetAudioDuringFreezeRecovery, kDelayToleranceMs,
kMaxTimeToSpeechMs);
}
@@ -1002,11 +983,11 @@
ASSERT_EQ(AudioFrame::kNormalSpeech, output.speech_type_);
// Next packet.
- rtp_info.timestamp += rtc::checked_cast<uint32_t>(
- expected_samples_per_channel);
+ rtp_info.timestamp +=
+ rtc::checked_cast<uint32_t>(expected_samples_per_channel);
rtp_info.sequenceNumber++;
- receive_timestamp += rtc::checked_cast<uint32_t>(
- expected_samples_per_channel);
+ receive_timestamp +=
+ rtc::checked_cast<uint32_t>(expected_samples_per_channel);
}
output.Reset();
@@ -1099,8 +1080,8 @@
if (packets_inserted > 4) {
// Expect preferred and actual buffer size to be no more than 2 frames.
EXPECT_LE(network_stats.preferred_buffer_size_ms, kFrameSizeMs * 2);
- EXPECT_LE(network_stats.current_buffer_size_ms, kFrameSizeMs * 2 +
- algorithmic_delay_ms_);
+ EXPECT_LE(network_stats.current_buffer_size_ms,
+ kFrameSizeMs * 2 + algorithmic_delay_ms_);
}
last_seq_no = seq_no;
last_timestamp = timestamp;
@@ -1166,8 +1147,8 @@
const int kSamples = kFrameSizeMs * kSampleRateKhz;
const size_t kPayloadBytes = kSamples * 2;
- const int algorithmic_delay_samples = std::max(
- algorithmic_delay_ms_ * kSampleRateKhz, 5 * kSampleRateKhz / 8);
+ const int algorithmic_delay_samples =
+ std::max(algorithmic_delay_ms_ * kSampleRateKhz, 5 * kSampleRateKhz / 8);
// Insert three speech packets. Three are needed to get the frame length
// correct.
uint8_t payload[kPayloadBytes] = {0};
@@ -1239,7 +1220,9 @@
*playout_timestamp);
}
-TEST_F(NetEqDecodingTest, DiscardDuplicateCng) { DuplicateCng(); }
+TEST_F(NetEqDecodingTest, DiscardDuplicateCng) {
+ DuplicateCng();
+}
TEST_F(NetEqDecodingTest, CngFirst) {
uint16_t seq_no = 0;
@@ -1493,25 +1476,25 @@
return ::testing::AssertionFailure() << "timestamp_ diff (" << a.timestamp_
<< " != " << b.timestamp_ << ")";
if (a.sample_rate_hz_ != b.sample_rate_hz_)
- return ::testing::AssertionFailure() << "sample_rate_hz_ diff ("
- << a.sample_rate_hz_
- << " != " << b.sample_rate_hz_ << ")";
+ return ::testing::AssertionFailure()
+ << "sample_rate_hz_ diff (" << a.sample_rate_hz_
+ << " != " << b.sample_rate_hz_ << ")";
if (a.samples_per_channel_ != b.samples_per_channel_)
return ::testing::AssertionFailure()
<< "samples_per_channel_ diff (" << a.samples_per_channel_
<< " != " << b.samples_per_channel_ << ")";
if (a.num_channels_ != b.num_channels_)
- return ::testing::AssertionFailure() << "num_channels_ diff ("
- << a.num_channels_
- << " != " << b.num_channels_ << ")";
+ return ::testing::AssertionFailure()
+ << "num_channels_ diff (" << a.num_channels_
+ << " != " << b.num_channels_ << ")";
if (a.speech_type_ != b.speech_type_)
- return ::testing::AssertionFailure() << "speech_type_ diff ("
- << a.speech_type_
- << " != " << b.speech_type_ << ")";
+ return ::testing::AssertionFailure()
+ << "speech_type_ diff (" << a.speech_type_
+ << " != " << b.speech_type_ << ")";
if (a.vad_activity_ != b.vad_activity_)
- return ::testing::AssertionFailure() << "vad_activity_ diff ("
- << a.vad_activity_
- << " != " << b.vad_activity_ << ")";
+ return ::testing::AssertionFailure()
+ << "vad_activity_ diff (" << a.vad_activity_
+ << " != " << b.vad_activity_ << ")";
return ::testing::AssertionSuccess();
}
@@ -1520,9 +1503,9 @@
::testing::AssertionResult res = AudioFramesEqualExceptData(a, b);
if (!res)
return res;
- if (memcmp(
- a.data(), b.data(),
- a.samples_per_channel_ * a.num_channels_ * sizeof(*a.data())) != 0) {
+ if (memcmp(a.data(), b.data(),
+ a.samples_per_channel_ * a.num_channels_ * sizeof(*a.data())) !=
+ 0) {
return ::testing::AssertionFailure() << "data_ diff";
}
return ::testing::AssertionSuccess();
diff --git a/modules/audio_coding/neteq/normal.cc b/modules/audio_coding/neteq/normal.cc
index f10158c..83f7616 100644
--- a/modules/audio_coding/neteq/normal.cc
+++ b/modules/audio_coding/neteq/normal.cc
@@ -76,8 +76,7 @@
// Adjust muting factor if needed (to BGN level).
size_t energy_length =
std::min(static_cast<size_t>(fs_mult * 64), length_per_channel);
- int scaling = 6 + fs_shift
- - WebRtcSpl_NormW32(decoded_max * decoded_max);
+ int scaling = 6 + fs_shift - WebRtcSpl_NormW32(decoded_max * decoded_max);
scaling = std::max(scaling, 0); // |scaling| should always be >= 0.
int32_t energy = WebRtcSpl_DotProductWithScale(signal.get(), signal.get(),
energy_length, scaling);
@@ -90,8 +89,7 @@
}
int local_mute_factor = 16384; // 1.0 in Q14.
- if ((energy != 0) &&
- (energy > background_noise_.Energy(channel_ix))) {
+ if ((energy != 0) && (energy > background_noise_.Energy(channel_ix))) {
// Normalize new frame energy to 15 bits.
scaling = WebRtcSpl_NormW32(energy) - 16;
// We want background_noise_.energy() / energy in Q14.
diff --git a/modules/audio_coding/neteq/normal.h b/modules/audio_coding/neteq/normal.h
index 14323ea..41bd30a 100644
--- a/modules/audio_coding/neteq/normal.h
+++ b/modules/audio_coding/neteq/normal.h
@@ -54,7 +54,8 @@
// |output| defines the number of channels that will be used when
// de-interleaving |input|. |last_mode| contains the mode used in the previous
// GetAudio call (i.e., not the current one).
- int Process(const int16_t* input, size_t length,
+ int Process(const int16_t* input,
+ size_t length,
Modes last_mode,
AudioMultiVector* output);
diff --git a/modules/audio_coding/neteq/normal_unittest.cc b/modules/audio_coding/neteq/normal_unittest.cc
index ab99d9a..106762a 100644
--- a/modules/audio_coding/neteq/normal_unittest.cc
+++ b/modules/audio_coding/neteq/normal_unittest.cc
@@ -39,7 +39,7 @@
return 0;
}
-} // namespace
+} // namespace
TEST(Normal, CreateAndDestroy) {
MockDecoderDatabase db;
@@ -84,10 +84,7 @@
// and using this as a denominator would lead to problems.
int input_size_samples = 63;
EXPECT_EQ(input_size_samples,
- normal.Process(input,
- input_size_samples,
- kModeExpand,
- &output));
+ normal.Process(input, input_size_samples, kModeExpand, &output));
EXPECT_CALL(db, Die()); // Called when |db| goes out of scope.
EXPECT_CALL(expand, Die()); // Called when |expand| goes out of scope.
@@ -139,10 +136,7 @@
EXPECT_CALL(expand, Process(_)).WillOnce(Invoke(ExpandProcess120ms));
EXPECT_CALL(expand, Reset());
EXPECT_EQ(static_cast<int>(kPacketsizeBytes),
- normal.Process(input,
- kPacketsizeBytes,
- kModeExpand,
- &output));
+ normal.Process(input, kPacketsizeBytes, kModeExpand, &output));
EXPECT_EQ(kPacketsizeBytes, output.Size());
diff --git a/modules/audio_coding/neteq/packet_buffer.cc b/modules/audio_coding/neteq/packet_buffer.cc
index f7b622d..c04534e 100644
--- a/modules/audio_coding/neteq/packet_buffer.cc
+++ b/modules/audio_coding/neteq/packet_buffer.cc
@@ -29,11 +29,8 @@
class NewTimestampIsLarger {
public:
explicit NewTimestampIsLarger(const Packet& new_packet)
- : new_packet_(new_packet) {
- }
- bool operator()(const Packet& packet) {
- return (new_packet_ >= packet);
- }
+ : new_packet_(new_packet) {}
+ bool operator()(const Packet& packet) { return (new_packet_ >= packet); }
private:
const Packet& new_packet_;
@@ -102,8 +99,7 @@
// should be inserted. The list is searched from the back, since the most
// likely case is that the new packet should be near the end of the list.
PacketList::reverse_iterator rit = std::find_if(
- buffer_.rbegin(), buffer_.rend(),
- NewTimestampIsLarger(packet));
+ buffer_.rbegin(), buffer_.rend(), NewTimestampIsLarger(packet));
// The new packet is to be inserted to the right of |rit|. If it has the same
// timestamp as |rit|, which has a higher priority, do not insert the new
diff --git a/modules/audio_coding/neteq/post_decode_vad.cc b/modules/audio_coding/neteq/post_decode_vad.cc
index a09d18f..9999d67 100644
--- a/modules/audio_coding/neteq/post_decode_vad.cc
+++ b/modules/audio_coding/neteq/post_decode_vad.cc
@@ -45,7 +45,8 @@
}
}
-void PostDecodeVad::Update(int16_t* signal, size_t length,
+void PostDecodeVad::Update(int16_t* signal,
+ size_t length,
AudioDecoder::SpeechType speech_type,
bool sid_frame,
int fs_hz) {
@@ -72,13 +73,13 @@
active_speech_ = false;
// Loop through frame sizes 30, 20, and 10 ms.
for (int vad_frame_size_ms = 30; vad_frame_size_ms >= 10;
- vad_frame_size_ms -= 10) {
+ vad_frame_size_ms -= 10) {
size_t vad_frame_size_samples =
static_cast<size_t>(vad_frame_size_ms * fs_hz / 1000);
while (length - vad_sample_index >= vad_frame_size_samples) {
- int vad_return = WebRtcVad_Process(
- vad_instance_, fs_hz, &signal[vad_sample_index],
- vad_frame_size_samples);
+ int vad_return =
+ WebRtcVad_Process(vad_instance_, fs_hz, &signal[vad_sample_index],
+ vad_frame_size_samples);
active_speech_ |= (vad_return == 1);
vad_sample_index += vad_frame_size_samples;
}
diff --git a/modules/audio_coding/neteq/post_decode_vad.h b/modules/audio_coding/neteq/post_decode_vad.h
index 7b67bbe..dac95f0 100644
--- a/modules/audio_coding/neteq/post_decode_vad.h
+++ b/modules/audio_coding/neteq/post_decode_vad.h
@@ -30,8 +30,7 @@
running_(false),
active_speech_(true),
sid_interval_counter_(0),
- vad_instance_(NULL) {
- }
+ vad_instance_(NULL) {}
virtual ~PostDecodeVad();
@@ -46,8 +45,11 @@
// Updates post-decode VAD with the audio data in |signal| having |length|
// samples. The data is of type |speech_type|, at the sample rate |fs_hz|.
- void Update(int16_t* signal, size_t length,
- AudioDecoder::SpeechType speech_type, bool sid_frame, int fs_hz);
+ void Update(int16_t* signal,
+ size_t length,
+ AudioDecoder::SpeechType speech_type,
+ bool sid_frame,
+ int fs_hz);
// Accessors.
bool enabled() const { return enabled_; }
diff --git a/modules/audio_coding/neteq/preemptive_expand.cc b/modules/audio_coding/neteq/preemptive_expand.cc
index bc75389..4702078 100644
--- a/modules/audio_coding/neteq/preemptive_expand.cc
+++ b/modules/audio_coding/neteq/preemptive_expand.cc
@@ -50,8 +50,7 @@
// but we must ensure that best_correlation is not larger than the length of
// the new data.
// but we must ensure that best_correlation is not larger than the new data.
- *peak_index = std::min(*peak_index,
- len - old_data_length_per_channel_);
+ *peak_index = std::min(*peak_index, len - old_data_length_per_channel_);
}
PreemptiveExpand::ReturnCodes PreemptiveExpand::CheckCriteriaAndStretch(
@@ -68,13 +67,13 @@
// Check for strong correlation (>0.9 in Q14) and at least 15 ms new data,
// or passive speech.
if (((best_correlation > kCorrelationThreshold) &&
- (old_data_length_per_channel_ <= fs_mult_120)) ||
+ (old_data_length_per_channel_ <= fs_mult_120)) ||
!active_speech) {
// Do accelerate operation by overlap add.
// Set length of the first part, not to be modified.
- size_t unmodified_length = std::max(old_data_length_per_channel_,
- fs_mult_120);
+ size_t unmodified_length =
+ std::max(old_data_length_per_channel_, fs_mult_120);
// Copy first part, including cross-fade region.
output->PushBackInterleaved(
input, (unmodified_length + peak_index) * num_channels_);
@@ -107,8 +106,8 @@
size_t num_channels,
const BackgroundNoise& background_noise,
size_t overlap_samples) const {
- return new PreemptiveExpand(
- sample_rate_hz, num_channels, background_noise, overlap_samples);
+ return new PreemptiveExpand(sample_rate_hz, num_channels, background_noise,
+ overlap_samples);
}
} // namespace webrtc
diff --git a/modules/audio_coding/neteq/preemptive_expand.h b/modules/audio_coding/neteq/preemptive_expand.h
index 303501d..197d3f1 100644
--- a/modules/audio_coding/neteq/preemptive_expand.h
+++ b/modules/audio_coding/neteq/preemptive_expand.h
@@ -35,15 +35,14 @@
size_t overlap_samples)
: TimeStretch(sample_rate_hz, num_channels, background_noise),
old_data_length_per_channel_(0),
- overlap_samples_(overlap_samples) {
- }
+ overlap_samples_(overlap_samples) {}
// This method performs the actual PreemptiveExpand operation. The samples are
// read from |input|, of length |input_length| elements, and are written to
// |output|. The number of samples added through time-stretching is
// is provided in the output |length_change_samples|. The method returns
// the outcome of the operation as an enumerator value.
- ReturnCodes Process(const int16_t *pw16_decoded,
+ ReturnCodes Process(const int16_t* pw16_decoded,
size_t len,
size_t old_data_len,
AudioMultiVector* output,
@@ -77,11 +76,10 @@
PreemptiveExpandFactory() {}
virtual ~PreemptiveExpandFactory() {}
- virtual PreemptiveExpand* Create(
- int sample_rate_hz,
- size_t num_channels,
- const BackgroundNoise& background_noise,
- size_t overlap_samples) const;
+ virtual PreemptiveExpand* Create(int sample_rate_hz,
+ size_t num_channels,
+ const BackgroundNoise& background_noise,
+ size_t overlap_samples) const;
};
} // namespace webrtc
diff --git a/modules/audio_coding/neteq/random_vector.cc b/modules/audio_coding/neteq/random_vector.cc
index c2df8cf..ada1758 100644
--- a/modules/audio_coding/neteq/random_vector.cc
+++ b/modules/audio_coding/neteq/random_vector.cc
@@ -13,29 +13,35 @@
namespace webrtc {
const int16_t RandomVector::kRandomTable[RandomVector::kRandomTableSize] = {
- 2680, 5532, 441, 5520, 16170, -5146, -1024, -8733, 3115, 9598, -10380,
- -4959, -1280, -21716, 7133, -1522, 13458, -3902, 2789, -675, 3441, 5016,
- -13599, -4003, -2739, 3922, -7209, 13352, -11617, -7241, 12905, -2314, 5426,
- 10121, -9702, 11207, -13542, 1373, 816, -5934, -12504, 4798, 1811, 4112,
- -613, 201, -10367, -2960, -2419, 3442, 4299, -6116, -6092, 1552, -1650,
- -480, -1237, 18720, -11858, -8303, -8212, 865, -2890, -16968, 12052, -5845,
- -5912, 9777, -5665, -6294, 5426, -4737, -6335, 1652, 761, 3832, 641, -8552,
- -9084, -5753, 8146, 12156, -4915, 15086, -1231, -1869, 11749, -9319, -6403,
- 11407, 6232, -1683, 24340, -11166, 4017, -10448, 3153, -2936, 6212, 2891,
- -866, -404, -4807, -2324, -1917, -2388, -6470, -3895, -10300, 5323, -5403,
- 2205, 4640, 7022, -21186, -6244, -882, -10031, -3395, -12885, 7155, -5339,
- 5079, -2645, -9515, 6622, 14651, 15852, 359, 122, 8246, -3502, -6696, -3679,
- -13535, -1409, -704, -7403, -4007, 1798, 279, -420, -12796, -14219, 1141,
- 3359, 11434, 7049, -6684, -7473, 14283, -4115, -9123, -8969, 4152, 4117,
- 13792, 5742, 16168, 8661, -1609, -6095, 1881, 14380, -5588, 6758, -6425,
- -22969, -7269, 7031, 1119, -1611, -5850, -11281, 3559, -8952, -10146, -4667,
- -16251, -1538, 2062, -1012, -13073, 227, -3142, -5265, 20, 5770, -7559,
- 4740, -4819, 992, -8208, -7130, -4652, 6725, 7369, -1036, 13144, -1588,
- -5304, -2344, -449, -5705, -8894, 5205, -17904, -11188, -1022, 4852, 10101,
- -5255, -4200, -752, 7941, -1543, 5959, 14719, 13346, 17045, -15605, -1678,
- -1600, -9230, 68, 23348, 1172, 7750, 11212, -18227, 9956, 4161, 883, 3947,
- 4341, 1014, -4889, -2603, 1246, -5630, -3596, -870, -1298, 2784, -3317,
- -6612, -20541, 4166, 4181, -8625, 3562, 12890, 4761, 3205, -12259, -8579 };
+ 2680, 5532, 441, 5520, 16170, -5146, -1024, -8733, 3115,
+ 9598, -10380, -4959, -1280, -21716, 7133, -1522, 13458, -3902,
+ 2789, -675, 3441, 5016, -13599, -4003, -2739, 3922, -7209,
+ 13352, -11617, -7241, 12905, -2314, 5426, 10121, -9702, 11207,
+ -13542, 1373, 816, -5934, -12504, 4798, 1811, 4112, -613,
+ 201, -10367, -2960, -2419, 3442, 4299, -6116, -6092, 1552,
+ -1650, -480, -1237, 18720, -11858, -8303, -8212, 865, -2890,
+ -16968, 12052, -5845, -5912, 9777, -5665, -6294, 5426, -4737,
+ -6335, 1652, 761, 3832, 641, -8552, -9084, -5753, 8146,
+ 12156, -4915, 15086, -1231, -1869, 11749, -9319, -6403, 11407,
+ 6232, -1683, 24340, -11166, 4017, -10448, 3153, -2936, 6212,
+ 2891, -866, -404, -4807, -2324, -1917, -2388, -6470, -3895,
+ -10300, 5323, -5403, 2205, 4640, 7022, -21186, -6244, -882,
+ -10031, -3395, -12885, 7155, -5339, 5079, -2645, -9515, 6622,
+ 14651, 15852, 359, 122, 8246, -3502, -6696, -3679, -13535,
+ -1409, -704, -7403, -4007, 1798, 279, -420, -12796, -14219,
+ 1141, 3359, 11434, 7049, -6684, -7473, 14283, -4115, -9123,
+ -8969, 4152, 4117, 13792, 5742, 16168, 8661, -1609, -6095,
+ 1881, 14380, -5588, 6758, -6425, -22969, -7269, 7031, 1119,
+ -1611, -5850, -11281, 3559, -8952, -10146, -4667, -16251, -1538,
+ 2062, -1012, -13073, 227, -3142, -5265, 20, 5770, -7559,
+ 4740, -4819, 992, -8208, -7130, -4652, 6725, 7369, -1036,
+ 13144, -1588, -5304, -2344, -449, -5705, -8894, 5205, -17904,
+ -11188, -1022, 4852, 10101, -5255, -4200, -752, 7941, -1543,
+ 5959, 14719, 13346, 17045, -15605, -1678, -1600, -9230, 68,
+ 23348, 1172, 7750, 11212, -18227, 9956, 4161, 883, 3947,
+ 4341, 1014, -4889, -2603, 1246, -5630, -3596, -870, -1298,
+ 2784, -3317, -6612, -20541, 4166, 4181, -8625, 3562, 12890,
+ 4761, 3205, -12259, -8579};
void RandomVector::Reset() {
seed_ = 777;
@@ -51,7 +57,7 @@
}
void RandomVector::IncreaseSeedIncrement(int16_t increase_by) {
- seed_increment_+= increase_by;
+ seed_increment_ += increase_by;
seed_increment_ &= kRandomTableSize - 1;
}
} // namespace webrtc
diff --git a/modules/audio_coding/neteq/random_vector.h b/modules/audio_coding/neteq/random_vector.h
index 18adbe0..2c6e06c 100644
--- a/modules/audio_coding/neteq/random_vector.h
+++ b/modules/audio_coding/neteq/random_vector.h
@@ -24,10 +24,7 @@
static const size_t kRandomTableSize = 256;
static const int16_t kRandomTable[kRandomTableSize];
- RandomVector()
- : seed_(777),
- seed_increment_(1) {
- }
+ RandomVector() : seed_(777), seed_increment_(1) {}
void Reset();
diff --git a/modules/audio_coding/neteq/red_payload_splitter_unittest.cc b/modules/audio_coding/neteq/red_payload_splitter_unittest.cc
index c3d9f33..73cd66c 100644
--- a/modules/audio_coding/neteq/red_payload_splitter_unittest.cc
+++ b/modules/audio_coding/neteq/red_payload_splitter_unittest.cc
@@ -100,8 +100,8 @@
// Not the last block; set F = 1.
*payload_ptr |= 0x80;
++payload_ptr;
- int this_offset = rtc::checked_cast<int>(
- (num_payloads - i - 1) * timestamp_offset);
+ int this_offset =
+ rtc::checked_cast<int>((num_payloads - i - 1) * timestamp_offset);
*payload_ptr = this_offset >> 6;
++payload_ptr;
assert(kPayloadLength <= 1023); // Max length described by 10 bits.
diff --git a/modules/audio_coding/neteq/rtcp.h b/modules/audio_coding/neteq/rtcp.h
index ce2035b..45bb058 100644
--- a/modules/audio_coding/neteq/rtcp.h
+++ b/modules/audio_coding/neteq/rtcp.h
@@ -22,9 +22,7 @@
class Rtcp {
public:
- Rtcp() {
- Init(0);
- }
+ Rtcp() { Init(0); }
~Rtcp() {}
@@ -39,17 +37,17 @@
void GetStatistics(bool no_reset, RtcpStatistics* stats);
private:
- uint16_t cycles_; // The number of wrap-arounds for the sequence number.
- uint16_t max_seq_no_; // The maximum sequence number received. Starts over
- // from 0 after wrap-around.
+ uint16_t cycles_; // The number of wrap-arounds for the sequence number.
+ uint16_t max_seq_no_; // The maximum sequence number received. Starts over
+ // from 0 after wrap-around.
uint16_t base_seq_no_; // The sequence number of the first received packet.
uint32_t received_packets_; // The number of packets that have been received.
uint32_t received_packets_prior_; // Number of packets received when last
// report was generated.
uint32_t expected_prior_; // Expected number of packets, at the time of the
// last report.
- int64_t jitter_; // Current jitter value in Q4.
- int32_t transit_; // Clock difference for previous packet.
+ int64_t jitter_; // Current jitter value in Q4.
+ int32_t transit_; // Clock difference for previous packet.
RTC_DISALLOW_COPY_AND_ASSIGN(Rtcp);
};
diff --git a/modules/audio_coding/neteq/statistics_calculator.cc b/modules/audio_coding/neteq/statistics_calculator.cc
index c698790..3d5744c 100644
--- a/modules/audio_coding/neteq/statistics_calculator.cc
+++ b/modules/audio_coding/neteq/statistics_calculator.cc
@@ -42,8 +42,7 @@
: uma_name_(uma_name),
report_interval_ms_(report_interval_ms),
max_value_(max_value),
- timer_(0) {
-}
+ timer_(0) {}
StatisticsCalculator::PeriodicUmaLogger::~PeriodicUmaLogger() = default;
@@ -66,8 +65,7 @@
const std::string& uma_name,
int report_interval_ms,
int max_value)
- : PeriodicUmaLogger(uma_name, report_interval_ms, max_value) {
-}
+ : PeriodicUmaLogger(uma_name, report_interval_ms, max_value) {}
StatisticsCalculator::PeriodicUmaCount::~PeriodicUmaCount() {
// Log the count for the current (incomplete) interval.
@@ -90,8 +88,7 @@
const std::string& uma_name,
int report_interval_ms,
int max_value)
- : PeriodicUmaLogger(uma_name, report_interval_ms, max_value) {
-}
+ : PeriodicUmaLogger(uma_name, report_interval_ms, max_value) {}
StatisticsCalculator::PeriodicUmaAverage::~PeriodicUmaAverage() {
// Log the average for the current (incomplete) interval.
@@ -266,11 +263,10 @@
waiting_times_.push_back(waiting_time_ms);
}
-void StatisticsCalculator::GetNetworkStatistics(
- int fs_hz,
- size_t num_samples_in_buffers,
- size_t samples_per_packet,
- NetEqNetworkStatistics *stats) {
+void StatisticsCalculator::GetNetworkStatistics(int fs_hz,
+ size_t num_samples_in_buffers,
+ size_t samples_per_packet,
+ NetEqNetworkStatistics* stats) {
RTC_DCHECK_GT(fs_hz, 0);
RTC_DCHECK(stats);
@@ -291,20 +287,18 @@
CalculateQ14Ratio(expanded_speech_samples_ + expanded_noise_samples_,
timestamps_since_last_report_);
- stats->speech_expand_rate =
- CalculateQ14Ratio(expanded_speech_samples_,
- timestamps_since_last_report_);
+ stats->speech_expand_rate = CalculateQ14Ratio(expanded_speech_samples_,
+ timestamps_since_last_report_);
- stats->secondary_decoded_rate =
- CalculateQ14Ratio(secondary_decoded_samples_,
- timestamps_since_last_report_);
+ stats->secondary_decoded_rate = CalculateQ14Ratio(
+ secondary_decoded_samples_, timestamps_since_last_report_);
const size_t discarded_secondary_samples =
discarded_secondary_packets_ * samples_per_packet;
- stats->secondary_discarded_rate = CalculateQ14Ratio(
- discarded_secondary_samples,
- static_cast<uint32_t>(discarded_secondary_samples +
- secondary_decoded_samples_));
+ stats->secondary_discarded_rate =
+ CalculateQ14Ratio(discarded_secondary_samples,
+ static_cast<uint32_t>(discarded_secondary_samples +
+ secondary_decoded_samples_));
if (waiting_times_.size() == 0) {
stats->mean_waiting_time_ms = -1;
diff --git a/modules/audio_coding/neteq/statistics_calculator.h b/modules/audio_coding/neteq/statistics_calculator.h
index a06ddfb..42fd4c9 100644
--- a/modules/audio_coding/neteq/statistics_calculator.h
+++ b/modules/audio_coding/neteq/statistics_calculator.h
@@ -98,7 +98,7 @@
void GetNetworkStatistics(int fs_hz,
size_t num_samples_in_buffers,
size_t samples_per_packet,
- NetEqNetworkStatistics *stats);
+ NetEqNetworkStatistics* stats);
// Populates |preferred_buffer_size_ms|, |jitter_peaks_found| and
// |clockdrift_ppm| in |stats|. This is a convenience method, and does not
diff --git a/modules/audio_coding/neteq/sync_buffer.cc b/modules/audio_coding/neteq/sync_buffer.cc
index 28d7649..82ca16f 100644
--- a/modules/audio_coding/neteq/sync_buffer.cc
+++ b/modules/audio_coding/neteq/sync_buffer.cc
@@ -27,7 +27,7 @@
next_index_ -= samples_added;
} else {
// This means that we are pushing out future data that was never used.
-// assert(false);
+ // assert(false);
// TODO(hlundin): This assert must be disabled to support 60 ms frames.
// This should not happen even for 60 ms frames, but it does. Investigate
// why.
@@ -75,9 +75,8 @@
RTC_DCHECK(output);
const size_t samples_to_read = std::min(FutureLength(), requested_len);
output->ResetWithoutMuting();
- const size_t tot_samples_read =
- ReadInterleavedFromIndex(next_index_, samples_to_read,
- output->mutable_data());
+ const size_t tot_samples_read = ReadInterleavedFromIndex(
+ next_index_, samples_to_read, output->mutable_data());
const size_t samples_read_per_channel = tot_samples_read / Channels();
next_index_ += samples_read_per_channel;
output->num_channels_ = Channels();
diff --git a/modules/audio_coding/neteq/sync_buffer.h b/modules/audio_coding/neteq/sync_buffer.h
index d880356..8a35326 100644
--- a/modules/audio_coding/neteq/sync_buffer.h
+++ b/modules/audio_coding/neteq/sync_buffer.h
@@ -92,7 +92,7 @@
private:
size_t next_index_;
uint32_t end_timestamp_; // The timestamp of the last sample in the buffer.
- size_t dtmf_index_; // Index to the first non-DTMF sample in the buffer.
+ size_t dtmf_index_; // Index to the first non-DTMF sample in the buffer.
RTC_DISALLOW_COPY_AND_ASSIGN(SyncBuffer);
};
diff --git a/modules/audio_coding/neteq/test/neteq_ilbc_quality_test.cc b/modules/audio_coding/neteq/test/neteq_ilbc_quality_test.cc
index bca401a..ad61235 100644
--- a/modules/audio_coding/neteq/test/neteq_ilbc_quality_test.cc
+++ b/modules/audio_coding/neteq/test/neteq_ilbc_quality_test.cc
@@ -52,7 +52,8 @@
int EncodeBlock(int16_t* in_data,
size_t block_size_samples,
- rtc::Buffer* payload, size_t max_bytes) override {
+ rtc::Buffer* payload,
+ size_t max_bytes) override {
const size_t kFrameSizeSamples = 80; // Samples per 10 ms.
size_t encoded_samples = 0;
uint32_t dummy_timestamp = 0;
diff --git a/modules/audio_coding/neteq/test/neteq_isac_quality_test.cc b/modules/audio_coding/neteq/test/neteq_isac_quality_test.cc
index d88f789..94984b87 100644
--- a/modules/audio_coding/neteq/test/neteq_isac_quality_test.cc
+++ b/modules/audio_coding/neteq/test/neteq_isac_quality_test.cc
@@ -30,8 +30,11 @@
NetEqIsacQualityTest();
void SetUp() override;
void TearDown() override;
- int EncodeBlock(int16_t* in_data, size_t block_size_samples,
- rtc::Buffer* payload, size_t max_bytes) override;
+ int EncodeBlock(int16_t* in_data,
+ size_t block_size_samples,
+ rtc::Buffer* payload,
+ size_t max_bytes) override;
+
private:
ISACFIX_MainStruct* isac_encoder_;
int bit_rate_kbps_;
@@ -44,10 +47,10 @@
NetEqDecoder::kDecoderISAC),
isac_encoder_(NULL),
bit_rate_kbps_(FLAG_bit_rate_kbps) {
- // Flag validation
- RTC_CHECK(FLAG_bit_rate_kbps >= 10 && FLAG_bit_rate_kbps <= 32)
- << "Invalid bit rate, should be between 10 and 32 kbps.";
- }
+ // Flag validation
+ RTC_CHECK(FLAG_bit_rate_kbps >= 10 && FLAG_bit_rate_kbps <= 32)
+ << "Invalid bit rate, should be between 10 and 32 kbps.";
+}
void NetEqIsacQualityTest::SetUp() {
ASSERT_EQ(1u, channels_) << "iSAC supports only mono audio.";
@@ -69,7 +72,8 @@
int NetEqIsacQualityTest::EncodeBlock(int16_t* in_data,
size_t block_size_samples,
- rtc::Buffer* payload, size_t max_bytes) {
+ rtc::Buffer* payload,
+ size_t max_bytes) {
// ISAC takes 10 ms for every call.
const int subblocks = kIsacBlockDurationMs / 10;
const int subblock_length = 10 * kIsacInputSamplingKhz;
@@ -80,11 +84,11 @@
// The Isac encoder does not perform encoding (and returns 0) until it
// receives a sequence of sub-blocks that amount to the frame duration.
EXPECT_EQ(0, value);
- payload->AppendData(max_bytes, [&] (rtc::ArrayView<uint8_t> payload) {
- value = WebRtcIsacfix_Encode(isac_encoder_, &in_data[pointer],
- payload.data());
- return (value >= 0) ? static_cast<size_t>(value) : 0;
- });
+ payload->AppendData(max_bytes, [&](rtc::ArrayView<uint8_t> payload) {
+ value = WebRtcIsacfix_Encode(isac_encoder_, &in_data[pointer],
+ payload.data());
+ return (value >= 0) ? static_cast<size_t>(value) : 0;
+ });
}
EXPECT_GT(value, 0);
return value;
diff --git a/modules/audio_coding/neteq/test/neteq_opus_quality_test.cc b/modules/audio_coding/neteq/test/neteq_opus_quality_test.cc
index c2542b6..6861e4c 100644
--- a/modules/audio_coding/neteq/test/neteq_opus_quality_test.cc
+++ b/modules/audio_coding/neteq/test/neteq_opus_quality_test.cc
@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "modules/audio_coding/codecs/opus/opus_interface.h"
#include "modules/audio_coding/codecs/opus/opus_inst.h"
+#include "modules/audio_coding/codecs/opus/opus_interface.h"
#include "modules/audio_coding/neteq/tools/neteq_quality_test.h"
#include "rtc_base/flags.h"
@@ -24,8 +24,10 @@
DEFINE_int(bit_rate_kbps, 32, "Target bit rate (kbps).");
-DEFINE_int(complexity, 10, "Complexity: 0 ~ 10 -- defined as in Opus"
- "specification.");
+DEFINE_int(complexity,
+ 10,
+ "Complexity: 0 ~ 10 -- defined as in Opus"
+ "specification.");
DEFINE_int(maxplaybackrate, 48000, "Maximum playback rate (Hz).");
@@ -46,8 +48,11 @@
NetEqOpusQualityTest();
void SetUp() override;
void TearDown() override;
- int EncodeBlock(int16_t* in_data, size_t block_size_samples,
- rtc::Buffer* payload, size_t max_bytes) override;
+ int EncodeBlock(int16_t* in_data,
+ size_t block_size_samples,
+ rtc::Buffer* payload,
+ size_t max_bytes) override;
+
private:
WebRtcOpusEncInst* opus_encoder_;
OpusRepacketizer* repacketizer_;
@@ -120,8 +125,7 @@
}
EXPECT_EQ(0, WebRtcOpus_SetComplexity(opus_encoder_, complexity_));
EXPECT_EQ(0, WebRtcOpus_SetMaxPlaybackRate(opus_encoder_, maxplaybackrate_));
- EXPECT_EQ(0, WebRtcOpus_SetPacketLossRate(opus_encoder_,
- target_loss_rate_));
+ EXPECT_EQ(0, WebRtcOpus_SetPacketLossRate(opus_encoder_, target_loss_rate_));
NetEqQualityTest::SetUp();
}
@@ -134,26 +138,25 @@
int NetEqOpusQualityTest::EncodeBlock(int16_t* in_data,
size_t block_size_samples,
- rtc::Buffer* payload, size_t max_bytes) {
+ rtc::Buffer* payload,
+ size_t max_bytes) {
EXPECT_EQ(block_size_samples, sub_block_size_samples_ * sub_packets_);
int16_t* pointer = in_data;
int value;
opus_repacketizer_init(repacketizer_);
for (int idx = 0; idx < sub_packets_; idx++) {
- payload->AppendData(max_bytes, [&] (rtc::ArrayView<uint8_t> payload) {
- value = WebRtcOpus_Encode(opus_encoder_,
- pointer, sub_block_size_samples_,
- max_bytes, payload.data());
+ payload->AppendData(max_bytes, [&](rtc::ArrayView<uint8_t> payload) {
+ value = WebRtcOpus_Encode(opus_encoder_, pointer, sub_block_size_samples_,
+ max_bytes, payload.data());
- Log() << "Encoded a frame with Opus mode "
- << (value == 0 ? 0 : payload[0] >> 3)
- << std::endl;
+ Log() << "Encoded a frame with Opus mode "
+ << (value == 0 ? 0 : payload[0] >> 3) << std::endl;
- return (value >= 0) ? static_cast<size_t>(value) : 0;
- });
+ return (value >= 0) ? static_cast<size_t>(value) : 0;
+ });
- if (OPUS_OK != opus_repacketizer_cat(repacketizer_,
- payload->data(), value)) {
+ if (OPUS_OK !=
+ opus_repacketizer_cat(repacketizer_, payload->data(), value)) {
opus_repacketizer_init(repacketizer_);
// If the repacketization fails, we discard this frame.
return 0;
diff --git a/modules/audio_coding/neteq/test/neteq_pcmu_quality_test.cc b/modules/audio_coding/neteq/test/neteq_pcmu_quality_test.cc
index bc3c168..54ff849 100644
--- a/modules/audio_coding/neteq/test/neteq_pcmu_quality_test.cc
+++ b/modules/audio_coding/neteq/test/neteq_pcmu_quality_test.cc
@@ -52,7 +52,8 @@
int EncodeBlock(int16_t* in_data,
size_t block_size_samples,
- rtc::Buffer* payload, size_t max_bytes) override {
+ rtc::Buffer* payload,
+ size_t max_bytes) override {
const size_t kFrameSizeSamples = 80; // Samples per 10 ms.
size_t encoded_samples = 0;
uint32_t dummy_timestamp = 0;
diff --git a/modules/audio_coding/neteq/test/neteq_performance_unittest.cc b/modules/audio_coding/neteq/test/neteq_performance_unittest.cc
index 0510af8..6b1c223 100644
--- a/modules/audio_coding/neteq/test/neteq_performance_unittest.cc
+++ b/modules/audio_coding/neteq/test/neteq_performance_unittest.cc
@@ -9,10 +9,10 @@
*/
#include "modules/audio_coding/neteq/tools/neteq_performance_test.h"
+#include "system_wrappers/include/field_trial.h"
#include "test/gtest.h"
#include "test/testsupport/perf_test.h"
#include "typedefs.h" // NOLINT(build/include)
-#include "system_wrappers/include/field_trial.h"
// Runs a test with 10% packet losses and 10% clock drift, to exercise
// both loss concealment and time-stretching code.
@@ -27,8 +27,8 @@
: kSimulationTimeMs,
kLossPeriod, kDriftFactor);
ASSERT_GT(runtime, 0);
- webrtc::test::PrintResult(
- "neteq_performance", "", "10_pl_10_drift", runtime, "ms", true);
+ webrtc::test::PrintResult("neteq_performance", "", "10_pl_10_drift", runtime,
+ "ms", true);
}
// Runs a test with neither packet losses nor clock drift, to put
@@ -37,7 +37,7 @@
TEST(NetEqPerformanceTest, RunClean) {
const int kSimulationTimeMs = 10000000;
const int kQuickSimulationTimeMs = 100000;
- const int kLossPeriod = 0; // No losses.
+ const int kLossPeriod = 0; // No losses.
const double kDriftFactor = 0.0; // No clock drift.
int64_t runtime = webrtc::test::NetEqPerformanceTest::Run(
webrtc::field_trial::IsEnabled("WebRTC-QuickPerfTest")
@@ -45,6 +45,6 @@
: kSimulationTimeMs,
kLossPeriod, kDriftFactor);
ASSERT_GT(runtime, 0);
- webrtc::test::PrintResult(
- "neteq_performance", "", "0_pl_0_drift", runtime, "ms", true);
+ webrtc::test::PrintResult("neteq_performance", "", "0_pl_0_drift", runtime,
+ "ms", true);
}
diff --git a/modules/audio_coding/neteq/test/neteq_speed_test.cc b/modules/audio_coding/neteq/test/neteq_speed_test.cc
index ad123fe..76b6878 100644
--- a/modules/audio_coding/neteq/test/neteq_speed_test.cc
+++ b/modules/audio_coding/neteq/test/neteq_speed_test.cc
@@ -19,23 +19,24 @@
// Define command line flags.
DEFINE_int(runtime_ms, 10000, "Simulated runtime in ms.");
-DEFINE_int(lossrate, 10,
- "Packet lossrate; drop every N packets.");
-DEFINE_float(drift, 0.1f,
- "Clockdrift factor.");
+DEFINE_int(lossrate, 10, "Packet lossrate; drop every N packets.");
+DEFINE_float(drift, 0.1f, "Clockdrift factor.");
DEFINE_bool(help, false, "Print this message.");
int main(int argc, char* argv[]) {
std::string program_name = argv[0];
- std::string usage = "Tool for measuring the speed of NetEq.\n"
- "Usage: " + program_name + " [options]\n\n"
+ std::string usage =
+ "Tool for measuring the speed of NetEq.\n"
+ "Usage: " +
+ program_name +
+ " [options]\n\n"
" --runtime_ms=N runtime in ms; default is 10000 ms\n"
" --lossrate=N drop every N packets; default is 10\n"
" --drift=F clockdrift factor between 0.0 and 1.0; "
"default is 0.1\n";
webrtc::test::SetExecutablePath(argv[0]);
- if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) ||
- FLAG_help || argc != 1) {
+ if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || FLAG_help ||
+ argc != 1) {
printf("%s", usage.c_str());
if (FLAG_help) {
rtc::FlagList::Print(nullptr, false);
@@ -47,9 +48,8 @@
RTC_CHECK_GE(FLAG_lossrate, 0);
RTC_CHECK(FLAG_drift >= 0.0 && FLAG_drift < 1.0);
- int64_t result =
- webrtc::test::NetEqPerformanceTest::Run(FLAG_runtime_ms, FLAG_lossrate,
- FLAG_drift);
+ int64_t result = webrtc::test::NetEqPerformanceTest::Run(
+ FLAG_runtime_ms, FLAG_lossrate, FLAG_drift);
if (result <= 0) {
std::cout << "There was an error" << std::endl;
return -1;
diff --git a/modules/audio_coding/neteq/time_stretch.cc b/modules/audio_coding/neteq/time_stretch.cc
index 8a1bfa2..560d9be 100644
--- a/modules/audio_coding/neteq/time_stretch.cc
+++ b/modules/audio_coding/neteq/time_stretch.cc
@@ -80,7 +80,7 @@
// Calculate scaling to ensure that |peak_index| samples can be square-summed
// without overflowing.
int scaling = 31 - WebRtcSpl_NormW32(max_input_value_ * max_input_value_) -
- WebRtcSpl_NormW32(static_cast<int32_t>(peak_index));
+ WebRtcSpl_NormW32(static_cast<int32_t>(peak_index));
scaling = std::max(0, scaling);
// |vec1| starts at 15 ms minus one pitch period.
@@ -99,8 +99,8 @@
WebRtcSpl_DotProductWithScale(vec1, vec2, peak_index, scaling);
// Check if the signal seems to be active speech or not (simple VAD).
- bool active_speech = SpeechDetection(vec1_energy, vec2_energy, peak_index,
- scaling);
+ bool active_speech =
+ SpeechDetection(vec1_energy, vec2_energy, peak_index, scaling);
int16_t best_correlation;
if (!active_speech) {
@@ -126,8 +126,8 @@
static_cast<int16_t>(vec2_energy >> energy2_scale);
// Calculate square-root of energy product.
- int16_t sqrt_energy_prod = WebRtcSpl_SqrtFloor(vec1_energy_int16 *
- vec2_energy_int16);
+ int16_t sqrt_energy_prod =
+ WebRtcSpl_SqrtFloor(vec1_energy_int16 * vec2_energy_int16);
// Calculate cross_corr / sqrt(en1*en2) in Q14.
int temp_scale = 14 - (energy1_scale + energy2_scale) / 2;
@@ -138,7 +138,6 @@
best_correlation = std::min(static_cast<int16_t>(16384), best_correlation);
}
-
// Check accelerate criteria and stretch the signal.
ReturnCodes return_value =
CheckCriteriaAndStretch(input, input_len, peak_index, best_correlation,
@@ -172,8 +171,10 @@
auto_corr, scaling);
}
-bool TimeStretch::SpeechDetection(int32_t vec1_energy, int32_t vec2_energy,
- size_t peak_index, int scaling) const {
+bool TimeStretch::SpeechDetection(int32_t vec1_energy,
+ int32_t vec2_energy,
+ size_t peak_index,
+ int scaling) const {
// Check if the signal seems to be active speech or not (simple VAD).
// If (vec1_energy + vec2_energy) / (2 * peak_index) <=
// 8 * background_noise_energy, then we say that the signal contains no
diff --git a/modules/audio_coding/neteq/time_stretch.h b/modules/audio_coding/neteq/time_stretch.h
index ace10cd..606d1d0 100644
--- a/modules/audio_coding/neteq/time_stretch.h
+++ b/modules/audio_coding/neteq/time_stretch.h
@@ -35,7 +35,8 @@
kError = -1
};
- TimeStretch(int sample_rate_hz, size_t num_channels,
+ TimeStretch(int sample_rate_hz,
+ size_t num_channels,
const BackgroundNoise& background_noise)
: sample_rate_hz_(sample_rate_hz),
fs_mult_(sample_rate_hz / 8000),
@@ -43,10 +44,8 @@
master_channel_(0), // First channel is master.
background_noise_(background_noise),
max_input_value_(0) {
- assert(sample_rate_hz_ == 8000 ||
- sample_rate_hz_ == 16000 ||
- sample_rate_hz_ == 32000 ||
- sample_rate_hz_ == 48000);
+ assert(sample_rate_hz_ == 8000 || sample_rate_hz_ == 16000 ||
+ sample_rate_hz_ == 32000 || sample_rate_hz_ == 48000);
assert(num_channels_ > 0);
assert(master_channel_ < num_channels_);
memset(auto_correlation_, 0, sizeof(auto_correlation_));
@@ -106,8 +105,10 @@
void AutoCorrelation();
// Performs a simple voice-activity detection based on the input parameters.
- bool SpeechDetection(int32_t vec1_energy, int32_t vec2_energy,
- size_t peak_index, int scaling) const;
+ bool SpeechDetection(int32_t vec1_energy,
+ int32_t vec2_energy,
+ size_t peak_index,
+ int scaling) const;
RTC_DISALLOW_COPY_AND_ASSIGN(TimeStretch);
};
diff --git a/modules/audio_coding/neteq/time_stretch_unittest.cc b/modules/audio_coding/neteq/time_stretch_unittest.cc
index 8d0f4d4..c96c7d4 100644
--- a/modules/audio_coding/neteq/time_stretch_unittest.cc
+++ b/modules/audio_coding/neteq/time_stretch_unittest.cc
@@ -34,8 +34,8 @@
const int kOverlapSamples = 5 * kSampleRate / 8000;
BackgroundNoise bgn(kNumChannels);
Accelerate accelerate(kSampleRate, kNumChannels, bgn);
- PreemptiveExpand preemptive_expand(
- kSampleRate, kNumChannels, bgn, kOverlapSamples);
+ PreemptiveExpand preemptive_expand(kSampleRate, kNumChannels, bgn,
+ kOverlapSamples);
}
TEST(TimeStretch, CreateUsingFactory) {
diff --git a/modules/audio_coding/neteq/timestamp_scaler.cc b/modules/audio_coding/neteq/timestamp_scaler.cc
index d7aa9fe..07d945e 100644
--- a/modules/audio_coding/neteq/timestamp_scaler.cc
+++ b/modules/audio_coding/neteq/timestamp_scaler.cc
@@ -70,7 +70,6 @@
}
}
-
uint32_t TimestampScaler::ToExternal(uint32_t internal_timestamp) const {
if (!first_packet_received_ || (numerator_ == denominator_)) {
// Not initialized, or scale factor is 1.
diff --git a/modules/audio_coding/neteq/timestamp_scaler_unittest.cc b/modules/audio_coding/neteq/timestamp_scaler_unittest.cc
index eeaf772..1f1445a 100644
--- a/modules/audio_coding/neteq/timestamp_scaler_unittest.cc
+++ b/modules/audio_coding/neteq/timestamp_scaler_unittest.cc
@@ -8,10 +8,10 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#include "modules/audio_coding/neteq/timestamp_scaler.h"
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "modules/audio_coding/neteq/mock/mock_decoder_database.h"
#include "modules/audio_coding/neteq/packet.h"
-#include "modules/audio_coding/neteq/timestamp_scaler.h"
#include "test/gmock.h"
#include "test/gtest.h"
@@ -60,7 +60,7 @@
// |external_timestamp| will be a large positive value.
start_timestamp = start_timestamp - 5 * kStep;
for (uint32_t timestamp = start_timestamp; timestamp != 5 * kStep;
- timestamp += kStep) {
+ timestamp += kStep) {
// Scale to internal timestamp.
EXPECT_EQ(timestamp, scaler.ToInternal(timestamp, kRtpPayloadType));
// Scale back.
diff --git a/modules/audio_coding/neteq/tools/audio_loop.cc b/modules/audio_coding/neteq/tools/audio_loop.cc
index b5ad881..972921b 100644
--- a/modules/audio_coding/neteq/tools/audio_loop.cc
+++ b/modules/audio_coding/neteq/tools/audio_loop.cc
@@ -21,16 +21,18 @@
size_t max_loop_length_samples,
size_t block_length_samples) {
FILE* fp = fopen(file_name.c_str(), "rb");
- if (!fp) return false;
+ if (!fp)
+ return false;
- audio_array_.reset(new int16_t[max_loop_length_samples +
- block_length_samples]);
- size_t samples_read = fread(audio_array_.get(), sizeof(int16_t),
- max_loop_length_samples, fp);
+ audio_array_.reset(
+ new int16_t[max_loop_length_samples + block_length_samples]);
+ size_t samples_read =
+ fread(audio_array_.get(), sizeof(int16_t), max_loop_length_samples, fp);
fclose(fp);
// Block length must be shorter than the loop length.
- if (block_length_samples > samples_read) return false;
+ if (block_length_samples > samples_read)
+ return false;
// Add an extra block length of samples to the end of the array, starting
// over again from the beginning of the array. This is done to simplify
@@ -54,6 +56,5 @@
return rtc::ArrayView<const int16_t>(output_ptr, block_length_samples_);
}
-
} // namespace test
} // namespace webrtc
diff --git a/modules/audio_coding/neteq/tools/audio_loop.h b/modules/audio_coding/neteq/tools/audio_loop.h
index abb1a36..876c2d7 100644
--- a/modules/audio_coding/neteq/tools/audio_loop.h
+++ b/modules/audio_coding/neteq/tools/audio_loop.h
@@ -26,10 +26,7 @@
class AudioLoop {
public:
AudioLoop()
- : next_index_(0),
- loop_length_samples_(0),
- block_length_samples_(0) {
- }
+ : next_index_(0), loop_length_samples_(0), block_length_samples_(0) {}
virtual ~AudioLoop() {}
@@ -38,7 +35,8 @@
// greater. Otherwise, the loop length is the same as the file length.
// The audio will be delivered in blocks of |block_length_samples|.
// Returns false if the initialization failed, otherwise true.
- bool Init(const std::string file_name, size_t max_loop_length_samples,
+ bool Init(const std::string file_name,
+ size_t max_loop_length_samples,
size_t block_length_samples);
// Returns a (pointer,size) pair for the next block of audio. The size is
diff --git a/modules/audio_coding/neteq/tools/audio_sink.h b/modules/audio_coding/neteq/tools/audio_sink.h
index 18ac6fc..05e6fe8 100644
--- a/modules/audio_coding/neteq/tools/audio_sink.h
+++ b/modules/audio_coding/neteq/tools/audio_sink.h
@@ -32,9 +32,8 @@
// Writes |audio_frame| to the AudioSink. Returns true if successful,
// otherwise false.
bool WriteAudioFrame(const AudioFrame& audio_frame) {
- return WriteArray(
- audio_frame.data(),
- audio_frame.samples_per_channel_ * audio_frame.num_channels_);
+ return WriteArray(audio_frame.data(), audio_frame.samples_per_channel_ *
+ audio_frame.num_channels_);
}
private:
diff --git a/modules/audio_coding/neteq/tools/input_audio_file.cc b/modules/audio_coding/neteq/tools/input_audio_file.cc
index 330a874..6d11064 100644
--- a/modules/audio_coding/neteq/tools/input_audio_file.cc
+++ b/modules/audio_coding/neteq/tools/input_audio_file.cc
@@ -20,7 +20,9 @@
fp_ = fopen(file_name.c_str(), "rb");
}
-InputAudioFile::~InputAudioFile() { fclose(fp_); }
+InputAudioFile::~InputAudioFile() {
+ fclose(fp_);
+}
bool InputAudioFile::Read(size_t samples, int16_t* destination) {
if (!fp_) {
@@ -73,7 +75,8 @@
return true;
}
-void InputAudioFile::DuplicateInterleaved(const int16_t* source, size_t samples,
+void InputAudioFile::DuplicateInterleaved(const int16_t* source,
+ size_t samples,
size_t channels,
int16_t* destination) {
// Start from the end of |source| and |destination|, and work towards the
diff --git a/modules/audio_coding/neteq/tools/input_audio_file.h b/modules/audio_coding/neteq/tools/input_audio_file.h
index 6bfa369..db5a944 100644
--- a/modules/audio_coding/neteq/tools/input_audio_file.h
+++ b/modules/audio_coding/neteq/tools/input_audio_file.h
@@ -45,8 +45,10 @@
// channels are identical. The output |destination| must have the capacity to
// hold samples * channels elements. Note that |source| and |destination| can
// be the same array (i.e., point to the same address).
- static void DuplicateInterleaved(const int16_t* source, size_t samples,
- size_t channels, int16_t* destination);
+ static void DuplicateInterleaved(const int16_t* source,
+ size_t samples,
+ size_t channels,
+ int16_t* destination);
private:
FILE* fp_;
diff --git a/modules/audio_coding/neteq/tools/neteq_external_decoder_test.cc b/modules/audio_coding/neteq/tools/neteq_external_decoder_test.cc
index 2c23e5c..3bd218b 100644
--- a/modules/audio_coding/neteq/tools/neteq_external_decoder_test.cc
+++ b/modules/audio_coding/neteq/tools/neteq_external_decoder_test.cc
@@ -8,7 +8,6 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-
#include "modules/audio_coding/neteq/tools/neteq_external_decoder_test.h"
#include "api/audio/audio_frame.h"
@@ -32,9 +31,8 @@
}
void NetEqExternalDecoderTest::Init() {
- ASSERT_EQ(NetEq::kOK,
- neteq_->RegisterExternalDecoder(decoder_, codec_, name_,
- kPayloadType));
+ ASSERT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder(decoder_, codec_, name_,
+ kPayloadType));
}
void NetEqExternalDecoderTest::InsertPacket(
diff --git a/modules/audio_coding/neteq/tools/neteq_external_decoder_test.h b/modules/audio_coding/neteq/tools/neteq_external_decoder_test.h
index b8670a3..78f0085 100644
--- a/modules/audio_coding/neteq/tools/neteq_external_decoder_test.h
+++ b/modules/audio_coding/neteq/tools/neteq_external_decoder_test.h
@@ -31,7 +31,7 @@
int sample_rate_hz,
AudioDecoder* decoder);
- virtual ~NetEqExternalDecoderTest() { }
+ virtual ~NetEqExternalDecoderTest() {}
// In Init(), we register the external decoder.
void Init();
diff --git a/modules/audio_coding/neteq/tools/neteq_performance_test.cc b/modules/audio_coding/neteq/tools/neteq_performance_test.cc
index 80aa809..e0dfebf 100644
--- a/modules/audio_coding/neteq/tools/neteq_performance_test.cc
+++ b/modules/audio_coding/neteq/tools/neteq_performance_test.cc
@@ -95,9 +95,8 @@
}
// Get next packet.
- packet_input_time_ms = rtp_gen.GetRtpHeader(kPayloadType,
- kInputBlockSizeSamples,
- &rtp_header);
+ packet_input_time_ms = rtp_gen.GetRtpHeader(
+ kPayloadType, kInputBlockSizeSamples, &rtp_header);
input_samples = audio_loop.GetNextBlock();
if (input_samples.empty())
return -1;
diff --git a/modules/audio_coding/neteq/tools/neteq_quality_test.cc b/modules/audio_coding/neteq/tools/neteq_quality_test.cc
index 82fa90e..faca895 100644
--- a/modules/audio_coding/neteq/tools/neteq_quality_test.cc
+++ b/modules/audio_coding/neteq/tools/neteq_quality_test.cc
@@ -47,7 +47,9 @@
return true;
}
-DEFINE_string(in_filename, DefaultInFilename().c_str(),
+DEFINE_string(
+ in_filename,
+ DefaultInFilename().c_str(),
"Filename for input audio (specify sample rate with --input_sample_rate, "
"and channels with --channels).");
@@ -55,8 +57,9 @@
DEFINE_int(channels, 1, "Number of channels in input audio.");
-DEFINE_string(out_filename, DefaultOutFilename().c_str(),
- "Name of output audio file.");
+DEFINE_string(out_filename,
+ DefaultOutFilename().c_str(),
+ "Name of output audio file.");
DEFINE_int(runtime_ms, 10000, "Simulated runtime (milliseconds).");
@@ -67,8 +70,9 @@
"Random loss mode: 0--no loss, 1--uniform loss, 2--Gilbert Elliot "
"loss, 3--fixed loss.");
-DEFINE_int(burst_length, 30,
- "Burst length in milliseconds, only valid for Gilbert Elliot loss.");
+DEFINE_int(burst_length,
+ 30,
+ "Burst length in milliseconds, only valid for Gilbert Elliot loss.");
DEFINE_float(drift_factor, 0.0, "Time drift factor.");
@@ -85,21 +89,22 @@
// to achieve the target packet loss rate |loss_rate|, when a packet is not
// lost only if all |units| drawings within the duration of the packet result in
// no-loss.
-static double ProbTrans00Solver(int units, double loss_rate,
+static double ProbTrans00Solver(int units,
+ double loss_rate,
double prob_trans_10) {
if (units == 1)
return prob_trans_10 / (1.0f - loss_rate) - prob_trans_10;
-// 0 == prob_trans_00 ^ (units - 1) + (1 - loss_rate) / prob_trans_10 *
-// prob_trans_00 - (1 - loss_rate) * (1 + 1 / prob_trans_10).
-// There is a unique solution between 0.0 and 1.0, due to the monotonicity and
-// an opposite sign at 0.0 and 1.0.
-// For simplicity, we reformulate the equation as
-// f(x) = x ^ (units - 1) + a x + b.
-// Its derivative is
-// f'(x) = (units - 1) x ^ (units - 2) + a.
-// The derivative is strictly greater than 0 when x is between 0 and 1.
-// We use Newton's method to solve the equation, iteration is
-// x(k+1) = x(k) - f(x) / f'(x);
+ // 0 == prob_trans_00 ^ (units - 1) + (1 - loss_rate) / prob_trans_10 *
+ // prob_trans_00 - (1 - loss_rate) * (1 + 1 / prob_trans_10).
+ // There is a unique solution between 0.0 and 1.0, due to the monotonicity and
+ // an opposite sign at 0.0 and 1.0.
+ // For simplicity, we reformulate the equation as
+ // f(x) = x ^ (units - 1) + a x + b.
+ // Its derivative is
+ // f'(x) = (units - 1) x ^ (units - 2) + a.
+ // The derivative is strictly greater than 0 when x is between 0 and 1.
+ // We use Newton's method to solve the equation, iteration is
+ // x(k+1) = x(k) - f(x) / f'(x);
const double kPrecision = 0.001f;
const int kIterations = 100;
const double a = (1.0f - loss_rate) / prob_trans_10;
@@ -117,7 +122,7 @@
x = 0.0f;
}
f = pow(x, units - 1) + a * x + b;
- iter ++;
+ iter++;
}
return x;
}
@@ -210,9 +215,7 @@
return false;
}
-UniformLoss::UniformLoss(double loss_rate)
- : loss_rate_(loss_rate) {
-}
+UniformLoss::UniformLoss(double loss_rate) : loss_rate_(loss_rate) {}
bool UniformLoss::Lost(int now_ms) {
int drop_this = rand();
@@ -223,8 +226,7 @@
: prob_trans_11_(prob_trans_11),
prob_trans_01_(prob_trans_01),
lost_last_(false),
- uniform_loss_model_(new UniformLoss(0)) {
-}
+ uniform_loss_model_(new UniformLoss(0)) {}
GilbertElliotLoss::~GilbertElliotLoss() {}
@@ -277,8 +279,8 @@
// a full packet duration is drawn with a loss, |unit_loss_rate| fulfills
// (1 - unit_loss_rate) ^ (block_duration_ms_ / kPacketLossTimeUnitMs) ==
// 1 - packet_loss_rate.
- double unit_loss_rate = (1.0f - pow(1.0f - 0.01f * packet_loss_rate_,
- 1.0f / units));
+ double unit_loss_rate =
+ (1.0f - pow(1.0f - 0.01f * packet_loss_rate_, 1.0f / units));
loss_model_.reset(new UniformLoss(unit_loss_rate));
break;
}
@@ -304,8 +306,8 @@
double loss_rate = 0.01f * packet_loss_rate_;
double prob_trans_10 = 1.0f * kPacketLossTimeUnitMs / FLAG_burst_length;
double prob_trans_00 = ProbTrans00Solver(units, loss_rate, prob_trans_10);
- loss_model_.reset(new GilbertElliotLoss(1.0f - prob_trans_10,
- 1.0f - prob_trans_00));
+ loss_model_.reset(
+ new GilbertElliotLoss(1.0f - prob_trans_10, 1.0f - prob_trans_00));
break;
}
case kFixedLoss: {
@@ -347,7 +349,7 @@
// The loop is to make sure that codecs with different block lengths share the
// same packet loss profile.
bool lost = false;
- for (int idx = 0; idx < cycles; idx ++) {
+ for (int idx = 0; idx < cycles; idx++) {
if (loss_model_->Lost(decoded_time_ms_)) {
// The packet will be lost if any of the drawings indicates a loss, but
// the loop has to go on to make sure that codecs with different block
@@ -359,14 +361,10 @@
}
int NetEqQualityTest::Transmit() {
- int packet_input_time_ms =
- rtp_generator_->GetRtpHeader(kPayloadType, in_size_samples_,
- &rtp_header_);
- Log() << "Packet of size "
- << payload_size_bytes_
- << " bytes, for frame at "
- << packet_input_time_ms
- << " ms ";
+ int packet_input_time_ms = rtp_generator_->GetRtpHeader(
+ kPayloadType, in_size_samples_, &rtp_header_);
+ Log() << "Packet of size " << payload_size_bytes_ << " bytes, for frame at "
+ << packet_input_time_ms << " ms ";
if (payload_size_bytes_ > 0) {
if (!PacketLost()) {
int ret = neteq_->InsertPacket(
@@ -411,9 +409,8 @@
decoded_time_ms_) {
ASSERT_TRUE(in_file_->Read(in_size_samples_ * channels_, &in_data_[0]));
payload_.Clear();
- payload_size_bytes_ = EncodeBlock(&in_data_[0],
- in_size_samples_, &payload_,
- max_payload_bytes_);
+ payload_size_bytes_ = EncodeBlock(&in_data_[0], in_size_samples_,
+ &payload_, max_payload_bytes_);
total_payload_size_bytes_ += payload_size_bytes_;
decodable_time_ms_ = Transmit() + block_duration_ms_;
}
@@ -423,8 +420,7 @@
}
}
Log() << "Average bit rate was "
- << 8.0f * total_payload_size_bytes_ / FLAG_runtime_ms
- << " kbps"
+ << 8.0f * total_payload_size_bytes_ / FLAG_runtime_ms << " kbps"
<< std::endl;
}
diff --git a/modules/audio_coding/neteq/tools/neteq_quality_test.h b/modules/audio_coding/neteq/tools/neteq_quality_test.h
index 2b82b0a..b19460c 100644
--- a/modules/audio_coding/neteq/tools/neteq_quality_test.h
+++ b/modules/audio_coding/neteq/tools/neteq_quality_test.h
@@ -36,7 +36,7 @@
class LossModel {
public:
- virtual ~LossModel() {};
+ virtual ~LossModel(){};
virtual bool Lost(int now_ms) = 0;
};
@@ -110,8 +110,10 @@
// |block_size_samples| (samples per channel),
// 2. save the bit stream to |payload| of |max_bytes| bytes in size,
// 3. returns the length of the payload (in bytes),
- virtual int EncodeBlock(int16_t* in_data, size_t block_size_samples,
- rtc::Buffer* payload, size_t max_bytes) = 0;
+ virtual int EncodeBlock(int16_t* in_data,
+ size_t block_size_samples,
+ rtc::Buffer* payload,
+ size_t max_bytes) = 0;
// PacketLost(...) determines weather a packet sent at an indicated time gets
// lost or not.
diff --git a/modules/audio_coding/neteq/tools/neteq_replacement_input.h b/modules/audio_coding/neteq/tools/neteq_replacement_input.h
index 1113001..9ce9b9d 100644
--- a/modules/audio_coding/neteq/tools/neteq_replacement_input.h
+++ b/modules/audio_coding/neteq/tools/neteq_replacement_input.h
@@ -42,7 +42,7 @@
const uint8_t replacement_payload_type_;
const std::set<uint8_t> comfort_noise_types_;
const std::set<uint8_t> forbidden_types_;
- std::unique_ptr<PacketData> packet_; // The next packet to deliver.
+ std::unique_ptr<PacketData> packet_; // The next packet to deliver.
uint32_t last_frame_size_timestamps_ = 960; // Initial guess: 20 ms @ 48 kHz.
};
diff --git a/modules/audio_coding/neteq/tools/neteq_rtpplay.cc b/modules/audio_coding/neteq/tools/neteq_rtpplay.cc
index d69b1a7..673c8fd 100644
--- a/modules/audio_coding/neteq/tools/neteq_rtpplay.cc
+++ b/modules/audio_coding/neteq/tools/neteq_rtpplay.cc
@@ -10,20 +10,20 @@
#include <errno.h>
#include <inttypes.h>
-#include <iostream>
#include <limits.h> // For ULONG_MAX returned by strtoul.
-#include <memory>
#include <stdio.h>
#include <stdlib.h> // For strtoul.
+#include <iostream>
+#include <memory>
#include <string>
#include "modules/audio_coding/neteq/include/neteq.h"
#include "modules/audio_coding/neteq/tools/fake_decode_from_file.h"
#include "modules/audio_coding/neteq/tools/input_audio_file.h"
#include "modules/audio_coding/neteq/tools/neteq_delay_analyzer.h"
-#include "modules/audio_coding/neteq/tools/neteq_stats_getter.h"
#include "modules/audio_coding/neteq/tools/neteq_packet_source_input.h"
#include "modules/audio_coding/neteq/tools/neteq_replacement_input.h"
+#include "modules/audio_coding/neteq/tools/neteq_stats_getter.h"
#include "modules/audio_coding/neteq/tools/neteq_test.h"
#include "modules/audio_coding/neteq/tools/output_audio_file.h"
#include "modules/audio_coding/neteq/tools/output_wav_file.h"
@@ -71,7 +71,7 @@
bool ValidateSsrcValue(const std::string& str) {
uint32_t dummy_ssrc;
- if (ParseSsrc(str, &dummy_ssrc)) // Value is ok.
+ if (ParseSsrc(str, &dummy_ssrc)) // Value is ok.
return true;
printf("Invalid SSRC: %s\n", str.c_str());
return false;
@@ -106,10 +106,15 @@
DEFINE_int(cn_wb, 98, "RTP payload type for comfort noise (16 kHz)");
DEFINE_int(cn_swb32, 99, "RTP payload type for comfort noise (32 kHz)");
DEFINE_int(cn_swb48, 100, "RTP payload type for comfort noise (48 kHz)");
-DEFINE_bool(codec_map, false, "Prints the mapping between RTP payload type and "
- "codec");
-DEFINE_string(replacement_audio_file, "",
- "A PCM file that will be used to populate ""dummy"" RTP packets");
+DEFINE_bool(codec_map,
+ false,
+ "Prints the mapping between RTP payload type and "
+ "codec");
+DEFINE_string(replacement_audio_file,
+ "",
+ "A PCM file that will be used to populate "
+ "dummy"
+ " RTP packets");
DEFINE_string(ssrc,
"",
"Only use packets with this SSRC (decimal or hex, the latter "
@@ -240,8 +245,8 @@
NetEq* neteq) override {
if (last_ssrc_ && packet.header.ssrc != *last_ssrc_) {
std::cout << "Changing streams from 0x" << std::hex << *last_ssrc_
- << " to 0x" << std::hex << packet.header.ssrc
- << std::dec << " (payload type "
+ << " to 0x" << std::hex << packet.header.ssrc << std::dec
+ << " (payload type "
<< static_cast<int>(packet.header.payloadType) << ")"
<< std::endl;
}
@@ -258,10 +263,13 @@
int RunTest(int argc, char* argv[]) {
std::string program_name = argv[0];
- std::string usage = "Tool for decoding an RTP dump file using NetEq.\n"
- "Run " + program_name + " --help for usage.\n"
- "Example usage:\n" + program_name +
- " input.rtp output.{pcm, wav}\n";
+ std::string usage =
+ "Tool for decoding an RTP dump file using NetEq.\n"
+ "Run " +
+ program_name +
+ " --help for usage.\n"
+ "Example usage:\n" +
+ program_name + " input.rtp output.{pcm, wav}\n";
if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true)) {
return 1;
}
@@ -406,10 +414,8 @@
{FLAG_g722, std::make_pair(NetEqDecoder::kDecoderG722, "g722")},
{FLAG_avt, std::make_pair(NetEqDecoder::kDecoderAVT, "avt")},
{FLAG_avt_16, std::make_pair(NetEqDecoder::kDecoderAVT16kHz, "avt-16")},
- {FLAG_avt_32,
- std::make_pair(NetEqDecoder::kDecoderAVT32kHz, "avt-32")},
- {FLAG_avt_48,
- std::make_pair(NetEqDecoder::kDecoderAVT48kHz, "avt-48")},
+ {FLAG_avt_32, std::make_pair(NetEqDecoder::kDecoderAVT32kHz, "avt-32")},
+ {FLAG_avt_48, std::make_pair(NetEqDecoder::kDecoderAVT48kHz, "avt-48")},
{FLAG_red, std::make_pair(NetEqDecoder::kDecoderRED, "red")},
{FLAG_cn_nb, std::make_pair(NetEqDecoder::kDecoderCNGnb, "cng-nb")},
{FLAG_cn_wb, std::make_pair(NetEqDecoder::kDecoderCNGwb, "cng-wb")},
@@ -440,9 +446,8 @@
std::set<uint8_t> cn_types = std_set_int32_to_uint8(
{FLAG_cn_nb, FLAG_cn_wb, FLAG_cn_swb32, FLAG_cn_swb48});
- std::set<uint8_t> forbidden_types =
- std_set_int32_to_uint8({FLAG_g722, FLAG_red, FLAG_avt,
- FLAG_avt_16, FLAG_avt_32, FLAG_avt_48});
+ std::set<uint8_t> forbidden_types = std_set_int32_to_uint8(
+ {FLAG_g722, FLAG_red, FLAG_avt, FLAG_avt_16, FLAG_avt_32, FLAG_avt_48});
input.reset(new NetEqReplacementInput(std::move(input), replacement_pt,
cn_types, forbidden_types));
diff --git a/modules/audio_coding/neteq/tools/neteq_stats_getter.cc b/modules/audio_coding/neteq/tools/neteq_stats_getter.cc
index 6474e21..58c9ae4 100644
--- a/modules/audio_coding/neteq/tools/neteq_stats_getter.cc
+++ b/modules/audio_coding/neteq/tools/neteq_stats_getter.cc
@@ -26,8 +26,7 @@
rtc::SimpleStringBuilder ss(ss_buf);
ss << "ConcealmentEvent duration_ms:" << duration_ms
<< " event_number:" << concealment_event_number
- << " time_from_previous_event_end_ms:"
- << time_from_previous_event_end_ms;
+ << " time_from_previous_event_end_ms:" << time_from_previous_event_end_ms;
return ss.str();
}
@@ -115,12 +114,10 @@
a.added_zero_samples += b.added_zero_samples;
a.mean_waiting_time_ms += b.mean_waiting_time_ms;
a.median_waiting_time_ms += b.median_waiting_time_ms;
- a.min_waiting_time_ms =
- std::min(a.min_waiting_time_ms,
- static_cast<double>(b.min_waiting_time_ms));
- a.max_waiting_time_ms =
- std::max(a.max_waiting_time_ms,
- static_cast<double>(b.max_waiting_time_ms));
+ a.min_waiting_time_ms = std::min(
+ a.min_waiting_time_ms, static_cast<double>(b.min_waiting_time_ms));
+ a.max_waiting_time_ms = std::max(
+ a.max_waiting_time_ms, static_cast<double>(b.max_waiting_time_ms));
return a;
});
diff --git a/modules/audio_coding/neteq/tools/neteq_stats_getter.h b/modules/audio_coding/neteq/tools/neteq_stats_getter.h
index dbb396a..975393c 100644
--- a/modules/audio_coding/neteq/tools/neteq_stats_getter.h
+++ b/modules/audio_coding/neteq/tools/neteq_stats_getter.h
@@ -69,9 +69,7 @@
double AverageSpeechExpandRate() const;
- NetEqDelayAnalyzer* delay_analyzer() const {
- return delay_analyzer_.get();
- }
+ NetEqDelayAnalyzer* delay_analyzer() const { return delay_analyzer_.get(); }
const std::vector<ConcealmentEvent>& concealment_events() const {
// Do not account for the last concealment event to avoid potential end
diff --git a/modules/audio_coding/neteq/tools/packet.cc b/modules/audio_coding/neteq/tools/packet.cc
index 9505a29..b1a9b64 100644
--- a/modules/audio_coding/neteq/tools/packet.cc
+++ b/modules/audio_coding/neteq/tools/packet.cc
@@ -158,11 +158,10 @@
destination->paddingLength = header_.paddingLength;
destination->headerLength = header_.headerLength;
destination->payload_type_frequency = header_.payload_type_frequency;
- memcpy(&destination->arrOfCSRCs,
- &header_.arrOfCSRCs,
+ memcpy(&destination->arrOfCSRCs, &header_.arrOfCSRCs,
sizeof(header_.arrOfCSRCs));
- memcpy(
- &destination->extension, &header_.extension, sizeof(header_.extension));
+ memcpy(&destination->extension, &header_.extension,
+ sizeof(header_.extension));
}
} // namespace test
diff --git a/modules/audio_coding/neteq/tools/packet.h b/modules/audio_coding/neteq/tools/packet.h
index 94d45c5..2c9a26f 100644
--- a/modules/audio_coding/neteq/tools/packet.h
+++ b/modules/audio_coding/neteq/tools/packet.h
@@ -15,7 +15,7 @@
#include <memory>
#include "api/rtp_headers.h" // NOLINT(build/include)
-#include "common_types.h" // NOLINT(build/include)
+#include "common_types.h" // NOLINT(build/include)
#include "rtc_base/constructormagic.h"
#include "typedefs.h" // NOLINT(build/include)
diff --git a/modules/audio_coding/neteq/tools/packet_unittest.cc b/modules/audio_coding/neteq/tools/packet_unittest.cc
index ce6a3b9..7f3d663 100644
--- a/modules/audio_coding/neteq/tools/packet_unittest.cc
+++ b/modules/audio_coding/neteq/tools/packet_unittest.cc
@@ -28,7 +28,7 @@
rtp_data[0] = 0x80;
rtp_data[1] = static_cast<uint8_t>(payload_type);
rtp_data[2] = (seq_number >> 8) & 0xFF;
- rtp_data[3] = (seq_number) & 0xFF;
+ rtp_data[3] = (seq_number)&0xFF;
rtp_data[4] = timestamp >> 24;
rtp_data[5] = (timestamp >> 16) & 0xFF;
rtp_data[6] = (timestamp >> 8) & 0xFF;
@@ -47,8 +47,8 @@
const uint16_t kSequenceNumber = 4711;
const uint32_t kTimestamp = 47114711;
const uint32_t kSsrc = 0x12345678;
- MakeRtpHeader(
- kPayloadType, kSequenceNumber, kTimestamp, kSsrc, packet_memory);
+ MakeRtpHeader(kPayloadType, kSequenceNumber, kTimestamp, kSsrc,
+ packet_memory);
const double kPacketTime = 1.0;
// Hand over ownership of |packet_memory| to |packet|.
Packet packet(packet_memory, kPacketLengthBytes, kPacketTime);
@@ -75,13 +75,11 @@
const uint16_t kSequenceNumber = 4711;
const uint32_t kTimestamp = 47114711;
const uint32_t kSsrc = 0x12345678;
- MakeRtpHeader(
- kPayloadType, kSequenceNumber, kTimestamp, kSsrc, packet_memory);
+ MakeRtpHeader(kPayloadType, kSequenceNumber, kTimestamp, kSsrc,
+ packet_memory);
const double kPacketTime = 1.0;
// Hand over ownership of |packet_memory| to |packet|.
- Packet packet(packet_memory,
- kPacketLengthBytes,
- kVirtualPacketLengthBytes,
+ Packet packet(packet_memory, kPacketLengthBytes, kVirtualPacketLengthBytes,
kPacketTime);
ASSERT_TRUE(packet.valid_header());
EXPECT_EQ(kPayloadType, packet.header().payloadType);
@@ -140,8 +138,8 @@
const uint16_t kSequenceNumber = 4711;
const uint32_t kTimestamp = 47114711;
const uint32_t kSsrc = 0x12345678;
- MakeRtpHeader(
- kRedPayloadType, kSequenceNumber, kTimestamp, kSsrc, packet_memory);
+ MakeRtpHeader(kRedPayloadType, kSequenceNumber, kTimestamp, kSsrc,
+ packet_memory);
// Create four RED headers.
// Payload types are just the same as the block index the offset is 100 times
// the block index.
@@ -154,8 +152,8 @@
uint32_t timestamp_offset = 100 * i;
int block_length = 10 * i;
bool last_block = (i == kRedBlocks - 1) ? true : false;
- payload_ptr += MakeRedHeader(
- payload_type, timestamp_offset, block_length, last_block, payload_ptr);
+ payload_ptr += MakeRedHeader(payload_type, timestamp_offset, block_length,
+ last_block, payload_ptr);
}
const double kPacketTime = 1.0;
// Hand over ownership of |packet_memory| to |packet|.
@@ -178,8 +176,7 @@
EXPECT_EQ(kRedBlocks, static_cast<int>(red_headers.size()));
int block_index = 0;
for (std::list<RTPHeader*>::reverse_iterator it = red_headers.rbegin();
- it != red_headers.rend();
- ++it) {
+ it != red_headers.rend(); ++it) {
// Reading list from the back, since the extraction puts the main payload
// (which is the last one on wire) first.
RTPHeader* red_block = *it;
diff --git a/modules/audio_coding/neteq/tools/rtp_analyze.cc b/modules/audio_coding/neteq/tools/rtp_analyze.cc
index 12721cc..f939038 100644
--- a/modules/audio_coding/neteq/tools/rtp_analyze.cc
+++ b/modules/audio_coding/neteq/tools/rtp_analyze.cc
@@ -20,10 +20,14 @@
// Define command line flags.
DEFINE_int(red, 117, "RTP payload type for RED");
-DEFINE_int(audio_level, -1, "Extension ID for audio level (RFC 6464); "
- "-1 not to print audio level");
-DEFINE_int(abs_send_time, -1, "Extension ID for absolute sender time; "
- "-1 not to print absolute send time");
+DEFINE_int(audio_level,
+ -1,
+ "Extension ID for audio level (RFC 6464); "
+ "-1 not to print audio level");
+DEFINE_int(abs_send_time,
+ -1,
+ "Extension ID for absolute sender time; "
+ "-1 not to print absolute send time");
DEFINE_bool(help, false, "Print this message");
int main(int argc, char* argv[]) {
@@ -37,8 +41,8 @@
program_name + " input.rtp output.txt\n\n" +
"Output is sent to stdout if no output file is given. " +
"Note that this tool can read files with or without payloads.\n";
- if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) ||
- FLAG_help || (argc != 2 && argc != 3)) {
+ if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || FLAG_help ||
+ (argc != 2 && argc != 3)) {
printf("%s", usage.c_str());
if (FLAG_help) {
rtc::FlagList::Print(nullptr, false);
@@ -47,10 +51,11 @@
return 1;
}
- RTC_CHECK(FLAG_red >= 0 && FLAG_red <= 127); // Payload type
- RTC_CHECK(FLAG_audio_level == -1 || // Default
- (FLAG_audio_level > 0 && FLAG_audio_level <= 255)); // Extension ID
- RTC_CHECK(FLAG_abs_send_time == -1 || // Default
+ RTC_CHECK(FLAG_red >= 0 && FLAG_red <= 127); // Payload type
+ RTC_CHECK(FLAG_audio_level == -1 || // Default
+ (FLAG_audio_level > 0 && FLAG_audio_level <= 255)); // Extension ID
+ RTC_CHECK(
+ FLAG_abs_send_time == -1 || // Default
(FLAG_abs_send_time > 0 && FLAG_abs_send_time <= 255)); // Extension ID
printf("Input file: %s\n", argv[1]);
@@ -104,19 +109,14 @@
}
// Write packet data to file. Use virtual_packet_length_bytes so that the
// correct packet sizes are printed also for RTP header-only dumps.
- fprintf(out_file,
- "%5u %10u %10u %5i %5i %2i %#08X",
- packet->header().sequenceNumber,
- packet->header().timestamp,
+ fprintf(out_file, "%5u %10u %10u %5i %5i %2i %#08X",
+ packet->header().sequenceNumber, packet->header().timestamp,
static_cast<unsigned int>(packet->time_ms()),
static_cast<int>(packet->virtual_packet_length_bytes()),
- packet->header().payloadType,
- packet->header().markerBit,
+ packet->header().payloadType, packet->header().markerBit,
packet->header().ssrc);
if (print_audio_level && packet->header().extension.hasAudioLevel) {
- fprintf(out_file,
- " %5u (%1i)",
- packet->header().extension.audioLevel,
+ fprintf(out_file, " %5u (%1i)", packet->header().extension.audioLevel,
packet->header().extension.voiceActivity);
}
if (print_abs_send_time && packet->header().extension.hasAbsoluteSendTime) {
@@ -156,11 +156,8 @@
while (!red_headers.empty()) {
webrtc::RTPHeader* red = red_headers.front();
assert(red);
- fprintf(out_file,
- "* %5u %10u %10u %5i\n",
- red->sequenceNumber,
- red->timestamp,
- static_cast<unsigned int>(packet->time_ms()),
+ fprintf(out_file, "* %5u %10u %10u %5i\n", red->sequenceNumber,
+ red->timestamp, static_cast<unsigned int>(packet->time_ms()),
red->payloadType);
red_headers.pop_front();
delete red;
diff --git a/modules/audio_coding/neteq/tools/rtp_encode.cc b/modules/audio_coding/neteq/tools/rtp_encode.cc
index 66e7a28..1984e3f 100644
--- a/modules/audio_coding/neteq/tools/rtp_encode.cc
+++ b/modules/audio_coding/neteq/tools/rtp_encode.cc
@@ -247,11 +247,16 @@
AudioEncoderCng::Config cng_config;
const auto default_payload_type = [&] {
switch (sample_rate_hz) {
- case 8000: return 13;
- case 16000: return 98;
- case 32000: return 99;
- case 48000: return 100;
- default: RTC_NOTREACHED();
+ case 8000:
+ return 13;
+ case 16000:
+ return 98;
+ case 32000:
+ return 99;
+ case 48000:
+ return 100;
+ default:
+ RTC_NOTREACHED();
}
return 0;
};
diff --git a/modules/audio_coding/neteq/tools/rtp_file_source.cc b/modules/audio_coding/neteq/tools/rtp_file_source.cc
index 0945667..806bba7 100644
--- a/modules/audio_coding/neteq/tools/rtp_file_source.cc
+++ b/modules/audio_coding/neteq/tools/rtp_file_source.cc
@@ -44,8 +44,7 @@
return !!temp_file;
}
-RtpFileSource::~RtpFileSource() {
-}
+RtpFileSource::~RtpFileSource() {}
bool RtpFileSource::RegisterRtpHeaderExtension(RTPExtensionType type,
uint8_t id) {
@@ -82,8 +81,7 @@
}
RtpFileSource::RtpFileSource()
- : PacketSource(),
- parser_(RtpHeaderParser::Create()) {}
+ : PacketSource(), parser_(RtpHeaderParser::Create()) {}
bool RtpFileSource::OpenFile(const std::string& file_name) {
rtp_reader_.reset(RtpFileReader::Create(RtpFileReader::kRtpDump, file_name));
diff --git a/modules/audio_coding/neteq/tools/rtp_generator.cc b/modules/audio_coding/neteq/tools/rtp_generator.cc
index cedd7ae..ab7acdc 100644
--- a/modules/audio_coding/neteq/tools/rtp_generator.cc
+++ b/modules/audio_coding/neteq/tools/rtp_generator.cc
@@ -32,8 +32,8 @@
uint32_t this_send_time = next_send_time_ms_;
assert(samples_per_ms_ > 0);
- next_send_time_ms_ += ((1.0 + drift_factor_) * payload_length_samples) /
- samples_per_ms_;
+ next_send_time_ms_ +=
+ ((1.0 + drift_factor_) * payload_length_samples) / samples_per_ms_;
return this_send_time;
}
@@ -46,8 +46,8 @@
uint32_t TimestampJumpRtpGenerator::GetRtpHeader(uint8_t payload_type,
size_t payload_length_samples,
RTPHeader* rtp_header) {
- uint32_t ret = RtpGenerator::GetRtpHeader(
- payload_type, payload_length_samples, rtp_header);
+ uint32_t ret = RtpGenerator::GetRtpHeader(payload_type,
+ payload_length_samples, rtp_header);
if (timestamp_ - static_cast<uint32_t>(payload_length_samples) <=
jump_from_timestamp_ &&
timestamp_ > jump_from_timestamp_) {
diff --git a/modules/audio_coding/neteq/tools/rtp_generator.h b/modules/audio_coding/neteq/tools/rtp_generator.h
index 3b3cca9..04fdbdd 100644
--- a/modules/audio_coding/neteq/tools/rtp_generator.h
+++ b/modules/audio_coding/neteq/tools/rtp_generator.h
@@ -32,8 +32,7 @@
next_send_time_ms_(start_send_time_ms),
ssrc_(ssrc),
samples_per_ms_(samples_per_ms),
- drift_factor_(0.0) {
- }
+ drift_factor_(0.0) {}
virtual ~RtpGenerator() {}
diff --git a/modules/audio_coding/test/Channel.cc b/modules/audio_coding/test/Channel.cc
index 7d5e6e2..8fdb677 100644
--- a/modules/audio_coding/test/Channel.cc
+++ b/modules/audio_coding/test/Channel.cc
@@ -30,11 +30,15 @@
rtpInfo.header.markerBit = false;
rtpInfo.header.ssrc = 0;
- rtpInfo.header.sequenceNumber = (external_sequence_number_ < 0) ?
- _seqNo++ : static_cast<uint16_t>(external_sequence_number_);
+ rtpInfo.header.sequenceNumber =
+ (external_sequence_number_ < 0)
+ ? _seqNo++
+ : static_cast<uint16_t>(external_sequence_number_);
rtpInfo.header.payloadType = payloadType;
- rtpInfo.header.timestamp = (external_send_timestamp_ < 0) ? timeStamp :
- static_cast<uint32_t>(external_send_timestamp_);
+ rtpInfo.header.timestamp =
+ (external_send_timestamp_ < 0)
+ ? timeStamp
+ : static_cast<uint32_t>(external_send_timestamp_);
if (frameType == kAudioFrameCN) {
rtpInfo.type.Audio.isCNG = true;
@@ -57,7 +61,7 @@
// only 0x80 if we have multiple blocks
_payloadData[0] = 0x80 + fragmentation->fragmentationPlType[1];
size_t REDheader = (fragmentation->fragmentationTimeDiff[1] << 10) +
- fragmentation->fragmentationLength[1];
+ fragmentation->fragmentationLength[1];
_payloadData[1] = uint8_t((REDheader >> 16) & 0x000000FF);
_payloadData[2] = uint8_t((REDheader >> 8) & 0x000000FF);
_payloadData[3] = uint8_t(REDheader & 0x000000FF);
@@ -96,7 +100,7 @@
_channelCritSect.Enter();
if (_saveBitStream) {
- //fwrite(payloadData, sizeof(uint8_t), payloadSize, _bitStreamFile);
+ // fwrite(payloadData, sizeof(uint8_t), payloadSize, _bitStreamFile);
}
if (!_isStereo) {
@@ -128,8 +132,8 @@
// TODO(turajs): rewite this method.
void Channel::CalcStatistics(WebRtcRTPHeader& rtpInfo, size_t payloadSize) {
int n;
- if ((rtpInfo.header.payloadType != _lastPayloadType)
- && (_lastPayloadType != -1)) {
+ if ((rtpInfo.header.payloadType != _lastPayloadType) &&
+ (_lastPayloadType != -1)) {
// payload-type is changed.
// we have to terminate the calculations on the previous payload type
// we ignore the last packet in that payload type just to make things
@@ -156,14 +160,15 @@
if (!newPayload) {
if (!currentPayloadStr->newPacket) {
if (!_useLastFrameSize) {
- _lastFrameSizeSample = (uint32_t) ((uint32_t) rtpInfo.header.timestamp -
- (uint32_t) currentPayloadStr->lastTimestamp);
+ _lastFrameSizeSample =
+ (uint32_t)((uint32_t)rtpInfo.header.timestamp -
+ (uint32_t)currentPayloadStr->lastTimestamp);
}
assert(_lastFrameSizeSample > 0);
int k = 0;
for (; k < MAX_NUM_FRAMESIZES; ++k) {
if ((currentPayloadStr->frameSizeStats[k].frameSizeSample ==
- _lastFrameSizeSample) ||
+ _lastFrameSizeSample) ||
(currentPayloadStr->frameSizeStats[k].frameSizeSample == 0)) {
break;
}
@@ -174,9 +179,9 @@
_lastPayloadType, _lastFrameSizeSample);
return;
}
- ACMTestFrameSizeStats* currentFrameSizeStats = &(currentPayloadStr
- ->frameSizeStats[k]);
- currentFrameSizeStats->frameSizeSample = (int16_t) _lastFrameSizeSample;
+ ACMTestFrameSizeStats* currentFrameSizeStats =
+ &(currentPayloadStr->frameSizeStats[k]);
+ currentFrameSizeStats->frameSizeSample = (int16_t)_lastFrameSizeSample;
// increment the number of encoded samples.
currentFrameSizeStats->totalEncodedSamples += _lastFrameSizeSample;
@@ -185,15 +190,15 @@
// increment the total number of bytes (this is based on
// the previous payload we don't know the frame-size of
// the current payload.
- currentFrameSizeStats->totalPayloadLenByte += currentPayloadStr
- ->lastPayloadLenByte;
+ currentFrameSizeStats->totalPayloadLenByte +=
+ currentPayloadStr->lastPayloadLenByte;
// store the maximum payload-size (this is based on
// the previous payload we don't know the frame-size of
// the current payload.
- if (currentFrameSizeStats->maxPayloadLen
- < currentPayloadStr->lastPayloadLenByte) {
- currentFrameSizeStats->maxPayloadLen = currentPayloadStr
- ->lastPayloadLenByte;
+ if (currentFrameSizeStats->maxPayloadLen <
+ currentPayloadStr->lastPayloadLenByte) {
+ currentFrameSizeStats->maxPayloadLen =
+ currentPayloadStr->lastPayloadLenByte;
}
// store the current values for the next time
currentPayloadStr->lastTimestamp = rtpInfo.header.timestamp;
@@ -203,8 +208,8 @@
currentPayloadStr->lastPayloadLenByte = payloadSize;
currentPayloadStr->lastTimestamp = rtpInfo.header.timestamp;
currentPayloadStr->payloadType = rtpInfo.header.payloadType;
- memset(currentPayloadStr->frameSizeStats, 0, MAX_NUM_FRAMESIZES *
- sizeof(ACMTestFrameSizeStats));
+ memset(currentPayloadStr->frameSizeStats, 0,
+ MAX_NUM_FRAMESIZES * sizeof(ACMTestFrameSizeStats));
}
} else {
n = 0;
@@ -216,8 +221,8 @@
_payloadStats[n].lastPayloadLenByte = payloadSize;
_payloadStats[n].lastTimestamp = rtpInfo.header.timestamp;
_payloadStats[n].payloadType = rtpInfo.header.payloadType;
- memset(_payloadStats[n].frameSizeStats, 0, MAX_NUM_FRAMESIZES *
- sizeof(ACMTestFrameSizeStats));
+ memset(_payloadStats[n].frameSizeStats, 0,
+ MAX_NUM_FRAMESIZES * sizeof(ACMTestFrameSizeStats));
}
}
@@ -262,8 +267,7 @@
}
}
-Channel::~Channel() {
-}
+Channel::~Channel() {}
void Channel::RegisterReceiverACM(AudioCodingModule* acm) {
_receiverACM = acm;
@@ -311,13 +315,13 @@
_channelCritSect.Leave();
return 0;
}
- payloadStats.frameSizeStats[n].usageLenSec = (double) payloadStats
- .frameSizeStats[n].totalEncodedSamples / (double) codecInst.plfreq;
+ payloadStats.frameSizeStats[n].usageLenSec =
+ (double)payloadStats.frameSizeStats[n].totalEncodedSamples /
+ (double)codecInst.plfreq;
payloadStats.frameSizeStats[n].rateBitPerSec =
- payloadStats.frameSizeStats[n].totalPayloadLenByte * 8
- / payloadStats.frameSizeStats[n].usageLenSec;
-
+ payloadStats.frameSizeStats[n].totalPayloadLenByte * 8 /
+ payloadStats.frameSizeStats[n].usageLenSec;
}
_channelCritSect.Leave();
return 0;
@@ -353,14 +357,14 @@
if (_payloadStats[k].payloadType == -1) {
break;
}
- payloadType[k] = (uint8_t) _payloadStats[k].payloadType;
+ payloadType[k] = (uint8_t)_payloadStats[k].payloadType;
payloadLenByte[k] = 0;
for (n = 0; n < MAX_NUM_FRAMESIZES; n++) {
if (_payloadStats[k].frameSizeStats[n].frameSizeSample == 0) {
break;
}
- payloadLenByte[k] += (uint16_t) _payloadStats[k].frameSizeStats[n]
- .totalPayloadLenByte;
+ payloadLenByte[k] +=
+ (uint16_t)_payloadStats[k].frameSizeStats[n].totalPayloadLenByte;
}
}
@@ -387,18 +391,15 @@
payloadStats.frameSizeStats[k].rateBitPerSec);
printf("Maximum Payload-Size.......... %" PRIuS " Bytes\n",
payloadStats.frameSizeStats[k].maxPayloadLen);
- printf(
- "Maximum Instantaneous Rate.... %.0f bits/sec\n",
- ((double) payloadStats.frameSizeStats[k].maxPayloadLen * 8.0
- * (double) codecInst.plfreq)
- / (double) payloadStats.frameSizeStats[k].frameSizeSample);
+ printf("Maximum Instantaneous Rate.... %.0f bits/sec\n",
+ ((double)payloadStats.frameSizeStats[k].maxPayloadLen * 8.0 *
+ (double)codecInst.plfreq) /
+ (double)payloadStats.frameSizeStats[k].frameSizeSample);
printf("Number of Packets............. %u\n",
- (unsigned int) payloadStats.frameSizeStats[k].numPackets);
+ (unsigned int)payloadStats.frameSizeStats[k].numPackets);
printf("Duration...................... %0.3f sec\n\n",
payloadStats.frameSizeStats[k].usageLenSec);
-
}
-
}
uint32_t Channel::LastInTimestamp() {
@@ -413,7 +414,7 @@
double rate;
uint64_t currTime = rtc::TimeMillis();
_channelCritSect.Enter();
- rate = ((double) _totalBytes * 8.0) / (double) (currTime - _beginTime);
+ rate = ((double)_totalBytes * 8.0) / (double)(currTime - _beginTime);
_channelCritSect.Leave();
return rate;
}
diff --git a/modules/audio_coding/test/Channel.h b/modules/audio_coding/test/Channel.h
index e01e33e..e5f5b54 100644
--- a/modules/audio_coding/test/Channel.h
+++ b/modules/audio_coding/test/Channel.h
@@ -20,8 +20,8 @@
namespace webrtc {
-#define MAX_NUM_PAYLOADS 50
-#define MAX_NUM_FRAMESIZES 6
+#define MAX_NUM_PAYLOADS 50
+#define MAX_NUM_FRAMESIZES 6
// TODO(turajs): Write constructor for this structure.
struct ACMTestFrameSizeStats {
@@ -45,7 +45,6 @@
class Channel : public AudioPacketizationCallback {
public:
-
Channel(int16_t chID = -1);
~Channel() override;
@@ -56,7 +55,7 @@
size_t payloadSize,
const RTPFragmentationHeader* fragmentation) override;
- void RegisterReceiverACM(AudioCodingModule *acm);
+ void RegisterReceiverACM(AudioCodingModule* acm);
void ResetStats();
@@ -68,9 +67,7 @@
void PrintStats(CodecInst& codecInst);
- void SetIsStereo(bool isStereo) {
- _isStereo = isStereo;
- }
+ void SetIsStereo(bool isStereo) { _isStereo = isStereo; }
uint32_t LastInTimestamp();
diff --git a/modules/audio_coding/test/EncodeDecodeTest.cc b/modules/audio_coding/test/EncodeDecodeTest.cc
index 0bf4de5..4e16dc8 100644
--- a/modules/audio_coding/test/EncodeDecodeTest.cc
+++ b/modules/audio_coding/test/EncodeDecodeTest.cc
@@ -10,10 +10,10 @@
#include "modules/audio_coding/test/EncodeDecodeTest.h"
-#include <memory>
-#include <sstream>
#include <stdio.h>
#include <stdlib.h>
+#include <memory>
+#include <sstream> // no-presubmit-check TODO(webrtc:8982)
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "common_types.h" // NOLINT(build/include)
diff --git a/modules/audio_coding/test/PCMFile.cc b/modules/audio_coding/test/PCMFile.cc
index 2b2f1f0..659f968 100644
--- a/modules/audio_coding/test/PCMFile.cc
+++ b/modules/audio_coding/test/PCMFile.cc
@@ -30,8 +30,8 @@
rewinded_(false),
read_stereo_(false),
save_stereo_(false) {
- timestamp_ = (((uint32_t) rand() & 0x0000FFFF) << 16) |
- ((uint32_t) rand() & 0x0000FFFF);
+ timestamp_ =
+ (((uint32_t)rand() & 0x0000FFFF) << 16) | ((uint32_t)rand() & 0x0000FFFF);
}
PCMFile::PCMFile(uint32_t timestamp)
@@ -52,7 +52,8 @@
}
}
-int16_t PCMFile::ChooseFile(std::string* file_name, int16_t max_len,
+int16_t PCMFile::ChooseFile(std::string* file_name,
+ int16_t max_len,
uint16_t* frequency_hz) {
char tmp_name[MAX_FILE_NAME_LENGTH_BYTE];
@@ -61,8 +62,8 @@
int16_t n = 0;
// Removing trailing spaces.
- while ((isspace(tmp_name[n]) || iscntrl(tmp_name[n])) && (tmp_name[n] != 0)
- && (n < MAX_FILE_NAME_LENGTH_BYTE)) {
+ while ((isspace(tmp_name[n]) || iscntrl(tmp_name[n])) && (tmp_name[n] != 0) &&
+ (n < MAX_FILE_NAME_LENGTH_BYTE)) {
n++;
}
if (n > 0) {
@@ -80,7 +81,7 @@
tmp_name[n + 1] = '\0';
}
- int16_t len = (int16_t) strlen(tmp_name);
+ int16_t len = (int16_t)strlen(tmp_name);
if (len > max_len) {
return -1;
}
@@ -91,15 +92,17 @@
printf("Enter the sampling frequency (in Hz) of the above file [%u]: ",
*frequency_hz);
EXPECT_TRUE(fgets(tmp_name, 10, stdin) != NULL);
- uint16_t tmp_frequency = (uint16_t) atoi(tmp_name);
+ uint16_t tmp_frequency = (uint16_t)atoi(tmp_name);
if (tmp_frequency > 0) {
*frequency_hz = tmp_frequency;
}
return 0;
}
-void PCMFile::Open(const std::string& file_name, uint16_t frequency,
- const char* mode, bool auto_rewind) {
+void PCMFile::Open(const std::string& file_name,
+ uint16_t frequency,
+ const char* mode,
+ bool auto_rewind) {
if ((pcm_file_ = fopen(file_name.c_str(), mode)) == NULL) {
printf("Cannot open file %s.\n", file_name.c_str());
ADD_FAILURE() << "Unable to read file";
@@ -125,9 +128,9 @@
channels = 2;
}
- int32_t payload_size = (int32_t) fread(audio_frame.mutable_data(),
- sizeof(uint16_t),
- samples_10ms_ * channels, pcm_file_);
+ int32_t payload_size =
+ (int32_t)fread(audio_frame.mutable_data(), sizeof(uint16_t),
+ samples_10ms_ * channels, pcm_file_);
if (payload_size < samples_10ms_ * channels) {
int16_t* frame_data = audio_frame.mutable_data();
for (int k = payload_size; k < samples_10ms_ * channels; k++) {
diff --git a/modules/audio_coding/test/PCMFile.h b/modules/audio_coding/test/PCMFile.h
index 05b9828..dc7a4fc 100644
--- a/modules/audio_coding/test/PCMFile.h
+++ b/modules/audio_coding/test/PCMFile.h
@@ -28,26 +28,27 @@
PCMFile(uint32_t timestamp);
~PCMFile();
- void Open(const std::string& filename, uint16_t frequency, const char* mode,
+ void Open(const std::string& filename,
+ uint16_t frequency,
+ const char* mode,
bool auto_rewind = false);
int32_t Read10MsData(AudioFrame& audio_frame);
- void Write10MsData(const int16_t *playout_buffer, size_t length_smpls);
+ void Write10MsData(const int16_t* playout_buffer, size_t length_smpls);
void Write10MsData(const AudioFrame& audio_frame);
uint16_t PayloadLength10Ms() const;
int32_t SamplingFrequency() const;
void Close();
- bool EndOfFile() const {
- return end_of_file_;
- }
+ bool EndOfFile() const { return end_of_file_; }
// Moves forward the specified number of 10 ms blocks. If a limit has been set
// with SetNum10MsBlocksToRead, fast-forwarding does not count towards this
// limit.
void FastForward(int num_10ms_blocks);
void Rewind();
- static int16_t ChooseFile(std::string* file_name, int16_t max_len,
+ static int16_t ChooseFile(std::string* file_name,
+ int16_t max_len,
uint16_t* frequency_hz);
bool Rewinded();
void SaveStereo(bool is_stereo = true);
diff --git a/modules/audio_coding/test/PacketLossTest.cc b/modules/audio_coding/test/PacketLossTest.cc
index d5fbfd1..c5cb396 100644
--- a/modules/audio_coding/test/PacketLossTest.cc
+++ b/modules/audio_coding/test/PacketLossTest.cc
@@ -23,11 +23,10 @@
burst_length_(1),
packet_counter_(0),
lost_packet_counter_(0),
- burst_lost_counter_(burst_length_) {
-}
+ burst_lost_counter_(burst_length_) {}
-void ReceiverWithPacketLoss::Setup(AudioCodingModule *acm,
- RTPStream *rtpStream,
+void ReceiverWithPacketLoss::Setup(AudioCodingModule* acm,
+ RTPStream* rtpStream,
std::string out_file_name,
int channels,
int loss_rate,
@@ -84,13 +83,14 @@
return false;
}
-SenderWithFEC::SenderWithFEC()
- : expected_loss_rate_(0) {
-}
+SenderWithFEC::SenderWithFEC() : expected_loss_rate_(0) {}
-void SenderWithFEC::Setup(AudioCodingModule *acm, RTPStream *rtpStream,
- std::string in_file_name, int sample_rate,
- int channels, int expected_loss_rate) {
+void SenderWithFEC::Setup(AudioCodingModule* acm,
+ RTPStream* rtpStream,
+ std::string in_file_name,
+ int sample_rate,
+ int channels,
+ int expected_loss_rate) {
Sender::Setup(acm, rtpStream, in_file_name, sample_rate, channels);
EXPECT_TRUE(SetFEC(true));
EXPECT_TRUE(SetPacketLossRate(expected_loss_rate));
@@ -111,18 +111,19 @@
return false;
}
-PacketLossTest::PacketLossTest(int channels, int expected_loss_rate,
- int actual_loss_rate, int burst_length)
+PacketLossTest::PacketLossTest(int channels,
+ int expected_loss_rate,
+ int actual_loss_rate,
+ int burst_length)
: channels_(channels),
- in_file_name_(channels_ == 1 ? "audio_coding/testfile32kHz" :
- "audio_coding/teststereo32kHz"),
+ in_file_name_(channels_ == 1 ? "audio_coding/testfile32kHz"
+ : "audio_coding/teststereo32kHz"),
sample_rate_hz_(32000),
sender_(new SenderWithFEC),
receiver_(new ReceiverWithPacketLoss),
expected_loss_rate_(expected_loss_rate),
actual_loss_rate_(actual_loss_rate),
- burst_length_(burst_length) {
-}
+ burst_length_(burst_length) {}
void PacketLossTest::Perform() {
#ifndef WEBRTC_CODEC_OPUS
diff --git a/modules/audio_coding/test/PacketLossTest.h b/modules/audio_coding/test/PacketLossTest.h
index 7eab442..f6f92db 100644
--- a/modules/audio_coding/test/PacketLossTest.h
+++ b/modules/audio_coding/test/PacketLossTest.h
@@ -20,8 +20,11 @@
class ReceiverWithPacketLoss : public Receiver {
public:
ReceiverWithPacketLoss();
- void Setup(AudioCodingModule *acm, RTPStream *rtpStream,
- std::string out_file_name, int channels, int loss_rate,
+ void Setup(AudioCodingModule* acm,
+ RTPStream* rtpStream,
+ std::string out_file_name,
+ int channels,
+ int loss_rate,
int burst_length);
bool IncomingPacket() override;
@@ -37,20 +40,27 @@
class SenderWithFEC : public Sender {
public:
SenderWithFEC();
- void Setup(AudioCodingModule *acm, RTPStream *rtpStream,
- std::string in_file_name, int sample_rate, int channels,
+ void Setup(AudioCodingModule* acm,
+ RTPStream* rtpStream,
+ std::string in_file_name,
+ int sample_rate,
+ int channels,
int expected_loss_rate);
bool SetPacketLossRate(int expected_loss_rate);
bool SetFEC(bool enable_fec);
+
protected:
int expected_loss_rate_;
};
class PacketLossTest : public ACMTest {
public:
- PacketLossTest(int channels, int expected_loss_rate_, int actual_loss_rate,
+ PacketLossTest(int channels,
+ int expected_loss_rate_,
+ int actual_loss_rate,
int burst_length);
void Perform();
+
protected:
int channels_;
std::string in_file_name_;
diff --git a/modules/audio_coding/test/RTPFile.cc b/modules/audio_coding/test/RTPFile.cc
index 8cc5bd9..a1329e7 100644
--- a/modules/audio_coding/test/RTPFile.cc
+++ b/modules/audio_coding/test/RTPFile.cc
@@ -14,9 +14,9 @@
#include <limits>
#ifdef WIN32
-# include <Winsock2.h>
+#include <Winsock2.h>
#else
-# include <arpa/inet.h>
+#include <arpa/inet.h>
#endif
#include "modules/include/module_common_types.h"
@@ -29,18 +29,22 @@
void RTPStream::ParseRTPHeader(WebRtcRTPHeader* rtpInfo,
const uint8_t* rtpHeader) {
rtpInfo->header.payloadType = rtpHeader[1];
- rtpInfo->header.sequenceNumber = (static_cast<uint16_t>(rtpHeader[2]) << 8) |
- rtpHeader[3];
+ rtpInfo->header.sequenceNumber =
+ (static_cast<uint16_t>(rtpHeader[2]) << 8) | rtpHeader[3];
rtpInfo->header.timestamp = (static_cast<uint32_t>(rtpHeader[4]) << 24) |
- (static_cast<uint32_t>(rtpHeader[5]) << 16) |
- (static_cast<uint32_t>(rtpHeader[6]) << 8) | rtpHeader[7];
+ (static_cast<uint32_t>(rtpHeader[5]) << 16) |
+ (static_cast<uint32_t>(rtpHeader[6]) << 8) |
+ rtpHeader[7];
rtpInfo->header.ssrc = (static_cast<uint32_t>(rtpHeader[8]) << 24) |
- (static_cast<uint32_t>(rtpHeader[9]) << 16) |
- (static_cast<uint32_t>(rtpHeader[10]) << 8) | rtpHeader[11];
+ (static_cast<uint32_t>(rtpHeader[9]) << 16) |
+ (static_cast<uint32_t>(rtpHeader[10]) << 8) |
+ rtpHeader[11];
}
-void RTPStream::MakeRTPheader(uint8_t* rtpHeader, uint8_t payloadType,
- int16_t seqNo, uint32_t timeStamp,
+void RTPStream::MakeRTPheader(uint8_t* rtpHeader,
+ uint8_t payloadType,
+ int16_t seqNo,
+ uint32_t timeStamp,
uint32_t ssrc) {
rtpHeader[0] = 0x80;
rtpHeader[1] = payloadType;
@@ -56,8 +60,11 @@
rtpHeader[11] = ssrc & 0xFF;
}
-RTPPacket::RTPPacket(uint8_t payloadType, uint32_t timeStamp, int16_t seqNo,
- const uint8_t* payloadData, size_t payloadSize,
+RTPPacket::RTPPacket(uint8_t payloadType,
+ uint32_t timeStamp,
+ int16_t seqNo,
+ const uint8_t* payloadData,
+ size_t payloadSize,
uint32_t frequency)
: payloadType(payloadType),
timeStamp(timeStamp),
@@ -82,20 +89,25 @@
delete _queueRWLock;
}
-void RTPBuffer::Write(const uint8_t payloadType, const uint32_t timeStamp,
- const int16_t seqNo, const uint8_t* payloadData,
- const size_t payloadSize, uint32_t frequency) {
- RTPPacket *packet = new RTPPacket(payloadType, timeStamp, seqNo, payloadData,
+void RTPBuffer::Write(const uint8_t payloadType,
+ const uint32_t timeStamp,
+ const int16_t seqNo,
+ const uint8_t* payloadData,
+ const size_t payloadSize,
+ uint32_t frequency) {
+ RTPPacket* packet = new RTPPacket(payloadType, timeStamp, seqNo, payloadData,
payloadSize, frequency);
_queueRWLock->AcquireLockExclusive();
_rtpQueue.push(packet);
_queueRWLock->ReleaseLockExclusive();
}
-size_t RTPBuffer::Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
- size_t payloadSize, uint32_t* offset) {
+size_t RTPBuffer::Read(WebRtcRTPHeader* rtpInfo,
+ uint8_t* payloadData,
+ size_t payloadSize,
+ uint32_t* offset) {
_queueRWLock->AcquireLockShared();
- RTPPacket *packet = _rtpQueue.front();
+ RTPPacket* packet = _rtpQueue.front();
_rtpQueue.pop();
_queueRWLock->ReleaseLockShared();
rtpInfo->header.markerBit = 1;
@@ -120,7 +132,7 @@
return eof;
}
-void RTPFile::Open(const char *filename, const char *mode) {
+void RTPFile::Open(const char* filename, const char* mode) {
if ((_rtpFile = fopen(filename, mode)) == NULL) {
printf("Cannot write file %s.\n", filename);
ADD_FAILURE() << "Unable to write file";
@@ -165,9 +177,12 @@
padding = ntohs(padding);
}
-void RTPFile::Write(const uint8_t payloadType, const uint32_t timeStamp,
- const int16_t seqNo, const uint8_t* payloadData,
- const size_t payloadSize, uint32_t frequency) {
+void RTPFile::Write(const uint8_t payloadType,
+ const uint32_t timeStamp,
+ const int16_t seqNo,
+ const uint8_t* payloadData,
+ const size_t payloadSize,
+ uint32_t frequency) {
/* write RTP packet to file */
uint8_t rtpHeader[12];
MakeRTPheader(rtpHeader, payloadType, seqNo, timeStamp, 0);
@@ -185,8 +200,10 @@
EXPECT_EQ(payloadSize, fwrite(payloadData, 1, payloadSize, _rtpFile));
}
-size_t RTPFile::Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
- size_t payloadSize, uint32_t* offset) {
+size_t RTPFile::Read(WebRtcRTPHeader* rtpInfo,
+ uint8_t* payloadData,
+ size_t payloadSize,
+ uint32_t* offset) {
uint16_t lengthBytes;
uint16_t plen;
uint8_t rtpHeader[12];
diff --git a/modules/audio_coding/test/RTPFile.h b/modules/audio_coding/test/RTPFile.h
index b9afe2f..73e97dd 100644
--- a/modules/audio_coding/test/RTPFile.h
+++ b/modules/audio_coding/test/RTPFile.h
@@ -22,30 +22,40 @@
class RTPStream {
public:
- virtual ~RTPStream() {
- }
+ virtual ~RTPStream() {}
- virtual void Write(const uint8_t payloadType, const uint32_t timeStamp,
- const int16_t seqNo, const uint8_t* payloadData,
- const size_t payloadSize, uint32_t frequency) = 0;
+ virtual void Write(const uint8_t payloadType,
+ const uint32_t timeStamp,
+ const int16_t seqNo,
+ const uint8_t* payloadData,
+ const size_t payloadSize,
+ uint32_t frequency) = 0;
// Returns the packet's payload size. Zero should be treated as an
// end-of-stream (in the case that EndOfFile() is true) or an error.
- virtual size_t Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
- size_t payloadSize, uint32_t* offset) = 0;
+ virtual size_t Read(WebRtcRTPHeader* rtpInfo,
+ uint8_t* payloadData,
+ size_t payloadSize,
+ uint32_t* offset) = 0;
virtual bool EndOfFile() const = 0;
protected:
- void MakeRTPheader(uint8_t* rtpHeader, uint8_t payloadType, int16_t seqNo,
- uint32_t timeStamp, uint32_t ssrc);
+ void MakeRTPheader(uint8_t* rtpHeader,
+ uint8_t payloadType,
+ int16_t seqNo,
+ uint32_t timeStamp,
+ uint32_t ssrc);
void ParseRTPHeader(WebRtcRTPHeader* rtpInfo, const uint8_t* rtpHeader);
};
class RTPPacket {
public:
- RTPPacket(uint8_t payloadType, uint32_t timeStamp, int16_t seqNo,
- const uint8_t* payloadData, size_t payloadSize,
+ RTPPacket(uint8_t payloadType,
+ uint32_t timeStamp,
+ int16_t seqNo,
+ const uint8_t* payloadData,
+ size_t payloadSize,
uint32_t frequency);
~RTPPacket();
@@ -80,20 +90,16 @@
private:
RWLockWrapper* _queueRWLock;
- std::queue<RTPPacket *> _rtpQueue;
+ std::queue<RTPPacket*> _rtpQueue;
};
class RTPFile : public RTPStream {
public:
- ~RTPFile() {
- }
+ ~RTPFile() {}
- RTPFile()
- : _rtpFile(NULL),
- _rtpEOF(false) {
- }
+ RTPFile() : _rtpFile(NULL), _rtpEOF(false) {}
- void Open(const char *outFilename, const char *mode);
+ void Open(const char* outFilename, const char* mode);
void Close();
diff --git a/modules/audio_coding/test/TestAllCodecs.cc b/modules/audio_coding/test/TestAllCodecs.cc
index f8debe9..df9c731 100644
--- a/modules/audio_coding/test/TestAllCodecs.cc
+++ b/modules/audio_coding/test/TestAllCodecs.cc
@@ -46,19 +46,19 @@
timestamp_diff_(0),
last_in_timestamp_(0),
total_bytes_(0),
- payload_size_(0) {
-}
+ payload_size_(0) {}
-TestPack::~TestPack() {
-}
+TestPack::~TestPack() {}
void TestPack::RegisterReceiverACM(AudioCodingModule* acm) {
receiver_acm_ = acm;
return;
}
-int32_t TestPack::SendData(FrameType frame_type, uint8_t payload_type,
- uint32_t timestamp, const uint8_t* payload_data,
+int32_t TestPack::SendData(FrameType frame_type,
+ uint8_t payload_type,
+ uint32_t timestamp,
+ const uint8_t* payload_data,
size_t payload_size,
const RTPFragmentationHeader* fragmentation) {
WebRtcRTPHeader rtp_info;
@@ -125,8 +125,8 @@
}
void TestAllCodecs::Perform() {
- const std::string file_name = webrtc::test::ResourcePath(
- "audio_coding/testfile32kHz", "pcm");
+ const std::string file_name =
+ webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
infile_a_.Open(file_name, 32000, "rb");
if (test_mode_ == 0) {
@@ -306,17 +306,17 @@
char codec_opus[] = "OPUS";
RegisterSendCodec('A', codec_opus, 48000, 6000, 480, kVariableSize);
Run(channel_a_to_b_);
- RegisterSendCodec('A', codec_opus, 48000, 20000, 480*2, kVariableSize);
+ RegisterSendCodec('A', codec_opus, 48000, 20000, 480 * 2, kVariableSize);
Run(channel_a_to_b_);
- RegisterSendCodec('A', codec_opus, 48000, 32000, 480*4, kVariableSize);
+ RegisterSendCodec('A', codec_opus, 48000, 32000, 480 * 4, kVariableSize);
Run(channel_a_to_b_);
RegisterSendCodec('A', codec_opus, 48000, 48000, 480, kVariableSize);
Run(channel_a_to_b_);
- RegisterSendCodec('A', codec_opus, 48000, 64000, 480*4, kVariableSize);
+ RegisterSendCodec('A', codec_opus, 48000, 64000, 480 * 4, kVariableSize);
Run(channel_a_to_b_);
- RegisterSendCodec('A', codec_opus, 48000, 96000, 480*6, kVariableSize);
+ RegisterSendCodec('A', codec_opus, 48000, 96000, 480 * 6, kVariableSize);
Run(channel_a_to_b_);
- RegisterSendCodec('A', codec_opus, 48000, 500000, 480*2, kVariableSize);
+ RegisterSendCodec('A', codec_opus, 48000, 500000, 480 * 2, kVariableSize);
Run(channel_a_to_b_);
outfile_b_.Close();
#endif
@@ -351,9 +351,12 @@
// used when registering, can be an internal header
// set to kVariableSize if the codec is a variable
// rate codec
-void TestAllCodecs::RegisterSendCodec(char side, char* codec_name,
- int32_t sampling_freq_hz, int rate,
- int packet_size, size_t extra_byte) {
+void TestAllCodecs::RegisterSendCodec(char side,
+ char* codec_name,
+ int32_t sampling_freq_hz,
+ int rate,
+ int packet_size,
+ size_t extra_byte) {
if (test_mode_ != 0) {
// Print out codec and settings.
printf("codec: %s Freq: %d Rate: %d PackSize: %d\n", codec_name,
@@ -377,9 +380,11 @@
// packet. If variable rate codec (extra_byte == -1), set to -1.
if (extra_byte != kVariableSize) {
// Add 0.875 to always round up to a whole byte
- packet_size_bytes_ = static_cast<size_t>(
- static_cast<float>(packet_size * rate) /
- static_cast<float>(sampling_freq_hz * 8) + 0.875) + extra_byte;
+ packet_size_bytes_ =
+ static_cast<size_t>(static_cast<float>(packet_size * rate) /
+ static_cast<float>(sampling_freq_hz * 8) +
+ 0.875) +
+ extra_byte;
} else {
// Packets will have a variable size.
packet_size_bytes_ = kVariableSize;
@@ -396,9 +401,7 @@
my_acm = acm_b_.get();
break;
}
- default: {
- break;
- }
+ default: { break; }
}
ASSERT_TRUE(my_acm != NULL);
diff --git a/modules/audio_coding/test/TestAllCodecs.h b/modules/audio_coding/test/TestAllCodecs.h
index e0285e9..36269a9 100644
--- a/modules/audio_coding/test/TestAllCodecs.h
+++ b/modules/audio_coding/test/TestAllCodecs.h
@@ -60,8 +60,12 @@
// codec name, and a sampling frequency matching is not required.
// This is useful for codecs which support several sampling frequency.
// Note! Only mono mode is tested in this test.
- void RegisterSendCodec(char side, char* codec_name, int32_t sampling_freq_hz,
- int rate, int packet_size, size_t extra_byte);
+ void RegisterSendCodec(char side,
+ char* codec_name,
+ int32_t sampling_freq_hz,
+ int rate,
+ int packet_size,
+ size_t extra_byte);
void Run(TestPack* channel);
void OpenOutFile(int test_number);
diff --git a/modules/audio_coding/test/TestRedFec.h b/modules/audio_coding/test/TestRedFec.h
index 98aa008..1d9dead 100644
--- a/modules/audio_coding/test/TestRedFec.h
+++ b/modules/audio_coding/test/TestRedFec.h
@@ -26,11 +26,13 @@
~TestRedFec();
void Perform();
+
private:
// The default value of '-1' indicates that the registration is based only on
// codec name and a sampling frequency matching is not required. This is
// useful for codecs which support several sampling frequency.
- int16_t RegisterSendCodec(char side, const char* codecName,
+ int16_t RegisterSendCodec(char side,
+ const char* codecName,
int32_t sampFreqHz = -1);
void Run();
void OpenOutFile(int16_t testNumber);
diff --git a/modules/audio_coding/test/TestStereo.cc b/modules/audio_coding/test/TestStereo.cc
index 2002068..2704d3d 100644
--- a/modules/audio_coding/test/TestStereo.cc
+++ b/modules/audio_coding/test/TestStereo.cc
@@ -34,11 +34,9 @@
total_bytes_(0),
payload_size_(0),
codec_mode_(kNotSet),
- lost_packet_(false) {
-}
+ lost_packet_(false) {}
-TestPackStereo::~TestPackStereo() {
-}
+TestPackStereo::~TestPackStereo() {}
void TestPackStereo::RegisterReceiverACM(AudioCodingModule* acm) {
receiver_acm_ = acm;
@@ -72,8 +70,8 @@
rtp_info.type.Audio.isCNG = true;
rtp_info.type.Audio.channel = static_cast<int>(kMono);
}
- status = receiver_acm_->IncomingPacket(payload_data, payload_size,
- rtp_info);
+ status =
+ receiver_acm_->IncomingPacket(payload_data, payload_size, rtp_info);
if (frame_type != kAudioFrameCN) {
payload_size_ = static_cast<int>(payload_size);
@@ -152,10 +150,10 @@
ACMVADMode vad_mode;
// Open both mono and stereo test files in 32 kHz.
- const std::string file_name_stereo = webrtc::test::ResourcePath(
- "audio_coding/teststereo32kHz", "pcm");
- const std::string file_name_mono = webrtc::test::ResourcePath(
- "audio_coding/testfile32kHz", "pcm");
+ const std::string file_name_stereo =
+ webrtc::test::ResourcePath("audio_coding/teststereo32kHz", "pcm");
+ const std::string file_name_mono =
+ webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
frequency_hz = 32000;
in_file_stereo_ = new PCMFile();
in_file_mono_ = new PCMFile();
@@ -230,22 +228,22 @@
OpenOutFile(test_cntr_);
char codec_g722[] = "G722";
RegisterSendCodec('A', codec_g722, 16000, 64000, 160, codec_channels,
- g722_pltype_);
+ g722_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
RegisterSendCodec('A', codec_g722, 16000, 64000, 320, codec_channels,
- g722_pltype_);
+ g722_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
RegisterSendCodec('A', codec_g722, 16000, 64000, 480, codec_channels,
- g722_pltype_);
+ g722_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
RegisterSendCodec('A', codec_g722, 16000, 64000, 640, codec_channels,
- g722_pltype_);
+ g722_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
RegisterSendCodec('A', codec_g722, 16000, 64000, 800, codec_channels,
- g722_pltype_);
+ g722_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
RegisterSendCodec('A', codec_g722, 16000, 64000, 960, codec_channels,
- g722_pltype_);
+ g722_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
@@ -259,16 +257,16 @@
OpenOutFile(test_cntr_);
char codec_l16[] = "L16";
RegisterSendCodec('A', codec_l16, 8000, 128000, 80, codec_channels,
- l16_8khz_pltype_);
+ l16_8khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
RegisterSendCodec('A', codec_l16, 8000, 128000, 160, codec_channels,
- l16_8khz_pltype_);
+ l16_8khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
RegisterSendCodec('A', codec_l16, 8000, 128000, 240, codec_channels,
- l16_8khz_pltype_);
+ l16_8khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
RegisterSendCodec('A', codec_l16, 8000, 128000, 320, codec_channels,
- l16_8khz_pltype_);
+ l16_8khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
@@ -280,16 +278,16 @@
test_cntr_++;
OpenOutFile(test_cntr_);
RegisterSendCodec('A', codec_l16, 16000, 256000, 160, codec_channels,
- l16_16khz_pltype_);
+ l16_16khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
RegisterSendCodec('A', codec_l16, 16000, 256000, 320, codec_channels,
- l16_16khz_pltype_);
+ l16_16khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
RegisterSendCodec('A', codec_l16, 16000, 256000, 480, codec_channels,
- l16_16khz_pltype_);
+ l16_16khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
RegisterSendCodec('A', codec_l16, 16000, 256000, 640, codec_channels,
- l16_16khz_pltype_);
+ l16_16khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
@@ -301,10 +299,10 @@
test_cntr_++;
OpenOutFile(test_cntr_);
RegisterSendCodec('A', codec_l16, 32000, 512000, 320, codec_channels,
- l16_32khz_pltype_);
+ l16_32khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
RegisterSendCodec('A', codec_l16, 32000, 512000, 640, codec_channels,
- l16_32khz_pltype_);
+ l16_32khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
#ifdef PCMA_AND_PCMU
@@ -392,26 +390,26 @@
char codec_opus[] = "opus";
// Run Opus with 10 ms frame size.
RegisterSendCodec('A', codec_opus, 48000, 64000, 480, codec_channels,
- opus_pltype_);
+ opus_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
// Run Opus with 20 ms frame size.
- RegisterSendCodec('A', codec_opus, 48000, 64000, 480*2, codec_channels,
- opus_pltype_);
+ RegisterSendCodec('A', codec_opus, 48000, 64000, 480 * 2, codec_channels,
+ opus_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
// Run Opus with 40 ms frame size.
- RegisterSendCodec('A', codec_opus, 48000, 64000, 480*4, codec_channels,
- opus_pltype_);
+ RegisterSendCodec('A', codec_opus, 48000, 64000, 480 * 4, codec_channels,
+ opus_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
// Run Opus with 60 ms frame size.
- RegisterSendCodec('A', codec_opus, 48000, 64000, 480*6, codec_channels,
- opus_pltype_);
+ RegisterSendCodec('A', codec_opus, 48000, 64000, 480 * 6, codec_channels,
+ opus_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
// Run Opus with 20 ms frame size and different bitrates.
RegisterSendCodec('A', codec_opus, 48000, 40000, 960, codec_channels,
- opus_pltype_);
+ opus_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
RegisterSendCodec('A', codec_opus, 48000, 510000, 960, codec_channels,
- opus_pltype_);
+ opus_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
#endif
@@ -430,7 +428,7 @@
channel_a2b_->set_codec_mode(kStereo);
OpenOutFile(test_cntr_);
RegisterSendCodec('A', codec_g722, 16000, 64000, 160, codec_channels,
- g722_pltype_);
+ g722_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
@@ -443,7 +441,7 @@
channel_a2b_->set_codec_mode(kStereo);
OpenOutFile(test_cntr_);
RegisterSendCodec('A', codec_l16, 8000, 128000, 80, codec_channels,
- l16_8khz_pltype_);
+ l16_8khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
if (test_mode_ != 0) {
@@ -454,7 +452,7 @@
test_cntr_++;
OpenOutFile(test_cntr_);
RegisterSendCodec('A', codec_l16, 16000, 256000, 160, codec_channels,
- l16_16khz_pltype_);
+ l16_16khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
if (test_mode_ != 0) {
@@ -465,7 +463,7 @@
test_cntr_++;
OpenOutFile(test_cntr_);
RegisterSendCodec('A', codec_l16, 32000, 512000, 320, codec_channels,
- l16_32khz_pltype_);
+ l16_32khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
#ifdef PCMA_AND_PCMU
@@ -497,7 +495,7 @@
channel_a2b_->set_codec_mode(kStereo);
OpenOutFile(test_cntr_);
RegisterSendCodec('A', codec_opus, 48000, 64000, 960, codec_channels,
- opus_pltype_);
+ opus_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
// Encode in mono, decode in stereo mode.
@@ -522,7 +520,7 @@
test_cntr_++;
OpenOutFile(test_cntr_);
RegisterSendCodec('A', codec_g722, 16000, 64000, 160, codec_channels,
- g722_pltype_);
+ g722_pltype_);
// Make sure it is possible to set VAD/CNG, now that we are sending mono
// again.
@@ -542,7 +540,7 @@
test_cntr_++;
OpenOutFile(test_cntr_);
RegisterSendCodec('A', codec_l16, 8000, 128000, 80, codec_channels,
- l16_8khz_pltype_);
+ l16_8khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
if (test_mode_ != 0) {
@@ -553,7 +551,7 @@
test_cntr_++;
OpenOutFile(test_cntr_);
RegisterSendCodec('A', codec_l16, 16000, 256000, 160, codec_channels,
- l16_16khz_pltype_);
+ l16_16khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
if (test_mode_ != 0) {
@@ -564,7 +562,7 @@
test_cntr_++;
OpenOutFile(test_cntr_);
RegisterSendCodec('A', codec_l16, 32000, 512000, 320, codec_channels,
- l16_32khz_pltype_);
+ l16_32khz_pltype_);
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
#ifdef PCMA_AND_PCMU
@@ -593,7 +591,7 @@
OpenOutFile(test_cntr_);
// Encode and decode in mono.
RegisterSendCodec('A', codec_opus, 48000, 32000, 960, codec_channels,
- opus_pltype_);
+ opus_pltype_);
CodecInst opus_codec_param;
for (uint8_t n = 0; n < num_encoders; n++) {
EXPECT_EQ(0, acm_b_->Codec(n, &opus_codec_param));
@@ -620,8 +618,10 @@
OpenOutFile(test_cntr_);
if (test_mode_ != 0) {
// Print out codec and settings
- printf("Test number: %d\nCodec: Opus Freq: 48000 Rate :32000 PackSize: 960"
- " Decode: mono\n", test_cntr_);
+ printf(
+ "Test number: %d\nCodec: Opus Freq: 48000 Rate :32000 PackSize: 960"
+ " Decode: mono\n",
+ test_cntr_);
}
Run(channel_a2b_, audio_channels, codec_channels);
out_file_.Close();
@@ -630,8 +630,10 @@
OpenOutFile(test_cntr_);
if (test_mode_ != 0) {
// Print out codec and settings
- printf("Test number: %d\nCodec: Opus Freq: 48000 Rate :32000 PackSize: 960"
- " Decode: stereo\n", test_cntr_);
+ printf(
+ "Test number: %d\nCodec: Opus Freq: 48000 Rate :32000 PackSize: 960"
+ " Decode: stereo\n",
+ test_cntr_);
}
opus_codec_param.channels = 2;
EXPECT_EQ(true,
@@ -644,8 +646,10 @@
OpenOutFile(test_cntr_);
if (test_mode_ != 0) {
// Print out codec and settings
- printf("Test number: %d\nCodec: Opus Freq: 48000 Rate :32000 PackSize: 960"
- " Decode: mono\n", test_cntr_);
+ printf(
+ "Test number: %d\nCodec: Opus Freq: 48000 Rate :32000 PackSize: 960"
+ " Decode: mono\n",
+ test_cntr_);
}
opus_codec_param.channels = 1;
EXPECT_EQ(true,
@@ -665,9 +669,10 @@
#ifdef WEBRTC_CODEC_OPUS
printf(" Opus\n");
#endif
- printf("\nTo complete the test, listen to the %d number of output "
- "files.\n",
- test_cntr_);
+ printf(
+ "\nTo complete the test, listen to the %d number of output "
+ "files.\n",
+ test_cntr_);
}
// Delete the file pointers.
@@ -684,9 +689,12 @@
// pack_size - packet size in samples
// channels - number of channels; 1 for mono, 2 for stereo
// payload_type - payload type for the codec
-void TestStereo::RegisterSendCodec(char side, char* codec_name,
- int32_t sampling_freq_hz, int rate,
- int pack_size, int channels,
+void TestStereo::RegisterSendCodec(char side,
+ char* codec_name,
+ int32_t sampling_freq_hz,
+ int rate,
+ int pack_size,
+ int channels,
int payload_type) {
if (test_mode_ != 0) {
// Print out codec and settings
@@ -722,7 +730,8 @@
CodecInst my_codec_param;
// Get all codec parameters before registering
EXPECT_GT(AudioCodingModule::Codec(codec_name, &my_codec_param,
- sampling_freq_hz, channels), -1);
+ sampling_freq_hz, channels),
+ -1);
my_codec_param.rate = rate;
my_codec_param.pacsize = pack_size;
EXPECT_EQ(0, my_acm->RegisterSendCodec(my_codec_param));
@@ -730,7 +739,9 @@
send_codec_name_ = codec_name;
}
-void TestStereo::Run(TestPackStereo* channel, int in_channels, int out_channels,
+void TestStereo::Run(TestPackStereo* channel,
+ int in_channels,
+ int out_channels,
int percent_loss) {
AudioFrame audio_frame;
@@ -785,8 +796,8 @@
variable_packets++;
} else {
// For fixed rate codecs, check that packet size is correct.
- if ((rec_size != pack_size_bytes_ * out_channels)
- && (pack_size_bytes_ < 65535)) {
+ if ((rec_size != pack_size_bytes_ * out_channels) &&
+ (pack_size_bytes_ < 65535)) {
error_count++;
}
}
@@ -831,7 +842,7 @@
std::string file_name;
std::stringstream file_stream;
file_stream << webrtc::test::OutputPath() << "teststereo_out_" << test_number
- << ".pcm";
+ << ".pcm";
file_name = file_stream.str();
out_file_.Open(file_name, 32000, "wb");
}
diff --git a/modules/audio_coding/test/TestStereo.h b/modules/audio_coding/test/TestStereo.h
index a454f25..6fd7d6f 100644
--- a/modules/audio_coding/test/TestStereo.h
+++ b/modules/audio_coding/test/TestStereo.h
@@ -23,11 +23,7 @@
namespace webrtc {
-enum StereoMonoMode {
- kNotSet,
- kMono,
- kStereo
-};
+enum StereoMonoMode { kNotSet, kMono, kStereo };
class TestPackStereo : public AudioPacketizationCallback {
public:
@@ -72,11 +68,17 @@
// The default value of '-1' indicates that the registration is based only on
// codec name and a sampling frequncy matching is not required. This is useful
// for codecs which support several sampling frequency.
- void RegisterSendCodec(char side, char* codec_name, int32_t samp_freq_hz,
- int rate, int pack_size, int channels,
+ void RegisterSendCodec(char side,
+ char* codec_name,
+ int32_t samp_freq_hz,
+ int rate,
+ int pack_size,
+ int channels,
int payload_type);
- void Run(TestPackStereo* channel, int in_channels, int out_channels,
+ void Run(TestPackStereo* channel,
+ int in_channels,
+ int out_channels,
int percent_loss = 0);
void OpenOutFile(int16_t test_number);
void DisplaySendReceiveCodec();
diff --git a/modules/audio_coding/test/TestVADDTX.cc b/modules/audio_coding/test/TestVADDTX.cc
index 5865638..d211a6b 100644
--- a/modules/audio_coding/test/TestVADDTX.cc
+++ b/modules/audio_coding/test/TestVADDTX.cc
@@ -84,8 +84,11 @@
// Encoding a file and see if the numbers that various packets occur follow
// the expectation.
-void TestVadDtx::Run(std::string in_filename, int frequency, int channels,
- std::string out_filename, bool append,
+void TestVadDtx::Run(std::string in_filename,
+ int frequency,
+ int channels,
+ std::string out_filename,
+ bool append,
const int* expects) {
monitor_->ResetStatistics();
@@ -146,13 +149,10 @@
// Following is the implementation of TestWebRtcVadDtx.
TestWebRtcVadDtx::TestWebRtcVadDtx()
- : vad_enabled_(false),
- dtx_enabled_(false),
- output_file_num_(0) {
-}
+ : vad_enabled_(false), dtx_enabled_(false), output_file_num_(0) {}
void TestWebRtcVadDtx::Perform() {
- // Go through various test cases.
+// Go through various test cases.
#ifdef WEBRTC_CODEC_ISAC
// Register iSAC WB as send codec
RegisterCodec(kIsacWb);
@@ -206,15 +206,14 @@
output_file_num_++;
}
std::stringstream out_filename;
- out_filename << webrtc::test::OutputPath()
- << "testWebRtcVadDtx_outFile_"
- << output_file_num_
- << ".pcm";
- Run(webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"),
- 32000, 1, out_filename.str(), !new_outfile, expects);
+ out_filename << webrtc::test::OutputPath() << "testWebRtcVadDtx_outFile_"
+ << output_file_num_ << ".pcm";
+ Run(webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"), 32000, 1,
+ out_filename.str(), !new_outfile, expects);
}
-void TestWebRtcVadDtx::SetVAD(bool enable_dtx, bool enable_vad,
+void TestWebRtcVadDtx::SetVAD(bool enable_dtx,
+ bool enable_vad,
ACMVADMode vad_mode) {
ACMVADMode mode;
EXPECT_EQ(0, acm_send_->SetVAD(enable_dtx, enable_vad, vad_mode));
@@ -227,10 +226,10 @@
enable_dtx = enable_vad = false;
}
- EXPECT_EQ(dtx_enabled_ , enable_dtx); // DTX should be set as expected.
+ EXPECT_EQ(dtx_enabled_, enable_dtx); // DTX should be set as expected.
if (dtx_enabled_) {
- EXPECT_TRUE(vad_enabled_); // WebRTC DTX cannot run without WebRTC VAD.
+ EXPECT_TRUE(vad_enabled_); // WebRTC DTX cannot run without WebRTC VAD.
} else {
// Using no DTX should not affect setting of VAD.
EXPECT_EQ(enable_vad, vad_enabled_);
@@ -250,19 +249,19 @@
int expects[] = {0, 1, 0, 0, 0};
// Register Opus as send codec
- std::string out_filename = webrtc::test::OutputPath() +
- "testOpusDtx_outFile_mono.pcm";
+ std::string out_filename =
+ webrtc::test::OutputPath() + "testOpusDtx_outFile_mono.pcm";
RegisterCodec(kOpus);
EXPECT_EQ(0, acm_send_->DisableOpusDtx());
- Run(webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"),
- 32000, 1, out_filename, false, expects);
+ Run(webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"), 32000, 1,
+ out_filename, false, expects);
EXPECT_EQ(0, acm_send_->EnableOpusDtx());
expects[kEmptyFrame] = 1;
expects[kAudioFrameCN] = 1;
- Run(webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"),
- 32000, 1, out_filename, true, expects);
+ Run(webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"), 32000, 1,
+ out_filename, true, expects);
// Register stereo Opus as send codec
out_filename = webrtc::test::OutputPath() + "testOpusDtx_outFile_stereo.pcm";
@@ -270,15 +269,15 @@
EXPECT_EQ(0, acm_send_->DisableOpusDtx());
expects[kEmptyFrame] = 0;
expects[kAudioFrameCN] = 0;
- Run(webrtc::test::ResourcePath("audio_coding/teststereo32kHz", "pcm"),
- 32000, 2, out_filename, false, expects);
+ Run(webrtc::test::ResourcePath("audio_coding/teststereo32kHz", "pcm"), 32000,
+ 2, out_filename, false, expects);
EXPECT_EQ(0, acm_send_->EnableOpusDtx());
expects[kEmptyFrame] = 1;
expects[kAudioFrameCN] = 1;
- Run(webrtc::test::ResourcePath("audio_coding/teststereo32kHz", "pcm"),
- 32000, 2, out_filename, true, expects);
+ Run(webrtc::test::ResourcePath("audio_coding/teststereo32kHz", "pcm"), 32000,
+ 2, out_filename, true, expects);
#endif
}
diff --git a/modules/audio_coding/test/TestVADDTX.h b/modules/audio_coding/test/TestVADDTX.h
index 8cd4444..e3840f7 100644
--- a/modules/audio_coding/test/TestVADDTX.h
+++ b/modules/audio_coding/test/TestVADDTX.h
@@ -28,6 +28,7 @@
void PrintStatistics();
void ResetStatistics();
void GetStatistics(uint32_t* stats);
+
private:
// 0 - kEmptyFrame
// 1 - kAudioFrameSpeech
@@ -37,7 +38,6 @@
uint32_t counter_[5];
};
-
// TestVadDtx is to verify that VAD/DTX perform as they should. It runs through
// an audio file and check if the occurrence of various packet types follows
// expectation. TestVadDtx needs its derived class to implement the Perform()
@@ -65,8 +65,12 @@
// 2 - kAudioFrameCN
// 3 - kVideoFrameKey (not used by audio)
// 4 - kVideoFrameDelta (not used by audio)
- void Run(std::string in_filename, int frequency, int channels,
- std::string out_filename, bool append, const int* expects);
+ void Run(std::string in_filename,
+ int frequency,
+ int channels,
+ std::string out_filename,
+ bool append,
+ const int* expects);
std::unique_ptr<AudioCodingModule> acm_send_;
std::unique_ptr<AudioCodingModule> acm_receive_;
diff --git a/modules/audio_coding/test/Tester.cc b/modules/audio_coding/test/Tester.cc
index 1124222..8ce50a4 100644
--- a/modules/audio_coding/test/Tester.cc
+++ b/modules/audio_coding/test/Tester.cc
@@ -115,7 +115,7 @@
#if defined(WEBRTC_IOS)
TEST(AudioCodingModuleTest, DISABLED_TestPacketLossStereo) {
#else
- TEST(AudioCodingModuleTest, TestPacketLossStereo) {
+TEST(AudioCodingModuleTest, TestPacketLossStereo) {
#endif
webrtc::PacketLossTest(2, 10, 10, 1).Perform();
}
@@ -128,3 +128,11 @@
#endif
webrtc::PacketLossTest(2, 10, 10, 2).Perform();
}
+
+// The full API test is too long to run automatically on bots, but can be used
+// for offline testing. User interaction is needed.
+#ifdef ACM_TEST_FULL_API
+TEST(AudioCodingModuleTest, TestAPI) {
+ webrtc::APITest().Perform();
+}
+#endif
diff --git a/modules/audio_coding/test/TwoWayCommunication.cc b/modules/audio_coding/test/TwoWayCommunication.cc
index 1ed5a72..5a78c11 100644
--- a/modules/audio_coding/test/TwoWayCommunication.cc
+++ b/modules/audio_coding/test/TwoWayCommunication.cc
@@ -60,8 +60,7 @@
_outFileRefB.Close();
}
-void TwoWayCommunication::ChooseCodec(uint8_t* codecID_A,
- uint8_t* codecID_B) {
+void TwoWayCommunication::ChooseCodec(uint8_t* codecID_A, uint8_t* codecID_B) {
std::unique_ptr<AudioCodingModule> tmpACM(AudioCodingModule::Create(
AudioCodingModule::Config(CreateBuiltinAudioDecoderFactory())));
uint8_t noCodec = tmpACM->NumberOfCodecs();
@@ -75,11 +74,11 @@
printf("\nChoose a send codec for side A [0]: ");
char myStr[15] = "";
EXPECT_TRUE(fgets(myStr, 10, stdin) != NULL);
- *codecID_A = (uint8_t) atoi(myStr);
+ *codecID_A = (uint8_t)atoi(myStr);
printf("\nChoose a send codec for side B [0]: ");
EXPECT_TRUE(fgets(myStr, 10, stdin) != NULL);
- *codecID_B = (uint8_t) atoi(myStr);
+ *codecID_B = (uint8_t)atoi(myStr);
printf("\n");
}
@@ -118,8 +117,8 @@
uint16_t frequencyHz;
//--- Input A
- std::string in_file_name = webrtc::test::ResourcePath(
- "audio_coding/testfile32kHz", "pcm");
+ std::string in_file_name =
+ webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
frequencyHz = 32000;
printf("Enter input file at side A [%s]: ", in_file_name.c_str());
PCMFile::ChooseFile(&in_file_name, 499, &frequencyHz);
@@ -134,8 +133,8 @@
_outFileRefA.Open(ref_file_name, frequencyHz, "wb");
//--- Input B
- in_file_name = webrtc::test::ResourcePath("audio_coding/testfile32kHz",
- "pcm");
+ in_file_name =
+ webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
frequencyHz = 32000;
printf("\n\nEnter input file at side B [%s]: ", in_file_name.c_str());
PCMFile::ChooseFile(&in_file_name, 499, &frequencyHz);
@@ -200,8 +199,8 @@
uint16_t frequencyHz;
//--- Input A and B
- std::string in_file_name = webrtc::test::ResourcePath(
- "audio_coding/testfile32kHz", "pcm");
+ std::string in_file_name =
+ webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
frequencyHz = 16000;
_inFileA.Open(in_file_name, frequencyHz, "rb");
_inFileB.Open(in_file_name, frequencyHz, "rb");
@@ -210,16 +209,16 @@
std::string output_file_a = webrtc::test::OutputPath() + "outAutotestA.pcm";
frequencyHz = 16000;
_outFileA.Open(output_file_a, frequencyHz, "wb");
- std::string output_ref_file_a = webrtc::test::OutputPath()
- + "ref_outAutotestA.pcm";
+ std::string output_ref_file_a =
+ webrtc::test::OutputPath() + "ref_outAutotestA.pcm";
_outFileRefA.Open(output_ref_file_a, frequencyHz, "wb");
//--- Output B
std::string output_file_b = webrtc::test::OutputPath() + "outAutotestB.pcm";
frequencyHz = 16000;
_outFileB.Open(output_file_b, frequencyHz, "wb");
- std::string output_ref_file_b = webrtc::test::OutputPath()
- + "ref_outAutotestB.pcm";
+ std::string output_ref_file_b =
+ webrtc::test::OutputPath() + "ref_outAutotestB.pcm";
_outFileRefB.Open(output_ref_file_b, frequencyHz, "wb");
//--- Set A-to-B channel
diff --git a/modules/audio_coding/test/TwoWayCommunication.h b/modules/audio_coding/test/TwoWayCommunication.h
index fb23275..f0becae 100644
--- a/modules/audio_coding/test/TwoWayCommunication.h
+++ b/modules/audio_coding/test/TwoWayCommunication.h
@@ -27,6 +27,7 @@
~TwoWayCommunication();
void Perform();
+
private:
void ChooseCodec(uint8_t* codecID_A, uint8_t* codecID_B);
void SetUp();
diff --git a/modules/audio_coding/test/delay_test.cc b/modules/audio_coding/test/delay_test.cc
index 532a8eb..3c20a54 100644
--- a/modules/audio_coding/test/delay_test.cc
+++ b/modules/audio_coding/test/delay_test.cc
@@ -83,26 +83,25 @@
void Initialize() {
test_cntr_ = 0;
- std::string file_name = webrtc::test::ResourcePath(
- "audio_coding/testfile32kHz", "pcm");
+ std::string file_name =
+ webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
if (strlen(FLAG_input_file) > 0)
file_name = FLAG_input_file;
in_file_a_.Open(file_name, 32000, "rb");
- ASSERT_EQ(0, acm_a_->InitializeReceiver()) <<
- "Couldn't initialize receiver.\n";
- ASSERT_EQ(0, acm_b_->InitializeReceiver()) <<
- "Couldn't initialize receiver.\n";
+ ASSERT_EQ(0, acm_a_->InitializeReceiver())
+ << "Couldn't initialize receiver.\n";
+ ASSERT_EQ(0, acm_b_->InitializeReceiver())
+ << "Couldn't initialize receiver.\n";
if (FLAG_delay > 0) {
- ASSERT_EQ(0, acm_b_->SetMinimumPlayoutDelay(FLAG_delay)) <<
- "Failed to set minimum delay.\n";
+ ASSERT_EQ(0, acm_b_->SetMinimumPlayoutDelay(FLAG_delay))
+ << "Failed to set minimum delay.\n";
}
int num_encoders = acm_a_->NumberOfCodecs();
CodecInst my_codec_param;
for (int n = 0; n < num_encoders; n++) {
- EXPECT_EQ(0, acm_b_->Codec(n, &my_codec_param)) <<
- "Failed to get codec.";
+ EXPECT_EQ(0, acm_b_->Codec(n, &my_codec_param)) << "Failed to get codec.";
if (STR_CASE_CMP(my_codec_param.plname, "opus") == 0)
my_codec_param.channels = 1;
else if (my_codec_param.channels > 1)
@@ -118,12 +117,14 @@
}
// Create and connect the channel
- ASSERT_EQ(0, acm_a_->RegisterTransportCallback(channel_a2b_)) <<
- "Couldn't register Transport callback.\n";
+ ASSERT_EQ(0, acm_a_->RegisterTransportCallback(channel_a2b_))
+ << "Couldn't register Transport callback.\n";
channel_a2b_->RegisterReceiverACM(acm_b_.get());
}
- void Perform(const TestSettings* config, size_t num_tests, int duration_sec,
+ void Perform(const TestSettings* config,
+ size_t num_tests,
+ int duration_sec,
const char* output_prefix) {
for (size_t n = 0; n < num_tests; ++n) {
ApplyConfig(config[n]);
@@ -134,14 +135,15 @@
private:
void ApplyConfig(const TestSettings& config) {
printf("====================================\n");
- printf("Test %d \n"
- "Codec: %s, %d kHz, %d channel(s)\n"
- "ACM: DTX %s, FEC %s\n"
- "Channel: %s\n",
- ++test_cntr_, config.codec.name, config.codec.sample_rate_hz,
- config.codec.num_channels, config.acm.dtx ? "on" : "off",
- config.acm.fec ? "on" : "off",
- config.packet_loss ? "with packet-loss" : "no packet-loss");
+ printf(
+ "Test %d \n"
+ "Codec: %s, %d kHz, %d channel(s)\n"
+ "ACM: DTX %s, FEC %s\n"
+ "Channel: %s\n",
+ ++test_cntr_, config.codec.name, config.codec.sample_rate_hz,
+ config.codec.num_channels, config.acm.dtx ? "on" : "off",
+ config.acm.fec ? "on" : "off",
+ config.packet_loss ? "with packet-loss" : "no packet-loss");
SendCodec(config.codec);
ConfigAcm(config.acm);
ConfigChannel(config.packet_loss);
@@ -149,20 +151,20 @@
void SendCodec(const CodecSettings& config) {
CodecInst my_codec_param;
- ASSERT_EQ(0, AudioCodingModule::Codec(
- config.name, &my_codec_param, config.sample_rate_hz,
- config.num_channels)) << "Specified codec is not supported.\n";
+ ASSERT_EQ(
+ 0, AudioCodingModule::Codec(config.name, &my_codec_param,
+ config.sample_rate_hz, config.num_channels))
+ << "Specified codec is not supported.\n";
encoding_sample_rate_hz_ = my_codec_param.plfreq;
- ASSERT_EQ(0, acm_a_->RegisterSendCodec(my_codec_param)) <<
- "Failed to register send-codec.\n";
+ ASSERT_EQ(0, acm_a_->RegisterSendCodec(my_codec_param))
+ << "Failed to register send-codec.\n";
}
void ConfigAcm(const AcmSettings& config) {
- ASSERT_EQ(0, acm_a_->SetVAD(config.dtx, config.dtx, VADAggr)) <<
- "Failed to set VAD.\n";
- ASSERT_EQ(0, acm_a_->SetREDStatus(config.fec)) <<
- "Failed to set RED.\n";
+ ASSERT_EQ(0, acm_a_->SetVAD(config.dtx, config.dtx, VADAggr))
+ << "Failed to set VAD.\n";
+ ASSERT_EQ(0, acm_a_->SetREDStatus(config.fec)) << "Failed to set RED.\n";
}
void ConfigChannel(bool packet_loss) {
@@ -172,7 +174,8 @@
void OpenOutFile(const char* output_id) {
std::stringstream file_stream;
file_stream << "delay_test_" << FLAG_codec << "_" << FLAG_sample_rate_hz
- << "Hz" << "_" << FLAG_delay << "ms.pcm";
+ << "Hz"
+ << "_" << FLAG_delay << "ms.pcm";
std::cout << "Output file: " << file_stream.str() << std::endl << std::endl;
std::string file_name = webrtc::test::OutputPath() + file_stream.str();
out_file_b_.Open(file_name.c_str(), 32000, "wb");
@@ -197,14 +200,15 @@
if ((num_frames & 0x3F) == 0x3F) {
NetworkStatistics statistics;
acm_b_->GetNetworkStatistics(&statistics);
- fprintf(stdout, "delay: min=%3d max=%3d mean=%3d median=%3d"
+ fprintf(stdout,
+ "delay: min=%3d max=%3d mean=%3d median=%3d"
" ts-based average = %6.3f, "
"curr buff-lev = %4u opt buff-lev = %4u \n",
statistics.minWaitingTimeMs, statistics.maxWaitingTimeMs,
statistics.meanWaitingTimeMs, statistics.medianWaitingTimeMs,
average_delay, statistics.currentBufferSize,
statistics.preferredBufferSize);
- fflush (stdout);
+ fflush(stdout);
}
in_file_a_.Read10MsData(audio_frame);
@@ -256,10 +260,8 @@
webrtc::TestSettings test_setting;
strcpy(test_setting.codec.name, FLAG_codec);
- if (FLAG_sample_rate_hz != 8000 &&
- FLAG_sample_rate_hz != 16000 &&
- FLAG_sample_rate_hz != 32000 &&
- FLAG_sample_rate_hz != 48000) {
+ if (FLAG_sample_rate_hz != 8000 && FLAG_sample_rate_hz != 16000 &&
+ FLAG_sample_rate_hz != 32000 && FLAG_sample_rate_hz != 48000) {
std::cout << "Invalid sampling rate.\n";
return 1;
}
diff --git a/modules/audio_coding/test/iSACTest.cc b/modules/audio_coding/test/iSACTest.cc
index a847132..e9fd867 100644
--- a/modules/audio_coding/test/iSACTest.cc
+++ b/modules/audio_coding/test/iSACTest.cc
@@ -41,11 +41,11 @@
return;
}
-int16_t SetISAConfig(ACMTestISACConfig& isacConfig, AudioCodingModule* acm,
+int16_t SetISAConfig(ACMTestISACConfig& isacConfig,
+ AudioCodingModule* acm,
int testMode) {
-
- if ((isacConfig.currentRateBitPerSec != 0)
- || (isacConfig.currentFrameSizeMsec != 0)) {
+ if ((isacConfig.currentRateBitPerSec != 0) ||
+ (isacConfig.currentFrameSizeMsec != 0)) {
auto sendCodec = acm->SendCodec();
EXPECT_TRUE(sendCodec);
if (isacConfig.currentRateBitPerSec < 0) {
@@ -57,8 +57,8 @@
sendCodec->rate = isacConfig.currentRateBitPerSec;
}
if (isacConfig.currentFrameSizeMsec != 0) {
- sendCodec->pacsize = isacConfig.currentFrameSizeMsec
- * (sendCodec->plfreq / 1000);
+ sendCodec->pacsize =
+ isacConfig.currentFrameSizeMsec * (sendCodec->plfreq / 1000);
}
EXPECT_EQ(0, acm->RegisterSendCodec(*sendCodec));
}
@@ -81,15 +81,15 @@
CodecInst codecParam;
for (codecCntr = 0; codecCntr < AudioCodingModule::NumberOfCodecs();
- codecCntr++) {
+ codecCntr++) {
EXPECT_EQ(0, AudioCodingModule::Codec(codecCntr, &codecParam));
- if (!STR_CASE_CMP(codecParam.plname, "ISAC")
- && codecParam.plfreq == 16000) {
+ if (!STR_CASE_CMP(codecParam.plname, "ISAC") &&
+ codecParam.plfreq == 16000) {
memcpy(&_paramISAC16kHz, &codecParam, sizeof(CodecInst));
_idISAC16kHz = codecCntr;
}
- if (!STR_CASE_CMP(codecParam.plname, "ISAC")
- && codecParam.plfreq == 32000) {
+ if (!STR_CASE_CMP(codecParam.plname, "ISAC") &&
+ codecParam.plfreq == 32000) {
memcpy(&_paramISAC32kHz, &codecParam, sizeof(CodecInst));
_idISAC32kHz = codecCntr;
}
@@ -115,8 +115,8 @@
EXPECT_EQ(0, _acmB->RegisterTransportCallback(_channel_B2A.get()));
_channel_B2A->RegisterReceiverACM(_acmA.get());
- file_name_swb_ = webrtc::test::ResourcePath("audio_coding/testfile32kHz",
- "pcm");
+ file_name_swb_ =
+ webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
EXPECT_EQ(0, _acmB->RegisterSendCodec(_paramISAC16kHz));
EXPECT_EQ(0, _acmA->RegisterSendCodec(_paramISAC32kHz));
@@ -213,7 +213,8 @@
_outFileB.Write10MsData(audioFrame);
}
-void ISACTest::EncodeDecode(int testNr, ACMTestISACConfig& wbISACConfig,
+void ISACTest::EncodeDecode(int testNr,
+ ACMTestISACConfig& wbISACConfig,
ACMTestISACConfig& swbISACConfig) {
// Files in Side A and B
_inFileA.Open(file_name_swb_, 32000, "rb", true);
@@ -241,8 +242,8 @@
SetISAConfig(wbISACConfig, _acmB.get(), _testMode);
bool adaptiveMode = false;
- if ((swbISACConfig.currentRateBitPerSec == -1)
- || (wbISACConfig.currentRateBitPerSec == -1)) {
+ if ((swbISACConfig.currentRateBitPerSec == -1) ||
+ (wbISACConfig.currentRateBitPerSec == -1)) {
adaptiveMode = true;
}
_myTimer.Reset();
diff --git a/modules/audio_coding/test/iSACTest.h b/modules/audio_coding/test/iSACTest.h
index d0e7d59..22c85b4 100644
--- a/modules/audio_coding/test/iSACTest.h
+++ b/modules/audio_coding/test/iSACTest.h
@@ -23,7 +23,7 @@
#include "modules/audio_coding/test/utility.h"
#define MAX_FILE_NAME_LENGTH_BYTE 500
-#define NO_OF_CLIENTS 15
+#define NO_OF_CLIENTS 15
namespace webrtc {
@@ -42,12 +42,14 @@
~ISACTest();
void Perform();
+
private:
void Setup();
void Run10ms();
- void EncodeDecode(int testNr, ACMTestISACConfig& wbISACConfig,
+ void EncodeDecode(int testNr,
+ ACMTestISACConfig& wbISACConfig,
ACMTestISACConfig& swbISACConfig);
void SwitchingSamplingRate(int testNr, int maxSampRateChange);
diff --git a/modules/audio_coding/test/opus_test.cc b/modules/audio_coding/test/opus_test.cc
index d3afd6b..40b5147 100644
--- a/modules/audio_coding/test/opus_test.cc
+++ b/modules/audio_coding/test/opus_test.cc
@@ -211,8 +211,11 @@
#endif
}
-void OpusTest::Run(TestPackStereo* channel, size_t channels, int bitrate,
- size_t frame_length, int percent_loss) {
+void OpusTest::Run(TestPackStereo* channel,
+ size_t channels,
+ int bitrate,
+ size_t frame_length,
+ int percent_loss) {
AudioFrame audio_frame;
int32_t out_freq_hz_b = out_file_.SamplingFrequency();
const size_t kBufferSizeSamples = 480 * 12 * 2; // 120 ms stereo audio.
@@ -237,8 +240,8 @@
// default.
const int kOpusComplexity5 = 5;
EXPECT_EQ(0, WebRtcOpus_SetComplexity(opus_mono_encoder_, kOpusComplexity5));
- EXPECT_EQ(0, WebRtcOpus_SetComplexity(opus_stereo_encoder_,
- kOpusComplexity5));
+ EXPECT_EQ(0,
+ WebRtcOpus_SetComplexity(opus_stereo_encoder_, kOpusComplexity5));
#endif
// Fast-forward 1 second (100 blocks) since the files start with silence.
@@ -263,19 +266,16 @@
}
// If input audio is sampled at 32 kHz, resampling to 48 kHz is required.
- EXPECT_EQ(480,
- resampler_.Resample10Msec(audio_frame.data(),
- audio_frame.sample_rate_hz_,
- 48000,
- channels,
- kBufferSizeSamples - written_samples,
- &audio[written_samples]));
+ EXPECT_EQ(480, resampler_.Resample10Msec(
+ audio_frame.data(), audio_frame.sample_rate_hz_, 48000,
+ channels, kBufferSizeSamples - written_samples,
+ &audio[written_samples]));
written_samples += 480 * channels;
// Sometimes we need to loop over the audio vector to produce the right
// number of packets.
- size_t loop_encode = (written_samples - read_samples) /
- (channels * frame_length);
+ size_t loop_encode =
+ (written_samples - read_samples) / (channels * frame_length);
if (loop_encode > 0) {
const size_t kMaxBytes = 1000; // Maximum number of bytes for one packet.
@@ -319,9 +319,9 @@
opus_stereo_decoder_, bitstream, bitstream_len_byte,
&out_audio[decoded_samples * channels], &audio_type);
} else {
- decoded_samples += WebRtcOpus_DecodePlc(
- opus_stereo_decoder_, &out_audio[decoded_samples * channels],
- 1);
+ decoded_samples +=
+ WebRtcOpus_DecodePlc(opus_stereo_decoder_,
+ &out_audio[decoded_samples * channels], 1);
}
}
@@ -377,14 +377,14 @@
void OpusTest::OpenOutFile(int test_number) {
std::string file_name;
std::stringstream file_stream;
- file_stream << webrtc::test::OutputPath() << "opustest_out_"
- << test_number << ".pcm";
+ file_stream << webrtc::test::OutputPath() << "opustest_out_" << test_number
+ << ".pcm";
file_name = file_stream.str();
out_file_.Open(file_name, 48000, "wb");
file_stream.str("");
file_name = file_stream.str();
file_stream << webrtc::test::OutputPath() << "opusstandalone_out_"
- << test_number << ".pcm";
+ << test_number << ".pcm";
file_name = file_stream.str();
out_file_standalone_.Open(file_name, 48000, "wb");
}
diff --git a/modules/audio_coding/test/opus_test.h b/modules/audio_coding/test/opus_test.h
index 3e9d9a7..1356f27 100644
--- a/modules/audio_coding/test/opus_test.h
+++ b/modules/audio_coding/test/opus_test.h
@@ -15,8 +15,8 @@
#include <memory>
-#include "modules/audio_coding/codecs/opus/opus_interface.h"
#include "modules/audio_coding/acm2/acm_resampler.h"
+#include "modules/audio_coding/codecs/opus/opus_interface.h"
#include "modules/audio_coding/test/ACMTest.h"
#include "modules/audio_coding/test/Channel.h"
#include "modules/audio_coding/test/PCMFile.h"
diff --git a/modules/audio_coding/test/target_delay_unittest.cc b/modules/audio_coding/test/target_delay_unittest.cc
index 89bf34f..7579d62 100644
--- a/modules/audio_coding/test/target_delay_unittest.cc
+++ b/modules/audio_coding/test/target_delay_unittest.cc
@@ -73,8 +73,8 @@
void WithTargetDelayBufferNotChanging() {
// A target delay that is one packet larger than jitter.
- const int kTargetDelayMs = (kInterarrivalJitterPacket + 1) *
- kNum10msPerFrame * 10;
+ const int kTargetDelayMs =
+ (kInterarrivalJitterPacket + 1) * kNum10msPerFrame * 10;
ASSERT_EQ(0, SetMinimumDelay(kTargetDelayMs));
for (int n = 0; n < 30; ++n) // Run enough iterations to fill the buffer.
Run(true);
@@ -91,8 +91,8 @@
int clean_optimal_delay = GetCurrentOptimalDelayMs();
// A relatively large delay.
- const int kTargetDelayMs = (kInterarrivalJitterPacket + 10) *
- kNum10msPerFrame * 10;
+ const int kTargetDelayMs =
+ (kInterarrivalJitterPacket + 10) * kNum10msPerFrame * 10;
ASSERT_EQ(0, SetMinimumDelay(kTargetDelayMs));
for (int n = 0; n < 300; ++n) // Run enough iterations to fill the buffer.
Run(true);
@@ -146,8 +146,8 @@
void Push() {
rtp_info_.header.timestamp += kFrameSizeSamples;
rtp_info_.header.sequenceNumber++;
- ASSERT_EQ(0, acm_->IncomingPacket(payload_, kFrameSizeSamples * 2,
- rtp_info_));
+ ASSERT_EQ(0,
+ acm_->IncomingPacket(payload_, kFrameSizeSamples * 2, rtp_info_));
}
// Pull audio equivalent to the amount of audio in one RTP packet.
@@ -195,9 +195,7 @@
return stats.preferredBufferSize;
}
- int RequiredDelay() {
- return acm_->LeastRequiredDelayMs();
- }
+ int RequiredDelay() { return acm_->LeastRequiredDelayMs(); }
std::unique_ptr<AudioCodingModule> acm_;
WebRtcRTPHeader rtp_info_;
diff --git a/modules/audio_coding/test/utility.cc b/modules/audio_coding/test/utility.cc
index 3c64620..83c25b5 100644
--- a/modules/audio_coding/test/utility.cc
+++ b/modules/audio_coding/test/utility.cc
@@ -23,11 +23,7 @@
namespace webrtc {
-ACMTestTimer::ACMTestTimer()
- : _msec(0),
- _sec(0),
- _min(0),
- _hour(0) {
+ACMTestTimer::ACMTestTimer() : _msec(0), _sec(0), _min(0), _hour(0) {
return;
}
@@ -68,12 +64,14 @@
void ACMTestTimer::CurrentTimeHMS(char* currTime) {
sprintf(currTime, "%4lu:%02u:%06.3f", _hour, _min,
- (double) _sec + (double) _msec / 1000.);
+ (double)_sec + (double)_msec / 1000.);
return;
}
-void ACMTestTimer::CurrentTime(unsigned long& h, unsigned char& m,
- unsigned char& s, unsigned short& ms) {
+void ACMTestTimer::CurrentTime(unsigned long& h,
+ unsigned char& m,
+ unsigned char& s,
+ unsigned short& ms) {
h = _hour;
m = _min;
s = _sec;
@@ -101,9 +99,8 @@
}
int16_t ChooseCodec(CodecInst& codecInst) {
-
PrintCodecs();
- //AudioCodingModule* tmpACM = AudioCodingModule::Create(0);
+ // AudioCodingModule* tmpACM = AudioCodingModule::Create(0);
uint8_t noCodec = AudioCodingModule::NumberOfCodecs();
int8_t codecID;
bool outOfRange = false;
@@ -118,7 +115,7 @@
}
} while (outOfRange);
- CHECK_ERROR(AudioCodingModule::Codec((uint8_t )codecID, &codecInst));
+ CHECK_ERROR(AudioCodingModule::Codec((uint8_t)codecID, &codecInst));
return 0;
}
@@ -132,7 +129,6 @@
printf("%2d- %-18s %5d %6d\n", codecCntr, codecInst.plname,
codecInst.plfreq, codecInst.rate);
}
-
}
namespace test {
@@ -192,7 +188,7 @@
if (_calcVar) {
// to calculate variance we have to update
// the sum of squares
- _sumSqr += (double) (newVal - oldVal) * (double) (newVal + oldVal);
+ _sumSqr += (double)(newVal - oldVal) * (double)(newVal + oldVal);
}
}
@@ -236,17 +232,15 @@
assert(_buffLen > 0);
if (_buffIsFull) {
-
- mean = _sum / (double) _buffLen;
+ mean = _sum / (double)_buffLen;
return 0;
} else {
if (_idx > 0) {
- mean = _sum / (double) _idx;
+ mean = _sum / (double)_idx;
return 0;
} else {
return -1;
}
-
}
}
@@ -254,11 +248,11 @@
assert(_buffLen > 0);
if (_buffIsFull) {
- var = _sumSqr / (double) _buffLen;
+ var = _sumSqr / (double)_buffLen;
return 0;
} else {
if (_idx > 0) {
- var = _sumSqr / (double) _idx;
+ var = _sumSqr / (double)_idx;
return 0;
} else {
return -1;
@@ -269,9 +263,9 @@
} // namespace test
bool FixedPayloadTypeCodec(const char* payloadName) {
- char fixPayloadTypeCodecs[NUM_CODECS_WITH_FIXED_PAYLOAD_TYPE][32] = { "PCMU",
- "PCMA", "GSM", "G723", "DVI4", "LPC", "PCMA", "G722", "QCELP", "CN",
- "MPA", "G728", "G729" };
+ char fixPayloadTypeCodecs[NUM_CODECS_WITH_FIXED_PAYLOAD_TYPE][32] = {
+ "PCMU", "PCMA", "GSM", "G723", "DVI4", "LPC", "PCMA",
+ "G722", "QCELP", "CN", "MPA", "G728", "G729"};
for (int n = 0; n < NUM_CODECS_WITH_FIXED_PAYLOAD_TYPE; n++) {
if (!STR_CASE_CMP(payloadName, fixPayloadTypeCodecs[n])) {
diff --git a/modules/audio_coding/test/utility.h b/modules/audio_coding/test/utility.h
index 07cbe71..6f17df5 100644
--- a/modules/audio_coding/test/utility.h
+++ b/modules/audio_coding/test/utility.h
@@ -17,48 +17,48 @@
namespace webrtc {
//-----------------------------
-#define CHECK_ERROR(f) \
- do { \
- EXPECT_GE(f, 0) << "Error Calling API"; \
- } while(0)
+#define CHECK_ERROR(f) \
+ do { \
+ EXPECT_GE(f, 0) << "Error Calling API"; \
+ } while (0)
//-----------------------------
-#define CHECK_PROTECTED(f) \
- do { \
- if (f >= 0) { \
- ADD_FAILURE() << "Error Calling API"; \
- } else { \
- printf("An expected error is caught.\n"); \
- } \
- } while(0)
+#define CHECK_PROTECTED(f) \
+ do { \
+ if (f >= 0) { \
+ ADD_FAILURE() << "Error Calling API"; \
+ } else { \
+ printf("An expected error is caught.\n"); \
+ } \
+ } while (0)
//----------------------------
-#define CHECK_ERROR_MT(f) \
- do { \
- if (f < 0) { \
- fprintf(stderr, "Error Calling API in file %s at line %d \n", \
- __FILE__, __LINE__); \
- } \
- } while(0)
+#define CHECK_ERROR_MT(f) \
+ do { \
+ if (f < 0) { \
+ fprintf(stderr, "Error Calling API in file %s at line %d \n", __FILE__, \
+ __LINE__); \
+ } \
+ } while (0)
//----------------------------
-#define CHECK_PROTECTED_MT(f) \
- do { \
- if (f >= 0) { \
- fprintf(stderr, "Error Calling API in file %s at line %d \n", \
- __FILE__, __LINE__); \
- } else { \
- printf("An expected error is caught.\n"); \
- } \
- } while(0)
+#define CHECK_PROTECTED_MT(f) \
+ do { \
+ if (f >= 0) { \
+ fprintf(stderr, "Error Calling API in file %s at line %d \n", __FILE__, \
+ __LINE__); \
+ } else { \
+ printf("An expected error is caught.\n"); \
+ } \
+ } while (0)
-#define DELETE_POINTER(p) \
- do { \
- if (p != NULL) { \
- delete p; \
- p = NULL; \
- } \
- } while(0)
+#define DELETE_POINTER(p) \
+ do { \
+ if (p != NULL) { \
+ delete p; \
+ p = NULL; \
+ } \
+ } while (0)
class ACMTestTimer {
public:
@@ -71,7 +71,9 @@
void Tick100ms();
void Tick1sec();
void CurrentTimeHMS(char* currTime);
- void CurrentTime(unsigned long& h, unsigned char& m, unsigned char& s,
+ void CurrentTime(unsigned long& h,
+ unsigned char& m,
+ unsigned char& s,
unsigned short& ms);
private: