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 ee9e45a7..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 8a3928c5..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 1351b8b3..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..4c12665d 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 5eaa3d73..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 2c23e5c9..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:
diff --git a/modules/audio_device/android/audio_device_unittest.cc b/modules/audio_device/android/audio_device_unittest.cc
index c297aaa6..06ae706 100644
--- a/modules/audio_device/android/audio_device_unittest.cc
+++ b/modules/audio_device/android/audio_device_unittest.cc
@@ -92,6 +92,7 @@
public:
virtual void Write(const void* source, size_t num_frames) = 0;
virtual void Read(void* destination, size_t num_frames) = 0;
+
protected:
virtual ~AudioStreamInterface() {}
};
@@ -100,11 +101,10 @@
// construction.
class FileAudioStream : public AudioStreamInterface {
public:
- FileAudioStream(
- size_t num_callbacks, const std::string& file_name, int sample_rate)
- : file_size_in_bytes_(0),
- sample_rate_(sample_rate),
- file_pos_(0) {
+ FileAudioStream(size_t num_callbacks,
+ const std::string& file_name,
+ int sample_rate)
+ : file_size_in_bytes_(0), sample_rate_(sample_rate), file_pos_(0) {
file_size_in_bytes_ = test::GetFileSize(file_name);
sample_rate_ = sample_rate;
EXPECT_GE(file_size_in_callbacks(), num_callbacks)
@@ -114,8 +114,8 @@
file_.reset(new int16_t[num_16bit_samples]);
FILE* audio_file = fopen(file_name.c_str(), "rb");
EXPECT_NE(audio_file, nullptr);
- size_t num_samples_read = fread(
- file_.get(), sizeof(int16_t), num_16bit_samples, audio_file);
+ size_t num_samples_read =
+ fread(file_.get(), sizeof(int16_t), num_16bit_samples, audio_file);
EXPECT_EQ(num_samples_read, num_16bit_samples);
fclose(audio_file);
}
@@ -126,15 +126,14 @@
// Read samples from file stored in memory (at construction) and copy
// |num_frames| (<=> 10ms) to the |destination| byte buffer.
void Read(void* destination, size_t num_frames) override {
- memcpy(destination,
- static_cast<int16_t*> (&file_[file_pos_]),
+ memcpy(destination, static_cast<int16_t*>(&file_[file_pos_]),
num_frames * sizeof(int16_t));
file_pos_ += num_frames;
}
int file_size_in_seconds() const {
- return static_cast<int>(
- file_size_in_bytes_ / (kBytesPerSample * sample_rate_));
+ return static_cast<int>(file_size_in_bytes_ /
+ (kBytesPerSample * sample_rate_));
}
size_t file_size_in_callbacks() const {
return file_size_in_seconds() * kNumCallbacksPerSecond;
@@ -167,9 +166,7 @@
EXPECT_NE(fifo_.get(), nullptr);
}
- ~FifoAudioStream() {
- Flush();
- }
+ ~FifoAudioStream() { Flush(); }
// Allocate new memory, copy |num_frames| samples from |source| into memory
// and add pointer to the memory location to end of the list.
@@ -181,9 +178,7 @@
return;
}
int16_t* memory = new int16_t[frames_per_buffer_];
- memcpy(static_cast<int16_t*> (&memory[0]),
- source,
- bytes_per_buffer_);
+ memcpy(static_cast<int16_t*>(&memory[0]), source, bytes_per_buffer_);
rtc::CritScope lock(&lock_);
fifo_->push_back(memory);
const size_t size = fifo_->size();
@@ -206,24 +201,20 @@
} else {
int16_t* memory = fifo_->front();
fifo_->pop_front();
- memcpy(destination,
- static_cast<int16_t*> (&memory[0]),
- bytes_per_buffer_);
+ memcpy(destination, static_cast<int16_t*>(&memory[0]), bytes_per_buffer_);
delete memory;
}
}
- size_t size() const {
- return fifo_->size();
- }
+ size_t size() const { return fifo_->size(); }
- size_t largest_size() const {
- return largest_size_;
- }
+ size_t largest_size() const { return largest_size_; }
size_t average_size() const {
- return (total_written_elements_ == 0) ? 0.0 : 0.5 + static_cast<float> (
- total_written_elements_) / (write_count_ - kNumIgnoreFirstCallbacks);
+ return (total_written_elements_ == 0)
+ ? 0.0
+ : 0.5 + static_cast<float>(total_written_elements_) /
+ (write_count_ - kNumIgnoreFirstCallbacks);
}
private:
@@ -255,8 +246,7 @@
bytes_per_buffer_(frames_per_buffer_ * sizeof(int16_t)),
play_count_(0),
rec_count_(0),
- pulse_time_(0) {
- }
+ pulse_time_(0) {}
// Insert periodic impulses in first two samples of |destination|.
void Read(void* destination, size_t num_frames) override {
@@ -272,7 +262,7 @@
}
PRINT(".");
const int16_t impulse = std::numeric_limits<int16_t>::max();
- int16_t* ptr16 = static_cast<int16_t*> (destination);
+ int16_t* ptr16 = static_cast<int16_t*>(destination);
for (size_t i = 0; i < 2; ++i) {
ptr16[i] = impulse;
}
@@ -289,19 +279,18 @@
// been transmitted (sets |pulse_time_| to value larger than zero).
return;
}
- const int16_t* ptr16 = static_cast<const int16_t*> (source);
+ const int16_t* ptr16 = static_cast<const int16_t*>(source);
std::vector<int16_t> vec(ptr16, ptr16 + num_frames);
// Find max value in the audio buffer.
int max = *std::max_element(vec.begin(), vec.end());
// Find index (element position in vector) of the max element.
- int index_of_max = std::distance(vec.begin(),
- std::find(vec.begin(), vec.end(),
- max));
+ int index_of_max =
+ std::distance(vec.begin(), std::find(vec.begin(), vec.end(), max));
if (max > kImpulseThreshold) {
PRINTD("(%d,%d)", max, index_of_max);
int64_t now_time = rtc::TimeMillis();
- int extra_delay = IndexToMilliseconds(static_cast<double> (index_of_max));
- PRINTD("[%d]", static_cast<int> (now_time - pulse_time_));
+ int extra_delay = IndexToMilliseconds(static_cast<double>(index_of_max));
+ PRINTD("[%d]", static_cast<int>(now_time - pulse_time_));
PRINTD("[%d]", extra_delay);
// Total latency is the difference between transmit time and detection
// tome plus the extra delay within the buffer in which we detected the
@@ -315,9 +304,7 @@
}
}
- size_t num_latency_values() const {
- return latencies_.size();
- }
+ size_t num_latency_values() const { return latencies_.size(); }
int min_latency() const {
if (latencies_.empty())
@@ -334,9 +321,9 @@
int average_latency() const {
if (latencies_.empty())
return 0;
- return 0.5 + static_cast<double> (
- std::accumulate(latencies_.begin(), latencies_.end(), 0)) /
- latencies_.size();
+ return 0.5 + static_cast<double>(
+ std::accumulate(latencies_.begin(), latencies_.end(), 0)) /
+ latencies_.size();
}
void PrintResults() const {
@@ -345,8 +332,8 @@
PRINT("%d ", *it);
}
PRINT("\n");
- PRINT("%s[min, max, avg]=[%d, %d, %d] ms\n", kTag,
- min_latency(), max_latency(), average_latency());
+ PRINT("%s[min, max, avg]=[%d, %d, %d] ms\n", kTag, min_latency(),
+ max_latency(), average_latency());
}
int IndexToMilliseconds(double index) const {
@@ -473,8 +460,7 @@
// AudioDeviceTest test fixture.
class AudioDeviceTest : public ::testing::Test {
protected:
- AudioDeviceTest()
- : test_is_done_(EventWrapper::Create()) {
+ AudioDeviceTest() : test_is_done_(EventWrapper::Create()) {
// One-time initialization of JVM and application context. Ensures that we
// can do calls between C++ and Java. Initializes both Java and OpenSL ES
// implementations.
@@ -487,22 +473,12 @@
record_parameters_ = audio_manager()->GetRecordAudioParameters();
build_info_.reset(new BuildInfo());
}
- virtual ~AudioDeviceTest() {
- EXPECT_EQ(0, audio_device_->Terminate());
- }
+ virtual ~AudioDeviceTest() { EXPECT_EQ(0, audio_device_->Terminate()); }
- int playout_sample_rate() const {
- return playout_parameters_.sample_rate();
- }
- int record_sample_rate() const {
- return record_parameters_.sample_rate();
- }
- size_t playout_channels() const {
- return playout_parameters_.channels();
- }
- size_t record_channels() const {
- return record_parameters_.channels();
- }
+ int playout_sample_rate() const { return playout_parameters_.sample_rate(); }
+ int record_sample_rate() const { return record_parameters_.sample_rate(); }
+ size_t playout_channels() const { return playout_parameters_.channels(); }
+ size_t record_channels() const { return record_parameters_.channels(); }
size_t playout_frames_per_10ms_buffer() const {
return playout_parameters_.frames_per_10ms_buffer();
}
@@ -527,8 +503,8 @@
}
AudioManager* GetAudioManager(AudioDeviceModule* adm) const {
- return static_cast<AudioDeviceModuleImpl*>(adm)->
- GetAndroidAudioManagerForTest();
+ return static_cast<AudioDeviceModuleImpl*>(adm)
+ ->GetAndroidAudioManagerForTest();
}
AudioDeviceBuffer* audio_device_buffer() const {
@@ -546,9 +522,7 @@
std::string GetFileName(int sample_rate) {
EXPECT_TRUE(sample_rate == 48000 || sample_rate == 44100);
char fname[64];
- snprintf(fname,
- sizeof(fname),
- "audio_device/audio_short%d",
+ snprintf(fname, sizeof(fname), "audio_device/audio_short%d",
sample_rate / 1000);
std::string file_name(webrtc::test::ResourcePath(fname, "pcm"));
EXPECT_TRUE(test::FileExists(file_name));
@@ -705,16 +679,16 @@
TEST_F(AudioDeviceTest, CorrectAudioLayerIsUsedForCombinedJavaOpenSLCombo) {
AudioDeviceModule::AudioLayer expected_layer =
AudioDeviceModule::kAndroidJavaInputAndOpenSLESOutputAudio;
- AudioDeviceModule::AudioLayer active_layer = TestActiveAudioLayer(
- expected_layer);
+ AudioDeviceModule::AudioLayer active_layer =
+ TestActiveAudioLayer(expected_layer);
EXPECT_EQ(expected_layer, active_layer);
}
TEST_F(AudioDeviceTest, CorrectAudioLayerIsUsedForJavaInBothDirections) {
AudioDeviceModule::AudioLayer expected_layer =
AudioDeviceModule::kAndroidJavaAudio;
- AudioDeviceModule::AudioLayer active_layer = TestActiveAudioLayer(
- expected_layer);
+ AudioDeviceModule::AudioLayer active_layer =
+ TestActiveAudioLayer(expected_layer);
EXPECT_EQ(expected_layer, active_layer);
}
@@ -774,7 +748,7 @@
TEST_F(AudioDeviceTest, UsesCorrectDelayEstimateForLowLatencyOutputPath) {
EXPECT_EQ(kLowLatencyModeDelayEstimateInMilliseconds,
TestDelayOnAudioLayer(
- AudioDeviceModule::kAndroidJavaInputAndOpenSLESOutputAudio));
+ AudioDeviceModule::kAndroidJavaInputAndOpenSLESOutputAudio));
}
// Ensure that the ADM internal audio device buffer is configured to use the
@@ -790,7 +764,6 @@
audio_device_buffer()->RecordingChannels());
}
-
TEST_F(AudioDeviceTest, InitTerminate) {
// Initialization is part of the test fixture.
EXPECT_TRUE(audio_device()->Initialized());
@@ -896,11 +869,8 @@
MockAudioTransportAndroid mock(kPlayout);
mock.HandleCallbacks(test_is_done_.get(), nullptr, kNumCallbacks);
EXPECT_CALL(mock, NeedMorePlayData(playout_frames_per_10ms_buffer(),
- kBytesPerSample,
- playout_channels(),
- playout_sample_rate(),
- NotNull(),
- _, _, _))
+ kBytesPerSample, playout_channels(),
+ playout_sample_rate(), NotNull(), _, _, _))
.Times(AtLeast(kNumCallbacks));
EXPECT_EQ(0, audio_device()->RegisterAudioCallback(&mock));
StartPlayout();
@@ -927,18 +897,14 @@
StopRecording();
}
-
// Start playout and recording (full-duplex audio) and verify that audio is
// active in both directions.
TEST_F(AudioDeviceTest, StartPlayoutAndRecordingVerifyCallbacks) {
MockAudioTransportAndroid mock(kPlayout | kRecording);
- mock.HandleCallbacks(test_is_done_.get(), nullptr, kNumCallbacks);
+ mock.HandleCallbacks(test_is_done_.get(), nullptr, kNumCallbacks);
EXPECT_CALL(mock, NeedMorePlayData(playout_frames_per_10ms_buffer(),
- kBytesPerSample,
- playout_channels(),
- playout_sample_rate(),
- NotNull(),
- _, _, _))
+ kBytesPerSample, playout_channels(),
+ playout_sample_rate(), NotNull(), _, _, _))
.Times(AtLeast(kNumCallbacks));
EXPECT_CALL(
mock, RecordedDataIsAvailable(NotNull(), record_frames_per_10ms_buffer(),
@@ -964,8 +930,7 @@
std::string file_name = GetFileName(playout_sample_rate());
std::unique_ptr<FileAudioStream> file_audio_stream(
new FileAudioStream(num_callbacks, file_name, playout_sample_rate()));
- mock.HandleCallbacks(test_is_done_.get(),
- file_audio_stream.get(),
+ mock.HandleCallbacks(test_is_done_.get(), file_audio_stream.get(),
num_callbacks);
// SetMaxPlayoutVolume();
EXPECT_EQ(0, audio_device()->RegisterAudioCallback(&mock));
@@ -999,15 +964,14 @@
NiceMock<MockAudioTransportAndroid> mock(kPlayout | kRecording);
std::unique_ptr<FifoAudioStream> fifo_audio_stream(
new FifoAudioStream(playout_frames_per_10ms_buffer()));
- mock.HandleCallbacks(test_is_done_.get(),
- fifo_audio_stream.get(),
+ mock.HandleCallbacks(test_is_done_.get(), fifo_audio_stream.get(),
kFullDuplexTimeInSec * kNumCallbacksPerSecond);
SetMaxPlayoutVolume();
EXPECT_EQ(0, audio_device()->RegisterAudioCallback(&mock));
StartRecording();
StartPlayout();
- test_is_done_->Wait(std::max(kTestTimeOutInMilliseconds,
- 1000 * kFullDuplexTimeInSec));
+ test_is_done_->Wait(
+ std::max(kTestTimeOutInMilliseconds, 1000 * kFullDuplexTimeInSec));
StopPlayout();
StopRecording();
@@ -1033,16 +997,15 @@
NiceMock<MockAudioTransportAndroid> mock(kPlayout | kRecording);
std::unique_ptr<LatencyMeasuringAudioStream> latency_audio_stream(
new LatencyMeasuringAudioStream(playout_frames_per_10ms_buffer()));
- mock.HandleCallbacks(test_is_done_.get(),
- latency_audio_stream.get(),
+ mock.HandleCallbacks(test_is_done_.get(), latency_audio_stream.get(),
kMeasureLatencyTimeInSec * kNumCallbacksPerSecond);
EXPECT_EQ(0, audio_device()->RegisterAudioCallback(&mock));
SetMaxPlayoutVolume();
DisableBuiltInAECIfAvailable();
StartRecording();
StartPlayout();
- test_is_done_->Wait(std::max(kTestTimeOutInMilliseconds,
- 1000 * kMeasureLatencyTimeInSec));
+ test_is_done_->Wait(
+ std::max(kTestTimeOutInMilliseconds, 1000 * kMeasureLatencyTimeInSec));
StopPlayout();
StopRecording();
// Verify that the correct number of transmitted impulses are detected.
diff --git a/modules/audio_device/android/audio_manager.h b/modules/audio_device/android/audio_manager.h
index 3de991c..d2d0eb6 100644
--- a/modules/audio_device/android/audio_manager.h
+++ b/modules/audio_device/android/audio_manager.h
@@ -11,8 +11,8 @@
#ifndef MODULES_AUDIO_DEVICE_ANDROID_AUDIO_MANAGER_H_
#define MODULES_AUDIO_DEVICE_ANDROID_AUDIO_MANAGER_H_
-#include <jni.h>
#include <SLES/OpenSLES.h>
+#include <jni.h>
#include <memory>
diff --git a/modules/audio_device/android/audio_manager_unittest.cc b/modules/audio_device/android/audio_manager_unittest.cc
index 00314eb..ed713cb 100644
--- a/modules/audio_device/android/audio_manager_unittest.cc
+++ b/modules/audio_device/android/audio_manager_unittest.cc
@@ -73,8 +73,7 @@
AudioParameters record_parameters_;
};
-TEST_F(AudioManagerTest, ConstructDestruct) {
-}
+TEST_F(AudioManagerTest, ConstructDestruct) {}
// It should not be possible to create an OpenSL engine object if Java based
// audio is requested in both directions.
@@ -187,8 +186,8 @@
BuildInfo build_info;
PRINT("%smodel: %s\n", kTag, build_info.GetDeviceModel().c_str());
PRINT("%sbrand: %s\n", kTag, build_info.GetBrand().c_str());
- PRINT("%smanufacturer: %s\n",
- kTag, build_info.GetDeviceManufacturer().c_str());
+ PRINT("%smanufacturer: %s\n", kTag,
+ build_info.GetDeviceManufacturer().c_str());
}
// Add Android build information to the test for logging purposes.
@@ -238,4 +237,3 @@
}
} // namespace webrtc
-
diff --git a/modules/audio_device/android/audio_record_jni.cc b/modules/audio_device/android/audio_record_jni.cc
index 02d7448..97ba6c6 100644
--- a/modules/audio_device/android/audio_record_jni.cc
+++ b/modules/audio_device/android/audio_record_jni.cc
@@ -140,7 +140,7 @@
RTC_DCHECK(!recording_);
ScopedHistogramTimer timer("WebRTC.Audio.InitRecordingDurationMs");
int frames_per_buffer = j_audio_record_->InitRecording(
- audio_parameters_.sample_rate(), audio_parameters_.channels());
+ audio_parameters_.sample_rate(), audio_parameters_.channels());
if (frames_per_buffer < 0) {
direct_buffer_address_ = nullptr;
RTC_LOG(LS_ERROR) << "InitRecording failed";
@@ -246,7 +246,7 @@
RTC_DCHECK(!direct_buffer_address_);
direct_buffer_address_ = env->GetDirectBufferAddress(byte_buffer);
jlong capacity = env->GetDirectBufferCapacity(byte_buffer);
- RTC_LOG(INFO) << "direct buffer capacity: " << capacity;
+ RTC_LOG(INFO) << "direct buffer capacity: " << capacity;
direct_buffer_capacity_in_bytes_ = static_cast<size_t>(capacity);
}
diff --git a/modules/audio_device/android/audio_record_jni.h b/modules/audio_device/android/audio_record_jni.h
index f508280..a700a51 100644
--- a/modules/audio_device/android/audio_record_jni.h
+++ b/modules/audio_device/android/audio_record_jni.h
@@ -48,7 +48,7 @@
class JavaAudioRecord {
public:
JavaAudioRecord(NativeRegistration* native_registration,
- std::unique_ptr<GlobalRef> audio_track);
+ std::unique_ptr<GlobalRef> audio_track);
~JavaAudioRecord();
int InitRecording(int sample_rate, size_t channels);
@@ -91,8 +91,10 @@
// is also stored in |direct_buffer_capacity_in_bytes_|.
// This method will be called by the WebRtcAudioRecord constructor, i.e.,
// on the same thread that this object is created on.
- static void JNICALL CacheDirectBufferAddress(
- JNIEnv* env, jobject obj, jobject byte_buffer, jlong nativeAudioRecord);
+ static void JNICALL CacheDirectBufferAddress(JNIEnv* env,
+ jobject obj,
+ jobject byte_buffer,
+ jlong nativeAudioRecord);
void OnCacheDirectBufferAddress(JNIEnv* env, jobject byte_buffer);
// Called periodically by the Java based WebRtcAudioRecord object when
@@ -101,8 +103,10 @@
// now time to send these to the consumer.
// This method is called on a high-priority thread from Java. The name of
// the thread is 'AudioRecordThread'.
- static void JNICALL DataIsRecorded(
- JNIEnv* env, jobject obj, jint length, jlong nativeAudioRecord);
+ static void JNICALL DataIsRecorded(JNIEnv* env,
+ jobject obj,
+ jint length,
+ jlong nativeAudioRecord);
void OnDataIsRecorded(int length);
// Stores thread ID in constructor.
diff --git a/modules/audio_device/android/audio_track_jni.cc b/modules/audio_device/android/audio_track_jni.cc
index f8f254a..b0e5ddf 100644
--- a/modules/audio_device/android/audio_track_jni.cc
+++ b/modules/audio_device/android/audio_track_jni.cc
@@ -221,11 +221,11 @@
RTC_DCHECK(!direct_buffer_address_);
direct_buffer_address_ = env->GetDirectBufferAddress(byte_buffer);
jlong capacity = env->GetDirectBufferCapacity(byte_buffer);
- RTC_LOG(INFO) << "direct buffer capacity: " << capacity;
+ RTC_LOG(INFO) << "direct buffer capacity: " << capacity;
direct_buffer_capacity_in_bytes_ = static_cast<size_t>(capacity);
const size_t bytes_per_frame = audio_parameters_.channels() * sizeof(int16_t);
frames_per_buffer_ = direct_buffer_capacity_in_bytes_ / bytes_per_frame;
- RTC_LOG(INFO) << "frames_per_buffer: " << frames_per_buffer_;
+ RTC_LOG(INFO) << "frames_per_buffer: " << frames_per_buffer_;
}
JNI_FUNCTION_ALIGN
diff --git a/modules/audio_device/android/audio_track_jni.h b/modules/audio_device/android/audio_track_jni.h
index fd9c61e..469aa82 100644
--- a/modules/audio_device/android/audio_track_jni.h
+++ b/modules/audio_device/android/audio_track_jni.h
@@ -90,8 +90,10 @@
// |byte_buffer| in |direct_buffer_address_|. The size of the buffer
// is also stored in |direct_buffer_capacity_in_bytes_|.
// Called on the same thread as the creating thread.
- static void JNICALL CacheDirectBufferAddress(
- JNIEnv* env, jobject obj, jobject byte_buffer, jlong nativeAudioTrack);
+ static void JNICALL CacheDirectBufferAddress(JNIEnv* env,
+ jobject obj,
+ jobject byte_buffer,
+ jlong nativeAudioTrack);
void OnCacheDirectBufferAddress(JNIEnv* env, jobject byte_buffer);
// Called periodically by the Java based WebRtcAudioTrack object when
@@ -99,8 +101,10 @@
// be written to the memory area |direct_buffer_address_| for playout.
// This method is called on a high-priority thread from Java. The name of
// the thread is 'AudioTrackThread'.
- static void JNICALL GetPlayoutData(
- JNIEnv* env, jobject obj, jint length, jlong nativeAudioTrack);
+ static void JNICALL GetPlayoutData(JNIEnv* env,
+ jobject obj,
+ jint length,
+ jlong nativeAudioTrack);
void OnGetPlayoutData(size_t length);
// Stores thread ID in constructor.
diff --git a/modules/audio_device/android/build_info.cc b/modules/audio_device/android/build_info.cc
index 9eab4b3..916be82 100644
--- a/modules/audio_device/android/build_info.cc
+++ b/modules/audio_device/android/build_info.cc
@@ -21,8 +21,8 @@
std::string BuildInfo::GetStringFromJava(const char* name) {
jmethodID id = j_build_info_.GetStaticMethodId(name, "()Ljava/lang/String;");
- jstring j_string = static_cast<jstring>(
- j_build_info_.CallStaticObjectMethod(id));
+ jstring j_string =
+ static_cast<jstring>(j_build_info_.CallStaticObjectMethod(id));
return j_environment_->JavaToStdString(j_string);
}
diff --git a/modules/audio_device/android/opensles_common.h b/modules/audio_device/android/opensles_common.h
index 90988ee..438c522 100644
--- a/modules/audio_device/android/opensles_common.h
+++ b/modules/audio_device/android/opensles_common.h
@@ -11,8 +11,8 @@
#ifndef MODULES_AUDIO_DEVICE_ANDROID_OPENSLES_COMMON_H_
#define MODULES_AUDIO_DEVICE_ANDROID_OPENSLES_COMMON_H_
-#include <stddef.h>
#include <SLES/OpenSLES.h>
+#include <stddef.h>
#include "rtc_base/checks.h"
diff --git a/modules/audio_device/audio_device_buffer.cc b/modules/audio_device/audio_device_buffer.cc
index 3bbc714..d872da5 100644
--- a/modules/audio_device/audio_device_buffer.cc
+++ b/modules/audio_device/audio_device_buffer.cc
@@ -244,8 +244,7 @@
recording_thread_checker_.DetachFromThread();
}
-void AudioDeviceBuffer::SetVQEData(int play_delay_ms,
- int rec_delay_ms) {
+void AudioDeviceBuffer::SetVQEData(int play_delay_ms, int rec_delay_ms) {
RTC_DCHECK_RUN_ON(&recording_thread_checker_);
play_delay_ms_ = play_delay_ms;
rec_delay_ms_ = rec_delay_ms;
diff --git a/modules/audio_device/audio_device_config.h b/modules/audio_device/audio_device_config.h
index fd12c8b..fa51747 100644
--- a/modules/audio_device/audio_device_config.h
+++ b/modules/audio_device/audio_device_config.h
@@ -28,4 +28,3 @@
#endif
#endif // AUDIO_DEVICE_AUDIO_DEVICE_CONFIG_H_
-
diff --git a/modules/audio_device/audio_device_generic.h b/modules/audio_device/audio_device_generic.h
index e7abcb3..be9c072 100644
--- a/modules/audio_device/audio_device_generic.h
+++ b/modules/audio_device/audio_device_generic.h
@@ -122,8 +122,8 @@
virtual int32_t EnableBuiltInAGC(bool enable);
virtual int32_t EnableBuiltInNS(bool enable);
- // iOS only.
- // TODO(henrika): add Android support.
+// iOS only.
+// TODO(henrika): add Android support.
#if defined(WEBRTC_IOS)
virtual int GetPlayoutAudioParameters(AudioParameters* params) const;
virtual int GetRecordAudioParameters(AudioParameters* params) const;
diff --git a/modules/audio_device/dummy/audio_device_dummy.cc b/modules/audio_device/dummy/audio_device_dummy.cc
index b7b61a7..b8fd837 100644
--- a/modules/audio_device/dummy/audio_device_dummy.cc
+++ b/modules/audio_device/dummy/audio_device_dummy.cc
@@ -21,13 +21,21 @@
return InitStatus::OK;
}
-int32_t AudioDeviceDummy::Terminate() { return 0; }
+int32_t AudioDeviceDummy::Terminate() {
+ return 0;
+}
-bool AudioDeviceDummy::Initialized() const { return true; }
+bool AudioDeviceDummy::Initialized() const {
+ return true;
+}
-int16_t AudioDeviceDummy::PlayoutDevices() { return -1; }
+int16_t AudioDeviceDummy::PlayoutDevices() {
+ return -1;
+}
-int16_t AudioDeviceDummy::RecordingDevices() { return -1; }
+int16_t AudioDeviceDummy::RecordingDevices() {
+ return -1;
+}
int32_t AudioDeviceDummy::PlayoutDeviceName(uint16_t index,
char name[kAdmMaxDeviceNameSize],
@@ -41,59 +49,99 @@
return -1;
}
-int32_t AudioDeviceDummy::SetPlayoutDevice(uint16_t index) { return -1; }
+int32_t AudioDeviceDummy::SetPlayoutDevice(uint16_t index) {
+ return -1;
+}
int32_t AudioDeviceDummy::SetPlayoutDevice(
AudioDeviceModule::WindowsDeviceType device) {
return -1;
}
-int32_t AudioDeviceDummy::SetRecordingDevice(uint16_t index) { return -1; }
+int32_t AudioDeviceDummy::SetRecordingDevice(uint16_t index) {
+ return -1;
+}
int32_t AudioDeviceDummy::SetRecordingDevice(
AudioDeviceModule::WindowsDeviceType device) {
return -1;
}
-int32_t AudioDeviceDummy::PlayoutIsAvailable(bool& available) { return -1; }
+int32_t AudioDeviceDummy::PlayoutIsAvailable(bool& available) {
+ return -1;
+}
-int32_t AudioDeviceDummy::InitPlayout() { return -1; }
+int32_t AudioDeviceDummy::InitPlayout() {
+ return -1;
+}
-bool AudioDeviceDummy::PlayoutIsInitialized() const { return false; }
+bool AudioDeviceDummy::PlayoutIsInitialized() const {
+ return false;
+}
-int32_t AudioDeviceDummy::RecordingIsAvailable(bool& available) { return -1; }
+int32_t AudioDeviceDummy::RecordingIsAvailable(bool& available) {
+ return -1;
+}
-int32_t AudioDeviceDummy::InitRecording() { return -1; }
+int32_t AudioDeviceDummy::InitRecording() {
+ return -1;
+}
-bool AudioDeviceDummy::RecordingIsInitialized() const { return false; }
+bool AudioDeviceDummy::RecordingIsInitialized() const {
+ return false;
+}
-int32_t AudioDeviceDummy::StartPlayout() { return -1; }
+int32_t AudioDeviceDummy::StartPlayout() {
+ return -1;
+}
-int32_t AudioDeviceDummy::StopPlayout() { return 0; }
+int32_t AudioDeviceDummy::StopPlayout() {
+ return 0;
+}
-bool AudioDeviceDummy::Playing() const { return false; }
+bool AudioDeviceDummy::Playing() const {
+ return false;
+}
-int32_t AudioDeviceDummy::StartRecording() { return -1; }
+int32_t AudioDeviceDummy::StartRecording() {
+ return -1;
+}
-int32_t AudioDeviceDummy::StopRecording() { return 0; }
+int32_t AudioDeviceDummy::StopRecording() {
+ return 0;
+}
-bool AudioDeviceDummy::Recording() const { return false; }
+bool AudioDeviceDummy::Recording() const {
+ return false;
+}
-int32_t AudioDeviceDummy::InitSpeaker() { return -1; }
+int32_t AudioDeviceDummy::InitSpeaker() {
+ return -1;
+}
-bool AudioDeviceDummy::SpeakerIsInitialized() const { return false; }
+bool AudioDeviceDummy::SpeakerIsInitialized() const {
+ return false;
+}
-int32_t AudioDeviceDummy::InitMicrophone() { return -1; }
+int32_t AudioDeviceDummy::InitMicrophone() {
+ return -1;
+}
-bool AudioDeviceDummy::MicrophoneIsInitialized() const { return false; }
+bool AudioDeviceDummy::MicrophoneIsInitialized() const {
+ return false;
+}
int32_t AudioDeviceDummy::SpeakerVolumeIsAvailable(bool& available) {
return -1;
}
-int32_t AudioDeviceDummy::SetSpeakerVolume(uint32_t volume) { return -1; }
+int32_t AudioDeviceDummy::SetSpeakerVolume(uint32_t volume) {
+ return -1;
+}
-int32_t AudioDeviceDummy::SpeakerVolume(uint32_t& volume) const { return -1; }
+int32_t AudioDeviceDummy::SpeakerVolume(uint32_t& volume) const {
+ return -1;
+}
int32_t AudioDeviceDummy::MaxSpeakerVolume(uint32_t& maxVolume) const {
return -1;
@@ -107,7 +155,9 @@
return -1;
}
-int32_t AudioDeviceDummy::SetMicrophoneVolume(uint32_t volume) { return -1; }
+int32_t AudioDeviceDummy::SetMicrophoneVolume(uint32_t volume) {
+ return -1;
+}
int32_t AudioDeviceDummy::MicrophoneVolume(uint32_t& volume) const {
return -1;
@@ -121,36 +171,56 @@
return -1;
}
-int32_t AudioDeviceDummy::SpeakerMuteIsAvailable(bool& available) { return -1; }
+int32_t AudioDeviceDummy::SpeakerMuteIsAvailable(bool& available) {
+ return -1;
+}
-int32_t AudioDeviceDummy::SetSpeakerMute(bool enable) { return -1; }
+int32_t AudioDeviceDummy::SetSpeakerMute(bool enable) {
+ return -1;
+}
-int32_t AudioDeviceDummy::SpeakerMute(bool& enabled) const { return -1; }
+int32_t AudioDeviceDummy::SpeakerMute(bool& enabled) const {
+ return -1;
+}
int32_t AudioDeviceDummy::MicrophoneMuteIsAvailable(bool& available) {
return -1;
}
-int32_t AudioDeviceDummy::SetMicrophoneMute(bool enable) { return -1; }
+int32_t AudioDeviceDummy::SetMicrophoneMute(bool enable) {
+ return -1;
+}
-int32_t AudioDeviceDummy::MicrophoneMute(bool& enabled) const { return -1; }
+int32_t AudioDeviceDummy::MicrophoneMute(bool& enabled) const {
+ return -1;
+}
int32_t AudioDeviceDummy::StereoPlayoutIsAvailable(bool& available) {
return -1;
}
-int32_t AudioDeviceDummy::SetStereoPlayout(bool enable) { return -1; }
+int32_t AudioDeviceDummy::SetStereoPlayout(bool enable) {
+ return -1;
+}
-int32_t AudioDeviceDummy::StereoPlayout(bool& enabled) const { return -1; }
+int32_t AudioDeviceDummy::StereoPlayout(bool& enabled) const {
+ return -1;
+}
int32_t AudioDeviceDummy::StereoRecordingIsAvailable(bool& available) {
return -1;
}
-int32_t AudioDeviceDummy::SetStereoRecording(bool enable) { return -1; }
+int32_t AudioDeviceDummy::SetStereoRecording(bool enable) {
+ return -1;
+}
-int32_t AudioDeviceDummy::StereoRecording(bool& enabled) const { return -1; }
+int32_t AudioDeviceDummy::StereoRecording(bool& enabled) const {
+ return -1;
+}
-int32_t AudioDeviceDummy::PlayoutDelay(uint16_t& delayMS) const { return -1; }
+int32_t AudioDeviceDummy::PlayoutDelay(uint16_t& delayMS) const {
+ return -1;
+}
void AudioDeviceDummy::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) {}
} // namespace webrtc
diff --git a/modules/audio_device/dummy/file_audio_device.h b/modules/audio_device/dummy/file_audio_device.h
index 8eea38c..f07690e 100644
--- a/modules/audio_device/dummy/file_audio_device.h
+++ b/modules/audio_device/dummy/file_audio_device.h
@@ -38,8 +38,7 @@
// The input file should be a readable 48k stereo raw file, and the output
// file should point to a writable location. The output format will also be
// 48k stereo raw audio.
- FileAudioDevice(const char* inputFilename,
- const char* outputFilename);
+ FileAudioDevice(const char* inputFilename, const char* outputFilename);
virtual ~FileAudioDevice();
// Retrieve the currently utilized audio layer
@@ -138,7 +137,7 @@
int32_t _record_index;
AudioDeviceBuffer* _ptrAudioBuffer;
int8_t* _recordingBuffer; // In bytes.
- int8_t* _playoutBuffer; // In bytes.
+ int8_t* _playoutBuffer; // In bytes.
uint32_t _recordingFramesLeft;
uint32_t _playoutFramesLeft;
rtc::CriticalSection _critSect;
diff --git a/modules/audio_device/include/audio_device.h b/modules/audio_device/include/audio_device.h
index 8b7a5cc..a861319 100644
--- a/modules/audio_device/include/audio_device.h
+++ b/modules/audio_device/include/audio_device.h
@@ -1,4 +1,4 @@
- /*
+/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
@@ -12,8 +12,8 @@
#define MODULES_AUDIO_DEVICE_INCLUDE_AUDIO_DEVICE_H_
#include "modules/audio_device/include/audio_device_defines.h"
-#include "rtc_base/scoped_ref_ptr.h"
#include "rtc_base/refcount.h"
+#include "rtc_base/scoped_ref_ptr.h"
namespace webrtc {
@@ -21,10 +21,7 @@
public:
// Deprecated.
// TODO(henrika): to be removed.
- enum ErrorCode {
- kAdmErrNone = 0,
- kAdmErrArgument = 1
- };
+ enum ErrorCode { kAdmErrNone = 0, kAdmErrArgument = 1 };
enum AudioLayer {
kPlatformDefaultAudio = 0,
@@ -46,11 +43,7 @@
};
// TODO(bugs.webrtc.org/7306): deprecated.
- enum ChannelType {
- kChannelLeft = 0,
- kChannelRight = 1,
- kChannelBoth = 2
- };
+ enum ChannelType { kChannelLeft = 0, kChannelRight = 1, kChannelBoth = 2 };
public:
// Creates an ADM.
diff --git a/modules/audio_device/include/mock_audio_device.h b/modules/audio_device/include/mock_audio_device.h
index 7984e0b..105442b 100644
--- a/modules/audio_device/include/mock_audio_device.h
+++ b/modules/audio_device/include/mock_audio_device.h
@@ -33,12 +33,14 @@
MOCK_CONST_METHOD0(Initialized, bool());
MOCK_METHOD0(PlayoutDevices, int16_t());
MOCK_METHOD0(RecordingDevices, int16_t());
- MOCK_METHOD3(PlayoutDeviceName, int32_t(uint16_t index,
- char name[kAdmMaxDeviceNameSize],
- char guid[kAdmMaxGuidSize]));
- MOCK_METHOD3(RecordingDeviceName, int32_t(uint16_t index,
- char name[kAdmMaxDeviceNameSize],
- char guid[kAdmMaxGuidSize]));
+ MOCK_METHOD3(PlayoutDeviceName,
+ int32_t(uint16_t index,
+ char name[kAdmMaxDeviceNameSize],
+ char guid[kAdmMaxGuidSize]));
+ MOCK_METHOD3(RecordingDeviceName,
+ int32_t(uint16_t index,
+ char name[kAdmMaxDeviceNameSize],
+ char guid[kAdmMaxGuidSize]));
MOCK_METHOD1(SetPlayoutDevice, int32_t(uint16_t index));
MOCK_METHOD1(SetPlayoutDevice, int32_t(WindowsDeviceType device));
MOCK_METHOD1(SetRecordingDevice, int32_t(uint16_t index));
diff --git a/modules/audio_device/ios/audio_device_ios.h b/modules/audio_device/ios/audio_device_ios.h
index b1d4053..eeebbf3 100644
--- a/modules/audio_device/ios/audio_device_ios.h
+++ b/modules/audio_device/ios/audio_device_ios.h
@@ -13,7 +13,6 @@
#include <memory>
-#include "sdk/objc/Framework/Headers/WebRTC/RTCMacros.h"
#include "modules/audio_device/audio_device_generic.h"
#include "modules/audio_device/ios/audio_session_observer.h"
#include "modules/audio_device/ios/voice_processing_audio_unit.h"
@@ -22,6 +21,7 @@
#include "rtc_base/thread.h"
#include "rtc_base/thread_annotations.h"
#include "rtc_base/thread_checker.h"
+#include "sdk/objc/Framework/Headers/WebRTC/RTCMacros.h"
RTC_FWD_DECL_OBJC_CLASS(RTCAudioSessionDelegateAdapter);
@@ -154,7 +154,7 @@
AudioBufferList* io_data) override;
// Handles messages from posts.
- void OnMessage(rtc::Message *msg) override;
+ void OnMessage(rtc::Message* msg) override;
private:
// Called by the relevant AudioSessionObserver methods on |thread_|.
diff --git a/modules/audio_device/ios/objc/RTCAudioSessionDelegateAdapter.h b/modules/audio_device/ios/objc/RTCAudioSessionDelegateAdapter.h
index 7a0f9d2..f024bfb 100644
--- a/modules/audio_device/ios/objc/RTCAudioSessionDelegateAdapter.h
+++ b/modules/audio_device/ios/objc/RTCAudioSessionDelegateAdapter.h
@@ -24,7 +24,6 @@
/** |observer| is a raw pointer and should be kept alive
* for this object's lifetime.
*/
-- (instancetype)initWithObserver:(webrtc::AudioSessionObserver *)observer
- NS_DESIGNATED_INITIALIZER;
+- (instancetype)initWithObserver:(webrtc::AudioSessionObserver *)observer NS_DESIGNATED_INITIALIZER;
@end
diff --git a/modules/audio_device/linux/alsasymboltable_linux.cc b/modules/audio_device/linux/alsasymboltable_linux.cc
index d605dba..5dfb91d 100644
--- a/modules/audio_device/linux/alsasymboltable_linux.cc
+++ b/modules/audio_device/linux/alsasymboltable_linux.cc
@@ -31,8 +31,7 @@
namespace adm_linux_alsa {
LATE_BINDING_SYMBOL_TABLE_DEFINE_BEGIN(AlsaSymbolTable, "libasound.so.2")
-#define X(sym) \
- LATE_BINDING_SYMBOL_TABLE_DEFINE_ENTRY(AlsaSymbolTable, sym)
+#define X(sym) LATE_BINDING_SYMBOL_TABLE_DEFINE_ENTRY(AlsaSymbolTable, sym)
ALSA_SYMBOLS_LIST
#undef X
LATE_BINDING_SYMBOL_TABLE_DEFINE_END(AlsaSymbolTable)
diff --git a/modules/audio_device/linux/alsasymboltable_linux.h b/modules/audio_device/linux/alsasymboltable_linux.h
index 9c1f954..c9970b0 100644
--- a/modules/audio_device/linux/alsasymboltable_linux.h
+++ b/modules/audio_device/linux/alsasymboltable_linux.h
@@ -36,109 +36,108 @@
// The ALSA symbols we need, as an X-Macro list.
// This list must contain precisely every libasound function that is used in
// alsasoundsystem.cc.
-#define ALSA_SYMBOLS_LIST \
- X(snd_device_name_free_hint) \
- X(snd_device_name_get_hint) \
- X(snd_device_name_hint) \
- X(snd_pcm_avail_update) \
- X(snd_pcm_close) \
- X(snd_pcm_delay) \
- X(snd_pcm_drop) \
- X(snd_pcm_open) \
- X(snd_pcm_prepare) \
- X(snd_pcm_readi) \
- X(snd_pcm_recover) \
- X(snd_pcm_resume) \
- X(snd_pcm_reset) \
- X(snd_pcm_state) \
- X(snd_pcm_set_params) \
- X(snd_pcm_get_params) \
- X(snd_pcm_start) \
- X(snd_pcm_stream) \
- X(snd_pcm_frames_to_bytes) \
- X(snd_pcm_bytes_to_frames) \
- X(snd_pcm_wait) \
- X(snd_pcm_writei) \
- X(snd_pcm_info_get_class) \
- X(snd_pcm_info_get_subdevices_avail) \
- X(snd_pcm_info_get_subdevice_name) \
- X(snd_pcm_info_set_subdevice) \
- X(snd_pcm_info_get_id) \
- X(snd_pcm_info_set_device) \
- X(snd_pcm_info_set_stream) \
- X(snd_pcm_info_get_name) \
- X(snd_pcm_info_get_subdevices_count) \
- X(snd_pcm_info_sizeof) \
- X(snd_pcm_hw_params) \
- X(snd_pcm_hw_params_malloc) \
- X(snd_pcm_hw_params_free) \
- X(snd_pcm_hw_params_any) \
- X(snd_pcm_hw_params_set_access) \
- X(snd_pcm_hw_params_set_format) \
- X(snd_pcm_hw_params_set_channels) \
- X(snd_pcm_hw_params_set_rate_near) \
- X(snd_pcm_hw_params_set_buffer_size_near) \
- X(snd_card_next) \
- X(snd_card_get_name) \
- X(snd_config_update) \
- X(snd_config_copy) \
- X(snd_config_get_id) \
- X(snd_ctl_open) \
- X(snd_ctl_close) \
- X(snd_ctl_card_info) \
- X(snd_ctl_card_info_sizeof) \
- X(snd_ctl_card_info_get_id) \
- X(snd_ctl_card_info_get_name) \
- X(snd_ctl_pcm_next_device) \
- X(snd_ctl_pcm_info) \
- X(snd_mixer_load) \
- X(snd_mixer_free) \
- X(snd_mixer_detach) \
- X(snd_mixer_close) \
- X(snd_mixer_open) \
- X(snd_mixer_attach) \
- X(snd_mixer_first_elem) \
- X(snd_mixer_elem_next) \
- X(snd_mixer_selem_get_name) \
- X(snd_mixer_selem_is_active) \
- X(snd_mixer_selem_register) \
- X(snd_mixer_selem_set_playback_volume_all) \
- X(snd_mixer_selem_get_playback_volume) \
- X(snd_mixer_selem_has_playback_volume) \
+#define ALSA_SYMBOLS_LIST \
+ X(snd_device_name_free_hint) \
+ X(snd_device_name_get_hint) \
+ X(snd_device_name_hint) \
+ X(snd_pcm_avail_update) \
+ X(snd_pcm_close) \
+ X(snd_pcm_delay) \
+ X(snd_pcm_drop) \
+ X(snd_pcm_open) \
+ X(snd_pcm_prepare) \
+ X(snd_pcm_readi) \
+ X(snd_pcm_recover) \
+ X(snd_pcm_resume) \
+ X(snd_pcm_reset) \
+ X(snd_pcm_state) \
+ X(snd_pcm_set_params) \
+ X(snd_pcm_get_params) \
+ X(snd_pcm_start) \
+ X(snd_pcm_stream) \
+ X(snd_pcm_frames_to_bytes) \
+ X(snd_pcm_bytes_to_frames) \
+ X(snd_pcm_wait) \
+ X(snd_pcm_writei) \
+ X(snd_pcm_info_get_class) \
+ X(snd_pcm_info_get_subdevices_avail) \
+ X(snd_pcm_info_get_subdevice_name) \
+ X(snd_pcm_info_set_subdevice) \
+ X(snd_pcm_info_get_id) \
+ X(snd_pcm_info_set_device) \
+ X(snd_pcm_info_set_stream) \
+ X(snd_pcm_info_get_name) \
+ X(snd_pcm_info_get_subdevices_count) \
+ X(snd_pcm_info_sizeof) \
+ X(snd_pcm_hw_params) \
+ X(snd_pcm_hw_params_malloc) \
+ X(snd_pcm_hw_params_free) \
+ X(snd_pcm_hw_params_any) \
+ X(snd_pcm_hw_params_set_access) \
+ X(snd_pcm_hw_params_set_format) \
+ X(snd_pcm_hw_params_set_channels) \
+ X(snd_pcm_hw_params_set_rate_near) \
+ X(snd_pcm_hw_params_set_buffer_size_near) \
+ X(snd_card_next) \
+ X(snd_card_get_name) \
+ X(snd_config_update) \
+ X(snd_config_copy) \
+ X(snd_config_get_id) \
+ X(snd_ctl_open) \
+ X(snd_ctl_close) \
+ X(snd_ctl_card_info) \
+ X(snd_ctl_card_info_sizeof) \
+ X(snd_ctl_card_info_get_id) \
+ X(snd_ctl_card_info_get_name) \
+ X(snd_ctl_pcm_next_device) \
+ X(snd_ctl_pcm_info) \
+ X(snd_mixer_load) \
+ X(snd_mixer_free) \
+ X(snd_mixer_detach) \
+ X(snd_mixer_close) \
+ X(snd_mixer_open) \
+ X(snd_mixer_attach) \
+ X(snd_mixer_first_elem) \
+ X(snd_mixer_elem_next) \
+ X(snd_mixer_selem_get_name) \
+ X(snd_mixer_selem_is_active) \
+ X(snd_mixer_selem_register) \
+ X(snd_mixer_selem_set_playback_volume_all) \
+ X(snd_mixer_selem_get_playback_volume) \
+ X(snd_mixer_selem_has_playback_volume) \
X(snd_mixer_selem_get_playback_volume_range) \
- X(snd_mixer_selem_has_playback_switch) \
- X(snd_mixer_selem_get_playback_switch) \
- X(snd_mixer_selem_set_playback_switch_all) \
- X(snd_mixer_selem_has_capture_switch) \
- X(snd_mixer_selem_get_capture_switch) \
- X(snd_mixer_selem_set_capture_switch_all) \
- X(snd_mixer_selem_has_capture_volume) \
- X(snd_mixer_selem_set_capture_volume_all) \
- X(snd_mixer_selem_get_capture_volume) \
- X(snd_mixer_selem_get_capture_volume_range) \
- X(snd_dlopen) \
- X(snd_dlclose) \
- X(snd_config) \
- X(snd_config_search) \
- X(snd_config_get_string) \
- X(snd_config_search_definition) \
- X(snd_config_get_type) \
- X(snd_config_delete) \
- X(snd_config_iterator_entry) \
- X(snd_config_iterator_first) \
- X(snd_config_iterator_next) \
- X(snd_config_iterator_end) \
- X(snd_config_delete_compound_members) \
- X(snd_config_get_integer) \
- X(snd_config_get_bool) \
- X(snd_dlsym) \
- X(snd_strerror) \
- X(snd_lib_error) \
+ X(snd_mixer_selem_has_playback_switch) \
+ X(snd_mixer_selem_get_playback_switch) \
+ X(snd_mixer_selem_set_playback_switch_all) \
+ X(snd_mixer_selem_has_capture_switch) \
+ X(snd_mixer_selem_get_capture_switch) \
+ X(snd_mixer_selem_set_capture_switch_all) \
+ X(snd_mixer_selem_has_capture_volume) \
+ X(snd_mixer_selem_set_capture_volume_all) \
+ X(snd_mixer_selem_get_capture_volume) \
+ X(snd_mixer_selem_get_capture_volume_range) \
+ X(snd_dlopen) \
+ X(snd_dlclose) \
+ X(snd_config) \
+ X(snd_config_search) \
+ X(snd_config_get_string) \
+ X(snd_config_search_definition) \
+ X(snd_config_get_type) \
+ X(snd_config_delete) \
+ X(snd_config_iterator_entry) \
+ X(snd_config_iterator_first) \
+ X(snd_config_iterator_next) \
+ X(snd_config_iterator_end) \
+ X(snd_config_delete_compound_members) \
+ X(snd_config_get_integer) \
+ X(snd_config_get_bool) \
+ X(snd_dlsym) \
+ X(snd_strerror) \
+ X(snd_lib_error) \
X(snd_lib_error_set_handler)
LATE_BINDING_SYMBOL_TABLE_DECLARE_BEGIN(AlsaSymbolTable)
-#define X(sym) \
- LATE_BINDING_SYMBOL_TABLE_DECLARE_ENTRY(AlsaSymbolTable, sym)
+#define X(sym) LATE_BINDING_SYMBOL_TABLE_DECLARE_ENTRY(AlsaSymbolTable, sym)
ALSA_SYMBOLS_LIST
#undef X
LATE_BINDING_SYMBOL_TABLE_DECLARE_END(AlsaSymbolTable)
diff --git a/modules/audio_device/linux/audio_device_alsa_linux.h b/modules/audio_device/linux/audio_device_alsa_linux.h
index 60e5743..f896145 100644
--- a/modules/audio_device/linux/audio_device_alsa_linux.h
+++ b/modules/audio_device/linux/audio_device_alsa_linux.h
@@ -25,178 +25,175 @@
#include <sys/ioctl.h>
#include <sys/soundcard.h>
-
-namespace webrtc
-{
+namespace webrtc {
class EventWrapper;
-class AudioDeviceLinuxALSA : public AudioDeviceGeneric
-{
-public:
- AudioDeviceLinuxALSA();
- virtual ~AudioDeviceLinuxALSA();
+class AudioDeviceLinuxALSA : public AudioDeviceGeneric {
+ public:
+ AudioDeviceLinuxALSA();
+ virtual ~AudioDeviceLinuxALSA();
- // Retrieve the currently utilized audio layer
- int32_t ActiveAudioLayer(
- AudioDeviceModule::AudioLayer& audioLayer) const override;
+ // Retrieve the currently utilized audio layer
+ int32_t ActiveAudioLayer(
+ AudioDeviceModule::AudioLayer& audioLayer) const override;
- // Main initializaton and termination
- InitStatus Init() override;
- int32_t Terminate() override;
- bool Initialized() const override;
+ // Main initializaton and termination
+ InitStatus Init() override;
+ int32_t Terminate() override;
+ bool Initialized() const override;
- // Device enumeration
- int16_t PlayoutDevices() override;
- int16_t RecordingDevices() override;
- int32_t PlayoutDeviceName(uint16_t index,
+ // Device enumeration
+ int16_t PlayoutDevices() override;
+ int16_t RecordingDevices() override;
+ int32_t PlayoutDeviceName(uint16_t index,
+ char name[kAdmMaxDeviceNameSize],
+ char guid[kAdmMaxGuidSize]) override;
+ int32_t RecordingDeviceName(uint16_t index,
char name[kAdmMaxDeviceNameSize],
char guid[kAdmMaxGuidSize]) override;
- int32_t RecordingDeviceName(uint16_t index,
- char name[kAdmMaxDeviceNameSize],
- char guid[kAdmMaxGuidSize]) override;
- // Device selection
- int32_t SetPlayoutDevice(uint16_t index) override;
- int32_t SetPlayoutDevice(
- AudioDeviceModule::WindowsDeviceType device) override;
- int32_t SetRecordingDevice(uint16_t index) override;
- int32_t SetRecordingDevice(
- AudioDeviceModule::WindowsDeviceType device) override;
+ // Device selection
+ int32_t SetPlayoutDevice(uint16_t index) override;
+ int32_t SetPlayoutDevice(
+ AudioDeviceModule::WindowsDeviceType device) override;
+ int32_t SetRecordingDevice(uint16_t index) override;
+ int32_t SetRecordingDevice(
+ AudioDeviceModule::WindowsDeviceType device) override;
- // Audio transport initialization
- int32_t PlayoutIsAvailable(bool& available) override;
- int32_t InitPlayout() override;
- bool PlayoutIsInitialized() const override;
- int32_t RecordingIsAvailable(bool& available) override;
- int32_t InitRecording() override;
- bool RecordingIsInitialized() const override;
+ // Audio transport initialization
+ int32_t PlayoutIsAvailable(bool& available) override;
+ int32_t InitPlayout() override;
+ bool PlayoutIsInitialized() const override;
+ int32_t RecordingIsAvailable(bool& available) override;
+ int32_t InitRecording() override;
+ bool RecordingIsInitialized() const override;
- // Audio transport control
- int32_t StartPlayout() override;
- int32_t StopPlayout() override;
- bool Playing() const override;
- int32_t StartRecording() override;
- int32_t StopRecording() override;
- bool Recording() const override;
+ // Audio transport control
+ int32_t StartPlayout() override;
+ int32_t StopPlayout() override;
+ bool Playing() const override;
+ int32_t StartRecording() override;
+ int32_t StopRecording() override;
+ bool Recording() const override;
- // Audio mixer initialization
- int32_t InitSpeaker() override;
- bool SpeakerIsInitialized() const override;
- int32_t InitMicrophone() override;
- bool MicrophoneIsInitialized() const override;
+ // Audio mixer initialization
+ int32_t InitSpeaker() override;
+ bool SpeakerIsInitialized() const override;
+ int32_t InitMicrophone() override;
+ bool MicrophoneIsInitialized() const override;
- // Speaker volume controls
- int32_t SpeakerVolumeIsAvailable(bool& available) override;
- int32_t SetSpeakerVolume(uint32_t volume) override;
- int32_t SpeakerVolume(uint32_t& volume) const override;
- int32_t MaxSpeakerVolume(uint32_t& maxVolume) const override;
- int32_t MinSpeakerVolume(uint32_t& minVolume) const override;
+ // Speaker volume controls
+ int32_t SpeakerVolumeIsAvailable(bool& available) override;
+ int32_t SetSpeakerVolume(uint32_t volume) override;
+ int32_t SpeakerVolume(uint32_t& volume) const override;
+ int32_t MaxSpeakerVolume(uint32_t& maxVolume) const override;
+ int32_t MinSpeakerVolume(uint32_t& minVolume) const override;
- // Microphone volume controls
- int32_t MicrophoneVolumeIsAvailable(bool& available) override;
- int32_t SetMicrophoneVolume(uint32_t volume) override;
- int32_t MicrophoneVolume(uint32_t& volume) const override;
- int32_t MaxMicrophoneVolume(uint32_t& maxVolume) const override;
- int32_t MinMicrophoneVolume(uint32_t& minVolume) const override;
+ // Microphone volume controls
+ int32_t MicrophoneVolumeIsAvailable(bool& available) override;
+ int32_t SetMicrophoneVolume(uint32_t volume) override;
+ int32_t MicrophoneVolume(uint32_t& volume) const override;
+ int32_t MaxMicrophoneVolume(uint32_t& maxVolume) const override;
+ int32_t MinMicrophoneVolume(uint32_t& minVolume) const override;
- // Speaker mute control
- int32_t SpeakerMuteIsAvailable(bool& available) override;
- int32_t SetSpeakerMute(bool enable) override;
- int32_t SpeakerMute(bool& enabled) const override;
+ // Speaker mute control
+ int32_t SpeakerMuteIsAvailable(bool& available) override;
+ int32_t SetSpeakerMute(bool enable) override;
+ int32_t SpeakerMute(bool& enabled) const override;
- // Microphone mute control
- int32_t MicrophoneMuteIsAvailable(bool& available) override;
- int32_t SetMicrophoneMute(bool enable) override;
- int32_t MicrophoneMute(bool& enabled) const override;
+ // Microphone mute control
+ int32_t MicrophoneMuteIsAvailable(bool& available) override;
+ int32_t SetMicrophoneMute(bool enable) override;
+ int32_t MicrophoneMute(bool& enabled) const override;
- // Stereo support
- int32_t StereoPlayoutIsAvailable(bool& available) override;
- int32_t SetStereoPlayout(bool enable) override;
- int32_t StereoPlayout(bool& enabled) const override;
- int32_t StereoRecordingIsAvailable(bool& available) override;
- int32_t SetStereoRecording(bool enable) override;
- int32_t StereoRecording(bool& enabled) const override;
+ // Stereo support
+ int32_t StereoPlayoutIsAvailable(bool& available) override;
+ int32_t SetStereoPlayout(bool enable) override;
+ int32_t StereoPlayout(bool& enabled) const override;
+ int32_t StereoRecordingIsAvailable(bool& available) override;
+ int32_t SetStereoRecording(bool enable) override;
+ int32_t StereoRecording(bool& enabled) const override;
- // Delay information and control
- int32_t PlayoutDelay(uint16_t& delayMS) const override;
+ // Delay information and control
+ int32_t PlayoutDelay(uint16_t& delayMS) const override;
- void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) override;
+ void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) override;
-private:
- int32_t GetDevicesInfo(const int32_t function,
- const bool playback,
- const int32_t enumDeviceNo = 0,
- char* enumDeviceName = NULL,
- const int32_t ednLen = 0) const;
- int32_t ErrorRecovery(int32_t error, snd_pcm_t* deviceHandle);
+ private:
+ int32_t GetDevicesInfo(const int32_t function,
+ const bool playback,
+ const int32_t enumDeviceNo = 0,
+ char* enumDeviceName = NULL,
+ const int32_t ednLen = 0) const;
+ int32_t ErrorRecovery(int32_t error, snd_pcm_t* deviceHandle);
- bool KeyPressed() const;
+ bool KeyPressed() const;
- void Lock() RTC_EXCLUSIVE_LOCK_FUNCTION(_critSect) { _critSect.Enter(); };
- void UnLock() RTC_UNLOCK_FUNCTION(_critSect) { _critSect.Leave(); };
+ void Lock() RTC_EXCLUSIVE_LOCK_FUNCTION(_critSect) { _critSect.Enter(); };
+ void UnLock() RTC_UNLOCK_FUNCTION(_critSect) { _critSect.Leave(); };
- inline int32_t InputSanityCheckAfterUnlockedPeriod() const;
- inline int32_t OutputSanityCheckAfterUnlockedPeriod() const;
+ inline int32_t InputSanityCheckAfterUnlockedPeriod() const;
+ inline int32_t OutputSanityCheckAfterUnlockedPeriod() const;
- static bool RecThreadFunc(void*);
- static bool PlayThreadFunc(void*);
- bool RecThreadProcess();
- bool PlayThreadProcess();
+ static bool RecThreadFunc(void*);
+ static bool PlayThreadFunc(void*);
+ bool RecThreadProcess();
+ bool PlayThreadProcess();
- AudioDeviceBuffer* _ptrAudioBuffer;
+ AudioDeviceBuffer* _ptrAudioBuffer;
- rtc::CriticalSection _critSect;
+ rtc::CriticalSection _critSect;
- // TODO(pbos): Make plain members and start/stop instead of resetting these
- // pointers. A thread can be reused.
- std::unique_ptr<rtc::PlatformThread> _ptrThreadRec;
- std::unique_ptr<rtc::PlatformThread> _ptrThreadPlay;
+ // TODO(pbos): Make plain members and start/stop instead of resetting these
+ // pointers. A thread can be reused.
+ std::unique_ptr<rtc::PlatformThread> _ptrThreadRec;
+ std::unique_ptr<rtc::PlatformThread> _ptrThreadPlay;
- AudioMixerManagerLinuxALSA _mixerManager;
+ AudioMixerManagerLinuxALSA _mixerManager;
- uint16_t _inputDeviceIndex;
- uint16_t _outputDeviceIndex;
- bool _inputDeviceIsSpecified;
- bool _outputDeviceIsSpecified;
+ uint16_t _inputDeviceIndex;
+ uint16_t _outputDeviceIndex;
+ bool _inputDeviceIsSpecified;
+ bool _outputDeviceIsSpecified;
- snd_pcm_t* _handleRecord;
- snd_pcm_t* _handlePlayout;
+ snd_pcm_t* _handleRecord;
+ snd_pcm_t* _handlePlayout;
- snd_pcm_uframes_t _recordingBuffersizeInFrame;
- snd_pcm_uframes_t _recordingPeriodSizeInFrame;
- snd_pcm_uframes_t _playoutBufferSizeInFrame;
- snd_pcm_uframes_t _playoutPeriodSizeInFrame;
+ snd_pcm_uframes_t _recordingBuffersizeInFrame;
+ snd_pcm_uframes_t _recordingPeriodSizeInFrame;
+ snd_pcm_uframes_t _playoutBufferSizeInFrame;
+ snd_pcm_uframes_t _playoutPeriodSizeInFrame;
- ssize_t _recordingBufferSizeIn10MS;
- ssize_t _playoutBufferSizeIn10MS;
- uint32_t _recordingFramesIn10MS;
- uint32_t _playoutFramesIn10MS;
+ ssize_t _recordingBufferSizeIn10MS;
+ ssize_t _playoutBufferSizeIn10MS;
+ uint32_t _recordingFramesIn10MS;
+ uint32_t _playoutFramesIn10MS;
- uint32_t _recordingFreq;
- uint32_t _playoutFreq;
- uint8_t _recChannels;
- uint8_t _playChannels;
+ uint32_t _recordingFreq;
+ uint32_t _playoutFreq;
+ uint8_t _recChannels;
+ uint8_t _playChannels;
- int8_t* _recordingBuffer; // in byte
- int8_t* _playoutBuffer; // in byte
- uint32_t _recordingFramesLeft;
- uint32_t _playoutFramesLeft;
+ int8_t* _recordingBuffer; // in byte
+ int8_t* _playoutBuffer; // in byte
+ uint32_t _recordingFramesLeft;
+ uint32_t _playoutFramesLeft;
- bool _initialized;
- bool _recording;
- bool _playing;
- bool _recIsInitialized;
- bool _playIsInitialized;
+ bool _initialized;
+ bool _recording;
+ bool _playing;
+ bool _recIsInitialized;
+ bool _playIsInitialized;
- snd_pcm_sframes_t _recordingDelay;
- snd_pcm_sframes_t _playoutDelay;
+ snd_pcm_sframes_t _recordingDelay;
+ snd_pcm_sframes_t _playoutDelay;
- char _oldKeyState[32];
+ char _oldKeyState[32];
#if defined(WEBRTC_USE_X11)
- Display* _XDisplay;
+ Display* _XDisplay;
#endif
};
-}
+} // namespace webrtc
#endif // MODULES_AUDIO_DEVICE_MAIN_SOURCE_LINUX_AUDIO_DEVICE_ALSA_LINUX_H_
diff --git a/modules/audio_device/linux/audio_device_pulse_linux.cc b/modules/audio_device/linux/audio_device_pulse_linux.cc
index 33eeee9..7dda66f 100644
--- a/modules/audio_device/linux/audio_device_pulse_linux.cc
+++ b/modules/audio_device/linux/audio_device_pulse_linux.cc
@@ -1951,8 +1951,7 @@
int32_t AudioDeviceLinuxPulse::ProcessRecordedData(int8_t* bufferData,
uint32_t bufferSizeInSamples,
uint32_t recDelay)
- RTC_EXCLUSIVE_LOCKS_REQUIRED(_critSect) {
-
+ RTC_EXCLUSIVE_LOCKS_REQUIRED(_critSect) {
_ptrAudioBuffer->SetRecordedBuffer(bufferData, bufferSizeInSamples);
// TODO(andrew): this is a temporary hack, to avoid non-causal far- and
diff --git a/modules/audio_device/linux/audio_device_pulse_linux.h b/modules/audio_device/linux/audio_device_pulse_linux.h
index 9aadfbe..d16c13f 100644
--- a/modules/audio_device/linux/audio_device_pulse_linux.h
+++ b/modules/audio_device/linux/audio_device_pulse_linux.h
@@ -85,253 +85,252 @@
// Init _configuredLatencyRec/Play to this value to disable latency requirements
const int32_t WEBRTC_PA_NO_LATENCY_REQUIREMENTS = -1;
-// Set this const to 1 to account for peeked and used data in latency calculation
+// Set this const to 1 to account for peeked and used data in latency
+// calculation
const uint32_t WEBRTC_PA_CAPTURE_BUFFER_LATENCY_ADJUSTMENT = 0;
-namespace webrtc
-{
+namespace webrtc {
class EventWrapper;
-class AudioDeviceLinuxPulse: public AudioDeviceGeneric
-{
-public:
- AudioDeviceLinuxPulse();
- virtual ~AudioDeviceLinuxPulse();
+class AudioDeviceLinuxPulse : public AudioDeviceGeneric {
+ public:
+ AudioDeviceLinuxPulse();
+ virtual ~AudioDeviceLinuxPulse();
- // Retrieve the currently utilized audio layer
- int32_t ActiveAudioLayer(
- AudioDeviceModule::AudioLayer& audioLayer) const override;
+ // Retrieve the currently utilized audio layer
+ int32_t ActiveAudioLayer(
+ AudioDeviceModule::AudioLayer& audioLayer) const override;
- // Main initializaton and termination
- InitStatus Init() override;
- int32_t Terminate() override;
- bool Initialized() const override;
+ // Main initializaton and termination
+ InitStatus Init() override;
+ int32_t Terminate() override;
+ bool Initialized() const override;
- // Device enumeration
- int16_t PlayoutDevices() override;
- int16_t RecordingDevices() override;
- int32_t PlayoutDeviceName(uint16_t index,
+ // Device enumeration
+ int16_t PlayoutDevices() override;
+ int16_t RecordingDevices() override;
+ int32_t PlayoutDeviceName(uint16_t index,
+ char name[kAdmMaxDeviceNameSize],
+ char guid[kAdmMaxGuidSize]) override;
+ int32_t RecordingDeviceName(uint16_t index,
char name[kAdmMaxDeviceNameSize],
char guid[kAdmMaxGuidSize]) override;
- int32_t RecordingDeviceName(uint16_t index,
- char name[kAdmMaxDeviceNameSize],
- char guid[kAdmMaxGuidSize]) override;
- // Device selection
- int32_t SetPlayoutDevice(uint16_t index) override;
- int32_t SetPlayoutDevice(
- AudioDeviceModule::WindowsDeviceType device) override;
- int32_t SetRecordingDevice(uint16_t index) override;
- int32_t SetRecordingDevice(
- AudioDeviceModule::WindowsDeviceType device) override;
+ // Device selection
+ int32_t SetPlayoutDevice(uint16_t index) override;
+ int32_t SetPlayoutDevice(
+ AudioDeviceModule::WindowsDeviceType device) override;
+ int32_t SetRecordingDevice(uint16_t index) override;
+ int32_t SetRecordingDevice(
+ AudioDeviceModule::WindowsDeviceType device) override;
- // Audio transport initialization
- int32_t PlayoutIsAvailable(bool& available) override;
- int32_t InitPlayout() override;
- bool PlayoutIsInitialized() const override;
- int32_t RecordingIsAvailable(bool& available) override;
- int32_t InitRecording() override;
- bool RecordingIsInitialized() const override;
+ // Audio transport initialization
+ int32_t PlayoutIsAvailable(bool& available) override;
+ int32_t InitPlayout() override;
+ bool PlayoutIsInitialized() const override;
+ int32_t RecordingIsAvailable(bool& available) override;
+ int32_t InitRecording() override;
+ bool RecordingIsInitialized() const override;
- // Audio transport control
- int32_t StartPlayout() override;
- int32_t StopPlayout() override;
- bool Playing() const override;
- int32_t StartRecording() override;
- int32_t StopRecording() override;
- bool Recording() const override;
+ // Audio transport control
+ int32_t StartPlayout() override;
+ int32_t StopPlayout() override;
+ bool Playing() const override;
+ int32_t StartRecording() override;
+ int32_t StopRecording() override;
+ bool Recording() const override;
- // Audio mixer initialization
- int32_t InitSpeaker() override;
- bool SpeakerIsInitialized() const override;
- int32_t InitMicrophone() override;
- bool MicrophoneIsInitialized() const override;
+ // Audio mixer initialization
+ int32_t InitSpeaker() override;
+ bool SpeakerIsInitialized() const override;
+ int32_t InitMicrophone() override;
+ bool MicrophoneIsInitialized() const override;
- // Speaker volume controls
- int32_t SpeakerVolumeIsAvailable(bool& available) override;
- int32_t SetSpeakerVolume(uint32_t volume) override;
- int32_t SpeakerVolume(uint32_t& volume) const override;
- int32_t MaxSpeakerVolume(uint32_t& maxVolume) const override;
- int32_t MinSpeakerVolume(uint32_t& minVolume) const override;
+ // Speaker volume controls
+ int32_t SpeakerVolumeIsAvailable(bool& available) override;
+ int32_t SetSpeakerVolume(uint32_t volume) override;
+ int32_t SpeakerVolume(uint32_t& volume) const override;
+ int32_t MaxSpeakerVolume(uint32_t& maxVolume) const override;
+ int32_t MinSpeakerVolume(uint32_t& minVolume) const override;
- // Microphone volume controls
- int32_t MicrophoneVolumeIsAvailable(bool& available) override;
- int32_t SetMicrophoneVolume(uint32_t volume) override;
- int32_t MicrophoneVolume(uint32_t& volume) const override;
- int32_t MaxMicrophoneVolume(uint32_t& maxVolume) const override;
- int32_t MinMicrophoneVolume(uint32_t& minVolume) const override;
+ // Microphone volume controls
+ int32_t MicrophoneVolumeIsAvailable(bool& available) override;
+ int32_t SetMicrophoneVolume(uint32_t volume) override;
+ int32_t MicrophoneVolume(uint32_t& volume) const override;
+ int32_t MaxMicrophoneVolume(uint32_t& maxVolume) const override;
+ int32_t MinMicrophoneVolume(uint32_t& minVolume) const override;
- // Speaker mute control
- int32_t SpeakerMuteIsAvailable(bool& available) override;
- int32_t SetSpeakerMute(bool enable) override;
- int32_t SpeakerMute(bool& enabled) const override;
+ // Speaker mute control
+ int32_t SpeakerMuteIsAvailable(bool& available) override;
+ int32_t SetSpeakerMute(bool enable) override;
+ int32_t SpeakerMute(bool& enabled) const override;
- // Microphone mute control
- int32_t MicrophoneMuteIsAvailable(bool& available) override;
- int32_t SetMicrophoneMute(bool enable) override;
- int32_t MicrophoneMute(bool& enabled) const override;
+ // Microphone mute control
+ int32_t MicrophoneMuteIsAvailable(bool& available) override;
+ int32_t SetMicrophoneMute(bool enable) override;
+ int32_t MicrophoneMute(bool& enabled) const override;
- // Stereo support
- int32_t StereoPlayoutIsAvailable(bool& available) override;
- int32_t SetStereoPlayout(bool enable) override;
- int32_t StereoPlayout(bool& enabled) const override;
- int32_t StereoRecordingIsAvailable(bool& available) override;
- int32_t SetStereoRecording(bool enable) override;
- int32_t StereoRecording(bool& enabled) const override;
+ // Stereo support
+ int32_t StereoPlayoutIsAvailable(bool& available) override;
+ int32_t SetStereoPlayout(bool enable) override;
+ int32_t StereoPlayout(bool& enabled) const override;
+ int32_t StereoRecordingIsAvailable(bool& available) override;
+ int32_t SetStereoRecording(bool enable) override;
+ int32_t StereoRecording(bool& enabled) const override;
- // Delay information and control
- int32_t PlayoutDelay(uint16_t& delayMS) const override;
+ // Delay information and control
+ int32_t PlayoutDelay(uint16_t& delayMS) const override;
- void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) override;
+ void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) override;
-private:
- void Lock() RTC_EXCLUSIVE_LOCK_FUNCTION(_critSect) { _critSect.Enter(); }
- void UnLock() RTC_UNLOCK_FUNCTION(_critSect) { _critSect.Leave(); }
- void WaitForOperationCompletion(pa_operation* paOperation) const;
- void WaitForSuccess(pa_operation* paOperation) const;
+ private:
+ void Lock() RTC_EXCLUSIVE_LOCK_FUNCTION(_critSect) { _critSect.Enter(); }
+ void UnLock() RTC_UNLOCK_FUNCTION(_critSect) { _critSect.Leave(); }
+ void WaitForOperationCompletion(pa_operation* paOperation) const;
+ void WaitForSuccess(pa_operation* paOperation) const;
- bool KeyPressed() const;
+ bool KeyPressed() const;
- static void PaContextStateCallback(pa_context* c, void* pThis);
- static void PaSinkInfoCallback(pa_context* c,
- const pa_sink_info* i,
- int eol,
- void* pThis);
- static void PaSourceInfoCallback(pa_context* c,
- const pa_source_info* i,
- int eol,
- void* pThis);
- static void PaServerInfoCallback(pa_context* c,
- const pa_server_info* i,
- void* pThis);
- static void PaStreamStateCallback(pa_stream* p, void* pThis);
- void PaContextStateCallbackHandler(pa_context* c);
- void PaSinkInfoCallbackHandler(const pa_sink_info* i, int eol);
- void PaSourceInfoCallbackHandler(const pa_source_info* i, int eol);
- void PaServerInfoCallbackHandler(const pa_server_info* i);
- void PaStreamStateCallbackHandler(pa_stream* p);
-
- void EnableWriteCallback();
- void DisableWriteCallback();
- static void PaStreamWriteCallback(pa_stream* unused,
- size_t buffer_space,
+ static void PaContextStateCallback(pa_context* c, void* pThis);
+ static void PaSinkInfoCallback(pa_context* c,
+ const pa_sink_info* i,
+ int eol,
+ void* pThis);
+ static void PaSourceInfoCallback(pa_context* c,
+ const pa_source_info* i,
+ int eol,
void* pThis);
- void PaStreamWriteCallbackHandler(size_t buffer_space);
- static void PaStreamUnderflowCallback(pa_stream* unused, void* pThis);
- void PaStreamUnderflowCallbackHandler();
- void EnableReadCallback();
- void DisableReadCallback();
- static void PaStreamReadCallback(pa_stream* unused1,
- size_t unused2,
- void* pThis);
- void PaStreamReadCallbackHandler();
- static void PaStreamOverflowCallback(pa_stream* unused, void* pThis);
- void PaStreamOverflowCallbackHandler();
- int32_t LatencyUsecs(pa_stream* stream);
- int32_t ReadRecordedData(const void* bufferData, size_t bufferSize);
- int32_t ProcessRecordedData(int8_t* bufferData,
- uint32_t bufferSizeInSamples,
- uint32_t recDelay);
+ static void PaServerInfoCallback(pa_context* c,
+ const pa_server_info* i,
+ void* pThis);
+ static void PaStreamStateCallback(pa_stream* p, void* pThis);
+ void PaContextStateCallbackHandler(pa_context* c);
+ void PaSinkInfoCallbackHandler(const pa_sink_info* i, int eol);
+ void PaSourceInfoCallbackHandler(const pa_source_info* i, int eol);
+ void PaServerInfoCallbackHandler(const pa_server_info* i);
+ void PaStreamStateCallbackHandler(pa_stream* p);
- int32_t CheckPulseAudioVersion();
- int32_t InitSamplingFrequency();
- int32_t GetDefaultDeviceInfo(bool recDevice, char* name, uint16_t& index);
- int32_t InitPulseAudio();
- int32_t TerminatePulseAudio();
+ void EnableWriteCallback();
+ void DisableWriteCallback();
+ static void PaStreamWriteCallback(pa_stream* unused,
+ size_t buffer_space,
+ void* pThis);
+ void PaStreamWriteCallbackHandler(size_t buffer_space);
+ static void PaStreamUnderflowCallback(pa_stream* unused, void* pThis);
+ void PaStreamUnderflowCallbackHandler();
+ void EnableReadCallback();
+ void DisableReadCallback();
+ static void PaStreamReadCallback(pa_stream* unused1,
+ size_t unused2,
+ void* pThis);
+ void PaStreamReadCallbackHandler();
+ static void PaStreamOverflowCallback(pa_stream* unused, void* pThis);
+ void PaStreamOverflowCallbackHandler();
+ int32_t LatencyUsecs(pa_stream* stream);
+ int32_t ReadRecordedData(const void* bufferData, size_t bufferSize);
+ int32_t ProcessRecordedData(int8_t* bufferData,
+ uint32_t bufferSizeInSamples,
+ uint32_t recDelay);
- void PaLock();
- void PaUnLock();
+ int32_t CheckPulseAudioVersion();
+ int32_t InitSamplingFrequency();
+ int32_t GetDefaultDeviceInfo(bool recDevice, char* name, uint16_t& index);
+ int32_t InitPulseAudio();
+ int32_t TerminatePulseAudio();
- static bool RecThreadFunc(void*);
- static bool PlayThreadFunc(void*);
- bool RecThreadProcess();
- bool PlayThreadProcess();
+ void PaLock();
+ void PaUnLock();
- AudioDeviceBuffer* _ptrAudioBuffer;
+ static bool RecThreadFunc(void*);
+ static bool PlayThreadFunc(void*);
+ bool RecThreadProcess();
+ bool PlayThreadProcess();
- rtc::CriticalSection _critSect;
- EventWrapper& _timeEventRec;
- EventWrapper& _timeEventPlay;
- EventWrapper& _recStartEvent;
- EventWrapper& _playStartEvent;
+ AudioDeviceBuffer* _ptrAudioBuffer;
- // TODO(pbos): Remove unique_ptr and use directly without resetting.
- std::unique_ptr<rtc::PlatformThread> _ptrThreadPlay;
- std::unique_ptr<rtc::PlatformThread> _ptrThreadRec;
+ rtc::CriticalSection _critSect;
+ EventWrapper& _timeEventRec;
+ EventWrapper& _timeEventPlay;
+ EventWrapper& _recStartEvent;
+ EventWrapper& _playStartEvent;
- AudioMixerManagerLinuxPulse _mixerManager;
+ // TODO(pbos): Remove unique_ptr and use directly without resetting.
+ std::unique_ptr<rtc::PlatformThread> _ptrThreadPlay;
+ std::unique_ptr<rtc::PlatformThread> _ptrThreadRec;
- uint16_t _inputDeviceIndex;
- uint16_t _outputDeviceIndex;
- bool _inputDeviceIsSpecified;
- bool _outputDeviceIsSpecified;
+ AudioMixerManagerLinuxPulse _mixerManager;
- int sample_rate_hz_;
- uint8_t _recChannels;
- uint8_t _playChannels;
+ uint16_t _inputDeviceIndex;
+ uint16_t _outputDeviceIndex;
+ bool _inputDeviceIsSpecified;
+ bool _outputDeviceIsSpecified;
- // Stores thread ID in constructor.
- // We can then use ThreadChecker::CalledOnValidThread() to ensure that
- // other methods are called from the same thread.
- // Currently only does RTC_DCHECK(thread_checker_.CalledOnValidThread()).
- rtc::ThreadChecker thread_checker_;
+ int sample_rate_hz_;
+ uint8_t _recChannels;
+ uint8_t _playChannels;
- bool _initialized;
- bool _recording;
- bool _playing;
- bool _recIsInitialized;
- bool _playIsInitialized;
- bool _startRec;
- bool _stopRec;
- bool _startPlay;
- bool _stopPlay;
- bool update_speaker_volume_at_startup_;
+ // Stores thread ID in constructor.
+ // We can then use ThreadChecker::CalledOnValidThread() to ensure that
+ // other methods are called from the same thread.
+ // Currently only does RTC_DCHECK(thread_checker_.CalledOnValidThread()).
+ rtc::ThreadChecker thread_checker_;
- uint32_t _sndCardPlayDelay;
- uint32_t _sndCardRecDelay;
+ bool _initialized;
+ bool _recording;
+ bool _playing;
+ bool _recIsInitialized;
+ bool _playIsInitialized;
+ bool _startRec;
+ bool _stopRec;
+ bool _startPlay;
+ bool _stopPlay;
+ bool update_speaker_volume_at_startup_;
- int32_t _writeErrors;
+ uint32_t _sndCardPlayDelay;
+ uint32_t _sndCardRecDelay;
- uint16_t _deviceIndex;
- int16_t _numPlayDevices;
- int16_t _numRecDevices;
- char* _playDeviceName;
- char* _recDeviceName;
- char* _playDisplayDeviceName;
- char* _recDisplayDeviceName;
- char _paServerVersion[32];
+ int32_t _writeErrors;
- int8_t* _playBuffer;
- size_t _playbackBufferSize;
- size_t _playbackBufferUnused;
- size_t _tempBufferSpace;
- int8_t* _recBuffer;
- size_t _recordBufferSize;
- size_t _recordBufferUsed;
- const void* _tempSampleData;
- size_t _tempSampleDataSize;
- int32_t _configuredLatencyPlay;
- int32_t _configuredLatencyRec;
+ uint16_t _deviceIndex;
+ int16_t _numPlayDevices;
+ int16_t _numRecDevices;
+ char* _playDeviceName;
+ char* _recDeviceName;
+ char* _playDisplayDeviceName;
+ char* _recDisplayDeviceName;
+ char _paServerVersion[32];
- // PulseAudio
- uint16_t _paDeviceIndex;
- bool _paStateChanged;
+ int8_t* _playBuffer;
+ size_t _playbackBufferSize;
+ size_t _playbackBufferUnused;
+ size_t _tempBufferSpace;
+ int8_t* _recBuffer;
+ size_t _recordBufferSize;
+ size_t _recordBufferUsed;
+ const void* _tempSampleData;
+ size_t _tempSampleDataSize;
+ int32_t _configuredLatencyPlay;
+ int32_t _configuredLatencyRec;
- pa_threaded_mainloop* _paMainloop;
- pa_mainloop_api* _paMainloopApi;
- pa_context* _paContext;
+ // PulseAudio
+ uint16_t _paDeviceIndex;
+ bool _paStateChanged;
- pa_stream* _recStream;
- pa_stream* _playStream;
- uint32_t _recStreamFlags;
- uint32_t _playStreamFlags;
- pa_buffer_attr _playBufferAttr;
- pa_buffer_attr _recBufferAttr;
+ pa_threaded_mainloop* _paMainloop;
+ pa_mainloop_api* _paMainloopApi;
+ pa_context* _paContext;
- char _oldKeyState[32];
- Display* _XDisplay;
+ pa_stream* _recStream;
+ pa_stream* _playStream;
+ uint32_t _recStreamFlags;
+ uint32_t _playStreamFlags;
+ pa_buffer_attr _playBufferAttr;
+ pa_buffer_attr _recBufferAttr;
+
+ char _oldKeyState[32];
+ Display* _XDisplay;
};
-}
+} // namespace webrtc
#endif // MODULES_AUDIO_DEVICE_MAIN_SOURCE_LINUX_AUDIO_DEVICE_PULSE_LINUX_H_
diff --git a/modules/audio_device/linux/audio_mixer_manager_alsa_linux.h b/modules/audio_device/linux/audio_mixer_manager_alsa_linux.h
index 61de607..0f31322 100644
--- a/modules/audio_device/linux/audio_mixer_manager_alsa_linux.h
+++ b/modules/audio_device/linux/audio_mixer_manager_alsa_linux.h
@@ -18,55 +18,53 @@
#include <alsa/asoundlib.h>
-namespace webrtc
-{
+namespace webrtc {
-class AudioMixerManagerLinuxALSA
-{
-public:
- int32_t OpenSpeaker(char* deviceName);
- int32_t OpenMicrophone(char* deviceName);
- int32_t SetSpeakerVolume(uint32_t volume);
- int32_t SpeakerVolume(uint32_t& volume) const;
- int32_t MaxSpeakerVolume(uint32_t& maxVolume) const;
- int32_t MinSpeakerVolume(uint32_t& minVolume) const;
- int32_t SpeakerVolumeIsAvailable(bool& available);
- int32_t SpeakerMuteIsAvailable(bool& available);
- int32_t SetSpeakerMute(bool enable);
- int32_t SpeakerMute(bool& enabled) const;
- int32_t MicrophoneMuteIsAvailable(bool& available);
- int32_t SetMicrophoneMute(bool enable);
- int32_t MicrophoneMute(bool& enabled) const;
- int32_t MicrophoneVolumeIsAvailable(bool& available);
- int32_t SetMicrophoneVolume(uint32_t volume);
- int32_t MicrophoneVolume(uint32_t& volume) const;
- int32_t MaxMicrophoneVolume(uint32_t& maxVolume) const;
- int32_t MinMicrophoneVolume(uint32_t& minVolume) const;
- int32_t Close();
- int32_t CloseSpeaker();
- int32_t CloseMicrophone();
- bool SpeakerIsInitialized() const;
- bool MicrophoneIsInitialized() const;
+class AudioMixerManagerLinuxALSA {
+ public:
+ int32_t OpenSpeaker(char* deviceName);
+ int32_t OpenMicrophone(char* deviceName);
+ int32_t SetSpeakerVolume(uint32_t volume);
+ int32_t SpeakerVolume(uint32_t& volume) const;
+ int32_t MaxSpeakerVolume(uint32_t& maxVolume) const;
+ int32_t MinSpeakerVolume(uint32_t& minVolume) const;
+ int32_t SpeakerVolumeIsAvailable(bool& available);
+ int32_t SpeakerMuteIsAvailable(bool& available);
+ int32_t SetSpeakerMute(bool enable);
+ int32_t SpeakerMute(bool& enabled) const;
+ int32_t MicrophoneMuteIsAvailable(bool& available);
+ int32_t SetMicrophoneMute(bool enable);
+ int32_t MicrophoneMute(bool& enabled) const;
+ int32_t MicrophoneVolumeIsAvailable(bool& available);
+ int32_t SetMicrophoneVolume(uint32_t volume);
+ int32_t MicrophoneVolume(uint32_t& volume) const;
+ int32_t MaxMicrophoneVolume(uint32_t& maxVolume) const;
+ int32_t MinMicrophoneVolume(uint32_t& minVolume) const;
+ int32_t Close();
+ int32_t CloseSpeaker();
+ int32_t CloseMicrophone();
+ bool SpeakerIsInitialized() const;
+ bool MicrophoneIsInitialized() const;
-public:
- AudioMixerManagerLinuxALSA();
- ~AudioMixerManagerLinuxALSA();
+ public:
+ AudioMixerManagerLinuxALSA();
+ ~AudioMixerManagerLinuxALSA();
-private:
- int32_t LoadMicMixerElement() const;
- int32_t LoadSpeakerMixerElement() const;
- void GetControlName(char *controlName, char* deviceName) const;
+ private:
+ int32_t LoadMicMixerElement() const;
+ int32_t LoadSpeakerMixerElement() const;
+ void GetControlName(char* controlName, char* deviceName) const;
-private:
- rtc::CriticalSection _critSect;
- mutable snd_mixer_t* _outputMixerHandle;
- char _outputMixerStr[kAdmMaxDeviceNameSize];
- mutable snd_mixer_t* _inputMixerHandle;
- char _inputMixerStr[kAdmMaxDeviceNameSize];
- mutable snd_mixer_elem_t* _outputMixerElement;
- mutable snd_mixer_elem_t* _inputMixerElement;
+ private:
+ rtc::CriticalSection _critSect;
+ mutable snd_mixer_t* _outputMixerHandle;
+ char _outputMixerStr[kAdmMaxDeviceNameSize];
+ mutable snd_mixer_t* _inputMixerHandle;
+ char _inputMixerStr[kAdmMaxDeviceNameSize];
+ mutable snd_mixer_elem_t* _outputMixerElement;
+ mutable snd_mixer_elem_t* _inputMixerElement;
};
-}
+} // namespace webrtc
#endif // MODULES_AUDIO_DEVICE_MAIN_SOURCE_LINUX_AUDIO_MIXER_MANAGER_ALSA_LINUX_H_
diff --git a/modules/audio_device/linux/audio_mixer_manager_pulse_linux.h b/modules/audio_device/linux/audio_mixer_manager_pulse_linux.h
index 7846ccb..1917b96 100644
--- a/modules/audio_device/linux/audio_mixer_manager_pulse_linux.h
+++ b/modules/audio_device/linux/audio_mixer_manager_pulse_linux.h
@@ -20,94 +20,98 @@
#include <stdint.h>
#ifndef UINT32_MAX
-#define UINT32_MAX ((uint32_t)-1)
+#define UINT32_MAX ((uint32_t)-1)
#endif
-namespace webrtc
-{
+namespace webrtc {
-class AudioMixerManagerLinuxPulse
-{
-public:
- int32_t SetPlayStream(pa_stream* playStream);
- int32_t SetRecStream(pa_stream* recStream);
- int32_t OpenSpeaker(uint16_t deviceIndex);
- int32_t OpenMicrophone(uint16_t deviceIndex);
- int32_t SetSpeakerVolume(uint32_t volume);
- int32_t SpeakerVolume(uint32_t& volume) const;
- int32_t MaxSpeakerVolume(uint32_t& maxVolume) const;
- int32_t MinSpeakerVolume(uint32_t& minVolume) const;
- int32_t SpeakerVolumeIsAvailable(bool& available);
- int32_t SpeakerMuteIsAvailable(bool& available);
- int32_t SetSpeakerMute(bool enable);
- int32_t StereoPlayoutIsAvailable(bool& available);
- int32_t StereoRecordingIsAvailable(bool& available);
- int32_t SpeakerMute(bool& enabled) const;
- int32_t MicrophoneMuteIsAvailable(bool& available);
- int32_t SetMicrophoneMute(bool enable);
- int32_t MicrophoneMute(bool& enabled) const;
- int32_t MicrophoneVolumeIsAvailable(bool& available);
- int32_t SetMicrophoneVolume(uint32_t volume);
- int32_t MicrophoneVolume(uint32_t& volume) const;
- int32_t MaxMicrophoneVolume(uint32_t& maxVolume) const;
- int32_t MinMicrophoneVolume(uint32_t& minVolume) const;
- int32_t SetPulseAudioObjects(pa_threaded_mainloop* mainloop,
- pa_context* context);
- int32_t Close();
- int32_t CloseSpeaker();
- int32_t CloseMicrophone();
- bool SpeakerIsInitialized() const;
- bool MicrophoneIsInitialized() const;
+class AudioMixerManagerLinuxPulse {
+ public:
+ int32_t SetPlayStream(pa_stream* playStream);
+ int32_t SetRecStream(pa_stream* recStream);
+ int32_t OpenSpeaker(uint16_t deviceIndex);
+ int32_t OpenMicrophone(uint16_t deviceIndex);
+ int32_t SetSpeakerVolume(uint32_t volume);
+ int32_t SpeakerVolume(uint32_t& volume) const;
+ int32_t MaxSpeakerVolume(uint32_t& maxVolume) const;
+ int32_t MinSpeakerVolume(uint32_t& minVolume) const;
+ int32_t SpeakerVolumeIsAvailable(bool& available);
+ int32_t SpeakerMuteIsAvailable(bool& available);
+ int32_t SetSpeakerMute(bool enable);
+ int32_t StereoPlayoutIsAvailable(bool& available);
+ int32_t StereoRecordingIsAvailable(bool& available);
+ int32_t SpeakerMute(bool& enabled) const;
+ int32_t MicrophoneMuteIsAvailable(bool& available);
+ int32_t SetMicrophoneMute(bool enable);
+ int32_t MicrophoneMute(bool& enabled) const;
+ int32_t MicrophoneVolumeIsAvailable(bool& available);
+ int32_t SetMicrophoneVolume(uint32_t volume);
+ int32_t MicrophoneVolume(uint32_t& volume) const;
+ int32_t MaxMicrophoneVolume(uint32_t& maxVolume) const;
+ int32_t MinMicrophoneVolume(uint32_t& minVolume) const;
+ int32_t SetPulseAudioObjects(pa_threaded_mainloop* mainloop,
+ pa_context* context);
+ int32_t Close();
+ int32_t CloseSpeaker();
+ int32_t CloseMicrophone();
+ bool SpeakerIsInitialized() const;
+ bool MicrophoneIsInitialized() const;
-public:
- AudioMixerManagerLinuxPulse();
- ~AudioMixerManagerLinuxPulse();
+ public:
+ AudioMixerManagerLinuxPulse();
+ ~AudioMixerManagerLinuxPulse();
-private:
- static void PaSinkInfoCallback(pa_context *c, const pa_sink_info *i,
- int eol, void *pThis);
- static void PaSinkInputInfoCallback(pa_context *c,
- const pa_sink_input_info *i, int eol,
- void *pThis);
- static void PaSourceInfoCallback(pa_context *c, const pa_source_info *i,
- int eol, void *pThis);
- static void
- PaSetVolumeCallback(pa_context* /*c*/, int success, void* /*pThis*/);
- void PaSinkInfoCallbackHandler(const pa_sink_info *i, int eol);
- void PaSinkInputInfoCallbackHandler(const pa_sink_input_info *i, int eol);
- void PaSourceInfoCallbackHandler(const pa_source_info *i, int eol);
+ private:
+ static void PaSinkInfoCallback(pa_context* c,
+ const pa_sink_info* i,
+ int eol,
+ void* pThis);
+ static void PaSinkInputInfoCallback(pa_context* c,
+ const pa_sink_input_info* i,
+ int eol,
+ void* pThis);
+ static void PaSourceInfoCallback(pa_context* c,
+ const pa_source_info* i,
+ int eol,
+ void* pThis);
+ static void PaSetVolumeCallback(pa_context* /*c*/,
+ int success,
+ void* /*pThis*/);
+ void PaSinkInfoCallbackHandler(const pa_sink_info* i, int eol);
+ void PaSinkInputInfoCallbackHandler(const pa_sink_input_info* i, int eol);
+ void PaSourceInfoCallbackHandler(const pa_source_info* i, int eol);
- void WaitForOperationCompletion(pa_operation* paOperation) const;
+ void WaitForOperationCompletion(pa_operation* paOperation) const;
- bool GetSinkInputInfo() const;
- bool GetSinkInfoByIndex(int device_index)const ;
- bool GetSourceInfoByIndex(int device_index) const;
+ bool GetSinkInputInfo() const;
+ bool GetSinkInfoByIndex(int device_index) const;
+ bool GetSourceInfoByIndex(int device_index) const;
-private:
- int16_t _paOutputDeviceIndex;
- int16_t _paInputDeviceIndex;
+ private:
+ int16_t _paOutputDeviceIndex;
+ int16_t _paInputDeviceIndex;
- pa_stream* _paPlayStream;
- pa_stream* _paRecStream;
+ pa_stream* _paPlayStream;
+ pa_stream* _paRecStream;
- pa_threaded_mainloop* _paMainloop;
- pa_context* _paContext;
+ pa_threaded_mainloop* _paMainloop;
+ pa_context* _paContext;
- mutable uint32_t _paVolume;
- mutable uint32_t _paMute;
- mutable uint32_t _paVolSteps;
- bool _paSpeakerMute;
- mutable uint32_t _paSpeakerVolume;
- mutable uint8_t _paChannels;
- bool _paObjectsSet;
+ mutable uint32_t _paVolume;
+ mutable uint32_t _paMute;
+ mutable uint32_t _paVolSteps;
+ bool _paSpeakerMute;
+ mutable uint32_t _paSpeakerVolume;
+ mutable uint8_t _paChannels;
+ bool _paObjectsSet;
- // Stores thread ID in constructor.
- // We can then use ThreadChecker::CalledOnValidThread() to ensure that
- // other methods are called from the same thread.
- // Currently only does RTC_DCHECK(thread_checker_.CalledOnValidThread()).
- rtc::ThreadChecker thread_checker_;
+ // Stores thread ID in constructor.
+ // We can then use ThreadChecker::CalledOnValidThread() to ensure that
+ // other methods are called from the same thread.
+ // Currently only does RTC_DCHECK(thread_checker_.CalledOnValidThread()).
+ rtc::ThreadChecker thread_checker_;
};
-}
+} // namespace webrtc
#endif // MODULES_AUDIO_DEVICE_MAIN_SOURCE_LINUX_AUDIO_MIXER_MANAGER_PULSE_LINUX_H_
diff --git a/modules/audio_device/linux/latebindingsymboltable_linux.h b/modules/audio_device/linux/latebindingsymboltable_linux.h
index b834f5c..1e28c22 100644
--- a/modules/audio_device/linux/latebindingsymboltable_linux.h
+++ b/modules/audio_device/linux/latebindingsymboltable_linux.h
@@ -26,7 +26,7 @@
namespace adm_linux {
#ifdef WEBRTC_LINUX
-typedef void *DllHandle;
+typedef void* DllHandle;
const DllHandle kInvalidDllHandle = NULL;
#else
@@ -40,37 +40,30 @@
bool InternalLoadSymbols(DllHandle handle,
int num_symbols,
- const char *const symbol_names[],
- void *symbols[]);
+ const char* const symbol_names[],
+ void* symbols[]);
template <int SYMBOL_TABLE_SIZE,
const char kDllName[],
- const char *const kSymbolNames[]>
+ const char* const kSymbolNames[]>
class LateBindingSymbolTable {
public:
LateBindingSymbolTable()
- : handle_(kInvalidDllHandle),
- undefined_symbols_(false) {
+ : handle_(kInvalidDllHandle), undefined_symbols_(false) {
memset(symbols_, 0, sizeof(symbols_));
}
- ~LateBindingSymbolTable() {
- Unload();
- }
+ ~LateBindingSymbolTable() { Unload(); }
- static int NumSymbols() {
- return SYMBOL_TABLE_SIZE;
- }
+ static int NumSymbols() { return SYMBOL_TABLE_SIZE; }
// We do not use this, but we offer it for theoretical convenience.
- static const char *GetSymbolName(int index) {
+ static const char* GetSymbolName(int index) {
assert(index < NumSymbols());
return kSymbolNames[index];
}
- bool IsLoaded() const {
- return handle_ != kInvalidDllHandle;
- }
+ bool IsLoaded() const { return handle_ != kInvalidDllHandle; }
// Loads the DLL and the symbol table. Returns true iff the DLL and symbol
// table loaded successfully.
@@ -106,7 +99,7 @@
// Retrieves the given symbol. NOTE: Recommended to use LATESYM_GET below
// instead of this.
- void *GetSymbol(int index) const {
+ void* GetSymbol(int index) const {
assert(IsLoaded());
assert(index < NumSymbols());
return symbols_[index];
@@ -115,15 +108,13 @@
private:
DllHandle handle_;
bool undefined_symbols_;
- void *symbols_[SYMBOL_TABLE_SIZE];
+ void* symbols_[SYMBOL_TABLE_SIZE];
RTC_DISALLOW_COPY_AND_ASSIGN(LateBindingSymbolTable);
};
// This macro must be invoked in a header to declare a symbol table class.
-#define LATE_BINDING_SYMBOL_TABLE_DECLARE_BEGIN(ClassName) \
-enum {
-
+#define LATE_BINDING_SYMBOL_TABLE_DECLARE_BEGIN(ClassName) enum {
// This macro must be invoked in the header declaration once for each symbol
// (recommended to use an X-Macro to avoid duplication).
// This macro defines an enum with names built from the symbols, which
@@ -150,26 +141,24 @@
// This macro must be invoked in a .cc file to define a previously-declared
// symbol table class.
#define LATE_BINDING_SYMBOL_TABLE_DEFINE_BEGIN(ClassName, dllName) \
-const char ClassName##_kDllName[] = dllName; \
-const char *const ClassName##_kSymbolNames[ClassName##_SYMBOL_TABLE_SIZE] = {
-
+ const char ClassName##_kDllName[] = dllName; \
+ const char* const ClassName##_kSymbolNames[ClassName##_SYMBOL_TABLE_SIZE] = {
// This macro must be invoked in the .cc definition once for each symbol
// (recommended to use an X-Macro to avoid duplication).
// This would have to use the mangled name if we were to ever support C++
// symbols.
-#define LATE_BINDING_SYMBOL_TABLE_DEFINE_ENTRY(ClassName, sym) \
- #sym,
+#define LATE_BINDING_SYMBOL_TABLE_DEFINE_ENTRY(ClassName, sym) #sym,
#define LATE_BINDING_SYMBOL_TABLE_DEFINE_END(ClassName) \
-};
+ } \
+ ;
// Index of a given symbol in the given symbol table class.
-#define LATESYM_INDEXOF(ClassName, sym) \
- (ClassName##_SYMBOL_TABLE_INDEX_##sym)
+#define LATESYM_INDEXOF(ClassName, sym) (ClassName##_SYMBOL_TABLE_INDEX_##sym)
// Returns a reference to the given late-binded symbol, with the correct type.
#define LATESYM_GET(ClassName, inst, sym) \
- (*reinterpret_cast<typeof(&sym)>( \
+ (*reinterpret_cast<typeof(&sym)>( \
(inst)->GetSymbol(LATESYM_INDEXOF(ClassName, sym))))
} // namespace adm_linux
diff --git a/modules/audio_device/linux/pulseaudiosymboltable_linux.cc b/modules/audio_device/linux/pulseaudiosymboltable_linux.cc
index 3d012fe..e0759e6 100644
--- a/modules/audio_device/linux/pulseaudiosymboltable_linux.cc
+++ b/modules/audio_device/linux/pulseaudiosymboltable_linux.cc
@@ -32,7 +32,7 @@
LATE_BINDING_SYMBOL_TABLE_DEFINE_BEGIN(PulseAudioSymbolTable, "libpulse.so.0")
#define X(sym) \
- LATE_BINDING_SYMBOL_TABLE_DEFINE_ENTRY(PulseAudioSymbolTable, sym)
+ LATE_BINDING_SYMBOL_TABLE_DEFINE_ENTRY(PulseAudioSymbolTable, sym)
PULSE_AUDIO_SYMBOLS_LIST
#undef X
LATE_BINDING_SYMBOL_TABLE_DEFINE_END(PulseAudioSymbolTable)
diff --git a/modules/audio_device/linux/pulseaudiosymboltable_linux.h b/modules/audio_device/linux/pulseaudiosymboltable_linux.h
index d21446c..2f6a951 100644
--- a/modules/audio_device/linux/pulseaudiosymboltable_linux.h
+++ b/modules/audio_device/linux/pulseaudiosymboltable_linux.h
@@ -36,66 +36,66 @@
// The PulseAudio symbols we need, as an X-Macro list.
// This list must contain precisely every libpulse function that is used in
// the ADM LINUX PULSE Device and Mixer classes
-#define PULSE_AUDIO_SYMBOLS_LIST \
- X(pa_bytes_per_second) \
- X(pa_context_connect) \
- X(pa_context_disconnect) \
- X(pa_context_errno) \
- X(pa_context_get_protocol_version) \
- X(pa_context_get_server_info) \
- X(pa_context_get_sink_info_list) \
- X(pa_context_get_sink_info_by_index) \
- X(pa_context_get_sink_info_by_name) \
- X(pa_context_get_sink_input_info) \
- X(pa_context_get_source_info_by_index) \
- X(pa_context_get_source_info_by_name) \
- X(pa_context_get_source_info_list) \
- X(pa_context_get_state) \
- X(pa_context_new) \
- X(pa_context_set_sink_input_volume) \
- X(pa_context_set_sink_input_mute) \
+#define PULSE_AUDIO_SYMBOLS_LIST \
+ X(pa_bytes_per_second) \
+ X(pa_context_connect) \
+ X(pa_context_disconnect) \
+ X(pa_context_errno) \
+ X(pa_context_get_protocol_version) \
+ X(pa_context_get_server_info) \
+ X(pa_context_get_sink_info_list) \
+ X(pa_context_get_sink_info_by_index) \
+ X(pa_context_get_sink_info_by_name) \
+ X(pa_context_get_sink_input_info) \
+ X(pa_context_get_source_info_by_index) \
+ X(pa_context_get_source_info_by_name) \
+ X(pa_context_get_source_info_list) \
+ X(pa_context_get_state) \
+ X(pa_context_new) \
+ X(pa_context_set_sink_input_volume) \
+ X(pa_context_set_sink_input_mute) \
X(pa_context_set_source_volume_by_index) \
- X(pa_context_set_source_mute_by_index) \
- X(pa_context_set_state_callback) \
- X(pa_context_unref) \
- X(pa_cvolume_set) \
- X(pa_operation_get_state) \
- X(pa_operation_unref) \
- X(pa_stream_connect_playback) \
- X(pa_stream_connect_record) \
- X(pa_stream_disconnect) \
- X(pa_stream_drop) \
- X(pa_stream_get_device_index) \
- X(pa_stream_get_index) \
- X(pa_stream_get_latency) \
- X(pa_stream_get_sample_spec) \
- X(pa_stream_get_state) \
- X(pa_stream_new) \
- X(pa_stream_peek) \
- X(pa_stream_readable_size) \
- X(pa_stream_set_buffer_attr) \
- X(pa_stream_set_overflow_callback) \
- X(pa_stream_set_read_callback) \
- X(pa_stream_set_state_callback) \
- X(pa_stream_set_underflow_callback) \
- X(pa_stream_set_write_callback) \
- X(pa_stream_unref) \
- X(pa_stream_writable_size) \
- X(pa_stream_write) \
- X(pa_strerror) \
- X(pa_threaded_mainloop_free) \
- X(pa_threaded_mainloop_get_api) \
- X(pa_threaded_mainloop_lock) \
- X(pa_threaded_mainloop_new) \
- X(pa_threaded_mainloop_signal) \
- X(pa_threaded_mainloop_start) \
- X(pa_threaded_mainloop_stop) \
- X(pa_threaded_mainloop_unlock) \
+ X(pa_context_set_source_mute_by_index) \
+ X(pa_context_set_state_callback) \
+ X(pa_context_unref) \
+ X(pa_cvolume_set) \
+ X(pa_operation_get_state) \
+ X(pa_operation_unref) \
+ X(pa_stream_connect_playback) \
+ X(pa_stream_connect_record) \
+ X(pa_stream_disconnect) \
+ X(pa_stream_drop) \
+ X(pa_stream_get_device_index) \
+ X(pa_stream_get_index) \
+ X(pa_stream_get_latency) \
+ X(pa_stream_get_sample_spec) \
+ X(pa_stream_get_state) \
+ X(pa_stream_new) \
+ X(pa_stream_peek) \
+ X(pa_stream_readable_size) \
+ X(pa_stream_set_buffer_attr) \
+ X(pa_stream_set_overflow_callback) \
+ X(pa_stream_set_read_callback) \
+ X(pa_stream_set_state_callback) \
+ X(pa_stream_set_underflow_callback) \
+ X(pa_stream_set_write_callback) \
+ X(pa_stream_unref) \
+ X(pa_stream_writable_size) \
+ X(pa_stream_write) \
+ X(pa_strerror) \
+ X(pa_threaded_mainloop_free) \
+ X(pa_threaded_mainloop_get_api) \
+ X(pa_threaded_mainloop_lock) \
+ X(pa_threaded_mainloop_new) \
+ X(pa_threaded_mainloop_signal) \
+ X(pa_threaded_mainloop_start) \
+ X(pa_threaded_mainloop_stop) \
+ X(pa_threaded_mainloop_unlock) \
X(pa_threaded_mainloop_wait)
LATE_BINDING_SYMBOL_TABLE_DECLARE_BEGIN(PulseAudioSymbolTable)
#define X(sym) \
- LATE_BINDING_SYMBOL_TABLE_DECLARE_ENTRY(PulseAudioSymbolTable, sym)
+ LATE_BINDING_SYMBOL_TABLE_DECLARE_ENTRY(PulseAudioSymbolTable, sym)
PULSE_AUDIO_SYMBOLS_LIST
#undef X
LATE_BINDING_SYMBOL_TABLE_DECLARE_END(PulseAudioSymbolTable)
diff --git a/modules/audio_device/mac/portaudio/pa_memorybarrier.h b/modules/audio_device/mac/portaudio/pa_memorybarrier.h
index f689622..19b5055 100644
--- a/modules/audio_device/mac/portaudio/pa_memorybarrier.h
+++ b/modules/audio_device/mac/portaudio/pa_memorybarrier.h
@@ -30,13 +30,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -47,10 +47,10 @@
/****************
* Some memory barrier primitives based on the system.
- * right now only OS X, FreeBSD, and Linux are supported. In addition to providing
- * memory barriers, these functions should ensure that data cached in registers
- * is written out to cache where it can be snooped by other CPUs. (ie, the volatile
- * keyword should not be required)
+ * right now only OS X, FreeBSD, and Linux are supported. In addition to
+ *providing memory barriers, these functions should ensure that data cached in
+ *registers is written out to cache where it can be snooped by other CPUs. (ie,
+ *the volatile keyword should not be required)
*
* the primitives that must be defined are:
*
@@ -61,67 +61,67 @@
****************/
#if defined(__APPLE__)
-# include <libkern/OSAtomic.h>
- /* Here are the memory barrier functions. Mac OS X only provides
- full memory barriers, so the three types of barriers are the same,
- however, these barriers are superior to compiler-based ones. */
-# define PaUtil_FullMemoryBarrier() OSMemoryBarrier()
-# define PaUtil_ReadMemoryBarrier() OSMemoryBarrier()
-# define PaUtil_WriteMemoryBarrier() OSMemoryBarrier()
+#include <libkern/OSAtomic.h>
+/* Here are the memory barrier functions. Mac OS X only provides
+ full memory barriers, so the three types of barriers are the same,
+ however, these barriers are superior to compiler-based ones. */
+#define PaUtil_FullMemoryBarrier() OSMemoryBarrier()
+#define PaUtil_ReadMemoryBarrier() OSMemoryBarrier()
+#define PaUtil_WriteMemoryBarrier() OSMemoryBarrier()
#elif defined(__GNUC__)
- /* GCC >= 4.1 has built-in intrinsics. We'll use those */
-# if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
-# define PaUtil_FullMemoryBarrier() __sync_synchronize()
-# define PaUtil_ReadMemoryBarrier() __sync_synchronize()
-# define PaUtil_WriteMemoryBarrier() __sync_synchronize()
- /* as a fallback, GCC understands volatile asm and "memory" to mean it
- * should not reorder memory read/writes */
- /* Note that it is not clear that any compiler actually defines __PPC__,
- * it can probably removed safely. */
-# elif defined( __ppc__ ) || defined( __powerpc__) || defined( __PPC__ )
-# define PaUtil_FullMemoryBarrier() asm volatile("sync":::"memory")
-# define PaUtil_ReadMemoryBarrier() asm volatile("sync":::"memory")
-# define PaUtil_WriteMemoryBarrier() asm volatile("sync":::"memory")
-# elif defined( __i386__ ) || defined( __i486__ ) || defined( __i586__ ) || \
- defined( __i686__ ) || defined( __x86_64__ )
-# define PaUtil_FullMemoryBarrier() asm volatile("mfence":::"memory")
-# define PaUtil_ReadMemoryBarrier() asm volatile("lfence":::"memory")
-# define PaUtil_WriteMemoryBarrier() asm volatile("sfence":::"memory")
-# else
-# ifdef ALLOW_SMP_DANGERS
-# warning Memory barriers not defined on this system or system unknown
-# warning For SMP safety, you should fix this.
-# define PaUtil_FullMemoryBarrier()
-# define PaUtil_ReadMemoryBarrier()
-# define PaUtil_WriteMemoryBarrier()
-# else
-# error Memory barriers are not defined on this system. You can still compile by defining ALLOW_SMP_DANGERS, but SMP safety will not be guaranteed.
-# endif
-# endif
-#elif (_MSC_VER >= 1400) && !defined(_WIN32_WCE)
-# include <intrin.h>
-# pragma intrinsic(_ReadWriteBarrier)
-# pragma intrinsic(_ReadBarrier)
-# pragma intrinsic(_WriteBarrier)
-# define PaUtil_FullMemoryBarrier() _ReadWriteBarrier()
-# define PaUtil_ReadMemoryBarrier() _ReadBarrier()
-# define PaUtil_WriteMemoryBarrier() _WriteBarrier()
-#elif defined(_WIN32_WCE)
-# define PaUtil_FullMemoryBarrier()
-# define PaUtil_ReadMemoryBarrier()
-# define PaUtil_WriteMemoryBarrier()
-#elif defined(_MSC_VER) || defined(__BORLANDC__)
-# define PaUtil_FullMemoryBarrier() _asm { lock add [esp], 0 }
-# define PaUtil_ReadMemoryBarrier() _asm { lock add [esp], 0 }
-# define PaUtil_WriteMemoryBarrier() _asm { lock add [esp], 0 }
+/* GCC >= 4.1 has built-in intrinsics. We'll use those */
+#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
+#define PaUtil_FullMemoryBarrier() __sync_synchronize()
+#define PaUtil_ReadMemoryBarrier() __sync_synchronize()
+#define PaUtil_WriteMemoryBarrier() __sync_synchronize()
+/* as a fallback, GCC understands volatile asm and "memory" to mean it
+ * should not reorder memory read/writes */
+/* Note that it is not clear that any compiler actually defines __PPC__,
+ * it can probably removed safely. */
+#elif defined(__ppc__) || defined(__powerpc__) || defined(__PPC__)
+#define PaUtil_FullMemoryBarrier() asm volatile("sync" ::: "memory")
+#define PaUtil_ReadMemoryBarrier() asm volatile("sync" ::: "memory")
+#define PaUtil_WriteMemoryBarrier() asm volatile("sync" ::: "memory")
+#elif defined(__i386__) || defined(__i486__) || defined(__i586__) || \
+ defined(__i686__) || defined(__x86_64__)
+#define PaUtil_FullMemoryBarrier() asm volatile("mfence" ::: "memory")
+#define PaUtil_ReadMemoryBarrier() asm volatile("lfence" ::: "memory")
+#define PaUtil_WriteMemoryBarrier() asm volatile("sfence" ::: "memory")
#else
-# ifdef ALLOW_SMP_DANGERS
-# warning Memory barriers not defined on this system or system unknown
-# warning For SMP safety, you should fix this.
-# define PaUtil_FullMemoryBarrier()
-# define PaUtil_ReadMemoryBarrier()
-# define PaUtil_WriteMemoryBarrier()
-# else
+#ifdef ALLOW_SMP_DANGERS
+#warning Memory barriers not defined on this system or system unknown
+#warning For SMP safety, you should fix this.
+#define PaUtil_FullMemoryBarrier()
+#define PaUtil_ReadMemoryBarrier()
+#define PaUtil_WriteMemoryBarrier()
+#else
+# error Memory barriers are not defined on this system. You can still compile by defining ALLOW_SMP_DANGERS, but SMP safety will not be guaranteed.
+#endif
+#endif
+#elif (_MSC_VER >= 1400) && !defined(_WIN32_WCE)
+#include <intrin.h>
+#pragma intrinsic(_ReadWriteBarrier)
+#pragma intrinsic(_ReadBarrier)
+#pragma intrinsic(_WriteBarrier)
+#define PaUtil_FullMemoryBarrier() _ReadWriteBarrier()
+#define PaUtil_ReadMemoryBarrier() _ReadBarrier()
+#define PaUtil_WriteMemoryBarrier() _WriteBarrier()
+#elif defined(_WIN32_WCE)
+#define PaUtil_FullMemoryBarrier()
+#define PaUtil_ReadMemoryBarrier()
+#define PaUtil_WriteMemoryBarrier()
+#elif defined(_MSC_VER) || defined(__BORLANDC__)
+#define PaUtil_FullMemoryBarrier() _asm { lock add [esp], 0}
+#define PaUtil_ReadMemoryBarrier() _asm { lock add [esp], 0}
+#define PaUtil_WriteMemoryBarrier() _asm { lock add [esp], 0}
+#else
+#ifdef ALLOW_SMP_DANGERS
+#warning Memory barriers not defined on this system or system unknown
+#warning For SMP safety, you should fix this.
+#define PaUtil_FullMemoryBarrier()
+#define PaUtil_ReadMemoryBarrier()
+#define PaUtil_WriteMemoryBarrier()
+#else
# error Memory barriers are not defined on this system. You can still compile by defining ALLOW_SMP_DANGERS, but SMP safety will not be guaranteed.
-# endif
+#endif
#endif
diff --git a/modules/audio_device/mac/portaudio/pa_ringbuffer.h b/modules/audio_device/mac/portaudio/pa_ringbuffer.h
index 210a65e..a88a82f 100644
--- a/modules/audio_device/mac/portaudio/pa_ringbuffer.h
+++ b/modules/audio_device/mac/portaudio/pa_ringbuffer.h
@@ -8,7 +8,7 @@
* Author: Phil Burk, http://www.softsynth.com
* modified for SMP safety on OS X by Bjorn Roche.
* also allowed for const where possible.
- * modified for multiple-byte-sized data elements by Sven Fischer
+ * modified for multiple-byte-sized data elements by Sven Fischer
*
* Note that this is safe only for a single-thread reader
* and a single-thread writer.
@@ -38,13 +38,13 @@
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
@@ -58,11 +58,11 @@
a single reader and a single writer (ie. one thread or callback writes
to the ring buffer, another thread or callback reads from it).
- The PaUtilRingBuffer structure manages a ring buffer containing N
- elements, where N must be a power of two. An element may be any size
+ The PaUtilRingBuffer structure manages a ring buffer containing N
+ elements, where N must be a power of two. An element may be any size
(specified in bytes).
- The memory area used to store the buffer elements must be allocated by
+ The memory area used to store the buffer elements must be allocated by
the client prior to calling PaUtil_InitializeRingBuffer() and must outlive
the use of the ring buffer.
*/
@@ -70,7 +70,7 @@
#if defined(__APPLE__)
#include <sys/types.h>
typedef int32_t PaRingBufferSize;
-#elif defined( __GNUC__ )
+#elif defined(__GNUC__)
typedef long PaRingBufferSize;
#elif (_MSC_VER >= 1400)
typedef long PaRingBufferSize;
@@ -80,23 +80,24 @@
typedef long PaRingBufferSize;
#endif
-
-
#ifdef __cplusplus
-extern "C"
-{
+extern "C" {
#endif /* __cplusplus */
-typedef struct PaUtilRingBuffer
-{
- PaRingBufferSize bufferSize; /**< Number of elements in FIFO. Power of 2. Set by PaUtil_InitRingBuffer. */
- PaRingBufferSize writeIndex; /**< Index of next writable element. Set by PaUtil_AdvanceRingBufferWriteIndex. */
- PaRingBufferSize readIndex; /**< Index of next readable element. Set by PaUtil_AdvanceRingBufferReadIndex. */
- PaRingBufferSize bigMask; /**< Used for wrapping indices with extra bit to distinguish full/empty. */
- PaRingBufferSize smallMask; /**< Used for fitting indices to buffer. */
- PaRingBufferSize elementSizeBytes; /**< Number of bytes per element. */
- char *buffer; /**< Pointer to the buffer containing the actual data. */
-}PaUtilRingBuffer;
+typedef struct PaUtilRingBuffer {
+ PaRingBufferSize
+ bufferSize; /**< Number of elements in FIFO. Power of 2. Set by
+ PaUtil_InitRingBuffer. */
+ PaRingBufferSize writeIndex; /**< Index of next writable element. Set by
+ PaUtil_AdvanceRingBufferWriteIndex. */
+ PaRingBufferSize readIndex; /**< Index of next readable element. Set by
+ PaUtil_AdvanceRingBufferReadIndex. */
+ PaRingBufferSize bigMask; /**< Used for wrapping indices with extra bit to
+ distinguish full/empty. */
+ PaRingBufferSize smallMask; /**< Used for fitting indices to buffer. */
+ PaRingBufferSize elementSizeBytes; /**< Number of bytes per element. */
+ char* buffer; /**< Pointer to the buffer containing the actual data. */
+} PaUtilRingBuffer;
/** Initialize Ring Buffer.
@@ -111,13 +112,16 @@
@return -1 if elementCount is not a power of 2, otherwise 0.
*/
-PaRingBufferSize PaUtil_InitializeRingBuffer( PaUtilRingBuffer *rbuf, PaRingBufferSize elementSizeBytes, PaRingBufferSize elementCount, void *dataPtr );
+PaRingBufferSize PaUtil_InitializeRingBuffer(PaUtilRingBuffer* rbuf,
+ PaRingBufferSize elementSizeBytes,
+ PaRingBufferSize elementCount,
+ void* dataPtr);
/** Clear buffer. Should only be called when buffer is NOT being read.
@param rbuf The ring buffer.
*/
-void PaUtil_FlushRingBuffer( PaUtilRingBuffer *rbuf );
+void PaUtil_FlushRingBuffer(PaUtilRingBuffer* rbuf);
/** Retrieve the number of elements available in the ring buffer for writing.
@@ -125,7 +129,7 @@
@return The number of elements available for writing.
*/
-PaRingBufferSize PaUtil_GetRingBufferWriteAvailable( PaUtilRingBuffer *rbuf );
+PaRingBufferSize PaUtil_GetRingBufferWriteAvailable(PaUtilRingBuffer* rbuf);
/** Retrieve the number of elements available in the ring buffer for reading.
@@ -133,7 +137,7 @@
@return The number of elements available for reading.
*/
-PaRingBufferSize PaUtil_GetRingBufferReadAvailable( PaUtilRingBuffer *rbuf );
+PaRingBufferSize PaUtil_GetRingBufferReadAvailable(PaUtilRingBuffer* rbuf);
/** Write data to the ring buffer.
@@ -145,7 +149,9 @@
@return The number of elements written.
*/
-PaRingBufferSize PaUtil_WriteRingBuffer( PaUtilRingBuffer *rbuf, const void *data, PaRingBufferSize elementCount );
+PaRingBufferSize PaUtil_WriteRingBuffer(PaUtilRingBuffer* rbuf,
+ const void* data,
+ PaRingBufferSize elementCount);
/** Read data from the ring buffer.
@@ -157,7 +163,9 @@
@return The number of elements read.
*/
-PaRingBufferSize PaUtil_ReadRingBuffer( PaUtilRingBuffer *rbuf, void *data, PaRingBufferSize elementCount );
+PaRingBufferSize PaUtil_ReadRingBuffer(PaUtilRingBuffer* rbuf,
+ void* data,
+ PaRingBufferSize elementCount);
/** Get address of region(s) to which we can write data.
@@ -179,9 +187,12 @@
@return The room available to be written or elementCount, whichever is smaller.
*/
-PaRingBufferSize PaUtil_GetRingBufferWriteRegions( PaUtilRingBuffer *rbuf, PaRingBufferSize elementCount,
- void **dataPtr1, PaRingBufferSize *sizePtr1,
- void **dataPtr2, PaRingBufferSize *sizePtr2 );
+PaRingBufferSize PaUtil_GetRingBufferWriteRegions(PaUtilRingBuffer* rbuf,
+ PaRingBufferSize elementCount,
+ void** dataPtr1,
+ PaRingBufferSize* sizePtr1,
+ void** dataPtr2,
+ PaRingBufferSize* sizePtr2);
/** Advance the write index to the next location to be written.
@@ -191,7 +202,9 @@
@return The new position.
*/
-PaRingBufferSize PaUtil_AdvanceRingBufferWriteIndex( PaUtilRingBuffer *rbuf, PaRingBufferSize elementCount );
+PaRingBufferSize PaUtil_AdvanceRingBufferWriteIndex(
+ PaUtilRingBuffer* rbuf,
+ PaRingBufferSize elementCount);
/** Get address of region(s) from which we can write data.
@@ -213,9 +226,12 @@
@return The number of elements available for reading.
*/
-PaRingBufferSize PaUtil_GetRingBufferReadRegions( PaUtilRingBuffer *rbuf, PaRingBufferSize elementCount,
- void **dataPtr1, PaRingBufferSize *sizePtr1,
- void **dataPtr2, PaRingBufferSize *sizePtr2 );
+PaRingBufferSize PaUtil_GetRingBufferReadRegions(PaUtilRingBuffer* rbuf,
+ PaRingBufferSize elementCount,
+ void** dataPtr1,
+ PaRingBufferSize* sizePtr1,
+ void** dataPtr2,
+ PaRingBufferSize* sizePtr2);
/** Advance the read index to the next location to be read.
@@ -225,7 +241,9 @@
@return The new position.
*/
-PaRingBufferSize PaUtil_AdvanceRingBufferReadIndex( PaUtilRingBuffer *rbuf, PaRingBufferSize elementCount );
+PaRingBufferSize PaUtil_AdvanceRingBufferReadIndex(
+ PaUtilRingBuffer* rbuf,
+ PaRingBufferSize elementCount);
#ifdef __cplusplus
}
diff --git a/modules/audio_device/win/audio_device_core_win.cc b/modules/audio_device/win/audio_device_core_win.cc
index 731d461..7df2cd0 100644
--- a/modules/audio_device/win/audio_device_core_win.cc
+++ b/modules/audio_device/win/audio_device_core_win.cc
@@ -28,9 +28,9 @@
#include <assert.h>
#include <string.h>
-#include <functiondiscoverykeys_devpkey.h>
#include <comdef.h>
#include <dmo.h>
+#include <functiondiscoverykeys_devpkey.h>
#include <mmsystem.h>
#include <strsafe.h>
#include <uuids.h>
@@ -1959,8 +1959,7 @@
RTC_LOG(LS_VERBOSE) << "cbSize : " << Wfx.cbSize;
RTC_LOG(LS_VERBOSE) << "Additional settings:";
RTC_LOG(LS_VERBOSE) << "_playAudioFrameSize: " << _playAudioFrameSize;
- RTC_LOG(LS_VERBOSE) << "_playBlockSize : "
- << _playBlockSize;
+ RTC_LOG(LS_VERBOSE) << "_playBlockSize : " << _playBlockSize;
RTC_LOG(LS_VERBOSE) << "_playChannels : " << _playChannels;
}
diff --git a/modules/audio_device/win/audio_device_core_win.h b/modules/audio_device/win/audio_device_core_win.h
index 1a0123e..4984bd9 100644
--- a/modules/audio_device/win/audio_device_core_win.h
+++ b/modules/audio_device/win/audio_device_core_win.h
@@ -17,24 +17,24 @@
#include "modules/audio_device/audio_device_generic.h"
-#include <wmcodecdsp.h> // CLSID_CWMAudioAEC
- // (must be before audioclient.h)
-#include <audioclient.h> // WASAPI
+#include <wmcodecdsp.h> // CLSID_CWMAudioAEC
+ // (must be before audioclient.h)
+#include <audioclient.h> // WASAPI
#include <audiopolicy.h>
-#include <mmdeviceapi.h> // MMDevice
-#include <avrt.h> // Avrt
+#include <avrt.h> // Avrt
#include <endpointvolume.h>
-#include <mediaobj.h> // IMediaObject
+#include <mediaobj.h> // IMediaObject
+#include <mmdeviceapi.h> // MMDevice
#include "rtc_base/criticalsection.h"
#include "rtc_base/scoped_ref_ptr.h"
// Use Multimedia Class Scheduler Service (MMCSS) to boost the thread priority
-#pragma comment( lib, "avrt.lib" )
+#pragma comment(lib, "avrt.lib")
// AVRT function pointers
-typedef BOOL (WINAPI *PAvRevertMmThreadCharacteristics)(HANDLE);
-typedef HANDLE (WINAPI *PAvSetMmThreadCharacteristicsA)(LPCSTR, LPDWORD);
-typedef BOOL (WINAPI *PAvSetMmThreadPriority)(HANDLE, AVRT_PRIORITY);
+typedef BOOL(WINAPI* PAvRevertMmThreadCharacteristics)(HANDLE);
+typedef HANDLE(WINAPI* PAvSetMmThreadCharacteristicsA)(LPCSTR, LPDWORD);
+typedef BOOL(WINAPI* PAvSetMmThreadPriority)(HANDLE, AVRT_PRIORITY);
namespace webrtc {
@@ -53,9 +53,7 @@
enum SelectMTA { kMTA };
// Constructor for STA initialization.
- ScopedCOMInitializer() {
- Initialize(COINIT_APARTMENTTHREADED);
- }
+ ScopedCOMInitializer() { Initialize(COINIT_APARTMENTTHREADED); }
// Constructor for MTA initialization.
explicit ScopedCOMInitializer(SelectMTA mta) {
@@ -70,9 +68,7 @@
bool succeeded() const { return SUCCEEDED(hr_); }
private:
- void Initialize(COINIT init) {
- hr_ = CoInitializeEx(NULL, init);
- }
+ void Initialize(COINIT init) { hr_ = CoInitializeEx(NULL, init); }
HRESULT hr_;
@@ -80,238 +76,246 @@
void operator=(const ScopedCOMInitializer&);
};
+class AudioDeviceWindowsCore : public AudioDeviceGeneric {
+ public:
+ AudioDeviceWindowsCore();
+ ~AudioDeviceWindowsCore();
-class AudioDeviceWindowsCore : public AudioDeviceGeneric
-{
-public:
- AudioDeviceWindowsCore();
- ~AudioDeviceWindowsCore();
+ static bool CoreAudioIsSupported();
- static bool CoreAudioIsSupported();
+ // Retrieve the currently utilized audio layer
+ virtual int32_t ActiveAudioLayer(
+ AudioDeviceModule::AudioLayer& audioLayer) const;
- // Retrieve the currently utilized audio layer
- virtual int32_t ActiveAudioLayer(AudioDeviceModule::AudioLayer& audioLayer) const;
+ // Main initializaton and termination
+ virtual InitStatus Init();
+ virtual int32_t Terminate();
+ virtual bool Initialized() const;
- // Main initializaton and termination
- virtual InitStatus Init();
- virtual int32_t Terminate();
- virtual bool Initialized() const;
+ // Device enumeration
+ virtual int16_t PlayoutDevices();
+ virtual int16_t RecordingDevices();
+ virtual int32_t PlayoutDeviceName(uint16_t index,
+ char name[kAdmMaxDeviceNameSize],
+ char guid[kAdmMaxGuidSize]);
+ virtual int32_t RecordingDeviceName(uint16_t index,
+ char name[kAdmMaxDeviceNameSize],
+ char guid[kAdmMaxGuidSize]);
- // Device enumeration
- virtual int16_t PlayoutDevices();
- virtual int16_t RecordingDevices();
- virtual int32_t PlayoutDeviceName(
- uint16_t index,
- char name[kAdmMaxDeviceNameSize],
- char guid[kAdmMaxGuidSize]);
- virtual int32_t RecordingDeviceName(
- uint16_t index,
- char name[kAdmMaxDeviceNameSize],
- char guid[kAdmMaxGuidSize]);
+ // Device selection
+ virtual int32_t SetPlayoutDevice(uint16_t index);
+ virtual int32_t SetPlayoutDevice(AudioDeviceModule::WindowsDeviceType device);
+ virtual int32_t SetRecordingDevice(uint16_t index);
+ virtual int32_t SetRecordingDevice(
+ AudioDeviceModule::WindowsDeviceType device);
- // Device selection
- virtual int32_t SetPlayoutDevice(uint16_t index);
- virtual int32_t SetPlayoutDevice(AudioDeviceModule::WindowsDeviceType device);
- virtual int32_t SetRecordingDevice(uint16_t index);
- virtual int32_t SetRecordingDevice(AudioDeviceModule::WindowsDeviceType device);
+ // Audio transport initialization
+ virtual int32_t PlayoutIsAvailable(bool& available);
+ virtual int32_t InitPlayout();
+ virtual bool PlayoutIsInitialized() const;
+ virtual int32_t RecordingIsAvailable(bool& available);
+ virtual int32_t InitRecording();
+ virtual bool RecordingIsInitialized() const;
- // Audio transport initialization
- virtual int32_t PlayoutIsAvailable(bool& available);
- virtual int32_t InitPlayout();
- virtual bool PlayoutIsInitialized() const;
- virtual int32_t RecordingIsAvailable(bool& available);
- virtual int32_t InitRecording();
- virtual bool RecordingIsInitialized() const;
+ // Audio transport control
+ virtual int32_t StartPlayout();
+ virtual int32_t StopPlayout();
+ virtual bool Playing() const;
+ virtual int32_t StartRecording();
+ virtual int32_t StopRecording();
+ virtual bool Recording() const;
- // Audio transport control
- virtual int32_t StartPlayout();
- virtual int32_t StopPlayout();
- virtual bool Playing() const;
- virtual int32_t StartRecording();
- virtual int32_t StopRecording();
- virtual bool Recording() const;
+ // Audio mixer initialization
+ virtual int32_t InitSpeaker();
+ virtual bool SpeakerIsInitialized() const;
+ virtual int32_t InitMicrophone();
+ virtual bool MicrophoneIsInitialized() const;
- // Audio mixer initialization
- virtual int32_t InitSpeaker();
- virtual bool SpeakerIsInitialized() const;
- virtual int32_t InitMicrophone();
- virtual bool MicrophoneIsInitialized() const;
+ // Speaker volume controls
+ virtual int32_t SpeakerVolumeIsAvailable(bool& available);
+ virtual int32_t SetSpeakerVolume(uint32_t volume);
+ virtual int32_t SpeakerVolume(uint32_t& volume) const;
+ virtual int32_t MaxSpeakerVolume(uint32_t& maxVolume) const;
+ virtual int32_t MinSpeakerVolume(uint32_t& minVolume) const;
- // Speaker volume controls
- virtual int32_t SpeakerVolumeIsAvailable(bool& available);
- virtual int32_t SetSpeakerVolume(uint32_t volume);
- virtual int32_t SpeakerVolume(uint32_t& volume) const;
- virtual int32_t MaxSpeakerVolume(uint32_t& maxVolume) const;
- virtual int32_t MinSpeakerVolume(uint32_t& minVolume) const;
+ // Microphone volume controls
+ virtual int32_t MicrophoneVolumeIsAvailable(bool& available);
+ virtual int32_t SetMicrophoneVolume(uint32_t volume);
+ virtual int32_t MicrophoneVolume(uint32_t& volume) const;
+ virtual int32_t MaxMicrophoneVolume(uint32_t& maxVolume) const;
+ virtual int32_t MinMicrophoneVolume(uint32_t& minVolume) const;
- // Microphone volume controls
- virtual int32_t MicrophoneVolumeIsAvailable(bool& available);
- virtual int32_t SetMicrophoneVolume(uint32_t volume);
- virtual int32_t MicrophoneVolume(uint32_t& volume) const;
- virtual int32_t MaxMicrophoneVolume(uint32_t& maxVolume) const;
- virtual int32_t MinMicrophoneVolume(uint32_t& minVolume) const;
+ // Speaker mute control
+ virtual int32_t SpeakerMuteIsAvailable(bool& available);
+ virtual int32_t SetSpeakerMute(bool enable);
+ virtual int32_t SpeakerMute(bool& enabled) const;
- // Speaker mute control
- virtual int32_t SpeakerMuteIsAvailable(bool& available);
- virtual int32_t SetSpeakerMute(bool enable);
- virtual int32_t SpeakerMute(bool& enabled) const;
+ // Microphone mute control
+ virtual int32_t MicrophoneMuteIsAvailable(bool& available);
+ virtual int32_t SetMicrophoneMute(bool enable);
+ virtual int32_t MicrophoneMute(bool& enabled) const;
- // Microphone mute control
- virtual int32_t MicrophoneMuteIsAvailable(bool& available);
- virtual int32_t SetMicrophoneMute(bool enable);
- virtual int32_t MicrophoneMute(bool& enabled) const;
+ // Stereo support
+ virtual int32_t StereoPlayoutIsAvailable(bool& available);
+ virtual int32_t SetStereoPlayout(bool enable);
+ virtual int32_t StereoPlayout(bool& enabled) const;
+ virtual int32_t StereoRecordingIsAvailable(bool& available);
+ virtual int32_t SetStereoRecording(bool enable);
+ virtual int32_t StereoRecording(bool& enabled) const;
- // Stereo support
- virtual int32_t StereoPlayoutIsAvailable(bool& available);
- virtual int32_t SetStereoPlayout(bool enable);
- virtual int32_t StereoPlayout(bool& enabled) const;
- virtual int32_t StereoRecordingIsAvailable(bool& available);
- virtual int32_t SetStereoRecording(bool enable);
- virtual int32_t StereoRecording(bool& enabled) const;
+ // Delay information and control
+ virtual int32_t PlayoutDelay(uint16_t& delayMS) const;
- // Delay information and control
- virtual int32_t PlayoutDelay(uint16_t& delayMS) const;
+ virtual bool BuiltInAECIsAvailable() const;
- virtual bool BuiltInAECIsAvailable() const;
+ virtual int32_t EnableBuiltInAEC(bool enable);
- virtual int32_t EnableBuiltInAEC(bool enable);
+ public:
+ virtual void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer);
-public:
- virtual void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer);
+ private:
+ bool KeyPressed() const;
-private:
- bool KeyPressed() const;
+ private: // avrt function pointers
+ PAvRevertMmThreadCharacteristics _PAvRevertMmThreadCharacteristics;
+ PAvSetMmThreadCharacteristicsA _PAvSetMmThreadCharacteristicsA;
+ PAvSetMmThreadPriority _PAvSetMmThreadPriority;
+ HMODULE _avrtLibrary;
+ bool _winSupportAvrt;
-private: // avrt function pointers
- PAvRevertMmThreadCharacteristics _PAvRevertMmThreadCharacteristics;
- PAvSetMmThreadCharacteristicsA _PAvSetMmThreadCharacteristicsA;
- PAvSetMmThreadPriority _PAvSetMmThreadPriority;
- HMODULE _avrtLibrary;
- bool _winSupportAvrt;
+ private: // thread functions
+ DWORD InitCaptureThreadPriority();
+ void RevertCaptureThreadPriority();
+ static DWORD WINAPI WSAPICaptureThread(LPVOID context);
+ DWORD DoCaptureThread();
-private: // thread functions
- DWORD InitCaptureThreadPriority();
- void RevertCaptureThreadPriority();
- static DWORD WINAPI WSAPICaptureThread(LPVOID context);
- DWORD DoCaptureThread();
+ static DWORD WINAPI WSAPICaptureThreadPollDMO(LPVOID context);
+ DWORD DoCaptureThreadPollDMO();
- static DWORD WINAPI WSAPICaptureThreadPollDMO(LPVOID context);
- DWORD DoCaptureThreadPollDMO();
+ static DWORD WINAPI WSAPIRenderThread(LPVOID context);
+ DWORD DoRenderThread();
- static DWORD WINAPI WSAPIRenderThread(LPVOID context);
- DWORD DoRenderThread();
+ void _Lock();
+ void _UnLock();
- void _Lock();
- void _UnLock();
+ int SetDMOProperties();
- int SetDMOProperties();
+ int SetBoolProperty(IPropertyStore* ptrPS,
+ REFPROPERTYKEY key,
+ VARIANT_BOOL value);
- int SetBoolProperty(IPropertyStore* ptrPS,
- REFPROPERTYKEY key,
- VARIANT_BOOL value);
+ int SetVtI4Property(IPropertyStore* ptrPS, REFPROPERTYKEY key, LONG value);
- int SetVtI4Property(IPropertyStore* ptrPS,
- REFPROPERTYKEY key,
- LONG value);
+ int32_t _EnumerateEndpointDevicesAll(EDataFlow dataFlow) const;
+ void _TraceCOMError(HRESULT hr) const;
- int32_t _EnumerateEndpointDevicesAll(EDataFlow dataFlow) const;
- void _TraceCOMError(HRESULT hr) const;
+ int32_t _RefreshDeviceList(EDataFlow dir);
+ int16_t _DeviceListCount(EDataFlow dir);
+ int32_t _GetDefaultDeviceName(EDataFlow dir,
+ ERole role,
+ LPWSTR szBuffer,
+ int bufferLen);
+ int32_t _GetListDeviceName(EDataFlow dir,
+ int index,
+ LPWSTR szBuffer,
+ int bufferLen);
+ int32_t _GetDeviceName(IMMDevice* pDevice, LPWSTR pszBuffer, int bufferLen);
+ int32_t _GetListDeviceID(EDataFlow dir,
+ int index,
+ LPWSTR szBuffer,
+ int bufferLen);
+ int32_t _GetDefaultDeviceID(EDataFlow dir,
+ ERole role,
+ LPWSTR szBuffer,
+ int bufferLen);
+ int32_t _GetDefaultDeviceIndex(EDataFlow dir, ERole role, int* index);
+ int32_t _GetDeviceID(IMMDevice* pDevice, LPWSTR pszBuffer, int bufferLen);
+ int32_t _GetDefaultDevice(EDataFlow dir, ERole role, IMMDevice** ppDevice);
+ int32_t _GetListDevice(EDataFlow dir, int index, IMMDevice** ppDevice);
- int32_t _RefreshDeviceList(EDataFlow dir);
- int16_t _DeviceListCount(EDataFlow dir);
- int32_t _GetDefaultDeviceName(EDataFlow dir, ERole role, LPWSTR szBuffer, int bufferLen);
- int32_t _GetListDeviceName(EDataFlow dir, int index, LPWSTR szBuffer, int bufferLen);
- int32_t _GetDeviceName(IMMDevice* pDevice, LPWSTR pszBuffer, int bufferLen);
- int32_t _GetListDeviceID(EDataFlow dir, int index, LPWSTR szBuffer, int bufferLen);
- int32_t _GetDefaultDeviceID(EDataFlow dir, ERole role, LPWSTR szBuffer, int bufferLen);
- int32_t _GetDefaultDeviceIndex(EDataFlow dir, ERole role, int* index);
- int32_t _GetDeviceID(IMMDevice* pDevice, LPWSTR pszBuffer, int bufferLen);
- int32_t _GetDefaultDevice(EDataFlow dir, ERole role, IMMDevice** ppDevice);
- int32_t _GetListDevice(EDataFlow dir, int index, IMMDevice** ppDevice);
+ // Converts from wide-char to UTF-8 if UNICODE is defined.
+ // Does nothing if UNICODE is undefined.
+ char* WideToUTF8(const TCHAR* src) const;
- // Converts from wide-char to UTF-8 if UNICODE is defined.
- // Does nothing if UNICODE is undefined.
- char* WideToUTF8(const TCHAR* src) const;
+ int32_t InitRecordingDMO();
- int32_t InitRecordingDMO();
+ ScopedCOMInitializer _comInit;
+ AudioDeviceBuffer* _ptrAudioBuffer;
+ rtc::CriticalSection _critSect;
+ rtc::CriticalSection _volumeMutex;
- ScopedCOMInitializer _comInit;
- AudioDeviceBuffer* _ptrAudioBuffer;
- rtc::CriticalSection _critSect;
- rtc::CriticalSection _volumeMutex;
+ IMMDeviceEnumerator* _ptrEnumerator;
+ IMMDeviceCollection* _ptrRenderCollection;
+ IMMDeviceCollection* _ptrCaptureCollection;
+ IMMDevice* _ptrDeviceOut;
+ IMMDevice* _ptrDeviceIn;
- IMMDeviceEnumerator* _ptrEnumerator;
- IMMDeviceCollection* _ptrRenderCollection;
- IMMDeviceCollection* _ptrCaptureCollection;
- IMMDevice* _ptrDeviceOut;
- IMMDevice* _ptrDeviceIn;
+ IAudioClient* _ptrClientOut;
+ IAudioClient* _ptrClientIn;
+ IAudioRenderClient* _ptrRenderClient;
+ IAudioCaptureClient* _ptrCaptureClient;
+ IAudioEndpointVolume* _ptrCaptureVolume;
+ ISimpleAudioVolume* _ptrRenderSimpleVolume;
- IAudioClient* _ptrClientOut;
- IAudioClient* _ptrClientIn;
- IAudioRenderClient* _ptrRenderClient;
- IAudioCaptureClient* _ptrCaptureClient;
- IAudioEndpointVolume* _ptrCaptureVolume;
- ISimpleAudioVolume* _ptrRenderSimpleVolume;
+ // DirectX Media Object (DMO) for the built-in AEC.
+ rtc::scoped_refptr<IMediaObject> _dmo;
+ rtc::scoped_refptr<IMediaBuffer> _mediaBuffer;
+ bool _builtInAecEnabled;
- // DirectX Media Object (DMO) for the built-in AEC.
- rtc::scoped_refptr<IMediaObject> _dmo;
- rtc::scoped_refptr<IMediaBuffer> _mediaBuffer;
- bool _builtInAecEnabled;
+ HANDLE _hRenderSamplesReadyEvent;
+ HANDLE _hPlayThread;
+ HANDLE _hRenderStartedEvent;
+ HANDLE _hShutdownRenderEvent;
- HANDLE _hRenderSamplesReadyEvent;
- HANDLE _hPlayThread;
- HANDLE _hRenderStartedEvent;
- HANDLE _hShutdownRenderEvent;
+ HANDLE _hCaptureSamplesReadyEvent;
+ HANDLE _hRecThread;
+ HANDLE _hCaptureStartedEvent;
+ HANDLE _hShutdownCaptureEvent;
- HANDLE _hCaptureSamplesReadyEvent;
- HANDLE _hRecThread;
- HANDLE _hCaptureStartedEvent;
- HANDLE _hShutdownCaptureEvent;
+ HANDLE _hMmTask;
- HANDLE _hMmTask;
+ UINT _playAudioFrameSize;
+ uint32_t _playSampleRate;
+ uint32_t _devicePlaySampleRate;
+ uint32_t _playBlockSize;
+ uint32_t _devicePlayBlockSize;
+ uint32_t _playChannels;
+ uint32_t _sndCardPlayDelay;
+ UINT64 _writtenSamples;
- UINT _playAudioFrameSize;
- uint32_t _playSampleRate;
- uint32_t _devicePlaySampleRate;
- uint32_t _playBlockSize;
- uint32_t _devicePlayBlockSize;
- uint32_t _playChannels;
- uint32_t _sndCardPlayDelay;
- UINT64 _writtenSamples;
+ UINT _recAudioFrameSize;
+ uint32_t _recSampleRate;
+ uint32_t _recBlockSize;
+ uint32_t _recChannels;
+ UINT64 _readSamples;
+ uint32_t _sndCardRecDelay;
- UINT _recAudioFrameSize;
- uint32_t _recSampleRate;
- uint32_t _recBlockSize;
- uint32_t _recChannels;
- UINT64 _readSamples;
- uint32_t _sndCardRecDelay;
+ uint16_t _recChannelsPrioList[3];
+ uint16_t _playChannelsPrioList[2];
- uint16_t _recChannelsPrioList[3];
- uint16_t _playChannelsPrioList[2];
+ LARGE_INTEGER _perfCounterFreq;
+ double _perfCounterFactor;
- LARGE_INTEGER _perfCounterFreq;
- double _perfCounterFactor;
+ private:
+ bool _initialized;
+ bool _recording;
+ bool _playing;
+ bool _recIsInitialized;
+ bool _playIsInitialized;
+ bool _speakerIsInitialized;
+ bool _microphoneIsInitialized;
-private:
- bool _initialized;
- bool _recording;
- bool _playing;
- bool _recIsInitialized;
- bool _playIsInitialized;
- bool _speakerIsInitialized;
- bool _microphoneIsInitialized;
+ bool _usingInputDeviceIndex;
+ bool _usingOutputDeviceIndex;
+ AudioDeviceModule::WindowsDeviceType _inputDevice;
+ AudioDeviceModule::WindowsDeviceType _outputDevice;
+ uint16_t _inputDeviceIndex;
+ uint16_t _outputDeviceIndex;
- bool _usingInputDeviceIndex;
- bool _usingOutputDeviceIndex;
- AudioDeviceModule::WindowsDeviceType _inputDevice;
- AudioDeviceModule::WindowsDeviceType _outputDevice;
- uint16_t _inputDeviceIndex;
- uint16_t _outputDeviceIndex;
-
- mutable char _str[512];
+ mutable char _str[512];
};
-#endif // #if (_MSC_VER >= 1400)
+#endif // #if (_MSC_VER >= 1400)
} // namespace webrtc
diff --git a/modules/audio_mixer/audio_frame_manipulator_unittest.cc b/modules/audio_mixer/audio_frame_manipulator_unittest.cc
index 3614821..28154a5 100644
--- a/modules/audio_mixer/audio_frame_manipulator_unittest.cc
+++ b/modules/audio_mixer/audio_frame_manipulator_unittest.cc
@@ -23,8 +23,8 @@
frame->num_channels_ = number_of_channels;
frame->samples_per_channel_ = samples_per_channel;
int16_t* frame_data = frame->mutable_data();
- std::fill(frame_data,
- frame_data + samples_per_channel * number_of_channels, value);
+ std::fill(frame_data, frame_data + samples_per_channel * number_of_channels,
+ value);
}
} // namespace
diff --git a/modules/audio_mixer/audio_mixer_impl_unittest.cc b/modules/audio_mixer/audio_mixer_impl_unittest.cc
index b9e1e73..57e4526 100644
--- a/modules/audio_mixer/audio_mixer_impl_unittest.cc
+++ b/modules/audio_mixer/audio_mixer_impl_unittest.cc
@@ -188,11 +188,11 @@
if (i == kAudioSources - 1 ||
i < kAudioSources - 1 -
AudioMixerImpl::kMaximumAmountOfMixedAudioSources) {
- EXPECT_FALSE(is_mixed) << "Mixing status of AudioSource #" << i
- << " wrong.";
+ EXPECT_FALSE(is_mixed)
+ << "Mixing status of AudioSource #" << i << " wrong.";
} else {
- EXPECT_TRUE(is_mixed) << "Mixing status of AudioSource #" << i
- << " wrong.";
+ EXPECT_TRUE(is_mixed)
+ << "Mixing status of AudioSource #" << i << " wrong.";
}
}
}
@@ -221,9 +221,8 @@
&audio_frame);
}
- EXPECT_EQ(
- 0,
- memcmp(participant.fake_frame()->data(), audio_frame.data(), n_samples));
+ EXPECT_EQ(0, memcmp(participant.fake_frame()->data(), audio_frame.data(),
+ n_samples));
}
TEST(AudioMixer, SourceAtNativeRateShouldNeverResample) {
diff --git a/modules/audio_processing/aec/aec_core.cc b/modules/audio_processing/aec/aec_core.cc
index 43949292..95ed595 100644
--- a/modules/audio_processing/aec/aec_core.cc
+++ b/modules/audio_processing/aec/aec_core.cc
@@ -14,11 +14,11 @@
#include "modules/audio_processing/aec/aec_core.h"
-#include <algorithm>
#include <math.h>
#include <stddef.h> // size_t
#include <stdlib.h>
#include <string.h>
+#include <algorithm>
#include "rtc_base/checks.h"
extern "C" {
@@ -178,9 +178,7 @@
// window, of which the length is 1 unit longer than indicated. Remove "+1" when
// the code is refactored.
PowerLevel::PowerLevel()
- : framelevel(kSubCountLen + 1),
- averagelevel(kCountLen + 1) {
-}
+ : framelevel(kSubCountLen + 1), averagelevel(kCountLen + 1) {}
BlockBuffer::BlockBuffer() {
buffer_ = WebRtc_CreateBuffer(kBufferSizeBlocks, sizeof(float) * PART_LEN);
@@ -238,10 +236,7 @@
}
DivergentFilterFraction::DivergentFilterFraction()
- : count_(0),
- occurrence_(0),
- fraction_(-1.0) {
-}
+ : count_(0), occurrence_(0), fraction_(-1.0) {}
void DivergentFilterFraction::Reset() {
Clear();
@@ -254,19 +249,18 @@
const float near_level = nearlevel.framelevel.GetLatestMean();
const float level_increase =
linoutlevel.framelevel.GetLatestMean() - near_level;
- const bool output_signal_active = nlpoutlevel.framelevel.GetLatestMean() >
- 40.0 * nlpoutlevel.minlevel;
+ const bool output_signal_active =
+ nlpoutlevel.framelevel.GetLatestMean() > 40.0 * nlpoutlevel.minlevel;
// Level increase should be, in principle, negative, when the filter
// does not diverge. Here we allow some margin (0.01 * near end level) and
// numerical error (1.0). We count divergence only when the AEC output
// signal is active.
- if (output_signal_active &&
- level_increase > std::max(0.01 * near_level, 1.0))
+ if (output_signal_active && level_increase > std::max(0.01 * near_level, 1.0))
occurrence_++;
++count_;
if (count_ == kDivergentFilterFractionAggregationWindowSize) {
fraction_ = static_cast<float>(occurrence_) /
- kDivergentFilterFractionAggregationWindowSize;
+ kDivergentFilterFractionAggregationWindowSize;
Clear();
}
}
@@ -416,9 +410,9 @@
}
}
-static int PartitionDelay(int num_partitions,
- float h_fft_buf[2]
- [kExtendedNumPartitions * PART_LEN1]) {
+static int PartitionDelay(
+ int num_partitions,
+ float h_fft_buf[2][kExtendedNumPartitions * PART_LEN1]) {
// Measures the energy in each filter partition and returns the partition with
// highest energy.
// TODO(bjornv): Spread computational cost by computing one partition per
@@ -445,7 +439,8 @@
}
// Update metric with 10 * log10(numerator / denominator).
-static void UpdateLogRatioMetric(Stats* metric, float numerator,
+static void UpdateLogRatioMetric(Stats* metric,
+ float numerator,
float denominator) {
RTC_DCHECK(metric);
RTC_CHECK(numerator >= 0);
@@ -736,9 +731,8 @@
}
if (aec->linoutlevel.framelevel.EndOfBlock()) {
- aec->divergent_filter_fraction.AddObservation(aec->nearlevel,
- aec->linoutlevel,
- aec->nlpoutlevel);
+ aec->divergent_filter_fraction.AddObservation(
+ aec->nearlevel, aec->linoutlevel, aec->nlpoutlevel);
}
if (aec->farlevel.averagelevel.EndOfBlock()) {
@@ -755,7 +749,6 @@
if ((aec->stateCounter > (0.5f * kCountLen * kSubCountLen)) &&
(aec->farlevel.framelevel.EndOfBlock()) &&
(far_average_level > (actThreshold * aec->farlevel.minlevel))) {
-
// ERL: error return loss.
const float near_average_level =
aec->nearlevel.averagelevel.GetLatestMean();
@@ -815,9 +808,9 @@
for (i = 0; i < kHistorySizeBlocks; i++) {
l1_norm += abs(i - median) * self->delay_histogram[i];
}
- self->delay_std =
- static_cast<int>((l1_norm + self->num_delay_values / 2) /
- self->num_delay_values) * kMsPerBlock;
+ self->delay_std = static_cast<int>((l1_norm + self->num_delay_values / 2) /
+ self->num_delay_values) *
+ kMsPerBlock;
// Determine fraction of delays that are out of bounds, that is, either
// negative (anti-causal system) or larger than the AEC filter length.
@@ -949,11 +942,11 @@
return delay_correction;
}
-static void RegressorPower(int num_partitions,
- int latest_added_partition,
- float x_fft_buf[2]
- [kExtendedNumPartitions * PART_LEN1],
- float x_pow[PART_LEN1]) {
+static void RegressorPower(
+ int num_partitions,
+ int latest_added_partition,
+ float x_fft_buf[2][kExtendedNumPartitions * PART_LEN1],
+ float x_pow[PART_LEN1]) {
RTC_DCHECK_LT(latest_added_partition, num_partitions);
memset(x_pow, 0, PART_LEN1 * sizeof(x_pow[0]));
@@ -976,21 +969,20 @@
}
}
-static void EchoSubtraction(const OouraFft& ooura_fft,
- int num_partitions,
- int extended_filter_enabled,
- int* extreme_filter_divergence,
- float filter_step_size,
- float error_threshold,
- float* x_fft,
- int* x_fft_buf_block_pos,
- float x_fft_buf[2]
- [kExtendedNumPartitions * PART_LEN1],
- float* const y,
- float x_pow[PART_LEN1],
- float h_fft_buf[2]
- [kExtendedNumPartitions * PART_LEN1],
- float echo_subtractor_output[PART_LEN]) {
+static void EchoSubtraction(
+ const OouraFft& ooura_fft,
+ int num_partitions,
+ int extended_filter_enabled,
+ int* extreme_filter_divergence,
+ float filter_step_size,
+ float error_threshold,
+ float* x_fft,
+ int* x_fft_buf_block_pos,
+ float x_fft_buf[2][kExtendedNumPartitions * PART_LEN1],
+ float* const y,
+ float x_pow[PART_LEN1],
+ float h_fft_buf[2][kExtendedNumPartitions * PART_LEN1],
+ float echo_subtractor_output[PART_LEN]) {
float s_fft[2][PART_LEN1];
float e_extended[PART_LEN2];
float s_extended[PART_LEN2];
@@ -1118,10 +1110,10 @@
// preferred.
memcpy(hNlPref, &hNl[minPrefBand], sizeof(float) * prefBandSize);
qsort(hNlPref, prefBandSize, sizeof(float), CmpFloat);
- hNlFb = hNlPref[static_cast<int>(floor(prefBandQuant *
- (prefBandSize - 1)))];
- hNlFbLow = hNlPref[static_cast<int>(floor(prefBandQuantLow *
- (prefBandSize - 1)))];
+ hNlFb =
+ hNlPref[static_cast<int>(floor(prefBandQuant * (prefBandSize - 1)))];
+ hNlFbLow = hNlPref[static_cast<int>(
+ floor(prefBandQuantLow * (prefBandSize - 1)))];
}
}
@@ -1142,10 +1134,10 @@
if (aec->hNlMinCtr == 2) {
aec->hNlNewMin = 0;
aec->hNlMinCtr = 0;
- aec->overDrive =
- WEBRTC_SPL_MAX(kTargetSupp[aec->nlp_mode] /
- static_cast<float>(log(aec->hNlFbMin + 1e-10f) + 1e-10f),
- min_overdrive[aec->nlp_mode]);
+ aec->overDrive = WEBRTC_SPL_MAX(
+ kTargetSupp[aec->nlp_mode] /
+ static_cast<float>(log(aec->hNlFbMin + 1e-10f) + 1e-10f),
+ min_overdrive[aec->nlp_mode]);
}
// Smooth the overdrive.
@@ -1773,20 +1765,18 @@
float nearend_buffer[NUM_HIGH_BANDS_MAX + 1]
[PART_LEN - (FRAME_LEN - PART_LEN)]) {
for (size_t i = 0; i < num_bands; ++i) {
- memcpy(
- &nearend_buffer[i][0],
- &nearend_frame[i]
- [nearend_start_index + FRAME_LEN - num_samples_to_buffer],
- num_samples_to_buffer * sizeof(float));
+ memcpy(&nearend_buffer[i][0],
+ &nearend_frame[i][nearend_start_index + FRAME_LEN -
+ num_samples_to_buffer],
+ num_samples_to_buffer * sizeof(float));
}
}
-void BufferOutputBlock(size_t num_bands,
- const float output_block[NUM_HIGH_BANDS_MAX + 1]
- [PART_LEN],
- size_t* output_buffer_size,
- float output_buffer[NUM_HIGH_BANDS_MAX + 1]
- [2 * PART_LEN]) {
+void BufferOutputBlock(
+ size_t num_bands,
+ const float output_block[NUM_HIGH_BANDS_MAX + 1][PART_LEN],
+ size_t* output_buffer_size,
+ float output_buffer[NUM_HIGH_BANDS_MAX + 1][2 * PART_LEN]) {
for (size_t i = 0; i < num_bands; ++i) {
memcpy(&output_buffer[i][*output_buffer_size], &output_block[i][0],
PART_LEN * sizeof(float));
diff --git a/modules/audio_processing/aec/aec_core_mips.cc b/modules/audio_processing/aec/aec_core_mips.cc
index ebe6349..bf89cfa 100644
--- a/modules/audio_processing/aec/aec_core_mips.cc
+++ b/modules/audio_processing/aec/aec_core_mips.cc
@@ -51,95 +51,94 @@
int len = PART_LEN1 >> 1;
__asm __volatile(
- ".set push \n\t"
- ".set noreorder \n\t"
- "1: \n\t"
- "lwc1 %[f0], 0(%[aRe]) \n\t"
- "lwc1 %[f1], 0(%[bRe]) \n\t"
- "lwc1 %[f2], 0(%[bIm]) \n\t"
- "lwc1 %[f3], 0(%[aIm]) \n\t"
- "lwc1 %[f4], 4(%[aRe]) \n\t"
- "lwc1 %[f5], 4(%[bRe]) \n\t"
- "lwc1 %[f6], 4(%[bIm]) \n\t"
- "mul.s %[f8], %[f0], %[f1] \n\t"
- "mul.s %[f0], %[f0], %[f2] \n\t"
- "mul.s %[f9], %[f4], %[f5] \n\t"
- "mul.s %[f4], %[f4], %[f6] \n\t"
- "lwc1 %[f7], 4(%[aIm]) \n\t"
+ ".set push \n\t"
+ ".set noreorder \n\t"
+ "1: \n\t"
+ "lwc1 %[f0], 0(%[aRe]) \n\t"
+ "lwc1 %[f1], 0(%[bRe]) \n\t"
+ "lwc1 %[f2], 0(%[bIm]) \n\t"
+ "lwc1 %[f3], 0(%[aIm]) \n\t"
+ "lwc1 %[f4], 4(%[aRe]) \n\t"
+ "lwc1 %[f5], 4(%[bRe]) \n\t"
+ "lwc1 %[f6], 4(%[bIm]) \n\t"
+ "mul.s %[f8], %[f0], %[f1] \n\t"
+ "mul.s %[f0], %[f0], %[f2] \n\t"
+ "mul.s %[f9], %[f4], %[f5] \n\t"
+ "mul.s %[f4], %[f4], %[f6] \n\t"
+ "lwc1 %[f7], 4(%[aIm]) \n\t"
#if !defined(MIPS32_R2_LE)
- "mul.s %[f12], %[f2], %[f3] \n\t"
- "mul.s %[f1], %[f3], %[f1] \n\t"
- "mul.s %[f11], %[f6], %[f7] \n\t"
- "addiu %[aRe], %[aRe], 8 \n\t"
- "addiu %[aIm], %[aIm], 8 \n\t"
- "addiu %[len], %[len], -1 \n\t"
- "sub.s %[f8], %[f8], %[f12] \n\t"
- "mul.s %[f12], %[f7], %[f5] \n\t"
- "lwc1 %[f2], 0(%[yf0]) \n\t"
- "add.s %[f1], %[f0], %[f1] \n\t"
- "lwc1 %[f3], 0(%[yf1]) \n\t"
- "sub.s %[f9], %[f9], %[f11] \n\t"
- "lwc1 %[f6], 4(%[yf0]) \n\t"
- "add.s %[f4], %[f4], %[f12] \n\t"
-#else // #if !defined(MIPS32_R2_LE)
- "addiu %[aRe], %[aRe], 8 \n\t"
- "addiu %[aIm], %[aIm], 8 \n\t"
- "addiu %[len], %[len], -1 \n\t"
- "nmsub.s %[f8], %[f8], %[f2], %[f3] \n\t"
- "lwc1 %[f2], 0(%[yf0]) \n\t"
- "madd.s %[f1], %[f0], %[f3], %[f1] \n\t"
- "lwc1 %[f3], 0(%[yf1]) \n\t"
- "nmsub.s %[f9], %[f9], %[f6], %[f7] \n\t"
- "lwc1 %[f6], 4(%[yf0]) \n\t"
- "madd.s %[f4], %[f4], %[f7], %[f5] \n\t"
+ "mul.s %[f12], %[f2], %[f3] \n\t"
+ "mul.s %[f1], %[f3], %[f1] \n\t"
+ "mul.s %[f11], %[f6], %[f7] \n\t"
+ "addiu %[aRe], %[aRe], 8 \n\t"
+ "addiu %[aIm], %[aIm], 8 \n\t"
+ "addiu %[len], %[len], -1 \n\t"
+ "sub.s %[f8], %[f8], %[f12] \n\t"
+ "mul.s %[f12], %[f7], %[f5] \n\t"
+ "lwc1 %[f2], 0(%[yf0]) \n\t"
+ "add.s %[f1], %[f0], %[f1] \n\t"
+ "lwc1 %[f3], 0(%[yf1]) \n\t"
+ "sub.s %[f9], %[f9], %[f11] \n\t"
+ "lwc1 %[f6], 4(%[yf0]) \n\t"
+ "add.s %[f4], %[f4], %[f12] \n\t"
+#else // #if !defined(MIPS32_R2_LE)
+ "addiu %[aRe], %[aRe], 8 \n\t"
+ "addiu %[aIm], %[aIm], 8 \n\t"
+ "addiu %[len], %[len], -1 \n\t"
+ "nmsub.s %[f8], %[f8], %[f2], %[f3] \n\t"
+ "lwc1 %[f2], 0(%[yf0]) \n\t"
+ "madd.s %[f1], %[f0], %[f3], %[f1] \n\t"
+ "lwc1 %[f3], 0(%[yf1]) \n\t"
+ "nmsub.s %[f9], %[f9], %[f6], %[f7] \n\t"
+ "lwc1 %[f6], 4(%[yf0]) \n\t"
+ "madd.s %[f4], %[f4], %[f7], %[f5] \n\t"
#endif // #if !defined(MIPS32_R2_LE)
- "lwc1 %[f5], 4(%[yf1]) \n\t"
- "add.s %[f2], %[f2], %[f8] \n\t"
- "addiu %[bRe], %[bRe], 8 \n\t"
- "addiu %[bIm], %[bIm], 8 \n\t"
- "add.s %[f3], %[f3], %[f1] \n\t"
- "add.s %[f6], %[f6], %[f9] \n\t"
- "add.s %[f5], %[f5], %[f4] \n\t"
- "swc1 %[f2], 0(%[yf0]) \n\t"
- "swc1 %[f3], 0(%[yf1]) \n\t"
- "swc1 %[f6], 4(%[yf0]) \n\t"
- "swc1 %[f5], 4(%[yf1]) \n\t"
- "addiu %[yf0], %[yf0], 8 \n\t"
- "bgtz %[len], 1b \n\t"
- " addiu %[yf1], %[yf1], 8 \n\t"
- "lwc1 %[f0], 0(%[aRe]) \n\t"
- "lwc1 %[f1], 0(%[bRe]) \n\t"
- "lwc1 %[f2], 0(%[bIm]) \n\t"
- "lwc1 %[f3], 0(%[aIm]) \n\t"
- "mul.s %[f8], %[f0], %[f1] \n\t"
- "mul.s %[f0], %[f0], %[f2] \n\t"
+ "lwc1 %[f5], 4(%[yf1]) \n\t"
+ "add.s %[f2], %[f2], %[f8] \n\t"
+ "addiu %[bRe], %[bRe], 8 \n\t"
+ "addiu %[bIm], %[bIm], 8 \n\t"
+ "add.s %[f3], %[f3], %[f1] \n\t"
+ "add.s %[f6], %[f6], %[f9] \n\t"
+ "add.s %[f5], %[f5], %[f4] \n\t"
+ "swc1 %[f2], 0(%[yf0]) \n\t"
+ "swc1 %[f3], 0(%[yf1]) \n\t"
+ "swc1 %[f6], 4(%[yf0]) \n\t"
+ "swc1 %[f5], 4(%[yf1]) \n\t"
+ "addiu %[yf0], %[yf0], 8 \n\t"
+ "bgtz %[len], 1b \n\t"
+ " addiu %[yf1], %[yf1], 8 \n\t"
+ "lwc1 %[f0], 0(%[aRe]) \n\t"
+ "lwc1 %[f1], 0(%[bRe]) \n\t"
+ "lwc1 %[f2], 0(%[bIm]) \n\t"
+ "lwc1 %[f3], 0(%[aIm]) \n\t"
+ "mul.s %[f8], %[f0], %[f1] \n\t"
+ "mul.s %[f0], %[f0], %[f2] \n\t"
#if !defined(MIPS32_R2_LE)
- "mul.s %[f12], %[f2], %[f3] \n\t"
- "mul.s %[f1], %[f3], %[f1] \n\t"
- "sub.s %[f8], %[f8], %[f12] \n\t"
- "lwc1 %[f2], 0(%[yf0]) \n\t"
- "add.s %[f1], %[f0], %[f1] \n\t"
- "lwc1 %[f3], 0(%[yf1]) \n\t"
-#else // #if !defined(MIPS32_R2_LE)
- "nmsub.s %[f8], %[f8], %[f2], %[f3] \n\t"
- "lwc1 %[f2], 0(%[yf0]) \n\t"
- "madd.s %[f1], %[f0], %[f3], %[f1] \n\t"
- "lwc1 %[f3], 0(%[yf1]) \n\t"
+ "mul.s %[f12], %[f2], %[f3] \n\t"
+ "mul.s %[f1], %[f3], %[f1] \n\t"
+ "sub.s %[f8], %[f8], %[f12] \n\t"
+ "lwc1 %[f2], 0(%[yf0]) \n\t"
+ "add.s %[f1], %[f0], %[f1] \n\t"
+ "lwc1 %[f3], 0(%[yf1]) \n\t"
+#else // #if !defined(MIPS32_R2_LE)
+ "nmsub.s %[f8], %[f8], %[f2], %[f3] \n\t"
+ "lwc1 %[f2], 0(%[yf0]) \n\t"
+ "madd.s %[f1], %[f0], %[f3], %[f1] \n\t"
+ "lwc1 %[f3], 0(%[yf1]) \n\t"
#endif // #if !defined(MIPS32_R2_LE)
- "add.s %[f2], %[f2], %[f8] \n\t"
- "add.s %[f3], %[f3], %[f1] \n\t"
- "swc1 %[f2], 0(%[yf0]) \n\t"
- "swc1 %[f3], 0(%[yf1]) \n\t"
- ".set pop \n\t"
- : [f0] "=&f" (f0), [f1] "=&f" (f1), [f2] "=&f" (f2),
- [f3] "=&f" (f3), [f4] "=&f" (f4), [f5] "=&f" (f5),
- [f6] "=&f" (f6), [f7] "=&f" (f7), [f8] "=&f" (f8),
- [f9] "=&f" (f9), [f10] "=&f" (f10), [f11] "=&f" (f11),
- [f12] "=&f" (f12), [f13] "=&f" (f13), [aRe] "+r" (aRe),
- [aIm] "+r" (aIm), [bRe] "+r" (bRe), [bIm] "+r" (bIm),
- [yf0] "+r" (yf0), [yf1] "+r" (yf1), [len] "+r" (len)
- :
- : "memory");
+ "add.s %[f2], %[f2], %[f8] \n\t"
+ "add.s %[f3], %[f3], %[f1] \n\t"
+ "swc1 %[f2], 0(%[yf0]) \n\t"
+ "swc1 %[f3], 0(%[yf1]) \n\t"
+ ".set pop \n\t"
+ : [f0] "=&f"(f0), [f1] "=&f"(f1), [f2] "=&f"(f2), [f3] "=&f"(f3),
+ [f4] "=&f"(f4), [f5] "=&f"(f5), [f6] "=&f"(f6), [f7] "=&f"(f7),
+ [f8] "=&f"(f8), [f9] "=&f"(f9), [f10] "=&f"(f10), [f11] "=&f"(f11),
+ [f12] "=&f"(f12), [f13] "=&f"(f13), [aRe] "+r"(aRe), [aIm] "+r"(aIm),
+ [bRe] "+r"(bRe), [bIm] "+r"(bIm), [yf0] "+r"(yf0), [yf1] "+r"(yf1),
+ [len] "+r"(len)
+ :
+ : "memory");
}
}
@@ -171,73 +170,71 @@
int len = PART_LEN >> 1;
__asm __volatile(
- ".set push \n\t"
- ".set noreorder \n\t"
- "addiu %[fft_tmp], %[fft], 0 \n\t"
- "1: \n\t"
- "lwc1 %[f0], 0(%[aRe]) \n\t"
- "lwc1 %[f1], 0(%[bRe]) \n\t"
- "lwc1 %[f2], 0(%[bIm]) \n\t"
- "lwc1 %[f4], 4(%[aRe]) \n\t"
- "lwc1 %[f5], 4(%[bRe]) \n\t"
- "lwc1 %[f6], 4(%[bIm]) \n\t"
- "addiu %[aRe], %[aRe], 8 \n\t"
- "addiu %[bRe], %[bRe], 8 \n\t"
- "mul.s %[f8], %[f0], %[f1] \n\t"
- "mul.s %[f0], %[f0], %[f2] \n\t"
- "lwc1 %[f3], 0(%[aIm]) \n\t"
- "mul.s %[f9], %[f4], %[f5] \n\t"
- "lwc1 %[f7], 4(%[aIm]) \n\t"
- "mul.s %[f4], %[f4], %[f6] \n\t"
+ ".set push \n\t"
+ ".set noreorder \n\t"
+ "addiu %[fft_tmp], %[fft], 0 \n\t"
+ "1: \n\t"
+ "lwc1 %[f0], 0(%[aRe]) \n\t"
+ "lwc1 %[f1], 0(%[bRe]) \n\t"
+ "lwc1 %[f2], 0(%[bIm]) \n\t"
+ "lwc1 %[f4], 4(%[aRe]) \n\t"
+ "lwc1 %[f5], 4(%[bRe]) \n\t"
+ "lwc1 %[f6], 4(%[bIm]) \n\t"
+ "addiu %[aRe], %[aRe], 8 \n\t"
+ "addiu %[bRe], %[bRe], 8 \n\t"
+ "mul.s %[f8], %[f0], %[f1] \n\t"
+ "mul.s %[f0], %[f0], %[f2] \n\t"
+ "lwc1 %[f3], 0(%[aIm]) \n\t"
+ "mul.s %[f9], %[f4], %[f5] \n\t"
+ "lwc1 %[f7], 4(%[aIm]) \n\t"
+ "mul.s %[f4], %[f4], %[f6] \n\t"
#if !defined(MIPS32_R2_LE)
- "mul.s %[f10], %[f3], %[f2] \n\t"
- "mul.s %[f1], %[f3], %[f1] \n\t"
- "mul.s %[f11], %[f7], %[f6] \n\t"
- "mul.s %[f5], %[f7], %[f5] \n\t"
- "addiu %[aIm], %[aIm], 8 \n\t"
- "addiu %[bIm], %[bIm], 8 \n\t"
- "addiu %[len], %[len], -1 \n\t"
- "add.s %[f8], %[f8], %[f10] \n\t"
- "sub.s %[f1], %[f0], %[f1] \n\t"
- "add.s %[f9], %[f9], %[f11] \n\t"
- "sub.s %[f5], %[f4], %[f5] \n\t"
-#else // #if !defined(MIPS32_R2_LE)
- "addiu %[aIm], %[aIm], 8 \n\t"
- "addiu %[bIm], %[bIm], 8 \n\t"
- "addiu %[len], %[len], -1 \n\t"
- "madd.s %[f8], %[f8], %[f3], %[f2] \n\t"
- "nmsub.s %[f1], %[f0], %[f3], %[f1] \n\t"
- "madd.s %[f9], %[f9], %[f7], %[f6] \n\t"
- "nmsub.s %[f5], %[f4], %[f7], %[f5] \n\t"
+ "mul.s %[f10], %[f3], %[f2] \n\t"
+ "mul.s %[f1], %[f3], %[f1] \n\t"
+ "mul.s %[f11], %[f7], %[f6] \n\t"
+ "mul.s %[f5], %[f7], %[f5] \n\t"
+ "addiu %[aIm], %[aIm], 8 \n\t"
+ "addiu %[bIm], %[bIm], 8 \n\t"
+ "addiu %[len], %[len], -1 \n\t"
+ "add.s %[f8], %[f8], %[f10] \n\t"
+ "sub.s %[f1], %[f0], %[f1] \n\t"
+ "add.s %[f9], %[f9], %[f11] \n\t"
+ "sub.s %[f5], %[f4], %[f5] \n\t"
+#else // #if !defined(MIPS32_R2_LE)
+ "addiu %[aIm], %[aIm], 8 \n\t"
+ "addiu %[bIm], %[bIm], 8 \n\t"
+ "addiu %[len], %[len], -1 \n\t"
+ "madd.s %[f8], %[f8], %[f3], %[f2] \n\t"
+ "nmsub.s %[f1], %[f0], %[f3], %[f1] \n\t"
+ "madd.s %[f9], %[f9], %[f7], %[f6] \n\t"
+ "nmsub.s %[f5], %[f4], %[f7], %[f5] \n\t"
#endif // #if !defined(MIPS32_R2_LE)
- "swc1 %[f8], 0(%[fft_tmp]) \n\t"
- "swc1 %[f1], 4(%[fft_tmp]) \n\t"
- "swc1 %[f9], 8(%[fft_tmp]) \n\t"
- "swc1 %[f5], 12(%[fft_tmp]) \n\t"
- "bgtz %[len], 1b \n\t"
- " addiu %[fft_tmp], %[fft_tmp], 16 \n\t"
- "lwc1 %[f0], 0(%[aRe]) \n\t"
- "lwc1 %[f1], 0(%[bRe]) \n\t"
- "lwc1 %[f2], 0(%[bIm]) \n\t"
- "lwc1 %[f3], 0(%[aIm]) \n\t"
- "mul.s %[f8], %[f0], %[f1] \n\t"
+ "swc1 %[f8], 0(%[fft_tmp]) \n\t"
+ "swc1 %[f1], 4(%[fft_tmp]) \n\t"
+ "swc1 %[f9], 8(%[fft_tmp]) \n\t"
+ "swc1 %[f5], 12(%[fft_tmp]) \n\t"
+ "bgtz %[len], 1b \n\t"
+ " addiu %[fft_tmp], %[fft_tmp], 16 \n\t"
+ "lwc1 %[f0], 0(%[aRe]) \n\t"
+ "lwc1 %[f1], 0(%[bRe]) \n\t"
+ "lwc1 %[f2], 0(%[bIm]) \n\t"
+ "lwc1 %[f3], 0(%[aIm]) \n\t"
+ "mul.s %[f8], %[f0], %[f1] \n\t"
#if !defined(MIPS32_R2_LE)
- "mul.s %[f10], %[f3], %[f2] \n\t"
- "add.s %[f8], %[f8], %[f10] \n\t"
-#else // #if !defined(MIPS32_R2_LE)
- "madd.s %[f8], %[f8], %[f3], %[f2] \n\t"
+ "mul.s %[f10], %[f3], %[f2] \n\t"
+ "add.s %[f8], %[f8], %[f10] \n\t"
+#else // #if !defined(MIPS32_R2_LE)
+ "madd.s %[f8], %[f8], %[f3], %[f2] \n\t"
#endif // #if !defined(MIPS32_R2_LE)
- "swc1 %[f8], 4(%[fft]) \n\t"
- ".set pop \n\t"
- : [f0] "=&f" (f0), [f1] "=&f" (f1), [f2] "=&f" (f2),
- [f3] "=&f" (f3), [f4] "=&f" (f4), [f5] "=&f" (f5),
- [f6] "=&f" (f6), [f7] "=&f" (f7), [f8] "=&f" (f8),
- [f9] "=&f" (f9), [f10] "=&f" (f10), [f11] "=&f" (f11),
- [f12] "=&f" (f12), [aRe] "+r" (aRe), [aIm] "+r" (aIm),
- [bRe] "+r" (bRe), [bIm] "+r" (bIm), [fft_tmp] "=&r" (fft_tmp),
- [len] "+r" (len)
- : [fft] "r" (fft)
- : "memory");
+ "swc1 %[f8], 4(%[fft]) \n\t"
+ ".set pop \n\t"
+ : [f0] "=&f"(f0), [f1] "=&f"(f1), [f2] "=&f"(f2), [f3] "=&f"(f3),
+ [f4] "=&f"(f4), [f5] "=&f"(f5), [f6] "=&f"(f6), [f7] "=&f"(f7),
+ [f8] "=&f"(f8), [f9] "=&f"(f9), [f10] "=&f"(f10), [f11] "=&f"(f11),
+ [f12] "=&f"(f12), [aRe] "+r"(aRe), [aIm] "+r"(aIm), [bRe] "+r"(bRe),
+ [bIm] "+r"(bIm), [fft_tmp] "=&r"(fft_tmp), [len] "+r"(len)
+ : [fft] "r"(fft)
+ : "memory");
ooura_fft.InverseFft(fft);
memset(fft + PART_LEN, 0, sizeof(float) * PART_LEN);
@@ -246,102 +243,101 @@
{
float scale = 2.0f / PART_LEN2;
__asm __volatile(
- ".set push \n\t"
- ".set noreorder \n\t"
- "addiu %[fft_tmp], %[fft], 0 \n\t"
- "addiu %[len], $zero, 8 \n\t"
- "1: \n\t"
- "addiu %[len], %[len], -1 \n\t"
- "lwc1 %[f0], 0(%[fft_tmp]) \n\t"
- "lwc1 %[f1], 4(%[fft_tmp]) \n\t"
- "lwc1 %[f2], 8(%[fft_tmp]) \n\t"
- "lwc1 %[f3], 12(%[fft_tmp]) \n\t"
- "mul.s %[f0], %[f0], %[scale] \n\t"
- "mul.s %[f1], %[f1], %[scale] \n\t"
- "mul.s %[f2], %[f2], %[scale] \n\t"
- "mul.s %[f3], %[f3], %[scale] \n\t"
- "lwc1 %[f4], 16(%[fft_tmp]) \n\t"
- "lwc1 %[f5], 20(%[fft_tmp]) \n\t"
- "lwc1 %[f6], 24(%[fft_tmp]) \n\t"
- "lwc1 %[f7], 28(%[fft_tmp]) \n\t"
- "mul.s %[f4], %[f4], %[scale] \n\t"
- "mul.s %[f5], %[f5], %[scale] \n\t"
- "mul.s %[f6], %[f6], %[scale] \n\t"
- "mul.s %[f7], %[f7], %[scale] \n\t"
- "swc1 %[f0], 0(%[fft_tmp]) \n\t"
- "swc1 %[f1], 4(%[fft_tmp]) \n\t"
- "swc1 %[f2], 8(%[fft_tmp]) \n\t"
- "swc1 %[f3], 12(%[fft_tmp]) \n\t"
- "swc1 %[f4], 16(%[fft_tmp]) \n\t"
- "swc1 %[f5], 20(%[fft_tmp]) \n\t"
- "swc1 %[f6], 24(%[fft_tmp]) \n\t"
- "swc1 %[f7], 28(%[fft_tmp]) \n\t"
- "bgtz %[len], 1b \n\t"
- " addiu %[fft_tmp], %[fft_tmp], 32 \n\t"
- ".set pop \n\t"
- : [f0] "=&f" (f0), [f1] "=&f" (f1), [f2] "=&f" (f2),
- [f3] "=&f" (f3), [f4] "=&f" (f4), [f5] "=&f" (f5),
- [f6] "=&f" (f6), [f7] "=&f" (f7), [len] "=&r" (len),
- [fft_tmp] "=&r" (fft_tmp)
- : [scale] "f" (scale), [fft] "r" (fft)
- : "memory");
+ ".set push \n\t"
+ ".set noreorder \n\t"
+ "addiu %[fft_tmp], %[fft], 0 \n\t"
+ "addiu %[len], $zero, 8 \n\t"
+ "1: \n\t"
+ "addiu %[len], %[len], -1 \n\t"
+ "lwc1 %[f0], 0(%[fft_tmp]) \n\t"
+ "lwc1 %[f1], 4(%[fft_tmp]) \n\t"
+ "lwc1 %[f2], 8(%[fft_tmp]) \n\t"
+ "lwc1 %[f3], 12(%[fft_tmp]) \n\t"
+ "mul.s %[f0], %[f0], %[scale] \n\t"
+ "mul.s %[f1], %[f1], %[scale] \n\t"
+ "mul.s %[f2], %[f2], %[scale] \n\t"
+ "mul.s %[f3], %[f3], %[scale] \n\t"
+ "lwc1 %[f4], 16(%[fft_tmp]) \n\t"
+ "lwc1 %[f5], 20(%[fft_tmp]) \n\t"
+ "lwc1 %[f6], 24(%[fft_tmp]) \n\t"
+ "lwc1 %[f7], 28(%[fft_tmp]) \n\t"
+ "mul.s %[f4], %[f4], %[scale] \n\t"
+ "mul.s %[f5], %[f5], %[scale] \n\t"
+ "mul.s %[f6], %[f6], %[scale] \n\t"
+ "mul.s %[f7], %[f7], %[scale] \n\t"
+ "swc1 %[f0], 0(%[fft_tmp]) \n\t"
+ "swc1 %[f1], 4(%[fft_tmp]) \n\t"
+ "swc1 %[f2], 8(%[fft_tmp]) \n\t"
+ "swc1 %[f3], 12(%[fft_tmp]) \n\t"
+ "swc1 %[f4], 16(%[fft_tmp]) \n\t"
+ "swc1 %[f5], 20(%[fft_tmp]) \n\t"
+ "swc1 %[f6], 24(%[fft_tmp]) \n\t"
+ "swc1 %[f7], 28(%[fft_tmp]) \n\t"
+ "bgtz %[len], 1b \n\t"
+ " addiu %[fft_tmp], %[fft_tmp], 32 \n\t"
+ ".set pop \n\t"
+ : [f0] "=&f"(f0), [f1] "=&f"(f1), [f2] "=&f"(f2), [f3] "=&f"(f3),
+ [f4] "=&f"(f4), [f5] "=&f"(f5), [f6] "=&f"(f6), [f7] "=&f"(f7),
+ [len] "=&r"(len), [fft_tmp] "=&r"(fft_tmp)
+ : [scale] "f"(scale), [fft] "r"(fft)
+ : "memory");
}
ooura_fft.Fft(fft);
aRe = h_fft_buf[0] + pos;
aIm = h_fft_buf[1] + pos;
__asm __volatile(
- ".set push \n\t"
- ".set noreorder \n\t"
- "addiu %[fft_tmp], %[fft], 0 \n\t"
- "addiu %[len], $zero, 31 \n\t"
- "lwc1 %[f0], 0(%[aRe]) \n\t"
- "lwc1 %[f1], 0(%[fft_tmp]) \n\t"
- "lwc1 %[f2], 256(%[aRe]) \n\t"
- "lwc1 %[f3], 4(%[fft_tmp]) \n\t"
- "lwc1 %[f4], 4(%[aRe]) \n\t"
- "lwc1 %[f5], 8(%[fft_tmp]) \n\t"
- "lwc1 %[f6], 4(%[aIm]) \n\t"
- "lwc1 %[f7], 12(%[fft_tmp]) \n\t"
- "add.s %[f0], %[f0], %[f1] \n\t"
- "add.s %[f2], %[f2], %[f3] \n\t"
- "add.s %[f4], %[f4], %[f5] \n\t"
- "add.s %[f6], %[f6], %[f7] \n\t"
- "addiu %[fft_tmp], %[fft_tmp], 16 \n\t"
- "swc1 %[f0], 0(%[aRe]) \n\t"
- "swc1 %[f2], 256(%[aRe]) \n\t"
- "swc1 %[f4], 4(%[aRe]) \n\t"
- "addiu %[aRe], %[aRe], 8 \n\t"
- "swc1 %[f6], 4(%[aIm]) \n\t"
- "addiu %[aIm], %[aIm], 8 \n\t"
- "1: \n\t"
- "lwc1 %[f0], 0(%[aRe]) \n\t"
- "lwc1 %[f1], 0(%[fft_tmp]) \n\t"
- "lwc1 %[f2], 0(%[aIm]) \n\t"
- "lwc1 %[f3], 4(%[fft_tmp]) \n\t"
- "lwc1 %[f4], 4(%[aRe]) \n\t"
- "lwc1 %[f5], 8(%[fft_tmp]) \n\t"
- "lwc1 %[f6], 4(%[aIm]) \n\t"
- "lwc1 %[f7], 12(%[fft_tmp]) \n\t"
- "add.s %[f0], %[f0], %[f1] \n\t"
- "add.s %[f2], %[f2], %[f3] \n\t"
- "add.s %[f4], %[f4], %[f5] \n\t"
- "add.s %[f6], %[f6], %[f7] \n\t"
- "addiu %[len], %[len], -1 \n\t"
- "addiu %[fft_tmp], %[fft_tmp], 16 \n\t"
- "swc1 %[f0], 0(%[aRe]) \n\t"
- "swc1 %[f2], 0(%[aIm]) \n\t"
- "swc1 %[f4], 4(%[aRe]) \n\t"
- "addiu %[aRe], %[aRe], 8 \n\t"
- "swc1 %[f6], 4(%[aIm]) \n\t"
- "bgtz %[len], 1b \n\t"
- " addiu %[aIm], %[aIm], 8 \n\t"
- ".set pop \n\t"
- : [f0] "=&f" (f0), [f1] "=&f" (f1), [f2] "=&f" (f2),
- [f3] "=&f" (f3), [f4] "=&f" (f4), [f5] "=&f" (f5),
- [f6] "=&f" (f6), [f7] "=&f" (f7), [len] "=&r" (len),
- [fft_tmp] "=&r" (fft_tmp), [aRe] "+r" (aRe), [aIm] "+r" (aIm)
- : [fft] "r" (fft)
- : "memory");
+ ".set push \n\t"
+ ".set noreorder \n\t"
+ "addiu %[fft_tmp], %[fft], 0 \n\t"
+ "addiu %[len], $zero, 31 \n\t"
+ "lwc1 %[f0], 0(%[aRe]) \n\t"
+ "lwc1 %[f1], 0(%[fft_tmp]) \n\t"
+ "lwc1 %[f2], 256(%[aRe]) \n\t"
+ "lwc1 %[f3], 4(%[fft_tmp]) \n\t"
+ "lwc1 %[f4], 4(%[aRe]) \n\t"
+ "lwc1 %[f5], 8(%[fft_tmp]) \n\t"
+ "lwc1 %[f6], 4(%[aIm]) \n\t"
+ "lwc1 %[f7], 12(%[fft_tmp]) \n\t"
+ "add.s %[f0], %[f0], %[f1] \n\t"
+ "add.s %[f2], %[f2], %[f3] \n\t"
+ "add.s %[f4], %[f4], %[f5] \n\t"
+ "add.s %[f6], %[f6], %[f7] \n\t"
+ "addiu %[fft_tmp], %[fft_tmp], 16 \n\t"
+ "swc1 %[f0], 0(%[aRe]) \n\t"
+ "swc1 %[f2], 256(%[aRe]) \n\t"
+ "swc1 %[f4], 4(%[aRe]) \n\t"
+ "addiu %[aRe], %[aRe], 8 \n\t"
+ "swc1 %[f6], 4(%[aIm]) \n\t"
+ "addiu %[aIm], %[aIm], 8 \n\t"
+ "1: \n\t"
+ "lwc1 %[f0], 0(%[aRe]) \n\t"
+ "lwc1 %[f1], 0(%[fft_tmp]) \n\t"
+ "lwc1 %[f2], 0(%[aIm]) \n\t"
+ "lwc1 %[f3], 4(%[fft_tmp]) \n\t"
+ "lwc1 %[f4], 4(%[aRe]) \n\t"
+ "lwc1 %[f5], 8(%[fft_tmp]) \n\t"
+ "lwc1 %[f6], 4(%[aIm]) \n\t"
+ "lwc1 %[f7], 12(%[fft_tmp]) \n\t"
+ "add.s %[f0], %[f0], %[f1] \n\t"
+ "add.s %[f2], %[f2], %[f3] \n\t"
+ "add.s %[f4], %[f4], %[f5] \n\t"
+ "add.s %[f6], %[f6], %[f7] \n\t"
+ "addiu %[len], %[len], -1 \n\t"
+ "addiu %[fft_tmp], %[fft_tmp], 16 \n\t"
+ "swc1 %[f0], 0(%[aRe]) \n\t"
+ "swc1 %[f2], 0(%[aIm]) \n\t"
+ "swc1 %[f4], 4(%[aRe]) \n\t"
+ "addiu %[aRe], %[aRe], 8 \n\t"
+ "swc1 %[f6], 4(%[aIm]) \n\t"
+ "bgtz %[len], 1b \n\t"
+ " addiu %[aIm], %[aIm], 8 \n\t"
+ ".set pop \n\t"
+ : [f0] "=&f"(f0), [f1] "=&f"(f1), [f2] "=&f"(f2), [f3] "=&f"(f3),
+ [f4] "=&f"(f4), [f5] "=&f"(f5), [f6] "=&f"(f6), [f7] "=&f"(f7),
+ [len] "=&r"(len), [fft_tmp] "=&r"(fft_tmp), [aRe] "+r"(aRe),
+ [aIm] "+r"(aIm)
+ : [fft] "r"(fft)
+ : "memory");
}
}
@@ -359,28 +355,28 @@
for (int i = 0; i < PART_LEN1; ++i) {
// Weight subbands
__asm __volatile(
- ".set push \n\t"
- ".set noreorder \n\t"
- "lwc1 %[temp1], 0(%[p_hNl]) \n\t"
- "lwc1 %[temp2], 0(%[p_wC]) \n\t"
- "c.lt.s %[hNlFb], %[temp1] \n\t"
- "bc1f 1f \n\t"
- " mul.s %[temp3], %[temp2], %[hNlFb] \n\t"
- "sub.s %[temp4], %[one], %[temp2] \n\t"
+ ".set push \n\t"
+ ".set noreorder \n\t"
+ "lwc1 %[temp1], 0(%[p_hNl]) \n\t"
+ "lwc1 %[temp2], 0(%[p_wC]) \n\t"
+ "c.lt.s %[hNlFb], %[temp1] \n\t"
+ "bc1f 1f \n\t"
+ " mul.s %[temp3], %[temp2], %[hNlFb] \n\t"
+ "sub.s %[temp4], %[one], %[temp2] \n\t"
#if !defined(MIPS32_R2_LE)
- "mul.s %[temp1], %[temp1], %[temp4] \n\t"
- "add.s %[temp1], %[temp3], %[temp1] \n\t"
-#else // #if !defined(MIPS32_R2_LE)
- "madd.s %[temp1], %[temp3], %[temp1], %[temp4] \n\t"
+ "mul.s %[temp1], %[temp1], %[temp4] \n\t"
+ "add.s %[temp1], %[temp3], %[temp1] \n\t"
+#else // #if !defined(MIPS32_R2_LE)
+ "madd.s %[temp1], %[temp3], %[temp1], %[temp4] \n\t"
#endif // #if !defined(MIPS32_R2_LE)
- "swc1 %[temp1], 0(%[p_hNl]) \n\t"
- "1: \n\t"
- "addiu %[p_wC], %[p_wC], 4 \n\t"
- ".set pop \n\t"
- : [temp1] "=&f" (temp1), [temp2] "=&f" (temp2), [temp3] "=&f" (temp3),
- [temp4] "=&f" (temp4), [p_wC] "+r" (p_WebRtcAec_wC)
- : [hNlFb] "f" (hNlFb), [one] "f" (one), [p_hNl] "r" (p_hNl)
- : "memory");
+ "swc1 %[temp1], 0(%[p_hNl]) \n\t"
+ "1: \n\t"
+ "addiu %[p_wC], %[p_wC], 4 \n\t"
+ ".set pop \n\t"
+ : [temp1] "=&f"(temp1), [temp2] "=&f"(temp2), [temp3] "=&f"(temp3),
+ [temp4] "=&f"(temp4), [p_wC] "+r"(p_WebRtcAec_wC)
+ : [hNlFb] "f"(hNlFb), [one] "f"(one), [p_hNl] "r"(p_hNl)
+ : "memory");
hNl[i] = powf(hNl[i], overdrive_scaling * WebRtcAec_overDriveCurve[i]);
}
@@ -399,22 +395,22 @@
for (int i = 0; i < PART_LEN1; ++i) {
__asm __volatile(
- "lwc1 %[temp1], 0(%[p_hNl]) \n\t"
- "lwc1 %[temp3], 0(%[p_efw1]) \n\t"
- "lwc1 %[temp2], 0(%[p_efw0]) \n\t"
- "addiu %[p_hNl], %[p_hNl], 4 \n\t"
- "mul.s %[temp3], %[temp3], %[temp1] \n\t"
- "mul.s %[temp2], %[temp2], %[temp1] \n\t"
- "addiu %[p_efw0], %[p_efw0], 4 \n\t"
- "addiu %[p_efw1], %[p_efw1], 4 \n\t"
- "neg.s %[temp4], %[temp3] \n\t"
- "swc1 %[temp2], -4(%[p_efw0]) \n\t"
- "swc1 %[temp4], -4(%[p_efw1]) \n\t"
- : [temp1] "=&f" (temp1), [temp2] "=&f" (temp2), [temp3] "=&f" (temp3),
- [temp4] "=&f" (temp4), [p_efw0] "+r" (p_efw0), [p_efw1] "+r" (p_efw1),
- [p_hNl] "+r" (p_hNl)
- :
- : "memory");
+ "lwc1 %[temp1], 0(%[p_hNl]) \n\t"
+ "lwc1 %[temp3], 0(%[p_efw1]) \n\t"
+ "lwc1 %[temp2], 0(%[p_efw0]) \n\t"
+ "addiu %[p_hNl], %[p_hNl], 4 \n\t"
+ "mul.s %[temp3], %[temp3], %[temp1] \n\t"
+ "mul.s %[temp2], %[temp2], %[temp1] \n\t"
+ "addiu %[p_efw0], %[p_efw0], 4 \n\t"
+ "addiu %[p_efw1], %[p_efw1], 4 \n\t"
+ "neg.s %[temp4], %[temp3] \n\t"
+ "swc1 %[temp2], -4(%[p_efw0]) \n\t"
+ "swc1 %[temp4], -4(%[p_efw1]) \n\t"
+ : [temp1] "=&f"(temp1), [temp2] "=&f"(temp2), [temp3] "=&f"(temp3),
+ [temp4] "=&f"(temp4), [p_efw0] "+r"(p_efw0), [p_efw1] "+r"(p_efw1),
+ [p_hNl] "+r"(p_hNl)
+ :
+ : "memory");
}
}
@@ -433,51 +429,50 @@
#endif
__asm __volatile(
- ".set push \n\t"
- ".set noreorder \n\t"
- "1: \n\t"
- "lwc1 %[f0], 0(%[x_pow]) \n\t"
- "lwc1 %[f1], 0(%[ef0]) \n\t"
- "lwc1 %[f2], 0(%[ef1]) \n\t"
- "add.s %[f0], %[f0], %[fac1] \n\t"
- "div.s %[f1], %[f1], %[f0] \n\t"
- "div.s %[f2], %[f2], %[f0] \n\t"
- "mul.s %[f0], %[f1], %[f1] \n\t"
+ ".set push \n\t"
+ ".set noreorder \n\t"
+ "1: \n\t"
+ "lwc1 %[f0], 0(%[x_pow]) \n\t"
+ "lwc1 %[f1], 0(%[ef0]) \n\t"
+ "lwc1 %[f2], 0(%[ef1]) \n\t"
+ "add.s %[f0], %[f0], %[fac1] \n\t"
+ "div.s %[f1], %[f1], %[f0] \n\t"
+ "div.s %[f2], %[f2], %[f0] \n\t"
+ "mul.s %[f0], %[f1], %[f1] \n\t"
#if defined(MIPS32_R2_LE)
- "madd.s %[f0], %[f0], %[f2], %[f2] \n\t"
+ "madd.s %[f0], %[f0], %[f2], %[f2] \n\t"
#else
- "mul.s %[f3], %[f2], %[f2] \n\t"
- "add.s %[f0], %[f0], %[f3] \n\t"
+ "mul.s %[f3], %[f2], %[f2] \n\t"
+ "add.s %[f0], %[f0], %[f3] \n\t"
#endif
- "c.le.s %[f0], %[err_th2] \n\t"
- "nop \n\t"
- "bc1t 2f \n\t"
- " nop \n\t"
- "sqrt.s %[f0], %[f0] \n\t"
- "add.s %[f0], %[f0], %[fac1] \n\t"
- "div.s %[f0], %[err_th], %[f0] \n\t"
- "mul.s %[f1], %[f1], %[f0] \n\t"
- "mul.s %[f2], %[f2], %[f0] \n\t"
- "2: \n\t"
- "mul.s %[f1], %[f1], %[mu] \n\t"
- "mul.s %[f2], %[f2], %[mu] \n\t"
- "swc1 %[f1], 0(%[ef0]) \n\t"
- "swc1 %[f2], 0(%[ef1]) \n\t"
- "addiu %[len], %[len], -1 \n\t"
- "addiu %[x_pow], %[x_pow], 4 \n\t"
- "addiu %[ef0], %[ef0], 4 \n\t"
- "bgtz %[len], 1b \n\t"
- " addiu %[ef1], %[ef1], 4 \n\t"
- ".set pop \n\t"
- : [f0] "=&f" (f0), [f1] "=&f" (f1), [f2] "=&f" (f2),
+ "c.le.s %[f0], %[err_th2] \n\t"
+ "nop \n\t"
+ "bc1t 2f \n\t"
+ " nop \n\t"
+ "sqrt.s %[f0], %[f0] \n\t"
+ "add.s %[f0], %[f0], %[fac1] \n\t"
+ "div.s %[f0], %[err_th], %[f0] \n\t"
+ "mul.s %[f1], %[f1], %[f0] \n\t"
+ "mul.s %[f2], %[f2], %[f0] \n\t"
+ "2: \n\t"
+ "mul.s %[f1], %[f1], %[mu] \n\t"
+ "mul.s %[f2], %[f2], %[mu] \n\t"
+ "swc1 %[f1], 0(%[ef0]) \n\t"
+ "swc1 %[f2], 0(%[ef1]) \n\t"
+ "addiu %[len], %[len], -1 \n\t"
+ "addiu %[x_pow], %[x_pow], 4 \n\t"
+ "addiu %[ef0], %[ef0], 4 \n\t"
+ "bgtz %[len], 1b \n\t"
+ " addiu %[ef1], %[ef1], 4 \n\t"
+ ".set pop \n\t"
+ : [f0] "=&f"(f0), [f1] "=&f"(f1), [f2] "=&f"(f2),
#if !defined(MIPS32_R2_LE)
- [f3] "=&f" (f3),
+ [f3] "=&f"(f3),
#endif
- [x_pow] "+r" (x_pow), [ef0] "+r" (ef0), [ef1] "+r" (ef1),
- [len] "+r" (len)
- : [fac1] "f" (fac1), [err_th2] "f" (err_th2), [mu] "f" (mu),
- [err_th] "f" (error_threshold)
- : "memory");
+ [x_pow] "+r"(x_pow), [ef0] "+r"(ef0), [ef1] "+r"(ef1), [len] "+r"(len)
+ : [fac1] "f"(fac1), [err_th2] "f"(err_th2), [mu] "f"(mu),
+ [err_th] "f"(error_threshold)
+ : "memory");
}
void WebRtcAec_InitAec_mips(void) {
diff --git a/modules/audio_processing/aec/aec_core_neon.cc b/modules/audio_processing/aec/aec_core_neon.cc
index 1fbf56b..072bd17 100644
--- a/modules/audio_processing/aec/aec_core_neon.cc
+++ b/modules/audio_processing/aec/aec_core_neon.cc
@@ -38,13 +38,12 @@
return aRe * bIm + aIm * bRe;
}
-static void FilterFarNEON(int num_partitions,
- int x_fft_buf_block_pos,
- float x_fft_buf[2]
- [kExtendedNumPartitions * PART_LEN1],
- float h_fft_buf[2]
- [kExtendedNumPartitions * PART_LEN1],
- float y_fft[2][PART_LEN1]) {
+static void FilterFarNEON(
+ int num_partitions,
+ int x_fft_buf_block_pos,
+ float x_fft_buf[2][kExtendedNumPartitions * PART_LEN1],
+ float h_fft_buf[2][kExtendedNumPartitions * PART_LEN1],
+ float y_fft[2][PART_LEN1]) {
int i;
for (i = 0; i < num_partitions; i++) {
int j;
diff --git a/modules/audio_processing/aec/aec_core_sse2.cc b/modules/audio_processing/aec/aec_core_sse2.cc
index 0532662..ede04dd 100644
--- a/modules/audio_processing/aec/aec_core_sse2.cc
+++ b/modules/audio_processing/aec/aec_core_sse2.cc
@@ -33,13 +33,12 @@
return aRe * bIm + aIm * bRe;
}
-static void FilterFarSSE2(int num_partitions,
- int x_fft_buf_block_pos,
- float x_fft_buf[2]
- [kExtendedNumPartitions * PART_LEN1],
- float h_fft_buf[2]
- [kExtendedNumPartitions * PART_LEN1],
- float y_fft[2][PART_LEN1]) {
+static void FilterFarSSE2(
+ int num_partitions,
+ int x_fft_buf_block_pos,
+ float x_fft_buf[2][kExtendedNumPartitions * PART_LEN1],
+ float h_fft_buf[2][kExtendedNumPartitions * PART_LEN1],
+ float y_fft[2][PART_LEN1]) {
int i;
for (i = 0; i < num_partitions; i++) {
int j;
@@ -257,10 +256,10 @@
_mm_and_ps(a, *(reinterpret_cast<const __m128*>(float_exponent_mask)));
const __m128 n_1 = _mm_castsi128_ps(_mm_srli_epi32(
_mm_castps_si128(two_n), shift_exponent_into_top_mantissa));
- const __m128 n_0 =
- _mm_or_ps(n_1, *(reinterpret_cast<const __m128*>(eight_biased_exponent)));
- const __m128 n =
- _mm_sub_ps(n_0, *(reinterpret_cast<const __m128*>(implicit_leading_one)));
+ const __m128 n_0 = _mm_or_ps(
+ n_1, *(reinterpret_cast<const __m128*>(eight_biased_exponent)));
+ const __m128 n = _mm_sub_ps(
+ n_0, *(reinterpret_cast<const __m128*>(implicit_leading_one)));
// Compute y.
static const ALIGN16_BEG int mantissa_mask[4] ALIGN16_END = {
@@ -269,9 +268,9 @@
0x3F800000, 0x3F800000, 0x3F800000, 0x3F800000};
const __m128 mantissa =
_mm_and_ps(a, *(reinterpret_cast<const __m128*>(mantissa_mask)));
- const __m128 y =
- _mm_or_ps(mantissa,
- *(reinterpret_cast<const __m128*>(zero_biased_exponent_is_one)));
+ const __m128 y = _mm_or_ps(
+ mantissa,
+ *(reinterpret_cast<const __m128*>(zero_biased_exponent_is_one)));
// Approximate log2(y) ~= (y - 1) * pol5(y).
// pol5(y) = C5 * y^5 + C4 * y^4 + C3 * y^3 + C2 * y^2 + C1 * y + C0
@@ -303,9 +302,8 @@
const __m128 pol5_y_8 = _mm_mul_ps(pol5_y_7, y);
const __m128 pol5_y =
_mm_add_ps(pol5_y_8, *(reinterpret_cast<const __m128*>(C0)));
- const __m128 y_minus_one =
- _mm_sub_ps(y,
- *(reinterpret_cast<const __m128*>(zero_biased_exponent_is_one)));
+ const __m128 y_minus_one = _mm_sub_ps(
+ y, *(reinterpret_cast<const __m128*>(zero_biased_exponent_is_one)));
const __m128 log2_y = _mm_mul_ps(y_minus_one, pol5_y);
// Combine parts.
diff --git a/modules/audio_processing/aec/echo_cancellation.cc b/modules/audio_processing/aec/echo_cancellation.cc
index 1633068..c8382ec 100644
--- a/modules/audio_processing/aec/echo_cancellation.cc
+++ b/modules/audio_processing/aec/echo_cancellation.cc
@@ -291,7 +291,7 @@
aecpc->farend_started = 1;
WebRtcAec_SetSystemDelay(aecpc->aec, WebRtcAec_system_delay(aecpc->aec) +
- static_cast<int>(newNrOfSamples));
+ static_cast<int>(newNrOfSamples));
// Write the time-domain data to |far_pre_buf|.
WebRtc_WriteBuffer(aecpc->far_pre_buf, farend_ptr, newNrOfSamples);
@@ -302,8 +302,8 @@
{
float* ptmp = NULL;
float tmp[PART_LEN2];
- WebRtc_ReadBuffer(aecpc->far_pre_buf,
- reinterpret_cast<void**>(&ptmp), tmp, PART_LEN2);
+ WebRtc_ReadBuffer(aecpc->far_pre_buf, reinterpret_cast<void**>(&ptmp),
+ tmp, PART_LEN2);
WebRtcAec_BufferFarendBlock(aecpc->aec, &ptmp[PART_LEN]);
}
@@ -545,9 +545,9 @@
const float minSkewEst = -0.5f;
const float maxSkewEst = 1.0f;
- reported_delay_ms =
- reported_delay_ms > kMaxTrustedDelayMs ? kMaxTrustedDelayMs :
- reported_delay_ms;
+ reported_delay_ms = reported_delay_ms > kMaxTrustedDelayMs
+ ? kMaxTrustedDelayMs
+ : reported_delay_ms;
// TODO(andrew): we need to investigate if this +10 is really wanted.
reported_delay_ms += 10;
aecInst->msInSndCardBuf = reported_delay_ms;
@@ -642,9 +642,8 @@
// for too long). When the far-end buffer is filled with
// approximately the same amount of data as reported by the system
// we end the startup phase.
- int overhead_elements =
- WebRtcAec_system_delay(aecInst->aec) / PART_LEN -
- aecInst->bufSizeStart;
+ int overhead_elements = WebRtcAec_system_delay(aecInst->aec) / PART_LEN -
+ aecInst->bufSizeStart;
if (overhead_elements == 0) {
// Enable the AEC
aecInst->startup_phase = 0;
@@ -780,10 +779,8 @@
// We use -1 to signal an initialized state in the "extended" implementation;
// compensate for that.
aecInst->filtDelay = aecInst->filtDelay < 0 ? 0 : aecInst->filtDelay;
- aecInst->filtDelay =
- WEBRTC_SPL_MAX(0, static_cast<int16_t>(0.8 *
- aecInst->filtDelay +
- 0.2 * current_delay));
+ aecInst->filtDelay = WEBRTC_SPL_MAX(
+ 0, static_cast<int16_t>(0.8 * aecInst->filtDelay + 0.2 * current_delay));
delay_difference = aecInst->filtDelay - aecInst->knownDelay;
if (delay_difference > 224) {
@@ -809,8 +806,8 @@
}
static void EstBufDelayExtended(Aec* aecInst) {
- int reported_delay = aecInst->msInSndCardBuf * sampMsNb *
- aecInst->rate_factor;
+ int reported_delay =
+ aecInst->msInSndCardBuf * sampMsNb * aecInst->rate_factor;
int current_delay = reported_delay - WebRtcAec_system_delay(aecInst->aec);
int delay_difference = 0;
@@ -839,8 +836,8 @@
aecInst->filtDelay = WEBRTC_SPL_MAX(0, 0.5 * current_delay);
} else {
aecInst->filtDelay = WEBRTC_SPL_MAX(
- 0, static_cast<int16_t>(0.95 * aecInst->filtDelay + 0.05 *
- current_delay));
+ 0,
+ static_cast<int16_t>(0.95 * aecInst->filtDelay + 0.05 * current_delay));
}
delay_difference = aecInst->filtDelay - aecInst->knownDelay;
diff --git a/modules/audio_processing/aec/system_delay_unittest.cc b/modules/audio_processing/aec/system_delay_unittest.cc
index fc57af8..e7e79fe 100644
--- a/modules/audio_processing/aec/system_delay_unittest.cc
+++ b/modules/audio_processing/aec/system_delay_unittest.cc
@@ -104,14 +104,8 @@
void SystemDelayTest::RenderAndCapture(int device_buffer_ms) {
EXPECT_EQ(0, WebRtcAec_BufferFarend(handle_, far_, samples_per_frame_));
- EXPECT_EQ(0,
- WebRtcAec_Process(handle_,
- &near_ptr_,
- 1,
- &out_ptr_,
- samples_per_frame_,
- device_buffer_ms,
- 0));
+ EXPECT_EQ(0, WebRtcAec_Process(handle_, &near_ptr_, 1, &out_ptr_,
+ samples_per_frame_, device_buffer_ms, 0));
}
size_t SystemDelayTest::BufferFillUp() {
@@ -157,16 +151,15 @@
EXPECT_GT(kStableConvergenceMs, process_time_ms);
}
// Verify that the buffer has been flushed.
- EXPECT_GE(static_cast<int>(buffer_size),
- WebRtcAec_system_delay(self_->aec));
+ EXPECT_GE(static_cast<int>(buffer_size), WebRtcAec_system_delay(self_->aec));
}
- int SystemDelayTest::MapBufferSizeToSamples(int size_in_ms,
- bool extended_filter) {
+int SystemDelayTest::MapBufferSizeToSamples(int size_in_ms,
+ bool extended_filter) {
// If extended_filter is disabled we add an extra 10 ms for the unprocessed
// frame. That is simply how the algorithm is constructed.
- return static_cast<int>(
- (size_in_ms + (extended_filter ? 0 : 10)) * samples_per_frame_ / 10);
+ return static_cast<int>((size_in_ms + (extended_filter ? 0 : 10)) *
+ samples_per_frame_ / 10);
}
// The tests should meet basic requirements and not be adjusted to what is
@@ -241,9 +234,9 @@
static_cast<int>(kDeviceBufMs * samples_per_frame_ / 10);
EXPECT_GE(average_reported_delay, WebRtcAec_system_delay(self_->aec));
int lower_bound = WebRtcAec_extended_filter_enabled(self_->aec)
- ? (average_reported_delay / 2 -
- rtc::checked_cast<int>(samples_per_frame_))
- : average_reported_delay * 3 / 4;
+ ? (average_reported_delay / 2 -
+ rtc::checked_cast<int>(samples_per_frame_))
+ : average_reported_delay * 3 / 4;
EXPECT_LE(lower_bound, WebRtcAec_system_delay(self_->aec));
}
}
@@ -322,14 +315,8 @@
// can make that assumption since we have a separate stability test.
int process_time_ms = 0;
for (; process_time_ms < kStableConvergenceMs; process_time_ms += 10) {
- EXPECT_EQ(0,
- WebRtcAec_Process(handle_,
- &near_ptr_,
- 1,
- &out_ptr_,
- samples_per_frame_,
- kDeviceBufMs,
- 0));
+ EXPECT_EQ(0, WebRtcAec_Process(handle_, &near_ptr_, 1, &out_ptr_,
+ samples_per_frame_, kDeviceBufMs, 0));
}
// Verify that a buffer size has been established.
EXPECT_EQ(0, self_->checkBuffSize);
@@ -414,8 +401,8 @@
for (int j = 0; j < 1000; j++) {
// Drift = -1 ms per 100 ms of data.
int device_buf_ms = kDeviceBufMs - (j / 10) + jump;
- int device_buf = MapBufferSizeToSamples(device_buf_ms,
- extended_filter == 1);
+ int device_buf =
+ MapBufferSizeToSamples(device_buf_ms, extended_filter == 1);
if (device_buf_ms < 30) {
// Add 10 ms data, taking affect next frame.
@@ -452,8 +439,8 @@
for (size_t i = 0; i < kNumSampleRates; i++) {
Init(kSampleRateHz[i]);
RunStableStartup();
- int device_buf = MapBufferSizeToSamples(kDeviceBufMs,
- extended_filter == 1);
+ int device_buf =
+ MapBufferSizeToSamples(kDeviceBufMs, extended_filter == 1);
// Glitch state.
for (int j = 0; j < 20; j++) {
EXPECT_EQ(0,
@@ -513,8 +500,8 @@
for (size_t i = 0; i < kNumSampleRates; i++) {
Init(kSampleRateHz[i]);
RunStableStartup();
- int device_buf = MapBufferSizeToSamples(kDeviceBufMs,
- extended_filter == 1);
+ int device_buf =
+ MapBufferSizeToSamples(kDeviceBufMs, extended_filter == 1);
// Normal state. We are currently not in a non-causal state.
bool non_causal = false;
@@ -566,8 +553,8 @@
for (size_t i = 0; i < kNumSampleRates; i++) {
Init(kSampleRateHz[i]);
RunStableStartup();
- const int device_buf = MapBufferSizeToSamples(kDeviceBufMs,
- extended_filter == 1);
+ const int device_buf =
+ MapBufferSizeToSamples(kDeviceBufMs, extended_filter == 1);
// Normal state. We are currently not in a non-causal state.
bool non_causal = false;
diff --git a/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc b/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc
index b075ff5..15717d1 100644
--- a/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc
+++ b/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc
@@ -357,9 +357,8 @@
RandomizeSampleVector(&random_generator, n);
static constexpr float kNoiseScaling = 1.f / 100.f;
- std::transform(
- y.begin(), y.end(), n.begin(), y.begin(),
- [](float a, float b) { return a + b * kNoiseScaling; });
+ std::transform(y.begin(), y.end(), n.begin(), y.begin(),
+ [](float a, float b) { return a + b * kNoiseScaling; });
x_hp_filter.Process(x[0]);
y_hp_filter.Process(y);
diff --git a/modules/audio_processing/aec3/aec3_common.cc b/modules/audio_processing/aec3/aec3_common.cc
index 7becce4..8e13055 100644
--- a/modules/audio_processing/aec3/aec3_common.cc
+++ b/modules/audio_processing/aec3/aec3_common.cc
@@ -10,8 +10,8 @@
#include "modules/audio_processing/aec3/aec3_common.h"
-#include "typedefs.h" // NOLINT(build/include)
#include "system_wrappers/include/cpu_features_wrapper.h"
+#include "typedefs.h" // NOLINT(build/include)
namespace webrtc {
diff --git a/modules/audio_processing/aec3/aec_state.cc b/modules/audio_processing/aec3/aec_state.cc
index b32ae3c..20b0580 100644
--- a/modules/audio_processing/aec3/aec_state.cc
+++ b/modules/audio_processing/aec3/aec_state.cc
@@ -387,7 +387,7 @@
} x = {in};
float out = x.a;
out *= 1.1920929e-7f; // 1/2^23
- out -= 126.942695f; // Remove bias.
+ out -= 126.942695f; // Remove bias.
return out;
};
RTC_DCHECK_GT(matching_data.size(), start_index + i);
diff --git a/modules/audio_processing/aec3/block_processor_metrics_unittest.cc b/modules/audio_processing/aec3/block_processor_metrics_unittest.cc
index 7ce8573..73f7689 100644
--- a/modules/audio_processing/aec3/block_processor_metrics_unittest.cc
+++ b/modules/audio_processing/aec3/block_processor_metrics_unittest.cc
@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "modules/audio_processing/aec3/aec3_common.h"
#include "modules/audio_processing/aec3/block_processor_metrics.h"
+#include "modules/audio_processing/aec3/aec3_common.h"
#include "test/gtest.h"
diff --git a/modules/audio_processing/aec3/echo_path_delay_estimator_unittest.cc b/modules/audio_processing/aec3/echo_path_delay_estimator_unittest.cc
index 841cdfa..0e237a5 100644
--- a/modules/audio_processing/aec3/echo_path_delay_estimator_unittest.cc
+++ b/modules/audio_processing/aec3/echo_path_delay_estimator_unittest.cc
@@ -104,9 +104,9 @@
} else {
ADD_FAILURE();
}
+ }
}
}
-}
// Verifies that the delay estimator does not produce delay estimates for render
// signals of low level.
diff --git a/modules/audio_processing/aec3/echo_remover.cc b/modules/audio_processing/aec3/echo_remover.cc
index e264d30..deae3a3 100644
--- a/modules/audio_processing/aec3/echo_remover.cc
+++ b/modules/audio_processing/aec3/echo_remover.cc
@@ -243,8 +243,6 @@
// Estimate the comfort noise.
cng_.Compute(aec_state_, Y2, &comfort_noise, &high_band_comfort_noise);
-
-
// Compute and apply the suppression gain.
suppression_gain_.GetGain(E2, R2, cng_.NoiseSpectrum(), E, X, Y,
render_signal_analyzer_, aec_state_, x,
diff --git a/modules/audio_processing/aec3/echo_remover_metrics_unittest.cc b/modules/audio_processing/aec3/echo_remover_metrics_unittest.cc
index fbd30d1..fb9f151 100644
--- a/modules/audio_processing/aec3/echo_remover_metrics_unittest.cc
+++ b/modules/audio_processing/aec3/echo_remover_metrics_unittest.cc
@@ -12,8 +12,8 @@
#include <math.h>
-#include "modules/audio_processing/aec3/aec_state.h"
#include "modules/audio_processing/aec3/aec3_fft.h"
+#include "modules/audio_processing/aec3/aec_state.h"
#include "test/gtest.h"
namespace webrtc {
@@ -78,23 +78,19 @@
// Verifies that the TransformDbMetricForReporting method is able to properly
// limit the output.
TEST(TransformDbMetricForReporting, Limits) {
- EXPECT_EQ(
- 0,
- aec3::TransformDbMetricForReporting(false, 0.f, 10.f, 0.f, 1.f, 0.001f));
- EXPECT_EQ(
- 10,
- aec3::TransformDbMetricForReporting(false, 0.f, 10.f, 0.f, 1.f, 100.f));
+ EXPECT_EQ(0, aec3::TransformDbMetricForReporting(false, 0.f, 10.f, 0.f, 1.f,
+ 0.001f));
+ EXPECT_EQ(10, aec3::TransformDbMetricForReporting(false, 0.f, 10.f, 0.f, 1.f,
+ 100.f));
}
// Verifies that the TransformDbMetricForReporting method is able to properly
// negate output.
TEST(TransformDbMetricForReporting, Negate) {
- EXPECT_EQ(
- 10,
- aec3::TransformDbMetricForReporting(true, -20.f, 20.f, 0.f, 1.f, 0.1f));
- EXPECT_EQ(
- -10,
- aec3::TransformDbMetricForReporting(true, -20.f, 20.f, 0.f, 1.f, 10.f));
+ EXPECT_EQ(10, aec3::TransformDbMetricForReporting(true, -20.f, 20.f, 0.f, 1.f,
+ 0.1f));
+ EXPECT_EQ(-10, aec3::TransformDbMetricForReporting(true, -20.f, 20.f, 0.f,
+ 1.f, 10.f));
}
// Verify the Update functionality of DbMetric.
diff --git a/modules/audio_processing/aec3/erle_estimator.cc b/modules/audio_processing/aec3/erle_estimator.cc
index 1f0429a..ab6c1c7 100644
--- a/modules/audio_processing/aec3/erle_estimator.cc
+++ b/modules/audio_processing/aec3/erle_estimator.cc
@@ -132,8 +132,8 @@
}
--hold_counter_time_domain_;
erle_time_domain_ = (hold_counter_time_domain_ > 0)
- ? erle_time_domain_
- : std::max(min_erle_, 0.97f * erle_time_domain_);
+ ? erle_time_domain_
+ : std::max(min_erle_, 0.97f * erle_time_domain_);
}
} // namespace webrtc
diff --git a/modules/audio_processing/aec3/main_filter_update_gain_unittest.cc b/modules/audio_processing/aec3/main_filter_update_gain_unittest.cc
index f398b84..ed30799 100644
--- a/modules/audio_processing/aec3/main_filter_update_gain_unittest.cc
+++ b/modules/audio_processing/aec3/main_filter_update_gain_unittest.cc
@@ -241,34 +241,34 @@
// Verifies that the magnitude of the gain on average decreases for a
// persistently exciting signal.
TEST(MainFilterUpdateGain, DecreasingGain) {
- std::vector<int> blocks_with_echo_path_changes;
- std::vector<int> blocks_with_saturation;
+ std::vector<int> blocks_with_echo_path_changes;
+ std::vector<int> blocks_with_saturation;
- std::array<float, kBlockSize> e;
- std::array<float, kBlockSize> y;
- FftData G_a;
- FftData G_b;
- FftData G_c;
- std::array<float, kFftLengthBy2Plus1> G_a_power;
- std::array<float, kFftLengthBy2Plus1> G_b_power;
- std::array<float, kFftLengthBy2Plus1> G_c_power;
+ std::array<float, kBlockSize> e;
+ std::array<float, kBlockSize> y;
+ FftData G_a;
+ FftData G_b;
+ FftData G_c;
+ std::array<float, kFftLengthBy2Plus1> G_a_power;
+ std::array<float, kFftLengthBy2Plus1> G_b_power;
+ std::array<float, kFftLengthBy2Plus1> G_c_power;
- RunFilterUpdateTest(100, 65, 12, blocks_with_echo_path_changes,
- blocks_with_saturation, false, &e, &y, &G_a);
- RunFilterUpdateTest(300, 65, 12, blocks_with_echo_path_changes,
- blocks_with_saturation, false, &e, &y, &G_b);
- RunFilterUpdateTest(600, 65, 12, blocks_with_echo_path_changes,
- blocks_with_saturation, false, &e, &y, &G_c);
+ RunFilterUpdateTest(100, 65, 12, blocks_with_echo_path_changes,
+ blocks_with_saturation, false, &e, &y, &G_a);
+ RunFilterUpdateTest(300, 65, 12, blocks_with_echo_path_changes,
+ blocks_with_saturation, false, &e, &y, &G_b);
+ RunFilterUpdateTest(600, 65, 12, blocks_with_echo_path_changes,
+ blocks_with_saturation, false, &e, &y, &G_c);
- G_a.Spectrum(Aec3Optimization::kNone, G_a_power);
- G_b.Spectrum(Aec3Optimization::kNone, G_b_power);
- G_c.Spectrum(Aec3Optimization::kNone, G_c_power);
+ G_a.Spectrum(Aec3Optimization::kNone, G_a_power);
+ G_b.Spectrum(Aec3Optimization::kNone, G_b_power);
+ G_c.Spectrum(Aec3Optimization::kNone, G_c_power);
- EXPECT_GT(std::accumulate(G_a_power.begin(), G_a_power.end(), 0.),
- std::accumulate(G_b_power.begin(), G_b_power.end(), 0.));
+ EXPECT_GT(std::accumulate(G_a_power.begin(), G_a_power.end(), 0.),
+ std::accumulate(G_b_power.begin(), G_b_power.end(), 0.));
- EXPECT_GT(std::accumulate(G_b_power.begin(), G_b_power.end(), 0.),
- std::accumulate(G_c_power.begin(), G_c_power.end(), 0.));
+ EXPECT_GT(std::accumulate(G_b_power.begin(), G_b_power.end(), 0.),
+ std::accumulate(G_c_power.begin(), G_c_power.end(), 0.));
}
// Verifies that the gain is zero when there is saturation and that the internal
diff --git a/modules/audio_processing/aec3/matched_filter_lag_aggregator_unittest.cc b/modules/audio_processing/aec3/matched_filter_lag_aggregator_unittest.cc
index 97c7f5b..cea5f13 100644
--- a/modules/audio_processing/aec3/matched_filter_lag_aggregator_unittest.cc
+++ b/modules/audio_processing/aec3/matched_filter_lag_aggregator_unittest.cc
@@ -6,7 +6,7 @@
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
- */
+ */
#include "modules/audio_processing/aec3/matched_filter_lag_aggregator.h"
diff --git a/modules/audio_processing/aec3/matched_filter_unittest.cc b/modules/audio_processing/aec3/matched_filter_unittest.cc
index c3c3a0d..fd878ff 100644
--- a/modules/audio_processing/aec3/matched_filter_unittest.cc
+++ b/modules/audio_processing/aec3/matched_filter_unittest.cc
@@ -6,7 +6,7 @@
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
- */
+ */
#include "modules/audio_processing/aec3/matched_filter.h"
diff --git a/modules/audio_processing/aec3/render_buffer.h b/modules/audio_processing/aec3/render_buffer.h
index 9419b30..34e7edf 100644
--- a/modules/audio_processing/aec3/render_buffer.h
+++ b/modules/audio_processing/aec3/render_buffer.h
@@ -82,7 +82,6 @@
return headroom;
}
-
// Returns a reference to the spectrum buffer.
const VectorBuffer& GetSpectrumBuffer() const { return *spectrum_buffer_; }
diff --git a/modules/audio_processing/aec3/residual_echo_estimator.cc b/modules/audio_processing/aec3/residual_echo_estimator.cc
index 85a15e1..ea787a4 100644
--- a/modules/audio_processing/aec3/residual_echo_estimator.cc
+++ b/modules/audio_processing/aec3/residual_echo_estimator.cc
@@ -216,7 +216,6 @@
const std::array<float, kFftLengthBy2Plus1>& X2,
const std::array<float, kFftLengthBy2Plus1>& Y2,
std::array<float, kFftLengthBy2Plus1>* R2) {
-
// Compute preliminary residual echo.
std::transform(X2.begin(), X2.end(), R2->begin(), [echo_path_gain](float a) {
return a * echo_path_gain * echo_path_gain;
diff --git a/modules/audio_processing/aec3/stationarity_estimator.cc b/modules/audio_processing/aec3/stationarity_estimator.cc
index d4e32f5..be04002 100644
--- a/modules/audio_processing/aec3/stationarity_estimator.cc
+++ b/modules/audio_processing/aec3/stationarity_estimator.cc
@@ -86,7 +86,6 @@
}
UpdateHangover();
SmoothStationaryPerFreq();
-
}
bool StationarityEstimator::EstimateBandStationarity(
diff --git a/modules/audio_processing/aec3/subtractor.h b/modules/audio_processing/aec3/subtractor.h
index 38fc3c6..33fdde5 100644
--- a/modules/audio_processing/aec3/subtractor.h
+++ b/modules/audio_processing/aec3/subtractor.h
@@ -11,8 +11,8 @@
#ifndef MODULES_AUDIO_PROCESSING_AEC3_SUBTRACTOR_H_
#define MODULES_AUDIO_PROCESSING_AEC3_SUBTRACTOR_H_
-#include <array>
#include <algorithm>
+#include <array>
#include <vector>
#include "modules/audio_processing/aec3/adaptive_fir_filter.h"
diff --git a/modules/audio_processing/aec3/suppression_gain_unittest.cc b/modules/audio_processing/aec3/suppression_gain_unittest.cc
index 7e5ee9f..4670178 100644
--- a/modules/audio_processing/aec3/suppression_gain_unittest.cc
+++ b/modules/audio_processing/aec3/suppression_gain_unittest.cc
@@ -144,7 +144,6 @@
}
std::for_each(g.begin(), g.end(),
[](float a) { EXPECT_NEAR(0.f, a, 0.001); });
-
}
} // namespace aec3
diff --git a/modules/audio_processing/aec_dump/mock_aec_dump.cc b/modules/audio_processing/aec_dump/mock_aec_dump.cc
index aa89e45..fe35d81 100644
--- a/modules/audio_processing/aec_dump/mock_aec_dump.cc
+++ b/modules/audio_processing/aec_dump/mock_aec_dump.cc
@@ -15,5 +15,5 @@
MockAecDump::MockAecDump() = default;
MockAecDump::~MockAecDump() = default;
-}
-}
+} // namespace test
+} // namespace webrtc
diff --git a/modules/audio_processing/aecm/aecm_core.cc b/modules/audio_processing/aecm/aecm_core.cc
index 3d9faca..21a2ba1 100644
--- a/modules/audio_processing/aecm/aecm_core.cc
+++ b/modules/audio_processing/aecm/aecm_core.cc
@@ -28,126 +28,97 @@
#include "typedefs.h" // NOLINT(build/include)
#ifdef AEC_DEBUG
-FILE *dfile;
-FILE *testfile;
+FILE* dfile;
+FILE* testfile;
#endif
const int16_t WebRtcAecm_kCosTable[] = {
- 8192, 8190, 8187, 8180, 8172, 8160, 8147, 8130, 8112,
- 8091, 8067, 8041, 8012, 7982, 7948, 7912, 7874, 7834,
- 7791, 7745, 7697, 7647, 7595, 7540, 7483, 7424, 7362,
- 7299, 7233, 7164, 7094, 7021, 6947, 6870, 6791, 6710,
- 6627, 6542, 6455, 6366, 6275, 6182, 6087, 5991, 5892,
- 5792, 5690, 5586, 5481, 5374, 5265, 5155, 5043, 4930,
- 4815, 4698, 4580, 4461, 4341, 4219, 4096, 3971, 3845,
- 3719, 3591, 3462, 3331, 3200, 3068, 2935, 2801, 2667,
- 2531, 2395, 2258, 2120, 1981, 1842, 1703, 1563, 1422,
- 1281, 1140, 998, 856, 713, 571, 428, 285, 142,
- 0, -142, -285, -428, -571, -713, -856, -998, -1140,
- -1281, -1422, -1563, -1703, -1842, -1981, -2120, -2258, -2395,
- -2531, -2667, -2801, -2935, -3068, -3200, -3331, -3462, -3591,
- -3719, -3845, -3971, -4095, -4219, -4341, -4461, -4580, -4698,
- -4815, -4930, -5043, -5155, -5265, -5374, -5481, -5586, -5690,
- -5792, -5892, -5991, -6087, -6182, -6275, -6366, -6455, -6542,
- -6627, -6710, -6791, -6870, -6947, -7021, -7094, -7164, -7233,
- -7299, -7362, -7424, -7483, -7540, -7595, -7647, -7697, -7745,
- -7791, -7834, -7874, -7912, -7948, -7982, -8012, -8041, -8067,
- -8091, -8112, -8130, -8147, -8160, -8172, -8180, -8187, -8190,
- -8191, -8190, -8187, -8180, -8172, -8160, -8147, -8130, -8112,
- -8091, -8067, -8041, -8012, -7982, -7948, -7912, -7874, -7834,
- -7791, -7745, -7697, -7647, -7595, -7540, -7483, -7424, -7362,
- -7299, -7233, -7164, -7094, -7021, -6947, -6870, -6791, -6710,
- -6627, -6542, -6455, -6366, -6275, -6182, -6087, -5991, -5892,
- -5792, -5690, -5586, -5481, -5374, -5265, -5155, -5043, -4930,
- -4815, -4698, -4580, -4461, -4341, -4219, -4096, -3971, -3845,
- -3719, -3591, -3462, -3331, -3200, -3068, -2935, -2801, -2667,
- -2531, -2395, -2258, -2120, -1981, -1842, -1703, -1563, -1422,
- -1281, -1140, -998, -856, -713, -571, -428, -285, -142,
- 0, 142, 285, 428, 571, 713, 856, 998, 1140,
- 1281, 1422, 1563, 1703, 1842, 1981, 2120, 2258, 2395,
- 2531, 2667, 2801, 2935, 3068, 3200, 3331, 3462, 3591,
- 3719, 3845, 3971, 4095, 4219, 4341, 4461, 4580, 4698,
- 4815, 4930, 5043, 5155, 5265, 5374, 5481, 5586, 5690,
- 5792, 5892, 5991, 6087, 6182, 6275, 6366, 6455, 6542,
- 6627, 6710, 6791, 6870, 6947, 7021, 7094, 7164, 7233,
- 7299, 7362, 7424, 7483, 7540, 7595, 7647, 7697, 7745,
- 7791, 7834, 7874, 7912, 7948, 7982, 8012, 8041, 8067,
- 8091, 8112, 8130, 8147, 8160, 8172, 8180, 8187, 8190
-};
+ 8192, 8190, 8187, 8180, 8172, 8160, 8147, 8130, 8112, 8091, 8067,
+ 8041, 8012, 7982, 7948, 7912, 7874, 7834, 7791, 7745, 7697, 7647,
+ 7595, 7540, 7483, 7424, 7362, 7299, 7233, 7164, 7094, 7021, 6947,
+ 6870, 6791, 6710, 6627, 6542, 6455, 6366, 6275, 6182, 6087, 5991,
+ 5892, 5792, 5690, 5586, 5481, 5374, 5265, 5155, 5043, 4930, 4815,
+ 4698, 4580, 4461, 4341, 4219, 4096, 3971, 3845, 3719, 3591, 3462,
+ 3331, 3200, 3068, 2935, 2801, 2667, 2531, 2395, 2258, 2120, 1981,
+ 1842, 1703, 1563, 1422, 1281, 1140, 998, 856, 713, 571, 428,
+ 285, 142, 0, -142, -285, -428, -571, -713, -856, -998, -1140,
+ -1281, -1422, -1563, -1703, -1842, -1981, -2120, -2258, -2395, -2531, -2667,
+ -2801, -2935, -3068, -3200, -3331, -3462, -3591, -3719, -3845, -3971, -4095,
+ -4219, -4341, -4461, -4580, -4698, -4815, -4930, -5043, -5155, -5265, -5374,
+ -5481, -5586, -5690, -5792, -5892, -5991, -6087, -6182, -6275, -6366, -6455,
+ -6542, -6627, -6710, -6791, -6870, -6947, -7021, -7094, -7164, -7233, -7299,
+ -7362, -7424, -7483, -7540, -7595, -7647, -7697, -7745, -7791, -7834, -7874,
+ -7912, -7948, -7982, -8012, -8041, -8067, -8091, -8112, -8130, -8147, -8160,
+ -8172, -8180, -8187, -8190, -8191, -8190, -8187, -8180, -8172, -8160, -8147,
+ -8130, -8112, -8091, -8067, -8041, -8012, -7982, -7948, -7912, -7874, -7834,
+ -7791, -7745, -7697, -7647, -7595, -7540, -7483, -7424, -7362, -7299, -7233,
+ -7164, -7094, -7021, -6947, -6870, -6791, -6710, -6627, -6542, -6455, -6366,
+ -6275, -6182, -6087, -5991, -5892, -5792, -5690, -5586, -5481, -5374, -5265,
+ -5155, -5043, -4930, -4815, -4698, -4580, -4461, -4341, -4219, -4096, -3971,
+ -3845, -3719, -3591, -3462, -3331, -3200, -3068, -2935, -2801, -2667, -2531,
+ -2395, -2258, -2120, -1981, -1842, -1703, -1563, -1422, -1281, -1140, -998,
+ -856, -713, -571, -428, -285, -142, 0, 142, 285, 428, 571,
+ 713, 856, 998, 1140, 1281, 1422, 1563, 1703, 1842, 1981, 2120,
+ 2258, 2395, 2531, 2667, 2801, 2935, 3068, 3200, 3331, 3462, 3591,
+ 3719, 3845, 3971, 4095, 4219, 4341, 4461, 4580, 4698, 4815, 4930,
+ 5043, 5155, 5265, 5374, 5481, 5586, 5690, 5792, 5892, 5991, 6087,
+ 6182, 6275, 6366, 6455, 6542, 6627, 6710, 6791, 6870, 6947, 7021,
+ 7094, 7164, 7233, 7299, 7362, 7424, 7483, 7540, 7595, 7647, 7697,
+ 7745, 7791, 7834, 7874, 7912, 7948, 7982, 8012, 8041, 8067, 8091,
+ 8112, 8130, 8147, 8160, 8172, 8180, 8187, 8190};
const int16_t WebRtcAecm_kSinTable[] = {
- 0, 142, 285, 428, 571, 713, 856, 998,
- 1140, 1281, 1422, 1563, 1703, 1842, 1981, 2120,
- 2258, 2395, 2531, 2667, 2801, 2935, 3068, 3200,
- 3331, 3462, 3591, 3719, 3845, 3971, 4095, 4219,
- 4341, 4461, 4580, 4698, 4815, 4930, 5043, 5155,
- 5265, 5374, 5481, 5586, 5690, 5792, 5892, 5991,
- 6087, 6182, 6275, 6366, 6455, 6542, 6627, 6710,
- 6791, 6870, 6947, 7021, 7094, 7164, 7233, 7299,
- 7362, 7424, 7483, 7540, 7595, 7647, 7697, 7745,
- 7791, 7834, 7874, 7912, 7948, 7982, 8012, 8041,
- 8067, 8091, 8112, 8130, 8147, 8160, 8172, 8180,
- 8187, 8190, 8191, 8190, 8187, 8180, 8172, 8160,
- 8147, 8130, 8112, 8091, 8067, 8041, 8012, 7982,
- 7948, 7912, 7874, 7834, 7791, 7745, 7697, 7647,
- 7595, 7540, 7483, 7424, 7362, 7299, 7233, 7164,
- 7094, 7021, 6947, 6870, 6791, 6710, 6627, 6542,
- 6455, 6366, 6275, 6182, 6087, 5991, 5892, 5792,
- 5690, 5586, 5481, 5374, 5265, 5155, 5043, 4930,
- 4815, 4698, 4580, 4461, 4341, 4219, 4096, 3971,
- 3845, 3719, 3591, 3462, 3331, 3200, 3068, 2935,
- 2801, 2667, 2531, 2395, 2258, 2120, 1981, 1842,
- 1703, 1563, 1422, 1281, 1140, 998, 856, 713,
- 571, 428, 285, 142, 0, -142, -285, -428,
- -571, -713, -856, -998, -1140, -1281, -1422, -1563,
- -1703, -1842, -1981, -2120, -2258, -2395, -2531, -2667,
- -2801, -2935, -3068, -3200, -3331, -3462, -3591, -3719,
- -3845, -3971, -4095, -4219, -4341, -4461, -4580, -4698,
- -4815, -4930, -5043, -5155, -5265, -5374, -5481, -5586,
- -5690, -5792, -5892, -5991, -6087, -6182, -6275, -6366,
- -6455, -6542, -6627, -6710, -6791, -6870, -6947, -7021,
- -7094, -7164, -7233, -7299, -7362, -7424, -7483, -7540,
- -7595, -7647, -7697, -7745, -7791, -7834, -7874, -7912,
- -7948, -7982, -8012, -8041, -8067, -8091, -8112, -8130,
- -8147, -8160, -8172, -8180, -8187, -8190, -8191, -8190,
- -8187, -8180, -8172, -8160, -8147, -8130, -8112, -8091,
- -8067, -8041, -8012, -7982, -7948, -7912, -7874, -7834,
- -7791, -7745, -7697, -7647, -7595, -7540, -7483, -7424,
- -7362, -7299, -7233, -7164, -7094, -7021, -6947, -6870,
- -6791, -6710, -6627, -6542, -6455, -6366, -6275, -6182,
- -6087, -5991, -5892, -5792, -5690, -5586, -5481, -5374,
- -5265, -5155, -5043, -4930, -4815, -4698, -4580, -4461,
- -4341, -4219, -4096, -3971, -3845, -3719, -3591, -3462,
- -3331, -3200, -3068, -2935, -2801, -2667, -2531, -2395,
- -2258, -2120, -1981, -1842, -1703, -1563, -1422, -1281,
- -1140, -998, -856, -713, -571, -428, -285, -142
-};
+ 0, 142, 285, 428, 571, 713, 856, 998, 1140, 1281, 1422,
+ 1563, 1703, 1842, 1981, 2120, 2258, 2395, 2531, 2667, 2801, 2935,
+ 3068, 3200, 3331, 3462, 3591, 3719, 3845, 3971, 4095, 4219, 4341,
+ 4461, 4580, 4698, 4815, 4930, 5043, 5155, 5265, 5374, 5481, 5586,
+ 5690, 5792, 5892, 5991, 6087, 6182, 6275, 6366, 6455, 6542, 6627,
+ 6710, 6791, 6870, 6947, 7021, 7094, 7164, 7233, 7299, 7362, 7424,
+ 7483, 7540, 7595, 7647, 7697, 7745, 7791, 7834, 7874, 7912, 7948,
+ 7982, 8012, 8041, 8067, 8091, 8112, 8130, 8147, 8160, 8172, 8180,
+ 8187, 8190, 8191, 8190, 8187, 8180, 8172, 8160, 8147, 8130, 8112,
+ 8091, 8067, 8041, 8012, 7982, 7948, 7912, 7874, 7834, 7791, 7745,
+ 7697, 7647, 7595, 7540, 7483, 7424, 7362, 7299, 7233, 7164, 7094,
+ 7021, 6947, 6870, 6791, 6710, 6627, 6542, 6455, 6366, 6275, 6182,
+ 6087, 5991, 5892, 5792, 5690, 5586, 5481, 5374, 5265, 5155, 5043,
+ 4930, 4815, 4698, 4580, 4461, 4341, 4219, 4096, 3971, 3845, 3719,
+ 3591, 3462, 3331, 3200, 3068, 2935, 2801, 2667, 2531, 2395, 2258,
+ 2120, 1981, 1842, 1703, 1563, 1422, 1281, 1140, 998, 856, 713,
+ 571, 428, 285, 142, 0, -142, -285, -428, -571, -713, -856,
+ -998, -1140, -1281, -1422, -1563, -1703, -1842, -1981, -2120, -2258, -2395,
+ -2531, -2667, -2801, -2935, -3068, -3200, -3331, -3462, -3591, -3719, -3845,
+ -3971, -4095, -4219, -4341, -4461, -4580, -4698, -4815, -4930, -5043, -5155,
+ -5265, -5374, -5481, -5586, -5690, -5792, -5892, -5991, -6087, -6182, -6275,
+ -6366, -6455, -6542, -6627, -6710, -6791, -6870, -6947, -7021, -7094, -7164,
+ -7233, -7299, -7362, -7424, -7483, -7540, -7595, -7647, -7697, -7745, -7791,
+ -7834, -7874, -7912, -7948, -7982, -8012, -8041, -8067, -8091, -8112, -8130,
+ -8147, -8160, -8172, -8180, -8187, -8190, -8191, -8190, -8187, -8180, -8172,
+ -8160, -8147, -8130, -8112, -8091, -8067, -8041, -8012, -7982, -7948, -7912,
+ -7874, -7834, -7791, -7745, -7697, -7647, -7595, -7540, -7483, -7424, -7362,
+ -7299, -7233, -7164, -7094, -7021, -6947, -6870, -6791, -6710, -6627, -6542,
+ -6455, -6366, -6275, -6182, -6087, -5991, -5892, -5792, -5690, -5586, -5481,
+ -5374, -5265, -5155, -5043, -4930, -4815, -4698, -4580, -4461, -4341, -4219,
+ -4096, -3971, -3845, -3719, -3591, -3462, -3331, -3200, -3068, -2935, -2801,
+ -2667, -2531, -2395, -2258, -2120, -1981, -1842, -1703, -1563, -1422, -1281,
+ -1140, -998, -856, -713, -571, -428, -285, -142};
// Initialization table for echo channel in 8 kHz
static const int16_t kChannelStored8kHz[PART_LEN1] = {
- 2040, 1815, 1590, 1498, 1405, 1395, 1385, 1418,
- 1451, 1506, 1562, 1644, 1726, 1804, 1882, 1918,
- 1953, 1982, 2010, 2025, 2040, 2034, 2027, 2021,
- 2014, 1997, 1980, 1925, 1869, 1800, 1732, 1683,
- 1635, 1604, 1572, 1545, 1517, 1481, 1444, 1405,
- 1367, 1331, 1294, 1270, 1245, 1239, 1233, 1247,
- 1260, 1282, 1303, 1338, 1373, 1407, 1441, 1470,
- 1499, 1524, 1549, 1565, 1582, 1601, 1621, 1649,
- 1676
-};
+ 2040, 1815, 1590, 1498, 1405, 1395, 1385, 1418, 1451, 1506, 1562,
+ 1644, 1726, 1804, 1882, 1918, 1953, 1982, 2010, 2025, 2040, 2034,
+ 2027, 2021, 2014, 1997, 1980, 1925, 1869, 1800, 1732, 1683, 1635,
+ 1604, 1572, 1545, 1517, 1481, 1444, 1405, 1367, 1331, 1294, 1270,
+ 1245, 1239, 1233, 1247, 1260, 1282, 1303, 1338, 1373, 1407, 1441,
+ 1470, 1499, 1524, 1549, 1565, 1582, 1601, 1621, 1649, 1676};
// Initialization table for echo channel in 16 kHz
static const int16_t kChannelStored16kHz[PART_LEN1] = {
- 2040, 1590, 1405, 1385, 1451, 1562, 1726, 1882,
- 1953, 2010, 2040, 2027, 2014, 1980, 1869, 1732,
- 1635, 1572, 1517, 1444, 1367, 1294, 1245, 1233,
- 1260, 1303, 1373, 1441, 1499, 1549, 1582, 1621,
- 1676, 1741, 1802, 1861, 1921, 1983, 2040, 2102,
- 2170, 2265, 2375, 2515, 2651, 2781, 2922, 3075,
- 3253, 3471, 3738, 3976, 4151, 4258, 4308, 4288,
- 4270, 4253, 4237, 4179, 4086, 3947, 3757, 3484,
- 3153
-};
+ 2040, 1590, 1405, 1385, 1451, 1562, 1726, 1882, 1953, 2010, 2040,
+ 2027, 2014, 1980, 1869, 1732, 1635, 1572, 1517, 1444, 1367, 1294,
+ 1245, 1233, 1260, 1303, 1373, 1441, 1499, 1549, 1582, 1621, 1676,
+ 1741, 1802, 1861, 1921, 1983, 2040, 2102, 2170, 2265, 2375, 2515,
+ 2651, 2781, 2922, 3075, 3253, 3471, 3738, 3976, 4151, 4258, 4308,
+ 4288, 4270, 4253, 4237, 4179, 4086, 3947, 3757, 3484, 3153};
// Moves the pointer to the next entry and inserts |far_spectrum| and
// corresponding Q-domain in its buffer.
@@ -168,8 +139,7 @@
// Update Q-domain buffer
self->far_q_domains[self->far_history_pos] = far_q;
// Update far end spectrum buffer
- memcpy(&(self->far_history[self->far_history_pos * PART_LEN1]),
- far_spectrum,
+ memcpy(&(self->far_history[self->far_history_pos * PART_LEN1]), far_spectrum,
sizeof(uint16_t) * PART_LEN1);
}
@@ -213,95 +183,90 @@
ResetAdaptiveChannel WebRtcAecm_ResetAdaptiveChannel;
AecmCore* WebRtcAecm_CreateCore() {
- AecmCore* aecm = static_cast<AecmCore*>(malloc(sizeof(AecmCore)));
+ AecmCore* aecm = static_cast<AecmCore*>(malloc(sizeof(AecmCore)));
- aecm->farFrameBuf = WebRtc_CreateBuffer(FRAME_LEN + PART_LEN,
- sizeof(int16_t));
- if (!aecm->farFrameBuf)
- {
- WebRtcAecm_FreeCore(aecm);
- return NULL;
- }
+ aecm->farFrameBuf =
+ WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, sizeof(int16_t));
+ if (!aecm->farFrameBuf) {
+ WebRtcAecm_FreeCore(aecm);
+ return NULL;
+ }
- aecm->nearNoisyFrameBuf = WebRtc_CreateBuffer(FRAME_LEN + PART_LEN,
- sizeof(int16_t));
- if (!aecm->nearNoisyFrameBuf)
- {
- WebRtcAecm_FreeCore(aecm);
- return NULL;
- }
+ aecm->nearNoisyFrameBuf =
+ WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, sizeof(int16_t));
+ if (!aecm->nearNoisyFrameBuf) {
+ WebRtcAecm_FreeCore(aecm);
+ return NULL;
+ }
- aecm->nearCleanFrameBuf = WebRtc_CreateBuffer(FRAME_LEN + PART_LEN,
- sizeof(int16_t));
- if (!aecm->nearCleanFrameBuf)
- {
- WebRtcAecm_FreeCore(aecm);
- return NULL;
- }
+ aecm->nearCleanFrameBuf =
+ WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, sizeof(int16_t));
+ if (!aecm->nearCleanFrameBuf) {
+ WebRtcAecm_FreeCore(aecm);
+ return NULL;
+ }
- aecm->outFrameBuf = WebRtc_CreateBuffer(FRAME_LEN + PART_LEN,
- sizeof(int16_t));
- if (!aecm->outFrameBuf)
- {
- WebRtcAecm_FreeCore(aecm);
- return NULL;
- }
+ aecm->outFrameBuf =
+ WebRtc_CreateBuffer(FRAME_LEN + PART_LEN, sizeof(int16_t));
+ if (!aecm->outFrameBuf) {
+ WebRtcAecm_FreeCore(aecm);
+ return NULL;
+ }
- aecm->delay_estimator_farend = WebRtc_CreateDelayEstimatorFarend(PART_LEN1,
- MAX_DELAY);
- if (aecm->delay_estimator_farend == NULL) {
- WebRtcAecm_FreeCore(aecm);
- return NULL;
- }
- aecm->delay_estimator =
- WebRtc_CreateDelayEstimator(aecm->delay_estimator_farend, 0);
- if (aecm->delay_estimator == NULL) {
- WebRtcAecm_FreeCore(aecm);
- return NULL;
- }
- // TODO(bjornv): Explicitly disable robust delay validation until no
- // performance regression has been established. Then remove the line.
- WebRtc_enable_robust_validation(aecm->delay_estimator, 0);
+ aecm->delay_estimator_farend =
+ WebRtc_CreateDelayEstimatorFarend(PART_LEN1, MAX_DELAY);
+ if (aecm->delay_estimator_farend == NULL) {
+ WebRtcAecm_FreeCore(aecm);
+ return NULL;
+ }
+ aecm->delay_estimator =
+ WebRtc_CreateDelayEstimator(aecm->delay_estimator_farend, 0);
+ if (aecm->delay_estimator == NULL) {
+ WebRtcAecm_FreeCore(aecm);
+ return NULL;
+ }
+ // TODO(bjornv): Explicitly disable robust delay validation until no
+ // performance regression has been established. Then remove the line.
+ WebRtc_enable_robust_validation(aecm->delay_estimator, 0);
- aecm->real_fft = WebRtcSpl_CreateRealFFT(PART_LEN_SHIFT);
- if (aecm->real_fft == NULL) {
- WebRtcAecm_FreeCore(aecm);
- return NULL;
- }
+ aecm->real_fft = WebRtcSpl_CreateRealFFT(PART_LEN_SHIFT);
+ if (aecm->real_fft == NULL) {
+ WebRtcAecm_FreeCore(aecm);
+ return NULL;
+ }
- // Init some aecm pointers. 16 and 32 byte alignment is only necessary
- // for Neon code currently.
- aecm->xBuf = (int16_t*) (((uintptr_t)aecm->xBuf_buf + 31) & ~ 31);
- aecm->dBufClean = (int16_t*) (((uintptr_t)aecm->dBufClean_buf + 31) & ~ 31);
- aecm->dBufNoisy = (int16_t*) (((uintptr_t)aecm->dBufNoisy_buf + 31) & ~ 31);
- aecm->outBuf = (int16_t*) (((uintptr_t)aecm->outBuf_buf + 15) & ~ 15);
- aecm->channelStored = (int16_t*) (((uintptr_t)
- aecm->channelStored_buf + 15) & ~ 15);
- aecm->channelAdapt16 = (int16_t*) (((uintptr_t)
- aecm->channelAdapt16_buf + 15) & ~ 15);
- aecm->channelAdapt32 = (int32_t*) (((uintptr_t)
- aecm->channelAdapt32_buf + 31) & ~ 31);
+ // Init some aecm pointers. 16 and 32 byte alignment is only necessary
+ // for Neon code currently.
+ aecm->xBuf = (int16_t*)(((uintptr_t)aecm->xBuf_buf + 31) & ~31);
+ aecm->dBufClean = (int16_t*)(((uintptr_t)aecm->dBufClean_buf + 31) & ~31);
+ aecm->dBufNoisy = (int16_t*)(((uintptr_t)aecm->dBufNoisy_buf + 31) & ~31);
+ aecm->outBuf = (int16_t*)(((uintptr_t)aecm->outBuf_buf + 15) & ~15);
+ aecm->channelStored =
+ (int16_t*)(((uintptr_t)aecm->channelStored_buf + 15) & ~15);
+ aecm->channelAdapt16 =
+ (int16_t*)(((uintptr_t)aecm->channelAdapt16_buf + 15) & ~15);
+ aecm->channelAdapt32 =
+ (int32_t*)(((uintptr_t)aecm->channelAdapt32_buf + 31) & ~31);
- return aecm;
+ return aecm;
}
void WebRtcAecm_InitEchoPathCore(AecmCore* aecm, const int16_t* echo_path) {
- int i = 0;
+ int i = 0;
- // Reset the stored channel
- memcpy(aecm->channelStored, echo_path, sizeof(int16_t) * PART_LEN1);
- // Reset the adapted channels
- memcpy(aecm->channelAdapt16, echo_path, sizeof(int16_t) * PART_LEN1);
- for (i = 0; i < PART_LEN1; i++)
- {
- aecm->channelAdapt32[i] = (int32_t)aecm->channelAdapt16[i] << 16;
- }
+ // Reset the stored channel
+ memcpy(aecm->channelStored, echo_path, sizeof(int16_t) * PART_LEN1);
+ // Reset the adapted channels
+ memcpy(aecm->channelAdapt16, echo_path, sizeof(int16_t) * PART_LEN1);
+ for (i = 0; i < PART_LEN1; i++) {
+ aecm->channelAdapt32[i] = (int32_t)aecm->channelAdapt16[i] << 16;
+ }
- // Reset channel storing variables
- aecm->mseAdaptOld = 1000;
- aecm->mseStoredOld = 1000;
- aecm->mseThreshold = WEBRTC_SPL_WORD32_MAX;
- aecm->mseChannelCount = 0;
+ // Reset channel storing variables
+ aecm->mseAdaptOld = 1000;
+ aecm->mseStoredOld = 1000;
+ aecm->mseThreshold = WEBRTC_SPL_WORD32_MAX;
+ aecm->mseChannelCount = 0;
}
static void CalcLinearEnergiesC(AecmCore* aecm,
@@ -310,65 +275,61 @@
uint32_t* far_energy,
uint32_t* echo_energy_adapt,
uint32_t* echo_energy_stored) {
- int i;
+ int i;
- // Get energy for the delayed far end signal and estimated
- // echo using both stored and adapted channels.
- for (i = 0; i < PART_LEN1; i++)
- {
- echo_est[i] = WEBRTC_SPL_MUL_16_U16(aecm->channelStored[i],
- far_spectrum[i]);
- (*far_energy) += (uint32_t)(far_spectrum[i]);
- *echo_energy_adapt += aecm->channelAdapt16[i] * far_spectrum[i];
- (*echo_energy_stored) += (uint32_t)echo_est[i];
- }
+ // Get energy for the delayed far end signal and estimated
+ // echo using both stored and adapted channels.
+ for (i = 0; i < PART_LEN1; i++) {
+ echo_est[i] =
+ WEBRTC_SPL_MUL_16_U16(aecm->channelStored[i], far_spectrum[i]);
+ (*far_energy) += (uint32_t)(far_spectrum[i]);
+ *echo_energy_adapt += aecm->channelAdapt16[i] * far_spectrum[i];
+ (*echo_energy_stored) += (uint32_t)echo_est[i];
+ }
}
static void StoreAdaptiveChannelC(AecmCore* aecm,
const uint16_t* far_spectrum,
int32_t* echo_est) {
- int i;
+ int i;
- // During startup we store the channel every block.
- memcpy(aecm->channelStored, aecm->channelAdapt16, sizeof(int16_t) * PART_LEN1);
- // Recalculate echo estimate
- for (i = 0; i < PART_LEN; i += 4)
- {
- echo_est[i] = WEBRTC_SPL_MUL_16_U16(aecm->channelStored[i],
- far_spectrum[i]);
- echo_est[i + 1] = WEBRTC_SPL_MUL_16_U16(aecm->channelStored[i + 1],
- far_spectrum[i + 1]);
- echo_est[i + 2] = WEBRTC_SPL_MUL_16_U16(aecm->channelStored[i + 2],
- far_spectrum[i + 2]);
- echo_est[i + 3] = WEBRTC_SPL_MUL_16_U16(aecm->channelStored[i + 3],
- far_spectrum[i + 3]);
- }
- echo_est[i] = WEBRTC_SPL_MUL_16_U16(aecm->channelStored[i],
- far_spectrum[i]);
+ // During startup we store the channel every block.
+ memcpy(aecm->channelStored, aecm->channelAdapt16,
+ sizeof(int16_t) * PART_LEN1);
+ // Recalculate echo estimate
+ for (i = 0; i < PART_LEN; i += 4) {
+ echo_est[i] =
+ WEBRTC_SPL_MUL_16_U16(aecm->channelStored[i], far_spectrum[i]);
+ echo_est[i + 1] =
+ WEBRTC_SPL_MUL_16_U16(aecm->channelStored[i + 1], far_spectrum[i + 1]);
+ echo_est[i + 2] =
+ WEBRTC_SPL_MUL_16_U16(aecm->channelStored[i + 2], far_spectrum[i + 2]);
+ echo_est[i + 3] =
+ WEBRTC_SPL_MUL_16_U16(aecm->channelStored[i + 3], far_spectrum[i + 3]);
+ }
+ echo_est[i] = WEBRTC_SPL_MUL_16_U16(aecm->channelStored[i], far_spectrum[i]);
}
static void ResetAdaptiveChannelC(AecmCore* aecm) {
- int i;
+ int i;
- // The stored channel has a significantly lower MSE than the adaptive one for
- // two consecutive calculations. Reset the adaptive channel.
- memcpy(aecm->channelAdapt16, aecm->channelStored,
- sizeof(int16_t) * PART_LEN1);
- // Restore the W32 channel
- for (i = 0; i < PART_LEN; i += 4)
- {
- aecm->channelAdapt32[i] = (int32_t)aecm->channelStored[i] << 16;
- aecm->channelAdapt32[i + 1] = (int32_t)aecm->channelStored[i + 1] << 16;
- aecm->channelAdapt32[i + 2] = (int32_t)aecm->channelStored[i + 2] << 16;
- aecm->channelAdapt32[i + 3] = (int32_t)aecm->channelStored[i + 3] << 16;
- }
+ // The stored channel has a significantly lower MSE than the adaptive one for
+ // two consecutive calculations. Reset the adaptive channel.
+ memcpy(aecm->channelAdapt16, aecm->channelStored,
+ sizeof(int16_t) * PART_LEN1);
+ // Restore the W32 channel
+ for (i = 0; i < PART_LEN; i += 4) {
aecm->channelAdapt32[i] = (int32_t)aecm->channelStored[i] << 16;
+ aecm->channelAdapt32[i + 1] = (int32_t)aecm->channelStored[i + 1] << 16;
+ aecm->channelAdapt32[i + 2] = (int32_t)aecm->channelStored[i + 2] << 16;
+ aecm->channelAdapt32[i + 3] = (int32_t)aecm->channelStored[i + 3] << 16;
+ }
+ aecm->channelAdapt32[i] = (int32_t)aecm->channelStored[i] << 16;
}
// Initialize function pointers for ARM Neon platform.
#if defined(WEBRTC_HAS_NEON)
-static void WebRtcAecm_InitNeon(void)
-{
+static void WebRtcAecm_InitNeon(void) {
WebRtcAecm_StoreAdaptiveChannel = WebRtcAecm_StoreAdaptiveChannelNeon;
WebRtcAecm_ResetAdaptiveChannel = WebRtcAecm_ResetAdaptiveChannelNeon;
WebRtcAecm_CalcLinearEnergies = WebRtcAecm_CalcLinearEnergiesNeon;
@@ -377,8 +338,7 @@
// Initialize function pointers for MIPS platform.
#if defined(MIPS32_LE)
-static void WebRtcAecm_InitMips(void)
-{
+static void WebRtcAecm_InitMips(void) {
#if defined(MIPS_DSP_R1_LE)
WebRtcAecm_StoreAdaptiveChannel = WebRtcAecm_StoreAdaptiveChannel_mips;
WebRtcAecm_ResetAdaptiveChannel = WebRtcAecm_ResetAdaptiveChannel_mips;
@@ -389,8 +349,8 @@
// WebRtcAecm_InitCore(...)
//
-// This function initializes the AECM instant created with WebRtcAecm_CreateCore(...)
-// Input:
+// This function initializes the AECM instant created with
+// WebRtcAecm_CreateCore(...) Input:
// - aecm : Pointer to the Echo Suppression instance
// - samplingFreq : Sampling Frequency
//
@@ -401,152 +361,147 @@
// -1 - Error
//
int WebRtcAecm_InitCore(AecmCore* const aecm, int samplingFreq) {
- int i = 0;
- int32_t tmp32 = PART_LEN1 * PART_LEN1;
- int16_t tmp16 = PART_LEN1;
+ int i = 0;
+ int32_t tmp32 = PART_LEN1 * PART_LEN1;
+ int16_t tmp16 = PART_LEN1;
- if (samplingFreq != 8000 && samplingFreq != 16000)
- {
- samplingFreq = 8000;
- return -1;
- }
- // sanity check of sampling frequency
- aecm->mult = (int16_t)samplingFreq / 8000;
+ if (samplingFreq != 8000 && samplingFreq != 16000) {
+ samplingFreq = 8000;
+ return -1;
+ }
+ // sanity check of sampling frequency
+ aecm->mult = (int16_t)samplingFreq / 8000;
- aecm->farBufWritePos = 0;
- aecm->farBufReadPos = 0;
- aecm->knownDelay = 0;
- aecm->lastKnownDelay = 0;
+ aecm->farBufWritePos = 0;
+ aecm->farBufReadPos = 0;
+ aecm->knownDelay = 0;
+ aecm->lastKnownDelay = 0;
- WebRtc_InitBuffer(aecm->farFrameBuf);
- WebRtc_InitBuffer(aecm->nearNoisyFrameBuf);
- WebRtc_InitBuffer(aecm->nearCleanFrameBuf);
- WebRtc_InitBuffer(aecm->outFrameBuf);
+ WebRtc_InitBuffer(aecm->farFrameBuf);
+ WebRtc_InitBuffer(aecm->nearNoisyFrameBuf);
+ WebRtc_InitBuffer(aecm->nearCleanFrameBuf);
+ WebRtc_InitBuffer(aecm->outFrameBuf);
- memset(aecm->xBuf_buf, 0, sizeof(aecm->xBuf_buf));
- memset(aecm->dBufClean_buf, 0, sizeof(aecm->dBufClean_buf));
- memset(aecm->dBufNoisy_buf, 0, sizeof(aecm->dBufNoisy_buf));
- memset(aecm->outBuf_buf, 0, sizeof(aecm->outBuf_buf));
+ memset(aecm->xBuf_buf, 0, sizeof(aecm->xBuf_buf));
+ memset(aecm->dBufClean_buf, 0, sizeof(aecm->dBufClean_buf));
+ memset(aecm->dBufNoisy_buf, 0, sizeof(aecm->dBufNoisy_buf));
+ memset(aecm->outBuf_buf, 0, sizeof(aecm->outBuf_buf));
- aecm->seed = 666;
- aecm->totCount = 0;
+ aecm->seed = 666;
+ aecm->totCount = 0;
- if (WebRtc_InitDelayEstimatorFarend(aecm->delay_estimator_farend) != 0) {
- return -1;
- }
- if (WebRtc_InitDelayEstimator(aecm->delay_estimator) != 0) {
- return -1;
- }
- // Set far end histories to zero
- memset(aecm->far_history, 0, sizeof(uint16_t) * PART_LEN1 * MAX_DELAY);
- memset(aecm->far_q_domains, 0, sizeof(int) * MAX_DELAY);
- aecm->far_history_pos = MAX_DELAY;
+ if (WebRtc_InitDelayEstimatorFarend(aecm->delay_estimator_farend) != 0) {
+ return -1;
+ }
+ if (WebRtc_InitDelayEstimator(aecm->delay_estimator) != 0) {
+ return -1;
+ }
+ // Set far end histories to zero
+ memset(aecm->far_history, 0, sizeof(uint16_t) * PART_LEN1 * MAX_DELAY);
+ memset(aecm->far_q_domains, 0, sizeof(int) * MAX_DELAY);
+ aecm->far_history_pos = MAX_DELAY;
- aecm->nlpFlag = 1;
- aecm->fixedDelay = -1;
+ aecm->nlpFlag = 1;
+ aecm->fixedDelay = -1;
- aecm->dfaCleanQDomain = 0;
- aecm->dfaCleanQDomainOld = 0;
- aecm->dfaNoisyQDomain = 0;
- aecm->dfaNoisyQDomainOld = 0;
+ aecm->dfaCleanQDomain = 0;
+ aecm->dfaCleanQDomainOld = 0;
+ aecm->dfaNoisyQDomain = 0;
+ aecm->dfaNoisyQDomainOld = 0;
- memset(aecm->nearLogEnergy, 0, sizeof(aecm->nearLogEnergy));
- aecm->farLogEnergy = 0;
- memset(aecm->echoAdaptLogEnergy, 0, sizeof(aecm->echoAdaptLogEnergy));
- memset(aecm->echoStoredLogEnergy, 0, sizeof(aecm->echoStoredLogEnergy));
+ memset(aecm->nearLogEnergy, 0, sizeof(aecm->nearLogEnergy));
+ aecm->farLogEnergy = 0;
+ memset(aecm->echoAdaptLogEnergy, 0, sizeof(aecm->echoAdaptLogEnergy));
+ memset(aecm->echoStoredLogEnergy, 0, sizeof(aecm->echoStoredLogEnergy));
- // Initialize the echo channels with a stored shape.
- if (samplingFreq == 8000)
- {
- WebRtcAecm_InitEchoPathCore(aecm, kChannelStored8kHz);
- }
- else
- {
- WebRtcAecm_InitEchoPathCore(aecm, kChannelStored16kHz);
- }
+ // Initialize the echo channels with a stored shape.
+ if (samplingFreq == 8000) {
+ WebRtcAecm_InitEchoPathCore(aecm, kChannelStored8kHz);
+ } else {
+ WebRtcAecm_InitEchoPathCore(aecm, kChannelStored16kHz);
+ }
- memset(aecm->echoFilt, 0, sizeof(aecm->echoFilt));
- memset(aecm->nearFilt, 0, sizeof(aecm->nearFilt));
- aecm->noiseEstCtr = 0;
+ memset(aecm->echoFilt, 0, sizeof(aecm->echoFilt));
+ memset(aecm->nearFilt, 0, sizeof(aecm->nearFilt));
+ aecm->noiseEstCtr = 0;
- aecm->cngMode = AecmTrue;
+ aecm->cngMode = AecmTrue;
- memset(aecm->noiseEstTooLowCtr, 0, sizeof(aecm->noiseEstTooLowCtr));
- memset(aecm->noiseEstTooHighCtr, 0, sizeof(aecm->noiseEstTooHighCtr));
- // Shape the initial noise level to an approximate pink noise.
- for (i = 0; i < (PART_LEN1 >> 1) - 1; i++)
- {
- aecm->noiseEst[i] = (tmp32 << 8);
- tmp16--;
- tmp32 -= (int32_t)((tmp16 << 1) + 1);
- }
- for (; i < PART_LEN1; i++)
- {
- aecm->noiseEst[i] = (tmp32 << 8);
- }
+ memset(aecm->noiseEstTooLowCtr, 0, sizeof(aecm->noiseEstTooLowCtr));
+ memset(aecm->noiseEstTooHighCtr, 0, sizeof(aecm->noiseEstTooHighCtr));
+ // Shape the initial noise level to an approximate pink noise.
+ for (i = 0; i < (PART_LEN1 >> 1) - 1; i++) {
+ aecm->noiseEst[i] = (tmp32 << 8);
+ tmp16--;
+ tmp32 -= (int32_t)((tmp16 << 1) + 1);
+ }
+ for (; i < PART_LEN1; i++) {
+ aecm->noiseEst[i] = (tmp32 << 8);
+ }
- aecm->farEnergyMin = WEBRTC_SPL_WORD16_MAX;
- aecm->farEnergyMax = WEBRTC_SPL_WORD16_MIN;
- aecm->farEnergyMaxMin = 0;
- aecm->farEnergyVAD = FAR_ENERGY_MIN; // This prevents false speech detection at the
- // beginning.
- aecm->farEnergyMSE = 0;
- aecm->currentVADValue = 0;
- aecm->vadUpdateCount = 0;
- aecm->firstVAD = 1;
+ aecm->farEnergyMin = WEBRTC_SPL_WORD16_MAX;
+ aecm->farEnergyMax = WEBRTC_SPL_WORD16_MIN;
+ aecm->farEnergyMaxMin = 0;
+ aecm->farEnergyVAD =
+ FAR_ENERGY_MIN; // This prevents false speech detection at the
+ // beginning.
+ aecm->farEnergyMSE = 0;
+ aecm->currentVADValue = 0;
+ aecm->vadUpdateCount = 0;
+ aecm->firstVAD = 1;
- aecm->startupState = 0;
- aecm->supGain = SUPGAIN_DEFAULT;
- aecm->supGainOld = SUPGAIN_DEFAULT;
+ aecm->startupState = 0;
+ aecm->supGain = SUPGAIN_DEFAULT;
+ aecm->supGainOld = SUPGAIN_DEFAULT;
- aecm->supGainErrParamA = SUPGAIN_ERROR_PARAM_A;
- aecm->supGainErrParamD = SUPGAIN_ERROR_PARAM_D;
- aecm->supGainErrParamDiffAB = SUPGAIN_ERROR_PARAM_A - SUPGAIN_ERROR_PARAM_B;
- aecm->supGainErrParamDiffBD = SUPGAIN_ERROR_PARAM_B - SUPGAIN_ERROR_PARAM_D;
+ aecm->supGainErrParamA = SUPGAIN_ERROR_PARAM_A;
+ aecm->supGainErrParamD = SUPGAIN_ERROR_PARAM_D;
+ aecm->supGainErrParamDiffAB = SUPGAIN_ERROR_PARAM_A - SUPGAIN_ERROR_PARAM_B;
+ aecm->supGainErrParamDiffBD = SUPGAIN_ERROR_PARAM_B - SUPGAIN_ERROR_PARAM_D;
- // Assert a preprocessor definition at compile-time. It's an assumption
- // used in assembly code, so check the assembly files before any change.
- static_assert(PART_LEN % 16 == 0, "PART_LEN is not a multiple of 16");
+ // Assert a preprocessor definition at compile-time. It's an assumption
+ // used in assembly code, so check the assembly files before any change.
+ static_assert(PART_LEN % 16 == 0, "PART_LEN is not a multiple of 16");
- // Initialize function pointers.
- WebRtcAecm_CalcLinearEnergies = CalcLinearEnergiesC;
- WebRtcAecm_StoreAdaptiveChannel = StoreAdaptiveChannelC;
- WebRtcAecm_ResetAdaptiveChannel = ResetAdaptiveChannelC;
+ // Initialize function pointers.
+ WebRtcAecm_CalcLinearEnergies = CalcLinearEnergiesC;
+ WebRtcAecm_StoreAdaptiveChannel = StoreAdaptiveChannelC;
+ WebRtcAecm_ResetAdaptiveChannel = ResetAdaptiveChannelC;
#if defined(WEBRTC_HAS_NEON)
- WebRtcAecm_InitNeon();
+ WebRtcAecm_InitNeon();
#endif
#if defined(MIPS32_LE)
- WebRtcAecm_InitMips();
+ WebRtcAecm_InitMips();
#endif
- return 0;
+ return 0;
}
// TODO(bjornv): This function is currently not used. Add support for these
// parameters from a higher level
int WebRtcAecm_Control(AecmCore* aecm, int delay, int nlpFlag) {
- aecm->nlpFlag = nlpFlag;
- aecm->fixedDelay = delay;
+ aecm->nlpFlag = nlpFlag;
+ aecm->fixedDelay = delay;
- return 0;
+ return 0;
}
void WebRtcAecm_FreeCore(AecmCore* aecm) {
- if (aecm == NULL) {
- return;
- }
+ if (aecm == NULL) {
+ return;
+ }
- WebRtc_FreeBuffer(aecm->farFrameBuf);
- WebRtc_FreeBuffer(aecm->nearNoisyFrameBuf);
- WebRtc_FreeBuffer(aecm->nearCleanFrameBuf);
- WebRtc_FreeBuffer(aecm->outFrameBuf);
+ WebRtc_FreeBuffer(aecm->farFrameBuf);
+ WebRtc_FreeBuffer(aecm->nearNoisyFrameBuf);
+ WebRtc_FreeBuffer(aecm->nearCleanFrameBuf);
+ WebRtc_FreeBuffer(aecm->outFrameBuf);
- WebRtc_FreeDelayEstimator(aecm->delay_estimator);
- WebRtc_FreeDelayEstimatorFarend(aecm->delay_estimator_farend);
- WebRtcSpl_FreeRealFFT(aecm->real_fft);
+ WebRtc_FreeDelayEstimator(aecm->delay_estimator);
+ WebRtc_FreeDelayEstimatorFarend(aecm->delay_estimator_farend);
+ WebRtcSpl_FreeRealFFT(aecm->real_fft);
- free(aecm);
+ free(aecm);
}
int WebRtcAecm_ProcessFrame(AecmCore* aecm,
@@ -554,89 +509,72 @@
const int16_t* nearendNoisy,
const int16_t* nearendClean,
int16_t* out) {
- int16_t outBlock_buf[PART_LEN + 8]; // Align buffer to 8-byte boundary.
- int16_t* outBlock = (int16_t*) (((uintptr_t) outBlock_buf + 15) & ~ 15);
+ int16_t outBlock_buf[PART_LEN + 8]; // Align buffer to 8-byte boundary.
+ int16_t* outBlock = (int16_t*)(((uintptr_t)outBlock_buf + 15) & ~15);
- int16_t farFrame[FRAME_LEN];
- const int16_t* out_ptr = NULL;
- int size = 0;
+ int16_t farFrame[FRAME_LEN];
+ const int16_t* out_ptr = NULL;
+ int size = 0;
- // Buffer the current frame.
- // Fetch an older one corresponding to the delay.
- WebRtcAecm_BufferFarFrame(aecm, farend, FRAME_LEN);
- WebRtcAecm_FetchFarFrame(aecm, farFrame, FRAME_LEN, aecm->knownDelay);
+ // Buffer the current frame.
+ // Fetch an older one corresponding to the delay.
+ WebRtcAecm_BufferFarFrame(aecm, farend, FRAME_LEN);
+ WebRtcAecm_FetchFarFrame(aecm, farFrame, FRAME_LEN, aecm->knownDelay);
- // Buffer the synchronized far and near frames,
- // to pass the smaller blocks individually.
- WebRtc_WriteBuffer(aecm->farFrameBuf, farFrame, FRAME_LEN);
- WebRtc_WriteBuffer(aecm->nearNoisyFrameBuf, nearendNoisy, FRAME_LEN);
- if (nearendClean != NULL)
- {
- WebRtc_WriteBuffer(aecm->nearCleanFrameBuf, nearendClean, FRAME_LEN);
+ // Buffer the synchronized far and near frames,
+ // to pass the smaller blocks individually.
+ WebRtc_WriteBuffer(aecm->farFrameBuf, farFrame, FRAME_LEN);
+ WebRtc_WriteBuffer(aecm->nearNoisyFrameBuf, nearendNoisy, FRAME_LEN);
+ if (nearendClean != NULL) {
+ WebRtc_WriteBuffer(aecm->nearCleanFrameBuf, nearendClean, FRAME_LEN);
+ }
+
+ // Process as many blocks as possible.
+ while (WebRtc_available_read(aecm->farFrameBuf) >= PART_LEN) {
+ int16_t far_block[PART_LEN];
+ const int16_t* far_block_ptr = NULL;
+ int16_t near_noisy_block[PART_LEN];
+ const int16_t* near_noisy_block_ptr = NULL;
+
+ WebRtc_ReadBuffer(aecm->farFrameBuf, (void**)&far_block_ptr, far_block,
+ PART_LEN);
+ WebRtc_ReadBuffer(aecm->nearNoisyFrameBuf, (void**)&near_noisy_block_ptr,
+ near_noisy_block, PART_LEN);
+ if (nearendClean != NULL) {
+ int16_t near_clean_block[PART_LEN];
+ const int16_t* near_clean_block_ptr = NULL;
+
+ WebRtc_ReadBuffer(aecm->nearCleanFrameBuf, (void**)&near_clean_block_ptr,
+ near_clean_block, PART_LEN);
+ if (WebRtcAecm_ProcessBlock(aecm, far_block_ptr, near_noisy_block_ptr,
+ near_clean_block_ptr, outBlock) == -1) {
+ return -1;
+ }
+ } else {
+ if (WebRtcAecm_ProcessBlock(aecm, far_block_ptr, near_noisy_block_ptr,
+ NULL, outBlock) == -1) {
+ return -1;
+ }
}
- // Process as many blocks as possible.
- while (WebRtc_available_read(aecm->farFrameBuf) >= PART_LEN)
- {
- int16_t far_block[PART_LEN];
- const int16_t* far_block_ptr = NULL;
- int16_t near_noisy_block[PART_LEN];
- const int16_t* near_noisy_block_ptr = NULL;
+ WebRtc_WriteBuffer(aecm->outFrameBuf, outBlock, PART_LEN);
+ }
- WebRtc_ReadBuffer(aecm->farFrameBuf, (void**) &far_block_ptr, far_block,
- PART_LEN);
- WebRtc_ReadBuffer(aecm->nearNoisyFrameBuf,
- (void**) &near_noisy_block_ptr,
- near_noisy_block,
- PART_LEN);
- if (nearendClean != NULL)
- {
- int16_t near_clean_block[PART_LEN];
- const int16_t* near_clean_block_ptr = NULL;
+ // Stuff the out buffer if we have less than a frame to output.
+ // This should only happen for the first frame.
+ size = (int)WebRtc_available_read(aecm->outFrameBuf);
+ if (size < FRAME_LEN) {
+ WebRtc_MoveReadPtr(aecm->outFrameBuf, size - FRAME_LEN);
+ }
- WebRtc_ReadBuffer(aecm->nearCleanFrameBuf,
- (void**) &near_clean_block_ptr,
- near_clean_block,
- PART_LEN);
- if (WebRtcAecm_ProcessBlock(aecm,
- far_block_ptr,
- near_noisy_block_ptr,
- near_clean_block_ptr,
- outBlock) == -1)
- {
- return -1;
- }
- } else
- {
- if (WebRtcAecm_ProcessBlock(aecm,
- far_block_ptr,
- near_noisy_block_ptr,
- NULL,
- outBlock) == -1)
- {
- return -1;
- }
- }
+ // Obtain an output frame.
+ WebRtc_ReadBuffer(aecm->outFrameBuf, (void**)&out_ptr, out, FRAME_LEN);
+ if (out_ptr != out) {
+ // ReadBuffer() hasn't copied to |out| in this case.
+ memcpy(out, out_ptr, FRAME_LEN * sizeof(int16_t));
+ }
- WebRtc_WriteBuffer(aecm->outFrameBuf, outBlock, PART_LEN);
- }
-
- // Stuff the out buffer if we have less than a frame to output.
- // This should only happen for the first frame.
- size = (int) WebRtc_available_read(aecm->outFrameBuf);
- if (size < FRAME_LEN)
- {
- WebRtc_MoveReadPtr(aecm->outFrameBuf, size - FRAME_LEN);
- }
-
- // Obtain an output frame.
- WebRtc_ReadBuffer(aecm->outFrameBuf, (void**) &out_ptr, out, FRAME_LEN);
- if (out_ptr != out) {
- // ReadBuffer() hasn't copied to |out| in this case.
- memcpy(out, out_ptr, FRAME_LEN * sizeof(int16_t));
- }
-
- return 0;
+ return 0;
}
// WebRtcAecm_AsymFilt(...)
@@ -653,26 +591,23 @@
//
// Return: - Filtered value.
//
-int16_t WebRtcAecm_AsymFilt(const int16_t filtOld, const int16_t inVal,
+int16_t WebRtcAecm_AsymFilt(const int16_t filtOld,
+ const int16_t inVal,
const int16_t stepSizePos,
- const int16_t stepSizeNeg)
-{
- int16_t retVal;
+ const int16_t stepSizeNeg) {
+ int16_t retVal;
- if ((filtOld == WEBRTC_SPL_WORD16_MAX) | (filtOld == WEBRTC_SPL_WORD16_MIN))
- {
- return inVal;
- }
- retVal = filtOld;
- if (filtOld > inVal)
- {
- retVal -= (filtOld - inVal) >> stepSizeNeg;
- } else
- {
- retVal += (inVal - filtOld) >> stepSizePos;
- }
+ if ((filtOld == WEBRTC_SPL_WORD16_MAX) | (filtOld == WEBRTC_SPL_WORD16_MIN)) {
+ return inVal;
+ }
+ retVal = filtOld;
+ if (filtOld > inVal) {
+ retVal -= (filtOld - inVal) >> stepSizeNeg;
+ } else {
+ retVal += (inVal - filtOld) >> stepSizePos;
+ }
- return retVal;
+ return retVal;
}
// ExtractFractionPart(a, zeros)
@@ -700,8 +635,9 @@
// WebRtcAecm_CalcEnergies(...)
//
-// This function calculates the log of energies for nearend, farend and estimated
-// echoes. There is also an update of energy decision levels, i.e. internal VAD.
+// This function calculates the log of energies for nearend, farend and
+// estimated echoes. There is also an update of energy decision levels, i.e.
+// internal VAD.
//
//
// @param aecm [i/o] Handle of the AECM instance.
@@ -716,123 +652,112 @@
const int16_t far_q,
const uint32_t nearEner,
int32_t* echoEst) {
- // Local variables
- uint32_t tmpAdapt = 0;
- uint32_t tmpStored = 0;
- uint32_t tmpFar = 0;
+ // Local variables
+ uint32_t tmpAdapt = 0;
+ uint32_t tmpStored = 0;
+ uint32_t tmpFar = 0;
- int i;
+ int i;
- int16_t tmp16;
- int16_t increase_max_shifts = 4;
- int16_t decrease_max_shifts = 11;
- int16_t increase_min_shifts = 11;
- int16_t decrease_min_shifts = 3;
+ int16_t tmp16;
+ int16_t increase_max_shifts = 4;
+ int16_t decrease_max_shifts = 11;
+ int16_t increase_min_shifts = 11;
+ int16_t decrease_min_shifts = 3;
- // Get log of near end energy and store in buffer
+ // Get log of near end energy and store in buffer
- // Shift buffer
- memmove(aecm->nearLogEnergy + 1, aecm->nearLogEnergy,
- sizeof(int16_t) * (MAX_BUF_LEN - 1));
+ // Shift buffer
+ memmove(aecm->nearLogEnergy + 1, aecm->nearLogEnergy,
+ sizeof(int16_t) * (MAX_BUF_LEN - 1));
- // Logarithm of integrated magnitude spectrum (nearEner)
- aecm->nearLogEnergy[0] = LogOfEnergyInQ8(nearEner, aecm->dfaNoisyQDomain);
+ // Logarithm of integrated magnitude spectrum (nearEner)
+ aecm->nearLogEnergy[0] = LogOfEnergyInQ8(nearEner, aecm->dfaNoisyQDomain);
- WebRtcAecm_CalcLinearEnergies(aecm, far_spectrum, echoEst, &tmpFar, &tmpAdapt, &tmpStored);
+ WebRtcAecm_CalcLinearEnergies(aecm, far_spectrum, echoEst, &tmpFar, &tmpAdapt,
+ &tmpStored);
- // Shift buffers
- memmove(aecm->echoAdaptLogEnergy + 1, aecm->echoAdaptLogEnergy,
- sizeof(int16_t) * (MAX_BUF_LEN - 1));
- memmove(aecm->echoStoredLogEnergy + 1, aecm->echoStoredLogEnergy,
- sizeof(int16_t) * (MAX_BUF_LEN - 1));
+ // Shift buffers
+ memmove(aecm->echoAdaptLogEnergy + 1, aecm->echoAdaptLogEnergy,
+ sizeof(int16_t) * (MAX_BUF_LEN - 1));
+ memmove(aecm->echoStoredLogEnergy + 1, aecm->echoStoredLogEnergy,
+ sizeof(int16_t) * (MAX_BUF_LEN - 1));
- // Logarithm of delayed far end energy
- aecm->farLogEnergy = LogOfEnergyInQ8(tmpFar, far_q);
+ // Logarithm of delayed far end energy
+ aecm->farLogEnergy = LogOfEnergyInQ8(tmpFar, far_q);
- // Logarithm of estimated echo energy through adapted channel
- aecm->echoAdaptLogEnergy[0] = LogOfEnergyInQ8(tmpAdapt,
- RESOLUTION_CHANNEL16 + far_q);
+ // Logarithm of estimated echo energy through adapted channel
+ aecm->echoAdaptLogEnergy[0] =
+ LogOfEnergyInQ8(tmpAdapt, RESOLUTION_CHANNEL16 + far_q);
- // Logarithm of estimated echo energy through stored channel
- aecm->echoStoredLogEnergy[0] =
- LogOfEnergyInQ8(tmpStored, RESOLUTION_CHANNEL16 + far_q);
+ // Logarithm of estimated echo energy through stored channel
+ aecm->echoStoredLogEnergy[0] =
+ LogOfEnergyInQ8(tmpStored, RESOLUTION_CHANNEL16 + far_q);
- // Update farend energy levels (min, max, vad, mse)
- if (aecm->farLogEnergy > FAR_ENERGY_MIN)
- {
- if (aecm->startupState == 0)
- {
- increase_max_shifts = 2;
- decrease_min_shifts = 2;
- increase_min_shifts = 8;
- }
-
- aecm->farEnergyMin = WebRtcAecm_AsymFilt(aecm->farEnergyMin, aecm->farLogEnergy,
- increase_min_shifts, decrease_min_shifts);
- aecm->farEnergyMax = WebRtcAecm_AsymFilt(aecm->farEnergyMax, aecm->farLogEnergy,
- increase_max_shifts, decrease_max_shifts);
- aecm->farEnergyMaxMin = (aecm->farEnergyMax - aecm->farEnergyMin);
-
- // Dynamic VAD region size
- tmp16 = 2560 - aecm->farEnergyMin;
- if (tmp16 > 0)
- {
- tmp16 = (int16_t)((tmp16 * FAR_ENERGY_VAD_REGION) >> 9);
- } else
- {
- tmp16 = 0;
- }
- tmp16 += FAR_ENERGY_VAD_REGION;
-
- if ((aecm->startupState == 0) | (aecm->vadUpdateCount > 1024))
- {
- // In startup phase or VAD update halted
- aecm->farEnergyVAD = aecm->farEnergyMin + tmp16;
- } else
- {
- if (aecm->farEnergyVAD > aecm->farLogEnergy)
- {
- aecm->farEnergyVAD +=
- (aecm->farLogEnergy + tmp16 - aecm->farEnergyVAD) >> 6;
- aecm->vadUpdateCount = 0;
- } else
- {
- aecm->vadUpdateCount++;
- }
- }
- // Put MSE threshold higher than VAD
- aecm->farEnergyMSE = aecm->farEnergyVAD + (1 << 8);
+ // Update farend energy levels (min, max, vad, mse)
+ if (aecm->farLogEnergy > FAR_ENERGY_MIN) {
+ if (aecm->startupState == 0) {
+ increase_max_shifts = 2;
+ decrease_min_shifts = 2;
+ increase_min_shifts = 8;
}
- // Update VAD variables
- if (aecm->farLogEnergy > aecm->farEnergyVAD)
- {
- if ((aecm->startupState == 0) | (aecm->farEnergyMaxMin > FAR_ENERGY_DIFF))
- {
- // We are in startup or have significant dynamics in input speech level
- aecm->currentVADValue = 1;
- }
- } else
- {
- aecm->currentVADValue = 0;
+ aecm->farEnergyMin =
+ WebRtcAecm_AsymFilt(aecm->farEnergyMin, aecm->farLogEnergy,
+ increase_min_shifts, decrease_min_shifts);
+ aecm->farEnergyMax =
+ WebRtcAecm_AsymFilt(aecm->farEnergyMax, aecm->farLogEnergy,
+ increase_max_shifts, decrease_max_shifts);
+ aecm->farEnergyMaxMin = (aecm->farEnergyMax - aecm->farEnergyMin);
+
+ // Dynamic VAD region size
+ tmp16 = 2560 - aecm->farEnergyMin;
+ if (tmp16 > 0) {
+ tmp16 = (int16_t)((tmp16 * FAR_ENERGY_VAD_REGION) >> 9);
+ } else {
+ tmp16 = 0;
}
- if ((aecm->currentVADValue) && (aecm->firstVAD))
- {
- aecm->firstVAD = 0;
- if (aecm->echoAdaptLogEnergy[0] > aecm->nearLogEnergy[0])
- {
- // The estimated echo has higher energy than the near end signal.
- // This means that the initialization was too aggressive. Scale
- // down by a factor 8
- for (i = 0; i < PART_LEN1; i++)
- {
- aecm->channelAdapt16[i] >>= 3;
- }
- // Compensate the adapted echo energy level accordingly.
- aecm->echoAdaptLogEnergy[0] -= (3 << 8);
- aecm->firstVAD = 1;
- }
+ tmp16 += FAR_ENERGY_VAD_REGION;
+
+ if ((aecm->startupState == 0) | (aecm->vadUpdateCount > 1024)) {
+ // In startup phase or VAD update halted
+ aecm->farEnergyVAD = aecm->farEnergyMin + tmp16;
+ } else {
+ if (aecm->farEnergyVAD > aecm->farLogEnergy) {
+ aecm->farEnergyVAD +=
+ (aecm->farLogEnergy + tmp16 - aecm->farEnergyVAD) >> 6;
+ aecm->vadUpdateCount = 0;
+ } else {
+ aecm->vadUpdateCount++;
+ }
}
+ // Put MSE threshold higher than VAD
+ aecm->farEnergyMSE = aecm->farEnergyVAD + (1 << 8);
+ }
+
+ // Update VAD variables
+ if (aecm->farLogEnergy > aecm->farEnergyVAD) {
+ if ((aecm->startupState == 0) | (aecm->farEnergyMaxMin > FAR_ENERGY_DIFF)) {
+ // We are in startup or have significant dynamics in input speech level
+ aecm->currentVADValue = 1;
+ }
+ } else {
+ aecm->currentVADValue = 0;
+ }
+ if ((aecm->currentVADValue) && (aecm->firstVAD)) {
+ aecm->firstVAD = 0;
+ if (aecm->echoAdaptLogEnergy[0] > aecm->nearLogEnergy[0]) {
+ // The estimated echo has higher energy than the near end signal.
+ // This means that the initialization was too aggressive. Scale
+ // down by a factor 8
+ for (i = 0; i < PART_LEN1; i++) {
+ aecm->channelAdapt16[i] >>= 3;
+ }
+ // Compensate the adapted echo energy level accordingly.
+ aecm->echoAdaptLogEnergy[0] -= (3 << 8);
+ aecm->firstVAD = 1;
+ }
+ }
}
// WebRtcAecm_CalcStepSize(...)
@@ -841,52 +766,50 @@
//
//
// @param aecm [in] Handle of the AECM instance.
-// @param mu [out] (Return value) Stepsize in log2(), i.e. number of shifts.
+// @param mu [out] (Return value) Stepsize in log2(), i.e. number of
+// shifts.
//
//
int16_t WebRtcAecm_CalcStepSize(AecmCore* const aecm) {
- int32_t tmp32;
- int16_t tmp16;
- int16_t mu = MU_MAX;
+ int32_t tmp32;
+ int16_t tmp16;
+ int16_t mu = MU_MAX;
- // Here we calculate the step size mu used in the
- // following NLMS based Channel estimation algorithm
- if (!aecm->currentVADValue)
- {
- // Far end energy level too low, no channel update
- mu = 0;
- } else if (aecm->startupState > 0)
- {
- if (aecm->farEnergyMin >= aecm->farEnergyMax)
- {
- mu = MU_MIN;
- } else
- {
- tmp16 = (aecm->farLogEnergy - aecm->farEnergyMin);
- tmp32 = tmp16 * MU_DIFF;
- tmp32 = WebRtcSpl_DivW32W16(tmp32, aecm->farEnergyMaxMin);
- mu = MU_MIN - 1 - (int16_t)(tmp32);
- // The -1 is an alternative to rounding. This way we get a larger
- // stepsize, so we in some sense compensate for truncation in NLMS
- }
- if (mu < MU_MAX)
- {
- mu = MU_MAX; // Equivalent with maximum step size of 2^-MU_MAX
- }
+ // Here we calculate the step size mu used in the
+ // following NLMS based Channel estimation algorithm
+ if (!aecm->currentVADValue) {
+ // Far end energy level too low, no channel update
+ mu = 0;
+ } else if (aecm->startupState > 0) {
+ if (aecm->farEnergyMin >= aecm->farEnergyMax) {
+ mu = MU_MIN;
+ } else {
+ tmp16 = (aecm->farLogEnergy - aecm->farEnergyMin);
+ tmp32 = tmp16 * MU_DIFF;
+ tmp32 = WebRtcSpl_DivW32W16(tmp32, aecm->farEnergyMaxMin);
+ mu = MU_MIN - 1 - (int16_t)(tmp32);
+ // The -1 is an alternative to rounding. This way we get a larger
+ // stepsize, so we in some sense compensate for truncation in NLMS
}
+ if (mu < MU_MAX) {
+ mu = MU_MAX; // Equivalent with maximum step size of 2^-MU_MAX
+ }
+ }
- return mu;
+ return mu;
}
// WebRtcAecm_UpdateChannel(...)
//
-// This function performs channel estimation. NLMS and decision on channel storage.
+// This function performs channel estimation. NLMS and decision on channel
+// storage.
//
//
// @param aecm [i/o] Handle of the AECM instance.
// @param far_spectrum [in] Absolute value of the farend signal in Q(far_q)
// @param far_q [in] Q-domain of the farend signal
-// @param dfa [in] Absolute value of the nearend signal (Q[aecm->dfaQDomain])
+// @param dfa [in] Absolute value of the nearend signal
+// (Q[aecm->dfaQDomain])
// @param mu [in] NLMS step size.
// @param echoEst [i/o] Estimated echo in Q(far_q+RESOLUTION_CHANNEL16).
//
@@ -896,343 +819,301 @@
const uint16_t* const dfa,
const int16_t mu,
int32_t* echoEst) {
- uint32_t tmpU32no1, tmpU32no2;
- int32_t tmp32no1, tmp32no2;
- int32_t mseStored;
- int32_t mseAdapt;
+ uint32_t tmpU32no1, tmpU32no2;
+ int32_t tmp32no1, tmp32no2;
+ int32_t mseStored;
+ int32_t mseAdapt;
- int i;
+ int i;
- int16_t zerosFar, zerosNum, zerosCh, zerosDfa;
- int16_t shiftChFar, shiftNum, shift2ResChan;
- int16_t tmp16no1;
- int16_t xfaQ, dfaQ;
+ int16_t zerosFar, zerosNum, zerosCh, zerosDfa;
+ int16_t shiftChFar, shiftNum, shift2ResChan;
+ int16_t tmp16no1;
+ int16_t xfaQ, dfaQ;
- // This is the channel estimation algorithm. It is base on NLMS but has a variable step
- // length, which was calculated above.
- if (mu)
- {
- for (i = 0; i < PART_LEN1; i++)
- {
- // Determine norm of channel and farend to make sure we don't get overflow in
- // multiplication
- zerosCh = WebRtcSpl_NormU32(aecm->channelAdapt32[i]);
- zerosFar = WebRtcSpl_NormU32((uint32_t)far_spectrum[i]);
- if (zerosCh + zerosFar > 31)
- {
- // Multiplication is safe
- tmpU32no1 = WEBRTC_SPL_UMUL_32_16(aecm->channelAdapt32[i],
- far_spectrum[i]);
- shiftChFar = 0;
- } else
- {
- // We need to shift down before multiplication
- shiftChFar = 32 - zerosCh - zerosFar;
- // If zerosCh == zerosFar == 0, shiftChFar is 32. A
- // right shift of 32 is undefined. To avoid that, we
- // do this check.
- tmpU32no1 = rtc::dchecked_cast<uint32_t>(
- shiftChFar >= 32
- ? 0
- : aecm->channelAdapt32[i] >> shiftChFar) *
- far_spectrum[i];
- }
- // Determine Q-domain of numerator
- zerosNum = WebRtcSpl_NormU32(tmpU32no1);
- if (dfa[i])
- {
- zerosDfa = WebRtcSpl_NormU32((uint32_t)dfa[i]);
- } else
- {
- zerosDfa = 32;
- }
- tmp16no1 = zerosDfa - 2 + aecm->dfaNoisyQDomain -
- RESOLUTION_CHANNEL32 - far_q + shiftChFar;
- if (zerosNum > tmp16no1 + 1)
- {
- xfaQ = tmp16no1;
- dfaQ = zerosDfa - 2;
- } else
- {
- xfaQ = zerosNum - 2;
- dfaQ = RESOLUTION_CHANNEL32 + far_q - aecm->dfaNoisyQDomain -
- shiftChFar + xfaQ;
- }
- // Add in the same Q-domain
- tmpU32no1 = WEBRTC_SPL_SHIFT_W32(tmpU32no1, xfaQ);
- tmpU32no2 = WEBRTC_SPL_SHIFT_W32((uint32_t)dfa[i], dfaQ);
- tmp32no1 = (int32_t)tmpU32no2 - (int32_t)tmpU32no1;
- zerosNum = WebRtcSpl_NormW32(tmp32no1);
- if ((tmp32no1) && (far_spectrum[i] > (CHANNEL_VAD << far_q)))
- {
- //
- // Update is needed
- //
- // This is what we would like to compute
- //
- // tmp32no1 = dfa[i] - (aecm->channelAdapt[i] * far_spectrum[i])
- // tmp32norm = (i + 1)
- // aecm->channelAdapt[i] += (2^mu) * tmp32no1
- // / (tmp32norm * far_spectrum[i])
- //
+ // This is the channel estimation algorithm. It is base on NLMS but has a
+ // variable step length, which was calculated above.
+ if (mu) {
+ for (i = 0; i < PART_LEN1; i++) {
+ // Determine norm of channel and farend to make sure we don't get overflow
+ // in multiplication
+ zerosCh = WebRtcSpl_NormU32(aecm->channelAdapt32[i]);
+ zerosFar = WebRtcSpl_NormU32((uint32_t)far_spectrum[i]);
+ if (zerosCh + zerosFar > 31) {
+ // Multiplication is safe
+ tmpU32no1 =
+ WEBRTC_SPL_UMUL_32_16(aecm->channelAdapt32[i], far_spectrum[i]);
+ shiftChFar = 0;
+ } else {
+ // We need to shift down before multiplication
+ shiftChFar = 32 - zerosCh - zerosFar;
+ // If zerosCh == zerosFar == 0, shiftChFar is 32. A
+ // right shift of 32 is undefined. To avoid that, we
+ // do this check.
+ tmpU32no1 =
+ rtc::dchecked_cast<uint32_t>(
+ shiftChFar >= 32 ? 0 : aecm->channelAdapt32[i] >> shiftChFar) *
+ far_spectrum[i];
+ }
+ // Determine Q-domain of numerator
+ zerosNum = WebRtcSpl_NormU32(tmpU32no1);
+ if (dfa[i]) {
+ zerosDfa = WebRtcSpl_NormU32((uint32_t)dfa[i]);
+ } else {
+ zerosDfa = 32;
+ }
+ tmp16no1 = zerosDfa - 2 + aecm->dfaNoisyQDomain - RESOLUTION_CHANNEL32 -
+ far_q + shiftChFar;
+ if (zerosNum > tmp16no1 + 1) {
+ xfaQ = tmp16no1;
+ dfaQ = zerosDfa - 2;
+ } else {
+ xfaQ = zerosNum - 2;
+ dfaQ = RESOLUTION_CHANNEL32 + far_q - aecm->dfaNoisyQDomain -
+ shiftChFar + xfaQ;
+ }
+ // Add in the same Q-domain
+ tmpU32no1 = WEBRTC_SPL_SHIFT_W32(tmpU32no1, xfaQ);
+ tmpU32no2 = WEBRTC_SPL_SHIFT_W32((uint32_t)dfa[i], dfaQ);
+ tmp32no1 = (int32_t)tmpU32no2 - (int32_t)tmpU32no1;
+ zerosNum = WebRtcSpl_NormW32(tmp32no1);
+ if ((tmp32no1) && (far_spectrum[i] > (CHANNEL_VAD << far_q))) {
+ //
+ // Update is needed
+ //
+ // This is what we would like to compute
+ //
+ // tmp32no1 = dfa[i] - (aecm->channelAdapt[i] * far_spectrum[i])
+ // tmp32norm = (i + 1)
+ // aecm->channelAdapt[i] += (2^mu) * tmp32no1
+ // / (tmp32norm * far_spectrum[i])
+ //
- // Make sure we don't get overflow in multiplication.
- if (zerosNum + zerosFar > 31)
- {
- if (tmp32no1 > 0)
- {
- tmp32no2 = (int32_t)WEBRTC_SPL_UMUL_32_16(tmp32no1,
- far_spectrum[i]);
- } else
- {
- tmp32no2 = -(int32_t)WEBRTC_SPL_UMUL_32_16(-tmp32no1,
- far_spectrum[i]);
- }
- shiftNum = 0;
- } else
- {
- shiftNum = 32 - (zerosNum + zerosFar);
- if (tmp32no1 > 0)
- {
- tmp32no2 = (tmp32no1 >> shiftNum) * far_spectrum[i];
- } else
- {
- tmp32no2 = -((-tmp32no1 >> shiftNum) * far_spectrum[i]);
- }
- }
- // Normalize with respect to frequency bin
- tmp32no2 = WebRtcSpl_DivW32W16(tmp32no2, i + 1);
- // Make sure we are in the right Q-domain
- shift2ResChan = shiftNum + shiftChFar - xfaQ - mu - ((30 - zerosFar) << 1);
- if (WebRtcSpl_NormW32(tmp32no2) < shift2ResChan)
- {
- tmp32no2 = WEBRTC_SPL_WORD32_MAX;
- } else
- {
- tmp32no2 = WEBRTC_SPL_SHIFT_W32(tmp32no2, shift2ResChan);
- }
- aecm->channelAdapt32[i] =
- WebRtcSpl_AddSatW32(aecm->channelAdapt32[i], tmp32no2);
- if (aecm->channelAdapt32[i] < 0)
- {
- // We can never have negative channel gain
- aecm->channelAdapt32[i] = 0;
- }
- aecm->channelAdapt16[i] =
- (int16_t)(aecm->channelAdapt32[i] >> 16);
- }
+ // Make sure we don't get overflow in multiplication.
+ if (zerosNum + zerosFar > 31) {
+ if (tmp32no1 > 0) {
+ tmp32no2 =
+ (int32_t)WEBRTC_SPL_UMUL_32_16(tmp32no1, far_spectrum[i]);
+ } else {
+ tmp32no2 =
+ -(int32_t)WEBRTC_SPL_UMUL_32_16(-tmp32no1, far_spectrum[i]);
+ }
+ shiftNum = 0;
+ } else {
+ shiftNum = 32 - (zerosNum + zerosFar);
+ if (tmp32no1 > 0) {
+ tmp32no2 = (tmp32no1 >> shiftNum) * far_spectrum[i];
+ } else {
+ tmp32no2 = -((-tmp32no1 >> shiftNum) * far_spectrum[i]);
+ }
}
+ // Normalize with respect to frequency bin
+ tmp32no2 = WebRtcSpl_DivW32W16(tmp32no2, i + 1);
+ // Make sure we are in the right Q-domain
+ shift2ResChan =
+ shiftNum + shiftChFar - xfaQ - mu - ((30 - zerosFar) << 1);
+ if (WebRtcSpl_NormW32(tmp32no2) < shift2ResChan) {
+ tmp32no2 = WEBRTC_SPL_WORD32_MAX;
+ } else {
+ tmp32no2 = WEBRTC_SPL_SHIFT_W32(tmp32no2, shift2ResChan);
+ }
+ aecm->channelAdapt32[i] =
+ WebRtcSpl_AddSatW32(aecm->channelAdapt32[i], tmp32no2);
+ if (aecm->channelAdapt32[i] < 0) {
+ // We can never have negative channel gain
+ aecm->channelAdapt32[i] = 0;
+ }
+ aecm->channelAdapt16[i] = (int16_t)(aecm->channelAdapt32[i] >> 16);
+ }
}
- // END: Adaptive channel update
+ }
+ // END: Adaptive channel update
- // Determine if we should store or restore the channel
- if ((aecm->startupState == 0) & (aecm->currentVADValue))
- {
- // During startup we store the channel every block,
- // and we recalculate echo estimate
+ // Determine if we should store or restore the channel
+ if ((aecm->startupState == 0) & (aecm->currentVADValue)) {
+ // During startup we store the channel every block,
+ // and we recalculate echo estimate
+ WebRtcAecm_StoreAdaptiveChannel(aecm, far_spectrum, echoEst);
+ } else {
+ if (aecm->farLogEnergy < aecm->farEnergyMSE) {
+ aecm->mseChannelCount = 0;
+ } else {
+ aecm->mseChannelCount++;
+ }
+ // Enough data for validation. Store channel if we can.
+ if (aecm->mseChannelCount >= (MIN_MSE_COUNT + 10)) {
+ // We have enough data.
+ // Calculate MSE of "Adapt" and "Stored" versions.
+ // It is actually not MSE, but average absolute error.
+ mseStored = 0;
+ mseAdapt = 0;
+ for (i = 0; i < MIN_MSE_COUNT; i++) {
+ tmp32no1 = ((int32_t)aecm->echoStoredLogEnergy[i] -
+ (int32_t)aecm->nearLogEnergy[i]);
+ tmp32no2 = WEBRTC_SPL_ABS_W32(tmp32no1);
+ mseStored += tmp32no2;
+
+ tmp32no1 = ((int32_t)aecm->echoAdaptLogEnergy[i] -
+ (int32_t)aecm->nearLogEnergy[i]);
+ tmp32no2 = WEBRTC_SPL_ABS_W32(tmp32no1);
+ mseAdapt += tmp32no2;
+ }
+ if (((mseStored << MSE_RESOLUTION) < (MIN_MSE_DIFF * mseAdapt)) &
+ ((aecm->mseStoredOld << MSE_RESOLUTION) <
+ (MIN_MSE_DIFF * aecm->mseAdaptOld))) {
+ // The stored channel has a significantly lower MSE than the adaptive
+ // one for two consecutive calculations. Reset the adaptive channel.
+ WebRtcAecm_ResetAdaptiveChannel(aecm);
+ } else if (((MIN_MSE_DIFF * mseStored) > (mseAdapt << MSE_RESOLUTION)) &
+ (mseAdapt < aecm->mseThreshold) &
+ (aecm->mseAdaptOld < aecm->mseThreshold)) {
+ // The adaptive channel has a significantly lower MSE than the stored
+ // one. The MSE for the adaptive channel has also been low for two
+ // consecutive calculations. Store the adaptive channel.
WebRtcAecm_StoreAdaptiveChannel(aecm, far_spectrum, echoEst);
- } else
- {
- if (aecm->farLogEnergy < aecm->farEnergyMSE)
- {
- aecm->mseChannelCount = 0;
- } else
- {
- aecm->mseChannelCount++;
+
+ // Update threshold
+ if (aecm->mseThreshold == WEBRTC_SPL_WORD32_MAX) {
+ aecm->mseThreshold = (mseAdapt + aecm->mseAdaptOld);
+ } else {
+ int scaled_threshold = aecm->mseThreshold * 5 / 8;
+ aecm->mseThreshold += ((mseAdapt - scaled_threshold) * 205) >> 8;
}
- // Enough data for validation. Store channel if we can.
- if (aecm->mseChannelCount >= (MIN_MSE_COUNT + 10))
- {
- // We have enough data.
- // Calculate MSE of "Adapt" and "Stored" versions.
- // It is actually not MSE, but average absolute error.
- mseStored = 0;
- mseAdapt = 0;
- for (i = 0; i < MIN_MSE_COUNT; i++)
- {
- tmp32no1 = ((int32_t)aecm->echoStoredLogEnergy[i]
- - (int32_t)aecm->nearLogEnergy[i]);
- tmp32no2 = WEBRTC_SPL_ABS_W32(tmp32no1);
- mseStored += tmp32no2;
+ }
- tmp32no1 = ((int32_t)aecm->echoAdaptLogEnergy[i]
- - (int32_t)aecm->nearLogEnergy[i]);
- tmp32no2 = WEBRTC_SPL_ABS_W32(tmp32no1);
- mseAdapt += tmp32no2;
- }
- if (((mseStored << MSE_RESOLUTION) < (MIN_MSE_DIFF * mseAdapt))
- & ((aecm->mseStoredOld << MSE_RESOLUTION) < (MIN_MSE_DIFF
- * aecm->mseAdaptOld)))
- {
- // The stored channel has a significantly lower MSE than the adaptive one for
- // two consecutive calculations. Reset the adaptive channel.
- WebRtcAecm_ResetAdaptiveChannel(aecm);
- } else if (((MIN_MSE_DIFF * mseStored) > (mseAdapt << MSE_RESOLUTION)) & (mseAdapt
- < aecm->mseThreshold) & (aecm->mseAdaptOld < aecm->mseThreshold))
- {
- // The adaptive channel has a significantly lower MSE than the stored one.
- // The MSE for the adaptive channel has also been low for two consecutive
- // calculations. Store the adaptive channel.
- WebRtcAecm_StoreAdaptiveChannel(aecm, far_spectrum, echoEst);
+ // Reset counter
+ aecm->mseChannelCount = 0;
- // Update threshold
- if (aecm->mseThreshold == WEBRTC_SPL_WORD32_MAX)
- {
- aecm->mseThreshold = (mseAdapt + aecm->mseAdaptOld);
- } else
- {
- int scaled_threshold = aecm->mseThreshold * 5 / 8;
- aecm->mseThreshold +=
- ((mseAdapt - scaled_threshold) * 205) >> 8;
- }
-
- }
-
- // Reset counter
- aecm->mseChannelCount = 0;
-
- // Store the MSE values.
- aecm->mseStoredOld = mseStored;
- aecm->mseAdaptOld = mseAdapt;
- }
+ // Store the MSE values.
+ aecm->mseStoredOld = mseStored;
+ aecm->mseAdaptOld = mseAdapt;
}
- // END: Determine if we should store or reset channel estimate.
+ }
+ // END: Determine if we should store or reset channel estimate.
}
// CalcSuppressionGain(...)
//
-// This function calculates the suppression gain that is used in the Wiener filter.
+// This function calculates the suppression gain that is used in the Wiener
+// filter.
//
//
// @param aecm [i/n] Handle of the AECM instance.
-// @param supGain [out] (Return value) Suppression gain with which to scale the noise
+// @param supGain [out] (Return value) Suppression gain with which to scale
+// the noise
// level (Q14).
//
//
int16_t WebRtcAecm_CalcSuppressionGain(AecmCore* const aecm) {
- int32_t tmp32no1;
+ int32_t tmp32no1;
- int16_t supGain = SUPGAIN_DEFAULT;
- int16_t tmp16no1;
- int16_t dE = 0;
+ int16_t supGain = SUPGAIN_DEFAULT;
+ int16_t tmp16no1;
+ int16_t dE = 0;
- // Determine suppression gain used in the Wiener filter. The gain is based on a mix of far
- // end energy and echo estimation error.
- // Adjust for the far end signal level. A low signal level indicates no far end signal,
- // hence we set the suppression gain to 0
- if (!aecm->currentVADValue)
- {
- supGain = 0;
- } else
- {
- // Adjust for possible double talk. If we have large variations in estimation error we
- // likely have double talk (or poor channel).
- tmp16no1 = (aecm->nearLogEnergy[0] - aecm->echoStoredLogEnergy[0] - ENERGY_DEV_OFFSET);
- dE = WEBRTC_SPL_ABS_W16(tmp16no1);
+ // Determine suppression gain used in the Wiener filter. The gain is based on
+ // a mix of far end energy and echo estimation error. Adjust for the far end
+ // signal level. A low signal level indicates no far end signal, hence we set
+ // the suppression gain to 0
+ if (!aecm->currentVADValue) {
+ supGain = 0;
+ } else {
+ // Adjust for possible double talk. If we have large variations in
+ // estimation error we likely have double talk (or poor channel).
+ tmp16no1 = (aecm->nearLogEnergy[0] - aecm->echoStoredLogEnergy[0] -
+ ENERGY_DEV_OFFSET);
+ dE = WEBRTC_SPL_ABS_W16(tmp16no1);
- if (dE < ENERGY_DEV_TOL)
- {
- // Likely no double talk. The better estimation, the more we can suppress signal.
- // Update counters
- if (dE < SUPGAIN_EPC_DT)
- {
- tmp32no1 = aecm->supGainErrParamDiffAB * dE;
- tmp32no1 += (SUPGAIN_EPC_DT >> 1);
- tmp16no1 = (int16_t)WebRtcSpl_DivW32W16(tmp32no1, SUPGAIN_EPC_DT);
- supGain = aecm->supGainErrParamA - tmp16no1;
- } else
- {
- tmp32no1 = aecm->supGainErrParamDiffBD * (ENERGY_DEV_TOL - dE);
- tmp32no1 += ((ENERGY_DEV_TOL - SUPGAIN_EPC_DT) >> 1);
- tmp16no1 = (int16_t)WebRtcSpl_DivW32W16(tmp32no1, (ENERGY_DEV_TOL
- - SUPGAIN_EPC_DT));
- supGain = aecm->supGainErrParamD + tmp16no1;
- }
- } else
- {
- // Likely in double talk. Use default value
- supGain = aecm->supGainErrParamD;
- }
+ if (dE < ENERGY_DEV_TOL) {
+ // Likely no double talk. The better estimation, the more we can suppress
+ // signal. Update counters
+ if (dE < SUPGAIN_EPC_DT) {
+ tmp32no1 = aecm->supGainErrParamDiffAB * dE;
+ tmp32no1 += (SUPGAIN_EPC_DT >> 1);
+ tmp16no1 = (int16_t)WebRtcSpl_DivW32W16(tmp32no1, SUPGAIN_EPC_DT);
+ supGain = aecm->supGainErrParamA - tmp16no1;
+ } else {
+ tmp32no1 = aecm->supGainErrParamDiffBD * (ENERGY_DEV_TOL - dE);
+ tmp32no1 += ((ENERGY_DEV_TOL - SUPGAIN_EPC_DT) >> 1);
+ tmp16no1 = (int16_t)WebRtcSpl_DivW32W16(
+ tmp32no1, (ENERGY_DEV_TOL - SUPGAIN_EPC_DT));
+ supGain = aecm->supGainErrParamD + tmp16no1;
+ }
+ } else {
+ // Likely in double talk. Use default value
+ supGain = aecm->supGainErrParamD;
}
+ }
- if (supGain > aecm->supGainOld)
- {
- tmp16no1 = supGain;
- } else
- {
- tmp16no1 = aecm->supGainOld;
- }
- aecm->supGainOld = supGain;
- if (tmp16no1 < aecm->supGain)
- {
- aecm->supGain += (int16_t)((tmp16no1 - aecm->supGain) >> 4);
- } else
- {
- aecm->supGain += (int16_t)((tmp16no1 - aecm->supGain) >> 4);
- }
+ if (supGain > aecm->supGainOld) {
+ tmp16no1 = supGain;
+ } else {
+ tmp16no1 = aecm->supGainOld;
+ }
+ aecm->supGainOld = supGain;
+ if (tmp16no1 < aecm->supGain) {
+ aecm->supGain += (int16_t)((tmp16no1 - aecm->supGain) >> 4);
+ } else {
+ aecm->supGain += (int16_t)((tmp16no1 - aecm->supGain) >> 4);
+ }
- // END: Update suppression gain
+ // END: Update suppression gain
- return aecm->supGain;
+ return aecm->supGain;
}
void WebRtcAecm_BufferFarFrame(AecmCore* const aecm,
const int16_t* const farend,
const int farLen) {
- int writeLen = farLen, writePos = 0;
+ int writeLen = farLen, writePos = 0;
- // Check if the write position must be wrapped
- while (aecm->farBufWritePos + writeLen > FAR_BUF_LEN)
- {
- // Write to remaining buffer space before wrapping
- writeLen = FAR_BUF_LEN - aecm->farBufWritePos;
- memcpy(aecm->farBuf + aecm->farBufWritePos, farend + writePos,
- sizeof(int16_t) * writeLen);
- aecm->farBufWritePos = 0;
- writePos = writeLen;
- writeLen = farLen - writeLen;
- }
-
+ // Check if the write position must be wrapped
+ while (aecm->farBufWritePos + writeLen > FAR_BUF_LEN) {
+ // Write to remaining buffer space before wrapping
+ writeLen = FAR_BUF_LEN - aecm->farBufWritePos;
memcpy(aecm->farBuf + aecm->farBufWritePos, farend + writePos,
sizeof(int16_t) * writeLen);
- aecm->farBufWritePos += writeLen;
+ aecm->farBufWritePos = 0;
+ writePos = writeLen;
+ writeLen = farLen - writeLen;
+ }
+
+ memcpy(aecm->farBuf + aecm->farBufWritePos, farend + writePos,
+ sizeof(int16_t) * writeLen);
+ aecm->farBufWritePos += writeLen;
}
void WebRtcAecm_FetchFarFrame(AecmCore* const aecm,
int16_t* const farend,
const int farLen,
const int knownDelay) {
- int readLen = farLen;
- int readPos = 0;
- int delayChange = knownDelay - aecm->lastKnownDelay;
+ int readLen = farLen;
+ int readPos = 0;
+ int delayChange = knownDelay - aecm->lastKnownDelay;
- aecm->farBufReadPos -= delayChange;
+ aecm->farBufReadPos -= delayChange;
- // Check if delay forces a read position wrap
- while (aecm->farBufReadPos < 0)
- {
- aecm->farBufReadPos += FAR_BUF_LEN;
- }
- while (aecm->farBufReadPos > FAR_BUF_LEN - 1)
- {
- aecm->farBufReadPos -= FAR_BUF_LEN;
- }
+ // Check if delay forces a read position wrap
+ while (aecm->farBufReadPos < 0) {
+ aecm->farBufReadPos += FAR_BUF_LEN;
+ }
+ while (aecm->farBufReadPos > FAR_BUF_LEN - 1) {
+ aecm->farBufReadPos -= FAR_BUF_LEN;
+ }
- aecm->lastKnownDelay = knownDelay;
+ aecm->lastKnownDelay = knownDelay;
- // Check if read position must be wrapped
- while (aecm->farBufReadPos + readLen > FAR_BUF_LEN)
- {
-
- // Read from remaining buffer space before wrapping
- readLen = FAR_BUF_LEN - aecm->farBufReadPos;
- memcpy(farend + readPos, aecm->farBuf + aecm->farBufReadPos,
- sizeof(int16_t) * readLen);
- aecm->farBufReadPos = 0;
- readPos = readLen;
- readLen = farLen - readLen;
- }
+ // Check if read position must be wrapped
+ while (aecm->farBufReadPos + readLen > FAR_BUF_LEN) {
+ // Read from remaining buffer space before wrapping
+ readLen = FAR_BUF_LEN - aecm->farBufReadPos;
memcpy(farend + readPos, aecm->farBuf + aecm->farBufReadPos,
sizeof(int16_t) * readLen);
- aecm->farBufReadPos += readLen;
+ aecm->farBufReadPos = 0;
+ readPos = readLen;
+ readLen = farLen - readLen;
+ }
+ memcpy(farend + readPos, aecm->farBuf + aecm->farBufReadPos,
+ sizeof(int16_t) * readLen);
+ aecm->farBufReadPos += readLen;
}
diff --git a/modules/audio_processing/aecm/aecm_core.h b/modules/audio_processing/aecm/aecm_core.h
index feb997e..3da3bca 100644
--- a/modules/audio_processing/aecm/aecm_core.h
+++ b/modules/audio_processing/aecm/aecm_core.h
@@ -29,109 +29,109 @@
#endif
typedef struct {
- int16_t real;
- int16_t imag;
+ int16_t real;
+ int16_t imag;
} ComplexInt16;
typedef struct {
- int farBufWritePos;
- int farBufReadPos;
- int knownDelay;
- int lastKnownDelay;
- int firstVAD; // Parameter to control poorly initialized channels
+ int farBufWritePos;
+ int farBufReadPos;
+ int knownDelay;
+ int lastKnownDelay;
+ int firstVAD; // Parameter to control poorly initialized channels
- RingBuffer* farFrameBuf;
- RingBuffer* nearNoisyFrameBuf;
- RingBuffer* nearCleanFrameBuf;
- RingBuffer* outFrameBuf;
+ RingBuffer* farFrameBuf;
+ RingBuffer* nearNoisyFrameBuf;
+ RingBuffer* nearCleanFrameBuf;
+ RingBuffer* outFrameBuf;
- int16_t farBuf[FAR_BUF_LEN];
+ int16_t farBuf[FAR_BUF_LEN];
- int16_t mult;
- uint32_t seed;
+ int16_t mult;
+ uint32_t seed;
- // Delay estimation variables
- void* delay_estimator_farend;
- void* delay_estimator;
- uint16_t currentDelay;
- // Far end history variables
- // TODO(bjornv): Replace |far_history| with ring_buffer.
- uint16_t far_history[PART_LEN1 * MAX_DELAY];
- int far_history_pos;
- int far_q_domains[MAX_DELAY];
+ // Delay estimation variables
+ void* delay_estimator_farend;
+ void* delay_estimator;
+ uint16_t currentDelay;
+ // Far end history variables
+ // TODO(bjornv): Replace |far_history| with ring_buffer.
+ uint16_t far_history[PART_LEN1 * MAX_DELAY];
+ int far_history_pos;
+ int far_q_domains[MAX_DELAY];
- int16_t nlpFlag;
- int16_t fixedDelay;
+ int16_t nlpFlag;
+ int16_t fixedDelay;
- uint32_t totCount;
+ uint32_t totCount;
- int16_t dfaCleanQDomain;
- int16_t dfaCleanQDomainOld;
- int16_t dfaNoisyQDomain;
- int16_t dfaNoisyQDomainOld;
+ int16_t dfaCleanQDomain;
+ int16_t dfaCleanQDomainOld;
+ int16_t dfaNoisyQDomain;
+ int16_t dfaNoisyQDomainOld;
- int16_t nearLogEnergy[MAX_BUF_LEN];
- int16_t farLogEnergy;
- int16_t echoAdaptLogEnergy[MAX_BUF_LEN];
- int16_t echoStoredLogEnergy[MAX_BUF_LEN];
+ int16_t nearLogEnergy[MAX_BUF_LEN];
+ int16_t farLogEnergy;
+ int16_t echoAdaptLogEnergy[MAX_BUF_LEN];
+ int16_t echoStoredLogEnergy[MAX_BUF_LEN];
- // The extra 16 or 32 bytes in the following buffers are for alignment based
- // Neon code.
- // It's designed this way since the current GCC compiler can't align a
- // buffer in 16 or 32 byte boundaries properly.
- int16_t channelStored_buf[PART_LEN1 + 8];
- int16_t channelAdapt16_buf[PART_LEN1 + 8];
- int32_t channelAdapt32_buf[PART_LEN1 + 8];
- int16_t xBuf_buf[PART_LEN2 + 16]; // farend
- int16_t dBufClean_buf[PART_LEN2 + 16]; // nearend
- int16_t dBufNoisy_buf[PART_LEN2 + 16]; // nearend
- int16_t outBuf_buf[PART_LEN + 8];
+ // The extra 16 or 32 bytes in the following buffers are for alignment based
+ // Neon code.
+ // It's designed this way since the current GCC compiler can't align a
+ // buffer in 16 or 32 byte boundaries properly.
+ int16_t channelStored_buf[PART_LEN1 + 8];
+ int16_t channelAdapt16_buf[PART_LEN1 + 8];
+ int32_t channelAdapt32_buf[PART_LEN1 + 8];
+ int16_t xBuf_buf[PART_LEN2 + 16]; // farend
+ int16_t dBufClean_buf[PART_LEN2 + 16]; // nearend
+ int16_t dBufNoisy_buf[PART_LEN2 + 16]; // nearend
+ int16_t outBuf_buf[PART_LEN + 8];
- // Pointers to the above buffers
- int16_t *channelStored;
- int16_t *channelAdapt16;
- int32_t *channelAdapt32;
- int16_t *xBuf;
- int16_t *dBufClean;
- int16_t *dBufNoisy;
- int16_t *outBuf;
+ // Pointers to the above buffers
+ int16_t* channelStored;
+ int16_t* channelAdapt16;
+ int32_t* channelAdapt32;
+ int16_t* xBuf;
+ int16_t* dBufClean;
+ int16_t* dBufNoisy;
+ int16_t* outBuf;
- int32_t echoFilt[PART_LEN1];
- int16_t nearFilt[PART_LEN1];
- int32_t noiseEst[PART_LEN1];
- int noiseEstTooLowCtr[PART_LEN1];
- int noiseEstTooHighCtr[PART_LEN1];
- int16_t noiseEstCtr;
- int16_t cngMode;
+ int32_t echoFilt[PART_LEN1];
+ int16_t nearFilt[PART_LEN1];
+ int32_t noiseEst[PART_LEN1];
+ int noiseEstTooLowCtr[PART_LEN1];
+ int noiseEstTooHighCtr[PART_LEN1];
+ int16_t noiseEstCtr;
+ int16_t cngMode;
- int32_t mseAdaptOld;
- int32_t mseStoredOld;
- int32_t mseThreshold;
+ int32_t mseAdaptOld;
+ int32_t mseStoredOld;
+ int32_t mseThreshold;
- int16_t farEnergyMin;
- int16_t farEnergyMax;
- int16_t farEnergyMaxMin;
- int16_t farEnergyVAD;
- int16_t farEnergyMSE;
- int currentVADValue;
- int16_t vadUpdateCount;
+ int16_t farEnergyMin;
+ int16_t farEnergyMax;
+ int16_t farEnergyMaxMin;
+ int16_t farEnergyVAD;
+ int16_t farEnergyMSE;
+ int currentVADValue;
+ int16_t vadUpdateCount;
- int16_t startupState;
- int16_t mseChannelCount;
- int16_t supGain;
- int16_t supGainOld;
+ int16_t startupState;
+ int16_t mseChannelCount;
+ int16_t supGain;
+ int16_t supGainOld;
- int16_t supGainErrParamA;
- int16_t supGainErrParamD;
- int16_t supGainErrParamDiffAB;
- int16_t supGainErrParamDiffBD;
+ int16_t supGainErrParamA;
+ int16_t supGainErrParamD;
+ int16_t supGainErrParamDiffAB;
+ int16_t supGainErrParamDiffBD;
- struct RealFFT* real_fft;
+ struct RealFFT* real_fft;
#ifdef AEC_DEBUG
- FILE *farFile;
- FILE *nearFile;
- FILE *outFile;
+ FILE* farFile;
+ FILE* nearFile;
+ FILE* outFile;
#endif
} AecmCore;
diff --git a/modules/audio_processing/aecm/aecm_core_c.cc b/modules/audio_processing/aecm/aecm_core_c.cc
index effe048..b640f1a6 100644
--- a/modules/audio_processing/aecm/aecm_core_c.cc
+++ b/modules/audio_processing/aecm/aecm_core_c.cc
@@ -30,28 +30,25 @@
// Square root of Hanning window in Q14.
static const ALIGN8_BEG int16_t WebRtcAecm_kSqrtHanning[] ALIGN8_END = {
- 0, 399, 798, 1196, 1594, 1990, 2386, 2780, 3172,
- 3562, 3951, 4337, 4720, 5101, 5478, 5853, 6224,
- 6591, 6954, 7313, 7668, 8019, 8364, 8705, 9040,
- 9370, 9695, 10013, 10326, 10633, 10933, 11227, 11514,
- 11795, 12068, 12335, 12594, 12845, 13089, 13325, 13553,
- 13773, 13985, 14189, 14384, 14571, 14749, 14918, 15079,
- 15231, 15373, 15506, 15631, 15746, 15851, 15947, 16034,
- 16111, 16179, 16237, 16286, 16325, 16354, 16373, 16384
-};
+ 0, 399, 798, 1196, 1594, 1990, 2386, 2780, 3172, 3562, 3951,
+ 4337, 4720, 5101, 5478, 5853, 6224, 6591, 6954, 7313, 7668, 8019,
+ 8364, 8705, 9040, 9370, 9695, 10013, 10326, 10633, 10933, 11227, 11514,
+ 11795, 12068, 12335, 12594, 12845, 13089, 13325, 13553, 13773, 13985, 14189,
+ 14384, 14571, 14749, 14918, 15079, 15231, 15373, 15506, 15631, 15746, 15851,
+ 15947, 16034, 16111, 16179, 16237, 16286, 16325, 16354, 16373, 16384};
#ifdef AECM_WITH_ABS_APPROX
-//Q15 alpha = 0.99439986968132 const Factor for magnitude approximation
+// Q15 alpha = 0.99439986968132 const Factor for magnitude approximation
static const uint16_t kAlpha1 = 32584;
-//Q15 beta = 0.12967166976970 const Factor for magnitude approximation
+// Q15 beta = 0.12967166976970 const Factor for magnitude approximation
static const uint16_t kBeta1 = 4249;
-//Q15 alpha = 0.94234827210087 const Factor for magnitude approximation
+// Q15 alpha = 0.94234827210087 const Factor for magnitude approximation
static const uint16_t kAlpha2 = 30879;
-//Q15 beta = 0.33787806009150 const Factor for magnitude approximation
+// Q15 beta = 0.33787806009150 const Factor for magnitude approximation
static const uint16_t kBeta2 = 11072;
-//Q15 alpha = 0.82247698684306 const Factor for magnitude approximation
+// Q15 alpha = 0.82247698684306 const Factor for magnitude approximation
static const uint16_t kAlpha3 = 26951;
-//Q15 beta = 0.57762063060713 const Factor for magnitude approximation
+// Q15 beta = 0.57762063060713 const Factor for magnitude approximation
static const uint16_t kBeta3 = 18927;
#endif
@@ -77,8 +74,8 @@
int16_t scaled_time_signal = time_signal[i] * (1 << time_signal_scaling);
fft[i] = (int16_t)((scaled_time_signal * WebRtcAecm_kSqrtHanning[i]) >> 14);
scaled_time_signal = time_signal[i + PART_LEN] * (1 << time_signal_scaling);
- fft[PART_LEN + i] = (int16_t)((
- scaled_time_signal * WebRtcAecm_kSqrtHanning[PART_LEN - i]) >> 14);
+ fft[PART_LEN + i] = (int16_t)(
+ (scaled_time_signal * WebRtcAecm_kSqrtHanning[PART_LEN - i]) >> 14);
}
// Do forward FFT, then take only the first PART_LEN complex samples,
@@ -115,32 +112,27 @@
outCFFT = WebRtcSpl_RealInverseFFT(aecm->real_fft, fft, ifft_out);
for (i = 0; i < PART_LEN; i++) {
ifft_out[i] = (int16_t)WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(
- ifft_out[i], WebRtcAecm_kSqrtHanning[i], 14);
+ ifft_out[i], WebRtcAecm_kSqrtHanning[i], 14);
tmp32no1 = WEBRTC_SPL_SHIFT_W32((int32_t)ifft_out[i],
- outCFFT - aecm->dfaCleanQDomain);
+ outCFFT - aecm->dfaCleanQDomain);
output[i] = (int16_t)WEBRTC_SPL_SAT(WEBRTC_SPL_WORD16_MAX,
tmp32no1 + aecm->outBuf[i],
WEBRTC_SPL_WORD16_MIN);
- tmp32no1 = (ifft_out[PART_LEN + i] *
- WebRtcAecm_kSqrtHanning[PART_LEN - i]) >> 14;
- tmp32no1 = WEBRTC_SPL_SHIFT_W32(tmp32no1,
- outCFFT - aecm->dfaCleanQDomain);
- aecm->outBuf[i] = (int16_t)WEBRTC_SPL_SAT(WEBRTC_SPL_WORD16_MAX,
- tmp32no1,
- WEBRTC_SPL_WORD16_MIN);
+ tmp32no1 =
+ (ifft_out[PART_LEN + i] * WebRtcAecm_kSqrtHanning[PART_LEN - i]) >> 14;
+ tmp32no1 = WEBRTC_SPL_SHIFT_W32(tmp32no1, outCFFT - aecm->dfaCleanQDomain);
+ aecm->outBuf[i] = (int16_t)WEBRTC_SPL_SAT(WEBRTC_SPL_WORD16_MAX, tmp32no1,
+ WEBRTC_SPL_WORD16_MIN);
}
// Copy the current block to the old position
// (aecm->outBuf is shifted elsewhere)
memcpy(aecm->xBuf, aecm->xBuf + PART_LEN, sizeof(int16_t) * PART_LEN);
- memcpy(aecm->dBufNoisy,
- aecm->dBufNoisy + PART_LEN,
+ memcpy(aecm->dBufNoisy, aecm->dBufNoisy + PART_LEN,
sizeof(int16_t) * PART_LEN);
- if (nearendClean != NULL)
- {
- memcpy(aecm->dBufClean,
- aecm->dBufClean + PART_LEN,
+ if (nearendClean != NULL) {
+ memcpy(aecm->dBufClean, aecm->dBufClean + PART_LEN,
sizeof(int16_t) * PART_LEN);
}
}
@@ -171,7 +163,7 @@
// In fft_buf, +16 for 32-byte alignment.
int16_t fft_buf[PART_LEN4 + 16];
- int16_t *fft = (int16_t *) (((uintptr_t) fft_buf + 31) & ~31);
+ int16_t* fft = (int16_t*)(((uintptr_t)fft_buf + 31) & ~31);
int16_t tmp16no1;
#ifndef WEBRTC_ARCH_ARM_V7
@@ -196,54 +188,43 @@
freq_signal[0].imag = 0;
freq_signal[PART_LEN].imag = 0;
freq_signal_abs[0] = (uint16_t)WEBRTC_SPL_ABS_W16(freq_signal[0].real);
- freq_signal_abs[PART_LEN] = (uint16_t)WEBRTC_SPL_ABS_W16(
- freq_signal[PART_LEN].real);
- (*freq_signal_sum_abs) = (uint32_t)(freq_signal_abs[0]) +
- (uint32_t)(freq_signal_abs[PART_LEN]);
+ freq_signal_abs[PART_LEN] =
+ (uint16_t)WEBRTC_SPL_ABS_W16(freq_signal[PART_LEN].real);
+ (*freq_signal_sum_abs) =
+ (uint32_t)(freq_signal_abs[0]) + (uint32_t)(freq_signal_abs[PART_LEN]);
- for (i = 1; i < PART_LEN; i++)
- {
- if (freq_signal[i].real == 0)
- {
+ for (i = 1; i < PART_LEN; i++) {
+ if (freq_signal[i].real == 0) {
freq_signal_abs[i] = (uint16_t)WEBRTC_SPL_ABS_W16(freq_signal[i].imag);
- }
- else if (freq_signal[i].imag == 0)
- {
+ } else if (freq_signal[i].imag == 0) {
freq_signal_abs[i] = (uint16_t)WEBRTC_SPL_ABS_W16(freq_signal[i].real);
- }
- else
- {
- // Approximation for magnitude of complex fft output
- // magn = sqrt(real^2 + imag^2)
- // magn ~= alpha * max(|imag|,|real|) + beta * min(|imag|,|real|)
- //
- // The parameters alpha and beta are stored in Q15
+ } else {
+// Approximation for magnitude of complex fft output
+// magn = sqrt(real^2 + imag^2)
+// magn ~= alpha * max(|imag|,|real|) + beta * min(|imag|,|real|)
+//
+// The parameters alpha and beta are stored in Q15
#ifdef AECM_WITH_ABS_APPROX
tmp16no1 = WEBRTC_SPL_ABS_W16(freq_signal[i].real);
tmp16no2 = WEBRTC_SPL_ABS_W16(freq_signal[i].imag);
- if(tmp16no1 > tmp16no2)
- {
+ if (tmp16no1 > tmp16no2) {
max_value = tmp16no1;
min_value = tmp16no2;
- } else
- {
+ } else {
max_value = tmp16no2;
min_value = tmp16no1;
}
// Magnitude in Q(-6)
- if ((max_value >> 2) > min_value)
- {
+ if ((max_value >> 2) > min_value) {
alpha = kAlpha1;
beta = kBeta1;
- } else if ((max_value >> 1) > min_value)
- {
+ } else if ((max_value >> 1) > min_value) {
alpha = kAlpha2;
beta = kBeta2;
- } else
- {
+ } else {
alpha = kAlpha3;
beta = kBeta3;
}
@@ -253,24 +234,21 @@
#else
#ifdef WEBRTC_ARCH_ARM_V7
__asm __volatile(
- "smulbb %[tmp32no1], %[real], %[real]\n\t"
- "smlabb %[tmp32no2], %[imag], %[imag], %[tmp32no1]\n\t"
- :[tmp32no1]"+&r"(tmp32no1),
- [tmp32no2]"=r"(tmp32no2)
- :[real]"r"(freq_signal[i].real),
- [imag]"r"(freq_signal[i].imag)
- );
+ "smulbb %[tmp32no1], %[real], %[real]\n\t"
+ "smlabb %[tmp32no2], %[imag], %[imag], %[tmp32no1]\n\t"
+ : [tmp32no1] "+&r"(tmp32no1), [tmp32no2] "=r"(tmp32no2)
+ : [real] "r"(freq_signal[i].real), [imag] "r"(freq_signal[i].imag));
#else
tmp16no1 = WEBRTC_SPL_ABS_W16(freq_signal[i].real);
tmp16no2 = WEBRTC_SPL_ABS_W16(freq_signal[i].imag);
tmp32no1 = tmp16no1 * tmp16no1;
tmp32no2 = tmp16no2 * tmp16no2;
tmp32no2 = WebRtcSpl_AddSatW32(tmp32no1, tmp32no2);
-#endif // WEBRTC_ARCH_ARM_V7
+#endif // WEBRTC_ARCH_ARM_V7
tmp32no1 = WebRtcSpl_SqrtFloor(tmp32no2);
freq_signal_abs[i] = (uint16_t)tmp32no1;
-#endif // AECM_WITH_ABS_APPROX
+#endif // AECM_WITH_ABS_APPROX
}
(*freq_signal_sum_abs) += (uint32_t)freq_signal_abs[i];
}
@@ -279,11 +257,11 @@
}
int RTC_NO_SANITIZE("signed-integer-overflow") // bugs.webrtc.org/8200
-WebRtcAecm_ProcessBlock(AecmCore* aecm,
- const int16_t* farend,
- const int16_t* nearendNoisy,
- const int16_t* nearendClean,
- int16_t* output) {
+ WebRtcAecm_ProcessBlock(AecmCore* aecm,
+ const int16_t* farend,
+ const int16_t* nearendNoisy,
+ const int16_t* nearendClean,
+ int16_t* output) {
int i;
uint32_t xfaSum;
@@ -302,13 +280,13 @@
// 32 byte aligned buffers (with +8 or +16).
// TODO(kma): define fft with ComplexInt16.
- int16_t fft_buf[PART_LEN4 + 2 + 16]; // +2 to make a loop safe.
+ int16_t fft_buf[PART_LEN4 + 2 + 16]; // +2 to make a loop safe.
int32_t echoEst32_buf[PART_LEN1 + 8];
int32_t dfw_buf[PART_LEN2 + 8];
int32_t efw_buf[PART_LEN2 + 8];
- int16_t* fft = (int16_t*) (((uintptr_t) fft_buf + 31) & ~ 31);
- int32_t* echoEst32 = (int32_t*) (((uintptr_t) echoEst32_buf + 31) & ~ 31);
+ int16_t* fft = (int16_t*)(((uintptr_t)fft_buf + 31) & ~31);
+ int32_t* echoEst32 = (int32_t*)(((uintptr_t)echoEst32_buf + 31) & ~31);
ComplexInt16* dfw = (ComplexInt16*)(((uintptr_t)dfw_buf + 31) & ~31);
ComplexInt16* efw = (ComplexInt16*)(((uintptr_t)efw_buf + 31) & ~31);
@@ -334,53 +312,37 @@
// (1) another CONV_LEN blocks
// (2) the rest
- if (aecm->startupState < 2)
- {
- aecm->startupState = (aecm->totCount >= CONV_LEN) +
- (aecm->totCount >= CONV_LEN2);
+ if (aecm->startupState < 2) {
+ aecm->startupState =
+ (aecm->totCount >= CONV_LEN) + (aecm->totCount >= CONV_LEN2);
}
// END: Determine startup state
// Buffer near and far end signals
memcpy(aecm->xBuf + PART_LEN, farend, sizeof(int16_t) * PART_LEN);
memcpy(aecm->dBufNoisy + PART_LEN, nearendNoisy, sizeof(int16_t) * PART_LEN);
- if (nearendClean != NULL)
- {
- memcpy(aecm->dBufClean + PART_LEN,
- nearendClean,
+ if (nearendClean != NULL) {
+ memcpy(aecm->dBufClean + PART_LEN, nearendClean,
sizeof(int16_t) * PART_LEN);
}
// Transform far end signal from time domain to frequency domain.
- far_q = TimeToFrequencyDomain(aecm,
- aecm->xBuf,
- dfw,
- xfa,
- &xfaSum);
+ far_q = TimeToFrequencyDomain(aecm, aecm->xBuf, dfw, xfa, &xfaSum);
// Transform noisy near end signal from time domain to frequency domain.
- zerosDBufNoisy = TimeToFrequencyDomain(aecm,
- aecm->dBufNoisy,
- dfw,
- dfaNoisy,
- &dfaNoisySum);
+ zerosDBufNoisy =
+ TimeToFrequencyDomain(aecm, aecm->dBufNoisy, dfw, dfaNoisy, &dfaNoisySum);
aecm->dfaNoisyQDomainOld = aecm->dfaNoisyQDomain;
aecm->dfaNoisyQDomain = (int16_t)zerosDBufNoisy;
-
- if (nearendClean == NULL)
- {
+ if (nearendClean == NULL) {
ptrDfaClean = dfaNoisy;
aecm->dfaCleanQDomainOld = aecm->dfaNoisyQDomainOld;
aecm->dfaCleanQDomain = aecm->dfaNoisyQDomain;
dfaCleanSum = dfaNoisySum;
- } else
- {
+ } else {
// Transform clean near end signal from time domain to frequency domain.
- zerosDBufClean = TimeToFrequencyDomain(aecm,
- aecm->dBufClean,
- dfw,
- dfaClean,
+ zerosDBufClean = TimeToFrequencyDomain(aecm, aecm->dBufClean, dfw, dfaClean,
&dfaCleanSum);
aecm->dfaCleanQDomainOld = aecm->dfaCleanQDomain;
aecm->dfaCleanQDomain = (int16_t)zerosDBufClean;
@@ -389,46 +351,34 @@
// Get the delay
// Save far-end history and estimate delay
WebRtcAecm_UpdateFarHistory(aecm, xfa, far_q);
- if (WebRtc_AddFarSpectrumFix(aecm->delay_estimator_farend,
- xfa,
- PART_LEN1,
+ if (WebRtc_AddFarSpectrumFix(aecm->delay_estimator_farend, xfa, PART_LEN1,
far_q) == -1) {
return -1;
}
- delay = WebRtc_DelayEstimatorProcessFix(aecm->delay_estimator,
- dfaNoisy,
- PART_LEN1,
- zerosDBufNoisy);
- if (delay == -1)
- {
+ delay = WebRtc_DelayEstimatorProcessFix(aecm->delay_estimator, dfaNoisy,
+ PART_LEN1, zerosDBufNoisy);
+ if (delay == -1) {
return -1;
- }
- else if (delay == -2)
- {
+ } else if (delay == -2) {
// If the delay is unknown, we assume zero.
// NOTE: this will have to be adjusted if we ever add lookahead.
delay = 0;
}
- if (aecm->fixedDelay >= 0)
- {
+ if (aecm->fixedDelay >= 0) {
// Use fixed delay
delay = aecm->fixedDelay;
}
// Get aligned far end spectrum
far_spectrum_ptr = WebRtcAecm_AlignedFarend(aecm, &far_q, delay);
- zerosXBuf = (int16_t) far_q;
- if (far_spectrum_ptr == NULL)
- {
+ zerosXBuf = (int16_t)far_q;
+ if (far_spectrum_ptr == NULL) {
return -1;
}
// Calculate log(energy) and update energy threshold levels
- WebRtcAecm_CalcEnergies(aecm,
- far_spectrum_ptr,
- zerosXBuf,
- dfaNoisySum,
+ WebRtcAecm_CalcEnergies(aecm, far_spectrum_ptr, zerosXBuf, dfaNoisySum,
echoEst32);
// Calculate stepsize
@@ -440,18 +390,12 @@
// This is the channel estimation algorithm.
// It is base on NLMS but has a variable step length,
// which was calculated above.
- WebRtcAecm_UpdateChannel(aecm,
- far_spectrum_ptr,
- zerosXBuf,
- dfaNoisy,
- mu,
+ WebRtcAecm_UpdateChannel(aecm, far_spectrum_ptr, zerosXBuf, dfaNoisy, mu,
echoEst32);
supGain = WebRtcAecm_CalcSuppressionGain(aecm);
-
// Calculate Wiener filter hnl[]
- for (i = 0; i < PART_LEN1; i++)
- {
+ for (i = 0; i < PART_LEN1; i++) {
// Far end signal through channel estimate in Q8
// How much can we shift right to preserve resolution
tmp32no1 = echoEst32[i] - aecm->echoFilt[i];
@@ -460,28 +404,24 @@
zeros32 = WebRtcSpl_NormW32(aecm->echoFilt[i]) + 1;
zeros16 = WebRtcSpl_NormW16(supGain) + 1;
- if (zeros32 + zeros16 > 16)
- {
+ if (zeros32 + zeros16 > 16) {
// Multiplication is safe
// Result in
// Q(RESOLUTION_CHANNEL+RESOLUTION_SUPGAIN+
// aecm->xfaQDomainBuf[diff])
- echoEst32Gained = WEBRTC_SPL_UMUL_32_16((uint32_t)aecm->echoFilt[i],
- (uint16_t)supGain);
+ echoEst32Gained =
+ WEBRTC_SPL_UMUL_32_16((uint32_t)aecm->echoFilt[i], (uint16_t)supGain);
resolutionDiff = 14 - RESOLUTION_CHANNEL16 - RESOLUTION_SUPGAIN;
resolutionDiff += (aecm->dfaCleanQDomain - zerosXBuf);
- } else
- {
+ } else {
tmp16no1 = 17 - zeros32 - zeros16;
- resolutionDiff = 14 + tmp16no1 - RESOLUTION_CHANNEL16 -
- RESOLUTION_SUPGAIN;
+ resolutionDiff =
+ 14 + tmp16no1 - RESOLUTION_CHANNEL16 - RESOLUTION_SUPGAIN;
resolutionDiff += (aecm->dfaCleanQDomain - zerosXBuf);
- if (zeros32 > tmp16no1)
- {
+ if (zeros32 > tmp16no1) {
echoEst32Gained = WEBRTC_SPL_UMUL_32_16((uint32_t)aecm->echoFilt[i],
supGain >> tmp16no1);
- } else
- {
+ } else {
// Result in Q-(RESOLUTION_CHANNEL+RESOLUTION_SUPGAIN-16)
echoEst32Gained = (aecm->echoFilt[i] >> tmp16no1) * supGain;
}
@@ -513,125 +453,100 @@
}
// Wiener filter coefficients, resulting hnl in Q14
- if (echoEst32Gained == 0)
- {
+ if (echoEst32Gained == 0) {
hnl[i] = ONE_Q14;
- } else if (aecm->nearFilt[i] == 0)
- {
+ } else if (aecm->nearFilt[i] == 0) {
hnl[i] = 0;
- } else
- {
+ } else {
// Multiply the suppression gain
// Rounding
echoEst32Gained += (uint32_t)(aecm->nearFilt[i] >> 1);
- tmpU32 = WebRtcSpl_DivU32U16(echoEst32Gained,
- (uint16_t)aecm->nearFilt[i]);
+ tmpU32 =
+ WebRtcSpl_DivU32U16(echoEst32Gained, (uint16_t)aecm->nearFilt[i]);
// Current resolution is
// Q-(RESOLUTION_CHANNEL+RESOLUTION_SUPGAIN- max(0,17-zeros16- zeros32))
// Make sure we are in Q14
tmp32no1 = (int32_t)WEBRTC_SPL_SHIFT_W32(tmpU32, resolutionDiff);
- if (tmp32no1 > ONE_Q14)
- {
+ if (tmp32no1 > ONE_Q14) {
hnl[i] = 0;
- } else if (tmp32no1 < 0)
- {
+ } else if (tmp32no1 < 0) {
hnl[i] = ONE_Q14;
- } else
- {
+ } else {
// 1-echoEst/dfa
hnl[i] = ONE_Q14 - (int16_t)tmp32no1;
- if (hnl[i] < 0)
- {
+ if (hnl[i] < 0) {
hnl[i] = 0;
}
}
}
- if (hnl[i])
- {
+ if (hnl[i]) {
numPosCoef++;
}
}
// Only in wideband. Prevent the gain in upper band from being larger than
// in lower band.
- if (aecm->mult == 2)
- {
+ if (aecm->mult == 2) {
// TODO(bjornv): Investigate if the scaling of hnl[i] below can cause
// speech distortion in double-talk.
- for (i = 0; i < PART_LEN1; i++)
- {
+ for (i = 0; i < PART_LEN1; i++) {
hnl[i] = (int16_t)((hnl[i] * hnl[i]) >> 14);
}
- for (i = kMinPrefBand; i <= kMaxPrefBand; i++)
- {
+ for (i = kMinPrefBand; i <= kMaxPrefBand; i++) {
avgHnl32 += (int32_t)hnl[i];
}
RTC_DCHECK_GT(kMaxPrefBand - kMinPrefBand + 1, 0);
avgHnl32 /= (kMaxPrefBand - kMinPrefBand + 1);
- for (i = kMaxPrefBand; i < PART_LEN1; i++)
- {
- if (hnl[i] > (int16_t)avgHnl32)
- {
+ for (i = kMaxPrefBand; i < PART_LEN1; i++) {
+ if (hnl[i] > (int16_t)avgHnl32) {
hnl[i] = (int16_t)avgHnl32;
}
}
}
// Calculate NLP gain, result is in Q14
- if (aecm->nlpFlag)
- {
- for (i = 0; i < PART_LEN1; i++)
- {
+ if (aecm->nlpFlag) {
+ for (i = 0; i < PART_LEN1; i++) {
// Truncate values close to zero and one.
- if (hnl[i] > NLP_COMP_HIGH)
- {
+ if (hnl[i] > NLP_COMP_HIGH) {
hnl[i] = ONE_Q14;
- } else if (hnl[i] < NLP_COMP_LOW)
- {
+ } else if (hnl[i] < NLP_COMP_LOW) {
hnl[i] = 0;
}
// Remove outliers
- if (numPosCoef < 3)
- {
+ if (numPosCoef < 3) {
nlpGain = 0;
- } else
- {
+ } else {
nlpGain = ONE_Q14;
}
// NLP
- if ((hnl[i] == ONE_Q14) && (nlpGain == ONE_Q14))
- {
+ if ((hnl[i] == ONE_Q14) && (nlpGain == ONE_Q14)) {
hnl[i] = ONE_Q14;
- } else
- {
+ } else {
hnl[i] = (int16_t)((hnl[i] * nlpGain) >> 14);
}
// multiply with Wiener coefficients
- efw[i].real = (int16_t)(WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(dfw[i].real,
- hnl[i], 14));
- efw[i].imag = (int16_t)(WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(dfw[i].imag,
- hnl[i], 14));
+ efw[i].real = (int16_t)(
+ WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(dfw[i].real, hnl[i], 14));
+ efw[i].imag = (int16_t)(
+ WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(dfw[i].imag, hnl[i], 14));
}
- }
- else
- {
+ } else {
// multiply with Wiener coefficients
- for (i = 0; i < PART_LEN1; i++)
- {
- efw[i].real = (int16_t)(WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(dfw[i].real,
- hnl[i], 14));
- efw[i].imag = (int16_t)(WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(dfw[i].imag,
- hnl[i], 14));
+ for (i = 0; i < PART_LEN1; i++) {
+ efw[i].real = (int16_t)(
+ WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(dfw[i].real, hnl[i], 14));
+ efw[i].imag = (int16_t)(
+ WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(dfw[i].imag, hnl[i], 14));
}
}
- if (aecm->cngMode == AecmTrue)
- {
+ if (aecm->cngMode == AecmTrue) {
ComfortNoise(aecm, ptrDfaClean, efw, hnl);
}
@@ -660,83 +575,66 @@
RTC_DCHECK_GE(shiftFromNearToNoise, 0);
RTC_DCHECK_LT(shiftFromNearToNoise, 16);
- if (aecm->noiseEstCtr < 100)
- {
+ if (aecm->noiseEstCtr < 100) {
// Track the minimum more quickly initially.
aecm->noiseEstCtr++;
minTrackShift = 6;
- } else
- {
+ } else {
minTrackShift = 9;
}
// Estimate noise power.
- for (i = 0; i < PART_LEN1; i++)
- {
+ for (i = 0; i < PART_LEN1; i++) {
// Shift to the noise domain.
tmp32 = (int32_t)dfa[i];
outLShift32 = tmp32 << shiftFromNearToNoise;
- if (outLShift32 < aecm->noiseEst[i])
- {
+ if (outLShift32 < aecm->noiseEst[i]) {
// Reset "too low" counter
aecm->noiseEstTooLowCtr[i] = 0;
// Track the minimum.
- if (aecm->noiseEst[i] < (1 << minTrackShift))
- {
+ if (aecm->noiseEst[i] < (1 << minTrackShift)) {
// For small values, decrease noiseEst[i] every
// |kNoiseEstIncCount| block. The regular approach below can not
// go further down due to truncation.
aecm->noiseEstTooHighCtr[i]++;
- if (aecm->noiseEstTooHighCtr[i] >= kNoiseEstIncCount)
- {
+ if (aecm->noiseEstTooHighCtr[i] >= kNoiseEstIncCount) {
aecm->noiseEst[i]--;
- aecm->noiseEstTooHighCtr[i] = 0; // Reset the counter
+ aecm->noiseEstTooHighCtr[i] = 0; // Reset the counter
}
+ } else {
+ aecm->noiseEst[i] -=
+ ((aecm->noiseEst[i] - outLShift32) >> minTrackShift);
}
- else
- {
- aecm->noiseEst[i] -= ((aecm->noiseEst[i] - outLShift32)
- >> minTrackShift);
- }
- } else
- {
+ } else {
// Reset "too high" counter
aecm->noiseEstTooHighCtr[i] = 0;
// Ramp slowly upwards until we hit the minimum again.
- if ((aecm->noiseEst[i] >> 19) > 0)
- {
+ if ((aecm->noiseEst[i] >> 19) > 0) {
// Avoid overflow.
// Multiplication with 2049 will cause wrap around. Scale
// down first and then multiply
aecm->noiseEst[i] >>= 11;
aecm->noiseEst[i] *= 2049;
- }
- else if ((aecm->noiseEst[i] >> 11) > 0)
- {
+ } else if ((aecm->noiseEst[i] >> 11) > 0) {
// Large enough for relative increase
aecm->noiseEst[i] *= 2049;
aecm->noiseEst[i] >>= 11;
- }
- else
- {
+ } else {
// Make incremental increases based on size every
// |kNoiseEstIncCount| block
aecm->noiseEstTooLowCtr[i]++;
- if (aecm->noiseEstTooLowCtr[i] >= kNoiseEstIncCount)
- {
+ if (aecm->noiseEstTooLowCtr[i] >= kNoiseEstIncCount) {
aecm->noiseEst[i] += (aecm->noiseEst[i] >> 9) + 1;
- aecm->noiseEstTooLowCtr[i] = 0; // Reset counter
+ aecm->noiseEstTooLowCtr[i] = 0; // Reset counter
}
}
}
}
- for (i = 0; i < PART_LEN1; i++)
- {
+ for (i = 0; i < PART_LEN1; i++) {
tmp32 = aecm->noiseEst[i] >> shiftFromNearToNoise;
- if (tmp32 > 32767)
- {
+ if (tmp32 > 32767) {
tmp32 = 32767;
aecm->noiseEst[i] = tmp32 << shiftFromNearToNoise;
}
@@ -750,23 +648,21 @@
WebRtcSpl_RandUArray(randW16, PART_LEN, &aecm->seed);
// Generate noise according to estimated energy.
- uReal[0] = 0; // Reject LF noise.
+ uReal[0] = 0; // Reject LF noise.
uImag[0] = 0;
- for (i = 1; i < PART_LEN1; i++)
- {
+ for (i = 1; i < PART_LEN1; i++) {
// Get a random index for the cos and sin tables over [0 359].
tmp16 = (int16_t)((359 * randW16[i - 1]) >> 15);
// Tables are in Q13.
- uReal[i] = (int16_t)((noiseRShift16[i] * WebRtcAecm_kCosTable[tmp16]) >>
- 13);
- uImag[i] = (int16_t)((-noiseRShift16[i] * WebRtcAecm_kSinTable[tmp16]) >>
- 13);
+ uReal[i] =
+ (int16_t)((noiseRShift16[i] * WebRtcAecm_kCosTable[tmp16]) >> 13);
+ uImag[i] =
+ (int16_t)((-noiseRShift16[i] * WebRtcAecm_kSinTable[tmp16]) >> 13);
}
uImag[PART_LEN] = 0;
- for (i = 0; i < PART_LEN1; i++)
- {
+ for (i = 0; i < PART_LEN1; i++) {
out[i].real = WebRtcSpl_AddSatW16(out[i].real, uReal[i]);
out[i].imag = WebRtcSpl_AddSatW16(out[i].imag, uImag[i]);
}
diff --git a/modules/audio_processing/aecm/aecm_core_mips.cc b/modules/audio_processing/aecm/aecm_core_mips.cc
index 58e5ec5..11e4095 100644
--- a/modules/audio_processing/aecm/aecm_core_mips.cc
+++ b/modules/audio_processing/aecm/aecm_core_mips.cc
@@ -16,56 +16,37 @@
#include "rtc_base/numerics/safe_conversions.h"
static const ALIGN8_BEG int16_t WebRtcAecm_kSqrtHanning[] ALIGN8_END = {
- 0, 399, 798, 1196, 1594, 1990, 2386, 2780, 3172,
- 3562, 3951, 4337, 4720, 5101, 5478, 5853, 6224,
- 6591, 6954, 7313, 7668, 8019, 8364, 8705, 9040,
- 9370, 9695, 10013, 10326, 10633, 10933, 11227, 11514,
- 11795, 12068, 12335, 12594, 12845, 13089, 13325, 13553,
- 13773, 13985, 14189, 14384, 14571, 14749, 14918, 15079,
- 15231, 15373, 15506, 15631, 15746, 15851, 15947, 16034,
- 16111, 16179, 16237, 16286, 16325, 16354, 16373, 16384
-};
+ 0, 399, 798, 1196, 1594, 1990, 2386, 2780, 3172, 3562, 3951,
+ 4337, 4720, 5101, 5478, 5853, 6224, 6591, 6954, 7313, 7668, 8019,
+ 8364, 8705, 9040, 9370, 9695, 10013, 10326, 10633, 10933, 11227, 11514,
+ 11795, 12068, 12335, 12594, 12845, 13089, 13325, 13553, 13773, 13985, 14189,
+ 14384, 14571, 14749, 14918, 15079, 15231, 15373, 15506, 15631, 15746, 15851,
+ 15947, 16034, 16111, 16179, 16237, 16286, 16325, 16354, 16373, 16384};
static const int16_t kNoiseEstQDomain = 15;
static const int16_t kNoiseEstIncCount = 5;
static int16_t coefTable[] = {
- 0, 4, 256, 260, 128, 132, 384, 388,
- 64, 68, 320, 324, 192, 196, 448, 452,
- 32, 36, 288, 292, 160, 164, 416, 420,
- 96, 100, 352, 356, 224, 228, 480, 484,
- 16, 20, 272, 276, 144, 148, 400, 404,
- 80, 84, 336, 340, 208, 212, 464, 468,
- 48, 52, 304, 308, 176, 180, 432, 436,
- 112, 116, 368, 372, 240, 244, 496, 500,
- 8, 12, 264, 268, 136, 140, 392, 396,
- 72, 76, 328, 332, 200, 204, 456, 460,
- 40, 44, 296, 300, 168, 172, 424, 428,
- 104, 108, 360, 364, 232, 236, 488, 492,
- 24, 28, 280, 284, 152, 156, 408, 412,
- 88, 92, 344, 348, 216, 220, 472, 476,
- 56, 60, 312, 316, 184, 188, 440, 444,
- 120, 124, 376, 380, 248, 252, 504, 508
-};
+ 0, 4, 256, 260, 128, 132, 384, 388, 64, 68, 320, 324, 192, 196, 448,
+ 452, 32, 36, 288, 292, 160, 164, 416, 420, 96, 100, 352, 356, 224, 228,
+ 480, 484, 16, 20, 272, 276, 144, 148, 400, 404, 80, 84, 336, 340, 208,
+ 212, 464, 468, 48, 52, 304, 308, 176, 180, 432, 436, 112, 116, 368, 372,
+ 240, 244, 496, 500, 8, 12, 264, 268, 136, 140, 392, 396, 72, 76, 328,
+ 332, 200, 204, 456, 460, 40, 44, 296, 300, 168, 172, 424, 428, 104, 108,
+ 360, 364, 232, 236, 488, 492, 24, 28, 280, 284, 152, 156, 408, 412, 88,
+ 92, 344, 348, 216, 220, 472, 476, 56, 60, 312, 316, 184, 188, 440, 444,
+ 120, 124, 376, 380, 248, 252, 504, 508};
static int16_t coefTable_ifft[] = {
- 0, 512, 256, 508, 128, 252, 384, 380,
- 64, 124, 320, 444, 192, 188, 448, 316,
- 32, 60, 288, 476, 160, 220, 416, 348,
- 96, 92, 352, 412, 224, 156, 480, 284,
- 16, 28, 272, 492, 144, 236, 400, 364,
- 80, 108, 336, 428, 208, 172, 464, 300,
- 48, 44, 304, 460, 176, 204, 432, 332,
- 112, 76, 368, 396, 240, 140, 496, 268,
- 8, 12, 264, 500, 136, 244, 392, 372,
- 72, 116, 328, 436, 200, 180, 456, 308,
- 40, 52, 296, 468, 168, 212, 424, 340,
- 104, 84, 360, 404, 232, 148, 488, 276,
- 24, 20, 280, 484, 152, 228, 408, 356,
- 88, 100, 344, 420, 216, 164, 472, 292,
- 56, 36, 312, 452, 184, 196, 440, 324,
- 120, 68, 376, 388, 248, 132, 504, 260
-};
+ 0, 512, 256, 508, 128, 252, 384, 380, 64, 124, 320, 444, 192, 188, 448,
+ 316, 32, 60, 288, 476, 160, 220, 416, 348, 96, 92, 352, 412, 224, 156,
+ 480, 284, 16, 28, 272, 492, 144, 236, 400, 364, 80, 108, 336, 428, 208,
+ 172, 464, 300, 48, 44, 304, 460, 176, 204, 432, 332, 112, 76, 368, 396,
+ 240, 140, 496, 268, 8, 12, 264, 500, 136, 244, 392, 372, 72, 116, 328,
+ 436, 200, 180, 456, 308, 40, 52, 296, 468, 168, 212, 424, 340, 104, 84,
+ 360, 404, 232, 148, 488, 276, 24, 20, 280, 484, 152, 228, 408, 356, 88,
+ 100, 344, 420, 216, 164, 472, 292, 56, 36, 312, 452, 184, 196, 440, 324,
+ 120, 68, 376, 388, 248, 132, 504, 260};
static void ComfortNoise(AecmCore* aecm,
const uint16_t* dfa,
@@ -81,122 +62,152 @@
int32_t tmp1, tmp2, tmp3, tmp4;
int16_t* pfrfi;
ComplexInt16* pfreq_signal;
- int16_t f_coef, s_coef;
+ int16_t f_coef, s_coef;
int32_t load_ptr, store_ptr1, store_ptr2, shift, shift1;
int32_t hann, hann1, coefs;
memset(fft, 0, sizeof(int16_t) * PART_LEN4);
// FFT of signal
- __asm __volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "addiu %[shift], %[time_signal_scaling], -14 \n\t"
- "addiu %[i], $zero, 64 \n\t"
- "addiu %[load_ptr], %[time_signal], 0 \n\t"
- "addiu %[hann], %[hanning], 0 \n\t"
- "addiu %[hann1], %[hanning], 128 \n\t"
- "addiu %[coefs], %[coefTable], 0 \n\t"
- "bltz %[shift], 2f \n\t"
- " negu %[shift1], %[shift] \n\t"
- "1: \n\t"
- "lh %[tmp1], 0(%[load_ptr]) \n\t"
- "lh %[tmp2], 0(%[hann]) \n\t"
- "lh %[tmp3], 128(%[load_ptr]) \n\t"
- "lh %[tmp4], 0(%[hann1]) \n\t"
- "addiu %[i], %[i], -1 \n\t"
- "mul %[tmp1], %[tmp1], %[tmp2] \n\t"
- "mul %[tmp3], %[tmp3], %[tmp4] \n\t"
- "lh %[f_coef], 0(%[coefs]) \n\t"
- "lh %[s_coef], 2(%[coefs]) \n\t"
- "addiu %[load_ptr], %[load_ptr], 2 \n\t"
- "addiu %[hann], %[hann], 2 \n\t"
- "addiu %[hann1], %[hann1], -2 \n\t"
- "addu %[store_ptr1], %[fft], %[f_coef] \n\t"
- "addu %[store_ptr2], %[fft], %[s_coef] \n\t"
- "sllv %[tmp1], %[tmp1], %[shift] \n\t"
- "sllv %[tmp3], %[tmp3], %[shift] \n\t"
- "sh %[tmp1], 0(%[store_ptr1]) \n\t"
- "sh %[tmp3], 0(%[store_ptr2]) \n\t"
- "bgtz %[i], 1b \n\t"
- " addiu %[coefs], %[coefs], 4 \n\t"
- "b 3f \n\t"
- " nop \n\t"
- "2: \n\t"
- "lh %[tmp1], 0(%[load_ptr]) \n\t"
- "lh %[tmp2], 0(%[hann]) \n\t"
- "lh %[tmp3], 128(%[load_ptr]) \n\t"
- "lh %[tmp4], 0(%[hann1]) \n\t"
- "addiu %[i], %[i], -1 \n\t"
- "mul %[tmp1], %[tmp1], %[tmp2] \n\t"
- "mul %[tmp3], %[tmp3], %[tmp4] \n\t"
- "lh %[f_coef], 0(%[coefs]) \n\t"
- "lh %[s_coef], 2(%[coefs]) \n\t"
- "addiu %[load_ptr], %[load_ptr], 2 \n\t"
- "addiu %[hann], %[hann], 2 \n\t"
- "addiu %[hann1], %[hann1], -2 \n\t"
- "addu %[store_ptr1], %[fft], %[f_coef] \n\t"
- "addu %[store_ptr2], %[fft], %[s_coef] \n\t"
- "srav %[tmp1], %[tmp1], %[shift1] \n\t"
- "srav %[tmp3], %[tmp3], %[shift1] \n\t"
- "sh %[tmp1], 0(%[store_ptr1]) \n\t"
- "sh %[tmp3], 0(%[store_ptr2]) \n\t"
- "bgtz %[i], 2b \n\t"
- " addiu %[coefs], %[coefs], 4 \n\t"
- "3: \n\t"
- ".set pop \n\t"
- : [load_ptr] "=&r" (load_ptr), [shift] "=&r" (shift), [hann] "=&r" (hann),
- [hann1] "=&r" (hann1), [shift1] "=&r" (shift1), [coefs] "=&r" (coefs),
- [tmp1] "=&r" (tmp1), [tmp2] "=&r" (tmp2), [tmp3] "=&r" (tmp3),
- [tmp4] "=&r" (tmp4), [i] "=&r" (i), [f_coef] "=&r" (f_coef),
- [s_coef] "=&r" (s_coef), [store_ptr1] "=&r" (store_ptr1),
- [store_ptr2] "=&r" (store_ptr2)
- : [time_signal] "r" (time_signal), [coefTable] "r" (coefTable),
- [time_signal_scaling] "r" (time_signal_scaling),
- [hanning] "r" (WebRtcAecm_kSqrtHanning), [fft] "r" (fft)
- : "memory", "hi", "lo"
- );
+ __asm __volatile(
+ ".set push \n\t"
+ ".set noreorder \n\t"
+ "addiu %[shift], %[time_signal_scaling], -14 \n\t"
+ "addiu %[i], $zero, 64 \n\t"
+ "addiu %[load_ptr], %[time_signal], 0 \n\t"
+ "addiu %[hann], %[hanning], 0 \n\t"
+ "addiu %[hann1], %[hanning], 128 \n\t"
+ "addiu %[coefs], %[coefTable], 0 \n\t"
+ "bltz %[shift], 2f \n\t"
+ " negu %[shift1], %[shift] \n\t"
+ "1: "
+ "\n\t"
+ "lh %[tmp1], 0(%[load_ptr]) \n\t"
+ "lh %[tmp2], 0(%[hann]) \n\t"
+ "lh %[tmp3], 128(%[load_ptr]) \n\t"
+ "lh %[tmp4], 0(%[hann1]) \n\t"
+ "addiu %[i], %[i], -1 \n\t"
+ "mul %[tmp1], %[tmp1], %[tmp2] \n\t"
+ "mul %[tmp3], %[tmp3], %[tmp4] \n\t"
+ "lh %[f_coef], 0(%[coefs]) \n\t"
+ "lh %[s_coef], 2(%[coefs]) \n\t"
+ "addiu %[load_ptr], %[load_ptr], 2 \n\t"
+ "addiu %[hann], %[hann], 2 \n\t"
+ "addiu %[hann1], %[hann1], -2 \n\t"
+ "addu %[store_ptr1], %[fft], %[f_coef] \n\t"
+ "addu %[store_ptr2], %[fft], %[s_coef] \n\t"
+ "sllv %[tmp1], %[tmp1], %[shift] \n\t"
+ "sllv %[tmp3], %[tmp3], %[shift] \n\t"
+ "sh %[tmp1], 0(%[store_ptr1]) \n\t"
+ "sh %[tmp3], 0(%[store_ptr2]) \n\t"
+ "bgtz %[i], 1b \n\t"
+ " addiu %[coefs], %[coefs], 4 \n\t"
+ "b 3f \n\t"
+ " nop \n\t"
+ "2: "
+ "\n\t"
+ "lh %[tmp1], 0(%[load_ptr]) \n\t"
+ "lh %[tmp2], 0(%[hann]) \n\t"
+ "lh %[tmp3], 128(%[load_ptr]) \n\t"
+ "lh %[tmp4], 0(%[hann1]) \n\t"
+ "addiu %[i], %[i], -1 \n\t"
+ "mul %[tmp1], %[tmp1], %[tmp2] \n\t"
+ "mul %[tmp3], %[tmp3], %[tmp4] \n\t"
+ "lh %[f_coef], 0(%[coefs]) \n\t"
+ "lh %[s_coef], 2(%[coefs]) \n\t"
+ "addiu %[load_ptr], %[load_ptr], 2 \n\t"
+ "addiu %[hann], %[hann], 2 \n\t"
+ "addiu %[hann1], %[hann1], -2 \n\t"
+ "addu %[store_ptr1], %[fft], %[f_coef] \n\t"
+ "addu %[store_ptr2], %[fft], %[s_coef] \n\t"
+ "srav %[tmp1], %[tmp1], %[shift1] \n\t"
+ "srav %[tmp3], %[tmp3], %[shift1] \n\t"
+ "sh %[tmp1], 0(%[store_ptr1]) \n\t"
+ "sh %[tmp3], 0(%[store_ptr2]) \n\t"
+ "bgtz %[i], 2b \n\t"
+ " addiu %[coefs], %[coefs], 4 \n\t"
+ "3: "
+ "\n\t"
+ ".set pop \n\t"
+ : [load_ptr] "=&r"(load_ptr), [shift] "=&r"(shift), [hann] "=&r"(hann),
+ [hann1] "=&r"(hann1), [shift1] "=&r"(shift1), [coefs] "=&r"(coefs),
+ [tmp1] "=&r"(tmp1), [tmp2] "=&r"(tmp2), [tmp3] "=&r"(tmp3),
+ [tmp4] "=&r"(tmp4), [i] "=&r"(i), [f_coef] "=&r"(f_coef),
+ [s_coef] "=&r"(s_coef), [store_ptr1] "=&r"(store_ptr1),
+ [store_ptr2] "=&r"(store_ptr2)
+ : [time_signal] "r"(time_signal), [coefTable] "r"(coefTable),
+ [time_signal_scaling] "r"(time_signal_scaling),
+ [hanning] "r"(WebRtcAecm_kSqrtHanning), [fft] "r"(fft)
+ : "memory", "hi", "lo");
WebRtcSpl_ComplexFFT(fft, PART_LEN_SHIFT, 1);
pfrfi = fft;
pfreq_signal = freq_signal;
- __asm __volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "addiu %[j], $zero, 128 \n\t"
- "1: \n\t"
- "lh %[tmp1], 0(%[pfrfi]) \n\t"
- "lh %[tmp2], 2(%[pfrfi]) \n\t"
- "lh %[tmp3], 4(%[pfrfi]) \n\t"
- "lh %[tmp4], 6(%[pfrfi]) \n\t"
- "subu %[tmp2], $zero, %[tmp2] \n\t"
- "sh %[tmp1], 0(%[pfreq_signal]) \n\t"
- "sh %[tmp2], 2(%[pfreq_signal]) \n\t"
- "subu %[tmp4], $zero, %[tmp4] \n\t"
- "sh %[tmp3], 4(%[pfreq_signal]) \n\t"
- "sh %[tmp4], 6(%[pfreq_signal]) \n\t"
- "lh %[tmp1], 8(%[pfrfi]) \n\t"
- "lh %[tmp2], 10(%[pfrfi]) \n\t"
- "lh %[tmp3], 12(%[pfrfi]) \n\t"
- "lh %[tmp4], 14(%[pfrfi]) \n\t"
- "addiu %[j], %[j], -8 \n\t"
- "subu %[tmp2], $zero, %[tmp2] \n\t"
- "sh %[tmp1], 8(%[pfreq_signal]) \n\t"
- "sh %[tmp2], 10(%[pfreq_signal]) \n\t"
- "subu %[tmp4], $zero, %[tmp4] \n\t"
- "sh %[tmp3], 12(%[pfreq_signal]) \n\t"
- "sh %[tmp4], 14(%[pfreq_signal]) \n\t"
- "addiu %[pfreq_signal], %[pfreq_signal], 16 \n\t"
- "bgtz %[j], 1b \n\t"
- " addiu %[pfrfi], %[pfrfi], 16 \n\t"
- ".set pop \n\t"
- : [tmp1] "=&r" (tmp1), [tmp2] "=&r" (tmp2), [tmp3] "=&r" (tmp3),
- [j] "=&r" (j), [pfrfi] "+r" (pfrfi), [pfreq_signal] "+r" (pfreq_signal),
- [tmp4] "=&r" (tmp4)
- :
- : "memory"
- );
+ __asm __volatile(
+ ".set push "
+ "\n\t"
+ ".set noreorder "
+ "\n\t"
+ "addiu %[j], $zero, 128 "
+ "\n\t"
+ "1: "
+ "\n\t"
+ "lh %[tmp1], 0(%[pfrfi]) "
+ "\n\t"
+ "lh %[tmp2], 2(%[pfrfi]) "
+ "\n\t"
+ "lh %[tmp3], 4(%[pfrfi]) "
+ "\n\t"
+ "lh %[tmp4], 6(%[pfrfi]) "
+ "\n\t"
+ "subu %[tmp2], $zero, %[tmp2] "
+ "\n\t"
+ "sh %[tmp1], 0(%[pfreq_signal]) "
+ "\n\t"
+ "sh %[tmp2], 2(%[pfreq_signal]) "
+ "\n\t"
+ "subu %[tmp4], $zero, %[tmp4] "
+ "\n\t"
+ "sh %[tmp3], 4(%[pfreq_signal]) "
+ "\n\t"
+ "sh %[tmp4], 6(%[pfreq_signal]) "
+ "\n\t"
+ "lh %[tmp1], 8(%[pfrfi]) "
+ "\n\t"
+ "lh %[tmp2], 10(%[pfrfi]) "
+ "\n\t"
+ "lh %[tmp3], 12(%[pfrfi]) "
+ "\n\t"
+ "lh %[tmp4], 14(%[pfrfi]) "
+ "\n\t"
+ "addiu %[j], %[j], -8 "
+ "\n\t"
+ "subu %[tmp2], $zero, %[tmp2] "
+ "\n\t"
+ "sh %[tmp1], 8(%[pfreq_signal]) "
+ "\n\t"
+ "sh %[tmp2], 10(%[pfreq_signal]) "
+ "\n\t"
+ "subu %[tmp4], $zero, %[tmp4] "
+ "\n\t"
+ "sh %[tmp3], 12(%[pfreq_signal]) "
+ "\n\t"
+ "sh %[tmp4], 14(%[pfreq_signal]) "
+ "\n\t"
+ "addiu %[pfreq_signal], %[pfreq_signal], 16 "
+ "\n\t"
+ "bgtz %[j], 1b "
+ "\n\t"
+ " addiu %[pfrfi], %[pfrfi], 16 "
+ "\n\t"
+ ".set pop "
+ "\n\t"
+ : [tmp1] "=&r"(tmp1), [tmp2] "=&r"(tmp2), [tmp3] "=&r"(tmp3),
+ [j] "=&r"(j), [pfrfi] "+r"(pfrfi), [pfreq_signal] "+r"(pfreq_signal),
+ [tmp4] "=&r"(tmp4)
+ :
+ : "memory");
}
static void InverseFFTAndWindow(AecmCore* aecm,
@@ -216,67 +227,118 @@
const int16_t* pp_kSqrtHanning = &WebRtcAecm_kSqrtHanning[PART_LEN];
int16_t* output1 = output;
- __asm __volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "addiu %[i], $zero, 64 \n\t"
- "1: \n\t"
- "lh %[tmp1], 0(%[pcoefTable_ifft]) \n\t"
- "lh %[tmp2], 2(%[pcoefTable_ifft]) \n\t"
- "lh %[tmp_re], 0(%[pefw]) \n\t"
- "lh %[tmp_im], 2(%[pefw]) \n\t"
- "addu %[pfft], %[fft], %[tmp2] \n\t"
- "sh %[tmp_re], 0(%[pfft]) \n\t"
- "sh %[tmp_im], 2(%[pfft]) \n\t"
- "addu %[pfft], %[fft], %[tmp1] \n\t"
- "sh %[tmp_re], 0(%[pfft]) \n\t"
- "subu %[tmp_im], $zero, %[tmp_im] \n\t"
- "sh %[tmp_im], 2(%[pfft]) \n\t"
- "lh %[tmp1], 4(%[pcoefTable_ifft]) \n\t"
- "lh %[tmp2], 6(%[pcoefTable_ifft]) \n\t"
- "lh %[tmp_re], 4(%[pefw]) \n\t"
- "lh %[tmp_im], 6(%[pefw]) \n\t"
- "addu %[pfft], %[fft], %[tmp2] \n\t"
- "sh %[tmp_re], 0(%[pfft]) \n\t"
- "sh %[tmp_im], 2(%[pfft]) \n\t"
- "addu %[pfft], %[fft], %[tmp1] \n\t"
- "sh %[tmp_re], 0(%[pfft]) \n\t"
- "subu %[tmp_im], $zero, %[tmp_im] \n\t"
- "sh %[tmp_im], 2(%[pfft]) \n\t"
- "lh %[tmp1], 8(%[pcoefTable_ifft]) \n\t"
- "lh %[tmp2], 10(%[pcoefTable_ifft]) \n\t"
- "lh %[tmp_re], 8(%[pefw]) \n\t"
- "lh %[tmp_im], 10(%[pefw]) \n\t"
- "addu %[pfft], %[fft], %[tmp2] \n\t"
- "sh %[tmp_re], 0(%[pfft]) \n\t"
- "sh %[tmp_im], 2(%[pfft]) \n\t"
- "addu %[pfft], %[fft], %[tmp1] \n\t"
- "sh %[tmp_re], 0(%[pfft]) \n\t"
- "subu %[tmp_im], $zero, %[tmp_im] \n\t"
- "sh %[tmp_im], 2(%[pfft]) \n\t"
- "lh %[tmp1], 12(%[pcoefTable_ifft]) \n\t"
- "lh %[tmp2], 14(%[pcoefTable_ifft]) \n\t"
- "lh %[tmp_re], 12(%[pefw]) \n\t"
- "lh %[tmp_im], 14(%[pefw]) \n\t"
- "addu %[pfft], %[fft], %[tmp2] \n\t"
- "sh %[tmp_re], 0(%[pfft]) \n\t"
- "sh %[tmp_im], 2(%[pfft]) \n\t"
- "addu %[pfft], %[fft], %[tmp1] \n\t"
- "sh %[tmp_re], 0(%[pfft]) \n\t"
- "subu %[tmp_im], $zero, %[tmp_im] \n\t"
- "sh %[tmp_im], 2(%[pfft]) \n\t"
- "addiu %[pcoefTable_ifft], %[pcoefTable_ifft], 16 \n\t"
- "addiu %[i], %[i], -4 \n\t"
- "bgtz %[i], 1b \n\t"
- " addiu %[pefw], %[pefw], 16 \n\t"
- ".set pop \n\t"
- : [tmp1] "=&r" (tmp1), [tmp2] "=&r" (tmp2), [pfft] "+r" (pfft),
- [i] "=&r" (i), [tmp_re] "=&r" (tmp_re), [tmp_im] "=&r" (tmp_im),
- [pefw] "+r" (pefw), [pcoefTable_ifft] "+r" (pcoefTable_ifft),
- [fft] "+r" (fft)
- :
- : "memory"
- );
+ __asm __volatile(
+ ".set push "
+ "\n\t"
+ ".set noreorder "
+ "\n\t"
+ "addiu %[i], $zero, 64 "
+ "\n\t"
+ "1: "
+ "\n\t"
+ "lh %[tmp1], 0(%[pcoefTable_ifft]) "
+ "\n\t"
+ "lh %[tmp2], 2(%[pcoefTable_ifft]) "
+ "\n\t"
+ "lh %[tmp_re], 0(%[pefw]) "
+ "\n\t"
+ "lh %[tmp_im], 2(%[pefw]) "
+ "\n\t"
+ "addu %[pfft], %[fft], %[tmp2] "
+ "\n\t"
+ "sh %[tmp_re], 0(%[pfft]) "
+ "\n\t"
+ "sh %[tmp_im], 2(%[pfft]) "
+ "\n\t"
+ "addu %[pfft], %[fft], %[tmp1] "
+ "\n\t"
+ "sh %[tmp_re], 0(%[pfft]) "
+ "\n\t"
+ "subu %[tmp_im], $zero, %[tmp_im] "
+ "\n\t"
+ "sh %[tmp_im], 2(%[pfft]) "
+ "\n\t"
+ "lh %[tmp1], 4(%[pcoefTable_ifft]) "
+ "\n\t"
+ "lh %[tmp2], 6(%[pcoefTable_ifft]) "
+ "\n\t"
+ "lh %[tmp_re], 4(%[pefw]) "
+ "\n\t"
+ "lh %[tmp_im], 6(%[pefw]) "
+ "\n\t"
+ "addu %[pfft], %[fft], %[tmp2] "
+ "\n\t"
+ "sh %[tmp_re], 0(%[pfft]) "
+ "\n\t"
+ "sh %[tmp_im], 2(%[pfft]) "
+ "\n\t"
+ "addu %[pfft], %[fft], %[tmp1] "
+ "\n\t"
+ "sh %[tmp_re], 0(%[pfft]) "
+ "\n\t"
+ "subu %[tmp_im], $zero, %[tmp_im] "
+ "\n\t"
+ "sh %[tmp_im], 2(%[pfft]) "
+ "\n\t"
+ "lh %[tmp1], 8(%[pcoefTable_ifft]) "
+ "\n\t"
+ "lh %[tmp2], 10(%[pcoefTable_ifft]) "
+ "\n\t"
+ "lh %[tmp_re], 8(%[pefw]) "
+ "\n\t"
+ "lh %[tmp_im], 10(%[pefw]) "
+ "\n\t"
+ "addu %[pfft], %[fft], %[tmp2] "
+ "\n\t"
+ "sh %[tmp_re], 0(%[pfft]) "
+ "\n\t"
+ "sh %[tmp_im], 2(%[pfft]) "
+ "\n\t"
+ "addu %[pfft], %[fft], %[tmp1] "
+ "\n\t"
+ "sh %[tmp_re], 0(%[pfft]) "
+ "\n\t"
+ "subu %[tmp_im], $zero, %[tmp_im] "
+ "\n\t"
+ "sh %[tmp_im], 2(%[pfft]) "
+ "\n\t"
+ "lh %[tmp1], 12(%[pcoefTable_ifft]) "
+ "\n\t"
+ "lh %[tmp2], 14(%[pcoefTable_ifft]) "
+ "\n\t"
+ "lh %[tmp_re], 12(%[pefw]) "
+ "\n\t"
+ "lh %[tmp_im], 14(%[pefw]) "
+ "\n\t"
+ "addu %[pfft], %[fft], %[tmp2] "
+ "\n\t"
+ "sh %[tmp_re], 0(%[pfft]) "
+ "\n\t"
+ "sh %[tmp_im], 2(%[pfft]) "
+ "\n\t"
+ "addu %[pfft], %[fft], %[tmp1] "
+ "\n\t"
+ "sh %[tmp_re], 0(%[pfft]) "
+ "\n\t"
+ "subu %[tmp_im], $zero, %[tmp_im] "
+ "\n\t"
+ "sh %[tmp_im], 2(%[pfft]) "
+ "\n\t"
+ "addiu %[pcoefTable_ifft], %[pcoefTable_ifft], 16 "
+ "\n\t"
+ "addiu %[i], %[i], -4 "
+ "\n\t"
+ "bgtz %[i], 1b "
+ "\n\t"
+ " addiu %[pefw], %[pefw], 16 "
+ "\n\t"
+ ".set pop "
+ "\n\t"
+ : [tmp1] "=&r"(tmp1), [tmp2] "=&r"(tmp2), [pfft] "+r"(pfft), [i] "=&r"(i),
+ [tmp_re] "=&r"(tmp_re), [tmp_im] "=&r"(tmp_im), [pefw] "+r"(pefw),
+ [pcoefTable_ifft] "+r"(pcoefTable_ifft), [fft] "+r"(fft)
+ :
+ : "memory");
fft[2] = efw[PART_LEN].real;
fft[3] = -efw[PART_LEN].imag;
@@ -284,150 +346,235 @@
outCFFT = WebRtcSpl_ComplexIFFT(fft, PART_LEN_SHIFT, 1);
pfft = fft;
- __asm __volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "addiu %[i], $zero, 128 \n\t"
- "1: \n\t"
- "lh %[tmp1], 0(%[ppfft]) \n\t"
- "lh %[tmp2], 4(%[ppfft]) \n\t"
- "lh %[tmp3], 8(%[ppfft]) \n\t"
- "lh %[tmp4], 12(%[ppfft]) \n\t"
- "addiu %[i], %[i], -4 \n\t"
- "sh %[tmp1], 0(%[pfft]) \n\t"
- "sh %[tmp2], 2(%[pfft]) \n\t"
- "sh %[tmp3], 4(%[pfft]) \n\t"
- "sh %[tmp4], 6(%[pfft]) \n\t"
- "addiu %[ppfft], %[ppfft], 16 \n\t"
- "bgtz %[i], 1b \n\t"
- " addiu %[pfft], %[pfft], 8 \n\t"
- ".set pop \n\t"
- : [tmp1] "=&r" (tmp1), [tmp2] "=&r" (tmp2), [pfft] "+r" (pfft),
- [i] "=&r" (i), [tmp3] "=&r" (tmp3), [tmp4] "=&r" (tmp4),
- [ppfft] "+r" (ppfft)
- :
- : "memory"
- );
+ __asm __volatile(
+ ".set push \n\t"
+ ".set noreorder \n\t"
+ "addiu %[i], $zero, 128 \n\t"
+ "1: \n\t"
+ "lh %[tmp1], 0(%[ppfft]) \n\t"
+ "lh %[tmp2], 4(%[ppfft]) \n\t"
+ "lh %[tmp3], 8(%[ppfft]) \n\t"
+ "lh %[tmp4], 12(%[ppfft]) \n\t"
+ "addiu %[i], %[i], -4 \n\t"
+ "sh %[tmp1], 0(%[pfft]) \n\t"
+ "sh %[tmp2], 2(%[pfft]) \n\t"
+ "sh %[tmp3], 4(%[pfft]) \n\t"
+ "sh %[tmp4], 6(%[pfft]) \n\t"
+ "addiu %[ppfft], %[ppfft], 16 \n\t"
+ "bgtz %[i], 1b \n\t"
+ " addiu %[pfft], %[pfft], 8 \n\t"
+ ".set pop \n\t"
+ : [tmp1] "=&r"(tmp1), [tmp2] "=&r"(tmp2), [pfft] "+r"(pfft), [i] "=&r"(i),
+ [tmp3] "=&r"(tmp3), [tmp4] "=&r"(tmp4), [ppfft] "+r"(ppfft)
+ :
+ : "memory");
pfft = fft;
out_aecm = (int32_t)(outCFFT - aecm->dfaCleanQDomain);
- __asm __volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "addiu %[i], $zero, 64 \n\t"
- "11: \n\t"
- "lh %[tmp1], 0(%[pfft]) \n\t"
- "lh %[tmp2], 0(%[p_kSqrtHanning]) \n\t"
- "addiu %[i], %[i], -2 \n\t"
- "mul %[tmp1], %[tmp1], %[tmp2] \n\t"
- "lh %[tmp3], 2(%[pfft]) \n\t"
- "lh %[tmp4], 2(%[p_kSqrtHanning]) \n\t"
- "mul %[tmp3], %[tmp3], %[tmp4] \n\t"
- "addiu %[tmp1], %[tmp1], 8192 \n\t"
- "sra %[tmp1], %[tmp1], 14 \n\t"
- "addiu %[tmp3], %[tmp3], 8192 \n\t"
- "sra %[tmp3], %[tmp3], 14 \n\t"
- "bgez %[out_aecm], 1f \n\t"
- " negu %[tmp2], %[out_aecm] \n\t"
- "srav %[tmp1], %[tmp1], %[tmp2] \n\t"
- "b 2f \n\t"
- " srav %[tmp3], %[tmp3], %[tmp2] \n\t"
- "1: \n\t"
- "sllv %[tmp1], %[tmp1], %[out_aecm] \n\t"
- "sllv %[tmp3], %[tmp3], %[out_aecm] \n\t"
- "2: \n\t"
- "lh %[tmp4], 0(%[paecm_buf]) \n\t"
- "lh %[tmp2], 2(%[paecm_buf]) \n\t"
- "addu %[tmp3], %[tmp3], %[tmp2] \n\t"
- "addu %[tmp1], %[tmp1], %[tmp4] \n\t"
+ __asm __volatile(
+ ".set push "
+ "\n\t"
+ ".set noreorder "
+ "\n\t"
+ "addiu %[i], $zero, 64 "
+ "\n\t"
+ "11: "
+ "\n\t"
+ "lh %[tmp1], 0(%[pfft]) "
+ "\n\t"
+ "lh %[tmp2], 0(%[p_kSqrtHanning]) "
+ "\n\t"
+ "addiu %[i], %[i], -2 "
+ "\n\t"
+ "mul %[tmp1], %[tmp1], %[tmp2] "
+ "\n\t"
+ "lh %[tmp3], 2(%[pfft]) "
+ "\n\t"
+ "lh %[tmp4], 2(%[p_kSqrtHanning]) "
+ "\n\t"
+ "mul %[tmp3], %[tmp3], %[tmp4] "
+ "\n\t"
+ "addiu %[tmp1], %[tmp1], 8192 "
+ "\n\t"
+ "sra %[tmp1], %[tmp1], 14 "
+ "\n\t"
+ "addiu %[tmp3], %[tmp3], 8192 "
+ "\n\t"
+ "sra %[tmp3], %[tmp3], 14 "
+ "\n\t"
+ "bgez %[out_aecm], 1f "
+ "\n\t"
+ " negu %[tmp2], %[out_aecm] "
+ "\n\t"
+ "srav %[tmp1], %[tmp1], %[tmp2] "
+ "\n\t"
+ "b 2f "
+ "\n\t"
+ " srav %[tmp3], %[tmp3], %[tmp2] "
+ "\n\t"
+ "1: "
+ "\n\t"
+ "sllv %[tmp1], %[tmp1], %[out_aecm] "
+ "\n\t"
+ "sllv %[tmp3], %[tmp3], %[out_aecm] "
+ "\n\t"
+ "2: "
+ "\n\t"
+ "lh %[tmp4], 0(%[paecm_buf]) "
+ "\n\t"
+ "lh %[tmp2], 2(%[paecm_buf]) "
+ "\n\t"
+ "addu %[tmp3], %[tmp3], %[tmp2] "
+ "\n\t"
+ "addu %[tmp1], %[tmp1], %[tmp4] "
+ "\n\t"
#if defined(MIPS_DSP_R1_LE)
- "shll_s.w %[tmp1], %[tmp1], 16 \n\t"
- "sra %[tmp1], %[tmp1], 16 \n\t"
- "shll_s.w %[tmp3], %[tmp3], 16 \n\t"
- "sra %[tmp3], %[tmp3], 16 \n\t"
-#else // #if defined(MIPS_DSP_R1_LE)
- "sra %[tmp4], %[tmp1], 31 \n\t"
- "sra %[tmp2], %[tmp1], 15 \n\t"
- "beq %[tmp4], %[tmp2], 3f \n\t"
- " ori %[tmp2], $zero, 0x7fff \n\t"
- "xor %[tmp1], %[tmp2], %[tmp4] \n\t"
- "3: \n\t"
- "sra %[tmp2], %[tmp3], 31 \n\t"
- "sra %[tmp4], %[tmp3], 15 \n\t"
- "beq %[tmp2], %[tmp4], 4f \n\t"
- " ori %[tmp4], $zero, 0x7fff \n\t"
- "xor %[tmp3], %[tmp4], %[tmp2] \n\t"
- "4: \n\t"
+ "shll_s.w %[tmp1], %[tmp1], 16 "
+ "\n\t"
+ "sra %[tmp1], %[tmp1], 16 "
+ "\n\t"
+ "shll_s.w %[tmp3], %[tmp3], 16 "
+ "\n\t"
+ "sra %[tmp3], %[tmp3], 16 "
+ "\n\t"
+#else // #if defined(MIPS_DSP_R1_LE)
+ "sra %[tmp4], %[tmp1], 31 "
+ "\n\t"
+ "sra %[tmp2], %[tmp1], 15 "
+ "\n\t"
+ "beq %[tmp4], %[tmp2], 3f "
+ "\n\t"
+ " ori %[tmp2], $zero, 0x7fff "
+ "\n\t"
+ "xor %[tmp1], %[tmp2], %[tmp4] "
+ "\n\t"
+ "3: "
+ "\n\t"
+ "sra %[tmp2], %[tmp3], 31 "
+ "\n\t"
+ "sra %[tmp4], %[tmp3], 15 "
+ "\n\t"
+ "beq %[tmp2], %[tmp4], 4f "
+ "\n\t"
+ " ori %[tmp4], $zero, 0x7fff "
+ "\n\t"
+ "xor %[tmp3], %[tmp4], %[tmp2] "
+ "\n\t"
+ "4: "
+ "\n\t"
#endif // #if defined(MIPS_DSP_R1_LE)
- "sh %[tmp1], 0(%[pfft]) \n\t"
- "sh %[tmp1], 0(%[output1]) \n\t"
- "sh %[tmp3], 2(%[pfft]) \n\t"
- "sh %[tmp3], 2(%[output1]) \n\t"
- "lh %[tmp1], 128(%[pfft]) \n\t"
- "lh %[tmp2], 0(%[pp_kSqrtHanning]) \n\t"
- "mul %[tmp1], %[tmp1], %[tmp2] \n\t"
- "lh %[tmp3], 130(%[pfft]) \n\t"
- "lh %[tmp4], -2(%[pp_kSqrtHanning]) \n\t"
- "mul %[tmp3], %[tmp3], %[tmp4] \n\t"
- "sra %[tmp1], %[tmp1], 14 \n\t"
- "sra %[tmp3], %[tmp3], 14 \n\t"
- "bgez %[out_aecm], 5f \n\t"
- " negu %[tmp2], %[out_aecm] \n\t"
- "srav %[tmp3], %[tmp3], %[tmp2] \n\t"
- "b 6f \n\t"
- " srav %[tmp1], %[tmp1], %[tmp2] \n\t"
- "5: \n\t"
- "sllv %[tmp1], %[tmp1], %[out_aecm] \n\t"
- "sllv %[tmp3], %[tmp3], %[out_aecm] \n\t"
- "6: \n\t"
+ "sh %[tmp1], 0(%[pfft]) "
+ "\n\t"
+ "sh %[tmp1], 0(%[output1]) "
+ "\n\t"
+ "sh %[tmp3], 2(%[pfft]) "
+ "\n\t"
+ "sh %[tmp3], 2(%[output1]) "
+ "\n\t"
+ "lh %[tmp1], 128(%[pfft]) "
+ "\n\t"
+ "lh %[tmp2], 0(%[pp_kSqrtHanning]) "
+ "\n\t"
+ "mul %[tmp1], %[tmp1], %[tmp2] "
+ "\n\t"
+ "lh %[tmp3], 130(%[pfft]) "
+ "\n\t"
+ "lh %[tmp4], -2(%[pp_kSqrtHanning]) "
+ "\n\t"
+ "mul %[tmp3], %[tmp3], %[tmp4] "
+ "\n\t"
+ "sra %[tmp1], %[tmp1], 14 "
+ "\n\t"
+ "sra %[tmp3], %[tmp3], 14 "
+ "\n\t"
+ "bgez %[out_aecm], 5f "
+ "\n\t"
+ " negu %[tmp2], %[out_aecm] "
+ "\n\t"
+ "srav %[tmp3], %[tmp3], %[tmp2] "
+ "\n\t"
+ "b 6f "
+ "\n\t"
+ " srav %[tmp1], %[tmp1], %[tmp2] "
+ "\n\t"
+ "5: "
+ "\n\t"
+ "sllv %[tmp1], %[tmp1], %[out_aecm] "
+ "\n\t"
+ "sllv %[tmp3], %[tmp3], %[out_aecm] "
+ "\n\t"
+ "6: "
+ "\n\t"
#if defined(MIPS_DSP_R1_LE)
- "shll_s.w %[tmp1], %[tmp1], 16 \n\t"
- "sra %[tmp1], %[tmp1], 16 \n\t"
- "shll_s.w %[tmp3], %[tmp3], 16 \n\t"
- "sra %[tmp3], %[tmp3], 16 \n\t"
-#else // #if defined(MIPS_DSP_R1_LE)
- "sra %[tmp4], %[tmp1], 31 \n\t"
- "sra %[tmp2], %[tmp1], 15 \n\t"
- "beq %[tmp4], %[tmp2], 7f \n\t"
- " ori %[tmp2], $zero, 0x7fff \n\t"
- "xor %[tmp1], %[tmp2], %[tmp4] \n\t"
- "7: \n\t"
- "sra %[tmp2], %[tmp3], 31 \n\t"
- "sra %[tmp4], %[tmp3], 15 \n\t"
- "beq %[tmp2], %[tmp4], 8f \n\t"
- " ori %[tmp4], $zero, 0x7fff \n\t"
- "xor %[tmp3], %[tmp4], %[tmp2] \n\t"
- "8: \n\t"
+ "shll_s.w %[tmp1], %[tmp1], 16 "
+ "\n\t"
+ "sra %[tmp1], %[tmp1], 16 "
+ "\n\t"
+ "shll_s.w %[tmp3], %[tmp3], 16 "
+ "\n\t"
+ "sra %[tmp3], %[tmp3], 16 "
+ "\n\t"
+#else // #if defined(MIPS_DSP_R1_LE)
+ "sra %[tmp4], %[tmp1], 31 "
+ "\n\t"
+ "sra %[tmp2], %[tmp1], 15 "
+ "\n\t"
+ "beq %[tmp4], %[tmp2], 7f "
+ "\n\t"
+ " ori %[tmp2], $zero, 0x7fff "
+ "\n\t"
+ "xor %[tmp1], %[tmp2], %[tmp4] "
+ "\n\t"
+ "7: "
+ "\n\t"
+ "sra %[tmp2], %[tmp3], 31 "
+ "\n\t"
+ "sra %[tmp4], %[tmp3], 15 "
+ "\n\t"
+ "beq %[tmp2], %[tmp4], 8f "
+ "\n\t"
+ " ori %[tmp4], $zero, 0x7fff "
+ "\n\t"
+ "xor %[tmp3], %[tmp4], %[tmp2] "
+ "\n\t"
+ "8: "
+ "\n\t"
#endif // #if defined(MIPS_DSP_R1_LE)
- "sh %[tmp1], 0(%[paecm_buf]) \n\t"
- "sh %[tmp3], 2(%[paecm_buf]) \n\t"
- "addiu %[output1], %[output1], 4 \n\t"
- "addiu %[paecm_buf], %[paecm_buf], 4 \n\t"
- "addiu %[pfft], %[pfft], 4 \n\t"
- "addiu %[p_kSqrtHanning], %[p_kSqrtHanning], 4 \n\t"
- "bgtz %[i], 11b \n\t"
- " addiu %[pp_kSqrtHanning], %[pp_kSqrtHanning], -4 \n\t"
- ".set pop \n\t"
- : [tmp1] "=&r" (tmp1), [tmp2] "=&r" (tmp2), [pfft] "+r" (pfft),
- [output1] "+r" (output1), [tmp3] "=&r" (tmp3), [tmp4] "=&r" (tmp4),
- [paecm_buf] "+r" (paecm_buf), [i] "=&r" (i),
- [pp_kSqrtHanning] "+r" (pp_kSqrtHanning),
- [p_kSqrtHanning] "+r" (p_kSqrtHanning)
- : [out_aecm] "r" (out_aecm),
- [WebRtcAecm_kSqrtHanning] "r" (WebRtcAecm_kSqrtHanning)
- : "hi", "lo","memory"
- );
+ "sh %[tmp1], 0(%[paecm_buf]) "
+ "\n\t"
+ "sh %[tmp3], 2(%[paecm_buf]) "
+ "\n\t"
+ "addiu %[output1], %[output1], 4 "
+ "\n\t"
+ "addiu %[paecm_buf], %[paecm_buf], 4 "
+ "\n\t"
+ "addiu %[pfft], %[pfft], 4 "
+ "\n\t"
+ "addiu %[p_kSqrtHanning], %[p_kSqrtHanning], 4 "
+ "\n\t"
+ "bgtz %[i], 11b "
+ "\n\t"
+ " addiu %[pp_kSqrtHanning], %[pp_kSqrtHanning], -4 "
+ "\n\t"
+ ".set pop "
+ "\n\t"
+ : [tmp1] "=&r"(tmp1), [tmp2] "=&r"(tmp2), [pfft] "+r"(pfft),
+ [output1] "+r"(output1), [tmp3] "=&r"(tmp3), [tmp4] "=&r"(tmp4),
+ [paecm_buf] "+r"(paecm_buf), [i] "=&r"(i),
+ [pp_kSqrtHanning] "+r"(pp_kSqrtHanning),
+ [p_kSqrtHanning] "+r"(p_kSqrtHanning)
+ : [out_aecm] "r"(out_aecm),
+ [WebRtcAecm_kSqrtHanning] "r"(WebRtcAecm_kSqrtHanning)
+ : "hi", "lo", "memory");
// Copy the current block to the old position
// (aecm->outBuf is shifted elsewhere)
memcpy(aecm->xBuf, aecm->xBuf + PART_LEN, sizeof(int16_t) * PART_LEN);
- memcpy(aecm->dBufNoisy,
- aecm->dBufNoisy + PART_LEN,
+ memcpy(aecm->dBufNoisy, aecm->dBufNoisy + PART_LEN,
sizeof(int16_t) * PART_LEN);
if (nearendClean != NULL) {
- memcpy(aecm->dBufClean,
- aecm->dBufClean + PART_LEN,
+ memcpy(aecm->dBufClean, aecm->dBufClean + PART_LEN,
sizeof(int16_t) * PART_LEN);
}
}
@@ -451,62 +598,61 @@
// Get energy for the delayed far end signal and estimated
// echo using both stored and adapted channels.
- for (i = 0; i < PART_LEN; i+= 4) {
- __asm __volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "lh %[stored0], 0(%[ch_stored_p]) \n\t"
- "lhu %[adept0], 0(%[ch_adapt_p]) \n\t"
- "lhu %[spectrum0], 0(%[spectrum_p]) \n\t"
- "lh %[stored1], 2(%[ch_stored_p]) \n\t"
- "lhu %[adept1], 2(%[ch_adapt_p]) \n\t"
- "lhu %[spectrum1], 2(%[spectrum_p]) \n\t"
- "mul %[echo0], %[stored0], %[spectrum0] \n\t"
- "mul %[temp0], %[adept0], %[spectrum0] \n\t"
- "mul %[echo1], %[stored1], %[spectrum1] \n\t"
- "mul %[temp1], %[adept1], %[spectrum1] \n\t"
- "addu %[par1], %[par1], %[spectrum0] \n\t"
- "addu %[par1], %[par1], %[spectrum1] \n\t"
- "addiu %[echo_p], %[echo_p], 16 \n\t"
- "addu %[par3], %[par3], %[echo0] \n\t"
- "addu %[par2], %[par2], %[temp0] \n\t"
- "addu %[par3], %[par3], %[echo1] \n\t"
- "addu %[par2], %[par2], %[temp1] \n\t"
- "usw %[echo0], -16(%[echo_p]) \n\t"
- "usw %[echo1], -12(%[echo_p]) \n\t"
- "lh %[stored0], 4(%[ch_stored_p]) \n\t"
- "lhu %[adept0], 4(%[ch_adapt_p]) \n\t"
- "lhu %[spectrum0], 4(%[spectrum_p]) \n\t"
- "lh %[stored1], 6(%[ch_stored_p]) \n\t"
- "lhu %[adept1], 6(%[ch_adapt_p]) \n\t"
- "lhu %[spectrum1], 6(%[spectrum_p]) \n\t"
- "mul %[echo0], %[stored0], %[spectrum0] \n\t"
- "mul %[temp0], %[adept0], %[spectrum0] \n\t"
- "mul %[echo1], %[stored1], %[spectrum1] \n\t"
- "mul %[temp1], %[adept1], %[spectrum1] \n\t"
- "addu %[par1], %[par1], %[spectrum0] \n\t"
- "addu %[par1], %[par1], %[spectrum1] \n\t"
- "addiu %[ch_stored_p], %[ch_stored_p], 8 \n\t"
- "addiu %[ch_adapt_p], %[ch_adapt_p], 8 \n\t"
- "addiu %[spectrum_p], %[spectrum_p], 8 \n\t"
- "addu %[par3], %[par3], %[echo0] \n\t"
- "addu %[par2], %[par2], %[temp0] \n\t"
- "addu %[par3], %[par3], %[echo1] \n\t"
- "addu %[par2], %[par2], %[temp1] \n\t"
- "usw %[echo0], -8(%[echo_p]) \n\t"
- "usw %[echo1], -4(%[echo_p]) \n\t"
- ".set pop \n\t"
- : [temp0] "=&r" (temp0), [stored0] "=&r" (stored0),
- [adept0] "=&r" (adept0), [spectrum0] "=&r" (spectrum0),
- [echo0] "=&r" (echo0), [echo_p] "+r" (echo_p), [par3] "+r" (par3),
- [par1] "+r" (par1), [par2] "+r" (par2), [stored1] "=&r" (stored1),
- [adept1] "=&r" (adept1), [echo1] "=&r" (echo1),
- [spectrum1] "=&r" (spectrum1), [temp1] "=&r" (temp1),
- [ch_stored_p] "+r" (ch_stored_p), [ch_adapt_p] "+r" (ch_adapt_p),
- [spectrum_p] "+r" (spectrum_p)
- :
- : "hi", "lo", "memory"
- );
+ for (i = 0; i < PART_LEN; i += 4) {
+ __asm __volatile(
+ ".set push \n\t"
+ ".set noreorder \n\t"
+ "lh %[stored0], 0(%[ch_stored_p]) \n\t"
+ "lhu %[adept0], 0(%[ch_adapt_p]) \n\t"
+ "lhu %[spectrum0], 0(%[spectrum_p]) \n\t"
+ "lh %[stored1], 2(%[ch_stored_p]) \n\t"
+ "lhu %[adept1], 2(%[ch_adapt_p]) \n\t"
+ "lhu %[spectrum1], 2(%[spectrum_p]) \n\t"
+ "mul %[echo0], %[stored0], %[spectrum0] \n\t"
+ "mul %[temp0], %[adept0], %[spectrum0] \n\t"
+ "mul %[echo1], %[stored1], %[spectrum1] \n\t"
+ "mul %[temp1], %[adept1], %[spectrum1] \n\t"
+ "addu %[par1], %[par1], %[spectrum0] \n\t"
+ "addu %[par1], %[par1], %[spectrum1] \n\t"
+ "addiu %[echo_p], %[echo_p], 16 \n\t"
+ "addu %[par3], %[par3], %[echo0] \n\t"
+ "addu %[par2], %[par2], %[temp0] \n\t"
+ "addu %[par3], %[par3], %[echo1] \n\t"
+ "addu %[par2], %[par2], %[temp1] \n\t"
+ "usw %[echo0], -16(%[echo_p]) \n\t"
+ "usw %[echo1], -12(%[echo_p]) \n\t"
+ "lh %[stored0], 4(%[ch_stored_p]) \n\t"
+ "lhu %[adept0], 4(%[ch_adapt_p]) \n\t"
+ "lhu %[spectrum0], 4(%[spectrum_p]) \n\t"
+ "lh %[stored1], 6(%[ch_stored_p]) \n\t"
+ "lhu %[adept1], 6(%[ch_adapt_p]) \n\t"
+ "lhu %[spectrum1], 6(%[spectrum_p]) \n\t"
+ "mul %[echo0], %[stored0], %[spectrum0] \n\t"
+ "mul %[temp0], %[adept0], %[spectrum0] \n\t"
+ "mul %[echo1], %[stored1], %[spectrum1] \n\t"
+ "mul %[temp1], %[adept1], %[spectrum1] \n\t"
+ "addu %[par1], %[par1], %[spectrum0] \n\t"
+ "addu %[par1], %[par1], %[spectrum1] \n\t"
+ "addiu %[ch_stored_p], %[ch_stored_p], 8 \n\t"
+ "addiu %[ch_adapt_p], %[ch_adapt_p], 8 \n\t"
+ "addiu %[spectrum_p], %[spectrum_p], 8 \n\t"
+ "addu %[par3], %[par3], %[echo0] \n\t"
+ "addu %[par2], %[par2], %[temp0] \n\t"
+ "addu %[par3], %[par3], %[echo1] \n\t"
+ "addu %[par2], %[par2], %[temp1] \n\t"
+ "usw %[echo0], -8(%[echo_p]) \n\t"
+ "usw %[echo1], -4(%[echo_p]) \n\t"
+ ".set pop \n\t"
+ : [temp0] "=&r"(temp0), [stored0] "=&r"(stored0),
+ [adept0] "=&r"(adept0), [spectrum0] "=&r"(spectrum0),
+ [echo0] "=&r"(echo0), [echo_p] "+r"(echo_p), [par3] "+r"(par3),
+ [par1] "+r"(par1), [par2] "+r"(par2), [stored1] "=&r"(stored1),
+ [adept1] "=&r"(adept1), [echo1] "=&r"(echo1),
+ [spectrum1] "=&r"(spectrum1), [temp1] "=&r"(temp1),
+ [ch_stored_p] "+r"(ch_stored_p), [ch_adapt_p] "+r"(ch_adapt_p),
+ [spectrum_p] "+r"(spectrum_p)
+ :
+ : "hi", "lo", "memory");
}
echo_est[PART_LEN] = WEBRTC_SPL_MUL_16_U16(aecm->channelStored[PART_LEN],
@@ -537,35 +683,33 @@
sizeof(int16_t) * PART_LEN1);
// Recalculate echo estimate
for (i = 0; i < PART_LEN; i += 4) {
- __asm __volatile (
- "ulw %[temp0], 0(%[temp8]) \n\t"
- "ulw %[temp2], 0(%[temp1]) \n\t"
- "ulw %[temp4], 4(%[temp8]) \n\t"
- "ulw %[temp5], 4(%[temp1]) \n\t"
- "muleq_s.w.phl %[temp3], %[temp2], %[temp0] \n\t"
- "muleq_s.w.phr %[temp0], %[temp2], %[temp0] \n\t"
- "muleq_s.w.phl %[temp6], %[temp5], %[temp4] \n\t"
- "muleq_s.w.phr %[temp4], %[temp5], %[temp4] \n\t"
- "addiu %[temp7], %[temp7], 16 \n\t"
- "addiu %[temp1], %[temp1], 8 \n\t"
- "addiu %[temp8], %[temp8], 8 \n\t"
- "sra %[temp3], %[temp3], 1 \n\t"
- "sra %[temp0], %[temp0], 1 \n\t"
- "sra %[temp6], %[temp6], 1 \n\t"
- "sra %[temp4], %[temp4], 1 \n\t"
- "usw %[temp3], -12(%[temp7]) \n\t"
- "usw %[temp0], -16(%[temp7]) \n\t"
- "usw %[temp6], -4(%[temp7]) \n\t"
- "usw %[temp4], -8(%[temp7]) \n\t"
- : [temp0] "=&r" (temp0), [temp2] "=&r" (temp2), [temp3] "=&r" (temp3),
- [temp4] "=&r" (temp4), [temp5] "=&r" (temp5), [temp6] "=&r" (temp6),
- [temp1] "+r" (temp1), [temp8] "+r" (temp8), [temp7] "+r" (temp7)
- :
- : "hi", "lo", "memory"
- );
+ __asm __volatile(
+ "ulw %[temp0], 0(%[temp8]) \n\t"
+ "ulw %[temp2], 0(%[temp1]) \n\t"
+ "ulw %[temp4], 4(%[temp8]) \n\t"
+ "ulw %[temp5], 4(%[temp1]) \n\t"
+ "muleq_s.w.phl %[temp3], %[temp2], %[temp0] \n\t"
+ "muleq_s.w.phr %[temp0], %[temp2], %[temp0] \n\t"
+ "muleq_s.w.phl %[temp6], %[temp5], %[temp4] \n\t"
+ "muleq_s.w.phr %[temp4], %[temp5], %[temp4] \n\t"
+ "addiu %[temp7], %[temp7], 16 \n\t"
+ "addiu %[temp1], %[temp1], 8 \n\t"
+ "addiu %[temp8], %[temp8], 8 \n\t"
+ "sra %[temp3], %[temp3], 1 \n\t"
+ "sra %[temp0], %[temp0], 1 \n\t"
+ "sra %[temp6], %[temp6], 1 \n\t"
+ "sra %[temp4], %[temp4], 1 \n\t"
+ "usw %[temp3], -12(%[temp7]) \n\t"
+ "usw %[temp0], -16(%[temp7]) \n\t"
+ "usw %[temp6], -4(%[temp7]) \n\t"
+ "usw %[temp4], -8(%[temp7]) \n\t"
+ : [temp0] "=&r"(temp0), [temp2] "=&r"(temp2), [temp3] "=&r"(temp3),
+ [temp4] "=&r"(temp4), [temp5] "=&r"(temp5), [temp6] "=&r"(temp6),
+ [temp1] "+r"(temp1), [temp8] "+r"(temp8), [temp7] "+r"(temp7)
+ :
+ : "hi", "lo", "memory");
}
- echo_est[i] = WEBRTC_SPL_MUL_16_U16(aecm->channelStored[i],
- far_spectrum[i]);
+ echo_est[i] = WEBRTC_SPL_MUL_16_U16(aecm->channelStored[i], far_spectrum[i]);
}
void WebRtcAecm_ResetAdaptiveChannel_mips(AecmCore* aecm) {
@@ -579,31 +723,28 @@
// The stored channel has a significantly lower MSE than the adaptive one for
// two consecutive calculations. Reset the adaptive channel.
- memcpy(aecm->channelAdapt16,
- aecm->channelStored,
+ memcpy(aecm->channelAdapt16, aecm->channelStored,
sizeof(int16_t) * PART_LEN1);
// Restore the W32 channel
for (i = 0; i < PART_LEN; i += 4) {
- __asm __volatile (
- "ulw %[temp1], 0(%[temp0]) \n\t"
- "ulw %[temp4], 4(%[temp0]) \n\t"
- "preceq.w.phl %[temp2], %[temp1] \n\t"
- "preceq.w.phr %[temp1], %[temp1] \n\t"
- "preceq.w.phl %[temp5], %[temp4] \n\t"
- "preceq.w.phr %[temp4], %[temp4] \n\t"
- "addiu %[temp0], %[temp0], 8 \n\t"
- "usw %[temp2], 4(%[temp3]) \n\t"
- "usw %[temp1], 0(%[temp3]) \n\t"
- "usw %[temp5], 12(%[temp3]) \n\t"
- "usw %[temp4], 8(%[temp3]) \n\t"
- "addiu %[temp3], %[temp3], 16 \n\t"
- : [temp1] "=&r" (temp1), [temp2] "=&r" (temp2),
- [temp4] "=&r" (temp4), [temp5] "=&r" (temp5),
- [temp3] "+r" (temp3), [temp0] "+r" (temp0)
- :
- : "memory"
- );
+ __asm __volatile(
+ "ulw %[temp1], 0(%[temp0]) \n\t"
+ "ulw %[temp4], 4(%[temp0]) \n\t"
+ "preceq.w.phl %[temp2], %[temp1] \n\t"
+ "preceq.w.phr %[temp1], %[temp1] \n\t"
+ "preceq.w.phl %[temp5], %[temp4] \n\t"
+ "preceq.w.phr %[temp4], %[temp4] \n\t"
+ "addiu %[temp0], %[temp0], 8 \n\t"
+ "usw %[temp2], 4(%[temp3]) \n\t"
+ "usw %[temp1], 0(%[temp3]) \n\t"
+ "usw %[temp5], 12(%[temp3]) \n\t"
+ "usw %[temp4], 8(%[temp3]) \n\t"
+ "addiu %[temp3], %[temp3], 16 \n\t"
+ : [temp1] "=&r"(temp1), [temp2] "=&r"(temp2), [temp4] "=&r"(temp4),
+ [temp5] "=&r"(temp5), [temp3] "+r"(temp3), [temp0] "+r"(temp0)
+ :
+ : "memory");
}
aecm->channelAdapt32[i] = (int32_t)aecm->channelStored[i] << 16;
@@ -633,7 +774,7 @@
// In fft_buf, +16 for 32-byte alignment.
int16_t fft_buf[PART_LEN4 + 16];
- int16_t *fft = (int16_t *) (((uintptr_t) fft_buf + 31) & ~31);
+ int16_t* fft = (int16_t*)(((uintptr_t)fft_buf + 31) & ~31);
int16_t tmp16no1;
#if !defined(MIPS_DSP_R2_LE)
@@ -662,25 +803,18 @@
freq_signal[PART_LEN].imag = 0;
freq_signal[PART_LEN].real = fft[PART_LEN2];
freq_signal_abs[0] = (uint16_t)WEBRTC_SPL_ABS_W16(freq_signal[0].real);
- freq_signal_abs[PART_LEN] = (uint16_t)WEBRTC_SPL_ABS_W16(
- freq_signal[PART_LEN].real);
- (*freq_signal_sum_abs) = (uint32_t)(freq_signal_abs[0]) +
- (uint32_t)(freq_signal_abs[PART_LEN]);
+ freq_signal_abs[PART_LEN] =
+ (uint16_t)WEBRTC_SPL_ABS_W16(freq_signal[PART_LEN].real);
+ (*freq_signal_sum_abs) =
+ (uint32_t)(freq_signal_abs[0]) + (uint32_t)(freq_signal_abs[PART_LEN]);
#if !defined(MIPS_DSP_R2_LE)
for (i = 1; i < PART_LEN; i++) {
- if (freq_signal[i].real == 0)
- {
- freq_signal_abs[i] = (uint16_t)WEBRTC_SPL_ABS_W16(
- freq_signal[i].imag);
- }
- else if (freq_signal[i].imag == 0)
- {
- freq_signal_abs[i] = (uint16_t)WEBRTC_SPL_ABS_W16(
- freq_signal[i].real);
- }
- else
- {
+ if (freq_signal[i].real == 0) {
+ freq_signal_abs[i] = (uint16_t)WEBRTC_SPL_ABS_W16(freq_signal[i].imag);
+ } else if (freq_signal[i].imag == 0) {
+ freq_signal_abs[i] = (uint16_t)WEBRTC_SPL_ABS_W16(freq_signal[i].real);
+ } else {
// Approximation for magnitude of complex fft output
// magn = sqrt(real^2 + imag^2)
// magn ~= alpha * max(|imag|,|real|) + beta * min(|imag|,|real|)
@@ -697,32 +831,30 @@
}
(*freq_signal_sum_abs) += (uint32_t)freq_signal_abs[i];
}
-#else // #if !defined(MIPS_DSP_R2_LE)
- freqs = (uint32_t)(freq_signal_abs[0]) +
- (uint32_t)(freq_signal_abs[PART_LEN]);
+#else // #if !defined(MIPS_DSP_R2_LE)
+ freqs =
+ (uint32_t)(freq_signal_abs[0]) + (uint32_t)(freq_signal_abs[PART_LEN]);
freqp = &(freq_signal[1].real);
- __asm __volatile (
- "lw %[freqt0], 0(%[freqp]) \n\t"
- "lw %[freqt1], 4(%[freqp]) \n\t"
- "lw %[freqt2], 8(%[freqp]) \n\t"
- "mult $ac0, $zero, $zero \n\t"
- "mult $ac1, $zero, $zero \n\t"
- "mult $ac2, $zero, $zero \n\t"
- "dpaq_s.w.ph $ac0, %[freqt0], %[freqt0] \n\t"
- "dpaq_s.w.ph $ac1, %[freqt1], %[freqt1] \n\t"
- "dpaq_s.w.ph $ac2, %[freqt2], %[freqt2] \n\t"
- "addiu %[freqp], %[freqp], 12 \n\t"
- "extr.w %[tmp32no20], $ac0, 1 \n\t"
- "extr.w %[tmp32no21], $ac1, 1 \n\t"
- "extr.w %[tmp32no22], $ac2, 1 \n\t"
- : [freqt0] "=&r" (freqt0), [freqt1] "=&r" (freqt1),
- [freqt2] "=&r" (freqt2), [freqp] "+r" (freqp),
- [tmp32no20] "=r" (tmp32no20), [tmp32no21] "=r" (tmp32no21),
- [tmp32no22] "=r" (tmp32no22)
- :
- : "memory", "hi", "lo", "$ac1hi", "$ac1lo", "$ac2hi", "$ac2lo"
- );
+ __asm __volatile(
+ "lw %[freqt0], 0(%[freqp]) \n\t"
+ "lw %[freqt1], 4(%[freqp]) \n\t"
+ "lw %[freqt2], 8(%[freqp]) \n\t"
+ "mult $ac0, $zero, $zero \n\t"
+ "mult $ac1, $zero, $zero \n\t"
+ "mult $ac2, $zero, $zero \n\t"
+ "dpaq_s.w.ph $ac0, %[freqt0], %[freqt0] \n\t"
+ "dpaq_s.w.ph $ac1, %[freqt1], %[freqt1] \n\t"
+ "dpaq_s.w.ph $ac2, %[freqt2], %[freqt2] \n\t"
+ "addiu %[freqp], %[freqp], 12 \n\t"
+ "extr.w %[tmp32no20], $ac0, 1 \n\t"
+ "extr.w %[tmp32no21], $ac1, 1 \n\t"
+ "extr.w %[tmp32no22], $ac2, 1 \n\t"
+ : [freqt0] "=&r"(freqt0), [freqt1] "=&r"(freqt1), [freqt2] "=&r"(freqt2),
+ [freqp] "+r"(freqp), [tmp32no20] "=r"(tmp32no20),
+ [tmp32no21] "=r"(tmp32no21), [tmp32no22] "=r"(tmp32no22)
+ :
+ : "memory", "hi", "lo", "$ac1hi", "$ac1lo", "$ac2hi", "$ac2lo");
tmp32no10 = WebRtcSpl_SqrtFloor(tmp32no20);
tmp32no11 = WebRtcSpl_SqrtFloor(tmp32no21);
@@ -734,57 +866,54 @@
freqs += (uint32_t)tmp32no11;
freqs += (uint32_t)tmp32no12;
freqabsp = &(freq_signal_abs[4]);
- for (i = 4; i < PART_LEN; i+=4)
- {
- __asm __volatile (
- "ulw %[freqt0], 0(%[freqp]) \n\t"
- "ulw %[freqt1], 4(%[freqp]) \n\t"
- "ulw %[freqt2], 8(%[freqp]) \n\t"
- "ulw %[freqt3], 12(%[freqp]) \n\t"
- "mult $ac0, $zero, $zero \n\t"
- "mult $ac1, $zero, $zero \n\t"
- "mult $ac2, $zero, $zero \n\t"
- "mult $ac3, $zero, $zero \n\t"
- "dpaq_s.w.ph $ac0, %[freqt0], %[freqt0] \n\t"
- "dpaq_s.w.ph $ac1, %[freqt1], %[freqt1] \n\t"
- "dpaq_s.w.ph $ac2, %[freqt2], %[freqt2] \n\t"
- "dpaq_s.w.ph $ac3, %[freqt3], %[freqt3] \n\t"
- "addiu %[freqp], %[freqp], 16 \n\t"
- "addiu %[freqabsp], %[freqabsp], 8 \n\t"
- "extr.w %[tmp32no20], $ac0, 1 \n\t"
- "extr.w %[tmp32no21], $ac1, 1 \n\t"
- "extr.w %[tmp32no22], $ac2, 1 \n\t"
- "extr.w %[tmp32no23], $ac3, 1 \n\t"
- : [freqt0] "=&r" (freqt0), [freqt1] "=&r" (freqt1),
- [freqt2] "=&r" (freqt2), [freqt3] "=&r" (freqt3),
- [tmp32no20] "=r" (tmp32no20), [tmp32no21] "=r" (tmp32no21),
- [tmp32no22] "=r" (tmp32no22), [tmp32no23] "=r" (tmp32no23),
- [freqabsp] "+r" (freqabsp), [freqp] "+r" (freqp)
- :
- : "memory", "hi", "lo", "$ac1hi", "$ac1lo",
- "$ac2hi", "$ac2lo", "$ac3hi", "$ac3lo"
- );
+ for (i = 4; i < PART_LEN; i += 4) {
+ __asm __volatile(
+ "ulw %[freqt0], 0(%[freqp]) \n\t"
+ "ulw %[freqt1], 4(%[freqp]) \n\t"
+ "ulw %[freqt2], 8(%[freqp]) \n\t"
+ "ulw %[freqt3], 12(%[freqp]) \n\t"
+ "mult $ac0, $zero, $zero \n\t"
+ "mult $ac1, $zero, $zero \n\t"
+ "mult $ac2, $zero, $zero \n\t"
+ "mult $ac3, $zero, $zero \n\t"
+ "dpaq_s.w.ph $ac0, %[freqt0], %[freqt0] \n\t"
+ "dpaq_s.w.ph $ac1, %[freqt1], %[freqt1] \n\t"
+ "dpaq_s.w.ph $ac2, %[freqt2], %[freqt2] \n\t"
+ "dpaq_s.w.ph $ac3, %[freqt3], %[freqt3] \n\t"
+ "addiu %[freqp], %[freqp], 16 \n\t"
+ "addiu %[freqabsp], %[freqabsp], 8 \n\t"
+ "extr.w %[tmp32no20], $ac0, 1 \n\t"
+ "extr.w %[tmp32no21], $ac1, 1 \n\t"
+ "extr.w %[tmp32no22], $ac2, 1 \n\t"
+ "extr.w %[tmp32no23], $ac3, 1 \n\t"
+ : [freqt0] "=&r"(freqt0), [freqt1] "=&r"(freqt1),
+ [freqt2] "=&r"(freqt2), [freqt3] "=&r"(freqt3),
+ [tmp32no20] "=r"(tmp32no20), [tmp32no21] "=r"(tmp32no21),
+ [tmp32no22] "=r"(tmp32no22), [tmp32no23] "=r"(tmp32no23),
+ [freqabsp] "+r"(freqabsp), [freqp] "+r"(freqp)
+ :
+ : "memory", "hi", "lo", "$ac1hi", "$ac1lo", "$ac2hi", "$ac2lo",
+ "$ac3hi", "$ac3lo");
tmp32no10 = WebRtcSpl_SqrtFloor(tmp32no20);
tmp32no11 = WebRtcSpl_SqrtFloor(tmp32no21);
tmp32no12 = WebRtcSpl_SqrtFloor(tmp32no22);
tmp32no13 = WebRtcSpl_SqrtFloor(tmp32no23);
- __asm __volatile (
- "sh %[tmp32no10], -8(%[freqabsp]) \n\t"
- "sh %[tmp32no11], -6(%[freqabsp]) \n\t"
- "sh %[tmp32no12], -4(%[freqabsp]) \n\t"
- "sh %[tmp32no13], -2(%[freqabsp]) \n\t"
- "addu %[freqs], %[freqs], %[tmp32no10] \n\t"
- "addu %[freqs], %[freqs], %[tmp32no11] \n\t"
- "addu %[freqs], %[freqs], %[tmp32no12] \n\t"
- "addu %[freqs], %[freqs], %[tmp32no13] \n\t"
- : [freqs] "+r" (freqs)
- : [tmp32no10] "r" (tmp32no10), [tmp32no11] "r" (tmp32no11),
- [tmp32no12] "r" (tmp32no12), [tmp32no13] "r" (tmp32no13),
- [freqabsp] "r" (freqabsp)
- : "memory"
- );
+ __asm __volatile(
+ "sh %[tmp32no10], -8(%[freqabsp]) \n\t"
+ "sh %[tmp32no11], -6(%[freqabsp]) \n\t"
+ "sh %[tmp32no12], -4(%[freqabsp]) \n\t"
+ "sh %[tmp32no13], -2(%[freqabsp]) \n\t"
+ "addu %[freqs], %[freqs], %[tmp32no10] \n\t"
+ "addu %[freqs], %[freqs], %[tmp32no11] \n\t"
+ "addu %[freqs], %[freqs], %[tmp32no12] \n\t"
+ "addu %[freqs], %[freqs], %[tmp32no13] \n\t"
+ : [freqs] "+r"(freqs)
+ : [tmp32no10] "r"(tmp32no10), [tmp32no11] "r"(tmp32no11),
+ [tmp32no12] "r"(tmp32no12), [tmp32no13] "r"(tmp32no13),
+ [freqabsp] "r"(freqabsp)
+ : "memory");
}
(*freq_signal_sum_abs) = freqs;
@@ -813,13 +942,13 @@
const uint16_t* far_spectrum_ptr = NULL;
// 32 byte aligned buffers (with +8 or +16).
- int16_t fft_buf[PART_LEN4 + 2 + 16]; // +2 to make a loop safe.
+ int16_t fft_buf[PART_LEN4 + 2 + 16]; // +2 to make a loop safe.
int32_t echoEst32_buf[PART_LEN1 + 8];
int32_t dfw_buf[PART_LEN2 + 8];
int32_t efw_buf[PART_LEN2 + 8];
- int16_t* fft = (int16_t*)(((uint32_t)fft_buf + 31) & ~ 31);
- int32_t* echoEst32 = (int32_t*)(((uint32_t)echoEst32_buf + 31) & ~ 31);
+ int16_t* fft = (int16_t*)(((uint32_t)fft_buf + 31) & ~31);
+ int32_t* echoEst32 = (int32_t*)(((uint32_t)echoEst32_buf + 31) & ~31);
ComplexInt16* dfw = (ComplexInt16*)(((uint32_t)dfw_buf + 31) & ~31);
ComplexInt16* efw = (ComplexInt16*)(((uint32_t)efw_buf + 31) & ~31);
@@ -856,35 +985,25 @@
// (2) the rest
if (aecm->startupState < 2) {
- aecm->startupState = (aecm->totCount >= CONV_LEN) +
- (aecm->totCount >= CONV_LEN2);
+ aecm->startupState =
+ (aecm->totCount >= CONV_LEN) + (aecm->totCount >= CONV_LEN2);
}
// END: Determine startup state
// Buffer near and far end signals
memcpy(aecm->xBuf + PART_LEN, farend, sizeof(int16_t) * PART_LEN);
- memcpy(aecm->dBufNoisy + PART_LEN,
- nearendNoisy,
- sizeof(int16_t) * PART_LEN);
+ memcpy(aecm->dBufNoisy + PART_LEN, nearendNoisy, sizeof(int16_t) * PART_LEN);
if (nearendClean != NULL) {
- memcpy(aecm->dBufClean + PART_LEN,
- nearendClean,
+ memcpy(aecm->dBufClean + PART_LEN, nearendClean,
sizeof(int16_t) * PART_LEN);
}
// Transform far end signal from time domain to frequency domain.
- far_q = TimeToFrequencyDomain(aecm,
- aecm->xBuf,
- dfw,
- xfa,
- &xfaSum);
+ far_q = TimeToFrequencyDomain(aecm, aecm->xBuf, dfw, xfa, &xfaSum);
// Transform noisy near end signal from time domain to frequency domain.
- zerosDBufNoisy = TimeToFrequencyDomain(aecm,
- aecm->dBufNoisy,
- dfw,
- dfaNoisy,
- &dfaNoisySum);
+ zerosDBufNoisy =
+ TimeToFrequencyDomain(aecm, aecm->dBufNoisy, dfw, dfaNoisy, &dfaNoisySum);
aecm->dfaNoisyQDomainOld = aecm->dfaNoisyQDomain;
aecm->dfaNoisyQDomain = (int16_t)zerosDBufNoisy;
@@ -895,10 +1014,7 @@
dfaCleanSum = dfaNoisySum;
} else {
// Transform clean near end signal from time domain to frequency domain.
- zerosDBufClean = TimeToFrequencyDomain(aecm,
- aecm->dBufClean,
- dfw,
- dfaClean,
+ zerosDBufClean = TimeToFrequencyDomain(aecm, aecm->dBufClean, dfw, dfaClean,
&dfaCleanSum);
aecm->dfaCleanQDomainOld = aecm->dfaCleanQDomain;
aecm->dfaCleanQDomain = (int16_t)zerosDBufClean;
@@ -912,14 +1028,11 @@
far_q) == -1) {
return -1;
}
- delay = WebRtc_DelayEstimatorProcessFix(aecm->delay_estimator,
- dfaNoisy,
- PART_LEN1,
- zerosDBufNoisy);
+ delay = WebRtc_DelayEstimatorProcessFix(aecm->delay_estimator, dfaNoisy,
+ PART_LEN1, zerosDBufNoisy);
if (delay == -1) {
return -1;
- }
- else if (delay == -2) {
+ } else if (delay == -2) {
// If the delay is unknown, we assume zero.
// NOTE: this will have to be adjusted if we ever add lookahead.
delay = 0;
@@ -932,17 +1045,14 @@
// Get aligned far end spectrum
far_spectrum_ptr = WebRtcAecm_AlignedFarend(aecm, &far_q, delay);
- zerosXBuf = (int16_t) far_q;
+ zerosXBuf = (int16_t)far_q;
if (far_spectrum_ptr == NULL) {
return -1;
}
// Calculate log(energy) and update energy threshold levels
- WebRtcAecm_CalcEnergies(aecm,
- far_spectrum_ptr,
- zerosXBuf,
- dfaNoisySum,
+ WebRtcAecm_CalcEnergies(aecm, far_spectrum_ptr, zerosXBuf, dfaNoisySum,
echoEst32);
// Calculate stepsize
mu = WebRtcAecm_CalcStepSize(aecm);
@@ -953,11 +1063,7 @@
// This is the channel estimation algorithm.
// It is base on NLMS but has a variable step length,
// which was calculated above.
- WebRtcAecm_UpdateChannel(aecm,
- far_spectrum_ptr,
- zerosXBuf,
- dfaNoisy,
- mu,
+ WebRtcAecm_UpdateChannel(aecm, far_spectrum_ptr, zerosXBuf, dfaNoisy, mu,
echoEst32);
supGain = WebRtcAecm_CalcSuppressionGain(aecm);
@@ -976,19 +1082,18 @@
// Multiplication is safe
// Result in
// Q(RESOLUTION_CHANNEL+RESOLUTION_SUPGAIN+aecm->xfaQDomainBuf[diff])
- echoEst32Gained = WEBRTC_SPL_UMUL_32_16((uint32_t)aecm->echoFilt[i],
- (uint16_t)supGain);
+ echoEst32Gained =
+ WEBRTC_SPL_UMUL_32_16((uint32_t)aecm->echoFilt[i], (uint16_t)supGain);
resolutionDiff = 14 - RESOLUTION_CHANNEL16 - RESOLUTION_SUPGAIN;
resolutionDiff += (aecm->dfaCleanQDomain - zerosXBuf);
} else {
tmp16no1 = 17 - zeros32 - zeros16;
- resolutionDiff = 14 + tmp16no1 - RESOLUTION_CHANNEL16 -
- RESOLUTION_SUPGAIN;
+ resolutionDiff =
+ 14 + tmp16no1 - RESOLUTION_CHANNEL16 - RESOLUTION_SUPGAIN;
resolutionDiff += (aecm->dfaCleanQDomain - zerosXBuf);
if (zeros32 > tmp16no1) {
- echoEst32Gained = WEBRTC_SPL_UMUL_32_16(
- (uint32_t)aecm->echoFilt[i],
- supGain >> tmp16no1);
+ echoEst32Gained = WEBRTC_SPL_UMUL_32_16((uint32_t)aecm->echoFilt[i],
+ supGain >> tmp16no1);
} else {
// Result in Q-(RESOLUTION_CHANNEL+RESOLUTION_SUPGAIN-16)
echoEst32Gained = (aecm->echoFilt[i] >> tmp16no1) * supGain;
@@ -1004,8 +1109,8 @@
tmp16no2 = ptrDfaClean[i] >> -qDomainDiff;
} else {
tmp16no1 = dfa_clean_q_domain_diff < 0
- ? aecm->nearFilt[i] >> -dfa_clean_q_domain_diff
- : aecm->nearFilt[i] << dfa_clean_q_domain_diff;
+ ? aecm->nearFilt[i] >> -dfa_clean_q_domain_diff
+ : aecm->nearFilt[i] << dfa_clean_q_domain_diff;
qDomainDiff = 0;
tmp16no2 = ptrDfaClean[i];
}
@@ -1017,8 +1122,8 @@
if ((tmp16no2) & (-qDomainDiff > zeros16)) {
aecm->nearFilt[i] = WEBRTC_SPL_WORD16_MAX;
} else {
- aecm->nearFilt[i] = qDomainDiff < 0 ? tmp16no2 << -qDomainDiff
- : tmp16no2 >> qDomainDiff;
+ aecm->nearFilt[i] =
+ qDomainDiff < 0 ? tmp16no2 << -qDomainDiff : tmp16no2 >> qDomainDiff;
}
// Wiener filter coefficients, resulting hnl in Q14
@@ -1031,8 +1136,8 @@
// Multiply the suppression gain
// Rounding
echoEst32Gained += (uint32_t)(aecm->nearFilt[i] >> 1);
- tmpU32 = WebRtcSpl_DivU32U16(echoEst32Gained,
- (uint16_t)aecm->nearFilt[i]);
+ tmpU32 =
+ WebRtcSpl_DivU32U16(echoEst32Gained, (uint16_t)aecm->nearFilt[i]);
// Current resolution is
// Q-(RESOLUTION_CHANNEL + RESOLUTION_SUPGAIN
@@ -1062,58 +1167,56 @@
// TODO(bjornv): Investigate if the scaling of hnl[i] below can cause
// speech distortion in double-talk.
for (i = 0; i < (PART_LEN1 >> 3); i++) {
- __asm __volatile (
- "lh %[temp1], 0(%[ptr1]) \n\t"
- "lh %[temp2], 2(%[ptr1]) \n\t"
- "lh %[temp3], 4(%[ptr1]) \n\t"
- "lh %[temp4], 6(%[ptr1]) \n\t"
- "lh %[temp5], 8(%[ptr1]) \n\t"
- "lh %[temp6], 10(%[ptr1]) \n\t"
- "lh %[temp7], 12(%[ptr1]) \n\t"
- "lh %[temp8], 14(%[ptr1]) \n\t"
- "mul %[temp1], %[temp1], %[temp1] \n\t"
- "mul %[temp2], %[temp2], %[temp2] \n\t"
- "mul %[temp3], %[temp3], %[temp3] \n\t"
- "mul %[temp4], %[temp4], %[temp4] \n\t"
- "mul %[temp5], %[temp5], %[temp5] \n\t"
- "mul %[temp6], %[temp6], %[temp6] \n\t"
- "mul %[temp7], %[temp7], %[temp7] \n\t"
- "mul %[temp8], %[temp8], %[temp8] \n\t"
- "sra %[temp1], %[temp1], 14 \n\t"
- "sra %[temp2], %[temp2], 14 \n\t"
- "sra %[temp3], %[temp3], 14 \n\t"
- "sra %[temp4], %[temp4], 14 \n\t"
- "sra %[temp5], %[temp5], 14 \n\t"
- "sra %[temp6], %[temp6], 14 \n\t"
- "sra %[temp7], %[temp7], 14 \n\t"
- "sra %[temp8], %[temp8], 14 \n\t"
- "sh %[temp1], 0(%[ptr1]) \n\t"
- "sh %[temp2], 2(%[ptr1]) \n\t"
- "sh %[temp3], 4(%[ptr1]) \n\t"
- "sh %[temp4], 6(%[ptr1]) \n\t"
- "sh %[temp5], 8(%[ptr1]) \n\t"
- "sh %[temp6], 10(%[ptr1]) \n\t"
- "sh %[temp7], 12(%[ptr1]) \n\t"
- "sh %[temp8], 14(%[ptr1]) \n\t"
- "addiu %[ptr1], %[ptr1], 16 \n\t"
- : [temp1] "=&r" (temp1), [temp2] "=&r" (temp2), [temp3] "=&r" (temp3),
- [temp4] "=&r" (temp4), [temp5] "=&r" (temp5), [temp6] "=&r" (temp6),
- [temp7] "=&r" (temp7), [temp8] "=&r" (temp8), [ptr1] "+r" (ptr1)
- :
- : "memory", "hi", "lo"
- );
+ __asm __volatile(
+ "lh %[temp1], 0(%[ptr1]) \n\t"
+ "lh %[temp2], 2(%[ptr1]) \n\t"
+ "lh %[temp3], 4(%[ptr1]) \n\t"
+ "lh %[temp4], 6(%[ptr1]) \n\t"
+ "lh %[temp5], 8(%[ptr1]) \n\t"
+ "lh %[temp6], 10(%[ptr1]) \n\t"
+ "lh %[temp7], 12(%[ptr1]) \n\t"
+ "lh %[temp8], 14(%[ptr1]) \n\t"
+ "mul %[temp1], %[temp1], %[temp1] \n\t"
+ "mul %[temp2], %[temp2], %[temp2] \n\t"
+ "mul %[temp3], %[temp3], %[temp3] \n\t"
+ "mul %[temp4], %[temp4], %[temp4] \n\t"
+ "mul %[temp5], %[temp5], %[temp5] \n\t"
+ "mul %[temp6], %[temp6], %[temp6] \n\t"
+ "mul %[temp7], %[temp7], %[temp7] \n\t"
+ "mul %[temp8], %[temp8], %[temp8] \n\t"
+ "sra %[temp1], %[temp1], 14 \n\t"
+ "sra %[temp2], %[temp2], 14 \n\t"
+ "sra %[temp3], %[temp3], 14 \n\t"
+ "sra %[temp4], %[temp4], 14 \n\t"
+ "sra %[temp5], %[temp5], 14 \n\t"
+ "sra %[temp6], %[temp6], 14 \n\t"
+ "sra %[temp7], %[temp7], 14 \n\t"
+ "sra %[temp8], %[temp8], 14 \n\t"
+ "sh %[temp1], 0(%[ptr1]) \n\t"
+ "sh %[temp2], 2(%[ptr1]) \n\t"
+ "sh %[temp3], 4(%[ptr1]) \n\t"
+ "sh %[temp4], 6(%[ptr1]) \n\t"
+ "sh %[temp5], 8(%[ptr1]) \n\t"
+ "sh %[temp6], 10(%[ptr1]) \n\t"
+ "sh %[temp7], 12(%[ptr1]) \n\t"
+ "sh %[temp8], 14(%[ptr1]) \n\t"
+ "addiu %[ptr1], %[ptr1], 16 \n\t"
+ : [temp1] "=&r"(temp1), [temp2] "=&r"(temp2), [temp3] "=&r"(temp3),
+ [temp4] "=&r"(temp4), [temp5] "=&r"(temp5), [temp6] "=&r"(temp6),
+ [temp7] "=&r"(temp7), [temp8] "=&r"(temp8), [ptr1] "+r"(ptr1)
+ :
+ : "memory", "hi", "lo");
}
- for(i = 0; i < (PART_LEN1 & 7); i++) {
- __asm __volatile (
- "lh %[temp1], 0(%[ptr1]) \n\t"
- "mul %[temp1], %[temp1], %[temp1] \n\t"
- "sra %[temp1], %[temp1], 14 \n\t"
- "sh %[temp1], 0(%[ptr1]) \n\t"
- "addiu %[ptr1], %[ptr1], 2 \n\t"
- : [temp1] "=&r" (temp1), [ptr1] "+r" (ptr1)
- :
- : "memory", "hi", "lo"
- );
+ for (i = 0; i < (PART_LEN1 & 7); i++) {
+ __asm __volatile(
+ "lh %[temp1], 0(%[ptr1]) \n\t"
+ "mul %[temp1], %[temp1], %[temp1] \n\t"
+ "sra %[temp1], %[temp1], 14 \n\t"
+ "sh %[temp1], 0(%[ptr1]) \n\t"
+ "addiu %[ptr1], %[ptr1], 2 \n\t"
+ : [temp1] "=&r"(temp1), [ptr1] "+r"(ptr1)
+ :
+ : "memory", "hi", "lo");
}
for (i = kMinPrefBand; i <= kMaxPrefBand; i++) {
@@ -1141,102 +1244,95 @@
} else {
for (i = 0; i < PART_LEN1; i++) {
#if defined(MIPS_DSP_R1_LE)
- __asm __volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "lh %[temp1], 0(%[ptr]) \n\t"
- "lh %[temp2], 0(%[dr_ptr]) \n\t"
- "slti %[temp4], %[temp1], 0x4001 \n\t"
- "beqz %[temp4], 3f \n\t"
- " lh %[temp3], 2(%[dr_ptr]) \n\t"
- "slti %[temp5], %[temp1], 3277 \n\t"
- "bnez %[temp5], 2f \n\t"
- " addiu %[dr_ptr], %[dr_ptr], 4 \n\t"
- "mul %[temp2], %[temp2], %[temp1] \n\t"
- "mul %[temp3], %[temp3], %[temp1] \n\t"
- "shra_r.w %[temp2], %[temp2], 14 \n\t"
- "shra_r.w %[temp3], %[temp3], 14 \n\t"
- "b 4f \n\t"
- " nop \n\t"
- "2: \n\t"
- "addu %[temp1], $zero, $zero \n\t"
- "addu %[temp2], $zero, $zero \n\t"
- "addu %[temp3], $zero, $zero \n\t"
- "b 1f \n\t"
- " nop \n\t"
- "3: \n\t"
- "addiu %[temp1], $0, 0x4000 \n\t"
- "1: \n\t"
- "sh %[temp1], 0(%[ptr]) \n\t"
- "4: \n\t"
- "sh %[temp2], 0(%[er_ptr]) \n\t"
- "sh %[temp3], 2(%[er_ptr]) \n\t"
- "addiu %[ptr], %[ptr], 2 \n\t"
- "addiu %[er_ptr], %[er_ptr], 4 \n\t"
- ".set pop \n\t"
- : [temp1] "=&r" (temp1), [temp2] "=&r" (temp2), [temp3] "=&r" (temp3),
- [temp4] "=&r" (temp4), [temp5] "=&r" (temp5), [ptr] "+r" (ptr),
- [er_ptr] "+r" (er_ptr), [dr_ptr] "+r" (dr_ptr)
- :
- : "memory", "hi", "lo"
- );
+ __asm __volatile(
+ ".set push \n\t"
+ ".set noreorder \n\t"
+ "lh %[temp1], 0(%[ptr]) \n\t"
+ "lh %[temp2], 0(%[dr_ptr]) \n\t"
+ "slti %[temp4], %[temp1], 0x4001 \n\t"
+ "beqz %[temp4], 3f \n\t"
+ " lh %[temp3], 2(%[dr_ptr]) \n\t"
+ "slti %[temp5], %[temp1], 3277 \n\t"
+ "bnez %[temp5], 2f \n\t"
+ " addiu %[dr_ptr], %[dr_ptr], 4 \n\t"
+ "mul %[temp2], %[temp2], %[temp1] \n\t"
+ "mul %[temp3], %[temp3], %[temp1] \n\t"
+ "shra_r.w %[temp2], %[temp2], 14 \n\t"
+ "shra_r.w %[temp3], %[temp3], 14 \n\t"
+ "b 4f \n\t"
+ " nop \n\t"
+ "2: \n\t"
+ "addu %[temp1], $zero, $zero \n\t"
+ "addu %[temp2], $zero, $zero \n\t"
+ "addu %[temp3], $zero, $zero \n\t"
+ "b 1f \n\t"
+ " nop \n\t"
+ "3: \n\t"
+ "addiu %[temp1], $0, 0x4000 \n\t"
+ "1: \n\t"
+ "sh %[temp1], 0(%[ptr]) \n\t"
+ "4: \n\t"
+ "sh %[temp2], 0(%[er_ptr]) \n\t"
+ "sh %[temp3], 2(%[er_ptr]) \n\t"
+ "addiu %[ptr], %[ptr], 2 \n\t"
+ "addiu %[er_ptr], %[er_ptr], 4 \n\t"
+ ".set pop \n\t"
+ : [temp1] "=&r"(temp1), [temp2] "=&r"(temp2), [temp3] "=&r"(temp3),
+ [temp4] "=&r"(temp4), [temp5] "=&r"(temp5), [ptr] "+r"(ptr),
+ [er_ptr] "+r"(er_ptr), [dr_ptr] "+r"(dr_ptr)
+ :
+ : "memory", "hi", "lo");
#else
- __asm __volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "lh %[temp1], 0(%[ptr]) \n\t"
- "lh %[temp2], 0(%[dr_ptr]) \n\t"
- "slti %[temp4], %[temp1], 0x4001 \n\t"
- "beqz %[temp4], 3f \n\t"
- " lh %[temp3], 2(%[dr_ptr]) \n\t"
- "slti %[temp5], %[temp1], 3277 \n\t"
- "bnez %[temp5], 2f \n\t"
- " addiu %[dr_ptr], %[dr_ptr], 4 \n\t"
- "mul %[temp2], %[temp2], %[temp1] \n\t"
- "mul %[temp3], %[temp3], %[temp1] \n\t"
- "addiu %[temp2], %[temp2], 0x2000 \n\t"
- "addiu %[temp3], %[temp3], 0x2000 \n\t"
- "sra %[temp2], %[temp2], 14 \n\t"
- "sra %[temp3], %[temp3], 14 \n\t"
- "b 4f \n\t"
- " nop \n\t"
- "2: \n\t"
- "addu %[temp1], $zero, $zero \n\t"
- "addu %[temp2], $zero, $zero \n\t"
- "addu %[temp3], $zero, $zero \n\t"
- "b 1f \n\t"
- " nop \n\t"
- "3: \n\t"
- "addiu %[temp1], $0, 0x4000 \n\t"
- "1: \n\t"
- "sh %[temp1], 0(%[ptr]) \n\t"
- "4: \n\t"
- "sh %[temp2], 0(%[er_ptr]) \n\t"
- "sh %[temp3], 2(%[er_ptr]) \n\t"
- "addiu %[ptr], %[ptr], 2 \n\t"
- "addiu %[er_ptr], %[er_ptr], 4 \n\t"
- ".set pop \n\t"
- : [temp1] "=&r" (temp1), [temp2] "=&r" (temp2), [temp3] "=&r" (temp3),
- [temp4] "=&r" (temp4), [temp5] "=&r" (temp5), [ptr] "+r" (ptr),
- [er_ptr] "+r" (er_ptr), [dr_ptr] "+r" (dr_ptr)
- :
- : "memory", "hi", "lo"
- );
+ __asm __volatile(
+ ".set push \n\t"
+ ".set noreorder \n\t"
+ "lh %[temp1], 0(%[ptr]) \n\t"
+ "lh %[temp2], 0(%[dr_ptr]) \n\t"
+ "slti %[temp4], %[temp1], 0x4001 \n\t"
+ "beqz %[temp4], 3f \n\t"
+ " lh %[temp3], 2(%[dr_ptr]) \n\t"
+ "slti %[temp5], %[temp1], 3277 \n\t"
+ "bnez %[temp5], 2f \n\t"
+ " addiu %[dr_ptr], %[dr_ptr], 4 \n\t"
+ "mul %[temp2], %[temp2], %[temp1] \n\t"
+ "mul %[temp3], %[temp3], %[temp1] \n\t"
+ "addiu %[temp2], %[temp2], 0x2000 \n\t"
+ "addiu %[temp3], %[temp3], 0x2000 \n\t"
+ "sra %[temp2], %[temp2], 14 \n\t"
+ "sra %[temp3], %[temp3], 14 \n\t"
+ "b 4f \n\t"
+ " nop \n\t"
+ "2: \n\t"
+ "addu %[temp1], $zero, $zero \n\t"
+ "addu %[temp2], $zero, $zero \n\t"
+ "addu %[temp3], $zero, $zero \n\t"
+ "b 1f \n\t"
+ " nop \n\t"
+ "3: \n\t"
+ "addiu %[temp1], $0, 0x4000 \n\t"
+ "1: \n\t"
+ "sh %[temp1], 0(%[ptr]) \n\t"
+ "4: \n\t"
+ "sh %[temp2], 0(%[er_ptr]) \n\t"
+ "sh %[temp3], 2(%[er_ptr]) \n\t"
+ "addiu %[ptr], %[ptr], 2 \n\t"
+ "addiu %[er_ptr], %[er_ptr], 4 \n\t"
+ ".set pop \n\t"
+ : [temp1] "=&r"(temp1), [temp2] "=&r"(temp2), [temp3] "=&r"(temp3),
+ [temp4] "=&r"(temp4), [temp5] "=&r"(temp5), [ptr] "+r"(ptr),
+ [er_ptr] "+r"(er_ptr), [dr_ptr] "+r"(dr_ptr)
+ :
+ : "memory", "hi", "lo");
#endif
}
}
- }
- else {
+ } else {
// multiply with Wiener coefficients
for (i = 0; i < PART_LEN1; i++) {
- efw[i].real = (int16_t)
- (WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(dfw[i].real,
- hnl[i],
- 14));
- efw[i].imag = (int16_t)
- (WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(dfw[i].imag,
- hnl[i],
- 14));
+ efw[i].real = (int16_t)(
+ WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(dfw[i].real, hnl[i], 14));
+ efw[i].imag = (int16_t)(
+ WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(dfw[i].imag, hnl[i], 14));
}
}
@@ -1284,26 +1380,25 @@
// Generate a uniform random array on [0 2^15-1].
WebRtcSpl_RandUArray(randW16, PART_LEN, &aecm->seed);
int16_t* randW16p = (int16_t*)randW16;
-#if defined (MIPS_DSP_R1_LE)
+#if defined(MIPS_DSP_R1_LE)
int16_t* kCosTablep = (int16_t*)WebRtcAecm_kCosTable;
int16_t* kSinTablep = (int16_t*)WebRtcAecm_kSinTable;
-#endif // #if defined(MIPS_DSP_R1_LE)
+#endif // #if defined(MIPS_DSP_R1_LE)
tmp1 = (int32_t*)aecm->noiseEst + 1;
dfap = (int16_t*)dfa + 1;
lambdap = (int16_t*)lambda + 1;
// Estimate noise power.
- for (i = 1; i < PART_LEN1; i+=2) {
- // Shift to the noise domain.
- __asm __volatile (
- "lh %[tmp32], 0(%[dfap]) \n\t"
- "lw %[tnoise], 0(%[tmp1]) \n\t"
- "sllv %[outLShift32], %[tmp32], %[shiftFromNearToNoise] \n\t"
- : [tmp32] "=&r" (tmp32), [outLShift32] "=r" (outLShift32),
- [tnoise] "=&r" (tnoise)
- : [tmp1] "r" (tmp1), [dfap] "r" (dfap),
- [shiftFromNearToNoise] "r" (shiftFromNearToNoise)
- : "memory"
- );
+ for (i = 1; i < PART_LEN1; i += 2) {
+ // Shift to the noise domain.
+ __asm __volatile(
+ "lh %[tmp32], 0(%[dfap]) \n\t"
+ "lw %[tnoise], 0(%[tmp1]) \n\t"
+ "sllv %[outLShift32], %[tmp32], %[shiftFromNearToNoise] \n\t"
+ : [tmp32] "=&r"(tmp32), [outLShift32] "=r"(outLShift32),
+ [tnoise] "=&r"(tnoise)
+ : [tmp1] "r"(tmp1), [dfap] "r"(dfap),
+ [shiftFromNearToNoise] "r"(shiftFromNearToNoise)
+ : "memory");
if (outLShift32 < tnoise) {
// Reset "too low" counter
@@ -1319,13 +1414,13 @@
aecm->noiseEstTooHighCtr[i] = 0; // Reset the counter
}
} else {
- __asm __volatile (
- "subu %[tmp32], %[tnoise], %[outLShift32] \n\t"
- "srav %[tmp32], %[tmp32], %[minTrackShift] \n\t"
- "subu %[tnoise], %[tnoise], %[tmp32] \n\t"
- : [tmp32] "=&r" (tmp32), [tnoise] "+r" (tnoise)
- : [outLShift32] "r" (outLShift32), [minTrackShift] "r" (minTrackShift)
- );
+ __asm __volatile(
+ "subu %[tmp32], %[tnoise], %[outLShift32] \n\t"
+ "srav %[tmp32], %[tmp32], %[minTrackShift] \n\t"
+ "subu %[tnoise], %[tnoise], %[tmp32] \n\t"
+ : [tmp32] "=&r"(tmp32), [tnoise] "+r"(tnoise)
+ :
+ [outLShift32] "r"(outLShift32), [minTrackShift] "r"(minTrackShift));
}
} else {
// Reset "too high" counter
@@ -1334,53 +1429,49 @@
if ((tnoise >> 19) <= 0) {
if ((tnoise >> 11) > 0) {
// Large enough for relative increase
- __asm __volatile (
- "mul %[tnoise], %[tnoise], %[c2049] \n\t"
- "sra %[tnoise], %[tnoise], 11 \n\t"
- : [tnoise] "+r" (tnoise)
- : [c2049] "r" (c2049)
- : "hi", "lo"
- );
+ __asm __volatile(
+ "mul %[tnoise], %[tnoise], %[c2049] \n\t"
+ "sra %[tnoise], %[tnoise], 11 \n\t"
+ : [tnoise] "+r"(tnoise)
+ : [c2049] "r"(c2049)
+ : "hi", "lo");
} else {
// Make incremental increases based on size every
// |kNoiseEstIncCount| block
aecm->noiseEstTooLowCtr[i]++;
if (aecm->noiseEstTooLowCtr[i] >= kNoiseEstIncCount) {
- __asm __volatile (
- "sra %[tmp32], %[tnoise], 9 \n\t"
- "addi %[tnoise], %[tnoise], 1 \n\t"
- "addu %[tnoise], %[tnoise], %[tmp32] \n\t"
- : [tnoise] "+r" (tnoise), [tmp32] "=&r" (tmp32)
- :
- );
- aecm->noiseEstTooLowCtr[i] = 0; // Reset counter
+ __asm __volatile(
+ "sra %[tmp32], %[tnoise], 9 \n\t"
+ "addi %[tnoise], %[tnoise], 1 \n\t"
+ "addu %[tnoise], %[tnoise], %[tmp32] \n\t"
+ : [tnoise] "+r"(tnoise), [tmp32] "=&r"(tmp32)
+ :);
+ aecm->noiseEstTooLowCtr[i] = 0; // Reset counter
}
}
} else {
// Avoid overflow.
// Multiplication with 2049 will cause wrap around. Scale
// down first and then multiply
- __asm __volatile (
- "sra %[tnoise], %[tnoise], 11 \n\t"
- "mul %[tnoise], %[tnoise], %[c2049] \n\t"
- : [tnoise] "+r" (tnoise)
- : [c2049] "r" (c2049)
- : "hi", "lo"
- );
+ __asm __volatile(
+ "sra %[tnoise], %[tnoise], 11 \n\t"
+ "mul %[tnoise], %[tnoise], %[c2049] \n\t"
+ : [tnoise] "+r"(tnoise)
+ : [c2049] "r"(c2049)
+ : "hi", "lo");
}
}
// Shift to the noise domain.
- __asm __volatile (
- "lh %[tmp32], 2(%[dfap]) \n\t"
- "lw %[tnoise1], 4(%[tmp1]) \n\t"
- "addiu %[dfap], %[dfap], 4 \n\t"
- "sllv %[outLShift32], %[tmp32], %[shiftFromNearToNoise] \n\t"
- : [tmp32] "=&r" (tmp32), [dfap] "+r" (dfap),
- [outLShift32] "=r" (outLShift32), [tnoise1] "=&r" (tnoise1)
- : [tmp1] "r" (tmp1), [shiftFromNearToNoise] "r" (shiftFromNearToNoise)
- : "memory"
- );
+ __asm __volatile(
+ "lh %[tmp32], 2(%[dfap]) \n\t"
+ "lw %[tnoise1], 4(%[tmp1]) \n\t"
+ "addiu %[dfap], %[dfap], 4 \n\t"
+ "sllv %[outLShift32], %[tmp32], %[shiftFromNearToNoise] \n\t"
+ : [tmp32] "=&r"(tmp32), [dfap] "+r"(dfap),
+ [outLShift32] "=r"(outLShift32), [tnoise1] "=&r"(tnoise1)
+ : [tmp1] "r"(tmp1), [shiftFromNearToNoise] "r"(shiftFromNearToNoise)
+ : "memory");
if (outLShift32 < tnoise1) {
// Reset "too low" counter
@@ -1393,16 +1484,16 @@
aecm->noiseEstTooHighCtr[i + 1]++;
if (aecm->noiseEstTooHighCtr[i + 1] >= kNoiseEstIncCount) {
tnoise1--;
- aecm->noiseEstTooHighCtr[i + 1] = 0; // Reset the counter
+ aecm->noiseEstTooHighCtr[i + 1] = 0; // Reset the counter
}
} else {
- __asm __volatile (
- "subu %[tmp32], %[tnoise1], %[outLShift32] \n\t"
- "srav %[tmp32], %[tmp32], %[minTrackShift] \n\t"
- "subu %[tnoise1], %[tnoise1], %[tmp32] \n\t"
- : [tmp32] "=&r" (tmp32), [tnoise1] "+r" (tnoise1)
- : [outLShift32] "r" (outLShift32), [minTrackShift] "r" (minTrackShift)
- );
+ __asm __volatile(
+ "subu %[tmp32], %[tnoise1], %[outLShift32] \n\t"
+ "srav %[tmp32], %[tmp32], %[minTrackShift] \n\t"
+ "subu %[tnoise1], %[tnoise1], %[tmp32] \n\t"
+ : [tmp32] "=&r"(tmp32), [tnoise1] "+r"(tnoise1)
+ :
+ [outLShift32] "r"(outLShift32), [minTrackShift] "r"(minTrackShift));
}
} else {
// Reset "too high" counter
@@ -1411,59 +1502,55 @@
if ((tnoise1 >> 19) <= 0) {
if ((tnoise1 >> 11) > 0) {
// Large enough for relative increase
- __asm __volatile (
- "mul %[tnoise1], %[tnoise1], %[c2049] \n\t"
- "sra %[tnoise1], %[tnoise1], 11 \n\t"
- : [tnoise1] "+r" (tnoise1)
- : [c2049] "r" (c2049)
- : "hi", "lo"
- );
+ __asm __volatile(
+ "mul %[tnoise1], %[tnoise1], %[c2049] \n\t"
+ "sra %[tnoise1], %[tnoise1], 11 \n\t"
+ : [tnoise1] "+r"(tnoise1)
+ : [c2049] "r"(c2049)
+ : "hi", "lo");
} else {
// Make incremental increases based on size every
// |kNoiseEstIncCount| block
aecm->noiseEstTooLowCtr[i + 1]++;
if (aecm->noiseEstTooLowCtr[i + 1] >= kNoiseEstIncCount) {
- __asm __volatile (
- "sra %[tmp32], %[tnoise1], 9 \n\t"
- "addi %[tnoise1], %[tnoise1], 1 \n\t"
- "addu %[tnoise1], %[tnoise1], %[tmp32] \n\t"
- : [tnoise1] "+r" (tnoise1), [tmp32] "=&r" (tmp32)
- :
- );
- aecm->noiseEstTooLowCtr[i + 1] = 0; // Reset counter
+ __asm __volatile(
+ "sra %[tmp32], %[tnoise1], 9 \n\t"
+ "addi %[tnoise1], %[tnoise1], 1 \n\t"
+ "addu %[tnoise1], %[tnoise1], %[tmp32] \n\t"
+ : [tnoise1] "+r"(tnoise1), [tmp32] "=&r"(tmp32)
+ :);
+ aecm->noiseEstTooLowCtr[i + 1] = 0; // Reset counter
}
}
} else {
// Avoid overflow.
// Multiplication with 2049 will cause wrap around. Scale
// down first and then multiply
- __asm __volatile (
- "sra %[tnoise1], %[tnoise1], 11 \n\t"
- "mul %[tnoise1], %[tnoise1], %[c2049] \n\t"
- : [tnoise1] "+r" (tnoise1)
- : [c2049] "r" (c2049)
- : "hi", "lo"
- );
+ __asm __volatile(
+ "sra %[tnoise1], %[tnoise1], 11 \n\t"
+ "mul %[tnoise1], %[tnoise1], %[c2049] \n\t"
+ : [tnoise1] "+r"(tnoise1)
+ : [c2049] "r"(c2049)
+ : "hi", "lo");
}
}
- __asm __volatile (
- "lh %[tmp16], 0(%[lambdap]) \n\t"
- "lh %[tmp161], 2(%[lambdap]) \n\t"
- "sw %[tnoise], 0(%[tmp1]) \n\t"
- "sw %[tnoise1], 4(%[tmp1]) \n\t"
- "subu %[tmp16], %[c114], %[tmp16] \n\t"
- "subu %[tmp161], %[c114], %[tmp161] \n\t"
- "srav %[tmp32], %[tnoise], %[shiftFromNearToNoise] \n\t"
- "srav %[tmp321], %[tnoise1], %[shiftFromNearToNoise] \n\t"
- "addiu %[lambdap], %[lambdap], 4 \n\t"
- "addiu %[tmp1], %[tmp1], 8 \n\t"
- : [tmp16] "=&r" (tmp16), [tmp161] "=&r" (tmp161), [tmp1] "+r" (tmp1),
- [tmp32] "=&r" (tmp32), [tmp321] "=&r" (tmp321), [lambdap] "+r" (lambdap)
- : [tnoise] "r" (tnoise), [tnoise1] "r" (tnoise1), [c114] "r" (c114),
- [shiftFromNearToNoise] "r" (shiftFromNearToNoise)
- : "memory"
- );
+ __asm __volatile(
+ "lh %[tmp16], 0(%[lambdap]) \n\t"
+ "lh %[tmp161], 2(%[lambdap]) \n\t"
+ "sw %[tnoise], 0(%[tmp1]) \n\t"
+ "sw %[tnoise1], 4(%[tmp1]) \n\t"
+ "subu %[tmp16], %[c114], %[tmp16] \n\t"
+ "subu %[tmp161], %[c114], %[tmp161] \n\t"
+ "srav %[tmp32], %[tnoise], %[shiftFromNearToNoise] \n\t"
+ "srav %[tmp321], %[tnoise1], %[shiftFromNearToNoise] \n\t"
+ "addiu %[lambdap], %[lambdap], 4 \n\t"
+ "addiu %[tmp1], %[tmp1], 8 \n\t"
+ : [tmp16] "=&r"(tmp16), [tmp161] "=&r"(tmp161), [tmp1] "+r"(tmp1),
+ [tmp32] "=&r"(tmp32), [tmp321] "=&r"(tmp321), [lambdap] "+r"(lambdap)
+ : [tnoise] "r"(tnoise), [tnoise1] "r"(tnoise1), [c114] "r"(c114),
+ [shiftFromNearToNoise] "r"(shiftFromNearToNoise)
+ : "memory");
if (tmp32 > 32767) {
tmp32 = 32767;
@@ -1471,33 +1558,31 @@
}
if (tmp321 > 32767) {
tmp321 = 32767;
- aecm->noiseEst[i+1] = tmp321 << shiftFromNearToNoise;
+ aecm->noiseEst[i + 1] = tmp321 << shiftFromNearToNoise;
}
- __asm __volatile (
- "mul %[tmp32], %[tmp32], %[tmp16] \n\t"
- "mul %[tmp321], %[tmp321], %[tmp161] \n\t"
- "sra %[nrsh1], %[tmp32], 14 \n\t"
- "sra %[nrsh2], %[tmp321], 14 \n\t"
- : [nrsh1] "=&r" (nrsh1), [nrsh2] "=r" (nrsh2)
- : [tmp16] "r" (tmp16), [tmp161] "r" (tmp161), [tmp32] "r" (tmp32),
- [tmp321] "r" (tmp321)
- : "memory", "hi", "lo"
- );
+ __asm __volatile(
+ "mul %[tmp32], %[tmp32], %[tmp16] \n\t"
+ "mul %[tmp321], %[tmp321], %[tmp161] \n\t"
+ "sra %[nrsh1], %[tmp32], 14 \n\t"
+ "sra %[nrsh2], %[tmp321], 14 \n\t"
+ : [nrsh1] "=&r"(nrsh1), [nrsh2] "=r"(nrsh2)
+ : [tmp16] "r"(tmp16), [tmp161] "r"(tmp161), [tmp32] "r"(tmp32),
+ [tmp321] "r"(tmp321)
+ : "memory", "hi", "lo");
- __asm __volatile (
- "lh %[tmp32], 0(%[randW16p]) \n\t"
- "lh %[tmp321], 2(%[randW16p]) \n\t"
- "addiu %[randW16p], %[randW16p], 4 \n\t"
- "mul %[tmp32], %[tmp32], %[c359] \n\t"
- "mul %[tmp321], %[tmp321], %[c359] \n\t"
- "sra %[tmp16], %[tmp32], 15 \n\t"
- "sra %[tmp161], %[tmp321], 15 \n\t"
- : [randW16p] "+r" (randW16p), [tmp32] "=&r" (tmp32),
- [tmp16] "=r" (tmp16), [tmp161] "=r" (tmp161), [tmp321] "=&r" (tmp321)
- : [c359] "r" (c359)
- : "memory", "hi", "lo"
- );
+ __asm __volatile(
+ "lh %[tmp32], 0(%[randW16p]) \n\t"
+ "lh %[tmp321], 2(%[randW16p]) \n\t"
+ "addiu %[randW16p], %[randW16p], 4 \n\t"
+ "mul %[tmp32], %[tmp32], %[c359] \n\t"
+ "mul %[tmp321], %[tmp321], %[c359] \n\t"
+ "sra %[tmp16], %[tmp32], 15 \n\t"
+ "sra %[tmp161], %[tmp321], 15 \n\t"
+ : [randW16p] "+r"(randW16p), [tmp32] "=&r"(tmp32), [tmp16] "=r"(tmp16),
+ [tmp161] "=r"(tmp161), [tmp321] "=&r"(tmp321)
+ : [c359] "r"(c359)
+ : "memory", "hi", "lo");
#if !defined(MIPS_DSP_R1_LE)
tmp32 = WebRtcAecm_kCosTable[tmp16];
@@ -1505,36 +1590,34 @@
tmp322 = WebRtcAecm_kCosTable[tmp161];
tmp323 = WebRtcAecm_kSinTable[tmp161];
#else
- __asm __volatile (
- "sll %[tmp16], %[tmp16], 1 \n\t"
- "sll %[tmp161], %[tmp161], 1 \n\t"
- "lhx %[tmp32], %[tmp16](%[kCosTablep]) \n\t"
- "lhx %[tmp321], %[tmp16](%[kSinTablep]) \n\t"
- "lhx %[tmp322], %[tmp161](%[kCosTablep]) \n\t"
- "lhx %[tmp323], %[tmp161](%[kSinTablep]) \n\t"
- : [tmp32] "=&r" (tmp32), [tmp321] "=&r" (tmp321),
- [tmp322] "=&r" (tmp322), [tmp323] "=&r" (tmp323)
- : [kCosTablep] "r" (kCosTablep), [tmp16] "r" (tmp16),
- [tmp161] "r" (tmp161), [kSinTablep] "r" (kSinTablep)
- : "memory"
- );
+ __asm __volatile(
+ "sll %[tmp16], %[tmp16], 1 \n\t"
+ "sll %[tmp161], %[tmp161], 1 \n\t"
+ "lhx %[tmp32], %[tmp16](%[kCosTablep]) \n\t"
+ "lhx %[tmp321], %[tmp16](%[kSinTablep]) \n\t"
+ "lhx %[tmp322], %[tmp161](%[kCosTablep]) \n\t"
+ "lhx %[tmp323], %[tmp161](%[kSinTablep]) \n\t"
+ : [tmp32] "=&r"(tmp32), [tmp321] "=&r"(tmp321), [tmp322] "=&r"(tmp322),
+ [tmp323] "=&r"(tmp323)
+ : [kCosTablep] "r"(kCosTablep), [tmp16] "r"(tmp16),
+ [tmp161] "r"(tmp161), [kSinTablep] "r"(kSinTablep)
+ : "memory");
#endif
- __asm __volatile (
- "mul %[tmp32], %[tmp32], %[nrsh1] \n\t"
- "negu %[tmp162], %[nrsh1] \n\t"
- "mul %[tmp322], %[tmp322], %[nrsh2] \n\t"
- "negu %[tmp163], %[nrsh2] \n\t"
- "sra %[tmp32], %[tmp32], 13 \n\t"
- "mul %[tmp321], %[tmp321], %[tmp162] \n\t"
- "sra %[tmp322], %[tmp322], 13 \n\t"
- "mul %[tmp323], %[tmp323], %[tmp163] \n\t"
- "sra %[tmp321], %[tmp321], 13 \n\t"
- "sra %[tmp323], %[tmp323], 13 \n\t"
- : [tmp32] "+r" (tmp32), [tmp321] "+r" (tmp321), [tmp162] "=&r" (tmp162),
- [tmp322] "+r" (tmp322), [tmp323] "+r" (tmp323), [tmp163] "=&r" (tmp163)
- : [nrsh1] "r" (nrsh1), [nrsh2] "r" (nrsh2)
- : "hi", "lo"
- );
+ __asm __volatile(
+ "mul %[tmp32], %[tmp32], %[nrsh1] \n\t"
+ "negu %[tmp162], %[nrsh1] \n\t"
+ "mul %[tmp322], %[tmp322], %[nrsh2] \n\t"
+ "negu %[tmp163], %[nrsh2] \n\t"
+ "sra %[tmp32], %[tmp32], 13 \n\t"
+ "mul %[tmp321], %[tmp321], %[tmp162] \n\t"
+ "sra %[tmp322], %[tmp322], 13 \n\t"
+ "mul %[tmp323], %[tmp323], %[tmp163] \n\t"
+ "sra %[tmp321], %[tmp321], 13 \n\t"
+ "sra %[tmp323], %[tmp323], 13 \n\t"
+ : [tmp32] "+r"(tmp32), [tmp321] "+r"(tmp321), [tmp162] "=&r"(tmp162),
+ [tmp322] "+r"(tmp322), [tmp323] "+r"(tmp323), [tmp163] "=&r"(tmp163)
+ : [nrsh1] "r"(nrsh1), [nrsh2] "r"(nrsh2)
+ : "hi", "lo");
// Tables are in Q13.
uReal[i] = (int16_t)tmp32;
uImag[i] = (int16_t)tmp321;
diff --git a/modules/audio_processing/aecm/aecm_core_neon.cc b/modules/audio_processing/aecm/aecm_core_neon.cc
index ca7211f..a2153a2 100644
--- a/modules/audio_processing/aecm/aecm_core_neon.cc
+++ b/modules/audio_processing/aecm/aecm_core_neon.cc
@@ -77,12 +77,12 @@
echo_stored_v = vaddq_u32(echo_est_v_low, echo_stored_v);
echo_stored_v = vaddq_u32(echo_est_v_high, echo_stored_v);
- echo_adapt_v = vmlal_u16(echo_adapt_v,
- vreinterpret_u16_s16(vget_low_s16(adapt_v)),
- vget_low_u16(spectrum_v));
- echo_adapt_v = vmlal_u16(echo_adapt_v,
- vreinterpret_u16_s16(vget_high_s16(adapt_v)),
- vget_high_u16(spectrum_v));
+ echo_adapt_v =
+ vmlal_u16(echo_adapt_v, vreinterpret_u16_s16(vget_low_s16(adapt_v)),
+ vget_low_u16(spectrum_v));
+ echo_adapt_v =
+ vmlal_u16(echo_adapt_v, vreinterpret_u16_s16(vget_high_s16(adapt_v)),
+ vget_high_u16(spectrum_v));
start_stored_p += 8;
start_adapt_p += 8;
diff --git a/modules/audio_processing/aecm/aecm_defines.h b/modules/audio_processing/aecm/aecm_defines.h
index ae2d2bc..5805549 100644
--- a/modules/audio_processing/aecm/aecm_defines.h
+++ b/modules/audio_processing/aecm/aecm_defines.h
@@ -11,77 +11,77 @@
#ifndef MODULES_AUDIO_PROCESSING_AECM_AECM_DEFINES_H_
#define MODULES_AUDIO_PROCESSING_AECM_AECM_DEFINES_H_
-#define AECM_DYNAMIC_Q /* Turn on/off dynamic Q-domain. */
+#define AECM_DYNAMIC_Q /* Turn on/off dynamic Q-domain. */
/* Algorithm parameters */
-#define FRAME_LEN 80 /* Total frame length, 10 ms. */
+#define FRAME_LEN 80 /* Total frame length, 10 ms. */
-#define PART_LEN 64 /* Length of partition. */
-#define PART_LEN_SHIFT 7 /* Length of (PART_LEN * 2) in base 2. */
+#define PART_LEN 64 /* Length of partition. */
+#define PART_LEN_SHIFT 7 /* Length of (PART_LEN * 2) in base 2. */
-#define PART_LEN1 (PART_LEN + 1) /* Unique fft coefficients. */
-#define PART_LEN2 (PART_LEN << 1) /* Length of partition * 2. */
-#define PART_LEN4 (PART_LEN << 2) /* Length of partition * 4. */
-#define FAR_BUF_LEN PART_LEN4 /* Length of buffers. */
-#define MAX_DELAY 100
+#define PART_LEN1 (PART_LEN + 1) /* Unique fft coefficients. */
+#define PART_LEN2 (PART_LEN << 1) /* Length of partition * 2. */
+#define PART_LEN4 (PART_LEN << 2) /* Length of partition * 4. */
+#define FAR_BUF_LEN PART_LEN4 /* Length of buffers. */
+#define MAX_DELAY 100
/* Counter parameters */
-#define CONV_LEN 512 /* Convergence length used at startup. */
-#define CONV_LEN2 (CONV_LEN << 1) /* Used at startup. */
+#define CONV_LEN 512 /* Convergence length used at startup. */
+#define CONV_LEN2 (CONV_LEN << 1) /* Used at startup. */
/* Energy parameters */
-#define MAX_BUF_LEN 64 /* History length of energy signals. */
-#define FAR_ENERGY_MIN 1025 /* Lowest Far energy level: At least 2 */
- /* in energy. */
-#define FAR_ENERGY_DIFF 929 /* Allowed difference between max */
- /* and min. */
-#define ENERGY_DEV_OFFSET 0 /* The energy error offset in Q8. */
-#define ENERGY_DEV_TOL 400 /* The energy estimation tolerance (Q8). */
-#define FAR_ENERGY_VAD_REGION 230 /* Far VAD tolerance region. */
+#define MAX_BUF_LEN 64 /* History length of energy signals. */
+#define FAR_ENERGY_MIN 1025 /* Lowest Far energy level: At least 2 */
+ /* in energy. */
+#define FAR_ENERGY_DIFF 929 /* Allowed difference between max */
+ /* and min. */
+#define ENERGY_DEV_OFFSET 0 /* The energy error offset in Q8. */
+#define ENERGY_DEV_TOL 400 /* The energy estimation tolerance (Q8). */
+#define FAR_ENERGY_VAD_REGION 230 /* Far VAD tolerance region. */
/* Stepsize parameters */
-#define MU_MIN 10 /* Min stepsize 2^-MU_MIN (far end energy */
- /* dependent). */
-#define MU_MAX 1 /* Max stepsize 2^-MU_MAX (far end energy */
- /* dependent). */
-#define MU_DIFF 9 /* MU_MIN - MU_MAX */
+#define MU_MIN 10 /* Min stepsize 2^-MU_MIN (far end energy */
+ /* dependent). */
+#define MU_MAX 1 /* Max stepsize 2^-MU_MAX (far end energy */
+ /* dependent). */
+#define MU_DIFF 9 /* MU_MIN - MU_MAX */
/* Channel parameters */
-#define MIN_MSE_COUNT 20 /* Min number of consecutive blocks with enough */
- /* far end energy to compare channel estimates. */
-#define MIN_MSE_DIFF 29 /* The ratio between adapted and stored channel to */
- /* accept a new storage (0.8 in Q-MSE_RESOLUTION). */
-#define MSE_RESOLUTION 5 /* MSE parameter resolution. */
-#define RESOLUTION_CHANNEL16 12 /* W16 Channel in Q-RESOLUTION_CHANNEL16. */
-#define RESOLUTION_CHANNEL32 28 /* W32 Channel in Q-RESOLUTION_CHANNEL. */
-#define CHANNEL_VAD 16 /* Minimum energy in frequency band */
- /* to update channel. */
+#define MIN_MSE_COUNT 20 /* Min number of consecutive blocks with enough */
+ /* far end energy to compare channel estimates. */
+#define MIN_MSE_DIFF 29 /* The ratio between adapted and stored channel to */
+ /* accept a new storage (0.8 in Q-MSE_RESOLUTION). */
+#define MSE_RESOLUTION 5 /* MSE parameter resolution. */
+#define RESOLUTION_CHANNEL16 12 /* W16 Channel in Q-RESOLUTION_CHANNEL16. */
+#define RESOLUTION_CHANNEL32 28 /* W32 Channel in Q-RESOLUTION_CHANNEL. */
+#define CHANNEL_VAD 16 /* Minimum energy in frequency band */
+ /* to update channel. */
/* Suppression gain parameters: SUPGAIN parameters in Q-(RESOLUTION_SUPGAIN). */
-#define RESOLUTION_SUPGAIN 8 /* Channel in Q-(RESOLUTION_SUPGAIN). */
-#define SUPGAIN_DEFAULT (1 << RESOLUTION_SUPGAIN) /* Default. */
-#define SUPGAIN_ERROR_PARAM_A 3072 /* Estimation error parameter */
- /* (Maximum gain) (8 in Q8). */
-#define SUPGAIN_ERROR_PARAM_B 1536 /* Estimation error parameter */
- /* (Gain before going down). */
-#define SUPGAIN_ERROR_PARAM_D SUPGAIN_DEFAULT /* Estimation error parameter */
- /* (Should be the same as Default) (1 in Q8). */
-#define SUPGAIN_EPC_DT 200 /* SUPGAIN_ERROR_PARAM_C * ENERGY_DEV_TOL */
+#define RESOLUTION_SUPGAIN 8 /* Channel in Q-(RESOLUTION_SUPGAIN). */
+#define SUPGAIN_DEFAULT (1 << RESOLUTION_SUPGAIN) /* Default. */
+#define SUPGAIN_ERROR_PARAM_A 3072 /* Estimation error parameter */
+ /* (Maximum gain) (8 in Q8). */
+#define SUPGAIN_ERROR_PARAM_B 1536 /* Estimation error parameter */
+ /* (Gain before going down). */
+#define SUPGAIN_ERROR_PARAM_D SUPGAIN_DEFAULT /* Estimation error parameter */
+/* (Should be the same as Default) (1 in Q8). */
+#define SUPGAIN_EPC_DT 200 /* SUPGAIN_ERROR_PARAM_C * ENERGY_DEV_TOL */
/* Defines for "check delay estimation" */
-#define CORR_WIDTH 31 /* Number of samples to correlate over. */
-#define CORR_MAX 16 /* Maximum correlation offset. */
-#define CORR_MAX_BUF 63
-#define CORR_DEV 4
-#define CORR_MAX_LEVEL 20
-#define CORR_MAX_LOW 4
-#define CORR_BUF_LEN (CORR_MAX << 1) + 1
+#define CORR_WIDTH 31 /* Number of samples to correlate over. */
+#define CORR_MAX 16 /* Maximum correlation offset. */
+#define CORR_MAX_BUF 63
+#define CORR_DEV 4
+#define CORR_MAX_LEVEL 20
+#define CORR_MAX_LOW 4
+#define CORR_BUF_LEN (CORR_MAX << 1) + 1
/* Note that CORR_WIDTH + 2*CORR_MAX <= MAX_BUF_LEN. */
-#define ONE_Q14 (1 << 14)
+#define ONE_Q14 (1 << 14)
/* NLP defines */
-#define NLP_COMP_LOW 3277 /* 0.2 in Q14 */
-#define NLP_COMP_HIGH ONE_Q14 /* 1 in Q14 */
+#define NLP_COMP_LOW 3277 /* 0.2 in Q14 */
+#define NLP_COMP_HIGH ONE_Q14 /* 1 in Q14 */
#endif
diff --git a/modules/audio_processing/aecm/echo_control_mobile.cc b/modules/audio_processing/aecm/echo_control_mobile.cc
index 36e2271..c947563 100644
--- a/modules/audio_processing/aecm/echo_control_mobile.cc
+++ b/modules/audio_processing/aecm/echo_control_mobile.cc
@@ -21,56 +21,56 @@
}
#include "modules/audio_processing/aecm/aecm_core.h"
-#define BUF_SIZE_FRAMES 50 // buffer size (frames)
+#define BUF_SIZE_FRAMES 50 // buffer size (frames)
// Maximum length of resampled signal. Must be an integer multiple of frames
// (ceil(1/(1 + MIN_SKEW)*2) + 1)*FRAME_LEN
// The factor of 2 handles wb, and the + 1 is as a safety margin
#define MAX_RESAMP_LEN (5 * FRAME_LEN)
-static const size_t kBufSizeSamp = BUF_SIZE_FRAMES * FRAME_LEN; // buffer size (samples)
-static const int kSampMsNb = 8; // samples per ms in nb
+static const size_t kBufSizeSamp =
+ BUF_SIZE_FRAMES * FRAME_LEN; // buffer size (samples)
+static const int kSampMsNb = 8; // samples per ms in nb
// Target suppression levels for nlp modes
// log{0.001, 0.00001, 0.00000001}
static const int kInitCheck = 42;
-typedef struct
-{
- int sampFreq;
- int scSampFreq;
- short bufSizeStart;
- int knownDelay;
+typedef struct {
+ int sampFreq;
+ int scSampFreq;
+ short bufSizeStart;
+ int knownDelay;
- // Stores the last frame added to the farend buffer
- short farendOld[2][FRAME_LEN];
- short initFlag; // indicates if AEC has been initialized
+ // Stores the last frame added to the farend buffer
+ short farendOld[2][FRAME_LEN];
+ short initFlag; // indicates if AEC has been initialized
- // Variables used for averaging far end buffer size
- short counter;
- short sum;
- short firstVal;
- short checkBufSizeCtr;
+ // Variables used for averaging far end buffer size
+ short counter;
+ short sum;
+ short firstVal;
+ short checkBufSizeCtr;
- // Variables used for delay shifts
- short msInSndCardBuf;
- short filtDelay;
- int timeForDelayChange;
- int ECstartup;
- int checkBuffSize;
- int delayChange;
- short lastDelayDiff;
+ // Variables used for delay shifts
+ short msInSndCardBuf;
+ short filtDelay;
+ int timeForDelayChange;
+ int ECstartup;
+ int checkBuffSize;
+ int delayChange;
+ short lastDelayDiff;
- int16_t echoMode;
+ int16_t echoMode;
#ifdef AEC_DEBUG
- FILE *bufFile;
- FILE *delayFile;
- FILE *preCompFile;
- FILE *postCompFile;
-#endif // AEC_DEBUG
- // Structures
- RingBuffer *farendBuf;
+ FILE* bufFile;
+ FILE* delayFile;
+ FILE* preCompFile;
+ FILE* postCompFile;
+#endif // AEC_DEBUG
+ // Structures
+ RingBuffer* farendBuf;
- AecmCore* aecmCore;
+ AecmCore* aecmCore;
} AecMobile;
// Estimates delay to set the position of the farend buffer read pointer
@@ -81,123 +81,117 @@
static int WebRtcAecm_DelayComp(AecMobile* aecm);
void* WebRtcAecm_Create() {
- AecMobile* aecm = static_cast<AecMobile*>(malloc(sizeof(AecMobile)));
+ AecMobile* aecm = static_cast<AecMobile*>(malloc(sizeof(AecMobile)));
- WebRtcSpl_Init();
+ WebRtcSpl_Init();
- aecm->aecmCore = WebRtcAecm_CreateCore();
- if (!aecm->aecmCore) {
- WebRtcAecm_Free(aecm);
- return NULL;
- }
+ aecm->aecmCore = WebRtcAecm_CreateCore();
+ if (!aecm->aecmCore) {
+ WebRtcAecm_Free(aecm);
+ return NULL;
+ }
- aecm->farendBuf = WebRtc_CreateBuffer(kBufSizeSamp,
- sizeof(int16_t));
- if (!aecm->farendBuf)
- {
- WebRtcAecm_Free(aecm);
- return NULL;
- }
+ aecm->farendBuf = WebRtc_CreateBuffer(kBufSizeSamp, sizeof(int16_t));
+ if (!aecm->farendBuf) {
+ WebRtcAecm_Free(aecm);
+ return NULL;
+ }
- aecm->initFlag = 0;
+ aecm->initFlag = 0;
#ifdef AEC_DEBUG
- aecm->aecmCore->farFile = fopen("aecFar.pcm","wb");
- aecm->aecmCore->nearFile = fopen("aecNear.pcm","wb");
- aecm->aecmCore->outFile = fopen("aecOut.pcm","wb");
- //aecm->aecmCore->outLpFile = fopen("aecOutLp.pcm","wb");
+ aecm->aecmCore->farFile = fopen("aecFar.pcm", "wb");
+ aecm->aecmCore->nearFile = fopen("aecNear.pcm", "wb");
+ aecm->aecmCore->outFile = fopen("aecOut.pcm", "wb");
+ // aecm->aecmCore->outLpFile = fopen("aecOutLp.pcm","wb");
- aecm->bufFile = fopen("aecBuf.dat", "wb");
- aecm->delayFile = fopen("aecDelay.dat", "wb");
- aecm->preCompFile = fopen("preComp.pcm", "wb");
- aecm->postCompFile = fopen("postComp.pcm", "wb");
-#endif // AEC_DEBUG
- return aecm;
+ aecm->bufFile = fopen("aecBuf.dat", "wb");
+ aecm->delayFile = fopen("aecDelay.dat", "wb");
+ aecm->preCompFile = fopen("preComp.pcm", "wb");
+ aecm->postCompFile = fopen("postComp.pcm", "wb");
+#endif // AEC_DEBUG
+ return aecm;
}
void WebRtcAecm_Free(void* aecmInst) {
AecMobile* aecm = static_cast<AecMobile*>(aecmInst);
- if (aecm == NULL) {
- return;
- }
+ if (aecm == NULL) {
+ return;
+ }
#ifdef AEC_DEBUG
- fclose(aecm->aecmCore->farFile);
- fclose(aecm->aecmCore->nearFile);
- fclose(aecm->aecmCore->outFile);
- //fclose(aecm->aecmCore->outLpFile);
+ fclose(aecm->aecmCore->farFile);
+ fclose(aecm->aecmCore->nearFile);
+ fclose(aecm->aecmCore->outFile);
+ // fclose(aecm->aecmCore->outLpFile);
- fclose(aecm->bufFile);
- fclose(aecm->delayFile);
- fclose(aecm->preCompFile);
- fclose(aecm->postCompFile);
-#endif // AEC_DEBUG
- WebRtcAecm_FreeCore(aecm->aecmCore);
- WebRtc_FreeBuffer(aecm->farendBuf);
- free(aecm);
+ fclose(aecm->bufFile);
+ fclose(aecm->delayFile);
+ fclose(aecm->preCompFile);
+ fclose(aecm->postCompFile);
+#endif // AEC_DEBUG
+ WebRtcAecm_FreeCore(aecm->aecmCore);
+ WebRtc_FreeBuffer(aecm->farendBuf);
+ free(aecm);
}
-int32_t WebRtcAecm_Init(void *aecmInst, int32_t sampFreq)
-{
- AecMobile* aecm = static_cast<AecMobile*>(aecmInst);
- AecmConfig aecConfig;
+int32_t WebRtcAecm_Init(void* aecmInst, int32_t sampFreq) {
+ AecMobile* aecm = static_cast<AecMobile*>(aecmInst);
+ AecmConfig aecConfig;
- if (aecm == NULL)
- {
- return -1;
- }
+ if (aecm == NULL) {
+ return -1;
+ }
- if (sampFreq != 8000 && sampFreq != 16000)
- {
- return AECM_BAD_PARAMETER_ERROR;
- }
- aecm->sampFreq = sampFreq;
+ if (sampFreq != 8000 && sampFreq != 16000) {
+ return AECM_BAD_PARAMETER_ERROR;
+ }
+ aecm->sampFreq = sampFreq;
- // Initialize AECM core
- if (WebRtcAecm_InitCore(aecm->aecmCore, aecm->sampFreq) == -1)
- {
- return AECM_UNSPECIFIED_ERROR;
- }
+ // Initialize AECM core
+ if (WebRtcAecm_InitCore(aecm->aecmCore, aecm->sampFreq) == -1) {
+ return AECM_UNSPECIFIED_ERROR;
+ }
- // Initialize farend buffer
- WebRtc_InitBuffer(aecm->farendBuf);
+ // Initialize farend buffer
+ WebRtc_InitBuffer(aecm->farendBuf);
- aecm->initFlag = kInitCheck; // indicates that initialization has been done
+ aecm->initFlag = kInitCheck; // indicates that initialization has been done
- aecm->delayChange = 1;
+ aecm->delayChange = 1;
- aecm->sum = 0;
- aecm->counter = 0;
- aecm->checkBuffSize = 1;
- aecm->firstVal = 0;
+ aecm->sum = 0;
+ aecm->counter = 0;
+ aecm->checkBuffSize = 1;
+ aecm->firstVal = 0;
- aecm->ECstartup = 1;
- aecm->bufSizeStart = 0;
- aecm->checkBufSizeCtr = 0;
- aecm->filtDelay = 0;
- aecm->timeForDelayChange = 0;
- aecm->knownDelay = 0;
- aecm->lastDelayDiff = 0;
+ aecm->ECstartup = 1;
+ aecm->bufSizeStart = 0;
+ aecm->checkBufSizeCtr = 0;
+ aecm->filtDelay = 0;
+ aecm->timeForDelayChange = 0;
+ aecm->knownDelay = 0;
+ aecm->lastDelayDiff = 0;
- memset(&aecm->farendOld, 0, sizeof(aecm->farendOld));
+ memset(&aecm->farendOld, 0, sizeof(aecm->farendOld));
- // Default settings.
- aecConfig.cngMode = AecmTrue;
- aecConfig.echoMode = 3;
+ // Default settings.
+ aecConfig.cngMode = AecmTrue;
+ aecConfig.echoMode = 3;
- if (WebRtcAecm_set_config(aecm, aecConfig) == -1)
- {
- return AECM_UNSPECIFIED_ERROR;
- }
+ if (WebRtcAecm_set_config(aecm, aecConfig) == -1) {
+ return AECM_UNSPECIFIED_ERROR;
+ }
- return 0;
+ return 0;
}
// Returns any error that is caused when buffering the
// farend signal.
-int32_t WebRtcAecm_GetBufferFarendError(void *aecmInst, const int16_t *farend,
- size_t nrOfSamples) {
+int32_t WebRtcAecm_GetBufferFarendError(void* aecmInst,
+ const int16_t* farend,
+ size_t nrOfSamples) {
AecMobile* aecm = static_cast<AecMobile*>(aecmInst);
if (aecm == NULL)
@@ -215,8 +209,8 @@
return 0;
}
-
-int32_t WebRtcAecm_BufferFarend(void *aecmInst, const int16_t *farend,
+int32_t WebRtcAecm_BufferFarend(void* aecmInst,
+ const int16_t* farend,
size_t nrOfSamples) {
AecMobile* aecm = static_cast<AecMobile*>(aecmInst);
@@ -227,8 +221,7 @@
return err;
// TODO(unknown): Is this really a good idea?
- if (!aecm->ECstartup)
- {
+ if (!aecm->ECstartup) {
WebRtcAecm_DelayComp(aecm);
}
@@ -237,412 +230,363 @@
return 0;
}
-int32_t WebRtcAecm_Process(void *aecmInst, const int16_t *nearendNoisy,
- const int16_t *nearendClean, int16_t *out,
- size_t nrOfSamples, int16_t msInSndCardBuf)
-{
- AecMobile* aecm = static_cast<AecMobile*>(aecmInst);
- int32_t retVal = 0;
- size_t i;
- short nmbrOfFilledBuffers;
- size_t nBlocks10ms;
- size_t nFrames;
+int32_t WebRtcAecm_Process(void* aecmInst,
+ const int16_t* nearendNoisy,
+ const int16_t* nearendClean,
+ int16_t* out,
+ size_t nrOfSamples,
+ int16_t msInSndCardBuf) {
+ AecMobile* aecm = static_cast<AecMobile*>(aecmInst);
+ int32_t retVal = 0;
+ size_t i;
+ short nmbrOfFilledBuffers;
+ size_t nBlocks10ms;
+ size_t nFrames;
#ifdef AEC_DEBUG
- short msInAECBuf;
+ short msInAECBuf;
#endif
- if (aecm == NULL)
- {
+ if (aecm == NULL) {
+ return -1;
+ }
+
+ if (nearendNoisy == NULL) {
+ return AECM_NULL_POINTER_ERROR;
+ }
+
+ if (out == NULL) {
+ return AECM_NULL_POINTER_ERROR;
+ }
+
+ if (aecm->initFlag != kInitCheck) {
+ return AECM_UNINITIALIZED_ERROR;
+ }
+
+ if (nrOfSamples != 80 && nrOfSamples != 160) {
+ return AECM_BAD_PARAMETER_ERROR;
+ }
+
+ if (msInSndCardBuf < 0) {
+ msInSndCardBuf = 0;
+ retVal = AECM_BAD_PARAMETER_WARNING;
+ } else if (msInSndCardBuf > 500) {
+ msInSndCardBuf = 500;
+ retVal = AECM_BAD_PARAMETER_WARNING;
+ }
+ msInSndCardBuf += 10;
+ aecm->msInSndCardBuf = msInSndCardBuf;
+
+ nFrames = nrOfSamples / FRAME_LEN;
+ nBlocks10ms = nFrames / aecm->aecmCore->mult;
+
+ if (aecm->ECstartup) {
+ if (nearendClean == NULL) {
+ if (out != nearendNoisy) {
+ memcpy(out, nearendNoisy, sizeof(short) * nrOfSamples);
+ }
+ } else if (out != nearendClean) {
+ memcpy(out, nearendClean, sizeof(short) * nrOfSamples);
+ }
+
+ nmbrOfFilledBuffers =
+ (short)WebRtc_available_read(aecm->farendBuf) / FRAME_LEN;
+ // The AECM is in the start up mode
+ // AECM is disabled until the soundcard buffer and farend buffers are OK
+
+ // Mechanism to ensure that the soundcard buffer is reasonably stable.
+ if (aecm->checkBuffSize) {
+ aecm->checkBufSizeCtr++;
+ // Before we fill up the far end buffer we require the amount of data on
+ // the sound card to be stable (+/-8 ms) compared to the first value. This
+ // comparison is made during the following 4 consecutive frames. If it
+ // seems to be stable then we start to fill up the far end buffer.
+
+ if (aecm->counter == 0) {
+ aecm->firstVal = aecm->msInSndCardBuf;
+ aecm->sum = 0;
+ }
+
+ if (abs(aecm->firstVal - aecm->msInSndCardBuf) <
+ WEBRTC_SPL_MAX(0.2 * aecm->msInSndCardBuf, kSampMsNb)) {
+ aecm->sum += aecm->msInSndCardBuf;
+ aecm->counter++;
+ } else {
+ aecm->counter = 0;
+ }
+
+ if (aecm->counter * nBlocks10ms >= 6) {
+ // The farend buffer size is determined in blocks of 80 samples
+ // Use 75% of the average value of the soundcard buffer
+ aecm->bufSizeStart = WEBRTC_SPL_MIN(
+ (3 * aecm->sum * aecm->aecmCore->mult) / (aecm->counter * 40),
+ BUF_SIZE_FRAMES);
+ // buffersize has now been determined
+ aecm->checkBuffSize = 0;
+ }
+
+ if (aecm->checkBufSizeCtr * nBlocks10ms > 50) {
+ // for really bad sound cards, don't disable echocanceller for more than
+ // 0.5 sec
+ aecm->bufSizeStart = WEBRTC_SPL_MIN(
+ (3 * aecm->msInSndCardBuf * aecm->aecmCore->mult) / 40,
+ BUF_SIZE_FRAMES);
+ aecm->checkBuffSize = 0;
+ }
+ }
+
+ // if checkBuffSize changed in the if-statement above
+ if (!aecm->checkBuffSize) {
+ // soundcard buffer is now reasonably stable
+ // When the far end buffer is filled with approximately the same amount of
+ // data as the amount on the sound card we end the start up phase and
+ // start to cancel echoes.
+
+ if (nmbrOfFilledBuffers == aecm->bufSizeStart) {
+ aecm->ECstartup = 0; // Enable the AECM
+ } else if (nmbrOfFilledBuffers > aecm->bufSizeStart) {
+ WebRtc_MoveReadPtr(aecm->farendBuf,
+ (int)WebRtc_available_read(aecm->farendBuf) -
+ (int)aecm->bufSizeStart * FRAME_LEN);
+ aecm->ECstartup = 0;
+ }
+ }
+
+ } else {
+ // AECM is enabled
+
+ // Note only 1 block supported for nb and 2 blocks for wb
+ for (i = 0; i < nFrames; i++) {
+ int16_t farend[FRAME_LEN];
+ const int16_t* farend_ptr = NULL;
+
+ nmbrOfFilledBuffers =
+ (short)WebRtc_available_read(aecm->farendBuf) / FRAME_LEN;
+
+ // Check that there is data in the far end buffer
+ if (nmbrOfFilledBuffers > 0) {
+ // Get the next 80 samples from the farend buffer
+ WebRtc_ReadBuffer(aecm->farendBuf, (void**)&farend_ptr, farend,
+ FRAME_LEN);
+
+ // Always store the last frame for use when we run out of data
+ memcpy(&(aecm->farendOld[i][0]), farend_ptr, FRAME_LEN * sizeof(short));
+ } else {
+ // We have no data so we use the last played frame
+ memcpy(farend, &(aecm->farendOld[i][0]), FRAME_LEN * sizeof(short));
+ farend_ptr = farend;
+ }
+
+ // Call buffer delay estimator when all data is extracted,
+ // i,e. i = 0 for NB and i = 1 for WB
+ if ((i == 0 && aecm->sampFreq == 8000) ||
+ (i == 1 && aecm->sampFreq == 16000)) {
+ WebRtcAecm_EstBufDelay(aecm, aecm->msInSndCardBuf);
+ }
+
+ // Call the AECM
+ /*WebRtcAecm_ProcessFrame(aecm->aecmCore, farend, &nearend[FRAME_LEN * i],
+ &out[FRAME_LEN * i], aecm->knownDelay);*/
+ if (WebRtcAecm_ProcessFrame(
+ aecm->aecmCore, farend_ptr, &nearendNoisy[FRAME_LEN * i],
+ (nearendClean ? &nearendClean[FRAME_LEN * i] : NULL),
+ &out[FRAME_LEN * i]) == -1)
return -1;
}
-
- if (nearendNoisy == NULL)
- {
- return AECM_NULL_POINTER_ERROR;
- }
-
- if (out == NULL)
- {
- return AECM_NULL_POINTER_ERROR;
- }
-
- if (aecm->initFlag != kInitCheck)
- {
- return AECM_UNINITIALIZED_ERROR;
- }
-
- if (nrOfSamples != 80 && nrOfSamples != 160)
- {
- return AECM_BAD_PARAMETER_ERROR;
- }
-
- if (msInSndCardBuf < 0)
- {
- msInSndCardBuf = 0;
- retVal = AECM_BAD_PARAMETER_WARNING;
- } else if (msInSndCardBuf > 500)
- {
- msInSndCardBuf = 500;
- retVal = AECM_BAD_PARAMETER_WARNING;
- }
- msInSndCardBuf += 10;
- aecm->msInSndCardBuf = msInSndCardBuf;
-
- nFrames = nrOfSamples / FRAME_LEN;
- nBlocks10ms = nFrames / aecm->aecmCore->mult;
-
- if (aecm->ECstartup)
- {
- if (nearendClean == NULL)
- {
- if (out != nearendNoisy)
- {
- memcpy(out, nearendNoisy, sizeof(short) * nrOfSamples);
- }
- } else if (out != nearendClean)
- {
- memcpy(out, nearendClean, sizeof(short) * nrOfSamples);
- }
-
- nmbrOfFilledBuffers =
- (short) WebRtc_available_read(aecm->farendBuf) / FRAME_LEN;
- // The AECM is in the start up mode
- // AECM is disabled until the soundcard buffer and farend buffers are OK
-
- // Mechanism to ensure that the soundcard buffer is reasonably stable.
- if (aecm->checkBuffSize)
- {
- aecm->checkBufSizeCtr++;
- // Before we fill up the far end buffer we require the amount of data on the
- // sound card to be stable (+/-8 ms) compared to the first value. This
- // comparison is made during the following 4 consecutive frames. If it seems
- // to be stable then we start to fill up the far end buffer.
-
- if (aecm->counter == 0)
- {
- aecm->firstVal = aecm->msInSndCardBuf;
- aecm->sum = 0;
- }
-
- if (abs(aecm->firstVal - aecm->msInSndCardBuf)
- < WEBRTC_SPL_MAX(0.2 * aecm->msInSndCardBuf, kSampMsNb))
- {
- aecm->sum += aecm->msInSndCardBuf;
- aecm->counter++;
- } else
- {
- aecm->counter = 0;
- }
-
- if (aecm->counter * nBlocks10ms >= 6)
- {
- // The farend buffer size is determined in blocks of 80 samples
- // Use 75% of the average value of the soundcard buffer
- aecm->bufSizeStart
- = WEBRTC_SPL_MIN((3 * aecm->sum
- * aecm->aecmCore->mult) / (aecm->counter * 40), BUF_SIZE_FRAMES);
- // buffersize has now been determined
- aecm->checkBuffSize = 0;
- }
-
- if (aecm->checkBufSizeCtr * nBlocks10ms > 50)
- {
- // for really bad sound cards, don't disable echocanceller for more than 0.5 sec
- aecm->bufSizeStart = WEBRTC_SPL_MIN((3 * aecm->msInSndCardBuf
- * aecm->aecmCore->mult) / 40, BUF_SIZE_FRAMES);
- aecm->checkBuffSize = 0;
- }
- }
-
- // if checkBuffSize changed in the if-statement above
- if (!aecm->checkBuffSize)
- {
- // soundcard buffer is now reasonably stable
- // When the far end buffer is filled with approximately the same amount of
- // data as the amount on the sound card we end the start up phase and start
- // to cancel echoes.
-
- if (nmbrOfFilledBuffers == aecm->bufSizeStart)
- {
- aecm->ECstartup = 0; // Enable the AECM
- } else if (nmbrOfFilledBuffers > aecm->bufSizeStart)
- {
- WebRtc_MoveReadPtr(aecm->farendBuf,
- (int) WebRtc_available_read(aecm->farendBuf)
- - (int) aecm->bufSizeStart * FRAME_LEN);
- aecm->ECstartup = 0;
- }
- }
-
- } else
- {
- // AECM is enabled
-
- // Note only 1 block supported for nb and 2 blocks for wb
- for (i = 0; i < nFrames; i++)
- {
- int16_t farend[FRAME_LEN];
- const int16_t* farend_ptr = NULL;
-
- nmbrOfFilledBuffers =
- (short) WebRtc_available_read(aecm->farendBuf) / FRAME_LEN;
-
- // Check that there is data in the far end buffer
- if (nmbrOfFilledBuffers > 0)
- {
- // Get the next 80 samples from the farend buffer
- WebRtc_ReadBuffer(aecm->farendBuf, (void**) &farend_ptr, farend,
- FRAME_LEN);
-
- // Always store the last frame for use when we run out of data
- memcpy(&(aecm->farendOld[i][0]), farend_ptr,
- FRAME_LEN * sizeof(short));
- } else
- {
- // We have no data so we use the last played frame
- memcpy(farend, &(aecm->farendOld[i][0]), FRAME_LEN * sizeof(short));
- farend_ptr = farend;
- }
-
- // Call buffer delay estimator when all data is extracted,
- // i,e. i = 0 for NB and i = 1 for WB
- if ((i == 0 && aecm->sampFreq == 8000) || (i == 1 && aecm->sampFreq == 16000))
- {
- WebRtcAecm_EstBufDelay(aecm, aecm->msInSndCardBuf);
- }
-
- // Call the AECM
- /*WebRtcAecm_ProcessFrame(aecm->aecmCore, farend, &nearend[FRAME_LEN * i],
- &out[FRAME_LEN * i], aecm->knownDelay);*/
- if (WebRtcAecm_ProcessFrame(aecm->aecmCore,
- farend_ptr,
- &nearendNoisy[FRAME_LEN * i],
- (nearendClean
- ? &nearendClean[FRAME_LEN * i]
- : NULL),
- &out[FRAME_LEN * i]) == -1)
- return -1;
- }
- }
+ }
#ifdef AEC_DEBUG
- msInAECBuf = (short) WebRtc_available_read(aecm->farendBuf) /
- (kSampMsNb * aecm->aecmCore->mult);
- fwrite(&msInAECBuf, 2, 1, aecm->bufFile);
- fwrite(&(aecm->knownDelay), sizeof(aecm->knownDelay), 1, aecm->delayFile);
+ msInAECBuf = (short)WebRtc_available_read(aecm->farendBuf) /
+ (kSampMsNb * aecm->aecmCore->mult);
+ fwrite(&msInAECBuf, 2, 1, aecm->bufFile);
+ fwrite(&(aecm->knownDelay), sizeof(aecm->knownDelay), 1, aecm->delayFile);
#endif
- return retVal;
+ return retVal;
}
-int32_t WebRtcAecm_set_config(void *aecmInst, AecmConfig config)
-{
- AecMobile* aecm = static_cast<AecMobile*>(aecmInst);
+int32_t WebRtcAecm_set_config(void* aecmInst, AecmConfig config) {
+ AecMobile* aecm = static_cast<AecMobile*>(aecmInst);
- if (aecm == NULL)
- {
- return -1;
- }
+ if (aecm == NULL) {
+ return -1;
+ }
- if (aecm->initFlag != kInitCheck)
- {
- return AECM_UNINITIALIZED_ERROR;
- }
+ if (aecm->initFlag != kInitCheck) {
+ return AECM_UNINITIALIZED_ERROR;
+ }
- if (config.cngMode != AecmFalse && config.cngMode != AecmTrue)
- {
- return AECM_BAD_PARAMETER_ERROR;
- }
- aecm->aecmCore->cngMode = config.cngMode;
+ if (config.cngMode != AecmFalse && config.cngMode != AecmTrue) {
+ return AECM_BAD_PARAMETER_ERROR;
+ }
+ aecm->aecmCore->cngMode = config.cngMode;
- if (config.echoMode < 0 || config.echoMode > 4)
- {
- return AECM_BAD_PARAMETER_ERROR;
- }
- aecm->echoMode = config.echoMode;
+ if (config.echoMode < 0 || config.echoMode > 4) {
+ return AECM_BAD_PARAMETER_ERROR;
+ }
+ aecm->echoMode = config.echoMode;
- if (aecm->echoMode == 0)
- {
- aecm->aecmCore->supGain = SUPGAIN_DEFAULT >> 3;
- aecm->aecmCore->supGainOld = SUPGAIN_DEFAULT >> 3;
- aecm->aecmCore->supGainErrParamA = SUPGAIN_ERROR_PARAM_A >> 3;
- aecm->aecmCore->supGainErrParamD = SUPGAIN_ERROR_PARAM_D >> 3;
- aecm->aecmCore->supGainErrParamDiffAB = (SUPGAIN_ERROR_PARAM_A >> 3)
- - (SUPGAIN_ERROR_PARAM_B >> 3);
- aecm->aecmCore->supGainErrParamDiffBD = (SUPGAIN_ERROR_PARAM_B >> 3)
- - (SUPGAIN_ERROR_PARAM_D >> 3);
- } else if (aecm->echoMode == 1)
- {
- aecm->aecmCore->supGain = SUPGAIN_DEFAULT >> 2;
- aecm->aecmCore->supGainOld = SUPGAIN_DEFAULT >> 2;
- aecm->aecmCore->supGainErrParamA = SUPGAIN_ERROR_PARAM_A >> 2;
- aecm->aecmCore->supGainErrParamD = SUPGAIN_ERROR_PARAM_D >> 2;
- aecm->aecmCore->supGainErrParamDiffAB = (SUPGAIN_ERROR_PARAM_A >> 2)
- - (SUPGAIN_ERROR_PARAM_B >> 2);
- aecm->aecmCore->supGainErrParamDiffBD = (SUPGAIN_ERROR_PARAM_B >> 2)
- - (SUPGAIN_ERROR_PARAM_D >> 2);
- } else if (aecm->echoMode == 2)
- {
- aecm->aecmCore->supGain = SUPGAIN_DEFAULT >> 1;
- aecm->aecmCore->supGainOld = SUPGAIN_DEFAULT >> 1;
- aecm->aecmCore->supGainErrParamA = SUPGAIN_ERROR_PARAM_A >> 1;
- aecm->aecmCore->supGainErrParamD = SUPGAIN_ERROR_PARAM_D >> 1;
- aecm->aecmCore->supGainErrParamDiffAB = (SUPGAIN_ERROR_PARAM_A >> 1)
- - (SUPGAIN_ERROR_PARAM_B >> 1);
- aecm->aecmCore->supGainErrParamDiffBD = (SUPGAIN_ERROR_PARAM_B >> 1)
- - (SUPGAIN_ERROR_PARAM_D >> 1);
- } else if (aecm->echoMode == 3)
- {
- aecm->aecmCore->supGain = SUPGAIN_DEFAULT;
- aecm->aecmCore->supGainOld = SUPGAIN_DEFAULT;
- aecm->aecmCore->supGainErrParamA = SUPGAIN_ERROR_PARAM_A;
- aecm->aecmCore->supGainErrParamD = SUPGAIN_ERROR_PARAM_D;
- aecm->aecmCore->supGainErrParamDiffAB = SUPGAIN_ERROR_PARAM_A - SUPGAIN_ERROR_PARAM_B;
- aecm->aecmCore->supGainErrParamDiffBD = SUPGAIN_ERROR_PARAM_B - SUPGAIN_ERROR_PARAM_D;
- } else if (aecm->echoMode == 4)
- {
- aecm->aecmCore->supGain = SUPGAIN_DEFAULT << 1;
- aecm->aecmCore->supGainOld = SUPGAIN_DEFAULT << 1;
- aecm->aecmCore->supGainErrParamA = SUPGAIN_ERROR_PARAM_A << 1;
- aecm->aecmCore->supGainErrParamD = SUPGAIN_ERROR_PARAM_D << 1;
- aecm->aecmCore->supGainErrParamDiffAB = (SUPGAIN_ERROR_PARAM_A << 1)
- - (SUPGAIN_ERROR_PARAM_B << 1);
- aecm->aecmCore->supGainErrParamDiffBD = (SUPGAIN_ERROR_PARAM_B << 1)
- - (SUPGAIN_ERROR_PARAM_D << 1);
- }
+ if (aecm->echoMode == 0) {
+ aecm->aecmCore->supGain = SUPGAIN_DEFAULT >> 3;
+ aecm->aecmCore->supGainOld = SUPGAIN_DEFAULT >> 3;
+ aecm->aecmCore->supGainErrParamA = SUPGAIN_ERROR_PARAM_A >> 3;
+ aecm->aecmCore->supGainErrParamD = SUPGAIN_ERROR_PARAM_D >> 3;
+ aecm->aecmCore->supGainErrParamDiffAB =
+ (SUPGAIN_ERROR_PARAM_A >> 3) - (SUPGAIN_ERROR_PARAM_B >> 3);
+ aecm->aecmCore->supGainErrParamDiffBD =
+ (SUPGAIN_ERROR_PARAM_B >> 3) - (SUPGAIN_ERROR_PARAM_D >> 3);
+ } else if (aecm->echoMode == 1) {
+ aecm->aecmCore->supGain = SUPGAIN_DEFAULT >> 2;
+ aecm->aecmCore->supGainOld = SUPGAIN_DEFAULT >> 2;
+ aecm->aecmCore->supGainErrParamA = SUPGAIN_ERROR_PARAM_A >> 2;
+ aecm->aecmCore->supGainErrParamD = SUPGAIN_ERROR_PARAM_D >> 2;
+ aecm->aecmCore->supGainErrParamDiffAB =
+ (SUPGAIN_ERROR_PARAM_A >> 2) - (SUPGAIN_ERROR_PARAM_B >> 2);
+ aecm->aecmCore->supGainErrParamDiffBD =
+ (SUPGAIN_ERROR_PARAM_B >> 2) - (SUPGAIN_ERROR_PARAM_D >> 2);
+ } else if (aecm->echoMode == 2) {
+ aecm->aecmCore->supGain = SUPGAIN_DEFAULT >> 1;
+ aecm->aecmCore->supGainOld = SUPGAIN_DEFAULT >> 1;
+ aecm->aecmCore->supGainErrParamA = SUPGAIN_ERROR_PARAM_A >> 1;
+ aecm->aecmCore->supGainErrParamD = SUPGAIN_ERROR_PARAM_D >> 1;
+ aecm->aecmCore->supGainErrParamDiffAB =
+ (SUPGAIN_ERROR_PARAM_A >> 1) - (SUPGAIN_ERROR_PARAM_B >> 1);
+ aecm->aecmCore->supGainErrParamDiffBD =
+ (SUPGAIN_ERROR_PARAM_B >> 1) - (SUPGAIN_ERROR_PARAM_D >> 1);
+ } else if (aecm->echoMode == 3) {
+ aecm->aecmCore->supGain = SUPGAIN_DEFAULT;
+ aecm->aecmCore->supGainOld = SUPGAIN_DEFAULT;
+ aecm->aecmCore->supGainErrParamA = SUPGAIN_ERROR_PARAM_A;
+ aecm->aecmCore->supGainErrParamD = SUPGAIN_ERROR_PARAM_D;
+ aecm->aecmCore->supGainErrParamDiffAB =
+ SUPGAIN_ERROR_PARAM_A - SUPGAIN_ERROR_PARAM_B;
+ aecm->aecmCore->supGainErrParamDiffBD =
+ SUPGAIN_ERROR_PARAM_B - SUPGAIN_ERROR_PARAM_D;
+ } else if (aecm->echoMode == 4) {
+ aecm->aecmCore->supGain = SUPGAIN_DEFAULT << 1;
+ aecm->aecmCore->supGainOld = SUPGAIN_DEFAULT << 1;
+ aecm->aecmCore->supGainErrParamA = SUPGAIN_ERROR_PARAM_A << 1;
+ aecm->aecmCore->supGainErrParamD = SUPGAIN_ERROR_PARAM_D << 1;
+ aecm->aecmCore->supGainErrParamDiffAB =
+ (SUPGAIN_ERROR_PARAM_A << 1) - (SUPGAIN_ERROR_PARAM_B << 1);
+ aecm->aecmCore->supGainErrParamDiffBD =
+ (SUPGAIN_ERROR_PARAM_B << 1) - (SUPGAIN_ERROR_PARAM_D << 1);
+ }
- return 0;
+ return 0;
}
int32_t WebRtcAecm_InitEchoPath(void* aecmInst,
const void* echo_path,
- size_t size_bytes)
-{
- AecMobile* aecm = static_cast<AecMobile*>(aecmInst);
- const int16_t* echo_path_ptr = static_cast<const int16_t*>(echo_path);
+ size_t size_bytes) {
+ AecMobile* aecm = static_cast<AecMobile*>(aecmInst);
+ const int16_t* echo_path_ptr = static_cast<const int16_t*>(echo_path);
- if (aecmInst == NULL) {
- return -1;
- }
- if (echo_path == NULL) {
- return AECM_NULL_POINTER_ERROR;
- }
- if (size_bytes != WebRtcAecm_echo_path_size_bytes())
- {
- // Input channel size does not match the size of AECM
- return AECM_BAD_PARAMETER_ERROR;
- }
- if (aecm->initFlag != kInitCheck)
- {
- return AECM_UNINITIALIZED_ERROR;
- }
+ if (aecmInst == NULL) {
+ return -1;
+ }
+ if (echo_path == NULL) {
+ return AECM_NULL_POINTER_ERROR;
+ }
+ if (size_bytes != WebRtcAecm_echo_path_size_bytes()) {
+ // Input channel size does not match the size of AECM
+ return AECM_BAD_PARAMETER_ERROR;
+ }
+ if (aecm->initFlag != kInitCheck) {
+ return AECM_UNINITIALIZED_ERROR;
+ }
- WebRtcAecm_InitEchoPathCore(aecm->aecmCore, echo_path_ptr);
+ WebRtcAecm_InitEchoPathCore(aecm->aecmCore, echo_path_ptr);
- return 0;
+ return 0;
}
int32_t WebRtcAecm_GetEchoPath(void* aecmInst,
void* echo_path,
- size_t size_bytes)
-{
- AecMobile* aecm = static_cast<AecMobile*>(aecmInst);
- int16_t* echo_path_ptr = static_cast<int16_t*>(echo_path);
+ size_t size_bytes) {
+ AecMobile* aecm = static_cast<AecMobile*>(aecmInst);
+ int16_t* echo_path_ptr = static_cast<int16_t*>(echo_path);
- if (aecmInst == NULL) {
- return -1;
- }
- if (echo_path == NULL) {
- return AECM_NULL_POINTER_ERROR;
- }
- if (size_bytes != WebRtcAecm_echo_path_size_bytes())
- {
- // Input channel size does not match the size of AECM
- return AECM_BAD_PARAMETER_ERROR;
- }
- if (aecm->initFlag != kInitCheck)
- {
- return AECM_UNINITIALIZED_ERROR;
- }
+ if (aecmInst == NULL) {
+ return -1;
+ }
+ if (echo_path == NULL) {
+ return AECM_NULL_POINTER_ERROR;
+ }
+ if (size_bytes != WebRtcAecm_echo_path_size_bytes()) {
+ // Input channel size does not match the size of AECM
+ return AECM_BAD_PARAMETER_ERROR;
+ }
+ if (aecm->initFlag != kInitCheck) {
+ return AECM_UNINITIALIZED_ERROR;
+ }
- memcpy(echo_path_ptr, aecm->aecmCore->channelStored, size_bytes);
- return 0;
+ memcpy(echo_path_ptr, aecm->aecmCore->channelStored, size_bytes);
+ return 0;
}
-size_t WebRtcAecm_echo_path_size_bytes()
-{
- return (PART_LEN1 * sizeof(int16_t));
+size_t WebRtcAecm_echo_path_size_bytes() {
+ return (PART_LEN1 * sizeof(int16_t));
}
-
static int WebRtcAecm_EstBufDelay(AecMobile* aecm, short msInSndCardBuf) {
- short delayNew, nSampSndCard;
- short nSampFar = (short) WebRtc_available_read(aecm->farendBuf);
- short diff;
+ short delayNew, nSampSndCard;
+ short nSampFar = (short)WebRtc_available_read(aecm->farendBuf);
+ short diff;
- nSampSndCard = msInSndCardBuf * kSampMsNb * aecm->aecmCore->mult;
+ nSampSndCard = msInSndCardBuf * kSampMsNb * aecm->aecmCore->mult;
- delayNew = nSampSndCard - nSampFar;
+ delayNew = nSampSndCard - nSampFar;
- if (delayNew < FRAME_LEN)
- {
- WebRtc_MoveReadPtr(aecm->farendBuf, FRAME_LEN);
- delayNew += FRAME_LEN;
+ if (delayNew < FRAME_LEN) {
+ WebRtc_MoveReadPtr(aecm->farendBuf, FRAME_LEN);
+ delayNew += FRAME_LEN;
+ }
+
+ aecm->filtDelay =
+ WEBRTC_SPL_MAX(0, (8 * aecm->filtDelay + 2 * delayNew) / 10);
+
+ diff = aecm->filtDelay - aecm->knownDelay;
+ if (diff > 224) {
+ if (aecm->lastDelayDiff < 96) {
+ aecm->timeForDelayChange = 0;
+ } else {
+ aecm->timeForDelayChange++;
}
-
- aecm->filtDelay = WEBRTC_SPL_MAX(0, (8 * aecm->filtDelay + 2 * delayNew) / 10);
-
- diff = aecm->filtDelay - aecm->knownDelay;
- if (diff > 224)
- {
- if (aecm->lastDelayDiff < 96)
- {
- aecm->timeForDelayChange = 0;
- } else
- {
- aecm->timeForDelayChange++;
- }
- } else if (diff < 96 && aecm->knownDelay > 0)
- {
- if (aecm->lastDelayDiff > 224)
- {
- aecm->timeForDelayChange = 0;
- } else
- {
- aecm->timeForDelayChange++;
- }
- } else
- {
- aecm->timeForDelayChange = 0;
+ } else if (diff < 96 && aecm->knownDelay > 0) {
+ if (aecm->lastDelayDiff > 224) {
+ aecm->timeForDelayChange = 0;
+ } else {
+ aecm->timeForDelayChange++;
}
- aecm->lastDelayDiff = diff;
+ } else {
+ aecm->timeForDelayChange = 0;
+ }
+ aecm->lastDelayDiff = diff;
- if (aecm->timeForDelayChange > 25)
- {
- aecm->knownDelay = WEBRTC_SPL_MAX((int)aecm->filtDelay - 160, 0);
- }
- return 0;
+ if (aecm->timeForDelayChange > 25) {
+ aecm->knownDelay = WEBRTC_SPL_MAX((int)aecm->filtDelay - 160, 0);
+ }
+ return 0;
}
static int WebRtcAecm_DelayComp(AecMobile* aecm) {
- int nSampFar = (int) WebRtc_available_read(aecm->farendBuf);
- int nSampSndCard, delayNew, nSampAdd;
- const int maxStuffSamp = 10 * FRAME_LEN;
+ int nSampFar = (int)WebRtc_available_read(aecm->farendBuf);
+ int nSampSndCard, delayNew, nSampAdd;
+ const int maxStuffSamp = 10 * FRAME_LEN;
- nSampSndCard = aecm->msInSndCardBuf * kSampMsNb * aecm->aecmCore->mult;
- delayNew = nSampSndCard - nSampFar;
+ nSampSndCard = aecm->msInSndCardBuf * kSampMsNb * aecm->aecmCore->mult;
+ delayNew = nSampSndCard - nSampFar;
- if (delayNew > FAR_BUF_LEN - FRAME_LEN * aecm->aecmCore->mult)
- {
- // The difference of the buffer sizes is larger than the maximum
- // allowed known delay. Compensate by stuffing the buffer.
- nSampAdd = (int)(WEBRTC_SPL_MAX(((nSampSndCard >> 1) - nSampFar),
- FRAME_LEN));
- nSampAdd = WEBRTC_SPL_MIN(nSampAdd, maxStuffSamp);
+ if (delayNew > FAR_BUF_LEN - FRAME_LEN * aecm->aecmCore->mult) {
+ // The difference of the buffer sizes is larger than the maximum
+ // allowed known delay. Compensate by stuffing the buffer.
+ nSampAdd =
+ (int)(WEBRTC_SPL_MAX(((nSampSndCard >> 1) - nSampFar), FRAME_LEN));
+ nSampAdd = WEBRTC_SPL_MIN(nSampAdd, maxStuffSamp);
- WebRtc_MoveReadPtr(aecm->farendBuf, -nSampAdd);
- aecm->delayChange = 1; // the delay needs to be updated
- }
+ WebRtc_MoveReadPtr(aecm->farendBuf, -nSampAdd);
+ aecm->delayChange = 1; // the delay needs to be updated
+ }
- return 0;
+ return 0;
}
diff --git a/modules/audio_processing/aecm/echo_control_mobile.h b/modules/audio_processing/aecm/echo_control_mobile.h
index e0091c3..576cf19 100644
--- a/modules/audio_processing/aecm/echo_control_mobile.h
+++ b/modules/audio_processing/aecm/echo_control_mobile.h
@@ -15,24 +15,21 @@
#include "typedefs.h" // NOLINT(build/include)
-enum {
- AecmFalse = 0,
- AecmTrue
-};
+enum { AecmFalse = 0, AecmTrue };
// Errors
-#define AECM_UNSPECIFIED_ERROR 12000
-#define AECM_UNSUPPORTED_FUNCTION_ERROR 12001
-#define AECM_UNINITIALIZED_ERROR 12002
-#define AECM_NULL_POINTER_ERROR 12003
-#define AECM_BAD_PARAMETER_ERROR 12004
+#define AECM_UNSPECIFIED_ERROR 12000
+#define AECM_UNSUPPORTED_FUNCTION_ERROR 12001
+#define AECM_UNINITIALIZED_ERROR 12002
+#define AECM_NULL_POINTER_ERROR 12003
+#define AECM_BAD_PARAMETER_ERROR 12004
// Warnings
-#define AECM_BAD_PARAMETER_WARNING 12100
+#define AECM_BAD_PARAMETER_WARNING 12100
typedef struct {
- int16_t cngMode; // AECM_FALSE, AECM_TRUE (default)
- int16_t echoMode; // 0, 1, 2, 3 (default), 4
+ int16_t cngMode; // AECM_FALSE, AECM_TRUE (default)
+ int16_t echoMode; // 0, 1, 2, 3 (default), 4
} AecmConfig;
#ifdef __cplusplus
@@ -202,7 +199,6 @@
*/
size_t WebRtcAecm_echo_path_size_bytes();
-
#ifdef __cplusplus
}
#endif
diff --git a/modules/audio_processing/agc/agc_manager_direct.cc b/modules/audio_processing/agc/agc_manager_direct.cc
index 2d6ee81..9714b4c 100644
--- a/modules/audio_processing/agc/agc_manager_direct.cc
+++ b/modules/audio_processing/agc/agc_manager_direct.cc
@@ -69,12 +69,12 @@
int new_level = level;
if (gain_error > 0) {
while (kGainMap[new_level] - kGainMap[level] < gain_error &&
- new_level < kMaxMicLevel) {
+ new_level < kMaxMicLevel) {
++new_level;
}
} else {
while (kGainMap[new_level] - kGainMap[level] > gain_error &&
- new_level > kMinMicLevel) {
+ new_level > kMinMicLevel) {
--new_level;
}
}
@@ -88,26 +88,21 @@
class DebugFile {
#ifdef WEBRTC_AGC_DEBUG_DUMP
public:
- explicit DebugFile(const char* filename)
- : file_(fopen(filename, "wb")) {
+ explicit DebugFile(const char* filename) : file_(fopen(filename, "wb")) {
RTC_DCHECK(file_);
}
- ~DebugFile() {
- fclose(file_);
- }
+ ~DebugFile() { fclose(file_); }
void Write(const int16_t* data, size_t length_samples) {
fwrite(data, 1, length_samples * sizeof(int16_t), file_);
}
+
private:
FILE* file_;
#else
public:
- explicit DebugFile(const char* filename) {
- }
- ~DebugFile() {
- }
- void Write(const int16_t* data, size_t length_samples) {
- }
+ explicit DebugFile(const char* filename) {}
+ ~DebugFile() {}
+ void Write(const int16_t* data, size_t length_samples) {}
#endif // WEBRTC_AGC_DEBUG_DUMP
};
@@ -272,7 +267,8 @@
if (voe_level > level_ + kLevelQuantizationSlack ||
voe_level < level_ - kLevelQuantizationSlack) {
RTC_DLOG(LS_INFO) << "[agc] Mic volume was manually adjusted. Updating "
- "stored level from " << level_ << " to " << voe_level;
+ "stored level from "
+ << level_ << " to " << voe_level;
level_ = voe_level;
// Always allow the user to increase the volume.
if (level_ > max_level_) {
@@ -383,15 +379,15 @@
// target and the newly received target. This serves to soften perceptible
// intra-talkspurt adjustments, at the cost of some adaptation speed.
if ((raw_compression == max_compression_gain_ &&
- target_compression_ == max_compression_gain_ - 1) ||
+ target_compression_ == max_compression_gain_ - 1) ||
(raw_compression == kMinCompressionGain &&
- target_compression_ == kMinCompressionGain + 1)) {
+ target_compression_ == kMinCompressionGain + 1)) {
// Special case to allow the target to reach the endpoints of the
// compression range. The deemphasis would otherwise halt it at 1 dB shy.
target_compression_ = raw_compression;
} else {
- target_compression_ = (raw_compression - target_compression_) / 2
- + target_compression_;
+ target_compression_ =
+ (raw_compression - target_compression_) / 2 + target_compression_;
}
// Residual error will be handled by adjusting the volume slider. Use the
diff --git a/modules/audio_processing/agc/gain_map_internal.h b/modules/audio_processing/agc/gain_map_internal.h
index f09c748..63d9b51 100644
--- a/modules/audio_processing/agc/gain_map_internal.h
+++ b/modules/audio_processing/agc/gain_map_internal.h
@@ -14,262 +14,23 @@
static const int kGainMapSize = 256;
// Uses parameters: si = 2, sf = 0.25, D = 8/256
static const int kGainMap[kGainMapSize] = {
- -56,
- -54,
- -52,
- -50,
- -48,
- -47,
- -45,
- -43,
- -42,
- -40,
- -38,
- -37,
- -35,
- -34,
- -33,
- -31,
- -30,
- -29,
- -27,
- -26,
- -25,
- -24,
- -23,
- -22,
- -20,
- -19,
- -18,
- -17,
- -16,
- -15,
- -14,
- -14,
- -13,
- -12,
- -11,
- -10,
- -9,
- -8,
- -8,
- -7,
- -6,
- -5,
- -5,
- -4,
- -3,
- -2,
- -2,
- -1,
- 0,
- 0,
- 1,
- 1,
- 2,
- 3,
- 3,
- 4,
- 4,
- 5,
- 5,
- 6,
- 6,
- 7,
- 7,
- 8,
- 8,
- 9,
- 9,
- 10,
- 10,
- 11,
- 11,
- 12,
- 12,
- 13,
- 13,
- 13,
- 14,
- 14,
- 15,
- 15,
- 15,
- 16,
- 16,
- 17,
- 17,
- 17,
- 18,
- 18,
- 18,
- 19,
- 19,
- 19,
- 20,
- 20,
- 21,
- 21,
- 21,
- 22,
- 22,
- 22,
- 23,
- 23,
- 23,
- 24,
- 24,
- 24,
- 24,
- 25,
- 25,
- 25,
- 26,
- 26,
- 26,
- 27,
- 27,
- 27,
- 28,
- 28,
- 28,
- 28,
- 29,
- 29,
- 29,
- 30,
- 30,
- 30,
- 30,
- 31,
- 31,
- 31,
- 32,
- 32,
- 32,
- 32,
- 33,
- 33,
- 33,
- 33,
- 34,
- 34,
- 34,
- 35,
- 35,
- 35,
- 35,
- 36,
- 36,
- 36,
- 36,
- 37,
- 37,
- 37,
- 38,
- 38,
- 38,
- 38,
- 39,
- 39,
- 39,
- 39,
- 40,
- 40,
- 40,
- 40,
- 41,
- 41,
- 41,
- 41,
- 42,
- 42,
- 42,
- 42,
- 43,
- 43,
- 43,
- 44,
- 44,
- 44,
- 44,
- 45,
- 45,
- 45,
- 45,
- 46,
- 46,
- 46,
- 46,
- 47,
- 47,
- 47,
- 47,
- 48,
- 48,
- 48,
- 48,
- 49,
- 49,
- 49,
- 49,
- 50,
- 50,
- 50,
- 50,
- 51,
- 51,
- 51,
- 51,
- 52,
- 52,
- 52,
- 52,
- 53,
- 53,
- 53,
- 53,
- 54,
- 54,
- 54,
- 54,
- 55,
- 55,
- 55,
- 55,
- 56,
- 56,
- 56,
- 56,
- 57,
- 57,
- 57,
- 57,
- 58,
- 58,
- 58,
- 58,
- 59,
- 59,
- 59,
- 59,
- 60,
- 60,
- 60,
- 60,
- 61,
- 61,
- 61,
- 61,
- 62,
- 62,
- 62,
- 62,
- 63,
- 63,
- 63,
- 63,
- 64
-};
+ -56, -54, -52, -50, -48, -47, -45, -43, -42, -40, -38, -37, -35, -34, -33,
+ -31, -30, -29, -27, -26, -25, -24, -23, -22, -20, -19, -18, -17, -16, -15,
+ -14, -14, -13, -12, -11, -10, -9, -8, -8, -7, -6, -5, -5, -4, -3,
+ -2, -2, -1, 0, 0, 1, 1, 2, 3, 3, 4, 4, 5, 5, 6,
+ 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13,
+ 13, 14, 14, 15, 15, 15, 16, 16, 17, 17, 17, 18, 18, 18, 19,
+ 19, 19, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24,
+ 24, 24, 25, 25, 25, 26, 26, 26, 27, 27, 27, 28, 28, 28, 28,
+ 29, 29, 29, 30, 30, 30, 30, 31, 31, 31, 32, 32, 32, 32, 33,
+ 33, 33, 33, 34, 34, 34, 35, 35, 35, 35, 36, 36, 36, 36, 37,
+ 37, 37, 38, 38, 38, 38, 39, 39, 39, 39, 40, 40, 40, 40, 41,
+ 41, 41, 41, 42, 42, 42, 42, 43, 43, 43, 44, 44, 44, 44, 45,
+ 45, 45, 45, 46, 46, 46, 46, 47, 47, 47, 47, 48, 48, 48, 48,
+ 49, 49, 49, 49, 50, 50, 50, 50, 51, 51, 51, 51, 52, 52, 52,
+ 52, 53, 53, 53, 53, 54, 54, 54, 54, 55, 55, 55, 55, 56, 56,
+ 56, 56, 57, 57, 57, 57, 58, 58, 58, 58, 59, 59, 59, 59, 60,
+ 60, 60, 60, 61, 61, 61, 61, 62, 62, 62, 62, 63, 63, 63, 63,
+ 64};
#endif // MODULES_AUDIO_PROCESSING_AGC_GAIN_MAP_INTERNAL_H_
diff --git a/modules/audio_processing/agc/mock_agc.h b/modules/audio_processing/agc/mock_agc.h
index cf2a859..ff1e9fd 100644
--- a/modules/audio_processing/agc/mock_agc.h
+++ b/modules/audio_processing/agc/mock_agc.h
@@ -20,8 +20,8 @@
class MockAgc : public Agc {
public:
MOCK_METHOD2(AnalyzePreproc, float(const int16_t* audio, size_t length));
- MOCK_METHOD3(Process, void(const int16_t* audio, size_t length,
- int sample_rate_hz));
+ MOCK_METHOD3(Process,
+ void(const int16_t* audio, size_t length, int sample_rate_hz));
MOCK_METHOD1(GetRmsErrorDb, bool(int* error));
MOCK_METHOD0(Reset, void());
MOCK_METHOD1(set_target_level_dbfs, int(int level));
diff --git a/modules/audio_processing/agc2/agc2_common.h b/modules/audio_processing/agc2/agc2_common.h
index a0919c8..3ed88a3 100644
--- a/modules/audio_processing/agc2/agc2_common.h
+++ b/modules/audio_processing/agc2/agc2_common.h
@@ -15,7 +15,6 @@
#include <cmath>
-
namespace webrtc {
constexpr float kMinFloatS16Value = -32768.f;
diff --git a/modules/audio_processing/agc2/gain_applier_unittest.cc b/modules/audio_processing/agc2/gain_applier_unittest.cc
index bbf3a85..3296345 100644
--- a/modules/audio_processing/agc2/gain_applier_unittest.cc
+++ b/modules/audio_processing/agc2/gain_applier_unittest.cc
@@ -72,8 +72,7 @@
float last_signal_level = initial_signal_level;
for (const auto sample : fake_audio.float_frame_view().channel(channel)) {
const float current_change = fabs(last_signal_level - sample);
- max_signal_change =
- std::max(max_signal_change, current_change);
+ max_signal_change = std::max(max_signal_change, current_change);
last_signal_level = sample;
}
const float total_gain_change =
diff --git a/modules/audio_processing/audio_buffer.cc b/modules/audio_processing/audio_buffer.cc
index 16f1174..f163f5a 100644
--- a/modules/audio_processing/audio_buffer.cc
+++ b/modules/audio_processing/audio_buffer.cc
@@ -49,20 +49,20 @@
size_t process_num_frames,
size_t num_process_channels,
size_t output_num_frames)
- : input_num_frames_(input_num_frames),
- num_input_channels_(num_input_channels),
- proc_num_frames_(process_num_frames),
- num_proc_channels_(num_process_channels),
- output_num_frames_(output_num_frames),
- num_channels_(num_process_channels),
- num_bands_(NumBandsFromSamplesPerChannel(proc_num_frames_)),
- num_split_frames_(rtc::CheckedDivExact(proc_num_frames_, num_bands_)),
- mixed_low_pass_valid_(false),
- reference_copied_(false),
- activity_(AudioFrame::kVadUnknown),
- keyboard_data_(NULL),
- data_(new IFChannelBuffer(proc_num_frames_, num_proc_channels_)),
- output_buffer_(new IFChannelBuffer(output_num_frames_, num_channels_)) {
+ : input_num_frames_(input_num_frames),
+ num_input_channels_(num_input_channels),
+ proc_num_frames_(process_num_frames),
+ num_proc_channels_(num_process_channels),
+ output_num_frames_(output_num_frames),
+ num_channels_(num_process_channels),
+ num_bands_(NumBandsFromSamplesPerChannel(proc_num_frames_)),
+ num_split_frames_(rtc::CheckedDivExact(proc_num_frames_, num_bands_)),
+ mixed_low_pass_valid_(false),
+ reference_copied_(false),
+ activity_(AudioFrame::kVadUnknown),
+ keyboard_data_(NULL),
+ data_(new IFChannelBuffer(proc_num_frames_, num_proc_channels_)),
+ output_buffer_(new IFChannelBuffer(output_num_frames_, num_channels_)) {
RTC_DCHECK_GT(input_num_frames_, 0);
RTC_DCHECK_GT(proc_num_frames_, 0);
RTC_DCHECK_GT(output_num_frames_, 0);
@@ -73,8 +73,8 @@
if (input_num_frames_ != proc_num_frames_ ||
output_num_frames_ != proc_num_frames_) {
// Create an intermediate buffer for resampling.
- process_buffer_.reset(new ChannelBuffer<float>(proc_num_frames_,
- num_proc_channels_));
+ process_buffer_.reset(
+ new ChannelBuffer<float>(proc_num_frames_, num_proc_channels_));
if (input_num_frames_ != proc_num_frames_) {
for (size_t i = 0; i < num_proc_channels_; ++i) {
@@ -92,12 +92,10 @@
}
if (num_bands_ > 1) {
- split_data_.reset(new IFChannelBuffer(proc_num_frames_,
- num_proc_channels_,
- num_bands_));
- splitting_filter_.reset(new SplittingFilter(num_proc_channels_,
- num_bands_,
- proc_num_frames_));
+ split_data_.reset(
+ new IFChannelBuffer(proc_num_frames_, num_proc_channels_, num_bands_));
+ splitting_filter_.reset(
+ new SplittingFilter(num_proc_channels_, num_bands_, proc_num_frames_));
}
}
@@ -132,8 +130,7 @@
// Resample.
if (input_num_frames_ != proc_num_frames_) {
for (size_t i = 0; i < num_proc_channels_; ++i) {
- input_resamplers_[i]->Resample(data_ptr[i],
- input_num_frames_,
+ input_resamplers_[i]->Resample(data_ptr[i], input_num_frames_,
process_buffer_->channels()[i],
proc_num_frames_);
}
@@ -142,8 +139,7 @@
// Convert to the S16 range.
for (size_t i = 0; i < num_proc_channels_; ++i) {
- FloatToFloatS16(data_ptr[i],
- proc_num_frames_,
+ FloatToFloatS16(data_ptr[i], proc_num_frames_,
data_->fbuf()->channels()[i]);
}
}
@@ -161,17 +157,14 @@
data_ptr = process_buffer_->channels();
}
for (size_t i = 0; i < num_channels_; ++i) {
- FloatS16ToFloat(data_->fbuf()->channels()[i],
- proc_num_frames_,
+ FloatS16ToFloat(data_->fbuf()->channels()[i], proc_num_frames_,
data_ptr[i]);
}
// Resample.
if (output_num_frames_ != proc_num_frames_) {
for (size_t i = 0; i < num_channels_; ++i) {
- output_resamplers_[i]->Resample(data_ptr[i],
- proc_num_frames_,
- data[i],
+ output_resamplers_[i]->Resample(data_ptr[i], proc_num_frames_, data[i],
output_num_frames_);
}
}
@@ -204,16 +197,14 @@
}
const int16_t* const* AudioBuffer::split_bands_const(size_t channel) const {
- return split_data_.get() ?
- split_data_->ibuf_const()->bands(channel) :
- data_->ibuf_const()->bands(channel);
+ return split_data_.get() ? split_data_->ibuf_const()->bands(channel)
+ : data_->ibuf_const()->bands(channel);
}
int16_t* const* AudioBuffer::split_bands(size_t channel) {
mixed_low_pass_valid_ = false;
- return split_data_.get() ?
- split_data_->ibuf()->bands(channel) :
- data_->ibuf()->bands(channel);
+ return split_data_.get() ? split_data_->ibuf()->bands(channel)
+ : data_->ibuf()->bands(channel);
}
const int16_t* const* AudioBuffer::split_channels_const(Band band) const {
@@ -261,16 +252,14 @@
}
const float* const* AudioBuffer::split_bands_const_f(size_t channel) const {
- return split_data_.get() ?
- split_data_->fbuf_const()->bands(channel) :
- data_->fbuf_const()->bands(channel);
+ return split_data_.get() ? split_data_->fbuf_const()->bands(channel)
+ : data_->fbuf_const()->bands(channel);
}
float* const* AudioBuffer::split_bands_f(size_t channel) {
mixed_low_pass_valid_ = false;
- return split_data_.get() ?
- split_data_->fbuf()->bands(channel) :
- data_->fbuf()->bands(channel);
+ return split_data_.get() ? split_data_->fbuf()->bands(channel)
+ : data_->fbuf()->bands(channel);
}
const float* const* AudioBuffer::split_channels_const_f(Band band) const {
@@ -401,19 +390,16 @@
num_input_channels_, deinterleaved[0]);
} else {
RTC_DCHECK_EQ(num_proc_channels_, num_input_channels_);
- Deinterleave(frame->data(),
- input_num_frames_,
- num_proc_channels_,
+ Deinterleave(frame->data(), input_num_frames_, num_proc_channels_,
deinterleaved);
}
// Resample.
if (input_num_frames_ != proc_num_frames_) {
for (size_t i = 0; i < num_proc_channels_; ++i) {
- input_resamplers_[i]->Resample(input_buffer_->fbuf_const()->channels()[i],
- input_num_frames_,
- data_->fbuf()->channels()[i],
- proc_num_frames_);
+ input_resamplers_[i]->Resample(
+ input_buffer_->fbuf_const()->channels()[i], input_num_frames_,
+ data_->fbuf()->channels()[i], proc_num_frames_);
}
}
}
@@ -453,8 +439,7 @@
if (!low_pass_reference_channels_.get() ||
low_pass_reference_channels_->num_channels() != num_channels_) {
low_pass_reference_channels_.reset(
- new ChannelBuffer<int16_t>(num_split_frames_,
- num_proc_channels_));
+ new ChannelBuffer<int16_t>(num_split_frames_, num_proc_channels_));
}
for (size_t i = 0; i < num_proc_channels_; i++) {
memcpy(low_pass_reference_channels_->channels()[i],
diff --git a/modules/audio_processing/audio_buffer.h b/modules/audio_processing/audio_buffer.h
index 508f96f..3d7c4a8 100644
--- a/modules/audio_processing/audio_buffer.h
+++ b/modules/audio_processing/audio_buffer.h
@@ -25,11 +25,7 @@
class PushSincResampler;
class IFChannelBuffer;
-enum Band {
- kBand0To8kHz = 0,
- kBand8To16kHz = 1,
- kBand16To24kHz = 2
-};
+enum Band { kBand0To8kHz = 0, kBand8To16kHz = 1, kBand16To24kHz = 2 };
class AudioBuffer {
public:
@@ -152,11 +148,11 @@
std::unique_ptr<IFChannelBuffer> data_;
std::unique_ptr<IFChannelBuffer> split_data_;
std::unique_ptr<SplittingFilter> splitting_filter_;
- std::unique_ptr<ChannelBuffer<int16_t> > mixed_low_pass_channels_;
- std::unique_ptr<ChannelBuffer<int16_t> > low_pass_reference_channels_;
+ std::unique_ptr<ChannelBuffer<int16_t>> mixed_low_pass_channels_;
+ std::unique_ptr<ChannelBuffer<int16_t>> low_pass_reference_channels_;
std::unique_ptr<IFChannelBuffer> input_buffer_;
std::unique_ptr<IFChannelBuffer> output_buffer_;
- std::unique_ptr<ChannelBuffer<float> > process_buffer_;
+ std::unique_ptr<ChannelBuffer<float>> process_buffer_;
std::vector<std::unique_ptr<PushSincResampler>> input_resamplers_;
std::vector<std::unique_ptr<PushSincResampler>> output_resamplers_;
};
diff --git a/modules/audio_processing/audio_processing_impl_locking_unittest.cc b/modules/audio_processing/audio_processing_impl_locking_unittest.cc
index 39f8b8b..b770fef 100644
--- a/modules/audio_processing/audio_processing_impl_locking_unittest.cc
+++ b/modules/audio_processing/audio_processing_impl_locking_unittest.cc
@@ -146,8 +146,7 @@
// Create test config for the first processing API function set.
test_configs.push_back(test_config);
- test_config.render_api_function =
- RenderApiImpl::AnalyzeReverseStreamImpl;
+ test_config.render_api_function = RenderApiImpl::AnalyzeReverseStreamImpl;
test_config.capture_api_function = CaptureApiImpl::ProcessStreamImpl3;
test_configs.push_back(test_config);
}
@@ -482,8 +481,7 @@
for (size_t k = 0; k < frame->samples_per_channel_; k++) {
// Store random 16 bit number between -(amplitude+1) and
// amplitude.
- frame_data[k * ch] =
- rand_gen->RandInt(2 * amplitude + 1) - amplitude - 1;
+ frame_data[k * ch] = rand_gen->RandInt(2 * amplitude + 1) - amplitude - 1;
}
}
}
diff --git a/modules/audio_processing/audio_processing_impl_unittest.cc b/modules/audio_processing/audio_processing_impl_unittest.cc
index 2ea0159..3ac5e71 100644
--- a/modules/audio_processing/audio_processing_impl_unittest.cc
+++ b/modules/audio_processing/audio_processing_impl_unittest.cc
@@ -72,15 +72,13 @@
// New sample rate. (Only impacts ProcessStream).
SetFrameSampleRate(&frame, 32000);
- EXPECT_CALL(mock, InitializeLocked())
- .Times(1);
+ EXPECT_CALL(mock, InitializeLocked()).Times(1);
EXPECT_NOERR(mock.ProcessStream(&frame));
// New number of channels.
// TODO(peah): Investigate why this causes 2 inits.
frame.num_channels_ = 2;
- EXPECT_CALL(mock, InitializeLocked())
- .Times(2);
+ EXPECT_CALL(mock, InitializeLocked()).Times(2);
EXPECT_NOERR(mock.ProcessStream(&frame));
// ProcessStream sets num_channels_ == num_output_channels.
frame.num_channels_ = 2;
diff --git a/modules/audio_processing/audio_processing_performance_unittest.cc b/modules/audio_processing/audio_processing_performance_unittest.cc
index 2e985ce..56615cb 100644
--- a/modules/audio_processing/audio_processing_performance_unittest.cc
+++ b/modules/audio_processing/audio_processing_performance_unittest.cc
@@ -160,13 +160,9 @@
// Handler for the frame counters.
class FrameCounters {
public:
- void IncreaseRenderCounter() {
- rtc::AtomicOps::Increment(&render_count_);
- }
+ void IncreaseRenderCounter() { rtc::AtomicOps::Increment(&render_count_); }
- void IncreaseCaptureCounter() {
- rtc::AtomicOps::Increment(&capture_count_);
- }
+ void IncreaseCaptureCounter() { rtc::AtomicOps::Increment(&capture_count_); }
int CaptureMinusRenderCounters() const {
// The return value will be approximate, but that's good enough since
@@ -196,9 +192,7 @@
// Class that represents a flag that can only be raised.
class LockedFlag {
public:
- bool get_flag() const {
- return rtc::AtomicOps::AcquireLoad(&flag_);
- }
+ bool get_flag() const { return rtc::AtomicOps::AcquireLoad(&flag_); }
void set_flag() {
if (!get_flag()) // read-only operation to avoid affecting the cache-line.
@@ -248,9 +242,8 @@
"_" + std::to_string(simulation_config_->sample_rate_hz) + "Hz";
webrtc::test::PrintResultMeanAndError(
- "apm_timing", sample_rate_name, processor_name,
- GetDurationAverage(), GetDurationStandardDeviation(),
- "us", false);
+ "apm_timing", sample_rate_name, processor_name, GetDurationAverage(),
+ GetDurationStandardDeviation(), "us", false);
if (kPrintAllDurations) {
webrtc::test::PrintResultList("apm_call_durations", sample_rate_name,
diff --git a/modules/audio_processing/beamformer/array_util.h b/modules/audio_processing/beamformer/array_util.h
index 8e69f81..9bdbecb 100644
--- a/modules/audio_processing/beamformer/array_util.h
+++ b/modules/audio_processing/beamformer/array_util.h
@@ -24,7 +24,7 @@
// y: the depth dimension, with positive forward from the camera's
// perspective.
// z: the vertical dimension, with positive upwards.
-template<typename T>
+template <typename T>
struct CartesianPoint {
CartesianPoint() {
c[0] = 0;
@@ -74,7 +74,7 @@
// The resulting Point will be in the xy-plane.
Point AzimuthToPoint(float azimuth);
-template<typename T>
+template <typename T>
float Distance(CartesianPoint<T> a, CartesianPoint<T> b) {
return std::sqrt((a.x() - b.x()) * (a.x() - b.x()) +
(a.y() - b.y()) * (a.y() - b.y()) +
diff --git a/modules/audio_processing/beamformer/complex_matrix_unittest.cc b/modules/audio_processing/beamformer/complex_matrix_unittest.cc
index e11dfd2..f9c7ea5 100644
--- a/modules/audio_processing/beamformer/complex_matrix_unittest.cc
+++ b/modules/audio_processing/beamformer/complex_matrix_unittest.cc
@@ -61,10 +61,10 @@
{complex<float>(3.3f, -3.3f), complex<float>(7.7f, -7.7f)},
{complex<float>(4.4f, -4.4f), complex<float>(8.8f, -8.8f)}};
- ComplexMatrix<float> initial_mat(
- *kValuesInitial, kNumInitialRows, kNumInitialCols);
- ComplexMatrix<float> expected_result(
- *kValuesExpected, kNumResultRows, kNumResultCols);
+ ComplexMatrix<float> initial_mat(*kValuesInitial, kNumInitialRows,
+ kNumInitialCols);
+ ComplexMatrix<float> expected_result(*kValuesExpected, kNumResultRows,
+ kNumResultCols);
ComplexMatrix<float> actual_result(kNumResultRows, kNumResultCols);
actual_result.ConjugateTranspose(initial_mat);
diff --git a/modules/audio_processing/beamformer/covariance_matrix_generator.cc b/modules/audio_processing/beamformer/covariance_matrix_generator.cc
index df36d59..afc6ddd 100644
--- a/modules/audio_processing/beamformer/covariance_matrix_generator.cc
+++ b/modules/audio_processing/beamformer/covariance_matrix_generator.cc
@@ -73,13 +73,8 @@
ComplexMatrix<float> interf_cov_vector(1, geometry.size());
ComplexMatrix<float> interf_cov_vector_transposed(geometry.size(), 1);
- PhaseAlignmentMasks(frequency_bin,
- fft_size,
- sample_rate,
- sound_speed,
- geometry,
- angle,
- &interf_cov_vector);
+ PhaseAlignmentMasks(frequency_bin, fft_size, sample_rate, sound_speed,
+ geometry, angle, &interf_cov_vector);
interf_cov_vector.Scale(1.f / Norm(interf_cov_vector));
interf_cov_vector_transposed.Transpose(interf_cov_vector);
interf_cov_vector.PointwiseConjugate();
diff --git a/modules/audio_processing/beamformer/covariance_matrix_generator.h b/modules/audio_processing/beamformer/covariance_matrix_generator.h
index 6a5841f..d26ed2f 100644
--- a/modules/audio_processing/beamformer/covariance_matrix_generator.h
+++ b/modules/audio_processing/beamformer/covariance_matrix_generator.h
@@ -11,8 +11,8 @@
#ifndef MODULES_AUDIO_PROCESSING_BEAMFORMER_COVARIANCE_MATRIX_GENERATOR_H_
#define MODULES_AUDIO_PROCESSING_BEAMFORMER_COVARIANCE_MATRIX_GENERATOR_H_
-#include "modules/audio_processing/beamformer/complex_matrix.h"
#include "modules/audio_processing/beamformer/array_util.h"
+#include "modules/audio_processing/beamformer/complex_matrix.h"
namespace webrtc {
diff --git a/modules/audio_processing/beamformer/covariance_matrix_generator_unittest.cc b/modules/audio_processing/beamformer/covariance_matrix_generator_unittest.cc
index a6518e5..4f77744 100644
--- a/modules/audio_processing/beamformer/covariance_matrix_generator_unittest.cc
+++ b/modules/audio_processing/beamformer/covariance_matrix_generator_unittest.cc
@@ -32,8 +32,7 @@
geometry.push_back(Point(i * kMicSpacing - first_mic, 0.f, 0.f));
}
ComplexMatrix<float> actual_covariance_matrix(kNumberMics, kNumberMics);
- CovarianceMatrixGenerator::UniformCovarianceMatrix(kWaveNumber,
- geometry,
+ CovarianceMatrixGenerator::UniformCovarianceMatrix(kWaveNumber, geometry,
&actual_covariance_matrix);
complex<float>* const* actual_els = actual_covariance_matrix.elements();
@@ -60,8 +59,7 @@
geometry.push_back(Point(i * kMicSpacing - first_mic, 0.f, 0.f));
}
ComplexMatrix<float> actual_covariance_matrix(kNumberMics, kNumberMics);
- CovarianceMatrixGenerator::UniformCovarianceMatrix(kWaveNumber,
- geometry,
+ CovarianceMatrixGenerator::UniformCovarianceMatrix(kWaveNumber, geometry,
&actual_covariance_matrix);
complex<float>* const* actual_els = actual_covariance_matrix.elements();
@@ -97,8 +95,7 @@
geometry.push_back(Point(-0.025f, 0.15f, -0.075f));
geometry.push_back(Point(-0.025f, -0.05f, 0.225f));
ComplexMatrix<float> actual_covariance_matrix(kNumberMics, kNumberMics);
- CovarianceMatrixGenerator::UniformCovarianceMatrix(kWaveNumber,
- geometry,
+ CovarianceMatrixGenerator::UniformCovarianceMatrix(kWaveNumber, geometry,
&actual_covariance_matrix);
complex<float>* const* actual_els = actual_covariance_matrix.elements();
@@ -154,14 +151,9 @@
geometry.push_back(Point(i * kMicSpacing - first_mic, 0.f, 0.f));
}
ComplexMatrix<float> actual_covariance_matrix(kNumberMics, kNumberMics);
- CovarianceMatrixGenerator::AngledCovarianceMatrix(kSpeedOfSound,
- kAngle,
- kFrequencyBin,
- kFftSize,
- kNumberFrequencyBins,
- kSampleRate,
- geometry,
- &actual_covariance_matrix);
+ CovarianceMatrixGenerator::AngledCovarianceMatrix(
+ kSpeedOfSound, kAngle, kFrequencyBin, kFftSize, kNumberFrequencyBins,
+ kSampleRate, geometry, &actual_covariance_matrix);
complex<float>* const* actual_els = actual_covariance_matrix.elements();
@@ -192,14 +184,9 @@
geometry.push_back(Point(i * kMicSpacing - first_mic, 0.f, 0.f));
}
ComplexMatrix<float> actual_covariance_matrix(kNumberMics, kNumberMics);
- CovarianceMatrixGenerator::AngledCovarianceMatrix(kSpeedOfSound,
- kAngle,
- kFrequencyBin,
- kFftSize,
- kNumberFrequencyBins,
- kSampleRate,
- geometry,
- &actual_covariance_matrix);
+ CovarianceMatrixGenerator::AngledCovarianceMatrix(
+ kSpeedOfSound, kAngle, kFrequencyBin, kFftSize, kNumberFrequencyBins,
+ kSampleRate, geometry, &actual_covariance_matrix);
complex<float>* const* actual_els = actual_covariance_matrix.elements();
diff --git a/modules/audio_processing/beamformer/matrix.h b/modules/audio_processing/beamformer/matrix.h
index bf94c25..3d1a709 100644
--- a/modules/audio_processing/beamformer/matrix.h
+++ b/modules/audio_processing/beamformer/matrix.h
@@ -33,7 +33,7 @@
std::complex<S> sqrt_wrapper(std::complex<S> x) {
return sqrt(x);
}
-} // namespace
+} // namespace
namespace webrtc {
diff --git a/modules/audio_processing/beamformer/matrix_test_helpers.h b/modules/audio_processing/beamformer/matrix_test_helpers.h
index 62b4708..e7b2f09 100644
--- a/modules/audio_processing/beamformer/matrix_test_helpers.h
+++ b/modules/audio_processing/beamformer/matrix_test_helpers.h
@@ -66,11 +66,9 @@
for (size_t i = 0; i < expected.num_rows(); ++i) {
for (size_t j = 0; j < expected.num_columns(); ++j) {
EXPECT_NEAR(expected_elements[i][j].real(),
- actual_elements[i][j].real(),
- kTolerance);
+ actual_elements[i][j].real(), kTolerance);
EXPECT_NEAR(expected_elements[i][j].imag(),
- actual_elements[i][j].imag(),
- kTolerance);
+ actual_elements[i][j].imag(), kTolerance);
}
}
}
@@ -87,11 +85,9 @@
for (size_t i = 0; i < expected.num_rows(); ++i) {
for (size_t j = 0; j < expected.num_columns(); ++j) {
EXPECT_NEAR(expected_elements[i][j].real(),
- actual_elements[i][j].real(),
- tolerance);
+ actual_elements[i][j].real(), tolerance);
EXPECT_NEAR(expected_elements[i][j].imag(),
- actual_elements[i][j].imag(),
- tolerance);
+ actual_elements[i][j].imag(), tolerance);
}
}
}
diff --git a/modules/audio_processing/beamformer/matrix_unittest.cc b/modules/audio_processing/beamformer/matrix_unittest.cc
index 4badfd0..4dcf91b 100644
--- a/modules/audio_processing/beamformer/matrix_unittest.cc
+++ b/modules/audio_processing/beamformer/matrix_unittest.cc
@@ -74,8 +74,8 @@
{1.1f, 5.5f}, {2.2f, 6.6f}, {3.3f, 7.7f}, {4.4f, 8.8f}};
Matrix<float> initial_mat(*kValuesInitial, kNumInitialRows, kNumInitialCols);
- Matrix<float> expected_result(
- *kValuesExpected, kNumResultRows, kNumResultCols);
+ Matrix<float> expected_result(*kValuesExpected, kNumResultRows,
+ kNumResultCols);
Matrix<float> actual_result(kNumResultRows, kNumResultCols);
actual_result.Transpose(initial_mat);
@@ -300,10 +300,10 @@
Matrix<complex<float> > lh_mat(*kValuesLeft, kNumRows, kNumCols);
Matrix<complex<float> > rh_mat(*kValuesRight, kNumRows, kNumCols);
- Matrix<complex<float> > expected_result_add(
- *kValuesExpectedAdd, kNumRows, kNumCols);
- Matrix<complex<float> > expected_result_multiply(
- *kValuesExpectedMultiply, kNumRows, kNumCols);
+ Matrix<complex<float> > expected_result_add(*kValuesExpectedAdd, kNumRows,
+ kNumCols);
+ Matrix<complex<float> > expected_result_multiply(*kValuesExpectedMultiply,
+ kNumRows, kNumCols);
Matrix<complex<float> > expected_result_pointwise_divide(
*kValuesExpectedPointwiseDivide, kNumRows, kNumCols);
Matrix<complex<float> > actual_result_add;
diff --git a/modules/audio_processing/beamformer/nonlinear_beamformer.cc b/modules/audio_processing/beamformer/nonlinear_beamformer.cc
index 12f6d2f..89dc44c 100644
--- a/modules/audio_processing/beamformer/nonlinear_beamformer.cc
+++ b/modules/audio_processing/beamformer/nonlinear_beamformer.cc
@@ -234,13 +234,9 @@
hold_target_blocks_ = kHoldTargetSeconds * 2 * sample_rate_hz / kFftSize;
interference_blocks_count_ = hold_target_blocks_;
- process_transform_.reset(new LappedTransform(num_input_channels_,
- 0u,
- chunk_length_,
- window_,
- kFftSize,
- kFftSize / 2,
- this));
+ process_transform_.reset(new LappedTransform(num_input_channels_, 0u,
+ chunk_length_, window_, kFftSize,
+ kFftSize / 2, this));
postfilter_transform_.reset(new PostFilterTransform(
num_postfilter_channels_, chunk_length_, window_, kFftSize));
const float wave_number_step =
@@ -267,10 +263,10 @@
// low_mean_end_bin_ high_mean_end_bin_
//
void NonlinearBeamformer::InitLowFrequencyCorrectionRanges() {
- low_mean_start_bin_ = Round(static_cast<float>(kLowMeanStartHz) *
- kFftSize / sample_rate_hz_);
- low_mean_end_bin_ = Round(static_cast<float>(kLowMeanEndHz) *
- kFftSize / sample_rate_hz_);
+ low_mean_start_bin_ =
+ Round(static_cast<float>(kLowMeanStartHz) * kFftSize / sample_rate_hz_);
+ low_mean_end_bin_ =
+ Round(static_cast<float>(kLowMeanEndHz) * kFftSize / sample_rate_hz_);
RTC_DCHECK_GT(low_mean_start_bin_, 0U);
RTC_DCHECK_LT(low_mean_start_bin_, low_mean_end_bin_);
@@ -280,10 +276,10 @@
const float kAliasingFreqHz =
kSpeedOfSoundMeterSeconds /
(min_mic_spacing_ * (1.f + std::abs(std::cos(target_angle_radians_))));
- const float kHighMeanStartHz = std::min(0.5f * kAliasingFreqHz,
- sample_rate_hz_ / 2.f);
- const float kHighMeanEndHz = std::min(0.75f * kAliasingFreqHz,
- sample_rate_hz_ / 2.f);
+ const float kHighMeanStartHz =
+ std::min(0.5f * kAliasingFreqHz, sample_rate_hz_ / 2.f);
+ const float kHighMeanEndHz =
+ std::min(0.75f * kAliasingFreqHz, sample_rate_hz_ / 2.f);
high_mean_start_bin_ = Round(kHighMeanStartHz * kFftSize / sample_rate_hz_);
high_mean_end_bin_ = Round(kHighMeanEndHz * kFftSize / sample_rate_hz_);
@@ -366,14 +362,8 @@
new ComplexMatrixF(num_input_channels_, num_input_channels_)));
ComplexMatrixF angled_cov_mat(num_input_channels_, num_input_channels_);
CovarianceMatrixGenerator::AngledCovarianceMatrix(
- kSpeedOfSoundMeterSeconds,
- interf_angles_radians_[j],
- i,
- kFftSize,
- kNumFreqBins,
- sample_rate_hz_,
- array_geometry_,
- &angled_cov_mat);
+ kSpeedOfSoundMeterSeconds, interf_angles_radians_[j], i, kFftSize,
+ kNumFreqBins, sample_rate_hz_, array_geometry_, &angled_cov_mat);
// Normalize matrices before averaging them.
complex_f normalization_factor = angled_cov_mat.elements()[0][0];
angled_cov_mat.Scale(1.f / normalization_factor);
@@ -442,7 +432,9 @@
kHalfBeamWidthRadians;
}
-bool NonlinearBeamformer::is_target_present() { return is_target_present_; }
+bool NonlinearBeamformer::is_target_present() {
+ return is_target_present_;
+}
void NonlinearBeamformer::ProcessAudioBlock(const complex_f* const* input,
size_t num_input_channels,
@@ -473,15 +465,11 @@
rmw *= rmw;
float rmw_r = rmw.real();
- new_mask_[i] = CalculatePostfilterMask(*interf_cov_mats_[i][0],
- rpsiws_[i][0],
- ratio_rxiw_rxim,
- rmw_r);
+ new_mask_[i] = CalculatePostfilterMask(
+ *interf_cov_mats_[i][0], rpsiws_[i][0], ratio_rxiw_rxim, rmw_r);
for (size_t j = 1; j < interf_angles_radians_.size(); ++j) {
- float tmp_mask = CalculatePostfilterMask(*interf_cov_mats_[i][j],
- rpsiws_[i][j],
- ratio_rxiw_rxim,
- rmw_r);
+ float tmp_mask = CalculatePostfilterMask(
+ *interf_cov_mats_[i][j], rpsiws_[i][j], ratio_rxiw_rxim, rmw_r);
if (tmp_mask < new_mask_[i]) {
new_mask_[i] = tmp_mask;
}
@@ -577,8 +565,8 @@
// Compute mean over the given range of time_smooth_mask_, [first, last).
float NonlinearBeamformer::MaskRangeMean(size_t first, size_t last) {
RTC_DCHECK_GT(last, first);
- const float sum = std::accumulate(time_smooth_mask_ + first,
- time_smooth_mask_ + last, 0.f);
+ const float sum =
+ std::accumulate(time_smooth_mask_ + first, time_smooth_mask_ + last, 0.f);
return sum / (last - first);
}
diff --git a/modules/audio_processing/beamformer/nonlinear_beamformer.h b/modules/audio_processing/beamformer/nonlinear_beamformer.h
index 9ae28ed..b58165f 100644
--- a/modules/audio_processing/beamformer/nonlinear_beamformer.h
+++ b/modules/audio_processing/beamformer/nonlinear_beamformer.h
@@ -21,8 +21,8 @@
#include <memory>
#include <vector>
-#include "common_audio/lapped_transform.h"
#include "common_audio/channel_buffer.h"
+#include "common_audio/lapped_transform.h"
#include "modules/audio_processing/beamformer/array_util.h"
#include "modules/audio_processing/beamformer/complex_matrix.h"
diff --git a/modules/audio_processing/beamformer/nonlinear_beamformer_test.cc b/modules/audio_processing/beamformer/nonlinear_beamformer_test.cc
index 7db5b9f3..10f5cc0 100644
--- a/modules/audio_processing/beamformer/nonlinear_beamformer_test.cc
+++ b/modules/audio_processing/beamformer/nonlinear_beamformer_test.cc
@@ -20,10 +20,11 @@
DEFINE_string(i, "", "The name of the input file to read from.");
DEFINE_string(o, "out.wav", "Name of the output file to write to.");
-DEFINE_string(mic_positions, "",
- "Space delimited cartesian coordinates of microphones in meters. "
- "The coordinates of each point are contiguous. "
- "For a two element array: \"x1 y1 z1 x2 y2 z2\"");
+DEFINE_string(mic_positions,
+ "",
+ "Space delimited cartesian coordinates of microphones in meters. "
+ "The coordinates of each point are contiguous. "
+ "For a two element array: \"x1 y1 z1 x2 y2 z2\"");
DEFINE_bool(help, false, "Prints this message.");
namespace webrtc {
@@ -63,8 +64,8 @@
} // namespace
int main(int argc, char* argv[]) {
- if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) ||
- FLAG_help || argc != 1) {
+ if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || FLAG_help ||
+ argc != 1) {
printf("%s", kUsage);
if (FLAG_help) {
rtc::FlagList::Print(nullptr, false);
@@ -84,8 +85,8 @@
NonlinearBeamformer bf(array_geometry, array_geometry.size());
bf.Initialize(kChunkSizeMs, in_file.sample_rate());
- printf("Input file: %s\nChannels: %" PRIuS ", Sample rate: %d Hz\n\n",
- FLAG_i, in_file.num_channels(), in_file.sample_rate());
+ printf("Input file: %s\nChannels: %" PRIuS ", Sample rate: %d Hz\n\n", FLAG_i,
+ in_file.num_channels(), in_file.sample_rate());
printf("Output file: %s\nChannels: %" PRIuS ", Sample rate: %d Hz\n\n",
FLAG_o, out_file.num_channels(), out_file.sample_rate());
@@ -94,17 +95,17 @@
in_file.num_channels());
std::vector<float> interleaved(buf.size());
- while (in_file.ReadSamples(interleaved.size(),
- &interleaved[0]) == interleaved.size()) {
+ while (in_file.ReadSamples(interleaved.size(), &interleaved[0]) ==
+ interleaved.size()) {
FloatS16ToFloat(&interleaved[0], interleaved.size(), &interleaved[0]);
- Deinterleave(&interleaved[0], buf.num_frames(),
- buf.num_channels(), buf.channels());
+ Deinterleave(&interleaved[0], buf.num_frames(), buf.num_channels(),
+ buf.channels());
bf.AnalyzeChunk(buf);
bf.PostFilter(&buf);
- Interleave(buf.channels(), buf.num_frames(),
- buf.num_channels(), &interleaved[0]);
+ Interleave(buf.channels(), buf.num_frames(), buf.num_channels(),
+ &interleaved[0]);
FloatToFloatS16(&interleaved[0], interleaved.size(), &interleaved[0]);
out_file.WriteSamples(&interleaved[0], interleaved.size());
}
diff --git a/modules/audio_processing/beamformer/nonlinear_beamformer_unittest.cc b/modules/audio_processing/beamformer/nonlinear_beamformer_unittest.cc
index 78b2f0a..7d81b88 100644
--- a/modules/audio_processing/beamformer/nonlinear_beamformer_unittest.cc
+++ b/modules/audio_processing/beamformer/nonlinear_beamformer_unittest.cc
@@ -260,8 +260,7 @@
TargetDirection1, kOutputReference);
}
-TEST(BeamformerBitExactnessTest,
- Stereo16kHz_ArrayGeometry1_TargetDirection1) {
+TEST(BeamformerBitExactnessTest, Stereo16kHz_ArrayGeometry1_TargetDirection1) {
const float kOutputReference[] = {-0.000077f, -0.000147f, -0.000138f,
-0.000077f, -0.000147f, -0.000138f};
@@ -269,8 +268,7 @@
TargetDirection1, kOutputReference);
}
-TEST(BeamformerBitExactnessTest,
- Stereo32kHz_ArrayGeometry1_TargetDirection1) {
+TEST(BeamformerBitExactnessTest, Stereo32kHz_ArrayGeometry1_TargetDirection1) {
const float kOutputReference[] = {-0.000061f, -0.000061f, -0.000061f,
-0.000061f, -0.000061f, -0.000061f};
@@ -278,8 +276,7 @@
TargetDirection1, kOutputReference);
}
-TEST(BeamformerBitExactnessTest,
- Stereo48kHz_ArrayGeometry1_TargetDirection1) {
+TEST(BeamformerBitExactnessTest, Stereo48kHz_ArrayGeometry1_TargetDirection1) {
const float kOutputReference[] = {0.000450f, 0.000436f, 0.000433f,
0.000450f, 0.000436f, 0.000433f};
@@ -298,8 +295,7 @@
TargetDirection2, kOutputReference);
}
-TEST(BeamformerBitExactnessTest,
- Stereo16kHz_ArrayGeometry1_TargetDirection2) {
+TEST(BeamformerBitExactnessTest, Stereo16kHz_ArrayGeometry1_TargetDirection2) {
const float kOutputReference[] = {0.000221f, -0.000249f, 0.000140f,
0.000221f, -0.000249f, 0.000140f};
@@ -307,8 +303,7 @@
TargetDirection2, kOutputReference);
}
-TEST(BeamformerBitExactnessTest,
- Stereo32kHz_ArrayGeometry1_TargetDirection2) {
+TEST(BeamformerBitExactnessTest, Stereo32kHz_ArrayGeometry1_TargetDirection2) {
const float kOutputReference[] = {0.000763f, -0.000336f, 0.000549f,
0.000763f, -0.000336f, 0.000549f};
@@ -316,8 +311,7 @@
TargetDirection2, kOutputReference);
}
-TEST(BeamformerBitExactnessTest,
- Stereo48kHz_ArrayGeometry1_TargetDirection2) {
+TEST(BeamformerBitExactnessTest, Stereo48kHz_ArrayGeometry1_TargetDirection2) {
const float kOutputReference[] = {-0.000004f, -0.000494f, 0.000255f,
-0.000004f, -0.000494f, 0.000255f};
@@ -325,8 +319,7 @@
TargetDirection2, kOutputReference);
}
-TEST(BeamformerBitExactnessTest,
- Stereo8kHz_ArrayGeometry2_TargetDirection2) {
+TEST(BeamformerBitExactnessTest, Stereo8kHz_ArrayGeometry2_TargetDirection2) {
const float kOutputReference[] = {-0.000914f, 0.002170f, -0.002382f,
-0.000914f, 0.002170f, -0.002382f};
@@ -334,8 +327,7 @@
TargetDirection2, kOutputReference);
}
-TEST(BeamformerBitExactnessTest,
- Stereo16kHz_ArrayGeometry2_TargetDirection2) {
+TEST(BeamformerBitExactnessTest, Stereo16kHz_ArrayGeometry2_TargetDirection2) {
const float kOutputReference[] = {0.000179f, -0.000179f, 0.000081f,
0.000179f, -0.000179f, 0.000081f};
@@ -343,8 +335,7 @@
TargetDirection2, kOutputReference);
}
-TEST(BeamformerBitExactnessTest,
- Stereo32kHz_ArrayGeometry2_TargetDirection2) {
+TEST(BeamformerBitExactnessTest, Stereo32kHz_ArrayGeometry2_TargetDirection2) {
const float kOutputReference[] = {0.000549f, -0.000214f, 0.000366f,
0.000549f, -0.000214f, 0.000366f};
@@ -352,8 +343,7 @@
TargetDirection2, kOutputReference);
}
-TEST(BeamformerBitExactnessTest,
- Stereo48kHz_ArrayGeometry2_TargetDirection2) {
+TEST(BeamformerBitExactnessTest, Stereo48kHz_ArrayGeometry2_TargetDirection2) {
const float kOutputReference[] = {0.000019f, -0.000310f, 0.000182f,
0.000019f, -0.000310f, 0.000182f};
diff --git a/modules/audio_processing/config_unittest.cc b/modules/audio_processing/config_unittest.cc
index 8776ee3..19e9ab3 100644
--- a/modules/audio_processing/config_unittest.cc
+++ b/modules/audio_processing/config_unittest.cc
@@ -19,11 +19,9 @@
static const int kDefaultFactor;
static const int kDefaultOffset;
- MyExperiment()
- : factor(kDefaultFactor), offset(kDefaultOffset) {}
+ MyExperiment() : factor(kDefaultFactor), offset(kDefaultOffset) {}
- MyExperiment(int factor, int offset)
- : factor(factor), offset(offset) {}
+ MyExperiment(int factor, int offset) : factor(factor), offset(offset) {}
int factor;
int offset;
@@ -61,17 +59,13 @@
ConfigOptionID::kAlgo1CostFunctionForTest;
Algo1_CostFunction() {}
- virtual int cost(int x) const {
- return x;
- }
+ virtual int cost(int x) const { return x; }
virtual ~Algo1_CostFunction() {}
};
struct SqrCost : Algo1_CostFunction {
- virtual int cost(int x) const {
- return x*x;
- }
+ virtual int cost(int x) const { return x * x; }
};
TEST(Config, SupportsPolymorphism) {
diff --git a/modules/audio_processing/echo_cancellation_impl.cc b/modules/audio_processing/echo_cancellation_impl.cc
index 99f676c..15cd0db 100644
--- a/modules/audio_processing/echo_cancellation_impl.cc
+++ b/modules/audio_processing/echo_cancellation_impl.cc
@@ -147,7 +147,6 @@
}
}
-
int EchoCancellationImpl::ProcessCaptureAudio(AudioBuffer* audio,
int stream_delay_ms) {
rtc::CritScope cs_capture(crit_capture_);
@@ -376,7 +375,8 @@
return GetDelayMetrics(median, std, &fraction_poor_delays);
}
-int EchoCancellationImpl::GetDelayMetrics(int* median, int* std,
+int EchoCancellationImpl::GetDelayMetrics(int* median,
+ int* std,
float* fraction_poor_delays) {
rtc::CritScope cs(crit_capture_);
if (median == NULL) {
@@ -445,8 +445,7 @@
rtc::CritScope cs(crit_capture_);
RTC_DCHECK(enabled_);
// Report the delay for the first AEC component.
- return WebRtcAec_system_delay(
- WebRtcAec_aec_core(cancellers_[0]->state()));
+ return WebRtcAec_system_delay(WebRtcAec_aec_core(cancellers_[0]->state()));
}
void EchoCancellationImpl::PackRenderAudioBuffer(
diff --git a/modules/audio_processing/echo_control_mobile_impl.cc b/modules/audio_processing/echo_control_mobile_impl.cc
index 0ff1bce..841364f 100644
--- a/modules/audio_processing/echo_control_mobile_impl.cc
+++ b/modules/audio_processing/echo_control_mobile_impl.cc
@@ -120,10 +120,10 @@
}
EchoControlMobileImpl::~EchoControlMobileImpl() {
- if (external_echo_path_ != NULL) {
- delete [] external_echo_path_;
- external_echo_path_ = NULL;
- }
+ if (external_echo_path_ != NULL) {
+ delete[] external_echo_path_;
+ external_echo_path_ = NULL;
+ }
}
void EchoControlMobileImpl::ProcessRenderAudio(
@@ -218,8 +218,7 @@
++handle_index;
}
for (size_t band = 1u; band < audio->num_bands(); ++band) {
- memset(audio->split_bands(capture)[band],
- 0,
+ memset(audio->split_bands(capture)[band], 0,
audio->num_frames_per_band() *
sizeof(audio->split_bands(capture)[band][0]));
}
@@ -269,8 +268,7 @@
return Configure();
}
-EchoControlMobile::RoutingMode EchoControlMobileImpl::routing_mode()
- const {
+EchoControlMobile::RoutingMode EchoControlMobileImpl::routing_mode() const {
rtc::CritScope cs(crit_capture_);
return routing_mode_;
}
diff --git a/modules/audio_processing/gain_control_impl.cc b/modules/audio_processing/gain_control_impl.cc
index 8be261c..685a27f 100644
--- a/modules/audio_processing/gain_control_impl.cc
+++ b/modules/audio_processing/gain_control_impl.cc
@@ -67,9 +67,7 @@
set_capture_level(capture_level);
}
- void set_capture_level(int capture_level) {
- capture_level_ = capture_level;
- }
+ void set_capture_level(int capture_level) { capture_level_ = capture_level; }
int get_capture_level() {
RTC_DCHECK(capture_level_);
@@ -259,7 +257,7 @@
data_dumper_->DumpRaw("gain_control_stream_analog_level", 1,
&analog_capture_level_);
// TODO(ajm): enable this assertion?
- //RTC_DCHECK_EQ(kAdaptiveAnalog, mode_);
+ // RTC_DCHECK_EQ(kAdaptiveAnalog, mode_);
return analog_capture_level_;
}
@@ -303,8 +301,7 @@
return mode_;
}
-int GainControlImpl::set_analog_level_limits(int minimum,
- int maximum) {
+int GainControlImpl::set_analog_level_limits(int minimum, int maximum) {
if (minimum < 0) {
return AudioProcessing::kBadParameterError;
}
@@ -419,11 +416,10 @@
WebRtcAgcConfig config;
// TODO(ajm): Flip the sign here (since AGC expects a positive value) if we
// change the interface.
- //RTC_DCHECK_LE(target_level_dbfs_, 0);
- //config.targetLevelDbfs = static_cast<int16_t>(-target_level_dbfs_);
+ // RTC_DCHECK_LE(target_level_dbfs_, 0);
+ // config.targetLevelDbfs = static_cast<int16_t>(-target_level_dbfs_);
config.targetLevelDbfs = static_cast<int16_t>(target_level_dbfs_);
- config.compressionGaindB =
- static_cast<int16_t>(compression_gain_db_);
+ config.compressionGaindB = static_cast<int16_t>(compression_gain_db_);
config.limiterEnable = limiter_enabled_;
int error = AudioProcessing::kNoError;
diff --git a/modules/audio_processing/include/audio_processing.h b/modules/audio_processing/include/audio_processing.h
index d5bdeea..38a97ca 100644
--- a/modules/audio_processing/include/audio_processing.h
+++ b/modules/audio_processing/include/audio_processing.h
@@ -18,7 +18,7 @@
#include <math.h>
#include <stddef.h> // size_t
-#include <stdio.h> // FILE
+#include <stdio.h> // FILE
#include <string.h>
#include <vector>
@@ -743,8 +743,8 @@
private:
static size_t calculate_frames(int sample_rate_hz) {
- return static_cast<size_t>(
- AudioProcessing::kChunkSizeMs * sample_rate_hz / 1000);
+ return static_cast<size_t>(AudioProcessing::kChunkSizeMs * sample_rate_hz /
+ 1000);
}
int sample_rate_hz_;
@@ -893,7 +893,8 @@
// Deprecated. Use GetStatistics on the AudioProcessing interface instead.
virtual int GetDelayMetrics(int* median, int* std) = 0;
// Deprecated. Use GetStatistics on the AudioProcessing interface instead.
- virtual int GetDelayMetrics(int* median, int* std,
+ virtual int GetDelayMetrics(int* median,
+ int* std,
float* fraction_poor_delays) = 0;
// Returns a pointer to the low level AEC component. In case of multiple
@@ -1037,8 +1038,7 @@
// Sets the |minimum| and |maximum| analog levels of the audio capture device.
// Must be set if and only if an analog mode is used. Limited to [0, 65535].
- virtual int set_analog_level_limits(int minimum,
- int maximum) = 0;
+ virtual int set_analog_level_limits(int minimum, int maximum) = 0;
virtual int analog_level_minimum() const = 0;
virtual int analog_level_maximum() const = 0;
@@ -1097,12 +1097,7 @@
// Determines the aggressiveness of the suppression. Increasing the level
// will reduce the noise level at the expense of a higher speech distortion.
- enum Level {
- kLow,
- kModerate,
- kHigh,
- kVeryHigh
- };
+ enum Level { kLow, kModerate, kHigh, kVeryHigh };
virtual int set_level(Level level) = 0;
virtual Level level() const = 0;
diff --git a/modules/audio_processing/include/config.h b/modules/audio_processing/include/config.h
index 4e318c9..9232b2e 100644
--- a/modules/audio_processing/include/config.h
+++ b/modules/audio_processing/include/config.h
@@ -64,11 +64,13 @@
// Returned references are owned by this.
//
// Requires std::is_default_constructible<T>
- template<typename T> const T& Get() const;
+ template <typename T>
+ const T& Get() const;
// Set the option, deleting any previous instance of the same.
// This instance gets ownership of the newly set value.
- template<typename T> void Set(T* value);
+ template <typename T>
+ void Set(T* value);
Config();
~Config();
@@ -78,16 +80,14 @@
virtual ~BaseOption() {}
};
- template<typename T>
+ template <typename T>
struct Option : BaseOption {
- explicit Option(T* v): value(v) {}
- ~Option() {
- delete value;
- }
+ explicit Option(T* v) : value(v) {}
+ ~Option() { delete value; }
T* value;
};
- template<typename T>
+ template <typename T>
static ConfigOptionID identifier() {
return T::identifier;
}
@@ -95,7 +95,7 @@
// Used to instantiate a default constructed object that doesn't needs to be
// owned. This allows Get<T> to be implemented without requiring explicitly
// locks.
- template<typename T>
+ template <typename T>
static const T& default_value() {
static const T* const def = new T();
return *def;
@@ -109,7 +109,7 @@
void operator=(const Config&);
};
-template<typename T>
+template <typename T>
const T& Config::Get() const {
OptionMap::const_iterator it = options_.find(identifier<T>());
if (it != options_.end()) {
@@ -121,7 +121,7 @@
return default_value<T>();
}
-template<typename T>
+template <typename T>
void Config::Set(T* value) {
BaseOption*& it = options_[identifier<T>()];
delete it;
diff --git a/modules/audio_processing/include/mock_audio_processing.h b/modules/audio_processing/include/mock_audio_processing.h
index b3253e9..9ceee10 100644
--- a/modules/audio_processing/include/mock_audio_processing.h
+++ b/modules/audio_processing/include/mock_audio_processing.h
@@ -40,8 +40,8 @@
MOCK_METHOD1(enable_delay_logging, int(bool enable));
MOCK_CONST_METHOD0(is_delay_logging_enabled, bool());
MOCK_METHOD2(GetDelayMetrics, int(int* median, int* std));
- MOCK_METHOD3(GetDelayMetrics, int(int* median, int* std,
- float* fraction_poor_delays));
+ MOCK_METHOD3(GetDelayMetrics,
+ int(int* median, int* std, float* fraction_poor_delays));
MOCK_CONST_METHOD0(aec_core, struct AecCore*());
};
@@ -148,18 +148,18 @@
high_pass_filter_(new testing::NiceMock<MockHighPassFilter>()),
level_estimator_(new testing::NiceMock<MockLevelEstimator>()),
noise_suppression_(new testing::NiceMock<MockNoiseSuppression>()),
- voice_detection_(new testing::NiceMock<MockVoiceDetection>()) {
- }
+ voice_detection_(new testing::NiceMock<MockVoiceDetection>()) {}
virtual ~MockAudioProcessing() {}
MOCK_METHOD0(Initialize, int());
- MOCK_METHOD6(Initialize, int(int capture_input_sample_rate_hz,
- int capture_output_sample_rate_hz,
- int render_sample_rate_hz,
- ChannelLayout capture_input_layout,
- ChannelLayout capture_output_layout,
- ChannelLayout render_input_layout));
+ MOCK_METHOD6(Initialize,
+ int(int capture_input_sample_rate_hz,
+ int capture_output_sample_rate_hz,
+ int render_sample_rate_hz,
+ ChannelLayout capture_input_layout,
+ ChannelLayout capture_output_layout,
+ ChannelLayout render_input_layout));
MOCK_METHOD1(Initialize, int(const ProcessingConfig& processing_config));
MOCK_METHOD1(ApplyConfig, void(const Config& config));
MOCK_METHOD1(SetExtraOptions, void(const webrtc::Config& config));
@@ -172,26 +172,30 @@
MOCK_METHOD1(set_output_will_be_muted, void(bool muted));
MOCK_METHOD1(SetRuntimeSetting, void(RuntimeSetting setting));
MOCK_METHOD1(ProcessStream, int(AudioFrame* frame));
- MOCK_METHOD7(ProcessStream, int(const float* const* src,
- size_t samples_per_channel,
- int input_sample_rate_hz,
- ChannelLayout input_layout,
- int output_sample_rate_hz,
- ChannelLayout output_layout,
- float* const* dest));
- MOCK_METHOD4(ProcessStream, int(const float* const* src,
- const StreamConfig& input_config,
- const StreamConfig& output_config,
- float* const* dest));
+ MOCK_METHOD7(ProcessStream,
+ int(const float* const* src,
+ size_t samples_per_channel,
+ int input_sample_rate_hz,
+ ChannelLayout input_layout,
+ int output_sample_rate_hz,
+ ChannelLayout output_layout,
+ float* const* dest));
+ MOCK_METHOD4(ProcessStream,
+ int(const float* const* src,
+ const StreamConfig& input_config,
+ const StreamConfig& output_config,
+ float* const* dest));
MOCK_METHOD1(ProcessReverseStream, int(AudioFrame* frame));
- MOCK_METHOD4(AnalyzeReverseStream, int(const float* const* data,
- size_t samples_per_channel,
- int sample_rate_hz,
- ChannelLayout layout));
- MOCK_METHOD4(ProcessReverseStream, int(const float* const* src,
- const StreamConfig& input_config,
- const StreamConfig& output_config,
- float* const* dest));
+ MOCK_METHOD4(AnalyzeReverseStream,
+ int(const float* const* data,
+ size_t samples_per_channel,
+ int sample_rate_hz,
+ ChannelLayout layout));
+ MOCK_METHOD4(ProcessReverseStream,
+ int(const float* const* src,
+ const StreamConfig& input_config,
+ const StreamConfig& output_config,
+ float* const* dest));
MOCK_METHOD1(set_stream_delay_ms, int(int delay));
MOCK_CONST_METHOD0(stream_delay_ms, int());
MOCK_CONST_METHOD0(was_stream_delay_set, bool());
@@ -215,9 +219,7 @@
virtual MockEchoControlMobile* echo_control_mobile() const {
return echo_control_mobile_.get();
}
- virtual MockGainControl* gain_control() const {
- return gain_control_.get();
- }
+ virtual MockGainControl* gain_control() const { return gain_control_.get(); }
virtual MockHighPassFilter* high_pass_filter() const {
return high_pass_filter_.get();
}
diff --git a/modules/audio_processing/intelligibility/intelligibility_enhancer.cc b/modules/audio_processing/intelligibility/intelligibility_enhancer.cc
index 0e696d9..0f7b118 100644
--- a/modules/audio_processing/intelligibility/intelligibility_enhancer.cc
+++ b/modules/audio_processing/intelligibility/intelligibility_enhancer.cc
@@ -31,16 +31,16 @@
const int kChunkSizeMs = 10; // Size provided by APM.
const float kClipFreqKhz = 0.2f;
const float kKbdAlpha = 1.5f;
-const float kLambdaBot = -1.f; // Extreme values in bisection
-const float kLambdaTop = -1e-5f; // search for lamda.
+const float kLambdaBot = -1.f; // Extreme values in bisection
+const float kLambdaTop = -1e-5f; // search for lamda.
const float kVoiceProbabilityThreshold = 0.5f;
// Number of chunks after voice activity which is still considered speech.
const size_t kSpeechOffsetDelay = 10;
-const float kDecayRate = 0.995f; // Power estimation decay rate.
+const float kDecayRate = 0.995f; // Power estimation decay rate.
const float kMaxRelativeGainChange = 0.005f;
const float kRho = 0.0004f; // Default production and interpretation SNR.
const float kPowerNormalizationFactor = 1.f / (1 << 30);
-const float kMaxActiveSNR = 128.f; // 21dB
+const float kMaxActiveSNR = 128.f; // 21dB
const float kMinInactiveSNR = 32.f; // 15dB
const size_t kGainUpdatePeriod = 10u;
@@ -133,8 +133,8 @@
}
}
-void IntelligibilityEnhancer::SetCaptureNoiseEstimate(
- std::vector<float> noise, float gain) {
+void IntelligibilityEnhancer::SetCaptureNoiseEstimate(std::vector<float> noise,
+ float gain) {
RTC_DCHECK_EQ(noise.size(), num_noise_bins_);
for (auto& bin : noise) {
bin *= gain;
@@ -176,10 +176,9 @@
MapToErbBands(noise_power_estimator_.power().data(), capture_filter_bank_,
filtered_noise_pow_.data());
SolveForGainsGivenLambda(kLambdaTop, start_freq_, gains_eq_.data());
- const float power_target = std::accumulate(
- filtered_clear_pow_.data(),
- filtered_clear_pow_.data() + bank_size_,
- 0.f);
+ const float power_target =
+ std::accumulate(filtered_clear_pow_.data(),
+ filtered_clear_pow_.data() + bank_size_, 0.f);
const float power_top =
DotProduct(gains_eq_.data(), filtered_clear_pow_.data(), bank_size_);
SolveForGainsGivenLambda(kLambdaBot, start_freq_, gains_eq_.data());
@@ -199,12 +198,11 @@
void IntelligibilityEnhancer::SnrBasedEffectActivation() {
const float* clear_psd = clear_power_estimator_.power().data();
const float* noise_psd = noise_power_estimator_.power().data();
- const float clear_power =
- std::accumulate(clear_psd, clear_psd + freqs_, 0.f);
- const float noise_power =
- std::accumulate(noise_psd, noise_psd + freqs_, 0.f);
- snr_ = kDecayRate * snr_ + (1.f - kDecayRate) * clear_power /
- (noise_power + std::numeric_limits<float>::epsilon());
+ const float clear_power = std::accumulate(clear_psd, clear_psd + freqs_, 0.f);
+ const float noise_power = std::accumulate(noise_psd, noise_psd + freqs_, 0.f);
+ snr_ = kDecayRate * snr_ +
+ (1.f - kDecayRate) * clear_power /
+ (noise_power + std::numeric_limits<float>::epsilon());
if (is_active_) {
if (snr_ > kMaxActiveSNR) {
RTC_LOG(LS_INFO) << "Intelligibility Enhancer was deactivated at chunk "
diff --git a/modules/audio_processing/intelligibility/intelligibility_enhancer.h b/modules/audio_processing/intelligibility/intelligibility_enhancer.h
index 3e0e269..3513092 100644
--- a/modules/audio_processing/intelligibility/intelligibility_enhancer.h
+++ b/modules/audio_processing/intelligibility/intelligibility_enhancer.h
@@ -93,7 +93,7 @@
static const size_t kMaxNumNoiseEstimatesToBuffer = 5;
- const size_t freqs_; // Num frequencies in frequency domain.
+ const size_t freqs_; // Num frequencies in frequency domain.
const size_t num_noise_bins_;
const size_t chunk_length_; // Chunk size in samples.
const size_t bank_size_; // Num ERB filters.
diff --git a/modules/audio_processing/intelligibility/intelligibility_utils.cc b/modules/audio_processing/intelligibility/intelligibility_utils.cc
index b6917f4..b606d95 100644
--- a/modules/audio_processing/intelligibility/intelligibility_utils.cc
+++ b/modules/audio_processing/intelligibility/intelligibility_utils.cc
@@ -37,11 +37,11 @@
} // namespace
-template<typename T>
+template <typename T>
PowerEstimator<T>::PowerEstimator(size_t num_freqs, float decay)
: power_(num_freqs, 0.f), decay_(decay) {}
-template<typename T>
+template <typename T>
void PowerEstimator<T>::Step(const T* data) {
for (size_t i = 0; i < power_.size(); ++i) {
power_[i] = decay_ * power_[i] +
diff --git a/modules/audio_processing/low_cut_filter_unittest.cc b/modules/audio_processing/low_cut_filter_unittest.cc
index d98d665..d7b3cb9 100644
--- a/modules/audio_processing/low_cut_filter_unittest.cc
+++ b/modules/audio_processing/low_cut_filter_unittest.cc
@@ -51,12 +51,10 @@
(stream_config.num_frames() * stream_config.num_channels());
for (size_t frame_no = 0; frame_no < num_frames_to_process; ++frame_no) {
std::vector<float> frame_input(
- input.begin() +
- stream_config.num_frames() * stream_config.num_channels() *
- frame_no,
- input.begin() +
- stream_config.num_frames() * stream_config.num_channels() *
- (frame_no + 1));
+ input.begin() + stream_config.num_frames() *
+ stream_config.num_channels() * frame_no,
+ input.begin() + stream_config.num_frames() *
+ stream_config.num_channels() * (frame_no + 1));
output = ProcessOneFrame(frame_input, stream_config, &low_cut_filter);
}
diff --git a/modules/audio_processing/noise_suppression_impl.cc b/modules/audio_processing/noise_suppression_impl.cc
index 8dd713f..15d4043 100644
--- a/modules/audio_processing/noise_suppression_impl.cc
+++ b/modules/audio_processing/noise_suppression_impl.cc
@@ -37,10 +37,9 @@
int error = NS_INIT(state_, sample_rate_hz);
RTC_DCHECK_EQ(0, error);
}
- ~Suppressor() {
- NS_FREE(state_);
- }
+ ~Suppressor() { NS_FREE(state_); }
NsState* state() { return state_; }
+
private:
NsState* state_ = nullptr;
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Suppressor);
@@ -96,15 +95,11 @@
RTC_DCHECK_EQ(suppressors_.size(), audio->num_channels());
for (size_t i = 0; i < suppressors_.size(); i++) {
#if defined(WEBRTC_NS_FLOAT)
- WebRtcNs_Process(suppressors_[i]->state(),
- audio->split_bands_const_f(i),
- audio->num_bands(),
- audio->split_bands_f(i));
+ WebRtcNs_Process(suppressors_[i]->state(), audio->split_bands_const_f(i),
+ audio->num_bands(), audio->split_bands_f(i));
#elif defined(WEBRTC_NS_FIXED)
- WebRtcNsx_Process(suppressors_[i]->state(),
- audio->split_bands_const(i),
- audio->num_bands(),
- audio->split_bands(i));
+ WebRtcNsx_Process(suppressors_[i]->state(), audio->split_bands_const(i),
+ audio->num_bands(), audio->split_bands(i));
#endif
}
}
@@ -190,8 +185,8 @@
noise_estimate.assign(WebRtcNsx_num_freq(), 0.f);
for (auto& suppressor : suppressors_) {
int q_noise;
- const uint32_t* noise = WebRtcNsx_noise_estimate(suppressor->state(),
- &q_noise);
+ const uint32_t* noise =
+ WebRtcNsx_noise_estimate(suppressor->state(), &q_noise);
const float kNormalizationFactor =
1.f / ((1 << q_noise) * suppressors_.size());
for (size_t i = 0; i < noise_estimate.size(); ++i) {
diff --git a/modules/audio_processing/noise_suppression_unittest.cc b/modules/audio_processing/noise_suppression_unittest.cc
index 0b734fd..b207485 100644
--- a/modules/audio_processing/noise_suppression_unittest.cc
+++ b/modules/audio_processing/noise_suppression_unittest.cc
@@ -97,18 +97,18 @@
TEST(NoiseSuppresionBitExactnessTest, Mono8kHzLow) {
#if defined(WEBRTC_ARCH_ARM64)
const float kSpeechProbabilityReference = -4.0f;
- const float kNoiseEstimateReference[] =
- {1432.341431f, 3321.919922f, 7677.521973f};
+ const float kNoiseEstimateReference[] = {1432.341431f, 3321.919922f,
+ 7677.521973f};
const float kOutputReference[] = {0.003510f, 0.004517f, 0.004669f};
#elif defined(WEBRTC_ARCH_ARM)
const float kSpeechProbabilityReference = -4.0f;
- const float kNoiseEstimateReference[] =
- {1432.341431f, 3321.919922f, 7677.521973f};
+ const float kNoiseEstimateReference[] = {1432.341431f, 3321.919922f,
+ 7677.521973f};
const float kOutputReference[] = {0.003510f, 0.004517f, 0.004669f};
#else
const float kSpeechProbabilityReference = 0.73421317f;
- const float kNoiseEstimateReference[] =
- {1175.266113f, 3289.305908f, 7532.991211f};
+ const float kNoiseEstimateReference[] = {1175.266113f, 3289.305908f,
+ 7532.991211f};
const float kOutputReference[] = {0.003263f, 0.004402f, 0.004537f};
#endif
@@ -120,18 +120,18 @@
TEST(NoiseSuppresionBitExactnessTest, Mono16kHzLow) {
#if defined(WEBRTC_ARCH_ARM64)
const float kSpeechProbabilityReference = -4.0f;
- const float kNoiseEstimateReference[] =
- {2534.461914f, 6277.638672f, 14367.499023f};
+ const float kNoiseEstimateReference[] = {2534.461914f, 6277.638672f,
+ 14367.499023f};
const float kOutputReference[] = {0.003449f, 0.004334f, 0.004303f};
#elif defined(WEBRTC_ARCH_ARM)
const float kSpeechProbabilityReference = -4.0f;
- const float kNoiseEstimateReference[] =
- {2534.461914f, 6277.638672f, 14367.499023f};
+ const float kNoiseEstimateReference[] = {2534.461914f, 6277.638672f,
+ 14367.499023f};
const float kOutputReference[] = {0.003449f, 0.004334f, 0.004303f};
#else
const float kSpeechProbabilityReference = 0.71672988f;
- const float kNoiseEstimateReference[] =
- {2151.313965f, 6509.765137f, 15658.848633f};
+ const float kNoiseEstimateReference[] = {2151.313965f, 6509.765137f,
+ 15658.848633f};
const float kOutputReference[] = {0.003574f, 0.004494f, 0.004499f};
#endif
@@ -143,18 +143,18 @@
TEST(NoiseSuppresionBitExactnessTest, Mono32kHzLow) {
#if defined(WEBRTC_ARCH_ARM64)
const float kSpeechProbabilityReference = -4.0f;
- const float kNoiseEstimateReference[] =
- {2540.059082f, 6317.822754f, 14440.845703f};
+ const float kNoiseEstimateReference[] = {2540.059082f, 6317.822754f,
+ 14440.845703f};
const float kOutputReference[] = {0.001679f, 0.002411f, 0.002594f};
#elif defined(WEBRTC_ARCH_ARM)
const float kSpeechProbabilityReference = -4.0f;
- const float kNoiseEstimateReference[] =
- {2540.059082f, 6317.822754f, 14440.845703f};
+ const float kNoiseEstimateReference[] = {2540.059082f, 6317.822754f,
+ 14440.845703f};
const float kOutputReference[] = {0.001679f, 0.002411f, 0.002594f};
#else
const float kSpeechProbabilityReference = 0.67999554f;
- const float kNoiseEstimateReference[] =
- {2149.780518f, 7076.936035f, 14939.945312f};
+ const float kNoiseEstimateReference[] = {2149.780518f, 7076.936035f,
+ 14939.945312f};
const float kOutputReference[] = {0.001221f, 0.001984f, 0.002228f};
#endif
@@ -166,18 +166,18 @@
TEST(NoiseSuppresionBitExactnessTest, Mono48kHzLow) {
#if defined(WEBRTC_ARCH_ARM64)
const float kSpeechProbabilityReference = -4.0f;
- const float kNoiseEstimateReference[] =
- {2564.605713f, 6213.656250f, 13372.284180f};
+ const float kNoiseEstimateReference[] = {2564.605713f, 6213.656250f,
+ 13372.284180f};
const float kOutputReference[] = {-0.013185f, -0.012769f, -0.012023f};
#elif defined(WEBRTC_ARCH_ARM)
const float kSpeechProbabilityReference = -4.0f;
- const float kNoiseEstimateReference[] =
- {2564.605713f, 6213.656250f, 13372.284180f};
+ const float kNoiseEstimateReference[] = {2564.605713f, 6213.656250f,
+ 13372.284180f};
const float kOutputReference[] = {-0.013185f, -0.012769f, -0.012023f};
#else
const float kSpeechProbabilityReference = 0.70645678f;
- const float kNoiseEstimateReference[] =
- {2168.783203f, 6902.895508f, 13190.677734f};
+ const float kNoiseEstimateReference[] = {2168.783203f, 6902.895508f,
+ 13190.677734f};
const float kOutputReference[] = {-0.013062f, -0.012657f, -0.011934f};
#endif
@@ -189,20 +189,20 @@
TEST(NoiseSuppresionBitExactnessTest, Stereo16kHzLow) {
#if defined(WEBRTC_ARCH_ARM64)
const float kSpeechProbabilityReference = -4.0f;
- const float kNoiseEstimateReference[] =
- {9992.127930f, 12689.569336f, 11589.296875f};
+ const float kNoiseEstimateReference[] = {9992.127930f, 12689.569336f,
+ 11589.296875f};
const float kOutputReference[] = {-0.011108f, -0.007904f, -0.012390f,
-0.002441f, 0.000855f, -0.003204f};
#elif defined(WEBRTC_ARCH_ARM)
const float kSpeechProbabilityReference = -4.0f;
- const float kNoiseEstimateReference[] =
- {10321.353516f, 12133.852539f, 10923.060547f};
+ const float kNoiseEstimateReference[] = {10321.353516f, 12133.852539f,
+ 10923.060547f};
const float kOutputReference[] = {-0.011108f, -0.007904f, -0.012390f,
-0.002472f, 0.000916f, -0.003235f};
#else
const float kSpeechProbabilityReference = 0.67230678f;
- const float kNoiseEstimateReference[] =
- {9771.250000f, 11329.377930f, 10503.052734f};
+ const float kNoiseEstimateReference[] = {9771.250000f, 11329.377930f,
+ 10503.052734f};
const float kOutputReference[] = {-0.011459f, -0.008110f, -0.012728f,
-0.002399f, 0.001018f, -0.003189f};
#endif
@@ -215,18 +215,18 @@
TEST(NoiseSuppresionBitExactnessTest, Mono16kHzModerate) {
#if defined(WEBRTC_ARCH_ARM64)
const float kSpeechProbabilityReference = -4.0f;
- const float kNoiseEstimateReference[] =
- {2057.085938f, 7601.055176f, 19666.187500f};
+ const float kNoiseEstimateReference[] = {2057.085938f, 7601.055176f,
+ 19666.187500f};
const float kOutputReference[] = {0.004669f, 0.005524f, 0.005432f};
#elif defined(WEBRTC_ARCH_ARM)
const float kSpeechProbabilityReference = -4.0f;
- const float kNoiseEstimateReference[] =
- {2244.497803f, 6864.164062f, 16726.523438f};
+ const float kNoiseEstimateReference[] = {2244.497803f, 6864.164062f,
+ 16726.523438f};
const float kOutputReference[] = {0.004669f, 0.005615f, 0.005585f};
#else
const float kSpeechProbabilityReference = 0.70897013f;
- const float kNoiseEstimateReference[] =
- {2171.490723f, 6553.567871f, 15626.562500f};
+ const float kNoiseEstimateReference[] = {2171.490723f, 6553.567871f,
+ 15626.562500f};
const float kOutputReference[] = {0.004513f, 0.005590f, 0.005614f};
#endif
@@ -238,18 +238,18 @@
TEST(NoiseSuppresionBitExactnessTest, Mono16kHzHigh) {
#if defined(WEBRTC_ARCH_ARM64)
const float kSpeechProbabilityReference = -4.0f;
- const float kNoiseEstimateReference[] =
- {2095.148193f, 7698.553711f, 19689.533203f};
+ const float kNoiseEstimateReference[] = {2095.148193f, 7698.553711f,
+ 19689.533203f};
const float kOutputReference[] = {0.004639f, 0.005402f, 0.005310f};
#elif defined(WEBRTC_ARCH_ARM)
const float kSpeechProbabilityReference = -4.0f;
- const float kNoiseEstimateReference[] =
- {2282.515625f, 6984.408203f, 16920.960938f};
+ const float kNoiseEstimateReference[] = {2282.515625f, 6984.408203f,
+ 16920.960938f};
const float kOutputReference[] = {0.004547f, 0.005432f, 0.005402f};
#else
const float kSpeechProbabilityReference = 0.70106733f;
- const float kNoiseEstimateReference[] =
- {2224.968506f, 6712.025879f, 15785.087891f};
+ const float kNoiseEstimateReference[] = {2224.968506f, 6712.025879f,
+ 15785.087891f};
const float kOutputReference[] = {0.004394f, 0.005406f, 0.005416f};
#endif
@@ -261,18 +261,18 @@
TEST(NoiseSuppresionBitExactnessTest, Mono16kHzVeryHigh) {
#if defined(WEBRTC_ARCH_ARM64)
const float kSpeechProbabilityReference = -4.0f;
- const float kNoiseEstimateReference[] =
- {2677.733398f, 6186.987305f, 14365.744141f};
+ const float kNoiseEstimateReference[] = {2677.733398f, 6186.987305f,
+ 14365.744141f};
const float kOutputReference[] = {0.004273f, 0.005127f, 0.005188f};
#elif defined(WEBRTC_ARCH_ARM)
const float kSpeechProbabilityReference = -4.0f;
- const float kNoiseEstimateReference[] =
- {2677.733398f, 6186.987305f, 14365.744141f};
+ const float kNoiseEstimateReference[] = {2677.733398f, 6186.987305f,
+ 14365.744141f};
const float kOutputReference[] = {0.004273f, 0.005127f, 0.005188f};
#else
const float kSpeechProbabilityReference = 0.70281971f;
- const float kNoiseEstimateReference[] =
- {2254.347900f, 6723.699707f, 15771.625977f};
+ const float kNoiseEstimateReference[] = {2254.347900f, 6723.699707f,
+ 15771.625977f};
const float kOutputReference[] = {0.004321f, 0.005247f, 0.005263f};
#endif
diff --git a/modules/audio_processing/ns/defines.h b/modules/audio_processing/ns/defines.h
index 66b45a9..d6abfea 100644
--- a/modules/audio_processing/ns/defines.h
+++ b/modules/audio_processing/ns/defines.h
@@ -11,39 +11,45 @@
#ifndef MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_DEFINES_H_
#define MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_DEFINES_H_
-#define BLOCKL_MAX 160 // max processing block length: 160
-#define ANAL_BLOCKL_MAX 256 // max analysis block length: 256
-#define HALF_ANAL_BLOCKL 129 // half max analysis block length + 1
-#define NUM_HIGH_BANDS_MAX 2 // max number of high bands: 2
+#define BLOCKL_MAX 160 // max processing block length: 160
+#define ANAL_BLOCKL_MAX 256 // max analysis block length: 256
+#define HALF_ANAL_BLOCKL 129 // half max analysis block length + 1
+#define NUM_HIGH_BANDS_MAX 2 // max number of high bands: 2
-#define QUANTILE (float)0.25
+#define QUANTILE (float)0.25
-#define SIMULT 3
-#define END_STARTUP_LONG 200
-#define END_STARTUP_SHORT 50
-#define FACTOR (float)40.0
-#define WIDTH (float)0.01
+#define SIMULT 3
+#define END_STARTUP_LONG 200
+#define END_STARTUP_SHORT 50
+#define FACTOR (float)40.0
+#define WIDTH (float)0.01
// Length of fft work arrays.
-#define IP_LENGTH (ANAL_BLOCKL_MAX >> 1) // must be at least ceil(2 + sqrt(ANAL_BLOCKL_MAX/2))
+#define IP_LENGTH \
+ (ANAL_BLOCKL_MAX >> 1) // must be at least ceil(2 + sqrt(ANAL_BLOCKL_MAX/2))
#define W_LENGTH (ANAL_BLOCKL_MAX >> 1)
-//PARAMETERS FOR NEW METHOD
-#define DD_PR_SNR (float)0.98 // DD update of prior SNR
-#define LRT_TAVG (float)0.50 // tavg parameter for LRT (previously 0.90)
-#define SPECT_FL_TAVG (float)0.30 // tavg parameter for spectral flatness measure
-#define SPECT_DIFF_TAVG (float)0.30 // tavg parameter for spectral difference measure
-#define PRIOR_UPDATE (float)0.10 // update parameter of prior model
-#define NOISE_UPDATE (float)0.90 // update parameter for noise
-#define SPEECH_UPDATE (float)0.99 // update parameter when likely speech
-#define WIDTH_PR_MAP (float)4.0 // width parameter in sigmoid map for prior model
-#define LRT_FEATURE_THR (float)0.5 // default threshold for LRT feature
-#define SF_FEATURE_THR (float)0.5 // default threshold for Spectral Flatness feature
-#define SD_FEATURE_THR (float)0.5 // default threshold for Spectral Difference feature
-#define PROB_RANGE (float)0.20 // probability threshold for noise state in
- // speech/noise likelihood
-#define HIST_PAR_EST 1000 // histogram size for estimation of parameters
-#define GAMMA_PAUSE (float)0.05 // update for conservative noise estimate
+// PARAMETERS FOR NEW METHOD
+#define DD_PR_SNR (float)0.98 // DD update of prior SNR
+#define LRT_TAVG (float)0.50 // tavg parameter for LRT (previously 0.90)
+#define SPECT_FL_TAVG \
+ (float)0.30 // tavg parameter for spectral flatness measure
+#define SPECT_DIFF_TAVG \
+ (float)0.30 // tavg parameter for spectral difference measure
+#define PRIOR_UPDATE (float)0.10 // update parameter of prior model
+#define NOISE_UPDATE (float)0.90 // update parameter for noise
+#define SPEECH_UPDATE (float)0.99 // update parameter when likely speech
+#define WIDTH_PR_MAP \
+ (float)4.0 // width parameter in sigmoid map for prior model
+#define LRT_FEATURE_THR (float)0.5 // default threshold for LRT feature
+#define SF_FEATURE_THR \
+ (float)0.5 // default threshold for Spectral Flatness feature
+#define SD_FEATURE_THR \
+ (float)0.5 // default threshold for Spectral Difference feature
+#define PROB_RANGE (float)0.20 // probability threshold for noise state in
+ // speech/noise likelihood
+#define HIST_PAR_EST 1000 // histogram size for estimation of parameters
+#define GAMMA_PAUSE (float)0.05 // update for conservative noise estimate
//
-#define B_LIM (float)0.5 // threshold in final energy gain factor calculation
-#endif // MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_DEFINES_H_
+#define B_LIM (float)0.5 // threshold in final energy gain factor calculation
+#endif // MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_DEFINES_H_
diff --git a/modules/audio_processing/ns/noise_suppression.h b/modules/audio_processing/ns/noise_suppression.h
index fa5da70..fd6aa96 100644
--- a/modules/audio_processing/ns/noise_suppression.h
+++ b/modules/audio_processing/ns/noise_suppression.h
@@ -93,9 +93,9 @@
* - outframe : Pointer to output frame for each band
*/
void WebRtcNs_Process(NsHandle* NS_inst,
- const float* const* spframe,
- size_t num_bands,
- float* const* outframe);
+ const float* const* spframe,
+ size_t num_bands,
+ float* const* outframe);
/* Returns the internally used prior speech probability of the current frame.
* There is a frequency bin based one as well, with which this should not be
diff --git a/modules/audio_processing/ns/ns_core.h b/modules/audio_processing/ns/ns_core.h
index 990d363..e90b8ce 100644
--- a/modules/audio_processing/ns/ns_core.h
+++ b/modules/audio_processing/ns/ns_core.h
@@ -78,26 +78,26 @@
float wfft[W_LENGTH];
// Parameters for new method: some not needed, will reduce/cleanup later.
- int32_t blockInd; // Frame index counter.
+ int32_t blockInd; // Frame index counter.
int modelUpdatePars[4]; // Parameters for updating or estimating.
// Thresholds/weights for prior model.
- float priorModelPars[7]; // Parameters for prior model.
- float noise[HALF_ANAL_BLOCKL]; // Noise spectrum from current frame.
+ float priorModelPars[7]; // Parameters for prior model.
+ float noise[HALF_ANAL_BLOCKL]; // Noise spectrum from current frame.
float noisePrev[HALF_ANAL_BLOCKL]; // Noise spectrum from previous frame.
// Magnitude spectrum of previous analyze frame.
float magnPrevAnalyze[HALF_ANAL_BLOCKL];
// Magnitude spectrum of previous process frame.
float magnPrevProcess[HALF_ANAL_BLOCKL];
float logLrtTimeAvg[HALF_ANAL_BLOCKL]; // Log LRT factor with time-smoothing.
- float priorSpeechProb; // Prior speech/noise probability.
+ float priorSpeechProb; // Prior speech/noise probability.
float featureData[7];
// Conservative noise spectrum estimate.
float magnAvgPause[HALF_ANAL_BLOCKL];
float signalEnergy; // Energy of |magn|.
float sumMagn;
- float whiteNoiseLevel; // Initial noise estimate.
+ float whiteNoiseLevel; // Initial noise estimate.
float initMagnEst[HALF_ANAL_BLOCKL]; // Initial magnitude spectrum estimate.
- float pinkNoiseNumerator; // Pink noise parameter: numerator.
+ float pinkNoiseNumerator; // Pink noise parameter: numerator.
float pinkNoiseExp; // Pink noise parameter: power of frequencies.
float parametricNoise[HALF_ANAL_BLOCKL];
// Parameters for feature extraction.
diff --git a/modules/audio_processing/ns/nsx_core.h b/modules/audio_processing/ns/nsx_core.h
index c8097f7..479e90c 100644
--- a/modules/audio_processing/ns/nsx_core.h
+++ b/modules/audio_processing/ns/nsx_core.h
@@ -20,98 +20,97 @@
#include "typedefs.h" // NOLINT(build/include)
typedef struct NoiseSuppressionFixedC_ {
- uint32_t fs;
+ uint32_t fs;
- const int16_t* window;
- int16_t analysisBuffer[ANAL_BLOCKL_MAX];
- int16_t synthesisBuffer[ANAL_BLOCKL_MAX];
- uint16_t noiseSupFilter[HALF_ANAL_BLOCKL];
- uint16_t overdrive; /* Q8 */
- uint16_t denoiseBound; /* Q14 */
- const int16_t* factor2Table;
- int16_t noiseEstLogQuantile[SIMULT* HALF_ANAL_BLOCKL];
- int16_t noiseEstDensity[SIMULT* HALF_ANAL_BLOCKL];
- int16_t noiseEstCounter[SIMULT];
- int16_t noiseEstQuantile[HALF_ANAL_BLOCKL];
+ const int16_t* window;
+ int16_t analysisBuffer[ANAL_BLOCKL_MAX];
+ int16_t synthesisBuffer[ANAL_BLOCKL_MAX];
+ uint16_t noiseSupFilter[HALF_ANAL_BLOCKL];
+ uint16_t overdrive; /* Q8 */
+ uint16_t denoiseBound; /* Q14 */
+ const int16_t* factor2Table;
+ int16_t noiseEstLogQuantile[SIMULT * HALF_ANAL_BLOCKL];
+ int16_t noiseEstDensity[SIMULT * HALF_ANAL_BLOCKL];
+ int16_t noiseEstCounter[SIMULT];
+ int16_t noiseEstQuantile[HALF_ANAL_BLOCKL];
- size_t anaLen;
- size_t anaLen2;
- size_t magnLen;
- int aggrMode;
- int stages;
- int initFlag;
- int gainMap;
+ size_t anaLen;
+ size_t anaLen2;
+ size_t magnLen;
+ int aggrMode;
+ int stages;
+ int initFlag;
+ int gainMap;
- int32_t maxLrt;
- int32_t minLrt;
+ int32_t maxLrt;
+ int32_t minLrt;
// Log LRT factor with time-smoothing in Q8.
- int32_t logLrtTimeAvgW32[HALF_ANAL_BLOCKL];
- int32_t featureLogLrt;
- int32_t thresholdLogLrt;
- int16_t weightLogLrt;
+ int32_t logLrtTimeAvgW32[HALF_ANAL_BLOCKL];
+ int32_t featureLogLrt;
+ int32_t thresholdLogLrt;
+ int16_t weightLogLrt;
- uint32_t featureSpecDiff;
- uint32_t thresholdSpecDiff;
- int16_t weightSpecDiff;
+ uint32_t featureSpecDiff;
+ uint32_t thresholdSpecDiff;
+ int16_t weightSpecDiff;
- uint32_t featureSpecFlat;
- uint32_t thresholdSpecFlat;
- int16_t weightSpecFlat;
+ uint32_t featureSpecFlat;
+ uint32_t thresholdSpecFlat;
+ int16_t weightSpecFlat;
// Conservative estimate of noise spectrum.
- int32_t avgMagnPause[HALF_ANAL_BLOCKL];
- uint32_t magnEnergy;
- uint32_t sumMagn;
- uint32_t curAvgMagnEnergy;
- uint32_t timeAvgMagnEnergy;
- uint32_t timeAvgMagnEnergyTmp;
+ int32_t avgMagnPause[HALF_ANAL_BLOCKL];
+ uint32_t magnEnergy;
+ uint32_t sumMagn;
+ uint32_t curAvgMagnEnergy;
+ uint32_t timeAvgMagnEnergy;
+ uint32_t timeAvgMagnEnergyTmp;
- uint32_t whiteNoiseLevel; // Initial noise estimate.
+ uint32_t whiteNoiseLevel; // Initial noise estimate.
// Initial magnitude spectrum estimate.
- uint32_t initMagnEst[HALF_ANAL_BLOCKL];
+ uint32_t initMagnEst[HALF_ANAL_BLOCKL];
// Pink noise parameters:
- int32_t pinkNoiseNumerator; // Numerator.
- int32_t pinkNoiseExp; // Power of freq.
- int minNorm; // Smallest normalization factor.
- int zeroInputSignal; // Zero input signal flag.
+ int32_t pinkNoiseNumerator; // Numerator.
+ int32_t pinkNoiseExp; // Power of freq.
+ int minNorm; // Smallest normalization factor.
+ int zeroInputSignal; // Zero input signal flag.
// Noise spectrum from previous frame.
- uint32_t prevNoiseU32[HALF_ANAL_BLOCKL];
+ uint32_t prevNoiseU32[HALF_ANAL_BLOCKL];
// Magnitude spectrum from previous frame.
- uint16_t prevMagnU16[HALF_ANAL_BLOCKL];
+ uint16_t prevMagnU16[HALF_ANAL_BLOCKL];
// Prior speech/noise probability in Q14.
- int16_t priorNonSpeechProb;
+ int16_t priorNonSpeechProb;
- int blockIndex; // Frame index counter.
+ int blockIndex; // Frame index counter.
// Parameter for updating or estimating thresholds/weights for prior model.
- int modelUpdate;
- int cntThresUpdate;
+ int modelUpdate;
+ int cntThresUpdate;
// Histograms for parameter estimation.
- int16_t histLrt[HIST_PAR_EST];
- int16_t histSpecFlat[HIST_PAR_EST];
- int16_t histSpecDiff[HIST_PAR_EST];
+ int16_t histLrt[HIST_PAR_EST];
+ int16_t histSpecFlat[HIST_PAR_EST];
+ int16_t histSpecDiff[HIST_PAR_EST];
// Quantities for high band estimate.
- int16_t dataBufHBFX[NUM_HIGH_BANDS_MAX][ANAL_BLOCKL_MAX];
+ int16_t dataBufHBFX[NUM_HIGH_BANDS_MAX][ANAL_BLOCKL_MAX];
- int qNoise;
- int prevQNoise;
- int prevQMagn;
- size_t blockLen10ms;
+ int qNoise;
+ int prevQNoise;
+ int prevQMagn;
+ size_t blockLen10ms;
- int16_t real[ANAL_BLOCKL_MAX];
- int16_t imag[ANAL_BLOCKL_MAX];
- int32_t energyIn;
- int scaleEnergyIn;
- int normData;
+ int16_t real[ANAL_BLOCKL_MAX];
+ int16_t imag[ANAL_BLOCKL_MAX];
+ int32_t energyIn;
+ int scaleEnergyIn;
+ int normData;
struct RealFFT* real_fft;
} NoiseSuppressionFixedC;
#ifdef __cplusplus
-extern "C"
-{
+extern "C" {
#endif
/****************************************************************************
diff --git a/modules/audio_processing/ns/nsx_defines.h b/modules/audio_processing/ns/nsx_defines.h
index 12869b3..dc14dbc 100644
--- a/modules/audio_processing/ns/nsx_defines.h
+++ b/modules/audio_processing/ns/nsx_defines.h
@@ -11,54 +11,64 @@
#ifndef MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_NSX_DEFINES_H_
#define MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_NSX_DEFINES_H_
-#define ANAL_BLOCKL_MAX 256 /* Max analysis block length */
-#define HALF_ANAL_BLOCKL 129 /* Half max analysis block length + 1 */
-#define NUM_HIGH_BANDS_MAX 2 /* Max number of high bands */
-#define SIMULT 3
-#define END_STARTUP_LONG 200
-#define END_STARTUP_SHORT 50
-#define FACTOR_Q16 2621440 /* 40 in Q16 */
-#define FACTOR_Q7 5120 /* 40 in Q7 */
-#define FACTOR_Q7_STARTUP 1024 /* 8 in Q7 */
-#define WIDTH_Q8 3 /* 0.01 in Q8 (or 25 ) */
+#define ANAL_BLOCKL_MAX 256 /* Max analysis block length */
+#define HALF_ANAL_BLOCKL 129 /* Half max analysis block length + 1 */
+#define NUM_HIGH_BANDS_MAX 2 /* Max number of high bands */
+#define SIMULT 3
+#define END_STARTUP_LONG 200
+#define END_STARTUP_SHORT 50
+#define FACTOR_Q16 2621440 /* 40 in Q16 */
+#define FACTOR_Q7 5120 /* 40 in Q7 */
+#define FACTOR_Q7_STARTUP 1024 /* 8 in Q7 */
+#define WIDTH_Q8 3 /* 0.01 in Q8 (or 25 ) */
/* PARAMETERS FOR NEW METHOD */
-#define DD_PR_SNR_Q11 2007 /* ~= Q11(0.98) DD update of prior SNR */
+#define DD_PR_SNR_Q11 2007 /* ~= Q11(0.98) DD update of prior SNR */
#define ONE_MINUS_DD_PR_SNR_Q11 41 /* DD update of prior SNR */
-#define SPECT_FLAT_TAVG_Q14 4915 /* (0.30) tavg parameter for spectral flatness measure */
-#define SPECT_DIFF_TAVG_Q8 77 /* (0.30) tavg parameter for spectral flatness measure */
-#define PRIOR_UPDATE_Q14 1638 /* Q14(0.1) Update parameter of prior model */
-#define NOISE_UPDATE_Q8 26 /* 26 ~= Q8(0.1) Update parameter for noise */
+#define SPECT_FLAT_TAVG_Q14 \
+ 4915 /* (0.30) tavg parameter for spectral flatness measure */
+#define SPECT_DIFF_TAVG_Q8 \
+ 77 /* (0.30) tavg parameter for spectral flatness measure */
+#define PRIOR_UPDATE_Q14 1638 /* Q14(0.1) Update parameter of prior model */
+#define NOISE_UPDATE_Q8 26 /* 26 ~= Q8(0.1) Update parameter for noise */
/* Probability threshold for noise state in speech/noise likelihood. */
#define ONE_MINUS_PROB_RANGE_Q8 205 /* 205 ~= Q8(0.8) */
-#define HIST_PAR_EST 1000 /* Histogram size for estimation of parameters */
+#define HIST_PAR_EST 1000 /* Histogram size for estimation of parameters */
/* FEATURE EXTRACTION CONFIG */
/* Bin size of histogram */
-#define BIN_SIZE_LRT 10
-/* Scale parameters: multiply dominant peaks of the histograms by scale factor to obtain. */
+#define BIN_SIZE_LRT 10
+/* Scale parameters: multiply dominant peaks of the histograms by scale factor
+ * to obtain. */
/* Thresholds for prior model */
-#define FACTOR_1_LRT_DIFF 6 /* For LRT and spectral difference (5 times bigger) */
-/* For spectral_flatness: used when noise is flatter than speech (10 times bigger). */
-#define FACTOR_2_FLAT_Q10 922
+#define FACTOR_1_LRT_DIFF \
+ 6 /* For LRT and spectral difference (5 times bigger) */
+/* For spectral_flatness: used when noise is flatter than speech (10 times
+ * bigger). */
+#define FACTOR_2_FLAT_Q10 922
/* Peak limit for spectral flatness (varies between 0 and 1) */
-#define THRES_PEAK_FLAT 24 /* * 2 * BIN_SIZE_FLAT_FX */
-/* Limit on spacing of two highest peaks in histogram: spacing determined by bin size. */
-#define LIM_PEAK_SPACE_FLAT_DIFF 4 /* * 2 * BIN_SIZE_DIFF_FX */
+#define THRES_PEAK_FLAT 24 /* * 2 * BIN_SIZE_FLAT_FX */
+/* Limit on spacing of two highest peaks in histogram: spacing determined by bin
+ * size. */
+#define LIM_PEAK_SPACE_FLAT_DIFF 4 /* * 2 * BIN_SIZE_DIFF_FX */
/* Limit on relevance of second peak */
-#define LIM_PEAK_WEIGHT_FLAT_DIFF 2
-#define THRES_FLUCT_LRT 10240 /* = 20 * inst->modelUpdate; fluctuation limit of LRT feat. */
+#define LIM_PEAK_WEIGHT_FLAT_DIFF 2
+#define THRES_FLUCT_LRT \
+ 10240 /* = 20 * inst->modelUpdate; fluctuation limit of LRT feat. */
/* Limit on the max and min values for the feature thresholds */
-#define MAX_FLAT_Q10 38912 /* * 2 * BIN_SIZE_FLAT_FX */
-#define MIN_FLAT_Q10 4096 /* * 2 * BIN_SIZE_FLAT_FX */
-#define MAX_DIFF 100 /* * 2 * BIN_SIZE_DIFF_FX */
-#define MIN_DIFF 16 /* * 2 * BIN_SIZE_DIFF_FX */
+#define MAX_FLAT_Q10 38912 /* * 2 * BIN_SIZE_FLAT_FX */
+#define MIN_FLAT_Q10 4096 /* * 2 * BIN_SIZE_FLAT_FX */
+#define MAX_DIFF 100 /* * 2 * BIN_SIZE_DIFF_FX */
+#define MIN_DIFF 16 /* * 2 * BIN_SIZE_DIFF_FX */
/* Criteria of weight of histogram peak to accept/reject feature */
-#define THRES_WEIGHT_FLAT_DIFF 154 /*(int)(0.3*(inst->modelUpdate)) for flatness and difference */
+#define THRES_WEIGHT_FLAT_DIFF \
+ 154 /*(int)(0.3*(inst->modelUpdate)) for flatness and difference */
-#define STAT_UPDATES 9 /* Update every 512 = 1 << 9 block */
-#define ONE_MINUS_GAMMA_PAUSE_Q8 13 /* ~= Q8(0.05) Update for conservative noise estimate */
-#define GAMMA_NOISE_TRANS_AND_SPEECH_Q8 3 /* ~= Q8(0.01) Update for transition and noise region */
+#define STAT_UPDATES 9 /* Update every 512 = 1 << 9 block */
+#define ONE_MINUS_GAMMA_PAUSE_Q8 \
+ 13 /* ~= Q8(0.05) Update for conservative noise estimate */
+#define GAMMA_NOISE_TRANS_AND_SPEECH_Q8 \
+ 3 /* ~= Q8(0.01) Update for transition and noise region */
#endif /* MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_NSX_DEFINES_H_ */
diff --git a/modules/audio_processing/ns/windows_private.h b/modules/audio_processing/ns/windows_private.h
index 2ffd693..17792ec 100644
--- a/modules/audio_processing/ns/windows_private.h
+++ b/modules/audio_processing/ns/windows_private.h
@@ -13,562 +13,660 @@
// Hanning window for 4ms 16kHz
static const float kHanning64w128[128] = {
- 0.00000000000000f, 0.02454122852291f, 0.04906767432742f,
- 0.07356456359967f, 0.09801714032956f, 0.12241067519922f,
- 0.14673047445536f, 0.17096188876030f, 0.19509032201613f,
- 0.21910124015687f, 0.24298017990326f, 0.26671275747490f,
- 0.29028467725446f, 0.31368174039889f, 0.33688985339222f,
- 0.35989503653499f, 0.38268343236509f, 0.40524131400499f,
- 0.42755509343028f, 0.44961132965461f, 0.47139673682600f,
- 0.49289819222978f, 0.51410274419322f, 0.53499761988710f,
- 0.55557023301960f, 0.57580819141785f, 0.59569930449243f,
- 0.61523159058063f, 0.63439328416365f, 0.65317284295378f,
- 0.67155895484702f, 0.68954054473707f, 0.70710678118655f,
- 0.72424708295147f, 0.74095112535496f, 0.75720884650648f,
- 0.77301045336274f, 0.78834642762661f, 0.80320753148064f,
- 0.81758481315158f, 0.83146961230255f, 0.84485356524971f,
- 0.85772861000027f, 0.87008699110871f, 0.88192126434835f,
- 0.89322430119552f, 0.90398929312344f, 0.91420975570353f,
- 0.92387953251129f, 0.93299279883474f, 0.94154406518302f,
- 0.94952818059304f, 0.95694033573221f, 0.96377606579544f,
- 0.97003125319454f, 0.97570213003853f, 0.98078528040323f,
- 0.98527764238894f, 0.98917650996478f, 0.99247953459871f,
- 0.99518472667220f, 0.99729045667869f, 0.99879545620517f,
- 0.99969881869620f, 1.00000000000000f,
- 0.99969881869620f, 0.99879545620517f, 0.99729045667869f,
- 0.99518472667220f, 0.99247953459871f, 0.98917650996478f,
- 0.98527764238894f, 0.98078528040323f, 0.97570213003853f,
- 0.97003125319454f, 0.96377606579544f, 0.95694033573221f,
- 0.94952818059304f, 0.94154406518302f, 0.93299279883474f,
- 0.92387953251129f, 0.91420975570353f, 0.90398929312344f,
- 0.89322430119552f, 0.88192126434835f, 0.87008699110871f,
- 0.85772861000027f, 0.84485356524971f, 0.83146961230255f,
- 0.81758481315158f, 0.80320753148064f, 0.78834642762661f,
- 0.77301045336274f, 0.75720884650648f, 0.74095112535496f,
- 0.72424708295147f, 0.70710678118655f, 0.68954054473707f,
- 0.67155895484702f, 0.65317284295378f, 0.63439328416365f,
- 0.61523159058063f, 0.59569930449243f, 0.57580819141785f,
- 0.55557023301960f, 0.53499761988710f, 0.51410274419322f,
- 0.49289819222978f, 0.47139673682600f, 0.44961132965461f,
- 0.42755509343028f, 0.40524131400499f, 0.38268343236509f,
- 0.35989503653499f, 0.33688985339222f, 0.31368174039889f,
- 0.29028467725446f, 0.26671275747490f, 0.24298017990326f,
- 0.21910124015687f, 0.19509032201613f, 0.17096188876030f,
- 0.14673047445536f, 0.12241067519922f, 0.09801714032956f,
- 0.07356456359967f, 0.04906767432742f, 0.02454122852291f
-};
-
-
+ 0.00000000000000f, 0.02454122852291f, 0.04906767432742f, 0.07356456359967f,
+ 0.09801714032956f, 0.12241067519922f, 0.14673047445536f, 0.17096188876030f,
+ 0.19509032201613f, 0.21910124015687f, 0.24298017990326f, 0.26671275747490f,
+ 0.29028467725446f, 0.31368174039889f, 0.33688985339222f, 0.35989503653499f,
+ 0.38268343236509f, 0.40524131400499f, 0.42755509343028f, 0.44961132965461f,
+ 0.47139673682600f, 0.49289819222978f, 0.51410274419322f, 0.53499761988710f,
+ 0.55557023301960f, 0.57580819141785f, 0.59569930449243f, 0.61523159058063f,
+ 0.63439328416365f, 0.65317284295378f, 0.67155895484702f, 0.68954054473707f,
+ 0.70710678118655f, 0.72424708295147f, 0.74095112535496f, 0.75720884650648f,
+ 0.77301045336274f, 0.78834642762661f, 0.80320753148064f, 0.81758481315158f,
+ 0.83146961230255f, 0.84485356524971f, 0.85772861000027f, 0.87008699110871f,
+ 0.88192126434835f, 0.89322430119552f, 0.90398929312344f, 0.91420975570353f,
+ 0.92387953251129f, 0.93299279883474f, 0.94154406518302f, 0.94952818059304f,
+ 0.95694033573221f, 0.96377606579544f, 0.97003125319454f, 0.97570213003853f,
+ 0.98078528040323f, 0.98527764238894f, 0.98917650996478f, 0.99247953459871f,
+ 0.99518472667220f, 0.99729045667869f, 0.99879545620517f, 0.99969881869620f,
+ 1.00000000000000f, 0.99969881869620f, 0.99879545620517f, 0.99729045667869f,
+ 0.99518472667220f, 0.99247953459871f, 0.98917650996478f, 0.98527764238894f,
+ 0.98078528040323f, 0.97570213003853f, 0.97003125319454f, 0.96377606579544f,
+ 0.95694033573221f, 0.94952818059304f, 0.94154406518302f, 0.93299279883474f,
+ 0.92387953251129f, 0.91420975570353f, 0.90398929312344f, 0.89322430119552f,
+ 0.88192126434835f, 0.87008699110871f, 0.85772861000027f, 0.84485356524971f,
+ 0.83146961230255f, 0.81758481315158f, 0.80320753148064f, 0.78834642762661f,
+ 0.77301045336274f, 0.75720884650648f, 0.74095112535496f, 0.72424708295147f,
+ 0.70710678118655f, 0.68954054473707f, 0.67155895484702f, 0.65317284295378f,
+ 0.63439328416365f, 0.61523159058063f, 0.59569930449243f, 0.57580819141785f,
+ 0.55557023301960f, 0.53499761988710f, 0.51410274419322f, 0.49289819222978f,
+ 0.47139673682600f, 0.44961132965461f, 0.42755509343028f, 0.40524131400499f,
+ 0.38268343236509f, 0.35989503653499f, 0.33688985339222f, 0.31368174039889f,
+ 0.29028467725446f, 0.26671275747490f, 0.24298017990326f, 0.21910124015687f,
+ 0.19509032201613f, 0.17096188876030f, 0.14673047445536f, 0.12241067519922f,
+ 0.09801714032956f, 0.07356456359967f, 0.04906767432742f, 0.02454122852291f};
// hybrib Hanning & flat window
static const float kBlocks80w128[128] = {
- (float)0.00000000, (float)0.03271908, (float)0.06540313, (float)0.09801714, (float)0.13052619,
- (float)0.16289547, (float)0.19509032, (float)0.22707626, (float)0.25881905, (float)0.29028468,
- (float)0.32143947, (float)0.35225005, (float)0.38268343, (float)0.41270703, (float)0.44228869,
- (float)0.47139674, (float)0.50000000, (float)0.52806785, (float)0.55557023, (float)0.58247770,
- (float)0.60876143, (float)0.63439328, (float)0.65934582, (float)0.68359230, (float)0.70710678,
- (float)0.72986407, (float)0.75183981, (float)0.77301045, (float)0.79335334, (float)0.81284668,
- (float)0.83146961, (float)0.84920218, (float)0.86602540, (float)0.88192126, (float)0.89687274,
- (float)0.91086382, (float)0.92387953, (float)0.93590593, (float)0.94693013, (float)0.95694034,
- (float)0.96592583, (float)0.97387698, (float)0.98078528, (float)0.98664333, (float)0.99144486,
- (float)0.99518473, (float)0.99785892, (float)0.99946459, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)0.99946459, (float)0.99785892, (float)0.99518473, (float)0.99144486,
- (float)0.98664333, (float)0.98078528, (float)0.97387698, (float)0.96592583, (float)0.95694034,
- (float)0.94693013, (float)0.93590593, (float)0.92387953, (float)0.91086382, (float)0.89687274,
- (float)0.88192126, (float)0.86602540, (float)0.84920218, (float)0.83146961, (float)0.81284668,
- (float)0.79335334, (float)0.77301045, (float)0.75183981, (float)0.72986407, (float)0.70710678,
- (float)0.68359230, (float)0.65934582, (float)0.63439328, (float)0.60876143, (float)0.58247770,
- (float)0.55557023, (float)0.52806785, (float)0.50000000, (float)0.47139674, (float)0.44228869,
- (float)0.41270703, (float)0.38268343, (float)0.35225005, (float)0.32143947, (float)0.29028468,
- (float)0.25881905, (float)0.22707626, (float)0.19509032, (float)0.16289547, (float)0.13052619,
- (float)0.09801714, (float)0.06540313, (float)0.03271908
-};
+ (float)0.00000000, (float)0.03271908, (float)0.06540313, (float)0.09801714,
+ (float)0.13052619, (float)0.16289547, (float)0.19509032, (float)0.22707626,
+ (float)0.25881905, (float)0.29028468, (float)0.32143947, (float)0.35225005,
+ (float)0.38268343, (float)0.41270703, (float)0.44228869, (float)0.47139674,
+ (float)0.50000000, (float)0.52806785, (float)0.55557023, (float)0.58247770,
+ (float)0.60876143, (float)0.63439328, (float)0.65934582, (float)0.68359230,
+ (float)0.70710678, (float)0.72986407, (float)0.75183981, (float)0.77301045,
+ (float)0.79335334, (float)0.81284668, (float)0.83146961, (float)0.84920218,
+ (float)0.86602540, (float)0.88192126, (float)0.89687274, (float)0.91086382,
+ (float)0.92387953, (float)0.93590593, (float)0.94693013, (float)0.95694034,
+ (float)0.96592583, (float)0.97387698, (float)0.98078528, (float)0.98664333,
+ (float)0.99144486, (float)0.99518473, (float)0.99785892, (float)0.99946459,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)0.99946459, (float)0.99785892, (float)0.99518473,
+ (float)0.99144486, (float)0.98664333, (float)0.98078528, (float)0.97387698,
+ (float)0.96592583, (float)0.95694034, (float)0.94693013, (float)0.93590593,
+ (float)0.92387953, (float)0.91086382, (float)0.89687274, (float)0.88192126,
+ (float)0.86602540, (float)0.84920218, (float)0.83146961, (float)0.81284668,
+ (float)0.79335334, (float)0.77301045, (float)0.75183981, (float)0.72986407,
+ (float)0.70710678, (float)0.68359230, (float)0.65934582, (float)0.63439328,
+ (float)0.60876143, (float)0.58247770, (float)0.55557023, (float)0.52806785,
+ (float)0.50000000, (float)0.47139674, (float)0.44228869, (float)0.41270703,
+ (float)0.38268343, (float)0.35225005, (float)0.32143947, (float)0.29028468,
+ (float)0.25881905, (float)0.22707626, (float)0.19509032, (float)0.16289547,
+ (float)0.13052619, (float)0.09801714, (float)0.06540313, (float)0.03271908};
// hybrib Hanning & flat window
static const float kBlocks160w256[256] = {
- (float)0.00000000, (float)0.01636173, (float)0.03271908, (float)0.04906767, (float)0.06540313,
- (float)0.08172107, (float)0.09801714, (float)0.11428696, (float)0.13052619, (float)0.14673047,
- (float)0.16289547, (float)0.17901686, (float)0.19509032, (float)0.21111155, (float)0.22707626,
- (float)0.24298018, (float)0.25881905, (float)0.27458862, (float)0.29028468, (float)0.30590302,
- (float)0.32143947, (float)0.33688985, (float)0.35225005, (float)0.36751594, (float)0.38268343,
- (float)0.39774847, (float)0.41270703, (float)0.42755509, (float)0.44228869, (float)0.45690388,
- (float)0.47139674, (float)0.48576339, (float)0.50000000, (float)0.51410274, (float)0.52806785,
- (float)0.54189158, (float)0.55557023, (float)0.56910015, (float)0.58247770, (float)0.59569930,
- (float)0.60876143, (float)0.62166057, (float)0.63439328, (float)0.64695615, (float)0.65934582,
- (float)0.67155895, (float)0.68359230, (float)0.69544264, (float)0.70710678, (float)0.71858162,
- (float)0.72986407, (float)0.74095113, (float)0.75183981, (float)0.76252720, (float)0.77301045,
- (float)0.78328675, (float)0.79335334, (float)0.80320753, (float)0.81284668, (float)0.82226822,
- (float)0.83146961, (float)0.84044840, (float)0.84920218, (float)0.85772861, (float)0.86602540,
- (float)0.87409034, (float)0.88192126, (float)0.88951608, (float)0.89687274, (float)0.90398929,
- (float)0.91086382, (float)0.91749450, (float)0.92387953, (float)0.93001722, (float)0.93590593,
- (float)0.94154407, (float)0.94693013, (float)0.95206268, (float)0.95694034, (float)0.96156180,
- (float)0.96592583, (float)0.97003125, (float)0.97387698, (float)0.97746197, (float)0.98078528,
- (float)0.98384601, (float)0.98664333, (float)0.98917651, (float)0.99144486, (float)0.99344778,
- (float)0.99518473, (float)0.99665524, (float)0.99785892, (float)0.99879546, (float)0.99946459,
- (float)0.99986614, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)0.99986614, (float)0.99946459, (float)0.99879546, (float)0.99785892,
- (float)0.99665524, (float)0.99518473, (float)0.99344778, (float)0.99144486, (float)0.98917651,
- (float)0.98664333, (float)0.98384601, (float)0.98078528, (float)0.97746197, (float)0.97387698,
- (float)0.97003125, (float)0.96592583, (float)0.96156180, (float)0.95694034, (float)0.95206268,
- (float)0.94693013, (float)0.94154407, (float)0.93590593, (float)0.93001722, (float)0.92387953,
- (float)0.91749450, (float)0.91086382, (float)0.90398929, (float)0.89687274, (float)0.88951608,
- (float)0.88192126, (float)0.87409034, (float)0.86602540, (float)0.85772861, (float)0.84920218,
- (float)0.84044840, (float)0.83146961, (float)0.82226822, (float)0.81284668, (float)0.80320753,
- (float)0.79335334, (float)0.78328675, (float)0.77301045, (float)0.76252720, (float)0.75183981,
- (float)0.74095113, (float)0.72986407, (float)0.71858162, (float)0.70710678, (float)0.69544264,
- (float)0.68359230, (float)0.67155895, (float)0.65934582, (float)0.64695615, (float)0.63439328,
- (float)0.62166057, (float)0.60876143, (float)0.59569930, (float)0.58247770, (float)0.56910015,
- (float)0.55557023, (float)0.54189158, (float)0.52806785, (float)0.51410274, (float)0.50000000,
- (float)0.48576339, (float)0.47139674, (float)0.45690388, (float)0.44228869, (float)0.42755509,
- (float)0.41270703, (float)0.39774847, (float)0.38268343, (float)0.36751594, (float)0.35225005,
- (float)0.33688985, (float)0.32143947, (float)0.30590302, (float)0.29028468, (float)0.27458862,
- (float)0.25881905, (float)0.24298018, (float)0.22707626, (float)0.21111155, (float)0.19509032,
- (float)0.17901686, (float)0.16289547, (float)0.14673047, (float)0.13052619, (float)0.11428696,
- (float)0.09801714, (float)0.08172107, (float)0.06540313, (float)0.04906767, (float)0.03271908,
- (float)0.01636173
-};
+ (float)0.00000000, (float)0.01636173, (float)0.03271908, (float)0.04906767,
+ (float)0.06540313, (float)0.08172107, (float)0.09801714, (float)0.11428696,
+ (float)0.13052619, (float)0.14673047, (float)0.16289547, (float)0.17901686,
+ (float)0.19509032, (float)0.21111155, (float)0.22707626, (float)0.24298018,
+ (float)0.25881905, (float)0.27458862, (float)0.29028468, (float)0.30590302,
+ (float)0.32143947, (float)0.33688985, (float)0.35225005, (float)0.36751594,
+ (float)0.38268343, (float)0.39774847, (float)0.41270703, (float)0.42755509,
+ (float)0.44228869, (float)0.45690388, (float)0.47139674, (float)0.48576339,
+ (float)0.50000000, (float)0.51410274, (float)0.52806785, (float)0.54189158,
+ (float)0.55557023, (float)0.56910015, (float)0.58247770, (float)0.59569930,
+ (float)0.60876143, (float)0.62166057, (float)0.63439328, (float)0.64695615,
+ (float)0.65934582, (float)0.67155895, (float)0.68359230, (float)0.69544264,
+ (float)0.70710678, (float)0.71858162, (float)0.72986407, (float)0.74095113,
+ (float)0.75183981, (float)0.76252720, (float)0.77301045, (float)0.78328675,
+ (float)0.79335334, (float)0.80320753, (float)0.81284668, (float)0.82226822,
+ (float)0.83146961, (float)0.84044840, (float)0.84920218, (float)0.85772861,
+ (float)0.86602540, (float)0.87409034, (float)0.88192126, (float)0.88951608,
+ (float)0.89687274, (float)0.90398929, (float)0.91086382, (float)0.91749450,
+ (float)0.92387953, (float)0.93001722, (float)0.93590593, (float)0.94154407,
+ (float)0.94693013, (float)0.95206268, (float)0.95694034, (float)0.96156180,
+ (float)0.96592583, (float)0.97003125, (float)0.97387698, (float)0.97746197,
+ (float)0.98078528, (float)0.98384601, (float)0.98664333, (float)0.98917651,
+ (float)0.99144486, (float)0.99344778, (float)0.99518473, (float)0.99665524,
+ (float)0.99785892, (float)0.99879546, (float)0.99946459, (float)0.99986614,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)0.99986614, (float)0.99946459, (float)0.99879546,
+ (float)0.99785892, (float)0.99665524, (float)0.99518473, (float)0.99344778,
+ (float)0.99144486, (float)0.98917651, (float)0.98664333, (float)0.98384601,
+ (float)0.98078528, (float)0.97746197, (float)0.97387698, (float)0.97003125,
+ (float)0.96592583, (float)0.96156180, (float)0.95694034, (float)0.95206268,
+ (float)0.94693013, (float)0.94154407, (float)0.93590593, (float)0.93001722,
+ (float)0.92387953, (float)0.91749450, (float)0.91086382, (float)0.90398929,
+ (float)0.89687274, (float)0.88951608, (float)0.88192126, (float)0.87409034,
+ (float)0.86602540, (float)0.85772861, (float)0.84920218, (float)0.84044840,
+ (float)0.83146961, (float)0.82226822, (float)0.81284668, (float)0.80320753,
+ (float)0.79335334, (float)0.78328675, (float)0.77301045, (float)0.76252720,
+ (float)0.75183981, (float)0.74095113, (float)0.72986407, (float)0.71858162,
+ (float)0.70710678, (float)0.69544264, (float)0.68359230, (float)0.67155895,
+ (float)0.65934582, (float)0.64695615, (float)0.63439328, (float)0.62166057,
+ (float)0.60876143, (float)0.59569930, (float)0.58247770, (float)0.56910015,
+ (float)0.55557023, (float)0.54189158, (float)0.52806785, (float)0.51410274,
+ (float)0.50000000, (float)0.48576339, (float)0.47139674, (float)0.45690388,
+ (float)0.44228869, (float)0.42755509, (float)0.41270703, (float)0.39774847,
+ (float)0.38268343, (float)0.36751594, (float)0.35225005, (float)0.33688985,
+ (float)0.32143947, (float)0.30590302, (float)0.29028468, (float)0.27458862,
+ (float)0.25881905, (float)0.24298018, (float)0.22707626, (float)0.21111155,
+ (float)0.19509032, (float)0.17901686, (float)0.16289547, (float)0.14673047,
+ (float)0.13052619, (float)0.11428696, (float)0.09801714, (float)0.08172107,
+ (float)0.06540313, (float)0.04906767, (float)0.03271908, (float)0.01636173};
// hybrib Hanning & flat window: for 20ms
static const float kBlocks320w512[512] = {
- (float)0.00000000, (float)0.00818114, (float)0.01636173, (float)0.02454123, (float)0.03271908,
- (float)0.04089475, (float)0.04906767, (float)0.05723732, (float)0.06540313, (float)0.07356456,
- (float)0.08172107, (float)0.08987211, (float)0.09801714, (float)0.10615561, (float)0.11428696,
- (float)0.12241068, (float)0.13052619, (float)0.13863297, (float)0.14673047, (float)0.15481816,
- (float)0.16289547, (float)0.17096189, (float)0.17901686, (float)0.18705985, (float)0.19509032,
- (float)0.20310773, (float)0.21111155, (float)0.21910124, (float)0.22707626, (float)0.23503609,
- (float)0.24298018, (float)0.25090801, (float)0.25881905, (float)0.26671276, (float)0.27458862,
- (float)0.28244610, (float)0.29028468, (float)0.29810383, (float)0.30590302, (float)0.31368174,
- (float)0.32143947, (float)0.32917568, (float)0.33688985, (float)0.34458148, (float)0.35225005,
- (float)0.35989504, (float)0.36751594, (float)0.37511224, (float)0.38268343, (float)0.39022901,
- (float)0.39774847, (float)0.40524131, (float)0.41270703, (float)0.42014512, (float)0.42755509,
- (float)0.43493645, (float)0.44228869, (float)0.44961133, (float)0.45690388, (float)0.46416584,
- (float)0.47139674, (float)0.47859608, (float)0.48576339, (float)0.49289819, (float)0.50000000,
- (float)0.50706834, (float)0.51410274, (float)0.52110274, (float)0.52806785, (float)0.53499762,
- (float)0.54189158, (float)0.54874927, (float)0.55557023, (float)0.56235401, (float)0.56910015,
- (float)0.57580819, (float)0.58247770, (float)0.58910822, (float)0.59569930, (float)0.60225052,
- (float)0.60876143, (float)0.61523159, (float)0.62166057, (float)0.62804795, (float)0.63439328,
- (float)0.64069616, (float)0.64695615, (float)0.65317284, (float)0.65934582, (float)0.66547466,
- (float)0.67155895, (float)0.67759830, (float)0.68359230, (float)0.68954054, (float)0.69544264,
- (float)0.70129818, (float)0.70710678, (float)0.71286806, (float)0.71858162, (float)0.72424708,
- (float)0.72986407, (float)0.73543221, (float)0.74095113, (float)0.74642045, (float)0.75183981,
- (float)0.75720885, (float)0.76252720, (float)0.76779452, (float)0.77301045, (float)0.77817464,
- (float)0.78328675, (float)0.78834643, (float)0.79335334, (float)0.79830715, (float)0.80320753,
- (float)0.80805415, (float)0.81284668, (float)0.81758481, (float)0.82226822, (float)0.82689659,
- (float)0.83146961, (float)0.83598698, (float)0.84044840, (float)0.84485357, (float)0.84920218,
- (float)0.85349396, (float)0.85772861, (float)0.86190585, (float)0.86602540, (float)0.87008699,
- (float)0.87409034, (float)0.87803519, (float)0.88192126, (float)0.88574831, (float)0.88951608,
- (float)0.89322430, (float)0.89687274, (float)0.90046115, (float)0.90398929, (float)0.90745693,
- (float)0.91086382, (float)0.91420976, (float)0.91749450, (float)0.92071783, (float)0.92387953,
- (float)0.92697940, (float)0.93001722, (float)0.93299280, (float)0.93590593, (float)0.93875641,
- (float)0.94154407, (float)0.94426870, (float)0.94693013, (float)0.94952818, (float)0.95206268,
- (float)0.95453345, (float)0.95694034, (float)0.95928317, (float)0.96156180, (float)0.96377607,
- (float)0.96592583, (float)0.96801094, (float)0.97003125, (float)0.97198664, (float)0.97387698,
- (float)0.97570213, (float)0.97746197, (float)0.97915640, (float)0.98078528, (float)0.98234852,
- (float)0.98384601, (float)0.98527764, (float)0.98664333, (float)0.98794298, (float)0.98917651,
- (float)0.99034383, (float)0.99144486, (float)0.99247953, (float)0.99344778, (float)0.99434953,
- (float)0.99518473, (float)0.99595331, (float)0.99665524, (float)0.99729046, (float)0.99785892,
- (float)0.99836060, (float)0.99879546, (float)0.99916346, (float)0.99946459, (float)0.99969882,
- (float)0.99986614, (float)0.99996653, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
- (float)1.00000000, (float)0.99996653, (float)0.99986614, (float)0.99969882, (float)0.99946459,
- (float)0.99916346, (float)0.99879546, (float)0.99836060, (float)0.99785892, (float)0.99729046,
- (float)0.99665524, (float)0.99595331, (float)0.99518473, (float)0.99434953, (float)0.99344778,
- (float)0.99247953, (float)0.99144486, (float)0.99034383, (float)0.98917651, (float)0.98794298,
- (float)0.98664333, (float)0.98527764, (float)0.98384601, (float)0.98234852, (float)0.98078528,
- (float)0.97915640, (float)0.97746197, (float)0.97570213, (float)0.97387698, (float)0.97198664,
- (float)0.97003125, (float)0.96801094, (float)0.96592583, (float)0.96377607, (float)0.96156180,
- (float)0.95928317, (float)0.95694034, (float)0.95453345, (float)0.95206268, (float)0.94952818,
- (float)0.94693013, (float)0.94426870, (float)0.94154407, (float)0.93875641, (float)0.93590593,
- (float)0.93299280, (float)0.93001722, (float)0.92697940, (float)0.92387953, (float)0.92071783,
- (float)0.91749450, (float)0.91420976, (float)0.91086382, (float)0.90745693, (float)0.90398929,
- (float)0.90046115, (float)0.89687274, (float)0.89322430, (float)0.88951608, (float)0.88574831,
- (float)0.88192126, (float)0.87803519, (float)0.87409034, (float)0.87008699, (float)0.86602540,
- (float)0.86190585, (float)0.85772861, (float)0.85349396, (float)0.84920218, (float)0.84485357,
- (float)0.84044840, (float)0.83598698, (float)0.83146961, (float)0.82689659, (float)0.82226822,
- (float)0.81758481, (float)0.81284668, (float)0.80805415, (float)0.80320753, (float)0.79830715,
- (float)0.79335334, (float)0.78834643, (float)0.78328675, (float)0.77817464, (float)0.77301045,
- (float)0.76779452, (float)0.76252720, (float)0.75720885, (float)0.75183981, (float)0.74642045,
- (float)0.74095113, (float)0.73543221, (float)0.72986407, (float)0.72424708, (float)0.71858162,
- (float)0.71286806, (float)0.70710678, (float)0.70129818, (float)0.69544264, (float)0.68954054,
- (float)0.68359230, (float)0.67759830, (float)0.67155895, (float)0.66547466, (float)0.65934582,
- (float)0.65317284, (float)0.64695615, (float)0.64069616, (float)0.63439328, (float)0.62804795,
- (float)0.62166057, (float)0.61523159, (float)0.60876143, (float)0.60225052, (float)0.59569930,
- (float)0.58910822, (float)0.58247770, (float)0.57580819, (float)0.56910015, (float)0.56235401,
- (float)0.55557023, (float)0.54874927, (float)0.54189158, (float)0.53499762, (float)0.52806785,
- (float)0.52110274, (float)0.51410274, (float)0.50706834, (float)0.50000000, (float)0.49289819,
- (float)0.48576339, (float)0.47859608, (float)0.47139674, (float)0.46416584, (float)0.45690388,
- (float)0.44961133, (float)0.44228869, (float)0.43493645, (float)0.42755509, (float)0.42014512,
- (float)0.41270703, (float)0.40524131, (float)0.39774847, (float)0.39022901, (float)0.38268343,
- (float)0.37511224, (float)0.36751594, (float)0.35989504, (float)0.35225005, (float)0.34458148,
- (float)0.33688985, (float)0.32917568, (float)0.32143947, (float)0.31368174, (float)0.30590302,
- (float)0.29810383, (float)0.29028468, (float)0.28244610, (float)0.27458862, (float)0.26671276,
- (float)0.25881905, (float)0.25090801, (float)0.24298018, (float)0.23503609, (float)0.22707626,
- (float)0.21910124, (float)0.21111155, (float)0.20310773, (float)0.19509032, (float)0.18705985,
- (float)0.17901686, (float)0.17096189, (float)0.16289547, (float)0.15481816, (float)0.14673047,
- (float)0.13863297, (float)0.13052619, (float)0.12241068, (float)0.11428696, (float)0.10615561,
- (float)0.09801714, (float)0.08987211, (float)0.08172107, (float)0.07356456, (float)0.06540313,
- (float)0.05723732, (float)0.04906767, (float)0.04089475, (float)0.03271908, (float)0.02454123,
- (float)0.01636173, (float)0.00818114
-};
-
+ (float)0.00000000, (float)0.00818114, (float)0.01636173, (float)0.02454123,
+ (float)0.03271908, (float)0.04089475, (float)0.04906767, (float)0.05723732,
+ (float)0.06540313, (float)0.07356456, (float)0.08172107, (float)0.08987211,
+ (float)0.09801714, (float)0.10615561, (float)0.11428696, (float)0.12241068,
+ (float)0.13052619, (float)0.13863297, (float)0.14673047, (float)0.15481816,
+ (float)0.16289547, (float)0.17096189, (float)0.17901686, (float)0.18705985,
+ (float)0.19509032, (float)0.20310773, (float)0.21111155, (float)0.21910124,
+ (float)0.22707626, (float)0.23503609, (float)0.24298018, (float)0.25090801,
+ (float)0.25881905, (float)0.26671276, (float)0.27458862, (float)0.28244610,
+ (float)0.29028468, (float)0.29810383, (float)0.30590302, (float)0.31368174,
+ (float)0.32143947, (float)0.32917568, (float)0.33688985, (float)0.34458148,
+ (float)0.35225005, (float)0.35989504, (float)0.36751594, (float)0.37511224,
+ (float)0.38268343, (float)0.39022901, (float)0.39774847, (float)0.40524131,
+ (float)0.41270703, (float)0.42014512, (float)0.42755509, (float)0.43493645,
+ (float)0.44228869, (float)0.44961133, (float)0.45690388, (float)0.46416584,
+ (float)0.47139674, (float)0.47859608, (float)0.48576339, (float)0.49289819,
+ (float)0.50000000, (float)0.50706834, (float)0.51410274, (float)0.52110274,
+ (float)0.52806785, (float)0.53499762, (float)0.54189158, (float)0.54874927,
+ (float)0.55557023, (float)0.56235401, (float)0.56910015, (float)0.57580819,
+ (float)0.58247770, (float)0.58910822, (float)0.59569930, (float)0.60225052,
+ (float)0.60876143, (float)0.61523159, (float)0.62166057, (float)0.62804795,
+ (float)0.63439328, (float)0.64069616, (float)0.64695615, (float)0.65317284,
+ (float)0.65934582, (float)0.66547466, (float)0.67155895, (float)0.67759830,
+ (float)0.68359230, (float)0.68954054, (float)0.69544264, (float)0.70129818,
+ (float)0.70710678, (float)0.71286806, (float)0.71858162, (float)0.72424708,
+ (float)0.72986407, (float)0.73543221, (float)0.74095113, (float)0.74642045,
+ (float)0.75183981, (float)0.75720885, (float)0.76252720, (float)0.76779452,
+ (float)0.77301045, (float)0.77817464, (float)0.78328675, (float)0.78834643,
+ (float)0.79335334, (float)0.79830715, (float)0.80320753, (float)0.80805415,
+ (float)0.81284668, (float)0.81758481, (float)0.82226822, (float)0.82689659,
+ (float)0.83146961, (float)0.83598698, (float)0.84044840, (float)0.84485357,
+ (float)0.84920218, (float)0.85349396, (float)0.85772861, (float)0.86190585,
+ (float)0.86602540, (float)0.87008699, (float)0.87409034, (float)0.87803519,
+ (float)0.88192126, (float)0.88574831, (float)0.88951608, (float)0.89322430,
+ (float)0.89687274, (float)0.90046115, (float)0.90398929, (float)0.90745693,
+ (float)0.91086382, (float)0.91420976, (float)0.91749450, (float)0.92071783,
+ (float)0.92387953, (float)0.92697940, (float)0.93001722, (float)0.93299280,
+ (float)0.93590593, (float)0.93875641, (float)0.94154407, (float)0.94426870,
+ (float)0.94693013, (float)0.94952818, (float)0.95206268, (float)0.95453345,
+ (float)0.95694034, (float)0.95928317, (float)0.96156180, (float)0.96377607,
+ (float)0.96592583, (float)0.96801094, (float)0.97003125, (float)0.97198664,
+ (float)0.97387698, (float)0.97570213, (float)0.97746197, (float)0.97915640,
+ (float)0.98078528, (float)0.98234852, (float)0.98384601, (float)0.98527764,
+ (float)0.98664333, (float)0.98794298, (float)0.98917651, (float)0.99034383,
+ (float)0.99144486, (float)0.99247953, (float)0.99344778, (float)0.99434953,
+ (float)0.99518473, (float)0.99595331, (float)0.99665524, (float)0.99729046,
+ (float)0.99785892, (float)0.99836060, (float)0.99879546, (float)0.99916346,
+ (float)0.99946459, (float)0.99969882, (float)0.99986614, (float)0.99996653,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)1.00000000, (float)1.00000000, (float)1.00000000,
+ (float)1.00000000, (float)0.99996653, (float)0.99986614, (float)0.99969882,
+ (float)0.99946459, (float)0.99916346, (float)0.99879546, (float)0.99836060,
+ (float)0.99785892, (float)0.99729046, (float)0.99665524, (float)0.99595331,
+ (float)0.99518473, (float)0.99434953, (float)0.99344778, (float)0.99247953,
+ (float)0.99144486, (float)0.99034383, (float)0.98917651, (float)0.98794298,
+ (float)0.98664333, (float)0.98527764, (float)0.98384601, (float)0.98234852,
+ (float)0.98078528, (float)0.97915640, (float)0.97746197, (float)0.97570213,
+ (float)0.97387698, (float)0.97198664, (float)0.97003125, (float)0.96801094,
+ (float)0.96592583, (float)0.96377607, (float)0.96156180, (float)0.95928317,
+ (float)0.95694034, (float)0.95453345, (float)0.95206268, (float)0.94952818,
+ (float)0.94693013, (float)0.94426870, (float)0.94154407, (float)0.93875641,
+ (float)0.93590593, (float)0.93299280, (float)0.93001722, (float)0.92697940,
+ (float)0.92387953, (float)0.92071783, (float)0.91749450, (float)0.91420976,
+ (float)0.91086382, (float)0.90745693, (float)0.90398929, (float)0.90046115,
+ (float)0.89687274, (float)0.89322430, (float)0.88951608, (float)0.88574831,
+ (float)0.88192126, (float)0.87803519, (float)0.87409034, (float)0.87008699,
+ (float)0.86602540, (float)0.86190585, (float)0.85772861, (float)0.85349396,
+ (float)0.84920218, (float)0.84485357, (float)0.84044840, (float)0.83598698,
+ (float)0.83146961, (float)0.82689659, (float)0.82226822, (float)0.81758481,
+ (float)0.81284668, (float)0.80805415, (float)0.80320753, (float)0.79830715,
+ (float)0.79335334, (float)0.78834643, (float)0.78328675, (float)0.77817464,
+ (float)0.77301045, (float)0.76779452, (float)0.76252720, (float)0.75720885,
+ (float)0.75183981, (float)0.74642045, (float)0.74095113, (float)0.73543221,
+ (float)0.72986407, (float)0.72424708, (float)0.71858162, (float)0.71286806,
+ (float)0.70710678, (float)0.70129818, (float)0.69544264, (float)0.68954054,
+ (float)0.68359230, (float)0.67759830, (float)0.67155895, (float)0.66547466,
+ (float)0.65934582, (float)0.65317284, (float)0.64695615, (float)0.64069616,
+ (float)0.63439328, (float)0.62804795, (float)0.62166057, (float)0.61523159,
+ (float)0.60876143, (float)0.60225052, (float)0.59569930, (float)0.58910822,
+ (float)0.58247770, (float)0.57580819, (float)0.56910015, (float)0.56235401,
+ (float)0.55557023, (float)0.54874927, (float)0.54189158, (float)0.53499762,
+ (float)0.52806785, (float)0.52110274, (float)0.51410274, (float)0.50706834,
+ (float)0.50000000, (float)0.49289819, (float)0.48576339, (float)0.47859608,
+ (float)0.47139674, (float)0.46416584, (float)0.45690388, (float)0.44961133,
+ (float)0.44228869, (float)0.43493645, (float)0.42755509, (float)0.42014512,
+ (float)0.41270703, (float)0.40524131, (float)0.39774847, (float)0.39022901,
+ (float)0.38268343, (float)0.37511224, (float)0.36751594, (float)0.35989504,
+ (float)0.35225005, (float)0.34458148, (float)0.33688985, (float)0.32917568,
+ (float)0.32143947, (float)0.31368174, (float)0.30590302, (float)0.29810383,
+ (float)0.29028468, (float)0.28244610, (float)0.27458862, (float)0.26671276,
+ (float)0.25881905, (float)0.25090801, (float)0.24298018, (float)0.23503609,
+ (float)0.22707626, (float)0.21910124, (float)0.21111155, (float)0.20310773,
+ (float)0.19509032, (float)0.18705985, (float)0.17901686, (float)0.17096189,
+ (float)0.16289547, (float)0.15481816, (float)0.14673047, (float)0.13863297,
+ (float)0.13052619, (float)0.12241068, (float)0.11428696, (float)0.10615561,
+ (float)0.09801714, (float)0.08987211, (float)0.08172107, (float)0.07356456,
+ (float)0.06540313, (float)0.05723732, (float)0.04906767, (float)0.04089475,
+ (float)0.03271908, (float)0.02454123, (float)0.01636173, (float)0.00818114};
// Hanning window: for 15ms at 16kHz with symmetric zeros
static const float kBlocks240w512[512] = {
- (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
- (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
- (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
- (float)0.00000000, (float)0.00000000, (float)0.00654494, (float)0.01308960, (float)0.01963369,
- (float)0.02617695, (float)0.03271908, (float)0.03925982, (float)0.04579887, (float)0.05233596,
- (float)0.05887080, (float)0.06540313, (float)0.07193266, (float)0.07845910, (float)0.08498218,
- (float)0.09150162, (float)0.09801714, (float)0.10452846, (float)0.11103531, (float)0.11753740,
- (float)0.12403446, (float)0.13052620, (float)0.13701233, (float)0.14349262, (float)0.14996676,
- (float)0.15643448, (float)0.16289547, (float)0.16934951, (float)0.17579629, (float)0.18223552,
- (float)0.18866697, (float)0.19509032, (float)0.20150533, (float)0.20791170, (float)0.21430916,
- (float)0.22069745, (float)0.22707628, (float)0.23344538, (float)0.23980446, (float)0.24615330,
- (float)0.25249159, (float)0.25881904, (float)0.26513544, (float)0.27144045, (float)0.27773386,
- (float)0.28401536, (float)0.29028466, (float)0.29654160, (float)0.30278578, (float)0.30901700,
- (float)0.31523499, (float)0.32143945, (float)0.32763019, (float)0.33380687, (float)0.33996925,
- (float)0.34611708, (float)0.35225007, (float)0.35836795, (float)0.36447051, (float)0.37055743,
- (float)0.37662852, (float)0.38268346, (float)0.38872197, (float)0.39474389, (float)0.40074885,
- (float)0.40673664, (float)0.41270703, (float)0.41865975, (float)0.42459452, (float)0.43051112,
- (float)0.43640924, (float)0.44228873, (float)0.44814920, (float)0.45399052, (float)0.45981237,
- (float)0.46561453, (float)0.47139674, (float)0.47715878, (float)0.48290035, (float)0.48862126,
- (float)0.49432120, (float)0.50000000, (float)0.50565743, (float)0.51129311, (float)0.51690692,
- (float)0.52249855, (float)0.52806789, (float)0.53361452, (float)0.53913832, (float)0.54463905,
- (float)0.55011642, (float)0.55557024, (float)0.56100029, (float)0.56640625, (float)0.57178795,
- (float)0.57714522, (float)0.58247769, (float)0.58778524, (float)0.59306765, (float)0.59832460,
- (float)0.60355598, (float)0.60876143, (float)0.61394083, (float)0.61909395, (float)0.62422055,
- (float)0.62932038, (float)0.63439333, (float)0.63943899, (float)0.64445734, (float)0.64944810,
- (float)0.65441096, (float)0.65934587, (float)0.66425246, (float)0.66913062, (float)0.67398012,
- (float)0.67880076, (float)0.68359232, (float)0.68835455, (float)0.69308740, (float)0.69779050,
- (float)0.70246369, (float)0.70710677, (float)0.71171963, (float)0.71630198, (float)0.72085363,
- (float)0.72537440, (float)0.72986406, (float)0.73432255, (float)0.73874950, (float)0.74314487,
- (float)0.74750835, (float)0.75183982, (float)0.75613910, (float)0.76040596, (float)0.76464027,
- (float)0.76884186, (float)0.77301043, (float)0.77714598, (float)0.78124821, (float)0.78531694,
- (float)0.78935206, (float)0.79335338, (float)0.79732066, (float)0.80125386, (float)0.80515265,
- (float)0.80901700, (float)0.81284672, (float)0.81664157, (float)0.82040149, (float)0.82412618,
- (float)0.82781565, (float)0.83146966, (float)0.83508795, (float)0.83867061, (float)0.84221727,
- (float)0.84572780, (float)0.84920216, (float)0.85264021, (float)0.85604161, (float)0.85940641,
- (float)0.86273444, (float)0.86602545, (float)0.86927933, (float)0.87249607, (float)0.87567532,
- (float)0.87881714, (float)0.88192129, (float)0.88498765, (float)0.88801610, (float)0.89100653,
- (float)0.89395881, (float)0.89687276, (float)0.89974827, (float)0.90258533, (float)0.90538365,
- (float)0.90814316, (float)0.91086388, (float)0.91354549, (float)0.91618794, (float)0.91879123,
- (float)0.92135513, (float)0.92387950, (float)0.92636442, (float)0.92880958, (float)0.93121493,
- (float)0.93358046, (float)0.93590593, (float)0.93819135, (float)0.94043654, (float)0.94264150,
- (float)0.94480604, (float)0.94693011, (float)0.94901365, (float)0.95105654, (float)0.95305866,
- (float)0.95501995, (float)0.95694035, (float)0.95881975, (float)0.96065807, (float)0.96245527,
- (float)0.96421117, (float)0.96592581, (float)0.96759909, (float)0.96923089, (float)0.97082120,
- (float)0.97236991, (float)0.97387701, (float)0.97534233, (float)0.97676587, (float)0.97814763,
- (float)0.97948742, (float)0.98078531, (float)0.98204112, (float)0.98325491, (float)0.98442656,
- (float)0.98555607, (float)0.98664331, (float)0.98768836, (float)0.98869103, (float)0.98965138,
- (float)0.99056935, (float)0.99144489, (float)0.99227792, (float)0.99306846, (float)0.99381649,
- (float)0.99452192, (float)0.99518472, (float)0.99580491, (float)0.99638247, (float)0.99691731,
- (float)0.99740952, (float)0.99785894, (float)0.99826562, (float)0.99862951, (float)0.99895066,
- (float)0.99922901, (float)0.99946457, (float)0.99965733, (float)0.99980724, (float)0.99991435,
- (float)0.99997860, (float)1.00000000, (float)0.99997860, (float)0.99991435, (float)0.99980724,
- (float)0.99965733, (float)0.99946457, (float)0.99922901, (float)0.99895066, (float)0.99862951,
- (float)0.99826562, (float)0.99785894, (float)0.99740946, (float)0.99691731, (float)0.99638247,
- (float)0.99580491, (float)0.99518472, (float)0.99452192, (float)0.99381644, (float)0.99306846,
- (float)0.99227792, (float)0.99144489, (float)0.99056935, (float)0.98965138, (float)0.98869103,
- (float)0.98768836, (float)0.98664331, (float)0.98555607, (float)0.98442656, (float)0.98325491,
- (float)0.98204112, (float)0.98078525, (float)0.97948742, (float)0.97814757, (float)0.97676587,
- (float)0.97534227, (float)0.97387695, (float)0.97236991, (float)0.97082120, (float)0.96923089,
- (float)0.96759909, (float)0.96592581, (float)0.96421117, (float)0.96245521, (float)0.96065807,
- (float)0.95881969, (float)0.95694029, (float)0.95501995, (float)0.95305860, (float)0.95105648,
- (float)0.94901365, (float)0.94693011, (float)0.94480604, (float)0.94264150, (float)0.94043654,
- (float)0.93819129, (float)0.93590593, (float)0.93358046, (float)0.93121493, (float)0.92880952,
- (float)0.92636436, (float)0.92387950, (float)0.92135507, (float)0.91879123, (float)0.91618794,
- (float)0.91354543, (float)0.91086382, (float)0.90814310, (float)0.90538365, (float)0.90258527,
- (float)0.89974827, (float)0.89687276, (float)0.89395875, (float)0.89100647, (float)0.88801610,
- (float)0.88498759, (float)0.88192123, (float)0.87881714, (float)0.87567532, (float)0.87249595,
- (float)0.86927933, (float)0.86602539, (float)0.86273432, (float)0.85940641, (float)0.85604161,
- (float)0.85264009, (float)0.84920216, (float)0.84572780, (float)0.84221715, (float)0.83867055,
- (float)0.83508795, (float)0.83146954, (float)0.82781565, (float)0.82412612, (float)0.82040137,
- (float)0.81664157, (float)0.81284660, (float)0.80901700, (float)0.80515265, (float)0.80125374,
- (float)0.79732066, (float)0.79335332, (float)0.78935200, (float)0.78531694, (float)0.78124815,
- (float)0.77714586, (float)0.77301049, (float)0.76884180, (float)0.76464021, (float)0.76040596,
- (float)0.75613904, (float)0.75183970, (float)0.74750835, (float)0.74314481, (float)0.73874938,
- (float)0.73432249, (float)0.72986400, (float)0.72537428, (float)0.72085363, (float)0.71630186,
- (float)0.71171951, (float)0.70710677, (float)0.70246363, (float)0.69779032, (float)0.69308734,
- (float)0.68835449, (float)0.68359220, (float)0.67880070, (float)0.67398006, (float)0.66913044,
- (float)0.66425240, (float)0.65934575, (float)0.65441096, (float)0.64944804, (float)0.64445722,
- (float)0.63943905, (float)0.63439327, (float)0.62932026, (float)0.62422055, (float)0.61909389,
- (float)0.61394072, (float)0.60876143, (float)0.60355592, (float)0.59832448, (float)0.59306765,
- (float)0.58778518, (float)0.58247757, (float)0.57714522, (float)0.57178789, (float)0.56640613,
- (float)0.56100023, (float)0.55557019, (float)0.55011630, (float)0.54463905, (float)0.53913826,
- (float)0.53361434, (float)0.52806783, (float)0.52249849, (float)0.51690674, (float)0.51129305,
- (float)0.50565726, (float)0.50000006, (float)0.49432117, (float)0.48862115, (float)0.48290038,
- (float)0.47715873, (float)0.47139663, (float)0.46561456, (float)0.45981231, (float)0.45399037,
- (float)0.44814920, (float)0.44228864, (float)0.43640912, (float)0.43051112, (float)0.42459446,
- (float)0.41865960, (float)0.41270703, (float)0.40673658, (float)0.40074870, (float)0.39474386,
- (float)0.38872188, (float)0.38268328, (float)0.37662849, (float)0.37055734, (float)0.36447033,
- (float)0.35836792, (float)0.35224995, (float)0.34611690, (float)0.33996922, (float)0.33380675,
- (float)0.32763001, (float)0.32143945, (float)0.31523487, (float)0.30901679, (float)0.30278572,
- (float)0.29654145, (float)0.29028472, (float)0.28401530, (float)0.27773371, (float)0.27144048,
- (float)0.26513538, (float)0.25881892, (float)0.25249159, (float)0.24615324, (float)0.23980433,
- (float)0.23344538, (float)0.22707619, (float)0.22069728, (float)0.21430916, (float)0.20791161,
- (float)0.20150517, (float)0.19509031, (float)0.18866688, (float)0.18223536, (float)0.17579627,
- (float)0.16934940, (float)0.16289529, (float)0.15643445, (float)0.14996666, (float)0.14349243,
- (float)0.13701232, (float)0.13052608, (float)0.12403426, (float)0.11753736, (float)0.11103519,
- (float)0.10452849, (float)0.09801710, (float)0.09150149, (float)0.08498220, (float)0.07845904,
- (float)0.07193252, (float)0.06540315, (float)0.05887074, (float)0.05233581, (float)0.04579888,
- (float)0.03925974, (float)0.03271893, (float)0.02617695, (float)0.01963361, (float)0.01308943,
- (float)0.00654493, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
- (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
- (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
- (float)0.00000000, (float)0.00000000
-};
-
+ (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
+ (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
+ (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
+ (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
+ (float)0.00000000, (float)0.00654494, (float)0.01308960, (float)0.01963369,
+ (float)0.02617695, (float)0.03271908, (float)0.03925982, (float)0.04579887,
+ (float)0.05233596, (float)0.05887080, (float)0.06540313, (float)0.07193266,
+ (float)0.07845910, (float)0.08498218, (float)0.09150162, (float)0.09801714,
+ (float)0.10452846, (float)0.11103531, (float)0.11753740, (float)0.12403446,
+ (float)0.13052620, (float)0.13701233, (float)0.14349262, (float)0.14996676,
+ (float)0.15643448, (float)0.16289547, (float)0.16934951, (float)0.17579629,
+ (float)0.18223552, (float)0.18866697, (float)0.19509032, (float)0.20150533,
+ (float)0.20791170, (float)0.21430916, (float)0.22069745, (float)0.22707628,
+ (float)0.23344538, (float)0.23980446, (float)0.24615330, (float)0.25249159,
+ (float)0.25881904, (float)0.26513544, (float)0.27144045, (float)0.27773386,
+ (float)0.28401536, (float)0.29028466, (float)0.29654160, (float)0.30278578,
+ (float)0.30901700, (float)0.31523499, (float)0.32143945, (float)0.32763019,
+ (float)0.33380687, (float)0.33996925, (float)0.34611708, (float)0.35225007,
+ (float)0.35836795, (float)0.36447051, (float)0.37055743, (float)0.37662852,
+ (float)0.38268346, (float)0.38872197, (float)0.39474389, (float)0.40074885,
+ (float)0.40673664, (float)0.41270703, (float)0.41865975, (float)0.42459452,
+ (float)0.43051112, (float)0.43640924, (float)0.44228873, (float)0.44814920,
+ (float)0.45399052, (float)0.45981237, (float)0.46561453, (float)0.47139674,
+ (float)0.47715878, (float)0.48290035, (float)0.48862126, (float)0.49432120,
+ (float)0.50000000, (float)0.50565743, (float)0.51129311, (float)0.51690692,
+ (float)0.52249855, (float)0.52806789, (float)0.53361452, (float)0.53913832,
+ (float)0.54463905, (float)0.55011642, (float)0.55557024, (float)0.56100029,
+ (float)0.56640625, (float)0.57178795, (float)0.57714522, (float)0.58247769,
+ (float)0.58778524, (float)0.59306765, (float)0.59832460, (float)0.60355598,
+ (float)0.60876143, (float)0.61394083, (float)0.61909395, (float)0.62422055,
+ (float)0.62932038, (float)0.63439333, (float)0.63943899, (float)0.64445734,
+ (float)0.64944810, (float)0.65441096, (float)0.65934587, (float)0.66425246,
+ (float)0.66913062, (float)0.67398012, (float)0.67880076, (float)0.68359232,
+ (float)0.68835455, (float)0.69308740, (float)0.69779050, (float)0.70246369,
+ (float)0.70710677, (float)0.71171963, (float)0.71630198, (float)0.72085363,
+ (float)0.72537440, (float)0.72986406, (float)0.73432255, (float)0.73874950,
+ (float)0.74314487, (float)0.74750835, (float)0.75183982, (float)0.75613910,
+ (float)0.76040596, (float)0.76464027, (float)0.76884186, (float)0.77301043,
+ (float)0.77714598, (float)0.78124821, (float)0.78531694, (float)0.78935206,
+ (float)0.79335338, (float)0.79732066, (float)0.80125386, (float)0.80515265,
+ (float)0.80901700, (float)0.81284672, (float)0.81664157, (float)0.82040149,
+ (float)0.82412618, (float)0.82781565, (float)0.83146966, (float)0.83508795,
+ (float)0.83867061, (float)0.84221727, (float)0.84572780, (float)0.84920216,
+ (float)0.85264021, (float)0.85604161, (float)0.85940641, (float)0.86273444,
+ (float)0.86602545, (float)0.86927933, (float)0.87249607, (float)0.87567532,
+ (float)0.87881714, (float)0.88192129, (float)0.88498765, (float)0.88801610,
+ (float)0.89100653, (float)0.89395881, (float)0.89687276, (float)0.89974827,
+ (float)0.90258533, (float)0.90538365, (float)0.90814316, (float)0.91086388,
+ (float)0.91354549, (float)0.91618794, (float)0.91879123, (float)0.92135513,
+ (float)0.92387950, (float)0.92636442, (float)0.92880958, (float)0.93121493,
+ (float)0.93358046, (float)0.93590593, (float)0.93819135, (float)0.94043654,
+ (float)0.94264150, (float)0.94480604, (float)0.94693011, (float)0.94901365,
+ (float)0.95105654, (float)0.95305866, (float)0.95501995, (float)0.95694035,
+ (float)0.95881975, (float)0.96065807, (float)0.96245527, (float)0.96421117,
+ (float)0.96592581, (float)0.96759909, (float)0.96923089, (float)0.97082120,
+ (float)0.97236991, (float)0.97387701, (float)0.97534233, (float)0.97676587,
+ (float)0.97814763, (float)0.97948742, (float)0.98078531, (float)0.98204112,
+ (float)0.98325491, (float)0.98442656, (float)0.98555607, (float)0.98664331,
+ (float)0.98768836, (float)0.98869103, (float)0.98965138, (float)0.99056935,
+ (float)0.99144489, (float)0.99227792, (float)0.99306846, (float)0.99381649,
+ (float)0.99452192, (float)0.99518472, (float)0.99580491, (float)0.99638247,
+ (float)0.99691731, (float)0.99740952, (float)0.99785894, (float)0.99826562,
+ (float)0.99862951, (float)0.99895066, (float)0.99922901, (float)0.99946457,
+ (float)0.99965733, (float)0.99980724, (float)0.99991435, (float)0.99997860,
+ (float)1.00000000, (float)0.99997860, (float)0.99991435, (float)0.99980724,
+ (float)0.99965733, (float)0.99946457, (float)0.99922901, (float)0.99895066,
+ (float)0.99862951, (float)0.99826562, (float)0.99785894, (float)0.99740946,
+ (float)0.99691731, (float)0.99638247, (float)0.99580491, (float)0.99518472,
+ (float)0.99452192, (float)0.99381644, (float)0.99306846, (float)0.99227792,
+ (float)0.99144489, (float)0.99056935, (float)0.98965138, (float)0.98869103,
+ (float)0.98768836, (float)0.98664331, (float)0.98555607, (float)0.98442656,
+ (float)0.98325491, (float)0.98204112, (float)0.98078525, (float)0.97948742,
+ (float)0.97814757, (float)0.97676587, (float)0.97534227, (float)0.97387695,
+ (float)0.97236991, (float)0.97082120, (float)0.96923089, (float)0.96759909,
+ (float)0.96592581, (float)0.96421117, (float)0.96245521, (float)0.96065807,
+ (float)0.95881969, (float)0.95694029, (float)0.95501995, (float)0.95305860,
+ (float)0.95105648, (float)0.94901365, (float)0.94693011, (float)0.94480604,
+ (float)0.94264150, (float)0.94043654, (float)0.93819129, (float)0.93590593,
+ (float)0.93358046, (float)0.93121493, (float)0.92880952, (float)0.92636436,
+ (float)0.92387950, (float)0.92135507, (float)0.91879123, (float)0.91618794,
+ (float)0.91354543, (float)0.91086382, (float)0.90814310, (float)0.90538365,
+ (float)0.90258527, (float)0.89974827, (float)0.89687276, (float)0.89395875,
+ (float)0.89100647, (float)0.88801610, (float)0.88498759, (float)0.88192123,
+ (float)0.87881714, (float)0.87567532, (float)0.87249595, (float)0.86927933,
+ (float)0.86602539, (float)0.86273432, (float)0.85940641, (float)0.85604161,
+ (float)0.85264009, (float)0.84920216, (float)0.84572780, (float)0.84221715,
+ (float)0.83867055, (float)0.83508795, (float)0.83146954, (float)0.82781565,
+ (float)0.82412612, (float)0.82040137, (float)0.81664157, (float)0.81284660,
+ (float)0.80901700, (float)0.80515265, (float)0.80125374, (float)0.79732066,
+ (float)0.79335332, (float)0.78935200, (float)0.78531694, (float)0.78124815,
+ (float)0.77714586, (float)0.77301049, (float)0.76884180, (float)0.76464021,
+ (float)0.76040596, (float)0.75613904, (float)0.75183970, (float)0.74750835,
+ (float)0.74314481, (float)0.73874938, (float)0.73432249, (float)0.72986400,
+ (float)0.72537428, (float)0.72085363, (float)0.71630186, (float)0.71171951,
+ (float)0.70710677, (float)0.70246363, (float)0.69779032, (float)0.69308734,
+ (float)0.68835449, (float)0.68359220, (float)0.67880070, (float)0.67398006,
+ (float)0.66913044, (float)0.66425240, (float)0.65934575, (float)0.65441096,
+ (float)0.64944804, (float)0.64445722, (float)0.63943905, (float)0.63439327,
+ (float)0.62932026, (float)0.62422055, (float)0.61909389, (float)0.61394072,
+ (float)0.60876143, (float)0.60355592, (float)0.59832448, (float)0.59306765,
+ (float)0.58778518, (float)0.58247757, (float)0.57714522, (float)0.57178789,
+ (float)0.56640613, (float)0.56100023, (float)0.55557019, (float)0.55011630,
+ (float)0.54463905, (float)0.53913826, (float)0.53361434, (float)0.52806783,
+ (float)0.52249849, (float)0.51690674, (float)0.51129305, (float)0.50565726,
+ (float)0.50000006, (float)0.49432117, (float)0.48862115, (float)0.48290038,
+ (float)0.47715873, (float)0.47139663, (float)0.46561456, (float)0.45981231,
+ (float)0.45399037, (float)0.44814920, (float)0.44228864, (float)0.43640912,
+ (float)0.43051112, (float)0.42459446, (float)0.41865960, (float)0.41270703,
+ (float)0.40673658, (float)0.40074870, (float)0.39474386, (float)0.38872188,
+ (float)0.38268328, (float)0.37662849, (float)0.37055734, (float)0.36447033,
+ (float)0.35836792, (float)0.35224995, (float)0.34611690, (float)0.33996922,
+ (float)0.33380675, (float)0.32763001, (float)0.32143945, (float)0.31523487,
+ (float)0.30901679, (float)0.30278572, (float)0.29654145, (float)0.29028472,
+ (float)0.28401530, (float)0.27773371, (float)0.27144048, (float)0.26513538,
+ (float)0.25881892, (float)0.25249159, (float)0.24615324, (float)0.23980433,
+ (float)0.23344538, (float)0.22707619, (float)0.22069728, (float)0.21430916,
+ (float)0.20791161, (float)0.20150517, (float)0.19509031, (float)0.18866688,
+ (float)0.18223536, (float)0.17579627, (float)0.16934940, (float)0.16289529,
+ (float)0.15643445, (float)0.14996666, (float)0.14349243, (float)0.13701232,
+ (float)0.13052608, (float)0.12403426, (float)0.11753736, (float)0.11103519,
+ (float)0.10452849, (float)0.09801710, (float)0.09150149, (float)0.08498220,
+ (float)0.07845904, (float)0.07193252, (float)0.06540315, (float)0.05887074,
+ (float)0.05233581, (float)0.04579888, (float)0.03925974, (float)0.03271893,
+ (float)0.02617695, (float)0.01963361, (float)0.01308943, (float)0.00654493,
+ (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
+ (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
+ (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
+ (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000};
// Hanning window: for 30ms with 1024 fft with symmetric zeros at 16kHz
static const float kBlocks480w1024[1024] = {
- (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
- (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
- (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
- (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
- (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
- (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
- (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00327249, (float)0.00654494,
- (float)0.00981732, (float)0.01308960, (float)0.01636173, (float)0.01963369, (float)0.02290544,
- (float)0.02617695, (float)0.02944817, (float)0.03271908, (float)0.03598964, (float)0.03925982,
- (float)0.04252957, (float)0.04579887, (float)0.04906768, (float)0.05233596, (float)0.05560368,
- (float)0.05887080, (float)0.06213730, (float)0.06540313, (float)0.06866825, (float)0.07193266,
- (float)0.07519628, (float)0.07845910, (float)0.08172107, (float)0.08498218, (float)0.08824237,
- (float)0.09150162, (float)0.09475989, (float)0.09801714, (float)0.10127335, (float)0.10452846,
- (float)0.10778246, (float)0.11103531, (float)0.11428697, (float)0.11753740, (float)0.12078657,
- (float)0.12403446, (float)0.12728101, (float)0.13052620, (float)0.13376999, (float)0.13701233,
- (float)0.14025325, (float)0.14349262, (float)0.14673047, (float)0.14996676, (float)0.15320145,
- (float)0.15643448, (float)0.15966582, (float)0.16289547, (float)0.16612339, (float)0.16934951,
- (float)0.17257382, (float)0.17579629, (float)0.17901687, (float)0.18223552, (float)0.18545224,
- (float)0.18866697, (float)0.19187967, (float)0.19509032, (float)0.19829889, (float)0.20150533,
- (float)0.20470962, (float)0.20791170, (float)0.21111156, (float)0.21430916, (float)0.21750447,
- (float)0.22069745, (float)0.22388805, (float)0.22707628, (float)0.23026206, (float)0.23344538,
- (float)0.23662618, (float)0.23980446, (float)0.24298020, (float)0.24615330, (float)0.24932377,
- (float)0.25249159, (float)0.25565669, (float)0.25881904, (float)0.26197866, (float)0.26513544,
- (float)0.26828939, (float)0.27144045, (float)0.27458861, (float)0.27773386, (float)0.28087610,
- (float)0.28401536, (float)0.28715158, (float)0.29028466, (float)0.29341471, (float)0.29654160,
- (float)0.29966527, (float)0.30278578, (float)0.30590302, (float)0.30901700, (float)0.31212768,
- (float)0.31523499, (float)0.31833893, (float)0.32143945, (float)0.32453656, (float)0.32763019,
- (float)0.33072028, (float)0.33380687, (float)0.33688986, (float)0.33996925, (float)0.34304500,
- (float)0.34611708, (float)0.34918544, (float)0.35225007, (float)0.35531089, (float)0.35836795,
- (float)0.36142117, (float)0.36447051, (float)0.36751595, (float)0.37055743, (float)0.37359497,
- (float)0.37662852, (float)0.37965801, (float)0.38268346, (float)0.38570479, (float)0.38872197,
- (float)0.39173502, (float)0.39474389, (float)0.39774847, (float)0.40074885, (float)0.40374491,
- (float)0.40673664, (float)0.40972406, (float)0.41270703, (float)0.41568562, (float)0.41865975,
- (float)0.42162940, (float)0.42459452, (float)0.42755508, (float)0.43051112, (float)0.43346250,
- (float)0.43640924, (float)0.43935132, (float)0.44228873, (float)0.44522133, (float)0.44814920,
- (float)0.45107228, (float)0.45399052, (float)0.45690390, (float)0.45981237, (float)0.46271592,
- (float)0.46561453, (float)0.46850815, (float)0.47139674, (float)0.47428030, (float)0.47715878,
- (float)0.48003215, (float)0.48290035, (float)0.48576337, (float)0.48862126, (float)0.49147385,
- (float)0.49432120, (float)0.49716330, (float)0.50000000, (float)0.50283140, (float)0.50565743,
- (float)0.50847799, (float)0.51129311, (float)0.51410276, (float)0.51690692, (float)0.51970553,
- (float)0.52249855, (float)0.52528602, (float)0.52806789, (float)0.53084403, (float)0.53361452,
- (float)0.53637928, (float)0.53913832, (float)0.54189163, (float)0.54463905, (float)0.54738063,
- (float)0.55011642, (float)0.55284631, (float)0.55557024, (float)0.55828828, (float)0.56100029,
- (float)0.56370628, (float)0.56640625, (float)0.56910014, (float)0.57178795, (float)0.57446963,
- (float)0.57714522, (float)0.57981455, (float)0.58247769, (float)0.58513463, (float)0.58778524,
- (float)0.59042960, (float)0.59306765, (float)0.59569931, (float)0.59832460, (float)0.60094351,
- (float)0.60355598, (float)0.60616195, (float)0.60876143, (float)0.61135441, (float)0.61394083,
- (float)0.61652070, (float)0.61909395, (float)0.62166059, (float)0.62422055, (float)0.62677383,
- (float)0.62932038, (float)0.63186020, (float)0.63439333, (float)0.63691956, (float)0.63943899,
- (float)0.64195162, (float)0.64445734, (float)0.64695615, (float)0.64944810, (float)0.65193301,
- (float)0.65441096, (float)0.65688187, (float)0.65934587, (float)0.66180271, (float)0.66425246,
- (float)0.66669512, (float)0.66913062, (float)0.67155898, (float)0.67398012, (float)0.67639405,
- (float)0.67880076, (float)0.68120021, (float)0.68359232, (float)0.68597710, (float)0.68835455,
- (float)0.69072467, (float)0.69308740, (float)0.69544262, (float)0.69779050, (float)0.70013082,
- (float)0.70246369, (float)0.70478904, (float)0.70710677, (float)0.70941699, (float)0.71171963,
- (float)0.71401459, (float)0.71630198, (float)0.71858168, (float)0.72085363, (float)0.72311789,
- (float)0.72537440, (float)0.72762316, (float)0.72986406, (float)0.73209721, (float)0.73432255,
- (float)0.73653996, (float)0.73874950, (float)0.74095118, (float)0.74314487, (float)0.74533057,
- (float)0.74750835, (float)0.74967808, (float)0.75183982, (float)0.75399351, (float)0.75613910,
- (float)0.75827658, (float)0.76040596, (float)0.76252723, (float)0.76464027, (float)0.76674515,
- (float)0.76884186, (float)0.77093029, (float)0.77301043, (float)0.77508241, (float)0.77714598,
- (float)0.77920127, (float)0.78124821, (float)0.78328675, (float)0.78531694, (float)0.78733873,
- (float)0.78935206, (float)0.79135692, (float)0.79335338, (float)0.79534125, (float)0.79732066,
- (float)0.79929149, (float)0.80125386, (float)0.80320752, (float)0.80515265, (float)0.80708915,
- (float)0.80901700, (float)0.81093621, (float)0.81284672, (float)0.81474853, (float)0.81664157,
- (float)0.81852591, (float)0.82040149, (float)0.82226825, (float)0.82412618, (float)0.82597536,
- (float)0.82781565, (float)0.82964706, (float)0.83146966, (float)0.83328325, (float)0.83508795,
- (float)0.83688378, (float)0.83867061, (float)0.84044838, (float)0.84221727, (float)0.84397703,
- (float)0.84572780, (float)0.84746957, (float)0.84920216, (float)0.85092574, (float)0.85264021,
- (float)0.85434544, (float)0.85604161, (float)0.85772866, (float)0.85940641, (float)0.86107504,
- (float)0.86273444, (float)0.86438453, (float)0.86602545, (float)0.86765707, (float)0.86927933,
- (float)0.87089235, (float)0.87249607, (float)0.87409031, (float)0.87567532, (float)0.87725097,
- (float)0.87881714, (float)0.88037390, (float)0.88192129, (float)0.88345921, (float)0.88498765,
- (float)0.88650668, (float)0.88801610, (float)0.88951612, (float)0.89100653, (float)0.89248741,
- (float)0.89395881, (float)0.89542055, (float)0.89687276, (float)0.89831537, (float)0.89974827,
- (float)0.90117162, (float)0.90258533, (float)0.90398932, (float)0.90538365, (float)0.90676826,
- (float)0.90814316, (float)0.90950841, (float)0.91086388, (float)0.91220951, (float)0.91354549,
- (float)0.91487163, (float)0.91618794, (float)0.91749454, (float)0.91879123, (float)0.92007810,
- (float)0.92135513, (float)0.92262226, (float)0.92387950, (float)0.92512691, (float)0.92636442,
- (float)0.92759192, (float)0.92880958, (float)0.93001723, (float)0.93121493, (float)0.93240267,
- (float)0.93358046, (float)0.93474817, (float)0.93590593, (float)0.93705362, (float)0.93819135,
- (float)0.93931901, (float)0.94043654, (float)0.94154406, (float)0.94264150, (float)0.94372880,
- (float)0.94480604, (float)0.94587320, (float)0.94693011, (float)0.94797695, (float)0.94901365,
- (float)0.95004016, (float)0.95105654, (float)0.95206273, (float)0.95305866, (float)0.95404440,
- (float)0.95501995, (float)0.95598525, (float)0.95694035, (float)0.95788521, (float)0.95881975,
- (float)0.95974404, (float)0.96065807, (float)0.96156180, (float)0.96245527, (float)0.96333838,
- (float)0.96421117, (float)0.96507370, (float)0.96592581, (float)0.96676767, (float)0.96759909,
- (float)0.96842021, (float)0.96923089, (float)0.97003126, (float)0.97082120, (float)0.97160077,
- (float)0.97236991, (float)0.97312868, (float)0.97387701, (float)0.97461486, (float)0.97534233,
- (float)0.97605932, (float)0.97676587, (float)0.97746199, (float)0.97814763, (float)0.97882277,
- (float)0.97948742, (float)0.98014158, (float)0.98078531, (float)0.98141843, (float)0.98204112,
- (float)0.98265332, (float)0.98325491, (float)0.98384601, (float)0.98442656, (float)0.98499662,
- (float)0.98555607, (float)0.98610497, (float)0.98664331, (float)0.98717111, (float)0.98768836,
- (float)0.98819500, (float)0.98869103, (float)0.98917651, (float)0.98965138, (float)0.99011570,
- (float)0.99056935, (float)0.99101239, (float)0.99144489, (float)0.99186671, (float)0.99227792,
- (float)0.99267852, (float)0.99306846, (float)0.99344778, (float)0.99381649, (float)0.99417448,
- (float)0.99452192, (float)0.99485862, (float)0.99518472, (float)0.99550015, (float)0.99580491,
- (float)0.99609905, (float)0.99638247, (float)0.99665523, (float)0.99691731, (float)0.99716878,
- (float)0.99740952, (float)0.99763954, (float)0.99785894, (float)0.99806762, (float)0.99826562,
- (float)0.99845290, (float)0.99862951, (float)0.99879545, (float)0.99895066, (float)0.99909520,
- (float)0.99922901, (float)0.99935216, (float)0.99946457, (float)0.99956632, (float)0.99965733,
- (float)0.99973762, (float)0.99980724, (float)0.99986613, (float)0.99991435, (float)0.99995178,
- (float)0.99997860, (float)0.99999464, (float)1.00000000, (float)0.99999464, (float)0.99997860,
- (float)0.99995178, (float)0.99991435, (float)0.99986613, (float)0.99980724, (float)0.99973762,
- (float)0.99965733, (float)0.99956632, (float)0.99946457, (float)0.99935216, (float)0.99922901,
- (float)0.99909520, (float)0.99895066, (float)0.99879545, (float)0.99862951, (float)0.99845290,
- (float)0.99826562, (float)0.99806762, (float)0.99785894, (float)0.99763954, (float)0.99740946,
- (float)0.99716872, (float)0.99691731, (float)0.99665523, (float)0.99638247, (float)0.99609905,
- (float)0.99580491, (float)0.99550015, (float)0.99518472, (float)0.99485862, (float)0.99452192,
- (float)0.99417448, (float)0.99381644, (float)0.99344778, (float)0.99306846, (float)0.99267852,
- (float)0.99227792, (float)0.99186671, (float)0.99144489, (float)0.99101239, (float)0.99056935,
- (float)0.99011564, (float)0.98965138, (float)0.98917651, (float)0.98869103, (float)0.98819494,
- (float)0.98768836, (float)0.98717111, (float)0.98664331, (float)0.98610497, (float)0.98555607,
- (float)0.98499656, (float)0.98442656, (float)0.98384601, (float)0.98325491, (float)0.98265326,
- (float)0.98204112, (float)0.98141843, (float)0.98078525, (float)0.98014158, (float)0.97948742,
- (float)0.97882277, (float)0.97814757, (float)0.97746193, (float)0.97676587, (float)0.97605932,
- (float)0.97534227, (float)0.97461486, (float)0.97387695, (float)0.97312862, (float)0.97236991,
- (float)0.97160077, (float)0.97082120, (float)0.97003126, (float)0.96923089, (float)0.96842015,
- (float)0.96759909, (float)0.96676761, (float)0.96592581, (float)0.96507365, (float)0.96421117,
- (float)0.96333838, (float)0.96245521, (float)0.96156180, (float)0.96065807, (float)0.95974404,
- (float)0.95881969, (float)0.95788515, (float)0.95694029, (float)0.95598525, (float)0.95501995,
- (float)0.95404440, (float)0.95305860, (float)0.95206267, (float)0.95105648, (float)0.95004016,
- (float)0.94901365, (float)0.94797695, (float)0.94693011, (float)0.94587314, (float)0.94480604,
- (float)0.94372880, (float)0.94264150, (float)0.94154406, (float)0.94043654, (float)0.93931895,
- (float)0.93819129, (float)0.93705362, (float)0.93590593, (float)0.93474817, (float)0.93358046,
- (float)0.93240267, (float)0.93121493, (float)0.93001723, (float)0.92880952, (float)0.92759192,
- (float)0.92636436, (float)0.92512691, (float)0.92387950, (float)0.92262226, (float)0.92135507,
- (float)0.92007804, (float)0.91879123, (float)0.91749448, (float)0.91618794, (float)0.91487157,
- (float)0.91354543, (float)0.91220951, (float)0.91086382, (float)0.90950835, (float)0.90814310,
- (float)0.90676820, (float)0.90538365, (float)0.90398932, (float)0.90258527, (float)0.90117157,
- (float)0.89974827, (float)0.89831525, (float)0.89687276, (float)0.89542055, (float)0.89395875,
- (float)0.89248741, (float)0.89100647, (float)0.88951600, (float)0.88801610, (float)0.88650662,
- (float)0.88498759, (float)0.88345915, (float)0.88192123, (float)0.88037384, (float)0.87881714,
- (float)0.87725091, (float)0.87567532, (float)0.87409031, (float)0.87249595, (float)0.87089223,
- (float)0.86927933, (float)0.86765701, (float)0.86602539, (float)0.86438447, (float)0.86273432,
- (float)0.86107504, (float)0.85940641, (float)0.85772860, (float)0.85604161, (float)0.85434544,
- (float)0.85264009, (float)0.85092574, (float)0.84920216, (float)0.84746951, (float)0.84572780,
- (float)0.84397697, (float)0.84221715, (float)0.84044844, (float)0.83867055, (float)0.83688372,
- (float)0.83508795, (float)0.83328319, (float)0.83146954, (float)0.82964706, (float)0.82781565,
- (float)0.82597530, (float)0.82412612, (float)0.82226813, (float)0.82040137, (float)0.81852591,
- (float)0.81664157, (float)0.81474847, (float)0.81284660, (float)0.81093609, (float)0.80901700,
- (float)0.80708915, (float)0.80515265, (float)0.80320752, (float)0.80125374, (float)0.79929143,
- (float)0.79732066, (float)0.79534125, (float)0.79335332, (float)0.79135686, (float)0.78935200,
- (float)0.78733861, (float)0.78531694, (float)0.78328675, (float)0.78124815, (float)0.77920121,
- (float)0.77714586, (float)0.77508223, (float)0.77301049, (float)0.77093029, (float)0.76884180,
- (float)0.76674509, (float)0.76464021, (float)0.76252711, (float)0.76040596, (float)0.75827658,
- (float)0.75613904, (float)0.75399339, (float)0.75183970, (float)0.74967796, (float)0.74750835,
- (float)0.74533057, (float)0.74314481, (float)0.74095106, (float)0.73874938, (float)0.73653996,
- (float)0.73432249, (float)0.73209721, (float)0.72986400, (float)0.72762305, (float)0.72537428,
- (float)0.72311789, (float)0.72085363, (float)0.71858162, (float)0.71630186, (float)0.71401453,
- (float)0.71171951, (float)0.70941705, (float)0.70710677, (float)0.70478898, (float)0.70246363,
- (float)0.70013070, (float)0.69779032, (float)0.69544268, (float)0.69308734, (float)0.69072461,
- (float)0.68835449, (float)0.68597704, (float)0.68359220, (float)0.68120021, (float)0.67880070,
- (float)0.67639399, (float)0.67398006, (float)0.67155886, (float)0.66913044, (float)0.66669512,
- (float)0.66425240, (float)0.66180259, (float)0.65934575, (float)0.65688181, (float)0.65441096,
- (float)0.65193301, (float)0.64944804, (float)0.64695609, (float)0.64445722, (float)0.64195150,
- (float)0.63943905, (float)0.63691956, (float)0.63439327, (float)0.63186014, (float)0.62932026,
- (float)0.62677372, (float)0.62422055, (float)0.62166059, (float)0.61909389, (float)0.61652064,
- (float)0.61394072, (float)0.61135429, (float)0.60876143, (float)0.60616189, (float)0.60355592,
- (float)0.60094339, (float)0.59832448, (float)0.59569913, (float)0.59306765, (float)0.59042960,
- (float)0.58778518, (float)0.58513451, (float)0.58247757, (float)0.57981461, (float)0.57714522,
- (float)0.57446963, (float)0.57178789, (float)0.56910002, (float)0.56640613, (float)0.56370628,
- (float)0.56100023, (float)0.55828822, (float)0.55557019, (float)0.55284619, (float)0.55011630,
- (float)0.54738069, (float)0.54463905, (float)0.54189152, (float)0.53913826, (float)0.53637916,
- (float)0.53361434, (float)0.53084403, (float)0.52806783, (float)0.52528596, (float)0.52249849,
- (float)0.51970541, (float)0.51690674, (float)0.51410276, (float)0.51129305, (float)0.50847787,
- (float)0.50565726, (float)0.50283122, (float)0.50000006, (float)0.49716327, (float)0.49432117,
- (float)0.49147379, (float)0.48862115, (float)0.48576325, (float)0.48290038, (float)0.48003212,
- (float)0.47715873, (float)0.47428021, (float)0.47139663, (float)0.46850798, (float)0.46561456,
- (float)0.46271589, (float)0.45981231, (float)0.45690379, (float)0.45399037, (float)0.45107210,
- (float)0.44814920, (float)0.44522130, (float)0.44228864, (float)0.43935123, (float)0.43640912,
- (float)0.43346232, (float)0.43051112, (float)0.42755505, (float)0.42459446, (float)0.42162928,
- (float)0.41865960, (float)0.41568545, (float)0.41270703, (float)0.40972400, (float)0.40673658,
- (float)0.40374479, (float)0.40074870, (float)0.39774850, (float)0.39474386, (float)0.39173496,
- (float)0.38872188, (float)0.38570464, (float)0.38268328, (float)0.37965804, (float)0.37662849,
- (float)0.37359491, (float)0.37055734, (float)0.36751580, (float)0.36447033, (float)0.36142117,
- (float)0.35836792, (float)0.35531086, (float)0.35224995, (float)0.34918529, (float)0.34611690,
- (float)0.34304500, (float)0.33996922, (float)0.33688980, (float)0.33380675, (float)0.33072016,
- (float)0.32763001, (float)0.32453656, (float)0.32143945, (float)0.31833887, (float)0.31523487,
- (float)0.31212750, (float)0.30901679, (float)0.30590302, (float)0.30278572, (float)0.29966521,
- (float)0.29654145, (float)0.29341453, (float)0.29028472, (float)0.28715155, (float)0.28401530,
- (float)0.28087601, (float)0.27773371, (float)0.27458847, (float)0.27144048, (float)0.26828936,
- (float)0.26513538, (float)0.26197854, (float)0.25881892, (float)0.25565651, (float)0.25249159,
- (float)0.24932374, (float)0.24615324, (float)0.24298008, (float)0.23980433, (float)0.23662600,
- (float)0.23344538, (float)0.23026201, (float)0.22707619, (float)0.22388794, (float)0.22069728,
- (float)0.21750426, (float)0.21430916, (float)0.21111152, (float)0.20791161, (float)0.20470949,
- (float)0.20150517, (float)0.19829892, (float)0.19509031, (float)0.19187963, (float)0.18866688,
- (float)0.18545210, (float)0.18223536, (float)0.17901689, (float)0.17579627, (float)0.17257376,
- (float)0.16934940, (float)0.16612324, (float)0.16289529, (float)0.15966584, (float)0.15643445,
- (float)0.15320137, (float)0.14996666, (float)0.14673033, (float)0.14349243, (float)0.14025325,
- (float)0.13701232, (float)0.13376991, (float)0.13052608, (float)0.12728085, (float)0.12403426,
- (float)0.12078657, (float)0.11753736, (float)0.11428688, (float)0.11103519, (float)0.10778230,
- (float)0.10452849, (float)0.10127334, (float)0.09801710, (float)0.09475980, (float)0.09150149,
- (float)0.08824220, (float)0.08498220, (float)0.08172106, (float)0.07845904, (float)0.07519618,
- (float)0.07193252, (float)0.06866808, (float)0.06540315, (float)0.06213728, (float)0.05887074,
- (float)0.05560357, (float)0.05233581, (float)0.04906749, (float)0.04579888, (float)0.04252954,
- (float)0.03925974, (float)0.03598953, (float)0.03271893, (float)0.02944798, (float)0.02617695,
- (float)0.02290541, (float)0.01963361, (float)0.01636161, (float)0.01308943, (float)0.00981712,
- (float)0.00654493, (float)0.00327244, (float)0.00000000, (float)0.00000000, (float)0.00000000,
- (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
- (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
- (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
- (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
- (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
- (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000
-};
+ (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
+ (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
+ (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
+ (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
+ (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
+ (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
+ (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
+ (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
+ (float)0.00000000, (float)0.00327249, (float)0.00654494, (float)0.00981732,
+ (float)0.01308960, (float)0.01636173, (float)0.01963369, (float)0.02290544,
+ (float)0.02617695, (float)0.02944817, (float)0.03271908, (float)0.03598964,
+ (float)0.03925982, (float)0.04252957, (float)0.04579887, (float)0.04906768,
+ (float)0.05233596, (float)0.05560368, (float)0.05887080, (float)0.06213730,
+ (float)0.06540313, (float)0.06866825, (float)0.07193266, (float)0.07519628,
+ (float)0.07845910, (float)0.08172107, (float)0.08498218, (float)0.08824237,
+ (float)0.09150162, (float)0.09475989, (float)0.09801714, (float)0.10127335,
+ (float)0.10452846, (float)0.10778246, (float)0.11103531, (float)0.11428697,
+ (float)0.11753740, (float)0.12078657, (float)0.12403446, (float)0.12728101,
+ (float)0.13052620, (float)0.13376999, (float)0.13701233, (float)0.14025325,
+ (float)0.14349262, (float)0.14673047, (float)0.14996676, (float)0.15320145,
+ (float)0.15643448, (float)0.15966582, (float)0.16289547, (float)0.16612339,
+ (float)0.16934951, (float)0.17257382, (float)0.17579629, (float)0.17901687,
+ (float)0.18223552, (float)0.18545224, (float)0.18866697, (float)0.19187967,
+ (float)0.19509032, (float)0.19829889, (float)0.20150533, (float)0.20470962,
+ (float)0.20791170, (float)0.21111156, (float)0.21430916, (float)0.21750447,
+ (float)0.22069745, (float)0.22388805, (float)0.22707628, (float)0.23026206,
+ (float)0.23344538, (float)0.23662618, (float)0.23980446, (float)0.24298020,
+ (float)0.24615330, (float)0.24932377, (float)0.25249159, (float)0.25565669,
+ (float)0.25881904, (float)0.26197866, (float)0.26513544, (float)0.26828939,
+ (float)0.27144045, (float)0.27458861, (float)0.27773386, (float)0.28087610,
+ (float)0.28401536, (float)0.28715158, (float)0.29028466, (float)0.29341471,
+ (float)0.29654160, (float)0.29966527, (float)0.30278578, (float)0.30590302,
+ (float)0.30901700, (float)0.31212768, (float)0.31523499, (float)0.31833893,
+ (float)0.32143945, (float)0.32453656, (float)0.32763019, (float)0.33072028,
+ (float)0.33380687, (float)0.33688986, (float)0.33996925, (float)0.34304500,
+ (float)0.34611708, (float)0.34918544, (float)0.35225007, (float)0.35531089,
+ (float)0.35836795, (float)0.36142117, (float)0.36447051, (float)0.36751595,
+ (float)0.37055743, (float)0.37359497, (float)0.37662852, (float)0.37965801,
+ (float)0.38268346, (float)0.38570479, (float)0.38872197, (float)0.39173502,
+ (float)0.39474389, (float)0.39774847, (float)0.40074885, (float)0.40374491,
+ (float)0.40673664, (float)0.40972406, (float)0.41270703, (float)0.41568562,
+ (float)0.41865975, (float)0.42162940, (float)0.42459452, (float)0.42755508,
+ (float)0.43051112, (float)0.43346250, (float)0.43640924, (float)0.43935132,
+ (float)0.44228873, (float)0.44522133, (float)0.44814920, (float)0.45107228,
+ (float)0.45399052, (float)0.45690390, (float)0.45981237, (float)0.46271592,
+ (float)0.46561453, (float)0.46850815, (float)0.47139674, (float)0.47428030,
+ (float)0.47715878, (float)0.48003215, (float)0.48290035, (float)0.48576337,
+ (float)0.48862126, (float)0.49147385, (float)0.49432120, (float)0.49716330,
+ (float)0.50000000, (float)0.50283140, (float)0.50565743, (float)0.50847799,
+ (float)0.51129311, (float)0.51410276, (float)0.51690692, (float)0.51970553,
+ (float)0.52249855, (float)0.52528602, (float)0.52806789, (float)0.53084403,
+ (float)0.53361452, (float)0.53637928, (float)0.53913832, (float)0.54189163,
+ (float)0.54463905, (float)0.54738063, (float)0.55011642, (float)0.55284631,
+ (float)0.55557024, (float)0.55828828, (float)0.56100029, (float)0.56370628,
+ (float)0.56640625, (float)0.56910014, (float)0.57178795, (float)0.57446963,
+ (float)0.57714522, (float)0.57981455, (float)0.58247769, (float)0.58513463,
+ (float)0.58778524, (float)0.59042960, (float)0.59306765, (float)0.59569931,
+ (float)0.59832460, (float)0.60094351, (float)0.60355598, (float)0.60616195,
+ (float)0.60876143, (float)0.61135441, (float)0.61394083, (float)0.61652070,
+ (float)0.61909395, (float)0.62166059, (float)0.62422055, (float)0.62677383,
+ (float)0.62932038, (float)0.63186020, (float)0.63439333, (float)0.63691956,
+ (float)0.63943899, (float)0.64195162, (float)0.64445734, (float)0.64695615,
+ (float)0.64944810, (float)0.65193301, (float)0.65441096, (float)0.65688187,
+ (float)0.65934587, (float)0.66180271, (float)0.66425246, (float)0.66669512,
+ (float)0.66913062, (float)0.67155898, (float)0.67398012, (float)0.67639405,
+ (float)0.67880076, (float)0.68120021, (float)0.68359232, (float)0.68597710,
+ (float)0.68835455, (float)0.69072467, (float)0.69308740, (float)0.69544262,
+ (float)0.69779050, (float)0.70013082, (float)0.70246369, (float)0.70478904,
+ (float)0.70710677, (float)0.70941699, (float)0.71171963, (float)0.71401459,
+ (float)0.71630198, (float)0.71858168, (float)0.72085363, (float)0.72311789,
+ (float)0.72537440, (float)0.72762316, (float)0.72986406, (float)0.73209721,
+ (float)0.73432255, (float)0.73653996, (float)0.73874950, (float)0.74095118,
+ (float)0.74314487, (float)0.74533057, (float)0.74750835, (float)0.74967808,
+ (float)0.75183982, (float)0.75399351, (float)0.75613910, (float)0.75827658,
+ (float)0.76040596, (float)0.76252723, (float)0.76464027, (float)0.76674515,
+ (float)0.76884186, (float)0.77093029, (float)0.77301043, (float)0.77508241,
+ (float)0.77714598, (float)0.77920127, (float)0.78124821, (float)0.78328675,
+ (float)0.78531694, (float)0.78733873, (float)0.78935206, (float)0.79135692,
+ (float)0.79335338, (float)0.79534125, (float)0.79732066, (float)0.79929149,
+ (float)0.80125386, (float)0.80320752, (float)0.80515265, (float)0.80708915,
+ (float)0.80901700, (float)0.81093621, (float)0.81284672, (float)0.81474853,
+ (float)0.81664157, (float)0.81852591, (float)0.82040149, (float)0.82226825,
+ (float)0.82412618, (float)0.82597536, (float)0.82781565, (float)0.82964706,
+ (float)0.83146966, (float)0.83328325, (float)0.83508795, (float)0.83688378,
+ (float)0.83867061, (float)0.84044838, (float)0.84221727, (float)0.84397703,
+ (float)0.84572780, (float)0.84746957, (float)0.84920216, (float)0.85092574,
+ (float)0.85264021, (float)0.85434544, (float)0.85604161, (float)0.85772866,
+ (float)0.85940641, (float)0.86107504, (float)0.86273444, (float)0.86438453,
+ (float)0.86602545, (float)0.86765707, (float)0.86927933, (float)0.87089235,
+ (float)0.87249607, (float)0.87409031, (float)0.87567532, (float)0.87725097,
+ (float)0.87881714, (float)0.88037390, (float)0.88192129, (float)0.88345921,
+ (float)0.88498765, (float)0.88650668, (float)0.88801610, (float)0.88951612,
+ (float)0.89100653, (float)0.89248741, (float)0.89395881, (float)0.89542055,
+ (float)0.89687276, (float)0.89831537, (float)0.89974827, (float)0.90117162,
+ (float)0.90258533, (float)0.90398932, (float)0.90538365, (float)0.90676826,
+ (float)0.90814316, (float)0.90950841, (float)0.91086388, (float)0.91220951,
+ (float)0.91354549, (float)0.91487163, (float)0.91618794, (float)0.91749454,
+ (float)0.91879123, (float)0.92007810, (float)0.92135513, (float)0.92262226,
+ (float)0.92387950, (float)0.92512691, (float)0.92636442, (float)0.92759192,
+ (float)0.92880958, (float)0.93001723, (float)0.93121493, (float)0.93240267,
+ (float)0.93358046, (float)0.93474817, (float)0.93590593, (float)0.93705362,
+ (float)0.93819135, (float)0.93931901, (float)0.94043654, (float)0.94154406,
+ (float)0.94264150, (float)0.94372880, (float)0.94480604, (float)0.94587320,
+ (float)0.94693011, (float)0.94797695, (float)0.94901365, (float)0.95004016,
+ (float)0.95105654, (float)0.95206273, (float)0.95305866, (float)0.95404440,
+ (float)0.95501995, (float)0.95598525, (float)0.95694035, (float)0.95788521,
+ (float)0.95881975, (float)0.95974404, (float)0.96065807, (float)0.96156180,
+ (float)0.96245527, (float)0.96333838, (float)0.96421117, (float)0.96507370,
+ (float)0.96592581, (float)0.96676767, (float)0.96759909, (float)0.96842021,
+ (float)0.96923089, (float)0.97003126, (float)0.97082120, (float)0.97160077,
+ (float)0.97236991, (float)0.97312868, (float)0.97387701, (float)0.97461486,
+ (float)0.97534233, (float)0.97605932, (float)0.97676587, (float)0.97746199,
+ (float)0.97814763, (float)0.97882277, (float)0.97948742, (float)0.98014158,
+ (float)0.98078531, (float)0.98141843, (float)0.98204112, (float)0.98265332,
+ (float)0.98325491, (float)0.98384601, (float)0.98442656, (float)0.98499662,
+ (float)0.98555607, (float)0.98610497, (float)0.98664331, (float)0.98717111,
+ (float)0.98768836, (float)0.98819500, (float)0.98869103, (float)0.98917651,
+ (float)0.98965138, (float)0.99011570, (float)0.99056935, (float)0.99101239,
+ (float)0.99144489, (float)0.99186671, (float)0.99227792, (float)0.99267852,
+ (float)0.99306846, (float)0.99344778, (float)0.99381649, (float)0.99417448,
+ (float)0.99452192, (float)0.99485862, (float)0.99518472, (float)0.99550015,
+ (float)0.99580491, (float)0.99609905, (float)0.99638247, (float)0.99665523,
+ (float)0.99691731, (float)0.99716878, (float)0.99740952, (float)0.99763954,
+ (float)0.99785894, (float)0.99806762, (float)0.99826562, (float)0.99845290,
+ (float)0.99862951, (float)0.99879545, (float)0.99895066, (float)0.99909520,
+ (float)0.99922901, (float)0.99935216, (float)0.99946457, (float)0.99956632,
+ (float)0.99965733, (float)0.99973762, (float)0.99980724, (float)0.99986613,
+ (float)0.99991435, (float)0.99995178, (float)0.99997860, (float)0.99999464,
+ (float)1.00000000, (float)0.99999464, (float)0.99997860, (float)0.99995178,
+ (float)0.99991435, (float)0.99986613, (float)0.99980724, (float)0.99973762,
+ (float)0.99965733, (float)0.99956632, (float)0.99946457, (float)0.99935216,
+ (float)0.99922901, (float)0.99909520, (float)0.99895066, (float)0.99879545,
+ (float)0.99862951, (float)0.99845290, (float)0.99826562, (float)0.99806762,
+ (float)0.99785894, (float)0.99763954, (float)0.99740946, (float)0.99716872,
+ (float)0.99691731, (float)0.99665523, (float)0.99638247, (float)0.99609905,
+ (float)0.99580491, (float)0.99550015, (float)0.99518472, (float)0.99485862,
+ (float)0.99452192, (float)0.99417448, (float)0.99381644, (float)0.99344778,
+ (float)0.99306846, (float)0.99267852, (float)0.99227792, (float)0.99186671,
+ (float)0.99144489, (float)0.99101239, (float)0.99056935, (float)0.99011564,
+ (float)0.98965138, (float)0.98917651, (float)0.98869103, (float)0.98819494,
+ (float)0.98768836, (float)0.98717111, (float)0.98664331, (float)0.98610497,
+ (float)0.98555607, (float)0.98499656, (float)0.98442656, (float)0.98384601,
+ (float)0.98325491, (float)0.98265326, (float)0.98204112, (float)0.98141843,
+ (float)0.98078525, (float)0.98014158, (float)0.97948742, (float)0.97882277,
+ (float)0.97814757, (float)0.97746193, (float)0.97676587, (float)0.97605932,
+ (float)0.97534227, (float)0.97461486, (float)0.97387695, (float)0.97312862,
+ (float)0.97236991, (float)0.97160077, (float)0.97082120, (float)0.97003126,
+ (float)0.96923089, (float)0.96842015, (float)0.96759909, (float)0.96676761,
+ (float)0.96592581, (float)0.96507365, (float)0.96421117, (float)0.96333838,
+ (float)0.96245521, (float)0.96156180, (float)0.96065807, (float)0.95974404,
+ (float)0.95881969, (float)0.95788515, (float)0.95694029, (float)0.95598525,
+ (float)0.95501995, (float)0.95404440, (float)0.95305860, (float)0.95206267,
+ (float)0.95105648, (float)0.95004016, (float)0.94901365, (float)0.94797695,
+ (float)0.94693011, (float)0.94587314, (float)0.94480604, (float)0.94372880,
+ (float)0.94264150, (float)0.94154406, (float)0.94043654, (float)0.93931895,
+ (float)0.93819129, (float)0.93705362, (float)0.93590593, (float)0.93474817,
+ (float)0.93358046, (float)0.93240267, (float)0.93121493, (float)0.93001723,
+ (float)0.92880952, (float)0.92759192, (float)0.92636436, (float)0.92512691,
+ (float)0.92387950, (float)0.92262226, (float)0.92135507, (float)0.92007804,
+ (float)0.91879123, (float)0.91749448, (float)0.91618794, (float)0.91487157,
+ (float)0.91354543, (float)0.91220951, (float)0.91086382, (float)0.90950835,
+ (float)0.90814310, (float)0.90676820, (float)0.90538365, (float)0.90398932,
+ (float)0.90258527, (float)0.90117157, (float)0.89974827, (float)0.89831525,
+ (float)0.89687276, (float)0.89542055, (float)0.89395875, (float)0.89248741,
+ (float)0.89100647, (float)0.88951600, (float)0.88801610, (float)0.88650662,
+ (float)0.88498759, (float)0.88345915, (float)0.88192123, (float)0.88037384,
+ (float)0.87881714, (float)0.87725091, (float)0.87567532, (float)0.87409031,
+ (float)0.87249595, (float)0.87089223, (float)0.86927933, (float)0.86765701,
+ (float)0.86602539, (float)0.86438447, (float)0.86273432, (float)0.86107504,
+ (float)0.85940641, (float)0.85772860, (float)0.85604161, (float)0.85434544,
+ (float)0.85264009, (float)0.85092574, (float)0.84920216, (float)0.84746951,
+ (float)0.84572780, (float)0.84397697, (float)0.84221715, (float)0.84044844,
+ (float)0.83867055, (float)0.83688372, (float)0.83508795, (float)0.83328319,
+ (float)0.83146954, (float)0.82964706, (float)0.82781565, (float)0.82597530,
+ (float)0.82412612, (float)0.82226813, (float)0.82040137, (float)0.81852591,
+ (float)0.81664157, (float)0.81474847, (float)0.81284660, (float)0.81093609,
+ (float)0.80901700, (float)0.80708915, (float)0.80515265, (float)0.80320752,
+ (float)0.80125374, (float)0.79929143, (float)0.79732066, (float)0.79534125,
+ (float)0.79335332, (float)0.79135686, (float)0.78935200, (float)0.78733861,
+ (float)0.78531694, (float)0.78328675, (float)0.78124815, (float)0.77920121,
+ (float)0.77714586, (float)0.77508223, (float)0.77301049, (float)0.77093029,
+ (float)0.76884180, (float)0.76674509, (float)0.76464021, (float)0.76252711,
+ (float)0.76040596, (float)0.75827658, (float)0.75613904, (float)0.75399339,
+ (float)0.75183970, (float)0.74967796, (float)0.74750835, (float)0.74533057,
+ (float)0.74314481, (float)0.74095106, (float)0.73874938, (float)0.73653996,
+ (float)0.73432249, (float)0.73209721, (float)0.72986400, (float)0.72762305,
+ (float)0.72537428, (float)0.72311789, (float)0.72085363, (float)0.71858162,
+ (float)0.71630186, (float)0.71401453, (float)0.71171951, (float)0.70941705,
+ (float)0.70710677, (float)0.70478898, (float)0.70246363, (float)0.70013070,
+ (float)0.69779032, (float)0.69544268, (float)0.69308734, (float)0.69072461,
+ (float)0.68835449, (float)0.68597704, (float)0.68359220, (float)0.68120021,
+ (float)0.67880070, (float)0.67639399, (float)0.67398006, (float)0.67155886,
+ (float)0.66913044, (float)0.66669512, (float)0.66425240, (float)0.66180259,
+ (float)0.65934575, (float)0.65688181, (float)0.65441096, (float)0.65193301,
+ (float)0.64944804, (float)0.64695609, (float)0.64445722, (float)0.64195150,
+ (float)0.63943905, (float)0.63691956, (float)0.63439327, (float)0.63186014,
+ (float)0.62932026, (float)0.62677372, (float)0.62422055, (float)0.62166059,
+ (float)0.61909389, (float)0.61652064, (float)0.61394072, (float)0.61135429,
+ (float)0.60876143, (float)0.60616189, (float)0.60355592, (float)0.60094339,
+ (float)0.59832448, (float)0.59569913, (float)0.59306765, (float)0.59042960,
+ (float)0.58778518, (float)0.58513451, (float)0.58247757, (float)0.57981461,
+ (float)0.57714522, (float)0.57446963, (float)0.57178789, (float)0.56910002,
+ (float)0.56640613, (float)0.56370628, (float)0.56100023, (float)0.55828822,
+ (float)0.55557019, (float)0.55284619, (float)0.55011630, (float)0.54738069,
+ (float)0.54463905, (float)0.54189152, (float)0.53913826, (float)0.53637916,
+ (float)0.53361434, (float)0.53084403, (float)0.52806783, (float)0.52528596,
+ (float)0.52249849, (float)0.51970541, (float)0.51690674, (float)0.51410276,
+ (float)0.51129305, (float)0.50847787, (float)0.50565726, (float)0.50283122,
+ (float)0.50000006, (float)0.49716327, (float)0.49432117, (float)0.49147379,
+ (float)0.48862115, (float)0.48576325, (float)0.48290038, (float)0.48003212,
+ (float)0.47715873, (float)0.47428021, (float)0.47139663, (float)0.46850798,
+ (float)0.46561456, (float)0.46271589, (float)0.45981231, (float)0.45690379,
+ (float)0.45399037, (float)0.45107210, (float)0.44814920, (float)0.44522130,
+ (float)0.44228864, (float)0.43935123, (float)0.43640912, (float)0.43346232,
+ (float)0.43051112, (float)0.42755505, (float)0.42459446, (float)0.42162928,
+ (float)0.41865960, (float)0.41568545, (float)0.41270703, (float)0.40972400,
+ (float)0.40673658, (float)0.40374479, (float)0.40074870, (float)0.39774850,
+ (float)0.39474386, (float)0.39173496, (float)0.38872188, (float)0.38570464,
+ (float)0.38268328, (float)0.37965804, (float)0.37662849, (float)0.37359491,
+ (float)0.37055734, (float)0.36751580, (float)0.36447033, (float)0.36142117,
+ (float)0.35836792, (float)0.35531086, (float)0.35224995, (float)0.34918529,
+ (float)0.34611690, (float)0.34304500, (float)0.33996922, (float)0.33688980,
+ (float)0.33380675, (float)0.33072016, (float)0.32763001, (float)0.32453656,
+ (float)0.32143945, (float)0.31833887, (float)0.31523487, (float)0.31212750,
+ (float)0.30901679, (float)0.30590302, (float)0.30278572, (float)0.29966521,
+ (float)0.29654145, (float)0.29341453, (float)0.29028472, (float)0.28715155,
+ (float)0.28401530, (float)0.28087601, (float)0.27773371, (float)0.27458847,
+ (float)0.27144048, (float)0.26828936, (float)0.26513538, (float)0.26197854,
+ (float)0.25881892, (float)0.25565651, (float)0.25249159, (float)0.24932374,
+ (float)0.24615324, (float)0.24298008, (float)0.23980433, (float)0.23662600,
+ (float)0.23344538, (float)0.23026201, (float)0.22707619, (float)0.22388794,
+ (float)0.22069728, (float)0.21750426, (float)0.21430916, (float)0.21111152,
+ (float)0.20791161, (float)0.20470949, (float)0.20150517, (float)0.19829892,
+ (float)0.19509031, (float)0.19187963, (float)0.18866688, (float)0.18545210,
+ (float)0.18223536, (float)0.17901689, (float)0.17579627, (float)0.17257376,
+ (float)0.16934940, (float)0.16612324, (float)0.16289529, (float)0.15966584,
+ (float)0.15643445, (float)0.15320137, (float)0.14996666, (float)0.14673033,
+ (float)0.14349243, (float)0.14025325, (float)0.13701232, (float)0.13376991,
+ (float)0.13052608, (float)0.12728085, (float)0.12403426, (float)0.12078657,
+ (float)0.11753736, (float)0.11428688, (float)0.11103519, (float)0.10778230,
+ (float)0.10452849, (float)0.10127334, (float)0.09801710, (float)0.09475980,
+ (float)0.09150149, (float)0.08824220, (float)0.08498220, (float)0.08172106,
+ (float)0.07845904, (float)0.07519618, (float)0.07193252, (float)0.06866808,
+ (float)0.06540315, (float)0.06213728, (float)0.05887074, (float)0.05560357,
+ (float)0.05233581, (float)0.04906749, (float)0.04579888, (float)0.04252954,
+ (float)0.03925974, (float)0.03598953, (float)0.03271893, (float)0.02944798,
+ (float)0.02617695, (float)0.02290541, (float)0.01963361, (float)0.01636161,
+ (float)0.01308943, (float)0.00981712, (float)0.00654493, (float)0.00327244,
+ (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
+ (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
+ (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
+ (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
+ (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
+ (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
+ (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
+ (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000};
#endif // MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_WINDOWS_PRIVATE_H_
diff --git a/modules/audio_processing/residual_echo_detector.cc b/modules/audio_processing/residual_echo_detector.cc
index aec545a..e805013 100644
--- a/modules/audio_processing/residual_echo_detector.cc
+++ b/modules/audio_processing/residual_echo_detector.cc
@@ -141,19 +141,20 @@
read_index -= kLookbackFrames;
}
RTC_DCHECK_LT(read_index, render_power_.size());
- RTC_LOG_F(LS_ERROR)
- << "Echo detector internal state: {"
- "Echo likelihood: " << echo_likelihood_
- << ", Best Delay: " << best_delay
- << ", Covariance: " << covariances_[best_delay].covariance()
- << ", Last capture power: " << capture_power
- << ", Capture mean: " << capture_mean
- << ", Capture_standard deviation: " << capture_std_deviation
- << ", Last render power: " << render_power_[read_index]
- << ", Render mean: " << render_power_mean_[read_index]
- << ", Render standard deviation: "
- << render_power_std_dev_[read_index]
- << ", Reliability: " << reliability_ << "}";
+ RTC_LOG_F(LS_ERROR) << "Echo detector internal state: {"
+ "Echo likelihood: "
+ << echo_likelihood_ << ", Best Delay: " << best_delay
+ << ", Covariance: "
+ << covariances_[best_delay].covariance()
+ << ", Last capture power: " << capture_power
+ << ", Capture mean: " << capture_mean
+ << ", Capture_standard deviation: "
+ << capture_std_deviation << ", Last render power: "
+ << render_power_[read_index]
+ << ", Render mean: " << render_power_mean_[read_index]
+ << ", Render standard deviation: "
+ << render_power_std_dev_[read_index]
+ << ", Reliability: " << reliability_ << "}";
log_counter_++;
}
}
diff --git a/modules/audio_processing/rms_level.h b/modules/audio_processing/rms_level.h
index ae124b7..ae45a45 100644
--- a/modules/audio_processing/rms_level.h
+++ b/modules/audio_processing/rms_level.h
@@ -72,4 +72,3 @@
} // namespace webrtc
#endif // MODULES_AUDIO_PROCESSING_RMS_LEVEL_H_
-
diff --git a/modules/audio_processing/splitting_filter.cc b/modules/audio_processing/splitting_filter.cc
index e2b8f82..122bc9c 100644
--- a/modules/audio_processing/splitting_filter.cc
+++ b/modules/audio_processing/splitting_filter.cc
@@ -63,8 +63,7 @@
IFChannelBuffer* bands) {
RTC_DCHECK_EQ(two_bands_states_.size(), data->num_channels());
for (size_t i = 0; i < two_bands_states_.size(); ++i) {
- WebRtcSpl_AnalysisQMF(data->ibuf_const()->channels()[i],
- data->num_frames(),
+ WebRtcSpl_AnalysisQMF(data->ibuf_const()->channels()[i], data->num_frames(),
bands->ibuf()->channels(0)[i],
bands->ibuf()->channels(1)[i],
two_bands_states_[i].analysis_state1,
@@ -76,12 +75,11 @@
IFChannelBuffer* data) {
RTC_DCHECK_LE(data->num_channels(), two_bands_states_.size());
for (size_t i = 0; i < data->num_channels(); ++i) {
- WebRtcSpl_SynthesisQMF(bands->ibuf_const()->channels(0)[i],
- bands->ibuf_const()->channels(1)[i],
- bands->num_frames_per_band(),
- data->ibuf()->channels()[i],
- two_bands_states_[i].synthesis_state1,
- two_bands_states_[i].synthesis_state2);
+ WebRtcSpl_SynthesisQMF(
+ bands->ibuf_const()->channels(0)[i],
+ bands->ibuf_const()->channels(1)[i], bands->num_frames_per_band(),
+ data->ibuf()->channels()[i], two_bands_states_[i].synthesis_state1,
+ two_bands_states_[i].synthesis_state2);
}
}
diff --git a/modules/audio_processing/splitting_filter_unittest.cc b/modules/audio_processing/splitting_filter_unittest.cc
index 3e0dbb9..1caee64 100644
--- a/modules/audio_processing/splitting_filter_unittest.cc
+++ b/modules/audio_processing/splitting_filter_unittest.cc
@@ -39,8 +39,7 @@
static const int kFrequenciesHz[kNumBands] = {1000, 12000, 18000};
static const float kAmplitude = 8192.f;
static const size_t kChunks = 8;
- SplittingFilter splitting_filter(kChannels,
- kNumBands,
+ SplittingFilter splitting_filter(kChannels, kNumBands,
kSamplesPer48kHzChannel);
IFChannelBuffer in_data(kSamplesPer48kHzChannel, kChannels, kNumBands);
IFChannelBuffer bands(kSamplesPer48kHzChannel, kChannels, kNumBands);
@@ -48,8 +47,7 @@
for (size_t i = 0; i < kChunks; ++i) {
// Input signal generation.
bool is_present[kNumBands];
- memset(in_data.fbuf()->channels()[0],
- 0,
+ memset(in_data.fbuf()->channels()[0], 0,
kSamplesPer48kHzChannel * sizeof(in_data.fbuf()->channels()[0][0]));
for (size_t j = 0; j < kNumBands; ++j) {
is_present[j] = i & (static_cast<size_t>(1) << j);
@@ -57,7 +55,7 @@
for (size_t k = 0; k < kSamplesPer48kHzChannel; ++k) {
in_data.fbuf()->channels()[0][k] +=
amplitude * sin(2.f * M_PI * kFrequenciesHz[j] *
- (i * kSamplesPer48kHzChannel + k) / kSampleRateHz);
+ (i * kSamplesPer48kHzChannel + k) / kSampleRateHz);
}
}
// Three band splitting filter.
diff --git a/modules/audio_processing/test/audioproc_float_impl.cc b/modules/audio_processing/test/audioproc_float_impl.cc
index 6a3f316..ebf20e3 100644
--- a/modules/audio_processing/test/audioproc_float_impl.cc
+++ b/modules/audio_processing/test/audioproc_float_impl.cc
@@ -128,9 +128,7 @@
DEFINE_int(aecm_comfort_noise,
kParameterNotSpecifiedValue,
"Activate (1) or deactivate(0) the AECM comfort noise");
-DEFINE_int(agc_mode,
- kParameterNotSpecifiedValue,
- "Specify the AGC mode (0-2)");
+DEFINE_int(agc_mode, kParameterNotSpecifiedValue, "Specify the AGC mode (0-2)");
DEFINE_int(agc_target_level,
kParameterNotSpecifiedValue,
"Specify the AGC target level (0-31)");
@@ -147,9 +145,7 @@
DEFINE_int(vad_likelihood,
kParameterNotSpecifiedValue,
"Specify the VAD likelihood (0-3)");
-DEFINE_int(ns_level,
- kParameterNotSpecifiedValue,
- "Specify the NS level (0-3)");
+DEFINE_int(ns_level, kParameterNotSpecifiedValue, "Specify the NS level (0-3)");
DEFINE_int(stream_delay,
kParameterNotSpecifiedValue,
"Specify the stream delay in ms to use");
@@ -454,8 +450,8 @@
int AudioprocFloatImpl(std::unique_ptr<AudioProcessingBuilder> ap_builder,
int argc,
char* argv[]) {
- if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) ||
- FLAG_help || argc != 1) {
+ if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || FLAG_help ||
+ argc != 1) {
printf("%s", kUsageDescription);
if (FLAG_help) {
rtc::FlagList::Print(nullptr, false);
diff --git a/modules/audio_processing/test/conversational_speech/generator.cc b/modules/audio_processing/test/conversational_speech/generator.cc
index ee3f81a..f6a0b46 100644
--- a/modules/audio_processing/test/conversational_speech/generator.cc
+++ b/modules/audio_processing/test/conversational_speech/generator.cc
@@ -40,8 +40,8 @@
} // namespace
int main(int argc, char* argv[]) {
- if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) ||
- FLAG_help || argc != 1) {
+ if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || FLAG_help ||
+ argc != 1) {
printf("%s", kUsageDescription);
if (FLAG_help) {
rtc::FlagList::Print(nullptr, false);
@@ -60,23 +60,23 @@
conversational_speech::LoadTiming(config.timing_filepath());
// Parse timing and audio tracks.
- auto wavreader_factory = rtc::MakeUnique<
- conversational_speech::WavReaderFactory>();
+ auto wavreader_factory =
+ rtc::MakeUnique<conversational_speech::WavReaderFactory>();
conversational_speech::MultiEndCall multiend_call(
timing, config.audiotracks_path(), std::move(wavreader_factory));
// Generate output audio tracks.
- auto generated_audiotrack_pairs = conversational_speech::Simulate(
- multiend_call, config.output_path());
+ auto generated_audiotrack_pairs =
+ conversational_speech::Simulate(multiend_call, config.output_path());
// Show paths to created audio tracks.
std::cout << "Output files:" << std::endl;
for (const auto& output_paths_entry : *generated_audiotrack_pairs) {
std::cout << " speaker: " << output_paths_entry.first << std::endl;
std::cout << " near end: " << output_paths_entry.second.near_end
- << std::endl;
+ << std::endl;
std::cout << " far end: " << output_paths_entry.second.far_end
- << std::endl;
+ << std::endl;
}
return 0;
diff --git a/modules/audio_processing/test/conversational_speech/mock_wavreader.cc b/modules/audio_processing/test/conversational_speech/mock_wavreader.cc
index 103483d..58d68e6 100644
--- a/modules/audio_processing/test/conversational_speech/mock_wavreader.cc
+++ b/modules/audio_processing/test/conversational_speech/mock_wavreader.cc
@@ -16,10 +16,12 @@
using testing::Return;
-MockWavReader::MockWavReader(
- int sample_rate, size_t num_channels, size_t num_samples)
- : sample_rate_(sample_rate), num_channels_(num_channels),
- num_samples_(num_samples) {
+MockWavReader::MockWavReader(int sample_rate,
+ size_t num_channels,
+ size_t num_samples)
+ : sample_rate_(sample_rate),
+ num_channels_(num_channels),
+ num_samples_(num_samples) {
ON_CALL(*this, SampleRate()).WillByDefault(Return(sample_rate_));
ON_CALL(*this, NumChannels()).WillByDefault(Return(num_channels_));
ON_CALL(*this, NumSamples()).WillByDefault(Return(num_samples_));
diff --git a/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.cc b/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.cc
index 76f5c80..eb8e3be 100644
--- a/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.cc
+++ b/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.cc
@@ -25,10 +25,9 @@
MockWavReaderFactory::MockWavReaderFactory(
const Params& default_params,
const std::map<std::string, const Params>& params)
- : default_params_(default_params),
- audiotrack_names_params_(params) {
- ON_CALL(*this, Create(_)).WillByDefault(Invoke(
- this, &MockWavReaderFactory::CreateMock));
+ : default_params_(default_params), audiotrack_names_params_(params) {
+ ON_CALL(*this, Create(_))
+ .WillByDefault(Invoke(this, &MockWavReaderFactory::CreateMock));
}
MockWavReaderFactory::MockWavReaderFactory(const Params& default_params)
@@ -41,16 +40,15 @@
const std::string& filepath) {
// Search the parameters corresponding to filepath.
const rtc::Pathname audiotrack_file_path(filepath);
- const auto it = audiotrack_names_params_.find(
- audiotrack_file_path.filename());
+ const auto it =
+ audiotrack_names_params_.find(audiotrack_file_path.filename());
// If not found, use default parameters.
if (it == audiotrack_names_params_.end()) {
RTC_LOG(LS_VERBOSE) << "using default parameters for " << filepath;
- return std::unique_ptr<WavReaderInterface>(
- new MockWavReader(default_params_.sample_rate,
- default_params_.num_channels,
- default_params_.num_samples));
+ return std::unique_ptr<WavReaderInterface>(new MockWavReader(
+ default_params_.sample_rate, default_params_.num_channels,
+ default_params_.num_samples));
}
// Found, use the audiotrack-specific parameters.
@@ -58,10 +56,8 @@
RTC_LOG(LS_VERBOSE) << "sample_rate " << it->second.sample_rate;
RTC_LOG(LS_VERBOSE) << "num_channels " << it->second.num_channels;
RTC_LOG(LS_VERBOSE) << "num_samples " << it->second.num_samples;
- return std::unique_ptr<WavReaderInterface>(
- new MockWavReader(it->second.sample_rate,
- it->second.num_channels,
- it->second.num_samples));
+ return std::unique_ptr<WavReaderInterface>(new MockWavReader(
+ it->second.sample_rate, it->second.num_channels, it->second.num_samples));
}
} // namespace conversational_speech
diff --git a/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.h b/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.h
index 4c055cf..e84f5f3 100644
--- a/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.h
+++ b/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.h
@@ -25,7 +25,7 @@
class MockWavReaderFactory : public WavReaderAbstractFactory {
public:
- struct Params{
+ struct Params {
int sample_rate;
size_t num_channels;
size_t num_samples;
@@ -36,8 +36,8 @@
explicit MockWavReaderFactory(const Params& default_params);
~MockWavReaderFactory();
- MOCK_CONST_METHOD1(Create, std::unique_ptr<WavReaderInterface>(
- const std::string&));
+ MOCK_CONST_METHOD1(Create,
+ std::unique_ptr<WavReaderInterface>(const std::string&));
private:
// Creates a MockWavReader instance using the parameters in
diff --git a/modules/audio_processing/test/conversational_speech/multiend_call.cc b/modules/audio_processing/test/conversational_speech/multiend_call.cc
index f5411bd..d633d90 100644
--- a/modules/audio_processing/test/conversational_speech/multiend_call.cc
+++ b/modules/audio_processing/test/conversational_speech/multiend_call.cc
@@ -21,11 +21,13 @@
namespace conversational_speech {
MultiEndCall::MultiEndCall(
- rtc::ArrayView<const Turn> timing, const std::string& audiotracks_path,
+ rtc::ArrayView<const Turn> timing,
+ const std::string& audiotracks_path,
std::unique_ptr<WavReaderAbstractFactory> wavreader_abstract_factory)
- : timing_(timing), audiotracks_path_(audiotracks_path),
- wavreader_abstract_factory_(std::move(wavreader_abstract_factory)),
- valid_(false) {
+ : timing_(timing),
+ audiotracks_path_(audiotracks_path),
+ wavreader_abstract_factory_(std::move(wavreader_abstract_factory)),
+ valid_(false) {
FindSpeakerNames();
if (CreateAudioTrackReaders())
valid_ = CheckTiming();
@@ -49,8 +51,8 @@
continue;
// Instance Pathname to retrieve the full path to the audiotrack file.
- const rtc::Pathname audiotrack_file_path(
- audiotracks_path_, turn.audiotrack_file_name);
+ const rtc::Pathname audiotrack_file_path(audiotracks_path_,
+ turn.audiotrack_file_name);
// Map the audiotrack file name to a new instance of WavReaderInterface.
std::unique_ptr<WavReaderInterface> wavreader =
@@ -69,8 +71,8 @@
return false;
}
- audiotrack_readers_.emplace(
- turn.audiotrack_file_name, std::move(wavreader));
+ audiotrack_readers_.emplace(turn.audiotrack_file_name,
+ std::move(wavreader));
}
return true;
@@ -101,10 +103,9 @@
// detect self cross-talk).
std::map<std::string, std::vector<size_t>> speaking_turn_indices;
for (const std::string& speaker_name : speaker_names_) {
- speaking_turn_indices.emplace(
- std::piecewise_construct,
- std::forward_as_tuple(speaker_name),
- std::forward_as_tuple());
+ speaking_turn_indices.emplace(std::piecewise_construct,
+ std::forward_as_tuple(speaker_name),
+ std::forward_as_tuple());
}
// Parse turns.
@@ -115,8 +116,8 @@
<< "Audio track reader not created";
// Begin and end timestamps for the current turn.
- int offset_samples = millisecond_to_samples(
- turn.offset, it->second->SampleRate());
+ int offset_samples =
+ millisecond_to_samples(turn.offset, it->second->SampleRate());
std::size_t begin_timestamp = last_turn.end + offset_samples;
std::size_t end_timestamp = begin_timestamp + it->second->NumSamples();
RTC_LOG(LS_INFO) << "turn #" << turn_index << " " << begin_timestamp << "-"
@@ -124,16 +125,16 @@
// The order is invalid if the offset is negative and its absolute value is
// larger then the duration of the previous turn.
- if (offset_samples < 0 && -offset_samples > static_cast<int>(
- last_turn.end - last_turn.begin)) {
+ if (offset_samples < 0 &&
+ -offset_samples > static_cast<int>(last_turn.end - last_turn.begin)) {
RTC_LOG(LS_ERROR) << "invalid order";
return false;
}
// Cross-talk with 3 or more speakers occurs when the beginning of the
// current interval falls in the last two turns.
- if (turn_index > 1 && in_interval(begin_timestamp, last_turn)
- && in_interval(begin_timestamp, second_last_turn)) {
+ if (turn_index > 1 && in_interval(begin_timestamp, last_turn) &&
+ in_interval(begin_timestamp, second_last_turn)) {
RTC_LOG(LS_ERROR) << "cross-talk with 3+ speakers";
return false;
}
@@ -164,8 +165,9 @@
std::vector<SpeakingTurn> speaking_turns_for_name;
std::copy_if(speaking_turns_.begin(), speaking_turns_.end(),
std::back_inserter(speaking_turns_for_name),
- [&speaker_name](const SpeakingTurn& st){
- return st.speaker_name == speaker_name; });
+ [&speaker_name](const SpeakingTurn& st) {
+ return st.speaker_name == speaker_name;
+ });
// Check for overlap between adjacent elements.
// This is a sufficient condition for self cross-talk since the intervals
@@ -173,7 +175,8 @@
auto overlap = std::adjacent_find(
speaking_turns_for_name.begin(), speaking_turns_for_name.end(),
[](const SpeakingTurn& a, const SpeakingTurn& b) {
- return a.end > b.begin; });
+ return a.end > b.begin;
+ });
if (overlap != speaking_turns_for_name.end()) {
RTC_LOG(LS_ERROR) << "Self cross-talk detected";
diff --git a/modules/audio_processing/test/conversational_speech/multiend_call.h b/modules/audio_processing/test/conversational_speech/multiend_call.h
index d91058f..a4eff38 100644
--- a/modules/audio_processing/test/conversational_speech/multiend_call.h
+++ b/modules/audio_processing/test/conversational_speech/multiend_call.h
@@ -51,18 +51,22 @@
};
MultiEndCall(
- rtc::ArrayView<const Turn> timing, const std::string& audiotracks_path,
+ rtc::ArrayView<const Turn> timing,
+ const std::string& audiotracks_path,
std::unique_ptr<WavReaderAbstractFactory> wavreader_abstract_factory);
~MultiEndCall();
const std::set<std::string>& speaker_names() const { return speaker_names_; }
const std::map<std::string, std::unique_ptr<WavReaderInterface>>&
- audiotrack_readers() const { return audiotrack_readers_; }
+ audiotrack_readers() const {
+ return audiotrack_readers_;
+ }
bool valid() const { return valid_; }
int sample_rate() const { return sample_rate_hz_; }
size_t total_duration_samples() const { return total_duration_samples_; }
const std::vector<SpeakingTurn>& speaking_turns() const {
- return speaking_turns_; }
+ return speaking_turns_;
+ }
private:
// Finds unique speaker names.
diff --git a/modules/audio_processing/test/conversational_speech/simulator.cc b/modules/audio_processing/test/conversational_speech/simulator.cc
index 437a973..946aee1 100644
--- a/modules/audio_processing/test/conversational_speech/simulator.cc
+++ b/modules/audio_processing/test/conversational_speech/simulator.cc
@@ -38,28 +38,27 @@
// Combines output path and speaker names to define the output file paths for
// the near-end and far=end audio tracks.
std::unique_ptr<std::map<std::string, SpeakerOutputFilePaths>>
- InitSpeakerOutputFilePaths(const std::set<std::string>& speaker_names,
- const std::string& output_path) {
+InitSpeakerOutputFilePaths(const std::set<std::string>& speaker_names,
+ const std::string& output_path) {
// Create map.
- auto speaker_output_file_paths_map = rtc::MakeUnique<
- std::map<std::string, SpeakerOutputFilePaths>>();
+ auto speaker_output_file_paths_map =
+ rtc::MakeUnique<std::map<std::string, SpeakerOutputFilePaths>>();
// Add near-end and far-end output paths into the map.
for (const auto& speaker_name : speaker_names) {
- const rtc::Pathname near_end_path(
- output_path, "s_" + speaker_name + "-near_end.wav");
+ const rtc::Pathname near_end_path(output_path,
+ "s_" + speaker_name + "-near_end.wav");
RTC_LOG(LS_VERBOSE) << "The near-end audio track will be created in "
<< near_end_path.pathname() << ".";
- const rtc::Pathname far_end_path(
- output_path, "s_" + speaker_name + "-far_end.wav");
+ const rtc::Pathname far_end_path(output_path,
+ "s_" + speaker_name + "-far_end.wav");
RTC_LOG(LS_VERBOSE) << "The far-end audio track will be created in "
<< far_end_path.pathname() << ".";
// Add to map.
speaker_output_file_paths_map->emplace(
- std::piecewise_construct,
- std::forward_as_tuple(speaker_name),
+ std::piecewise_construct, std::forward_as_tuple(speaker_name),
std::forward_as_tuple(near_end_path.pathname(),
far_end_path.pathname()));
}
@@ -71,16 +70,13 @@
// output track of a speaker.
class SpeakerWavWriters {
public:
- SpeakerWavWriters(
- const SpeakerOutputFilePaths& output_file_paths, int sample_rate)
- : near_end_wav_writer_(output_file_paths.near_end, sample_rate, 1u),
- far_end_wav_writer_(output_file_paths.far_end, sample_rate, 1u) {}
- WavWriter* near_end_wav_writer() {
- return &near_end_wav_writer_;
- }
- WavWriter* far_end_wav_writer() {
- return &far_end_wav_writer_;
- }
+ SpeakerWavWriters(const SpeakerOutputFilePaths& output_file_paths,
+ int sample_rate)
+ : near_end_wav_writer_(output_file_paths.near_end, sample_rate, 1u),
+ far_end_wav_writer_(output_file_paths.far_end, sample_rate, 1u) {}
+ WavWriter* near_end_wav_writer() { return &near_end_wav_writer_; }
+ WavWriter* far_end_wav_writer() { return &far_end_wav_writer_; }
+
private:
WavWriter near_end_wav_writer_;
WavWriter far_end_wav_writer_;
@@ -89,18 +85,18 @@
// Initializes one WavWriter instance for each speaker and both the near-end and
// far-end output tracks.
std::unique_ptr<std::map<std::string, SpeakerWavWriters>>
- InitSpeakersWavWriters(const std::map<std::string, SpeakerOutputFilePaths>&
- speaker_output_file_paths, int sample_rate) {
+InitSpeakersWavWriters(const std::map<std::string, SpeakerOutputFilePaths>&
+ speaker_output_file_paths,
+ int sample_rate) {
// Create map.
- auto speaker_wav_writers_map = rtc::MakeUnique<
- std::map<std::string, SpeakerWavWriters>>();
+ auto speaker_wav_writers_map =
+ rtc::MakeUnique<std::map<std::string, SpeakerWavWriters>>();
// Add SpeakerWavWriters instance into the map.
for (auto it = speaker_output_file_paths.begin();
- it != speaker_output_file_paths.end(); ++it) {
+ it != speaker_output_file_paths.end(); ++it) {
speaker_wav_writers_map->emplace(
- std::piecewise_construct,
- std::forward_as_tuple(it->first),
+ std::piecewise_construct, std::forward_as_tuple(it->first),
std::forward_as_tuple(it->second, sample_rate));
}
@@ -112,17 +108,16 @@
const std::map<std::string, std::unique_ptr<WavReaderInterface>>&
audiotrack_readers) {
// Create map.
- auto audiotracks_map = rtc::MakeUnique<
- std::map<std::string, std::vector<int16_t>>>();
+ auto audiotracks_map =
+ rtc::MakeUnique<std::map<std::string, std::vector<int16_t>>>();
// Add audio track vectors.
for (auto it = audiotrack_readers.begin(); it != audiotrack_readers.end();
- ++it) {
+ ++it) {
// Add map entry.
- audiotracks_map->emplace(
- std::piecewise_construct,
- std::forward_as_tuple(it->first),
- std::forward_as_tuple(it->second->NumSamples()));
+ audiotracks_map->emplace(std::piecewise_construct,
+ std::forward_as_tuple(it->first),
+ std::forward_as_tuple(it->second->NumSamples()));
// Read samples.
it->second->ReadInt16Samples(audiotracks_map->at(it->first));
@@ -136,7 +131,8 @@
// adds zeros as left padding. The padding corresponds to intervals during which
// a speaker is not active.
void PadLeftWriteChunk(rtc::ArrayView<const int16_t> source_samples,
- size_t interval_begin, WavWriter* wav_writer) {
+ size_t interval_begin,
+ WavWriter* wav_writer) {
// Add left padding.
RTC_CHECK(wav_writer);
RTC_CHECK_GE(interval_begin, wav_writer->num_samples());
@@ -179,11 +175,12 @@
namespace conversational_speech {
std::unique_ptr<std::map<std::string, SpeakerOutputFilePaths>> Simulate(
- const MultiEndCall& multiend_call, const std::string& output_path) {
+ const MultiEndCall& multiend_call,
+ const std::string& output_path) {
// Set output file paths and initialize wav writers.
const auto& speaker_names = multiend_call.speaker_names();
- auto speaker_output_file_paths = InitSpeakerOutputFilePaths(
- speaker_names, output_path);
+ auto speaker_output_file_paths =
+ InitSpeakerOutputFilePaths(speaker_names, output_path);
auto speakers_wav_writers = InitSpeakersWavWriters(
*speaker_output_file_paths, multiend_call.sample_rate());
diff --git a/modules/audio_processing/test/conversational_speech/simulator.h b/modules/audio_processing/test/conversational_speech/simulator.h
index 671c3b9..743db42 100644
--- a/modules/audio_processing/test/conversational_speech/simulator.h
+++ b/modules/audio_processing/test/conversational_speech/simulator.h
@@ -26,16 +26,16 @@
struct SpeakerOutputFilePaths {
SpeakerOutputFilePaths(const std::string& new_near_end,
const std::string& new_far_end)
- : near_end(new_near_end),
- far_end(new_far_end) {}
+ : near_end(new_near_end), far_end(new_far_end) {}
// Paths to the near-end and far-end audio track files.
const std::string near_end;
const std::string far_end;
};
// Generates the near-end and far-end audio track pairs for each speaker.
-std::unique_ptr<std::map<std::string, SpeakerOutputFilePaths>>
- Simulate(const MultiEndCall& multiend_call, const std::string& output_path);
+std::unique_ptr<std::map<std::string, SpeakerOutputFilePaths>> Simulate(
+ const MultiEndCall& multiend_call,
+ const std::string& output_path);
} // namespace conversational_speech
} // namespace test
diff --git a/modules/audio_processing/test/conversational_speech/timing.cc b/modules/audio_processing/test/conversational_speech/timing.cc
index 2e96d2b..6c19f32 100644
--- a/modules/audio_processing/test/conversational_speech/timing.cc
+++ b/modules/audio_processing/test/conversational_speech/timing.cc
@@ -19,7 +19,7 @@
namespace test {
namespace conversational_speech {
-bool Turn::operator==(const Turn &b) const {
+bool Turn::operator==(const Turn& b) const {
return b.speaker_name == speaker_name &&
b.audiotrack_file_name == audiotrack_file_name && b.offset == offset &&
b.gain == gain;
diff --git a/modules/audio_processing/test/conversational_speech/timing.h b/modules/audio_processing/test/conversational_speech/timing.h
index 07a26e1..812f3d5 100644
--- a/modules/audio_processing/test/conversational_speech/timing.h
+++ b/modules/audio_processing/test/conversational_speech/timing.h
@@ -20,7 +20,7 @@
namespace test {
namespace conversational_speech {
-struct Turn{
+struct Turn {
Turn(std::string new_speaker_name,
std::string new_audiotrack_file_name,
int new_offset,
@@ -29,7 +29,7 @@
audiotrack_file_name(new_audiotrack_file_name),
offset(new_offset),
gain(gain) {}
- bool operator==(const Turn &b) const;
+ bool operator==(const Turn& b) const;
std::string speaker_name;
std::string audiotrack_file_name;
int offset;
diff --git a/modules/audio_processing/test/conversational_speech/wavreader_factory.cc b/modules/audio_processing/test/conversational_speech/wavreader_factory.cc
index 8342d3f..1a5cf8f 100644
--- a/modules/audio_processing/test/conversational_speech/wavreader_factory.cc
+++ b/modules/audio_processing/test/conversational_speech/wavreader_factory.cc
@@ -37,17 +37,11 @@
return wav_reader_.ReadSamples(samples.size(), samples.begin());
}
- int SampleRate() const override {
- return wav_reader_.sample_rate();
- }
+ int SampleRate() const override { return wav_reader_.sample_rate(); }
- size_t NumChannels() const override {
- return wav_reader_.num_channels();
- }
+ size_t NumChannels() const override { return wav_reader_.num_channels(); }
- size_t NumSamples() const override {
- return wav_reader_.num_samples();
- }
+ size_t NumSamples() const override { return wav_reader_.num_samples(); }
private:
WavReader wav_reader_;
diff --git a/modules/audio_processing/test/conversational_speech/wavreader_factory.h b/modules/audio_processing/test/conversational_speech/wavreader_factory.h
index e168d0d..2f86bf5 100644
--- a/modules/audio_processing/test/conversational_speech/wavreader_factory.h
+++ b/modules/audio_processing/test/conversational_speech/wavreader_factory.h
@@ -25,8 +25,8 @@
public:
WavReaderFactory();
~WavReaderFactory() override;
- std::unique_ptr<WavReaderInterface> Create(const std::string& filepath) const
- override;
+ std::unique_ptr<WavReaderInterface> Create(
+ const std::string& filepath) const override;
};
} // namespace conversational_speech
diff --git a/modules/audio_processing/test/debug_dump_replayer.cc b/modules/audio_processing/test/debug_dump_replayer.cc
index bc95cfd..a06c76e 100644
--- a/modules/audio_processing/test/debug_dump_replayer.cc
+++ b/modules/audio_processing/test/debug_dump_replayer.cc
@@ -23,8 +23,8 @@
auto& buffer_ref = *buffer;
if (!buffer_ref.get() || buffer_ref->num_frames() != config.num_frames() ||
buffer_ref->num_channels() != config.num_channels()) {
- buffer_ref.reset(new ChannelBuffer<float>(config.num_frames(),
- config.num_channels()));
+ buffer_ref.reset(
+ new ChannelBuffer<float>(config.num_frames(), config.num_channels()));
}
}
diff --git a/modules/audio_processing/test/debug_dump_test.cc b/modules/audio_processing/test/debug_dump_test.cc
index d90d14f..4e29433 100644
--- a/modules/audio_processing/test/debug_dump_test.cc
+++ b/modules/audio_processing/test/debug_dump_test.cc
@@ -33,8 +33,8 @@
auto& buffer_ref = *buffer;
if (!buffer_ref.get() || buffer_ref->num_frames() != config.num_frames() ||
buffer_ref->num_channels() != config.num_channels()) {
- buffer_ref.reset(new ChannelBuffer<float>(config.num_frames(),
- config.num_channels()));
+ buffer_ref.reset(
+ new ChannelBuffer<float>(config.num_frames(), config.num_channels()));
}
}
@@ -87,7 +87,8 @@
AudioProcessing* apm() const { return apm_.get(); }
private:
- static void ReadAndDeinterleave(ResampleInputAudioFile* audio, int channels,
+ static void ReadAndDeinterleave(ResampleInputAudioFile* audio,
+ int channels,
const StreamConfig& config,
float* const* buffer);
@@ -227,11 +228,10 @@
apm_->ProcessStream(input_->channels(), input_config_,
output_config_, output_->channels()));
- RTC_CHECK_EQ(AudioProcessing::kNoError,
- apm_->ProcessReverseStream(reverse_->channels(),
- reverse_config_,
- reverse_config_,
- reverse_->channels()));
+ RTC_CHECK_EQ(
+ AudioProcessing::kNoError,
+ apm_->ProcessReverseStream(reverse_->channels(), reverse_config_,
+ reverse_config_, reverse_->channels()));
}
}
@@ -288,9 +288,9 @@
ASSERT_EQ(output_config.num_frames() * sizeof(float),
msg->output_channel(0).size());
for (int i = 0; i < msg->output_channel_size(); ++i) {
- ASSERT_EQ(0, memcmp(output->channels()[i],
- msg->output_channel(i).data(),
- msg->output_channel(i).size()));
+ ASSERT_EQ(0,
+ memcmp(output->channels()[i], msg->output_channel(i).data(),
+ msg->output_channel(i).size()));
}
}
}
diff --git a/modules/audio_processing/test/fake_recording_device.h b/modules/audio_processing/test/fake_recording_device.h
index 0d93b7a..13f94a7 100644
--- a/modules/audio_processing/test/fake_recording_device.h
+++ b/modules/audio_processing/test/fake_recording_device.h
@@ -15,8 +15,8 @@
#include <memory>
#include <vector>
-#include "api/audio/audio_frame.h"
#include "api/array_view.h"
+#include "api/audio/audio_frame.h"
#include "common_audio/channel_buffer.h"
#include "rtc_base/checks.h"
diff --git a/modules/audio_processing/test/protobuf_utils.cc b/modules/audio_processing/test/protobuf_utils.cc
index 3b623b9..6ecc97e 100644
--- a/modules/audio_processing/test/protobuf_utils.cc
+++ b/modules/audio_processing/test/protobuf_utils.cc
@@ -14,8 +14,8 @@
namespace webrtc {
size_t ReadMessageBytesFromFile(FILE* file, std::unique_ptr<uint8_t[]>* bytes) {
- // The "wire format" for the size is little-endian. Assume we're running on
- // a little-endian machine.
+// The "wire format" for the size is little-endian. Assume we're running on
+// a little-endian machine.
#ifndef WEBRTC_ARCH_LITTLE_ENDIAN
#error "Need to convert messsage from little-endian."
#endif
diff --git a/modules/audio_processing/test/test_utils.cc b/modules/audio_processing/test/test_utils.cc
index 846ce2b..937775e 100644
--- a/modules/audio_processing/test/test_utils.cc
+++ b/modules/audio_processing/test/test_utils.cc
@@ -91,9 +91,9 @@
}
// TODO(aluebs): Use ScaleToInt16Range() from audio_util
for (size_t i = 0; i < length; ++i) {
- buffer[i] = buffer[i] > 0 ?
- buffer[i] * std::numeric_limits<int16_t>::max() :
- -buffer[i] * std::numeric_limits<int16_t>::min();
+ buffer[i] = buffer[i] > 0
+ ? buffer[i] * std::numeric_limits<int16_t>::max()
+ : -buffer[i] * std::numeric_limits<int16_t>::min();
}
if (wav_file) {
wav_file->WriteSamples(buffer.get(), length);
@@ -113,11 +113,10 @@
return static_cast<size_t>(AudioProcessing::kChunkSizeMs * rate / 1000);
}
-void SetFrameSampleRate(AudioFrame* frame,
- int sample_rate_hz) {
+void SetFrameSampleRate(AudioFrame* frame, int sample_rate_hz) {
frame->sample_rate_hz_ = sample_rate_hz;
- frame->samples_per_channel_ = AudioProcessing::kChunkSizeMs *
- sample_rate_hz / 1000;
+ frame->samples_per_channel_ =
+ AudioProcessing::kChunkSizeMs * sample_rate_hz / 1000;
}
AudioProcessing::ChannelLayout LayoutFromChannels(size_t num_channels) {
diff --git a/modules/audio_processing/test/test_utils.h b/modules/audio_processing/test/test_utils.h
index 43f907a..6e4154a 100644
--- a/modules/audio_processing/test/test_utils.h
+++ b/modules/audio_processing/test/test_utils.h
@@ -91,8 +91,7 @@
size_t SamplesFromRate(int rate);
-void SetFrameSampleRate(AudioFrame* frame,
- int sample_rate_hz);
+void SetFrameSampleRate(AudioFrame* frame, int sample_rate_hz);
template <typename T>
void SetContainerFormat(int sample_rate_hz,
@@ -130,14 +129,14 @@
// Returns a vector<T> parsed from whitespace delimited values in to_parse,
// or an empty vector if the string could not be parsed.
-template<typename T>
+template <typename T>
std::vector<T> ParseList(const std::string& to_parse) {
std::vector<T> values;
std::istringstream str(to_parse);
std::copy(
- std::istream_iterator<T>(str),
- std::istream_iterator<T>(),
+ std::istream_iterator<T>(str), // no-presubmit-check TODO(webrtc:8982)
+ std::istream_iterator<T>(), // no-presubmit-check TODO(webrtc:8982)
std::back_inserter(values));
return values;
diff --git a/modules/audio_processing/three_band_filter_bank.cc b/modules/audio_processing/three_band_filter_bank.cc
index f5a319b..dbbfc28 100644
--- a/modules/audio_processing/three_band_filter_bank.cc
+++ b/modules/audio_processing/three_band_filter_bank.cc
@@ -68,19 +68,19 @@
// A Kaiser window is used because of its flexibility and the alpha is set to
// 3.5, since that sets a stop band attenuation of 40dB ensuring a fast
// transition.
-const float kLowpassCoeffs[kNumBands * kSparsity][kNumCoeffs] =
- {{-0.00047749f, -0.00496888f, +0.16547118f, +0.00425496f},
- {-0.00173287f, -0.01585778f, +0.14989004f, +0.00994113f},
- {-0.00304815f, -0.02536082f, +0.12154542f, +0.01157993f},
- {-0.00383509f, -0.02982767f, +0.08543175f, +0.00983212f},
- {-0.00346946f, -0.02587886f, +0.04760441f, +0.00607594f},
- {-0.00154717f, -0.01136076f, +0.01387458f, +0.00186353f},
- {+0.00186353f, +0.01387458f, -0.01136076f, -0.00154717f},
- {+0.00607594f, +0.04760441f, -0.02587886f, -0.00346946f},
- {+0.00983212f, +0.08543175f, -0.02982767f, -0.00383509f},
- {+0.01157993f, +0.12154542f, -0.02536082f, -0.00304815f},
- {+0.00994113f, +0.14989004f, -0.01585778f, -0.00173287f},
- {+0.00425496f, +0.16547118f, -0.00496888f, -0.00047749f}};
+const float kLowpassCoeffs[kNumBands * kSparsity][kNumCoeffs] = {
+ {-0.00047749f, -0.00496888f, +0.16547118f, +0.00425496f},
+ {-0.00173287f, -0.01585778f, +0.14989004f, +0.00994113f},
+ {-0.00304815f, -0.02536082f, +0.12154542f, +0.01157993f},
+ {-0.00383509f, -0.02982767f, +0.08543175f, +0.00983212f},
+ {-0.00346946f, -0.02587886f, +0.04760441f, +0.00607594f},
+ {-0.00154717f, -0.01136076f, +0.01387458f, +0.00186353f},
+ {+0.00186353f, +0.01387458f, -0.01136076f, -0.00154717f},
+ {+0.00607594f, +0.04760441f, -0.02587886f, -0.00346946f},
+ {+0.00983212f, +0.08543175f, -0.02982767f, -0.00383509f},
+ {+0.01157993f, +0.12154542f, -0.02536082f, -0.00304815f},
+ {+0.00994113f, +0.14989004f, -0.01585778f, -0.00173287f},
+ {+0.00425496f, +0.16547118f, -0.00496888f, -0.00047749f}};
// Downsamples |in| into |out|, taking one every |kNumbands| starting from
// |offset|. |split_length| is the |out| length. |in| has to be at least
@@ -150,8 +150,7 @@
Downsample(in, in_buffer_.size(), kNumBands - i - 1, &in_buffer_[0]);
for (size_t j = 0; j < kSparsity; ++j) {
const size_t offset = i + j * kNumBands;
- analysis_filters_[offset]->Filter(&in_buffer_[0],
- in_buffer_.size(),
+ analysis_filters_[offset]->Filter(&in_buffer_[0], in_buffer_.size(),
&out_buffer_[0]);
DownModulate(&out_buffer_[0], out_buffer_.size(), offset, out);
}
@@ -173,15 +172,13 @@
for (size_t j = 0; j < kSparsity; ++j) {
const size_t offset = i + j * kNumBands;
UpModulate(in, in_buffer_.size(), offset, &in_buffer_[0]);
- synthesis_filters_[offset]->Filter(&in_buffer_[0],
- in_buffer_.size(),
+ synthesis_filters_[offset]->Filter(&in_buffer_[0], in_buffer_.size(),
&out_buffer_[0]);
Upsample(&out_buffer_[0], out_buffer_.size(), i, out);
}
}
}
-
// Modulates |in| by |dct_modulation_| and accumulates it in each of the
// |kNumBands| bands of |out|. |offset| is the index in the period of the
// cosines used for modulation. |split_length| is the length of |in| and each
diff --git a/modules/audio_processing/transient/click_annotate.cc b/modules/audio_processing/transient/click_annotate.cc
index 1f01d01..ce646b5 100644
--- a/modules/audio_processing/transient/click_annotate.cc
+++ b/modules/audio_processing/transient/click_annotate.cc
@@ -73,9 +73,7 @@
// Read first buffer from the PCM test file.
size_t file_samples_read = ReadInt16FromFileToFloatBuffer(
- pcm_file.get(),
- audio_buffer_length,
- audio_buffer.get());
+ pcm_file.get(), audio_buffer_length, audio_buffer.get());
for (int time = 0; file_samples_read > 0; time += chunk_size_ms) {
// Pad the rest of the buffer with zeros.
for (size_t i = file_samples_read; i < audio_buffer_length; ++i) {
@@ -92,14 +90,12 @@
send_times.push_back(value);
// Read next buffer from the PCM test file.
- file_samples_read = ReadInt16FromFileToFloatBuffer(pcm_file.get(),
- audio_buffer_length,
- audio_buffer.get());
+ file_samples_read = ReadInt16FromFileToFloatBuffer(
+ pcm_file.get(), audio_buffer_length, audio_buffer.get());
}
- size_t floats_written = WriteFloatBufferToFile(dat_file.get(),
- send_times.size(),
- &send_times[0]);
+ size_t floats_written =
+ WriteFloatBufferToFile(dat_file.get(), send_times.size(), &send_times[0]);
if (floats_written == 0) {
printf("\nThe send times could not be written to DAT file\n\n");
diff --git a/modules/audio_processing/transient/common.h b/modules/audio_processing/transient/common.h
index 69546fc..63c9a7b 100644
--- a/modules/audio_processing/transient/common.h
+++ b/modules/audio_processing/transient/common.h
@@ -22,6 +22,6 @@
kSampleRate48kHz = 48000
};
-} // namespace ts
-} // namespace webrtc
+} // namespace ts
+} // namespace webrtc
#endif // MODULES_AUDIO_PROCESSING_TRANSIENT_COMMON_H_
diff --git a/modules/audio_processing/transient/daubechies_8_wavelet_coeffs.h b/modules/audio_processing/transient/daubechies_8_wavelet_coeffs.h
index 4de24e0..92233bf 100644
--- a/modules/audio_processing/transient/daubechies_8_wavelet_coeffs.h
+++ b/modules/audio_processing/transient/daubechies_8_wavelet_coeffs.h
@@ -19,44 +19,25 @@
const int kDaubechies8CoefficientsLength = 16;
-const float kDaubechies8HighPassCoefficients[kDaubechies8CoefficientsLength]
- = {
- -5.44158422430816093862e-02f,
- 3.12871590914465924627e-01f,
- -6.75630736298012846142e-01f,
- 5.85354683654869090148e-01f,
- 1.58291052560238926228e-02f,
- -2.84015542962428091389e-01f,
- -4.72484573997972536787e-04f,
- 1.28747426620186011803e-01f,
- 1.73693010020221083600e-02f,
- -4.40882539310647192377e-02f,
- -1.39810279170155156436e-02f,
- 8.74609404701565465445e-03f,
- 4.87035299301066034600e-03f,
- -3.91740372995977108837e-04f,
- -6.75449405998556772109e-04f,
- -1.17476784002281916305e-04f
-};
+const float kDaubechies8HighPassCoefficients[kDaubechies8CoefficientsLength] = {
+ -5.44158422430816093862e-02f, 3.12871590914465924627e-01f,
+ -6.75630736298012846142e-01f, 5.85354683654869090148e-01f,
+ 1.58291052560238926228e-02f, -2.84015542962428091389e-01f,
+ -4.72484573997972536787e-04f, 1.28747426620186011803e-01f,
+ 1.73693010020221083600e-02f, -4.40882539310647192377e-02f,
+ -1.39810279170155156436e-02f, 8.74609404701565465445e-03f,
+ 4.87035299301066034600e-03f, -3.91740372995977108837e-04f,
+ -6.75449405998556772109e-04f, -1.17476784002281916305e-04f};
const float kDaubechies8LowPassCoefficients[kDaubechies8CoefficientsLength] = {
- -1.17476784002281916305e-04f,
- 6.75449405998556772109e-04f,
- -3.91740372995977108837e-04f,
- -4.87035299301066034600e-03f,
- 8.74609404701565465445e-03f,
- 1.39810279170155156436e-02f,
- -4.40882539310647192377e-02f,
- -1.73693010020221083600e-02f,
- 1.28747426620186011803e-01f,
- 4.72484573997972536787e-04f,
- -2.84015542962428091389e-01f,
- -1.58291052560238926228e-02f,
- 5.85354683654869090148e-01f,
- 6.75630736298012846142e-01f,
- 3.12871590914465924627e-01f,
- 5.44158422430816093862e-02f
-};
+ -1.17476784002281916305e-04f, 6.75449405998556772109e-04f,
+ -3.91740372995977108837e-04f, -4.87035299301066034600e-03f,
+ 8.74609404701565465445e-03f, 1.39810279170155156436e-02f,
+ -4.40882539310647192377e-02f, -1.73693010020221083600e-02f,
+ 1.28747426620186011803e-01f, 4.72484573997972536787e-04f,
+ -2.84015542962428091389e-01f, -1.58291052560238926228e-02f,
+ 5.85354683654869090148e-01f, 6.75630736298012846142e-01f,
+ 3.12871590914465924627e-01f, 5.44158422430816093862e-02f};
} // namespace webrtc
diff --git a/modules/audio_processing/transient/dyadic_decimator.h b/modules/audio_processing/transient/dyadic_decimator.h
index 104f95d..e5b1961 100644
--- a/modules/audio_processing/transient/dyadic_decimator.h
+++ b/modules/audio_processing/transient/dyadic_decimator.h
@@ -44,7 +44,7 @@
// GetOutLengthToDyadicDecimate().
// Must be previously allocated.
// Returns the number of output samples, -1 on error.
-template<typename T>
+template <typename T>
static size_t DyadicDecimate(const T* in,
size_t in_length,
bool odd_sequence,
diff --git a/modules/audio_processing/transient/dyadic_decimator_unittest.cc b/modules/audio_processing/transient/dyadic_decimator_unittest.cc
index c407f47..3e65a7b9 100644
--- a/modules/audio_processing/transient/dyadic_decimator_unittest.cc
+++ b/modules/audio_processing/transient/dyadic_decimator_unittest.cc
@@ -19,7 +19,7 @@
static const size_t kOutBufferLength = 3;
int16_t const test_buffer_even_len[] = {0, 1, 2, 3, 4, 5};
-int16_t const test_buffer_odd_len[] = {0, 1, 2, 3, 4};
+int16_t const test_buffer_odd_len[] = {0, 1, 2, 3, 4};
int16_t test_buffer_out[kOutBufferLength];
TEST(DyadicDecimatorTest, GetOutLengthToDyadicDecimate) {
@@ -29,30 +29,23 @@
EXPECT_EQ(2u, GetOutLengthToDyadicDecimate(5, true));
}
-
TEST(DyadicDecimatorTest, DyadicDecimateErrorValues) {
size_t out_samples = 0;
- out_samples = DyadicDecimate(static_cast<int16_t*>(NULL),
- kEvenBufferLength,
+ out_samples = DyadicDecimate(static_cast<int16_t*>(NULL), kEvenBufferLength,
false, // Even sequence.
- test_buffer_out,
- kOutBufferLength);
+ test_buffer_out, kOutBufferLength);
EXPECT_EQ(0u, out_samples);
- out_samples = DyadicDecimate(test_buffer_even_len,
- kEvenBufferLength,
+ out_samples = DyadicDecimate(test_buffer_even_len, kEvenBufferLength,
false, // Even sequence.
- static_cast<int16_t*>(NULL),
- kOutBufferLength);
+ static_cast<int16_t*>(NULL), kOutBufferLength);
EXPECT_EQ(0u, out_samples);
// Less than required |out_length|.
- out_samples = DyadicDecimate(test_buffer_even_len,
- kEvenBufferLength,
+ out_samples = DyadicDecimate(test_buffer_even_len, kEvenBufferLength,
false, // Even sequence.
- test_buffer_out,
- 2);
+ test_buffer_out, 2);
EXPECT_EQ(0u, out_samples);
}
@@ -60,11 +53,9 @@
size_t expected_out_samples =
GetOutLengthToDyadicDecimate(kEvenBufferLength, false);
- size_t out_samples = DyadicDecimate(test_buffer_even_len,
- kEvenBufferLength,
+ size_t out_samples = DyadicDecimate(test_buffer_even_len, kEvenBufferLength,
false, // Even sequence.
- test_buffer_out,
- kOutBufferLength);
+ test_buffer_out, kOutBufferLength);
EXPECT_EQ(expected_out_samples, out_samples);
@@ -77,11 +68,9 @@
size_t expected_out_samples =
GetOutLengthToDyadicDecimate(kEvenBufferLength, true);
- size_t out_samples = DyadicDecimate(test_buffer_even_len,
- kEvenBufferLength,
+ size_t out_samples = DyadicDecimate(test_buffer_even_len, kEvenBufferLength,
true, // Odd sequence.
- test_buffer_out,
- kOutBufferLength);
+ test_buffer_out, kOutBufferLength);
EXPECT_EQ(expected_out_samples, out_samples);
@@ -94,11 +83,9 @@
size_t expected_out_samples =
GetOutLengthToDyadicDecimate(kOddBufferLength, false);
- size_t out_samples = DyadicDecimate(test_buffer_odd_len,
- kOddBufferLength,
+ size_t out_samples = DyadicDecimate(test_buffer_odd_len, kOddBufferLength,
false, // Even sequence.
- test_buffer_out,
- kOutBufferLength);
+ test_buffer_out, kOutBufferLength);
EXPECT_EQ(expected_out_samples, out_samples);
@@ -111,11 +98,9 @@
size_t expected_out_samples =
GetOutLengthToDyadicDecimate(kOddBufferLength, true);
- size_t out_samples = DyadicDecimate(test_buffer_odd_len,
- kOddBufferLength,
+ size_t out_samples = DyadicDecimate(test_buffer_odd_len, kOddBufferLength,
true, // Odd sequence.
- test_buffer_out,
- kOutBufferLength);
+ test_buffer_out, kOutBufferLength);
EXPECT_EQ(expected_out_samples, out_samples);
diff --git a/modules/audio_processing/transient/file_utils_unittest.cc b/modules/audio_processing/transient/file_utils_unittest.cc
index d9880f9..05f8341 100644
--- a/modules/audio_processing/transient/file_utils_unittest.cc
+++ b/modules/audio_processing/transient/file_utils_unittest.cc
@@ -11,8 +11,8 @@
#include "modules/audio_processing/transient/file_utils.h"
#include <string.h>
-#include <string>
#include <memory>
+#include <string>
#include <vector>
#include "rtc_base/system/file_wrapper.h"
@@ -26,18 +26,18 @@
static const uint8_t kEBytesf[4] = {0x54, 0xF8, 0x2D, 0x40};
static const uint8_t kAvogadroBytesf[4] = {0x2F, 0x0C, 0xFF, 0x66};
-static const uint8_t kPiBytes[8] =
- {0x18, 0x2D, 0x44, 0x54, 0xFB, 0x21, 0x09, 0x40};
-static const uint8_t kEBytes[8] =
- {0x69, 0x57, 0x14, 0x8B, 0x0A, 0xBF, 0x05, 0x40};
-static const uint8_t kAvogadroBytes[8] =
- {0xF4, 0xBC, 0xA8, 0xDF, 0x85, 0xE1, 0xDF, 0x44};
+static const uint8_t kPiBytes[8] = {0x18, 0x2D, 0x44, 0x54,
+ 0xFB, 0x21, 0x09, 0x40};
+static const uint8_t kEBytes[8] = {0x69, 0x57, 0x14, 0x8B,
+ 0x0A, 0xBF, 0x05, 0x40};
+static const uint8_t kAvogadroBytes[8] = {0xF4, 0xBC, 0xA8, 0xDF,
+ 0x85, 0xE1, 0xDF, 0x44};
static const double kPi = 3.14159265358979323846;
static const double kE = 2.71828182845904523536;
static const double kAvogadro = 602214100000000000000000.0;
-class TransientFileUtilsTest: public ::testing::Test {
+class TransientFileUtilsTest : public ::testing::Test {
protected:
TransientFileUtilsTest()
: kTestFileName(
@@ -47,12 +47,10 @@
test::ResourcePath("audio_processing/transient/float-utils",
"dat")) {}
- ~TransientFileUtilsTest() override {
- CleanupTempFiles();
- }
+ ~TransientFileUtilsTest() override { CleanupTempFiles(); }
std::string CreateTempFilename(const std::string& dir,
- const std::string& prefix) {
+ const std::string& prefix) {
std::string filename = test::TempFilename(dir, prefix);
temp_filenames_.push_back(filename);
return filename;
@@ -170,9 +168,8 @@
const size_t kBufferLength = 12;
std::unique_ptr<int16_t[]> buffer(new int16_t[kBufferLength]);
- EXPECT_EQ(kBufferLength, ReadInt16BufferFromFile(file.get(),
- kBufferLength,
- buffer.get()));
+ EXPECT_EQ(kBufferLength,
+ ReadInt16BufferFromFile(file.get(), kBufferLength, buffer.get()));
EXPECT_EQ(22377, buffer[4]);
EXPECT_EQ(16389, buffer[7]);
EXPECT_EQ(17631, buffer[kBufferLength - 1]);
@@ -184,9 +181,9 @@
// int16s read.
const size_t kBufferLenghtLargerThanFile = kBufferLength * 2;
buffer.reset(new int16_t[kBufferLenghtLargerThanFile]);
- EXPECT_EQ(kBufferLength, ReadInt16BufferFromFile(file.get(),
- kBufferLenghtLargerThanFile,
- buffer.get()));
+ EXPECT_EQ(kBufferLength,
+ ReadInt16BufferFromFile(file.get(), kBufferLenghtLargerThanFile,
+ buffer.get()));
EXPECT_EQ(11544, buffer[0]);
EXPECT_EQ(22377, buffer[4]);
EXPECT_EQ(16389, buffer[7]);
@@ -211,9 +208,8 @@
const size_t kBufferLength = 12;
std::unique_ptr<float[]> buffer(new float[kBufferLength]);
- EXPECT_EQ(kBufferLength, ReadInt16FromFileToFloatBuffer(file.get(),
- kBufferLength,
- buffer.get()));
+ EXPECT_EQ(kBufferLength, ReadInt16FromFileToFloatBuffer(
+ file.get(), kBufferLength, buffer.get()));
EXPECT_DOUBLE_EQ(11544, buffer[0]);
EXPECT_DOUBLE_EQ(22377, buffer[4]);
@@ -228,9 +224,8 @@
const size_t kBufferLenghtLargerThanFile = kBufferLength * 2;
buffer.reset(new float[kBufferLenghtLargerThanFile]);
EXPECT_EQ(kBufferLength,
- ReadInt16FromFileToFloatBuffer(file.get(),
- kBufferLenghtLargerThanFile,
- buffer.get()));
+ ReadInt16FromFileToFloatBuffer(
+ file.get(), kBufferLenghtLargerThanFile, buffer.get()));
EXPECT_DOUBLE_EQ(11544, buffer[0]);
EXPECT_DOUBLE_EQ(22377, buffer[4]);
EXPECT_DOUBLE_EQ(16389, buffer[7]);
@@ -255,9 +250,8 @@
const size_t kBufferLength = 12;
std::unique_ptr<double[]> buffer(new double[kBufferLength]);
- EXPECT_EQ(kBufferLength, ReadInt16FromFileToDoubleBuffer(file.get(),
- kBufferLength,
- buffer.get()));
+ EXPECT_EQ(kBufferLength, ReadInt16FromFileToDoubleBuffer(
+ file.get(), kBufferLength, buffer.get()));
EXPECT_DOUBLE_EQ(11544, buffer[0]);
EXPECT_DOUBLE_EQ(22377, buffer[4]);
EXPECT_DOUBLE_EQ(16389, buffer[7]);
@@ -271,9 +265,8 @@
const size_t kBufferLenghtLargerThanFile = kBufferLength * 2;
buffer.reset(new double[kBufferLenghtLargerThanFile]);
EXPECT_EQ(kBufferLength,
- ReadInt16FromFileToDoubleBuffer(file.get(),
- kBufferLenghtLargerThanFile,
- buffer.get()));
+ ReadInt16FromFileToDoubleBuffer(
+ file.get(), kBufferLenghtLargerThanFile, buffer.get()));
EXPECT_DOUBLE_EQ(11544, buffer[0]);
EXPECT_DOUBLE_EQ(22377, buffer[4]);
EXPECT_DOUBLE_EQ(16389, buffer[7]);
@@ -297,9 +290,8 @@
const size_t kBufferLength = 3;
std::unique_ptr<float[]> buffer(new float[kBufferLength]);
- EXPECT_EQ(kBufferLength, ReadFloatBufferFromFile(file.get(),
- kBufferLength,
- buffer.get()));
+ EXPECT_EQ(kBufferLength,
+ ReadFloatBufferFromFile(file.get(), kBufferLength, buffer.get()));
EXPECT_FLOAT_EQ(kPi, buffer[0]);
EXPECT_FLOAT_EQ(kE, buffer[1]);
EXPECT_FLOAT_EQ(kAvogadro, buffer[2]);
@@ -311,9 +303,9 @@
// doubles read.
const size_t kBufferLenghtLargerThanFile = kBufferLength * 2;
buffer.reset(new float[kBufferLenghtLargerThanFile]);
- EXPECT_EQ(kBufferLength, ReadFloatBufferFromFile(file.get(),
- kBufferLenghtLargerThanFile,
- buffer.get()));
+ EXPECT_EQ(kBufferLength,
+ ReadFloatBufferFromFile(file.get(), kBufferLenghtLargerThanFile,
+ buffer.get()));
EXPECT_FLOAT_EQ(kPi, buffer[0]);
EXPECT_FLOAT_EQ(kE, buffer[1]);
EXPECT_FLOAT_EQ(kAvogadro, buffer[2]);
@@ -336,9 +328,8 @@
const size_t kBufferLength = 3;
std::unique_ptr<double[]> buffer(new double[kBufferLength]);
- EXPECT_EQ(kBufferLength, ReadDoubleBufferFromFile(file.get(),
- kBufferLength,
- buffer.get()));
+ EXPECT_EQ(kBufferLength,
+ ReadDoubleBufferFromFile(file.get(), kBufferLength, buffer.get()));
EXPECT_DOUBLE_EQ(kPi, buffer[0]);
EXPECT_DOUBLE_EQ(kE, buffer[1]);
EXPECT_DOUBLE_EQ(kAvogadro, buffer[2]);
@@ -350,9 +341,9 @@
// doubles read.
const size_t kBufferLenghtLargerThanFile = kBufferLength * 2;
buffer.reset(new double[kBufferLenghtLargerThanFile]);
- EXPECT_EQ(kBufferLength, ReadDoubleBufferFromFile(file.get(),
- kBufferLenghtLargerThanFile,
- buffer.get()));
+ EXPECT_EQ(kBufferLength,
+ ReadDoubleBufferFromFile(file.get(), kBufferLenghtLargerThanFile,
+ buffer.get()));
EXPECT_DOUBLE_EQ(kPi, buffer[0]);
EXPECT_DOUBLE_EQ(kE, buffer[1]);
EXPECT_DOUBLE_EQ(kAvogadro, buffer[2]);
@@ -366,8 +357,8 @@
TEST_F(TransientFileUtilsTest, MAYBE_WriteInt16BufferToFile) {
std::unique_ptr<FileWrapper> file(FileWrapper::Create());
- std::string kOutFileName = CreateTempFilename(test::OutputPath(),
- "utils_test");
+ std::string kOutFileName =
+ CreateTempFilename(test::OutputPath(), "utils_test");
file->OpenFile(kOutFileName.c_str(), false); // Write mode.
ASSERT_TRUE(file->is_open()) << "File could not be opened:\n"
@@ -381,8 +372,7 @@
written_buffer[1] = 2;
written_buffer[2] = 3;
- EXPECT_EQ(kBufferLength, WriteInt16BufferToFile(file.get(),
- kBufferLength,
+ EXPECT_EQ(kBufferLength, WriteInt16BufferToFile(file.get(), kBufferLength,
written_buffer.get()));
file->CloseFile();
@@ -391,11 +381,9 @@
ASSERT_TRUE(file->is_open()) << "File could not be opened:\n"
<< kOutFileName.c_str();
- EXPECT_EQ(kBufferLength, ReadInt16BufferFromFile(file.get(),
- kBufferLength,
+ EXPECT_EQ(kBufferLength, ReadInt16BufferFromFile(file.get(), kBufferLength,
read_buffer.get()));
- EXPECT_EQ(0, memcmp(written_buffer.get(),
- read_buffer.get(),
+ EXPECT_EQ(0, memcmp(written_buffer.get(), read_buffer.get(),
kBufferLength * sizeof(written_buffer[0])));
}
@@ -407,8 +395,8 @@
TEST_F(TransientFileUtilsTest, MAYBE_WriteFloatBufferToFile) {
std::unique_ptr<FileWrapper> file(FileWrapper::Create());
- std::string kOutFileName = CreateTempFilename(test::OutputPath(),
- "utils_test");
+ std::string kOutFileName =
+ CreateTempFilename(test::OutputPath(), "utils_test");
file->OpenFile(kOutFileName.c_str(), false); // Write mode.
ASSERT_TRUE(file->is_open()) << "File could not be opened:\n"
@@ -422,8 +410,7 @@
written_buffer[1] = static_cast<float>(kE);
written_buffer[2] = static_cast<float>(kAvogadro);
- EXPECT_EQ(kBufferLength, WriteFloatBufferToFile(file.get(),
- kBufferLength,
+ EXPECT_EQ(kBufferLength, WriteFloatBufferToFile(file.get(), kBufferLength,
written_buffer.get()));
file->CloseFile();
@@ -432,11 +419,9 @@
ASSERT_TRUE(file->is_open()) << "File could not be opened:\n"
<< kOutFileName.c_str();
- EXPECT_EQ(kBufferLength, ReadFloatBufferFromFile(file.get(),
- kBufferLength,
+ EXPECT_EQ(kBufferLength, ReadFloatBufferFromFile(file.get(), kBufferLength,
read_buffer.get()));
- EXPECT_EQ(0, memcmp(written_buffer.get(),
- read_buffer.get(),
+ EXPECT_EQ(0, memcmp(written_buffer.get(), read_buffer.get(),
kBufferLength * sizeof(written_buffer[0])));
}
@@ -448,8 +433,8 @@
TEST_F(TransientFileUtilsTest, MAYBE_WriteDoubleBufferToFile) {
std::unique_ptr<FileWrapper> file(FileWrapper::Create());
- std::string kOutFileName = CreateTempFilename(test::OutputPath(),
- "utils_test");
+ std::string kOutFileName =
+ CreateTempFilename(test::OutputPath(), "utils_test");
file->OpenFile(kOutFileName.c_str(), false); // Write mode.
ASSERT_TRUE(file->is_open()) << "File could not be opened:\n"
@@ -463,8 +448,7 @@
written_buffer[1] = kE;
written_buffer[2] = kAvogadro;
- EXPECT_EQ(kBufferLength, WriteDoubleBufferToFile(file.get(),
- kBufferLength,
+ EXPECT_EQ(kBufferLength, WriteDoubleBufferToFile(file.get(), kBufferLength,
written_buffer.get()));
file->CloseFile();
@@ -473,11 +457,9 @@
ASSERT_TRUE(file->is_open()) << "File could not be opened:\n"
<< kOutFileName.c_str();
- EXPECT_EQ(kBufferLength, ReadDoubleBufferFromFile(file.get(),
- kBufferLength,
+ EXPECT_EQ(kBufferLength, ReadDoubleBufferFromFile(file.get(), kBufferLength,
read_buffer.get()));
- EXPECT_EQ(0, memcmp(written_buffer.get(),
- read_buffer.get(),
+ EXPECT_EQ(0, memcmp(written_buffer.get(), read_buffer.get(),
kBufferLength * sizeof(written_buffer[0])));
}
@@ -501,9 +483,8 @@
// Tests with file not opened.
EXPECT_EQ(0u, ReadInt16BufferFromFile(file.get(), 1, int16_buffer.get()));
- EXPECT_EQ(0u, ReadInt16FromFileToDoubleBuffer(file.get(),
- 1,
- double_buffer.get()));
+ EXPECT_EQ(
+ 0u, ReadInt16FromFileToDoubleBuffer(file.get(), 1, double_buffer.get()));
EXPECT_EQ(0u, ReadDoubleBufferFromFile(file.get(), 1, double_buffer.get()));
EXPECT_EQ(0u, WriteInt16BufferToFile(file.get(), 1, int16_buffer.get()));
EXPECT_EQ(0u, WriteDoubleBufferToFile(file.get(), 1, double_buffer.get()));
@@ -518,9 +499,8 @@
EXPECT_EQ(0u, ReadInt16FromFileToDoubleBuffer(NULL, 1, double_buffer.get()));
EXPECT_EQ(0u, ReadInt16FromFileToDoubleBuffer(file.get(), 1, NULL));
- EXPECT_EQ(0u, ReadInt16FromFileToDoubleBuffer(file.get(),
- 0,
- double_buffer.get()));
+ EXPECT_EQ(
+ 0u, ReadInt16FromFileToDoubleBuffer(file.get(), 0, double_buffer.get()));
EXPECT_EQ(0u, ReadDoubleBufferFromFile(NULL, 1, double_buffer.get()));
EXPECT_EQ(0u, ReadDoubleBufferFromFile(file.get(), 1, NULL));
@@ -536,4 +516,3 @@
}
} // namespace webrtc
-
diff --git a/modules/audio_processing/transient/moving_moments.cc b/modules/audio_processing/transient/moving_moments.cc
index 46b16b8..4be4d6a 100644
--- a/modules/audio_processing/transient/moving_moments.cc
+++ b/modules/audio_processing/transient/moving_moments.cc
@@ -18,10 +18,7 @@
namespace webrtc {
MovingMoments::MovingMoments(size_t length)
- : length_(length),
- queue_(),
- sum_(0.0),
- sum_of_squares_(0.0) {
+ : length_(length), queue_(), sum_(0.0), sum_of_squares_(0.0) {
RTC_DCHECK_GT(length, 0);
for (size_t i = 0; i < length; ++i) {
queue_.push(0.0);
@@ -30,8 +27,10 @@
MovingMoments::~MovingMoments() {}
-void MovingMoments::CalculateMoments(const float* in, size_t in_length,
- float* first, float* second) {
+void MovingMoments::CalculateMoments(const float* in,
+ size_t in_length,
+ float* first,
+ float* second) {
RTC_DCHECK(in);
RTC_DCHECK_GT(in_length, 0);
RTC_DCHECK(first);
diff --git a/modules/audio_processing/transient/moving_moments.h b/modules/audio_processing/transient/moving_moments.h
index f1b3e38..6dc0520 100644
--- a/modules/audio_processing/transient/moving_moments.h
+++ b/modules/audio_processing/transient/moving_moments.h
@@ -33,8 +33,10 @@
// Calculates the new values using |in|. Results will be in the out buffers.
// |first| and |second| must be allocated with at least |in_length|.
- void CalculateMoments(const float* in, size_t in_length,
- float* first, float* second);
+ void CalculateMoments(const float* in,
+ size_t in_length,
+ float* first,
+ float* second);
private:
size_t length_;
@@ -48,5 +50,4 @@
} // namespace webrtc
-
#endif // MODULES_AUDIO_PROCESSING_TRANSIENT_MOVING_MOMENTS_H_
diff --git a/modules/audio_processing/transient/moving_moments_unittest.cc b/modules/audio_processing/transient/moving_moments_unittest.cc
index 057bc45..b0e613e 100644
--- a/modules/audio_processing/transient/moving_moments_unittest.cc
+++ b/modules/audio_processing/transient/moving_moments_unittest.cc
@@ -26,7 +26,8 @@
virtual void SetUp();
// Calls CalculateMoments and verifies that it produces the expected
// outputs.
- void CalculateMomentsAndVerify(const float* input, size_t input_length,
+ void CalculateMomentsAndVerify(const float* input,
+ size_t input_length,
const float* expected_mean,
const float* expected_mean_squares);
@@ -42,14 +43,13 @@
}
void MovingMomentsTest::CalculateMomentsAndVerify(
- const float* input, size_t input_length,
+ const float* input,
+ size_t input_length,
const float* expected_mean,
const float* expected_mean_squares) {
ASSERT_LE(input_length, kMaxOutputLength);
- moving_moments_->CalculateMoments(input,
- input_length,
- output_mean_,
+ moving_moments_->CalculateMoments(input, input_length, output_mean_,
output_mean_squares_);
for (size_t i = 1; i < input_length; ++i) {
@@ -73,10 +73,10 @@
const float kInput[] = {5.f, 5.f, 5.f, 5.f, 5.f, 5.f, 5.f, 5.f, 5.f, 5.f};
const size_t kInputLength = sizeof(kInput) / sizeof(kInput[0]);
- const float expected_mean[kInputLength] =
- {1.f, 2.f, 3.f, 4.f, 5.f, 5.f, 5.f, 5.f, 5.f, 5.f};
- const float expected_mean_squares[kInputLength] =
- {5.f, 10.f, 15.f, 20.f, 25.f, 25.f, 25.f, 25.f, 25.f, 25.f};
+ const float expected_mean[kInputLength] = {1.f, 2.f, 3.f, 4.f, 5.f,
+ 5.f, 5.f, 5.f, 5.f, 5.f};
+ const float expected_mean_squares[kInputLength] = {
+ 5.f, 10.f, 15.f, 20.f, 25.f, 25.f, 25.f, 25.f, 25.f, 25.f};
CalculateMomentsAndVerify(kInput, kInputLength, expected_mean,
expected_mean_squares);
@@ -86,24 +86,23 @@
const float kInput[] = {1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f};
const size_t kInputLength = sizeof(kInput) / sizeof(kInput[0]);
- const float expected_mean[kInputLength] =
- {0.2f, 0.6f, 1.2f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f};
- const float expected_mean_squares[kInputLength] =
- {0.2f, 1.f, 2.8f, 6.f, 11.f, 18.f, 27.f, 38.f, 51.f};
+ const float expected_mean[kInputLength] = {0.2f, 0.6f, 1.2f, 2.f, 3.f,
+ 4.f, 5.f, 6.f, 7.f};
+ const float expected_mean_squares[kInputLength] = {
+ 0.2f, 1.f, 2.8f, 6.f, 11.f, 18.f, 27.f, 38.f, 51.f};
CalculateMomentsAndVerify(kInput, kInputLength, expected_mean,
expected_mean_squares);
}
TEST_F(MovingMomentsTest, CorrectMomentsOfADecreasingBuffer) {
- const float kInput[] =
- {-1.f, -2.f, -3.f, -4.f, -5.f, -6.f, -7.f, -8.f, -9.f};
+ const float kInput[] = {-1.f, -2.f, -3.f, -4.f, -5.f, -6.f, -7.f, -8.f, -9.f};
const size_t kInputLength = sizeof(kInput) / sizeof(kInput[0]);
- const float expected_mean[kInputLength] =
- {-0.2f, -0.6f, -1.2f, -2.f, -3.f, -4.f, -5.f, -6.f, -7.f};
- const float expected_mean_squares[kInputLength] =
- {0.2f, 1.f, 2.8f, 6.f, 11.f, 18.f, 27.f, 38.f, 51.f};
+ const float expected_mean[kInputLength] = {-0.2f, -0.6f, -1.2f, -2.f, -3.f,
+ -4.f, -5.f, -6.f, -7.f};
+ const float expected_mean_squares[kInputLength] = {
+ 0.2f, 1.f, 2.8f, 6.f, 11.f, 18.f, 27.f, 38.f, 51.f};
CalculateMomentsAndVerify(kInput, kInputLength, expected_mean,
expected_mean_squares);
@@ -112,76 +111,78 @@
TEST_F(MovingMomentsTest, CorrectMomentsOfAZeroMeanSequence) {
const size_t kMovingMomentsBufferLength = 4;
moving_moments_.reset(new MovingMoments(kMovingMomentsBufferLength));
- const float kInput[] =
- {1.f, -1.f, 1.f, -1.f, 1.f, -1.f, 1.f, -1.f, 1.f, -1.f};
+ const float kInput[] = {1.f, -1.f, 1.f, -1.f, 1.f,
+ -1.f, 1.f, -1.f, 1.f, -1.f};
const size_t kInputLength = sizeof(kInput) / sizeof(kInput[0]);
- const float expected_mean[kInputLength] =
- {0.25f, 0.f, 0.25f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f};
- const float expected_mean_squares[kInputLength] =
- {0.25f, 0.5f, 0.75f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f};
+ const float expected_mean[kInputLength] = {0.25f, 0.f, 0.25f, 0.f, 0.f,
+ 0.f, 0.f, 0.f, 0.f, 0.f};
+ const float expected_mean_squares[kInputLength] = {
+ 0.25f, 0.5f, 0.75f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f};
CalculateMomentsAndVerify(kInput, kInputLength, expected_mean,
expected_mean_squares);
}
TEST_F(MovingMomentsTest, CorrectMomentsOfAnArbitraryBuffer) {
- const float kInput[] =
- {0.2f, 0.3f, 0.5f, 0.7f, 0.11f, 0.13f, 0.17f, 0.19f, 0.23f};
+ const float kInput[] = {0.2f, 0.3f, 0.5f, 0.7f, 0.11f,
+ 0.13f, 0.17f, 0.19f, 0.23f};
const size_t kInputLength = sizeof(kInput) / sizeof(kInput[0]);
- const float expected_mean[kInputLength] =
- {0.04f, 0.1f, 0.2f, 0.34f, 0.362f, 0.348f, 0.322f, 0.26f, 0.166f};
- const float expected_mean_squares[kInputLength] =
- {0.008f, 0.026f, 0.076f, 0.174f, 0.1764f, 0.1718f, 0.1596f, 0.1168f,
- 0.0294f};
+ const float expected_mean[kInputLength] = {
+ 0.04f, 0.1f, 0.2f, 0.34f, 0.362f, 0.348f, 0.322f, 0.26f, 0.166f};
+ const float expected_mean_squares[kInputLength] = {0.008f, 0.026f, 0.076f,
+ 0.174f, 0.1764f, 0.1718f,
+ 0.1596f, 0.1168f, 0.0294f};
CalculateMomentsAndVerify(kInput, kInputLength, expected_mean,
expected_mean_squares);
}
TEST_F(MovingMomentsTest, MutipleCalculateMomentsCalls) {
- const float kInputFirstCall[] =
- {0.2f, 0.3f, 0.5f, 0.7f, 0.11f, 0.13f, 0.17f, 0.19f, 0.23f};
- const size_t kInputFirstCallLength = sizeof(kInputFirstCall) /
- sizeof(kInputFirstCall[0]);
+ const float kInputFirstCall[] = {0.2f, 0.3f, 0.5f, 0.7f, 0.11f,
+ 0.13f, 0.17f, 0.19f, 0.23f};
+ const size_t kInputFirstCallLength =
+ sizeof(kInputFirstCall) / sizeof(kInputFirstCall[0]);
const float kInputSecondCall[] = {0.29f, 0.31f};
- const size_t kInputSecondCallLength = sizeof(kInputSecondCall) /
- sizeof(kInputSecondCall[0]);
+ const size_t kInputSecondCallLength =
+ sizeof(kInputSecondCall) / sizeof(kInputSecondCall[0]);
const float kInputThirdCall[] = {0.37f, 0.41f, 0.43f, 0.47f};
- const size_t kInputThirdCallLength = sizeof(kInputThirdCall) /
- sizeof(kInputThirdCall[0]);
+ const size_t kInputThirdCallLength =
+ sizeof(kInputThirdCall) / sizeof(kInputThirdCall[0]);
- const float expected_mean_first_call[kInputFirstCallLength] =
- {0.04f, 0.1f, 0.2f, 0.34f, 0.362f, 0.348f, 0.322f, 0.26f, 0.166f};
- const float expected_mean_squares_first_call[kInputFirstCallLength] =
- {0.008f, 0.026f, 0.076f, 0.174f, 0.1764f, 0.1718f, 0.1596f, 0.1168f,
- 0.0294f};
+ const float expected_mean_first_call[kInputFirstCallLength] = {
+ 0.04f, 0.1f, 0.2f, 0.34f, 0.362f, 0.348f, 0.322f, 0.26f, 0.166f};
+ const float expected_mean_squares_first_call[kInputFirstCallLength] = {
+ 0.008f, 0.026f, 0.076f, 0.174f, 0.1764f,
+ 0.1718f, 0.1596f, 0.1168f, 0.0294f};
- const float expected_mean_second_call[kInputSecondCallLength] =
- {0.202f, 0.238f};
- const float expected_mean_squares_second_call[kInputSecondCallLength] =
- {0.0438f, 0.0596f};
+ const float expected_mean_second_call[kInputSecondCallLength] = {0.202f,
+ 0.238f};
+ const float expected_mean_squares_second_call[kInputSecondCallLength] = {
+ 0.0438f, 0.0596f};
- const float expected_mean_third_call[kInputThirdCallLength] =
- {0.278f, 0.322f, 0.362f, 0.398f};
- const float expected_mean_squares_third_call[kInputThirdCallLength] =
- {0.0812f, 0.1076f, 0.134f, 0.1614f};
+ const float expected_mean_third_call[kInputThirdCallLength] = {
+ 0.278f, 0.322f, 0.362f, 0.398f};
+ const float expected_mean_squares_third_call[kInputThirdCallLength] = {
+ 0.0812f, 0.1076f, 0.134f, 0.1614f};
CalculateMomentsAndVerify(kInputFirstCall, kInputFirstCallLength,
- expected_mean_first_call, expected_mean_squares_first_call);
+ expected_mean_first_call,
+ expected_mean_squares_first_call);
CalculateMomentsAndVerify(kInputSecondCall, kInputSecondCallLength,
- expected_mean_second_call, expected_mean_squares_second_call);
+ expected_mean_second_call,
+ expected_mean_squares_second_call);
CalculateMomentsAndVerify(kInputThirdCall, kInputThirdCallLength,
- expected_mean_third_call, expected_mean_squares_third_call);
+ expected_mean_third_call,
+ expected_mean_squares_third_call);
}
-TEST_F(MovingMomentsTest,
- VerifySampleBasedVsBlockBasedCalculation) {
- const float kInput[] =
- {0.2f, 0.3f, 0.5f, 0.7f, 0.11f, 0.13f, 0.17f, 0.19f, 0.23f};
+TEST_F(MovingMomentsTest, VerifySampleBasedVsBlockBasedCalculation) {
+ const float kInput[] = {0.2f, 0.3f, 0.5f, 0.7f, 0.11f,
+ 0.13f, 0.17f, 0.19f, 0.23f};
const size_t kInputLength = sizeof(kInput) / sizeof(kInput[0]);
float output_mean_block_based[kInputLength];
@@ -190,17 +191,16 @@
float output_mean_sample_based;
float output_mean_squares_sample_based;
- moving_moments_->CalculateMoments(
- kInput, kInputLength, output_mean_block_based,
- output_mean_squares_block_based);
+ moving_moments_->CalculateMoments(kInput, kInputLength,
+ output_mean_block_based,
+ output_mean_squares_block_based);
moving_moments_.reset(new MovingMoments(kMovingMomentsBufferLength));
for (size_t i = 0; i < kInputLength; ++i) {
- moving_moments_->CalculateMoments(
- &kInput[i], 1, &output_mean_sample_based,
- &output_mean_squares_sample_based);
+ moving_moments_->CalculateMoments(&kInput[i], 1, &output_mean_sample_based,
+ &output_mean_squares_sample_based);
EXPECT_FLOAT_EQ(output_mean_block_based[i], output_mean_sample_based);
EXPECT_FLOAT_EQ(output_mean_squares_block_based[i],
- output_mean_squares_sample_based);
+ output_mean_squares_sample_based);
}
}
diff --git a/modules/audio_processing/transient/transient_detector.cc b/modules/audio_processing/transient/transient_detector.cc
index 1bb6f9f..c3bf282 100644
--- a/modules/audio_processing/transient/transient_detector.cc
+++ b/modules/audio_processing/transient/transient_detector.cc
@@ -51,8 +51,7 @@
wpd_tree_.reset(new WPDTree(samples_per_chunk_,
kDaubechies8HighPassCoefficients,
kDaubechies8LowPassCoefficients,
- kDaubechies8CoefficientsLength,
- kLevels));
+ kDaubechies8CoefficientsLength, kLevels));
for (size_t i = 0; i < kLeaves; ++i) {
moving_moments_[i].reset(
new MovingMoments(samples_per_transient / kLeaves));
@@ -86,8 +85,7 @@
for (size_t i = 0; i < kLeaves; ++i) {
WPDNode* leaf = wpd_tree_->NodeAt(kLevels, i);
- moving_moments_[i]->CalculateMoments(leaf->data(),
- tree_leaves_data_length_,
+ moving_moments_[i]->CalculateMoments(leaf->data(), tree_leaves_data_length_,
first_moments_.get(),
second_moments_.get());
@@ -127,8 +125,9 @@
const float kVerticalScaling = 0.5f;
const float kVerticalShift = 1.f;
- result = (cos(result * horizontal_scaling + kHorizontalShift)
- + kVerticalShift) * kVerticalScaling;
+ result =
+ (cos(result * horizontal_scaling + kHorizontalShift) + kVerticalShift) *
+ kVerticalScaling;
result *= result;
}
diff --git a/modules/audio_processing/transient/transient_detector_unittest.cc b/modules/audio_processing/transient/transient_detector_unittest.cc
index 8f60954..69a669f 100644
--- a/modules/audio_processing/transient/transient_detector_unittest.cc
+++ b/modules/audio_processing/transient/transient_detector_unittest.cc
@@ -23,8 +23,7 @@
namespace webrtc {
-static const int kSampleRatesHz[] = {ts::kSampleRate8kHz,
- ts::kSampleRate16kHz,
+static const int kSampleRatesHz[] = {ts::kSampleRate8kHz, ts::kSampleRate16kHz,
ts::kSampleRate32kHz,
ts::kSampleRate48kHz};
static const size_t kNumberOfSampleRates =
@@ -57,7 +56,7 @@
bool file_opened = detect_file->is_open();
ASSERT_TRUE(file_opened) << "File could not be opened.\n"
- << detect_file_name.str().c_str();
+ << detect_file_name.str().c_str();
// Prepare audio file.
std::stringstream audio_file_name;
@@ -80,8 +79,7 @@
size_t frames_read = 0;
- while (ReadInt16FromFileToFloatBuffer(audio_file.get(),
- buffer_length,
+ while (ReadInt16FromFileToFloatBuffer(audio_file.get(), buffer_length,
buffer.get()) == buffer_length) {
++frames_read;
@@ -92,8 +90,8 @@
<< "Detect test file is malformed.\n";
// Compare results with data from the matlab test file.
- EXPECT_NEAR(file_value, detector_value, kTolerance) << "Frame: "
- << frames_read;
+ EXPECT_NEAR(file_value, detector_value, kTolerance)
+ << "Frame: " << frames_read;
}
detect_file->CloseFile();
diff --git a/modules/audio_processing/transient/transient_suppression_test.cc b/modules/audio_processing/transient/transient_suppression_test.cc
index 8512e01..00e1989 100644
--- a/modules/audio_processing/transient/transient_suppression_test.cc
+++ b/modules/audio_processing/transient/transient_suppression_test.cc
@@ -10,8 +10,8 @@
#include "modules/audio_processing/transient/transient_suppressor.h"
-#include <stdlib.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <memory>
@@ -36,9 +36,7 @@
10,
"Time between each chunk of samples in milliseconds.");
-DEFINE_int(sample_rate_hz,
- 16000,
- "Sampling frequency of the signal in Hertz.");
+DEFINE_int(sample_rate_hz, 16000, "Sampling frequency of the signal in Hertz.");
DEFINE_int(detection_rate_hz,
0,
"Sampling frequency of the detection signal in Hertz.");
@@ -79,9 +77,7 @@
tmpbuf.reset(new int16_t[num_channels * audio_buffer_size]);
read_ptr = tmpbuf.get();
}
- if (fread(read_ptr,
- sizeof(*read_ptr),
- num_channels * audio_buffer_size,
+ if (fread(read_ptr, sizeof(*read_ptr), num_channels * audio_buffer_size,
in_file) != num_channels * audio_buffer_size) {
return false;
}
@@ -104,8 +100,8 @@
}
if (reference_file) {
std::unique_ptr<int16_t[]> ibuf(new int16_t[audio_buffer_size]);
- if (fread(ibuf.get(), sizeof(ibuf[0]), audio_buffer_size, reference_file)
- != audio_buffer_size)
+ if (fread(ibuf.get(), sizeof(ibuf[0]), audio_buffer_size, reference_file) !=
+ audio_buffer_size)
return false;
S16ToFloat(ibuf.get(), audio_buffer_size, reference_buffer);
}
@@ -163,8 +159,8 @@
Agc agc;
TransientSuppressor suppressor;
- suppressor.Initialize(
- FLAG_sample_rate_hz, detection_rate_hz, FLAG_num_channels);
+ suppressor.Initialize(FLAG_sample_rate_hz, detection_rate_hz,
+ FLAG_num_channels);
const size_t audio_buffer_size =
FLAG_chunk_size_ms * FLAG_sample_rate_hz / 1000;
@@ -184,38 +180,27 @@
if (reference_file)
reference_buffer.reset(new float[audio_buffer_size]);
- while (ReadBuffers(in_file,
- audio_buffer_size,
- FLAG_num_channels,
- audio_buffer_i.get(),
- detection_file,
- detection_buffer_size,
- detection_buffer.get(),
- reference_file,
- reference_buffer.get())) {
- agc.Process(audio_buffer_i.get(),
- static_cast<int>(audio_buffer_size),
+ while (ReadBuffers(in_file, audio_buffer_size, FLAG_num_channels,
+ audio_buffer_i.get(), detection_file,
+ detection_buffer_size, detection_buffer.get(),
+ reference_file, reference_buffer.get())) {
+ agc.Process(audio_buffer_i.get(), static_cast<int>(audio_buffer_size),
FLAG_sample_rate_hz);
for (size_t i = 0; i < FLAG_num_channels * audio_buffer_size; ++i) {
audio_buffer_f[i] = audio_buffer_i[i];
}
- ASSERT_EQ(0,
- suppressor.Suppress(audio_buffer_f.get(),
- audio_buffer_size,
- FLAG_num_channels,
- detection_buffer.get(),
- detection_buffer_size,
- reference_buffer.get(),
- audio_buffer_size,
- agc.voice_probability(),
- true))
+ ASSERT_EQ(0, suppressor.Suppress(audio_buffer_f.get(), audio_buffer_size,
+ FLAG_num_channels, detection_buffer.get(),
+ detection_buffer_size,
+ reference_buffer.get(), audio_buffer_size,
+ agc.voice_probability(), true))
<< "The transient suppressor could not suppress the frame";
// Write result to out file.
- WritePCM(
- out_file, audio_buffer_size, FLAG_num_channels, audio_buffer_f.get());
+ WritePCM(out_file, audio_buffer_size, FLAG_num_channels,
+ audio_buffer_f.get());
}
fclose(in_file);
@@ -231,8 +216,8 @@
} // namespace webrtc
int main(int argc, char* argv[]) {
- if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) ||
- FLAG_help || argc != 1) {
+ if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || FLAG_help ||
+ argc != 1) {
printf("%s", webrtc::kUsage);
if (FLAG_help) {
rtc::FlagList::Print(nullptr, false);
diff --git a/modules/audio_processing/transient/transient_suppressor.cc b/modules/audio_processing/transient/transient_suppressor.cc
index 9bbd7d9..28eb666 100644
--- a/modules/audio_processing/transient/transient_suppressor.cc
+++ b/modules/audio_processing/transient/transient_suppressor.cc
@@ -60,8 +60,7 @@
use_hard_restoration_(false),
chunks_since_voice_change_(0),
seed_(182),
- using_reference_(false) {
-}
+ using_reference_(false) {}
TransientSuppressor::~TransientSuppressor() {}
@@ -110,17 +109,14 @@
RTC_DCHECK_GE(complex_analysis_length_, kMaxVoiceBin);
num_channels_ = num_channels;
in_buffer_.reset(new float[analysis_length_ * num_channels_]);
- memset(in_buffer_.get(),
- 0,
+ memset(in_buffer_.get(), 0,
analysis_length_ * num_channels_ * sizeof(in_buffer_[0]));
detection_length_ = detection_rate_hz * ts::kChunkSizeMs / 1000;
detection_buffer_.reset(new float[detection_length_]);
- memset(detection_buffer_.get(),
- 0,
+ memset(detection_buffer_.get(), 0,
detection_length_ * sizeof(detection_buffer_[0]));
out_buffer_.reset(new float[analysis_length_ * num_channels_]);
- memset(out_buffer_.get(),
- 0,
+ memset(out_buffer_.get(), 0,
analysis_length_ * num_channels_ * sizeof(out_buffer_[0]));
// ip[0] must be zero to trigger initialization using rdft().
size_t ip_length = 2 + sqrtf(analysis_length_);
@@ -129,14 +125,12 @@
wfft_.reset(new float[complex_analysis_length_ - 1]);
memset(wfft_.get(), 0, (complex_analysis_length_ - 1) * sizeof(wfft_[0]));
spectral_mean_.reset(new float[complex_analysis_length_ * num_channels_]);
- memset(spectral_mean_.get(),
- 0,
+ memset(spectral_mean_.get(), 0,
complex_analysis_length_ * num_channels_ * sizeof(spectral_mean_[0]));
fft_buffer_.reset(new float[analysis_length_ + 2]);
memset(fft_buffer_.get(), 0, (analysis_length_ + 2) * sizeof(fft_buffer_[0]));
magnitudes_.reset(new float[complex_analysis_length_]);
- memset(magnitudes_.get(),
- 0,
+ memset(magnitudes_.get(), 0,
complex_analysis_length_ * sizeof(magnitudes_[0]));
mean_factor_.reset(new float[complex_analysis_length_]);
@@ -190,8 +184,8 @@
detection_data = &in_buffer_[buffer_delay_];
}
- float detector_result = detector_->Detect(
- detection_data, detection_length, reference_data, reference_length);
+ float detector_result = detector_->Detect(detection_data, detection_length,
+ reference_data, reference_length);
if (detector_result < 0) {
return -1;
}
@@ -247,8 +241,8 @@
fft_buffer_[1] = 0.f;
for (size_t i = 0; i < complex_analysis_length_; ++i) {
- magnitudes_[i] = ComplexMagnitude(fft_buffer_[i * 2],
- fft_buffer_[i * 2 + 1]);
+ magnitudes_[i] =
+ ComplexMagnitude(fft_buffer_[i * 2], fft_buffer_[i * 2 + 1]);
}
// Restore audio if necessary.
if (suppression_enabled_) {
@@ -269,11 +263,7 @@
// Put R[n/2] back in fft_buffer_[1].
fft_buffer_[1] = fft_buffer_[analysis_length_];
- WebRtc_rdft(analysis_length_,
- -1,
- fft_buffer_.get(),
- ip_.get(),
- wfft_.get());
+ WebRtc_rdft(analysis_length_, -1, fft_buffer_.get(), ip_.get(), wfft_.get());
const float fft_scaling = 2.f / analysis_length_;
for (size_t i = 0; i < analysis_length_; ++i) {
@@ -301,8 +291,7 @@
keypress_counter_ = 0;
}
- if (detection_enabled_ &&
- ++chunks_since_keypress_ > kChunksUntilNotTyping) {
+ if (detection_enabled_ && ++chunks_since_keypress_ > kChunksUntilNotTyping) {
if (suppression_enabled_) {
RTC_LOG(LS_INFO) << "[ts] Transient suppression is now disabled.";
}
@@ -337,26 +326,22 @@
// |detection_enabled_| is updated by UpdateKeypress().
void TransientSuppressor::UpdateBuffers(float* data) {
// TODO(aluebs): Change to ring buffer.
- memmove(in_buffer_.get(),
- &in_buffer_[data_length_],
+ memmove(in_buffer_.get(), &in_buffer_[data_length_],
(buffer_delay_ + (num_channels_ - 1) * analysis_length_) *
sizeof(in_buffer_[0]));
// Copy new chunk to buffer.
for (int i = 0; i < num_channels_; ++i) {
memcpy(&in_buffer_[buffer_delay_ + i * analysis_length_],
- &data[i * data_length_],
- data_length_ * sizeof(*data));
+ &data[i * data_length_], data_length_ * sizeof(*data));
}
if (detection_enabled_) {
// Shift previous chunk in out buffer.
- memmove(out_buffer_.get(),
- &out_buffer_[data_length_],
+ memmove(out_buffer_.get(), &out_buffer_[data_length_],
(buffer_delay_ + (num_channels_ - 1) * analysis_length_) *
sizeof(out_buffer_[0]));
// Initialize new chunk in out buffer.
for (int i = 0; i < num_channels_; ++i) {
- memset(&out_buffer_[buffer_delay_ + i * analysis_length_],
- 0,
+ memset(&out_buffer_[buffer_delay_ + i * analysis_length_], 0,
data_length_ * sizeof(out_buffer_[0]));
}
}
@@ -375,7 +360,7 @@
if (magnitudes_[i] > spectral_mean[i] && magnitudes_[i] > 0) {
// RandU() generates values on [0, int16::max()]
const float phase = 2 * ts::kPi * WebRtcSpl_RandU(&seed_) /
- std::numeric_limits<int16_t>::max();
+ std::numeric_limits<int16_t>::max();
const float scaled_mean = detector_result * spectral_mean[i];
fft_buffer_[i * 2] = (1 - detector_result) * fft_buffer_[i * 2] +
diff --git a/modules/audio_processing/transient/wpd_node.cc b/modules/audio_processing/transient/wpd_node.cc
index 20d6a90..2e0ee7e 100644
--- a/modules/audio_processing/transient/wpd_node.cc
+++ b/modules/audio_processing/transient/wpd_node.cc
@@ -23,13 +23,12 @@
WPDNode::WPDNode(size_t length,
const float* coefficients,
size_t coefficients_length)
- : // The data buffer has parent data length to be able to contain and filter
- // it.
+ : // The data buffer has parent data length to be able to contain and
+ // filter it.
data_(new float[2 * length + 1]),
length_(length),
- filter_(CreateFirFilter(coefficients,
- coefficients_length,
- 2 * length + 1)) {
+ filter_(
+ CreateFirFilter(coefficients, coefficients_length, 2 * length + 1)) {
RTC_DCHECK_GT(length, 0);
RTC_DCHECK(coefficients);
RTC_DCHECK_GT(coefficients_length, 0);
@@ -48,8 +47,8 @@
// Decimate data.
const bool kOddSequence = true;
- size_t output_samples = DyadicDecimate(
- data_.get(), parent_data_length, kOddSequence, data_.get(), length_);
+ size_t output_samples = DyadicDecimate(data_.get(), parent_data_length,
+ kOddSequence, data_.get(), length_);
if (output_samples != length_) {
return -1;
}
diff --git a/modules/audio_processing/transient/wpd_node_unittest.cc b/modules/audio_processing/transient/wpd_node_unittest.cc
index 1929361..5f92382 100644
--- a/modules/audio_processing/transient/wpd_node_unittest.cc
+++ b/modules/audio_processing/transient/wpd_node_unittest.cc
@@ -20,18 +20,17 @@
static const float kTolerance = 0.0001f;
static const size_t kParentDataLength = kDataLength * 2;
-static const float kParentData[kParentDataLength] =
- {1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f, 10.f};
+static const float kParentData[kParentDataLength] = {1.f, 2.f, 3.f, 4.f, 5.f,
+ 6.f, 7.f, 8.f, 9.f, 10.f};
static const float kCoefficients[] = {0.2f, -0.3f, 0.5f, -0.7f, 0.11f};
-static const size_t kCoefficientsLength = sizeof(kCoefficients) /
- sizeof(kCoefficients[0]);
+static const size_t kCoefficientsLength =
+ sizeof(kCoefficients) / sizeof(kCoefficients[0]);
TEST(WPDNodeTest, Accessors) {
WPDNode node(kDataLength, kCoefficients, kCoefficientsLength);
EXPECT_EQ(0, node.set_data(kParentData, kDataLength));
- EXPECT_EQ(0, memcmp(node.data(),
- kParentData,
+ EXPECT_EQ(0, memcmp(node.data(), kParentData,
kDataLength * sizeof(node.data()[0])));
}
diff --git a/modules/audio_processing/transient/wpd_tree.cc b/modules/audio_processing/transient/wpd_tree.cc
index a01b816..72f4d76 100644
--- a/modules/audio_processing/transient/wpd_tree.cc
+++ b/modules/audio_processing/transient/wpd_tree.cc
@@ -19,8 +19,10 @@
namespace webrtc {
-WPDTree::WPDTree(size_t data_length, const float* high_pass_coefficients,
- const float* low_pass_coefficients, size_t coefficients_length,
+WPDTree::WPDTree(size_t data_length,
+ const float* high_pass_coefficients,
+ const float* low_pass_coefficients,
+ size_t coefficients_length,
int levels)
: data_length_(data_length),
levels_(levels),
@@ -98,8 +100,8 @@
index_left_child = index * 2;
index_right_child = index_left_child + 1;
- update_result = nodes_[index_left_child]->Update(
- nodes_[index]->data(), nodes_[index]->length());
+ update_result = nodes_[index_left_child]->Update(nodes_[index]->data(),
+ nodes_[index]->length());
if (update_result != 0) {
return -1;
}
diff --git a/modules/audio_processing/transient/wpd_tree.h b/modules/audio_processing/transient/wpd_tree.h
index 53fc06b2..707a89d 100644
--- a/modules/audio_processing/transient/wpd_tree.h
+++ b/modules/audio_processing/transient/wpd_tree.h
@@ -47,9 +47,7 @@
~WPDTree();
// Returns the number of nodes at any given level.
- static int NumberOfNodesAtLevel(int level) {
- return 1 << level;
- }
+ static int NumberOfNodesAtLevel(int level) { return 1 << level; }
// Returns a pointer to the node at the given level and index(of that level).
// Level goes from 0 to levels().
diff --git a/modules/audio_processing/transient/wpd_tree_unittest.cc b/modules/audio_processing/transient/wpd_tree_unittest.cc
index 02c7f51..88f0739 100644
--- a/modules/audio_processing/transient/wpd_tree_unittest.cc
+++ b/modules/audio_processing/transient/wpd_tree_unittest.cc
@@ -30,13 +30,10 @@
float test_buffer[kTestBufferSize];
memset(test_buffer, 0.f, kTestBufferSize * sizeof(*test_buffer));
float test_coefficients[] = {1.f, 2.f, 3.f, 4.f, 5.f};
- const size_t kTestCoefficientsLength = sizeof(test_coefficients) /
- sizeof(test_coefficients[0]);
- WPDTree tree(kTestBufferSize,
- test_coefficients,
- test_coefficients,
- kTestCoefficientsLength,
- kLevels);
+ const size_t kTestCoefficientsLength =
+ sizeof(test_coefficients) / sizeof(test_coefficients[0]);
+ WPDTree tree(kTestBufferSize, test_coefficients, test_coefficients,
+ kTestCoefficientsLength, kLevels);
ASSERT_EQ(kExpectedNumberOfNodes, tree.num_nodes());
// Checks for NodeAt(level, index).
int nodes_at_level = 0;
@@ -79,10 +76,8 @@
const int kLeaves = 1 << kLevels;
const size_t kLeavesSamples = kTestBufferSize >> kLevels;
// Create tree with Discrete Meyer Wavelet Coefficients.
- WPDTree tree(kTestBufferSize,
- kDaubechies8HighPassCoefficients,
- kDaubechies8LowPassCoefficients,
- kDaubechies8CoefficientsLength,
+ WPDTree tree(kTestBufferSize, kDaubechies8HighPassCoefficients,
+ kDaubechies8LowPassCoefficients, kDaubechies8CoefficientsLength,
kLevels);
// Allocate and open all matlab and out files.
std::unique_ptr<FileWrapper> matlab_files_data[kLeaves];
@@ -134,9 +129,8 @@
size_t frames_read = 0;
// Read first buffer from the PCM test file.
- size_t file_samples_read = ReadInt16FromFileToFloatBuffer(test_file.get(),
- kTestBufferSize,
- test_buffer);
+ size_t file_samples_read = ReadInt16FromFileToFloatBuffer(
+ test_file.get(), kTestBufferSize, test_buffer);
while (file_samples_read > 0 && frames_read < kMaxFramesToTest) {
++frames_read;
@@ -152,10 +146,8 @@
// Compare results with data from the matlab test files.
for (int i = 0; i < kLeaves; ++i) {
// Compare data values
- size_t matlab_samples_read =
- ReadDoubleBufferFromFile(matlab_files_data[i].get(),
- kLeavesSamples,
- matlab_buffer);
+ size_t matlab_samples_read = ReadDoubleBufferFromFile(
+ matlab_files_data[i].get(), kLeavesSamples, matlab_buffer);
ASSERT_EQ(kLeavesSamples, matlab_samples_read)
<< "Matlab test files are malformed.\n"
@@ -170,15 +162,13 @@
}
// Write results to out files.
- WriteFloatBufferToFile(out_files_data[i].get(),
- kLeavesSamples,
+ WriteFloatBufferToFile(out_files_data[i].get(), kLeavesSamples,
node_data);
}
// Read next buffer from the PCM test file.
- file_samples_read = ReadInt16FromFileToFloatBuffer(test_file.get(),
- kTestBufferSize,
- test_buffer);
+ file_samples_read = ReadInt16FromFileToFloatBuffer(
+ test_file.get(), kTestBufferSize, test_buffer);
}
// Close all matlab and out files.
diff --git a/modules/audio_processing/typing_detection.cc b/modules/audio_processing/typing_detection.cc
index 6e18124..e725b26 100644
--- a/modules/audio_processing/typing_detection.cc
+++ b/modules/audio_processing/typing_detection.cc
@@ -24,8 +24,7 @@
reporting_threshold_(300),
penalty_decay_(1),
type_event_delay_(2),
- report_detection_update_period_(1) {
-}
+ report_detection_update_period_(1) {}
TypingDetection::~TypingDetection() {}
@@ -41,8 +40,7 @@
else
++time_since_last_typing_;
- if (time_since_last_typing_ < type_event_delay_ &&
- vad_activity &&
+ if (time_since_last_typing_ < type_event_delay_ && vad_activity &&
time_active_ < time_window_) {
penalty_counter_ += cost_per_typing_;
if (penalty_counter_ > reporting_threshold_)
@@ -73,15 +71,20 @@
int penalty_decay,
int type_event_delay,
int report_detection_update_period) {
- if (time_window) time_window_ = time_window;
+ if (time_window)
+ time_window_ = time_window;
- if (cost_per_typing) cost_per_typing_ = cost_per_typing;
+ if (cost_per_typing)
+ cost_per_typing_ = cost_per_typing;
- if (reporting_threshold) reporting_threshold_ = reporting_threshold;
+ if (reporting_threshold)
+ reporting_threshold_ = reporting_threshold;
- if (penalty_decay) penalty_decay_ = penalty_decay;
+ if (penalty_decay)
+ penalty_decay_ = penalty_decay;
- if (type_event_delay) type_event_delay_ = type_event_delay;
+ if (type_event_delay)
+ type_event_delay_ = type_event_delay;
if (report_detection_update_period)
report_detection_update_period_ = report_detection_update_period;
diff --git a/modules/audio_processing/utility/block_mean_calculator.cc b/modules/audio_processing/utility/block_mean_calculator.cc
index 3d76692..82c1c0f 100644
--- a/modules/audio_processing/utility/block_mean_calculator.cc
+++ b/modules/audio_processing/utility/block_mean_calculator.cc
@@ -15,10 +15,7 @@
namespace webrtc {
BlockMeanCalculator::BlockMeanCalculator(size_t block_length)
- : block_length_(block_length),
- count_(0),
- sum_(0.0),
- mean_(0.0) {
+ : block_length_(block_length), count_(0), sum_(0.0), mean_(0.0) {
RTC_DCHECK(block_length_ != 0);
}
diff --git a/modules/audio_processing/utility/delay_estimator.cc b/modules/audio_processing/utility/delay_estimator.cc
index 871b541..a15b914 100644
--- a/modules/audio_processing/utility/delay_estimator.cc
+++ b/modules/audio_processing/utility/delay_estimator.cc
@@ -21,9 +21,9 @@
static const int kShiftsAtZero = 13; // Right shifts at zero binary spectrum.
static const int kShiftsLinearSlope = 3;
-static const int32_t kProbabilityOffset = 1024; // 2 in Q9.
+static const int32_t kProbabilityOffset = 1024; // 2 in Q9.
static const int32_t kProbabilityLowerLimit = 8704; // 17 in Q9.
-static const int32_t kProbabilityMinSpread = 2816; // 5.5 in Q9.
+static const int32_t kProbabilityMinSpread = 2816; // 5.5 in Q9.
// Robust validation settings
static const float kHistogramMax = 3000.f;
@@ -39,13 +39,13 @@
// Counts and returns number of bits of a 32-bit word.
static int BitCount(uint32_t u32) {
- uint32_t tmp = u32 - ((u32 >> 1) & 033333333333) -
- ((u32 >> 2) & 011111111111);
+ uint32_t tmp =
+ u32 - ((u32 >> 1) & 033333333333) - ((u32 >> 2) & 011111111111);
tmp = ((tmp + (tmp >> 3)) & 030707070707);
tmp = (tmp + (tmp >> 6));
tmp = (tmp + (tmp >> 12) + (tmp >> 24)) & 077;
- return ((int) tmp);
+ return ((int)tmp);
}
// Compares the |binary_vector| with all rows of the |binary_matrix| and counts
@@ -69,7 +69,7 @@
// Compare |binary_vector| with all rows of the |binary_matrix|
for (; n < matrix_size; n++) {
- bit_counts[n] = (int32_t) BitCount(binary_vector ^ binary_matrix[n]);
+ bit_counts[n] = (int32_t)BitCount(binary_vector ^ binary_matrix[n]);
}
}
@@ -96,8 +96,9 @@
int32_t valley_level_q14) {
const float valley_depth = valley_depth_q14 * kQ14Scaling;
float decrease_in_last_set = valley_depth;
- const int max_hits_for_slow_change = (candidate_delay < self->last_delay) ?
- kMaxHitsWhenPossiblyNonCausal : kMaxHitsWhenPossiblyCausal;
+ const int max_hits_for_slow_change = (candidate_delay < self->last_delay)
+ ? kMaxHitsWhenPossiblyNonCausal
+ : kMaxHitsWhenPossiblyCausal;
int i = 0;
RTC_DCHECK_EQ(self->history_size, self->farend->history_size);
@@ -127,18 +128,20 @@
// |candidate_delay| is a "potential" candidate and we start decreasing
// these histogram bins more rapidly with |valley_depth|.
if (self->candidate_hits < max_hits_for_slow_change) {
- decrease_in_last_set = (self->mean_bit_counts[self->compare_delay] -
- valley_level_q14) * kQ14Scaling;
+ decrease_in_last_set =
+ (self->mean_bit_counts[self->compare_delay] - valley_level_q14) *
+ kQ14Scaling;
}
// 4. All other bins are decreased with |valley_depth|.
// TODO(bjornv): Investigate how to make this loop more efficient. Split up
// the loop? Remove parts that doesn't add too much.
for (i = 0; i < self->history_size; ++i) {
int is_in_last_set = (i >= self->last_delay - 2) &&
- (i <= self->last_delay + 1) && (i != candidate_delay);
- int is_in_candidate_set = (i >= candidate_delay - 2) &&
- (i <= candidate_delay + 1);
- self->histogram[i] -= decrease_in_last_set * is_in_last_set +
+ (i <= self->last_delay + 1) && (i != candidate_delay);
+ int is_in_candidate_set =
+ (i >= candidate_delay - 2) && (i <= candidate_delay + 1);
+ self->histogram[i] -=
+ decrease_in_last_set * is_in_last_set +
valley_depth * (!is_in_last_set && !is_in_candidate_set);
// 5. No histogram bin can go below 0.
if (self->histogram[i] < 0) {
@@ -196,16 +199,18 @@
// into tables?
if (delay_difference > self->allowed_offset) {
fraction = 1.f - kFractionSlope * (delay_difference - self->allowed_offset);
- fraction = (fraction > kMinFractionWhenPossiblyCausal ? fraction :
- kMinFractionWhenPossiblyCausal);
+ fraction = (fraction > kMinFractionWhenPossiblyCausal
+ ? fraction
+ : kMinFractionWhenPossiblyCausal);
} else if (delay_difference < 0) {
- fraction = kMinFractionWhenPossiblyNonCausal -
- kFractionSlope * delay_difference;
+ fraction =
+ kMinFractionWhenPossiblyNonCausal - kFractionSlope * delay_difference;
fraction = (fraction > 1.f ? 1.f : fraction);
}
histogram_threshold *= fraction;
- histogram_threshold = (histogram_threshold > kMinHistogramThreshold ?
- histogram_threshold : kMinHistogramThreshold);
+ histogram_threshold =
+ (histogram_threshold > kMinHistogramThreshold ? histogram_threshold
+ : kMinHistogramThreshold);
is_histogram_valid =
(self->histogram[candidate_delay] >= histogram_threshold) &&
@@ -243,8 +248,8 @@
// i) Before we actually have a valid estimate (|last_delay| == -2), we say
// a candidate is valid if either algorithm states so
// (|is_instantaneous_valid| OR |is_histogram_valid|).
- is_robust = (self->last_delay < 0) &&
- (is_instantaneous_valid || is_histogram_valid);
+ is_robust =
+ (self->last_delay < 0) && (is_instantaneous_valid || is_histogram_valid);
// ii) Otherwise, we need both algorithms to be certain
// (|is_instantaneous_valid| AND |is_histogram_valid|)
is_robust |= is_instantaneous_valid && is_histogram_valid;
@@ -252,13 +257,12 @@
// the instantaneous one if |is_histogram_valid| = 1 and the histogram
// is significantly strong.
is_robust |= is_histogram_valid &&
- (self->histogram[candidate_delay] > self->last_delay_histogram);
+ (self->histogram[candidate_delay] > self->last_delay_histogram);
return is_robust;
}
void WebRtc_FreeBinaryDelayEstimatorFarend(BinaryDelayEstimatorFarend* self) {
-
if (self == NULL) {
return;
}
@@ -302,20 +306,17 @@
self->binary_far_history = static_cast<uint32_t*>(
realloc(self->binary_far_history,
history_size * sizeof(*self->binary_far_history)));
- self->far_bit_counts = static_cast<int*>(
- realloc(self->far_bit_counts,
- history_size * sizeof(*self->far_bit_counts)));
+ self->far_bit_counts = static_cast<int*>(realloc(
+ self->far_bit_counts, history_size * sizeof(*self->far_bit_counts)));
if ((self->binary_far_history == NULL) || (self->far_bit_counts == NULL)) {
history_size = 0;
}
// Fill with zeros if we have expanded the buffers.
if (history_size > self->history_size) {
int size_diff = history_size - self->history_size;
- memset(&self->binary_far_history[self->history_size],
- 0,
+ memset(&self->binary_far_history[self->history_size], 0,
sizeof(*self->binary_far_history) * size_diff);
- memset(&self->far_bit_counts[self->history_size],
- 0,
+ memset(&self->far_bit_counts[self->history_size], 0,
sizeof(*self->far_bit_counts) * size_diff);
}
self->history_size = history_size;
@@ -330,7 +331,8 @@
}
void WebRtc_SoftResetBinaryDelayEstimatorFarend(
- BinaryDelayEstimatorFarend* self, int delay_shift) {
+ BinaryDelayEstimatorFarend* self,
+ int delay_shift) {
int abs_shift = abs(delay_shift);
int shift_size = 0;
int dest_index = 0;
@@ -355,8 +357,7 @@
sizeof(*self->binary_far_history) * shift_size);
memset(&self->binary_far_history[padding_index], 0,
sizeof(*self->binary_far_history) * abs_shift);
- memmove(&self->far_bit_counts[dest_index],
- &self->far_bit_counts[src_index],
+ memmove(&self->far_bit_counts[dest_index], &self->far_bit_counts[src_index],
sizeof(*self->far_bit_counts) * shift_size);
memset(&self->far_bit_counts[padding_index], 0,
sizeof(*self->far_bit_counts) * abs_shift);
@@ -378,7 +379,6 @@
}
void WebRtc_FreeBinaryDelayEstimator(BinaryDelayEstimator* self) {
-
if (self == NULL) {
return;
}
@@ -403,7 +403,8 @@
}
BinaryDelayEstimator* WebRtc_CreateBinaryDelayEstimator(
- BinaryDelayEstimatorFarend* farend, int max_lookahead) {
+ BinaryDelayEstimatorFarend* farend,
+ int max_lookahead) {
BinaryDelayEstimator* self = NULL;
if ((farend != NULL) && (max_lookahead >= 0)) {
@@ -457,22 +458,18 @@
self->histogram = static_cast<float*>(
realloc(self->histogram, (history_size + 1) * sizeof(*self->histogram)));
- if ((self->mean_bit_counts == NULL) ||
- (self->bit_counts == NULL) ||
+ if ((self->mean_bit_counts == NULL) || (self->bit_counts == NULL) ||
(self->histogram == NULL)) {
history_size = 0;
}
// Fill with zeros if we have expanded the buffers.
if (history_size > self->history_size) {
int size_diff = history_size - self->history_size;
- memset(&self->mean_bit_counts[self->history_size],
- 0,
+ memset(&self->mean_bit_counts[self->history_size], 0,
sizeof(*self->mean_bit_counts) * size_diff);
- memset(&self->bit_counts[self->history_size],
- 0,
+ memset(&self->bit_counts[self->history_size], 0,
sizeof(*self->bit_counts) * size_diff);
- memset(&self->histogram[self->history_size],
- 0,
+ memset(&self->histogram[self->history_size], 0,
sizeof(*self->histogram) * size_diff);
}
self->history_size = history_size;
@@ -485,15 +482,14 @@
RTC_DCHECK(self);
memset(self->bit_counts, 0, sizeof(int32_t) * self->history_size);
- memset(self->binary_near_history,
- 0,
+ memset(self->binary_near_history, 0,
sizeof(uint32_t) * self->near_history_size);
for (i = 0; i <= self->history_size; ++i) {
self->mean_bit_counts[i] = (20 << 9); // 20 in Q9.
self->histogram[i] = 0.f;
}
- self->minimum_probability = kMaxBitCountsQ9; // 32 in Q9.
- self->last_delay_probability = (int) kMaxBitCountsQ9; // 32 in Q9.
+ self->minimum_probability = kMaxBitCountsQ9; // 32 in Q9.
+ self->last_delay_probability = (int)kMaxBitCountsQ9; // 32 in Q9.
// Default return value if we're unable to estimate. -1 is used for errors.
self->last_delay = -2;
@@ -617,8 +613,8 @@
// and deeper than the best estimate so far
// (|value_best_candidate| < |last_delay_probability|)
valid_candidate = ((valley_depth > kProbabilityOffset) &&
- ((value_best_candidate < self->minimum_probability) ||
- (value_best_candidate < self->last_delay_probability)));
+ ((value_best_candidate < self->minimum_probability) ||
+ (value_best_candidate < self->last_delay_probability)));
// Check for nonstationary farend signal.
const bool non_stationary_farend =
@@ -637,7 +633,6 @@
int is_histogram_valid = HistogramBasedValidation(self, candidate_delay);
valid_candidate = RobustValidation(self, candidate_delay, valid_candidate,
is_histogram_valid);
-
}
// Only update the delay estimate when the farend is nonstationary and when
@@ -645,8 +640,9 @@
if (non_stationary_farend && valid_candidate) {
if (candidate_delay != self->last_delay) {
self->last_delay_histogram =
- (self->histogram[candidate_delay] > kLastHistogramMax ?
- kLastHistogramMax : self->histogram[candidate_delay]);
+ (self->histogram[candidate_delay] > kLastHistogramMax
+ ? kLastHistogramMax
+ : self->histogram[candidate_delay]);
// Adjust the histogram if we made a change to |last_delay|, though it was
// not the most likely one according to the histogram.
if (self->histogram[candidate_delay] <
@@ -679,8 +675,8 @@
} else {
// Note that |last_delay_probability| states how deep the minimum of the
// cost function is, so it is rather an error probability.
- quality = (float) (kMaxBitCountsQ9 - self->last_delay_probability) /
- kMaxBitCountsQ9;
+ quality = (float)(kMaxBitCountsQ9 - self->last_delay_probability) /
+ kMaxBitCountsQ9;
if (quality < 0) {
quality = 0;
}
diff --git a/modules/audio_processing/utility/delay_estimator.h b/modules/audio_processing/utility/delay_estimator.h
index cce6113..11483ec 100644
--- a/modules/audio_processing/utility/delay_estimator.h
+++ b/modules/audio_processing/utility/delay_estimator.h
@@ -117,7 +117,8 @@
// - delay_shift : The amount of blocks to shift history buffers.
//
void WebRtc_SoftResetBinaryDelayEstimatorFarend(
- BinaryDelayEstimatorFarend* self, int delay_shift);
+ BinaryDelayEstimatorFarend* self,
+ int delay_shift);
// Adds the binary far-end spectrum to the internal far-end history buffer. This
// spectrum is used as reference when calculating the delay using
@@ -153,7 +154,8 @@
// See WebRtc_CreateDelayEstimator(..) in delay_estimator_wrapper.c for detailed
// description.
BinaryDelayEstimator* WebRtc_CreateBinaryDelayEstimator(
- BinaryDelayEstimatorFarend* farend, int max_lookahead);
+ BinaryDelayEstimatorFarend* farend,
+ int max_lookahead);
// Re-allocates |history_size| dependent buffers. The far-end buffers will be
// updated at the same time if needed.
diff --git a/modules/audio_processing/utility/delay_estimator_unittest.cc b/modules/audio_processing/utility/delay_estimator_unittest.cc
index 36700e5..3e4e050 100644
--- a/modules/audio_processing/utility/delay_estimator_unittest.cc
+++ b/modules/audio_processing/utility/delay_estimator_unittest.cc
@@ -27,7 +27,7 @@
const int kDifferentHistorySize = 3;
const int kDifferentLookahead = 1;
-const int kEnable[] = { 0, 1 };
+const int kEnable[] = {0, 1};
const size_t kSizeEnable = sizeof(kEnable) / sizeof(*kEnable);
class DelayEstimatorTest : public ::testing::Test {
@@ -41,9 +41,13 @@
void VerifyDelay(BinaryDelayEstimator* binary_handle, int offset, int delay);
void RunBinarySpectra(BinaryDelayEstimator* binary1,
BinaryDelayEstimator* binary2,
- int near_offset, int lookahead_offset, int far_offset);
- void RunBinarySpectraTest(int near_offset, int lookahead_offset,
- int ref_robust_validation, int robust_validation);
+ int near_offset,
+ int lookahead_offset,
+ int far_offset);
+ void RunBinarySpectraTest(int near_offset,
+ int lookahead_offset,
+ int ref_robust_validation,
+ int robust_validation);
void* handle_;
DelayEstimator* self_;
@@ -83,8 +87,8 @@
}
void DelayEstimatorTest::SetUp() {
- farend_handle_ = WebRtc_CreateDelayEstimatorFarend(kSpectrumSize,
- kHistorySize);
+ farend_handle_ =
+ WebRtc_CreateDelayEstimatorFarend(kSpectrumSize, kHistorySize);
ASSERT_TRUE(farend_handle_ != NULL);
farend_self_ = reinterpret_cast<DelayEstimatorFarend*>(farend_handle_);
handle_ = WebRtc_CreateDelayEstimator(farend_handle_, kLookahead);
@@ -131,7 +135,8 @@
}
void DelayEstimatorTest::VerifyDelay(BinaryDelayEstimator* binary_handle,
- int offset, int delay) {
+ int offset,
+ int delay) {
// Verify that we WebRtc_binary_last_delay() returns correct delay.
EXPECT_EQ(delay, WebRtc_binary_last_delay(binary_handle));
@@ -147,8 +152,8 @@
int near_offset,
int lookahead_offset,
int far_offset) {
- int different_validations = binary1->robust_validation_enabled ^
- binary2->robust_validation_enabled;
+ int different_validations =
+ binary1->robust_validation_enabled ^ binary2->robust_validation_enabled;
WebRtc_InitBinaryDelayEstimatorFarend(binary_farend_);
WebRtc_InitBinaryDelayEstimator(binary1);
WebRtc_InitBinaryDelayEstimator(binary2);
@@ -160,9 +165,8 @@
WebRtc_AddBinaryFarSpectrum(binary_farend_,
binary_spectrum_[i + far_offset]);
int delay_1 = WebRtc_ProcessBinarySpectrum(binary1, binary_spectrum_[i]);
- int delay_2 =
- WebRtc_ProcessBinarySpectrum(binary2,
- binary_spectrum_[i - near_offset]);
+ int delay_2 = WebRtc_ProcessBinarySpectrum(
+ binary2, binary_spectrum_[i - near_offset]);
VerifyDelay(binary1, far_offset + kLookahead, delay_1);
VerifyDelay(binary2,
@@ -177,7 +181,7 @@
// all the time, unless one of them has robust validation turned on. In
// that case the robust validation leaves the initial state faster.
if ((near_offset == 0) && (lookahead_offset == 0)) {
- if (!different_validations) {
+ if (!different_validations) {
EXPECT_EQ(delay_1, delay_2);
} else {
if (binary1->robust_validation_enabled) {
@@ -199,9 +203,8 @@
int lookahead_offset,
int ref_robust_validation,
int robust_validation) {
- BinaryDelayEstimator* binary2 =
- WebRtc_CreateBinaryDelayEstimator(binary_farend_,
- kLookahead + lookahead_offset);
+ BinaryDelayEstimator* binary2 = WebRtc_CreateBinaryDelayEstimator(
+ binary_farend_, kLookahead + lookahead_offset);
// Verify the delay for both causal and non-causal systems. For causal systems
// the delay is equivalent with a positive |offset| of the far-end sequence.
// For non-causal systems the delay is equivalent with a negative |offset| of
@@ -209,8 +212,7 @@
binary_->robust_validation_enabled = ref_robust_validation;
binary2->robust_validation_enabled = robust_validation;
for (int offset = -kLookahead;
- offset < kMaxDelay - lookahead_offset - near_offset;
- offset++) {
+ offset < kMaxDelay - lookahead_offset - near_offset; offset++) {
RunBinarySpectra(binary_, binary2, near_offset, lookahead_offset, offset);
}
WebRtc_FreeBinaryDelayEstimator(binary2);
@@ -248,8 +250,8 @@
// 3) Incorrect spectrum size.
EXPECT_EQ(-1, WebRtc_AddFarSpectrumFloat(NULL, far_f_, spectrum_size_));
// Use |farend_handle_| which is properly created at SetUp().
- EXPECT_EQ(-1, WebRtc_AddFarSpectrumFloat(farend_handle_, NULL,
- spectrum_size_));
+ EXPECT_EQ(-1,
+ WebRtc_AddFarSpectrumFloat(farend_handle_, NULL, spectrum_size_));
EXPECT_EQ(-1, WebRtc_AddFarSpectrumFloat(farend_handle_, far_f_,
spectrum_size_ + 1));
@@ -259,8 +261,8 @@
// 3) Incorrect spectrum size.
// 4) Too high precision in far-end spectrum (Q-domain > 15).
EXPECT_EQ(-1, WebRtc_AddFarSpectrumFix(NULL, far_u16_, spectrum_size_, 0));
- EXPECT_EQ(-1, WebRtc_AddFarSpectrumFix(farend_handle_, NULL, spectrum_size_,
- 0));
+ EXPECT_EQ(-1,
+ WebRtc_AddFarSpectrumFix(farend_handle_, NULL, spectrum_size_, 0));
EXPECT_EQ(-1, WebRtc_AddFarSpectrumFix(farend_handle_, far_u16_,
spectrum_size_ + 1, 0));
EXPECT_EQ(-1, WebRtc_AddFarSpectrumFix(farend_handle_, far_u16_,
@@ -313,16 +315,15 @@
// 3) Incorrect spectrum size.
// 4) Non matching history sizes if multiple delay estimators using the same
// far-end reference.
- EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFloat(NULL, near_f_,
- spectrum_size_));
+ EXPECT_EQ(-1,
+ WebRtc_DelayEstimatorProcessFloat(NULL, near_f_, spectrum_size_));
// Use |handle_| which is properly created at SetUp().
- EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFloat(handle_, NULL,
- spectrum_size_));
+ EXPECT_EQ(-1,
+ WebRtc_DelayEstimatorProcessFloat(handle_, NULL, spectrum_size_));
EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFloat(handle_, near_f_,
spectrum_size_ + 1));
// |tmp_handle| is already in a non-matching state.
- EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFloat(tmp_handle,
- near_f_,
+ EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFloat(tmp_handle, near_f_,
spectrum_size_));
// WebRtc_DelayEstimatorProcessFix() should return -1 if we have:
@@ -332,19 +333,17 @@
// 4) Too high precision in near-end spectrum (Q-domain > 15).
// 5) Non matching history sizes if multiple delay estimators using the same
// far-end reference.
- EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFix(NULL, near_u16_, spectrum_size_,
- 0));
- EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFix(handle_, NULL, spectrum_size_,
- 0));
+ EXPECT_EQ(
+ -1, WebRtc_DelayEstimatorProcessFix(NULL, near_u16_, spectrum_size_, 0));
+ EXPECT_EQ(-1,
+ WebRtc_DelayEstimatorProcessFix(handle_, NULL, spectrum_size_, 0));
EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFix(handle_, near_u16_,
spectrum_size_ + 1, 0));
EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFix(handle_, near_u16_,
spectrum_size_, 16));
// |tmp_handle| is already in a non-matching state.
- EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFix(tmp_handle,
- near_u16_,
- spectrum_size_,
- 0));
+ EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFix(tmp_handle, near_u16_,
+ spectrum_size_, 0));
WebRtc_FreeDelayEstimator(tmp_handle);
// WebRtc_last_delay() should return -1 if we have a NULL pointer as |handle|.
@@ -382,8 +381,8 @@
// In this test we verify that the mean spectra are initialized after first
// time we call WebRtc_AddFarSpectrum() and Process() respectively. The test
// also verifies the state is not left for zero spectra.
- const float kZerosFloat[kSpectrumSize] = { 0.0 };
- const uint16_t kZerosU16[kSpectrumSize] = { 0 };
+ const float kZerosFloat[kSpectrumSize] = {0.0};
+ const uint16_t kZerosU16[kSpectrumSize] = {0};
// For floating point operations, process one frame and verify initialization
// flag.
@@ -391,14 +390,14 @@
EXPECT_EQ(0, WebRtc_AddFarSpectrumFloat(farend_handle_, kZerosFloat,
spectrum_size_));
EXPECT_EQ(0, farend_self_->far_spectrum_initialized);
- EXPECT_EQ(0, WebRtc_AddFarSpectrumFloat(farend_handle_, far_f_,
- spectrum_size_));
+ EXPECT_EQ(0,
+ WebRtc_AddFarSpectrumFloat(farend_handle_, far_f_, spectrum_size_));
EXPECT_EQ(1, farend_self_->far_spectrum_initialized);
EXPECT_EQ(-2, WebRtc_DelayEstimatorProcessFloat(handle_, kZerosFloat,
spectrum_size_));
EXPECT_EQ(0, self_->near_spectrum_initialized);
- EXPECT_EQ(-2, WebRtc_DelayEstimatorProcessFloat(handle_, near_f_,
- spectrum_size_));
+ EXPECT_EQ(
+ -2, WebRtc_DelayEstimatorProcessFloat(handle_, near_f_, spectrum_size_));
EXPECT_EQ(1, self_->near_spectrum_initialized);
// For fixed point operations, process one frame and verify initialization
@@ -407,8 +406,8 @@
EXPECT_EQ(0, WebRtc_AddFarSpectrumFix(farend_handle_, kZerosU16,
spectrum_size_, 0));
EXPECT_EQ(0, farend_self_->far_spectrum_initialized);
- EXPECT_EQ(0, WebRtc_AddFarSpectrumFix(farend_handle_, far_u16_,
- spectrum_size_, 0));
+ EXPECT_EQ(
+ 0, WebRtc_AddFarSpectrumFix(farend_handle_, far_u16_, spectrum_size_, 0));
EXPECT_EQ(1, farend_self_->far_spectrum_initialized);
EXPECT_EQ(-2, WebRtc_DelayEstimatorProcessFix(handle_, kZerosU16,
spectrum_size_, 0));
@@ -429,10 +428,10 @@
// Floating point operations.
Init();
for (int i = 0; i < 200; i++) {
- EXPECT_EQ(0, WebRtc_AddFarSpectrumFloat(farend_handle_, far_f_,
- spectrum_size_));
- last_delay = WebRtc_DelayEstimatorProcessFloat(handle_, near_f_,
- spectrum_size_);
+ EXPECT_EQ(
+ 0, WebRtc_AddFarSpectrumFloat(farend_handle_, far_f_, spectrum_size_));
+ last_delay =
+ WebRtc_DelayEstimatorProcessFloat(handle_, near_f_, spectrum_size_);
if (last_delay != -2) {
EXPECT_EQ(last_delay, WebRtc_last_delay(handle_));
if (!WebRtc_is_robust_validation_enabled(handle_)) {
@@ -451,8 +450,8 @@
for (int i = 0; i < 200; i++) {
EXPECT_EQ(0, WebRtc_AddFarSpectrumFix(farend_handle_, far_u16_,
spectrum_size_, 0));
- last_delay = WebRtc_DelayEstimatorProcessFix(handle_, near_u16_,
- spectrum_size_, 0);
+ last_delay =
+ WebRtc_DelayEstimatorProcessFix(handle_, near_u16_, spectrum_size_, 0);
if (last_delay != -2) {
EXPECT_EQ(last_delay, WebRtc_last_delay(handle_));
if (!WebRtc_is_robust_validation_enabled(handle_)) {
@@ -577,8 +576,8 @@
}
TEST_F(DelayEstimatorTest, VerifyLookaheadAtCreate) {
- void* farend_handle = WebRtc_CreateDelayEstimatorFarend(kSpectrumSize,
- kMaxDelay);
+ void* farend_handle =
+ WebRtc_CreateDelayEstimatorFarend(kSpectrumSize, kMaxDelay);
ASSERT_TRUE(farend_handle != NULL);
void* handle = WebRtc_CreateDelayEstimator(farend_handle, kLookahead);
ASSERT_TRUE(handle != NULL);
diff --git a/modules/audio_processing/utility/delay_estimator_wrapper.cc b/modules/audio_processing/utility/delay_estimator_wrapper.cc
index f907c80..27c2a3a 100644
--- a/modules/audio_processing/utility/delay_estimator_wrapper.cc
+++ b/modules/audio_processing/utility/delay_estimator_wrapper.cc
@@ -72,7 +72,7 @@
for (i = kBandFirst; i <= kBandLast; i++) {
if (spectrum[i] > 0) {
// Convert input spectrum from Q(|q_domain|) to Q15.
- int32_t spectrum_q15 = ((int32_t) spectrum[i]) << (15 - q_domain);
+ int32_t spectrum_q15 = ((int32_t)spectrum[i]) << (15 - q_domain);
threshold_spectrum[i].int32_ = (spectrum_q15 >> 1);
*threshold_initialized = 1;
}
@@ -80,7 +80,7 @@
}
for (i = kBandFirst; i <= kBandLast; i++) {
// Convert input spectrum from Q(|q_domain|) to Q15.
- int32_t spectrum_q15 = ((int32_t) spectrum[i]) << (15 - q_domain);
+ int32_t spectrum_q15 = ((int32_t)spectrum[i]) << (15 - q_domain);
// Update the |threshold_spectrum|.
WebRtc_MeanEstimatorFix(spectrum_q15, 6, &(threshold_spectrum[i].int32_));
// Convert |spectrum| at current frequency bin to a binary value.
@@ -123,7 +123,7 @@
}
void WebRtc_FreeDelayEstimatorFarend(void* handle) {
- DelayEstimatorFarend* self = (DelayEstimatorFarend*) handle;
+ DelayEstimatorFarend* self = (DelayEstimatorFarend*)handle;
if (handle == NULL) {
return;
@@ -158,8 +158,8 @@
memory_fail |= (self->binary_farend == NULL);
// Allocate memory for spectrum buffers.
- self->mean_far_spectrum =
- static_cast<SpectrumType*>(malloc(spectrum_size * sizeof(SpectrumType)));
+ self->mean_far_spectrum = static_cast<SpectrumType*>(
+ malloc(spectrum_size * sizeof(SpectrumType)));
memory_fail |= (self->mean_far_spectrum == NULL);
self->spectrum_size = spectrum_size;
@@ -174,7 +174,7 @@
}
int WebRtc_InitDelayEstimatorFarend(void* handle) {
- DelayEstimatorFarend* self = (DelayEstimatorFarend*) handle;
+ DelayEstimatorFarend* self = (DelayEstimatorFarend*)handle;
if (self == NULL) {
return -1;
@@ -193,7 +193,7 @@
}
void WebRtc_SoftResetDelayEstimatorFarend(void* handle, int delay_shift) {
- DelayEstimatorFarend* self = (DelayEstimatorFarend*) handle;
+ DelayEstimatorFarend* self = (DelayEstimatorFarend*)handle;
RTC_DCHECK(self);
WebRtc_SoftResetBinaryDelayEstimatorFarend(self->binary_farend, delay_shift);
}
@@ -202,7 +202,7 @@
const uint16_t* far_spectrum,
int spectrum_size,
int far_q) {
- DelayEstimatorFarend* self = (DelayEstimatorFarend*) handle;
+ DelayEstimatorFarend* self = (DelayEstimatorFarend*)handle;
uint32_t binary_spectrum = 0;
if (self == NULL) {
@@ -232,7 +232,7 @@
int WebRtc_AddFarSpectrumFloat(void* handle,
const float* far_spectrum,
int spectrum_size) {
- DelayEstimatorFarend* self = (DelayEstimatorFarend*) handle;
+ DelayEstimatorFarend* self = (DelayEstimatorFarend*)handle;
uint32_t binary_spectrum = 0;
if (self == NULL) {
@@ -256,7 +256,7 @@
}
void WebRtc_FreeDelayEstimator(void* handle) {
- DelayEstimator* self = (DelayEstimator*) handle;
+ DelayEstimator* self = (DelayEstimator*)handle;
if (handle == NULL) {
return;
@@ -273,7 +273,7 @@
void* WebRtc_CreateDelayEstimator(void* farend_handle, int max_lookahead) {
DelayEstimator* self = NULL;
- DelayEstimatorFarend* farend = (DelayEstimatorFarend*) farend_handle;
+ DelayEstimatorFarend* farend = (DelayEstimatorFarend*)farend_handle;
if (farend_handle != NULL) {
self = static_cast<DelayEstimator*>(malloc(sizeof(DelayEstimator)));
@@ -304,7 +304,7 @@
}
int WebRtc_InitDelayEstimator(void* handle) {
- DelayEstimator* self = (DelayEstimator*) handle;
+ DelayEstimator* self = (DelayEstimator*)handle;
if (self == NULL) {
return -1;
@@ -323,7 +323,7 @@
}
int WebRtc_SoftResetDelayEstimator(void* handle, int delay_shift) {
- DelayEstimator* self = (DelayEstimator*) handle;
+ DelayEstimator* self = (DelayEstimator*)handle;
RTC_DCHECK(self);
return WebRtc_SoftResetBinaryDelayEstimator(self->binary_handle, delay_shift);
}
@@ -352,7 +352,7 @@
}
int WebRtc_set_lookahead(void* handle, int lookahead) {
- DelayEstimator* self = (DelayEstimator*) handle;
+ DelayEstimator* self = (DelayEstimator*)handle;
RTC_DCHECK(self);
RTC_DCHECK(self->binary_handle);
if ((lookahead > self->binary_handle->near_history_size - 1) ||
@@ -364,14 +364,14 @@
}
int WebRtc_lookahead(void* handle) {
- DelayEstimator* self = (DelayEstimator*) handle;
+ DelayEstimator* self = (DelayEstimator*)handle;
RTC_DCHECK(self);
RTC_DCHECK(self->binary_handle);
return self->binary_handle->lookahead;
}
int WebRtc_set_allowed_offset(void* handle, int allowed_offset) {
- DelayEstimator* self = (DelayEstimator*) handle;
+ DelayEstimator* self = (DelayEstimator*)handle;
if ((self == NULL) || (allowed_offset < 0)) {
return -1;
@@ -381,7 +381,7 @@
}
int WebRtc_get_allowed_offset(const void* handle) {
- const DelayEstimator* self = (const DelayEstimator*) handle;
+ const DelayEstimator* self = (const DelayEstimator*)handle;
if (self == NULL) {
return -1;
@@ -390,7 +390,7 @@
}
int WebRtc_enable_robust_validation(void* handle, int enable) {
- DelayEstimator* self = (DelayEstimator*) handle;
+ DelayEstimator* self = (DelayEstimator*)handle;
if (self == NULL) {
return -1;
@@ -404,7 +404,7 @@
}
int WebRtc_is_robust_validation_enabled(const void* handle) {
- const DelayEstimator* self = (const DelayEstimator*) handle;
+ const DelayEstimator* self = (const DelayEstimator*)handle;
if (self == NULL) {
return -1;
@@ -416,7 +416,7 @@
const uint16_t* near_spectrum,
int spectrum_size,
int near_q) {
- DelayEstimator* self = (DelayEstimator*) handle;
+ DelayEstimator* self = (DelayEstimator*)handle;
uint32_t binary_spectrum = 0;
if (self == NULL) {
@@ -436,10 +436,9 @@
}
// Get binary spectra.
- binary_spectrum = BinarySpectrumFix(near_spectrum,
- self->mean_near_spectrum,
- near_q,
- &(self->near_spectrum_initialized));
+ binary_spectrum =
+ BinarySpectrumFix(near_spectrum, self->mean_near_spectrum, near_q,
+ &(self->near_spectrum_initialized));
return WebRtc_ProcessBinarySpectrum(self->binary_handle, binary_spectrum);
}
@@ -447,7 +446,7 @@
int WebRtc_DelayEstimatorProcessFloat(void* handle,
const float* near_spectrum,
int spectrum_size) {
- DelayEstimator* self = (DelayEstimator*) handle;
+ DelayEstimator* self = (DelayEstimator*)handle;
uint32_t binary_spectrum = 0;
if (self == NULL) {
@@ -470,7 +469,7 @@
}
int WebRtc_last_delay(void* handle) {
- DelayEstimator* self = (DelayEstimator*) handle;
+ DelayEstimator* self = (DelayEstimator*)handle;
if (self == NULL) {
return -1;
@@ -480,7 +479,7 @@
}
float WebRtc_last_delay_quality(void* handle) {
- DelayEstimator* self = (DelayEstimator*) handle;
+ DelayEstimator* self = (DelayEstimator*)handle;
RTC_DCHECK(self);
return WebRtc_binary_last_delay_quality(self->binary_handle);
}
diff --git a/modules/audio_processing/utility/ooura_fft.cc b/modules/audio_processing/utility/ooura_fft.cc
index d753a81..2add4eb 100644
--- a/modules/audio_processing/utility/ooura_fft.cc
+++ b/modules/audio_processing/utility/ooura_fft.cc
@@ -313,7 +313,6 @@
}
#endif
-
} // namespace
OouraFft::OouraFft() {
diff --git a/modules/audio_processing/utility/ooura_fft_mips.cc b/modules/audio_processing/utility/ooura_fft_mips.cc
index 569e1d7..c782ee7 100644
--- a/modules/audio_processing/utility/ooura_fft_mips.cc
+++ b/modules/audio_processing/utility/ooura_fft_mips.cc
@@ -279,533 +279,600 @@
const float* first = rdft_wk3ri_first;
const float* second = rdft_wk3ri_second;
- __asm __volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- // first 8
- "lwc1 %[f0], 0(%[a]) \n\t"
- "lwc1 %[f1], 4(%[a]) \n\t"
- "lwc1 %[f2], 8(%[a]) \n\t"
- "lwc1 %[f3], 12(%[a]) \n\t"
- "lwc1 %[f4], 16(%[a]) \n\t"
- "lwc1 %[f5], 20(%[a]) \n\t"
- "lwc1 %[f6], 24(%[a]) \n\t"
- "lwc1 %[f7], 28(%[a]) \n\t"
- "add.s %[f8], %[f0], %[f2] \n\t"
- "sub.s %[f0], %[f0], %[f2] \n\t"
- "add.s %[f2], %[f4], %[f6] \n\t"
- "sub.s %[f4], %[f4], %[f6] \n\t"
- "add.s %[f6], %[f1], %[f3] \n\t"
- "sub.s %[f1], %[f1], %[f3] \n\t"
- "add.s %[f3], %[f5], %[f7] \n\t"
- "sub.s %[f5], %[f5], %[f7] \n\t"
- "add.s %[f7], %[f8], %[f2] \n\t"
- "sub.s %[f8], %[f8], %[f2] \n\t"
- "sub.s %[f2], %[f1], %[f4] \n\t"
- "add.s %[f1], %[f1], %[f4] \n\t"
- "add.s %[f4], %[f6], %[f3] \n\t"
- "sub.s %[f6], %[f6], %[f3] \n\t"
- "sub.s %[f3], %[f0], %[f5] \n\t"
- "add.s %[f0], %[f0], %[f5] \n\t"
- "swc1 %[f7], 0(%[a]) \n\t"
- "swc1 %[f8], 16(%[a]) \n\t"
- "swc1 %[f2], 28(%[a]) \n\t"
- "swc1 %[f1], 12(%[a]) \n\t"
- "swc1 %[f4], 4(%[a]) \n\t"
- "swc1 %[f6], 20(%[a]) \n\t"
- "swc1 %[f3], 8(%[a]) \n\t"
- "swc1 %[f0], 24(%[a]) \n\t"
- // second 8
- "lwc1 %[f0], 32(%[a]) \n\t"
- "lwc1 %[f1], 36(%[a]) \n\t"
- "lwc1 %[f2], 40(%[a]) \n\t"
- "lwc1 %[f3], 44(%[a]) \n\t"
- "lwc1 %[f4], 48(%[a]) \n\t"
- "lwc1 %[f5], 52(%[a]) \n\t"
- "lwc1 %[f6], 56(%[a]) \n\t"
- "lwc1 %[f7], 60(%[a]) \n\t"
- "add.s %[f8], %[f4], %[f6] \n\t"
- "sub.s %[f4], %[f4], %[f6] \n\t"
- "add.s %[f6], %[f1], %[f3] \n\t"
- "sub.s %[f1], %[f1], %[f3] \n\t"
- "add.s %[f3], %[f0], %[f2] \n\t"
- "sub.s %[f0], %[f0], %[f2] \n\t"
- "add.s %[f2], %[f5], %[f7] \n\t"
- "sub.s %[f5], %[f5], %[f7] \n\t"
- "add.s %[f7], %[f4], %[f1] \n\t"
- "sub.s %[f4], %[f4], %[f1] \n\t"
- "add.s %[f1], %[f3], %[f8] \n\t"
- "sub.s %[f3], %[f3], %[f8] \n\t"
- "sub.s %[f8], %[f0], %[f5] \n\t"
- "add.s %[f0], %[f0], %[f5] \n\t"
- "add.s %[f5], %[f6], %[f2] \n\t"
- "sub.s %[f6], %[f2], %[f6] \n\t"
- "lwc1 %[f9], 8(%[rdft_w]) \n\t"
- "sub.s %[f2], %[f8], %[f7] \n\t"
- "add.s %[f8], %[f8], %[f7] \n\t"
- "sub.s %[f7], %[f4], %[f0] \n\t"
- "add.s %[f4], %[f4], %[f0] \n\t"
- // prepare for loop
- "addiu %[a_ptr], %[a], 64 \n\t"
- "addiu %[p1_rdft], %[rdft_w], 8 \n\t"
- "addiu %[p2_rdft], %[rdft_w], 16 \n\t"
- "addiu %[count], $zero, 7 \n\t"
- // finish second 8
- "mul.s %[f2], %[f9], %[f2] \n\t"
- "mul.s %[f8], %[f9], %[f8] \n\t"
- "mul.s %[f7], %[f9], %[f7] \n\t"
- "mul.s %[f4], %[f9], %[f4] \n\t"
- "swc1 %[f1], 32(%[a]) \n\t"
- "swc1 %[f3], 52(%[a]) \n\t"
- "swc1 %[f5], 36(%[a]) \n\t"
- "swc1 %[f6], 48(%[a]) \n\t"
- "swc1 %[f2], 40(%[a]) \n\t"
- "swc1 %[f8], 44(%[a]) \n\t"
- "swc1 %[f7], 56(%[a]) \n\t"
- "swc1 %[f4], 60(%[a]) \n\t"
- // loop
- "1: \n\t"
- "lwc1 %[f0], 0(%[a_ptr]) \n\t"
- "lwc1 %[f1], 4(%[a_ptr]) \n\t"
- "lwc1 %[f2], 8(%[a_ptr]) \n\t"
- "lwc1 %[f3], 12(%[a_ptr]) \n\t"
- "lwc1 %[f4], 16(%[a_ptr]) \n\t"
- "lwc1 %[f5], 20(%[a_ptr]) \n\t"
- "lwc1 %[f6], 24(%[a_ptr]) \n\t"
- "lwc1 %[f7], 28(%[a_ptr]) \n\t"
- "add.s %[f8], %[f0], %[f2] \n\t"
- "sub.s %[f0], %[f0], %[f2] \n\t"
- "add.s %[f2], %[f4], %[f6] \n\t"
- "sub.s %[f4], %[f4], %[f6] \n\t"
- "add.s %[f6], %[f1], %[f3] \n\t"
- "sub.s %[f1], %[f1], %[f3] \n\t"
- "add.s %[f3], %[f5], %[f7] \n\t"
- "sub.s %[f5], %[f5], %[f7] \n\t"
- "lwc1 %[f10], 4(%[p1_rdft]) \n\t"
- "lwc1 %[f11], 0(%[p2_rdft]) \n\t"
- "lwc1 %[f12], 4(%[p2_rdft]) \n\t"
- "lwc1 %[f13], 8(%[first]) \n\t"
- "lwc1 %[f14], 12(%[first]) \n\t"
- "add.s %[f7], %[f8], %[f2] \n\t"
- "sub.s %[f8], %[f8], %[f2] \n\t"
- "add.s %[f2], %[f6], %[f3] \n\t"
- "sub.s %[f6], %[f6], %[f3] \n\t"
- "add.s %[f3], %[f0], %[f5] \n\t"
- "sub.s %[f0], %[f0], %[f5] \n\t"
- "add.s %[f5], %[f1], %[f4] \n\t"
- "sub.s %[f1], %[f1], %[f4] \n\t"
- "swc1 %[f7], 0(%[a_ptr]) \n\t"
- "swc1 %[f2], 4(%[a_ptr]) \n\t"
- "mul.s %[f4], %[f9], %[f8] \n\t"
+ __asm __volatile(
+ ".set push \n\t"
+ ".set noreorder \n\t"
+ // first 8
+ "lwc1 %[f0], 0(%[a]) \n\t"
+ "lwc1 %[f1], 4(%[a]) \n\t"
+ "lwc1 %[f2], 8(%[a]) \n\t"
+ "lwc1 %[f3], 12(%[a]) \n\t"
+ "lwc1 %[f4], 16(%[a]) \n\t"
+ "lwc1 %[f5], 20(%[a]) \n\t"
+ "lwc1 %[f6], 24(%[a]) \n\t"
+ "lwc1 %[f7], 28(%[a]) \n\t"
+ "add.s %[f8], %[f0], %[f2] \n\t"
+ "sub.s %[f0], %[f0], %[f2] \n\t"
+ "add.s %[f2], %[f4], %[f6] \n\t"
+ "sub.s %[f4], %[f4], %[f6] \n\t"
+ "add.s %[f6], %[f1], %[f3] \n\t"
+ "sub.s %[f1], %[f1], %[f3] \n\t"
+ "add.s %[f3], %[f5], %[f7] \n\t"
+ "sub.s %[f5], %[f5], %[f7] \n\t"
+ "add.s %[f7], %[f8], %[f2] \n\t"
+ "sub.s %[f8], %[f8], %[f2] \n\t"
+ "sub.s %[f2], %[f1], %[f4] \n\t"
+ "add.s %[f1], %[f1], %[f4] \n\t"
+ "add.s %[f4], %[f6], %[f3] \n\t"
+ "sub.s %[f6], %[f6], %[f3] \n\t"
+ "sub.s %[f3], %[f0], %[f5] \n\t"
+ "add.s %[f0], %[f0], %[f5] \n\t"
+ "swc1 %[f7], 0(%[a]) \n\t"
+ "swc1 %[f8], 16(%[a]) \n\t"
+ "swc1 %[f2], 28(%[a]) \n\t"
+ "swc1 %[f1], 12(%[a]) \n\t"
+ "swc1 %[f4], 4(%[a]) \n\t"
+ "swc1 %[f6], 20(%[a]) \n\t"
+ "swc1 %[f3], 8(%[a]) \n\t"
+ "swc1 %[f0], 24(%[a]) \n\t"
+ // second 8
+ "lwc1 %[f0], 32(%[a]) \n\t"
+ "lwc1 %[f1], 36(%[a]) \n\t"
+ "lwc1 %[f2], 40(%[a]) \n\t"
+ "lwc1 %[f3], 44(%[a]) \n\t"
+ "lwc1 %[f4], 48(%[a]) \n\t"
+ "lwc1 %[f5], 52(%[a]) \n\t"
+ "lwc1 %[f6], 56(%[a]) \n\t"
+ "lwc1 %[f7], 60(%[a]) \n\t"
+ "add.s %[f8], %[f4], %[f6] \n\t"
+ "sub.s %[f4], %[f4], %[f6] \n\t"
+ "add.s %[f6], %[f1], %[f3] \n\t"
+ "sub.s %[f1], %[f1], %[f3] \n\t"
+ "add.s %[f3], %[f0], %[f2] \n\t"
+ "sub.s %[f0], %[f0], %[f2] \n\t"
+ "add.s %[f2], %[f5], %[f7] \n\t"
+ "sub.s %[f5], %[f5], %[f7] \n\t"
+ "add.s %[f7], %[f4], %[f1] \n\t"
+ "sub.s %[f4], %[f4], %[f1] \n\t"
+ "add.s %[f1], %[f3], %[f8] \n\t"
+ "sub.s %[f3], %[f3], %[f8] \n\t"
+ "sub.s %[f8], %[f0], %[f5] \n\t"
+ "add.s %[f0], %[f0], %[f5] \n\t"
+ "add.s %[f5], %[f6], %[f2] \n\t"
+ "sub.s %[f6], %[f2], %[f6] \n\t"
+ "lwc1 %[f9], 8(%[rdft_w]) \n\t"
+ "sub.s %[f2], %[f8], %[f7] \n\t"
+ "add.s %[f8], %[f8], %[f7] \n\t"
+ "sub.s %[f7], %[f4], %[f0] \n\t"
+ "add.s %[f4], %[f4], %[f0] \n\t"
+ // prepare for loop
+ "addiu %[a_ptr], %[a], 64 \n\t"
+ "addiu %[p1_rdft], %[rdft_w], 8 \n\t"
+ "addiu %[p2_rdft], %[rdft_w], 16 \n\t"
+ "addiu %[count], $zero, 7 \n\t"
+ // finish second 8
+ "mul.s %[f2], %[f9], %[f2] \n\t"
+ "mul.s %[f8], %[f9], %[f8] \n\t"
+ "mul.s %[f7], %[f9], %[f7] \n\t"
+ "mul.s %[f4], %[f9], %[f4] \n\t"
+ "swc1 %[f1], 32(%[a]) \n\t"
+ "swc1 %[f3], 52(%[a]) \n\t"
+ "swc1 %[f5], 36(%[a]) \n\t"
+ "swc1 %[f6], 48(%[a]) \n\t"
+ "swc1 %[f2], 40(%[a]) \n\t"
+ "swc1 %[f8], 44(%[a]) \n\t"
+ "swc1 %[f7], 56(%[a]) \n\t"
+ "swc1 %[f4], 60(%[a]) \n\t"
+ // loop
+ "1: \n\t"
+ "lwc1 %[f0], 0(%[a_ptr]) \n\t"
+ "lwc1 %[f1], 4(%[a_ptr]) \n\t"
+ "lwc1 %[f2], 8(%[a_ptr]) \n\t"
+ "lwc1 %[f3], 12(%[a_ptr]) \n\t"
+ "lwc1 %[f4], 16(%[a_ptr]) \n\t"
+ "lwc1 %[f5], 20(%[a_ptr]) \n\t"
+ "lwc1 %[f6], 24(%[a_ptr]) \n\t"
+ "lwc1 %[f7], 28(%[a_ptr]) \n\t"
+ "add.s %[f8], %[f0], %[f2] \n\t"
+ "sub.s %[f0], %[f0], %[f2] \n\t"
+ "add.s %[f2], %[f4], %[f6] \n\t"
+ "sub.s %[f4], %[f4], %[f6] \n\t"
+ "add.s %[f6], %[f1], %[f3] \n\t"
+ "sub.s %[f1], %[f1], %[f3] \n\t"
+ "add.s %[f3], %[f5], %[f7] \n\t"
+ "sub.s %[f5], %[f5], %[f7] \n\t"
+ "lwc1 %[f10], 4(%[p1_rdft]) \n\t"
+ "lwc1 %[f11], 0(%[p2_rdft]) \n\t"
+ "lwc1 %[f12], 4(%[p2_rdft]) \n\t"
+ "lwc1 %[f13], 8(%[first]) \n\t"
+ "lwc1 %[f14], 12(%[first]) \n\t"
+ "add.s %[f7], %[f8], %[f2] \n\t"
+ "sub.s %[f8], %[f8], %[f2] \n\t"
+ "add.s %[f2], %[f6], %[f3] \n\t"
+ "sub.s %[f6], %[f6], %[f3] \n\t"
+ "add.s %[f3], %[f0], %[f5] \n\t"
+ "sub.s %[f0], %[f0], %[f5] \n\t"
+ "add.s %[f5], %[f1], %[f4] \n\t"
+ "sub.s %[f1], %[f1], %[f4] \n\t"
+ "swc1 %[f7], 0(%[a_ptr]) \n\t"
+ "swc1 %[f2], 4(%[a_ptr]) \n\t"
+ "mul.s %[f4], %[f9], %[f8] \n\t"
#if defined(MIPS32_R2_LE)
- "mul.s %[f8], %[f10], %[f8] \n\t"
- "mul.s %[f7], %[f11], %[f0] \n\t"
- "mul.s %[f0], %[f12], %[f0] \n\t"
- "mul.s %[f2], %[f13], %[f3] \n\t"
- "mul.s %[f3], %[f14], %[f3] \n\t"
- "nmsub.s %[f4], %[f4], %[f10], %[f6] \n\t"
- "madd.s %[f8], %[f8], %[f9], %[f6] \n\t"
- "nmsub.s %[f7], %[f7], %[f12], %[f5] \n\t"
- "madd.s %[f0], %[f0], %[f11], %[f5] \n\t"
- "nmsub.s %[f2], %[f2], %[f14], %[f1] \n\t"
- "madd.s %[f3], %[f3], %[f13], %[f1] \n\t"
+ "mul.s %[f8], %[f10], %[f8] \n\t"
+ "mul.s %[f7], %[f11], %[f0] \n\t"
+ "mul.s %[f0], %[f12], %[f0] \n\t"
+ "mul.s %[f2], %[f13], %[f3] \n\t"
+ "mul.s %[f3], %[f14], %[f3] \n\t"
+ "nmsub.s %[f4], %[f4], %[f10], %[f6] \n\t"
+ "madd.s %[f8], %[f8], %[f9], %[f6] \n\t"
+ "nmsub.s %[f7], %[f7], %[f12], %[f5] \n\t"
+ "madd.s %[f0], %[f0], %[f11], %[f5] \n\t"
+ "nmsub.s %[f2], %[f2], %[f14], %[f1] \n\t"
+ "madd.s %[f3], %[f3], %[f13], %[f1] \n\t"
#else
- "mul.s %[f7], %[f10], %[f6] \n\t"
- "mul.s %[f6], %[f9], %[f6] \n\t"
- "mul.s %[f8], %[f10], %[f8] \n\t"
- "mul.s %[f2], %[f11], %[f0] \n\t"
- "mul.s %[f11], %[f11], %[f5] \n\t"
- "mul.s %[f5], %[f12], %[f5] \n\t"
- "mul.s %[f0], %[f12], %[f0] \n\t"
- "mul.s %[f12], %[f13], %[f3] \n\t"
- "mul.s %[f13], %[f13], %[f1] \n\t"
- "mul.s %[f1], %[f14], %[f1] \n\t"
- "mul.s %[f3], %[f14], %[f3] \n\t"
- "sub.s %[f4], %[f4], %[f7] \n\t"
- "add.s %[f8], %[f6], %[f8] \n\t"
- "sub.s %[f7], %[f2], %[f5] \n\t"
- "add.s %[f0], %[f11], %[f0] \n\t"
- "sub.s %[f2], %[f12], %[f1] \n\t"
- "add.s %[f3], %[f13], %[f3] \n\t"
+ "mul.s %[f7], %[f10], %[f6] \n\t"
+ "mul.s %[f6], %[f9], %[f6] \n\t"
+ "mul.s %[f8], %[f10], %[f8] \n\t"
+ "mul.s %[f2], %[f11], %[f0] \n\t"
+ "mul.s %[f11], %[f11], %[f5] \n\t"
+ "mul.s %[f5], %[f12], %[f5] \n\t"
+ "mul.s %[f0], %[f12], %[f0] \n\t"
+ "mul.s %[f12], %[f13], %[f3] \n\t"
+ "mul.s %[f13], %[f13], %[f1] \n\t"
+ "mul.s %[f1], %[f14], %[f1] \n\t"
+ "mul.s %[f3], %[f14], %[f3] \n\t"
+ "sub.s %[f4], %[f4], %[f7] \n\t"
+ "add.s %[f8], %[f6], %[f8] \n\t"
+ "sub.s %[f7], %[f2], %[f5] \n\t"
+ "add.s %[f0], %[f11], %[f0] \n\t"
+ "sub.s %[f2], %[f12], %[f1] \n\t"
+ "add.s %[f3], %[f13], %[f3] \n\t"
#endif
- "swc1 %[f4], 16(%[a_ptr]) \n\t"
- "swc1 %[f8], 20(%[a_ptr]) \n\t"
- "swc1 %[f7], 8(%[a_ptr]) \n\t"
- "swc1 %[f0], 12(%[a_ptr]) \n\t"
- "swc1 %[f2], 24(%[a_ptr]) \n\t"
- "swc1 %[f3], 28(%[a_ptr]) \n\t"
- "lwc1 %[f0], 32(%[a_ptr]) \n\t"
- "lwc1 %[f1], 36(%[a_ptr]) \n\t"
- "lwc1 %[f2], 40(%[a_ptr]) \n\t"
- "lwc1 %[f3], 44(%[a_ptr]) \n\t"
- "lwc1 %[f4], 48(%[a_ptr]) \n\t"
- "lwc1 %[f5], 52(%[a_ptr]) \n\t"
- "lwc1 %[f6], 56(%[a_ptr]) \n\t"
- "lwc1 %[f7], 60(%[a_ptr]) \n\t"
- "add.s %[f8], %[f0], %[f2] \n\t"
- "sub.s %[f0], %[f0], %[f2] \n\t"
- "add.s %[f2], %[f4], %[f6] \n\t"
- "sub.s %[f4], %[f4], %[f6] \n\t"
- "add.s %[f6], %[f1], %[f3] \n\t"
- "sub.s %[f1], %[f1], %[f3] \n\t"
- "add.s %[f3], %[f5], %[f7] \n\t"
- "sub.s %[f5], %[f5], %[f7] \n\t"
- "lwc1 %[f11], 8(%[p2_rdft]) \n\t"
- "lwc1 %[f12], 12(%[p2_rdft]) \n\t"
- "lwc1 %[f13], 8(%[second]) \n\t"
- "lwc1 %[f14], 12(%[second]) \n\t"
- "add.s %[f7], %[f8], %[f2] \n\t"
- "sub.s %[f8], %[f2], %[f8] \n\t"
- "add.s %[f2], %[f6], %[f3] \n\t"
- "sub.s %[f6], %[f3], %[f6] \n\t"
- "add.s %[f3], %[f0], %[f5] \n\t"
- "sub.s %[f0], %[f0], %[f5] \n\t"
- "add.s %[f5], %[f1], %[f4] \n\t"
- "sub.s %[f1], %[f1], %[f4] \n\t"
- "swc1 %[f7], 32(%[a_ptr]) \n\t"
- "swc1 %[f2], 36(%[a_ptr]) \n\t"
- "mul.s %[f4], %[f10], %[f8] \n\t"
+ "swc1 %[f4], 16(%[a_ptr]) \n\t"
+ "swc1 %[f8], 20(%[a_ptr]) \n\t"
+ "swc1 %[f7], 8(%[a_ptr]) \n\t"
+ "swc1 %[f0], 12(%[a_ptr]) \n\t"
+ "swc1 %[f2], 24(%[a_ptr]) \n\t"
+ "swc1 %[f3], 28(%[a_ptr]) \n\t"
+ "lwc1 %[f0], 32(%[a_ptr]) \n\t"
+ "lwc1 %[f1], 36(%[a_ptr]) \n\t"
+ "lwc1 %[f2], 40(%[a_ptr]) \n\t"
+ "lwc1 %[f3], 44(%[a_ptr]) \n\t"
+ "lwc1 %[f4], 48(%[a_ptr]) \n\t"
+ "lwc1 %[f5], 52(%[a_ptr]) \n\t"
+ "lwc1 %[f6], 56(%[a_ptr]) \n\t"
+ "lwc1 %[f7], 60(%[a_ptr]) \n\t"
+ "add.s %[f8], %[f0], %[f2] \n\t"
+ "sub.s %[f0], %[f0], %[f2] \n\t"
+ "add.s %[f2], %[f4], %[f6] \n\t"
+ "sub.s %[f4], %[f4], %[f6] \n\t"
+ "add.s %[f6], %[f1], %[f3] \n\t"
+ "sub.s %[f1], %[f1], %[f3] \n\t"
+ "add.s %[f3], %[f5], %[f7] \n\t"
+ "sub.s %[f5], %[f5], %[f7] \n\t"
+ "lwc1 %[f11], 8(%[p2_rdft]) \n\t"
+ "lwc1 %[f12], 12(%[p2_rdft]) \n\t"
+ "lwc1 %[f13], 8(%[second]) \n\t"
+ "lwc1 %[f14], 12(%[second]) \n\t"
+ "add.s %[f7], %[f8], %[f2] \n\t"
+ "sub.s %[f8], %[f2], %[f8] \n\t"
+ "add.s %[f2], %[f6], %[f3] \n\t"
+ "sub.s %[f6], %[f3], %[f6] \n\t"
+ "add.s %[f3], %[f0], %[f5] \n\t"
+ "sub.s %[f0], %[f0], %[f5] \n\t"
+ "add.s %[f5], %[f1], %[f4] \n\t"
+ "sub.s %[f1], %[f1], %[f4] \n\t"
+ "swc1 %[f7], 32(%[a_ptr]) \n\t"
+ "swc1 %[f2], 36(%[a_ptr]) \n\t"
+ "mul.s %[f4], %[f10], %[f8] \n\t"
#if defined(MIPS32_R2_LE)
- "mul.s %[f10], %[f10], %[f6] \n\t"
- "mul.s %[f7], %[f11], %[f0] \n\t"
- "mul.s %[f11], %[f11], %[f5] \n\t"
- "mul.s %[f2], %[f13], %[f3] \n\t"
- "mul.s %[f13], %[f13], %[f1] \n\t"
- "madd.s %[f4], %[f4], %[f9], %[f6] \n\t"
- "nmsub.s %[f10], %[f10], %[f9], %[f8] \n\t"
- "nmsub.s %[f7], %[f7], %[f12], %[f5] \n\t"
- "madd.s %[f11], %[f11], %[f12], %[f0] \n\t"
- "nmsub.s %[f2], %[f2], %[f14], %[f1] \n\t"
- "madd.s %[f13], %[f13], %[f14], %[f3] \n\t"
+ "mul.s %[f10], %[f10], %[f6] \n\t"
+ "mul.s %[f7], %[f11], %[f0] \n\t"
+ "mul.s %[f11], %[f11], %[f5] \n\t"
+ "mul.s %[f2], %[f13], %[f3] \n\t"
+ "mul.s %[f13], %[f13], %[f1] \n\t"
+ "madd.s %[f4], %[f4], %[f9], %[f6] \n\t"
+ "nmsub.s %[f10], %[f10], %[f9], %[f8] \n\t"
+ "nmsub.s %[f7], %[f7], %[f12], %[f5] \n\t"
+ "madd.s %[f11], %[f11], %[f12], %[f0] \n\t"
+ "nmsub.s %[f2], %[f2], %[f14], %[f1] \n\t"
+ "madd.s %[f13], %[f13], %[f14], %[f3] \n\t"
#else
- "mul.s %[f2], %[f9], %[f6] \n\t"
- "mul.s %[f10], %[f10], %[f6] \n\t"
- "mul.s %[f9], %[f9], %[f8] \n\t"
- "mul.s %[f7], %[f11], %[f0] \n\t"
- "mul.s %[f8], %[f12], %[f5] \n\t"
- "mul.s %[f11], %[f11], %[f5] \n\t"
- "mul.s %[f12], %[f12], %[f0] \n\t"
- "mul.s %[f5], %[f13], %[f3] \n\t"
- "mul.s %[f0], %[f14], %[f1] \n\t"
- "mul.s %[f13], %[f13], %[f1] \n\t"
- "mul.s %[f14], %[f14], %[f3] \n\t"
- "add.s %[f4], %[f4], %[f2] \n\t"
- "sub.s %[f10], %[f10], %[f9] \n\t"
- "sub.s %[f7], %[f7], %[f8] \n\t"
- "add.s %[f11], %[f11], %[f12] \n\t"
- "sub.s %[f2], %[f5], %[f0] \n\t"
- "add.s %[f13], %[f13], %[f14] \n\t"
+ "mul.s %[f2], %[f9], %[f6] \n\t"
+ "mul.s %[f10], %[f10], %[f6] \n\t"
+ "mul.s %[f9], %[f9], %[f8] \n\t"
+ "mul.s %[f7], %[f11], %[f0] \n\t"
+ "mul.s %[f8], %[f12], %[f5] \n\t"
+ "mul.s %[f11], %[f11], %[f5] \n\t"
+ "mul.s %[f12], %[f12], %[f0] \n\t"
+ "mul.s %[f5], %[f13], %[f3] \n\t"
+ "mul.s %[f0], %[f14], %[f1] \n\t"
+ "mul.s %[f13], %[f13], %[f1] \n\t"
+ "mul.s %[f14], %[f14], %[f3] \n\t"
+ "add.s %[f4], %[f4], %[f2] \n\t"
+ "sub.s %[f10], %[f10], %[f9] \n\t"
+ "sub.s %[f7], %[f7], %[f8] \n\t"
+ "add.s %[f11], %[f11], %[f12] \n\t"
+ "sub.s %[f2], %[f5], %[f0] \n\t"
+ "add.s %[f13], %[f13], %[f14] \n\t"
#endif
- "swc1 %[f4], 48(%[a_ptr]) \n\t"
- "swc1 %[f10], 52(%[a_ptr]) \n\t"
- "swc1 %[f7], 40(%[a_ptr]) \n\t"
- "swc1 %[f11], 44(%[a_ptr]) \n\t"
- "swc1 %[f2], 56(%[a_ptr]) \n\t"
- "swc1 %[f13], 60(%[a_ptr]) \n\t"
- "addiu %[count], %[count], -1 \n\t"
- "lwc1 %[f9], 8(%[p1_rdft]) \n\t"
- "addiu %[a_ptr], %[a_ptr], 64 \n\t"
- "addiu %[p1_rdft], %[p1_rdft], 8 \n\t"
- "addiu %[p2_rdft], %[p2_rdft], 16 \n\t"
- "addiu %[first], %[first], 8 \n\t"
- "bgtz %[count], 1b \n\t"
- " addiu %[second], %[second], 8 \n\t"
- ".set pop \n\t"
- : [f0] "=&f" (f0), [f1] "=&f" (f1), [f2] "=&f" (f2), [f3] "=&f" (f3),
- [f4] "=&f" (f4), [f5] "=&f" (f5), [f6] "=&f" (f6), [f7] "=&f" (f7),
- [f8] "=&f" (f8), [f9] "=&f" (f9), [f10] "=&f" (f10), [f11] "=&f" (f11),
- [f12] "=&f" (f12), [f13] "=&f" (f13), [f14] "=&f" (f14),
- [a_ptr] "=&r" (a_ptr), [p1_rdft] "=&r" (p1_rdft), [first] "+r" (first),
- [p2_rdft] "=&r" (p2_rdft), [count] "=&r" (count), [second] "+r" (second)
- : [a] "r" (a), [rdft_w] "r" (rdft_w)
- : "memory"
- );
+ "swc1 %[f4], 48(%[a_ptr]) \n\t"
+ "swc1 %[f10], 52(%[a_ptr]) \n\t"
+ "swc1 %[f7], 40(%[a_ptr]) \n\t"
+ "swc1 %[f11], 44(%[a_ptr]) \n\t"
+ "swc1 %[f2], 56(%[a_ptr]) \n\t"
+ "swc1 %[f13], 60(%[a_ptr]) \n\t"
+ "addiu %[count], %[count], -1 \n\t"
+ "lwc1 %[f9], 8(%[p1_rdft]) \n\t"
+ "addiu %[a_ptr], %[a_ptr], 64 \n\t"
+ "addiu %[p1_rdft], %[p1_rdft], 8 \n\t"
+ "addiu %[p2_rdft], %[p2_rdft], 16 \n\t"
+ "addiu %[first], %[first], 8 \n\t"
+ "bgtz %[count], 1b \n\t"
+ " addiu %[second], %[second], 8 \n\t"
+ ".set pop \n\t"
+ : [f0] "=&f"(f0), [f1] "=&f"(f1), [f2] "=&f"(f2), [f3] "=&f"(f3),
+ [f4] "=&f"(f4), [f5] "=&f"(f5), [f6] "=&f"(f6), [f7] "=&f"(f7),
+ [f8] "=&f"(f8), [f9] "=&f"(f9), [f10] "=&f"(f10), [f11] "=&f"(f11),
+ [f12] "=&f"(f12), [f13] "=&f"(f13), [f14] "=&f"(f14),
+ [a_ptr] "=&r"(a_ptr), [p1_rdft] "=&r"(p1_rdft), [first] "+r"(first),
+ [p2_rdft] "=&r"(p2_rdft), [count] "=&r"(count), [second] "+r"(second)
+ : [a] "r"(a), [rdft_w] "r"(rdft_w)
+ : "memory");
}
void cftmdl_128_mips(float* a) {
float f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14;
int tmp_a, count;
- __asm __volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "addiu %[tmp_a], %[a], 0 \n\t"
- "addiu %[count], $zero, 4 \n\t"
- "1: \n\t"
- "addiu %[count], %[count], -1 \n\t"
- "lwc1 %[f0], 0(%[tmp_a]) \n\t"
- "lwc1 %[f2], 32(%[tmp_a]) \n\t"
- "lwc1 %[f4], 64(%[tmp_a]) \n\t"
- "lwc1 %[f6], 96(%[tmp_a]) \n\t"
- "lwc1 %[f1], 4(%[tmp_a]) \n\t"
- "lwc1 %[f3], 36(%[tmp_a]) \n\t"
- "lwc1 %[f5], 68(%[tmp_a]) \n\t"
- "lwc1 %[f7], 100(%[tmp_a]) \n\t"
- "add.s %[f8], %[f0], %[f2] \n\t"
- "sub.s %[f0], %[f0], %[f2] \n\t"
- "add.s %[f2], %[f4], %[f6] \n\t"
- "sub.s %[f4], %[f4], %[f6] \n\t"
- "add.s %[f6], %[f1], %[f3] \n\t"
- "sub.s %[f1], %[f1], %[f3] \n\t"
- "add.s %[f3], %[f5], %[f7] \n\t"
- "sub.s %[f5], %[f5], %[f7] \n\t"
- "add.s %[f7], %[f8], %[f2] \n\t"
- "sub.s %[f8], %[f8], %[f2] \n\t"
- "add.s %[f2], %[f1], %[f4] \n\t"
- "sub.s %[f1], %[f1], %[f4] \n\t"
- "add.s %[f4], %[f6], %[f3] \n\t"
- "sub.s %[f6], %[f6], %[f3] \n\t"
- "sub.s %[f3], %[f0], %[f5] \n\t"
- "add.s %[f0], %[f0], %[f5] \n\t"
- "swc1 %[f7], 0(%[tmp_a]) \n\t"
- "swc1 %[f8], 64(%[tmp_a]) \n\t"
- "swc1 %[f2], 36(%[tmp_a]) \n\t"
- "swc1 %[f1], 100(%[tmp_a]) \n\t"
- "swc1 %[f4], 4(%[tmp_a]) \n\t"
- "swc1 %[f6], 68(%[tmp_a]) \n\t"
- "swc1 %[f3], 32(%[tmp_a]) \n\t"
- "swc1 %[f0], 96(%[tmp_a]) \n\t"
- "bgtz %[count], 1b \n\t"
- " addiu %[tmp_a], %[tmp_a], 8 \n\t"
- ".set pop \n\t"
- : [f0] "=&f" (f0), [f1] "=&f" (f1), [f2] "=&f" (f2), [f3] "=&f" (f3),
- [f4] "=&f" (f4), [f5] "=&f" (f5), [f6] "=&f" (f6), [f7] "=&f" (f7),
- [f8] "=&f" (f8), [tmp_a] "=&r" (tmp_a), [count] "=&r" (count)
- : [a] "r" (a)
- : "memory"
- );
+ __asm __volatile(
+ ".set push \n\t"
+ ".set noreorder \n\t"
+ "addiu %[tmp_a], %[a], 0 \n\t"
+ "addiu %[count], $zero, 4 \n\t"
+ "1: \n\t"
+ "addiu %[count], %[count], -1 \n\t"
+ "lwc1 %[f0], 0(%[tmp_a]) \n\t"
+ "lwc1 %[f2], 32(%[tmp_a]) \n\t"
+ "lwc1 %[f4], 64(%[tmp_a]) \n\t"
+ "lwc1 %[f6], 96(%[tmp_a]) \n\t"
+ "lwc1 %[f1], 4(%[tmp_a]) \n\t"
+ "lwc1 %[f3], 36(%[tmp_a]) \n\t"
+ "lwc1 %[f5], 68(%[tmp_a]) \n\t"
+ "lwc1 %[f7], 100(%[tmp_a]) \n\t"
+ "add.s %[f8], %[f0], %[f2] \n\t"
+ "sub.s %[f0], %[f0], %[f2] \n\t"
+ "add.s %[f2], %[f4], %[f6] \n\t"
+ "sub.s %[f4], %[f4], %[f6] \n\t"
+ "add.s %[f6], %[f1], %[f3] \n\t"
+ "sub.s %[f1], %[f1], %[f3] \n\t"
+ "add.s %[f3], %[f5], %[f7] \n\t"
+ "sub.s %[f5], %[f5], %[f7] \n\t"
+ "add.s %[f7], %[f8], %[f2] \n\t"
+ "sub.s %[f8], %[f8], %[f2] \n\t"
+ "add.s %[f2], %[f1], %[f4] \n\t"
+ "sub.s %[f1], %[f1], %[f4] \n\t"
+ "add.s %[f4], %[f6], %[f3] \n\t"
+ "sub.s %[f6], %[f6], %[f3] \n\t"
+ "sub.s %[f3], %[f0], %[f5] \n\t"
+ "add.s %[f0], %[f0], %[f5] \n\t"
+ "swc1 %[f7], 0(%[tmp_a]) \n\t"
+ "swc1 %[f8], 64(%[tmp_a]) \n\t"
+ "swc1 %[f2], 36(%[tmp_a]) \n\t"
+ "swc1 %[f1], 100(%[tmp_a]) \n\t"
+ "swc1 %[f4], 4(%[tmp_a]) \n\t"
+ "swc1 %[f6], 68(%[tmp_a]) \n\t"
+ "swc1 %[f3], 32(%[tmp_a]) \n\t"
+ "swc1 %[f0], 96(%[tmp_a]) \n\t"
+ "bgtz %[count], 1b \n\t"
+ " addiu %[tmp_a], %[tmp_a], 8 \n\t"
+ ".set pop \n\t"
+ : [f0] "=&f"(f0), [f1] "=&f"(f1), [f2] "=&f"(f2), [f3] "=&f"(f3),
+ [f4] "=&f"(f4), [f5] "=&f"(f5), [f6] "=&f"(f6), [f7] "=&f"(f7),
+ [f8] "=&f"(f8), [tmp_a] "=&r"(tmp_a), [count] "=&r"(count)
+ : [a] "r"(a)
+ : "memory");
f9 = rdft_w[2];
- __asm __volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "addiu %[tmp_a], %[a], 128 \n\t"
- "addiu %[count], $zero, 4 \n\t"
- "1: \n\t"
- "addiu %[count], %[count], -1 \n\t"
- "lwc1 %[f0], 0(%[tmp_a]) \n\t"
- "lwc1 %[f2], 32(%[tmp_a]) \n\t"
- "lwc1 %[f5], 68(%[tmp_a]) \n\t"
- "lwc1 %[f7], 100(%[tmp_a]) \n\t"
- "lwc1 %[f1], 4(%[tmp_a]) \n\t"
- "lwc1 %[f3], 36(%[tmp_a]) \n\t"
- "lwc1 %[f4], 64(%[tmp_a]) \n\t"
- "lwc1 %[f6], 96(%[tmp_a]) \n\t"
- "sub.s %[f8], %[f0], %[f2] \n\t"
- "add.s %[f0], %[f0], %[f2] \n\t"
- "sub.s %[f2], %[f5], %[f7] \n\t"
- "add.s %[f5], %[f5], %[f7] \n\t"
- "sub.s %[f7], %[f1], %[f3] \n\t"
- "add.s %[f1], %[f1], %[f3] \n\t"
- "sub.s %[f3], %[f4], %[f6] \n\t"
- "add.s %[f4], %[f4], %[f6] \n\t"
- "sub.s %[f6], %[f8], %[f2] \n\t"
- "add.s %[f8], %[f8], %[f2] \n\t"
- "add.s %[f2], %[f5], %[f1] \n\t"
- "sub.s %[f5], %[f5], %[f1] \n\t"
- "add.s %[f1], %[f3], %[f7] \n\t"
- "sub.s %[f3], %[f3], %[f7] \n\t"
- "add.s %[f7], %[f0], %[f4] \n\t"
- "sub.s %[f0], %[f0], %[f4] \n\t"
- "sub.s %[f4], %[f6], %[f1] \n\t"
- "add.s %[f6], %[f6], %[f1] \n\t"
- "sub.s %[f1], %[f3], %[f8] \n\t"
- "add.s %[f3], %[f3], %[f8] \n\t"
- "mul.s %[f4], %[f4], %[f9] \n\t"
- "mul.s %[f6], %[f6], %[f9] \n\t"
- "mul.s %[f1], %[f1], %[f9] \n\t"
- "mul.s %[f3], %[f3], %[f9] \n\t"
- "swc1 %[f7], 0(%[tmp_a]) \n\t"
- "swc1 %[f2], 4(%[tmp_a]) \n\t"
- "swc1 %[f5], 64(%[tmp_a]) \n\t"
- "swc1 %[f0], 68(%[tmp_a]) \n\t"
- "swc1 %[f4], 32(%[tmp_a]) \n\t"
- "swc1 %[f6], 36(%[tmp_a]) \n\t"
- "swc1 %[f1], 96(%[tmp_a]) \n\t"
- "swc1 %[f3], 100(%[tmp_a]) \n\t"
- "bgtz %[count], 1b \n\t"
- " addiu %[tmp_a], %[tmp_a], 8 \n\t"
- ".set pop \n\t"
- : [f0] "=&f" (f0), [f1] "=&f" (f1), [f2] "=&f" (f2), [f3] "=&f" (f3),
- [f4] "=&f" (f4), [f5] "=&f" (f5), [f6] "=&f" (f6), [f7] "=&f" (f7),
- [f8] "=&f" (f8), [tmp_a] "=&r" (tmp_a), [count] "=&r" (count)
- : [a] "r" (a), [f9] "f" (f9)
- : "memory"
- );
+ __asm __volatile(
+ ".set push \n\t"
+ ".set noreorder \n\t"
+ "addiu %[tmp_a], %[a], 128 \n\t"
+ "addiu %[count], $zero, 4 \n\t"
+ "1: \n\t"
+ "addiu %[count], %[count], -1 \n\t"
+ "lwc1 %[f0], 0(%[tmp_a]) \n\t"
+ "lwc1 %[f2], 32(%[tmp_a]) \n\t"
+ "lwc1 %[f5], 68(%[tmp_a]) \n\t"
+ "lwc1 %[f7], 100(%[tmp_a]) \n\t"
+ "lwc1 %[f1], 4(%[tmp_a]) \n\t"
+ "lwc1 %[f3], 36(%[tmp_a]) \n\t"
+ "lwc1 %[f4], 64(%[tmp_a]) \n\t"
+ "lwc1 %[f6], 96(%[tmp_a]) \n\t"
+ "sub.s %[f8], %[f0], %[f2] \n\t"
+ "add.s %[f0], %[f0], %[f2] \n\t"
+ "sub.s %[f2], %[f5], %[f7] \n\t"
+ "add.s %[f5], %[f5], %[f7] \n\t"
+ "sub.s %[f7], %[f1], %[f3] \n\t"
+ "add.s %[f1], %[f1], %[f3] \n\t"
+ "sub.s %[f3], %[f4], %[f6] \n\t"
+ "add.s %[f4], %[f4], %[f6] \n\t"
+ "sub.s %[f6], %[f8], %[f2] \n\t"
+ "add.s %[f8], %[f8], %[f2] \n\t"
+ "add.s %[f2], %[f5], %[f1] \n\t"
+ "sub.s %[f5], %[f5], %[f1] \n\t"
+ "add.s %[f1], %[f3], %[f7] \n\t"
+ "sub.s %[f3], %[f3], %[f7] \n\t"
+ "add.s %[f7], %[f0], %[f4] \n\t"
+ "sub.s %[f0], %[f0], %[f4] \n\t"
+ "sub.s %[f4], %[f6], %[f1] \n\t"
+ "add.s %[f6], %[f6], %[f1] \n\t"
+ "sub.s %[f1], %[f3], %[f8] \n\t"
+ "add.s %[f3], %[f3], %[f8] \n\t"
+ "mul.s %[f4], %[f4], %[f9] \n\t"
+ "mul.s %[f6], %[f6], %[f9] \n\t"
+ "mul.s %[f1], %[f1], %[f9] \n\t"
+ "mul.s %[f3], %[f3], %[f9] \n\t"
+ "swc1 %[f7], 0(%[tmp_a]) \n\t"
+ "swc1 %[f2], 4(%[tmp_a]) \n\t"
+ "swc1 %[f5], 64(%[tmp_a]) \n\t"
+ "swc1 %[f0], 68(%[tmp_a]) \n\t"
+ "swc1 %[f4], 32(%[tmp_a]) \n\t"
+ "swc1 %[f6], 36(%[tmp_a]) \n\t"
+ "swc1 %[f1], 96(%[tmp_a]) \n\t"
+ "swc1 %[f3], 100(%[tmp_a]) \n\t"
+ "bgtz %[count], 1b \n\t"
+ " addiu %[tmp_a], %[tmp_a], 8 \n\t"
+ ".set pop \n\t"
+ : [f0] "=&f"(f0), [f1] "=&f"(f1), [f2] "=&f"(f2), [f3] "=&f"(f3),
+ [f4] "=&f"(f4), [f5] "=&f"(f5), [f6] "=&f"(f6), [f7] "=&f"(f7),
+ [f8] "=&f"(f8), [tmp_a] "=&r"(tmp_a), [count] "=&r"(count)
+ : [a] "r"(a), [f9] "f"(f9)
+ : "memory");
f10 = rdft_w[3];
f11 = rdft_w[4];
f12 = rdft_w[5];
f13 = rdft_wk3ri_first[2];
f14 = rdft_wk3ri_first[3];
- __asm __volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "addiu %[tmp_a], %[a], 256 \n\t"
- "addiu %[count], $zero, 4 \n\t"
- "1: \n\t"
- "addiu %[count], %[count], -1 \n\t"
- "lwc1 %[f0], 0(%[tmp_a]) \n\t"
- "lwc1 %[f2], 32(%[tmp_a]) \n\t"
- "lwc1 %[f4], 64(%[tmp_a]) \n\t"
- "lwc1 %[f6], 96(%[tmp_a]) \n\t"
- "lwc1 %[f1], 4(%[tmp_a]) \n\t"
- "lwc1 %[f3], 36(%[tmp_a]) \n\t"
- "lwc1 %[f5], 68(%[tmp_a]) \n\t"
- "lwc1 %[f7], 100(%[tmp_a]) \n\t"
- "add.s %[f8], %[f0], %[f2] \n\t"
- "sub.s %[f0], %[f0], %[f2] \n\t"
- "add.s %[f2], %[f4], %[f6] \n\t"
- "sub.s %[f4], %[f4], %[f6] \n\t"
- "add.s %[f6], %[f1], %[f3] \n\t"
- "sub.s %[f1], %[f1], %[f3] \n\t"
- "add.s %[f3], %[f5], %[f7] \n\t"
- "sub.s %[f5], %[f5], %[f7] \n\t"
- "sub.s %[f7], %[f8], %[f2] \n\t"
- "add.s %[f8], %[f8], %[f2] \n\t"
- "add.s %[f2], %[f1], %[f4] \n\t"
- "sub.s %[f1], %[f1], %[f4] \n\t"
- "sub.s %[f4], %[f6], %[f3] \n\t"
- "add.s %[f6], %[f6], %[f3] \n\t"
- "sub.s %[f3], %[f0], %[f5] \n\t"
- "add.s %[f0], %[f0], %[f5] \n\t"
- "swc1 %[f8], 0(%[tmp_a]) \n\t"
- "swc1 %[f6], 4(%[tmp_a]) \n\t"
- "mul.s %[f5], %[f9], %[f7] \n\t"
+ __asm __volatile(
+ ".set push \n\t"
+ ".set noreorder \n\t"
+ "addiu %[tmp_a], %[a], 256 \n\t"
+ "addiu %[count], $zero, 4 \n\t"
+ "1: \n\t"
+ "addiu %[count], %[count], -1 \n\t"
+ "lwc1 %[f0], 0(%[tmp_a]) \n\t"
+ "lwc1 %[f2], 32(%[tmp_a]) \n\t"
+ "lwc1 %[f4], 64(%[tmp_a]) \n\t"
+ "lwc1 %[f6], 96(%[tmp_a]) \n\t"
+ "lwc1 %[f1], 4(%[tmp_a]) \n\t"
+ "lwc1 %[f3], 36(%[tmp_a]) \n\t"
+ "lwc1 %[f5], 68(%[tmp_a]) \n\t"
+ "lwc1 %[f7], 100(%[tmp_a]) \n\t"
+ "add.s %[f8], %[f0], %[f2] \n\t"
+ "sub.s %[f0], %[f0], %[f2] \n\t"
+ "add.s %[f2], %[f4], %[f6] \n\t"
+ "sub.s %[f4], %[f4], %[f6] \n\t"
+ "add.s %[f6], %[f1], %[f3] \n\t"
+ "sub.s %[f1], %[f1], %[f3] \n\t"
+ "add.s %[f3], %[f5], %[f7] \n\t"
+ "sub.s %[f5], %[f5], %[f7] \n\t"
+ "sub.s %[f7], %[f8], %[f2] \n\t"
+ "add.s %[f8], %[f8], %[f2] \n\t"
+ "add.s %[f2], %[f1], %[f4] \n\t"
+ "sub.s %[f1], %[f1], %[f4] \n\t"
+ "sub.s %[f4], %[f6], %[f3] \n\t"
+ "add.s %[f6], %[f6], %[f3] \n\t"
+ "sub.s %[f3], %[f0], %[f5] \n\t"
+ "add.s %[f0], %[f0], %[f5] \n\t"
+ "swc1 %[f8], 0(%[tmp_a]) \n\t"
+ "swc1 %[f6], 4(%[tmp_a]) \n\t"
+ "mul.s %[f5], %[f9], %[f7] \n\t"
#if defined(MIPS32_R2_LE)
- "mul.s %[f7], %[f10], %[f7] \n\t"
- "mul.s %[f8], %[f11], %[f3] \n\t"
- "mul.s %[f3], %[f12], %[f3] \n\t"
- "mul.s %[f6], %[f13], %[f0] \n\t"
- "mul.s %[f0], %[f14], %[f0] \n\t"
- "nmsub.s %[f5], %[f5], %[f10], %[f4] \n\t"
- "madd.s %[f7], %[f7], %[f9], %[f4] \n\t"
- "nmsub.s %[f8], %[f8], %[f12], %[f2] \n\t"
- "madd.s %[f3], %[f3], %[f11], %[f2] \n\t"
- "nmsub.s %[f6], %[f6], %[f14], %[f1] \n\t"
- "madd.s %[f0], %[f0], %[f13], %[f1] \n\t"
- "swc1 %[f5], 64(%[tmp_a]) \n\t"
- "swc1 %[f7], 68(%[tmp_a]) \n\t"
+ "mul.s %[f7], %[f10], %[f7] \n\t"
+ "mul.s %[f8], %[f11], %[f3] \n\t"
+ "mul.s %[f3], %[f12], %[f3] \n\t"
+ "mul.s %[f6], %[f13], %[f0] \n\t"
+ "mul.s %[f0], %[f14], %[f0] \n\t"
+ "nmsub.s %[f5], %[f5], %[f10], %[f4] \n\t"
+ "madd.s %[f7], %[f7], %[f9], %[f4] \n\t"
+ "nmsub.s %[f8], %[f8], %[f12], %[f2] \n\t"
+ "madd.s %[f3], %[f3], %[f11], %[f2] \n\t"
+ "nmsub.s %[f6], %[f6], %[f14], %[f1] \n\t"
+ "madd.s %[f0], %[f0], %[f13], %[f1] \n\t"
+ "swc1 %[f5], 64(%[tmp_a]) \n\t"
+ "swc1 %[f7], 68(%[tmp_a]) \n\t"
#else
- "mul.s %[f8], %[f10], %[f4] \n\t"
- "mul.s %[f4], %[f9], %[f4] \n\t"
- "mul.s %[f7], %[f10], %[f7] \n\t"
- "mul.s %[f6], %[f11], %[f3] \n\t"
- "mul.s %[f3], %[f12], %[f3] \n\t"
- "sub.s %[f5], %[f5], %[f8] \n\t"
- "mul.s %[f8], %[f12], %[f2] \n\t"
- "mul.s %[f2], %[f11], %[f2] \n\t"
- "add.s %[f7], %[f4], %[f7] \n\t"
- "mul.s %[f4], %[f13], %[f0] \n\t"
- "mul.s %[f0], %[f14], %[f0] \n\t"
- "sub.s %[f8], %[f6], %[f8] \n\t"
- "mul.s %[f6], %[f14], %[f1] \n\t"
- "mul.s %[f1], %[f13], %[f1] \n\t"
- "add.s %[f3], %[f2], %[f3] \n\t"
- "swc1 %[f5], 64(%[tmp_a]) \n\t"
- "swc1 %[f7], 68(%[tmp_a]) \n\t"
- "sub.s %[f6], %[f4], %[f6] \n\t"
- "add.s %[f0], %[f1], %[f0] \n\t"
+ "mul.s %[f8], %[f10], %[f4] \n\t"
+ "mul.s %[f4], %[f9], %[f4] \n\t"
+ "mul.s %[f7], %[f10], %[f7] \n\t"
+ "mul.s %[f6], %[f11], %[f3] \n\t"
+ "mul.s %[f3], %[f12], %[f3] \n\t"
+ "sub.s %[f5], %[f5], %[f8] \n\t"
+ "mul.s %[f8], %[f12], %[f2] \n\t"
+ "mul.s %[f2], %[f11], %[f2] \n\t"
+ "add.s %[f7], %[f4], %[f7] \n\t"
+ "mul.s %[f4], %[f13], %[f0] \n\t"
+ "mul.s %[f0], %[f14], %[f0] \n\t"
+ "sub.s %[f8], %[f6], %[f8] \n\t"
+ "mul.s %[f6], %[f14], %[f1] \n\t"
+ "mul.s %[f1], %[f13], %[f1] \n\t"
+ "add.s %[f3], %[f2], %[f3] \n\t"
+ "swc1 %[f5], 64(%[tmp_a]) \n\t"
+ "swc1 %[f7], 68(%[tmp_a]) \n\t"
+ "sub.s %[f6], %[f4], %[f6] \n\t"
+ "add.s %[f0], %[f1], %[f0] \n\t"
#endif
- "swc1 %[f8], 32(%[tmp_a]) \n\t"
- "swc1 %[f3], 36(%[tmp_a]) \n\t"
- "swc1 %[f6], 96(%[tmp_a]) \n\t"
- "swc1 %[f0], 100(%[tmp_a]) \n\t"
- "bgtz %[count], 1b \n\t"
- " addiu %[tmp_a], %[tmp_a], 8 \n\t"
- ".set pop \n\t"
- : [f0] "=&f" (f0), [f1] "=&f" (f1), [f2] "=&f" (f2), [f3] "=&f" (f3),
- [f4] "=&f" (f4), [f5] "=&f" (f5), [f6] "=&f" (f6), [f7] "=&f" (f7),
- [f8] "=&f" (f8), [tmp_a] "=&r" (tmp_a), [count] "=&r" (count)
- : [a] "r" (a), [f9] "f" (f9), [f10] "f" (f10), [f11] "f" (f11),
- [f12] "f" (f12), [f13] "f" (f13), [f14] "f" (f14)
- : "memory"
- );
+ "swc1 %[f8], 32(%[tmp_a]) \n\t"
+ "swc1 %[f3], 36(%[tmp_a]) \n\t"
+ "swc1 %[f6], 96(%[tmp_a]) \n\t"
+ "swc1 %[f0], 100(%[tmp_a]) \n\t"
+ "bgtz %[count], 1b \n\t"
+ " addiu %[tmp_a], %[tmp_a], 8 \n\t"
+ ".set pop \n\t"
+ : [f0] "=&f"(f0), [f1] "=&f"(f1), [f2] "=&f"(f2), [f3] "=&f"(f3),
+ [f4] "=&f"(f4), [f5] "=&f"(f5), [f6] "=&f"(f6), [f7] "=&f"(f7),
+ [f8] "=&f"(f8), [tmp_a] "=&r"(tmp_a), [count] "=&r"(count)
+ : [a] "r"(a), [f9] "f"(f9), [f10] "f"(f10), [f11] "f"(f11),
+ [f12] "f"(f12), [f13] "f"(f13), [f14] "f"(f14)
+ : "memory");
f11 = rdft_w[6];
f12 = rdft_w[7];
f13 = rdft_wk3ri_second[2];
f14 = rdft_wk3ri_second[3];
- __asm __volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "addiu %[tmp_a], %[a], 384 \n\t"
- "addiu %[count], $zero, 4 \n\t"
- "1: \n\t"
- "addiu %[count], %[count], -1 \n\t"
- "lwc1 %[f0], 0(%[tmp_a]) \n\t"
- "lwc1 %[f1], 4(%[tmp_a]) \n\t"
- "lwc1 %[f2], 32(%[tmp_a]) \n\t"
- "lwc1 %[f3], 36(%[tmp_a]) \n\t"
- "lwc1 %[f4], 64(%[tmp_a]) \n\t"
- "lwc1 %[f5], 68(%[tmp_a]) \n\t"
- "lwc1 %[f6], 96(%[tmp_a]) \n\t"
- "lwc1 %[f7], 100(%[tmp_a]) \n\t"
- "add.s %[f8], %[f0], %[f2] \n\t"
- "sub.s %[f0], %[f0], %[f2] \n\t"
- "add.s %[f2], %[f4], %[f6] \n\t"
- "sub.s %[f4], %[f4], %[f6] \n\t"
- "add.s %[f6], %[f1], %[f3] \n\t"
- "sub.s %[f1], %[f1], %[f3] \n\t"
- "add.s %[f3], %[f5], %[f7] \n\t"
- "sub.s %[f5], %[f5], %[f7] \n\t"
- "sub.s %[f7], %[f2], %[f8] \n\t"
- "add.s %[f2], %[f2], %[f8] \n\t"
- "add.s %[f8], %[f1], %[f4] \n\t"
- "sub.s %[f1], %[f1], %[f4] \n\t"
- "sub.s %[f4], %[f3], %[f6] \n\t"
- "add.s %[f3], %[f3], %[f6] \n\t"
- "sub.s %[f6], %[f0], %[f5] \n\t"
- "add.s %[f0], %[f0], %[f5] \n\t"
- "swc1 %[f2], 0(%[tmp_a]) \n\t"
- "swc1 %[f3], 4(%[tmp_a]) \n\t"
- "mul.s %[f5], %[f10], %[f7] \n\t"
+ __asm __volatile(
+ ".set push "
+ "\n\t"
+ ".set noreorder "
+ "\n\t"
+ "addiu %[tmp_a], %[a], 384 "
+ "\n\t"
+ "addiu %[count], $zero, 4 "
+ "\n\t"
+ "1: "
+ "\n\t"
+ "addiu %[count], %[count], -1 "
+ "\n\t"
+ "lwc1 %[f0], 0(%[tmp_a]) "
+ "\n\t"
+ "lwc1 %[f1], 4(%[tmp_a]) "
+ "\n\t"
+ "lwc1 %[f2], 32(%[tmp_a]) "
+ "\n\t"
+ "lwc1 %[f3], 36(%[tmp_a]) "
+ "\n\t"
+ "lwc1 %[f4], 64(%[tmp_a]) "
+ "\n\t"
+ "lwc1 %[f5], 68(%[tmp_a]) "
+ "\n\t"
+ "lwc1 %[f6], 96(%[tmp_a]) "
+ "\n\t"
+ "lwc1 %[f7], 100(%[tmp_a]) "
+ "\n\t"
+ "add.s %[f8], %[f0], %[f2] "
+ "\n\t"
+ "sub.s %[f0], %[f0], %[f2] "
+ "\n\t"
+ "add.s %[f2], %[f4], %[f6] "
+ "\n\t"
+ "sub.s %[f4], %[f4], %[f6] "
+ "\n\t"
+ "add.s %[f6], %[f1], %[f3] "
+ "\n\t"
+ "sub.s %[f1], %[f1], %[f3] "
+ "\n\t"
+ "add.s %[f3], %[f5], %[f7] "
+ "\n\t"
+ "sub.s %[f5], %[f5], %[f7] "
+ "\n\t"
+ "sub.s %[f7], %[f2], %[f8] "
+ "\n\t"
+ "add.s %[f2], %[f2], %[f8] "
+ "\n\t"
+ "add.s %[f8], %[f1], %[f4] "
+ "\n\t"
+ "sub.s %[f1], %[f1], %[f4] "
+ "\n\t"
+ "sub.s %[f4], %[f3], %[f6] "
+ "\n\t"
+ "add.s %[f3], %[f3], %[f6] "
+ "\n\t"
+ "sub.s %[f6], %[f0], %[f5] "
+ "\n\t"
+ "add.s %[f0], %[f0], %[f5] "
+ "\n\t"
+ "swc1 %[f2], 0(%[tmp_a]) "
+ "\n\t"
+ "swc1 %[f3], 4(%[tmp_a]) "
+ "\n\t"
+ "mul.s %[f5], %[f10], %[f7] "
+ "\n\t"
#if defined(MIPS32_R2_LE)
- "mul.s %[f7], %[f9], %[f7] \n\t"
- "mul.s %[f2], %[f12], %[f8] \n\t"
- "mul.s %[f8], %[f11], %[f8] \n\t"
- "mul.s %[f3], %[f14], %[f1] \n\t"
- "mul.s %[f1], %[f13], %[f1] \n\t"
- "madd.s %[f5], %[f5], %[f9], %[f4] \n\t"
- "msub.s %[f7], %[f7], %[f10], %[f4] \n\t"
- "msub.s %[f2], %[f2], %[f11], %[f6] \n\t"
- "madd.s %[f8], %[f8], %[f12], %[f6] \n\t"
- "msub.s %[f3], %[f3], %[f13], %[f0] \n\t"
- "madd.s %[f1], %[f1], %[f14], %[f0] \n\t"
- "swc1 %[f5], 64(%[tmp_a]) \n\t"
- "swc1 %[f7], 68(%[tmp_a]) \n\t"
+ "mul.s %[f7], %[f9], %[f7] "
+ "\n\t"
+ "mul.s %[f2], %[f12], %[f8] "
+ "\n\t"
+ "mul.s %[f8], %[f11], %[f8] "
+ "\n\t"
+ "mul.s %[f3], %[f14], %[f1] "
+ "\n\t"
+ "mul.s %[f1], %[f13], %[f1] "
+ "\n\t"
+ "madd.s %[f5], %[f5], %[f9], %[f4] "
+ "\n\t"
+ "msub.s %[f7], %[f7], %[f10], %[f4] "
+ "\n\t"
+ "msub.s %[f2], %[f2], %[f11], %[f6] "
+ "\n\t"
+ "madd.s %[f8], %[f8], %[f12], %[f6] "
+ "\n\t"
+ "msub.s %[f3], %[f3], %[f13], %[f0] "
+ "\n\t"
+ "madd.s %[f1], %[f1], %[f14], %[f0] "
+ "\n\t"
+ "swc1 %[f5], 64(%[tmp_a]) "
+ "\n\t"
+ "swc1 %[f7], 68(%[tmp_a]) "
+ "\n\t"
#else
- "mul.s %[f2], %[f9], %[f4] \n\t"
- "mul.s %[f4], %[f10], %[f4] \n\t"
- "mul.s %[f7], %[f9], %[f7] \n\t"
- "mul.s %[f3], %[f11], %[f6] \n\t"
- "mul.s %[f6], %[f12], %[f6] \n\t"
- "add.s %[f5], %[f5], %[f2] \n\t"
- "sub.s %[f7], %[f4], %[f7] \n\t"
- "mul.s %[f2], %[f12], %[f8] \n\t"
- "mul.s %[f8], %[f11], %[f8] \n\t"
- "mul.s %[f4], %[f14], %[f1] \n\t"
- "mul.s %[f1], %[f13], %[f1] \n\t"
- "sub.s %[f2], %[f3], %[f2] \n\t"
- "mul.s %[f3], %[f13], %[f0] \n\t"
- "mul.s %[f0], %[f14], %[f0] \n\t"
- "add.s %[f8], %[f8], %[f6] \n\t"
- "swc1 %[f5], 64(%[tmp_a]) \n\t"
- "swc1 %[f7], 68(%[tmp_a]) \n\t"
- "sub.s %[f3], %[f3], %[f4] \n\t"
- "add.s %[f1], %[f1], %[f0] \n\t"
+ "mul.s %[f2], %[f9], %[f4] "
+ "\n\t"
+ "mul.s %[f4], %[f10], %[f4] "
+ "\n\t"
+ "mul.s %[f7], %[f9], %[f7] "
+ "\n\t"
+ "mul.s %[f3], %[f11], %[f6] "
+ "\n\t"
+ "mul.s %[f6], %[f12], %[f6] "
+ "\n\t"
+ "add.s %[f5], %[f5], %[f2] "
+ "\n\t"
+ "sub.s %[f7], %[f4], %[f7] "
+ "\n\t"
+ "mul.s %[f2], %[f12], %[f8] "
+ "\n\t"
+ "mul.s %[f8], %[f11], %[f8] "
+ "\n\t"
+ "mul.s %[f4], %[f14], %[f1] "
+ "\n\t"
+ "mul.s %[f1], %[f13], %[f1] "
+ "\n\t"
+ "sub.s %[f2], %[f3], %[f2] "
+ "\n\t"
+ "mul.s %[f3], %[f13], %[f0] "
+ "\n\t"
+ "mul.s %[f0], %[f14], %[f0] "
+ "\n\t"
+ "add.s %[f8], %[f8], %[f6] "
+ "\n\t"
+ "swc1 %[f5], 64(%[tmp_a]) "
+ "\n\t"
+ "swc1 %[f7], 68(%[tmp_a]) "
+ "\n\t"
+ "sub.s %[f3], %[f3], %[f4] "
+ "\n\t"
+ "add.s %[f1], %[f1], %[f0] "
+ "\n\t"
#endif
- "swc1 %[f2], 32(%[tmp_a]) \n\t"
- "swc1 %[f8], 36(%[tmp_a]) \n\t"
- "swc1 %[f3], 96(%[tmp_a]) \n\t"
- "swc1 %[f1], 100(%[tmp_a]) \n\t"
- "bgtz %[count], 1b \n\t"
- " addiu %[tmp_a], %[tmp_a], 8 \n\t"
- ".set pop \n\t"
- : [f0] "=&f" (f0), [f1] "=&f" (f1), [f2] "=&f" (f2), [f3] "=&f" (f3),
- [f4] "=&f" (f4), [f5] "=&f" (f5), [f6] "=&f" (f6), [f7] "=&f" (f7),
- [f8] "=&f" (f8), [tmp_a] "=&r" (tmp_a), [count] "=&r" (count)
- : [a] "r" (a), [f9] "f" (f9), [f10] "f" (f10), [f11] "f" (f11),
- [f12] "f" (f12), [f13] "f" (f13), [f14] "f" (f14)
- : "memory"
- );
+ "swc1 %[f2], 32(%[tmp_a]) "
+ "\n\t"
+ "swc1 %[f8], 36(%[tmp_a]) "
+ "\n\t"
+ "swc1 %[f3], 96(%[tmp_a]) "
+ "\n\t"
+ "swc1 %[f1], 100(%[tmp_a]) "
+ "\n\t"
+ "bgtz %[count], 1b "
+ "\n\t"
+ " addiu %[tmp_a], %[tmp_a], 8 "
+ "\n\t"
+ ".set pop "
+ "\n\t"
+ : [f0] "=&f"(f0), [f1] "=&f"(f1), [f2] "=&f"(f2), [f3] "=&f"(f3),
+ [f4] "=&f"(f4), [f5] "=&f"(f5), [f6] "=&f"(f6), [f7] "=&f"(f7),
+ [f8] "=&f"(f8), [tmp_a] "=&r"(tmp_a), [count] "=&r"(count)
+ : [a] "r"(a), [f9] "f"(f9), [f10] "f"(f10), [f11] "f"(f11),
+ [f12] "f"(f12), [f13] "f"(f13), [f14] "f"(f14)
+ : "memory");
}
void cftfsub_128_mips(float* a) {
@@ -815,55 +882,53 @@
cft1st_128_mips(a);
cftmdl_128_mips(a);
- __asm __volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "addiu %[tmp_a], %[a], 0 \n\t"
- "addiu %[count], $zero, 16 \n\t"
- "1: \n\t"
- "addiu %[count], %[count], -1 \n\t"
- "lwc1 %[f0], 0(%[tmp_a]) \n\t"
- "lwc1 %[f2], 128(%[tmp_a]) \n\t"
- "lwc1 %[f4], 256(%[tmp_a]) \n\t"
- "lwc1 %[f6], 384(%[tmp_a]) \n\t"
- "lwc1 %[f1], 4(%[tmp_a]) \n\t"
- "lwc1 %[f3], 132(%[tmp_a]) \n\t"
- "lwc1 %[f5], 260(%[tmp_a]) \n\t"
- "lwc1 %[f7], 388(%[tmp_a]) \n\t"
- "add.s %[f8], %[f0], %[f2] \n\t"
- "sub.s %[f0], %[f0], %[f2] \n\t"
- "add.s %[f2], %[f4], %[f6] \n\t"
- "sub.s %[f4], %[f4], %[f6] \n\t"
- "add.s %[f6], %[f1], %[f3] \n\t"
- "sub.s %[f1], %[f1], %[f3] \n\t"
- "add.s %[f3], %[f5], %[f7] \n\t"
- "sub.s %[f5], %[f5], %[f7] \n\t"
- "add.s %[f7], %[f8], %[f2] \n\t"
- "sub.s %[f8], %[f8], %[f2] \n\t"
- "add.s %[f2], %[f1], %[f4] \n\t"
- "sub.s %[f1], %[f1], %[f4] \n\t"
- "add.s %[f4], %[f6], %[f3] \n\t"
- "sub.s %[f6], %[f6], %[f3] \n\t"
- "sub.s %[f3], %[f0], %[f5] \n\t"
- "add.s %[f0], %[f0], %[f5] \n\t"
- "swc1 %[f7], 0(%[tmp_a]) \n\t"
- "swc1 %[f8], 256(%[tmp_a]) \n\t"
- "swc1 %[f2], 132(%[tmp_a]) \n\t"
- "swc1 %[f1], 388(%[tmp_a]) \n\t"
- "swc1 %[f4], 4(%[tmp_a]) \n\t"
- "swc1 %[f6], 260(%[tmp_a]) \n\t"
- "swc1 %[f3], 128(%[tmp_a]) \n\t"
- "swc1 %[f0], 384(%[tmp_a]) \n\t"
- "bgtz %[count], 1b \n\t"
- " addiu %[tmp_a], %[tmp_a], 8 \n\t"
- ".set pop \n\t"
- : [f0] "=&f" (f0), [f1] "=&f" (f1), [f2] "=&f" (f2), [f3] "=&f" (f3),
- [f4] "=&f" (f4), [f5] "=&f" (f5), [f6] "=&f" (f6), [f7] "=&f" (f7),
- [f8] "=&f" (f8), [tmp_a] "=&r" (tmp_a),
- [count] "=&r" (count)
- : [a] "r" (a)
- : "memory"
- );
+ __asm __volatile(
+ ".set push \n\t"
+ ".set noreorder \n\t"
+ "addiu %[tmp_a], %[a], 0 \n\t"
+ "addiu %[count], $zero, 16 \n\t"
+ "1: \n\t"
+ "addiu %[count], %[count], -1 \n\t"
+ "lwc1 %[f0], 0(%[tmp_a]) \n\t"
+ "lwc1 %[f2], 128(%[tmp_a]) \n\t"
+ "lwc1 %[f4], 256(%[tmp_a]) \n\t"
+ "lwc1 %[f6], 384(%[tmp_a]) \n\t"
+ "lwc1 %[f1], 4(%[tmp_a]) \n\t"
+ "lwc1 %[f3], 132(%[tmp_a]) \n\t"
+ "lwc1 %[f5], 260(%[tmp_a]) \n\t"
+ "lwc1 %[f7], 388(%[tmp_a]) \n\t"
+ "add.s %[f8], %[f0], %[f2] \n\t"
+ "sub.s %[f0], %[f0], %[f2] \n\t"
+ "add.s %[f2], %[f4], %[f6] \n\t"
+ "sub.s %[f4], %[f4], %[f6] \n\t"
+ "add.s %[f6], %[f1], %[f3] \n\t"
+ "sub.s %[f1], %[f1], %[f3] \n\t"
+ "add.s %[f3], %[f5], %[f7] \n\t"
+ "sub.s %[f5], %[f5], %[f7] \n\t"
+ "add.s %[f7], %[f8], %[f2] \n\t"
+ "sub.s %[f8], %[f8], %[f2] \n\t"
+ "add.s %[f2], %[f1], %[f4] \n\t"
+ "sub.s %[f1], %[f1], %[f4] \n\t"
+ "add.s %[f4], %[f6], %[f3] \n\t"
+ "sub.s %[f6], %[f6], %[f3] \n\t"
+ "sub.s %[f3], %[f0], %[f5] \n\t"
+ "add.s %[f0], %[f0], %[f5] \n\t"
+ "swc1 %[f7], 0(%[tmp_a]) \n\t"
+ "swc1 %[f8], 256(%[tmp_a]) \n\t"
+ "swc1 %[f2], 132(%[tmp_a]) \n\t"
+ "swc1 %[f1], 388(%[tmp_a]) \n\t"
+ "swc1 %[f4], 4(%[tmp_a]) \n\t"
+ "swc1 %[f6], 260(%[tmp_a]) \n\t"
+ "swc1 %[f3], 128(%[tmp_a]) \n\t"
+ "swc1 %[f0], 384(%[tmp_a]) \n\t"
+ "bgtz %[count], 1b \n\t"
+ " addiu %[tmp_a], %[tmp_a], 8 \n\t"
+ ".set pop \n\t"
+ : [f0] "=&f"(f0), [f1] "=&f"(f1), [f2] "=&f"(f2), [f3] "=&f"(f3),
+ [f4] "=&f"(f4), [f5] "=&f"(f5), [f6] "=&f"(f6), [f7] "=&f"(f7),
+ [f8] "=&f"(f8), [tmp_a] "=&r"(tmp_a), [count] "=&r"(count)
+ : [a] "r"(a)
+ : "memory");
}
void cftbsub_128_mips(float* a) {
@@ -873,55 +938,54 @@
cft1st_128_mips(a);
cftmdl_128_mips(a);
- __asm __volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "addiu %[tmp_a], %[a], 0 \n\t"
- "addiu %[count], $zero, 16 \n\t"
- "1: \n\t"
- "addiu %[count], %[count], -1 \n\t"
- "lwc1 %[f0], 0(%[tmp_a]) \n\t"
- "lwc1 %[f2], 128(%[tmp_a]) \n\t"
- "lwc1 %[f4], 256(%[tmp_a]) \n\t"
- "lwc1 %[f6], 384(%[tmp_a]) \n\t"
- "lwc1 %[f1], 4(%[tmp_a]) \n\t"
- "lwc1 %[f3], 132(%[tmp_a]) \n\t"
- "lwc1 %[f5], 260(%[tmp_a]) \n\t"
- "lwc1 %[f7], 388(%[tmp_a]) \n\t"
- "add.s %[f8], %[f0], %[f2] \n\t"
- "sub.s %[f0], %[f0], %[f2] \n\t"
- "add.s %[f2], %[f4], %[f6] \n\t"
- "sub.s %[f4], %[f4], %[f6] \n\t"
- "add.s %[f6], %[f1], %[f3] \n\t"
- "sub.s %[f1], %[f3], %[f1] \n\t"
- "add.s %[f3], %[f5], %[f7] \n\t"
- "sub.s %[f5], %[f5], %[f7] \n\t"
- "add.s %[f7], %[f8], %[f2] \n\t"
- "sub.s %[f8], %[f8], %[f2] \n\t"
- "sub.s %[f2], %[f1], %[f4] \n\t"
- "add.s %[f1], %[f1], %[f4] \n\t"
- "add.s %[f4], %[f3], %[f6] \n\t"
- "sub.s %[f6], %[f3], %[f6] \n\t"
- "sub.s %[f3], %[f0], %[f5] \n\t"
- "add.s %[f0], %[f0], %[f5] \n\t"
- "neg.s %[f4], %[f4] \n\t"
- "swc1 %[f7], 0(%[tmp_a]) \n\t"
- "swc1 %[f8], 256(%[tmp_a]) \n\t"
- "swc1 %[f2], 132(%[tmp_a]) \n\t"
- "swc1 %[f1], 388(%[tmp_a]) \n\t"
- "swc1 %[f6], 260(%[tmp_a]) \n\t"
- "swc1 %[f3], 128(%[tmp_a]) \n\t"
- "swc1 %[f0], 384(%[tmp_a]) \n\t"
- "swc1 %[f4], 4(%[tmp_a]) \n\t"
- "bgtz %[count], 1b \n\t"
- " addiu %[tmp_a], %[tmp_a], 8 \n\t"
- ".set pop \n\t"
- : [f0] "=&f" (f0), [f1] "=&f" (f1), [f2] "=&f" (f2), [f3] "=&f" (f3),
- [f4] "=&f" (f4), [f5] "=&f" (f5), [f6] "=&f" (f6), [f7] "=&f" (f7),
- [f8] "=&f" (f8), [tmp_a] "=&r" (tmp_a), [count] "=&r" (count)
- : [a] "r" (a)
- : "memory"
- );
+ __asm __volatile(
+ ".set push \n\t"
+ ".set noreorder \n\t"
+ "addiu %[tmp_a], %[a], 0 \n\t"
+ "addiu %[count], $zero, 16 \n\t"
+ "1: \n\t"
+ "addiu %[count], %[count], -1 \n\t"
+ "lwc1 %[f0], 0(%[tmp_a]) \n\t"
+ "lwc1 %[f2], 128(%[tmp_a]) \n\t"
+ "lwc1 %[f4], 256(%[tmp_a]) \n\t"
+ "lwc1 %[f6], 384(%[tmp_a]) \n\t"
+ "lwc1 %[f1], 4(%[tmp_a]) \n\t"
+ "lwc1 %[f3], 132(%[tmp_a]) \n\t"
+ "lwc1 %[f5], 260(%[tmp_a]) \n\t"
+ "lwc1 %[f7], 388(%[tmp_a]) \n\t"
+ "add.s %[f8], %[f0], %[f2] \n\t"
+ "sub.s %[f0], %[f0], %[f2] \n\t"
+ "add.s %[f2], %[f4], %[f6] \n\t"
+ "sub.s %[f4], %[f4], %[f6] \n\t"
+ "add.s %[f6], %[f1], %[f3] \n\t"
+ "sub.s %[f1], %[f3], %[f1] \n\t"
+ "add.s %[f3], %[f5], %[f7] \n\t"
+ "sub.s %[f5], %[f5], %[f7] \n\t"
+ "add.s %[f7], %[f8], %[f2] \n\t"
+ "sub.s %[f8], %[f8], %[f2] \n\t"
+ "sub.s %[f2], %[f1], %[f4] \n\t"
+ "add.s %[f1], %[f1], %[f4] \n\t"
+ "add.s %[f4], %[f3], %[f6] \n\t"
+ "sub.s %[f6], %[f3], %[f6] \n\t"
+ "sub.s %[f3], %[f0], %[f5] \n\t"
+ "add.s %[f0], %[f0], %[f5] \n\t"
+ "neg.s %[f4], %[f4] \n\t"
+ "swc1 %[f7], 0(%[tmp_a]) \n\t"
+ "swc1 %[f8], 256(%[tmp_a]) \n\t"
+ "swc1 %[f2], 132(%[tmp_a]) \n\t"
+ "swc1 %[f1], 388(%[tmp_a]) \n\t"
+ "swc1 %[f6], 260(%[tmp_a]) \n\t"
+ "swc1 %[f3], 128(%[tmp_a]) \n\t"
+ "swc1 %[f0], 384(%[tmp_a]) \n\t"
+ "swc1 %[f4], 4(%[tmp_a]) \n\t"
+ "bgtz %[count], 1b \n\t"
+ " addiu %[tmp_a], %[tmp_a], 8 \n\t"
+ ".set pop \n\t"
+ : [f0] "=&f"(f0), [f1] "=&f"(f1), [f2] "=&f"(f2), [f3] "=&f"(f3),
+ [f4] "=&f"(f4), [f5] "=&f"(f5), [f6] "=&f"(f6), [f7] "=&f"(f7),
+ [f8] "=&f"(f8), [tmp_a] "=&r"(tmp_a), [count] "=&r"(count)
+ : [a] "r"(a)
+ : "memory");
}
void rftfsub_128_mips(float* a) {
@@ -931,254 +995,252 @@
float* a2 = &a[126];
const float* c1 = &c[1];
const float* c2 = &c[31];
- float f1, f2, f3 ,f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15;
+ float f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15;
int count;
- __asm __volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "lwc1 %[f6], 0(%[c2]) \n\t"
- "lwc1 %[f1], 0(%[a1]) \n\t"
- "lwc1 %[f2], 0(%[a2]) \n\t"
- "lwc1 %[f3], 4(%[a1]) \n\t"
- "lwc1 %[f4], 4(%[a2]) \n\t"
- "lwc1 %[f5], 0(%[c1]) \n\t"
- "sub.s %[f6], %[f0], %[f6] \n\t"
- "sub.s %[f7], %[f1], %[f2] \n\t"
- "add.s %[f8], %[f3], %[f4] \n\t"
- "addiu %[count], $zero, 15 \n\t"
- "mul.s %[f9], %[f6], %[f7] \n\t"
- "mul.s %[f6], %[f6], %[f8] \n\t"
+ __asm __volatile(
+ ".set push \n\t"
+ ".set noreorder \n\t"
+ "lwc1 %[f6], 0(%[c2]) \n\t"
+ "lwc1 %[f1], 0(%[a1]) \n\t"
+ "lwc1 %[f2], 0(%[a2]) \n\t"
+ "lwc1 %[f3], 4(%[a1]) \n\t"
+ "lwc1 %[f4], 4(%[a2]) \n\t"
+ "lwc1 %[f5], 0(%[c1]) \n\t"
+ "sub.s %[f6], %[f0], %[f6] \n\t"
+ "sub.s %[f7], %[f1], %[f2] \n\t"
+ "add.s %[f8], %[f3], %[f4] \n\t"
+ "addiu %[count], $zero, 15 \n\t"
+ "mul.s %[f9], %[f6], %[f7] \n\t"
+ "mul.s %[f6], %[f6], %[f8] \n\t"
#if !defined(MIPS32_R2_LE)
- "mul.s %[f8], %[f5], %[f8] \n\t"
- "mul.s %[f5], %[f5], %[f7] \n\t"
- "sub.s %[f9], %[f9], %[f8] \n\t"
- "add.s %[f6], %[f6], %[f5] \n\t"
+ "mul.s %[f8], %[f5], %[f8] \n\t"
+ "mul.s %[f5], %[f5], %[f7] \n\t"
+ "sub.s %[f9], %[f9], %[f8] \n\t"
+ "add.s %[f6], %[f6], %[f5] \n\t"
#else
- "nmsub.s %[f9], %[f9], %[f5], %[f8] \n\t"
- "madd.s %[f6], %[f6], %[f5], %[f7] \n\t"
+ "nmsub.s %[f9], %[f9], %[f5], %[f8] \n\t"
+ "madd.s %[f6], %[f6], %[f5], %[f7] \n\t"
#endif
- "sub.s %[f1], %[f1], %[f9] \n\t"
- "add.s %[f2], %[f2], %[f9] \n\t"
- "sub.s %[f3], %[f3], %[f6] \n\t"
- "sub.s %[f4], %[f4], %[f6] \n\t"
- "swc1 %[f1], 0(%[a1]) \n\t"
- "swc1 %[f2], 0(%[a2]) \n\t"
- "swc1 %[f3], 4(%[a1]) \n\t"
- "swc1 %[f4], 4(%[a2]) \n\t"
- "addiu %[a1], %[a1], 8 \n\t"
- "addiu %[a2], %[a2], -8 \n\t"
- "addiu %[c1], %[c1], 4 \n\t"
- "addiu %[c2], %[c2], -4 \n\t"
- "1: \n\t"
- "lwc1 %[f6], 0(%[c2]) \n\t"
- "lwc1 %[f1], 0(%[a1]) \n\t"
- "lwc1 %[f2], 0(%[a2]) \n\t"
- "lwc1 %[f3], 4(%[a1]) \n\t"
- "lwc1 %[f4], 4(%[a2]) \n\t"
- "lwc1 %[f5], 0(%[c1]) \n\t"
- "sub.s %[f6], %[f0], %[f6] \n\t"
- "sub.s %[f7], %[f1], %[f2] \n\t"
- "add.s %[f8], %[f3], %[f4] \n\t"
- "lwc1 %[f10], -4(%[c2]) \n\t"
- "lwc1 %[f11], 8(%[a1]) \n\t"
- "lwc1 %[f12], -8(%[a2]) \n\t"
- "mul.s %[f9], %[f6], %[f7] \n\t"
- "mul.s %[f6], %[f6], %[f8] \n\t"
+ "sub.s %[f1], %[f1], %[f9] \n\t"
+ "add.s %[f2], %[f2], %[f9] \n\t"
+ "sub.s %[f3], %[f3], %[f6] \n\t"
+ "sub.s %[f4], %[f4], %[f6] \n\t"
+ "swc1 %[f1], 0(%[a1]) \n\t"
+ "swc1 %[f2], 0(%[a2]) \n\t"
+ "swc1 %[f3], 4(%[a1]) \n\t"
+ "swc1 %[f4], 4(%[a2]) \n\t"
+ "addiu %[a1], %[a1], 8 \n\t"
+ "addiu %[a2], %[a2], -8 \n\t"
+ "addiu %[c1], %[c1], 4 \n\t"
+ "addiu %[c2], %[c2], -4 \n\t"
+ "1: \n\t"
+ "lwc1 %[f6], 0(%[c2]) \n\t"
+ "lwc1 %[f1], 0(%[a1]) \n\t"
+ "lwc1 %[f2], 0(%[a2]) \n\t"
+ "lwc1 %[f3], 4(%[a1]) \n\t"
+ "lwc1 %[f4], 4(%[a2]) \n\t"
+ "lwc1 %[f5], 0(%[c1]) \n\t"
+ "sub.s %[f6], %[f0], %[f6] \n\t"
+ "sub.s %[f7], %[f1], %[f2] \n\t"
+ "add.s %[f8], %[f3], %[f4] \n\t"
+ "lwc1 %[f10], -4(%[c2]) \n\t"
+ "lwc1 %[f11], 8(%[a1]) \n\t"
+ "lwc1 %[f12], -8(%[a2]) \n\t"
+ "mul.s %[f9], %[f6], %[f7] \n\t"
+ "mul.s %[f6], %[f6], %[f8] \n\t"
#if !defined(MIPS32_R2_LE)
- "mul.s %[f8], %[f5], %[f8] \n\t"
- "mul.s %[f5], %[f5], %[f7] \n\t"
- "lwc1 %[f13], 12(%[a1]) \n\t"
- "lwc1 %[f14], -4(%[a2]) \n\t"
- "lwc1 %[f15], 4(%[c1]) \n\t"
- "sub.s %[f9], %[f9], %[f8] \n\t"
- "add.s %[f6], %[f6], %[f5] \n\t"
+ "mul.s %[f8], %[f5], %[f8] \n\t"
+ "mul.s %[f5], %[f5], %[f7] \n\t"
+ "lwc1 %[f13], 12(%[a1]) \n\t"
+ "lwc1 %[f14], -4(%[a2]) \n\t"
+ "lwc1 %[f15], 4(%[c1]) \n\t"
+ "sub.s %[f9], %[f9], %[f8] \n\t"
+ "add.s %[f6], %[f6], %[f5] \n\t"
#else
- "lwc1 %[f13], 12(%[a1]) \n\t"
- "lwc1 %[f14], -4(%[a2]) \n\t"
- "lwc1 %[f15], 4(%[c1]) \n\t"
- "nmsub.s %[f9], %[f9], %[f5], %[f8] \n\t"
- "madd.s %[f6], %[f6], %[f5], %[f7] \n\t"
+ "lwc1 %[f13], 12(%[a1]) \n\t"
+ "lwc1 %[f14], -4(%[a2]) \n\t"
+ "lwc1 %[f15], 4(%[c1]) \n\t"
+ "nmsub.s %[f9], %[f9], %[f5], %[f8] \n\t"
+ "madd.s %[f6], %[f6], %[f5], %[f7] \n\t"
#endif
- "sub.s %[f10], %[f0], %[f10] \n\t"
- "sub.s %[f5], %[f11], %[f12] \n\t"
- "add.s %[f7], %[f13], %[f14] \n\t"
- "sub.s %[f1], %[f1], %[f9] \n\t"
- "add.s %[f2], %[f2], %[f9] \n\t"
- "sub.s %[f3], %[f3], %[f6] \n\t"
- "mul.s %[f8], %[f10], %[f5] \n\t"
- "mul.s %[f10], %[f10], %[f7] \n\t"
+ "sub.s %[f10], %[f0], %[f10] \n\t"
+ "sub.s %[f5], %[f11], %[f12] \n\t"
+ "add.s %[f7], %[f13], %[f14] \n\t"
+ "sub.s %[f1], %[f1], %[f9] \n\t"
+ "add.s %[f2], %[f2], %[f9] \n\t"
+ "sub.s %[f3], %[f3], %[f6] \n\t"
+ "mul.s %[f8], %[f10], %[f5] \n\t"
+ "mul.s %[f10], %[f10], %[f7] \n\t"
#if !defined(MIPS32_R2_LE)
- "mul.s %[f9], %[f15], %[f7] \n\t"
- "mul.s %[f15], %[f15], %[f5] \n\t"
- "sub.s %[f4], %[f4], %[f6] \n\t"
- "swc1 %[f1], 0(%[a1]) \n\t"
- "swc1 %[f2], 0(%[a2]) \n\t"
- "sub.s %[f8], %[f8], %[f9] \n\t"
- "add.s %[f10], %[f10], %[f15] \n\t"
+ "mul.s %[f9], %[f15], %[f7] \n\t"
+ "mul.s %[f15], %[f15], %[f5] \n\t"
+ "sub.s %[f4], %[f4], %[f6] \n\t"
+ "swc1 %[f1], 0(%[a1]) \n\t"
+ "swc1 %[f2], 0(%[a2]) \n\t"
+ "sub.s %[f8], %[f8], %[f9] \n\t"
+ "add.s %[f10], %[f10], %[f15] \n\t"
#else
- "swc1 %[f1], 0(%[a1]) \n\t"
- "swc1 %[f2], 0(%[a2]) \n\t"
- "sub.s %[f4], %[f4], %[f6] \n\t"
- "nmsub.s %[f8], %[f8], %[f15], %[f7] \n\t"
- "madd.s %[f10], %[f10], %[f15], %[f5] \n\t"
+ "swc1 %[f1], 0(%[a1]) \n\t"
+ "swc1 %[f2], 0(%[a2]) \n\t"
+ "sub.s %[f4], %[f4], %[f6] \n\t"
+ "nmsub.s %[f8], %[f8], %[f15], %[f7] \n\t"
+ "madd.s %[f10], %[f10], %[f15], %[f5] \n\t"
#endif
- "swc1 %[f3], 4(%[a1]) \n\t"
- "swc1 %[f4], 4(%[a2]) \n\t"
- "sub.s %[f11], %[f11], %[f8] \n\t"
- "add.s %[f12], %[f12], %[f8] \n\t"
- "sub.s %[f13], %[f13], %[f10] \n\t"
- "sub.s %[f14], %[f14], %[f10] \n\t"
- "addiu %[c2], %[c2], -8 \n\t"
- "addiu %[c1], %[c1], 8 \n\t"
- "swc1 %[f11], 8(%[a1]) \n\t"
- "swc1 %[f12], -8(%[a2]) \n\t"
- "swc1 %[f13], 12(%[a1]) \n\t"
- "swc1 %[f14], -4(%[a2]) \n\t"
- "addiu %[a1], %[a1], 16 \n\t"
- "addiu %[count], %[count], -1 \n\t"
- "bgtz %[count], 1b \n\t"
- " addiu %[a2], %[a2], -16 \n\t"
- ".set pop \n\t"
- : [a1] "+r" (a1), [a2] "+r" (a2), [c1] "+r" (c1), [c2] "+r" (c2),
- [f1] "=&f" (f1), [f2] "=&f" (f2), [f3] "=&f" (f3), [f4] "=&f" (f4),
- [f5] "=&f" (f5), [f6] "=&f" (f6), [f7] "=&f" (f7), [f8] "=&f" (f8),
- [f9] "=&f" (f9), [f10] "=&f" (f10), [f11] "=&f" (f11), [f12] "=&f" (f12),
- [f13] "=&f" (f13), [f14] "=&f" (f14), [f15] "=&f" (f15),
- [count] "=&r" (count)
- : [f0] "f" (f0)
- : "memory"
- );
+ "swc1 %[f3], 4(%[a1]) \n\t"
+ "swc1 %[f4], 4(%[a2]) \n\t"
+ "sub.s %[f11], %[f11], %[f8] \n\t"
+ "add.s %[f12], %[f12], %[f8] \n\t"
+ "sub.s %[f13], %[f13], %[f10] \n\t"
+ "sub.s %[f14], %[f14], %[f10] \n\t"
+ "addiu %[c2], %[c2], -8 \n\t"
+ "addiu %[c1], %[c1], 8 \n\t"
+ "swc1 %[f11], 8(%[a1]) \n\t"
+ "swc1 %[f12], -8(%[a2]) \n\t"
+ "swc1 %[f13], 12(%[a1]) \n\t"
+ "swc1 %[f14], -4(%[a2]) \n\t"
+ "addiu %[a1], %[a1], 16 \n\t"
+ "addiu %[count], %[count], -1 \n\t"
+ "bgtz %[count], 1b \n\t"
+ " addiu %[a2], %[a2], -16 \n\t"
+ ".set pop \n\t"
+ : [a1] "+r"(a1), [a2] "+r"(a2), [c1] "+r"(c1), [c2] "+r"(c2),
+ [f1] "=&f"(f1), [f2] "=&f"(f2), [f3] "=&f"(f3), [f4] "=&f"(f4),
+ [f5] "=&f"(f5), [f6] "=&f"(f6), [f7] "=&f"(f7), [f8] "=&f"(f8),
+ [f9] "=&f"(f9), [f10] "=&f"(f10), [f11] "=&f"(f11), [f12] "=&f"(f12),
+ [f13] "=&f"(f13), [f14] "=&f"(f14), [f15] "=&f"(f15),
+ [count] "=&r"(count)
+ : [f0] "f"(f0)
+ : "memory");
}
void rftbsub_128_mips(float* a) {
- const float *c = rdft_w + 32;
+ const float* c = rdft_w + 32;
const float f0 = 0.5f;
float* a1 = &a[2];
float* a2 = &a[126];
const float* c1 = &c[1];
const float* c2 = &c[31];
- float f1, f2, f3 ,f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15;
+ float f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15;
int count;
a[1] = -a[1];
a[65] = -a[65];
- __asm __volatile (
- ".set push \n\t"
- ".set noreorder \n\t"
- "lwc1 %[f6], 0(%[c2]) \n\t"
- "lwc1 %[f1], 0(%[a1]) \n\t"
- "lwc1 %[f2], 0(%[a2]) \n\t"
- "lwc1 %[f3], 4(%[a1]) \n\t"
- "lwc1 %[f4], 4(%[a2]) \n\t"
- "lwc1 %[f5], 0(%[c1]) \n\t"
- "sub.s %[f6], %[f0], %[f6] \n\t"
- "sub.s %[f7], %[f1], %[f2] \n\t"
- "add.s %[f8], %[f3], %[f4] \n\t"
- "addiu %[count], $zero, 15 \n\t"
- "mul.s %[f9], %[f6], %[f7] \n\t"
- "mul.s %[f6], %[f6], %[f8] \n\t"
+ __asm __volatile(
+ ".set push \n\t"
+ ".set noreorder \n\t"
+ "lwc1 %[f6], 0(%[c2]) \n\t"
+ "lwc1 %[f1], 0(%[a1]) \n\t"
+ "lwc1 %[f2], 0(%[a2]) \n\t"
+ "lwc1 %[f3], 4(%[a1]) \n\t"
+ "lwc1 %[f4], 4(%[a2]) \n\t"
+ "lwc1 %[f5], 0(%[c1]) \n\t"
+ "sub.s %[f6], %[f0], %[f6] \n\t"
+ "sub.s %[f7], %[f1], %[f2] \n\t"
+ "add.s %[f8], %[f3], %[f4] \n\t"
+ "addiu %[count], $zero, 15 \n\t"
+ "mul.s %[f9], %[f6], %[f7] \n\t"
+ "mul.s %[f6], %[f6], %[f8] \n\t"
#if !defined(MIPS32_R2_LE)
- "mul.s %[f8], %[f5], %[f8] \n\t"
- "mul.s %[f5], %[f5], %[f7] \n\t"
- "add.s %[f9], %[f9], %[f8] \n\t"
- "sub.s %[f6], %[f6], %[f5] \n\t"
+ "mul.s %[f8], %[f5], %[f8] \n\t"
+ "mul.s %[f5], %[f5], %[f7] \n\t"
+ "add.s %[f9], %[f9], %[f8] \n\t"
+ "sub.s %[f6], %[f6], %[f5] \n\t"
#else
- "madd.s %[f9], %[f9], %[f5], %[f8] \n\t"
- "nmsub.s %[f6], %[f6], %[f5], %[f7] \n\t"
+ "madd.s %[f9], %[f9], %[f5], %[f8] \n\t"
+ "nmsub.s %[f6], %[f6], %[f5], %[f7] \n\t"
#endif
- "sub.s %[f1], %[f1], %[f9] \n\t"
- "add.s %[f2], %[f2], %[f9] \n\t"
- "sub.s %[f3], %[f6], %[f3] \n\t"
- "sub.s %[f4], %[f6], %[f4] \n\t"
- "swc1 %[f1], 0(%[a1]) \n\t"
- "swc1 %[f2], 0(%[a2]) \n\t"
- "swc1 %[f3], 4(%[a1]) \n\t"
- "swc1 %[f4], 4(%[a2]) \n\t"
- "addiu %[a1], %[a1], 8 \n\t"
- "addiu %[a2], %[a2], -8 \n\t"
- "addiu %[c1], %[c1], 4 \n\t"
- "addiu %[c2], %[c2], -4 \n\t"
- "1: \n\t"
- "lwc1 %[f6], 0(%[c2]) \n\t"
- "lwc1 %[f1], 0(%[a1]) \n\t"
- "lwc1 %[f2], 0(%[a2]) \n\t"
- "lwc1 %[f3], 4(%[a1]) \n\t"
- "lwc1 %[f4], 4(%[a2]) \n\t"
- "lwc1 %[f5], 0(%[c1]) \n\t"
- "sub.s %[f6], %[f0], %[f6] \n\t"
- "sub.s %[f7], %[f1], %[f2] \n\t"
- "add.s %[f8], %[f3], %[f4] \n\t"
- "lwc1 %[f10], -4(%[c2]) \n\t"
- "lwc1 %[f11], 8(%[a1]) \n\t"
- "lwc1 %[f12], -8(%[a2]) \n\t"
- "mul.s %[f9], %[f6], %[f7] \n\t"
- "mul.s %[f6], %[f6], %[f8] \n\t"
+ "sub.s %[f1], %[f1], %[f9] \n\t"
+ "add.s %[f2], %[f2], %[f9] \n\t"
+ "sub.s %[f3], %[f6], %[f3] \n\t"
+ "sub.s %[f4], %[f6], %[f4] \n\t"
+ "swc1 %[f1], 0(%[a1]) \n\t"
+ "swc1 %[f2], 0(%[a2]) \n\t"
+ "swc1 %[f3], 4(%[a1]) \n\t"
+ "swc1 %[f4], 4(%[a2]) \n\t"
+ "addiu %[a1], %[a1], 8 \n\t"
+ "addiu %[a2], %[a2], -8 \n\t"
+ "addiu %[c1], %[c1], 4 \n\t"
+ "addiu %[c2], %[c2], -4 \n\t"
+ "1: \n\t"
+ "lwc1 %[f6], 0(%[c2]) \n\t"
+ "lwc1 %[f1], 0(%[a1]) \n\t"
+ "lwc1 %[f2], 0(%[a2]) \n\t"
+ "lwc1 %[f3], 4(%[a1]) \n\t"
+ "lwc1 %[f4], 4(%[a2]) \n\t"
+ "lwc1 %[f5], 0(%[c1]) \n\t"
+ "sub.s %[f6], %[f0], %[f6] \n\t"
+ "sub.s %[f7], %[f1], %[f2] \n\t"
+ "add.s %[f8], %[f3], %[f4] \n\t"
+ "lwc1 %[f10], -4(%[c2]) \n\t"
+ "lwc1 %[f11], 8(%[a1]) \n\t"
+ "lwc1 %[f12], -8(%[a2]) \n\t"
+ "mul.s %[f9], %[f6], %[f7] \n\t"
+ "mul.s %[f6], %[f6], %[f8] \n\t"
#if !defined(MIPS32_R2_LE)
- "mul.s %[f8], %[f5], %[f8] \n\t"
- "mul.s %[f5], %[f5], %[f7] \n\t"
- "lwc1 %[f13], 12(%[a1]) \n\t"
- "lwc1 %[f14], -4(%[a2]) \n\t"
- "lwc1 %[f15], 4(%[c1]) \n\t"
- "add.s %[f9], %[f9], %[f8] \n\t"
- "sub.s %[f6], %[f6], %[f5] \n\t"
+ "mul.s %[f8], %[f5], %[f8] \n\t"
+ "mul.s %[f5], %[f5], %[f7] \n\t"
+ "lwc1 %[f13], 12(%[a1]) \n\t"
+ "lwc1 %[f14], -4(%[a2]) \n\t"
+ "lwc1 %[f15], 4(%[c1]) \n\t"
+ "add.s %[f9], %[f9], %[f8] \n\t"
+ "sub.s %[f6], %[f6], %[f5] \n\t"
#else
- "lwc1 %[f13], 12(%[a1]) \n\t"
- "lwc1 %[f14], -4(%[a2]) \n\t"
- "lwc1 %[f15], 4(%[c1]) \n\t"
- "madd.s %[f9], %[f9], %[f5], %[f8] \n\t"
- "nmsub.s %[f6], %[f6], %[f5], %[f7] \n\t"
+ "lwc1 %[f13], 12(%[a1]) \n\t"
+ "lwc1 %[f14], -4(%[a2]) \n\t"
+ "lwc1 %[f15], 4(%[c1]) \n\t"
+ "madd.s %[f9], %[f9], %[f5], %[f8] \n\t"
+ "nmsub.s %[f6], %[f6], %[f5], %[f7] \n\t"
#endif
- "sub.s %[f10], %[f0], %[f10] \n\t"
- "sub.s %[f5], %[f11], %[f12] \n\t"
- "add.s %[f7], %[f13], %[f14] \n\t"
- "sub.s %[f1], %[f1], %[f9] \n\t"
- "add.s %[f2], %[f2], %[f9] \n\t"
- "sub.s %[f3], %[f6], %[f3] \n\t"
- "mul.s %[f8], %[f10], %[f5] \n\t"
- "mul.s %[f10], %[f10], %[f7] \n\t"
+ "sub.s %[f10], %[f0], %[f10] \n\t"
+ "sub.s %[f5], %[f11], %[f12] \n\t"
+ "add.s %[f7], %[f13], %[f14] \n\t"
+ "sub.s %[f1], %[f1], %[f9] \n\t"
+ "add.s %[f2], %[f2], %[f9] \n\t"
+ "sub.s %[f3], %[f6], %[f3] \n\t"
+ "mul.s %[f8], %[f10], %[f5] \n\t"
+ "mul.s %[f10], %[f10], %[f7] \n\t"
#if !defined(MIPS32_R2_LE)
- "mul.s %[f9], %[f15], %[f7] \n\t"
- "mul.s %[f15], %[f15], %[f5] \n\t"
- "sub.s %[f4], %[f6], %[f4] \n\t"
- "swc1 %[f1], 0(%[a1]) \n\t"
- "swc1 %[f2], 0(%[a2]) \n\t"
- "add.s %[f8], %[f8], %[f9] \n\t"
- "sub.s %[f10], %[f10], %[f15] \n\t"
+ "mul.s %[f9], %[f15], %[f7] \n\t"
+ "mul.s %[f15], %[f15], %[f5] \n\t"
+ "sub.s %[f4], %[f6], %[f4] \n\t"
+ "swc1 %[f1], 0(%[a1]) \n\t"
+ "swc1 %[f2], 0(%[a2]) \n\t"
+ "add.s %[f8], %[f8], %[f9] \n\t"
+ "sub.s %[f10], %[f10], %[f15] \n\t"
#else
- "swc1 %[f1], 0(%[a1]) \n\t"
- "swc1 %[f2], 0(%[a2]) \n\t"
- "sub.s %[f4], %[f6], %[f4] \n\t"
- "madd.s %[f8], %[f8], %[f15], %[f7] \n\t"
- "nmsub.s %[f10], %[f10], %[f15], %[f5] \n\t"
+ "swc1 %[f1], 0(%[a1]) \n\t"
+ "swc1 %[f2], 0(%[a2]) \n\t"
+ "sub.s %[f4], %[f6], %[f4] \n\t"
+ "madd.s %[f8], %[f8], %[f15], %[f7] \n\t"
+ "nmsub.s %[f10], %[f10], %[f15], %[f5] \n\t"
#endif
- "swc1 %[f3], 4(%[a1]) \n\t"
- "swc1 %[f4], 4(%[a2]) \n\t"
- "sub.s %[f11], %[f11], %[f8] \n\t"
- "add.s %[f12], %[f12], %[f8] \n\t"
- "sub.s %[f13], %[f10], %[f13] \n\t"
- "sub.s %[f14], %[f10], %[f14] \n\t"
- "addiu %[c2], %[c2], -8 \n\t"
- "addiu %[c1], %[c1], 8 \n\t"
- "swc1 %[f11], 8(%[a1]) \n\t"
- "swc1 %[f12], -8(%[a2]) \n\t"
- "swc1 %[f13], 12(%[a1]) \n\t"
- "swc1 %[f14], -4(%[a2]) \n\t"
- "addiu %[a1], %[a1], 16 \n\t"
- "addiu %[count], %[count], -1 \n\t"
- "bgtz %[count], 1b \n\t"
- " addiu %[a2], %[a2], -16 \n\t"
- ".set pop \n\t"
- : [a1] "+r" (a1), [a2] "+r" (a2), [c1] "+r" (c1), [c2] "+r" (c2),
- [f1] "=&f" (f1), [f2] "=&f" (f2), [f3] "=&f" (f3), [f4] "=&f" (f4),
- [f5] "=&f" (f5), [f6] "=&f" (f6), [f7] "=&f" (f7), [f8] "=&f" (f8),
- [f9] "=&f" (f9), [f10] "=&f" (f10), [f11] "=&f" (f11), [f12] "=&f" (f12),
- [f13] "=&f" (f13), [f14] "=&f" (f14), [f15] "=&f" (f15),
- [count] "=&r" (count)
- : [f0] "f" (f0)
- : "memory"
- );
+ "swc1 %[f3], 4(%[a1]) \n\t"
+ "swc1 %[f4], 4(%[a2]) \n\t"
+ "sub.s %[f11], %[f11], %[f8] \n\t"
+ "add.s %[f12], %[f12], %[f8] \n\t"
+ "sub.s %[f13], %[f10], %[f13] \n\t"
+ "sub.s %[f14], %[f10], %[f14] \n\t"
+ "addiu %[c2], %[c2], -8 \n\t"
+ "addiu %[c1], %[c1], 8 \n\t"
+ "swc1 %[f11], 8(%[a1]) \n\t"
+ "swc1 %[f12], -8(%[a2]) \n\t"
+ "swc1 %[f13], 12(%[a1]) \n\t"
+ "swc1 %[f14], -4(%[a2]) \n\t"
+ "addiu %[a1], %[a1], 16 \n\t"
+ "addiu %[count], %[count], -1 \n\t"
+ "bgtz %[count], 1b \n\t"
+ " addiu %[a2], %[a2], -16 \n\t"
+ ".set pop \n\t"
+ : [a1] "+r"(a1), [a2] "+r"(a2), [c1] "+r"(c1), [c2] "+r"(c2),
+ [f1] "=&f"(f1), [f2] "=&f"(f2), [f3] "=&f"(f3), [f4] "=&f"(f4),
+ [f5] "=&f"(f5), [f6] "=&f"(f6), [f7] "=&f"(f7), [f8] "=&f"(f8),
+ [f9] "=&f"(f9), [f10] "=&f"(f10), [f11] "=&f"(f11), [f12] "=&f"(f12),
+ [f13] "=&f"(f13), [f14] "=&f"(f14), [f15] "=&f"(f15),
+ [count] "=&r"(count)
+ : [f0] "f"(f0)
+ : "memory");
}
#endif
diff --git a/modules/audio_processing/vad/gmm_unittest.cc b/modules/audio_processing/vad/gmm_unittest.cc
index dfc8855..d895afa 100644
--- a/modules/audio_processing/vad/gmm_unittest.cc
+++ b/modules/audio_processing/vad/gmm_unittest.cc
@@ -37,10 +37,10 @@
voice_gmm.covar_inverse = &kVoiceGmmCovarInverse[0][0][0];
// Test vectors. These are the mean of the GMM means.
- const double kXVoice[kVoiceGmmDim] = {
- -1.35893162459863, 602.862491970368, 178.022069191324};
- const double kXNoise[kNoiseGmmDim] = {
- -2.33443722724409, 2827.97828765184, 141.114178166812};
+ const double kXVoice[kVoiceGmmDim] = {-1.35893162459863, 602.862491970368,
+ 178.022069191324};
+ const double kXNoise[kNoiseGmmDim] = {-2.33443722724409, 2827.97828765184,
+ 141.114178166812};
// Expected pdf values. These values are computed in MATLAB using EvalGmm.m
const double kPdfNoise = 1.88904409403101e-07;
diff --git a/modules/audio_processing/vad/noise_gmm_tables.h b/modules/audio_processing/vad/noise_gmm_tables.h
index c07dade..1556277 100644
--- a/modules/audio_processing/vad/noise_gmm_tables.h
+++ b/modules/audio_processing/vad/noise_gmm_tables.h
@@ -70,16 +70,8 @@
{-2.30193040814533e+00, 1.43953696546439e+03, 7.04085275122649e+01}};
static const double kNoiseGmmWeights[kNoiseGmmNumMixtures] = {
- -1.09422832086193e+01,
- -1.10847897513425e+01,
- -1.36767587732187e+01,
- -1.79789356118641e+01,
- -1.42830169160894e+01,
- -1.56500228061379e+01,
- -1.83124990950113e+01,
- -1.69979436177477e+01,
- -1.12329424387828e+01,
- -1.41311785780639e+01,
- -1.47171861448585e+01,
- -1.35963362781839e+01};
+ -1.09422832086193e+01, -1.10847897513425e+01, -1.36767587732187e+01,
+ -1.79789356118641e+01, -1.42830169160894e+01, -1.56500228061379e+01,
+ -1.83124990950113e+01, -1.69979436177477e+01, -1.12329424387828e+01,
+ -1.41311785780639e+01, -1.47171861448585e+01, -1.35963362781839e+01};
#endif // MODULES_AUDIO_PROCESSING_VAD_NOISE_GMM_TABLES_H_
diff --git a/modules/audio_processing/vad/pitch_based_vad.cc b/modules/audio_processing/vad/pitch_based_vad.cc
index 240ec63..025ef205 100644
--- a/modules/audio_processing/vad/pitch_based_vad.cc
+++ b/modules/audio_processing/vad/pitch_based_vad.cc
@@ -13,9 +13,9 @@
#include <math.h>
#include <string.h>
-#include "modules/audio_processing/vad/vad_circular_buffer.h"
#include "modules/audio_processing/vad/common.h"
#include "modules/audio_processing/vad/noise_gmm_tables.h"
+#include "modules/audio_processing/vad/vad_circular_buffer.h"
#include "modules/audio_processing/vad/voice_gmm_tables.h"
namespace webrtc {
@@ -58,8 +58,7 @@
voice_gmm_.covar_inverse = &kVoiceGmmCovarInverse[0][0][0];
}
-PitchBasedVad::~PitchBasedVad() {
-}
+PitchBasedVad::~PitchBasedVad() {}
int PitchBasedVad::VoicingProbability(const AudioFeatures& features,
double* p_combined) {
diff --git a/modules/audio_processing/vad/pitch_internal_unittest.cc b/modules/audio_processing/vad/pitch_internal_unittest.cc
index c1fde10..19c2e1a 100644
--- a/modules/audio_processing/vad/pitch_internal_unittest.cc
+++ b/modules/audio_processing/vad/pitch_internal_unittest.cc
@@ -26,12 +26,12 @@
double lags[] = {90, 111, 122, 50};
// Expected outputs
- double expected_log_pitch_gain[] = {
- -0.541212549898316, -1.45672279045507, -0.80471895621705};
+ double expected_log_pitch_gain[] = {-0.541212549898316, -1.45672279045507,
+ -0.80471895621705};
double expected_log_old_gain = log(gains[kNumInputParameters - 1]);
- double expected_pitch_lag_hz[] = {
- 92.3076923076923, 70.9010339734121, 93.0232558139535};
+ double expected_pitch_lag_hz[] = {92.3076923076923, 70.9010339734121,
+ 93.0232558139535};
double expected_old_lag = lags[kNumInputParameters - 1];
double log_pitch_gain[kNumOutputParameters];
diff --git a/modules/audio_processing/vad/pole_zero_filter.cc b/modules/audio_processing/vad/pole_zero_filter.cc
index fa56a3c..b9967d7 100644
--- a/modules/audio_processing/vad/pole_zero_filter.cc
+++ b/modules/audio_processing/vad/pole_zero_filter.cc
@@ -53,7 +53,8 @@
}
template <typename T>
-static float FilterArPast(const T* past, size_t order,
+static float FilterArPast(const T* past,
+ size_t order,
const float* coefficients) {
float sum = 0.0f;
size_t past_index = order - 1;
diff --git a/modules/audio_processing/vad/standalone_vad.cc b/modules/audio_processing/vad/standalone_vad.cc
index 2640892..813d375 100644
--- a/modules/audio_processing/vad/standalone_vad.cc
+++ b/modules/audio_processing/vad/standalone_vad.cc
@@ -21,8 +21,7 @@
static const int kDefaultStandaloneVadMode = 3;
StandaloneVad::StandaloneVad(VadInst* vad)
- : vad_(vad), buffer_(), index_(0), mode_(kDefaultStandaloneVadMode) {
-}
+ : vad_(vad), buffer_(), index_(0), mode_(kDefaultStandaloneVadMode) {}
StandaloneVad::~StandaloneVad() {
WebRtcVad_Free(vad_);
diff --git a/modules/audio_processing/vad/standalone_vad.h b/modules/audio_processing/vad/standalone_vad.h
index b85de0a..3f6eb7f 100644
--- a/modules/audio_processing/vad/standalone_vad.h
+++ b/modules/audio_processing/vad/standalone_vad.h
@@ -11,8 +11,8 @@
#ifndef MODULES_AUDIO_PROCESSING_AGC_STANDALONE_VAD_H_
#define MODULES_AUDIO_PROCESSING_AGC_STANDALONE_VAD_H_
-#include "modules/audio_processing/vad/common.h"
#include "common_audio/vad/include/webrtc_vad.h"
+#include "modules/audio_processing/vad/common.h"
#include "typedefs.h" // NOLINT(build/include)
namespace webrtc {
diff --git a/modules/audio_processing/vad/vad_audio_proc.cc b/modules/audio_processing/vad/vad_audio_proc.cc
index 459cda6..e9007c6 100644
--- a/modules/audio_processing/vad/vad_audio_proc.cc
+++ b/modules/audio_processing/vad/vad_audio_proc.cc
@@ -67,8 +67,7 @@
WebRtcIsac_InitPitchAnalysis(pitch_analysis_handle_.get());
}
-VadAudioProc::~VadAudioProc() {
-}
+VadAudioProc::~VadAudioProc() {}
void VadAudioProc::ResetBuffer() {
memcpy(audio_buffer_, &audio_buffer_[kNumSamplesToProcess],
diff --git a/modules/audio_processing/vad/vad_audio_proc_internal.h b/modules/audio_processing/vad/vad_audio_proc_internal.h
index ab1e636..915524f 100644
--- a/modules/audio_processing/vad/vad_audio_proc_internal.h
+++ b/modules/audio_processing/vad/vad_audio_proc_internal.h
@@ -14,23 +14,10 @@
namespace webrtc {
// These values should match MATLAB counterparts for unit-tests to pass.
-static const double kCorrWeight[] = {1.000000,
- 0.985000,
- 0.970225,
- 0.955672,
- 0.941337,
- 0.927217,
- 0.913308,
- 0.899609,
- 0.886115,
- 0.872823,
- 0.859730,
- 0.846834,
- 0.834132,
- 0.821620,
- 0.809296,
- 0.797156,
- 0.785199};
+static const double kCorrWeight[] = {
+ 1.000000, 0.985000, 0.970225, 0.955672, 0.941337, 0.927217,
+ 0.913308, 0.899609, 0.886115, 0.872823, 0.859730, 0.846834,
+ 0.834132, 0.821620, 0.809296, 0.797156, 0.785199};
static const double kLpcAnalWin[] = {
0.00000000, 0.01314436, 0.02628645, 0.03942400, 0.05255473, 0.06567639,
@@ -75,11 +62,9 @@
0.06567639, 0.05255473, 0.03942400, 0.02628645, 0.01314436, 0.00000000};
static const size_t kFilterOrder = 2;
-static const float kCoeffNumerator[kFilterOrder + 1] = {0.974827f,
- -1.949650f,
+static const float kCoeffNumerator[kFilterOrder + 1] = {0.974827f, -1.949650f,
0.974827f};
-static const float kCoeffDenominator[kFilterOrder + 1] = {1.0f,
- -1.971999f,
+static const float kCoeffDenominator[kFilterOrder + 1] = {1.0f, -1.971999f,
0.972457f};
static_assert(kFilterOrder + 1 ==
diff --git a/modules/audio_processing/vad/vad_circular_buffer.cc b/modules/audio_processing/vad/vad_circular_buffer.cc
index 3c4d5ad..31f14d7 100644
--- a/modules/audio_processing/vad/vad_circular_buffer.cc
+++ b/modules/audio_processing/vad/vad_circular_buffer.cc
@@ -19,11 +19,9 @@
is_full_(false),
index_(0),
buffer_size_(buffer_size),
- sum_(0) {
-}
+ sum_(0) {}
-VadCircularBuffer::~VadCircularBuffer() {
-}
+VadCircularBuffer::~VadCircularBuffer() {}
void VadCircularBuffer::Reset() {
is_full_ = false;
diff --git a/modules/audio_processing/vad/voice_activity_detector.cc b/modules/audio_processing/vad/voice_activity_detector.cc
index 66a704f..f0d34c6 100644
--- a/modules/audio_processing/vad/voice_activity_detector.cc
+++ b/modules/audio_processing/vad/voice_activity_detector.cc
@@ -27,8 +27,7 @@
VoiceActivityDetector::VoiceActivityDetector()
: last_voice_probability_(kDefaultVoiceValue),
- standalone_vad_(StandaloneVad::Create()) {
-}
+ standalone_vad_(StandaloneVad::Create()) {}
VoiceActivityDetector::~VoiceActivityDetector() = default;
diff --git a/modules/audio_processing/vad/voice_activity_detector.h b/modules/audio_processing/vad/voice_activity_detector.h
index 0079cb2..e424ac1 100644
--- a/modules/audio_processing/vad/voice_activity_detector.h
+++ b/modules/audio_processing/vad/voice_activity_detector.h
@@ -15,10 +15,10 @@
#include <vector>
#include "common_audio/resampler/include/resampler.h"
-#include "modules/audio_processing/vad/vad_audio_proc.h"
#include "modules/audio_processing/vad/common.h"
#include "modules/audio_processing/vad/pitch_based_vad.h"
#include "modules/audio_processing/vad/standalone_vad.h"
+#include "modules/audio_processing/vad/vad_audio_proc.h"
namespace webrtc {
diff --git a/modules/audio_processing/vad/voice_gmm_tables.h b/modules/audio_processing/vad/voice_gmm_tables.h
index 29cc7d6..ef4ad7e 100644
--- a/modules/audio_processing/vad/voice_gmm_tables.h
+++ b/modules/audio_processing/vad/voice_gmm_tables.h
@@ -70,16 +70,8 @@
{-7.29187507662854e-01, 5.22717685022855e+02, 1.16377942283991e+02}};
static const double kVoiceGmmWeights[kVoiceGmmNumMixtures] = {
- -1.39789694361035e+01,
- -1.19527720202104e+01,
- -1.32396317929055e+01,
- -1.09436815209238e+01,
- -1.13440027478149e+01,
- -1.12200721834504e+01,
- -1.02537324043693e+01,
- -1.60789861938302e+01,
- -1.03394494048344e+01,
- -1.83207938586818e+01,
- -1.31186044948288e+01,
- -9.52479998673554e+00};
+ -1.39789694361035e+01, -1.19527720202104e+01, -1.32396317929055e+01,
+ -1.09436815209238e+01, -1.13440027478149e+01, -1.12200721834504e+01,
+ -1.02537324043693e+01, -1.60789861938302e+01, -1.03394494048344e+01,
+ -1.83207938586818e+01, -1.31186044948288e+01, -9.52479998673554e+00};
#endif // MODULES_AUDIO_PROCESSING_VAD_VOICE_GMM_TABLES_H_
diff --git a/modules/audio_processing/voice_detection_impl.cc b/modules/audio_processing/voice_detection_impl.cc
index 5ee0c7b..9280be1 100644
--- a/modules/audio_processing/voice_detection_impl.cc
+++ b/modules/audio_processing/voice_detection_impl.cc
@@ -23,10 +23,9 @@
int error = WebRtcVad_Init(state_);
RTC_DCHECK_EQ(0, error);
}
- ~Vad() {
- WebRtcVad_Free(state_);
- }
+ ~Vad() { WebRtcVad_Free(state_); }
VadInst* state() { return state_; }
+
private:
VadInst* state_ = nullptr;
RTC_DISALLOW_COPY_AND_ASSIGN(Vad);
@@ -65,9 +64,9 @@
RTC_DCHECK_GE(160, audio->num_frames_per_band());
// TODO(ajm): concatenate data in frame buffer here.
- int vad_ret = WebRtcVad_Process(vad_->state(), sample_rate_hz_,
- audio->mixed_low_pass_data(),
- frame_size_samples_);
+ int vad_ret =
+ WebRtcVad_Process(vad_->state(), sample_rate_hz_,
+ audio->mixed_low_pass_data(), frame_size_samples_);
if (vad_ret == 0) {
stream_has_voice_ = false;
audio->set_activity(AudioFrame::kVadPassive);
@@ -103,7 +102,7 @@
bool VoiceDetectionImpl::stream_has_voice() const {
rtc::CritScope cs(crit_);
// TODO(ajm): enable this assertion?
- //RTC_DCHECK(using_external_vad_ || is_component_enabled());
+ // RTC_DCHECK(using_external_vad_ || is_component_enabled());
return stream_has_voice_;
}
@@ -142,7 +141,7 @@
int VoiceDetectionImpl::set_frame_size_ms(int size) {
rtc::CritScope cs(crit_);
- RTC_DCHECK_EQ(10, size); // TODO(ajm): remove when supported.
+ RTC_DCHECK_EQ(10, size); // TODO(ajm): remove when supported.
frame_size_ms_ = size;
Initialize(sample_rate_hz_);
return AudioProcessing::kNoError;
diff --git a/modules/bitrate_controller/bitrate_controller_impl.cc b/modules/bitrate_controller/bitrate_controller_impl.cc
index 5b9b9ad..38f97fb 100644
--- a/modules/bitrate_controller/bitrate_controller_impl.cc
+++ b/modules/bitrate_controller/bitrate_controller_impl.cc
@@ -25,8 +25,7 @@
: public RtcpBandwidthObserver {
public:
explicit RtcpBandwidthObserverImpl(BitrateControllerImpl* owner)
- : owner_(owner) {
- }
+ : owner_(owner) {}
~RtcpBandwidthObserverImpl() override = default;
// Received RTCP REMB or TMMBR.
void OnReceivedEstimatedBitrate(uint32_t bitrate) override {
@@ -102,8 +101,7 @@
int max_bitrate_bps) {
{
rtc::CritScope cs(&critsect_);
- bandwidth_estimation_.SetBitrates(start_bitrate_bps,
- min_bitrate_bps,
+ bandwidth_estimation_.SetBitrates(start_bitrate_bps, min_bitrate_bps,
max_bitrate_bps);
}
MaybeTriggerOnNetworkChanged();
diff --git a/modules/bitrate_controller/bitrate_controller_impl.h b/modules/bitrate_controller/bitrate_controller_impl.h
index 6a67808..e315c5f 100644
--- a/modules/bitrate_controller/bitrate_controller_impl.h
+++ b/modules/bitrate_controller/bitrate_controller_impl.h
@@ -54,7 +54,6 @@
int min_bitrate_bps,
int max_bitrate_bps) override;
-
void SetReservedBitrate(uint32_t reserved_bitrate_bps) override;
// Returns true if the parameters have changed since the last call.
diff --git a/modules/bitrate_controller/bitrate_controller_unittest.cc b/modules/bitrate_controller/bitrate_controller_unittest.cc
index 8bd7800..ce930d1 100644
--- a/modules/bitrate_controller/bitrate_controller_unittest.cc
+++ b/modules/bitrate_controller/bitrate_controller_unittest.cc
@@ -26,28 +26,29 @@
using webrtc::PacedSender;
using webrtc::RtcpBandwidthObserver;
-uint8_t WeightedLoss(int num_packets1, uint8_t fraction_loss1,
- int num_packets2, uint8_t fraction_loss2) {
- int weighted_sum = num_packets1 * fraction_loss1 +
- num_packets2 * fraction_loss2;
+uint8_t WeightedLoss(int num_packets1,
+ uint8_t fraction_loss1,
+ int num_packets2,
+ uint8_t fraction_loss2) {
+ int weighted_sum =
+ num_packets1 * fraction_loss1 + num_packets2 * fraction_loss2;
int total_num_packets = num_packets1 + num_packets2;
return (weighted_sum + total_num_packets / 2) / total_num_packets;
}
webrtc::RTCPReportBlock CreateReportBlock(
- uint32_t remote_ssrc, uint32_t source_ssrc,
- uint8_t fraction_lost, uint32_t extended_high_sequence_number) {
+ uint32_t remote_ssrc,
+ uint32_t source_ssrc,
+ uint8_t fraction_lost,
+ uint32_t extended_high_sequence_number) {
return webrtc::RTCPReportBlock(remote_ssrc, source_ssrc, fraction_lost, 0,
extended_high_sequence_number, 0, 0, 0);
}
-class TestBitrateObserver: public BitrateObserver {
+class TestBitrateObserver : public BitrateObserver {
public:
TestBitrateObserver()
- : last_bitrate_(0),
- last_fraction_loss_(0),
- last_rtt_(0) {
- }
+ : last_bitrate_(0), last_fraction_loss_(0), last_rtt_(0) {}
virtual void OnNetworkChanged(uint32_t bitrate,
uint8_t fraction_loss,
@@ -76,8 +77,7 @@
bandwidth_observer_ = controller_.get();
}
- virtual void TearDown() {
- }
+ virtual void TearDown() {}
const int kMinBitrateBps = 100000;
const int kStartBitrateBps = 200000;
@@ -197,8 +197,8 @@
RtcpBandwidthObserver* second_bandwidth_observer = controller_.get();
report_blocks = {CreateReportBlock(kSenderSsrc2, kMediaSsrc2, 0, 21)};
- second_bandwidth_observer->OnReceivedRtcpReceiverReport(
- report_blocks, 100, time_ms);
+ second_bandwidth_observer->OnReceivedRtcpReceiverReport(report_blocks, 100,
+ time_ms);
// Test start bitrate.
EXPECT_EQ(200000, bitrate_observer_.last_bitrate_);
@@ -212,8 +212,8 @@
time_ms += 500;
report_blocks = {CreateReportBlock(kSenderSsrc2, kMediaSsrc2, 0, 21)};
- second_bandwidth_observer->OnReceivedRtcpReceiverReport(
- report_blocks, 100, time_ms);
+ second_bandwidth_observer->OnReceivedRtcpReceiverReport(report_blocks, 100,
+ time_ms);
EXPECT_EQ(217000, bitrate_observer_.last_bitrate_);
EXPECT_EQ(0, bitrate_observer_.last_fraction_loss_);
EXPECT_EQ(100, bitrate_observer_.last_rtt_);
@@ -221,8 +221,8 @@
// Extra report should not change estimate.
report_blocks = {CreateReportBlock(kSenderSsrc2, kMediaSsrc2, 0, 31)};
- second_bandwidth_observer->OnReceivedRtcpReceiverReport(
- report_blocks, 100, time_ms);
+ second_bandwidth_observer->OnReceivedRtcpReceiverReport(report_blocks, 100,
+ time_ms);
EXPECT_EQ(217000, bitrate_observer_.last_bitrate_);
time_ms += 500;
@@ -232,34 +232,34 @@
// Second report should not change estimate.
report_blocks = {CreateReportBlock(kSenderSsrc2, kMediaSsrc2, 0, 41)};
- second_bandwidth_observer->OnReceivedRtcpReceiverReport(
- report_blocks, 100, time_ms);
+ second_bandwidth_observer->OnReceivedRtcpReceiverReport(report_blocks, 100,
+ time_ms);
EXPECT_EQ(235360, bitrate_observer_.last_bitrate_);
time_ms += 1000;
// Reports from only one bandwidth observer is ok.
report_blocks = {CreateReportBlock(kSenderSsrc2, kMediaSsrc2, 0, 61)};
- second_bandwidth_observer->OnReceivedRtcpReceiverReport(
- report_blocks, 50, time_ms);
+ second_bandwidth_observer->OnReceivedRtcpReceiverReport(report_blocks, 50,
+ time_ms);
EXPECT_EQ(255189, bitrate_observer_.last_bitrate_);
time_ms += 1000;
report_blocks = {CreateReportBlock(kSenderSsrc2, kMediaSsrc2, 0, 81)};
- second_bandwidth_observer->OnReceivedRtcpReceiverReport(
- report_blocks, 50, time_ms);
+ second_bandwidth_observer->OnReceivedRtcpReceiverReport(report_blocks, 50,
+ time_ms);
EXPECT_EQ(276604, bitrate_observer_.last_bitrate_);
time_ms += 1000;
report_blocks = {CreateReportBlock(kSenderSsrc2, kMediaSsrc2, 0, 121)};
- second_bandwidth_observer->OnReceivedRtcpReceiverReport(
- report_blocks, 50, time_ms);
+ second_bandwidth_observer->OnReceivedRtcpReceiverReport(report_blocks, 50,
+ time_ms);
EXPECT_EQ(299732, bitrate_observer_.last_bitrate_);
time_ms += 1000;
// Reach max cap.
report_blocks = {CreateReportBlock(kSenderSsrc2, kMediaSsrc2, 0, 141)};
- second_bandwidth_observer->OnReceivedRtcpReceiverReport(
- report_blocks, 50, time_ms);
+ second_bandwidth_observer->OnReceivedRtcpReceiverReport(report_blocks, 50,
+ time_ms);
EXPECT_EQ(300000, bitrate_observer_.last_bitrate_);
// Test that a low REMB trigger immediately.
diff --git a/modules/bitrate_controller/send_side_bandwidth_estimation.cc b/modules/bitrate_controller/send_side_bandwidth_estimation.cc
index 323c210..d304516 100644
--- a/modules/bitrate_controller/send_side_bandwidth_estimation.cc
+++ b/modules/bitrate_controller/send_side_bandwidth_estimation.cc
@@ -193,8 +193,8 @@
*rtt = last_round_trip_time_ms_;
}
-void SendSideBandwidthEstimation::UpdateReceiverEstimate(
- int64_t now_ms, uint32_t bandwidth) {
+void SendSideBandwidthEstimation::UpdateReceiverEstimate(int64_t now_ms,
+ uint32_t bandwidth) {
bwe_incoming_ = bandwidth;
CapBitrateToThresholds(now_ms, current_bitrate_bps_);
}
diff --git a/modules/bitrate_controller/send_side_bandwidth_estimation.h b/modules/bitrate_controller/send_side_bandwidth_estimation.h
index d09184c0..54b571e 100644
--- a/modules/bitrate_controller/send_side_bandwidth_estimation.h
+++ b/modules/bitrate_controller/send_side_bandwidth_estimation.h
@@ -54,9 +54,7 @@
// Call when we receive a RTCP message with a ReceiveBlock.
void UpdateRtt(int64_t rtt, int64_t now_ms);
- void SetBitrates(int send_bitrate,
- int min_bitrate,
- int max_bitrate);
+ void SetBitrates(int send_bitrate, int min_bitrate, int max_bitrate);
void SetSendBitrate(int bitrate);
void SetMinMaxBitrate(int min_bitrate, int max_bitrate);
int GetMinBitrate() const;
diff --git a/modules/bitrate_controller/send_side_bandwidth_estimation_unittest.cc b/modules/bitrate_controller/send_side_bandwidth_estimation_unittest.cc
index 567d81f..8d5b08b 100644
--- a/modules/bitrate_controller/send_side_bandwidth_estimation_unittest.cc
+++ b/modules/bitrate_controller/send_side_bandwidth_estimation_unittest.cc
@@ -164,5 +164,4 @@
EXPECT_EQ(bitrate_bps, kForcedHighBitrate);
}
-
} // namespace webrtc
diff --git a/modules/congestion_controller/bbr/bbr_network_controller.cc b/modules/congestion_controller/bbr/bbr_network_controller.cc
index a8de48a..89fab5d 100644
--- a/modules/congestion_controller/bbr/bbr_network_controller.cc
+++ b/modules/congestion_controller/bbr/bbr_network_controller.cc
@@ -430,7 +430,7 @@
} else {
bytes_acked_since_queue_drained_ += data_acked;
}
- }
+ }
}
// Handle logic specific to PROBE_BW mode.
diff --git a/modules/congestion_controller/include/receive_side_congestion_controller.h b/modules/congestion_controller/include/receive_side_congestion_controller.h
index a4b593a..ef3c8b1 100644
--- a/modules/congestion_controller/include/receive_side_congestion_controller.h
+++ b/modules/congestion_controller/include/receive_side_congestion_controller.h
@@ -30,9 +30,8 @@
class ReceiveSideCongestionController : public CallStatsObserver,
public Module {
public:
- ReceiveSideCongestionController(
- const Clock* clock,
- PacketRouter* packet_router);
+ ReceiveSideCongestionController(const Clock* clock,
+ PacketRouter* packet_router);
virtual ~ReceiveSideCongestionController() {}
diff --git a/modules/congestion_controller/probe_controller.cc b/modules/congestion_controller/probe_controller.cc
index 56fc8ad..674fa42 100644
--- a/modules/congestion_controller/probe_controller.cc
+++ b/modules/congestion_controller/probe_controller.cc
@@ -81,7 +81,7 @@
int64_t max_bitrate_bps) {
rtc::CritScope cs(&critsect_);
- if (start_bitrate_bps > 0) {
+ if (start_bitrate_bps > 0) {
start_bitrate_bps_ = start_bitrate_bps;
estimated_bitrate_bps_ = start_bitrate_bps;
} else if (start_bitrate_bps_ == 0) {
diff --git a/modules/congestion_controller/probe_controller_unittest.cc b/modules/congestion_controller/probe_controller_unittest.cc
index 6e47e01..14f53b7 100644
--- a/modules/congestion_controller/probe_controller_unittest.cc
+++ b/modules/congestion_controller/probe_controller_unittest.cc
@@ -249,7 +249,7 @@
// Make sure we use |kStartBitrateBps| as the estimated bitrate
// until SetEstimatedBitrate is called with an updated estimate.
clock_.AdvanceTimeMilliseconds(10000);
- EXPECT_CALL(local_pacer, CreateProbeCluster(kStartBitrateBps*2));
+ EXPECT_CALL(local_pacer, CreateProbeCluster(kStartBitrateBps * 2));
probe_controller_->Process();
}
diff --git a/modules/congestion_controller/send_side_congestion_controller.cc b/modules/congestion_controller/send_side_congestion_controller.cc
index 8df5ed0..480b741 100644
--- a/modules/congestion_controller/send_side_congestion_controller.cc
+++ b/modules/congestion_controller/send_side_congestion_controller.cc
@@ -97,10 +97,10 @@
}
bool IsPacerPushbackExperimentEnabled() {
- return webrtc::field_trial::IsEnabled(kPacerPushbackExperiment) || (
- !webrtc::field_trial::IsDisabled(kPacerPushbackExperiment) &&
- webrtc::runtime_enabled_features::IsFeatureEnabled(
- webrtc::runtime_enabled_features::kDualStreamModeFeatureName));
+ return webrtc::field_trial::IsEnabled(kPacerPushbackExperiment) ||
+ (!webrtc::field_trial::IsDisabled(kPacerPushbackExperiment) &&
+ webrtc::runtime_enabled_features::IsFeatureEnabled(
+ webrtc::runtime_enabled_features::kDualStreamModeFeatureName));
}
} // namespace
diff --git a/modules/congestion_controller/transport_feedback_adapter_unittest.cc b/modules/congestion_controller/transport_feedback_adapter_unittest.cc
index 00e60bb..39aa72e 100644
--- a/modules/congestion_controller/transport_feedback_adapter_unittest.cc
+++ b/modules/congestion_controller/transport_feedback_adapter_unittest.cc
@@ -34,7 +34,7 @@
const PacedPacketInfo kPacingInfo2(2, 14, 7000);
const PacedPacketInfo kPacingInfo3(3, 20, 10000);
const PacedPacketInfo kPacingInfo4(4, 22, 10000);
-}
+} // namespace
namespace test {
@@ -85,8 +85,7 @@
const std::vector<PacketFeedback> packets = {
PacketFeedback(100, 200, 0, 1000, kPacingInfo0),
PacketFeedback(110, 210, 1, 2000, kPacingInfo0),
- PacketFeedback(120, 220, 2, 3000, kPacingInfo0)
- };
+ PacketFeedback(120, 220, 2, 3000, kPacingInfo0)};
rtcp::TransportFeedback feedback;
feedback.SetBase(packets[0].sequence_number,
@@ -171,8 +170,7 @@
PacketFeedback(130, 230, 3, 1500, kPacingInfo0),
PacketFeedback(140, 240, 4, 1500, kPacingInfo0),
PacketFeedback(150, 250, 5, 1500, kPacingInfo0),
- PacketFeedback(160, 260, 6, 1500, kPacingInfo0)
- };
+ PacketFeedback(160, 260, 6, 1500, kPacingInfo0)};
for (const PacketFeedback& packet : sent_packets)
OnSentPacket(packet);
@@ -180,8 +178,7 @@
// Note: Important to include the last packet, as only unreceived packets in
// between received packets can be inferred.
std::vector<PacketFeedback> received_packets = {
- sent_packets[0], sent_packets[2], sent_packets[6]
- };
+ sent_packets[0], sent_packets[2], sent_packets[6]};
rtcp::TransportFeedback feedback;
feedback.SetBase(received_packets[0].sequence_number,
diff --git a/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.cc b/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.cc
index 722f5dc..6bf8d51 100644
--- a/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.cc
+++ b/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.cc
@@ -22,8 +22,7 @@
BlankDetectorDesktopCapturerWrapper::BlankDetectorDesktopCapturerWrapper(
std::unique_ptr<DesktopCapturer> capturer,
RgbaColor blank_pixel)
- : capturer_(std::move(capturer)),
- blank_pixel_(blank_pixel) {
+ : capturer_(std::move(capturer)), blank_pixel_(blank_pixel) {
RTC_DCHECK(capturer_);
}
diff --git a/modules/desktop_capture/blank_detector_desktop_capturer_wrapper_unittest.cc b/modules/desktop_capture/blank_detector_desktop_capturer_wrapper_unittest.cc
index f9cfee0..d4ec008 100644
--- a/modules/desktop_capture/blank_detector_desktop_capturer_wrapper_unittest.cc
+++ b/modules/desktop_capture/blank_detector_desktop_capturer_wrapper_unittest.cc
@@ -49,7 +49,7 @@
};
BlankDetectorDesktopCapturerWrapperTest::
-BlankDetectorDesktopCapturerWrapperTest() {
+ BlankDetectorDesktopCapturerWrapperTest() {
frame_generator_.size()->set(frame_width_, frame_height_);
frame_generator_.set_desktop_frame_painter(&painter_);
std::unique_ptr<DesktopCapturer> capturer(new FakeDesktopCapturer());
@@ -63,7 +63,7 @@
}
BlankDetectorDesktopCapturerWrapperTest::
-~BlankDetectorDesktopCapturerWrapperTest() = default;
+ ~BlankDetectorDesktopCapturerWrapperTest() = default;
void BlankDetectorDesktopCapturerWrapperTest::OnCaptureResult(
DesktopCapturer::Result result,
diff --git a/modules/desktop_capture/capture_result_desktop_capturer_wrapper.cc b/modules/desktop_capture/capture_result_desktop_capturer_wrapper.cc
index b15ce2b..5e0d264 100644
--- a/modules/desktop_capture/capture_result_desktop_capturer_wrapper.cc
+++ b/modules/desktop_capture/capture_result_desktop_capturer_wrapper.cc
@@ -20,13 +20,12 @@
CaptureResultDesktopCapturerWrapper::CaptureResultDesktopCapturerWrapper(
std::unique_ptr<DesktopCapturer> base_capturer,
ResultObserver* observer)
- : DesktopCapturerWrapper(std::move(base_capturer)),
- observer_(observer) {
+ : DesktopCapturerWrapper(std::move(base_capturer)), observer_(observer) {
RTC_DCHECK(observer_);
}
-CaptureResultDesktopCapturerWrapper::
-~CaptureResultDesktopCapturerWrapper() = default;
+CaptureResultDesktopCapturerWrapper::~CaptureResultDesktopCapturerWrapper() =
+ default;
void CaptureResultDesktopCapturerWrapper::Start(Callback* callback) {
if ((callback_ == nullptr) != (callback == nullptr)) {
diff --git a/modules/desktop_capture/capture_result_desktop_capturer_wrapper.h b/modules/desktop_capture/capture_result_desktop_capturer_wrapper.h
index 3f97bc5..ffce296 100644
--- a/modules/desktop_capture/capture_result_desktop_capturer_wrapper.h
+++ b/modules/desktop_capture/capture_result_desktop_capturer_wrapper.h
@@ -21,9 +21,8 @@
// A DesktopCapturerWrapper implementation to capture the result of
// |base_capturer|. Derived classes are expected to provide a ResultObserver
// implementation to observe the DesktopFrame returned by |base_capturer_|.
-class CaptureResultDesktopCapturerWrapper
- : public DesktopCapturerWrapper,
- public DesktopCapturer::Callback {
+class CaptureResultDesktopCapturerWrapper : public DesktopCapturerWrapper,
+ public DesktopCapturer::Callback {
public:
using Callback = DesktopCapturer::Callback;
diff --git a/modules/desktop_capture/cropped_desktop_frame.h b/modules/desktop_capture/cropped_desktop_frame.h
index f6cac6c..59dced4 100644
--- a/modules/desktop_capture/cropped_desktop_frame.h
+++ b/modules/desktop_capture/cropped_desktop_frame.h
@@ -27,4 +27,3 @@
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_CROPPED_DESKTOP_FRAME_H_
-
diff --git a/modules/desktop_capture/cropped_desktop_frame_unittest.cc b/modules/desktop_capture/cropped_desktop_frame_unittest.cc
index d15f207..fbd488f 100644
--- a/modules/desktop_capture/cropped_desktop_frame_unittest.cc
+++ b/modules/desktop_capture/cropped_desktop_frame_unittest.cc
@@ -32,15 +32,16 @@
}
TEST(CroppedDesktopFrameTest, ReturnNullptrIfSizeIsNotSufficient) {
- ASSERT_EQ(nullptr, CreateCroppedDesktopFrame(
- CreateTestFrame(), DesktopRect::MakeWH(11, 10)));
+ ASSERT_EQ(nullptr, CreateCroppedDesktopFrame(CreateTestFrame(),
+ DesktopRect::MakeWH(11, 10)));
}
TEST(CroppedDesktopFrameTest, ReturnNullIfCropRegionIsOutOfBounds) {
std::unique_ptr<DesktopFrame> frame = CreateTestFrame();
frame->set_top_left(DesktopVector(100, 200));
- ASSERT_EQ(nullptr, CreateCroppedDesktopFrame(std::move(frame),
- DesktopRect::MakeLTRB(101, 203, 109, 218)));
+ ASSERT_EQ(nullptr,
+ CreateCroppedDesktopFrame(
+ std::move(frame), DesktopRect::MakeLTRB(101, 203, 109, 218)));
}
TEST(CroppedDesktopFrameTest, CropASubArea) {
@@ -56,7 +57,7 @@
std::unique_ptr<DesktopFrame> frame = CreateTestFrame();
frame->set_top_left(DesktopVector(100, 200));
frame = CreateCroppedDesktopFrame(std::move(frame),
- DesktopRect::MakeLTRB(1, 3, 9, 18));
+ DesktopRect::MakeLTRB(1, 3, 9, 18));
ASSERT_EQ(frame->size().width(), 8);
ASSERT_EQ(frame->size().height(), 15);
ASSERT_EQ(frame->top_left().x(), 101);
diff --git a/modules/desktop_capture/cropping_window_capturer.h b/modules/desktop_capture/cropping_window_capturer.h
index 9fbfdda..c889801 100644
--- a/modules/desktop_capture/cropping_window_capturer.h
+++ b/modules/desktop_capture/cropping_window_capturer.h
@@ -13,8 +13,8 @@
#include <memory>
-#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_capture_options.h"
+#include "modules/desktop_capture/desktop_capturer.h"
namespace webrtc {
@@ -76,4 +76,3 @@
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_CROPPING_WINDOW_CAPTURER_H_
-
diff --git a/modules/desktop_capture/cropping_window_capturer_win.cc b/modules/desktop_capture/cropping_window_capturer_win.cc
index b08f441..ae270a6 100644
--- a/modules/desktop_capture/cropping_window_capturer_win.cc
+++ b/modules/desktop_capture/cropping_window_capturer_win.cc
@@ -147,8 +147,7 @@
class CroppingWindowCapturerWin : public CroppingWindowCapturer {
public:
- CroppingWindowCapturerWin(
- const DesktopCaptureOptions& options)
+ CroppingWindowCapturerWin(const DesktopCaptureOptions& options)
: CroppingWindowCapturer(options) {}
private:
@@ -216,8 +215,8 @@
if (region_type == SIMPLEREGION) {
// The |region_rect| returned from GetRgnBox() is always in window
// coordinate.
- region_rect.Translate(
- window_region_rect_.left(), window_region_rect_.top());
+ region_rect.Translate(window_region_rect_.left(),
+ window_region_rect_.top());
// MSDN: The window region determines the area *within* the window where the
// system permits drawing.
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd144950(v=vs.85).aspx.
diff --git a/modules/desktop_capture/desktop_and_cursor_composer.cc b/modules/desktop_capture/desktop_and_cursor_composer.cc
index cad53f1..7656ba3 100644
--- a/modules/desktop_capture/desktop_and_cursor_composer.cc
+++ b/modules/desktop_capture/desktop_and_cursor_composer.cc
@@ -28,8 +28,10 @@
// Helper function that blends one image into another. Source image must be
// pre-multiplied with the alpha channel. Destination is assumed to be opaque.
-void AlphaBlend(uint8_t* dest, int dest_stride,
- const uint8_t* src, int src_stride,
+void AlphaBlend(uint8_t* dest,
+ int dest_stride,
+ const uint8_t* src,
+ int src_stride,
const DesktopSize& size) {
for (int y = 0; y < size.height(); ++y) {
for (int x = 0; x < size.width(); ++x) {
@@ -111,8 +113,7 @@
cursor.image()->data() +
origin_shift.y() * cursor.image()->stride() +
origin_shift.x() * DesktopFrame::kBytesPerPixel,
- cursor.image()->stride(),
- target_rect.size());
+ cursor.image()->stride(), target_rect.size());
}
DesktopFrameWithCursor::~DesktopFrameWithCursor() {
diff --git a/modules/desktop_capture/desktop_and_cursor_composer_unittest.cc b/modules/desktop_capture/desktop_and_cursor_composer_unittest.cc
index 9c3ab7b..c94a3cd 100644
--- a/modules/desktop_capture/desktop_and_cursor_composer_unittest.cc
+++ b/modules/desktop_capture/desktop_and_cursor_composer_unittest.cc
@@ -11,8 +11,8 @@
#include <memory>
#include "modules/desktop_capture/desktop_and_cursor_composer.h"
-#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_capture_options.h"
+#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_frame.h"
#include "modules/desktop_capture/mouse_cursor.h"
#include "modules/desktop_capture/shared_desktop_frame.h"
@@ -30,9 +30,15 @@
const int kTestCursorSize = 3;
const uint32_t kTestCursorData[kTestCursorSize][kTestCursorSize] = {
- { 0xffffffff, 0x99990000, 0xaa222222, },
- { 0x88008800, 0xaa0000aa, 0xaa333333, },
- { 0x00000000, 0xaa0000aa, 0xaa333333, },
+ {
+ 0xffffffff, 0x99990000, 0xaa222222,
+ },
+ {
+ 0x88008800, 0xaa0000aa, 0xaa333333,
+ },
+ {
+ 0x00000000, 0xaa0000aa, 0xaa333333,
+ },
};
uint32_t GetFakeFramePixelValue(const DesktopVector& p) {
@@ -197,19 +203,11 @@
int hotspot_x, hotspot_y;
bool inside;
} tests[] = {
- {0, 0, 0, 0, true},
- {50, 50, 0, 0, true},
- {100, 50, 0, 0, true},
- {50, 100, 0, 0, true},
- {100, 100, 0, 0, true},
- {0, 0, 2, 5, true},
- {1, 1, 2, 5, true},
- {50, 50, 2, 5, true},
- {100, 100, 2, 5, true},
- {0, 0, 5, 2, true},
- {50, 50, 5, 2, true},
- {100, 100, 5, 2, true},
- {0, 0, 0, 0, false},
+ {0, 0, 0, 0, true}, {50, 50, 0, 0, true}, {100, 50, 0, 0, true},
+ {50, 100, 0, 0, true}, {100, 100, 0, 0, true}, {0, 0, 2, 5, true},
+ {1, 1, 2, 5, true}, {50, 50, 2, 5, true}, {100, 100, 2, 5, true},
+ {0, 0, 5, 2, true}, {50, 50, 5, 2, true}, {100, 100, 5, 2, true},
+ {0, 0, 0, 0, false},
};
for (size_t i = 0; i < arraysize(tests); i++) {
@@ -245,19 +243,9 @@
int x;
int y;
} tests[] = {
- { 0, 0 },
- { 50, 50 },
- { 50, 150 },
- { 100, 150 },
- { 50, 200 },
- { 99, 200 },
- { 100, 199 },
- { 200, 300 },
- { 200, 299 },
- { 199, 300 },
- { -1, -1 },
- { -10000, -10000 },
- { 10000, 10000 },
+ {0, 0}, {50, 50}, {50, 150}, {100, 150}, {50, 200},
+ {99, 200}, {100, 199}, {200, 300}, {200, 299}, {199, 300},
+ {-1, -1}, {-10000, -10000}, {10000, 10000},
};
for (size_t i = 0; i < arraysize(tests); i++) {
SCOPED_TRACE(i);
@@ -281,12 +269,7 @@
int x;
int y;
} tests[] = {
- { 100, 200 },
- { 101, 200 },
- { 100, 201 },
- { 101, 201 },
- { 150, 250 },
- { 199, 299 },
+ {100, 200}, {101, 200}, {100, 201}, {101, 201}, {150, 250}, {199, 299},
};
fake_screen_->set_is_occluded(true);
for (size_t i = 0; i < arraysize(tests); i++) {
@@ -311,12 +294,7 @@
int x;
int y;
} tests[] = {
- { 100, 200 },
- { 101, 200 },
- { 100, 201 },
- { 101, 201 },
- { 150, 250 },
- { 199, 299 },
+ {100, 200}, {101, 200}, {100, 201}, {101, 201}, {150, 250}, {199, 299},
};
for (size_t i = 0; i < arraysize(tests); i++) {
SCOPED_TRACE(i);
diff --git a/modules/desktop_capture/desktop_capture_options.h b/modules/desktop_capture/desktop_capture_options.h
index a945d27..60aa05c 100644
--- a/modules/desktop_capture/desktop_capture_options.h
+++ b/modules/desktop_capture/desktop_capture_options.h
@@ -108,9 +108,7 @@
}
// Allowing directx based capturer or not, this capturer works on windows 7
// with platform update / windows 8 or upper.
- bool allow_directx_capturer() const {
- return allow_directx_capturer_;
- }
+ bool allow_directx_capturer() const { return allow_directx_capturer_; }
void set_allow_directx_capturer(bool enabled) {
allow_directx_capturer_ = enabled;
}
diff --git a/modules/desktop_capture/desktop_capture_types.h b/modules/desktop_capture/desktop_capture_types.h
index 5d6ab8a..f0a2baf 100644
--- a/modules/desktop_capture/desktop_capture_types.h
+++ b/modules/desktop_capture/desktop_capture_types.h
@@ -41,17 +41,14 @@
// An integer to attach to each DesktopFrame to differentiate the generator of
// the frame.
namespace DesktopCapturerId {
- constexpr uint32_t CreateFourCC(char a, char b, char c, char d) {
- return ((static_cast<uint32_t>(a)) |
- (static_cast<uint32_t>(b) << 8) |
- (static_cast<uint32_t>(c) << 16) |
- (static_cast<uint32_t>(d) << 24));
- }
+constexpr uint32_t CreateFourCC(char a, char b, char c, char d) {
+ return ((static_cast<uint32_t>(a)) | (static_cast<uint32_t>(b) << 8) |
+ (static_cast<uint32_t>(c) << 16) | (static_cast<uint32_t>(d) << 24));
+}
- constexpr uint32_t kUnknown = 0;
- constexpr uint32_t kScreenCapturerWinGdi = CreateFourCC('G', 'D', 'I', ' ');
- constexpr uint32_t kScreenCapturerWinDirectx =
- CreateFourCC('D', 'X', 'G', 'I');
+constexpr uint32_t kUnknown = 0;
+constexpr uint32_t kScreenCapturerWinGdi = CreateFourCC('G', 'D', 'I', ' ');
+constexpr uint32_t kScreenCapturerWinDirectx = CreateFourCC('D', 'X', 'G', 'I');
} // namespace DesktopCapturerId
} // namespace webrtc
diff --git a/modules/desktop_capture/desktop_capturer.h b/modules/desktop_capture/desktop_capturer.h
index 335427a..47196cf 100644
--- a/modules/desktop_capture/desktop_capturer.h
+++ b/modules/desktop_capture/desktop_capturer.h
@@ -19,8 +19,8 @@
#include <type_traits>
#include <vector>
-#include "modules/desktop_capture/desktop_frame.h"
#include "modules/desktop_capture/desktop_capture_types.h"
+#include "modules/desktop_capture/desktop_frame.h"
#include "modules/desktop_capture/shared_memory.h"
namespace webrtc {
@@ -152,4 +152,3 @@
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_H_
-
diff --git a/modules/desktop_capture/desktop_capturer_differ_wrapper_unittest.cc b/modules/desktop_capture/desktop_capturer_differ_wrapper_unittest.cc
index 0a08088..4721a14 100644
--- a/modules/desktop_capture/desktop_capturer_differ_wrapper_unittest.cc
+++ b/modules/desktop_capture/desktop_capturer_differ_wrapper_unittest.cc
@@ -122,8 +122,8 @@
OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, testing::_))
.Times(1)
.WillOnce(testing::Invoke([&updated_region, check_result, exactly_match](
- DesktopCapturer::Result result,
- std::unique_ptr<DesktopFrame>* frame) {
+ DesktopCapturer::Result result,
+ std::unique_ptr<DesktopFrame>* frame) {
ASSERT_EQ(result, DesktopCapturer::Result::SUCCESS);
if (check_result) {
if (exactly_match) {
diff --git a/modules/desktop_capture/desktop_frame.cc b/modules/desktop_capture/desktop_frame.cc
index 67f2009..1d315e2 100644
--- a/modules/desktop_capture/desktop_frame.cc
+++ b/modules/desktop_capture/desktop_frame.cc
@@ -36,7 +36,8 @@
DesktopFrame::~DesktopFrame() = default;
-void DesktopFrame::CopyPixelsFrom(const uint8_t* src_buffer, int src_stride,
+void DesktopFrame::CopyPixelsFrom(const uint8_t* src_buffer,
+ int src_stride,
const DesktopRect& dest_rect) {
RTC_CHECK(DesktopRect::MakeSize(size()).ContainsRect(dest_rect));
@@ -51,11 +52,12 @@
void DesktopFrame::CopyPixelsFrom(const DesktopFrame& src_frame,
const DesktopVector& src_pos,
const DesktopRect& dest_rect) {
- RTC_CHECK(DesktopRect::MakeSize(src_frame.size()).ContainsRect(
- DesktopRect::MakeOriginSize(src_pos, dest_rect.size())));
+ RTC_CHECK(DesktopRect::MakeSize(src_frame.size())
+ .ContainsRect(
+ DesktopRect::MakeOriginSize(src_pos, dest_rect.size())));
- CopyPixelsFrom(src_frame.GetFrameDataAtPos(src_pos),
- src_frame.stride(), dest_rect);
+ CopyPixelsFrom(src_frame.GetFrameDataAtPos(src_pos), src_frame.stride(),
+ dest_rect);
}
DesktopRect DesktopFrame::rect() const {
@@ -94,7 +96,8 @@
}
BasicDesktopFrame::BasicDesktopFrame(DesktopSize size)
- : DesktopFrame(size, kBytesPerPixel * size.width(),
+ : DesktopFrame(size,
+ kBytesPerPixel * size.width(),
new uint8_t[kBytesPerPixel * size.width() * size.height()],
nullptr) {}
@@ -142,9 +145,7 @@
DesktopSize size,
int stride,
std::unique_ptr<SharedMemory> shared_memory)
- : SharedMemoryDesktopFrame(size,
- stride,
- shared_memory.release()) {}
+ : SharedMemoryDesktopFrame(size, stride, shared_memory.release()) {}
SharedMemoryDesktopFrame::~SharedMemoryDesktopFrame() {
delete shared_memory_;
diff --git a/modules/desktop_capture/desktop_frame.h b/modules/desktop_capture/desktop_frame.h
index 421d4b4..2a3b71e 100644
--- a/modules/desktop_capture/desktop_frame.h
+++ b/modules/desktop_capture/desktop_frame.h
@@ -90,9 +90,7 @@
// Not all DesktopCapturer implementations set this field; it's set to
// kUnknown by default.
uint32_t capturer_id() const { return capturer_id_; }
- void set_capturer_id(uint32_t capturer_id) {
- capturer_id_ = capturer_id;
- }
+ void set_capturer_id(uint32_t capturer_id) { capturer_id_ = capturer_id; }
// Copies various information from |other|. Anything initialized in
// constructor are not copied.
@@ -193,4 +191,3 @@
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_DESKTOP_FRAME_H_
-
diff --git a/modules/desktop_capture/desktop_frame_rotation.cc b/modules/desktop_capture/desktop_frame_rotation.cc
index 7cf0348..d7ea48c 100644
--- a/modules/desktop_capture/desktop_frame_rotation.cc
+++ b/modules/desktop_capture/desktop_frame_rotation.cc
@@ -12,8 +12,8 @@
#include <string.h>
-#include "third_party/libyuv/include/libyuv/rotate_argb.h"
#include "rtc_base/checks.h"
+#include "third_party/libyuv/include/libyuv/rotate_argb.h"
namespace webrtc {
@@ -109,10 +109,10 @@
}
int result = libyuv::ARGBRotate(
- source.GetFrameDataAtPos(source_rect.top_left()), source.stride(),
- target->GetFrameDataAtPos(target_rect.top_left()), target->stride(),
- source_rect.width(), source_rect.height(),
- ToLibyuvRotationMode(rotation));
+ source.GetFrameDataAtPos(source_rect.top_left()), source.stride(),
+ target->GetFrameDataAtPos(target_rect.top_left()), target->stride(),
+ source_rect.width(), source_rect.height(),
+ ToLibyuvRotationMode(rotation));
RTC_DCHECK_EQ(result, 0);
}
diff --git a/modules/desktop_capture/desktop_frame_rotation_unittest.cc b/modules/desktop_capture/desktop_frame_rotation_unittest.cc
index e31f472..acd6db1 100644
--- a/modules/desktop_capture/desktop_frame_rotation_unittest.cc
+++ b/modules/desktop_capture/desktop_frame_rotation_unittest.cc
@@ -39,8 +39,8 @@
TEST(DesktopFrameRotationTest, CopyRect3x4) {
// A DesktopFrame of 4-pixel width by 3-pixel height.
static uint32_t frame_pixels[] = {
- 0, 1, 2, 3, //
- 4, 5, 6, 7, //
+ 0, 1, 2, 3, //
+ 4, 5, 6, 7, //
8, 9, 10, 11, //
};
ArrayDesktopFrame frame(DesktopSize(4, 3), frame_pixels);
@@ -55,8 +55,8 @@
// After Rotating clock-wise 90 degree
{
static uint32_t expected_pixels[] = {
- 8, 4, 0, //
- 9, 5, 1, //
+ 8, 4, 0, //
+ 9, 5, 1, //
10, 6, 2, //
11, 7, 3, //
};
@@ -72,8 +72,8 @@
{
static uint32_t expected_pixels[] = {
11, 10, 9, 8, //
- 7, 6, 5, 4, //
- 3, 2, 1, 0, //
+ 7, 6, 5, 4, //
+ 3, 2, 1, 0, //
};
ArrayDesktopFrame expected(DesktopSize(4, 3), expected_pixels);
@@ -88,8 +88,8 @@
static uint32_t expected_pixels[] = {
3, 7, 11, //
2, 6, 10, //
- 1, 5, 9, //
- 0, 4, 8, //
+ 1, 5, 9, //
+ 0, 4, 8, //
};
ArrayDesktopFrame expected(DesktopSize(3, 4), expected_pixels);
@@ -103,8 +103,8 @@
TEST(DesktopFrameRotationTest, CopyRect3x5) {
// A DesktopFrame of 5-pixel width by 3-pixel height.
static uint32_t frame_pixels[] = {
- 0, 1, 2, 3, 4, //
- 5, 6, 7, 8, 9, //
+ 0, 1, 2, 3, 4, //
+ 5, 6, 7, 8, 9, //
10, 11, 12, 13, 14, //
};
ArrayDesktopFrame frame(DesktopSize(5, 3), frame_pixels);
@@ -135,10 +135,10 @@
// After Rotating clock-wise 180 degree
{
- static uint32_t expected_pixels[] {
+ static uint32_t expected_pixels[]{
14, 13, 12, 11, 10, //
- 9, 8, 7, 6, 5, //
- 4, 3, 2, 1, 0, //
+ 9, 8, 7, 6, 5, //
+ 4, 3, 2, 1, 0, //
};
ArrayDesktopFrame expected(DesktopSize(5, 3), expected_pixels);
@@ -169,8 +169,8 @@
TEST(DesktopFrameRotationTest, PartialCopyRect3x5) {
// A DesktopFrame of 5-pixel width by 3-pixel height.
static uint32_t frame_pixels[] = {
- 0, 1, 2, 3, 4, //
- 5, 6, 7, 8, 9, //
+ 0, 1, 2, 3, 4, //
+ 5, 6, 7, 8, 9, //
10, 11, 12, 13, 14, //
};
ArrayDesktopFrame frame(DesktopSize(5, 3), frame_pixels);
@@ -225,11 +225,11 @@
{
static uint32_t expected_pixels[] = {
- 0, 0, 0, //
+ 0, 0, 0, //
11, 6, 0, //
12, 7, 0, //
13, 8, 0, //
- 0, 0, 0, //
+ 0, 0, 0, //
};
ArrayDesktopFrame expected(DesktopSize(3, 5), expected_pixels);
@@ -259,8 +259,8 @@
{
static uint32_t expected_pixels[] = {
0, 13, 12, 11, 0, //
- 0, 8, 7, 6, 0, //
- 0, 0, 0, 0, 0, //
+ 0, 8, 7, 6, 0, //
+ 0, 0, 0, 0, 0, //
};
ArrayDesktopFrame expected(DesktopSize(5, 3), expected_pixels);
@@ -310,20 +310,20 @@
TEST(DesktopFrameRotationTest, WithOffset) {
// A DesktopFrame of 4-pixel width by 3-pixel height.
static uint32_t frame_pixels[] = {
- 0, 1, 2, 3, //
- 4, 5, 6, 7, //
+ 0, 1, 2, 3, //
+ 4, 5, 6, 7, //
8, 9, 10, 11, //
};
ArrayDesktopFrame frame(DesktopSize(4, 3), frame_pixels);
{
static uint32_t expected_pixels[] = {
- 0, 0, 0, 0, 0, 0, 0, 0, //
- 0, 0, 1, 2, 3, 0, 0, 0, //
- 0, 4, 5, 6, 7, 0, 0, 0, //
- 0, 8, 9, 10, 11, 0, 0, 0, //
- 0, 0, 0, 0, 0, 0, 0, 0, //
- 0, 0, 0, 0, 0, 0, 0, 0, //
+ 0, 0, 0, 0, 0, 0, 0, 0, //
+ 0, 0, 1, 2, 3, 0, 0, 0, //
+ 0, 4, 5, 6, 7, 0, 0, 0, //
+ 0, 8, 9, 10, 11, 0, 0, 0, //
+ 0, 0, 0, 0, 0, 0, 0, 0, //
+ 0, 0, 0, 0, 0, 0, 0, 0, //
};
ArrayDesktopFrame expected(DesktopSize(8, 6), expected_pixels);
@@ -339,12 +339,12 @@
{
static uint32_t expected_pixels[] = {
- 0, 0, 0, 0, 0, 0, 0, 0, //
- 0, 11, 10, 9, 8, 0, 0, 0, //
- 0, 7, 6, 5, 4, 0, 0, 0, //
- 0, 3, 2, 1, 0, 0, 0, 0, //
- 0, 0, 0, 0, 0, 0, 0, 0, //
- 0, 0, 0, 0, 0, 0, 0, 0, //
+ 0, 0, 0, 0, 0, 0, 0, 0, //
+ 0, 11, 10, 9, 8, 0, 0, 0, //
+ 0, 7, 6, 5, 4, 0, 0, 0, //
+ 0, 3, 2, 1, 0, 0, 0, 0, //
+ 0, 0, 0, 0, 0, 0, 0, 0, //
+ 0, 0, 0, 0, 0, 0, 0, 0, //
};
ArrayDesktopFrame expected(DesktopSize(8, 6), expected_pixels);
@@ -360,14 +360,14 @@
{
static uint32_t expected_pixels[] = {
- 0, 0, 0, 0, 0, 0, //
- 0, 8, 4, 0, 0, 0, //
- 0, 9, 5, 1, 0, 0, //
- 0, 10, 6, 2, 0, 0, //
- 0, 11, 7, 3, 0, 0, //
- 0, 0, 0, 0, 0, 0, //
- 0, 0, 0, 0, 0, 0, //
- 0, 0, 0, 0, 0, 0, //
+ 0, 0, 0, 0, 0, 0, //
+ 0, 8, 4, 0, 0, 0, //
+ 0, 9, 5, 1, 0, 0, //
+ 0, 10, 6, 2, 0, 0, //
+ 0, 11, 7, 3, 0, 0, //
+ 0, 0, 0, 0, 0, 0, //
+ 0, 0, 0, 0, 0, 0, //
+ 0, 0, 0, 0, 0, 0, //
};
ArrayDesktopFrame expected(DesktopSize(6, 8), expected_pixels);
@@ -383,14 +383,14 @@
{
static uint32_t expected_pixels[] = {
- 0, 0, 0, 0, 0, 0, //
- 0, 3, 7, 11, 0, 0, //
- 0, 2, 6, 10, 0, 0, //
- 0, 1, 5, 9, 0, 0, //
- 0, 0, 4, 8, 0, 0, //
- 0, 0, 0, 0, 0, 0, //
- 0, 0, 0, 0, 0, 0, //
- 0, 0, 0, 0, 0, 0, //
+ 0, 0, 0, 0, 0, 0, //
+ 0, 3, 7, 11, 0, 0, //
+ 0, 2, 6, 10, 0, 0, //
+ 0, 1, 5, 9, 0, 0, //
+ 0, 0, 4, 8, 0, 0, //
+ 0, 0, 0, 0, 0, 0, //
+ 0, 0, 0, 0, 0, 0, //
+ 0, 0, 0, 0, 0, 0, //
};
ArrayDesktopFrame expected(DesktopSize(6, 8), expected_pixels);
diff --git a/modules/desktop_capture/desktop_frame_win.cc b/modules/desktop_capture/desktop_frame_win.cc
index fbc1200..58ebac9 100644
--- a/modules/desktop_capture/desktop_frame_win.cc
+++ b/modules/desktop_capture/desktop_frame_win.cc
@@ -53,8 +53,8 @@
section_handle = shared_memory->handle();
}
void* data = nullptr;
- HBITMAP bitmap = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, &data,
- section_handle, 0);
+ HBITMAP bitmap =
+ CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, &data, section_handle, 0);
if (!bitmap) {
RTC_LOG(LS_WARNING) << "Failed to allocate new window frame "
<< GetLastError();
diff --git a/modules/desktop_capture/desktop_frame_win.h b/modules/desktop_capture/desktop_frame_win.h
index 9ae1dc4..5cad867 100644
--- a/modules/desktop_capture/desktop_frame_win.h
+++ b/modules/desktop_capture/desktop_frame_win.h
@@ -48,4 +48,3 @@
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_DESKTOP_FRAME_WIN_H_
-
diff --git a/modules/desktop_capture/desktop_geometry.cc b/modules/desktop_capture/desktop_geometry.cc
index 8c1b23a..8220e5f 100644
--- a/modules/desktop_capture/desktop_geometry.cc
+++ b/modules/desktop_capture/desktop_geometry.cc
@@ -15,8 +15,8 @@
namespace webrtc {
bool DesktopRect::Contains(const DesktopVector& point) const {
- return point.x() >= left() && point.x() < right() &&
- point.y() >= top() && point.y() < bottom();
+ return point.x() >= left() && point.x() < right() && point.y() >= top() &&
+ point.y() < bottom();
}
bool DesktopRect::ContainsRect(const DesktopRect& rect) const {
@@ -76,4 +76,3 @@
}
} // namespace webrtc
-
diff --git a/modules/desktop_capture/desktop_geometry.h b/modules/desktop_capture/desktop_geometry.h
index c1ee1a5..e01b435 100644
--- a/modules/desktop_capture/desktop_geometry.h
+++ b/modules/desktop_capture/desktop_geometry.h
@@ -51,9 +51,7 @@
class DesktopSize {
public:
DesktopSize() : width_(0), height_(0) {}
- DesktopSize(int32_t width, int32_t height)
- : width_(width), height_(height) {
- }
+ DesktopSize(int32_t width, int32_t height) : width_(width), height_(height) {}
int32_t width() const { return width_; }
int32_t height() const { return height_; }
@@ -83,12 +81,16 @@
static DesktopRect MakeWH(int32_t width, int32_t height) {
return DesktopRect(0, 0, width, height);
}
- static DesktopRect MakeXYWH(int32_t x, int32_t y,
- int32_t width, int32_t height) {
+ static DesktopRect MakeXYWH(int32_t x,
+ int32_t y,
+ int32_t width,
+ int32_t height) {
return DesktopRect(x, y, x + width, y + height);
}
- static DesktopRect MakeLTRB(int32_t left, int32_t top,
- int32_t right, int32_t bottom) {
+ static DesktopRect MakeLTRB(int32_t left,
+ int32_t top,
+ int32_t right,
+ int32_t bottom) {
return DesktopRect(left, top, right, bottom);
}
static DesktopRect MakeOriginSize(const DesktopVector& origin,
@@ -115,7 +117,7 @@
bool equals(const DesktopRect& other) const {
return left_ == other.left_ && top_ == other.top_ &&
- right_ == other.right_ && bottom_ == other.bottom_;
+ right_ == other.right_ && bottom_ == other.bottom_;
}
// Returns true if |point| lies within the rectangle boundaries.
@@ -151,8 +153,7 @@
private:
DesktopRect(int32_t left, int32_t top, int32_t right, int32_t bottom)
- : left_(left), top_(top), right_(right), bottom_(bottom) {
- }
+ : left_(left), top_(top), right_(right), bottom_(bottom) {}
int32_t left_;
int32_t top_;
@@ -163,4 +164,3 @@
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_DESKTOP_GEOMETRY_H_
-
diff --git a/modules/desktop_capture/desktop_region.cc b/modules/desktop_capture/desktop_region.cc
index fb310d4..472f815 100644
--- a/modules/desktop_capture/desktop_region.cc
+++ b/modules/desktop_capture/desktop_region.cc
@@ -17,15 +17,13 @@
namespace webrtc {
DesktopRegion::RowSpan::RowSpan(int32_t left, int32_t right)
- : left(left), right(right) {
-}
+ : left(left), right(right) {}
DesktopRegion::Row::Row(const Row&) = default;
DesktopRegion::Row::Row(Row&&) = default;
DesktopRegion::Row::Row(int32_t top, int32_t bottom)
- : top(top), bottom(bottom) {
-}
+ : top(top), bottom(bottom) {}
DesktopRegion::Row::~Row() {}
@@ -63,8 +61,7 @@
Rows::const_iterator it1 = rows_.begin();
Rows::const_iterator it2 = region.rows_.begin();
while (it1 != rows_.end()) {
- if (it2 == region.rows_.end() ||
- it1->first != it2->first ||
+ if (it2 == region.rows_.end() || it1->first != it2->first ||
it1->second->top != it2->second->top ||
it1->second->bottom != it2->second->bottom ||
it1->second->spans != it2->second->spans) {
@@ -100,14 +97,13 @@
// necessary.
Rows::iterator row = rows_.upper_bound(top);
while (top < rect.bottom()) {
- if (row == rows_.end() || top < row->second->top) {
+ if (row == rows_.end() || top < row->second->top) {
// If |top| is above the top of the current |row| then add a new row above
// the current one.
int32_t bottom = rect.bottom();
if (row != rows_.end() && row->second->top < bottom)
bottom = row->second->top;
- row = rows_.insert(
- row, Rows::value_type(bottom, new Row(top, bottom)));
+ row = rows_.insert(row, Rows::value_type(bottom, new Row(top, bottom)));
} else if (top > row->second->top) {
// If the |top| falls in the middle of the |row| then split |row| into
// two, at |top|, and leave |row| referring to the lower of the two,
@@ -421,9 +417,8 @@
}
// Find the first span that ends at or after |left|.
- RowSpanSet::iterator start =
- std::lower_bound(row->spans.begin(), row->spans.end(), left,
- CompareSpanRight);
+ RowSpanSet::iterator start = std::lower_bound(
+ row->spans.begin(), row->spans.end(), left, CompareSpanRight);
assert(start < row->spans.end());
// Find the first span that starts after |right|.
@@ -462,9 +457,8 @@
bool DesktopRegion::IsSpanInRow(const Row& row, const RowSpan& span) {
// Find the first span that starts at or after |span.left| and then check if
// it's the same span.
- RowSpanSet::const_iterator it =
- std::lower_bound(row.spans.begin(), row.spans.end(), span.left,
- CompareSpanLeft);
+ RowSpanSet::const_iterator it = std::lower_bound(
+ row.spans.begin(), row.spans.end(), span.left, CompareSpanLeft);
return it != row.spans.end() && *it == span;
}
diff --git a/modules/desktop_capture/desktop_region.h b/modules/desktop_capture/desktop_region.h
index 93f78a4..305f877 100644
--- a/modules/desktop_capture/desktop_region.h
+++ b/modules/desktop_capture/desktop_region.h
@@ -166,4 +166,3 @@
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_DESKTOP_REGION_H_
-
diff --git a/modules/desktop_capture/desktop_region_unittest.cc b/modules/desktop_capture/desktop_region_unittest.cc
index 0e94c9d..65fc42f 100644
--- a/modules/desktop_capture/desktop_region_unittest.cc
+++ b/modules/desktop_capture/desktop_region_unittest.cc
@@ -23,7 +23,8 @@
}
void CompareRegion(const DesktopRegion& region,
- const DesktopRect rects[], int rects_size) {
+ const DesktopRect rects[],
+ int rects_size) {
DesktopRegion::Iterator it(region);
for (int i = 0; i < rects_size; ++i) {
SCOPED_TRACE(i);
@@ -31,8 +32,8 @@
EXPECT_TRUE(it.rect().equals(rects[i]))
<< it.rect().left() << "-" << it.rect().right() << "."
<< it.rect().top() << "-" << it.rect().bottom() << " "
- << rects[i].left() << "-" << rects[i].right() << "."
- << rects[i].top() << "-" << rects[i].bottom();
+ << rects[i].left() << "-" << rects[i].right() << "." << rects[i].top()
+ << "-" << rects[i].bottom();
it.Advance();
}
EXPECT_TRUE(it.IsAtEnd());
@@ -68,22 +69,27 @@
int count;
DesktopRect rects[4];
} cases[] = {
- { 1, { DesktopRect::MakeXYWH(10, 10, 10, 10) } },
- { 2, { DesktopRect::MakeXYWH(10, 10, 10, 10),
- DesktopRect::MakeXYWH(30, 10, 10, 15) } },
- { 2, { DesktopRect::MakeXYWH(10, 10, 10, 10),
- DesktopRect::MakeXYWH(10, 30, 10, 5) } },
- { 3, { DesktopRect::MakeXYWH(10, 10, 10, 9),
- DesktopRect::MakeXYWH(30, 10, 15, 10),
- DesktopRect::MakeXYWH(10, 30, 8, 10) } },
- { 4, { DesktopRect::MakeXYWH(0, 0, 30, 10),
- DesktopRect::MakeXYWH(40, 0, 10, 30),
- DesktopRect::MakeXYWH(0, 20, 10, 30),
- DesktopRect::MakeXYWH(20, 40, 30, 10) } },
- { 4, { DesktopRect::MakeXYWH(0, 0, 10, 100),
- DesktopRect::MakeXYWH(20, 10, 30, 10),
- DesktopRect::MakeXYWH(20, 30, 30, 10),
- DesktopRect::MakeXYWH(20, 50, 30, 10) } },
+ {1, {DesktopRect::MakeXYWH(10, 10, 10, 10)}},
+ {2,
+ {DesktopRect::MakeXYWH(10, 10, 10, 10),
+ DesktopRect::MakeXYWH(30, 10, 10, 15)}},
+ {2,
+ {DesktopRect::MakeXYWH(10, 10, 10, 10),
+ DesktopRect::MakeXYWH(10, 30, 10, 5)}},
+ {3,
+ {DesktopRect::MakeXYWH(10, 10, 10, 9),
+ DesktopRect::MakeXYWH(30, 10, 15, 10),
+ DesktopRect::MakeXYWH(10, 30, 8, 10)}},
+ {4,
+ {DesktopRect::MakeXYWH(0, 0, 30, 10),
+ DesktopRect::MakeXYWH(40, 0, 10, 30),
+ DesktopRect::MakeXYWH(0, 20, 10, 30),
+ DesktopRect::MakeXYWH(20, 40, 30, 10)}},
+ {4,
+ {DesktopRect::MakeXYWH(0, 0, 10, 100),
+ DesktopRect::MakeXYWH(20, 10, 30, 10),
+ DesktopRect::MakeXYWH(20, 30, 30, 10),
+ DesktopRect::MakeXYWH(20, 50, 30, 10)}},
};
for (size_t i = 0; i < (sizeof(cases) / sizeof(Case)); ++i) {
@@ -114,81 +120,97 @@
int expected_count;
DesktopRect expected_rects[3];
} cases[] = {
- // Touching rectangles that merge into one.
- { DesktopRect::MakeLTRB(100, 100, 200, 200),
- DesktopRect::MakeLTRB(0, 100, 100, 200),
- 1, { DesktopRect::MakeLTRB(0, 100, 200, 200) } },
- { DesktopRect::MakeLTRB(100, 100, 200, 200),
- DesktopRect::MakeLTRB(100, 0, 200, 100),
- 1, { DesktopRect::MakeLTRB(100, 0, 200, 200) } },
+ // Touching rectangles that merge into one.
+ {DesktopRect::MakeLTRB(100, 100, 200, 200),
+ DesktopRect::MakeLTRB(0, 100, 100, 200),
+ 1,
+ {DesktopRect::MakeLTRB(0, 100, 200, 200)}},
+ {DesktopRect::MakeLTRB(100, 100, 200, 200),
+ DesktopRect::MakeLTRB(100, 0, 200, 100),
+ 1,
+ {DesktopRect::MakeLTRB(100, 0, 200, 200)}},
- // Rectangles touching on the vertical edge.
- { DesktopRect::MakeLTRB(100, 100, 200, 200),
- DesktopRect::MakeLTRB(0, 150, 100, 250),
- 3, { DesktopRect::MakeLTRB(100, 100, 200, 150),
- DesktopRect::MakeLTRB(0, 150, 200, 200),
- DesktopRect::MakeLTRB(0, 200, 100, 250) } },
- { DesktopRect::MakeLTRB(100, 100, 200, 200),
- DesktopRect::MakeLTRB(0, 50, 100, 150),
- 3, { DesktopRect::MakeLTRB(0, 50, 100, 100),
- DesktopRect::MakeLTRB(0, 100, 200, 150),
- DesktopRect::MakeLTRB(100, 150, 200, 200) } },
- { DesktopRect::MakeLTRB(100, 100, 200, 200),
- DesktopRect::MakeLTRB(0, 120, 100, 180),
- 3, { DesktopRect::MakeLTRB(100, 100, 200, 120),
- DesktopRect::MakeLTRB(0, 120, 200, 180),
- DesktopRect::MakeLTRB(100, 180, 200, 200) } },
+ // Rectangles touching on the vertical edge.
+ {DesktopRect::MakeLTRB(100, 100, 200, 200),
+ DesktopRect::MakeLTRB(0, 150, 100, 250),
+ 3,
+ {DesktopRect::MakeLTRB(100, 100, 200, 150),
+ DesktopRect::MakeLTRB(0, 150, 200, 200),
+ DesktopRect::MakeLTRB(0, 200, 100, 250)}},
+ {DesktopRect::MakeLTRB(100, 100, 200, 200),
+ DesktopRect::MakeLTRB(0, 50, 100, 150),
+ 3,
+ {DesktopRect::MakeLTRB(0, 50, 100, 100),
+ DesktopRect::MakeLTRB(0, 100, 200, 150),
+ DesktopRect::MakeLTRB(100, 150, 200, 200)}},
+ {DesktopRect::MakeLTRB(100, 100, 200, 200),
+ DesktopRect::MakeLTRB(0, 120, 100, 180),
+ 3,
+ {DesktopRect::MakeLTRB(100, 100, 200, 120),
+ DesktopRect::MakeLTRB(0, 120, 200, 180),
+ DesktopRect::MakeLTRB(100, 180, 200, 200)}},
- // Rectangles touching on the horizontal edge.
- { DesktopRect::MakeLTRB(100, 100, 200, 200),
- DesktopRect::MakeLTRB(150, 0, 250, 100),
- 2, { DesktopRect::MakeLTRB(150, 0, 250, 100),
- DesktopRect::MakeLTRB(100, 100, 200, 200) } },
- { DesktopRect::MakeLTRB(100, 100, 200, 200),
- DesktopRect::MakeLTRB(50, 0, 150, 100),
- 2, { DesktopRect::MakeLTRB(50, 0, 150, 100),
- DesktopRect::MakeLTRB(100, 100, 200, 200) } },
- { DesktopRect::MakeLTRB(100, 100, 200, 200),
- DesktopRect::MakeLTRB(120, 0, 180, 100),
- 2, { DesktopRect::MakeLTRB(120, 0, 180, 100),
- DesktopRect::MakeLTRB(100, 100, 200, 200) } },
+ // Rectangles touching on the horizontal edge.
+ {DesktopRect::MakeLTRB(100, 100, 200, 200),
+ DesktopRect::MakeLTRB(150, 0, 250, 100),
+ 2,
+ {DesktopRect::MakeLTRB(150, 0, 250, 100),
+ DesktopRect::MakeLTRB(100, 100, 200, 200)}},
+ {DesktopRect::MakeLTRB(100, 100, 200, 200),
+ DesktopRect::MakeLTRB(50, 0, 150, 100),
+ 2,
+ {DesktopRect::MakeLTRB(50, 0, 150, 100),
+ DesktopRect::MakeLTRB(100, 100, 200, 200)}},
+ {DesktopRect::MakeLTRB(100, 100, 200, 200),
+ DesktopRect::MakeLTRB(120, 0, 180, 100),
+ 2,
+ {DesktopRect::MakeLTRB(120, 0, 180, 100),
+ DesktopRect::MakeLTRB(100, 100, 200, 200)}},
- // Overlapping rectangles.
- { DesktopRect::MakeLTRB(100, 100, 200, 200),
- DesktopRect::MakeLTRB(50, 50, 150, 150),
- 3, { DesktopRect::MakeLTRB(50, 50, 150, 100),
- DesktopRect::MakeLTRB(50, 100, 200, 150),
- DesktopRect::MakeLTRB(100, 150, 200, 200) } },
- { DesktopRect::MakeLTRB(100, 100, 200, 200),
- DesktopRect::MakeLTRB(150, 50, 250, 150),
- 3, { DesktopRect::MakeLTRB(150, 50, 250, 100),
- DesktopRect::MakeLTRB(100, 100, 250, 150),
- DesktopRect::MakeLTRB(100, 150, 200, 200) } },
- { DesktopRect::MakeLTRB(100, 100, 200, 200),
- DesktopRect::MakeLTRB(0, 120, 150, 180),
- 3, { DesktopRect::MakeLTRB(100, 100, 200, 120),
- DesktopRect::MakeLTRB(0, 120, 200, 180),
- DesktopRect::MakeLTRB(100, 180, 200, 200) } },
- { DesktopRect::MakeLTRB(100, 100, 200, 200),
- DesktopRect::MakeLTRB(120, 0, 180, 150),
- 2, { DesktopRect::MakeLTRB(120, 0, 180, 100),
- DesktopRect::MakeLTRB(100, 100, 200, 200) } },
- { DesktopRect::MakeLTRB(100, 0, 200, 300),
- DesktopRect::MakeLTRB(0, 100, 300, 200),
- 3, { DesktopRect::MakeLTRB(100, 0, 200, 100),
- DesktopRect::MakeLTRB(0, 100, 300, 200),
- DesktopRect::MakeLTRB(100, 200, 200, 300)} },
+ // Overlapping rectangles.
+ {DesktopRect::MakeLTRB(100, 100, 200, 200),
+ DesktopRect::MakeLTRB(50, 50, 150, 150),
+ 3,
+ {DesktopRect::MakeLTRB(50, 50, 150, 100),
+ DesktopRect::MakeLTRB(50, 100, 200, 150),
+ DesktopRect::MakeLTRB(100, 150, 200, 200)}},
+ {DesktopRect::MakeLTRB(100, 100, 200, 200),
+ DesktopRect::MakeLTRB(150, 50, 250, 150),
+ 3,
+ {DesktopRect::MakeLTRB(150, 50, 250, 100),
+ DesktopRect::MakeLTRB(100, 100, 250, 150),
+ DesktopRect::MakeLTRB(100, 150, 200, 200)}},
+ {DesktopRect::MakeLTRB(100, 100, 200, 200),
+ DesktopRect::MakeLTRB(0, 120, 150, 180),
+ 3,
+ {DesktopRect::MakeLTRB(100, 100, 200, 120),
+ DesktopRect::MakeLTRB(0, 120, 200, 180),
+ DesktopRect::MakeLTRB(100, 180, 200, 200)}},
+ {DesktopRect::MakeLTRB(100, 100, 200, 200),
+ DesktopRect::MakeLTRB(120, 0, 180, 150),
+ 2,
+ {DesktopRect::MakeLTRB(120, 0, 180, 100),
+ DesktopRect::MakeLTRB(100, 100, 200, 200)}},
+ {DesktopRect::MakeLTRB(100, 0, 200, 300),
+ DesktopRect::MakeLTRB(0, 100, 300, 200),
+ 3,
+ {DesktopRect::MakeLTRB(100, 0, 200, 100),
+ DesktopRect::MakeLTRB(0, 100, 300, 200),
+ DesktopRect::MakeLTRB(100, 200, 200, 300)}},
- // One rectangle enclosing another.
- { DesktopRect::MakeLTRB(100, 100, 200, 200),
- DesktopRect::MakeLTRB(150, 150, 180, 180),
- 1, { DesktopRect::MakeLTRB(100, 100, 200, 200) } },
- { DesktopRect::MakeLTRB(100, 100, 200, 200),
- DesktopRect::MakeLTRB(100, 100, 180, 180),
- 1, { DesktopRect::MakeLTRB(100, 100, 200, 200) } },
- { DesktopRect::MakeLTRB(100, 100, 200, 200),
- DesktopRect::MakeLTRB(150, 150, 200, 200),
- 1, { DesktopRect::MakeLTRB(100, 100, 200, 200) } },
+ // One rectangle enclosing another.
+ {DesktopRect::MakeLTRB(100, 100, 200, 200),
+ DesktopRect::MakeLTRB(150, 150, 180, 180),
+ 1,
+ {DesktopRect::MakeLTRB(100, 100, 200, 200)}},
+ {DesktopRect::MakeLTRB(100, 100, 200, 200),
+ DesktopRect::MakeLTRB(100, 100, 180, 180),
+ 1,
+ {DesktopRect::MakeLTRB(100, 100, 200, 200)}},
+ {DesktopRect::MakeLTRB(100, 100, 200, 200),
+ DesktopRect::MakeLTRB(150, 150, 200, 200),
+ 1,
+ {DesktopRect::MakeLTRB(100, 100, 200, 200)}},
};
for (size_t i = 0; i < (sizeof(cases) / sizeof(Case)); ++i) {
@@ -219,7 +241,9 @@
const int kLastRectSizes[] = {3, 27};
DesktopRegion base_region;
- bool base_map[kMapWidth] = { false, };
+ bool base_map[kMapWidth] = {
+ false,
+ };
base_region.AddRect(DesktopRect::MakeXYWH(5, 0, 5, 1));
std::fill_n(base_map + 5, 5, true);
@@ -239,13 +263,15 @@
SCOPED_TRACE(x);
DesktopRegion r = base_region;
- r.AddRect(DesktopRect::MakeXYWH(x, 0, last_rect_size, 1));
+ r.AddRect(DesktopRect::MakeXYWH(x, 0, last_rect_size, 1));
bool expected_map[kMapWidth];
std::copy(base_map, base_map + kMapWidth, expected_map);
std::fill_n(expected_map + x, last_rect_size, true);
- bool map[kMapWidth] = { false, };
+ bool map[kMapWidth] = {
+ false,
+ };
int pos = -1;
for (DesktopRegion::Iterator it(r); !it.IsAtEnd(); it.Advance()) {
@@ -266,32 +292,42 @@
int expected_count;
DesktopRect expected_rects[6];
} cases[] = {
- { 3, { DesktopRect::MakeLTRB(100, 100, 200, 200),
+ {3,
+ {
+ DesktopRect::MakeLTRB(100, 100, 200, 200),
DesktopRect::MakeLTRB(0, 100, 100, 200),
- DesktopRect::MakeLTRB(310, 110, 320, 120), },
- 2, { DesktopRect::MakeLTRB(0, 100, 200, 200),
- DesktopRect::MakeLTRB(310, 110, 320, 120) } },
- { 3, { DesktopRect::MakeLTRB(100, 100, 200, 200),
- DesktopRect::MakeLTRB(50, 50, 150, 150),
- DesktopRect::MakeLTRB(300, 125, 350, 175) },
- 4, { DesktopRect::MakeLTRB(50, 50, 150, 100),
- DesktopRect::MakeLTRB(50, 100, 200, 150),
- DesktopRect::MakeLTRB(300, 125, 350, 175),
- DesktopRect::MakeLTRB(100, 150, 200, 200) } },
- { 4, { DesktopRect::MakeLTRB(0, 0, 30, 30),
- DesktopRect::MakeLTRB(10, 10, 40, 40),
- DesktopRect::MakeLTRB(20, 20, 50, 50),
- DesktopRect::MakeLTRB(50, 0, 65, 15) },
- 6, { DesktopRect::MakeLTRB(0, 0, 30, 10),
- DesktopRect::MakeLTRB(50, 0, 65, 15),
- DesktopRect::MakeLTRB(0, 10, 40, 20),
- DesktopRect::MakeLTRB(0, 20, 50, 30),
- DesktopRect::MakeLTRB(10, 30, 50, 40),
- DesktopRect::MakeLTRB(20, 40, 50, 50) } },
- { 3, { DesktopRect::MakeLTRB(10, 10, 40, 20),
- DesktopRect::MakeLTRB(10, 30, 40, 40),
- DesktopRect::MakeLTRB(10, 20, 40, 30) },
- 1, { DesktopRect::MakeLTRB(10, 10, 40, 40) } },
+ DesktopRect::MakeLTRB(310, 110, 320, 120),
+ },
+ 2,
+ {DesktopRect::MakeLTRB(0, 100, 200, 200),
+ DesktopRect::MakeLTRB(310, 110, 320, 120)}},
+ {3,
+ {DesktopRect::MakeLTRB(100, 100, 200, 200),
+ DesktopRect::MakeLTRB(50, 50, 150, 150),
+ DesktopRect::MakeLTRB(300, 125, 350, 175)},
+ 4,
+ {DesktopRect::MakeLTRB(50, 50, 150, 100),
+ DesktopRect::MakeLTRB(50, 100, 200, 150),
+ DesktopRect::MakeLTRB(300, 125, 350, 175),
+ DesktopRect::MakeLTRB(100, 150, 200, 200)}},
+ {4,
+ {DesktopRect::MakeLTRB(0, 0, 30, 30),
+ DesktopRect::MakeLTRB(10, 10, 40, 40),
+ DesktopRect::MakeLTRB(20, 20, 50, 50),
+ DesktopRect::MakeLTRB(50, 0, 65, 15)},
+ 6,
+ {DesktopRect::MakeLTRB(0, 0, 30, 10),
+ DesktopRect::MakeLTRB(50, 0, 65, 15),
+ DesktopRect::MakeLTRB(0, 10, 40, 20),
+ DesktopRect::MakeLTRB(0, 20, 50, 30),
+ DesktopRect::MakeLTRB(10, 30, 50, 40),
+ DesktopRect::MakeLTRB(20, 40, 50, 50)}},
+ {3,
+ {DesktopRect::MakeLTRB(10, 10, 40, 20),
+ DesktopRect::MakeLTRB(10, 30, 40, 40),
+ DesktopRect::MakeLTRB(10, 20, 40, 30)},
+ 1,
+ {DesktopRect::MakeLTRB(10, 10, 40, 40)}},
};
for (size_t i = 0; i < (sizeof(cases) / sizeof(Case)); ++i) {
@@ -316,44 +352,62 @@
DesktopRect rects[4];
int id;
} regions[] = {
- // Same region with one of the rectangles 1 pixel wider/taller.
- { 2, { DesktopRect::MakeLTRB(0, 100, 200, 200),
- DesktopRect::MakeLTRB(310, 110, 320, 120) }, 0 },
- { 2, { DesktopRect::MakeLTRB(0, 100, 201, 200),
- DesktopRect::MakeLTRB(310, 110, 320, 120) }, 1 },
- { 2, { DesktopRect::MakeLTRB(0, 100, 200, 201),
- DesktopRect::MakeLTRB(310, 110, 320, 120) }, 2 },
+ // Same region with one of the rectangles 1 pixel wider/taller.
+ {2,
+ {DesktopRect::MakeLTRB(0, 100, 200, 200),
+ DesktopRect::MakeLTRB(310, 110, 320, 120)},
+ 0},
+ {2,
+ {DesktopRect::MakeLTRB(0, 100, 201, 200),
+ DesktopRect::MakeLTRB(310, 110, 320, 120)},
+ 1},
+ {2,
+ {DesktopRect::MakeLTRB(0, 100, 200, 201),
+ DesktopRect::MakeLTRB(310, 110, 320, 120)},
+ 2},
- // Same region with one of the rectangles shifted horizontally and
- // vertically.
- { 4, { DesktopRect::MakeLTRB(0, 0, 30, 30),
- DesktopRect::MakeLTRB(10, 10, 40, 40),
- DesktopRect::MakeLTRB(20, 20, 50, 50),
- DesktopRect::MakeLTRB(50, 0, 65, 15) }, 3 },
- { 4, { DesktopRect::MakeLTRB(0, 0, 30, 30),
- DesktopRect::MakeLTRB(10, 10, 40, 40),
- DesktopRect::MakeLTRB(20, 20, 50, 50),
- DesktopRect::MakeLTRB(50, 1, 65, 16) }, 4 },
- { 4, { DesktopRect::MakeLTRB(0, 0, 30, 30),
- DesktopRect::MakeLTRB(10, 10, 40, 40),
- DesktopRect::MakeLTRB(20, 20, 50, 50),
- DesktopRect::MakeLTRB(51, 0, 66, 15) }, 5 },
+ // Same region with one of the rectangles shifted horizontally and
+ // vertically.
+ {4,
+ {DesktopRect::MakeLTRB(0, 0, 30, 30),
+ DesktopRect::MakeLTRB(10, 10, 40, 40),
+ DesktopRect::MakeLTRB(20, 20, 50, 50),
+ DesktopRect::MakeLTRB(50, 0, 65, 15)},
+ 3},
+ {4,
+ {DesktopRect::MakeLTRB(0, 0, 30, 30),
+ DesktopRect::MakeLTRB(10, 10, 40, 40),
+ DesktopRect::MakeLTRB(20, 20, 50, 50),
+ DesktopRect::MakeLTRB(50, 1, 65, 16)},
+ 4},
+ {4,
+ {DesktopRect::MakeLTRB(0, 0, 30, 30),
+ DesktopRect::MakeLTRB(10, 10, 40, 40),
+ DesktopRect::MakeLTRB(20, 20, 50, 50),
+ DesktopRect::MakeLTRB(51, 0, 66, 15)},
+ 5},
- // Same region defined by a different set of rectangles - one of the
- // rectangle is split horizontally into two.
- { 3, { DesktopRect::MakeLTRB(100, 100, 200, 200),
- DesktopRect::MakeLTRB(50, 50, 150, 150),
- DesktopRect::MakeLTRB(300, 125, 350, 175) }, 6 },
- { 4, { DesktopRect::MakeLTRB(100, 100, 200, 200),
- DesktopRect::MakeLTRB(50, 50, 100, 150),
- DesktopRect::MakeLTRB(100, 50, 150, 150),
- DesktopRect::MakeLTRB(300, 125, 350, 175) }, 6 },
+ // Same region defined by a different set of rectangles - one of the
+ // rectangle is split horizontally into two.
+ {3,
+ {DesktopRect::MakeLTRB(100, 100, 200, 200),
+ DesktopRect::MakeLTRB(50, 50, 150, 150),
+ DesktopRect::MakeLTRB(300, 125, 350, 175)},
+ 6},
+ {4,
+ {DesktopRect::MakeLTRB(100, 100, 200, 200),
+ DesktopRect::MakeLTRB(50, 50, 100, 150),
+ DesktopRect::MakeLTRB(100, 50, 150, 150),
+ DesktopRect::MakeLTRB(300, 125, 350, 175)},
+ 6},
- // Rectangle region defined by a set of rectangles that merge into one.
- { 3, { DesktopRect::MakeLTRB(10, 10, 40, 20),
- DesktopRect::MakeLTRB(10, 30, 40, 40),
- DesktopRect::MakeLTRB(10, 20, 40, 30) }, 7 },
- { 1, { DesktopRect::MakeLTRB(10, 10, 40, 40) }, 7 },
+ // Rectangle region defined by a set of rectangles that merge into one.
+ {3,
+ {DesktopRect::MakeLTRB(10, 10, 40, 20),
+ DesktopRect::MakeLTRB(10, 30, 40, 40),
+ DesktopRect::MakeLTRB(10, 20, 40, 30)},
+ 7},
+ {1, {DesktopRect::MakeLTRB(10, 10, 40, 40)}, 7},
};
int kTotalRegions = sizeof(regions) / sizeof(Region);
@@ -379,15 +433,18 @@
int expected_count;
DesktopRect expected_rects[5];
} cases[] = {
- { 3, { DesktopRect::MakeLTRB(0, 0, 30, 30),
- DesktopRect::MakeLTRB(10, 10, 40, 40),
- DesktopRect::MakeLTRB(20, 20, 50, 50) },
- 3, 5,
- 5, { DesktopRect::MakeLTRB(3, 5, 33, 15),
- DesktopRect::MakeLTRB(3, 15, 43, 25),
- DesktopRect::MakeLTRB(3, 25, 53, 35),
- DesktopRect::MakeLTRB(13, 35, 53, 45),
- DesktopRect::MakeLTRB(23, 45, 53, 55) } },
+ {3,
+ {DesktopRect::MakeLTRB(0, 0, 30, 30),
+ DesktopRect::MakeLTRB(10, 10, 40, 40),
+ DesktopRect::MakeLTRB(20, 20, 50, 50)},
+ 3,
+ 5,
+ 5,
+ {DesktopRect::MakeLTRB(3, 5, 33, 15),
+ DesktopRect::MakeLTRB(3, 15, 43, 25),
+ DesktopRect::MakeLTRB(3, 25, 53, 35),
+ DesktopRect::MakeLTRB(13, 35, 53, 45),
+ DesktopRect::MakeLTRB(23, 45, 53, 55)}},
};
for (size_t i = 0; i < (sizeof(cases) / sizeof(Case)); ++i) {
@@ -408,27 +465,42 @@
int expected_count;
DesktopRect expected_rects[5];
} cases[] = {
- { 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
- 1, { DesktopRect::MakeLTRB(50, 50, 150, 150) },
- 1, { DesktopRect::MakeLTRB(50, 50, 100, 100) } },
+ {1,
+ {DesktopRect::MakeLTRB(0, 0, 100, 100)},
+ 1,
+ {DesktopRect::MakeLTRB(50, 50, 150, 150)},
+ 1,
+ {DesktopRect::MakeLTRB(50, 50, 100, 100)}},
- { 1, { DesktopRect::MakeLTRB(100, 0, 200, 300) },
- 1, { DesktopRect::MakeLTRB(0, 100, 300, 200) },
- 1, { DesktopRect::MakeLTRB(100, 100, 200, 200) } },
+ {1,
+ {DesktopRect::MakeLTRB(100, 0, 200, 300)},
+ 1,
+ {DesktopRect::MakeLTRB(0, 100, 300, 200)},
+ 1,
+ {DesktopRect::MakeLTRB(100, 100, 200, 200)}},
- { 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
- 2, { DesktopRect::MakeLTRB(50, 10, 150, 30),
- DesktopRect::MakeLTRB(50, 30, 160, 50) },
- 1, { DesktopRect::MakeLTRB(50, 10, 100, 50) } },
+ {1,
+ {DesktopRect::MakeLTRB(0, 0, 100, 100)},
+ 2,
+ {DesktopRect::MakeLTRB(50, 10, 150, 30),
+ DesktopRect::MakeLTRB(50, 30, 160, 50)},
+ 1,
+ {DesktopRect::MakeLTRB(50, 10, 100, 50)}},
- { 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
- 2, { DesktopRect::MakeLTRB(50, 10, 150, 30),
- DesktopRect::MakeLTRB(50, 30, 90, 50) },
- 2, { DesktopRect::MakeLTRB(50, 10, 100, 30),
- DesktopRect::MakeLTRB(50, 30, 90, 50) } },
- { 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
- 1, { DesktopRect::MakeLTRB(100, 50, 200, 200) },
- 0, {} },
+ {1,
+ {DesktopRect::MakeLTRB(0, 0, 100, 100)},
+ 2,
+ {DesktopRect::MakeLTRB(50, 10, 150, 30),
+ DesktopRect::MakeLTRB(50, 30, 90, 50)},
+ 2,
+ {DesktopRect::MakeLTRB(50, 10, 100, 30),
+ DesktopRect::MakeLTRB(50, 30, 90, 50)}},
+ {1,
+ {DesktopRect::MakeLTRB(0, 0, 100, 100)},
+ 1,
+ {DesktopRect::MakeLTRB(100, 50, 200, 200)},
+ 0,
+ {}},
};
for (size_t i = 0; i < (sizeof(cases) / sizeof(Case)); ++i) {
@@ -453,81 +525,123 @@
int expected_count;
DesktopRect expected_rects[5];
} cases[] = {
- // Subtract one rect from another.
- { 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
- 1, { DesktopRect::MakeLTRB(50, 50, 150, 150) },
- 2, { DesktopRect::MakeLTRB(0, 0, 100, 50),
- DesktopRect::MakeLTRB(0, 50, 50, 100) } },
+ // Subtract one rect from another.
+ {1,
+ {DesktopRect::MakeLTRB(0, 0, 100, 100)},
+ 1,
+ {DesktopRect::MakeLTRB(50, 50, 150, 150)},
+ 2,
+ {DesktopRect::MakeLTRB(0, 0, 100, 50),
+ DesktopRect::MakeLTRB(0, 50, 50, 100)}},
- { 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
- 1, { DesktopRect::MakeLTRB(-50, -50, 50, 50) },
- 2, { DesktopRect::MakeLTRB(50, 0, 100, 50),
- DesktopRect::MakeLTRB(0, 50, 100, 100) } },
+ {1,
+ {DesktopRect::MakeLTRB(0, 0, 100, 100)},
+ 1,
+ {DesktopRect::MakeLTRB(-50, -50, 50, 50)},
+ 2,
+ {DesktopRect::MakeLTRB(50, 0, 100, 50),
+ DesktopRect::MakeLTRB(0, 50, 100, 100)}},
- { 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
- 1, { DesktopRect::MakeLTRB(-50, 50, 50, 150) },
- 2, { DesktopRect::MakeLTRB(0, 0, 100, 50),
- DesktopRect::MakeLTRB(50, 50, 100, 100) } },
+ {1,
+ {DesktopRect::MakeLTRB(0, 0, 100, 100)},
+ 1,
+ {DesktopRect::MakeLTRB(-50, 50, 50, 150)},
+ 2,
+ {DesktopRect::MakeLTRB(0, 0, 100, 50),
+ DesktopRect::MakeLTRB(50, 50, 100, 100)}},
- { 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
- 1, { DesktopRect::MakeLTRB(50, 50, 150, 70) },
- 3, { DesktopRect::MakeLTRB(0, 0, 100, 50),
- DesktopRect::MakeLTRB(0, 50, 50, 70),
- DesktopRect::MakeLTRB(0, 70, 100, 100) } },
+ {1,
+ {DesktopRect::MakeLTRB(0, 0, 100, 100)},
+ 1,
+ {DesktopRect::MakeLTRB(50, 50, 150, 70)},
+ 3,
+ {DesktopRect::MakeLTRB(0, 0, 100, 50),
+ DesktopRect::MakeLTRB(0, 50, 50, 70),
+ DesktopRect::MakeLTRB(0, 70, 100, 100)}},
- { 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
- 1, { DesktopRect::MakeLTRB(50, 50, 70, 70) },
- 4, { DesktopRect::MakeLTRB(0, 0, 100, 50),
- DesktopRect::MakeLTRB(0, 50, 50, 70),
- DesktopRect::MakeLTRB(70, 50, 100, 70),
- DesktopRect::MakeLTRB(0, 70, 100, 100) } },
+ {1,
+ {DesktopRect::MakeLTRB(0, 0, 100, 100)},
+ 1,
+ {DesktopRect::MakeLTRB(50, 50, 70, 70)},
+ 4,
+ {DesktopRect::MakeLTRB(0, 0, 100, 50),
+ DesktopRect::MakeLTRB(0, 50, 50, 70),
+ DesktopRect::MakeLTRB(70, 50, 100, 70),
+ DesktopRect::MakeLTRB(0, 70, 100, 100)}},
- // Empty result.
- { 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
- 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
- 0, {} },
+ // Empty result.
+ {1,
+ {DesktopRect::MakeLTRB(0, 0, 100, 100)},
+ 1,
+ {DesktopRect::MakeLTRB(0, 0, 100, 100)},
+ 0,
+ {}},
- { 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
- 1, { DesktopRect::MakeLTRB(-10, -10, 110, 110) },
- 0, {} },
+ {1,
+ {DesktopRect::MakeLTRB(0, 0, 100, 100)},
+ 1,
+ {DesktopRect::MakeLTRB(-10, -10, 110, 110)},
+ 0,
+ {}},
- { 2, { DesktopRect::MakeLTRB(0, 0, 100, 100),
- DesktopRect::MakeLTRB(50, 50, 150, 150) },
- 2, { DesktopRect::MakeLTRB(0, 0, 100, 100),
- DesktopRect::MakeLTRB(50, 50, 150, 150) },
- 0, {} },
+ {2,
+ {DesktopRect::MakeLTRB(0, 0, 100, 100),
+ DesktopRect::MakeLTRB(50, 50, 150, 150)},
+ 2,
+ {DesktopRect::MakeLTRB(0, 0, 100, 100),
+ DesktopRect::MakeLTRB(50, 50, 150, 150)},
+ 0,
+ {}},
- // One rect out of disjoint set.
- { 3, { DesktopRect::MakeLTRB(0, 0, 10, 10),
- DesktopRect::MakeLTRB(20, 20, 30, 30),
- DesktopRect::MakeLTRB(40, 0, 50, 10) },
- 1, { DesktopRect::MakeLTRB(20, 20, 30, 30) },
- 2, { DesktopRect::MakeLTRB(0, 0, 10, 10),
- DesktopRect::MakeLTRB(40, 0, 50, 10) } },
+ // One rect out of disjoint set.
+ {3,
+ {DesktopRect::MakeLTRB(0, 0, 10, 10),
+ DesktopRect::MakeLTRB(20, 20, 30, 30),
+ DesktopRect::MakeLTRB(40, 0, 50, 10)},
+ 1,
+ {DesktopRect::MakeLTRB(20, 20, 30, 30)},
+ 2,
+ {DesktopRect::MakeLTRB(0, 0, 10, 10),
+ DesktopRect::MakeLTRB(40, 0, 50, 10)}},
- // Row merging.
- { 3, { DesktopRect::MakeLTRB(0, 0, 100, 50),
- DesktopRect::MakeLTRB(0, 50, 150, 70),
- DesktopRect::MakeLTRB(0, 70, 100, 100) },
- 1, { DesktopRect::MakeLTRB(100, 50, 150, 70) },
- 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) } },
+ // Row merging.
+ {3,
+ {DesktopRect::MakeLTRB(0, 0, 100, 50),
+ DesktopRect::MakeLTRB(0, 50, 150, 70),
+ DesktopRect::MakeLTRB(0, 70, 100, 100)},
+ 1,
+ {DesktopRect::MakeLTRB(100, 50, 150, 70)},
+ 1,
+ {DesktopRect::MakeLTRB(0, 0, 100, 100)}},
- // No-op subtraction.
- { 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
- 1, { DesktopRect::MakeLTRB(100, 0, 200, 100) },
- 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) } },
+ // No-op subtraction.
+ {1,
+ {DesktopRect::MakeLTRB(0, 0, 100, 100)},
+ 1,
+ {DesktopRect::MakeLTRB(100, 0, 200, 100)},
+ 1,
+ {DesktopRect::MakeLTRB(0, 0, 100, 100)}},
- { 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
- 1, { DesktopRect::MakeLTRB(-100, 0, 0, 100) },
- 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) } },
+ {1,
+ {DesktopRect::MakeLTRB(0, 0, 100, 100)},
+ 1,
+ {DesktopRect::MakeLTRB(-100, 0, 0, 100)},
+ 1,
+ {DesktopRect::MakeLTRB(0, 0, 100, 100)}},
- { 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
- 1, { DesktopRect::MakeLTRB(0, 100, 0, 200) },
- 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) } },
+ {1,
+ {DesktopRect::MakeLTRB(0, 0, 100, 100)},
+ 1,
+ {DesktopRect::MakeLTRB(0, 100, 0, 200)},
+ 1,
+ {DesktopRect::MakeLTRB(0, 0, 100, 100)}},
- { 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) },
- 1, { DesktopRect::MakeLTRB(0, -100, 100, 0) },
- 1, { DesktopRect::MakeLTRB(0, 0, 100, 100) } },
+ {1,
+ {DesktopRect::MakeLTRB(0, 0, 100, 100)},
+ 1,
+ {DesktopRect::MakeLTRB(0, -100, 100, 0)},
+ 1,
+ {DesktopRect::MakeLTRB(0, 0, 100, 100)}},
};
for (size_t i = 0; i < (sizeof(cases) / sizeof(Case)); ++i) {
@@ -552,19 +666,21 @@
struct SpanSet {
int count;
struct Range {
- int start;
- int end;
+ int start;
+ int end;
} spans[3];
} span_sets[] = {
- {1, { {0, 3} } },
- {1, { {0, 5} } },
- {1, { {0, 7} } },
- {1, { {0, 12} } },
- {2, { {0, 3}, {4, 5}, {6, 16} } },
+ {1, {{0, 3}}},
+ {1, {{0, 5}}},
+ {1, {{0, 7}}},
+ {1, {{0, 12}}},
+ {2, {{0, 3}, {4, 5}, {6, 16}}},
};
DesktopRegion base_region;
- bool base_map[kMapWidth] = { false, };
+ bool base_map[kMapWidth] = {
+ false,
+ };
base_region.AddRect(DesktopRect::MakeXYWH(5, 0, 5, 1));
std::fill_n(base_map + 5, 5, true);
@@ -599,7 +715,9 @@
}
r.Subtract(region2);
- bool map[kMapWidth] = { false, };
+ bool map[kMapWidth] = {
+ false,
+ };
int pos = -1;
for (DesktopRegion::Iterator it(r); !it.IsAtEnd(); it.Advance()) {
@@ -623,19 +741,21 @@
struct SpanSet {
int count;
struct Range {
- int start;
- int end;
+ int start;
+ int end;
} spans[3];
} span_sets[] = {
- {1, { {0, 3} } },
- {1, { {0, 5} } },
- {1, { {0, 7} } },
- {1, { {0, 12} } },
- {2, { {0, 3}, {4, 5}, {6, 16} } },
+ {1, {{0, 3}}},
+ {1, {{0, 5}}},
+ {1, {{0, 7}}},
+ {1, {{0, 12}}},
+ {2, {{0, 3}, {4, 5}, {6, 16}}},
};
DesktopRegion base_region;
- bool base_map[kMapHeight] = { false, };
+ bool base_map[kMapHeight] = {
+ false,
+ };
base_region.AddRect(DesktopRect::MakeXYWH(0, 5, 1, 5));
std::fill_n(base_map + 5, 5, true);
@@ -670,7 +790,9 @@
}
r.Subtract(region2);
- bool map[kMapHeight] = { false, };
+ bool map[kMapHeight] = {
+ false,
+ };
int pos = -1;
for (DesktopRegion::Iterator it(r); !it.IsAtEnd(); it.Advance()) {
@@ -686,19 +808,18 @@
}
}
-
TEST(DesktopRegionTest, DISABLED_Performance) {
for (int c = 0; c < 1000; ++c) {
DesktopRegion r;
for (int i = 0; i < 10; ++i) {
- r.AddRect(DesktopRect::MakeXYWH(
- RadmonInt(1000), RadmonInt(1000), 200, 200));
+ r.AddRect(
+ DesktopRect::MakeXYWH(RadmonInt(1000), RadmonInt(1000), 200, 200));
}
for (int i = 0; i < 1000; ++i) {
- r.AddRect(DesktopRect::MakeXYWH(
- RadmonInt(1000), RadmonInt(1000),
- 5 + RadmonInt(10) * 5, 5 + RadmonInt(10) * 5));
+ r.AddRect(DesktopRect::MakeXYWH(RadmonInt(1000), RadmonInt(1000),
+ 5 + RadmonInt(10) * 5,
+ 5 + RadmonInt(10) * 5));
}
// Iterate over the rectangles.
diff --git a/modules/desktop_capture/differ_block.cc b/modules/desktop_capture/differ_block.cc
index 3315247..e15211d 100644
--- a/modules/desktop_capture/differ_block.cc
+++ b/modules/desktop_capture/differ_block.cc
@@ -12,9 +12,9 @@
#include <string.h>
-#include "typedefs.h" // NOLINT(build/include)
#include "modules/desktop_capture/differ_vector_sse2.h"
#include "system_wrappers/include/cpu_features_wrapper.h"
+#include "typedefs.h" // NOLINT(build/include)
namespace webrtc {
diff --git a/modules/desktop_capture/differ_block.h b/modules/desktop_capture/differ_block.h
index 7bf9a7b..2019ae0 100644
--- a/modules/desktop_capture/differ_block.h
+++ b/modules/desktop_capture/differ_block.h
@@ -35,9 +35,7 @@
// Low level function to compare 2 blocks of pixels of size
// (kBlockSize, kBlockSize). Returns whether the blocks differ.
-bool BlockDifference(const uint8_t* image1,
- const uint8_t* image2,
- int stride);
+bool BlockDifference(const uint8_t* image1, const uint8_t* image2, int stride);
} // namespace webrtc
diff --git a/modules/desktop_capture/differ_block_unittest.cc b/modules/desktop_capture/differ_block_unittest.cc
index 3f08632..ac8b3a1 100644
--- a/modules/desktop_capture/differ_block_unittest.cc
+++ b/modules/desktop_capture/differ_block_unittest.cc
@@ -27,9 +27,9 @@
static const int kSizeOfBlock = kBlockSize * kBlockSize * kBytesPerPixel;
uint8_t block_buffer[kSizeOfBlock * 2 + 16];
-void PrepareBuffers(uint8_t* &block1, uint8_t* &block2) {
- block1 = reinterpret_cast<uint8_t*>
- ((reinterpret_cast<uintptr_t>(&block_buffer[0]) + 15) & ~15);
+void PrepareBuffers(uint8_t*& block1, uint8_t*& block2) {
+ block1 = reinterpret_cast<uint8_t*>(
+ (reinterpret_cast<uintptr_t>(&block_buffer[0]) + 15) & ~15);
GenerateData(block1, kSizeOfBlock);
block2 = block1 + kSizeOfBlock;
memcpy(block2, block1, kSizeOfBlock);
@@ -51,7 +51,7 @@
uint8_t* block1;
uint8_t* block2;
PrepareBuffers(block1, block2);
- block2[kSizeOfBlock-2] += 1;
+ block2[kSizeOfBlock - 2] += 1;
for (int i = 0; i < kTimesToRun; ++i) {
int result = BlockDifference(block1, block2, kBlockSize * kBytesPerPixel);
@@ -63,7 +63,7 @@
uint8_t* block1;
uint8_t* block2;
PrepareBuffers(block1, block2);
- block2[kSizeOfBlock/2+1] += 1;
+ block2[kSizeOfBlock / 2 + 1] += 1;
for (int i = 0; i < kTimesToRun; ++i) {
int result = BlockDifference(block1, block2, kBlockSize * kBytesPerPixel);
diff --git a/modules/desktop_capture/differ_vector_sse2.cc b/modules/desktop_capture/differ_vector_sse2.cc
index 9b552e0..1c8b602 100644
--- a/modules/desktop_capture/differ_vector_sse2.cc
+++ b/modules/desktop_capture/differ_vector_sse2.cc
@@ -13,8 +13,8 @@
#if defined(_MSC_VER)
#include <intrin.h>
#else
-#include <mmintrin.h>
#include <emmintrin.h>
+#include <mmintrin.h>
#endif
namespace webrtc {
diff --git a/modules/desktop_capture/fake_desktop_capturer.h b/modules/desktop_capture/fake_desktop_capturer.h
index cb1cfe1..82c053c 100644
--- a/modules/desktop_capture/fake_desktop_capturer.h
+++ b/modules/desktop_capture/fake_desktop_capturer.h
@@ -13,8 +13,8 @@
#include <memory>
-#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_capture_types.h"
+#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_frame_generator.h"
#include "modules/desktop_capture/shared_memory.h"
diff --git a/modules/desktop_capture/fallback_desktop_capturer_wrapper.cc b/modules/desktop_capture/fallback_desktop_capturer_wrapper.cc
index b261a03..2dd8ce1 100644
--- a/modules/desktop_capture/fallback_desktop_capturer_wrapper.cc
+++ b/modules/desktop_capture/fallback_desktop_capturer_wrapper.cc
@@ -51,16 +51,16 @@
}
// static
-std::unique_ptr<SharedMemoryFactory>
-SharedMemoryFactoryProxy::Create(SharedMemoryFactory* factory) {
+std::unique_ptr<SharedMemoryFactory> SharedMemoryFactoryProxy::Create(
+ SharedMemoryFactory* factory) {
return std::unique_ptr<SharedMemoryFactory>(
new SharedMemoryFactoryProxy(factory));
}
SharedMemoryFactoryProxy::~SharedMemoryFactoryProxy() = default;
-std::unique_ptr<SharedMemory>
-SharedMemoryFactoryProxy::CreateSharedMemory(size_t size) {
+std::unique_ptr<SharedMemory> SharedMemoryFactoryProxy::CreateSharedMemory(
+ size_t size) {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
return factory_->CreateSharedMemory(size);
}
diff --git a/modules/desktop_capture/fallback_desktop_capturer_wrapper.h b/modules/desktop_capture/fallback_desktop_capturer_wrapper.h
index a6f2ceb..97affbe 100644
--- a/modules/desktop_capture/fallback_desktop_capturer_wrapper.h
+++ b/modules/desktop_capture/fallback_desktop_capturer_wrapper.h
@@ -13,8 +13,8 @@
#include <memory>
-#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_capture_types.h"
+#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_frame.h"
#include "modules/desktop_capture/shared_memory.h"
diff --git a/modules/desktop_capture/fallback_desktop_capturer_wrapper_unittest.cc b/modules/desktop_capture/fallback_desktop_capturer_wrapper_unittest.cc
index ca11162..f2d6071 100644
--- a/modules/desktop_capture/fallback_desktop_capturer_wrapper_unittest.cc
+++ b/modules/desktop_capture/fallback_desktop_capturer_wrapper_unittest.cc
@@ -180,8 +180,8 @@
}
TEST_F(FallbackDesktopCapturerWrapperTest, WithSharedMemory) {
- wrapper_->SetSharedMemoryFactory(std::unique_ptr<SharedMemoryFactory>(
- new FakeSharedMemoryFactory()));
+ wrapper_->SetSharedMemoryFactory(
+ std::unique_ptr<SharedMemoryFactory>(new FakeSharedMemoryFactory()));
wrapper_->CaptureFrame();
main_capturer_->set_result(DesktopCapturer::Result::ERROR_TEMPORARY);
wrapper_->CaptureFrame();
diff --git a/modules/desktop_capture/mac/desktop_configuration.h b/modules/desktop_capture/mac/desktop_configuration.h
index 736d623..2bee9af 100644
--- a/modules/desktop_capture/mac/desktop_configuration.h
+++ b/modules/desktop_capture/mac/desktop_configuration.h
@@ -14,8 +14,8 @@
#include <ApplicationServices/ApplicationServices.h>
#include <vector>
-#include "typedefs.h" // NOLINT(build/include)
#include "modules/desktop_capture/desktop_geometry.h"
+#include "typedefs.h" // NOLINT(build/include)
namespace webrtc {
diff --git a/modules/desktop_capture/mac/desktop_configuration_monitor.cc b/modules/desktop_capture/mac/desktop_configuration_monitor.cc
index e8378c3..d4364be 100644
--- a/modules/desktop_capture/mac/desktop_configuration_monitor.cc
+++ b/modules/desktop_capture/mac/desktop_configuration_monitor.cc
@@ -43,7 +43,7 @@
void DesktopConfigurationMonitor::Lock() {
if (!display_configuration_capture_event_->Wait(
- kDisplayConfigurationEventTimeoutMs)) {
+ kDisplayConfigurationEventTimeoutMs)) {
RTC_LOG_F(LS_ERROR) << "Event wait timed out.";
abort();
}
@@ -57,7 +57,7 @@
void DesktopConfigurationMonitor::DisplaysReconfiguredCallback(
CGDirectDisplayID display,
CGDisplayChangeSummaryFlags flags,
- void *user_parameter) {
+ void* user_parameter) {
DesktopConfigurationMonitor* monitor =
reinterpret_cast<DesktopConfigurationMonitor*>(user_parameter);
monitor->DisplaysReconfigured(display, flags);
diff --git a/modules/desktop_capture/mac/desktop_configuration_monitor.h b/modules/desktop_capture/mac/desktop_configuration_monitor.h
index 746fbb2..5215e54 100644
--- a/modules/desktop_capture/mac/desktop_configuration_monitor.h
+++ b/modules/desktop_capture/mac/desktop_configuration_monitor.h
@@ -45,7 +45,7 @@
private:
static void DisplaysReconfiguredCallback(CGDirectDisplayID display,
CGDisplayChangeSummaryFlags flags,
- void *user_parameter);
+ void* user_parameter);
void DisplaysReconfigured(CGDirectDisplayID display,
CGDisplayChangeSummaryFlags flags);
diff --git a/modules/desktop_capture/mac/full_screen_chrome_window_detector.cc b/modules/desktop_capture/mac/full_screen_chrome_window_detector.cc
index a9f334f..0cda46c 100644
--- a/modules/desktop_capture/mac/full_screen_chrome_window_detector.cc
+++ b/modules/desktop_capture/mac/full_screen_chrome_window_detector.cc
@@ -27,7 +27,7 @@
std::string GetWindowTitle(CGWindowID id) {
CFArrayRef window_id_array =
- CFArrayCreate(NULL, reinterpret_cast<const void **>(&id), 1, NULL);
+ CFArrayCreate(NULL, reinterpret_cast<const void**>(&id), 1, NULL);
CFArrayRef window_array =
CGWindowListCreateDescriptionFromArray(window_id_array);
std::string title;
@@ -35,7 +35,7 @@
if (window_array && CFArrayGetCount(window_array)) {
CFDictionaryRef window = reinterpret_cast<CFDictionaryRef>(
CFArrayGetValueAtIndex(window_array, 0));
- CFStringRef title_ref = reinterpret_cast<CFStringRef>(
+ CFStringRef title_ref = reinterpret_cast<CFStringRef>(
CFDictionaryGetValue(window, kCGWindowName));
if (title_ref)
@@ -49,7 +49,7 @@
int GetWindowOwnerPid(CGWindowID id) {
CFArrayRef window_id_array =
- CFArrayCreate(NULL, reinterpret_cast<const void **>(&id), 1, NULL);
+ CFArrayCreate(NULL, reinterpret_cast<const void**>(&id), 1, NULL);
CFArrayRef window_array =
CGWindowListCreateDescriptionFromArray(window_id_array);
int pid = 0;
@@ -57,7 +57,7 @@
if (window_array && CFArrayGetCount(window_array)) {
CFDictionaryRef window = reinterpret_cast<CFDictionaryRef>(
CFArrayGetValueAtIndex(window_array, 0));
- CFNumberRef pid_ref = reinterpret_cast<CFNumberRef>(
+ CFNumberRef pid_ref = reinterpret_cast<CFNumberRef>(
CFDictionaryGetValue(window, kCGWindowOwnerPID));
if (pid_ref)
@@ -97,7 +97,7 @@
CFDictionaryGetValue(window, kCGWindowName));
CFNumberRef window_id_ref = reinterpret_cast<CFNumberRef>(
CFDictionaryGetValue(window, kCGWindowNumber));
- CFNumberRef window_pid_ref = reinterpret_cast<CFNumberRef>(
+ CFNumberRef window_pid_ref = reinterpret_cast<CFNumberRef>(
CFDictionaryGetValue(window, kCGWindowOwnerPID));
if (!window_title_ref || !window_id_ref || !window_pid_ref)
@@ -170,8 +170,8 @@
void FullScreenChromeWindowDetector::UpdateWindowListIfNeeded(
CGWindowID original_window) {
if (IsChromeWindow(original_window) &&
- (rtc::TimeNanos() - last_update_time_ns_) / rtc::kNumNanosecsPerMillisec
- > kUpdateIntervalMs) {
+ (rtc::TimeNanos() - last_update_time_ns_) / rtc::kNumNanosecsPerMillisec >
+ kUpdateIntervalMs) {
previous_window_list_.clear();
previous_window_list_.swap(current_window_list_);
diff --git a/modules/desktop_capture/mac/window_list_utils.cc b/modules/desktop_capture/mac/window_list_utils.cc
index d30eb4b..7f89cde 100644
--- a/modules/desktop_capture/mac/window_list_utils.cc
+++ b/modules/desktop_capture/mac/window_list_utils.cc
@@ -19,9 +19,9 @@
#include "rtc_base/checks.h"
#include "rtc_base/macutils.h"
-static_assert(
- static_cast<webrtc::WindowId>(kCGNullWindowID) == webrtc::kNullWindowId,
- "kNullWindowId needs to equal to kCGNullWindowID.");
+static_assert(static_cast<webrtc::WindowId>(kCGNullWindowID) ==
+ webrtc::kNullWindowId,
+ "kNullWindowId needs to equal to kCGNullWindowID.");
namespace webrtc {
@@ -69,8 +69,8 @@
// Only get on screen, non-desktop windows.
// According to
- // https://developer.apple.com/documentation/coregraphics/cgwindowlistoption/1454105-optiononscreenonly ,
- // when kCGWindowListOptionOnScreenOnly is used, the order of windows are in
+ // https://developer.apple.com/documentation/coregraphics/cgwindowlistoption/1454105-optiononscreenonly
+ // , when kCGWindowListOptionOnScreenOnly is used, the order of windows are in
// decreasing z-order.
CFArrayRef window_array = CGWindowListCopyWindowInfo(
kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements,
@@ -143,7 +143,7 @@
WindowId id = GetWindowId(window);
std::string title = GetWindowTitle(window);
if (id != kNullWindowId && !title.empty()) {
- windows->push_back(DesktopCapturer::Source{ id, title });
+ windows->push_back(DesktopCapturer::Source{id, title});
}
return true;
},
@@ -151,9 +151,8 @@
}
// Returns true if the window is occupying a full screen.
-bool IsWindowFullScreen(
- const MacDesktopConfiguration& desktop_config,
- CFDictionaryRef window) {
+bool IsWindowFullScreen(const MacDesktopConfiguration& desktop_config,
+ CFDictionaryRef window) {
bool fullscreen = false;
CFDictionaryRef bounds_ref = reinterpret_cast<CFDictionaryRef>(
CFDictionaryGetValue(window, kCGWindowBounds));
@@ -164,10 +163,9 @@
for (MacDisplayConfigurations::const_iterator it =
desktop_config.displays.begin();
it != desktop_config.displays.end(); it++) {
- if (it->bounds.equals(DesktopRect::MakeXYWH(bounds.origin.x,
- bounds.origin.y,
- bounds.size.width,
- bounds.size.height))) {
+ if (it->bounds.equals(
+ DesktopRect::MakeXYWH(bounds.origin.x, bounds.origin.y,
+ bounds.size.width, bounds.size.height))) {
fullscreen = true;
break;
}
@@ -185,10 +183,9 @@
bool IsWindowOnScreen(CGWindowID id) {
bool on_screen;
- if (GetWindowRef(id,
- [&on_screen](CFDictionaryRef window) {
- on_screen = IsWindowOnScreen(window);
- })) {
+ if (GetWindowRef(id, [&on_screen](CFDictionaryRef window) {
+ on_screen = IsWindowOnScreen(window);
+ })) {
return on_screen;
}
return false;
@@ -265,18 +262,16 @@
return DesktopRect();
}
- return DesktopRect::MakeXYWH(gc_window_rect.origin.x,
- gc_window_rect.origin.y,
+ return DesktopRect::MakeXYWH(gc_window_rect.origin.x, gc_window_rect.origin.y,
gc_window_rect.size.width,
gc_window_rect.size.height);
}
DesktopRect GetWindowBounds(CGWindowID id) {
DesktopRect result;
- if (GetWindowRef(id,
- [&result](CFDictionaryRef window) {
- result = GetWindowBounds(window);
- })) {
+ if (GetWindowRef(id, [&result](CFDictionaryRef window) {
+ result = GetWindowBounds(window);
+ })) {
return result;
}
return DesktopRect();
diff --git a/modules/desktop_capture/mouse_cursor.cc b/modules/desktop_capture/mouse_cursor.cc
index bb9f327..3b61e10 100644
--- a/modules/desktop_capture/mouse_cursor.cc
+++ b/modules/desktop_capture/mouse_cursor.cc
@@ -19,8 +19,7 @@
MouseCursor::MouseCursor() {}
MouseCursor::MouseCursor(DesktopFrame* image, const DesktopVector& hotspot)
- : image_(image),
- hotspot_(hotspot) {
+ : image_(image), hotspot_(hotspot) {
assert(0 <= hotspot_.x() && hotspot_.x() <= image_->size().width());
assert(0 <= hotspot_.y() && hotspot_.y() <= image_->size().height());
}
diff --git a/modules/desktop_capture/mouse_cursor.h b/modules/desktop_capture/mouse_cursor.h
index daf6c96..31fe836 100644
--- a/modules/desktop_capture/mouse_cursor.h
+++ b/modules/desktop_capture/mouse_cursor.h
@@ -34,7 +34,7 @@
void set_image(DesktopFrame* image) { image_.reset(image); }
const DesktopFrame* image() const { return image_.get(); }
- void set_hotspot(const DesktopVector& hotspot ) { hotspot_ = hotspot; }
+ void set_hotspot(const DesktopVector& hotspot) { hotspot_ = hotspot; }
const DesktopVector& hotspot() const { return hotspot_; }
private:
diff --git a/modules/desktop_capture/mouse_cursor_monitor.h b/modules/desktop_capture/mouse_cursor_monitor.h
index e969d8e..a589c59 100644
--- a/modules/desktop_capture/mouse_cursor_monitor.h
+++ b/modules/desktop_capture/mouse_cursor_monitor.h
@@ -110,4 +110,3 @@
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_MOUSE_CURSOR_MONITOR_H_
-
diff --git a/modules/desktop_capture/mouse_cursor_monitor_unittest.cc b/modules/desktop_capture/mouse_cursor_monitor_unittest.cc
index 812873f..ea7ba60 100644
--- a/modules/desktop_capture/mouse_cursor_monitor_unittest.cc
+++ b/modules/desktop_capture/mouse_cursor_monitor_unittest.cc
@@ -10,11 +10,11 @@
#include <memory>
-#include "modules/desktop_capture/mouse_cursor_monitor.h"
-#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_capture_options.h"
+#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_frame.h"
#include "modules/desktop_capture/mouse_cursor.h"
+#include "modules/desktop_capture/mouse_cursor_monitor.h"
#include "test/gtest.h"
namespace webrtc {
@@ -22,9 +22,7 @@
class MouseCursorMonitorTest : public testing::Test,
public MouseCursorMonitor::Callback {
public:
- MouseCursorMonitorTest()
- : position_received_(false) {
- }
+ MouseCursorMonitorTest() : position_received_(false) {}
// MouseCursorMonitor::Callback interface
void OnMouseCursor(MouseCursor* cursor_image) override {
diff --git a/modules/desktop_capture/mouse_cursor_monitor_win.cc b/modules/desktop_capture/mouse_cursor_monitor_win.cc
index 0c0a7b7..bc03b95 100644
--- a/modules/desktop_capture/mouse_cursor_monitor_win.cc
+++ b/modules/desktop_capture/mouse_cursor_monitor_win.cc
@@ -31,8 +31,7 @@
bool IsSameCursorShape(const CURSORINFO& left, const CURSORINFO& right) {
// If the cursors are not showing, we do not care the hCursor handle.
return left.flags == right.flags &&
- (left.flags != CURSOR_SHOWING ||
- left.hCursor == right.hCursor);
+ (left.flags != CURSOR_SHOWING || left.hCursor == right.hCursor);
}
} // namespace
@@ -152,8 +151,9 @@
} else {
if (inside) {
HWND windowUnderCursor = WindowFromPoint(cursor_info.ptScreenPos);
- inside = windowUnderCursor ?
- (window_ == GetAncestor(windowUnderCursor, GA_ROOT)) : false;
+ inside = windowUnderCursor
+ ? (window_ == GetAncestor(windowUnderCursor, GA_ROOT))
+ : false;
}
position = position.subtract(cropped_rect.top_left());
}
@@ -171,11 +171,10 @@
DesktopRect MouseCursorMonitorWin::GetScreenRect() {
assert(screen_ != kInvalidScreenId);
if (screen_ == kFullDesktopScreenId) {
- return DesktopRect::MakeXYWH(
- GetSystemMetrics(SM_XVIRTUALSCREEN),
- GetSystemMetrics(SM_YVIRTUALSCREEN),
- GetSystemMetrics(SM_CXVIRTUALSCREEN),
- GetSystemMetrics(SM_CYVIRTUALSCREEN));
+ return DesktopRect::MakeXYWH(GetSystemMetrics(SM_XVIRTUALSCREEN),
+ GetSystemMetrics(SM_YVIRTUALSCREEN),
+ GetSystemMetrics(SM_CXVIRTUALSCREEN),
+ GetSystemMetrics(SM_CYVIRTUALSCREEN));
}
DISPLAY_DEVICE device;
device.cb = sizeof(device);
@@ -186,19 +185,19 @@
DEVMODE device_mode;
device_mode.dmSize = sizeof(device_mode);
device_mode.dmDriverExtra = 0;
- result = EnumDisplaySettingsEx(
- device.DeviceName, ENUM_CURRENT_SETTINGS, &device_mode, 0);
+ result = EnumDisplaySettingsEx(device.DeviceName, ENUM_CURRENT_SETTINGS,
+ &device_mode, 0);
if (!result)
return DesktopRect();
- return DesktopRect::MakeXYWH(device_mode.dmPosition.x,
- device_mode.dmPosition.y,
- device_mode.dmPelsWidth,
- device_mode.dmPelsHeight);
+ return DesktopRect::MakeXYWH(
+ device_mode.dmPosition.x, device_mode.dmPosition.y,
+ device_mode.dmPelsWidth, device_mode.dmPelsHeight);
}
MouseCursorMonitor* MouseCursorMonitor::CreateForWindow(
- const DesktopCaptureOptions& options, WindowId window) {
+ const DesktopCaptureOptions& options,
+ WindowId window) {
return new MouseCursorMonitorWin(reinterpret_cast<HWND>(window));
}
diff --git a/modules/desktop_capture/mouse_cursor_monitor_x11.cc b/modules/desktop_capture/mouse_cursor_monitor_x11.cc
index 039f9c3..41749bd 100644
--- a/modules/desktop_capture/mouse_cursor_monitor_x11.cc
+++ b/modules/desktop_capture/mouse_cursor_monitor_x11.cc
@@ -12,9 +12,9 @@
#include "modules/desktop_capture/mouse_cursor_monitor.h"
-#include <X11/extensions/Xfixes.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
+#include <X11/extensions/Xfixes.h>
#include "modules/desktop_capture/desktop_capture_options.h"
#include "modules/desktop_capture/desktop_capture_types.h"
@@ -35,7 +35,7 @@
while (true) {
// If the window is in WithdrawnState then look at all of its children.
::Window root, parent;
- ::Window *children;
+ ::Window* children;
unsigned int num_children;
if (!XQueryTree(display, window, &root, &parent, &children,
&num_children)) {
@@ -104,12 +104,9 @@
std::unique_ptr<DesktopFrame> default_cursor(
new BasicDesktopFrame(DesktopSize(kSize, kSize)));
const uint8_t pixels[kSize * kSize] = {
- 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xff, 0xff, 0xff, 0x00,
- 0x00, 0xff, 0xff, 0xff, 0x00,
- 0x00, 0xff, 0xff, 0xff, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00
- };
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff,
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t* ptr = default_cursor->data();
for (int y = 0; y < kSize; ++y) {
for (int x = 0; x < kSize; ++x) {
@@ -228,11 +225,11 @@
XErrorTrap error_trap(display());
img = XFixesGetCursorImage(display());
if (!img || error_trap.GetLastErrorAndDisable() != 0)
- return;
- }
+ return;
+ }
- std::unique_ptr<DesktopFrame> image(
- new BasicDesktopFrame(DesktopSize(img->width, img->height)));
+ std::unique_ptr<DesktopFrame> image(
+ new BasicDesktopFrame(DesktopSize(img->width, img->height)));
// Xlib stores 32-bit data in longs, even if longs are 64-bits long.
unsigned long* src = img->pixels;
@@ -252,7 +249,8 @@
// static
MouseCursorMonitor* MouseCursorMonitor::CreateForWindow(
- const DesktopCaptureOptions& options, WindowId window) {
+ const DesktopCaptureOptions& options,
+ WindowId window) {
if (!options.x_display())
return NULL;
window = GetTopLevelWindow(options.x_display()->display(), window);
diff --git a/modules/desktop_capture/screen_capture_frame_queue.h b/modules/desktop_capture/screen_capture_frame_queue.h
index a9a1643..a5bb595 100644
--- a/modules/desktop_capture/screen_capture_frame_queue.h
+++ b/modules/desktop_capture/screen_capture_frame_queue.h
@@ -16,10 +16,9 @@
#include "rtc_base/constructormagic.h"
// TODO(zijiehe): These headers are not used in this file, but to avoid build
// break in remoting/host. We should add headers in each individual files.
-#include "modules/desktop_capture/desktop_frame.h" // Remove
+#include "modules/desktop_capture/desktop_frame.h" // Remove
#include "modules/desktop_capture/shared_desktop_frame.h" // Remove
-
namespace webrtc {
// Represents a queue of reusable video frames. Provides access to the 'current'
@@ -43,9 +42,7 @@
// Moves to the next frame in the queue, moving the 'current' frame to become
// the 'previous' one.
- void MoveToNextFrame() {
- current_ = (current_ + 1) % kQueueLength;
- }
+ void MoveToNextFrame() { current_ = (current_ + 1) % kQueueLength; }
// Replaces the current frame with a new one allocated by the caller. The
// existing frame (if any) is destroyed. Takes ownership of |frame|.
@@ -62,9 +59,7 @@
current_ = 0;
}
- FrameType* current_frame() const {
- return frames_[current_].get();
- }
+ FrameType* current_frame() const { return frames_[current_].get(); }
FrameType* previous_frame() const {
return frames_[(current_ + kQueueLength - 1) % kQueueLength].get();
diff --git a/modules/desktop_capture/screen_capturer_helper.cc b/modules/desktop_capture/screen_capturer_helper.cc
index 4e4635e..2e4fef8 100644
--- a/modules/desktop_capture/screen_capturer_helper.cc
+++ b/modules/desktop_capture/screen_capturer_helper.cc
@@ -16,12 +16,9 @@
namespace webrtc {
ScreenCapturerHelper::ScreenCapturerHelper()
- : invalid_region_lock_(RWLockWrapper::CreateRWLock()),
- log_grid_size_(0) {
-}
+ : invalid_region_lock_(RWLockWrapper::CreateRWLock()), log_grid_size_(0) {}
-ScreenCapturerHelper::~ScreenCapturerHelper() {
-}
+ScreenCapturerHelper::~ScreenCapturerHelper() {}
void ScreenCapturerHelper::ClearInvalidRegion() {
WriteLockScoped scoped_invalid_region_lock(*invalid_region_lock_);
@@ -39,8 +36,7 @@
invalid_region_.AddRect(DesktopRect::MakeSize(size));
}
-void ScreenCapturerHelper::TakeInvalidRegion(
- DesktopRegion* invalid_region) {
+void ScreenCapturerHelper::TakeInvalidRegion(DesktopRegion* invalid_region) {
invalid_region->Clear();
{
@@ -65,8 +61,7 @@
return size_most_recent_;
}
-void ScreenCapturerHelper::set_size_most_recent(
- const DesktopSize& size) {
+void ScreenCapturerHelper::set_size_most_recent(const DesktopSize& size) {
size_most_recent_ = size;
}
diff --git a/modules/desktop_capture/screen_capturer_helper_unittest.cc b/modules/desktop_capture/screen_capturer_helper_unittest.cc
index f2944ab..1ce4959 100644
--- a/modules/desktop_capture/screen_capturer_helper_unittest.cc
+++ b/modules/desktop_capture/screen_capturer_helper_unittest.cc
@@ -55,8 +55,7 @@
TEST_F(ScreenCapturerHelperTest, SizeMostRecent) {
EXPECT_TRUE(capturer_helper_.size_most_recent().is_empty());
capturer_helper_.set_size_most_recent(DesktopSize(12, 34));
- EXPECT_TRUE(
- DesktopSize(12, 34).equals(capturer_helper_.size_most_recent()));
+ EXPECT_TRUE(DesktopSize(12, 34).equals(capturer_helper_.size_most_recent()));
}
TEST_F(ScreenCapturerHelperTest, SetLogGridSize) {
@@ -103,7 +102,8 @@
EXPECT_TRUE(DesktopRegion(DesktopRect::MakeXYWH(7, 7, 1, 1)).Equals(region));
}
-void TestExpandRegionToGrid(const DesktopRegion& region, int log_grid_size,
+void TestExpandRegionToGrid(const DesktopRegion& region,
+ int log_grid_size,
const DesktopRegion& expanded_region_expected) {
DesktopRegion expanded_region1;
ScreenCapturerHelper::ExpandToGrid(region, log_grid_size, &expanded_region1);
@@ -115,9 +115,15 @@
EXPECT_TRUE(expanded_region1.Equals(expanded_region2));
}
-void TestExpandRectToGrid(int l, int t, int r, int b, int log_grid_size,
- int lExpanded, int tExpanded,
- int rExpanded, int bExpanded) {
+void TestExpandRectToGrid(int l,
+ int t,
+ int r,
+ int b,
+ int log_grid_size,
+ int lExpanded,
+ int tExpanded,
+ int rExpanded,
+ int bExpanded) {
TestExpandRegionToGrid(DesktopRegion(DesktopRect::MakeLTRB(l, t, r, b)),
log_grid_size,
DesktopRegion(DesktopRect::MakeLTRB(
@@ -131,23 +137,23 @@
int x = i * kGridSize;
for (int j = -2; j <= 2; j++) {
int y = j * kGridSize;
- TestExpandRectToGrid(x + 0, y + 0, x + 1, y + 1, kLogGridSize,
- x + 0, y + 0, x + kGridSize, y + kGridSize);
+ TestExpandRectToGrid(x + 0, y + 0, x + 1, y + 1, kLogGridSize, x + 0,
+ y + 0, x + kGridSize, y + kGridSize);
TestExpandRectToGrid(x + 0, y + kGridSize - 1, x + 1, y + kGridSize,
- kLogGridSize,
- x + 0, y + 0, x + kGridSize, y + kGridSize);
- TestExpandRectToGrid(x + kGridSize - 1, y + kGridSize - 1,
- x + kGridSize, y + kGridSize, kLogGridSize,
- x + 0, y + 0, x + kGridSize, y + kGridSize);
- TestExpandRectToGrid(x + kGridSize - 1, y + 0,
- x + kGridSize, y + 1, kLogGridSize,
- x + 0, y + 0, x + kGridSize, y + kGridSize);
+ kLogGridSize, x + 0, y + 0, x + kGridSize,
+ y + kGridSize);
+ TestExpandRectToGrid(x + kGridSize - 1, y + kGridSize - 1, x + kGridSize,
+ y + kGridSize, kLogGridSize, x + 0, y + 0,
+ x + kGridSize, y + kGridSize);
+ TestExpandRectToGrid(x + kGridSize - 1, y + 0, x + kGridSize, y + 1,
+ kLogGridSize, x + 0, y + 0, x + kGridSize,
+ y + kGridSize);
TestExpandRectToGrid(x - 1, y + 0, x + 1, y + 1, kLogGridSize,
x - kGridSize, y + 0, x + kGridSize, y + kGridSize);
TestExpandRectToGrid(x - 1, y - 1, x + 1, y + 0, kLogGridSize,
x - kGridSize, y - kGridSize, x + kGridSize, y);
- TestExpandRectToGrid(x + 0, y - 1, x + 1, y + 1, kLogGridSize,
- x, y - kGridSize, x + kGridSize, y + kGridSize);
+ TestExpandRectToGrid(x + 0, y - 1, x + 1, y + 1, kLogGridSize, x,
+ y - kGridSize, x + kGridSize, y + kGridSize);
TestExpandRectToGrid(x - 1, y - 1, x + 0, y + 1, kLogGridSize,
x - kGridSize, y - kGridSize, x, y + kGridSize);
@@ -164,18 +170,18 @@
}
if (q != 1) {
region.AddRect(DesktopRect::MakeXYWH(x, y - 1, 1, 1));
- expanded_region_expected.AddRect(DesktopRect::MakeXYWH(
- x, y - kGridSize, kGridSize, kGridSize));
+ expanded_region_expected.AddRect(
+ DesktopRect::MakeXYWH(x, y - kGridSize, kGridSize, kGridSize));
}
if (q != 2) {
region.AddRect(DesktopRect::MakeXYWH(x - 1, y, 1, 1));
- expanded_region_expected.AddRect(DesktopRect::MakeXYWH(
- x - kGridSize, y, kGridSize, kGridSize));
+ expanded_region_expected.AddRect(
+ DesktopRect::MakeXYWH(x - kGridSize, y, kGridSize, kGridSize));
}
if (q != 3) {
region.AddRect(DesktopRect::MakeXYWH(x, y, 1, 1));
- expanded_region_expected.AddRect(DesktopRect::MakeXYWH(
- x, y, kGridSize, kGridSize));
+ expanded_region_expected.AddRect(
+ DesktopRect::MakeXYWH(x, y, kGridSize, kGridSize));
}
TestExpandRegionToGrid(region, kLogGridSize, expanded_region_expected);
diff --git a/modules/desktop_capture/screen_capturer_integration_test.cc b/modules/desktop_capture/screen_capturer_integration_test.cc
index 0104a56..fdcf67b 100644
--- a/modules/desktop_capture/screen_capturer_integration_test.cc
+++ b/modules/desktop_capture/screen_capturer_integration_test.cc
@@ -89,8 +89,8 @@
void TestCaptureUpdatedRegion(
std::initializer_list<DesktopCapturer*> capturers) {
RTC_DCHECK(capturers.size() > 0);
- // A large enough area for the tests, which should be able to be fulfilled
- // by most systems.
+// A large enough area for the tests, which should be able to be fulfilled
+// by most systems.
#if defined(WEBRTC_WIN)
// On Windows, an interesting warning window may pop up randomly. The root
// cause is still under investigation, so reduce the test area to work
@@ -212,8 +212,8 @@
return;
}
- if (ArePixelsColoredBy(
- *frame, rect, color, drawer->MayDrawIncompleteShapes())) {
+ if (ArePixelsColoredBy(*frame, rect, color,
+ drawer->MayDrawIncompleteShapes())) {
capturers[j] = nullptr;
succeeded_capturers++;
}
@@ -222,17 +222,15 @@
// been resolved.
else if (i == wait_capture_round - 1) {
std::string result;
- rtc::Base64::EncodeFromArray(frame->data(),
- frame->size().height() * frame->stride(),
- &result);
+ rtc::Base64::EncodeFromArray(
+ frame->data(), frame->size().height() * frame->stride(), &result);
std::cout << frame->size().width() << " x " << frame->size().height()
<< std::endl;
// Split the entire string (can be over 4M) into several lines to
// avoid browser from sticking.
static const size_t kLineLength = 32768;
const char* result_end = result.c_str() + result.length();
- for (const char* it = result.c_str();
- it < result_end;
+ for (const char* it = result.c_str(); it < result_end;
it += kLineLength) {
const size_t max_length = result_end - it;
std::cout << std::string(it, std::min(kLineLength, max_length))
diff --git a/modules/desktop_capture/screen_capturer_mac_unittest.cc b/modules/desktop_capture/screen_capturer_mac_unittest.cc
index 00d2d02..812f230 100644
--- a/modules/desktop_capture/screen_capturer_mac_unittest.cc
+++ b/modules/desktop_capture/screen_capturer_mac_unittest.cc
@@ -13,8 +13,8 @@
#include <memory>
#include <ostream>
-#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_capture_options.h"
+#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_frame.h"
#include "modules/desktop_capture/desktop_geometry.h"
#include "modules/desktop_capture/desktop_region.h"
diff --git a/modules/desktop_capture/screen_capturer_unittest.cc b/modules/desktop_capture/screen_capturer_unittest.cc
index 9ed4f4c..0264867 100644
--- a/modules/desktop_capture/screen_capturer_unittest.cc
+++ b/modules/desktop_capture/screen_capturer_unittest.cc
@@ -73,12 +73,9 @@
class FakeSharedMemory : public SharedMemory {
public:
FakeSharedMemory(char* buffer, size_t size)
- : SharedMemory(buffer, size, 0, kTestSharedMemoryId),
- buffer_(buffer) {
- }
- virtual ~FakeSharedMemory() {
- delete[] buffer_;
- }
+ : SharedMemory(buffer, size, 0, kTestSharedMemoryId), buffer_(buffer) {}
+ virtual ~FakeSharedMemory() { delete[] buffer_; }
+
private:
char* buffer_;
RTC_DISALLOW_COPY_AND_ASSIGN(FakeSharedMemory);
diff --git a/modules/desktop_capture/screen_capturer_win.cc b/modules/desktop_capture/screen_capturer_win.cc
index ecdc48e..be6d8a5 100644
--- a/modules/desktop_capture/screen_capturer_win.cc
+++ b/modules/desktop_capture/screen_capturer_win.cc
@@ -12,8 +12,8 @@
#include <utility>
#include "modules/desktop_capture/blank_detector_desktop_capturer_wrapper.h"
-#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_capture_options.h"
+#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/fallback_desktop_capturer_wrapper.h"
#include "modules/desktop_capture/rgba_color.h"
#include "modules/desktop_capture/win/screen_capturer_win_directx.h"
@@ -25,8 +25,7 @@
namespace {
std::unique_ptr<DesktopCapturer> CreateScreenCapturerWinDirectx() {
- std::unique_ptr<DesktopCapturer> capturer(
- new ScreenCapturerWinDirectx());
+ std::unique_ptr<DesktopCapturer> capturer(new ScreenCapturerWinDirectx());
capturer.reset(new BlankDetectorDesktopCapturerWrapper(
std::move(capturer), RgbaColor(0, 0, 0, 0)));
return capturer;
diff --git a/modules/desktop_capture/screen_capturer_x11.cc b/modules/desktop_capture/screen_capturer_x11.cc
index 5b099ca..e95fccc 100644
--- a/modules/desktop_capture/screen_capturer_x11.cc
+++ b/modules/desktop_capture/screen_capturer_x11.cc
@@ -14,10 +14,10 @@
#include <set>
#include <utility>
-#include <X11/extensions/Xdamage.h>
-#include <X11/extensions/Xfixes.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
+#include <X11/extensions/Xdamage.h>
+#include <X11/extensions/Xfixes.h>
#include "modules/desktop_capture/desktop_capture_options.h"
#include "modules/desktop_capture/desktop_capturer.h"
@@ -128,8 +128,8 @@
ScreenCapturerLinux::~ScreenCapturerLinux() {
options_.x_display()->RemoveEventHandler(ConfigureNotify, this);
if (use_damage_) {
- options_.x_display()->RemoveEventHandler(
- damage_event_base_ + XDamageNotify, this);
+ options_.x_display()->RemoveEventHandler(damage_event_base_ + XDamageNotify,
+ this);
}
DeinitXlib();
}
@@ -197,8 +197,8 @@
// properly.
// Request notifications every time the screen becomes damaged.
- damage_handle_ = XDamageCreate(display(), root_window_,
- XDamageReportNonEmpty);
+ damage_handle_ =
+ XDamageCreate(display(), root_window_, XDamageReportNonEmpty);
if (!damage_handle_) {
RTC_LOG(LS_ERROR) << "Unable to initialize XDamage.";
return;
@@ -212,8 +212,8 @@
return;
}
- options_.x_display()->AddEventHandler(
- damage_event_base_ + XDamageNotify, this);
+ options_.x_display()->AddEventHandler(damage_event_base_ + XDamageNotify,
+ this);
use_damage_ = true;
RTC_LOG(LS_INFO) << "Using XDamage extension.";
@@ -240,10 +240,10 @@
// reinitializes |x_server_pixel_buffer_|. Check if the pixel buffer is still
// in a good shape.
if (!x_server_pixel_buffer_.is_initialized()) {
- // We failed to initialize pixel buffer.
- RTC_LOG(LS_ERROR) << "Pixel buffer is not initialized.";
- callback_->OnCaptureResult(Result::ERROR_PERMANENT, nullptr);
- return;
+ // We failed to initialize pixel buffer.
+ RTC_LOG(LS_ERROR) << "Pixel buffer is not initialized.";
+ callback_->OnCaptureResult(Result::ERROR_PERMANENT, nullptr);
+ return;
}
// If the current frame is from an older generation then allocate a new one.
@@ -336,8 +336,8 @@
updated_region->IntersectWith(
DesktopRect::MakeSize(x_server_pixel_buffer_.window_size()));
- for (DesktopRegion::Iterator it(*updated_region);
- !it.IsAtEnd(); it.Advance()) {
+ for (DesktopRegion::Iterator it(*updated_region); !it.IsAtEnd();
+ it.Advance()) {
if (!x_server_pixel_buffer_.CaptureRect(it.rect(), frame.get()))
return nullptr;
}
@@ -379,8 +379,8 @@
DesktopFrame* current = queue_.current_frame();
DesktopFrame* last = queue_.previous_frame();
RTC_DCHECK(current != last);
- for (DesktopRegion::Iterator it(last_invalid_region_);
- !it.IsAtEnd(); it.Advance()) {
+ for (DesktopRegion::Iterator it(last_invalid_region_); !it.IsAtEnd();
+ it.Advance()) {
current->CopyPixelsFrom(*last, it.rect().top_left(), it.rect());
}
}
diff --git a/modules/desktop_capture/screen_drawer.h b/modules/desktop_capture/screen_drawer.h
index 89dfd66..0f4ee25 100644
--- a/modules/desktop_capture/screen_drawer.h
+++ b/modules/desktop_capture/screen_drawer.h
@@ -15,9 +15,9 @@
#include <memory>
-#include "modules/desktop_capture/rgba_color.h"
#include "modules/desktop_capture/desktop_capture_types.h"
#include "modules/desktop_capture/desktop_geometry.h"
+#include "modules/desktop_capture/rgba_color.h"
namespace webrtc {
diff --git a/modules/desktop_capture/screen_drawer_linux.cc b/modules/desktop_capture/screen_drawer_linux.cc
index cbd8ba8..cbd19a9 100644
--- a/modules/desktop_capture/screen_drawer_linux.cc
+++ b/modules/desktop_capture/screen_drawer_linux.cc
@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include <string.h>
#include <X11/Xlib.h>
+#include <string.h>
#include <memory>
diff --git a/modules/desktop_capture/screen_drawer_unittest.cc b/modules/desktop_capture/screen_drawer_unittest.cc
index 349edbc..71429c5 100644
--- a/modules/desktop_capture/screen_drawer_unittest.cc
+++ b/modules/desktop_capture/screen_drawer_unittest.cc
@@ -10,15 +10,15 @@
#include "modules/desktop_capture/screen_drawer.h"
-#include <atomic>
#include <stdint.h>
+#include <atomic>
#include "rtc_base/checks.h"
#include "rtc_base/function_view.h"
#include "rtc_base/logging.h"
-#include "rtc_base/random.h"
#include "rtc_base/platform_thread.h"
#include "rtc_base/ptr_util.h"
+#include "rtc_base/random.h"
#include "rtc_base/timeutils.h"
#include "system_wrappers/include/sleep.h"
#include "test/gtest.h"
@@ -45,9 +45,7 @@
Task(std::atomic<bool>* created,
const std::atomic<bool>& ready,
rtc::FunctionView<std::unique_ptr<ScreenDrawerLock>()> ctor)
- : created_(created),
- ready_(ready),
- ctor_(ctor) {}
+ : created_(created), ready_(ready), ctor_(ctor) {}
~Task() = default;
@@ -85,7 +83,8 @@
// Wait for the first lock in Task::RunTask() to be created.
// TODO(zijiehe): Find a better solution to wait for the creation of the first
- // lock. See https://chromium-review.googlesource.com/c/607688/13/webrtc/modules/desktop_capture/screen_drawer_unittest.cc
+ // lock. See
+ // https://chromium-review.googlesource.com/c/607688/13/webrtc/modules/desktop_capture/screen_drawer_unittest.cc
while (!created.load()) {
SleepMs(1);
}
@@ -152,9 +151,7 @@
return rtc::MakeUnique<ScreenDrawerLockPosix>(semaphore_name);
});
#elif defined(WEBRTC_WIN)
- TestScreenDrawerLock([]() {
- return ScreenDrawerLock::Create();
- });
+ TestScreenDrawerLock([]() { return ScreenDrawerLock::Create(); });
#endif
}
diff --git a/modules/desktop_capture/shared_memory.cc b/modules/desktop_capture/shared_memory.cc
index fcbdd54..b4ff78b 100644
--- a/modules/desktop_capture/shared_memory.cc
+++ b/modules/desktop_capture/shared_memory.cc
@@ -19,10 +19,6 @@
#endif
SharedMemory::SharedMemory(void* data, size_t size, Handle handle, int id)
- : data_(data),
- size_(size),
- handle_(handle),
- id_(id) {
-}
+ : data_(data), size_(size), handle_(handle), id_(id) {}
} // namespace webrtc
diff --git a/modules/desktop_capture/shared_memory.h b/modules/desktop_capture/shared_memory.h
index dc72b29..3bafa0b 100644
--- a/modules/desktop_capture/shared_memory.h
+++ b/modules/desktop_capture/shared_memory.h
@@ -80,4 +80,3 @@
} // namespace webrtc
#endif // MODULES_DESKTOP_CAPTURE_SHARED_MEMORY_H_
-
diff --git a/modules/desktop_capture/test_utils.cc b/modules/desktop_capture/test_utils.cc
index 0a4749a..81473ee 100644
--- a/modules/desktop_capture/test_utils.cc
+++ b/modules/desktop_capture/test_utils.cc
@@ -34,8 +34,7 @@
const uint8_t* left_array = left.data();
const uint8_t* right_array = right.data();
for (int i = 0; i < left.size().height(); i++) {
- if (memcmp(left_array,
- right_array,
+ if (memcmp(left_array, right_array,
DesktopFrame::kBytesPerPixel * left.size().width()) != 0) {
return false;
}
diff --git a/modules/desktop_capture/win/cursor.cc b/modules/desktop_capture/win/cursor.cc
index 38dc02b..dfce5fb 100644
--- a/modules/desktop_capture/win/cursor.cc
+++ b/modules/desktop_capture/win/cursor.cc
@@ -26,19 +26,15 @@
#if defined(WEBRTC_ARCH_LITTLE_ENDIAN)
-#define RGBA(r, g, b, a) \
- ((((a) << 24) & 0xff000000) | \
- (((b) << 16) & 0xff0000) | \
- (((g) << 8) & 0xff00) | \
- ((r) & 0xff))
+#define RGBA(r, g, b, a) \
+ ((((a) << 24) & 0xff000000) | (((b) << 16) & 0xff0000) | \
+ (((g) << 8) & 0xff00) | ((r)&0xff))
#else // !defined(WEBRTC_ARCH_LITTLE_ENDIAN)
-#define RGBA(r, g, b, a) \
- ((((r) << 24) & 0xff000000) | \
- (((g) << 16) & 0xff0000) | \
- (((b) << 8) & 0xff00) | \
- ((a) & 0xff))
+#define RGBA(r, g, b, a) \
+ ((((r) << 24) & 0xff000000) | (((g) << 16) & 0xff0000) | \
+ (((b) << 8) & 0xff00) | ((a)&0xff))
#endif // !defined(WEBRTC_ARCH_LITTLE_ENDIAN)
@@ -149,13 +145,8 @@
bmi.bV5AlphaMask = 0xff000000;
bmi.bV5CSType = LCS_WINDOWS_COLOR_SPACE;
bmi.bV5Intent = LCS_GM_BUSINESS;
- if (!GetDIBits(dc,
- scoped_mask,
- 0,
- height,
- mask_data.get(),
- reinterpret_cast<BITMAPINFO*>(&bmi),
- DIB_RGB_COLORS)) {
+ if (!GetDIBits(dc, scoped_mask, 0, height, mask_data.get(),
+ reinterpret_cast<BITMAPINFO*>(&bmi), DIB_RGB_COLORS)) {
RTC_LOG_F(LS_ERROR) << "Unable to get bitmap bits. Error = "
<< GetLastError();
return NULL;
@@ -169,13 +160,8 @@
if (is_color) {
image.reset(new BasicDesktopFrame(DesktopSize(width, height)));
// Get the pixels from the color bitmap.
- if (!GetDIBits(dc,
- scoped_color,
- 0,
- height,
- image->data(),
- reinterpret_cast<BITMAPINFO*>(&bmi),
- DIB_RGB_COLORS)) {
+ if (!GetDIBits(dc, scoped_color, 0, height, image->data(),
+ reinterpret_cast<BITMAPINFO*>(&bmi), DIB_RGB_COLORS)) {
RTC_LOG_F(LS_ERROR) << "Unable to get bitmap bits. Error = "
<< GetLastError();
return NULL;
@@ -194,8 +180,8 @@
image.reset(new BasicDesktopFrame(DesktopSize(width, height)));
// The XOR mask becomes the color bitmap.
- memcpy(
- image->data(), mask_plane + (width * height), image->stride() * height);
+ memcpy(image->data(), mask_plane + (width * height),
+ image->stride() * height);
}
// Reconstruct transparency from the mask if the color image does not has
@@ -232,8 +218,8 @@
}
}
if (add_outline) {
- AddCursorOutline(
- width, height, reinterpret_cast<uint32_t*>(image->data()));
+ AddCursorOutline(width, height,
+ reinterpret_cast<uint32_t*>(image->data()));
}
}
@@ -241,8 +227,7 @@
// images.
AlphaMul(reinterpret_cast<uint32_t*>(image->data()), width, height);
- return new MouseCursor(
- image.release(), DesktopVector(hotspot_x, hotspot_y));
+ return new MouseCursor(image.release(), DesktopVector(hotspot_x, hotspot_y));
}
} // namespace webrtc
diff --git a/modules/desktop_capture/win/cursor_unittest.cc b/modules/desktop_capture/win/cursor_unittest.cc
index 368a3da..ff7b6bf 100644
--- a/modules/desktop_capture/win/cursor_unittest.cc
+++ b/modules/desktop_capture/win/cursor_unittest.cc
@@ -74,17 +74,17 @@
} // namespace
TEST(MouseCursorTest, MatchCursors) {
- EXPECT_TRUE(ConvertToMouseShapeAndCompare(IDD_CURSOR1_24BPP,
- IDD_CURSOR1_32BPP));
+ EXPECT_TRUE(
+ ConvertToMouseShapeAndCompare(IDD_CURSOR1_24BPP, IDD_CURSOR1_32BPP));
- EXPECT_TRUE(ConvertToMouseShapeAndCompare(IDD_CURSOR1_8BPP,
- IDD_CURSOR1_32BPP));
+ EXPECT_TRUE(
+ ConvertToMouseShapeAndCompare(IDD_CURSOR1_8BPP, IDD_CURSOR1_32BPP));
- EXPECT_TRUE(ConvertToMouseShapeAndCompare(IDD_CURSOR2_1BPP,
- IDD_CURSOR2_32BPP));
+ EXPECT_TRUE(
+ ConvertToMouseShapeAndCompare(IDD_CURSOR2_1BPP, IDD_CURSOR2_32BPP));
- EXPECT_TRUE(ConvertToMouseShapeAndCompare(IDD_CURSOR3_4BPP,
- IDD_CURSOR3_32BPP));
+ EXPECT_TRUE(
+ ConvertToMouseShapeAndCompare(IDD_CURSOR3_4BPP, IDD_CURSOR3_32BPP));
}
} // namespace webrtc
diff --git a/modules/desktop_capture/win/cursor_unittest_resources.h b/modules/desktop_capture/win/cursor_unittest_resources.h
index 043103d..f583554 100644
--- a/modules/desktop_capture/win/cursor_unittest_resources.h
+++ b/modules/desktop_capture/win/cursor_unittest_resources.h
@@ -11,14 +11,14 @@
#ifndef MODULES_DESKTOP_CAPTURE_WIN_CURSOR_UNITTEST_RESOURCES_H_
#define MODULES_DESKTOP_CAPTURE_WIN_CURSOR_UNITTEST_RESOURCES_H_
-#define IDD_CURSOR1_24BPP 101
-#define IDD_CURSOR1_32BPP 102
-#define IDD_CURSOR1_8BPP 103
+#define IDD_CURSOR1_24BPP 101
+#define IDD_CURSOR1_32BPP 102
+#define IDD_CURSOR1_8BPP 103
-#define IDD_CURSOR2_1BPP 104
-#define IDD_CURSOR2_32BPP 105
+#define IDD_CURSOR2_1BPP 104
+#define IDD_CURSOR2_32BPP 105
-#define IDD_CURSOR3_4BPP 106
-#define IDD_CURSOR3_32BPP 107
+#define IDD_CURSOR3_4BPP 106
+#define IDD_CURSOR3_32BPP 107
#endif // MODULES_DESKTOP_CAPTURE_WIN_CURSOR_UNITTEST_RESOURCES_H_
diff --git a/modules/desktop_capture/win/d3d_device.cc b/modules/desktop_capture/win/d3d_device.cc
index c2b78c1..b220b13 100644
--- a/modules/desktop_capture/win/d3d_device.cc
+++ b/modules/desktop_capture/win/d3d_device.cc
@@ -69,8 +69,9 @@
// static
std::vector<D3dDevice> D3dDevice::EnumDevices() {
ComPtr<IDXGIFactory1> factory;
- _com_error error = CreateDXGIFactory1(__uuidof(IDXGIFactory1),
- reinterpret_cast<void**>(factory.GetAddressOf()));
+ _com_error error =
+ CreateDXGIFactory1(__uuidof(IDXGIFactory1),
+ reinterpret_cast<void**>(factory.GetAddressOf()));
if (error.Error() != S_OK || !factory) {
RTC_LOG(LS_WARNING) << "Cannot create IDXGIFactory1.";
return std::vector<D3dDevice>();
diff --git a/modules/desktop_capture/win/d3d_device.h b/modules/desktop_capture/win/d3d_device.h
index 8f545d3..b40279c 100644
--- a/modules/desktop_capture/win/d3d_device.h
+++ b/modules/desktop_capture/win/d3d_device.h
@@ -11,10 +11,10 @@
#ifndef MODULES_DESKTOP_CAPTURE_WIN_D3D_DEVICE_H_
#define MODULES_DESKTOP_CAPTURE_WIN_D3D_DEVICE_H_
-#include <comdef.h>
-#include <wrl/client.h>
#include <D3D11.h>
#include <DXGI.h>
+#include <comdef.h>
+#include <wrl/client.h>
#include <vector>
diff --git a/modules/desktop_capture/win/desktop.cc b/modules/desktop_capture/win/desktop.cc
index 34842b3..459b6fe 100644
--- a/modules/desktop_capture/win/desktop.cc
+++ b/modules/desktop_capture/win/desktop.cc
@@ -16,8 +16,7 @@
namespace webrtc {
-Desktop::Desktop(HDESK desktop, bool own) : desktop_(desktop), own_(own) {
-}
+Desktop::Desktop(HDESK desktop, bool own) : desktop_(desktop), own_(own) {}
Desktop::~Desktop() {
if (own_ && desktop_ != NULL) {
@@ -72,10 +71,10 @@
}
Desktop* Desktop::GetDesktop(const WCHAR* desktop_name) {
- ACCESS_MASK desired_access =
- DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW | DESKTOP_ENUMERATE |
- DESKTOP_HOOKCONTROL | DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS |
- DESKTOP_SWITCHDESKTOP | GENERIC_WRITE;
+ ACCESS_MASK desired_access = DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW |
+ DESKTOP_ENUMERATE | DESKTOP_HOOKCONTROL |
+ DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS |
+ DESKTOP_SWITCHDESKTOP | GENERIC_WRITE;
HDESK desktop = OpenDesktop(desktop_name, 0, FALSE, desired_access);
if (desktop == NULL) {
RTC_LOG(LS_ERROR) << "Failed to open the desktop '" << desktop_name
diff --git a/modules/desktop_capture/win/dxgi_adapter_duplicator.cc b/modules/desktop_capture/win/dxgi_adapter_duplicator.cc
index c4cd982..81354fb 100644
--- a/modules/desktop_capture/win/dxgi_adapter_duplicator.cc
+++ b/modules/desktop_capture/win/dxgi_adapter_duplicator.cc
@@ -10,8 +10,8 @@
#include "modules/desktop_capture/win/dxgi_adapter_duplicator.h"
-#include <comdef.h>
#include <DXGI.h>
+#include <comdef.h>
#include <algorithm>
diff --git a/modules/desktop_capture/win/dxgi_context.cc b/modules/desktop_capture/win/dxgi_context.cc
index 6b4649e..6a679cb 100644
--- a/modules/desktop_capture/win/dxgi_context.cc
+++ b/modules/desktop_capture/win/dxgi_context.cc
@@ -14,8 +14,8 @@
namespace webrtc {
DxgiAdapterContext::DxgiAdapterContext() = default;
-DxgiAdapterContext::DxgiAdapterContext(
- const DxgiAdapterContext& context) = default;
+DxgiAdapterContext::DxgiAdapterContext(const DxgiAdapterContext& context) =
+ default;
DxgiAdapterContext::~DxgiAdapterContext() = default;
DxgiFrameContext::DxgiFrameContext() = default;
diff --git a/modules/desktop_capture/win/dxgi_duplicator_controller.cc b/modules/desktop_capture/win/dxgi_duplicator_controller.cc
index 2da12a6..2029811 100644
--- a/modules/desktop_capture/win/dxgi_duplicator_controller.cc
+++ b/modules/desktop_capture/win/dxgi_duplicator_controller.cc
@@ -67,8 +67,7 @@
return session_id != 0;
}
-DxgiDuplicatorController::DxgiDuplicatorController()
- : refcount_(0) {}
+DxgiDuplicatorController::DxgiDuplicatorController() : refcount_(0) {}
void DxgiDuplicatorController::AddRef() {
int refcount = (++refcount_);
@@ -104,13 +103,14 @@
return result;
}
-DxgiDuplicatorController::Result
-DxgiDuplicatorController::Duplicate(DxgiFrame* frame) {
+DxgiDuplicatorController::Result DxgiDuplicatorController::Duplicate(
+ DxgiFrame* frame) {
return DoDuplicate(frame, -1);
}
-DxgiDuplicatorController::Result
-DxgiDuplicatorController::DuplicateMonitor(DxgiFrame* frame, int monitor_id) {
+DxgiDuplicatorController::Result DxgiDuplicatorController::DuplicateMonitor(
+ DxgiFrame* frame,
+ int monitor_id) {
RTC_DCHECK_GE(monitor_id, 0);
return DoDuplicate(frame, monitor_id);
}
@@ -141,8 +141,9 @@
return false;
}
-DxgiDuplicatorController::Result
-DxgiDuplicatorController::DoDuplicate(DxgiFrame* frame, int monitor_id) {
+DxgiDuplicatorController::Result DxgiDuplicatorController::DoDuplicate(
+ DxgiFrame* frame,
+ int monitor_id) {
RTC_DCHECK(frame);
rtc::CritScope lock(&lock_);
@@ -443,8 +444,8 @@
// |fallback_frame|.
shared_frame = target;
} else {
- fallback_frame = SharedDesktopFrame::Wrap(std::unique_ptr<DesktopFrame>(
- new BasicDesktopFrame(desktop_size())));
+ fallback_frame = SharedDesktopFrame::Wrap(
+ std::unique_ptr<DesktopFrame>(new BasicDesktopFrame(desktop_size())));
shared_frame = fallback_frame.get();
}
@@ -454,8 +455,7 @@
if (GetNumFramesCaptured() > 0) {
// Sleep |ms_per_frame| before capturing next frame to ensure the screen
// has been updated by the video adapter.
- webrtc::SleepMs(
- ms_per_frame - (rtc::TimeMillis() - last_frame_start_ms));
+ webrtc::SleepMs(ms_per_frame - (rtc::TimeMillis() - last_frame_start_ms));
}
last_frame_start_ms = rtc::TimeMillis();
if (!DoDuplicateAll(context, shared_frame)) {
diff --git a/modules/desktop_capture/win/dxgi_frame.cc b/modules/desktop_capture/win/dxgi_frame.cc
index b51fcca..85d708c 100644
--- a/modules/desktop_capture/win/dxgi_frame.cc
+++ b/modules/desktop_capture/win/dxgi_frame.cc
@@ -21,8 +21,7 @@
namespace webrtc {
-DxgiFrame::DxgiFrame(SharedMemoryFactory* factory)
- : factory_(factory) {}
+DxgiFrame::DxgiFrame(SharedMemoryFactory* factory) : factory_(factory) {}
DxgiFrame::~DxgiFrame() = default;
diff --git a/modules/desktop_capture/win/dxgi_frame.h b/modules/desktop_capture/win/dxgi_frame.h
index 49f2320..c87f42e 100644
--- a/modules/desktop_capture/win/dxgi_frame.h
+++ b/modules/desktop_capture/win/dxgi_frame.h
@@ -14,8 +14,8 @@
#include <memory>
#include <vector>
-#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_capture_types.h"
+#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_geometry.h"
#include "modules/desktop_capture/resolution_tracker.h"
#include "modules/desktop_capture/shared_desktop_frame.h"
diff --git a/modules/desktop_capture/win/dxgi_output_duplicator.cc b/modules/desktop_capture/win/dxgi_output_duplicator.cc
index 4675b07..f1f6f42 100644
--- a/modules/desktop_capture/win/dxgi_output_duplicator.cc
+++ b/modules/desktop_capture/win/dxgi_output_duplicator.cc
@@ -12,10 +12,10 @@
#include <string.h>
-#include <unknwn.h>
#include <DXGI.h>
#include <DXGIFormat.h>
#include <Windows.h>
+#include <unknwn.h>
#include <algorithm>
@@ -177,9 +177,7 @@
// context here. The |updated_region| always starts from (0, 0).
DesktopRegion updated_region;
updated_region.Swap(&context->updated_region);
- if (error.Error() == S_OK &&
- frame_info.AccumulatedFrames > 0 &&
- resource) {
+ if (error.Error() == S_OK && frame_info.AccumulatedFrames > 0 && resource) {
DetectUpdatedRegion(frame_info, &context->updated_region);
SpreadContextChange(context);
if (!texture_->CopyFrom(frame_info, resource.Get())) {
@@ -195,8 +193,8 @@
it.Advance()) {
// The |updated_region| returned by Windows is rotated, but the |source|
// frame is not. So we need to rotate it reversely.
- const DesktopRect source_rect = RotateRect(
- it.rect(), desktop_size(), ReverseRotation(rotation_));
+ const DesktopRect source_rect =
+ RotateRect(it.rect(), desktop_size(), ReverseRotation(rotation_));
RotateDesktopFrame(source, source_rect, rotation_, offset, target);
}
} else {
diff --git a/modules/desktop_capture/win/dxgi_output_duplicator.h b/modules/desktop_capture/win/dxgi_output_duplicator.h
index 3f10533..d2a019d 100644
--- a/modules/desktop_capture/win/dxgi_output_duplicator.h
+++ b/modules/desktop_capture/win/dxgi_output_duplicator.h
@@ -11,10 +11,10 @@
#ifndef MODULES_DESKTOP_CAPTURE_WIN_DXGI_OUTPUT_DUPLICATOR_H_
#define MODULES_DESKTOP_CAPTURE_WIN_DXGI_OUTPUT_DUPLICATOR_H_
-#include <comdef.h>
-#include <wrl/client.h>
#include <DXGI.h>
#include <DXGI1_2.h>
+#include <comdef.h>
+#include <wrl/client.h>
#include <memory>
#include <string>
diff --git a/modules/desktop_capture/win/dxgi_texture.cc b/modules/desktop_capture/win/dxgi_texture.cc
index 8f1d034..c8081fb 100644
--- a/modules/desktop_capture/win/dxgi_texture.cc
+++ b/modules/desktop_capture/win/dxgi_texture.cc
@@ -10,9 +10,9 @@
#include "modules/desktop_capture/win/dxgi_texture.h"
+#include <D3D11.h>
#include <comdef.h>
#include <wrl/client.h>
-#include <D3D11.h>
#include "modules/desktop_capture/desktop_region.h"
#include "rtc_base/checks.h"
diff --git a/modules/desktop_capture/win/dxgi_texture_mapping.cc b/modules/desktop_capture/win/dxgi_texture_mapping.cc
index dfe8259..01bcaba 100644
--- a/modules/desktop_capture/win/dxgi_texture_mapping.cc
+++ b/modules/desktop_capture/win/dxgi_texture_mapping.cc
@@ -10,9 +10,9 @@
#include "modules/desktop_capture/win/dxgi_texture_mapping.h"
-#include <comdef.h>
#include <DXGI.h>
#include <DXGI1_2.h>
+#include <comdef.h>
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
diff --git a/modules/desktop_capture/win/dxgi_texture_staging.cc b/modules/desktop_capture/win/dxgi_texture_staging.cc
index e3e9157..f2b3583 100644
--- a/modules/desktop_capture/win/dxgi_texture_staging.cc
+++ b/modules/desktop_capture/win/dxgi_texture_staging.cc
@@ -10,10 +10,10 @@
#include "modules/desktop_capture/win/dxgi_texture_staging.h"
-#include <comdef.h>
-#include <unknwn.h>
#include <DXGI.h>
#include <DXGI1_2.h>
+#include <comdef.h>
+#include <unknwn.h>
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
@@ -45,8 +45,8 @@
AssertStageAndSurfaceAreSameObject();
D3D11_TEXTURE2D_DESC current_desc;
stage_->GetDesc(¤t_desc);
- const bool recreate_needed = (
- memcmp(&desc, ¤t_desc, sizeof(D3D11_TEXTURE2D_DESC)) != 0);
+ const bool recreate_needed =
+ (memcmp(&desc, ¤t_desc, sizeof(D3D11_TEXTURE2D_DESC)) != 0);
RTC_HISTOGRAM_BOOLEAN("WebRTC.DesktopCapture.StagingTextureRecreate",
recreate_needed);
if (!recreate_needed) {
diff --git a/modules/desktop_capture/win/dxgi_texture_staging.h b/modules/desktop_capture/win/dxgi_texture_staging.h
index 65d56ba..998b79f 100644
--- a/modules/desktop_capture/win/dxgi_texture_staging.h
+++ b/modules/desktop_capture/win/dxgi_texture_staging.h
@@ -11,9 +11,9 @@
#ifndef MODULES_DESKTOP_CAPTURE_WIN_DXGI_TEXTURE_STAGING_H_
#define MODULES_DESKTOP_CAPTURE_WIN_DXGI_TEXTURE_STAGING_H_
-#include <wrl/client.h>
#include <D3D11.h>
#include <DXGI1_2.h>
+#include <wrl/client.h>
#include "modules/desktop_capture/desktop_geometry.h"
#include "modules/desktop_capture/desktop_region.h"
diff --git a/modules/desktop_capture/win/scoped_gdi_object.h b/modules/desktop_capture/win/scoped_gdi_object.h
index 60a8b5c..cc6299c 100644
--- a/modules/desktop_capture/win/scoped_gdi_object.h
+++ b/modules/desktop_capture/win/scoped_gdi_object.h
@@ -20,19 +20,15 @@
namespace win {
// Scoper for GDI objects.
-template<class T, class Traits>
+template <class T, class Traits>
class ScopedGDIObject {
public:
ScopedGDIObject() : handle_(NULL) {}
explicit ScopedGDIObject(T object) : handle_(object) {}
- ~ScopedGDIObject() {
- Traits::Close(handle_);
- }
+ ~ScopedGDIObject() { Traits::Close(handle_); }
- T Get() {
- return handle_;
- }
+ T Get() { return handle_; }
void Set(T object) {
if (handle_ && object != handle_)
diff --git a/modules/desktop_capture/win/scoped_thread_desktop.cc b/modules/desktop_capture/win/scoped_thread_desktop.cc
index bbc00ef..22e8e7b 100644
--- a/modules/desktop_capture/win/scoped_thread_desktop.cc
+++ b/modules/desktop_capture/win/scoped_thread_desktop.cc
@@ -15,8 +15,7 @@
namespace webrtc {
ScopedThreadDesktop::ScopedThreadDesktop()
- : initial_(Desktop::GetThreadDesktop()) {
-}
+ : initial_(Desktop::GetThreadDesktop()) {}
ScopedThreadDesktop::~ScopedThreadDesktop() {
Revert();
diff --git a/modules/desktop_capture/win/screen_capture_utils.cc b/modules/desktop_capture/win/screen_capture_utils.cc
index 948adc8..e294497 100644
--- a/modules/desktop_capture/win/screen_capture_utils.cc
+++ b/modules/desktop_capture/win/screen_capture_utils.cc
@@ -95,15 +95,14 @@
DEVMODE device_mode;
device_mode.dmSize = sizeof(device_mode);
device_mode.dmDriverExtra = 0;
- result = EnumDisplaySettingsEx(
- device.DeviceName, ENUM_CURRENT_SETTINGS, &device_mode, 0);
+ result = EnumDisplaySettingsEx(device.DeviceName, ENUM_CURRENT_SETTINGS,
+ &device_mode, 0);
if (!result)
return DesktopRect();
- return DesktopRect::MakeXYWH(device_mode.dmPosition.x,
- device_mode.dmPosition.y,
- device_mode.dmPelsWidth,
- device_mode.dmPelsHeight);
+ return DesktopRect::MakeXYWH(
+ device_mode.dmPosition.x, device_mode.dmPosition.y,
+ device_mode.dmPelsWidth, device_mode.dmPelsHeight);
}
} // namespace webrtc
diff --git a/modules/desktop_capture/win/screen_capture_utils.h b/modules/desktop_capture/win/screen_capture_utils.h
index 2e7d1ff..f494dd2 100644
--- a/modules/desktop_capture/win/screen_capture_utils.h
+++ b/modules/desktop_capture/win/screen_capture_utils.h
@@ -11,8 +11,8 @@
#ifndef MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURE_UTILS_H_
#define MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURE_UTILS_H_
-#include <vector>
#include <string>
+#include <vector>
#include "modules/desktop_capture/desktop_capturer.h"
diff --git a/modules/desktop_capture/win/screen_capture_utils_unittest.cc b/modules/desktop_capture/win/screen_capture_utils_unittest.cc
index b9dbf3d..a71c4f7 100644
--- a/modules/desktop_capture/win/screen_capture_utils_unittest.cc
+++ b/modules/desktop_capture/win/screen_capture_utils_unittest.cc
@@ -10,8 +10,8 @@
#include "modules/desktop_capture/win/screen_capture_utils.h"
-#include <vector>
#include <string>
+#include <vector>
#include "modules/desktop_capture/desktop_capturer.h"
#include "test/gtest.h"
diff --git a/modules/desktop_capture/win/screen_capturer_win_directx.cc b/modules/desktop_capture/win/screen_capturer_win_directx.cc
index 807acc6..0432bfb 100644
--- a/modules/desktop_capture/win/screen_capturer_win_directx.cc
+++ b/modules/desktop_capture/win/screen_capturer_win_directx.cc
@@ -65,14 +65,13 @@
}
for (const auto& device_name : device_names) {
- const auto it = std::find(
- gdi_names.begin(), gdi_names.end(), device_name);
+ const auto it = std::find(gdi_names.begin(), gdi_names.end(), device_name);
if (it == gdi_names.end()) {
// devices_names[i] has not been found in gdi_names, so use max_screen_id.
max_screen_id++;
- screens->push_back({ max_screen_id });
+ screens->push_back({max_screen_id});
} else {
- screens->push_back({ gdi_screens[it - gdi_names.begin()] });
+ screens->push_back({gdi_screens[it - gdi_names.begin()]});
}
}
@@ -132,8 +131,8 @@
if (current_screen_id_ == kFullDesktopScreenId) {
result = controller_->Duplicate(frames_.current_frame());
} else {
- result = controller_->DuplicateMonitor(
- frames_.current_frame(), current_screen_id_);
+ result = controller_->DuplicateMonitor(frames_.current_frame(),
+ current_screen_id_);
}
using DuplicateResult = DxgiDuplicatorController::Result;
@@ -170,9 +169,8 @@
case DuplicateResult::SUCCEEDED: {
std::unique_ptr<DesktopFrame> frame =
frames_.current_frame()->frame()->Share();
- frame->set_capture_time_ms(
- (rtc::TimeNanos() - capture_start_time_nanos) /
- rtc::kNumNanosecsPerMillisec);
+ frame->set_capture_time_ms((rtc::TimeNanos() - capture_start_time_nanos) /
+ rtc::kNumNanosecsPerMillisec);
frame->set_capturer_id(DesktopCapturerId::kScreenCapturerWinDirectx);
callback_->OnCaptureResult(Result::SUCCESS, std::move(frame));
break;
diff --git a/modules/desktop_capture/win/screen_capturer_win_directx_unittest.cc b/modules/desktop_capture/win/screen_capturer_win_directx_unittest.cc
index d07a648..5874cb8 100644
--- a/modules/desktop_capture/win/screen_capturer_win_directx_unittest.cc
+++ b/modules/desktop_capture/win/screen_capturer_win_directx_unittest.cc
@@ -10,8 +10,8 @@
#include "modules/desktop_capture/win/screen_capturer_win_directx.h"
-#include <vector>
#include <string>
+#include <vector>
#include "modules/desktop_capture/desktop_capturer.h"
#include "test/gtest.h"
@@ -22,9 +22,7 @@
// devices in its output, since the device name is missing.
TEST(ScreenCaptureUtilsTest, GetScreenListFromDeviceNamesAndGetIndex) {
const std::vector<std::string> device_names = {
- "\\\\.\\DISPLAY0",
- "\\\\.\\DISPLAY1",
- "\\\\.\\DISPLAY2",
+ "\\\\.\\DISPLAY0", "\\\\.\\DISPLAY1", "\\\\.\\DISPLAY2",
};
DesktopCapturer::SourceList screens;
ASSERT_TRUE(ScreenCapturerWinDirectx::GetScreenListFromDeviceNames(
@@ -32,8 +30,8 @@
ASSERT_EQ(device_names.size(), screens.size());
for (size_t i = 0; i < screens.size(); i++) {
- ASSERT_EQ(ScreenCapturerWinDirectx::GetIndexFromScreenId(
- screens[i].id, device_names),
+ ASSERT_EQ(ScreenCapturerWinDirectx::GetIndexFromScreenId(screens[i].id,
+ device_names),
static_cast<int>(i));
}
}
diff --git a/modules/desktop_capture/win/screen_capturer_win_gdi.cc b/modules/desktop_capture/win/screen_capturer_win_gdi.cc
index 25aa0d1..03f8340 100644
--- a/modules/desktop_capture/win/screen_capturer_win_gdi.cc
+++ b/modules/desktop_capture/win/screen_capturer_win_gdi.cc
@@ -88,14 +88,12 @@
// Emit the current frame.
std::unique_ptr<DesktopFrame> frame = queue_.current_frame()->Share();
- frame->set_dpi(DesktopVector(
- GetDeviceCaps(desktop_dc_, LOGPIXELSX),
- GetDeviceCaps(desktop_dc_, LOGPIXELSY)));
+ frame->set_dpi(DesktopVector(GetDeviceCaps(desktop_dc_, LOGPIXELSX),
+ GetDeviceCaps(desktop_dc_, LOGPIXELSY)));
frame->mutable_updated_region()->SetRect(
DesktopRect::MakeSize(frame->size()));
- frame->set_capture_time_ms(
- (rtc::TimeNanos() - capture_start_time_nanos) /
- rtc::kNumNanosecsPerMillisec);
+ frame->set_capture_time_ms((rtc::TimeNanos() - capture_start_time_nanos) /
+ rtc::kNumNanosecsPerMillisec);
frame->set_capturer_id(DesktopCapturerId::kScreenCapturerWinGdi);
callback_->OnCaptureResult(Result::SUCCESS, std::move(frame));
}
@@ -216,8 +214,8 @@
}
bool result = (BitBlt(memory_dc_, 0, 0, screen_rect.width(),
- screen_rect.height(), desktop_dc_, screen_rect.left(), screen_rect.top(),
- SRCCOPY | CAPTUREBLT) != FALSE);
+ screen_rect.height(), desktop_dc_, screen_rect.left(),
+ screen_rect.top(), SRCCOPY | CAPTUREBLT) != FALSE);
if (!result) {
RTC_LOG_GLE(LS_WARNING) << "BitBlt failed";
}
diff --git a/modules/desktop_capture/win/screen_capturer_win_gdi.h b/modules/desktop_capture/win/screen_capturer_win_gdi.h
index 2e30d59..be4794e 100644
--- a/modules/desktop_capture/win/screen_capturer_win_gdi.h
+++ b/modules/desktop_capture/win/screen_capturer_win_gdi.h
@@ -44,7 +44,7 @@
bool SelectSource(SourceId id) override;
private:
- typedef HRESULT (WINAPI * DwmEnableCompositionFunc)(UINT);
+ typedef HRESULT(WINAPI* DwmEnableCompositionFunc)(UINT);
// Make sure that the device contexts match the screen configuration.
void PrepareCaptureResources();
diff --git a/modules/desktop_capture/win/screen_capturer_win_magnifier.cc b/modules/desktop_capture/win/screen_capturer_win_magnifier.cc
index d52b028..c7b07d1 100644
--- a/modules/desktop_capture/win/screen_capturer_win_magnifier.cc
+++ b/modules/desktop_capture/win/screen_capturer_win_magnifier.cc
@@ -136,8 +136,8 @@
void ScreenCapturerWinMagnifier::SetExcludedWindow(WindowId excluded_window) {
excluded_window_ = (HWND)excluded_window;
if (excluded_window_ && magnifier_initialized_) {
- set_window_filter_list_func_(
- magnifier_window_, MW_FILTERMODE_EXCLUDE, 1, &excluded_window_);
+ set_window_filter_list_func_(magnifier_window_, MW_FILTERMODE_EXCLUDE, 1,
+ &excluded_window_);
}
}
@@ -186,8 +186,7 @@
RECT clipped,
HRGN dirty) {
ScreenCapturerWinMagnifier* owner =
- reinterpret_cast<ScreenCapturerWinMagnifier*>(
- TlsGetValue(GetTlsIndex()));
+ reinterpret_cast<ScreenCapturerWinMagnifier*>(TlsGetValue(GetTlsIndex()));
TlsSetValue(GetTlsIndex(), nullptr);
owner->OnCaptured(srcdata, srcheader);
@@ -243,10 +242,10 @@
}
HMODULE hInstance = nullptr;
- result = GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
- GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
- reinterpret_cast<char*>(&DefWindowProc),
- &hInstance);
+ result =
+ GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
+ GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
+ reinterpret_cast<char*>(&DefWindowProc), &hInstance);
if (!result) {
mag_uninitialize_func_();
RTC_LOG_F(LS_WARNING) << "Failed to initialize ScreenCapturerWinMagnifier: "
@@ -346,8 +345,7 @@
// Copy the data into the frame.
current_frame->CopyPixelsFrom(
- reinterpret_cast<uint8_t*>(data),
- header.stride,
+ reinterpret_cast<uint8_t*>(data), header.stride,
DesktopRect::MakeXYWH(0, 0, header.width, header.height));
magnifier_capture_succeeded_ = true;
diff --git a/modules/desktop_capture/win/screen_capturer_win_magnifier.h b/modules/desktop_capture/win/screen_capturer_win_magnifier.h
index d994b1e..28f29bc 100644
--- a/modules/desktop_capture/win/screen_capturer_win_magnifier.h
+++ b/modules/desktop_capture/win/screen_capturer_win_magnifier.h
@@ -13,9 +13,9 @@
#include <memory>
-#include <windows.h>
#include <magnification.h>
#include <wincodec.h>
+#include <windows.h>
#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/screen_capture_frame_queue.h"
diff --git a/modules/desktop_capture/win/window_capture_utils.cc b/modules/desktop_capture/win/window_capture_utils.cc
index 2190248..4c5489f 100644
--- a/modules/desktop_capture/win/window_capture_utils.cc
+++ b/modules/desktop_capture/win/window_capture_utils.cc
@@ -25,8 +25,7 @@
if (!::GetWindowRect(window, &rect)) {
return false;
}
- *result = DesktopRect::MakeLTRB(
- rect.left, rect.top, rect.right, rect.bottom);
+ *result = DesktopRect::MakeLTRB(rect.left, rect.top, rect.right, rect.bottom);
return true;
}
@@ -97,22 +96,22 @@
}
int GetWindowRegionTypeWithBoundary(HWND window, DesktopRect* result) {
- win::ScopedGDIObject<HRGN, win::DeleteObjectTraits<HRGN>>
- scoped_hrgn(CreateRectRgn(0, 0, 0, 0));
+ win::ScopedGDIObject<HRGN, win::DeleteObjectTraits<HRGN>> scoped_hrgn(
+ CreateRectRgn(0, 0, 0, 0));
const int region_type = GetWindowRgn(window, scoped_hrgn.Get());
if (region_type == SIMPLEREGION) {
RECT rect;
GetRgnBox(scoped_hrgn.Get(), &rect);
- *result = DesktopRect::MakeLTRB(
- rect.left, rect.top, rect.right, rect.bottom);
+ *result =
+ DesktopRect::MakeLTRB(rect.left, rect.top, rect.right, rect.bottom);
}
return region_type;
}
bool GetDcSize(HDC hdc, DesktopSize* size) {
- win::ScopedGDIObject<HGDIOBJ, win::DeleteObjectTraits<HGDIOBJ>>
- scoped_hgdi(GetCurrentObject(hdc, OBJ_BITMAP));
+ win::ScopedGDIObject<HGDIOBJ, win::DeleteObjectTraits<HGDIOBJ>> scoped_hgdi(
+ GetCurrentObject(hdc, OBJ_BITMAP));
BITMAP bitmap;
memset(&bitmap, 0, sizeof(BITMAP));
if (GetObject(scoped_hgdi.Get(), sizeof(BITMAP), &bitmap) == 0) {
diff --git a/modules/desktop_capture/win/window_capture_utils.h b/modules/desktop_capture/win/window_capture_utils.h
index eb4f945..024c7eb 100644
--- a/modules/desktop_capture/win/window_capture_utils.h
+++ b/modules/desktop_capture/win/window_capture_utils.h
@@ -59,7 +59,7 @@
// function returns false if native APIs fail.
bool IsWindowMaximized(HWND window, bool* result);
-typedef HRESULT (WINAPI *DwmIsCompositionEnabledFunc)(BOOL* enabled);
+typedef HRESULT(WINAPI* DwmIsCompositionEnabledFunc)(BOOL* enabled);
class WindowCaptureHelperWin {
public:
WindowCaptureHelperWin();
diff --git a/modules/desktop_capture/window_capturer_unittest.cc b/modules/desktop_capture/window_capturer_unittest.cc
index 0c31fb7..ac51d15 100644
--- a/modules/desktop_capture/window_capturer_unittest.cc
+++ b/modules/desktop_capture/window_capturer_unittest.cc
@@ -10,8 +10,8 @@
#include <memory>
-#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_capture_options.h"
+#include "modules/desktop_capture/desktop_capturer.h"
#include "modules/desktop_capture/desktop_frame.h"
#include "modules/desktop_capture/desktop_region.h"
#include "test/gtest.h"
diff --git a/modules/desktop_capture/window_capturer_win.cc b/modules/desktop_capture/window_capturer_win.cc
index 1b59af6..f345a5e 100644
--- a/modules/desktop_capture/window_capturer_win.cc
+++ b/modules/desktop_capture/window_capturer_win.cc
@@ -104,8 +104,8 @@
}
if (is_maximized) {
- return GetCroppedWindowRect(
- window, drawable_rect, /* original_rect */ nullptr);
+ return GetCroppedWindowRect(window, drawable_rect,
+ /* original_rect */ nullptr);
}
*drawable_rect = *original_rect;
return true;
@@ -198,8 +198,8 @@
bool WindowCapturerWin::IsOccluded(const DesktopVector& pos) {
DesktopVector sys_pos = pos.add(GetFullscreenRect().top_left());
- return reinterpret_cast<HWND>(window_finder_.GetWindowUnderPoint(sys_pos))
- != window_;
+ return reinterpret_cast<HWND>(window_finder_.GetWindowUnderPoint(sys_pos)) !=
+ window_;
}
void WindowCapturerWin::Start(Callback* callback) {
@@ -317,10 +317,8 @@
// Aero is enabled or PrintWindow() failed, use BitBlt.
if (!result) {
result = BitBlt(mem_dc, 0, 0, frame->size().width(), frame->size().height(),
- window_dc,
- cropped_rect.left() - original_rect.left(),
- cropped_rect.top() - original_rect.top(),
- SRCCOPY);
+ window_dc, cropped_rect.left() - original_rect.left(),
+ cropped_rect.top() - original_rect.top(), SRCCOPY);
}
SelectObject(mem_dc, previous_object);
diff --git a/modules/desktop_capture/window_capturer_x11.cc b/modules/desktop_capture/window_capturer_x11.cc
index 5536b6a..c4ca3ae 100644
--- a/modules/desktop_capture/window_capturer_x11.cc
+++ b/modules/desktop_capture/window_capturer_x11.cc
@@ -10,9 +10,9 @@
#include <string.h>
+#include <X11/Xutil.h>
#include <X11/extensions/Xcomposite.h>
#include <X11/extensions/Xrender.h>
-#include <X11/Xutil.h>
#include <utility>
@@ -93,15 +93,14 @@
}
bool WindowCapturerLinux::GetSourceList(SourceList* sources) {
- return GetWindowList(&atom_cache_,
- [this, sources](::Window window) {
- Source w;
- w.id = window;
- if (this->GetWindowTitle(window, &w.title)) {
- sources->push_back(w);
- }
- return true;
- });
+ return GetWindowList(&atom_cache_, [this, sources](::Window window) {
+ Source w;
+ w.id = window;
+ if (this->GetWindowTitle(window, &w.title)) {
+ sources->push_back(w);
+ }
+ return true;
+ });
}
bool WindowCapturerLinux::SelectSource(SourceId id) {
@@ -134,8 +133,8 @@
::Window parent;
::Window root;
// Find the root window to pass event to.
- int status = XQueryTree(
- display(), selected_window_, &root, &parent, &children, &num_children);
+ int status = XQueryTree(display(), selected_window_, &root, &parent,
+ &children, &num_children);
if (status == 0) {
RTC_LOG(LS_ERROR) << "Failed to query for the root window.";
return false;
@@ -164,11 +163,8 @@
memset(xev.xclient.data.l, 0, sizeof(xev.xclient.data.l));
- XSendEvent(display(),
- root,
- False,
- SubstructureRedirectMask | SubstructureNotifyMask,
- &xev);
+ XSendEvent(display(), root, False,
+ SubstructureRedirectMask | SubstructureNotifyMask, &xev);
}
XFlush(display());
return true;
@@ -229,7 +225,7 @@
bool WindowCapturerLinux::IsOccluded(const DesktopVector& pos) {
return window_finder_.GetWindowUnderPoint(pos) !=
- static_cast<WindowId>(selected_window_);
+ static_cast<WindowId>(selected_window_);
}
bool WindowCapturerLinux::HandleXEvent(const XEvent& event) {
@@ -237,7 +233,7 @@
XConfigureEvent xce = event.xconfigure;
if (xce.window == selected_window_) {
if (!DesktopRectFromXAttributes(xce).equals(
- x_server_pixel_buffer_.window_rect())) {
+ x_server_pixel_buffer_.window_rect())) {
if (!x_server_pixel_buffer_.Init(display(), selected_window_)) {
RTC_LOG(LS_ERROR)
<< "Failed to initialize pixel buffer after resizing.";
@@ -260,8 +256,8 @@
if (status && window_name.value && window_name.nitems) {
int cnt;
char** list = nullptr;
- status = Xutf8TextPropertyToTextList(display(), &window_name, &list,
- &cnt);
+ status =
+ Xutf8TextPropertyToTextList(display(), &window_name, &list, &cnt);
if (status >= Success && cnt && *list) {
if (cnt > 1) {
RTC_LOG(LS_INFO) << "Window has " << cnt
diff --git a/modules/desktop_capture/window_finder_unittest.cc b/modules/desktop_capture/window_finder_unittest.cc
index ccbc469..70f0d86 100644
--- a/modules/desktop_capture/window_finder_unittest.cc
+++ b/modules/desktop_capture/window_finder_unittest.cc
@@ -28,8 +28,8 @@
#if defined(WEBRTC_WIN)
#include <windows.h>
-#include "modules/desktop_capture/window_finder_win.h"
#include "modules/desktop_capture/win/window_capture_utils.h"
+#include "modules/desktop_capture/window_finder_win.h"
#endif
namespace webrtc {
@@ -64,8 +64,8 @@
MoveWindow(console_window, 0, 0, kMaxSize, kMaxSize, true);
// Brings console window to top.
- SetWindowPos(
- console_window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
+ SetWindowPos(console_window, HWND_TOPMOST, 0, 0, 0, 0,
+ SWP_NOMOVE | SWP_NOSIZE);
BringWindowToTop(console_window);
WindowFinderWin finder;
@@ -154,14 +154,14 @@
return;
}
- ASSERT_EQ(kNullWindowId, finder->GetWindowUnderPoint(
- DesktopVector(INT16_MAX, INT16_MAX)));
- ASSERT_EQ(kNullWindowId, finder->GetWindowUnderPoint(
- DesktopVector(INT16_MAX, INT16_MIN)));
- ASSERT_EQ(kNullWindowId, finder->GetWindowUnderPoint(
- DesktopVector(INT16_MIN, INT16_MAX)));
- ASSERT_EQ(kNullWindowId, finder->GetWindowUnderPoint(
- DesktopVector(INT16_MIN, INT16_MIN)));
+ ASSERT_EQ(kNullWindowId,
+ finder->GetWindowUnderPoint(DesktopVector(INT16_MAX, INT16_MAX)));
+ ASSERT_EQ(kNullWindowId,
+ finder->GetWindowUnderPoint(DesktopVector(INT16_MAX, INT16_MIN)));
+ ASSERT_EQ(kNullWindowId,
+ finder->GetWindowUnderPoint(DesktopVector(INT16_MIN, INT16_MAX)));
+ ASSERT_EQ(kNullWindowId,
+ finder->GetWindowUnderPoint(DesktopVector(INT16_MIN, INT16_MIN)));
}
} // namespace
diff --git a/modules/desktop_capture/window_finder_win.cc b/modules/desktop_capture/window_finder_win.cc
index 9f87106..7c31dea 100644
--- a/modules/desktop_capture/window_finder_win.cc
+++ b/modules/desktop_capture/window_finder_win.cc
@@ -20,7 +20,7 @@
WindowFinderWin::~WindowFinderWin() = default;
WindowId WindowFinderWin::GetWindowUnderPoint(DesktopVector point) {
- HWND window = WindowFromPoint(POINT { point.x(), point.y() });
+ HWND window = WindowFromPoint(POINT{point.x(), point.y()});
if (!window) {
return kNullWindowId;
}
diff --git a/modules/desktop_capture/window_finder_x11.cc b/modules/desktop_capture/window_finder_x11.cc
index 3096217..192f929 100644
--- a/modules/desktop_capture/window_finder_x11.cc
+++ b/modules/desktop_capture/window_finder_x11.cc
@@ -16,8 +16,7 @@
namespace webrtc {
-WindowFinderX11::WindowFinderX11(XAtomCache* cache)
- : cache_(cache) {
+WindowFinderX11::WindowFinderX11(XAtomCache* cache) : cache_(cache) {
RTC_DCHECK(cache_);
}
@@ -25,16 +24,15 @@
WindowId WindowFinderX11::GetWindowUnderPoint(DesktopVector point) {
WindowId id = kNullWindowId;
- GetWindowList(cache_,
- [&id, this, point](::Window window) {
- DesktopRect rect;
- if (GetWindowRect(this->cache_->display(), window, &rect) &&
- rect.Contains(point)) {
- id = window;
- return false;
- }
- return true;
- });
+ GetWindowList(cache_, [&id, this, point](::Window window) {
+ DesktopRect rect;
+ if (GetWindowRect(this->cache_->display(), window, &rect) &&
+ rect.Contains(point)) {
+ id = window;
+ return false;
+ }
+ return true;
+ });
return id;
}
diff --git a/modules/desktop_capture/x11/shared_x_display.cc b/modules/desktop_capture/x11/shared_x_display.cc
index ff2cba5..db6a64b 100644
--- a/modules/desktop_capture/x11/shared_x_display.cc
+++ b/modules/desktop_capture/x11/shared_x_display.cc
@@ -19,8 +19,7 @@
namespace webrtc {
-SharedXDisplay::SharedXDisplay(Display* display)
- : display_(display) {
+SharedXDisplay::SharedXDisplay(Display* display) : display_(display) {
RTC_DCHECK(display_);
}
diff --git a/modules/desktop_capture/x11/window_list_utils.cc b/modules/desktop_capture/x11/window_list_utils.cc
index 65c7edf..fe070d8 100644
--- a/modules/desktop_capture/x11/window_list_utils.cc
+++ b/modules/desktop_capture/x11/window_list_utils.cc
@@ -10,10 +10,10 @@
#include "modules/desktop_capture/x11/window_list_utils.h"
-#include <string.h>
-#include <X11/Xlib.h>
#include <X11/Xatom.h>
+#include <X11/Xlib.h>
#include <X11/Xutil.h>
+#include <string.h>
#include <algorithm>
@@ -49,10 +49,9 @@
Atom actual_type;
int actual_format;
unsigned long bytes_after; // NOLINT: type required by XGetWindowProperty
- int status = XGetWindowProperty(display, window, property, 0L, ~0L, False,
- AnyPropertyType, &actual_type,
- &actual_format, &size_,
- &bytes_after, &data_);
+ int status = XGetWindowProperty(
+ display, window, property, 0L, ~0L, False, AnyPropertyType,
+ &actual_type, &actual_format, &size_, &bytes_after, &data_);
if (status != Success) {
data_ = nullptr;
return;
@@ -78,9 +77,7 @@
const PropertyType* data() const {
return reinterpret_cast<PropertyType*>(data_);
}
- PropertyType* data() {
- return reinterpret_cast<PropertyType*>(data_);
- }
+ PropertyType* data() { return reinterpret_cast<PropertyType*>(data_); }
private:
bool is_valid_ = false;
@@ -106,7 +103,7 @@
RTC_DCHECK_EQ(state, WithdrawnState);
// If the window is in WithdrawnState then look at all of its children.
::Window root, parent;
- ::Window *children;
+ ::Window* children;
unsigned int num_children;
if (!XQueryTree(cache->display(), window, &root, &parent, &children,
&num_children)) {
@@ -137,14 +134,12 @@
// says this hint *should* be present on all windows, and we use the existence
// of _NET_WM_WINDOW_TYPE_NORMAL in the property to indicate a window is not
// a desktop element (that is, only "normal" windows should be shareable).
- XWindowProperty<uint32_t> window_type(
- cache->display(), window, cache->WindowType());
+ XWindowProperty<uint32_t> window_type(cache->display(), window,
+ cache->WindowType());
if (window_type.is_valid() && window_type.size() > 0) {
uint32_t* end = window_type.data() + window_type.size();
- bool is_normal = (end != std::find(
- window_type.data(),
- end,
- cache->WindowTypeNormal()));
+ bool is_normal =
+ (end != std::find(window_type.data(), end, cache->WindowTypeNormal()));
return !is_normal;
}
@@ -166,8 +161,8 @@
int32_t GetWindowState(XAtomCache* cache, ::Window window) {
// Get WM_STATE property of the window.
- XWindowProperty<uint32_t> window_state(
- cache->display(), window, cache->WmState());
+ XWindowProperty<uint32_t> window_state(cache->display(), window,
+ cache->WmState());
// WM_STATE is considered to be set to WithdrawnState when it missing.
return window_state.is_valid() ? *window_state.data() : WithdrawnState;
@@ -188,11 +183,7 @@
unsigned int num_children;
{
XErrorTrap error_trap(display);
- if (XQueryTree(display,
- root_window,
- &root_window,
- &parent,
- &children,
+ if (XQueryTree(display, root_window, &root_window, &parent, &children,
&num_children) == 0 ||
error_trap.GetLastErrorAndDisable() != 0) {
failed_screens++;
@@ -242,14 +233,8 @@
{
XErrorTrap error_trap(display);
::Window child;
- if (!XTranslateCoordinates(display,
- window,
- attributes->root,
- -rect->left(),
- -rect->top(),
- &offset_x,
- &offset_y,
- &child) ||
+ if (!XTranslateCoordinates(display, window, attributes->root, -rect->left(),
+ -rect->top(), &offset_x, &offset_y, &child) ||
error_trap.GetLastErrorAndDisable() != 0) {
return false;
}
diff --git a/modules/desktop_capture/x11/window_list_utils.h b/modules/desktop_capture/x11/window_list_utils.h
index 92571b2..72d2a70 100644
--- a/modules/desktop_capture/x11/window_list_utils.h
+++ b/modules/desktop_capture/x11/window_list_utils.h
@@ -45,9 +45,7 @@
// Creates a DesktopRect from |attributes|.
template <typename T>
DesktopRect DesktopRectFromXAttributes(const T& attributes) {
- return DesktopRect::MakeXYWH(attributes.x,
- attributes.y,
- attributes.width,
+ return DesktopRect::MakeXYWH(attributes.x, attributes.y, attributes.width,
attributes.height);
}
diff --git a/modules/desktop_capture/x11/x_atom_cache.h b/modules/desktop_capture/x11/x_atom_cache.h
index d77d2fb..5246c2b 100644
--- a/modules/desktop_capture/x11/x_atom_cache.h
+++ b/modules/desktop_capture/x11/x_atom_cache.h
@@ -11,8 +11,8 @@
#ifndef MODULES_DESKTOP_CAPTURE_X11_X_ATOM_CACHE_H_
#define MODULES_DESKTOP_CAPTURE_X11_X_ATOM_CACHE_H_
-#include <X11/Xlib.h>
#include <X11/Xatom.h>
+#include <X11/Xlib.h>
namespace webrtc {
diff --git a/modules/desktop_capture/x11/x_error_trap.cc b/modules/desktop_capture/x11/x_error_trap.cc
index a0dbac6..6559c3d 100644
--- a/modules/desktop_capture/x11/x_error_trap.cc
+++ b/modules/desktop_capture/x11/x_error_trap.cc
@@ -37,11 +37,10 @@
} // namespace
XErrorTrap::XErrorTrap(Display* display)
- : original_error_handler_(NULL),
- enabled_(true) {
+ : original_error_handler_(NULL), enabled_(true) {
#if defined(TOOLKIT_GTK)
gdk_error_trap_push();
-#else // !defined(TOOLKIT_GTK)
+#else // !defined(TOOLKIT_GTK)
assert(!g_xserver_error_trap_enabled);
original_error_handler_ = XSetErrorHandler(&XServerErrorHandler);
g_xserver_error_trap_enabled = true;
@@ -53,7 +52,7 @@
enabled_ = false;
#if defined(TOOLKIT_GTK)
return gdk_error_trap_push();
-#else // !defined(TOOLKIT_GTK)
+#else // !defined(TOOLKIT_GTK)
assert(g_xserver_error_trap_enabled);
XSetErrorHandler(original_error_handler_);
g_xserver_error_trap_enabled = false;
diff --git a/modules/desktop_capture/x11/x_server_pixel_buffer.cc b/modules/desktop_capture/x11/x_server_pixel_buffer.cc
index ab1b95a..e327d3fc 100644
--- a/modules/desktop_capture/x11/x_server_pixel_buffer.cc
+++ b/modules/desktop_capture/x11/x_server_pixel_buffer.cc
@@ -52,10 +52,8 @@
// Returns true if |image| is in RGB format.
bool IsXImageRGBFormat(XImage* image) {
- return image->bits_per_pixel == 32 &&
- image->red_mask == 0xff0000 &&
- image->green_mask == 0xff00 &&
- image->blue_mask == 0xff;
+ return image->bits_per_pixel == 32 && image->red_mask == 0xff0000 &&
+ image->green_mask == 0xff00 && image->blue_mask == 0xff;
}
// We expose two forms of blitting to handle variations in the pixel format.
@@ -255,11 +253,9 @@
{
XErrorTrap error_trap(display_);
- shm_pixmap_ = XShmCreatePixmap(display_, window_,
- shm_segment_info_->shmaddr,
- shm_segment_info_,
- window_rect_.width(),
- window_rect_.height(), depth);
+ shm_pixmap_ = XShmCreatePixmap(
+ display_, window_, shm_segment_info_->shmaddr, shm_segment_info_,
+ window_rect_.width(), window_rect_.height(), depth);
XSync(display_, False);
if (error_trap.GetLastErrorAndDisable() != 0) {
// |shm_pixmap_| is not not valid because the request was not processed
@@ -275,8 +271,7 @@
shm_gc_values.subwindow_mode = IncludeInferiors;
shm_gc_values.graphics_exposures = False;
shm_gc_ = XCreateGC(display_, window_,
- GCSubwindowMode | GCGraphicsExposures,
- &shm_gc_values);
+ GCSubwindowMode | GCGraphicsExposures, &shm_gc_values);
XSync(display_, False);
if (error_trap.GetLastErrorAndDisable() != 0) {
XFreePixmap(display_, shm_pixmap_);
@@ -321,9 +316,9 @@
if (shm_segment_info_ && (shm_pixmap_ || xshm_get_image_succeeded_)) {
if (shm_pixmap_) {
- XCopyArea(display_, window_, shm_pixmap_, shm_gc_,
- rect.left(), rect.top(), rect.width(), rect.height(),
- rect.left(), rect.top());
+ XCopyArea(display_, window_, shm_pixmap_, shm_gc_, rect.left(),
+ rect.top(), rect.width(), rect.height(), rect.left(),
+ rect.top());
XSync(display_, False);
}
diff --git a/modules/include/module_common_types.h b/modules/include/module_common_types.h
index 65bb207..08b36d1 100644
--- a/modules/include/module_common_types.h
+++ b/modules/include/module_common_types.h
@@ -185,8 +185,7 @@
memset(fragmentationOffset + oldVectorSize, 0,
sizeof(size_t) * (size16 - oldVectorSize));
// copy old values
- memcpy(fragmentationOffset, oldOffsets,
- sizeof(size_t) * oldVectorSize);
+ memcpy(fragmentationOffset, oldOffsets, sizeof(size_t) * oldVectorSize);
delete[] oldOffsets;
}
// length
@@ -195,8 +194,7 @@
fragmentationLength = new size_t[size16];
memset(fragmentationLength + oldVectorSize, 0,
sizeof(size_t) * (size16 - oldVectorSize));
- memcpy(fragmentationLength, oldLengths,
- sizeof(size_t) * oldVectorSize);
+ memcpy(fragmentationLength, oldLengths, sizeof(size_t) * oldVectorSize);
delete[] oldLengths;
}
// time diff
diff --git a/modules/include/module_common_types_public.h b/modules/include/module_common_types_public.h
index 2fbb49a..f1ae3de 100644
--- a/modules/include/module_common_types_public.h
+++ b/modules/include/module_common_types_public.h
@@ -68,9 +68,7 @@
}
// Only update the internal state to the specified last (unwrapped) value.
- void UpdateLast(int64_t last_value) {
- last_value_ = last_value;
- }
+ void UpdateLast(int64_t last_value) { last_value_ = last_value; }
// Unwrap the value and update the internal state.
int64_t Unwrap(U value) {
diff --git a/modules/module_common_types_unittest.cc b/modules/module_common_types_unittest.cc
index 3045c0d..8289bea 100644
--- a/modules/module_common_types_unittest.cc
+++ b/modules/module_common_types_unittest.cc
@@ -112,7 +112,6 @@
EXPECT_EQ(0x0000FFFFu, LatestTimestamp(0xFFFF0000, 0x0000FFFF));
}
-
TEST(SequenceNumberUnwrapper, Limits) {
SequenceNumberUnwrapper unwrapper;
diff --git a/modules/pacing/alr_detector.cc b/modules/pacing/alr_detector.cc
index 17fae29..1d16a71 100644
--- a/modules/pacing/alr_detector.cc
+++ b/modules/pacing/alr_detector.cc
@@ -11,8 +11,8 @@
#include "modules/pacing/alr_detector.h"
#include <algorithm>
-#include <string>
#include <cstdio>
+#include <string>
#include "logging/rtc_event_log/events/rtc_event_alr_state.h"
#include "logging/rtc_event_log/rtc_event_log.h"
diff --git a/modules/pacing/bitrate_prober.cc b/modules/pacing/bitrate_prober.cc
index 7f60207..345855b 100644
--- a/modules/pacing/bitrate_prober.cc
+++ b/modules/pacing/bitrate_prober.cc
@@ -124,9 +124,9 @@
if (next_probe_time_ms_ >= 0) {
time_until_probe_ms = next_probe_time_ms_ - now_ms;
if (time_until_probe_ms < -kMaxProbeDelayMs) {
- RTC_LOG(LS_WARNING)<<"Probe delay too high"<<
- " (next_ms:"<<next_probe_time_ms_<<
- ", now_ms: "<<now_ms<<")";
+ RTC_LOG(LS_WARNING) << "Probe delay too high"
+ << " (next_ms:" << next_probe_time_ms_
+ << ", now_ms: " << now_ms << ")";
return -1;
}
}
@@ -183,5 +183,4 @@
return cluster.time_started_ms + delta_ms;
}
-
} // namespace webrtc
diff --git a/modules/pacing/bitrate_prober_unittest.cc b/modules/pacing/bitrate_prober_unittest.cc
index 184ac06..dc59698 100644
--- a/modules/pacing/bitrate_prober_unittest.cc
+++ b/modules/pacing/bitrate_prober_unittest.cc
@@ -49,7 +49,7 @@
// Verify that the actual bitrate is withing 10% of the target.
double bitrate = kProbeSize * (kClusterSize - 1) * 8 * 1000.0 / now_ms;
EXPECT_GT(bitrate, kTestBitrate1 * 0.9);
- EXPECT_LT(bitrate, kTestBitrate1 * 1.1);
+ EXPECT_LT(bitrate, kTestBitrate1 * 1.1);
now_ms += prober.TimeUntilNextProbe(now_ms);
int64_t probe2_started = now_ms;
@@ -66,7 +66,7 @@
EXPECT_GE(duration, kMinProbeDurationMs);
bitrate = kProbeSize * (kClusterSize - 1) * 8 * 1000.0 / duration;
EXPECT_GT(bitrate, kTestBitrate2 * 0.9);
- EXPECT_LT(bitrate, kTestBitrate2 * 1.1);
+ EXPECT_LT(bitrate, kTestBitrate2 * 1.1);
EXPECT_EQ(-1, prober.TimeUntilNextProbe(now_ms));
EXPECT_FALSE(prober.IsProbing());
diff --git a/modules/pacing/mock/mock_paced_sender.h b/modules/pacing/mock/mock_paced_sender.h
index da4fd04..4a5337d 100644
--- a/modules/pacing/mock/mock_paced_sender.h
+++ b/modules/pacing/mock/mock_paced_sender.h
@@ -23,12 +23,13 @@
public:
MockPacedSender()
: PacedSender(Clock::GetRealTimeClock(), nullptr, nullptr) {}
- MOCK_METHOD6(SendPacket, bool(Priority priority,
- uint32_t ssrc,
- uint16_t sequence_number,
- int64_t capture_time_ms,
- size_t bytes,
- bool retransmission));
+ MOCK_METHOD6(SendPacket,
+ bool(Priority priority,
+ uint32_t ssrc,
+ uint16_t sequence_number,
+ int64_t capture_time_ms,
+ size_t bytes,
+ bool retransmission));
MOCK_METHOD1(CreateProbeCluster, void(int));
MOCK_METHOD1(SetEstimatedBitrate, void(uint32_t));
MOCK_METHOD2(SetPacingRates, void(uint32_t, uint32_t));
diff --git a/modules/pacing/paced_sender.cc b/modules/pacing/paced_sender.cc
index 276e4d3..96554ad 100644
--- a/modules/pacing/paced_sender.cc
+++ b/modules/pacing/paced_sender.cc
@@ -14,8 +14,8 @@
#include <map>
#include <queue>
#include <set>
-#include <vector>
#include <utility>
+#include <vector>
#include "modules/include/module_common_types.h"
#include "modules/pacing/alr_detector.h"
@@ -194,9 +194,9 @@
if (capture_time_ms < 0)
capture_time_ms = now_ms;
- packets_->Push(PacketQueueInterface::Packet(priority, ssrc, sequence_number,
- capture_time_ms, now_ms, bytes,
- retransmission, packet_counter_++));
+ packets_->Push(PacketQueueInterface::Packet(
+ priority, ssrc, sequence_number, capture_time_ms, now_ms, bytes,
+ retransmission, packet_counter_++));
}
void PacedSender::SetAccountForAudioPackets(bool account_for_audio) {
diff --git a/modules/pacing/paced_sender_unittest.cc b/modules/pacing/paced_sender_unittest.cc
index fa55e21..fb79ebc 100644
--- a/modules/pacing/paced_sender_unittest.cc
+++ b/modules/pacing/paced_sender_unittest.cc
@@ -411,20 +411,12 @@
uint32_t ssrc = 12345;
uint16_t sequence_number = 1234;
- SendAndExpectPacket(PacedSender::kNormalPriority,
- ssrc,
- sequence_number,
- clock_.TimeInMilliseconds(),
- 250,
- false);
+ SendAndExpectPacket(PacedSender::kNormalPriority, ssrc, sequence_number,
+ clock_.TimeInMilliseconds(), 250, false);
// Expect packet on second ssrc to be queued and sent as well.
- SendAndExpectPacket(PacedSender::kNormalPriority,
- ssrc + 1,
- sequence_number,
- clock_.TimeInMilliseconds(),
- 250,
- false);
+ SendAndExpectPacket(PacedSender::kNormalPriority, ssrc + 1, sequence_number,
+ clock_.TimeInMilliseconds(), 250, false);
clock_.AdvanceTimeMilliseconds(1000);
send_bucket_->Process();
@@ -504,12 +496,8 @@
int64_t start_time = clock_.TimeInMilliseconds();
while (clock_.TimeInMilliseconds() - start_time < kBitrateWindow) {
- SendAndExpectPacket(PacedSender::kNormalPriority,
- ssrc,
- sequence_number++,
- capture_time_ms,
- 250,
- false);
+ SendAndExpectPacket(PacedSender::kNormalPriority, ssrc, sequence_number++,
+ capture_time_ms, 250, false);
EXPECT_CALL(callback_, TimeToSendPadding(250, _))
.Times(1)
.WillOnce(Return(250));
@@ -1050,12 +1038,8 @@
EXPECT_EQ(0, send_bucket_->QueueInMs());
send_bucket_->SetPacingRates(30000 * kPaceMultiplier, 0);
- SendAndExpectPacket(PacedSender::kNormalPriority,
- ssrc,
- sequence_number,
- clock_.TimeInMilliseconds(),
- 1200,
- false);
+ SendAndExpectPacket(PacedSender::kNormalPriority, ssrc, sequence_number,
+ clock_.TimeInMilliseconds(), 1200, false);
clock_.AdvanceTimeMilliseconds(500);
EXPECT_EQ(500, send_bucket_->QueueInMs());
diff --git a/modules/pacing/packet_router_unittest.cc b/modules/pacing/packet_router_unittest.cc
index 34b533b..3da134a 100644
--- a/modules/pacing/packet_router_unittest.cc
+++ b/modules/pacing/packet_router_unittest.cc
@@ -234,11 +234,10 @@
EXPECT_CALL(rtp_1, TimeToSendPadding(requested_padding_bytes, _)).Times(0);
EXPECT_CALL(rtp_2, SendingMedia()).Times(1).WillOnce(Return(false));
EXPECT_CALL(rtp_2, TimeToSendPadding(_, _)).Times(0);
- EXPECT_EQ(0u,
- packet_router.TimeToSendPadding(
- requested_padding_bytes,
- PacedPacketInfo(PacedPacketInfo::kNotAProbe, kProbeMinBytes,
- kProbeMinBytes)));
+ EXPECT_EQ(0u, packet_router.TimeToSendPadding(
+ requested_padding_bytes,
+ PacedPacketInfo(PacedPacketInfo::kNotAProbe, kProbeMinBytes,
+ kProbeMinBytes)));
// Only one module has BWE extensions.
EXPECT_CALL(rtp_1, SendingMedia()).Times(1).WillOnce(Return(true));
@@ -262,11 +261,10 @@
EXPECT_CALL(rtp_2, SendingMedia()).Times(1).WillOnce(Return(true));
EXPECT_CALL(rtp_2, HasBweExtensions()).Times(1).WillOnce(Return(true));
EXPECT_CALL(rtp_2, TimeToSendPadding(requested_padding_bytes, _)).Times(1);
- EXPECT_EQ(0u,
- packet_router.TimeToSendPadding(
- requested_padding_bytes,
- PacedPacketInfo(PacedPacketInfo::kNotAProbe, kProbeMinBytes,
- kProbeMinBytes)));
+ EXPECT_EQ(0u, packet_router.TimeToSendPadding(
+ requested_padding_bytes,
+ PacedPacketInfo(PacedPacketInfo::kNotAProbe, kProbeMinBytes,
+ kProbeMinBytes)));
packet_router.RemoveSendRtpModule(&rtp_2);
}
@@ -360,14 +358,14 @@
// Verify that TimeToSendPacket does not end up in a receiver.
EXPECT_CALL(rtp, TimeToSendPacket(_, _, _, _, _)).Times(0);
EXPECT_TRUE(packet_router.TimeToSendPacket(
- kSsrc, 1, 1, false, PacedPacketInfo(PacedPacketInfo::kNotAProbe,
- kProbeMinBytes, kProbeMinBytes)));
+ kSsrc, 1, 1, false,
+ PacedPacketInfo(PacedPacketInfo::kNotAProbe, kProbeMinBytes,
+ kProbeMinBytes)));
// Verify that TimeToSendPadding does not end up in a receiver.
EXPECT_CALL(rtp, TimeToSendPadding(_, _)).Times(0);
- EXPECT_EQ(0u,
- packet_router.TimeToSendPadding(
- 200, PacedPacketInfo(PacedPacketInfo::kNotAProbe,
- kProbeMinBytes, kProbeMinBytes)));
+ EXPECT_EQ(0u, packet_router.TimeToSendPadding(
+ 200, PacedPacketInfo(PacedPacketInfo::kNotAProbe,
+ kProbeMinBytes, kProbeMinBytes)));
packet_router.RemoveSendRtpModule(&rtp);
}
diff --git a/modules/remote_bitrate_estimator/aimd_rate_control.cc b/modules/remote_bitrate_estimator/aimd_rate_control.cc
index 949cc6a..8be5e49 100644
--- a/modules/remote_bitrate_estimator/aimd_rate_control.cc
+++ b/modules/remote_bitrate_estimator/aimd_rate_control.cc
@@ -114,7 +114,7 @@
if (ValidEstimate()) {
// TODO(terelius/holmer): Investigate consequences of increasing
// the threshold to 0.95 * LatestEstimate().
- const uint32_t threshold = static_cast<uint32_t> (0.5 * LatestEstimate());
+ const uint32_t threshold = static_cast<uint32_t>(0.5 * LatestEstimate());
return incoming_bitrate_bps < threshold;
}
return false;
@@ -206,8 +206,8 @@
const float incoming_bitrate_kbps = incoming_bitrate_bps / 1000.0f;
// Calculate the max bit rate std dev given the normalized
// variance and the current incoming bit rate.
- const float std_max_bit_rate = sqrt(var_max_bitrate_kbps_ *
- avg_max_bitrate_kbps_);
+ const float std_max_bit_rate =
+ sqrt(var_max_bitrate_kbps_ * avg_max_bitrate_kbps_);
switch (rate_control_state_) {
case kRcHold:
break;
@@ -295,15 +295,17 @@
}
uint32_t AimdRateControl::MultiplicativeRateIncrease(
- int64_t now_ms, int64_t last_ms, uint32_t current_bitrate_bps) const {
+ int64_t now_ms,
+ int64_t last_ms,
+ uint32_t current_bitrate_bps) const {
double alpha = 1.08;
if (last_ms > -1) {
auto time_since_last_update_ms =
rtc::SafeMin<int64_t>(now_ms - last_ms, 1000);
- alpha = pow(alpha, time_since_last_update_ms / 1000.0);
+ alpha = pow(alpha, time_since_last_update_ms / 1000.0);
}
- uint32_t multiplicative_increase_bps = std::max(
- current_bitrate_bps * (alpha - 1.0), 1000.0);
+ uint32_t multiplicative_increase_bps =
+ std::max(current_bitrate_bps * (alpha - 1.0), 1000.0);
return multiplicative_increase_bps;
}
@@ -318,13 +320,14 @@
if (avg_max_bitrate_kbps_ == -1.0f) {
avg_max_bitrate_kbps_ = incoming_bitrate_kbps;
} else {
- avg_max_bitrate_kbps_ = (1 - alpha) * avg_max_bitrate_kbps_ +
- alpha * incoming_bitrate_kbps;
+ avg_max_bitrate_kbps_ =
+ (1 - alpha) * avg_max_bitrate_kbps_ + alpha * incoming_bitrate_kbps;
}
// Estimate the max bit rate variance and normalize the variance
// with the average max bit rate.
const float norm = std::max(avg_max_bitrate_kbps_, 1.0f);
- var_max_bitrate_kbps_ = (1 - alpha) * var_max_bitrate_kbps_ +
+ var_max_bitrate_kbps_ =
+ (1 - alpha) * var_max_bitrate_kbps_ +
alpha * (avg_max_bitrate_kbps_ - incoming_bitrate_kbps) *
(avg_max_bitrate_kbps_ - incoming_bitrate_kbps) / norm;
// 0.4 ~= 14 kbit/s at 500 kbit/s
diff --git a/modules/remote_bitrate_estimator/aimd_rate_control.h b/modules/remote_bitrate_estimator/aimd_rate_control.h
index c62ad7d..4de15d0 100644
--- a/modules/remote_bitrate_estimator/aimd_rate_control.h
+++ b/modules/remote_bitrate_estimator/aimd_rate_control.h
@@ -64,7 +64,8 @@
// large compared to the bitrate actually being received by the other end.
uint32_t ClampBitrate(uint32_t new_bitrate_bps,
uint32_t incoming_bitrate_bps) const;
- uint32_t MultiplicativeRateIncrease(int64_t now_ms, int64_t last_ms,
+ uint32_t MultiplicativeRateIncrease(int64_t now_ms,
+ int64_t last_ms,
uint32_t current_bitrate_bps) const;
uint32_t AdditiveRateIncrease(int64_t now_ms, int64_t last_ms) const;
void UpdateChangePeriod(int64_t now_ms);
diff --git a/modules/remote_bitrate_estimator/bwe_simulations.cc b/modules/remote_bitrate_estimator/bwe_simulations.cc
index 87106f1..de6d2d9 100644
--- a/modules/remote_bitrate_estimator/bwe_simulations.cc
+++ b/modules/remote_bitrate_estimator/bwe_simulations.cc
@@ -551,4 +551,3 @@
} // namespace bwe
} // namespace testing
} // namespace webrtc
-
diff --git a/modules/remote_bitrate_estimator/inter_arrival.cc b/modules/remote_bitrate_estimator/inter_arrival.cc
index ef3ca8b..b779e41 100644
--- a/modules/remote_bitrate_estimator/inter_arrival.cc
+++ b/modules/remote_bitrate_estimator/inter_arrival.cc
@@ -51,8 +51,8 @@
} else if (NewTimestampGroup(arrival_time_ms, timestamp)) {
// First packet of a later frame, the previous frame sample is ready.
if (prev_timestamp_group_.complete_time_ms >= 0) {
- *timestamp_delta = current_timestamp_group_.timestamp -
- prev_timestamp_group_.timestamp;
+ *timestamp_delta =
+ current_timestamp_group_.timestamp - prev_timestamp_group_.timestamp;
*arrival_time_delta_ms = current_timestamp_group_.complete_time_ms -
prev_timestamp_group_.complete_time_ms;
// Check system time differences to see if we have an unproportional jump
@@ -86,7 +86,7 @@
}
assert(*arrival_time_delta_ms >= 0);
*packet_size_delta = static_cast<int>(current_timestamp_group_.size) -
- static_cast<int>(prev_timestamp_group_.size);
+ static_cast<int>(prev_timestamp_group_.size);
calculated_deltas = true;
}
prev_timestamp_group_ = current_timestamp_group_;
@@ -95,8 +95,8 @@
current_timestamp_group_.timestamp = timestamp;
current_timestamp_group_.size = 0;
} else {
- current_timestamp_group_.timestamp = LatestTimestamp(
- current_timestamp_group_.timestamp, timestamp);
+ current_timestamp_group_.timestamp =
+ LatestTimestamp(current_timestamp_group_.timestamp, timestamp);
}
// Accumulate the frame size.
current_timestamp_group_.size += packet_size;
@@ -113,8 +113,8 @@
// Assume that a diff which is bigger than half the timestamp interval
// (32 bits) must be due to reordering. This code is almost identical to
// that in IsNewerTimestamp() in module_common_types.h.
- uint32_t timestamp_diff = timestamp -
- current_timestamp_group_.first_timestamp;
+ uint32_t timestamp_diff =
+ timestamp - current_timestamp_group_.first_timestamp;
return timestamp_diff < 0x80000000;
}
}
@@ -128,8 +128,8 @@
} else if (BelongsToBurst(arrival_time_ms, timestamp)) {
return false;
} else {
- uint32_t timestamp_diff = timestamp -
- current_timestamp_group_.first_timestamp;
+ uint32_t timestamp_diff =
+ timestamp - current_timestamp_group_.first_timestamp;
return timestamp_diff > kTimestampGroupLengthTicks;
}
}
@@ -140,15 +140,15 @@
return false;
}
assert(current_timestamp_group_.complete_time_ms >= 0);
- int64_t arrival_time_delta_ms = arrival_time_ms -
- current_timestamp_group_.complete_time_ms;
+ int64_t arrival_time_delta_ms =
+ arrival_time_ms - current_timestamp_group_.complete_time_ms;
uint32_t timestamp_diff = timestamp - current_timestamp_group_.timestamp;
int64_t ts_delta_ms = timestamp_to_ms_coeff_ * timestamp_diff + 0.5;
if (ts_delta_ms == 0)
return true;
int propagation_delta_ms = arrival_time_delta_ms - ts_delta_ms;
return propagation_delta_ms < 0 &&
- arrival_time_delta_ms <= kBurstDeltaThresholdMs;
+ arrival_time_delta_ms <= kBurstDeltaThresholdMs;
}
void InterArrival::Reset() {
diff --git a/modules/remote_bitrate_estimator/inter_arrival.h b/modules/remote_bitrate_estimator/inter_arrival.h
index f6ab280..e9aaf9b 100644
--- a/modules/remote_bitrate_estimator/inter_arrival.h
+++ b/modules/remote_bitrate_estimator/inter_arrival.h
@@ -54,14 +54,9 @@
private:
struct TimestampGroup {
TimestampGroup()
- : size(0),
- first_timestamp(0),
- timestamp(0),
- complete_time_ms(-1) {}
+ : size(0), first_timestamp(0), timestamp(0), complete_time_ms(-1) {}
- bool IsFirstPacket() const {
- return complete_time_ms == -1;
- }
+ bool IsFirstPacket() const { return complete_time_ms == -1; }
size_t size;
uint32_t first_timestamp;
diff --git a/modules/remote_bitrate_estimator/inter_arrival_unittest.cc b/modules/remote_bitrate_estimator/inter_arrival_unittest.cc
index cd038c4..545b196 100644
--- a/modules/remote_bitrate_estimator/inter_arrival_unittest.cc
+++ b/modules/remote_bitrate_estimator/inter_arrival_unittest.cc
@@ -36,18 +36,15 @@
inter_arrival_.reset(
new InterArrival(kTimestampGroupLengthUs / 1000, 1.0, true));
inter_arrival_rtp_.reset(new InterArrival(
- MakeRtpTimestamp(kTimestampGroupLengthUs),
- kRtpTimestampToMs,
- true));
+ MakeRtpTimestamp(kTimestampGroupLengthUs), kRtpTimestampToMs, true));
inter_arrival_ast_.reset(new InterArrival(
- MakeAbsSendTime(kTimestampGroupLengthUs),
- kAstToMs,
- true));
+ MakeAbsSendTime(kTimestampGroupLengthUs), kAstToMs, true));
}
// Test that neither inter_arrival instance complete the timestamp group from
// the given data.
- void ExpectFalse(int64_t timestamp_us, int64_t arrival_time_ms,
+ void ExpectFalse(int64_t timestamp_us,
+ int64_t arrival_time_ms,
size_t packet_size) {
InternalExpectFalse(inter_arrival_rtp_.get(),
MakeRtpTimestamp(timestamp_us), arrival_time_ms,
@@ -60,8 +57,10 @@
// the given data and that all returned deltas are as expected (except
// timestamp delta, which is rounded from us to different ranges and must
// match within an interval, given in |timestamp_near].
- void ExpectTrue(int64_t timestamp_us, int64_t arrival_time_ms,
- size_t packet_size, int64_t expected_timestamp_delta_us,
+ void ExpectTrue(int64_t timestamp_us,
+ int64_t arrival_time_ms,
+ size_t packet_size,
+ int64_t expected_timestamp_delta_us,
int64_t expected_arrival_time_delta_ms,
int expected_packet_size_delta,
uint32_t timestamp_near) {
@@ -77,7 +76,8 @@
expected_packet_size_delta, timestamp_near << 8);
}
- void WrapTestHelper(int64_t wrap_start_us, uint32_t timestamp_near,
+ void WrapTestHelper(int64_t wrap_start_us,
+ uint32_t timestamp_near,
bool unorderly_within_group) {
// Step through the range of a 32 bit int, 1/4 at a time to not cause
// packets close to wraparound to be judged as out of order.
@@ -92,21 +92,21 @@
// G3
arrival_time += kBurstThresholdMs + 1;
- ExpectTrue(wrap_start_us / 2, arrival_time, 1,
- wrap_start_us / 4, 6, 0, // Delta G2-G1
+ ExpectTrue(wrap_start_us / 2, arrival_time, 1, wrap_start_us / 4, 6,
+ 0, // Delta G2-G1
0);
// G4
arrival_time += kBurstThresholdMs + 1;
int64_t g4_arrival_time = arrival_time;
ExpectTrue(wrap_start_us / 2 + wrap_start_us / 4, arrival_time, 1,
- wrap_start_us / 4, 6, 0, // Delta G3-G2
+ wrap_start_us / 4, 6, 0, // Delta G3-G2
timestamp_near);
// G5
arrival_time += kBurstThresholdMs + 1;
- ExpectTrue(wrap_start_us, arrival_time, 2,
- wrap_start_us / 4, 6, 0, // Delta G4-G3
+ ExpectTrue(wrap_start_us, arrival_time, 2, wrap_start_us / 4, 6,
+ 0, // Delta G4-G3
timestamp_near);
for (int i = 0; i < 10; ++i) {
// Slowly step across the wrap point.
@@ -141,12 +141,10 @@
// G7
arrival_time += kBurstThresholdMs + 1;
- ExpectTrue(wrap_start_us + 2 * kTriggerNewGroupUs,
- arrival_time, 100,
+ ExpectTrue(wrap_start_us + 2 * kTriggerNewGroupUs, arrival_time, 100,
// Delta G6-G5
kTriggerNewGroupUs - 9 * kMinStep,
- g6_arrival_time - g5_arrival_time,
- 10 - (2 + 10),
+ g6_arrival_time - g5_arrival_time, 10 - (2 + 10),
timestamp_near);
}
@@ -158,13 +156,16 @@
}
static uint32_t MakeAbsSendTime(int64_t us) {
- uint32_t absolute_send_time = static_cast<uint32_t>(
- ((static_cast<uint64_t>(us) << 18) + 500000) / 1000000) & 0x00FFFFFFul;
+ uint32_t absolute_send_time =
+ static_cast<uint32_t>(((static_cast<uint64_t>(us) << 18) + 500000) /
+ 1000000) &
+ 0x00FFFFFFul;
return absolute_send_time << 8;
}
static void InternalExpectFalse(InterArrival* inter_arrival,
- uint32_t timestamp, int64_t arrival_time_ms,
+ uint32_t timestamp,
+ int64_t arrival_time_ms,
size_t packet_size) {
uint32_t dummy_timestamp = 101;
int64_t dummy_arrival_time_ms = 303;
@@ -179,7 +180,8 @@
}
static void InternalExpectTrue(InterArrival* inter_arrival,
- uint32_t timestamp, int64_t arrival_time_ms,
+ uint32_t timestamp,
+ int64_t arrival_time_ms,
size_t packet_size,
uint32_t expected_timestamp_delta,
int64_t expected_arrival_time_delta_ms,
@@ -222,8 +224,7 @@
arrival_time += kBurstThresholdMs + 1;
ExpectTrue(2 * kTriggerNewGroupUs, arrival_time, 1,
// Delta G2-G1
- kTriggerNewGroupUs, g2_arrival_time - g1_arrival_time, 1,
- 0);
+ kTriggerNewGroupUs, g2_arrival_time - g1_arrival_time, 1, 0);
}
TEST_F(InterArrivalTest, SecondGroup) {
@@ -242,16 +243,14 @@
int64_t g3_arrival_time = arrival_time;
ExpectTrue(2 * kTriggerNewGroupUs, arrival_time, 1,
// Delta G2-G1
- kTriggerNewGroupUs, g2_arrival_time - g1_arrival_time, 1,
- 0);
+ kTriggerNewGroupUs, g2_arrival_time - g1_arrival_time, 1, 0);
// G4
// First packet of 4th group yields deltas between group 2 and 3.
arrival_time += kBurstThresholdMs + 1;
ExpectTrue(3 * kTriggerNewGroupUs, arrival_time, 2,
// Delta G3-G2
- kTriggerNewGroupUs, g3_arrival_time - g2_arrival_time, -1,
- 0);
+ kTriggerNewGroupUs, g3_arrival_time - g2_arrival_time, -1, 0);
}
TEST_F(InterArrivalTest, AccumulatedGroup) {
@@ -275,9 +274,9 @@
// G3
arrival_time = 500;
- ExpectTrue(2 * kTriggerNewGroupUs, arrival_time, 100,
- g2_timestamp, g2_arrival_time - g1_arrival_time,
- (2 + 10) - 1, // Delta G2-G1
+ ExpectTrue(2 * kTriggerNewGroupUs, arrival_time, 100, g2_timestamp,
+ g2_arrival_time - g1_arrival_time,
+ (2 + 10) - 1, // Delta G2-G1
0);
}
@@ -311,8 +310,7 @@
ExpectTrue(timestamp, arrival_time, 100,
// Delta G2-G1
g2_timestamp - g1_timestamp, g2_arrival_time - g1_arrival_time,
- (2 + 10) - 1,
- 0);
+ (2 + 10) - 1, 0);
}
TEST_F(InterArrivalTest, OutOfOrderWithinGroup) {
@@ -347,10 +345,8 @@
// G3
timestamp = 2 * kTriggerNewGroupUs;
arrival_time = 500;
- ExpectTrue(timestamp, arrival_time, 100,
- g2_timestamp - g1_timestamp, g2_arrival_time - g1_arrival_time,
- (2 + 10) - 1,
- 0);
+ ExpectTrue(timestamp, arrival_time, 100, g2_timestamp - g1_timestamp,
+ g2_arrival_time - g1_arrival_time, (2 + 10) - 1, 0);
}
TEST_F(InterArrivalTest, TwoBursts) {
@@ -373,13 +369,12 @@
// G3
timestamp += 30000;
arrival_time += kBurstThresholdMs + 1;
- ExpectTrue(timestamp, arrival_time, 100,
- g2_timestamp, g2_arrival_time - g1_arrival_time,
+ ExpectTrue(timestamp, arrival_time, 100, g2_timestamp,
+ g2_arrival_time - g1_arrival_time,
10 - 1, // Delta G2-G1
0);
}
-
TEST_F(InterArrivalTest, NoBursts) {
// G1
ExpectFalse(0, 17, 1);
diff --git a/modules/remote_bitrate_estimator/overuse_detector.cc b/modules/remote_bitrate_estimator/overuse_detector.cc
index 421c1db..776ca42 100644
--- a/modules/remote_bitrate_estimator/overuse_detector.cc
+++ b/modules/remote_bitrate_estimator/overuse_detector.cc
@@ -11,8 +11,8 @@
#include "modules/remote_bitrate_estimator/overuse_detector.h"
#include <math.h>
-#include <stdlib.h>
#include <stdio.h>
+#include <stdlib.h>
#include <algorithm>
#include <string>
@@ -142,8 +142,7 @@
const double k = fabs(modified_offset) < threshold_ ? k_down_ : k_up_;
const int64_t kMaxTimeDeltaMs = 100;
int64_t time_delta_ms = std::min(now_ms - last_update_ms_, kMaxTimeDeltaMs);
- threshold_ +=
- k * (fabs(modified_offset) - threshold_) * time_delta_ms;
+ threshold_ += k * (fabs(modified_offset) - threshold_) * time_delta_ms;
threshold_ = rtc::SafeClamp(threshold_, 6.f, 600.f);
last_update_ms_ = now_ms;
}
diff --git a/modules/remote_bitrate_estimator/overuse_detector_unittest.cc b/modules/remote_bitrate_estimator/overuse_detector_unittest.cc
index 2b50d70..366902c 100644
--- a/modules/remote_bitrate_estimator/overuse_detector_unittest.cc
+++ b/modules/remote_bitrate_estimator/overuse_detector_unittest.cc
@@ -41,11 +41,11 @@
random_(123456789) {}
protected:
- void SetUp() override {
- overuse_detector_.reset(new OveruseDetector());
- }
+ void SetUp() override { overuse_detector_.reset(new OveruseDetector()); }
- int Run100000Samples(int packets_per_frame, size_t packet_size, int mean_ms,
+ int Run100000Samples(int packets_per_frame,
+ size_t packet_size,
+ int mean_ms,
int standard_deviation_ms) {
int unique_overuse = 0;
int last_overuse = -1;
@@ -69,8 +69,11 @@
return unique_overuse;
}
- int RunUntilOveruse(int packets_per_frame, size_t packet_size, int mean_ms,
- int standard_deviation_ms, int drift_per_frame_ms) {
+ int RunUntilOveruse(int packets_per_frame,
+ size_t packet_size,
+ int mean_ms,
+ int standard_deviation_ms,
+ int drift_per_frame_ms) {
// Simulate a higher send pace, that is too high.
for (int i = 0; i < 1000; ++i) {
for (int j = 0; j < packets_per_frame; ++j) {
@@ -89,7 +92,8 @@
return -1;
}
- void UpdateDetector(uint32_t rtp_timestamp, int64_t receive_time_ms,
+ void UpdateDetector(uint32_t rtp_timestamp,
+ int64_t receive_time_ms,
size_t packet_size) {
uint32_t timestamp_delta;
int64_t time_delta;
@@ -189,8 +193,9 @@
frame_duration_ms, sigma_ms);
EXPECT_EQ(0, unique_overuse);
- int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
- frame_duration_ms, sigma_ms, drift_per_frame_ms);
+ int frames_until_overuse =
+ RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
+ sigma_ms, drift_per_frame_ms);
EXPECT_EQ(7, frames_until_overuse);
}
@@ -204,8 +209,9 @@
frame_duration_ms, sigma_ms);
EXPECT_EQ(0, unique_overuse);
- int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
- frame_duration_ms, sigma_ms, drift_per_frame_ms);
+ int frames_until_overuse =
+ RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
+ sigma_ms, drift_per_frame_ms);
EXPECT_EQ(7, frames_until_overuse);
}
@@ -328,8 +334,9 @@
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
frame_duration_ms, sigma_ms);
EXPECT_EQ(0, unique_overuse);
- int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
- frame_duration_ms, sigma_ms, drift_per_frame_ms);
+ int frames_until_overuse =
+ RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
+ sigma_ms, drift_per_frame_ms);
EXPECT_EQ(20, frames_until_overuse);
}
@@ -342,8 +349,9 @@
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
frame_duration_ms, sigma_ms);
EXPECT_EQ(0, unique_overuse);
- int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
- frame_duration_ms, sigma_ms, drift_per_frame_ms);
+ int frames_until_overuse =
+ RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
+ sigma_ms, drift_per_frame_ms);
EXPECT_EQ(4, frames_until_overuse);
}
@@ -356,8 +364,9 @@
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
frame_duration_ms, sigma_ms);
EXPECT_EQ(0, unique_overuse);
- int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
- frame_duration_ms, sigma_ms, drift_per_frame_ms);
+ int frames_until_overuse =
+ RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
+ sigma_ms, drift_per_frame_ms);
EXPECT_EQ(44, frames_until_overuse);
}
@@ -370,8 +379,9 @@
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
frame_duration_ms, sigma_ms);
EXPECT_EQ(0, unique_overuse);
- int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
- frame_duration_ms, sigma_ms, drift_per_frame_ms);
+ int frames_until_overuse =
+ RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
+ sigma_ms, drift_per_frame_ms);
EXPECT_EQ(4, frames_until_overuse);
}
@@ -390,8 +400,9 @@
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
frame_duration_ms, sigma_ms);
EXPECT_EQ(0, unique_overuse);
- int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
- frame_duration_ms, sigma_ms, drift_per_frame_ms);
+ int frames_until_overuse =
+ RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
+ sigma_ms, drift_per_frame_ms);
EXPECT_EQ(20, frames_until_overuse);
}
@@ -410,8 +421,9 @@
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
frame_duration_ms, sigma_ms);
EXPECT_EQ(0, unique_overuse);
- int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
- frame_duration_ms, sigma_ms, drift_per_frame_ms);
+ int frames_until_overuse =
+ RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
+ sigma_ms, drift_per_frame_ms);
EXPECT_EQ(44, frames_until_overuse);
}
@@ -430,8 +442,9 @@
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
frame_duration_ms, sigma_ms);
EXPECT_EQ(0, unique_overuse);
- int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
- frame_duration_ms, sigma_ms, drift_per_frame_ms);
+ int frames_until_overuse =
+ RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
+ sigma_ms, drift_per_frame_ms);
EXPECT_EQ(20, frames_until_overuse);
}
@@ -450,8 +463,9 @@
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
frame_duration_ms, sigma_ms);
EXPECT_EQ(0, unique_overuse);
- int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
- frame_duration_ms, sigma_ms, drift_per_frame_ms);
+ int frames_until_overuse =
+ RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
+ sigma_ms, drift_per_frame_ms);
EXPECT_EQ(44, frames_until_overuse);
}
@@ -470,8 +484,9 @@
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
frame_duration_ms, sigma_ms);
EXPECT_EQ(0, unique_overuse);
- int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
- frame_duration_ms, sigma_ms, drift_per_frame_ms);
+ int frames_until_overuse =
+ RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
+ sigma_ms, drift_per_frame_ms);
EXPECT_EQ(19, frames_until_overuse);
}
@@ -484,8 +499,9 @@
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
frame_duration_ms, sigma_ms);
EXPECT_EQ(0, unique_overuse);
- int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
- frame_duration_ms, sigma_ms, drift_per_frame_ms);
+ int frames_until_overuse =
+ RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
+ sigma_ms, drift_per_frame_ms);
EXPECT_EQ(5, frames_until_overuse);
}
@@ -498,8 +514,9 @@
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
frame_duration_ms, sigma_ms);
EXPECT_EQ(0, unique_overuse);
- int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
- frame_duration_ms, sigma_ms, drift_per_frame_ms);
+ int frames_until_overuse =
+ RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
+ sigma_ms, drift_per_frame_ms);
EXPECT_EQ(44, frames_until_overuse);
}
@@ -512,8 +529,9 @@
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
frame_duration_ms, sigma_ms);
EXPECT_EQ(0, unique_overuse);
- int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
- frame_duration_ms, sigma_ms, drift_per_frame_ms);
+ int frames_until_overuse =
+ RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
+ sigma_ms, drift_per_frame_ms);
EXPECT_EQ(10, frames_until_overuse);
}
@@ -532,8 +550,9 @@
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
frame_duration_ms, sigma_ms);
EXPECT_EQ(0, unique_overuse);
- int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
- frame_duration_ms, sigma_ms, drift_per_frame_ms);
+ int frames_until_overuse =
+ RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
+ sigma_ms, drift_per_frame_ms);
EXPECT_EQ(19, frames_until_overuse);
}
@@ -546,8 +565,9 @@
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
frame_duration_ms, sigma_ms);
EXPECT_EQ(0, unique_overuse);
- int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
- frame_duration_ms, sigma_ms, drift_per_frame_ms);
+ int frames_until_overuse =
+ RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
+ sigma_ms, drift_per_frame_ms);
EXPECT_EQ(5, frames_until_overuse);
}
@@ -560,8 +580,9 @@
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
frame_duration_ms, sigma_ms);
EXPECT_EQ(0, unique_overuse);
- int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
- frame_duration_ms, sigma_ms, drift_per_frame_ms);
+ int frames_until_overuse =
+ RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
+ sigma_ms, drift_per_frame_ms);
EXPECT_EQ(44, frames_until_overuse);
}
@@ -574,8 +595,9 @@
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
frame_duration_ms, sigma_ms);
EXPECT_EQ(0, unique_overuse);
- int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
- frame_duration_ms, sigma_ms, drift_per_frame_ms);
+ int frames_until_overuse =
+ RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
+ sigma_ms, drift_per_frame_ms);
EXPECT_EQ(10, frames_until_overuse);
}
@@ -594,8 +616,9 @@
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
frame_duration_ms, sigma_ms);
EXPECT_EQ(0, unique_overuse);
- int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
- frame_duration_ms, sigma_ms, drift_per_frame_ms);
+ int frames_until_overuse =
+ RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
+ sigma_ms, drift_per_frame_ms);
EXPECT_EQ(19, frames_until_overuse);
}
@@ -608,8 +631,9 @@
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
frame_duration_ms, sigma_ms);
EXPECT_EQ(0, unique_overuse);
- int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
- frame_duration_ms, sigma_ms, drift_per_frame_ms);
+ int frames_until_overuse =
+ RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
+ sigma_ms, drift_per_frame_ms);
EXPECT_EQ(5, frames_until_overuse);
}
@@ -622,8 +646,9 @@
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
frame_duration_ms, sigma_ms);
EXPECT_EQ(0, unique_overuse);
- int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
- frame_duration_ms, sigma_ms, drift_per_frame_ms);
+ int frames_until_overuse =
+ RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
+ sigma_ms, drift_per_frame_ms);
EXPECT_EQ(44, frames_until_overuse);
}
@@ -636,8 +661,9 @@
int unique_overuse = Run100000Samples(packets_per_frame, packet_size,
frame_duration_ms, sigma_ms);
EXPECT_EQ(0, unique_overuse);
- int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size,
- frame_duration_ms, sigma_ms, drift_per_frame_ms);
+ int frames_until_overuse =
+ RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms,
+ sigma_ms, drift_per_frame_ms);
EXPECT_EQ(10, frames_until_overuse);
}
@@ -648,9 +674,7 @@
"WebRTC-AdaptiveBweThreshold/Enabled-0.01,0.00018/") {}
protected:
- void SetUp() override {
- overuse_detector_.reset(new OveruseDetector());
- }
+ void SetUp() override { overuse_detector_.reset(new OveruseDetector()); }
test::ScopedFieldTrials override_field_trials_;
};
diff --git a/modules/remote_bitrate_estimator/overuse_estimator.cc b/modules/remote_bitrate_estimator/overuse_estimator.cc
index 3d8ab2a..09de5c6 100644
--- a/modules/remote_bitrate_estimator/overuse_estimator.cc
+++ b/modules/remote_bitrate_estimator/overuse_estimator.cc
@@ -73,12 +73,12 @@
}
const double h[2] = {fs_delta, 1.0};
- const double Eh[2] = {E_[0][0]*h[0] + E_[0][1]*h[1],
- E_[1][0]*h[0] + E_[1][1]*h[1]};
+ const double Eh[2] = {E_[0][0] * h[0] + E_[0][1] * h[1],
+ E_[1][0] * h[0] + E_[1][1] * h[1]};
BWE_TEST_LOGGING_PLOT(1, "d_ms", now_ms, slope_ * h[0] - offset_);
- const double residual = t_ts_delta - slope_*h[0] - offset_;
+ const double residual = t_ts_delta - slope_ * h[0] - offset_;
const bool in_stable_state =
(current_hypothesis == BandwidthUsage::kBwNormal);
@@ -92,13 +92,12 @@
min_frame_period, in_stable_state);
}
- const double denom = var_noise_ + h[0]*Eh[0] + h[1]*Eh[1];
+ const double denom = var_noise_ + h[0] * Eh[0] + h[1] * Eh[1];
- const double K[2] = {Eh[0] / denom,
- Eh[1] / denom};
+ const double K[2] = {Eh[0] / denom, Eh[1] / denom};
- const double IKh[2][2] = {{1.0 - K[0]*h[0], -K[0]*h[1]},
- {-K[1]*h[0], 1.0 - K[1]*h[1]}};
+ const double IKh[2][2] = {{1.0 - K[0] * h[0], -K[0] * h[1]},
+ {-K[1] * h[0], 1.0 - K[1] * h[1]}};
const double e00 = E_[0][0];
const double e01 = E_[0][1];
@@ -109,7 +108,8 @@
E_[1][1] = e01 * IKh[1][0] + E_[1][1] * IKh[1][1];
// The covariance matrix must be positive semi-definite.
- bool positive_semi_definite = E_[0][0] + E_[1][1] >= 0 &&
+ bool positive_semi_definite =
+ E_[0][0] + E_[1][1] >= 0 &&
E_[0][0] * E_[1][1] - E_[0][1] * E_[1][0] >= 0 && E_[0][0] >= 0;
assert(positive_semi_definite);
if (!positive_semi_definite) {
@@ -150,16 +150,15 @@
// of the network. |alpha| is tuned for 30 frames per second, but is scaled
// according to |ts_delta|.
double alpha = 0.01;
- if (num_of_deltas_ > 10*30) {
+ if (num_of_deltas_ > 10 * 30) {
alpha = 0.002;
}
// Only update the noise estimate if we're not over-using. |beta| is a
// function of alpha and the time delta since the previous update.
const double beta = pow(1 - alpha, ts_delta * 30.0 / 1000.0);
- avg_noise_ = beta * avg_noise_
- + (1 - beta) * residual;
- var_noise_ = beta * var_noise_
- + (1 - beta) * (avg_noise_ - residual) * (avg_noise_ - residual);
+ avg_noise_ = beta * avg_noise_ + (1 - beta) * residual;
+ var_noise_ = beta * var_noise_ +
+ (1 - beta) * (avg_noise_ - residual) * (avg_noise_ - residual);
if (var_noise_ < 1) {
var_noise_ = 1;
}
diff --git a/modules/remote_bitrate_estimator/overuse_estimator.h b/modules/remote_bitrate_estimator/overuse_estimator.h
index 61a7150..4c92493 100644
--- a/modules/remote_bitrate_estimator/overuse_estimator.h
+++ b/modules/remote_bitrate_estimator/overuse_estimator.h
@@ -34,20 +34,14 @@
int64_t now_ms);
// Returns the estimated noise/jitter variance in ms^2.
- double var_noise() const {
- return var_noise_;
- }
+ double var_noise() const { return var_noise_; }
// Returns the estimated inter-arrival time delta offset in ms.
- double offset() const {
- return offset_;
- }
+ double offset() const { return offset_; }
// Returns the number of deltas which the current over-use estimator state is
// based on.
- unsigned int num_of_deltas() const {
- return num_of_deltas_;
- }
+ unsigned int num_of_deltas() const { return num_of_deltas_; }
private:
double UpdateMinFramePeriod(double ts_delta);
diff --git a/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc b/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc
index b061cbd..045674d 100644
--- a/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc
+++ b/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc
@@ -35,15 +35,15 @@
kExpectedNumberOfProbes = 3
};
-static const double kTimestampToMs = 1000.0 /
- static_cast<double>(1 << kInterArrivalShift);
+static const double kTimestampToMs =
+ 1000.0 / static_cast<double>(1 << kInterArrivalShift);
-template<typename K, typename V>
+template <typename K, typename V>
std::vector<K> Keys(const std::map<K, V>& map) {
std::vector<K> keys;
keys.reserve(map.size());
for (typename std::map<K, V>::const_iterator it = map.begin();
- it != map.end(); ++it) {
+ it != map.end(); ++it) {
keys.push_back(it->first);
}
return keys;
@@ -61,39 +61,38 @@
bool RemoteBitrateEstimatorAbsSendTime::IsWithinClusterBounds(
int send_delta_ms,
const Cluster& cluster_aggregate) {
- if (cluster_aggregate.count == 0)
- return true;
- float cluster_mean = cluster_aggregate.send_mean_ms /
- static_cast<float>(cluster_aggregate.count);
- return fabs(static_cast<float>(send_delta_ms) - cluster_mean) < 2.5f;
- }
+ if (cluster_aggregate.count == 0)
+ return true;
+ float cluster_mean = cluster_aggregate.send_mean_ms /
+ static_cast<float>(cluster_aggregate.count);
+ return fabs(static_cast<float>(send_delta_ms) - cluster_mean) < 2.5f;
+}
- void RemoteBitrateEstimatorAbsSendTime::AddCluster(
- std::list<Cluster>* clusters,
- Cluster* cluster) {
- cluster->send_mean_ms /= static_cast<float>(cluster->count);
- cluster->recv_mean_ms /= static_cast<float>(cluster->count);
- cluster->mean_size /= cluster->count;
- clusters->push_back(*cluster);
- }
+void RemoteBitrateEstimatorAbsSendTime::AddCluster(std::list<Cluster>* clusters,
+ Cluster* cluster) {
+ cluster->send_mean_ms /= static_cast<float>(cluster->count);
+ cluster->recv_mean_ms /= static_cast<float>(cluster->count);
+ cluster->mean_size /= cluster->count;
+ clusters->push_back(*cluster);
+}
- RemoteBitrateEstimatorAbsSendTime::RemoteBitrateEstimatorAbsSendTime(
- RemoteBitrateObserver* observer,
- const Clock* clock)
- : clock_(clock),
- observer_(observer),
- inter_arrival_(),
- estimator_(),
- detector_(),
- incoming_bitrate_(kBitrateWindowMs, 8000),
- incoming_bitrate_initialized_(false),
- total_probes_received_(0),
- first_packet_time_ms_(-1),
- last_update_ms_(-1),
- uma_recorded_(false) {
- RTC_DCHECK(clock_);
- RTC_DCHECK(observer_);
- RTC_LOG(LS_INFO) << "RemoteBitrateEstimatorAbsSendTime: Instantiating.";
+RemoteBitrateEstimatorAbsSendTime::RemoteBitrateEstimatorAbsSendTime(
+ RemoteBitrateObserver* observer,
+ const Clock* clock)
+ : clock_(clock),
+ observer_(observer),
+ inter_arrival_(),
+ estimator_(),
+ detector_(),
+ incoming_bitrate_(kBitrateWindowMs, 8000),
+ incoming_bitrate_initialized_(false),
+ total_probes_received_(0),
+ first_packet_time_ms_(-1),
+ last_update_ms_(-1),
+ uma_recorded_(false) {
+ RTC_DCHECK(clock_);
+ RTC_DCHECK(observer_);
+ RTC_LOG(LS_INFO) << "RemoteBitrateEstimatorAbsSendTime: Instantiating.";
}
void RemoteBitrateEstimatorAbsSendTime::ComputeClusters(
@@ -102,8 +101,7 @@
int64_t prev_send_time = -1;
int64_t prev_recv_time = -1;
for (std::list<Probe>::const_iterator it = probes_.begin();
- it != probes_.end();
- ++it) {
+ it != probes_.end(); ++it) {
if (prev_send_time >= 0) {
int send_delta_ms = it->send_time_ms - prev_send_time;
int recv_delta_ms = it->recv_time_ms - prev_recv_time;
@@ -111,8 +109,7 @@
++current.num_above_min_delta;
}
if (!IsWithinClusterBounds(send_delta_ms, current)) {
- if (current.count >= kMinClusterSize &&
- current.send_mean_ms > 0.0f &&
+ if (current.count >= kMinClusterSize && current.send_mean_ms > 0.0f &&
current.recv_mean_ms > 0.0f) {
AddCluster(clusters, ¤t);
}
@@ -126,8 +123,7 @@
prev_send_time = it->send_time_ms;
prev_recv_time = it->recv_time_ms;
}
- if (current.count >= kMinClusterSize &&
- current.send_mean_ms > 0.0f &&
+ if (current.count >= kMinClusterSize && current.send_mean_ms > 0.0f &&
current.recv_mean_ms > 0.0f) {
AddCluster(clusters, ¤t);
}
@@ -139,8 +135,7 @@
int highest_probe_bitrate_bps = 0;
std::list<Cluster>::const_iterator best_it = clusters.end();
for (std::list<Cluster>::const_iterator it = clusters.begin();
- it != clusters.end();
- ++it) {
+ it != clusters.end(); ++it) {
if (it->send_mean_ms == 0 || it->recv_mean_ms == 0)
continue;
if (it->num_above_min_delta > it->count / 2 &&
diff --git a/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time_unittest.cc b/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time_unittest.cc
index ccfb646..bf7f594 100644
--- a/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time_unittest.cc
+++ b/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time_unittest.cc
@@ -14,14 +14,15 @@
namespace webrtc {
-class RemoteBitrateEstimatorAbsSendTimeTest :
- public RemoteBitrateEstimatorTest {
+class RemoteBitrateEstimatorAbsSendTimeTest
+ : public RemoteBitrateEstimatorTest {
public:
RemoteBitrateEstimatorAbsSendTimeTest() {}
virtual void SetUp() {
bitrate_estimator_.reset(new RemoteBitrateEstimatorAbsSendTime(
bitrate_observer_.get(), &clock_));
}
+
protected:
RTC_DISALLOW_COPY_AND_ASSIGN(RemoteBitrateEstimatorAbsSendTimeTest);
};
diff --git a/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc b/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc
index 612a51e..8188215 100644
--- a/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc
+++ b/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc
@@ -76,8 +76,8 @@
uma_recorded_ = true;
}
uint32_t ssrc = header.ssrc;
- uint32_t rtp_timestamp = header.timestamp +
- header.extension.transmissionTimeOffset;
+ uint32_t rtp_timestamp =
+ header.timestamp + header.extension.transmissionTimeOffset;
int64_t now_ms = clock_->TimeInMilliseconds();
rtc::CritScope cs(&crit_sect_);
SsrcOveruseEstimatorMap::iterator it = overuse_detectors_.find(ssrc);
@@ -152,7 +152,7 @@
rtc::CritScope cs_(&crit_sect_);
RTC_DCHECK_GT(process_interval_ms_, 0);
return last_process_time_ + process_interval_ms_ -
- clock_->TimeInMilliseconds();
+ clock_->TimeInMilliseconds();
}
void RemoteBitrateEstimatorSingleStream::UpdateEstimate(int64_t now_ms) {
@@ -184,10 +184,9 @@
}
AimdRateControl* remote_rate = GetRemoteRate();
- double mean_noise_var = sum_var_noise /
- static_cast<double>(overuse_detectors_.size());
- const RateControlInput input(bw_state,
- incoming_bitrate_.Rate(now_ms),
+ double mean_noise_var =
+ sum_var_noise / static_cast<double>(overuse_detectors_.size());
+ const RateControlInput input(bw_state, incoming_bitrate_.Rate(now_ms),
mean_noise_var);
uint32_t target_bitrate = remote_rate->Update(&input, now_ms);
if (remote_rate->ValidEstimate()) {
@@ -237,7 +236,7 @@
ssrcs->resize(overuse_detectors_.size());
int i = 0;
for (SsrcOveruseEstimatorMap::const_iterator it = overuse_detectors_.begin();
- it != overuse_detectors_.end(); ++it, ++i) {
+ it != overuse_detectors_.end(); ++it, ++i) {
(*ssrcs)[i] = it->first;
}
}
diff --git a/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream_unittest.cc b/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream_unittest.cc
index c4bb76bb2..120db13 100644
--- a/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream_unittest.cc
+++ b/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream_unittest.cc
@@ -14,14 +14,14 @@
namespace webrtc {
-class RemoteBitrateEstimatorSingleTest :
- public RemoteBitrateEstimatorTest {
+class RemoteBitrateEstimatorSingleTest : public RemoteBitrateEstimatorTest {
public:
RemoteBitrateEstimatorSingleTest() {}
virtual void SetUp() {
bitrate_estimator_.reset(new RemoteBitrateEstimatorSingleStream(
bitrate_observer_.get(), &clock_));
}
+
protected:
RTC_DISALLOW_COPY_AND_ASSIGN(RemoteBitrateEstimatorSingleTest);
};
diff --git a/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc b/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc
index 0b3ff43..5e11794 100644
--- a/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc
+++ b/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc
@@ -69,8 +69,10 @@
RtpPacket* packet = new RtpPacket;
packet->send_time = time_now_us + kSendSideOffsetUs;
packet->size = packet_size;
- packet->rtp_timestamp = rtp_timestamp_offset_ + static_cast<uint32_t>(
- ((frequency_ / 1000) * packet->send_time + 500) / 1000);
+ packet->rtp_timestamp =
+ rtp_timestamp_offset_ +
+ static_cast<uint32_t>(((frequency_ / 1000) * packet->send_time + 500) /
+ 1000);
packet->ssrc = ssrc_;
packets->push_back(packet);
}
@@ -90,11 +92,12 @@
}
RtcpPacket* rtcp = new RtcpPacket;
int64_t send_time_us = time_now_us + kSendSideOffsetUs;
- rtcp->timestamp = rtp_timestamp_offset_ + static_cast<uint32_t>(
- ((frequency_ / 1000) * send_time_us + 500) / 1000);
+ rtcp->timestamp =
+ rtp_timestamp_offset_ +
+ static_cast<uint32_t>(((frequency_ / 1000) * send_time_us + 500) / 1000);
rtcp->ntp_secs = send_time_us / 1000000;
- rtcp->ntp_frac = static_cast<int64_t>((send_time_us % 1000000) *
- kNtpFracPerMs);
+ rtcp->ntp_frac =
+ static_cast<int64_t>((send_time_us % 1000000) * kNtpFracPerMs);
rtcp->ssrc = ssrc_;
next_rtcp_time_ = time_now_us + kRtcpIntervalUs;
return rtcp;
@@ -119,12 +122,10 @@
}
StreamGenerator::StreamGenerator(int capacity, int64_t time_now)
- : capacity_(capacity),
- prev_arrival_time_us_(time_now) {}
+ : capacity_(capacity), prev_arrival_time_us_(time_now) {}
StreamGenerator::~StreamGenerator() {
- for (StreamMap::iterator it = streams_.begin(); it != streams_.end();
- ++it) {
+ for (StreamMap::iterator it = streams_.begin(); it != streams_.end(); ++it) {
delete it->second;
}
streams_.clear();
@@ -153,8 +154,9 @@
int total_bitrate_after = 0;
for (StreamMap::iterator it = streams_.begin(); it != streams_.end(); ++it) {
bitrate_before += it->second->bitrate_bps();
- int64_t bitrate_after = (bitrate_before * bitrate_bps +
- total_bitrate_before / 2) / total_bitrate_before;
+ int64_t bitrate_after =
+ (bitrate_before * bitrate_bps + total_bitrate_before / 2) /
+ total_bitrate_before;
it->second->set_bitrate_bps(bitrate_after - total_bitrate_after);
total_bitrate_after += it->second->bitrate_bps();
}
@@ -174,17 +176,18 @@
assert(packets != NULL);
assert(packets->empty());
assert(capacity_ > 0);
- StreamMap::iterator it = std::min_element(streams_.begin(), streams_.end(),
- RtpStream::Compare);
+ StreamMap::iterator it =
+ std::min_element(streams_.begin(), streams_.end(), RtpStream::Compare);
(*it).second->GenerateFrame(time_now_us, packets);
int i = 0;
for (RtpStream::PacketList::iterator packet_it = packets->begin();
- packet_it != packets->end(); ++packet_it) {
+ packet_it != packets->end(); ++packet_it) {
int capacity_bpus = capacity_ / 1000;
int64_t required_network_time_us =
(8 * 1000 * (*packet_it)->size + capacity_bpus / 2) / capacity_bpus;
- prev_arrival_time_us_ = std::max(time_now_us + required_network_time_us,
- prev_arrival_time_us_ + required_network_time_us);
+ prev_arrival_time_us_ =
+ std::max(time_now_us + required_network_time_us,
+ prev_arrival_time_us_ + required_network_time_us);
(*packet_it)->arrival_time = prev_arrival_time_us_;
++i;
}
@@ -196,21 +199,21 @@
RemoteBitrateEstimatorTest::RemoteBitrateEstimatorTest()
: clock_(100000000),
bitrate_observer_(new testing::TestBitrateObserver),
- stream_generator_(new testing::StreamGenerator(
- 1e6, // Capacity.
- clock_.TimeInMicroseconds())),
+ stream_generator_(
+ new testing::StreamGenerator(1e6, // Capacity.
+ clock_.TimeInMicroseconds())),
arrival_time_offset_ms_(0) {}
RemoteBitrateEstimatorTest::~RemoteBitrateEstimatorTest() {}
void RemoteBitrateEstimatorTest::AddDefaultStream() {
- stream_generator_->AddStream(new testing::RtpStream(
- 30, // Frames per second.
- 3e5, // Bitrate.
- 1, // SSRC.
- 90000, // RTP frequency.
- 0xFFFFF000, // Timestamp offset.
- 0)); // RTCP receive time.
+ stream_generator_->AddStream(
+ new testing::RtpStream(30, // Frames per second.
+ 3e5, // Bitrate.
+ 1, // SSRC.
+ 90000, // RTP frequency.
+ 0xFFFFF000, // Timestamp offset.
+ 0)); // RTCP receive time.
}
uint32_t RemoteBitrateEstimatorTest::AbsSendTime(int64_t t, int64_t denom) {
@@ -250,8 +253,8 @@
RTC_DCHECK_GT(bitrate_bps, 0);
stream_generator_->SetBitrateBps(bitrate_bps);
testing::RtpStream::PacketList packets;
- int64_t next_time_us = stream_generator_->GenerateFrame(
- &packets, clock_.TimeInMicroseconds());
+ int64_t next_time_us =
+ stream_generator_->GenerateFrame(&packets, clock_.TimeInMicroseconds());
bool overuse = false;
while (!packets.empty()) {
testing::RtpStream::RtpPacket* packet = packets.front();
@@ -339,8 +342,8 @@
absolute_send_time);
clock_.AdvanceTimeMilliseconds(1000 / kFramerate);
timestamp += 90 * kFrameIntervalMs;
- absolute_send_time = AddAbsSendTime(absolute_send_time,
- kFrameIntervalAbsSendTime);
+ absolute_send_time =
+ AddAbsSendTime(absolute_send_time, kFrameIntervalAbsSendTime);
}
bitrate_estimator_->Process();
EXPECT_TRUE(bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_bps));
@@ -377,19 +380,18 @@
absolute_send_time);
clock_.AdvanceTimeMilliseconds(kFrameIntervalMs);
timestamp += 90 * kFrameIntervalMs;
- absolute_send_time = AddAbsSendTime(absolute_send_time,
- kFrameIntervalAbsSendTime);
+ absolute_send_time =
+ AddAbsSendTime(absolute_send_time, kFrameIntervalAbsSendTime);
}
bitrate_estimator_->Process();
EXPECT_TRUE(bitrate_observer_->updated());
- EXPECT_NEAR(expected_bitrate_bps,
- bitrate_observer_->latest_bitrate(),
+ EXPECT_NEAR(expected_bitrate_bps, bitrate_observer_->latest_bitrate(),
kAcceptedBitrateErrorBps);
for (int i = 0; i < 10; ++i) {
clock_.AdvanceTimeMilliseconds(2 * kFrameIntervalMs);
timestamp += 2 * 90 * kFrameIntervalMs;
- absolute_send_time = AddAbsSendTime(absolute_send_time,
- 2 * kFrameIntervalAbsSendTime);
+ absolute_send_time =
+ AddAbsSendTime(absolute_send_time, 2 * kFrameIntervalAbsSendTime);
IncomingPacket(kDefaultSsrc, 1000, clock_.TimeInMilliseconds(), timestamp,
absolute_send_time);
IncomingPacket(
@@ -400,8 +402,7 @@
}
bitrate_estimator_->Process();
EXPECT_TRUE(bitrate_observer_->updated());
- EXPECT_NEAR(expected_bitrate_bps,
- bitrate_observer_->latest_bitrate(),
+ EXPECT_NEAR(expected_bitrate_bps, bitrate_observer_->latest_bitrate(),
kAcceptedBitrateErrorBps);
}
@@ -472,7 +473,8 @@
ASSERT_EQ(bitrate_sum, kStartBitrate);
}
if (wrap_time_stamp) {
- stream_generator_->set_rtp_timestamp_offset(kDefaultSsrc,
+ stream_generator_->set_rtp_timestamp_offset(
+ kDefaultSsrc,
std::numeric_limits<uint32_t>::max() - steady_state_time * 90000);
}
@@ -538,8 +540,8 @@
bitrate_estimator_->Process();
clock_.AdvanceTimeMilliseconds(kFrameIntervalMs);
timestamp += 90 * kFrameIntervalMs;
- absolute_send_time = AddAbsSendTime(absolute_send_time,
- kFrameIntervalAbsSendTime);
+ absolute_send_time =
+ AddAbsSendTime(absolute_send_time, kFrameIntervalAbsSendTime);
}
EXPECT_TRUE(bitrate_observer_->updated());
EXPECT_GE(bitrate_observer_->latest_bitrate(), 400000u);
@@ -558,8 +560,8 @@
absolute_send_time);
clock_.AdvanceTimeMilliseconds(kFrameIntervalMs / kTimestampGroupLength);
timestamp += 1;
- absolute_send_time = AddAbsSendTime(absolute_send_time,
- kSingleRtpTickAbsSendTime);
+ absolute_send_time =
+ AddAbsSendTime(absolute_send_time, kSingleRtpTickAbsSendTime);
}
// Increase time until next batch to simulate over-use.
clock_.AdvanceTimeMilliseconds(10);
@@ -575,8 +577,7 @@
EXPECT_LT(bitrate_observer_->latest_bitrate(), 400000u);
}
-void RemoteBitrateEstimatorTest::TestWrappingHelper(
- int silence_time_s) {
+void RemoteBitrateEstimatorTest::TestWrappingHelper(int silence_time_s) {
const int kFramerate = 100;
const int kFrameIntervalMs = 1000 / kFramerate;
const uint32_t kFrameIntervalAbsSendTime = AbsSendTime(1, kFramerate);
@@ -588,8 +589,8 @@
absolute_send_time);
timestamp += kFrameIntervalMs;
clock_.AdvanceTimeMilliseconds(kFrameIntervalMs);
- absolute_send_time = AddAbsSendTime(absolute_send_time,
- kFrameIntervalAbsSendTime);
+ absolute_send_time =
+ AddAbsSendTime(absolute_send_time, kFrameIntervalAbsSendTime);
bitrate_estimator_->Process();
}
uint32_t bitrate_before = 0;
@@ -597,16 +598,16 @@
bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_before);
clock_.AdvanceTimeMilliseconds(silence_time_s * 1000);
- absolute_send_time = AddAbsSendTime(absolute_send_time,
- AbsSendTime(silence_time_s, 1));
+ absolute_send_time =
+ AddAbsSendTime(absolute_send_time, AbsSendTime(silence_time_s, 1));
bitrate_estimator_->Process();
for (size_t i = 0; i < 21; ++i) {
IncomingPacket(kDefaultSsrc, 1000, clock_.TimeInMilliseconds(), timestamp,
absolute_send_time);
timestamp += kFrameIntervalMs;
clock_.AdvanceTimeMilliseconds(2 * kFrameIntervalMs);
- absolute_send_time = AddAbsSendTime(absolute_send_time,
- kFrameIntervalAbsSendTime);
+ absolute_send_time =
+ AddAbsSendTime(absolute_send_time, kFrameIntervalAbsSendTime);
bitrate_estimator_->Process();
}
uint32_t bitrate_after = 0;
diff --git a/modules/remote_bitrate_estimator/remote_estimator_proxy.cc b/modules/remote_bitrate_estimator/remote_estimator_proxy.cc
index 1e42266..8cde28d 100644
--- a/modules/remote_bitrate_estimator/remote_estimator_proxy.cc
+++ b/modules/remote_bitrate_estimator/remote_estimator_proxy.cc
@@ -10,8 +10,8 @@
#include "modules/remote_bitrate_estimator/remote_estimator_proxy.h"
-#include <limits>
#include <algorithm>
+#include <limits>
#include "modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h"
#include "rtc_base/checks.h"
diff --git a/modules/remote_bitrate_estimator/remote_estimator_proxy_unittest.cc b/modules/remote_bitrate_estimator/remote_estimator_proxy_unittest.cc
index 4197fcc..6c1fc8c 100644
--- a/modules/remote_bitrate_estimator/remote_estimator_proxy_unittest.cc
+++ b/modules/remote_bitrate_estimator/remote_estimator_proxy_unittest.cc
@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "modules/pacing/packet_router.h"
#include "modules/remote_bitrate_estimator/remote_estimator_proxy.h"
+#include "modules/pacing/packet_router.h"
#include "modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h"
#include "system_wrappers/include/clock.h"
#include "test/gmock.h"
diff --git a/modules/remote_bitrate_estimator/test/bwe.cc b/modules/remote_bitrate_estimator/test/bwe.cc
index 656cb5b..536743f 100644
--- a/modules/remote_bitrate_estimator/test/bwe.cc
+++ b/modules/remote_bitrate_estimator/test/bwe.cc
@@ -34,15 +34,13 @@
: flow_id_(flow_id),
received_packets_(kSetCapacity),
rate_counter_(),
- loss_account_() {
-}
+ loss_account_() {}
BweReceiver::BweReceiver(int flow_id, int64_t window_size_ms)
: flow_id_(flow_id),
received_packets_(kSetCapacity),
rate_counter_(window_size_ms),
- loss_account_() {
-}
+ loss_account_() {}
void BweReceiver::ReceivePacket(int64_t arrival_time_ms,
const MediaPacket& media_packet) {
diff --git a/modules/remote_bitrate_estimator/test/bwe_test.cc b/modules/remote_bitrate_estimator/test/bwe_test.cc
index 71088ff..737847c 100644
--- a/modules/remote_bitrate_estimator/test/bwe_test.cc
+++ b/modules/remote_bitrate_estimator/test/bwe_test.cc
@@ -34,8 +34,7 @@
namespace bwe {
PacketProcessorRunner::PacketProcessorRunner(PacketProcessor* processor)
- : processor_(processor) {
-}
+ : processor_(processor) {}
PacketProcessorRunner::~PacketProcessorRunner() {
for (Packet* packet : queue_)
@@ -97,8 +96,7 @@
}
// Plot link capacity by default.
-BweTest::BweTest() : BweTest(true) {
-}
+BweTest::BweTest() : BweTest(true) {}
BweTest::BweTest(bool plot_capacity)
: run_time_ms_(0),
@@ -117,9 +115,8 @@
void BweTest::SetUp() {
const ::testing::TestInfo* const test_info =
::testing::UnitTest::GetInstance()->current_test_info();
- std::string test_name =
- std::string(test_info->test_case_name()) + "_" +
- std::string(test_info->name());
+ std::string test_name = std::string(test_info->test_case_name()) + "_" +
+ std::string(test_info->name());
BWE_TEST_LOGGING_GLOBAL_CONTEXT(test_name);
BWE_TEST_LOGGING_GLOBAL_ENABLE(false);
}
@@ -769,8 +766,8 @@
// max_delay_ms = 1000;
std::string title("5.6_Long_TCP_Fairness");
- std::string flow_name = std::string() +
- bwe_names[bwe_type] + 'x' + bwe_names[kTcpEstimator];
+ std::string flow_name =
+ std::string() + bwe_names[bwe_type] + 'x' + bwe_names[kTcpEstimator];
RunFairnessTest(bwe_type, kNumRmcatFlows, kNumTcpFlows, kRunTimeS,
kCapacityKbps, max_delay_ms, rtt_ms, kMaxJitterMs, kOffSetsMs,
diff --git a/modules/remote_bitrate_estimator/test/bwe_test.h b/modules/remote_bitrate_estimator/test/bwe_test.h
index 43156e7..24d5f10 100644
--- a/modules/remote_bitrate_estimator/test/bwe_test.h
+++ b/modules/remote_bitrate_estimator/test/bwe_test.h
@@ -133,8 +133,7 @@
Link uplink_;
private:
- void FindPacketsToProcess(const FlowIds& flow_ids, Packets* in,
- Packets* out);
+ void FindPacketsToProcess(const FlowIds& flow_ids, Packets* in, Packets* out);
void GiveFeedbackToAffectedSenders(PacketReceiver* receiver);
int64_t run_time_ms_;
diff --git a/modules/remote_bitrate_estimator/test/bwe_test_baselinefile.cc b/modules/remote_bitrate_estimator/test/bwe_test_baselinefile.cc
index 7b12f06..d273e21 100644
--- a/modules/remote_bitrate_estimator/test/bwe_test_baselinefile.cc
+++ b/modules/remote_bitrate_estimator/test/bwe_test_baselinefile.cc
@@ -42,8 +42,7 @@
// the baseline file is missing. This is the default when verifying files, but
// not when updating (i.e. we always write it out if missing).
BaseLineFileVerify(const std::string& filepath, bool allow_missing_file)
- : reader_(),
- fail_to_read_response_(false) {
+ : reader_(), fail_to_read_response_(false) {
std::unique_ptr<ResourceFileReader> reader;
reader.reset(ResourceFileReader::Create(filepath, "bin"));
if (!reader.get()) {
@@ -72,7 +71,7 @@
reader_->Read(&read_bps) && read_bps == estimate_bps) {
} else {
printf("ERROR: Baseline differs starting at: %d ms (%d vs %d)!\n",
- static_cast<uint32_t>(time_ms), estimate_bps, read_bps);
+ static_cast<uint32_t>(time_ms), estimate_bps, read_bps);
reader_.reset(NULL);
}
}
@@ -101,9 +100,7 @@
public:
BaseLineFileUpdate(const std::string& filepath,
BaseLineFileInterface* verifier)
- : verifier_(verifier),
- output_content_(),
- filepath_(filepath) {
+ : verifier_(verifier), output_content_(), filepath_(filepath) {
output_content_.push_back(kMagicMarker);
output_content_.push_back(kFileVersion1);
}
@@ -126,13 +123,13 @@
writer.reset(OutputFileWriter::Create(filepath_, "bin"));
if (!writer.get()) {
printf("WARNING: Cannot create output file: %s.bin\n",
- filepath_.c_str());
+ filepath_.c_str());
return false;
}
printf("NOTE: Writing baseline file for BWE test: %s.bin\n",
filepath_.c_str());
for (std::vector<uint32_t>::iterator it = output_content_.begin();
- it != output_content_.end(); ++it) {
+ it != output_content_.end(); ++it) {
writer->Write(*it);
}
return true;
@@ -150,7 +147,8 @@
};
BaseLineFileInterface* BaseLineFileInterface::Create(
- const std::string& filename, bool write_output_file) {
+ const std::string& filename,
+ bool write_output_file) {
std::string filepath = filename;
std::replace(filepath.begin(), filepath.end(), '/', '_');
filepath = std::string(kResourceSubDir) + "/" + filepath;
diff --git a/modules/remote_bitrate_estimator/test/bwe_test_fileutils.cc b/modules/remote_bitrate_estimator/test/bwe_test_fileutils.cc
index ffd410e..afea787 100644
--- a/modules/remote_bitrate_estimator/test/bwe_test_fileutils.cc
+++ b/modules/remote_bitrate_estimator/test/bwe_test_fileutils.cc
@@ -80,8 +80,8 @@
OutputFileWriter* OutputFileWriter::Create(const std::string& filename,
const std::string& extension) {
- std::string filepath = webrtc::test::OutputPath() + filename + "." +
- extension;
+ std::string filepath =
+ webrtc::test::OutputPath() + filename + "." + extension;
FILE* file = fopen(filepath.c_str(), "wb");
if (file == NULL) {
BWE_TEST_LOGGING_CONTEXT("OutputFileWriter");
diff --git a/modules/remote_bitrate_estimator/test/bwe_test_framework.cc b/modules/remote_bitrate_estimator/test/bwe_test_framework.cc
index 2a6614f..8b36cd7 100644
--- a/modules/remote_bitrate_estimator/test/bwe_test_framework.cc
+++ b/modules/remote_bitrate_estimator/test/bwe_test_framework.cc
@@ -39,9 +39,7 @@
return (max_delay_us_ == 0 || max_delay_us_ >= packet_delay_us);
}
- const Stats<double>& delay_stats() const {
- return delay_stats_;
- }
+ const Stats<double>& delay_stats() const { return delay_stats_; }
private:
int64_t max_delay_us_;
@@ -50,7 +48,7 @@
RTC_DISALLOW_COPY_AND_ASSIGN(DelayCapHelper);
};
-const FlowIds CreateFlowIds(const int *flow_ids_array, size_t num_flow_ids) {
+const FlowIds CreateFlowIds(const int* flow_ids_array, size_t num_flow_ids) {
FlowIds flow_ids(&flow_ids_array[0], flow_ids_array + num_flow_ids);
return flow_ids;
}
@@ -109,8 +107,7 @@
sender_timestamp_us_(send_time_us),
payload_size_(payload_size) {}
-Packet::~Packet() {
-}
+Packet::~Packet() {}
bool Packet::operator<(const Packet& rhs) const {
return send_time_us_ < rhs.send_time_us_;
@@ -138,8 +135,7 @@
int64_t send_time_us,
size_t payload_size,
const RTPHeader& header)
- : Packet(flow_id, send_time_us, payload_size), header_(header) {
-}
+ : Packet(flow_id, send_time_us, payload_size), header_(header) {}
MediaPacket::MediaPacket(int64_t send_time_us, uint16_t sequence_number)
: Packet(0, send_time_us, 0) {
@@ -149,8 +145,9 @@
void MediaPacket::SetAbsSendTimeMs(int64_t abs_send_time_ms) {
header_.extension.hasAbsoluteSendTime = true;
- header_.extension.absoluteSendTime = ((static_cast<int64_t>(abs_send_time_ms *
- (1 << 18)) + 500) / 1000) & 0x00fffffful;
+ header_.extension.absoluteSendTime =
+ ((static_cast<int64_t>(abs_send_time_ms * (1 << 18)) + 500) / 1000) &
+ 0x00fffffful;
}
BbrBweFeedback::BbrBweFeedback(
@@ -168,8 +165,7 @@
RTCPReportBlock report_block)
: FeedbackPacket(flow_id, send_time_us, last_send_time_ms),
estimated_bps_(estimated_bps),
- report_block_(report_block) {
-}
+ report_block_(report_block) {}
SendSideBweFeedback::SendSideBweFeedback(
int flow_id,
@@ -272,7 +268,6 @@
LogStats();
}
-
void RateCounterFilter::LogStats() {
BWE_TEST_LOGGING_CONTEXT("RateCounterFilter");
packets_per_second_stats_.Log("pps");
@@ -315,15 +310,13 @@
LossFilter::LossFilter(PacketProcessorListener* listener, int flow_id)
: PacketProcessor(listener, flow_id, kRegular),
random_(0x12345678),
- loss_fraction_(0.0f) {
-}
+ loss_fraction_(0.0f) {}
LossFilter::LossFilter(PacketProcessorListener* listener,
const FlowIds& flow_ids)
: PacketProcessor(listener, flow_ids, kRegular),
random_(0x12345678),
- loss_fraction_(0.0f) {
-}
+ loss_fraction_(0.0f) {}
void LossFilter::SetLoss(float loss_percent) {
BWE_TEST_LOGGING_ENABLE(false);
@@ -335,7 +328,7 @@
void LossFilter::RunFor(int64_t /*time_ms*/, Packets* in_out) {
assert(in_out);
- for (PacketsIt it = in_out->begin(); it != in_out->end(); ) {
+ for (PacketsIt it = in_out->begin(); it != in_out->end();) {
if (random_.Rand<float>() < loss_fraction_) {
delete *it;
it = in_out->erase(it);
@@ -350,15 +343,13 @@
DelayFilter::DelayFilter(PacketProcessorListener* listener, int flow_id)
: PacketProcessor(listener, flow_id, kRegular),
one_way_delay_us_(kDefaultOneWayDelayUs),
- last_send_time_us_(0) {
-}
+ last_send_time_us_(0) {}
DelayFilter::DelayFilter(PacketProcessorListener* listener,
const FlowIds& flow_ids)
: PacketProcessor(listener, flow_ids, kRegular),
one_way_delay_us_(kDefaultOneWayDelayUs),
- last_send_time_us_(0) {
-}
+ last_send_time_us_(0) {}
void DelayFilter::SetOneWayDelayMs(int64_t one_way_delay_ms) {
BWE_TEST_LOGGING_ENABLE(false);
@@ -381,8 +372,7 @@
random_(0x89674523),
stddev_jitter_us_(0),
last_send_time_us_(0),
- reordering_(false) {
-}
+ reordering_(false) {}
JitterFilter::JitterFilter(PacketProcessorListener* listener,
const FlowIds& flow_ids)
@@ -390,8 +380,7 @@
random_(0x89674523),
stddev_jitter_us_(0),
last_send_time_us_(0),
- reordering_(false) {
-}
+ reordering_(false) {}
const int kN = 3; // Truncated N sigma gaussian.
@@ -410,7 +399,7 @@
const int64_t gaussian_random = random->Gaussian(mean, std_dev);
return rtc::SafeClamp(gaussian_random, -kN * std_dev, kN * std_dev);
}
-}
+} // namespace
void JitterFilter::RunFor(int64_t /*time_ms*/, Packets* in_out) {
assert(in_out);
@@ -448,15 +437,13 @@
ReorderFilter::ReorderFilter(PacketProcessorListener* listener, int flow_id)
: PacketProcessor(listener, flow_id, kRegular),
random_(0x27452389),
- reorder_fraction_(0.0f) {
-}
+ reorder_fraction_(0.0f) {}
ReorderFilter::ReorderFilter(PacketProcessorListener* listener,
const FlowIds& flow_ids)
: PacketProcessor(listener, flow_ids, kRegular),
random_(0x27452389),
- reorder_fraction_(0.0f) {
-}
+ reorder_fraction_(0.0f) {}
void ReorderFilter::SetReorder(float reorder_percent) {
BWE_TEST_LOGGING_ENABLE(false);
@@ -490,16 +477,14 @@
: PacketProcessor(listener, flow_id, kRegular),
capacity_kbps_(kDefaultKbps),
last_send_time_us_(0),
- delay_cap_helper_(new DelayCapHelper()) {
-}
+ delay_cap_helper_(new DelayCapHelper()) {}
ChokeFilter::ChokeFilter(PacketProcessorListener* listener,
const FlowIds& flow_ids)
: PacketProcessor(listener, flow_ids, kRegular),
capacity_kbps_(kDefaultKbps),
last_send_time_us_(0),
- delay_cap_helper_(new DelayCapHelper()) {
-}
+ delay_cap_helper_(new DelayCapHelper()) {}
ChokeFilter::~ChokeFilter() {}
@@ -515,7 +500,7 @@
void ChokeFilter::RunFor(int64_t /*time_ms*/, Packets* in_out) {
assert(in_out);
- for (PacketsIt it = in_out->begin(); it != in_out->end(); ) {
+ for (PacketsIt it = in_out->begin(); it != in_out->end();) {
int64_t earliest_send_time_us =
std::max(last_send_time_us_, (*it)->send_time_us());
int64_t new_send_time_us =
@@ -556,8 +541,7 @@
name_(""),
delay_cap_helper_(new DelayCapHelper()),
packets_per_second_stats_(),
- kbps_stats_() {
-}
+ kbps_stats_() {}
TraceBasedDeliveryFilter::TraceBasedDeliveryFilter(
PacketProcessorListener* listener,
@@ -571,8 +555,7 @@
name_(""),
delay_cap_helper_(new DelayCapHelper()),
packets_per_second_stats_(),
- kbps_stats_() {
-}
+ kbps_stats_() {}
TraceBasedDeliveryFilter::TraceBasedDeliveryFilter(
PacketProcessorListener* listener,
@@ -587,11 +570,9 @@
name_(name),
delay_cap_helper_(new DelayCapHelper()),
packets_per_second_stats_(),
- kbps_stats_() {
-}
+ kbps_stats_() {}
-TraceBasedDeliveryFilter::~TraceBasedDeliveryFilter() {
-}
+TraceBasedDeliveryFilter::~TraceBasedDeliveryFilter() {}
bool TraceBasedDeliveryFilter::Init(const std::string& filename) {
FILE* trace_file = fopen(filename.c_str(), "r");
@@ -769,8 +750,7 @@
uint32_t kbps,
uint32_t ssrc,
int64_t first_frame_offset_ms)
- : VideoSource(flow_id, fps, kbps, ssrc, first_frame_offset_ms) {
-}
+ : VideoSource(flow_id, fps, kbps, ssrc, first_frame_offset_ms) {}
void AdaptiveVideoSource::SetBitrateBps(int bitrate_bps) {
bits_per_second_ = bitrate_bps;
@@ -787,8 +767,7 @@
key_frame_interval_(key_frame_interval),
frame_counter_(0),
compensation_bytes_(0),
- compensation_per_frame_(0) {
-}
+ compensation_per_frame_(0) {}
uint32_t PeriodicKeyFrameSource::NextFrameSize() {
uint32_t payload_size = frame_size_bytes_;
diff --git a/modules/remote_bitrate_estimator/test/bwe_test_framework.h b/modules/remote_bitrate_estimator/test/bwe_test_framework.h
index 983a79a..bfb4935 100644
--- a/modules/remote_bitrate_estimator/test/bwe_test_framework.h
+++ b/modules/remote_bitrate_estimator/test/bwe_test_framework.h
@@ -75,7 +75,7 @@
};
typedef std::set<int> FlowIds;
-const FlowIds CreateFlowIds(const int *flow_ids_array, size_t num_flow_ids);
+const FlowIds CreateFlowIds(const int* flow_ids_array, size_t num_flow_ids);
const FlowIds CreateFlowIdRange(int initial_value, int last_value);
template <typename T>
@@ -85,7 +85,8 @@
return *a < *b;
}
-template<typename T> class Stats {
+template <typename T>
+class Stats {
public:
Stats()
: data_(),
@@ -95,12 +96,9 @@
mean_(0),
variance_(0),
min_(0),
- max_(0) {
- }
+ max_(0) {}
- void Push(T data_point) {
- data_.push_back(data_point);
- }
+ void Push(T data_point) { data_.push_back(data_point); }
T GetMean() {
if (last_mean_count_ != data_.size()) {
@@ -125,9 +123,7 @@
}
return variance_;
}
- T GetStdDev() {
- return sqrt(static_cast<double>(GetVariance()));
- }
+ T GetStdDev() { return sqrt(static_cast<double>(GetVariance())); }
T GetMin() {
RefreshMinMax();
return min_;
@@ -139,14 +135,14 @@
std::string AsString() {
std::stringstream ss;
- ss << (GetMean() >= 0 ? GetMean() : -1) << ", " <<
- (GetStdDev() >= 0 ? GetStdDev() : -1);
+ ss << (GetMean() >= 0 ? GetMean() : -1) << ", "
+ << (GetStdDev() >= 0 ? GetStdDev() : -1);
return ss.str();
}
void Log(const std::string& units) {
- BWE_TEST_LOGGING_LOG5("", "%f %s\t+/-%f\t[%f,%f]",
- GetMean(), units.c_str(), GetStdDev(), GetMin(), GetMax());
+ BWE_TEST_LOGGING_LOG5("", "%f %s\t+/-%f\t[%f,%f]", GetMean(), units.c_str(),
+ GetStdDev(), GetMin(), GetMax());
}
private:
diff --git a/modules/remote_bitrate_estimator/test/bwe_test_framework_unittest.cc b/modules/remote_bitrate_estimator/test/bwe_test_framework_unittest.cc
index 2562732..3e41ac1 100644
--- a/modules/remote_bitrate_estimator/test/bwe_test_framework_unittest.cc
+++ b/modules/remote_bitrate_estimator/test/bwe_test_framework_unittest.cc
@@ -153,8 +153,10 @@
virtual ~BweTestFramework_RateCounterFilterTest() {}
protected:
- void TestRateCounter(int64_t run_for_ms, uint32_t payload_bits,
- uint32_t expected_pps, uint32_t expected_bps) {
+ void TestRateCounter(int64_t run_for_ms,
+ uint32_t payload_bits,
+ uint32_t expected_pps,
+ uint32_t expected_bps) {
Packets packets;
RTPHeader header;
// "Send" a packet every 10 ms.
@@ -280,7 +282,8 @@
}
protected:
- void TestDelayFilter(int64_t run_for_ms, uint32_t in_packets,
+ void TestDelayFilter(int64_t run_for_ms,
+ uint32_t in_packets,
uint32_t out_packets) {
Packets packets;
for (uint32_t i = 0; i < in_packets; ++i) {
@@ -301,7 +304,7 @@
void TestDelayFilter(int64_t delay_ms) {
filter_.SetOneWayDelayMs(delay_ms);
- TestDelayFilter(1, 0, 0); // No input should yield no output
+ TestDelayFilter(1, 0, 0); // No input should yield no output
// Single packet
TestDelayFilter(0, 1, 1);
@@ -357,8 +360,8 @@
TestDelayFilter(1, 10, 10); // Expect no delay (delay time is zero)
TestDelayFilter(1, 0, 0); // Check no packets are still in buffer
filter_.SetOneWayDelayMs(0);
- TestDelayFilter(1, 5, 5); // Expect no delay (delay time is zero)
- TestDelayFilter(1, 0, 0); // Check no packets are still in buffer
+ TestDelayFilter(1, 5, 5); // Expect no delay (delay time is zero)
+ TestDelayFilter(1, 0, 0); // Check no packets are still in buffer
}
TEST_F(BweTestFramework_DelayFilterTest, Delay1) {
@@ -580,11 +583,7 @@
class BweTestFramework_ChokeFilterTest : public ::testing::Test {
public:
BweTestFramework_ChokeFilterTest()
- : now_ms_(0),
- sequence_number_(0),
- output_packets_(),
- send_times_us_() {
- }
+ : now_ms_(0), sequence_number_(0), output_packets_(), send_times_us_() {}
virtual ~BweTestFramework_ChokeFilterTest() {
for (auto* packet : output_packets_)
delete packet;
diff --git a/modules/remote_bitrate_estimator/test/bwe_test_logging.cc b/modules/remote_bitrate_estimator/test/bwe_test_logging.cc
index 68f3cb0..571ed50 100644
--- a/modules/remote_bitrate_estimator/test/bwe_test_logging.cc
+++ b/modules/remote_bitrate_estimator/test/bwe_test_logging.cc
@@ -41,12 +41,14 @@
Logging::GetInstance()->PushState(ToString(name), timestamp_ms, enabled);
}
-Logging::Context::Context(const std::string& name, int64_t timestamp_ms,
+Logging::Context::Context(const std::string& name,
+ int64_t timestamp_ms,
bool enabled) {
Logging::GetInstance()->PushState(name, timestamp_ms, enabled);
}
-Logging::Context::Context(const char* name, int64_t timestamp_ms,
+Logging::Context::Context(const char* name,
+ int64_t timestamp_ms,
bool enabled) {
Logging::GetInstance()->PushState(name, timestamp_ms, enabled);
}
@@ -204,20 +206,16 @@
}
}
-Logging::Logging()
- : thread_map_() {
-}
+Logging::Logging() : thread_map_() {}
Logging::~Logging() = default;
Logging::State::State() : tag(""), timestamp_ms(0), enabled(true) {}
-Logging::State::State(const std::string& tag, int64_t timestamp_ms,
+Logging::State::State(const std::string& tag,
+ int64_t timestamp_ms,
bool enabled)
- : tag(tag),
- timestamp_ms(timestamp_ms),
- enabled(enabled) {
-}
+ : tag(tag), timestamp_ms(timestamp_ms), enabled(enabled) {}
void Logging::State::MergePrevious(const State& previous) {
if (tag.empty()) {
@@ -229,7 +227,8 @@
enabled = previous.enabled && enabled;
}
-void Logging::PushState(const std::string& append_to_tag, int64_t timestamp_ms,
+void Logging::PushState(const std::string& append_to_tag,
+ int64_t timestamp_ms,
bool enabled) {
rtc::CritScope cs(&crit_sect_);
State new_state(append_to_tag, timestamp_ms, enabled);
diff --git a/modules/remote_bitrate_estimator/test/bwe_test_logging.h b/modules/remote_bitrate_estimator/test/bwe_test_logging.h
index 0f84249..20a29cc 100644
--- a/modules/remote_bitrate_estimator/test/bwe_test_logging.h
+++ b/modules/remote_bitrate_estimator/test/bwe_test_logging.h
@@ -132,57 +132,56 @@
#include "rtc_base/constructormagic.h"
#include "rtc_base/criticalsection.h"
-#define BWE_TEST_LOGGING_GLOBAL_CONTEXT(name) \
- do { \
- webrtc::testing::bwe::Logging::GetInstance()->SetGlobalContext(name); \
- } while (0)
+#define BWE_TEST_LOGGING_GLOBAL_CONTEXT(name) \
+ do { \
+ webrtc::testing::bwe::Logging::GetInstance()->SetGlobalContext(name); \
+ } while (0)
-#define BWE_TEST_LOGGING_GLOBAL_ENABLE(enabled) \
- do { \
- webrtc::testing::bwe::Logging::GetInstance()->SetGlobalEnable(enabled); \
- } while (0)
+#define BWE_TEST_LOGGING_GLOBAL_ENABLE(enabled) \
+ do { \
+ webrtc::testing::bwe::Logging::GetInstance()->SetGlobalEnable(enabled); \
+ } while (0)
-#define __BWE_TEST_LOGGING_CONTEXT_NAME(ctx, line) ctx ## line
+#define __BWE_TEST_LOGGING_CONTEXT_NAME(ctx, line) ctx##line
#define __BWE_TEST_LOGGING_CONTEXT_DECLARE(ctx, line, name, time, enabled) \
- webrtc::testing::bwe::Logging::Context \
- __BWE_TEST_LOGGING_CONTEXT_NAME(ctx, line)(name, time, enabled)
+ webrtc::testing::bwe::Logging::Context __BWE_TEST_LOGGING_CONTEXT_NAME( \
+ ctx, line)(name, time, enabled)
#define BWE_TEST_LOGGING_CONTEXT(name) \
- __BWE_TEST_LOGGING_CONTEXT_DECLARE(__bwe_log_, __LINE__, name, -1, true)
-#define BWE_TEST_LOGGING_ENABLE(enabled) \
- __BWE_TEST_LOGGING_CONTEXT_DECLARE(__bwe_log_, __LINE__, "", -1, \
- static_cast<bool>(enabled))
-#define BWE_TEST_LOGGING_TIME(time) \
- __BWE_TEST_LOGGING_CONTEXT_DECLARE(__bwe_log_, __LINE__, "", \
- static_cast<int64_t>(time), true)
+ __BWE_TEST_LOGGING_CONTEXT_DECLARE(__bwe_log_, __LINE__, name, -1, true)
+#define BWE_TEST_LOGGING_ENABLE(enabled) \
+ __BWE_TEST_LOGGING_CONTEXT_DECLARE(__bwe_log_, __LINE__, "", -1, \
+ static_cast<bool>(enabled))
+#define BWE_TEST_LOGGING_TIME(time) \
+ __BWE_TEST_LOGGING_CONTEXT_DECLARE(__bwe_log_, __LINE__, "", \
+ static_cast<int64_t>(time), true)
-#define BWE_TEST_LOGGING_LOG1(name, format, _1) \
- do { \
- BWE_TEST_LOGGING_CONTEXT(name); \
- webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1); \
- } while (0)
-#define BWE_TEST_LOGGING_LOG2(name, format, _1, _2) \
- do { \
- BWE_TEST_LOGGING_CONTEXT(name); \
- webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2); \
- } while (0)
-#define BWE_TEST_LOGGING_LOG3(name, format, _1, _2, _3) \
- do { \
- BWE_TEST_LOGGING_CONTEXT(name); \
- webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2, _3); \
- } while (0)
-#define BWE_TEST_LOGGING_LOG4(name, format, _1, _2, _3, _4) \
- do { \
- BWE_TEST_LOGGING_CONTEXT(name); \
- webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2, _3, \
- _4); \
- } while (0)
-#define BWE_TEST_LOGGING_LOG5(name, format, _1, _2, _3, _4, _5) \
- do {\
- BWE_TEST_LOGGING_CONTEXT(name); \
- webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2, _3, \
- _4, _5); \
- } while (0)
+#define BWE_TEST_LOGGING_LOG1(name, format, _1) \
+ do { \
+ BWE_TEST_LOGGING_CONTEXT(name); \
+ webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1); \
+ } while (0)
+#define BWE_TEST_LOGGING_LOG2(name, format, _1, _2) \
+ do { \
+ BWE_TEST_LOGGING_CONTEXT(name); \
+ webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2); \
+ } while (0)
+#define BWE_TEST_LOGGING_LOG3(name, format, _1, _2, _3) \
+ do { \
+ BWE_TEST_LOGGING_CONTEXT(name); \
+ webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2, _3); \
+ } while (0)
+#define BWE_TEST_LOGGING_LOG4(name, format, _1, _2, _3, _4) \
+ do { \
+ BWE_TEST_LOGGING_CONTEXT(name); \
+ webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2, _3, _4); \
+ } while (0)
+#define BWE_TEST_LOGGING_LOG5(name, format, _1, _2, _3, _4, _5) \
+ do { \
+ BWE_TEST_LOGGING_CONTEXT(name); \
+ webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2, _3, _4, \
+ _5); \
+ } while (0)
#define BWE_TEST_LOGGING_PLOT(figure, name, time, value) \
do { \
@@ -266,6 +265,7 @@
Context(const std::string& name, int64_t timestamp_ms, bool enabled);
Context(const char* name, int64_t timestamp_ms, bool enabled);
~Context();
+
private:
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Context);
};
@@ -281,7 +281,8 @@
// Note: Implicit |this| argument counts as the first argument.
__attribute__((__format__(__printf__, 2, 3)))
#endif
- void Log(const char format[], ...);
+ void
+ Log(const char format[], ...);
void Plot(int figure, const std::string& name, double value);
void Plot(int figure,
const std::string& name,
@@ -340,7 +341,8 @@
Logging();
~Logging();
- void PushState(const std::string& append_to_tag, int64_t timestamp_ms,
+ void PushState(const std::string& append_to_tag,
+ int64_t timestamp_ms,
bool enabled);
void PopState();
diff --git a/modules/remote_bitrate_estimator/test/estimators/bbr.h b/modules/remote_bitrate_estimator/test/estimators/bbr.h
index 1d16ac5..ee45dbf 100644
--- a/modules/remote_bitrate_estimator/test/estimators/bbr.h
+++ b/modules/remote_bitrate_estimator/test/estimators/bbr.h
@@ -230,6 +230,7 @@
void ReceivePacket(int64_t arrival_time_ms,
const MediaPacket& media_packet) override;
FeedbackPacket* GetFeedback(int64_t now_ms) override;
+
private:
SimulatedClock clock_;
std::vector<uint16_t> packet_feedbacks_;
diff --git a/modules/remote_bitrate_estimator/test/estimators/nada.cc b/modules/remote_bitrate_estimator/test/estimators/nada.cc
index d3d0bae..e74397e 100644
--- a/modules/remote_bitrate_estimator/test/estimators/nada.cc
+++ b/modules/remote_bitrate_estimator/test/estimators/nada.cc
@@ -46,11 +46,9 @@
last_congestion_signal_ms_(0),
last_delays_index_(0),
exp_smoothed_delay_ms_(-1),
- est_queuing_delay_signal_ms_(0) {
-}
+ est_queuing_delay_signal_ms_(0) {}
-NadaBweReceiver::~NadaBweReceiver() {
-}
+NadaBweReceiver::~NadaBweReceiver() {}
void NadaBweReceiver::ReceivePacket(int64_t arrival_time_ms,
const MediaPacket& media_packet) {
@@ -162,8 +160,7 @@
: BweSender(kbps), // Referred as "Reference Rate" = R_n.,
clock_(clock),
observer_(observer),
- original_operating_mode_(true) {
-}
+ original_operating_mode_(true) {}
NadaBweSender::NadaBweSender(BitrateObserver* observer, Clock* clock)
: BweSender(kMinNadaBitrateKbps), // Referred as "Reference Rate" = R_n.
@@ -171,8 +168,7 @@
observer_(observer),
original_operating_mode_(true) {}
-NadaBweSender::~NadaBweSender() {
-}
+NadaBweSender::~NadaBweSender() {}
int NadaBweSender::GetFeedbackIntervalMs() const {
return 100;
@@ -243,8 +239,7 @@
return 100;
}
-void NadaBweSender::Process() {
-}
+void NadaBweSender::Process() {}
void NadaBweSender::AcceleratedRampUp(const NadaFeedback& fb) {
const int kMaxRampUpQueuingDelayMs = 50; // Referred as T_th.
diff --git a/modules/remote_bitrate_estimator/test/estimators/nada.h b/modules/remote_bitrate_estimator/test/estimators/nada.h
index f00a6d3..c9b7cd6 100644
--- a/modules/remote_bitrate_estimator/test/estimators/nada.h
+++ b/modules/remote_bitrate_estimator/test/estimators/nada.h
@@ -7,7 +7,7 @@
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*
-*/
+ */
// Implementation of Network-Assisted Dynamic Adaptation's (NADA's) proposal
// Version according to Draft Document (mentioned in references)
diff --git a/modules/remote_bitrate_estimator/test/estimators/nada_unittest.cc b/modules/remote_bitrate_estimator/test/estimators/nada_unittest.cc
index eac9e93..2b48528 100644
--- a/modules/remote_bitrate_estimator/test/estimators/nada_unittest.cc
+++ b/modules/remote_bitrate_estimator/test/estimators/nada_unittest.cc
@@ -426,8 +426,8 @@
// Raw delays are = [50 250 450 650 850 1050 1250 1450] ms.
// Baseline delay will be 50 ms.
// Delay signals should be: [0 200 400 600 800 1000 1200 1400] ms.
- const int64_t kMedianFilteredDelaysMs[] = {
- 0, 100, 200, 300, 400, 600, 800, 1000};
+ const int64_t kMedianFilteredDelaysMs[] = {0, 100, 200, 300,
+ 400, 600, 800, 1000};
const int kNumPackets = arraysize(kMedianFilteredDelaysMs);
const float kAlpha = 0.1f; // Used for exponential smoothing.
diff --git a/modules/remote_bitrate_estimator/test/estimators/remb.cc b/modules/remote_bitrate_estimator/test/estimators/remb.cc
index ae96389..51b38ac 100644
--- a/modules/remote_bitrate_estimator/test/estimators/remb.cc
+++ b/modules/remote_bitrate_estimator/test/estimators/remb.cc
@@ -37,8 +37,7 @@
1000 * kMaxBitrateKbps);
}
-RembBweSender::~RembBweSender() {
-}
+RembBweSender::~RembBweSender() {}
void RembBweSender::GiveFeedback(const FeedbackPacket& feedback) {
const RembFeedback& remb_feedback =
@@ -80,8 +79,7 @@
estimator_->SetMinBitrate(kRemoteBitrateEstimatorMinBitrateBps);
}
-RembReceiver::~RembReceiver() {
-}
+RembReceiver::~RembReceiver() {}
void RembReceiver::ReceivePacket(int64_t arrival_time_ms,
const MediaPacket& media_packet) {
diff --git a/modules/remote_bitrate_estimator/test/estimators/send_side.cc b/modules/remote_bitrate_estimator/test/estimators/send_side.cc
index 6e03eee..563c335 100644
--- a/modules/remote_bitrate_estimator/test/estimators/send_side.cc
+++ b/modules/remote_bitrate_estimator/test/estimators/send_side.cc
@@ -143,11 +143,9 @@
}
SendSideBweReceiver::SendSideBweReceiver(int flow_id)
- : BweReceiver(flow_id), last_feedback_ms_(0) {
-}
+ : BweReceiver(flow_id), last_feedback_ms_(0) {}
-SendSideBweReceiver::~SendSideBweReceiver() {
-}
+SendSideBweReceiver::~SendSideBweReceiver() {}
void SendSideBweReceiver::ReceivePacket(int64_t arrival_time_ms,
const MediaPacket& media_packet) {
diff --git a/modules/remote_bitrate_estimator/test/estimators/tcp.cc b/modules/remote_bitrate_estimator/test/estimators/tcp.cc
index 5899837..759c2f6 100644
--- a/modules/remote_bitrate_estimator/test/estimators/tcp.cc
+++ b/modules/remote_bitrate_estimator/test/estimators/tcp.cc
@@ -22,13 +22,9 @@
namespace bwe {
TcpBweReceiver::TcpBweReceiver(int flow_id)
- : BweReceiver(flow_id),
- last_feedback_ms_(0),
- latest_owd_ms_(0) {
-}
+ : BweReceiver(flow_id), last_feedback_ms_(0), latest_owd_ms_(0) {}
-TcpBweReceiver::~TcpBweReceiver() {
-}
+TcpBweReceiver::~TcpBweReceiver() {}
void TcpBweReceiver::ReceivePacket(int64_t arrival_time_ms,
const MediaPacket& media_packet) {
diff --git a/modules/remote_bitrate_estimator/test/metric_recorder.cc b/modules/remote_bitrate_estimator/test/metric_recorder.cc
index 612ad4a..b33afb2 100644
--- a/modules/remote_bitrate_estimator/test/metric_recorder.cc
+++ b/modules/remote_bitrate_estimator/test/metric_recorder.cc
@@ -27,13 +27,12 @@
double NormLp(T sum, size_t size, double p) {
return pow(sum / size, 1.0 / p);
}
-}
+} // namespace
const double kP = 1.0; // Used for Norm Lp.
LinkShare::LinkShare(ChokeFilter* choke_filter)
- : choke_filter_(choke_filter), running_flows_(choke_filter->flow_ids()) {
-}
+ : choke_filter_(choke_filter), running_flows_(choke_filter->flow_ids()) {}
void LinkShare::PauseFlow(int flow_id) {
running_flows_.erase(flow_id);
@@ -288,10 +287,10 @@
average_bitrate_kbps + pos_error + extra_error, "estimate_error",
optimal_bitrate_per_flow_kbps, optimum_title, flow_id_);
- BWE_TEST_LOGGING_LOG1("RESULTS >>> " + bwe_name + " Channel utilization : ",
- "%lf %%",
- 100.0 * static_cast<double>(average_bitrate_kbps) /
- optimal_bitrate_per_flow_kbps);
+ BWE_TEST_LOGGING_LOG1(
+ "RESULTS >>> " + bwe_name + " Channel utilization : ", "%lf %%",
+ 100.0 * static_cast<double>(average_bitrate_kbps) /
+ optimal_bitrate_per_flow_kbps);
RTC_UNUSED(pos_error);
RTC_UNUSED(neg_error);
diff --git a/modules/remote_bitrate_estimator/test/packet.h b/modules/remote_bitrate_estimator/test/packet.h
index 0a0e0ca..3050e54 100644
--- a/modules/remote_bitrate_estimator/test/packet.h
+++ b/modules/remote_bitrate_estimator/test/packet.h
@@ -17,8 +17,8 @@
#include <vector>
#include "common_types.h" // NOLINT(build/include)
-#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
+#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
namespace webrtc {
namespace testing {
diff --git a/modules/remote_bitrate_estimator/test/packet_receiver.cc b/modules/remote_bitrate_estimator/test/packet_receiver.cc
index f4a42ed..d68ea9a3 100644
--- a/modules/remote_bitrate_estimator/test/packet_receiver.cc
+++ b/modules/remote_bitrate_estimator/test/packet_receiver.cc
@@ -68,11 +68,9 @@
bwe_type,
plot_delay,
plot_bwe,
- nullptr) {
-}
+ nullptr) {}
-PacketReceiver::~PacketReceiver() {
-}
+PacketReceiver::~PacketReceiver() {}
void PacketReceiver::RunFor(int64_t time_ms, Packets* in_out) {
Packets feedback;
diff --git a/modules/remote_bitrate_estimator/test/packet_sender.cc b/modules/remote_bitrate_estimator/test/packet_sender.cc
index d45f363..fbd6956 100644
--- a/modules/remote_bitrate_estimator/test/packet_sender.cc
+++ b/modules/remote_bitrate_estimator/test/packet_sender.cc
@@ -86,8 +86,7 @@
modules_.push_back(bwe_.get());
}
-VideoSender::~VideoSender() {
-}
+VideoSender::~VideoSender() {}
void VideoSender::Pause() {
previous_sending_bitrate_ = TargetBitrateKbps();
@@ -338,8 +337,7 @@
TcpSender::TcpSender(PacketProcessorListener* listener,
int flow_id,
int64_t offset_ms)
- : TcpSender(listener, flow_id, offset_ms, kNoLimit) {
-}
+ : TcpSender(listener, flow_id, offset_ms, kNoLimit) {}
TcpSender::TcpSender(PacketProcessorListener* listener,
int flow_id,
@@ -358,8 +356,7 @@
send_limit_bytes_(send_limit_bytes),
last_generated_packets_ms_(0),
num_recent_sent_packets_(0),
- bitrate_kbps_(0) {
-}
+ bitrate_kbps_(0) {}
void TcpSender::RunFor(int64_t time_ms, Packets* in_out) {
if (clock_.TimeInMilliseconds() + time_ms < offset_ms_) {
@@ -477,8 +474,8 @@
generated.push_back(
new MediaPacket(*flow_ids().begin(), 1000 * clock_.TimeInMilliseconds(),
kPacketSizeBytes, next_sequence_number_++));
- generated.back()->set_sender_timestamp_us(
- 1000 * clock_.TimeInMilliseconds());
+ generated.back()->set_sender_timestamp_us(1000 *
+ clock_.TimeInMilliseconds());
total_sent_bytes_ += kPacketSizeBytes;
}
diff --git a/modules/remote_bitrate_estimator/test/packet_sender.h b/modules/remote_bitrate_estimator/test/packet_sender.h
index 81a466b..718b5b7 100644
--- a/modules/remote_bitrate_estimator/test/packet_sender.h
+++ b/modules/remote_bitrate_estimator/test/packet_sender.h
@@ -11,8 +11,8 @@
#ifndef MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_PACKET_SENDER_H_
#define MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_PACKET_SENDER_H_
-#include <list>
#include <limits>
+#include <list>
#include <memory>
#include <set>
#include <string>
diff --git a/modules/remote_bitrate_estimator/tools/bwe_rtp.cc b/modules/remote_bitrate_estimator/tools/bwe_rtp.cc
index 2fcb424..47e3cfa 100644
--- a/modules/remote_bitrate_estimator/tools/bwe_rtp.cc
+++ b/modules/remote_bitrate_estimator/tools/bwe_rtp.cc
@@ -128,13 +128,13 @@
new webrtc::RemoteBitrateEstimatorAbsSendTime(observer, clock);
*estimator_used = "AbsoluteSendTimeRemoteBitrateEstimator";
break;
- }
+ }
case webrtc::kRtpExtensionTransmissionTimeOffset: {
*estimator =
new webrtc::RemoteBitrateEstimatorSingleStream(observer, clock);
- *estimator_used = "RemoteBitrateEstimator";
- break;
- }
+ *estimator_used = "RemoteBitrateEstimator";
+ break;
+ }
default:
assert(false);
}
diff --git a/modules/remote_bitrate_estimator/tools/bwe_rtp.h b/modules/remote_bitrate_estimator/tools/bwe_rtp.h
index 9a4723b..57484fd 100644
--- a/modules/remote_bitrate_estimator/tools/bwe_rtp.h
+++ b/modules/remote_bitrate_estimator/tools/bwe_rtp.h
@@ -21,16 +21,15 @@
namespace test {
class RtpFileReader;
}
-}
+} // namespace webrtc
-bool ParseArgsAndSetupEstimator(
- int argc,
- char** argv,
- webrtc::Clock* clock,
- webrtc::RemoteBitrateObserver* observer,
- webrtc::test::RtpFileReader** rtp_reader,
- webrtc::RtpHeaderParser** parser,
- webrtc::RemoteBitrateEstimator** estimator,
- std::string* estimator_used);
+bool ParseArgsAndSetupEstimator(int argc,
+ char** argv,
+ webrtc::Clock* clock,
+ webrtc::RemoteBitrateObserver* observer,
+ webrtc::test::RtpFileReader** rtp_reader,
+ webrtc::RtpHeaderParser** parser,
+ webrtc::RemoteBitrateEstimator** estimator,
+ std::string* estimator_used);
#endif // MODULES_REMOTE_BITRATE_ESTIMATOR_TOOLS_BWE_RTP_H_
diff --git a/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc b/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc
index 887921b..0594a335 100644
--- a/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc
+++ b/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc
@@ -104,10 +104,8 @@
printf("Parsed %d packets\nTime passed: %" PRId64 " ms\n", packet_counter,
clock.TimeInMilliseconds());
printf("Estimator used: %s\n", estimator_used.c_str());
- printf("Packets with absolute send time: %d\n",
- abs_send_time_count);
- printf("Packets with timestamp offset: %d\n",
- ts_offset_count);
+ printf("Packets with absolute send time: %d\n", abs_send_time_count);
+ printf("Packets with timestamp offset: %d\n", ts_offset_count);
printf("Packets with no extension: %d\n",
packet_counter - ts_offset_count - abs_send_time_count);
return 0;
diff --git a/modules/remote_bitrate_estimator/tools/rtp_to_text.cc b/modules/remote_bitrate_estimator/tools/rtp_to_text.cc
index 54f027a..9e82da4 100644
--- a/modules/remote_bitrate_estimator/tools/rtp_to_text.cc
+++ b/modules/remote_bitrate_estimator/tools/rtp_to_text.cc
@@ -29,7 +29,8 @@
bool arrival_time_only = (argc >= 5 && strncmp(argv[4], "-t", 2) == 0);
std::unique_ptr<webrtc::test::RtpFileReader> rtp_reader(reader);
std::unique_ptr<webrtc::RtpHeaderParser> rtp_parser(parser);
- fprintf(stdout, "seqnum timestamp ts_offset abs_sendtime recvtime "
+ fprintf(stdout,
+ "seqnum timestamp ts_offset abs_sendtime recvtime "
"markerbit ssrc size original_size\n");
int packet_counter = 0;
int non_zero_abs_send_time = 0;
@@ -47,24 +48,19 @@
ss << static_cast<int64_t>(packet.time_ms) * 1000000;
fprintf(stdout, "%s\n", ss.str().c_str());
} else {
- fprintf(stdout,
- "%u %u %d %u %u %d %u %" PRIuS " %" PRIuS "\n",
- header.sequenceNumber,
- header.timestamp,
+ fprintf(stdout, "%u %u %d %u %u %d %u %" PRIuS " %" PRIuS "\n",
+ header.sequenceNumber, header.timestamp,
header.extension.transmissionTimeOffset,
- header.extension.absoluteSendTime,
- packet.time_ms,
- header.markerBit,
- header.ssrc,
- packet.length,
+ header.extension.absoluteSendTime, packet.time_ms,
+ header.markerBit, header.ssrc, packet.length,
packet.original_length);
}
++packet_counter;
}
fprintf(stderr, "Parsed %d packets\n", packet_counter);
fprintf(stderr, "Packets with non-zero absolute send time: %d\n",
- non_zero_abs_send_time);
+ non_zero_abs_send_time);
fprintf(stderr, "Packets with non-zero timestamp offset: %d\n",
- non_zero_ts_offsets);
+ non_zero_ts_offsets);
return 0;
}
diff --git a/modules/rtp_rtcp/include/receive_statistics.h b/modules/rtp_rtcp/include/receive_statistics.h
index acf8317..0adc79b 100644
--- a/modules/rtp_rtcp/include/receive_statistics.h
+++ b/modules/rtp_rtcp/include/receive_statistics.h
@@ -16,8 +16,8 @@
#include "modules/include/module.h"
#include "modules/include/module_common_types.h"
-#include "modules/rtp_rtcp/source/rtcp_packet/report_block.h"
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
+#include "modules/rtp_rtcp/source/rtcp_packet/report_block.h"
#include "typedefs.h" // NOLINT(build/include)
namespace webrtc {
diff --git a/modules/rtp_rtcp/include/remote_ntp_time_estimator.h b/modules/rtp_rtcp/include/remote_ntp_time_estimator.h
index e3d95b2..5195e8a 100644
--- a/modules/rtp_rtcp/include/remote_ntp_time_estimator.h
+++ b/modules/rtp_rtcp/include/remote_ntp_time_estimator.h
@@ -33,7 +33,9 @@
// Updates the estimator with round trip time |rtt|, NTP seconds |ntp_secs|,
// NTP fraction |ntp_frac| and RTP timestamp |rtcp_timestamp|.
- bool UpdateRtcpTimestamp(int64_t rtt, uint32_t ntp_secs, uint32_t ntp_frac,
+ bool UpdateRtcpTimestamp(int64_t rtt,
+ uint32_t ntp_secs,
+ uint32_t ntp_frac,
uint32_t rtp_timestamp);
// Estimates the NTP timestamp in local timebase from |rtp_timestamp|.
diff --git a/modules/rtp_rtcp/include/rtp_payload_registry.h b/modules/rtp_rtcp/include/rtp_payload_registry.h
index c80f475..be296da 100644
--- a/modules/rtp_rtcp/include/rtp_payload_registry.h
+++ b/modules/rtp_rtcp/include/rtp_payload_registry.h
@@ -68,8 +68,8 @@
std::map<int, RtpUtility::Payload> payload_type_map_;
int8_t last_received_payload_type_;
- // As a first step in splitting this class up in separate cases for audio and
- // video, DCHECK that no instance is used for both audio and video.
+// As a first step in splitting this class up in separate cases for audio and
+// video, DCHECK that no instance is used for both audio and video.
#if RTC_DCHECK_IS_ON
bool used_for_audio_ RTC_GUARDED_BY(crit_sect_) = false;
bool used_for_video_ RTC_GUARDED_BY(crit_sect_) = false;
diff --git a/modules/rtp_rtcp/include/rtp_rtcp_defines.h b/modules/rtp_rtcp/include/rtp_rtcp_defines.h
index 2cd3c54..d3515f6 100644
--- a/modules/rtp_rtcp/include/rtp_rtcp_defines.h
+++ b/modules/rtp_rtcp/include/rtp_rtcp_defines.h
@@ -22,8 +22,8 @@
#include "system_wrappers/include/clock.h"
#include "typedefs.h" // NOLINT(build/include)
-#define RTCP_CNAME_SIZE 256 // RFC 3550 page 44, including null termination
-#define IP_PACKET_SIZE 1500 // we assume ethernet
+#define RTCP_CNAME_SIZE 256 // RFC 3550 page 44, including null termination
+#define IP_PACKET_SIZE 1500 // we assume ethernet
#define MAX_NUMBER_OF_PARALLEL_TELEPHONE_EVENTS 10
namespace webrtc {
@@ -97,15 +97,9 @@
enum RTPAliveType { kRtpDead = 0, kRtpNoRtp = 1, kRtpAlive = 2 };
-enum ProtectionType {
- kUnprotectedPacket,
- kProtectedPacket
-};
+enum ProtectionType { kUnprotectedPacket, kProtectedPacket };
-enum StorageType {
- kDontRetransmit,
- kAllowRetransmission
-};
+enum StorageType { kDontRetransmit, kAllowRetransmission };
enum RTPExtensionType {
kRtpExtensionNone,
@@ -166,10 +160,10 @@
};
enum RtxMode {
- kRtxOff = 0x0,
- kRtxRetransmitted = 0x1, // Only send retransmissions over RTX.
- kRtxRedundantPayloads = 0x2 // Preventively send redundant payloads
- // instead of padding.
+ kRtxOff = 0x0,
+ kRtxRetransmitted = 0x1, // Only send retransmissions over RTX.
+ kRtxRedundantPayloads = 0x2 // Preventively send redundant payloads
+ // instead of padding.
};
const size_t kRtxHeaderSize = 2;
diff --git a/modules/rtp_rtcp/source/byte_io.h b/modules/rtp_rtcp/source/byte_io.h
index e482452..f9d973b 100644
--- a/modules/rtp_rtcp/source/byte_io.h
+++ b/modules/rtp_rtcp/source/byte_io.h
@@ -11,7 +11,6 @@
#ifndef MODULES_RTP_RTCP_SOURCE_BYTE_IO_H_
#define MODULES_RTP_RTCP_SOURCE_BYTE_IO_H_
-
// This file contains classes for reading and writing integer types from/to
// byte array representations. Signed/unsigned, partial (whole byte) sizes,
// and big/little endian byte order is all supported.
@@ -35,7 +34,6 @@
// These classes are implemented as recursive templetizations, inteded to make
// it easy for the compiler to completely inline the reading/writing.
-
#include <limits>
#include "typedefs.h" // NOLINT(build/include)
@@ -129,8 +127,8 @@
// two's complement for is used.
static T ReinterpretAsSigned(U unsigned_val) {
// An unsigned value with only the highest order bit set (ex 0x80).
- const U kUnsignedHighestBitMask =
- static_cast<U>(1) << ((sizeof(U) * 8) - 1);
+ const U kUnsignedHighestBitMask = static_cast<U>(1)
+ << ((sizeof(U) * 8) - 1);
// A signed value with only the highest bit set. Since this is two's
// complement form, we can use the min value from std::numeric_limits.
const T kSignedHighestBitMask = std::numeric_limits<T>::min();
@@ -353,20 +351,16 @@
public:
static T ReadBigEndian(const uint8_t* data) {
static_assert(sizeof(T) >= 8, kSizeErrorMsg);
- return
- (Get(data, 0) << 56) | (Get(data, 1) << 48) |
- (Get(data, 2) << 40) | (Get(data, 3) << 32) |
- (Get(data, 4) << 24) | (Get(data, 5) << 16) |
- (Get(data, 6) << 8) | Get(data, 7);
+ return (Get(data, 0) << 56) | (Get(data, 1) << 48) | (Get(data, 2) << 40) |
+ (Get(data, 3) << 32) | (Get(data, 4) << 24) | (Get(data, 5) << 16) |
+ (Get(data, 6) << 8) | Get(data, 7);
}
static T ReadLittleEndian(const uint8_t* data) {
static_assert(sizeof(T) >= 8, kSizeErrorMsg);
- return
- Get(data, 0) | (Get(data, 1) << 8) |
- (Get(data, 2) << 16) | (Get(data, 3) << 24) |
- (Get(data, 4) << 32) | (Get(data, 5) << 40) |
- (Get(data, 6) << 48) | (Get(data, 7) << 56);
+ return Get(data, 0) | (Get(data, 1) << 8) | (Get(data, 2) << 16) |
+ (Get(data, 3) << 24) | (Get(data, 4) << 32) | (Get(data, 5) << 40) |
+ (Get(data, 6) << 48) | (Get(data, 7) << 56);
}
private:
diff --git a/modules/rtp_rtcp/source/byte_io_unittest.cc b/modules/rtp_rtcp/source/byte_io_unittest.cc
index 3ddb761..20b6636 100644
--- a/modules/rtp_rtcp/source/byte_io_unittest.cc
+++ b/modules/rtp_rtcp/source/byte_io_unittest.cc
@@ -127,10 +127,10 @@
};
TEST_F(ByteIoTest, Test16UBitBigEndian) {
- TestRead<uint16_t, ByteReader<uint16_t>::ReadBigEndian,
- sizeof(uint16_t)>(true);
- TestWrite<uint16_t, ByteWriter<uint16_t>::WriteBigEndian,
- sizeof(uint16_t)>(true);
+ TestRead<uint16_t, ByteReader<uint16_t>::ReadBigEndian, sizeof(uint16_t)>(
+ true);
+ TestWrite<uint16_t, ByteWriter<uint16_t>::WriteBigEndian, sizeof(uint16_t)>(
+ true);
}
TEST_F(ByteIoTest, Test24UBitBigEndian) {
@@ -139,24 +139,23 @@
}
TEST_F(ByteIoTest, Test32UBitBigEndian) {
- TestRead<uint32_t, ByteReader<uint32_t>::ReadBigEndian,
- sizeof(uint32_t)>(true);
- TestWrite<uint32_t, ByteWriter<uint32_t>::WriteBigEndian,
- sizeof(uint32_t)>(true);
+ TestRead<uint32_t, ByteReader<uint32_t>::ReadBigEndian, sizeof(uint32_t)>(
+ true);
+ TestWrite<uint32_t, ByteWriter<uint32_t>::WriteBigEndian, sizeof(uint32_t)>(
+ true);
}
TEST_F(ByteIoTest, Test64UBitBigEndian) {
- TestRead<uint64_t, ByteReader<uint64_t>::ReadBigEndian,
- sizeof(uint64_t)>(true);
- TestWrite<uint64_t, ByteWriter<uint64_t>::WriteBigEndian,
- sizeof(uint64_t)>(true);
+ TestRead<uint64_t, ByteReader<uint64_t>::ReadBigEndian, sizeof(uint64_t)>(
+ true);
+ TestWrite<uint64_t, ByteWriter<uint64_t>::WriteBigEndian, sizeof(uint64_t)>(
+ true);
}
TEST_F(ByteIoTest, Test16SBitBigEndian) {
- TestRead<int16_t, ByteReader<int16_t>::ReadBigEndian,
- sizeof(int16_t)>(true);
- TestWrite<int16_t, ByteWriter<int16_t>::WriteBigEndian,
- sizeof(int16_t)>(true);
+ TestRead<int16_t, ByteReader<int16_t>::ReadBigEndian, sizeof(int16_t)>(true);
+ TestWrite<int16_t, ByteWriter<int16_t>::WriteBigEndian, sizeof(int16_t)>(
+ true);
}
TEST_F(ByteIoTest, Test24SBitBigEndian) {
@@ -165,24 +164,22 @@
}
TEST_F(ByteIoTest, Test32SBitBigEndian) {
- TestRead<int32_t, ByteReader<int32_t>::ReadBigEndian,
- sizeof(int32_t)>(true);
- TestWrite<int32_t, ByteWriter<int32_t>::WriteBigEndian,
- sizeof(int32_t)>(true);
+ TestRead<int32_t, ByteReader<int32_t>::ReadBigEndian, sizeof(int32_t)>(true);
+ TestWrite<int32_t, ByteWriter<int32_t>::WriteBigEndian, sizeof(int32_t)>(
+ true);
}
TEST_F(ByteIoTest, Test64SBitBigEndian) {
- TestRead<int64_t, ByteReader<int64_t>::ReadBigEndian,
- sizeof(int64_t)>(true);
- TestWrite<int64_t, ByteWriter<int64_t>::WriteBigEndian,
- sizeof(int64_t)>(true);
+ TestRead<int64_t, ByteReader<int64_t>::ReadBigEndian, sizeof(int64_t)>(true);
+ TestWrite<int64_t, ByteWriter<int64_t>::WriteBigEndian, sizeof(int64_t)>(
+ true);
}
TEST_F(ByteIoTest, Test16UBitLittleEndian) {
- TestRead<uint16_t, ByteReader<uint16_t>::ReadLittleEndian,
- sizeof(uint16_t)>(false);
+ TestRead<uint16_t, ByteReader<uint16_t>::ReadLittleEndian, sizeof(uint16_t)>(
+ false);
TestWrite<uint16_t, ByteWriter<uint16_t>::WriteLittleEndian,
- sizeof(uint16_t)>(false);
+ sizeof(uint16_t)>(false);
}
TEST_F(ByteIoTest, Test24UBitLittleEndian) {
@@ -191,24 +188,24 @@
}
TEST_F(ByteIoTest, Test32UBitLittleEndian) {
- TestRead<uint32_t, ByteReader<uint32_t>::ReadLittleEndian,
- sizeof(uint32_t)>(false);
+ TestRead<uint32_t, ByteReader<uint32_t>::ReadLittleEndian, sizeof(uint32_t)>(
+ false);
TestWrite<uint32_t, ByteWriter<uint32_t>::WriteLittleEndian,
- sizeof(uint32_t)>(false);
+ sizeof(uint32_t)>(false);
}
TEST_F(ByteIoTest, Test64UBitLittleEndian) {
- TestRead<uint64_t, ByteReader<uint64_t>::ReadLittleEndian,
- sizeof(uint64_t)>(false);
+ TestRead<uint64_t, ByteReader<uint64_t>::ReadLittleEndian, sizeof(uint64_t)>(
+ false);
TestWrite<uint64_t, ByteWriter<uint64_t>::WriteLittleEndian,
- sizeof(uint64_t)>(false);
+ sizeof(uint64_t)>(false);
}
TEST_F(ByteIoTest, Test16SBitLittleEndian) {
- TestRead<int16_t, ByteReader<int16_t>::ReadLittleEndian,
- sizeof(int16_t)>(false);
- TestWrite<int16_t, ByteWriter<int16_t>::WriteLittleEndian,
- sizeof(int16_t)>(false);
+ TestRead<int16_t, ByteReader<int16_t>::ReadLittleEndian, sizeof(int16_t)>(
+ false);
+ TestWrite<int16_t, ByteWriter<int16_t>::WriteLittleEndian, sizeof(int16_t)>(
+ false);
}
TEST_F(ByteIoTest, Test24SBitLittleEndian) {
@@ -217,17 +214,17 @@
}
TEST_F(ByteIoTest, Test32SBitLittleEndian) {
- TestRead<int32_t, ByteReader<int32_t>::ReadLittleEndian,
- sizeof(int32_t)>(false);
- TestWrite<int32_t, ByteWriter<int32_t>::WriteLittleEndian,
- sizeof(int32_t)>(false);
+ TestRead<int32_t, ByteReader<int32_t>::ReadLittleEndian, sizeof(int32_t)>(
+ false);
+ TestWrite<int32_t, ByteWriter<int32_t>::WriteLittleEndian, sizeof(int32_t)>(
+ false);
}
TEST_F(ByteIoTest, Test64SBitLittleEndian) {
- TestRead<int64_t, ByteReader<int64_t>::ReadLittleEndian,
- sizeof(int64_t)>(false);
- TestWrite<int64_t, ByteWriter<int64_t>::WriteLittleEndian,
- sizeof(int64_t)>(false);
+ TestRead<int64_t, ByteReader<int64_t>::ReadLittleEndian, sizeof(int64_t)>(
+ false);
+ TestWrite<int64_t, ByteWriter<int64_t>::WriteLittleEndian, sizeof(int64_t)>(
+ false);
}
// Sets up a fixed byte array and converts N bytes from the array into a
diff --git a/modules/rtp_rtcp/source/fec_private_tables_bursty.cc b/modules/rtp_rtcp/source/fec_private_tables_bursty.cc
index 49a590b..9dbc012 100644
--- a/modules/rtp_rtcp/source/fec_private_tables_bursty.cc
+++ b/modules/rtp_rtcp/source/fec_private_tables_bursty.cc
@@ -10,7 +10,6 @@
#include "modules/rtp_rtcp/source/fec_private_tables_bursty.h"
-
namespace {
// clang-format off
#define kMaskBursty1_1 \
diff --git a/modules/rtp_rtcp/source/flexfec_sender_unittest.cc b/modules/rtp_rtcp/source/flexfec_sender_unittest.cc
index 4c2a48d..ddc2805 100644
--- a/modules/rtp_rtcp/source/flexfec_sender_unittest.cc
+++ b/modules/rtp_rtcp/source/flexfec_sender_unittest.cc
@@ -281,11 +281,11 @@
SimulatedClock clock(kInitialSimulatedClockTime);
const size_t kExtensionHeaderLength = 1;
const size_t kRtpOneByteHeaderLength = 4;
- const size_t kExtensionsTotalSize = Word32Align(
- kRtpOneByteHeaderLength +
- kExtensionHeaderLength + AbsoluteSendTime::kValueSizeBytes +
- kExtensionHeaderLength + TransmissionOffset::kValueSizeBytes +
- kExtensionHeaderLength + TransportSequenceNumber::kValueSizeBytes);
+ const size_t kExtensionsTotalSize =
+ Word32Align(kRtpOneByteHeaderLength + kExtensionHeaderLength +
+ AbsoluteSendTime::kValueSizeBytes + kExtensionHeaderLength +
+ TransmissionOffset::kValueSizeBytes + kExtensionHeaderLength +
+ TransportSequenceNumber::kValueSizeBytes);
FlexfecSender sender(kFlexfecPayloadType, kFlexfecSsrc, kMediaSsrc, kNoMid,
kRtpHeaderExtensions, RTPSender::FecExtensionSizes(),
nullptr /* rtp_state */, &clock);
diff --git a/modules/rtp_rtcp/source/forward_error_correction.cc b/modules/rtp_rtcp/source/forward_error_correction.cc
index 30689e3..b743110 100644
--- a/modules/rtp_rtcp/source/forward_error_correction.cc
+++ b/modules/rtp_rtcp/source/forward_error_correction.cc
@@ -52,7 +52,7 @@
// the std::unique_ptr's are not covariant w.r.t. the types that
// they are pointing to.
template <typename S, typename T>
-bool ForwardErrorCorrection::SortablePacket::LessThan::operator() (
+bool ForwardErrorCorrection::SortablePacket::LessThan::operator()(
const S& first,
const T& second) {
RTC_DCHECK_EQ(first->ssrc, second->ssrc);
diff --git a/modules/rtp_rtcp/source/forward_error_correction.h b/modules/rtp_rtcp/source/forward_error_correction.h
index 1f06b29..819f6bc 100644
--- a/modules/rtp_rtcp/source/forward_error_correction.h
+++ b/modules/rtp_rtcp/source/forward_error_correction.h
@@ -67,7 +67,7 @@
// packets belonging to the same SSRC.
struct LessThan {
template <typename S, typename T>
- bool operator() (const S& first, const T& second);
+ bool operator()(const S& first, const T& second);
};
uint32_t ssrc;
@@ -83,8 +83,8 @@
ReceivedPacket();
~ReceivedPacket();
- bool is_fec; // Set to true if this is an FEC packet and false
- // otherwise.
+ bool is_fec; // Set to true if this is an FEC packet and false
+ // otherwise.
rtc::scoped_refptr<Packet> pkt; // Pointer to the packet storage.
};
diff --git a/modules/rtp_rtcp/source/nack_rtx_unittest.cc b/modules/rtp_rtcp/source/nack_rtx_unittest.cc
index 7775024..53ff5d5 100644
--- a/modules/rtp_rtcp/source/nack_rtx_unittest.cc
+++ b/modules/rtp_rtcp/source/nack_rtx_unittest.cc
@@ -1,12 +1,12 @@
/*
-* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
-*
-* Use of this source code is governed by a BSD-style license
-* that can be found in the LICENSE file in the root of the source
-* tree. An additional intellectual property rights grant can be found
-* in the file PATENTS. All contributing project authors may
-* be found in the AUTHORS file in the root of the source tree.
-*/
+ * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
#include <algorithm>
#include <iterator>
@@ -62,9 +62,7 @@
count_rtx_ssrc_(0),
module_(NULL) {}
- void SetSendModule(RtpRtcp* rtpRtcpModule) {
- module_ = rtpRtcpModule;
- }
+ void SetSendModule(RtpRtcp* rtpRtcpModule) { module_ = rtpRtcpModule; }
void DropEveryNthPacket(int n) { packet_loss_ = n; }
@@ -120,9 +118,7 @@
RtpRtcpRtxNackTest()
: rtp_rtcp_module_(nullptr),
transport_(kTestRtxSsrc),
- rtx_stream_(&media_stream_,
- rtx_associated_payload_types_,
- kTestSsrc),
+ rtx_stream_(&media_stream_, rtx_associated_payload_types_, kTestSsrc),
payload_data_length(sizeof(payload_data)),
fake_clock(123456),
retransmission_rate_limiter_(&fake_clock, kMaxRttMs) {}
@@ -227,8 +223,8 @@
std::unique_ptr<ReceiveStatistics> receive_statistics_;
RtpRtcp* rtp_rtcp_module_;
RtxLoopBackTransport transport_;
- const std::map<int, int> rtx_associated_payload_types_ =
- {{kRtxPayloadType, kPayloadType}};
+ const std::map<int, int> rtx_associated_payload_types_ = {
+ {kRtxPayloadType, kPayloadType}};
VerifyingMediaStream media_stream_;
RtxReceiveStream rtx_stream_;
uint8_t payload_data[65000];
diff --git a/modules/rtp_rtcp/source/packet_loss_stats.cc b/modules/rtp_rtcp/source/packet_loss_stats.cc
index 35184db..076348d 100644
--- a/modules/rtp_rtcp/source/packet_loss_stats.cc
+++ b/modules/rtp_rtcp/source/packet_loss_stats.cc
@@ -23,24 +23,24 @@
PacketLossStats::PacketLossStats()
: single_loss_historic_count_(0),
multiple_loss_historic_event_count_(0),
- multiple_loss_historic_packet_count_(0) {
-}
+ multiple_loss_historic_packet_count_(0) {}
PacketLossStats::~PacketLossStats() = default;
void PacketLossStats::AddLostPacket(uint16_t sequence_number) {
// Detect sequence number wrap around.
if (!lost_packets_buffer_.empty() &&
- static_cast<int>(*(lost_packets_buffer_.rbegin())) - sequence_number
- > 0x8000) {
+ static_cast<int>(*(lost_packets_buffer_.rbegin())) - sequence_number >
+ 0x8000) {
// The buffer contains large numbers and this is a small number.
lost_packets_wrapped_buffer_.insert(sequence_number);
} else {
lost_packets_buffer_.insert(sequence_number);
}
- if (lost_packets_wrapped_buffer_.size() + lost_packets_buffer_.size()
- > kBufferSize || (!lost_packets_wrapped_buffer_.empty() &&
- *(lost_packets_wrapped_buffer_.rbegin()) > 0x4000)) {
+ if (lost_packets_wrapped_buffer_.size() + lost_packets_buffer_.size() >
+ kBufferSize ||
+ (!lost_packets_wrapped_buffer_.empty() &&
+ *(lost_packets_wrapped_buffer_.rbegin()) > 0x4000)) {
PruneBuffer();
}
}
diff --git a/modules/rtp_rtcp/source/receive_statistics_impl.cc b/modules/rtp_rtcp/source/receive_statistics_impl.cc
index bb2833f..888fa92 100644
--- a/modules/rtp_rtcp/source/receive_statistics_impl.cc
+++ b/modules/rtp_rtcp/source/receive_statistics_impl.cc
@@ -121,7 +121,7 @@
uint32_t last_receive_time_rtp =
NtpToRtp(last_receive_time_ntp_, header.payload_type_frequency);
int32_t time_diff_samples = (receive_time_rtp - last_receive_time_rtp) -
- (header.timestamp - last_received_timestamp_);
+ (header.timestamp - last_received_timestamp_);
time_diff_samples = std::abs(time_diff_samples);
@@ -219,9 +219,9 @@
// Number of received RTP packets since last report, counts all packets but
// not re-transmissions.
- uint32_t rec_since_last =
- (receive_counters_.transmitted.packets -
- receive_counters_.retransmitted.packets) - last_report_inorder_packets_;
+ uint32_t rec_since_last = (receive_counters_.transmitted.packets -
+ receive_counters_.retransmitted.packets) -
+ last_report_inorder_packets_;
// With NACK we don't know the expected retransmissions during the last
// second. We know how many "old" packets we have received. We just count
@@ -243,8 +243,7 @@
uint8_t local_fraction_lost = 0;
if (exp_since_last) {
// Scale 0 to 255, where 255 is 100% loss.
- local_fraction_lost =
- static_cast<uint8_t>(255 * missing / exp_since_last);
+ local_fraction_lost = static_cast<uint8_t>(255 * missing / exp_since_last);
}
stats.fraction_lost = local_fraction_lost;
@@ -261,9 +260,8 @@
last_reported_statistics_ = stats;
// Only for report blocks in RTCP SR and RR.
- last_report_inorder_packets_ =
- receive_counters_.transmitted.packets -
- receive_counters_.retransmitted.packets;
+ last_report_inorder_packets_ = receive_counters_.transmitted.packets -
+ receive_counters_.retransmitted.packets;
last_report_old_packets_ = receive_counters_.retransmitted.packets;
last_report_seq_max_ = received_seq_max_;
BWE_TEST_LOGGING_PLOT_WITH_SSRC(1, "cumulative_loss_pkts",
@@ -276,8 +274,8 @@
return stats;
}
-void StreamStatisticianImpl::GetDataCounters(
- size_t* bytes_received, uint32_t* packets_received) const {
+void StreamStatisticianImpl::GetDataCounters(size_t* bytes_received,
+ uint32_t* packets_received) const {
rtc::CritScope cs(&stream_lock_);
if (bytes_received) {
*bytes_received = receive_counters_.transmitted.payload_bytes +
@@ -309,8 +307,7 @@
uint32_t frequency_khz = header.payload_type_frequency / 1000;
assert(frequency_khz > 0);
- int64_t time_diff_ms = clock_->TimeInMilliseconds() -
- last_receive_time_ms_;
+ int64_t time_diff_ms = clock_->TimeInMilliseconds() - last_receive_time_ms_;
// Diff in time stamp since last received in order.
uint32_t timestamp_diff = header.timestamp - last_received_timestamp_;
@@ -347,8 +344,8 @@
return true;
} else {
// If we have a restart of the remote side this packet is still in order.
- return !IsNewerSequenceNumber(sequence_number, received_seq_max_ -
- max_reordering_threshold_);
+ return !IsNewerSequenceNumber(
+ sequence_number, received_seq_max_ - max_reordering_threshold_);
}
}
diff --git a/modules/rtp_rtcp/source/receive_statistics_unittest.cc b/modules/rtp_rtcp/source/receive_statistics_unittest.cc
index c586b3d..29fc88d 100644
--- a/modules/rtp_rtcp/source/receive_statistics_unittest.cc
+++ b/modules/rtp_rtcp/source/receive_statistics_unittest.cc
@@ -39,9 +39,8 @@
class ReceiveStatisticsTest : public ::testing::Test {
public:
- ReceiveStatisticsTest() :
- clock_(0),
- receive_statistics_(ReceiveStatistics::Create(&clock_)) {
+ ReceiveStatisticsTest()
+ : clock_(0), receive_statistics_(ReceiveStatistics::Create(&clock_)) {
header1_ = CreateRtpHeader(kSsrc1);
header2_ = CreateRtpHeader(kSsrc2);
}
@@ -74,8 +73,7 @@
EXPECT_EQ(200u, bytes_received);
EXPECT_EQ(2u, packets_received);
- statistician =
- receive_statistics_->GetStatistician(kSsrc2);
+ statistician = receive_statistics_->GetStatistician(kSsrc2);
ASSERT_TRUE(statistician != NULL);
EXPECT_GT(statistician->BitrateReceived(), 0u);
statistician->GetDataCounters(&bytes_received, &packets_received);
@@ -236,8 +234,8 @@
// Call GetStatistics, simulating a timed rtcp sender thread.
RtcpStatistics statistics;
- receive_statistics_->GetStatistician(kSsrc1)
- ->GetStatistics(&statistics, true);
+ receive_statistics_->GetStatistician(kSsrc1)->GetStatistics(&statistics,
+ true);
EXPECT_EQ(1u, callback.num_calls_);
EXPECT_EQ(callback.ssrc_, kSsrc1);
@@ -272,8 +270,8 @@
receive_statistics_->IncomingPacket(header1_, kPacketSize1, false);
++header1_.sequenceNumber;
- receive_statistics_->GetStatistician(kSsrc1)
- ->GetStatistics(&statistics, true);
+ receive_statistics_->GetStatistician(kSsrc1)->GetStatistics(&statistics,
+ true);
// Should not have been called after deregister.
EXPECT_EQ(1u, callback.num_calls_);
@@ -324,8 +322,8 @@
// One packet of size kPacketSize1.
header1_.headerLength = kHeaderLength;
- receive_statistics_->IncomingPacket(
- header1_, kPacketSize1 + kHeaderLength, false);
+ receive_statistics_->IncomingPacket(header1_, kPacketSize1 + kHeaderLength,
+ false);
StreamDataCounters expected;
expected.transmitted.payload_bytes = kPacketSize1;
expected.transmitted.header_bytes = kHeaderLength;
@@ -368,8 +366,8 @@
++header1_.sequenceNumber;
clock_.AdvanceTimeMilliseconds(5);
// One FEC packet.
- receive_statistics_->IncomingPacket(
- header1_, kPacketSize1 + kHeaderLength, false);
+ receive_statistics_->IncomingPacket(header1_, kPacketSize1 + kHeaderLength,
+ false);
receive_statistics_->FecPacketReceived(header1_,
kPacketSize1 + kHeaderLength);
expected.transmitted.payload_bytes = kPacketSize1 * 4;
@@ -385,8 +383,8 @@
// New stats, but callback should not be called.
++header1_.sequenceNumber;
clock_.AdvanceTimeMilliseconds(5);
- receive_statistics_->IncomingPacket(
- header1_, kPacketSize1 + kHeaderLength, true);
+ receive_statistics_->IncomingPacket(header1_, kPacketSize1 + kHeaderLength,
+ true);
callback.Matches(5, kSsrc1, expected);
}
@@ -402,8 +400,8 @@
kPacketSize1 + kHeaderLength);
EXPECT_EQ(0u, callback.num_calls_);
- receive_statistics_->IncomingPacket(
- header1_, kPacketSize1 + kHeaderLength, false);
+ receive_statistics_->IncomingPacket(header1_, kPacketSize1 + kHeaderLength,
+ false);
StreamDataCounters expected;
expected.transmitted.payload_bytes = kPacketSize1;
expected.transmitted.header_bytes = kHeaderLength;
diff --git a/modules/rtp_rtcp/source/remote_ntp_time_estimator_unittest.cc b/modules/rtp_rtcp/source/remote_ntp_time_estimator_unittest.cc
index e752369..5254cd5 100644
--- a/modules/rtp_rtcp/source/remote_ntp_time_estimator_unittest.cc
+++ b/modules/rtp_rtcp/source/remote_ntp_time_estimator_unittest.cc
@@ -1,12 +1,12 @@
/*
-* Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
-*
-* Use of this source code is governed by a BSD-style license
-* that can be found in the LICENSE file in the root of the source
-* tree. An additional intellectual property rights grant can be found
-* in the file PATENTS. All contributing project authors may
-* be found in the AUTHORS file in the root of the source tree.
-*/
+ * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
#include "modules/rtp_rtcp/include/remote_ntp_time_estimator.h"
#include "common_types.h" // NOLINT(build/include)
@@ -63,8 +63,11 @@
ReceiveRtcpSr(kTestRtt, rtcp_timestamp, ntp.seconds(), ntp.fractions());
}
- void UpdateRtcpTimestamp(int64_t rtt, uint32_t ntp_secs, uint32_t ntp_frac,
- uint32_t rtp_timestamp, bool expected_result) {
+ void UpdateRtcpTimestamp(int64_t rtt,
+ uint32_t ntp_secs,
+ uint32_t ntp_frac,
+ uint32_t rtp_timestamp,
+ bool expected_result) {
EXPECT_EQ(expected_result, estimator_->UpdateRtcpTimestamp(
rtt, ntp_secs, ntp_frac, rtp_timestamp));
}
diff --git a/modules/rtp_rtcp/source/rtcp_nack_stats.cc b/modules/rtp_rtcp/source/rtcp_nack_stats.cc
index 8700b04..24b7085 100644
--- a/modules/rtp_rtcp/source/rtcp_nack_stats.cc
+++ b/modules/rtp_rtcp/source/rtcp_nack_stats.cc
@@ -15,14 +15,12 @@
namespace webrtc {
RtcpNackStats::RtcpNackStats()
- : max_sequence_number_(0),
- requests_(0),
- unique_requests_(0) {}
+ : max_sequence_number_(0), requests_(0), unique_requests_(0) {}
void RtcpNackStats::ReportRequest(uint16_t sequence_number) {
if (requests_ == 0 ||
IsNewerSequenceNumber(sequence_number, max_sequence_number_)) {
- max_sequence_number_ = sequence_number;
+ max_sequence_number_ = sequence_number;
++unique_requests_;
}
++requests_;
diff --git a/modules/rtp_rtcp/source/rtcp_nack_stats.h b/modules/rtp_rtcp/source/rtcp_nack_stats.h
index d9e2622..9da4351 100644
--- a/modules/rtp_rtcp/source/rtcp_nack_stats.h
+++ b/modules/rtp_rtcp/source/rtcp_nack_stats.h
@@ -1,12 +1,12 @@
/*
-* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
-*
-* Use of this source code is governed by a BSD-style license
-* that can be found in the LICENSE file in the root of the source
-* tree. An additional intellectual property rights grant can be found
-* in the file PATENTS. All contributing project authors may
-* be found in the AUTHORS file in the root of the source tree.
-*/
+ * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
#ifndef MODULES_RTP_RTCP_SOURCE_RTCP_NACK_STATS_H_
#define MODULES_RTP_RTCP_SOURCE_RTCP_NACK_STATS_H_
diff --git a/modules/rtp_rtcp/source/rtcp_nack_stats_unittest.cc b/modules/rtp_rtcp/source/rtcp_nack_stats_unittest.cc
index 5b4def5..1c30173 100644
--- a/modules/rtp_rtcp/source/rtcp_nack_stats_unittest.cc
+++ b/modules/rtp_rtcp/source/rtcp_nack_stats_unittest.cc
@@ -61,4 +61,3 @@
}
} // namespace webrtc
-
diff --git a/modules/rtp_rtcp/source/rtcp_packet.cc b/modules/rtp_rtcp/source/rtcp_packet.cc
index ecce5ef..194b992 100644
--- a/modules/rtp_rtcp/source/rtcp_packet.cc
+++ b/modules/rtp_rtcp/source/rtcp_packet.cc
@@ -75,8 +75,8 @@
RTC_DCHECK_LE(count_or_format, 0x1f);
constexpr uint8_t kVersionBits = 2 << 6;
constexpr uint8_t kNoPaddingBit = 0 << 5;
- buffer[*pos + 0] = kVersionBits | kNoPaddingBit |
- static_cast<uint8_t>(count_or_format);
+ buffer[*pos + 0] =
+ kVersionBits | kNoPaddingBit | static_cast<uint8_t>(count_or_format);
buffer[*pos + 1] = packet_type;
buffer[*pos + 2] = (length >> 8) & 0xff;
buffer[*pos + 3] = length & 0xff;
diff --git a/modules/rtp_rtcp/source/rtcp_packet/app.cc b/modules/rtp_rtcp/source/rtcp_packet/app.cc
index 10d2a77..4e21bc9 100644
--- a/modules/rtp_rtcp/source/rtcp_packet/app.cc
+++ b/modules/rtp_rtcp/source/rtcp_packet/app.cc
@@ -64,9 +64,9 @@
void App::SetData(const uint8_t* data, size_t data_length) {
RTC_DCHECK(data);
RTC_DCHECK_EQ(data_length % 4, 0) << "Data must be 32 bits aligned.";
- RTC_DCHECK_LE(data_length, kMaxDataSize) << "App data size " << data_length
- << " exceed maximum of "
- << kMaxDataSize << " bytes.";
+ RTC_DCHECK_LE(data_length, kMaxDataSize)
+ << "App data size " << data_length << " exceed maximum of "
+ << kMaxDataSize << " bytes.";
data_.SetData(data, data_length);
}
diff --git a/modules/rtp_rtcp/source/rtcp_packet/common_header.h b/modules/rtp_rtcp/source/rtcp_packet/common_header.h
index d91956e..5416406 100644
--- a/modules/rtp_rtcp/source/rtcp_packet/common_header.h
+++ b/modules/rtp_rtcp/source/rtcp_packet/common_header.h
@@ -21,7 +21,7 @@
CommonHeader() {}
CommonHeader(const CommonHeader&) = default;
- CommonHeader& operator =(const CommonHeader&) = default;
+ CommonHeader& operator=(const CommonHeader&) = default;
bool Parse(const uint8_t* buffer, size_t size_bytes);
diff --git a/modules/rtp_rtcp/source/rtcp_packet/common_header_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/common_header_unittest.cc
index a284642..e8b4c52 100644
--- a/modules/rtp_rtcp/source/rtcp_packet/common_header_unittest.cc
+++ b/modules/rtp_rtcp/source/rtcp_packet/common_header_unittest.cc
@@ -42,9 +42,8 @@
}
TEST(RtcpCommonHeaderTest, PacketSize) {
- uint8_t buffer[] = {0x80, 0x00, 0x00, 0x02,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00};
+ uint8_t buffer[] = {0x80, 0x00, 0x00, 0x02, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
CommonHeader header;
EXPECT_FALSE(header.Parse(buffer, sizeof(buffer) - 1));
EXPECT_TRUE(header.Parse(buffer, sizeof(buffer)));
@@ -55,9 +54,8 @@
TEST(RtcpCommonHeaderTest, PaddingAndPayloadSize) {
// Set v = 2, p = 1, but leave fmt, pt as 0.
- uint8_t buffer[] = {0xa0, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00};
+ uint8_t buffer[] = {0xa0, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
CommonHeader header;
// Padding bit set, but no byte for padding (can't specify padding length).
EXPECT_FALSE(header.Parse(buffer, 4));
diff --git a/modules/rtp_rtcp/source/rtcp_packet/extended_reports_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/extended_reports_unittest.cc
index 1e72d4a..c37f77e 100644
--- a/modules/rtp_rtcp/source/rtcp_packet/extended_reports_unittest.cc
+++ b/modules/rtp_rtcp/source/rtcp_packet/extended_reports_unittest.cc
@@ -39,16 +39,13 @@
metric1.endSystemDelay == metric2.endSystemDelay &&
metric1.signalLevel == metric2.signalLevel &&
metric1.noiseLevel == metric2.noiseLevel &&
- metric1.RERL == metric2.RERL &&
- metric1.Gmin == metric2.Gmin &&
+ metric1.RERL == metric2.RERL && metric1.Gmin == metric2.Gmin &&
metric1.Rfactor == metric2.Rfactor &&
metric1.extRfactor == metric2.extRfactor &&
- metric1.MOSLQ == metric2.MOSLQ &&
- metric1.MOSCQ == metric2.MOSCQ &&
+ metric1.MOSLQ == metric2.MOSLQ && metric1.MOSCQ == metric2.MOSCQ &&
metric1.RXconfig == metric2.RXconfig &&
metric1.JBnominal == metric2.JBnominal &&
- metric1.JBmax == metric2.JBmax &&
- metric1.JBabsMax == metric2.JBabsMax;
+ metric1.JBmax == metric2.JBmax && metric1.JBabsMax == metric2.JBabsMax;
}
namespace rtcp {
@@ -57,8 +54,7 @@
}
bool operator==(const ReceiveTimeInfo& time1, const ReceiveTimeInfo& time2) {
- return time1.ssrc == time2.ssrc &&
- time1.last_rr == time2.last_rr &&
+ return time1.ssrc == time2.ssrc && time1.last_rr == time2.last_rr &&
time1.delay_since_last_rr == time2.delay_since_last_rr;
}
@@ -113,26 +109,26 @@
template <>
RTCPVoIPMetric RtcpPacketExtendedReportsTest::Rand<RTCPVoIPMetric>() {
RTCPVoIPMetric metric;
- metric.lossRate = Rand<uint8_t>();
- metric.discardRate = Rand<uint8_t>();
- metric.burstDensity = Rand<uint8_t>();
- metric.gapDensity = Rand<uint8_t>();
- metric.burstDuration = Rand<uint16_t>();
- metric.gapDuration = Rand<uint16_t>();
+ metric.lossRate = Rand<uint8_t>();
+ metric.discardRate = Rand<uint8_t>();
+ metric.burstDensity = Rand<uint8_t>();
+ metric.gapDensity = Rand<uint8_t>();
+ metric.burstDuration = Rand<uint16_t>();
+ metric.gapDuration = Rand<uint16_t>();
metric.roundTripDelay = Rand<uint16_t>();
metric.endSystemDelay = Rand<uint16_t>();
- metric.signalLevel = Rand<uint8_t>();
- metric.noiseLevel = Rand<uint8_t>();
- metric.RERL = Rand<uint8_t>();
- metric.Gmin = Rand<uint8_t>();
- metric.Rfactor = Rand<uint8_t>();
- metric.extRfactor = Rand<uint8_t>();
- metric.MOSLQ = Rand<uint8_t>();
- metric.MOSCQ = Rand<uint8_t>();
- metric.RXconfig = Rand<uint8_t>();
- metric.JBnominal = Rand<uint16_t>();
- metric.JBmax = Rand<uint16_t>();
- metric.JBabsMax = Rand<uint16_t>();
+ metric.signalLevel = Rand<uint8_t>();
+ metric.noiseLevel = Rand<uint8_t>();
+ metric.RERL = Rand<uint8_t>();
+ metric.Gmin = Rand<uint8_t>();
+ metric.Rfactor = Rand<uint8_t>();
+ metric.extRfactor = Rand<uint8_t>();
+ metric.MOSLQ = Rand<uint8_t>();
+ metric.MOSCQ = Rand<uint8_t>();
+ metric.RXconfig = Rand<uint8_t>();
+ metric.JBnominal = Rand<uint16_t>();
+ metric.JBmax = Rand<uint16_t>();
+ metric.JBabsMax = Rand<uint16_t>();
return metric;
}
diff --git a/modules/rtp_rtcp/source/rtcp_packet/fir_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/fir_unittest.cc
index 2800fbc..d9eb465 100644
--- a/modules/rtp_rtcp/source/rtcp_packet/fir_unittest.cc
+++ b/modules/rtp_rtcp/source/rtcp_packet/fir_unittest.cc
@@ -29,11 +29,9 @@
constexpr uint32_t kRemoteSsrc = 0x23456789;
constexpr uint8_t kSeqNr = 13;
// Manually created Fir packet matching constants above.
-constexpr uint8_t kPacket[] = {0x84, 206, 0x00, 0x04,
- 0x12, 0x34, 0x56, 0x78,
- 0x00, 0x00, 0x00, 0x00,
- 0x23, 0x45, 0x67, 0x89,
- 0x0d, 0x00, 0x00, 0x00};
+constexpr uint8_t kPacket[] = {0x84, 206, 0x00, 0x04, 0x12, 0x34, 0x56,
+ 0x78, 0x00, 0x00, 0x00, 0x00, 0x23, 0x45,
+ 0x67, 0x89, 0x0d, 0x00, 0x00, 0x00};
} // namespace
TEST(RtcpPacketFirTest, Parse) {
@@ -77,20 +75,16 @@
}
TEST(RtcpPacketFirTest, ParseFailsOnZeroFciEntries) {
- constexpr uint8_t kPacketWithoutFci[] = {0x84, 206, 0x00, 0x02,
- 0x12, 0x34, 0x56, 0x78,
- 0x00, 0x00, 0x00, 0x00};
+ constexpr uint8_t kPacketWithoutFci[] = {0x84, 206, 0x00, 0x02, 0x12, 0x34,
+ 0x56, 0x78, 0x00, 0x00, 0x00, 0x00};
Fir parsed;
EXPECT_FALSE(test::ParseSinglePacket(kPacketWithoutFci, &parsed));
}
TEST(RtcpPacketFirTest, ParseFailsOnFractionalFciEntries) {
- constexpr uint8_t kPacketWithOneAndHalfFci[] = {0x84, 206, 0x00, 0x05,
- 0x12, 0x34, 0x56, 0x78,
- 0x00, 0x00, 0x00, 0x00,
- 0x23, 0x45, 0x67, 0x89,
- 0x0d, 0x00, 0x00, 0x00,
- 'h', 'a', 'l', 'f'};
+ constexpr uint8_t kPacketWithOneAndHalfFci[] = {
+ 0x84, 206, 0x00, 0x05, 0x12, 0x34, 0x56, 0x78, 0x00, 0x00, 0x00, 0x00,
+ 0x23, 0x45, 0x67, 0x89, 0x0d, 0x00, 0x00, 0x00, 'h', 'a', 'l', 'f'};
Fir parsed;
EXPECT_FALSE(test::ParseSinglePacket(kPacketWithOneAndHalfFci, &parsed));
diff --git a/modules/rtp_rtcp/source/rtcp_packet/pli_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/pli_unittest.cc
index e6cf7be..67e614d 100644
--- a/modules/rtp_rtcp/source/rtcp_packet/pli_unittest.cc
+++ b/modules/rtp_rtcp/source/rtcp_packet/pli_unittest.cc
@@ -23,9 +23,8 @@
const uint32_t kSenderSsrc = 0x12345678;
const uint32_t kRemoteSsrc = 0x23456789;
// Manually created Pli packet matching constants above.
-const uint8_t kPacket[] = {0x81, 206, 0x00, 0x02,
- 0x12, 0x34, 0x56, 0x78,
- 0x23, 0x45, 0x67, 0x89};
+const uint8_t kPacket[] = {0x81, 206, 0x00, 0x02, 0x12, 0x34,
+ 0x56, 0x78, 0x23, 0x45, 0x67, 0x89};
} // namespace
TEST(RtcpPacketPliTest, Parse) {
@@ -45,7 +44,7 @@
rtc::Buffer packet = pli.Build();
EXPECT_THAT(make_tuple(packet.data(), packet.size()),
- ElementsAreArray(kPacket));
+ ElementsAreArray(kPacket));
}
TEST(RtcpPacketPliTest, ParseFailsOnTooSmallPacket) {
diff --git a/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request_unittest.cc
index e807369..f10f93e 100644
--- a/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request_unittest.cc
+++ b/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request_unittest.cc
@@ -23,9 +23,8 @@
const uint32_t kSenderSsrc = 0x12345678;
const uint32_t kRemoteSsrc = 0x23456789;
// Manually created packet matching constants above.
-const uint8_t kPacket[] = {0x85, 205, 0x00, 0x02,
- 0x12, 0x34, 0x56, 0x78,
- 0x23, 0x45, 0x67, 0x89};
+const uint8_t kPacket[] = {0x85, 205, 0x00, 0x02, 0x12, 0x34,
+ 0x56, 0x78, 0x23, 0x45, 0x67, 0x89};
} // namespace
TEST(RtcpPacketRapidResyncRequestTest, Parse) {
@@ -56,9 +55,8 @@
}
TEST(RtcpPacketRapidResyncRequestTest, ParseFailsOnTooLargePacket) {
- const uint8_t kTooLargePacket[] = {0x85, 205, 0x00, 0x03,
- 0x12, 0x34, 0x56, 0x78,
- 0x32, 0x21, 0x65, 0x87,
+ const uint8_t kTooLargePacket[] = {0x85, 205, 0x00, 0x03, 0x12, 0x34,
+ 0x56, 0x78, 0x32, 0x21, 0x65, 0x87,
0x23, 0x45, 0x67, 0x89};
RapidResyncRequest parsed;
EXPECT_FALSE(test::ParseSinglePacket(kTooLargePacket, &parsed));
diff --git a/modules/rtp_rtcp/source/rtcp_packet/rrtr_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/rrtr_unittest.cc
index 7bd79b3..56622ea 100644
--- a/modules/rtp_rtcp/source/rtcp_packet/rrtr_unittest.cc
+++ b/modules/rtp_rtcp/source/rtcp_packet/rrtr_unittest.cc
@@ -19,9 +19,8 @@
const uint32_t kNtpSec = 0x12345678;
const uint32_t kNtpFrac = 0x23456789;
-const uint8_t kBlock[] = {0x04, 0x00, 0x00, 0x02,
- 0x12, 0x34, 0x56, 0x78,
- 0x23, 0x45, 0x67, 0x89};
+const uint8_t kBlock[] = {0x04, 0x00, 0x00, 0x02, 0x12, 0x34,
+ 0x56, 0x78, 0x23, 0x45, 0x67, 0x89};
const size_t kBlockSizeBytes = sizeof(kBlock);
static_assert(
kBlockSizeBytes == Rrtr::kLength,
diff --git a/modules/rtp_rtcp/source/rtcp_packet/sdes_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/sdes_unittest.cc
index 7896f2d..b903a4e 100644
--- a/modules/rtp_rtcp/source/rtcp_packet/sdes_unittest.cc
+++ b/modules/rtp_rtcp/source/rtcp_packet/sdes_unittest.cc
@@ -97,11 +97,10 @@
TEST(RtcpPacketSdesTest, ParseSkipsNonCNameField) {
const uint8_t kName[] = "abc";
const uint8_t kCname[] = "de";
- const uint8_t kValidPacket[] = {0x81, 202, 0x00, 0x04,
- 0x12, 0x34, 0x56, 0x78,
- kNameTag, 3, kName[0], kName[1], kName[2],
- kCnameTag, 2, kCname[0], kCname[1],
- kTerminatorTag, kPadding, kPadding};
+ const uint8_t kValidPacket[] = {
+ 0x81, 202, 0x00, 0x04, 0x12, 0x34, 0x56,
+ 0x78, kNameTag, 3, kName[0], kName[1], kName[2], kCnameTag,
+ 2, kCname[0], kCname[1], kTerminatorTag, kPadding, kPadding};
// Sanity checks packet was assembled correctly.
ASSERT_EQ(0u, sizeof(kValidPacket) % 4);
ASSERT_EQ(kValidPacket[3] + 1u, sizeof(kValidPacket) / 4);
@@ -118,13 +117,14 @@
const uint8_t kName[] = "ab";
const uint8_t kEmail[] = "de";
const uint8_t kCname[] = "def";
- const uint8_t kPacket[] = {0x82, 202, 0x00, 0x07,
- 0x12, 0x34, 0x56, 0x78, // 1st chunk.
- kNameTag, 3, kName[0], kName[1], kName[2],
- kEmailTag, 2, kEmail[0], kEmail[1],
- kTerminatorTag, kPadding, kPadding,
- 0x23, 0x45, 0x67, 0x89, // 2nd chunk.
- kCnameTag, 3, kCname[0], kCname[1], kCname[2],
+ const uint8_t kPacket[] = {
+ 0x82, 202, 0x00, 0x07, 0x12,
+ 0x34, 0x56, 0x78, // 1st chunk.
+ kNameTag, 3, kName[0], kName[1], kName[2],
+ kEmailTag, 2, kEmail[0], kEmail[1], kTerminatorTag,
+ kPadding, kPadding, 0x23, 0x45, 0x67,
+ 0x89, // 2nd chunk.
+ kCnameTag, 3, kCname[0], kCname[1], kCname[2],
kTerminatorTag, kPadding, kPadding};
// Sanity checks packet was assembled correctly.
ASSERT_EQ(0u, sizeof(kPacket) % 4);
@@ -141,10 +141,9 @@
const uint8_t kName[] = "abc";
const uint8_t kCname[] = "d";
// No place for next chunk item.
- const uint8_t kInvalidPacket[] = {0x81, 202, 0x00, 0x03,
- 0x12, 0x34, 0x56, 0x78,
- kNameTag, 3, kName[0], kName[1], kName[2],
- kCnameTag, 1, kCname[0]};
+ const uint8_t kInvalidPacket[] = {
+ 0x81, 202, 0x00, 0x03, 0x12, 0x34, 0x56, 0x78,
+ kNameTag, 3, kName[0], kName[1], kName[2], kCnameTag, 1, kCname[0]};
// Sanity checks packet was assembled correctly.
ASSERT_EQ(0u, sizeof(kInvalidPacket) % 4);
ASSERT_EQ(kInvalidPacket[3] + 1u, sizeof(kInvalidPacket) / 4);
@@ -157,11 +156,9 @@
const uint8_t kName[] = "ab";
const uint8_t kCname[] = "d";
// Next chunk item has non-terminator type, but not the size.
- const uint8_t kInvalidPacket[] = {0x81, 202, 0x00, 0x03,
- 0x12, 0x34, 0x56, 0x78,
- kNameTag, 2, kName[0], kName[1],
- kCnameTag, 1, kCname[0],
- kEmailTag};
+ const uint8_t kInvalidPacket[] = {
+ 0x81, 202, 0x00, 0x03, 0x12, 0x34, 0x56, 0x78,
+ kNameTag, 2, kName[0], kName[1], kCnameTag, 1, kCname[0], kEmailTag};
// Sanity checks packet was assembled correctly.
ASSERT_EQ(0u, sizeof(kInvalidPacket) % 4);
ASSERT_EQ(kInvalidPacket[3] + 1u, sizeof(kInvalidPacket) / 4);
@@ -174,10 +171,9 @@
const uint8_t kName[] = "abc";
const uint8_t kCname[] = "d";
// Last chunk item has length that goes beyond the buffer end.
- const uint8_t kInvalidPacket[] = {0x81, 202, 0x00, 0x03,
- 0x12, 0x34, 0x56, 0x78,
- kNameTag, 3, kName[0], kName[1], kName[2],
- kCnameTag, 2, kCname[0]};
+ const uint8_t kInvalidPacket[] = {
+ 0x81, 202, 0x00, 0x03, 0x12, 0x34, 0x56, 0x78,
+ kNameTag, 3, kName[0], kName[1], kName[2], kCnameTag, 2, kCname[0]};
// Sanity checks packet was assembled correctly.
ASSERT_EQ(0u, sizeof(kInvalidPacket) % 4);
ASSERT_EQ(kInvalidPacket[3] + 1u, sizeof(kInvalidPacket) / 4);
@@ -189,11 +185,10 @@
TEST(RtcpPacketSdesTest, ParseFailsWithTwoCNames) {
const uint8_t kCname1[] = "a";
const uint8_t kCname2[] = "de";
- const uint8_t kInvalidPacket[] = {0x81, 202, 0x00, 0x03,
- 0x12, 0x34, 0x56, 0x78,
- kCnameTag, 1, kCname1[0],
- kCnameTag, 2, kCname2[0], kCname2[1],
- kTerminatorTag};
+ const uint8_t kInvalidPacket[] = {
+ 0x81, 202, 0x00, 0x03, 0x12, 0x34, 0x56,
+ 0x78, kCnameTag, 1, kCname1[0], kCnameTag, 2, kCname2[0],
+ kCname2[1], kTerminatorTag};
// Sanity checks packet was assembled correctly.
ASSERT_EQ(0u, sizeof(kInvalidPacket) % 4);
ASSERT_EQ(kInvalidPacket[3] + 1u, sizeof(kInvalidPacket) / 4);
@@ -206,12 +201,11 @@
const uint8_t kCname[] = "a";
const uint8_t kEmail[] = "de";
// Two chunks are promised in the header, but no place for the second chunk.
- const uint8_t kInvalidPacket[] = {0x82, 202, 0x00, 0x04,
- 0x12, 0x34, 0x56, 0x78, // 1st chunk.
- kCnameTag, 1, kCname[0],
- kEmailTag, 2, kEmail[0], kEmail[1],
- kTerminatorTag,
- 0x23, 0x45, 0x67, 0x89}; // 2nd chunk.
+ const uint8_t kInvalidPacket[] = {
+ 0x82, 202, 0x00, 0x04, 0x12, 0x34, 0x56,
+ 0x78, // 1st chunk.
+ kCnameTag, 1, kCname[0], kEmailTag, 2, kEmail[0], kEmail[1],
+ kTerminatorTag, 0x23, 0x45, 0x67, 0x89}; // 2nd chunk.
// Sanity checks packet was assembled correctly.
ASSERT_EQ(0u, sizeof(kInvalidPacket) % 4);
ASSERT_EQ(kInvalidPacket[3] + 1u, sizeof(kInvalidPacket) / 4);
diff --git a/modules/rtp_rtcp/source/rtcp_packet/sender_report_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/sender_report_unittest.cc
index 30edc7e..a0c6e72 100644
--- a/modules/rtp_rtcp/source/rtcp_packet/sender_report_unittest.cc
+++ b/modules/rtp_rtcp/source/rtcp_packet/sender_report_unittest.cc
@@ -29,13 +29,10 @@
const uint32_t kRtpTimestamp = 0x33343536;
const uint32_t kPacketCount = 0x44454647;
const uint32_t kOctetCount = 0x55565758;
-const uint8_t kPacket[] = {0x80, 200, 0x00, 0x06,
- 0x12, 0x34, 0x56, 0x78,
- 0x11, 0x12, 0x14, 0x18,
- 0x22, 0x24, 0x26, 0x28,
- 0x33, 0x34, 0x35, 0x36,
- 0x44, 0x45, 0x46, 0x47,
- 0x55, 0x56, 0x57, 0x58};
+const uint8_t kPacket[] = {0x80, 200, 0x00, 0x06, 0x12, 0x34, 0x56,
+ 0x78, 0x11, 0x12, 0x14, 0x18, 0x22, 0x24,
+ 0x26, 0x28, 0x33, 0x34, 0x35, 0x36, 0x44,
+ 0x45, 0x46, 0x47, 0x55, 0x56, 0x57, 0x58};
} // namespace
TEST(RtcpPacketSenderReportTest, CreateWithoutReportBlocks) {
diff --git a/modules/rtp_rtcp/source/rtcp_packet/tmmbn_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/tmmbn_unittest.cc
index 5a85d8a..e5d2e0b 100644
--- a/modules/rtp_rtcp/source/rtcp_packet/tmmbn_unittest.cc
+++ b/modules/rtp_rtcp/source/rtcp_packet/tmmbn_unittest.cc
@@ -26,11 +26,9 @@
const uint32_t kRemoteSsrc = 0x23456789;
const uint32_t kBitrateBps = 312000;
const uint16_t kOverhead = 0x1fe;
-const uint8_t kPacket[] = {0x84, 205, 0x00, 0x04,
- 0x12, 0x34, 0x56, 0x78,
- 0x00, 0x00, 0x00, 0x00,
- 0x23, 0x45, 0x67, 0x89,
- 0x0a, 0x61, 0x61, 0xfe};
+const uint8_t kPacket[] = {0x84, 205, 0x00, 0x04, 0x12, 0x34, 0x56,
+ 0x78, 0x00, 0x00, 0x00, 0x00, 0x23, 0x45,
+ 0x67, 0x89, 0x0a, 0x61, 0x61, 0xfe};
} // namespace
TEST(RtcpPacketTmmbnTest, Create) {
@@ -97,9 +95,8 @@
}
TEST(RtcpPacketTmmbnTest, ParseFailsOnUnAlignedPacket) {
- const uint8_t kUnalignedPacket[] = {0x84, 205, 0x00, 0x03,
- 0x12, 0x34, 0x56, 0x78,
- 0x00, 0x00, 0x00, 0x00,
+ const uint8_t kUnalignedPacket[] = {0x84, 205, 0x00, 0x03, 0x12, 0x34,
+ 0x56, 0x78, 0x00, 0x00, 0x00, 0x00,
0x23, 0x45, 0x67, 0x89};
Tmmbn tmmbn;
diff --git a/modules/rtp_rtcp/source/rtcp_packet/tmmbr_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/tmmbr_unittest.cc
index d3fe72a..63fa911 100644
--- a/modules/rtp_rtcp/source/rtcp_packet/tmmbr_unittest.cc
+++ b/modules/rtp_rtcp/source/rtcp_packet/tmmbr_unittest.cc
@@ -26,11 +26,9 @@
const uint32_t kRemoteSsrc = 0x23456789;
const uint32_t kBitrateBps = 312000;
const uint16_t kOverhead = 0x1fe;
-const uint8_t kPacket[] = {0x83, 205, 0x00, 0x04,
- 0x12, 0x34, 0x56, 0x78,
- 0x00, 0x00, 0x00, 0x00,
- 0x23, 0x45, 0x67, 0x89,
- 0x0a, 0x61, 0x61, 0xfe};
+const uint8_t kPacket[] = {0x83, 205, 0x00, 0x04, 0x12, 0x34, 0x56,
+ 0x78, 0x00, 0x00, 0x00, 0x00, 0x23, 0x45,
+ 0x67, 0x89, 0x0a, 0x61, 0x61, 0xfe};
} // namespace
TEST(RtcpPacketTmmbrTest, Create) {
@@ -74,21 +72,17 @@
}
TEST(RtcpPacketTmmbrTest, ParseFailsWithoutItems) {
- const uint8_t kZeroItemsPacket[] = {0x83, 205, 0x00, 0x02,
- 0x12, 0x34, 0x56, 0x78,
- 0x00, 0x00, 0x00, 0x00};
+ const uint8_t kZeroItemsPacket[] = {0x83, 205, 0x00, 0x02, 0x12, 0x34,
+ 0x56, 0x78, 0x00, 0x00, 0x00, 0x00};
Tmmbr tmmbr;
EXPECT_FALSE(test::ParseSinglePacket(kZeroItemsPacket, &tmmbr));
}
TEST(RtcpPacketTmmbrTest, ParseFailsOnUnAlignedPacket) {
- const uint8_t kUnalignedPacket[] = {0x83, 205, 0x00, 0x05,
- 0x12, 0x34, 0x56, 0x78,
- 0x00, 0x00, 0x00, 0x00,
- 0x23, 0x45, 0x67, 0x89,
- 0x0a, 0x61, 0x61, 0xfe,
- 0x34, 0x56, 0x78, 0x9a};
+ const uint8_t kUnalignedPacket[] = {
+ 0x83, 205, 0x00, 0x05, 0x12, 0x34, 0x56, 0x78, 0x00, 0x00, 0x00, 0x00,
+ 0x23, 0x45, 0x67, 0x89, 0x0a, 0x61, 0x61, 0xfe, 0x34, 0x56, 0x78, 0x9a};
Tmmbr tmmbr;
EXPECT_FALSE(test::ParseSinglePacket(kUnalignedPacket, &tmmbr));
diff --git a/modules/rtp_rtcp/source/rtcp_packet/transport_feedback_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/transport_feedback_unittest.cc
index 310246a..0496525 100644
--- a/modules/rtp_rtcp/source/rtcp_packet/transport_feedback_unittest.cc
+++ b/modules/rtp_rtcp/source/rtcp_packet/transport_feedback_unittest.cc
@@ -79,8 +79,8 @@
ASSERT_TRUE(feedback_->IsConsistent());
serialized_ = feedback_->Build();
VerifyInternal();
- feedback_ = TransportFeedback::ParseFrom(serialized_.data(),
- serialized_.size());
+ feedback_ =
+ TransportFeedback::ParseFrom(serialized_.data(), serialized_.size());
ASSERT_TRUE(feedback_->IsConsistent());
ASSERT_NE(nullptr, feedback_.get());
VerifyInternal();
@@ -209,10 +209,7 @@
TEST(RtcpPacketTest, TransportFeedback_LargeAndNegativeDeltas) {
const uint16_t kReceived[] = {1, 2, 6, 7, 8};
const int64_t kReceiveTimes[] = {
- 2000,
- 1000,
- 4000,
- 3000,
+ 2000, 1000, 4000, 3000,
3000 + TransportFeedback::kDeltaScaleFactor * (1 << 8)};
const size_t kLength = sizeof(kReceived) / sizeof(uint16_t);
const size_t kExpectedSizeBytes =
diff --git a/modules/rtp_rtcp/source/rtcp_packet/voip_metric_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/voip_metric_unittest.cc
index a2fbcc5..598b8c6 100644
--- a/modules/rtp_rtcp/source/rtcp_packet/voip_metric_unittest.cc
+++ b/modules/rtp_rtcp/source/rtcp_packet/voip_metric_unittest.cc
@@ -17,11 +17,10 @@
namespace {
const uint32_t kRemoteSsrc = 0x23456789;
-const uint8_t kBlock[] = {0x07, 0x00, 0x00, 0x08, 0x23, 0x45, 0x67, 0x89,
- 0x01, 0x02, 0x03, 0x04, 0x11, 0x12, 0x22, 0x23,
- 0x33, 0x34, 0x44, 0x45, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x00, 0x55, 0x56,
- 0x66, 0x67, 0x77, 0x78};
+const uint8_t kBlock[] = {0x07, 0x00, 0x00, 0x08, 0x23, 0x45, 0x67, 0x89, 0x01,
+ 0x02, 0x03, 0x04, 0x11, 0x12, 0x22, 0x23, 0x33, 0x34,
+ 0x44, 0x45, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
+ 0x0c, 0x0d, 0x00, 0x55, 0x56, 0x66, 0x67, 0x77, 0x78};
const size_t kBlockSizeBytes = sizeof(kBlock);
static_assert(
kBlockSizeBytes == VoipMetric::kLength,
diff --git a/modules/rtp_rtcp/source/rtcp_receiver.cc b/modules/rtp_rtcp/source/rtcp_receiver.cc
index af164cc..491bd45 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver.cc
+++ b/modules/rtp_rtcp/source/rtcp_receiver.cc
@@ -820,8 +820,7 @@
TmmbrInformation* tmmbr_info = FindOrCreateTmmbrInfo(tmmbr.sender_ssrc());
auto* entry = &tmmbr_info->tmmbr[sender_ssrc];
- entry->tmmbr_item = rtcp::TmmbItem(sender_ssrc,
- request.bitrate_bps(),
+ entry->tmmbr_item = rtcp::TmmbItem(sender_ssrc, request.bitrate_bps(),
request.packet_overhead());
entry->last_updated_ms = clock_->TimeInMilliseconds();
diff --git a/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc b/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc
index a6fd593..41d4725 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc
+++ b/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc
@@ -1235,8 +1235,8 @@
// Modify the TransportFeedback packet so that it is invalid.
const size_t kStatusCountOffset = 14;
- ByteWriter<uint16_t>::WriteBigEndian(
- &built_packet.data()[kStatusCountOffset], 42);
+ ByteWriter<uint16_t>::WriteBigEndian(&built_packet.data()[kStatusCountOffset],
+ 42);
// Stress no transport feedback is expected.
EXPECT_CALL(transport_feedback_observer_, OnTransportFeedback(_)).Times(0);
diff --git a/modules/rtp_rtcp/source/rtcp_sender_unittest.cc b/modules/rtp_rtcp/source/rtcp_sender_unittest.cc
index c7c38bf..974f19f 100644
--- a/modules/rtp_rtcp/source/rtcp_sender_unittest.cc
+++ b/modules/rtp_rtcp/source/rtcp_sender_unittest.cc
@@ -42,8 +42,7 @@
RtcpPacketTypeCounter counter_;
};
-class TestTransport : public Transport,
- public RtpData {
+class TestTransport : public Transport, public RtpData {
public:
TestTransport() {}
@@ -69,7 +68,7 @@
static const uint32_t kRemoteSsrc = 0x22222222;
static const uint32_t kStartRtpTimestamp = 0x34567;
static const uint32_t kRtpTimestamp = 0x45678;
-}
+} // namespace
class RtcpSenderTest : public ::testing::Test {
protected:
@@ -309,8 +308,9 @@
TEST_F(RtcpSenderTest, SetInvalidApplicationSpecificData) {
const uint8_t kData[] = {'t', 'e', 's', 't', 'd', 'a', 't'};
const uint16_t kInvalidDataLength = sizeof(kData) / sizeof(kData[0]);
- EXPECT_EQ(-1, rtcp_sender_->SetApplicationSpecificData(
- 0, 0, kData, kInvalidDataLength)); // Should by multiple of 4.
+ EXPECT_EQ(-1,
+ rtcp_sender_->SetApplicationSpecificData(
+ 0, 0, kData, kInvalidDataLength)); // Should by multiple of 4.
}
TEST_F(RtcpSenderTest, SendFir) {
@@ -630,23 +630,24 @@
TEST_F(RtcpSenderTest, ByeMustBeLast) {
MockTransport mock_transport;
EXPECT_CALL(mock_transport, SendRtcp(_, _))
- .WillOnce(Invoke([](const uint8_t* data, size_t len) {
- const uint8_t* next_packet = data;
- const uint8_t* const packet_end = data + len;
- rtcp::CommonHeader packet;
- while (next_packet < packet_end) {
- EXPECT_TRUE(packet.Parse(next_packet, packet_end - next_packet));
- next_packet = packet.NextPacket();
- if (packet.type() == rtcp::Bye::kPacketType) // Main test expectation.
- EXPECT_EQ(0, packet_end - next_packet)
- << "Bye packet should be last in a compound RTCP packet.";
- if (next_packet == packet_end) // Validate test was set correctly.
- EXPECT_EQ(packet.type(), rtcp::Bye::kPacketType)
- << "Last packet in this test expected to be Bye.";
- }
+ .WillOnce(Invoke([](const uint8_t* data, size_t len) {
+ const uint8_t* next_packet = data;
+ const uint8_t* const packet_end = data + len;
+ rtcp::CommonHeader packet;
+ while (next_packet < packet_end) {
+ EXPECT_TRUE(packet.Parse(next_packet, packet_end - next_packet));
+ next_packet = packet.NextPacket();
+ if (packet.type() ==
+ rtcp::Bye::kPacketType) // Main test expectation.
+ EXPECT_EQ(0, packet_end - next_packet)
+ << "Bye packet should be last in a compound RTCP packet.";
+ if (next_packet == packet_end) // Validate test was set correctly.
+ EXPECT_EQ(packet.type(), rtcp::Bye::kPacketType)
+ << "Last packet in this test expected to be Bye.";
+ }
- return true;
- }));
+ return true;
+ }));
// Re-configure rtcp_sender_ with mock_transport_
rtcp_sender_.reset(new RTCPSender(false, &clock_, receive_statistics_.get(),
diff --git a/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc b/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc
index 1fe5000..c2ec58a 100644
--- a/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc
+++ b/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc
@@ -246,7 +246,6 @@
config.outgoing_transport = &mock_transport;
RtcpTransceiverImpl rtcp_transceiver(config);
-
EXPECT_CALL(mock_transport, SendRtcp(_, _)).Times(0);
const uint8_t raw[] = {1, 2, 3, 4};
diff --git a/modules/rtp_rtcp/source/rtp_fec_unittest.cc b/modules/rtp_rtcp/source/rtp_fec_unittest.cc
index ba18fc6..cbad0ae 100644
--- a/modules/rtp_rtcp/source/rtp_fec_unittest.cc
+++ b/modules/rtp_rtcp/source/rtp_fec_unittest.cc
@@ -155,19 +155,19 @@
// All recovered packets must be identical to the corresponding
// original packets.
- auto cmp = [](
- const std::unique_ptr<ForwardErrorCorrection::Packet>& media_packet,
- const std::unique_ptr<ForwardErrorCorrection::RecoveredPacket>&
- recovered_packet) {
- if (media_packet->length != recovered_packet->pkt->length) {
- return false;
- }
- if (memcmp(media_packet->data, recovered_packet->pkt->data,
- media_packet->length) != 0) {
- return false;
- }
- return true;
- };
+ auto cmp =
+ [](const std::unique_ptr<ForwardErrorCorrection::Packet>& media_packet,
+ const std::unique_ptr<ForwardErrorCorrection::RecoveredPacket>&
+ recovered_packet) {
+ if (media_packet->length != recovered_packet->pkt->length) {
+ return false;
+ }
+ if (memcmp(media_packet->data, recovered_packet->pkt->data,
+ media_packet->length) != 0) {
+ return false;
+ }
+ return true;
+ };
return std::equal(media_packets_.cbegin(), media_packets_.cend(),
recovered_packets_.cbegin(), cmp);
}
@@ -286,8 +286,7 @@
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
for (const auto& received_packet : this->received_packets_) {
- this->fec_.DecodeFec(*received_packet,
- &this->recovered_packets_);
+ this->fec_.DecodeFec(*received_packet, &this->recovered_packets_);
}
// No packets lost, expect complete recovery.
@@ -318,8 +317,7 @@
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
for (const auto& received_packet : this->received_packets_) {
- this->fec_.DecodeFec(*received_packet,
- &this->recovered_packets_);
+ this->fec_.DecodeFec(*received_packet, &this->recovered_packets_);
}
// One packet lost, one FEC packet, expect complete recovery.
@@ -334,8 +332,7 @@
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
for (const auto& received_packet : this->received_packets_) {
- this->fec_.DecodeFec(*received_packet,
- &this->recovered_packets_);
+ this->fec_.DecodeFec(*received_packet, &this->recovered_packets_);
}
// 2 packets lost, one FEC packet, cannot get complete recovery.
@@ -398,8 +395,7 @@
this->ReceivedPackets(this->media_packets_, this->media_loss_mask_, false);
for (const auto& received_packet : this->received_packets_) {
- this->fec_.DecodeFec(*received_packet,
- &this->recovered_packets_);
+ this->fec_.DecodeFec(*received_packet, &this->recovered_packets_);
}
// Expect that no decoding is done to get missing packet (seq#0) of third
@@ -441,8 +437,7 @@
true);
for (const auto& received_packet : this->received_packets_) {
- this->fec_.DecodeFec(*received_packet,
- &this->recovered_packets_);
+ this->fec_.DecodeFec(*received_packet, &this->recovered_packets_);
}
// Expect 3 media packets in recovered list, and complete recovery.
@@ -493,8 +488,7 @@
true);
for (const auto& received_packet : this->received_packets_) {
- this->fec_.DecodeFec(*received_packet,
- &this->recovered_packets_);
+ this->fec_.DecodeFec(*received_packet, &this->recovered_packets_);
}
// The two FEC packets are received and should allow for complete recovery,
@@ -552,8 +546,7 @@
true);
for (const auto& received_packet : this->received_packets_) {
- this->fec_.DecodeFec(*received_packet,
- &this->recovered_packets_);
+ this->fec_.DecodeFec(*received_packet, &this->recovered_packets_);
}
// The two FEC packets are received and should allow for complete recovery,
@@ -598,8 +591,7 @@
std::swap(*it0, *it1);
for (const auto& received_packet : this->received_packets_) {
- this->fec_.DecodeFec(*received_packet,
- &this->recovered_packets_);
+ this->fec_.DecodeFec(*received_packet, &this->recovered_packets_);
}
// Expect 3 media packets in recovered list, and complete recovery.
@@ -638,8 +630,7 @@
this->ReceivedPackets(this->media_packets_, this->media_loss_mask_, false);
for (const auto& received_packet : this->received_packets_) {
- this->fec_.DecodeFec(*received_packet,
- &this->recovered_packets_);
+ this->fec_.DecodeFec(*received_packet, &this->recovered_packets_);
}
// Expect 3 media packets in recovered list, and complete recovery.
@@ -687,8 +678,7 @@
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
for (const auto& received_packet : this->received_packets_) {
- this->fec_.DecodeFec(*received_packet,
- &this->recovered_packets_);
+ this->fec_.DecodeFec(*received_packet, &this->recovered_packets_);
}
// With media packet#1 and FEC packets #1, #2, #3, expect complete recovery.
@@ -705,8 +695,7 @@
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
for (const auto& received_packet : this->received_packets_) {
- this->fec_.DecodeFec(*received_packet,
- &this->recovered_packets_);
+ this->fec_.DecodeFec(*received_packet, &this->recovered_packets_);
}
// Cannot get complete recovery for this loss configuration with random mask.
@@ -753,8 +742,7 @@
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
for (const auto& received_packet : this->received_packets_) {
- this->fec_.DecodeFec(*received_packet,
- &this->recovered_packets_);
+ this->fec_.DecodeFec(*received_packet, &this->recovered_packets_);
}
// Expect complete recovery for consecutive packet loss <= 50%.
@@ -771,8 +759,7 @@
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
for (const auto& received_packet : this->received_packets_) {
- this->fec_.DecodeFec(*received_packet,
- &this->recovered_packets_);
+ this->fec_.DecodeFec(*received_packet, &this->recovered_packets_);
}
// Expect complete recovery for consecutive packet loss <= 50%.
@@ -789,8 +776,7 @@
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
for (const auto& received_packet : this->received_packets_) {
- this->fec_.DecodeFec(*received_packet,
- &this->recovered_packets_);
+ this->fec_.DecodeFec(*received_packet, &this->recovered_packets_);
}
// Cannot get complete recovery for this loss configuration.
@@ -820,8 +806,7 @@
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
for (const auto& received_packet : this->received_packets_) {
- this->fec_.DecodeFec(*received_packet,
- &this->recovered_packets_);
+ this->fec_.DecodeFec(*received_packet, &this->recovered_packets_);
}
// No packets lost, expect complete recovery.
@@ -852,8 +837,7 @@
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
for (const auto& received_packet : this->received_packets_) {
- this->fec_.DecodeFec(*received_packet,
- &this->recovered_packets_);
+ this->fec_.DecodeFec(*received_packet, &this->recovered_packets_);
}
// One packet lost, one FEC packet, expect complete recovery.
@@ -868,8 +852,7 @@
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
for (const auto& received_packet : this->received_packets_) {
- this->fec_.DecodeFec(*received_packet,
- &this->recovered_packets_);
+ this->fec_.DecodeFec(*received_packet, &this->recovered_packets_);
}
// 2 packets lost, one FEC packet, cannot get complete recovery.
@@ -914,8 +897,7 @@
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
for (const auto& received_packet : this->received_packets_) {
- this->fec_.DecodeFec(*received_packet,
- &this->recovered_packets_);
+ this->fec_.DecodeFec(*received_packet, &this->recovered_packets_);
}
// With media packet#3 and FEC packets #0, #1, #3, expect complete recovery.
@@ -933,8 +915,7 @@
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
for (const auto& received_packet : this->received_packets_) {
- this->fec_.DecodeFec(*received_packet,
- &this->recovered_packets_);
+ this->fec_.DecodeFec(*received_packet, &this->recovered_packets_);
}
// Cannot get complete recovery for this loss configuration.
@@ -970,8 +951,7 @@
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
for (const auto& received_packet : this->received_packets_) {
- this->fec_.DecodeFec(*received_packet,
- &this->recovered_packets_);
+ this->fec_.DecodeFec(*received_packet, &this->recovered_packets_);
}
// One packet lost, one FEC packet, expect complete recovery.
@@ -985,8 +965,7 @@
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
for (const auto& received_packet : this->received_packets_) {
- this->fec_.DecodeFec(*received_packet,
- &this->recovered_packets_);
+ this->fec_.DecodeFec(*received_packet, &this->recovered_packets_);
}
// Unprotected packet lost. Recovery not possible.
@@ -1001,8 +980,7 @@
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
for (const auto& received_packet : this->received_packets_) {
- this->fec_.DecodeFec(*received_packet,
- &this->recovered_packets_);
+ this->fec_.DecodeFec(*received_packet, &this->recovered_packets_);
}
// 2 protected packets lost, one FEC packet, cannot get complete recovery.
@@ -1041,8 +1019,7 @@
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
for (const auto& received_packet : this->received_packets_) {
- this->fec_.DecodeFec(*received_packet,
- &this->recovered_packets_);
+ this->fec_.DecodeFec(*received_packet, &this->recovered_packets_);
}
// One packet lost, one FEC packet, expect complete recovery.
@@ -1056,8 +1033,7 @@
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
for (const auto& received_packet : this->received_packets_) {
- this->fec_.DecodeFec(*received_packet,
- &this->recovered_packets_);
+ this->fec_.DecodeFec(*received_packet, &this->recovered_packets_);
}
// Unprotected packet lost. Recovery not possible.
@@ -1076,8 +1052,7 @@
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
for (const auto& received_packet : this->received_packets_) {
- this->fec_.DecodeFec(*received_packet,
- &this->recovered_packets_);
+ this->fec_.DecodeFec(*received_packet, &this->recovered_packets_);
}
// 5 protected packets lost, one FEC packet, cannot get complete recovery.
@@ -1116,8 +1091,7 @@
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
for (const auto& received_packet : this->received_packets_) {
- this->fec_.DecodeFec(*received_packet,
- &this->recovered_packets_);
+ this->fec_.DecodeFec(*received_packet, &this->recovered_packets_);
}
// One packet lost, one FEC packet, expect complete recovery.
@@ -1131,8 +1105,7 @@
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
for (const auto& received_packet : this->received_packets_) {
- this->fec_.DecodeFec(*received_packet,
- &this->recovered_packets_);
+ this->fec_.DecodeFec(*received_packet, &this->recovered_packets_);
}
// Unprotected packet lost. Recovery not possible.
@@ -1151,8 +1124,7 @@
this->NetworkReceivedPackets(this->media_loss_mask_, this->fec_loss_mask_);
for (const auto& received_packet : this->received_packets_) {
- this->fec_.DecodeFec(*received_packet,
- &this->recovered_packets_);
+ this->fec_.DecodeFec(*received_packet, &this->recovered_packets_);
}
// 5 protected packets lost, one FEC packet, cannot get complete recovery.
diff --git a/modules/rtp_rtcp/source/rtp_format_h264.cc b/modules/rtp_rtcp/source/rtp_format_h264.cc
index 633f0ae..9c91611 100644
--- a/modules/rtp_rtcp/source/rtp_format_h264.cc
+++ b/modules/rtp_rtcp/source/rtp_format_h264.cc
@@ -92,8 +92,7 @@
RTC_CHECK_GT(max_payload_len, last_packet_reduction_len);
}
-RtpPacketizerH264::~RtpPacketizerH264() {
-}
+RtpPacketizerH264::~RtpPacketizerH264() {}
RtpPacketizerH264::Fragment::~Fragment() = default;
@@ -582,8 +581,8 @@
uint32_t pps_id;
uint32_t sps_id;
if (PpsParser::ParsePpsIds(&payload_data[start_offset],
- end_offset - start_offset, &pps_id,
- &sps_id)) {
+ end_offset - start_offset, &pps_id,
+ &sps_id)) {
nalu.pps_id = pps_id;
nalu.sps_id = sps_id;
} else {
diff --git a/modules/rtp_rtcp/source/rtp_format_h264_unittest.cc b/modules/rtp_rtcp/source/rtp_format_h264_unittest.cc
index cbf9996..0eaf7a5 100644
--- a/modules/rtp_rtcp/source/rtp_format_h264_unittest.cc
+++ b/modules/rtp_rtcp/source/rtp_format_h264_unittest.cc
@@ -493,7 +493,7 @@
0xC7, 0xE0, 0x1B, 0x41, 0x10, 0x8D, 0x00};
const uint8_t kIdrOne[] = {kIdr, 0xFF, 0x00, 0x00, 0x04};
const uint8_t kIdrTwo[] = {kIdr, 0xFF, 0x00, 0x11};
-}
+} // namespace
class RtpPacketizerH264TestSpsRewriting : public ::testing::Test {
public:
@@ -665,7 +665,7 @@
TEST_F(RtpDepacketizerH264Test, TestStapANaluSpsWithResolution) {
uint8_t packet[] = {kStapA, // F=0, NRI=0, Type=24.
- // Length (2 bytes), nal header, payload.
+ // Length (2 bytes), nal header, payload.
0x00, 0x19, kSps, 0x7A, 0x00, 0x1F, 0xBC, 0xD9, 0x40,
0x50, 0x05, 0xBA, 0x10, 0x00, 0x00, 0x03, 0x00, 0xC0,
0x00, 0x00, 0x03, 0x2A, 0xE0, 0xF1, 0x83, 0x25, 0x80,
@@ -796,9 +796,9 @@
TEST_F(RtpDepacketizerH264Test, TestStapADelta) {
uint8_t packet[16] = {kStapA, // F=0, NRI=0, Type=24.
- // Length, nal header, payload.
- 0, 0x02, kSlice, 0xFF, 0, 0x03, kSlice, 0xFF,
- 0x00, 0, 0x04, kSlice, 0xFF, 0x00, 0x11};
+ // Length, nal header, payload.
+ 0, 0x02, kSlice, 0xFF, 0, 0x03, kSlice, 0xFF, 0x00, 0,
+ 0x04, kSlice, 0xFF, 0x00, 0x11};
RtpDepacketizer::ParsedPayload payload;
ASSERT_TRUE(depacketizer_->Parse(&payload, packet, sizeof(packet)));
@@ -904,7 +904,7 @@
}
TEST_F(RtpDepacketizerH264Test, TestStapAPacketWithTruncatedNalUnits) {
- const uint8_t kPayload[] = { 0x58, 0xCB, 0xED, 0xDF};
+ const uint8_t kPayload[] = {0x58, 0xCB, 0xED, 0xDF};
RtpDepacketizer::ParsedPayload payload;
EXPECT_FALSE(depacketizer_->Parse(&payload, kPayload, sizeof(kPayload)));
}
@@ -923,7 +923,7 @@
TEST_F(RtpDepacketizerH264Test, TestSeiPacket) {
const uint8_t kPayload[] = {
- kSei, // F=0, NRI=0, Type=6.
+ kSei, // F=0, NRI=0, Type=6.
0x03, 0x03, 0x03, 0x03 // Payload.
};
RtpDepacketizer::ParsedPayload payload;
diff --git a/modules/rtp_rtcp/source/rtp_format_video_generic.cc b/modules/rtp_rtcp/source/rtp_format_video_generic.cc
index 14e4880..8be5b4a 100644
--- a/modules/rtp_rtcp/source/rtp_format_video_generic.cc
+++ b/modules/rtp_rtcp/source/rtp_format_video_generic.cc
@@ -30,8 +30,7 @@
num_packets_left_(0),
num_larger_packets_(0) {}
-RtpPacketizerGeneric::~RtpPacketizerGeneric() {
-}
+RtpPacketizerGeneric::~RtpPacketizerGeneric() {}
size_t RtpPacketizerGeneric::SetPayloadData(
const uint8_t* payload_data,
diff --git a/modules/rtp_rtcp/source/rtp_format_vp8.cc b/modules/rtp_rtcp/source/rtp_format_vp8.cc
index 85ab7c1..0f559e8 100644
--- a/modules/rtp_rtcp/source/rtp_format_vp8.cc
+++ b/modules/rtp_rtcp/source/rtp_format_vp8.cc
@@ -109,9 +109,8 @@
}
if (has_tid || has_key_idx) {
- if (ParseVP8TIDAndKeyIdx(
- vp8, &data, &data_length, &parsed_bytes, has_tid, has_key_idx) !=
- 0) {
+ if (ParseVP8TIDAndKeyIdx(vp8, &data, &data_length, &parsed_bytes, has_tid,
+ has_key_idx) != 0) {
return -1;
}
}
@@ -171,8 +170,7 @@
RTC_DCHECK(ValidateHeader(hdr_info));
}
-RtpPacketizerVp8::~RtpPacketizerVp8() {
-}
+RtpPacketizerVp8::~RtpPacketizerVp8() {}
size_t RtpPacketizerVp8::SetPayloadData(
const uint8_t* payload_data,
@@ -252,8 +250,8 @@
if (num_packets_left == 2 && current_packet_bytes == remaining_data) {
--current_packet_bytes;
}
- QueuePacket(payload_len - remaining_data,
- current_packet_bytes, remaining_data == payload_len);
+ QueuePacket(payload_len - remaining_data, current_packet_bytes,
+ remaining_data == payload_len);
remaining_data -= current_packet_bytes;
--num_packets_left;
}
@@ -302,8 +300,7 @@
return -1;
memcpy(&buffer[vp8_fixed_payload_descriptor_bytes_ + extension_length],
- &payload_data_[packet_info.payload_start_pos],
- packet_info.size);
+ &payload_data_[packet_info.payload_start_pos], packet_info.size);
// Return total length of written data.
return packet_info.size + vp8_fixed_payload_descriptor_bytes_ +
@@ -318,20 +315,20 @@
*x_field = 0;
extension_length = 1; // One octet for the X field.
if (PictureIdPresent()) {
- if (WritePictureIDFields(
- x_field, buffer, buffer_length, &extension_length) < 0) {
+ if (WritePictureIDFields(x_field, buffer, buffer_length,
+ &extension_length) < 0) {
return -1;
}
}
if (TL0PicIdxFieldPresent()) {
- if (WriteTl0PicIdxFields(
- x_field, buffer, buffer_length, &extension_length) < 0) {
+ if (WriteTl0PicIdxFields(x_field, buffer, buffer_length,
+ &extension_length) < 0) {
return -1;
}
}
if (TIDFieldPresent() || KeyIdxFieldPresent()) {
- if (WriteTIDAndKeyIdxFields(
- x_field, buffer, buffer_length, &extension_length) < 0) {
+ if (WriteTIDAndKeyIdxFields(x_field, buffer, buffer_length,
+ &extension_length) < 0) {
return -1;
}
}
@@ -516,8 +513,7 @@
if (extension) {
const int parsed_bytes =
ParseVP8Extension(&parsed_payload->type.Video.codecHeader.VP8,
- payload_data,
- payload_data_length);
+ payload_data, payload_data_length);
if (parsed_bytes < 0)
return false;
payload_data += parsed_bytes;
diff --git a/modules/rtp_rtcp/source/rtp_format_vp8.h b/modules/rtp_rtcp/source/rtp_format_vp8.h
index 7697480..3f0d7e5 100644
--- a/modules/rtp_rtcp/source/rtp_format_vp8.h
+++ b/modules/rtp_rtcp/source/rtp_format_vp8.h
@@ -82,13 +82,10 @@
// Splits given part of payload to packets with a given capacity. The last
// packet should be reduced by last_packet_reduction_len_.
- void GeneratePacketsSplitPayloadBalanced(size_t payload_len,
- size_t capacity);
+ void GeneratePacketsSplitPayloadBalanced(size_t payload_len, size_t capacity);
// Insert packet into packet queue.
- void QueuePacket(size_t start_pos,
- size_t packet_size,
- bool first_packet);
+ void QueuePacket(size_t start_pos, size_t packet_size, bool first_packet);
// Write the payload header and copy the payload to the buffer.
// The info in packet_info determines which part of the payload is written
diff --git a/modules/rtp_rtcp/source/rtp_format_vp8_test_helper.cc b/modules/rtp_rtcp/source/rtp_format_vp8_test_helper.cc
index 62d7c3c..8dc7ba0 100644
--- a/modules/rtp_rtcp/source/rtp_format_vp8_test_helper.cc
+++ b/modules/rtp_rtcp/source/rtp_format_vp8_test_helper.cc
@@ -8,7 +8,6 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-
#include "modules/rtp_rtcp/source/rtp_format_vp8_test_helper.h"
#include "test/gtest.h"
@@ -32,12 +31,13 @@
RtpFormatVp8TestHelper::~RtpFormatVp8TestHelper() {
delete fragmentation_;
- delete [] payload_data_;
+ delete[] payload_data_;
}
bool RtpFormatVp8TestHelper::Init(const size_t* partition_sizes,
size_t num_partitions) {
- if (inited_) return false;
+ if (inited_)
+ return false;
fragmentation_ = new RTPFragmentationHeader;
fragmentation_->VerifyAndAllocateFragmentationHeader(num_partitions);
payload_size_ = 0;
@@ -95,7 +95,7 @@
// First octet tests.
#define EXPECT_BIT_EQ(x, n, a) EXPECT_EQ((((x) >> (n)) & 0x1), a)
-#define EXPECT_RSV_ZERO(x) EXPECT_EQ(((x) & 0xE0), 0)
+#define EXPECT_RSV_ZERO(x) EXPECT_EQ(((x)&0xE0), 0)
#define EXPECT_BIT_X_EQ(x, a) EXPECT_BIT_EQ(x, 7, a)
@@ -103,7 +103,7 @@
#define EXPECT_BIT_S_EQ(x, a) EXPECT_BIT_EQ(x, 4, a)
-#define EXPECT_PART_ID_EQ(x, a) EXPECT_EQ(((x) & 0x0F), a)
+#define EXPECT_PART_ID_EQ(x, a) EXPECT_EQ(((x)&0x0F), a)
// Extension fields tests
#define EXPECT_BIT_I_EQ(x, a) EXPECT_BIT_EQ(x, 7, a)
@@ -114,11 +114,11 @@
#define EXPECT_BIT_K_EQ(x, a) EXPECT_BIT_EQ(x, 4, a)
-#define EXPECT_TID_EQ(x, a) EXPECT_EQ((((x) & 0xC0) >> 6), a)
+#define EXPECT_TID_EQ(x, a) EXPECT_EQ((((x)&0xC0) >> 6), a)
#define EXPECT_BIT_Y_EQ(x, a) EXPECT_BIT_EQ(x, 5, a)
-#define EXPECT_KEYIDX_EQ(x, a) EXPECT_EQ(((x) & 0x1F), a)
+#define EXPECT_KEYIDX_EQ(x, a) EXPECT_EQ(((x)&0x1F), a)
void RtpFormatVp8TestHelper::CheckHeader(bool frag_start) {
payload_start_ = 1;
@@ -127,8 +127,7 @@
if (hdr_info_->pictureId != kNoPictureId ||
hdr_info_->temporalIdx != kNoTemporalIdx ||
- hdr_info_->tl0PicIdx != kNoTl0PicIdx ||
- hdr_info_->keyIdx != kNoKeyIdx) {
+ hdr_info_->tl0PicIdx != kNoTl0PicIdx || hdr_info_->keyIdx != kNoKeyIdx) {
EXPECT_BIT_X_EQ(buffer[0], 1);
++payload_start_;
CheckPictureID();
diff --git a/modules/rtp_rtcp/source/rtp_format_vp8_unittest.cc b/modules/rtp_rtcp/source/rtp_format_vp8_unittest.cc
index 3226000..cff14ed 100644
--- a/modules/rtp_rtcp/source/rtp_format_vp8_unittest.cc
+++ b/modules/rtp_rtcp/source/rtp_format_vp8_unittest.cc
@@ -123,11 +123,8 @@
ASSERT_EQ(num_packets, kExpectedNum);
helper_->set_sloppy_partitioning(true);
- helper_->GetAllPacketsAndCheck(&packetizer,
- kExpectedSizes,
- kExpectedPart,
- kExpectedFragStart,
- kExpectedNum);
+ helper_->GetAllPacketsAndCheck(&packetizer, kExpectedSizes, kExpectedPart,
+ kExpectedFragStart, kExpectedNum);
}
TEST_F(RtpPacketizerVp8Test, TestEqualSizeWithLastPacketReduction) {
@@ -184,11 +181,8 @@
ASSERT_EQ(num_packets, kExpectedNum);
helper_->set_sloppy_partitioning(true);
- helper_->GetAllPacketsAndCheck(&packetizer,
- kExpectedSizes,
- kExpectedPart,
- kExpectedFragStart,
- kExpectedNum);
+ helper_->GetAllPacketsAndCheck(&packetizer, kExpectedSizes, kExpectedPart,
+ kExpectedFragStart, kExpectedNum);
}
// Verify Tl0PicIdx and TID fields, and layerSync bit.
@@ -216,11 +210,8 @@
CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart);
ASSERT_EQ(num_packets, kExpectedNum);
- helper_->GetAllPacketsAndCheck(&packetizer,
- kExpectedSizes,
- kExpectedPart,
- kExpectedFragStart,
- kExpectedNum);
+ helper_->GetAllPacketsAndCheck(&packetizer, kExpectedSizes, kExpectedPart,
+ kExpectedFragStart, kExpectedNum);
}
// Verify KeyIdx field.
@@ -246,11 +237,8 @@
CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart);
ASSERT_EQ(num_packets, kExpectedNum);
- helper_->GetAllPacketsAndCheck(&packetizer,
- kExpectedSizes,
- kExpectedPart,
- kExpectedFragStart,
- kExpectedNum);
+ helper_->GetAllPacketsAndCheck(&packetizer, kExpectedSizes, kExpectedPart,
+ kExpectedFragStart, kExpectedNum);
}
// Verify TID field and KeyIdx field in combination.
@@ -277,11 +265,8 @@
CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart);
ASSERT_EQ(num_packets, kExpectedNum);
- helper_->GetAllPacketsAndCheck(&packetizer,
- kExpectedSizes,
- kExpectedPart,
- kExpectedFragStart,
- kExpectedNum);
+ helper_->GetAllPacketsAndCheck(&packetizer, kExpectedSizes, kExpectedPart,
+ kExpectedFragStart, kExpectedNum);
}
class RtpDepacketizerVp8Test : public ::testing::Test {
@@ -310,14 +295,14 @@
RtpDepacketizer::ParsedPayload payload;
ASSERT_TRUE(depacketizer_->Parse(&payload, packet, sizeof(packet)));
- ExpectPacket(
- &payload, packet + kHeaderLength, sizeof(packet) - kHeaderLength);
+ ExpectPacket(&payload, packet + kHeaderLength,
+ sizeof(packet) - kHeaderLength);
EXPECT_EQ(kVideoFrameDelta, payload.frame_type);
EXPECT_EQ(kVideoCodecVP8, payload.type.Video.codec);
VerifyBasicHeader(&payload.type, 0, 1, 4);
- VerifyExtensions(
- &payload.type, kNoPictureId, kNoTl0PicIdx, kNoTemporalIdx, kNoKeyIdx);
+ VerifyExtensions(&payload.type, kNoPictureId, kNoTl0PicIdx, kNoTemporalIdx,
+ kNoKeyIdx);
}
TEST_F(RtpDepacketizerVp8Test, PictureID) {
@@ -331,13 +316,13 @@
RtpDepacketizer::ParsedPayload payload;
ASSERT_TRUE(depacketizer_->Parse(&payload, packet, sizeof(packet)));
- ExpectPacket(
- &payload, packet + kHeaderLength1, sizeof(packet) - kHeaderLength1);
+ ExpectPacket(&payload, packet + kHeaderLength1,
+ sizeof(packet) - kHeaderLength1);
EXPECT_EQ(kVideoFrameDelta, payload.frame_type);
EXPECT_EQ(kVideoCodecVP8, payload.type.Video.codec);
VerifyBasicHeader(&payload.type, 1, 0, 0);
- VerifyExtensions(
- &payload.type, kPictureId, kNoTl0PicIdx, kNoTemporalIdx, kNoKeyIdx);
+ VerifyExtensions(&payload.type, kPictureId, kNoTl0PicIdx, kNoTemporalIdx,
+ kNoKeyIdx);
// Re-use packet, but change to long PictureID.
packet[2] = 0x80 | kPictureId;
@@ -345,14 +330,11 @@
payload = RtpDepacketizer::ParsedPayload();
ASSERT_TRUE(depacketizer_->Parse(&payload, packet, sizeof(packet)));
- ExpectPacket(
- &payload, packet + kHeaderLength2, sizeof(packet) - kHeaderLength2);
+ ExpectPacket(&payload, packet + kHeaderLength2,
+ sizeof(packet) - kHeaderLength2);
VerifyBasicHeader(&payload.type, 1, 0, 0);
- VerifyExtensions(&payload.type,
- (kPictureId << 8) + kPictureId,
- kNoTl0PicIdx,
- kNoTemporalIdx,
- kNoKeyIdx);
+ VerifyExtensions(&payload.type, (kPictureId << 8) + kPictureId, kNoTl0PicIdx,
+ kNoTemporalIdx, kNoKeyIdx);
}
TEST_F(RtpDepacketizerVp8Test, Tl0PicIdx) {
@@ -365,13 +347,13 @@
RtpDepacketizer::ParsedPayload payload;
ASSERT_TRUE(depacketizer_->Parse(&payload, packet, sizeof(packet)));
- ExpectPacket(
- &payload, packet + kHeaderLength, sizeof(packet) - kHeaderLength);
+ ExpectPacket(&payload, packet + kHeaderLength,
+ sizeof(packet) - kHeaderLength);
EXPECT_EQ(kVideoFrameKey, payload.frame_type);
EXPECT_EQ(kVideoCodecVP8, payload.type.Video.codec);
VerifyBasicHeader(&payload.type, 0, 1, 0);
- VerifyExtensions(
- &payload.type, kNoPictureId, kTl0PicIdx, kNoTemporalIdx, kNoKeyIdx);
+ VerifyExtensions(&payload.type, kNoPictureId, kTl0PicIdx, kNoTemporalIdx,
+ kNoKeyIdx);
}
TEST_F(RtpDepacketizerVp8Test, TIDAndLayerSync) {
@@ -383,8 +365,8 @@
RtpDepacketizer::ParsedPayload payload;
ASSERT_TRUE(depacketizer_->Parse(&payload, packet, sizeof(packet)));
- ExpectPacket(
- &payload, packet + kHeaderLength, sizeof(packet) - kHeaderLength);
+ ExpectPacket(&payload, packet + kHeaderLength,
+ sizeof(packet) - kHeaderLength);
EXPECT_EQ(kVideoFrameDelta, payload.frame_type);
EXPECT_EQ(kVideoCodecVP8, payload.type.Video.codec);
VerifyBasicHeader(&payload.type, 0, 0, 8);
@@ -402,13 +384,13 @@
RtpDepacketizer::ParsedPayload payload;
ASSERT_TRUE(depacketizer_->Parse(&payload, packet, sizeof(packet)));
- ExpectPacket(
- &payload, packet + kHeaderLength, sizeof(packet) - kHeaderLength);
+ ExpectPacket(&payload, packet + kHeaderLength,
+ sizeof(packet) - kHeaderLength);
EXPECT_EQ(kVideoFrameDelta, payload.frame_type);
EXPECT_EQ(kVideoCodecVP8, payload.type.Video.codec);
VerifyBasicHeader(&payload.type, 0, 0, 8);
- VerifyExtensions(
- &payload.type, kNoPictureId, kNoTl0PicIdx, kNoTemporalIdx, kKeyIdx);
+ VerifyExtensions(&payload.type, kNoPictureId, kNoTl0PicIdx, kNoTemporalIdx,
+ kKeyIdx);
}
TEST_F(RtpDepacketizerVp8Test, MultipleExtensions) {
@@ -423,8 +405,8 @@
RtpDepacketizer::ParsedPayload payload;
ASSERT_TRUE(depacketizer_->Parse(&payload, packet, sizeof(packet)));
- ExpectPacket(
- &payload, packet + kHeaderLength, sizeof(packet) - kHeaderLength);
+ ExpectPacket(&payload, packet + kHeaderLength,
+ sizeof(packet) - kHeaderLength);
EXPECT_EQ(kVideoFrameDelta, payload.frame_type);
EXPECT_EQ(kVideoCodecVP8, payload.type.Video.codec);
VerifyBasicHeader(&payload.type, 0, 0, 8);
@@ -467,10 +449,8 @@
EXPECT_EQ(kVideoFrameKey, payload.frame_type);
EXPECT_EQ(kVideoCodecVP8, payload.type.Video.codec);
VerifyBasicHeader(&payload.type, 1, 1, 0);
- VerifyExtensions(&payload.type,
- input_header.pictureId,
- input_header.tl0PicIdx,
- input_header.temporalIdx,
+ VerifyExtensions(&payload.type, input_header.pictureId,
+ input_header.tl0PicIdx, input_header.temporalIdx,
input_header.keyIdx);
EXPECT_EQ(payload.type.Video.codecHeader.VP8.layerSync,
input_header.layerSync);
diff --git a/modules/rtp_rtcp/source/rtp_format_vp9.cc b/modules/rtp_rtcp/source/rtp_format_vp9.cc
index b354fb1..cae7911 100644
--- a/modules/rtp_rtcp/source/rtp_format_vp9.cc
+++ b/modules/rtp_rtcp/source/rtp_format_vp9.cc
@@ -73,8 +73,7 @@
// +-+-+-+-+-+-+-+-+
//
size_t LayerInfoLength(const RTPVideoHeaderVP9& hdr) {
- if (hdr.temporal_idx == kNoTemporalIdx &&
- hdr.spatial_idx == kNoSpatialIdx) {
+ if (hdr.temporal_idx == kNoTemporalIdx && hdr.spatial_idx == kNoSpatialIdx) {
return 0;
}
return hdr.flexible_mode ? 1 : 2;
@@ -127,12 +126,12 @@
RTC_DCHECK_GT(hdr.num_spatial_layers, 0U);
RTC_DCHECK_LE(hdr.num_spatial_layers, kMaxVp9NumberOfSpatialLayers);
RTC_DCHECK_LE(hdr.gof.num_frames_in_gof, kMaxVp9FramesInGof);
- size_t length = 1; // V
+ size_t length = 1; // V
if (hdr.spatial_layer_resolution_present) {
- length += 4 * hdr.num_spatial_layers; // Y
+ length += 4 * hdr.num_spatial_layers; // Y
}
if (hdr.gof.num_frames_in_gof > 0) {
- ++length; // G
+ ++length; // G
}
// N_G
length += hdr.gof.num_frames_in_gof; // T, U, R
@@ -194,7 +193,8 @@
RETURN_FALSE_ON_ERROR(writer->WriteBits(TemporalIdxField(vp9, 0), 3));
RETURN_FALSE_ON_ERROR(writer->WriteBits(vp9.temporal_up_switch ? 1 : 0, 1));
RETURN_FALSE_ON_ERROR(writer->WriteBits(SpatialIdxField(vp9, 0), 3));
- RETURN_FALSE_ON_ERROR(writer->WriteBits(vp9.inter_layer_predicted ? 1: 0, 1));
+ RETURN_FALSE_ON_ERROR(
+ writer->WriteBits(vp9.inter_layer_predicted ? 1 : 0, 1));
return true;
}
@@ -232,8 +232,8 @@
//
bool WriteRefIndices(const RTPVideoHeaderVP9& vp9,
rtc::BitBufferWriter* writer) {
- if (!PictureIdPresent(vp9) ||
- vp9.num_ref_pics == 0 || vp9.num_ref_pics > kMaxVp9RefPics) {
+ if (!PictureIdPresent(vp9) || vp9.num_ref_pics == 0 ||
+ vp9.num_ref_pics > kMaxVp9RefPics) {
return false;
}
for (uint8_t i = 0; i < vp9.num_ref_pics; ++i) {
@@ -469,8 +469,7 @@
payload_size_(0),
last_packet_reduction_len_(last_packet_reduction_len) {}
-RtpPacketizerVp9::~RtpPacketizerVp9() {
-}
+RtpPacketizerVp9::~RtpPacketizerVp9() {}
std::string RtpPacketizerVp9::ToString() {
return "RtpPacketizerVp9";
@@ -634,8 +633,8 @@
return false;
// Copy payload data.
- memcpy(&buffer[header_length],
- &payload_[packet_info.payload_start_pos], packet_info.size);
+ memcpy(&buffer[header_length], &payload_[packet_info.payload_start_pos],
+ packet_info.size);
packet->SetPayloadSize(header_length + packet_info.size);
return true;
diff --git a/modules/rtp_rtcp/source/rtp_format_vp9.h b/modules/rtp_rtcp/source/rtp_format_vp9.h
index 0171977..9017864 100644
--- a/modules/rtp_rtcp/source/rtp_format_vp9.h
+++ b/modules/rtp_rtcp/source/rtp_format_vp9.h
@@ -87,7 +87,6 @@
RTC_DISALLOW_COPY_AND_ASSIGN(RtpPacketizerVp9);
};
-
class RtpDepacketizerVp9 : public RtpDepacketizer {
public:
~RtpDepacketizerVp9() override = default;
diff --git a/modules/rtp_rtcp/source/rtp_format_vp9_unittest.cc b/modules/rtp_rtcp/source/rtp_format_vp9_unittest.cc
index 2fe415a..e798302 100644
--- a/modules/rtp_rtcp/source/rtp_format_vp9_unittest.cc
+++ b/modules/rtp_rtcp/source/rtp_format_vp9_unittest.cc
@@ -225,7 +225,7 @@
const size_t kFrameSize = 30;
const size_t kPacketSize = 12;
- expected_.picture_id = kMaxOneBytePictureId; // 2 byte payload descriptor
+ expected_.picture_id = kMaxOneBytePictureId; // 2 byte payload descriptor
expected_.max_picture_id = kMaxOneBytePictureId;
Init(kFrameSize, kPacketSize);
@@ -584,8 +584,7 @@
class RtpDepacketizerVp9Test : public ::testing::Test {
protected:
- RtpDepacketizerVp9Test()
- : depacketizer_(new RtpDepacketizerVp9()) {}
+ RtpDepacketizerVp9Test() : depacketizer_(new RtpDepacketizerVp9()) {}
void SetUp() override { expected_.InitRTPVideoHeaderVP9(); }
@@ -705,8 +704,8 @@
TEST_F(RtpDepacketizerVp9Test, ParseRefIdxFailsWithNoPictureId) {
const uint8_t kPdiff = 3;
uint8_t packet[13] = {0};
- packet[0] = 0x58; // I:0 P:1 L:0 F:1 B:1 E:0 V:0 Z:0
- packet[1] = (kPdiff << 1); // P,F: P_DIFF:3 N:0
+ packet[0] = 0x58; // I:0 P:1 L:0 F:1 B:1 E:0 V:0 Z:0
+ packet[1] = (kPdiff << 1); // P,F: P_DIFF:3 N:0
RtpDepacketizer::ParsedPayload parsed;
EXPECT_FALSE(depacketizer_->Parse(&parsed, packet, sizeof(packet)));
diff --git a/modules/rtp_rtcp/source/rtp_payload_registry.cc b/modules/rtp_rtcp/source/rtp_payload_registry.cc
index c48cd6c..f69940a 100644
--- a/modules/rtp_rtcp/source/rtp_payload_registry.cc
+++ b/modules/rtp_rtcp/source/rtp_payload_registry.cc
@@ -30,8 +30,8 @@
bool PayloadIsCompatible(const RtpUtility::Payload& payload,
const VideoCodec& video_codec) {
if (!payload.typeSpecific.is_video() ||
- _stricmp(payload.name,
- CodecTypeToPayloadString(video_codec.codecType)) != 0)
+ _stricmp(payload.name, CodecTypeToPayloadString(video_codec.codecType)) !=
+ 0)
return false;
// For H264, profiles must match as well.
if (video_codec.codecType == kVideoCodecH264) {
@@ -72,15 +72,15 @@
// Sanity check.
switch (payload_type) {
// Reserved payload types to avoid RTCP conflicts when marker bit is set.
- case 64: // 192 Full INTRA-frame request.
- case 72: // 200 Sender report.
- case 73: // 201 Receiver report.
- case 74: // 202 Source description.
- case 75: // 203 Goodbye.
- case 76: // 204 Application-defined.
- case 77: // 205 Transport layer FB message.
- case 78: // 206 Payload-specific FB message.
- case 79: // 207 Extended report.
+ case 64: // 192 Full INTRA-frame request.
+ case 72: // 200 Sender report.
+ case 73: // 201 Receiver report.
+ case 74: // 202 Source description.
+ case 75: // 203 Goodbye.
+ case 76: // 204 Application-defined.
+ case 77: // 205 Transport layer FB message.
+ case 78: // 206 Payload-specific FB message.
+ case 79: // 207 Extended report.
RTC_LOG(LS_ERROR) << "Can't register invalid receiver payload type: "
<< payload_type;
return false;
@@ -91,8 +91,7 @@
} // namespace
-RTPPayloadRegistry::RTPPayloadRegistry()
- : last_received_payload_type_(-1) {}
+RTPPayloadRegistry::RTPPayloadRegistry() : last_received_payload_type_(-1) {}
RTPPayloadRegistry::~RTPPayloadRegistry() = default;
@@ -215,8 +214,7 @@
}
}
-int RTPPayloadRegistry::GetPayloadTypeFrequency(
- uint8_t payload_type) const {
+int RTPPayloadRegistry::GetPayloadTypeFrequency(uint8_t payload_type) const {
const auto payload = PayloadTypeToPayload(payload_type);
if (!payload) {
return -1;
diff --git a/modules/rtp_rtcp/source/rtp_receiver_audio.cc b/modules/rtp_rtcp/source/rtp_receiver_audio.cc
index 0669519..3db5ef5 100644
--- a/modules/rtp_rtcp/source/rtp_receiver_audio.cc
+++ b/modules/rtp_rtcp/source/rtp_receiver_audio.cc
@@ -11,7 +11,7 @@
#include "modules/rtp_rtcp/source/rtp_receiver_audio.h"
#include <assert.h> // assert
-#include <math.h> // pow()
+#include <math.h> // pow()
#include <string.h> // memcpy()
#include "common_types.h" // NOLINT(build/include)
@@ -53,8 +53,7 @@
return telephone_event_forward_to_decoder_;
}
-bool RTPReceiverAudio::TelephoneEventPayloadType(
- int8_t payload_type) const {
+bool RTPReceiverAudio::TelephoneEventPayloadType(int8_t payload_type) const {
rtc::CritScope lock(&crit_sect_);
return telephone_event_payload_type_ == payload_type;
}
@@ -139,8 +138,7 @@
num_energy_ = rtp_header->type.Audio.numEnergy;
if (rtp_header->type.Audio.numEnergy > 0 &&
rtp_header->type.Audio.numEnergy <= kRtpCsrcSize) {
- memcpy(current_remote_energy_,
- rtp_header->type.Audio.arrOfEnergy,
+ memcpy(current_remote_energy_, rtp_header->type.Audio.arrOfEnergy,
rtp_header->type.Audio.numEnergy);
}
@@ -154,7 +152,6 @@
RTPAliveType RTPReceiverAudio::ProcessDeadOrAlive(
uint16_t last_payload_length) const {
-
// Our CNG is 9 bytes; if it's a likely CNG the receiver needs to check
// kRtpNoRtp against NetEq speech_type kOutputPLCtoCNG.
if (last_payload_length < 10) { // our CNG is 9 bytes
@@ -264,8 +261,7 @@
// don't forward event to decoder
return 0;
}
- std::set<uint8_t>::iterator first =
- telephone_event_reported_.begin();
+ std::set<uint8_t>::iterator first = telephone_event_reported_.begin();
if (first != telephone_event_reported_.end() && *first > 15) {
// don't forward non DTMF events
return 0;
diff --git a/modules/rtp_rtcp/source/rtp_receiver_impl.cc b/modules/rtp_rtcp/source/rtp_receiver_impl.cc
index fb2cc66..a0d201a 100644
--- a/modules/rtp_rtcp/source/rtp_receiver_impl.cc
+++ b/modules/rtp_rtcp/source/rtp_receiver_impl.cc
@@ -89,7 +89,6 @@
current_remote_csrc_(),
last_received_timestamp_(0),
last_received_frame_time_ms_(-1) {
-
memset(current_remote_csrc_, 0, sizeof(current_remote_csrc_));
}
@@ -122,8 +121,7 @@
return rtp_payload_registry_->RegisterReceivePayload(video_codec);
}
-int32_t RtpReceiverImpl::DeRegisterReceivePayload(
- const int8_t payload_type) {
+int32_t RtpReceiverImpl::DeRegisterReceivePayload(const int8_t payload_type) {
rtc::CritScope lock(&critical_section_rtp_receiver_);
return rtp_payload_registry_->DeRegisterReceivePayload(payload_type);
}
@@ -140,13 +138,12 @@
assert(num_csrcs_ <= kRtpCsrcSize);
if (num_csrcs_ > 0) {
- memcpy(array_of_csrcs, current_remote_csrc_, sizeof(uint32_t)*num_csrcs_);
+ memcpy(array_of_csrcs, current_remote_csrc_, sizeof(uint32_t) * num_csrcs_);
}
return num_csrcs_;
}
-int32_t RtpReceiverImpl::Energy(
- uint8_t array_of_energy[kRtpCsrcSize]) const {
+int32_t RtpReceiverImpl::Energy(uint8_t array_of_energy[kRtpCsrcSize]) const {
return rtp_media_receiver_->Energy(array_of_energy);
}
@@ -157,8 +154,7 @@
// Trigger our callbacks.
CheckSSRCChanged(rtp_header);
- if (CheckPayloadChanged(rtp_header,
- &payload_specific) == -1) {
+ if (CheckPayloadChanged(rtp_header, &payload_specific) == -1) {
if (payload_length == 0) {
// OK, keep-alive packet.
return true;
@@ -282,9 +278,8 @@
if (payload_type != last_received_payload_type) {
bool should_discard_changes = false;
- rtp_media_receiver_->CheckPayloadChanged(
- payload_type, specific_payload,
- &should_discard_changes);
+ rtp_media_receiver_->CheckPayloadChanged(payload_type, specific_payload,
+ &should_discard_changes);
if (should_discard_changes) {
return 0;
@@ -314,8 +309,7 @@
rtc::CritScope lock(&critical_section_rtp_receiver_);
// Copy new.
- memcpy(current_remote_csrc_,
- rtp_header.header.arrOfCSRCs,
+ memcpy(current_remote_csrc_, rtp_header.header.arrOfCSRCs,
num_csrcs * sizeof(uint32_t));
num_csrcs_ = num_csrcs;
diff --git a/modules/rtp_rtcp/source/rtp_receiver_video.cc b/modules/rtp_rtcp/source/rtp_receiver_video.cc
index ee6cc27..d93ee76 100644
--- a/modules/rtp_rtcp/source/rtp_receiver_video.cc
+++ b/modules/rtp_rtcp/source/rtp_receiver_video.cc
@@ -32,11 +32,9 @@
}
RTPReceiverVideo::RTPReceiverVideo(RtpData* data_callback)
- : RTPReceiverStrategy(data_callback) {
-}
+ : RTPReceiverStrategy(data_callback) {}
-RTPReceiverVideo::~RTPReceiverVideo() {
-}
+RTPReceiverVideo::~RTPReceiverVideo() {}
int32_t RTPReceiverVideo::OnNewPayloadTypeCreated(
int payload_type,
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
index 289ef53..fe8dbf3 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
@@ -64,8 +64,7 @@
} else {
// No clock implementation provided, use default clock.
RtpRtcp::Configuration configuration_copy;
- memcpy(&configuration_copy, &configuration,
- sizeof(RtpRtcp::Configuration));
+ memcpy(&configuration_copy, &configuration, sizeof(RtpRtcp::Configuration));
configuration_copy.clock = Clock::GetRealTimeClock();
return new ModuleRtpRtcpImpl(configuration_copy);
}
@@ -221,10 +220,10 @@
} else {
// Report rtt from receiver.
if (process_rtt) {
- int64_t rtt_ms;
- if (rtt_stats_ && rtcp_receiver_.GetAndResetXrRrRtt(&rtt_ms)) {
- rtt_stats_->OnRttUpdate(rtt_ms);
- }
+ int64_t rtt_ms;
+ if (rtt_stats_ && rtcp_receiver_.GetAndResetXrRrRtt(&rtt_ms)) {
+ rtt_stats_->OnRttUpdate(rtt_ms);
+ }
}
}
@@ -277,8 +276,7 @@
rtcp_receiver_.IncomingPacket(rtcp_packet, length);
}
-int32_t ModuleRtpRtcpImpl::RegisterSendPayload(
- const CodecInst& voice_codec) {
+int32_t ModuleRtpRtcpImpl::RegisterSendPayload(const CodecInst& voice_codec) {
return rtp_sender_->RegisterPayload(
voice_codec.plname, voice_codec.pltype, voice_codec.plfreq,
voice_codec.channels, (voice_codec.rate < 0) ? 0 : voice_codec.rate);
@@ -365,16 +363,15 @@
StreamDataCounters rtp_stats;
StreamDataCounters rtx_stats;
rtp_sender_->GetDataCounters(&rtp_stats, &rtx_stats);
- state.packets_sent = rtp_stats.transmitted.packets +
- rtx_stats.transmitted.packets;
+ state.packets_sent =
+ rtp_stats.transmitted.packets + rtx_stats.transmitted.packets;
state.media_bytes_sent = rtp_stats.transmitted.payload_bytes +
rtx_stats.transmitted.payload_bytes;
state.send_bitrate = rtp_sender_->BitrateSent();
}
state.module = this;
- LastReceivedNTP(&state.last_rr_ntp_secs,
- &state.last_rr_ntp_frac,
+ LastReceivedNTP(&state.last_rr_ntp_secs, &state.last_rr_ntp_frac,
&state.remote_sr);
state.last_xr_rtis = rtcp_receiver_.ConsumeReceivedXrReferenceTimeInfo();
@@ -432,7 +429,7 @@
rtcp_sender_.SetLastRtpTime(time_stamp, capture_time_ms);
// Make sure an RTCP report isn't queued behind a key frame.
if (rtcp_sender_.TimeToSendRTCPReport(kVideoFrameKey == frame_type)) {
- rtcp_sender_.SendRTCP(GetFeedbackState(), kRtcpReport);
+ rtcp_sender_.SendRTCP(GetFeedbackState(), kRtcpReport);
}
int64_t expected_retransmission_time_ms = rtt_ms();
if (expected_retransmission_time_ms == 0) {
@@ -456,7 +453,7 @@
bool retransmission,
const PacedPacketInfo& pacing_info) {
return rtp_sender_->TimeToSendPacket(ssrc, sequence_number, capture_time_ms,
- retransmission, pacing_info);
+ retransmission, pacing_info);
}
size_t ModuleRtpRtcpImpl::TimeToSendPadding(
@@ -501,22 +498,18 @@
return rtcp_sender_.RemoveMixedCNAME(ssrc);
}
-int32_t ModuleRtpRtcpImpl::RemoteCNAME(
- const uint32_t remote_ssrc,
- char c_name[RTCP_CNAME_SIZE]) const {
+int32_t ModuleRtpRtcpImpl::RemoteCNAME(const uint32_t remote_ssrc,
+ char c_name[RTCP_CNAME_SIZE]) const {
return rtcp_receiver_.CNAME(remote_ssrc, c_name);
}
-int32_t ModuleRtpRtcpImpl::RemoteNTP(
- uint32_t* received_ntpsecs,
- uint32_t* received_ntpfrac,
- uint32_t* rtcp_arrival_time_secs,
- uint32_t* rtcp_arrival_time_frac,
- uint32_t* rtcp_timestamp) const {
- return rtcp_receiver_.NTP(received_ntpsecs,
- received_ntpfrac,
- rtcp_arrival_time_secs,
- rtcp_arrival_time_frac,
+int32_t ModuleRtpRtcpImpl::RemoteNTP(uint32_t* received_ntpsecs,
+ uint32_t* received_ntpfrac,
+ uint32_t* rtcp_arrival_time_secs,
+ uint32_t* rtcp_arrival_time_frac,
+ uint32_t* rtcp_timestamp) const {
+ return rtcp_receiver_.NTP(received_ntpsecs, received_ntpfrac,
+ rtcp_arrival_time_secs, rtcp_arrival_time_frac,
rtcp_timestamp)
? 0
: -1;
@@ -554,13 +547,13 @@
const uint32_t name,
const uint8_t* data,
const uint16_t length) {
- return rtcp_sender_.SetApplicationSpecificData(sub_type, name, data, length);
+ return rtcp_sender_.SetApplicationSpecificData(sub_type, name, data, length);
}
// (XR) VOIP metric.
int32_t ModuleRtpRtcpImpl::SetRTCPVoIPMetrics(
- const RTCPVoIPMetric* voip_metric) {
- return rtcp_sender_.SetRTCPVoIPMetrics(voip_metric);
+ const RTCPVoIPMetric* voip_metric) {
+ return rtcp_sender_.SetRTCPVoIPMetrics(voip_metric);
}
void ModuleRtpRtcpImpl::SetRtcpXrRrtrStatus(bool enable) {
@@ -573,9 +566,8 @@
}
// TODO(asapersson): Replace this method with the one below.
-int32_t ModuleRtpRtcpImpl::DataCountersRTP(
- size_t* bytes_sent,
- uint32_t* packets_sent) const {
+int32_t ModuleRtpRtcpImpl::DataCountersRTP(size_t* bytes_sent,
+ uint32_t* packets_sent) const {
StreamDataCounters rtp_stats;
StreamDataCounters rtx_stats;
rtp_sender_->GetDataCounters(&rtp_stats, &rtx_stats);
@@ -589,8 +581,8 @@
rtx_stats.transmitted.header_bytes;
}
if (packets_sent) {
- *packets_sent = rtp_stats.transmitted.packets +
- rtx_stats.transmitted.packets;
+ *packets_sent =
+ rtp_stats.transmitted.packets + rtx_stats.transmitted.packets;
}
return 0;
}
@@ -605,7 +597,8 @@
bool outgoing,
uint32_t ssrc,
struct RtpPacketLossStats* loss_stats) const {
- if (!loss_stats) return;
+ if (!loss_stats)
+ return;
const PacketLossStats* stats_source = NULL;
if (outgoing) {
if (SSRC() == ssrc) {
@@ -617,8 +610,7 @@
}
}
if (stats_source) {
- loss_stats->single_packet_loss_count =
- stats_source->GetSingleLossCount();
+ loss_stats->single_packet_loss_count = stats_source->GetSingleLossCount();
loss_stats->multiple_packet_loss_event_count =
stats_source->GetMultipleLossEventCount();
loss_stats->multiple_packet_loss_packet_count =
@@ -776,15 +768,13 @@
}
// Send a TelephoneEvent tone using RFC 2833 (4733).
-int32_t ModuleRtpRtcpImpl::SendTelephoneEventOutband(
- const uint8_t key,
- const uint16_t time_ms,
- const uint8_t level) {
+int32_t ModuleRtpRtcpImpl::SendTelephoneEventOutband(const uint8_t key,
+ const uint16_t time_ms,
+ const uint8_t level) {
return rtp_sender_->SendTelephoneEvent(key, time_ms, level);
}
-int32_t ModuleRtpRtcpImpl::SetAudioLevel(
- const uint8_t level_d_bov) {
+int32_t ModuleRtpRtcpImpl::SetAudioLevel(const uint8_t level_d_bov) {
return rtp_sender_->SetAudioLevel(level_d_bov);
}
@@ -843,8 +833,7 @@
for (uint16_t nack_sequence_number : nack_sequence_numbers) {
send_loss_stats_.AddLostPacket(nack_sequence_number);
}
- if (!rtp_sender_->StorePackets() ||
- nack_sequence_numbers.size() == 0) {
+ if (!rtp_sender_->StorePackets() || nack_sequence_numbers.size() == 0) {
return;
}
// Use RTT from RtcpRttStats class if provided.
@@ -869,11 +858,8 @@
uint32_t ntp_secs = 0;
uint32_t ntp_frac = 0;
- if (!rtcp_receiver_.NTP(&ntp_secs,
- &ntp_frac,
- rtcp_arrival_time_secs,
- rtcp_arrival_time_frac,
- NULL)) {
+ if (!rtcp_receiver_.NTP(&ntp_secs, &ntp_frac, rtcp_arrival_time_secs,
+ rtcp_arrival_time_frac, NULL)) {
return false;
}
*remote_sr =
@@ -922,7 +908,7 @@
}
StreamDataCountersCallback*
- ModuleRtpRtcpImpl::GetSendChannelRtpStatisticsCallback() const {
+ModuleRtpRtcpImpl::GetSendChannelRtpStatisticsCallback() const {
return rtp_sender_->GetRtpStatisticsCallback();
}
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc
index c92e744..0c9e885 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc
@@ -49,8 +49,7 @@
int64_t rtt_ms_;
};
-class SendTransport : public Transport,
- public RtpData {
+class SendTransport : public Transport, public RtpData {
public:
SendTransport()
: receiver_(nullptr),
@@ -61,9 +60,7 @@
keepalive_payload_type_(0),
num_keepalive_sent_(0) {}
- void SetRtpRtcpModule(ModuleRtpRtcpImpl* receiver) {
- receiver_ = receiver;
- }
+ void SetRtpRtcpModule(ModuleRtpRtcpImpl* receiver) { receiver_ = receiver; }
void SimulateNetworkDelay(int64_t delay_ms, SimulatedClock* clock) {
clock_ = clock;
delay_ms_ = delay_ms;
@@ -156,9 +153,7 @@
// Received RTCP stats for (own) local SSRC.
return counter_map_[impl_->SSRC()];
}
- int RtpSent() {
- return transport_.rtp_packets_sent_;
- }
+ int RtpSent() { return transport_.rtp_packets_sent_; }
uint16_t LastRtpSequenceNumber() {
return transport_.last_rtp_header_.sequenceNumber;
}
@@ -250,8 +245,8 @@
const uint8_t payload[100] = {0};
EXPECT_EQ(true, module->impl_->SendOutgoingData(
- kVideoFrameKey, codec_.plType, 0, 0, payload,
- sizeof(payload), nullptr, &rtp_video_header, nullptr));
+ kVideoFrameKey, codec_.plType, 0, 0, payload,
+ sizeof(payload), nullptr, &rtp_video_header, nullptr));
}
void IncomingRtcpNack(const RtpRtcpModule* module, uint16_t sequence_number) {
@@ -348,16 +343,16 @@
int64_t avg_rtt;
int64_t min_rtt;
int64_t max_rtt;
- EXPECT_EQ(0,
- sender_.impl_->RTT(kReceiverSsrc, &rtt, &avg_rtt, &min_rtt, &max_rtt));
+ EXPECT_EQ(
+ 0, sender_.impl_->RTT(kReceiverSsrc, &rtt, &avg_rtt, &min_rtt, &max_rtt));
EXPECT_NEAR(2 * kOneWayNetworkDelayMs, rtt, 1);
EXPECT_NEAR(2 * kOneWayNetworkDelayMs, avg_rtt, 1);
EXPECT_NEAR(2 * kOneWayNetworkDelayMs, min_rtt, 1);
EXPECT_NEAR(2 * kOneWayNetworkDelayMs, max_rtt, 1);
// No RTT from other ssrc.
- EXPECT_EQ(-1,
- sender_.impl_->RTT(kReceiverSsrc+1, &rtt, &avg_rtt, &min_rtt, &max_rtt));
+ EXPECT_EQ(-1, sender_.impl_->RTT(kReceiverSsrc + 1, &rtt, &avg_rtt, &min_rtt,
+ &max_rtt));
// Verify RTT from rtt_stats config.
EXPECT_EQ(0, sender_.rtt_stats_.LastProcessedRtt());
@@ -464,8 +459,8 @@
rtp.transmitted.header_bytes = 2;
rtp.transmitted.padding_bytes = 3;
EXPECT_EQ(rtp.transmitted.TotalBytes(), rtp.transmitted.payload_bytes +
- rtp.transmitted.header_bytes +
- rtp.transmitted.padding_bytes);
+ rtp.transmitted.header_bytes +
+ rtp.transmitted.padding_bytes);
StreamDataCounters rtp2;
rtp2.first_packet_time_ms = -1;
diff --git a/modules/rtp_rtcp/source/rtp_sender.cc b/modules/rtp_rtcp/source/rtp_sender.cc
index 8e0a4e8..42cdcf8 100644
--- a/modules/rtp_rtcp/source/rtp_sender.cc
+++ b/modules/rtp_rtcp/source/rtp_sender.cc
@@ -79,10 +79,14 @@
switch (frame_type) {
case kEmptyFrame:
return "empty";
- case kAudioFrameSpeech: return "audio_speech";
- case kAudioFrameCN: return "audio_cn";
- case kVideoFrameKey: return "video_key";
- case kVideoFrameDelta: return "video_delta";
+ case kAudioFrameSpeech:
+ return "audio_speech";
+ case kAudioFrameCN:
+ return "audio_cn";
+ case kVideoFrameKey:
+ return "video_key";
+ case kVideoFrameDelta:
+ return "video_delta";
}
return "";
}
@@ -260,8 +264,8 @@
RTC_DCHECK(payload);
// Check if it's the same as we already have.
- if (RtpUtility::StringCompare(
- payload->name, payload_name, RTP_PAYLOAD_NAME_SIZE - 1)) {
+ if (RtpUtility::StringCompare(payload->name, payload_name,
+ RTP_PAYLOAD_NAME_SIZE - 1)) {
if (audio_configured_ && payload->typeSpecific.is_audio()) {
auto& p = payload->typeSpecific.audio_payload();
if (rtc::SafeEq(p.format.clockrate_hz, frequency) &&
@@ -439,8 +443,8 @@
result = audio_->SendAudio(frame_type, payload_type, rtp_timestamp,
payload_data, payload_size);
} else {
- TRACE_EVENT_ASYNC_STEP1("webrtc", "Video", capture_time_ms,
- "Send", "type", FrameTypeToString(frame_type));
+ TRACE_EVENT_ASYNC_STEP1("webrtc", "Video", capture_time_ms, "Send", "type",
+ FrameTypeToString(frame_type));
if (frame_type == kEmptyFrame)
return true;
@@ -983,9 +987,9 @@
rtc::CritScope cs(&statistics_crit_);
// TODO(holmer): Compute this iteratively instead.
send_delays_[now_ms] = now_ms - capture_time_ms;
- send_delays_.erase(send_delays_.begin(),
- send_delays_.lower_bound(now_ms -
- kSendSideDelayWindowMs));
+ send_delays_.erase(
+ send_delays_.begin(),
+ send_delays_.lower_bound(now_ms - kSendSideDelayWindowMs));
int num_delays = 0;
for (auto it = send_delays_.upper_bound(now_ms - kSendSideDelayWindowMs);
it != send_delays_.end(); ++it) {
diff --git a/modules/rtp_rtcp/source/rtp_sender_audio.cc b/modules/rtp_rtcp/source/rtp_sender_audio.cc
index 4ca1688..bf86a39 100644
--- a/modules/rtp_rtcp/source/rtp_sender_audio.cc
+++ b/modules/rtp_rtcp/source/rtp_sender_audio.cc
@@ -26,8 +26,7 @@
namespace webrtc {
RTPSenderAudio::RTPSenderAudio(Clock* clock, RTPSender* rtp_sender)
- : clock_(clock),
- rtp_sender_(rtp_sender) {}
+ : clock_(clock), rtp_sender_(rtp_sender) {}
RTPSenderAudio::~RTPSenderAudio() {}
@@ -190,7 +189,8 @@
dtmf_duration_samples -= 0xffff;
dtmf_length_samples_ -= 0xffff;
- return SendTelephoneEventPacket(ended, dtmf_timestamp_,
+ return SendTelephoneEventPacket(
+ ended, dtmf_timestamp_,
static_cast<uint16_t>(dtmf_duration_samples), false);
} else {
if (!SendTelephoneEventPacket(ended, dtmf_timestamp_,
diff --git a/modules/rtp_rtcp/source/rtp_sender_unittest.cc b/modules/rtp_rtcp/source/rtp_sender_unittest.cc
index aa27263..86b0aa3 100644
--- a/modules/rtp_rtcp/source/rtp_sender_unittest.cc
+++ b/modules/rtp_rtcp/source/rtp_sender_unittest.cc
@@ -390,9 +390,8 @@
const size_t kMinPaddingSize = 50;
EXPECT_CALL(transport, SendRtp(_, kMinPaddingSize + kRtpHeaderSize, _))
.WillOnce(testing::Return(true));
- EXPECT_EQ(
- kMinPaddingSize,
- rtp_sender_->TimeToSendPadding(kMinPaddingSize - 5, PacedPacketInfo()));
+ EXPECT_EQ(kMinPaddingSize, rtp_sender_->TimeToSendPadding(kMinPaddingSize - 5,
+ PacedPacketInfo()));
}
TEST_P(RtpSenderTestWithoutPacer, AssignSequenceNumberSetPaddingTimestamps) {
@@ -941,21 +940,22 @@
PacketOptions options;
EXPECT_CALL(transport,
SendRtp(_, kPayloadSizes[0] + rtp_header_len + kRtxHeaderSize, _))
- .WillOnce(testing::DoAll(testing::SaveArg<2>(&options),
- testing::Return(true)));
+ .WillOnce(
+ testing::DoAll(testing::SaveArg<2>(&options), testing::Return(true)));
EXPECT_EQ(kPayloadSizes[0],
rtp_sender_->TimeToSendPadding(500, PacedPacketInfo()));
EXPECT_TRUE(options.is_retransmit);
- EXPECT_CALL(transport, SendRtp(_, kPayloadSizes[kNumPayloadSizes - 1] +
- rtp_header_len + kRtxHeaderSize,
+ EXPECT_CALL(transport, SendRtp(_,
+ kPayloadSizes[kNumPayloadSizes - 1] +
+ rtp_header_len + kRtxHeaderSize,
_))
.WillOnce(testing::Return(true));
options.is_retransmit = false;
EXPECT_CALL(transport, SendRtp(_, kMaxPaddingSize + rtp_header_len, _))
- .WillOnce(testing::DoAll(testing::SaveArg<2>(&options),
- testing::Return(true)));
+ .WillOnce(
+ testing::DoAll(testing::SaveArg<2>(&options), testing::Return(true)));
EXPECT_EQ(kPayloadSizes[kNumPayloadSizes - 1] + kMaxPaddingSize,
rtp_sender_->TimeToSendPadding(999, PacedPacketInfo()));
EXPECT_FALSE(options.is_retransmit);
diff --git a/modules/rtp_rtcp/source/rtp_utility.cc b/modules/rtp_rtcp/source/rtp_utility.cc
index 1d44b3c..e050da6 100644
--- a/modules/rtp_rtcp/source/rtp_utility.cc
+++ b/modules/rtp_rtcp/source/rtp_utility.cc
@@ -33,8 +33,7 @@
* Misc utility routines
*/
-bool StringCompare(const char* str1, const char* str2,
- const uint32_t length) {
+bool StringCompare(const char* str1, const char* str2, const uint32_t length) {
return _strnicmp(str1, str2, length) == 0;
}
@@ -48,11 +47,9 @@
RtpHeaderParser::RtpHeaderParser(const uint8_t* rtpData,
const size_t rtpDataLength)
: _ptrRTPDataBegin(rtpData),
- _ptrRTPDataEnd(rtpData ? (rtpData + rtpDataLength) : NULL) {
-}
+ _ptrRTPDataEnd(rtpData ? (rtpData + rtpDataLength) : NULL) {}
-RtpHeaderParser::~RtpHeaderParser() {
-}
+RtpHeaderParser::~RtpHeaderParser() {}
bool RtpHeaderParser::RTCP() const {
// 72 to 76 is reserved for RTP
@@ -60,21 +57,21 @@
// for RTCP 200 SR == marker bit + 72
// for RTCP 204 APP == marker bit + 76
/*
- * RTCP
- *
- * FIR full INTRA-frame request 192 [RFC2032] supported
- * NACK negative acknowledgement 193 [RFC2032]
- * IJ Extended inter-arrival jitter report 195 [RFC-ietf-avt-rtp-toff
- * set-07.txt] http://tools.ietf.org/html/draft-ietf-avt-rtp-toffset-07
- * SR sender report 200 [RFC3551] supported
- * RR receiver report 201 [RFC3551] supported
- * SDES source description 202 [RFC3551] supported
- * BYE goodbye 203 [RFC3551] supported
- * APP application-defined 204 [RFC3551] ignored
- * RTPFB Transport layer FB message 205 [RFC4585] supported
- * PSFB Payload-specific FB message 206 [RFC4585] supported
- * XR extended report 207 [RFC3611] supported
- */
+ * RTCP
+ *
+ * FIR full INTRA-frame request 192 [RFC2032] supported
+ * NACK negative acknowledgement 193 [RFC2032]
+ * IJ Extended inter-arrival jitter report 195 [RFC-ietf-avt-rtp-toff
+ * set-07.txt] http://tools.ietf.org/html/draft-ietf-avt-rtp-toffset-07
+ * SR sender report 200 [RFC3551] supported
+ * RR receiver report 201 [RFC3551] supported
+ * SDES source description 202 [RFC3551] supported
+ * BYE goodbye 203 [RFC3551] supported
+ * APP application-defined 204 [RFC3551] ignored
+ * RTPFB Transport layer FB message 205 [RFC4585] supported
+ * PSFB Payload-specific FB message 206 [RFC4585] supported
+ * XR extended report 207 [RFC3611] supported
+ */
/* 205 RFC 5104
* FMT 1 NACK supported
@@ -84,15 +81,15 @@
*/
/* 206 RFC 5104
- * FMT 1: Picture Loss Indication (PLI) supported
- * FMT 2: Slice Lost Indication (SLI)
- * FMT 3: Reference Picture Selection Indication (RPSI)
- * FMT 4: Full Intra Request (FIR) Command supported
- * FMT 5: Temporal-Spatial Trade-off Request (TSTR)
- * FMT 6: Temporal-Spatial Trade-off Notification (TSTN)
- * FMT 7: Video Back Channel Message (VBCM)
- * FMT 15: Application layer FB message
- */
+ * FMT 1: Picture Loss Indication (PLI) supported
+ * FMT 2: Slice Lost Indication (SLI)
+ * FMT 3: Reference Picture Selection Indication (RPSI)
+ * FMT 4: Full Intra Request (FIR) Command supported
+ * FMT 5: Temporal-Spatial Trade-off Request (TSTR)
+ * FMT 6: Temporal-Spatial Trade-off Notification (TSTN)
+ * FMT 7: Video Back Channel Message (VBCM)
+ * FMT 15: Application layer FB message
+ */
const ptrdiff_t length = _ptrRTPDataEnd - _ptrRTPDataBegin;
if (length < kRtcpMinHeaderLength) {
@@ -147,8 +144,8 @@
uint32_t SSRC = ByteReader<uint32_t>::ReadBigEndian(ptr);
ptr += 4;
- header->payloadType = PT;
- header->ssrc = SSRC;
+ header->payloadType = PT;
+ header->ssrc = SSRC;
header->headerLength = 4 + (len << 2);
return true;
@@ -163,18 +160,18 @@
}
// Version
- const uint8_t V = _ptrRTPDataBegin[0] >> 6;
+ const uint8_t V = _ptrRTPDataBegin[0] >> 6;
// Padding
- const bool P = ((_ptrRTPDataBegin[0] & 0x20) == 0) ? false : true;
+ const bool P = ((_ptrRTPDataBegin[0] & 0x20) == 0) ? false : true;
// eXtension
- const bool X = ((_ptrRTPDataBegin[0] & 0x10) == 0) ? false : true;
+ const bool X = ((_ptrRTPDataBegin[0] & 0x10) == 0) ? false : true;
const uint8_t CC = _ptrRTPDataBegin[0] & 0x0f;
- const bool M = ((_ptrRTPDataBegin[1] & 0x80) == 0) ? false : true;
+ const bool M = ((_ptrRTPDataBegin[1] & 0x80) == 0) ? false : true;
const uint8_t PT = _ptrRTPDataBegin[1] & 0x7f;
- const uint16_t sequenceNumber = (_ptrRTPDataBegin[2] << 8) +
- _ptrRTPDataBegin[3];
+ const uint16_t sequenceNumber =
+ (_ptrRTPDataBegin[2] << 8) + _ptrRTPDataBegin[3];
const uint8_t* ptr = &_ptrRTPDataBegin[4];
@@ -194,13 +191,13 @@
return false;
}
- header->markerBit = M;
- header->payloadType = PT;
+ header->markerBit = M;
+ header->payloadType = PT;
header->sequenceNumber = sequenceNumber;
- header->timestamp = RTPTimestamp;
- header->ssrc = SSRC;
- header->numCSRCs = CC;
- header->paddingLength = P ? *(_ptrRTPDataEnd - 1) : 0;
+ header->timestamp = RTPTimestamp;
+ header->ssrc = SSRC;
+ header->numCSRCs = CC;
+ header->paddingLength = P ? *(_ptrRTPDataEnd - 1) : 0;
for (uint8_t i = 0; i < CC; ++i) {
uint32_t CSRC = ByteReader<uint32_t>::ReadBigEndian(ptr);
@@ -208,7 +205,7 @@
header->arrOfCSRCs[i] = CSRC;
}
- header->headerLength = 12 + CSRCocts;
+ header->headerLength = 12 + CSRCocts;
// If in effect, MAY be omitted for those packets for which the offset
// is zero.
@@ -270,10 +267,8 @@
static constexpr uint16_t kRtpOneByteHeaderExtensionId = 0xBEDE;
if (definedByProfile == kRtpOneByteHeaderExtensionId) {
const uint8_t* ptrRTPDataExtensionEnd = ptr + XLen;
- ParseOneByteExtensionHeader(header,
- ptrExtensionMap,
- ptrRTPDataExtensionEnd,
- ptr);
+ ParseOneByteExtensionHeader(header, ptrExtensionMap,
+ ptrRTPDataExtensionEnd, ptr);
}
header->headerLength += XLen;
}
diff --git a/modules/rtp_rtcp/source/ulpfec_receiver_impl.cc b/modules/rtp_rtcp/source/ulpfec_receiver_impl.cc
index cb3e28b..3afd612 100644
--- a/modules/rtp_rtcp/source/ulpfec_receiver_impl.cc
+++ b/modules/rtp_rtcp/source/ulpfec_receiver_impl.cc
@@ -233,7 +233,7 @@
// not modifying the vector we are currently iterating over (packets are added
// in AddReceivedRedPacket).
std::vector<std::unique_ptr<ForwardErrorCorrection::ReceivedPacket>>
- received_packets;
+ received_packets;
received_packets.swap(received_packets_);
for (const auto& received_packet : received_packets) {
@@ -260,8 +260,7 @@
// header, OnRecoveredPacket will recurse back here.
recovered_packet->returned = true;
crit_sect_.Leave();
- recovered_packet_callback_->OnRecoveredPacket(packet->data,
- packet->length);
+ recovered_packet_callback_->OnRecoveredPacket(packet->data, packet->length);
crit_sect_.Enter();
}
diff --git a/modules/rtp_rtcp/source/ulpfec_receiver_unittest.cc b/modules/rtp_rtcp/source/ulpfec_receiver_unittest.cc
index c3bd5a7..e050f80 100644
--- a/modules/rtp_rtcp/source/ulpfec_receiver_unittest.cc
+++ b/modules/rtp_rtcp/source/ulpfec_receiver_unittest.cc
@@ -15,8 +15,8 @@
#include "modules/rtp_rtcp/include/rtp_header_parser.h"
#include "modules/rtp_rtcp/include/ulpfec_receiver.h"
-#include "modules/rtp_rtcp/mocks/mock_rtp_rtcp.h"
#include "modules/rtp_rtcp/mocks/mock_recovered_packet_receiver.h"
+#include "modules/rtp_rtcp/mocks/mock_rtp_rtcp.h"
#include "modules/rtp_rtcp/source/byte_io.h"
#include "modules/rtp_rtcp/source/fec_test_helper.h"
#include "modules/rtp_rtcp/source/forward_error_correction.h"
@@ -351,8 +351,7 @@
EncodeFec(media_packets_batch1, kNumFecPacketsBatch1, &fec_packets);
BuildAndAddRedMediaPacket(augmented_media_packets_batch1.front());
- EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket(_, _))
- .Times(1);
+ EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket(_, _)).Times(1);
EXPECT_EQ(0, receiver_fec_->ProcessReceivedFec());
delayed_fec = fec_packets.front();
@@ -367,15 +366,13 @@
for (auto it = augmented_media_packets_batch2.begin();
it != augmented_media_packets_batch2.end(); ++it) {
BuildAndAddRedMediaPacket(*it);
- EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket(_, _))
- .Times(1);
+ EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket(_, _)).Times(1);
EXPECT_EQ(0, receiver_fec_->ProcessReceivedFec());
}
// Add the delayed FEC packet. One packet should be reconstructed.
BuildAndAddRedFecPacket(delayed_fec);
- EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket(_, _))
- .Times(1);
+ EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket(_, _)).Times(1);
EXPECT_EQ(0, receiver_fec_->ProcessReceivedFec());
}
@@ -393,8 +390,7 @@
EncodeFec(media_packets_batch1, kNumFecPacketsBatch1, &fec_packets);
BuildAndAddRedMediaPacket(augmented_media_packets_batch1.front());
- EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket(_, _))
- .Times(1);
+ EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket(_, _)).Times(1);
EXPECT_EQ(0, receiver_fec_->ProcessReceivedFec());
delayed_fec = fec_packets.front();
@@ -409,8 +405,7 @@
for (auto it = augmented_media_packets_batch2.begin();
it != augmented_media_packets_batch2.end(); ++it) {
BuildAndAddRedMediaPacket(*it);
- EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket(_, _))
- .Times(1);
+ EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket(_, _)).Times(1);
EXPECT_EQ(0, receiver_fec_->ProcessReceivedFec());
}
@@ -451,8 +446,7 @@
// and should have been dropped. Only the media packet we inserted will be
// returned.
BuildAndAddRedMediaPacket(augmented_media_packets.front());
- EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket(_, _))
- .Times(1);
+ EXPECT_CALL(recovered_packet_receiver_, OnRecoveredPacket(_, _)).Times(1);
EXPECT_EQ(0, receiver_fec_->ProcessReceivedFec());
}
diff --git a/modules/rtp_rtcp/test/testAPI/test_api_audio.cc b/modules/rtp_rtcp/test/testAPI/test_api_audio.cc
index a6ccc90..d64440f 100644
--- a/modules/rtp_rtcp/test/testAPI/test_api_audio.cc
+++ b/modules/rtp_rtcp/test/testAPI/test_api_audio.cc
@@ -25,7 +25,7 @@
namespace {
const uint32_t kTestRate = 64000u;
-const uint8_t kTestPayload[] = { 't', 'e', 's', 't' };
+const uint8_t kTestPayload[] = {'t', 'e', 's', 't'};
const uint8_t kPcmuPayloadType = 96;
const uint8_t kDtmfPayloadType = 97;
diff --git a/modules/rtp_rtcp/test/testAPI/test_api_rtcp.cc b/modules/rtp_rtcp/test/testAPI/test_api_rtcp.cc
index e1b333f..44b1ff5 100644
--- a/modules/rtp_rtcp/test/testAPI/test_api_rtcp.cc
+++ b/modules/rtp_rtcp/test/testAPI/test_api_rtcp.cc
@@ -28,11 +28,8 @@
class RtcpCallback : public RtcpIntraFrameObserver {
public:
- void SetModule(RtpRtcp* module) {
- _rtpRtcpModule = module;
- }
- virtual void OnRTCPPacketTimeout(const int32_t id) {
- }
+ void SetModule(RtpRtcp* module) { _rtpRtcpModule = module; }
+ virtual void OnRTCPPacketTimeout(const int32_t id) {}
virtual void OnLipSyncUpdate(const int32_t id,
const int32_t audioVideoOffset) {}
void OnReceivedIntraFrameRequest(uint32_t ssrc) override {}
diff --git a/modules/rtp_rtcp/test/testAPI/test_api_video.cc b/modules/rtp_rtcp/test/testAPI/test_api_video.cc
index 6d6f31b..91d1bfd 100644
--- a/modules/rtp_rtcp/test/testAPI/test_api_video.cc
+++ b/modules/rtp_rtcp/test/testAPI/test_api_video.cc
@@ -27,7 +27,6 @@
namespace {
const unsigned char kPayloadType = 100;
-
};
namespace webrtc {
@@ -75,13 +74,13 @@
payload_data_length_ = sizeof(video_frame_);
for (size_t n = 0; n < payload_data_length_; n++) {
- video_frame_[n] = n%10;
+ video_frame_[n] = n % 10;
}
}
size_t BuildRTPheader(uint8_t* dataBuffer,
- uint32_t timestamp,
- uint32_t sequence_number) {
+ uint32_t timestamp,
+ uint32_t sequence_number) {
dataBuffer[0] = static_cast<uint8_t>(0x80); // version 2
dataBuffer[1] = static_cast<uint8_t>(kPayloadType);
ByteWriter<uint16_t>::WriteBigEndian(dataBuffer + 2, sequence_number);
@@ -105,8 +104,7 @@
// Correct seq num, timestamp and payload type.
size_t header_length = BuildRTPheader(buffer, timestamp, sequence_number);
buffer[0] |= 0x20; // Set padding bit.
- int32_t* data =
- reinterpret_cast<int32_t*>(&(buffer[header_length]));
+ int32_t* data = reinterpret_cast<int32_t*>(&(buffer[header_length]));
// Fill data buffer with random data.
for (size_t j = 0; j < (padding_bytes_in_packet >> 2); j++) {
@@ -134,7 +132,7 @@
uint32_t test_ssrc_;
uint32_t test_timestamp_;
uint16_t test_sequence_number_;
- uint8_t video_frame_[65000];
+ uint8_t video_frame_[65000];
size_t payload_data_length_;
SimulatedClock fake_clock;
RateLimiter retransmission_rate_limiter_;
@@ -158,8 +156,8 @@
EXPECT_EQ(0, rtp_payload_registry_.RegisterReceivePayload(codec));
for (int frame_idx = 0; frame_idx < 10; ++frame_idx) {
for (int packet_idx = 0; packet_idx < 5; ++packet_idx) {
- size_t packet_size = PaddingPacket(padding_packet, timestamp, seq_num,
- kPadSize);
+ size_t packet_size =
+ PaddingPacket(padding_packet, timestamp, seq_num, kPadSize);
++seq_num;
RTPHeader header;
std::unique_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create());
diff --git a/modules/rtp_rtcp/test/testFec/average_residual_loss_xor_codes.h b/modules/rtp_rtcp/test/testFec/average_residual_loss_xor_codes.h
index ccf9752..0bc2f56 100644
--- a/modules/rtp_rtcp/test/testFec/average_residual_loss_xor_codes.h
+++ b/modules/rtp_rtcp/test/testFec/average_residual_loss_xor_codes.h
@@ -23,169 +23,35 @@
// loss expected for each code size up to:
// (kMaxMediaPacketsTest, kMaxMediaPacketsTest).
const float kMaxResidualLossRandomMask[kNumberCodes] = {
- 0.009463f,
- 0.022436f,
- 0.007376f,
- 0.033895f,
- 0.012423f,
- 0.004644f,
- 0.043438f,
- 0.019937f,
- 0.008820f,
- 0.003438f,
- 0.051282f,
- 0.025795f,
- 0.012872f,
- 0.006458f,
- 0.003195f,
- 0.057728f,
- 0.032146f,
- 0.016708f,
- 0.009242f,
- 0.005054f,
- 0.003078f,
- 0.063050f,
- 0.037261f,
- 0.021767f,
- 0.012447f,
- 0.007099f,
- 0.003826f,
- 0.002504f,
- 0.067476f,
- 0.042348f,
- 0.026169f,
- 0.015695f,
- 0.009478f,
- 0.005887f,
- 0.003568f,
- 0.001689f,
- 0.071187f,
- 0.046575f,
- 0.031697f,
- 0.019797f,
- 0.012433f,
- 0.007027f,
- 0.004845f,
- 0.002777f,
- 0.001753f,
- 0.074326f,
- 0.050628f,
- 0.034978f,
- 0.021955f,
- 0.014821f,
- 0.009462f,
- 0.006393f,
- 0.004181f,
- 0.003105f,
- 0.001231f,
- 0.077008f,
- 0.054226f,
- 0.038407f,
- 0.026251f,
- 0.018634f,
- 0.011568f,
- 0.008130f,
- 0.004957f,
- 0.003334f,
- 0.002069f,
- 0.001304f,
- 0.079318f,
- 0.057180f,
- 0.041268f,
- 0.028842f,
- 0.020033f,
- 0.014061f,
- 0.009636f,
- 0.006411f,
- 0.004583f,
- 0.002817f,
- 0.001770f,
- 0.001258f
-};
+ 0.009463f, 0.022436f, 0.007376f, 0.033895f, 0.012423f, 0.004644f, 0.043438f,
+ 0.019937f, 0.008820f, 0.003438f, 0.051282f, 0.025795f, 0.012872f, 0.006458f,
+ 0.003195f, 0.057728f, 0.032146f, 0.016708f, 0.009242f, 0.005054f, 0.003078f,
+ 0.063050f, 0.037261f, 0.021767f, 0.012447f, 0.007099f, 0.003826f, 0.002504f,
+ 0.067476f, 0.042348f, 0.026169f, 0.015695f, 0.009478f, 0.005887f, 0.003568f,
+ 0.001689f, 0.071187f, 0.046575f, 0.031697f, 0.019797f, 0.012433f, 0.007027f,
+ 0.004845f, 0.002777f, 0.001753f, 0.074326f, 0.050628f, 0.034978f, 0.021955f,
+ 0.014821f, 0.009462f, 0.006393f, 0.004181f, 0.003105f, 0.001231f, 0.077008f,
+ 0.054226f, 0.038407f, 0.026251f, 0.018634f, 0.011568f, 0.008130f, 0.004957f,
+ 0.003334f, 0.002069f, 0.001304f, 0.079318f, 0.057180f, 0.041268f, 0.028842f,
+ 0.020033f, 0.014061f, 0.009636f, 0.006411f, 0.004583f, 0.002817f, 0.001770f,
+ 0.001258f};
// For the bursty mask type: reference level for the maximum average residual
// loss expected for each code size up to:
// (kMaxMediaPacketsTestf, kMaxMediaPacketsTest).
const float kMaxResidualLossBurstyMask[kNumberCodes] = {
- 0.033236f,
- 0.053344f,
- 0.026616f,
- 0.064129f,
- 0.036589f,
- 0.021892f,
- 0.071055f,
- 0.043890f,
- 0.028009f,
- 0.018524f,
- 0.075968f,
- 0.049828f,
- 0.033288f,
- 0.022791f,
- 0.016088f,
- 0.079672f,
- 0.054586f,
- 0.037872f,
- 0.026679f,
- 0.019326f,
- 0.014293f,
- 0.082582f,
- 0.058719f,
- 0.042045f,
- 0.030504f,
- 0.022391f,
- 0.016894f,
- 0.012946f,
- 0.084935f,
- 0.062169f,
- 0.045620f,
- 0.033713f,
- 0.025570f,
- 0.019439f,
- 0.015121f,
- 0.011920f,
- 0.086881f,
- 0.065267f,
- 0.048721f,
- 0.037613f,
- 0.028278f,
- 0.022152f,
- 0.017314f,
- 0.013791f,
- 0.011130f,
- 0.088516f,
- 0.067911f,
- 0.051709f,
- 0.040819f,
- 0.030777f,
- 0.024547f,
- 0.019689f,
- 0.015877f,
- 0.012773f,
- 0.010516f,
- 0.089909f,
- 0.070332f,
- 0.054402f,
- 0.043210f,
- 0.034096f,
- 0.026625f,
- 0.021823f,
- 0.017648f,
- 0.014649f,
- 0.011982f,
- 0.010035f,
- 0.091109f,
- 0.072428f,
- 0.056775f,
- 0.045418f,
- 0.036679f,
- 0.028599f,
- 0.023693f,
- 0.019966f,
- 0.016603f,
- 0.013690f,
- 0.011359f,
- 0.009657f
-};
+ 0.033236f, 0.053344f, 0.026616f, 0.064129f, 0.036589f, 0.021892f, 0.071055f,
+ 0.043890f, 0.028009f, 0.018524f, 0.075968f, 0.049828f, 0.033288f, 0.022791f,
+ 0.016088f, 0.079672f, 0.054586f, 0.037872f, 0.026679f, 0.019326f, 0.014293f,
+ 0.082582f, 0.058719f, 0.042045f, 0.030504f, 0.022391f, 0.016894f, 0.012946f,
+ 0.084935f, 0.062169f, 0.045620f, 0.033713f, 0.025570f, 0.019439f, 0.015121f,
+ 0.011920f, 0.086881f, 0.065267f, 0.048721f, 0.037613f, 0.028278f, 0.022152f,
+ 0.017314f, 0.013791f, 0.011130f, 0.088516f, 0.067911f, 0.051709f, 0.040819f,
+ 0.030777f, 0.024547f, 0.019689f, 0.015877f, 0.012773f, 0.010516f, 0.089909f,
+ 0.070332f, 0.054402f, 0.043210f, 0.034096f, 0.026625f, 0.021823f, 0.017648f,
+ 0.014649f, 0.011982f, 0.010035f, 0.091109f, 0.072428f, 0.056775f, 0.045418f,
+ 0.036679f, 0.028599f, 0.023693f, 0.019966f, 0.016603f, 0.013690f, 0.011359f,
+ 0.009657f};
} // namespace webrtc
#endif // MODULES_RTP_RTCP_TEST_TESTFEC_AVERAGE_RESIDUAL_LOSS_XOR_CODES_H_
diff --git a/modules/rtp_rtcp/test/testFec/test_fec.cc b/modules/rtp_rtcp/test/testFec/test_fec.cc
index fd50b46..7c65d3d 100644
--- a/modules/rtp_rtcp/test/testFec/test_fec.cc
+++ b/modules/rtp_rtcp/test/testFec/test_fec.cc
@@ -252,8 +252,8 @@
const uint32_t kMinPacketSize = 12;
const uint32_t kMaxPacketSize = static_cast<uint32_t>(
IP_PACKET_SIZE - 12 - 28 - fec->MaxPacketOverhead());
- media_packet->length = random.Rand(kMinPacketSize,
- kMaxPacketSize);
+ media_packet->length =
+ random.Rand(kMinPacketSize, kMaxPacketSize);
// Generate random values for the first 2 bytes.
media_packet->data[0] = random.Rand<uint8_t>();
@@ -456,8 +456,8 @@
} // loop over num_imp_packets
} // loop over FecPackets
} // loop over num_media_packets
- } // loop over loss rates
- } // loop over mask types
+ } // loop over loss rates
+ } // loop over mask types
// Have DecodeFec clear the recovered packet list.
fec->ResetState(&recovered_packet_list);
diff --git a/modules/rtp_rtcp/test/testFec/test_packet_masks_metrics.cc b/modules/rtp_rtcp/test/testFec/test_packet_masks_metrics.cc
index 292e9fe..f6d2dea 100644
--- a/modules/rtp_rtcp/test/testFec/test_packet_masks_metrics.cc
+++ b/modules/rtp_rtcp/test/testFec/test_packet_masks_metrics.cc
@@ -41,7 +41,7 @@
* (1) Random loss: Bernoulli process, characterized by the average loss rate.
* (2) Bursty loss: Markov chain (Gilbert-Elliot model), characterized by two
* parameters: average loss rate and average burst length.
-*/
+ */
#include <math.h>
@@ -71,9 +71,9 @@
// The code type.
enum CodeType {
- xor_random_code, // XOR with random mask type.
- xor_bursty_code, // XOR with bursty mask type.
- rs_code // Reed_solomon.
+ xor_random_code, // XOR with random mask type.
+ xor_bursty_code, // XOR with bursty mask type.
+ rs_code // Reed_solomon.
};
// The code size parameters.
@@ -89,10 +89,7 @@
};
// The type of loss models.
-enum LossModelType {
- kRandomLossModel,
- kBurstyLossModel
-};
+enum LossModelType { kRandomLossModel, kBurstyLossModel };
struct LossModel {
LossModelType loss_type;
@@ -101,19 +98,19 @@
};
// Average loss rates.
-const float kAverageLossRate[] = { 0.025f, 0.05f, 0.1f, 0.25f };
+const float kAverageLossRate[] = {0.025f, 0.05f, 0.1f, 0.25f};
// Average burst lengths. The case of |kAverageBurstLength = 1.0| refers to
// the random model. Note that for the random (Bernoulli) model, the average
// burst length is determined by the average loss rate, i.e.,
// AverageBurstLength = 1 / (1 - AverageLossRate) for random model.
-const float kAverageBurstLength[] = { 1.0f, 2.0f, 4.0f };
+const float kAverageBurstLength[] = {1.0f, 2.0f, 4.0f};
// Total number of loss models: For each burst length case, there are
// a number of models corresponding to the loss rates.
-const int kNumLossModels = (sizeof(kAverageBurstLength) /
- sizeof(*kAverageBurstLength)) * (sizeof(kAverageLossRate) /
- sizeof(*kAverageLossRate));
+const int kNumLossModels =
+ (sizeof(kAverageBurstLength) / sizeof(*kAverageBurstLength)) *
+ (sizeof(kAverageLossRate) / sizeof(*kAverageLossRate));
// Thresholds on the average loss rate of the packet loss model, below which
// certain properties of the codes are expected.
@@ -123,8 +120,8 @@
// Set of thresholds on the expected average recovery rate, for each code type.
// These are global thresholds for now; in future version we may condition them
// on the code length/size and protection level.
-const float kRecoveryRateXorRandom[3] = { 0.94f, 0.50f, 0.19f };
-const float kRecoveryRateXorBursty[3] = { 0.90f, 0.54f, 0.22f };
+const float kRecoveryRateXorRandom[3] = {0.94f, 0.50f, 0.19f};
+const float kRecoveryRateXorBursty[3] = {0.90f, 0.54f, 0.22f};
// Metrics for a given FEC code; each code is defined by the code type
// (RS, XOR-random/bursty), and the code size parameters (k,m), where
@@ -150,7 +147,7 @@
class FecPacketMaskMetricsTest : public ::testing::Test {
protected:
- FecPacketMaskMetricsTest() { }
+ FecPacketMaskMetricsTest() {}
int max_num_codes_;
LossModel loss_model_[kNumLossModels];
@@ -251,10 +248,9 @@
int tot_num_packets) {
// Loop over the loss models.
for (int k = 0; k < kNumLossModels; k++) {
- double loss_rate = static_cast<double>(
- loss_model_[k].average_loss_rate);
- double burst_length = static_cast<double>(
- loss_model_[k].average_burst_length);
+ double loss_rate = static_cast<double>(loss_model_[k].average_loss_rate);
+ double burst_length =
+ static_cast<double>(loss_model_[k].average_burst_length);
double result = 1.0;
if (loss_model_[k].loss_type == kRandomLossModel) {
for (int i = 0; i < tot_num_packets; i++) {
@@ -279,7 +275,7 @@
// Use stationary probability for first state/packet.
if (state[0] == 0) { // Received
result = (1.0 - loss_rate);
- } else { // Lost
+ } else { // Lost
result = loss_rate;
}
@@ -287,13 +283,13 @@
for (int i = 1; i < tot_num_packets; i++) {
// Current state is received
if (state[i] == 0) {
- if (state[i-1] == 0) {
- result *= prob00; // Previous received, current received.
- } else {
- result *= prob10; // Previous lost, current received.
- }
+ if (state[i - 1] == 0) {
+ result *= prob00; // Previous received, current received.
+ } else {
+ result *= prob10; // Previous lost, current received.
+ }
} else { // Current state is lost
- if (state[i-1] == 0) {
+ if (state[i - 1] == 0) {
result *= prob01; // Previous received, current lost.
} else {
result *= prob11; // Previous lost, current lost.
@@ -333,13 +329,12 @@
for (int loss = 1; loss <= num_fec_packets; loss++) {
int index = gap_number * (2 * kMaxMediaPacketsTest) + loss;
residual_loss_gap += metrics.residual_loss_per_loss_gap[index];
- tot_num_configs +=
- code_params_[code_index].configuration_density[index];
+ tot_num_configs += code_params_[code_index].configuration_density[index];
}
// Normalize, to compare across code sizes.
if (tot_num_configs > 0) {
- residual_loss_gap = residual_loss_gap /
- static_cast<double>(tot_num_configs);
+ residual_loss_gap =
+ residual_loss_gap / static_cast<double>(tot_num_configs);
}
return residual_loss_gap;
}
@@ -354,7 +349,7 @@
metrics->recovery_rate_per_loss[loss] = 0.0;
int tot_num_configs = 0;
double arl = 0.0;
- for (int gap = 0; gap < kMaxGapSize; gap ++) {
+ for (int gap = 0; gap < kMaxGapSize; gap++) {
int index = gap * (2 * kMaxMediaPacketsTest) + loss;
arl += metrics->residual_loss_per_loss_gap[index];
tot_num_configs +=
@@ -366,7 +361,8 @@
}
// Recovery rate for a given loss |loss| is 1 minus the scaled |arl|,
// where the scale factor is relative to code size/parameters.
- double scaled_loss = static_cast<double>(loss * num_media_packets) /
+ double scaled_loss =
+ static_cast<double>(loss * num_media_packets) /
static_cast<double>(num_media_packets + num_fec_packets);
metrics->recovery_rate_per_loss[loss] = 1.0 - arl / scaled_loss;
}
@@ -384,10 +380,9 @@
// Compute the metrics for an FEC code, given by the code type |code_type|
// (XOR-random/ bursty or RS), and by the code index |code_index|
// (which containes the code size parameters/protection length).
- void ComputeMetricsForCode(CodeType code_type,
- int code_index) {
+ void ComputeMetricsForCode(CodeType code_type, int code_index) {
std::unique_ptr<double[]> prob_weight(new double[kNumLossModels]);
- memset(prob_weight.get() , 0, sizeof(double) * kNumLossModels);
+ memset(prob_weight.get(), 0, sizeof(double) * kNumLossModels);
MetricsFecCode metrics_code;
SetMetricsZero(&metrics_code);
@@ -395,7 +390,7 @@
int num_fec_packets = code_params_[code_index].num_fec_packets;
int tot_num_packets = num_media_packets + num_fec_packets;
std::unique_ptr<uint8_t[]> state(new uint8_t[tot_num_packets]);
- memset(state.get() , 0, tot_num_packets);
+ memset(state.get(), 0, tot_num_packets);
int num_loss_configurations = static_cast<int>(pow(2.0f, tot_num_packets));
// Loop over all loss configurations for the symbol sequence of length
@@ -426,9 +421,9 @@
if (bit_value == 1) {
state[j] = 1; // Lost state.
num_packets_lost++;
- if (j < num_media_packets) {
- num_media_packets_lost++;
- }
+ if (j < num_media_packets) {
+ num_media_packets_lost++;
+ }
}
} // Done with loop over total number of packets.
assert(num_media_packets_lost <= num_media_packets);
@@ -440,9 +435,8 @@
// Compute the number of recovered packets.
int num_recovered_packets = 0;
if (code_type == xor_random_code || code_type == xor_bursty_code) {
- num_recovered_packets = RecoveredMediaPackets(num_media_packets,
- num_fec_packets,
- state.get());
+ num_recovered_packets = RecoveredMediaPackets(
+ num_media_packets, num_fec_packets, state.get());
} else {
// For the RS code, we can either completely recover all the packets
// if the loss is less than or equal to the number of FEC packets,
@@ -455,18 +449,17 @@
assert(num_recovered_packets <= num_media_packets);
// Compute the residual loss. We only care about recovering media/source
// packets, so residual loss is based on lost/recovered media packets.
- residual_loss = static_cast<double>(num_media_packets_lost -
- num_recovered_packets);
+ residual_loss =
+ static_cast<double>(num_media_packets_lost - num_recovered_packets);
// Compute the probability weights for this configuration.
- ComputeProbabilityWeight(prob_weight.get(),
- state.get(),
+ ComputeProbabilityWeight(prob_weight.get(), state.get(),
tot_num_packets);
// Update the average and variance of the residual loss.
for (int k = 0; k < kNumLossModels; k++) {
- metrics_code.average_residual_loss[k] += residual_loss *
- prob_weight[k];
- metrics_code.variance_residual_loss[k] += residual_loss *
+ metrics_code.average_residual_loss[k] +=
residual_loss * prob_weight[k];
+ metrics_code.variance_residual_loss[k] +=
+ residual_loss * residual_loss * prob_weight[k];
}
} // Done with processing for num_media_packets_lost >= 1.
// Update the distribution statistics.
@@ -494,12 +487,12 @@
metrics_code.average_residual_loss[k] /
static_cast<double>(tot_num_packets);
metrics_code.variance_residual_loss[k] =
- metrics_code.variance_residual_loss[k] /
- static_cast<double>(num_media_packets * num_media_packets);
+ metrics_code.variance_residual_loss[k] /
+ static_cast<double>(num_media_packets * num_media_packets);
metrics_code.variance_residual_loss[k] =
metrics_code.variance_residual_loss[k] -
(metrics_code.average_residual_loss[k] *
- metrics_code.average_residual_loss[k]);
+ metrics_code.average_residual_loss[k]);
assert(metrics_code.variance_residual_loss[k] >= 0.0);
assert(metrics_code.average_residual_loss[k] > 0.0);
metrics_code.variance_residual_loss[k] =
@@ -508,10 +501,8 @@
}
// Compute marginal distribution as a function of loss parameter.
- ComputeRecoveryRatePerLoss(&metrics_code,
- num_media_packets,
- num_fec_packets,
- code_index);
+ ComputeRecoveryRatePerLoss(&metrics_code, num_media_packets,
+ num_fec_packets, code_index);
if (code_type == rs_code) {
CopyMetrics(&kMetricsReedSolomon[code_index], metrics_code);
} else if (code_type == xor_random_code) {
@@ -523,24 +514,25 @@
}
}
- void WriteOutMetricsAllFecCodes() {
+ void WriteOutMetricsAllFecCodes() {
std::string filename = test::OutputPath() + "data_metrics_all_codes";
FILE* fp = fopen(filename.c_str(), "wb");
// Loop through codes up to |kMaxMediaPacketsTest|.
int code_index = 0;
for (int num_media_packets = 1; num_media_packets <= kMaxMediaPacketsTest;
- num_media_packets++) {
+ num_media_packets++) {
for (int num_fec_packets = 1; num_fec_packets <= num_media_packets;
- num_fec_packets++) {
+ num_fec_packets++) {
fprintf(fp, "FOR CODE: (%d, %d) \n", num_media_packets,
num_fec_packets);
for (int k = 0; k < kNumLossModels; k++) {
float loss_rate = loss_model_[k].average_loss_rate;
float burst_length = loss_model_[k].average_burst_length;
- fprintf(fp, "Loss rate = %.2f, Burst length = %.2f: %.4f %.4f %.4f"
+ fprintf(
+ fp,
+ "Loss rate = %.2f, Burst length = %.2f: %.4f %.4f %.4f"
" **** %.4f %.4f %.4f \n",
- loss_rate,
- burst_length,
+ loss_rate, burst_length,
100 * kMetricsReedSolomon[code_index].average_residual_loss[k],
100 * kMetricsXorRandom[code_index].average_residual_loss[k],
100 * kMetricsXorBursty[code_index].average_residual_loss[k],
@@ -548,40 +540,27 @@
kMetricsXorRandom[code_index].variance_residual_loss[k],
kMetricsXorBursty[code_index].variance_residual_loss[k]);
}
- for (int gap = 0; gap < kGapSizeOutput; gap ++) {
- double rs_residual_loss = ComputeResidualLossPerGap(
- kMetricsReedSolomon[code_index],
- gap,
- num_fec_packets,
- code_index);
+ for (int gap = 0; gap < kGapSizeOutput; gap++) {
+ double rs_residual_loss =
+ ComputeResidualLossPerGap(kMetricsReedSolomon[code_index], gap,
+ num_fec_packets, code_index);
double xor_random_residual_loss = ComputeResidualLossPerGap(
- kMetricsXorRandom[code_index],
- gap,
- num_fec_packets,
- code_index);
+ kMetricsXorRandom[code_index], gap, num_fec_packets, code_index);
double xor_bursty_residual_loss = ComputeResidualLossPerGap(
- kMetricsXorBursty[code_index],
- gap,
- num_fec_packets,
- code_index);
- fprintf(fp, "Residual loss as a function of gap "
- "%d: %.4f %.4f %.4f \n",
- gap,
- rs_residual_loss,
- xor_random_residual_loss,
- xor_bursty_residual_loss);
+ kMetricsXorBursty[code_index], gap, num_fec_packets, code_index);
+ fprintf(fp,
+ "Residual loss as a function of gap "
+ "%d: %.4f %.4f %.4f \n",
+ gap, rs_residual_loss, xor_random_residual_loss,
+ xor_bursty_residual_loss);
}
fprintf(fp, "Recovery rate as a function of loss number \n");
for (int loss = 1; loss <= num_media_packets + num_fec_packets;
- loss ++) {
- fprintf(fp, "For loss number %d: %.4f %.4f %.4f \n",
- loss,
- kMetricsReedSolomon[code_index].
- recovery_rate_per_loss[loss],
- kMetricsXorRandom[code_index].
- recovery_rate_per_loss[loss],
- kMetricsXorBursty[code_index].
- recovery_rate_per_loss[loss]);
+ loss++) {
+ fprintf(fp, "For loss number %d: %.4f %.4f %.4f \n", loss,
+ kMetricsReedSolomon[code_index].recovery_rate_per_loss[loss],
+ kMetricsXorRandom[code_index].recovery_rate_per_loss[loss],
+ kMetricsXorBursty[code_index].recovery_rate_per_loss[loss]);
}
fprintf(fp, "******************\n");
fprintf(fp, "\n");
@@ -592,10 +571,9 @@
}
void SetLossModels() {
- int num_loss_rates = sizeof(kAverageLossRate) /
- sizeof(*kAverageLossRate);
- int num_burst_lengths = sizeof(kAverageBurstLength) /
- sizeof(*kAverageBurstLength);
+ int num_loss_rates = sizeof(kAverageLossRate) / sizeof(*kAverageLossRate);
+ int num_burst_lengths =
+ sizeof(kAverageBurstLength) / sizeof(*kAverageBurstLength);
int num_loss_models = 0;
for (int k = 0; k < num_burst_lengths; k++) {
for (int k2 = 0; k2 < num_loss_rates; k2++) {
@@ -617,9 +595,9 @@
void SetCodeParams() {
int code_index = 0;
for (int num_media_packets = 1; num_media_packets <= kMaxMediaPacketsTest;
- num_media_packets++) {
+ num_media_packets++) {
for (int num_fec_packets = 1; num_fec_packets <= num_media_packets;
- num_fec_packets++) {
+ num_fec_packets++) {
code_params_[code_index].num_media_packets = num_media_packets;
code_params_[code_index].num_fec_packets = num_fec_packets;
code_params_[code_index].protection_level =
@@ -646,8 +624,10 @@
}
}
if (row_degree == 0) {
- printf("Invalid mask: FEC packet has empty mask (does not protect "
- "anything) %d %d %d \n", i, num_media_packets, num_fec_packets);
+ printf(
+ "Invalid mask: FEC packet has empty mask (does not protect "
+ "anything) %d %d %d \n",
+ i, num_media_packets, num_fec_packets);
return -1;
}
}
@@ -660,8 +640,10 @@
}
}
if (column_degree == 0) {
- printf("Invalid mask: Media packet has no protection at all %d %d %d "
- "\n", j, num_media_packets, num_fec_packets);
+ printf(
+ "Invalid mask: Media packet has no protection at all %d %d %d "
+ "\n",
+ j, num_media_packets, num_fec_packets);
return -1;
}
}
@@ -696,8 +678,10 @@
}
}
if (degree == num_fec_packets) {
- printf("Invalid mask: Two media packets are have full degree "
- "%d %d %d %d \n", j, j2, num_media_packets, num_fec_packets);
+ printf(
+ "Invalid mask: Two media packets are have full degree "
+ "%d %d %d %d \n",
+ j, j2, num_media_packets, num_fec_packets);
return -1;
}
}
@@ -738,7 +722,7 @@
static_cast<int>(internal::PacketMaskSize(num_media_packets));
internal::PacketMaskTable mask_table(fec_mask_type, num_media_packets);
for (int num_fec_packets = 1; num_fec_packets <= num_media_packets;
- num_fec_packets++) {
+ num_fec_packets++) {
memset(packet_mask.get(), 0, num_media_packets * mask_bytes_fec_packet);
rtc::ArrayView<const uint8_t> mask =
mask_table.LookUp(num_media_packets, num_fec_packets);
@@ -751,8 +735,7 @@
return -1;
}
// Compute the metrics for this code/mask.
- ComputeMetricsForCode(code_type,
- code_index);
+ ComputeMetricsForCode(code_type, code_index);
code_index++;
}
}
@@ -763,12 +746,11 @@
void ProcessRS(CodeType code_type) {
int code_index = 0;
for (int num_media_packets = 1; num_media_packets <= kMaxMediaPacketsTest;
- num_media_packets++) {
+ num_media_packets++) {
for (int num_fec_packets = 1; num_fec_packets <= num_media_packets;
- num_fec_packets++) {
+ num_fec_packets++) {
// Compute the metrics for this code type.
- ComputeMetricsForCode(code_type,
- code_index);
+ ComputeMetricsForCode(code_type, code_index);
code_index++;
}
}
@@ -801,10 +783,9 @@
SetCodeParams();
ComputeMetricsAllCodes();
WriteOutMetricsAllFecCodes();
- int num_loss_rates = sizeof(kAverageLossRate) /
- sizeof(*kAverageLossRate);
- int num_burst_lengths = sizeof(kAverageBurstLength) /
- sizeof(*kAverageBurstLength);
+ int num_loss_rates = sizeof(kAverageLossRate) / sizeof(*kAverageLossRate);
+ int num_burst_lengths =
+ sizeof(kAverageBurstLength) / sizeof(*kAverageBurstLength);
for (int code_index = 0; code_index < max_num_codes_; code_index++) {
double sum_residual_loss_random_mask_random_loss = 0.0;
double sum_residual_loss_bursty_mask_bursty_loss = 0.0;
@@ -822,7 +803,7 @@
sum_residual_loss_random_mask_random_loss / num_loss_rates;
float average_residual_loss_bursty_mask_bursty_loss =
sum_residual_loss_bursty_mask_bursty_loss /
- (num_loss_rates * (num_burst_lengths - 1));
+ (num_loss_rates * (num_burst_lengths - 1));
const float ref_random_mask = kMaxResidualLossRandomMask[code_index];
const float ref_bursty_mask = kMaxResidualLossBurstyMask[code_index];
EXPECT_LE(average_residual_loss_random_mask_random_loss, ref_random_mask);
@@ -844,16 +825,16 @@
float loss_rate = loss_model_[k].average_loss_rate;
float protection_level = code_params_[code_index].protection_level;
// Under these conditions we expect XOR to not be better than RS.
- if (loss_model_[k].loss_type == kRandomLossModel &&
- loss_rate <= protection_level) {
+ if (loss_model_[k].loss_type == kRandomLossModel &&
+ loss_rate <= protection_level) {
EXPECT_GE(kMetricsXorRandom[code_index].average_residual_loss[k],
kMetricsReedSolomon[code_index].average_residual_loss[k]);
EXPECT_GE(kMetricsXorBursty[code_index].average_residual_loss[k],
kMetricsReedSolomon[code_index].average_residual_loss[k]);
- }
- // TODO(marpan): There are some cases (for high loss rates and/or
- // burst loss models) where XOR is better than RS. Is there some pattern
- // we can identify and enforce as a constraint?
+ }
+ // TODO(marpan): There are some cases (for high loss rates and/or
+ // burst loss models) where XOR is better than RS. Is there some pattern
+ // we can identify and enforce as a constraint?
}
}
}
@@ -868,25 +849,24 @@
// TODO(marpan): Examine this further to see if the condition can be strictly
// satisfied (i.e., scale = 1.0) for all codes with different/better masks.
double scale = 0.90;
- int num_loss_rates = sizeof(kAverageLossRate) /
- sizeof(*kAverageLossRate);
- int num_burst_lengths = sizeof(kAverageBurstLength) /
- sizeof(*kAverageBurstLength);
+ int num_loss_rates = sizeof(kAverageLossRate) / sizeof(*kAverageLossRate);
+ int num_burst_lengths =
+ sizeof(kAverageBurstLength) / sizeof(*kAverageBurstLength);
for (int code_index = 0; code_index < max_num_codes_; code_index++) {
for (int i = 0; i < num_burst_lengths; i++) {
for (int j = 0; j < num_loss_rates - 1; j++) {
int k = num_loss_rates * i + j;
// For XOR random.
if (kMetricsXorRandom[code_index].average_residual_loss[k] >
- kMetricsReedSolomon[code_index].average_residual_loss[k]) {
+ kMetricsReedSolomon[code_index].average_residual_loss[k]) {
double diff_rs_xor_random_loss1 =
(kMetricsXorRandom[code_index].average_residual_loss[k] -
kMetricsReedSolomon[code_index].average_residual_loss[k]) /
- kMetricsXorRandom[code_index].average_residual_loss[k];
+ kMetricsXorRandom[code_index].average_residual_loss[k];
double diff_rs_xor_random_loss2 =
- (kMetricsXorRandom[code_index].average_residual_loss[k+1] -
- kMetricsReedSolomon[code_index].average_residual_loss[k+1]) /
- kMetricsXorRandom[code_index].average_residual_loss[k+1];
+ (kMetricsXorRandom[code_index].average_residual_loss[k + 1] -
+ kMetricsReedSolomon[code_index].average_residual_loss[k + 1]) /
+ kMetricsXorRandom[code_index].average_residual_loss[k + 1];
EXPECT_GE(diff_rs_xor_random_loss1, scale * diff_rs_xor_random_loss2);
}
// TODO(marpan): Investigate the cases for the bursty mask where
@@ -909,11 +889,11 @@
for (int code_index1 = 0; code_index1 < max_num_codes_; code_index1++) {
float protection_level1 = code_params_[code_index1].protection_level;
int length1 = code_params_[code_index1].num_media_packets +
- code_params_[code_index1].num_fec_packets;
+ code_params_[code_index1].num_fec_packets;
for (int code_index2 = 0; code_index2 < max_num_codes_; code_index2++) {
float protection_level2 = code_params_[code_index2].protection_level;
int length2 = code_params_[code_index2].num_media_packets +
- code_params_[code_index2].num_fec_packets;
+ code_params_[code_index2].num_fec_packets;
// Codes with higher protection are more efficient, conditioned on the
// length of the code (higher protection but shorter length codes are
// generally not more efficient). For two codes with equal protection,
@@ -959,11 +939,9 @@
double scale = 0.95;
for (int code_index = 0; code_index < max_num_codes_; code_index++) {
for (int k = 0; k < kNumLossModels; k++) {
- EXPECT_LE(scale *
- kMetricsXorRandom[code_index].variance_residual_loss[k],
+ EXPECT_LE(scale * kMetricsXorRandom[code_index].variance_residual_loss[k],
kMetricsReedSolomon[code_index].variance_residual_loss[k]);
- EXPECT_LE(scale *
- kMetricsXorBursty[code_index].variance_residual_loss[k],
+ EXPECT_LE(scale * kMetricsXorBursty[code_index].variance_residual_loss[k],
kMetricsReedSolomon[code_index].variance_residual_loss[k]);
}
}
@@ -979,8 +957,8 @@
int num_fec_packets = code_params_[code_index].num_fec_packets;
for (int loss = 1; loss <= num_fec_packets; loss++) {
int index = loss; // |gap| is zero.
- EXPECT_EQ(kMetricsXorBursty[code_index].
- residual_loss_per_loss_gap[index], 0.0);
+ EXPECT_EQ(kMetricsXorBursty[code_index].residual_loss_per_loss_gap[index],
+ 0.0);
}
}
}
@@ -1036,42 +1014,46 @@
// Perfect recovery (|recovery_rate_per_loss| == 1) is expected for
// |loss_number| = 1, for all codes.
int loss_number = 1;
- EXPECT_EQ(kMetricsReedSolomon[code_index].
- recovery_rate_per_loss[loss_number], 1.0);
- EXPECT_EQ(kMetricsXorRandom[code_index].
- recovery_rate_per_loss[loss_number], 1.0);
- EXPECT_EQ(kMetricsXorBursty[code_index].
- recovery_rate_per_loss[loss_number], 1.0);
+ EXPECT_EQ(
+ kMetricsReedSolomon[code_index].recovery_rate_per_loss[loss_number],
+ 1.0);
+ EXPECT_EQ(kMetricsXorRandom[code_index].recovery_rate_per_loss[loss_number],
+ 1.0);
+ EXPECT_EQ(kMetricsXorBursty[code_index].recovery_rate_per_loss[loss_number],
+ 1.0);
// For |loss_number| = |num_fec_packets| / 2, we expect the following:
// Perfect recovery for RS, and recovery for XOR above the threshold.
loss_number = num_fec_packets / 2 > 0 ? num_fec_packets / 2 : 1;
- EXPECT_EQ(kMetricsReedSolomon[code_index].
- recovery_rate_per_loss[loss_number], 1.0);
- EXPECT_GE(kMetricsXorRandom[code_index].
- recovery_rate_per_loss[loss_number], kRecoveryRateXorRandom[0]);
- EXPECT_GE(kMetricsXorBursty[code_index].
- recovery_rate_per_loss[loss_number], kRecoveryRateXorBursty[0]);
+ EXPECT_EQ(
+ kMetricsReedSolomon[code_index].recovery_rate_per_loss[loss_number],
+ 1.0);
+ EXPECT_GE(kMetricsXorRandom[code_index].recovery_rate_per_loss[loss_number],
+ kRecoveryRateXorRandom[0]);
+ EXPECT_GE(kMetricsXorBursty[code_index].recovery_rate_per_loss[loss_number],
+ kRecoveryRateXorBursty[0]);
// For |loss_number| = |num_fec_packets|, we expect the following:
// Perfect recovery for RS, and recovery for XOR above the threshold.
loss_number = num_fec_packets;
- EXPECT_EQ(kMetricsReedSolomon[code_index].
- recovery_rate_per_loss[loss_number], 1.0);
- EXPECT_GE(kMetricsXorRandom[code_index].
- recovery_rate_per_loss[loss_number], kRecoveryRateXorRandom[1]);
- EXPECT_GE(kMetricsXorBursty[code_index].
- recovery_rate_per_loss[loss_number], kRecoveryRateXorBursty[1]);
+ EXPECT_EQ(
+ kMetricsReedSolomon[code_index].recovery_rate_per_loss[loss_number],
+ 1.0);
+ EXPECT_GE(kMetricsXorRandom[code_index].recovery_rate_per_loss[loss_number],
+ kRecoveryRateXorRandom[1]);
+ EXPECT_GE(kMetricsXorBursty[code_index].recovery_rate_per_loss[loss_number],
+ kRecoveryRateXorBursty[1]);
// For |loss_number| = |num_fec_packets| + 1, we expect the following:
// Zero recovery for RS, but non-zero recovery for XOR.
if (num_fec_packets > 1 && num_media_packets > 2) {
- loss_number = num_fec_packets + 1;
- EXPECT_EQ(kMetricsReedSolomon[code_index].
- recovery_rate_per_loss[loss_number], 0.0);
- EXPECT_GE(kMetricsXorRandom[code_index].
- recovery_rate_per_loss[loss_number],
- kRecoveryRateXorRandom[2]);
- EXPECT_GE(kMetricsXorBursty[code_index].
- recovery_rate_per_loss[loss_number],
- kRecoveryRateXorBursty[2]);
+ loss_number = num_fec_packets + 1;
+ EXPECT_EQ(
+ kMetricsReedSolomon[code_index].recovery_rate_per_loss[loss_number],
+ 0.0);
+ EXPECT_GE(
+ kMetricsXorRandom[code_index].recovery_rate_per_loss[loss_number],
+ kRecoveryRateXorRandom[2]);
+ EXPECT_GE(
+ kMetricsXorBursty[code_index].recovery_rate_per_loss[loss_number],
+ kRecoveryRateXorBursty[2]);
}
}
}
diff --git a/modules/utility/include/helpers_android.h b/modules/utility/include/helpers_android.h
index 808b347..b7bb0b2 100644
--- a/modules/utility/include/helpers_android.h
+++ b/modules/utility/include/helpers_android.h
@@ -42,11 +42,15 @@
// JNIEnv-helper methods that wraps the API which uses the JNI interface
// pointer (JNIEnv*). It allows us to RTC_CHECK success and that no Java
// exception is thrown while calling the method.
-jmethodID GetMethodID(
- JNIEnv* jni, jclass c, const char* name, const char* signature);
+jmethodID GetMethodID(JNIEnv* jni,
+ jclass c,
+ const char* name,
+ const char* signature);
-jmethodID GetStaticMethodID(
- JNIEnv* jni, jclass c, const char* name, const char* signature);
+jmethodID GetStaticMethodID(JNIEnv* jni,
+ jclass c,
+ const char* name,
+ const char* signature);
jclass FindClass(JNIEnv* jni, const char* name);
diff --git a/modules/utility/include/jvm_android.h b/modules/utility/include/jvm_android.h
index f899263..eb18cc2 100644
--- a/modules/utility/include/jvm_android.h
+++ b/modules/utility/include/jvm_android.h
@@ -78,8 +78,9 @@
NativeRegistration(JNIEnv* jni, jclass clazz);
~NativeRegistration();
- std::unique_ptr<GlobalRef> NewObject(
- const char* name, const char* signature, ...);
+ std::unique_ptr<GlobalRef> NewObject(const char* name,
+ const char* signature,
+ ...);
private:
JNIEnv* const jni_;
@@ -99,7 +100,9 @@
// |loaded_classes| array defined in jvm_android.cc.
// This method must be called on the construction thread.
std::unique_ptr<NativeRegistration> RegisterNatives(
- const char* name, const JNINativeMethod *methods, int num_methods);
+ const char* name,
+ const JNINativeMethod* methods,
+ int num_methods);
// Converts from Java string to std::string.
// This method must be called on the construction thread.
diff --git a/modules/utility/include/process_thread.h b/modules/utility/include/process_thread.h
index 28e1191..4ab40b2 100644
--- a/modules/utility/include/process_thread.h
+++ b/modules/utility/include/process_thread.h
@@ -74,4 +74,4 @@
} // namespace webrtc
-#endif // MODULES_UTILITY_INCLUDE_PROCESS_THREAD_H_
+#endif // MODULES_UTILITY_INCLUDE_PROCESS_THREAD_H_
diff --git a/modules/utility/source/helpers_android.cc b/modules/utility/source/helpers_android.cc
index 5e760b4..0206d15 100644
--- a/modules/utility/source/helpers_android.cc
+++ b/modules/utility/source/helpers_android.cc
@@ -47,8 +47,10 @@
return ret;
}
-jmethodID GetMethodID (
- JNIEnv* jni, jclass c, const char* name, const char* signature) {
+jmethodID GetMethodID(JNIEnv* jni,
+ jclass c,
+ const char* name,
+ const char* signature) {
jmethodID m = jni->GetMethodID(c, name, signature);
CHECK_EXCEPTION(jni) << "Error during GetMethodID: " << name << ", "
<< signature;
@@ -56,8 +58,10 @@
return m;
}
-jmethodID GetStaticMethodID (
- JNIEnv* jni, jclass c, const char* name, const char* signature) {
+jmethodID GetStaticMethodID(JNIEnv* jni,
+ jclass c,
+ const char* name,
+ const char* signature) {
jmethodID m = jni->GetStaticMethodID(c, name, signature);
CHECK_EXCEPTION(jni) << "Error during GetStaticMethodID: " << name << ", "
<< signature;
@@ -107,6 +111,8 @@
}
}
-JNIEnv* AttachThreadScoped::env() { return env_; }
+JNIEnv* AttachThreadScoped::env() {
+ return env_;
+}
} // namespace webrtc
diff --git a/modules/utility/source/jvm_android.cc b/modules/utility/source/jvm_android.cc
index d43ec65..2d48c2d 100644
--- a/modules/utility/source/jvm_android.cc
+++ b/modules/utility/source/jvm_android.cc
@@ -27,10 +27,10 @@
const char* name;
jclass clazz;
} loaded_classes[] = {
- {"org/webrtc/voiceengine/BuildInfo", nullptr},
- {"org/webrtc/voiceengine/WebRtcAudioManager", nullptr},
- {"org/webrtc/voiceengine/WebRtcAudioRecord", nullptr},
- {"org/webrtc/voiceengine/WebRtcAudioTrack", nullptr},
+ {"org/webrtc/voiceengine/BuildInfo", nullptr},
+ {"org/webrtc/voiceengine/WebRtcAudioManager", nullptr},
+ {"org/webrtc/voiceengine/WebRtcAudioRecord", nullptr},
+ {"org/webrtc/voiceengine/WebRtcAudioTrack", nullptr},
};
// Android's FindClass() is trickier than usual because the app-specific
@@ -68,8 +68,7 @@
}
// AttachCurrentThreadIfNeeded implementation.
-AttachCurrentThreadIfNeeded::AttachCurrentThreadIfNeeded()
- : attached_(false) {
+AttachCurrentThreadIfNeeded::AttachCurrentThreadIfNeeded() : attached_(false) {
RTC_LOG(INFO) << "AttachCurrentThreadIfNeeded::ctor";
JavaVM* jvm = JVM::GetInstance()->jvm();
RTC_CHECK(jvm);
@@ -141,27 +140,26 @@
CHECK_EXCEPTION(jni_) << "Error during UnregisterNatives";
}
-std::unique_ptr<GlobalRef> NativeRegistration::NewObject(
- const char* name, const char* signature, ...) {
+std::unique_ptr<GlobalRef> NativeRegistration::NewObject(const char* name,
+ const char* signature,
+ ...) {
RTC_LOG(INFO) << "NativeRegistration::NewObject";
va_list args;
va_start(args, signature);
- jobject obj = jni_->NewObjectV(j_class_,
- GetMethodID(jni_, j_class_, name, signature),
- args);
+ jobject obj = jni_->NewObjectV(
+ j_class_, GetMethodID(jni_, j_class_, name, signature), args);
CHECK_EXCEPTION(jni_) << "Error during NewObjectV";
va_end(args);
return std::unique_ptr<GlobalRef>(new GlobalRef(jni_, obj));
}
// JavaClass implementation.
-jmethodID JavaClass::GetMethodId(
- const char* name, const char* signature) {
+jmethodID JavaClass::GetMethodId(const char* name, const char* signature) {
return GetMethodID(jni_, j_class_, name, signature);
}
-jmethodID JavaClass::GetStaticMethodId(
- const char* name, const char* signature) {
+jmethodID JavaClass::GetStaticMethodId(const char* name,
+ const char* signature) {
return GetStaticMethodID(jni_, j_class_, name, signature);
}
@@ -192,7 +190,9 @@
}
std::unique_ptr<NativeRegistration> JNIEnvironment::RegisterNatives(
- const char* name, const JNINativeMethod *methods, int num_methods) {
+ const char* name,
+ const JNINativeMethod* methods,
+ int num_methods) {
RTC_LOG(INFO) << "JNIEnvironment::RegisterNatives: " << name;
RTC_DCHECK(thread_checker_.CalledOnValidThread());
jclass clazz = LookUpClass(name);
diff --git a/modules/utility/source/process_thread_impl.cc b/modules/utility/source/process_thread_impl.cc
index 014624e..97272da 100644
--- a/modules/utility/source/process_thread_impl.cc
+++ b/modules/utility/source/process_thread_impl.cc
@@ -32,13 +32,12 @@
}
return time_now + interval;
}
-}
+} // namespace
ProcessThread::~ProcessThread() {}
// static
-std::unique_ptr<ProcessThread> ProcessThread::Create(
- const char* thread_name) {
+std::unique_ptr<ProcessThread> ProcessThread::Create(const char* thread_name) {
return std::unique_ptr<ProcessThread>(new ProcessThreadImpl(thread_name));
}
@@ -76,7 +75,7 @@
void ProcessThreadImpl::Stop() {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
- if(!thread_.get())
+ if (!thread_.get())
return;
{
@@ -155,9 +154,8 @@
{
rtc::CritScope lock(&lock_);
- modules_.remove_if([&module](const ModuleCallback& m) {
- return m.module == module;
- });
+ modules_.remove_if(
+ [&module](const ModuleCallback& m) { return m.module == module; });
}
// Notify the module that it's been detached.
diff --git a/modules/utility/source/process_thread_impl.h b/modules/utility/source/process_thread_impl.h
index 9856fba..fcc668f 100644
--- a/modules/utility/source/process_thread_impl.h
+++ b/modules/utility/source/process_thread_impl.h
@@ -85,4 +85,4 @@
} // namespace webrtc
-#endif // MODULES_UTILITY_SOURCE_PROCESS_THREAD_IMPL_H_
+#endif // MODULES_UTILITY_SOURCE_PROCESS_THREAD_IMPL_H_
diff --git a/modules/utility/source/process_thread_impl_unittest.cc b/modules/utility/source/process_thread_impl_unittest.cc
index d278964..d5926b2 100644
--- a/modules/utility/source/process_thread_impl_unittest.cc
+++ b/modules/utility/source/process_thread_impl_unittest.cc
@@ -137,9 +137,8 @@
.WillOnce(Return(0))
.WillRepeatedly(Return(1));
EXPECT_CALL(module, Process())
- .WillOnce(DoAll(SetEvent(event.get()),
- Increment(&process_count),
- Return()))
+ .WillOnce(
+ DoAll(SetEvent(event.get()), Increment(&process_count), Return()))
.WillRepeatedly(DoAll(Increment(&process_count), Return()));
thread.RegisterModule(&module, RTC_FROM_HERE);
@@ -174,13 +173,11 @@
int64_t start_time = 0;
int64_t called_time = 0;
EXPECT_CALL(module, TimeUntilNextProcess())
- .WillOnce(DoAll(SetTimestamp(&start_time),
- Return(milliseconds)))
+ .WillOnce(DoAll(SetTimestamp(&start_time), Return(milliseconds)))
.WillRepeatedly(Return(milliseconds));
EXPECT_CALL(module, Process())
- .WillOnce(DoAll(SetTimestamp(&called_time),
- SetEvent(event.get()),
- Return()))
+ .WillOnce(
+ DoAll(SetTimestamp(&called_time), SetEvent(event.get()), Return()))
.WillRepeatedly(Return());
EXPECT_CALL(module, ProcessThreadAttached(&thread)).Times(1);
@@ -238,11 +235,9 @@
MockModule module;
int callback_count = 0;
// Ask for a callback after 20ms.
- EXPECT_CALL(module, TimeUntilNextProcess())
- .WillRepeatedly(Return(20));
+ EXPECT_CALL(module, TimeUntilNextProcess()).WillRepeatedly(Return(20));
EXPECT_CALL(module, Process())
- .WillRepeatedly(DoAll(Increment(&callback_count),
- Return()));
+ .WillRepeatedly(DoAll(Increment(&callback_count), Return()));
EXPECT_CALL(module, ProcessThreadAttached(&thread)).Times(1);
thread.RegisterModule(&module, RTC_FROM_HERE);
@@ -281,8 +276,7 @@
// The second time TimeUntilNextProcess is then called, is after Process
// has been called and we don't expect any more calls.
EXPECT_CALL(module, TimeUntilNextProcess())
- .WillOnce(DoAll(SetTimestamp(&start_time),
- SetEvent(started.get()),
+ .WillOnce(DoAll(SetTimestamp(&start_time), SetEvent(started.get()),
Return(1000)))
.WillOnce(Return(1000));
EXPECT_CALL(module, Process())
diff --git a/modules/video_capture/device_info_impl.h b/modules/video_capture/device_info_impl.h
index 7e23f04..f6e1970 100644
--- a/modules/video_capture/device_info_impl.h
+++ b/modules/video_capture/device_info_impl.h
@@ -16,45 +16,42 @@
#include "modules/video_capture/video_capture.h"
#include "rtc_base/synchronization/rw_lock_wrapper.h"
-namespace webrtc
-{
-namespace videocapturemodule
-{
-class DeviceInfoImpl: public VideoCaptureModule::DeviceInfo
-{
-public:
- DeviceInfoImpl();
- virtual ~DeviceInfoImpl(void);
- virtual int32_t NumberOfCapabilities(const char* deviceUniqueIdUTF8);
- virtual int32_t GetCapability(
- const char* deviceUniqueIdUTF8,
- const uint32_t deviceCapabilityNumber,
- VideoCaptureCapability& capability);
+namespace webrtc {
+namespace videocapturemodule {
+class DeviceInfoImpl : public VideoCaptureModule::DeviceInfo {
+ public:
+ DeviceInfoImpl();
+ virtual ~DeviceInfoImpl(void);
+ virtual int32_t NumberOfCapabilities(const char* deviceUniqueIdUTF8);
+ virtual int32_t GetCapability(const char* deviceUniqueIdUTF8,
+ const uint32_t deviceCapabilityNumber,
+ VideoCaptureCapability& capability);
- virtual int32_t GetBestMatchedCapability(
- const char* deviceUniqueIdUTF8,
- const VideoCaptureCapability& requested,
- VideoCaptureCapability& resulting);
- virtual int32_t GetOrientation(const char* deviceUniqueIdUTF8,
- VideoRotation& orientation);
+ virtual int32_t GetBestMatchedCapability(
+ const char* deviceUniqueIdUTF8,
+ const VideoCaptureCapability& requested,
+ VideoCaptureCapability& resulting);
+ virtual int32_t GetOrientation(const char* deviceUniqueIdUTF8,
+ VideoRotation& orientation);
-protected:
- /* Initialize this object*/
+ protected:
+ /* Initialize this object*/
- virtual int32_t Init()=0;
- /*
- * Fills the member variable _captureCapabilities with capabilities for the given device name.
- */
- virtual int32_t CreateCapabilityMap(const char* deviceUniqueIdUTF8)=0;
+ virtual int32_t Init() = 0;
+ /*
+ * Fills the member variable _captureCapabilities with capabilities for the
+ * given device name.
+ */
+ virtual int32_t CreateCapabilityMap(const char* deviceUniqueIdUTF8) = 0;
-protected:
- // Data members
- typedef std::vector<VideoCaptureCapability> VideoCaptureCapabilities;
- VideoCaptureCapabilities _captureCapabilities;
- RWLockWrapper& _apiLock;
- char* _lastUsedDeviceName;
- uint32_t _lastUsedDeviceNameLength;
+ protected:
+ // Data members
+ typedef std::vector<VideoCaptureCapability> VideoCaptureCapabilities;
+ VideoCaptureCapabilities _captureCapabilities;
+ RWLockWrapper& _apiLock;
+ char* _lastUsedDeviceName;
+ uint32_t _lastUsedDeviceNameLength;
};
} // namespace videocapturemodule
} // namespace webrtc
-#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_DEVICE_INFO_IMPL_H_
+#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_DEVICE_INFO_IMPL_H_
diff --git a/modules/video_capture/external/device_info_external.cc b/modules/video_capture/external/device_info_external.cc
index 4951dc8..cd660e2 100644
--- a/modules/video_capture/external/device_info_external.cc
+++ b/modules/video_capture/external/device_info_external.cc
@@ -25,19 +25,21 @@
const char* /*dialogTitleUTF8*/,
void* /*parentWindow*/,
uint32_t /*positionX*/,
- uint32_t /*positionY*/) { return -1; }
- virtual int32_t GetDeviceName(
- uint32_t deviceNumber,
- char* deviceNameUTF8,
- uint32_t deviceNameLength,
- char* deviceUniqueIdUTF8,
- uint32_t deviceUniqueIdUTF8Length,
- char* productUniqueIdUTF8=0,
- uint32_t productUniqueIdUTF8Length=0) {
+ uint32_t /*positionY*/) {
return -1;
}
- virtual int32_t CreateCapabilityMap(
- const char* deviceUniqueIdUTF8) { return 0; }
+ virtual int32_t GetDeviceName(uint32_t deviceNumber,
+ char* deviceNameUTF8,
+ uint32_t deviceNameLength,
+ char* deviceUniqueIdUTF8,
+ uint32_t deviceUniqueIdUTF8Length,
+ char* productUniqueIdUTF8 = 0,
+ uint32_t productUniqueIdUTF8Length = 0) {
+ return -1;
+ }
+ virtual int32_t CreateCapabilityMap(const char* deviceUniqueIdUTF8) {
+ return 0;
+ }
virtual int32_t Init() { return 0; }
};
diff --git a/modules/video_capture/linux/device_info_linux.h b/modules/video_capture/linux/device_info_linux.h
index 86eb61e..fc7b4d8 100644
--- a/modules/video_capture/linux/device_info_linux.h
+++ b/modules/video_capture/linux/device_info_linux.h
@@ -14,40 +14,39 @@
#include "modules/video_capture/device_info_impl.h"
#include "modules/video_capture/video_capture_impl.h"
-namespace webrtc
-{
-namespace videocapturemodule
-{
-class DeviceInfoLinux: public DeviceInfoImpl
-{
-public:
- DeviceInfoLinux();
- virtual ~DeviceInfoLinux();
- virtual uint32_t NumberOfDevices();
- virtual int32_t GetDeviceName(
- uint32_t deviceNumber,
- char* deviceNameUTF8,
- uint32_t deviceNameLength,
- char* deviceUniqueIdUTF8,
- uint32_t deviceUniqueIdUTF8Length,
- char* productUniqueIdUTF8=0,
- uint32_t productUniqueIdUTF8Length=0);
- /*
- * Fills the membervariable _captureCapabilities with capabilites for the given device name.
- */
- virtual int32_t CreateCapabilityMap (const char* deviceUniqueIdUTF8);
- virtual int32_t DisplayCaptureSettingsDialogBox(
- const char* /*deviceUniqueIdUTF8*/,
- const char* /*dialogTitleUTF8*/,
- void* /*parentWindow*/,
- uint32_t /*positionX*/,
- uint32_t /*positionY*/) { return -1;}
- int32_t FillCapabilities(int fd);
- int32_t Init();
-private:
+namespace webrtc {
+namespace videocapturemodule {
+class DeviceInfoLinux : public DeviceInfoImpl {
+ public:
+ DeviceInfoLinux();
+ virtual ~DeviceInfoLinux();
+ virtual uint32_t NumberOfDevices();
+ virtual int32_t GetDeviceName(uint32_t deviceNumber,
+ char* deviceNameUTF8,
+ uint32_t deviceNameLength,
+ char* deviceUniqueIdUTF8,
+ uint32_t deviceUniqueIdUTF8Length,
+ char* productUniqueIdUTF8 = 0,
+ uint32_t productUniqueIdUTF8Length = 0);
+ /*
+ * Fills the membervariable _captureCapabilities with capabilites for the
+ * given device name.
+ */
+ virtual int32_t CreateCapabilityMap(const char* deviceUniqueIdUTF8);
+ virtual int32_t DisplayCaptureSettingsDialogBox(
+ const char* /*deviceUniqueIdUTF8*/,
+ const char* /*dialogTitleUTF8*/,
+ void* /*parentWindow*/,
+ uint32_t /*positionX*/,
+ uint32_t /*positionY*/) {
+ return -1;
+ }
+ int32_t FillCapabilities(int fd);
+ int32_t Init();
- bool IsDeviceNameMatches(const char* name, const char* deviceUniqueIdUTF8);
+ private:
+ bool IsDeviceNameMatches(const char* name, const char* deviceUniqueIdUTF8);
};
} // namespace videocapturemodule
} // namespace webrtc
-#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_LINUX_DEVICE_INFO_LINUX_H_
+#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_LINUX_DEVICE_INFO_LINUX_H_
diff --git a/modules/video_capture/linux/video_capture_linux.h b/modules/video_capture/linux/video_capture_linux.h
index c0649a5..88455f9 100644
--- a/modules/video_capture/linux/video_capture_linux.h
+++ b/modules/video_capture/linux/video_capture_linux.h
@@ -18,50 +18,46 @@
#include "rtc_base/criticalsection.h"
#include "rtc_base/platform_thread.h"
-namespace webrtc
-{
-namespace videocapturemodule
-{
-class VideoCaptureModuleV4L2: public VideoCaptureImpl
-{
-public:
- VideoCaptureModuleV4L2();
- virtual ~VideoCaptureModuleV4L2();
- virtual int32_t Init(const char* deviceUniqueId);
- virtual int32_t StartCapture(const VideoCaptureCapability& capability);
- virtual int32_t StopCapture();
- virtual bool CaptureStarted();
- virtual int32_t CaptureSettings(VideoCaptureCapability& settings);
+namespace webrtc {
+namespace videocapturemodule {
+class VideoCaptureModuleV4L2 : public VideoCaptureImpl {
+ public:
+ VideoCaptureModuleV4L2();
+ virtual ~VideoCaptureModuleV4L2();
+ virtual int32_t Init(const char* deviceUniqueId);
+ virtual int32_t StartCapture(const VideoCaptureCapability& capability);
+ virtual int32_t StopCapture();
+ virtual bool CaptureStarted();
+ virtual int32_t CaptureSettings(VideoCaptureCapability& settings);
-private:
- enum {kNoOfV4L2Bufffers=4};
+ private:
+ enum { kNoOfV4L2Bufffers = 4 };
- static bool CaptureThread(void*);
- bool CaptureProcess();
- bool AllocateVideoBuffers();
- bool DeAllocateVideoBuffers();
+ static bool CaptureThread(void*);
+ bool CaptureProcess();
+ bool AllocateVideoBuffers();
+ bool DeAllocateVideoBuffers();
- // TODO(pbos): Stop using unique_ptr and resetting the thread.
- std::unique_ptr<rtc::PlatformThread> _captureThread;
- rtc::CriticalSection _captureCritSect;
+ // TODO(pbos): Stop using unique_ptr and resetting the thread.
+ std::unique_ptr<rtc::PlatformThread> _captureThread;
+ rtc::CriticalSection _captureCritSect;
- int32_t _deviceId;
- int32_t _deviceFd;
+ int32_t _deviceId;
+ int32_t _deviceFd;
- int32_t _buffersAllocatedByDevice;
- int32_t _currentWidth;
- int32_t _currentHeight;
- int32_t _currentFrameRate;
- bool _captureStarted;
- VideoType _captureVideoType;
- struct Buffer
- {
- void *start;
- size_t length;
- };
- Buffer *_pool;
+ int32_t _buffersAllocatedByDevice;
+ int32_t _currentWidth;
+ int32_t _currentHeight;
+ int32_t _currentFrameRate;
+ bool _captureStarted;
+ VideoType _captureVideoType;
+ struct Buffer {
+ void* start;
+ size_t length;
+ };
+ Buffer* _pool;
};
} // namespace videocapturemodule
} // namespace webrtc
-#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_LINUX_VIDEO_CAPTURE_LINUX_H_
+#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_LINUX_VIDEO_CAPTURE_LINUX_H_
diff --git a/modules/video_capture/test/video_capture_unittest.cc b/modules/video_capture/test/video_capture_unittest.cc
index 1c6d064..aed299c 100644
--- a/modules/video_capture/test/video_capture_unittest.cc
+++ b/modules/video_capture/test/video_capture_unittest.cc
@@ -32,25 +32,24 @@
using webrtc::VideoCaptureFactory;
using webrtc::VideoCaptureModule;
-
-#define WAIT_(ex, timeout, res) \
- do { \
- res = (ex); \
- int64_t start = rtc::TimeMillis(); \
+#define WAIT_(ex, timeout, res) \
+ do { \
+ res = (ex); \
+ int64_t start = rtc::TimeMillis(); \
while (!res && rtc::TimeMillis() < start + timeout) { \
- SleepMs(5); \
- res = (ex); \
- } \
+ SleepMs(5); \
+ res = (ex); \
+ } \
} while (0)
#define EXPECT_TRUE_WAIT(ex, timeout) \
- do { \
- bool res; \
- WAIT_(ex, timeout, res); \
- if (!res) EXPECT_TRUE(ex); \
+ do { \
+ bool res; \
+ WAIT_(ex, timeout, res); \
+ if (!res) \
+ EXPECT_TRUE(ex); \
} while (0)
-
static const int kTimeOut = 5000;
static const int kTestHeight = 288;
static const int kTestWidth = 352;
@@ -59,8 +58,8 @@
class TestVideoCaptureCallback
: public rtc::VideoSinkInterface<webrtc::VideoFrame> {
public:
- TestVideoCaptureCallback() :
- last_render_time_ms_(0),
+ TestVideoCaptureCallback()
+ : last_render_time_ms_(0),
incoming_frames_(0),
timing_warnings_(0),
rotate_frame_(webrtc::kVideoRotation_0) {}
@@ -85,16 +84,15 @@
EXPECT_EQ(rotate_frame_, videoFrame.rotation());
#endif
// RenderTimstamp should be the time now.
- EXPECT_TRUE(
- videoFrame.render_time_ms() >= rtc::TimeMillis()-30 &&
- videoFrame.render_time_ms() <= rtc::TimeMillis());
+ EXPECT_TRUE(videoFrame.render_time_ms() >= rtc::TimeMillis() - 30 &&
+ videoFrame.render_time_ms() <= rtc::TimeMillis());
if ((videoFrame.render_time_ms() >
- last_render_time_ms_ + (1000 * 1.1) / capability_.maxFPS &&
- last_render_time_ms_ > 0) ||
+ last_render_time_ms_ + (1000 * 1.1) / capability_.maxFPS &&
+ last_render_time_ms_ > 0) ||
(videoFrame.render_time_ms() <
- last_render_time_ms_ + (1000 * 0.9) / capability_.maxFPS &&
- last_render_time_ms_ > 0)) {
+ last_render_time_ms_ + (1000 * 0.9) / capability_.maxFPS &&
+ last_render_time_ms_ > 0)) {
timing_warnings_++;
}
@@ -105,7 +103,7 @@
void SetExpectedCapability(VideoCaptureCapability capability) {
rtc::CritScope cs(&capture_cs_);
- capability_= capability;
+ capability_ = capability;
incoming_frames_ = 0;
last_render_time_ms_ = 0;
}
@@ -161,8 +159,8 @@
char device_name[256];
char unique_name[256];
- EXPECT_EQ(0, device_info_->GetDeviceName(
- device, device_name, 256, unique_name, 256));
+ EXPECT_EQ(0, device_info_->GetDeviceName(device, device_name, 256,
+ unique_name, 256));
rtc::scoped_refptr<VideoCaptureModule> module(
VideoCaptureFactory::Create(unique_name));
@@ -251,8 +249,8 @@
OpenVideoCaptureDevice(0, &capture_observer));
ASSERT_TRUE(module.get() != NULL);
- int number_of_capabilities = device_info_->NumberOfCapabilities(
- module->CurrentDeviceName());
+ int number_of_capabilities =
+ device_info_->NumberOfCapabilities(module->CurrentDeviceName());
EXPECT_GT(number_of_capabilities, 0);
// Key is <width>x<height>, value is vector of maxFPS values at that
// resolution.
@@ -293,8 +291,7 @@
EXPECT_GT(frame_rates_by_resolution.size(), 1U);
for (FrameRatesByResolution::const_iterator it =
frame_rates_by_resolution.begin();
- it != frame_rates_by_resolution.end();
- ++it) {
+ it != frame_rates_by_resolution.end(); ++it) {
EXPECT_GT(it->second.size(), 1U) << it->first;
}
#endif // WEBRTC_ANDROID
@@ -328,7 +325,6 @@
OpenVideoCaptureDevice(1, &capture_observer2));
ASSERT_TRUE(module1.get() != NULL);
-
VideoCaptureCapability capability2;
#ifndef WEBRTC_MAC
device_info_->GetCapability(module2->CurrentDeviceName(), 0, capability2);
@@ -378,8 +374,7 @@
capture_module_->RegisterCaptureDataCallback(&capture_callback_);
}
- void TearDown() {
- }
+ void TearDown() {}
webrtc::VideoCaptureExternal* capture_input_interface_;
rtc::scoped_refptr<VideoCaptureModule> capture_module_;
@@ -393,8 +388,9 @@
webrtc::VideoType::kI420, test_frame_->width(), test_frame_->height());
std::unique_ptr<uint8_t[]> test_buffer(new uint8_t[length]);
webrtc::ExtractBuffer(*test_frame_, length, test_buffer.get());
- EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(),
- length, capture_callback_.capability(), 0));
+ EXPECT_EQ(0,
+ capture_input_interface_->IncomingFrame(
+ test_buffer.get(), length, capture_callback_.capability(), 0));
EXPECT_TRUE(capture_callback_.CompareLastFrame(*test_frame_));
}
@@ -404,18 +400,22 @@
webrtc::VideoType::kI420, test_frame_->width(), test_frame_->height());
std::unique_ptr<uint8_t[]> test_buffer(new uint8_t[length]);
webrtc::ExtractBuffer(*test_frame_, length, test_buffer.get());
- EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(),
- length, capture_callback_.capability(), 0));
+ EXPECT_EQ(0,
+ capture_input_interface_->IncomingFrame(
+ test_buffer.get(), length, capture_callback_.capability(), 0));
EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kVideoRotation_90));
capture_callback_.SetExpectedCaptureRotation(webrtc::kVideoRotation_90);
- EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(),
- length, capture_callback_.capability(), 0));
+ EXPECT_EQ(0,
+ capture_input_interface_->IncomingFrame(
+ test_buffer.get(), length, capture_callback_.capability(), 0));
EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kVideoRotation_180));
capture_callback_.SetExpectedCaptureRotation(webrtc::kVideoRotation_180);
- EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(),
- length, capture_callback_.capability(), 0));
+ EXPECT_EQ(0,
+ capture_input_interface_->IncomingFrame(
+ test_buffer.get(), length, capture_callback_.capability(), 0));
EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kVideoRotation_270));
capture_callback_.SetExpectedCaptureRotation(webrtc::kVideoRotation_270);
- EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(),
- length, capture_callback_.capability(), 0));
+ EXPECT_EQ(0,
+ capture_input_interface_->IncomingFrame(
+ test_buffer.get(), length, capture_callback_.capability(), 0));
}
diff --git a/modules/video_capture/video_capture.h b/modules/video_capture/video_capture.h
index fb3a461..0231f28 100644
--- a/modules/video_capture/video_capture.h
+++ b/modules/video_capture/video_capture.h
@@ -18,7 +18,7 @@
namespace webrtc {
-class VideoCaptureModule: public rtc::RefCountInterface {
+class VideoCaptureModule : public rtc::RefCountInterface {
public:
// Interface for receiving information about available camera devices.
class DeviceInfo {
@@ -32,25 +32,21 @@
// Otherwise same as deviceNameUTF8.
// productUniqueIdUTF8 - Unique product id if it exist.
// Null terminated otherwise.
- virtual int32_t GetDeviceName(
- uint32_t deviceNumber,
- char* deviceNameUTF8,
- uint32_t deviceNameLength,
- char* deviceUniqueIdUTF8,
- uint32_t deviceUniqueIdUTF8Length,
- char* productUniqueIdUTF8 = 0,
- uint32_t productUniqueIdUTF8Length = 0) = 0;
-
+ virtual int32_t GetDeviceName(uint32_t deviceNumber,
+ char* deviceNameUTF8,
+ uint32_t deviceNameLength,
+ char* deviceUniqueIdUTF8,
+ uint32_t deviceUniqueIdUTF8Length,
+ char* productUniqueIdUTF8 = 0,
+ uint32_t productUniqueIdUTF8Length = 0) = 0;
// Returns the number of capabilities this device.
- virtual int32_t NumberOfCapabilities(
- const char* deviceUniqueIdUTF8) = 0;
+ virtual int32_t NumberOfCapabilities(const char* deviceUniqueIdUTF8) = 0;
// Gets the capabilities of the named device.
- virtual int32_t GetCapability(
- const char* deviceUniqueIdUTF8,
- const uint32_t deviceCapabilityNumber,
- VideoCaptureCapability& capability) = 0;
+ virtual int32_t GetCapability(const char* deviceUniqueIdUTF8,
+ const uint32_t deviceCapabilityNumber,
+ VideoCaptureCapability& capability) = 0;
// Gets clockwise angle the captured frames should be rotated in order
// to be displayed correctly on a normally rotated display.
@@ -65,7 +61,7 @@
const VideoCaptureCapability& requested,
VideoCaptureCapability& resulting) = 0;
- // Display OS /capture device specific settings dialog
+ // Display OS /capture device specific settings dialog
virtual int32_t DisplayCaptureSettingsDialogBox(
const char* deviceUniqueIdUTF8,
const char* dialogTitleUTF8,
@@ -78,14 +74,13 @@
// Register capture data callback
virtual void RegisterCaptureDataCallback(
- rtc::VideoSinkInterface<VideoFrame> *dataCallback) = 0;
+ rtc::VideoSinkInterface<VideoFrame>* dataCallback) = 0;
// Remove capture data callback
virtual void DeRegisterCaptureDataCallback() = 0;
// Start capture device
- virtual int32_t StartCapture(
- const VideoCaptureCapability& capability) = 0;
+ virtual int32_t StartCapture(const VideoCaptureCapability& capability) = 0;
virtual int32_t StopCapture() = 0;
@@ -113,8 +108,8 @@
// Return whether the rotation is applied or left pending.
virtual bool GetApplyRotation() = 0;
-protected:
- virtual ~VideoCaptureModule() {};
+ protected:
+ virtual ~VideoCaptureModule(){};
};
} // namespace webrtc
diff --git a/modules/video_capture/video_capture_config.h b/modules/video_capture/video_capture_config.h
index 4cfff6e..f285b9e 100644
--- a/modules/video_capture/video_capture_config.h
+++ b/modules/video_capture/video_capture_config.h
@@ -11,23 +11,23 @@
#ifndef MODULES_VIDEO_CAPTURE_MAIN_SOURCE_VIDEO_CAPTURE_CONFIG_H_
#define MODULES_VIDEO_CAPTURE_MAIN_SOURCE_VIDEO_CAPTURE_CONFIG_H_
-namespace webrtc
-{
-namespace videocapturemodule
-{
-enum {kDefaultWidth = 640}; // Start width
-enum {kDefaultHeight = 480}; // Start heigt
-enum {kDefaultFrameRate = 30}; // Start frame rate
+namespace webrtc {
+namespace videocapturemodule {
+enum { kDefaultWidth = 640 }; // Start width
+enum { kDefaultHeight = 480 }; // Start heigt
+enum { kDefaultFrameRate = 30 }; // Start frame rate
-enum {kMaxFrameRate =60}; // Max allowed frame rate of the start image
+enum { kMaxFrameRate = 60 }; // Max allowed frame rate of the start image
-enum {kDefaultCaptureDelay = 120};
-enum {kMaxCaptureDelay = 270}; // Max capture delay allowed in the precompiled capture delay values.
+enum { kDefaultCaptureDelay = 120 };
+enum {
+ kMaxCaptureDelay = 270
+}; // Max capture delay allowed in the precompiled capture delay values.
-enum {kFrameRateCallbackInterval = 1000};
-enum {kFrameRateCountHistorySize = 90};
-enum {kFrameRateHistoryWindowMs = 2000};
+enum { kFrameRateCallbackInterval = 1000 };
+enum { kFrameRateCountHistorySize = 90 };
+enum { kFrameRateHistoryWindowMs = 2000 };
} // namespace videocapturemodule
} // namespace webrtc
-#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_VIDEO_CAPTURE_CONFIG_H_
+#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_VIDEO_CAPTURE_CONFIG_H_
diff --git a/modules/video_capture/video_capture_defines.h b/modules/video_capture/video_capture_defines.h
index ec5bf24..350025f 100644
--- a/modules/video_capture/video_capture_defines.h
+++ b/modules/video_capture/video_capture_defines.h
@@ -15,63 +15,59 @@
#include "modules/include/module_common_types.h"
#include "typedefs.h" // NOLINT(build/include)
-namespace webrtc
-{
+namespace webrtc {
-enum {kVideoCaptureUniqueNameLength =1024}; //Max unique capture device name lenght
-enum {kVideoCaptureDeviceNameLength =256}; //Max capture device name lenght
-enum {kVideoCaptureProductIdLength =128}; //Max product id length
+enum {
+ kVideoCaptureUniqueNameLength = 1024
+}; // Max unique capture device name lenght
+enum { kVideoCaptureDeviceNameLength = 256 }; // Max capture device name lenght
+enum { kVideoCaptureProductIdLength = 128 }; // Max product id length
-struct VideoCaptureCapability
-{
- int32_t width;
- int32_t height;
- int32_t maxFPS;
- VideoType videoType;
- bool interlaced;
+struct VideoCaptureCapability {
+ int32_t width;
+ int32_t height;
+ int32_t maxFPS;
+ VideoType videoType;
+ bool interlaced;
- VideoCaptureCapability()
- {
- width = 0;
- height = 0;
- maxFPS = 0;
- videoType = VideoType::kUnknown;
- interlaced = false;
- }
- ;
- bool operator!=(const VideoCaptureCapability &other) const
- {
- if (width != other.width)
- return true;
- if (height != other.height)
- return true;
- if (maxFPS != other.maxFPS)
- return true;
- if (videoType != other.videoType)
- return true;
- if (interlaced != other.interlaced)
- return true;
- return false;
- }
- bool operator==(const VideoCaptureCapability &other) const
- {
- return !operator!=(other);
- }
+ VideoCaptureCapability() {
+ width = 0;
+ height = 0;
+ maxFPS = 0;
+ videoType = VideoType::kUnknown;
+ interlaced = false;
+ };
+ bool operator!=(const VideoCaptureCapability& other) const {
+ if (width != other.width)
+ return true;
+ if (height != other.height)
+ return true;
+ if (maxFPS != other.maxFPS)
+ return true;
+ if (videoType != other.videoType)
+ return true;
+ if (interlaced != other.interlaced)
+ return true;
+ return false;
+ }
+ bool operator==(const VideoCaptureCapability& other) const {
+ return !operator!=(other);
+ }
};
/* External Capture interface. Returned by Create
and implemented by the capture module.
*/
-class VideoCaptureExternal
-{
-public:
- // |capture_time| must be specified in the NTP time format in milliseconds.
- virtual int32_t IncomingFrame(uint8_t* videoFrame,
- size_t videoFrameLength,
- const VideoCaptureCapability& frameInfo,
- int64_t captureTime = 0) = 0;
-protected:
- ~VideoCaptureExternal() {}
+class VideoCaptureExternal {
+ public:
+ // |capture_time| must be specified in the NTP time format in milliseconds.
+ virtual int32_t IncomingFrame(uint8_t* videoFrame,
+ size_t videoFrameLength,
+ const VideoCaptureCapability& frameInfo,
+ int64_t captureTime = 0) = 0;
+
+ protected:
+ ~VideoCaptureExternal() {}
};
} // namespace webrtc
diff --git a/modules/video_capture/video_capture_impl.h b/modules/video_capture/video_capture_impl.h
index d252597..7826427 100644
--- a/modules/video_capture/video_capture_impl.h
+++ b/modules/video_capture/video_capture_impl.h
@@ -22,98 +22,97 @@
#include "rtc_base/criticalsection.h"
#include "rtc_base/scoped_ref_ptr.h"
-namespace webrtc
-{
+namespace webrtc {
namespace videocapturemodule {
// Class definitions
-class VideoCaptureImpl: public VideoCaptureModule, public VideoCaptureExternal
-{
-public:
+class VideoCaptureImpl : public VideoCaptureModule,
+ public VideoCaptureExternal {
+ public:
+ /*
+ * Create a video capture module object
+ *
+ * id - unique identifier of this video capture module object
+ * deviceUniqueIdUTF8 - name of the device. Available names can be found by
+ * using GetDeviceName
+ */
+ static rtc::scoped_refptr<VideoCaptureModule> Create(
+ const char* deviceUniqueIdUTF8);
- /*
- * Create a video capture module object
- *
- * id - unique identifier of this video capture module object
- * deviceUniqueIdUTF8 - name of the device. Available names can be found by using GetDeviceName
- */
- static rtc::scoped_refptr<VideoCaptureModule> Create(
- const char* deviceUniqueIdUTF8);
+ /*
+ * Create a video capture module object used for external capture.
+ *
+ * id - unique identifier of this video capture module object
+ * externalCapture - [out] interface to call when a new frame is captured.
+ */
+ static rtc::scoped_refptr<VideoCaptureModule> Create(
+ VideoCaptureExternal*& externalCapture);
- /*
- * Create a video capture module object used for external capture.
- *
- * id - unique identifier of this video capture module object
- * externalCapture - [out] interface to call when a new frame is captured.
- */
- static rtc::scoped_refptr<VideoCaptureModule> Create(
- VideoCaptureExternal*& externalCapture);
+ static DeviceInfo* CreateDeviceInfo();
- static DeviceInfo* CreateDeviceInfo();
+ // Helpers for converting between (integral) degrees and
+ // VideoRotation values. Return 0 on success.
+ static int32_t RotationFromDegrees(int degrees, VideoRotation* rotation);
+ static int32_t RotationInDegrees(VideoRotation rotation, int* degrees);
- // Helpers for converting between (integral) degrees and
- // VideoRotation values. Return 0 on success.
- static int32_t RotationFromDegrees(int degrees, VideoRotation* rotation);
- static int32_t RotationInDegrees(VideoRotation rotation, int* degrees);
+ // Call backs
+ void RegisterCaptureDataCallback(
+ rtc::VideoSinkInterface<VideoFrame>* dataCallback) override;
+ void DeRegisterCaptureDataCallback() override;
- //Call backs
- void RegisterCaptureDataCallback(
- rtc::VideoSinkInterface<VideoFrame>* dataCallback) override;
- void DeRegisterCaptureDataCallback() override;
+ int32_t SetCaptureRotation(VideoRotation rotation) override;
+ bool SetApplyRotation(bool enable) override;
+ bool GetApplyRotation() override { return apply_rotation_; }
- int32_t SetCaptureRotation(VideoRotation rotation) override;
- bool SetApplyRotation(bool enable) override;
- bool GetApplyRotation() override {
- return apply_rotation_;
- }
+ const char* CurrentDeviceName() const override;
- const char* CurrentDeviceName() const override;
+ // Implement VideoCaptureExternal
+ // |capture_time| must be specified in NTP time format in milliseconds.
+ int32_t IncomingFrame(uint8_t* videoFrame,
+ size_t videoFrameLength,
+ const VideoCaptureCapability& frameInfo,
+ int64_t captureTime = 0) override;
- // Implement VideoCaptureExternal
- // |capture_time| must be specified in NTP time format in milliseconds.
- int32_t IncomingFrame(uint8_t* videoFrame,
- size_t videoFrameLength,
- const VideoCaptureCapability& frameInfo,
- int64_t captureTime = 0) override;
+ // Platform dependent
+ int32_t StartCapture(const VideoCaptureCapability& capability) override {
+ _requestedCapability = capability;
+ return -1;
+ }
+ int32_t StopCapture() override { return -1; }
+ bool CaptureStarted() override { return false; }
+ int32_t CaptureSettings(VideoCaptureCapability& /*settings*/) override {
+ return -1;
+ }
- // Platform dependent
- int32_t StartCapture(const VideoCaptureCapability& capability) override
- {
- _requestedCapability = capability;
- return -1;
- }
- int32_t StopCapture() override { return -1; }
- bool CaptureStarted() override {return false; }
- int32_t CaptureSettings(VideoCaptureCapability& /*settings*/) override
- { return -1; }
+ protected:
+ VideoCaptureImpl();
+ virtual ~VideoCaptureImpl();
+ int32_t DeliverCapturedFrame(VideoFrame& captureFrame);
-protected:
- VideoCaptureImpl();
- virtual ~VideoCaptureImpl();
- int32_t DeliverCapturedFrame(VideoFrame& captureFrame);
+ char* _deviceUniqueId; // current Device unique name;
+ rtc::CriticalSection _apiCs;
+ VideoCaptureCapability _requestedCapability; // Should be set by platform
+ // dependent code in
+ // StartCapture.
+ private:
+ void UpdateFrameCount();
+ uint32_t CalculateFrameRate(int64_t now_ns);
- char* _deviceUniqueId; // current Device unique name;
- rtc::CriticalSection _apiCs;
- VideoCaptureCapability _requestedCapability; // Should be set by platform dependent code in StartCapture.
-private:
- void UpdateFrameCount();
- uint32_t CalculateFrameRate(int64_t now_ns);
+ // last time the module process function was called.
+ int64_t _lastProcessTimeNanos;
+ // last time the frame rate callback function was called.
+ int64_t _lastFrameRateCallbackTimeNanos;
- // last time the module process function was called.
- int64_t _lastProcessTimeNanos;
- // last time the frame rate callback function was called.
- int64_t _lastFrameRateCallbackTimeNanos;
+ rtc::VideoSinkInterface<VideoFrame>* _dataCallBack;
- rtc::VideoSinkInterface<VideoFrame>* _dataCallBack;
+ int64_t _lastProcessFrameTimeNanos;
+ // timestamp for local captured frames
+ int64_t _incomingFrameTimesNanos[kFrameRateCountHistorySize];
+ VideoRotation _rotateFrame; // Set if the frame should be rotated by the
+ // capture module.
- int64_t _lastProcessFrameTimeNanos;
- // timestamp for local captured frames
- int64_t _incomingFrameTimesNanos[kFrameRateCountHistorySize];
- VideoRotation _rotateFrame; // Set if the frame should be rotated by the
- // capture module.
-
- // Indicate whether rotation should be applied before delivered externally.
- bool apply_rotation_;
+ // Indicate whether rotation should be applied before delivered externally.
+ bool apply_rotation_;
};
} // namespace videocapturemodule
} // namespace webrtc
diff --git a/modules/video_capture/windows/device_info_ds.h b/modules/video_capture/windows/device_info_ds.h
index 69991b2..6898855 100644
--- a/modules/video_capture/windows/device_info_ds.h
+++ b/modules/video_capture/windows/device_info_ds.h
@@ -16,91 +16,84 @@
#include <dshow.h>
-namespace webrtc
-{
-namespace videocapturemodule
-{
-struct VideoCaptureCapabilityWindows: public VideoCaptureCapability
-{
- uint32_t directShowCapabilityIndex;
- bool supportFrameRateControl;
- VideoCaptureCapabilityWindows()
- {
- directShowCapabilityIndex = 0;
- supportFrameRateControl = false;
- }
+namespace webrtc {
+namespace videocapturemodule {
+struct VideoCaptureCapabilityWindows : public VideoCaptureCapability {
+ uint32_t directShowCapabilityIndex;
+ bool supportFrameRateControl;
+ VideoCaptureCapabilityWindows() {
+ directShowCapabilityIndex = 0;
+ supportFrameRateControl = false;
+ }
};
-class DeviceInfoDS: public DeviceInfoImpl
-{
-public:
- // Factory function.
- static DeviceInfoDS* Create();
+class DeviceInfoDS : public DeviceInfoImpl {
+ public:
+ // Factory function.
+ static DeviceInfoDS* Create();
- DeviceInfoDS();
- virtual ~DeviceInfoDS();
+ DeviceInfoDS();
+ virtual ~DeviceInfoDS();
- int32_t Init();
- virtual uint32_t NumberOfDevices();
+ int32_t Init();
+ virtual uint32_t NumberOfDevices();
- /*
- * Returns the available capture devices.
- */
- virtual int32_t
- GetDeviceName(uint32_t deviceNumber,
- char* deviceNameUTF8,
- uint32_t deviceNameLength,
- char* deviceUniqueIdUTF8,
- uint32_t deviceUniqueIdUTF8Length,
- char* productUniqueIdUTF8,
- uint32_t productUniqueIdUTF8Length);
+ /*
+ * Returns the available capture devices.
+ */
+ virtual int32_t GetDeviceName(uint32_t deviceNumber,
+ char* deviceNameUTF8,
+ uint32_t deviceNameLength,
+ char* deviceUniqueIdUTF8,
+ uint32_t deviceUniqueIdUTF8Length,
+ char* productUniqueIdUTF8,
+ uint32_t productUniqueIdUTF8Length);
- /*
- * Display OS /capture device specific settings dialog
- */
- virtual int32_t
- DisplayCaptureSettingsDialogBox(
- const char* deviceUniqueIdUTF8,
- const char* dialogTitleUTF8,
- void* parentWindow,
- uint32_t positionX,
- uint32_t positionY);
+ /*
+ * Display OS /capture device specific settings dialog
+ */
+ virtual int32_t DisplayCaptureSettingsDialogBox(
+ const char* deviceUniqueIdUTF8,
+ const char* dialogTitleUTF8,
+ void* parentWindow,
+ uint32_t positionX,
+ uint32_t positionY);
- // Windows specific
+ // Windows specific
- /* Gets a capture device filter
- The user of this API is responsible for releasing the filter when it not needed.
- */
- IBaseFilter * GetDeviceFilter(const char* deviceUniqueIdUTF8,
- char* productUniqueIdUTF8 = NULL,
- uint32_t productUniqueIdUTF8Length = 0);
+ /* Gets a capture device filter
+ The user of this API is responsible for releasing the filter when it not
+ needed.
+ */
+ IBaseFilter* GetDeviceFilter(const char* deviceUniqueIdUTF8,
+ char* productUniqueIdUTF8 = NULL,
+ uint32_t productUniqueIdUTF8Length = 0);
- int32_t
- GetWindowsCapability(const int32_t capabilityIndex,
- VideoCaptureCapabilityWindows& windowsCapability);
+ int32_t GetWindowsCapability(
+ const int32_t capabilityIndex,
+ VideoCaptureCapabilityWindows& windowsCapability);
- static void GetProductId(const char* devicePath,
- char* productUniqueIdUTF8,
- uint32_t productUniqueIdUTF8Length);
+ static void GetProductId(const char* devicePath,
+ char* productUniqueIdUTF8,
+ uint32_t productUniqueIdUTF8Length);
-protected:
- int32_t GetDeviceInfo(uint32_t deviceNumber,
- char* deviceNameUTF8,
- uint32_t deviceNameLength,
- char* deviceUniqueIdUTF8,
- uint32_t deviceUniqueIdUTF8Length,
- char* productUniqueIdUTF8,
- uint32_t productUniqueIdUTF8Length);
+ protected:
+ int32_t GetDeviceInfo(uint32_t deviceNumber,
+ char* deviceNameUTF8,
+ uint32_t deviceNameLength,
+ char* deviceUniqueIdUTF8,
+ uint32_t deviceUniqueIdUTF8Length,
+ char* productUniqueIdUTF8,
+ uint32_t productUniqueIdUTF8Length);
- virtual int32_t
- CreateCapabilityMap(const char* deviceUniqueIdUTF8);
+ virtual int32_t CreateCapabilityMap(const char* deviceUniqueIdUTF8);
-private:
- ICreateDevEnum* _dsDevEnum;
- IEnumMoniker* _dsMonikerDevEnum;
- bool _CoUninitializeIsRequired;
- std::vector<VideoCaptureCapabilityWindows> _captureCapabilitiesWindows;
+ private:
+ ICreateDevEnum* _dsDevEnum;
+ IEnumMoniker* _dsMonikerDevEnum;
+ bool _CoUninitializeIsRequired;
+ std::vector<VideoCaptureCapabilityWindows> _captureCapabilitiesWindows;
};
} // namespace videocapturemodule
} // namespace webrtc
-#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_DEVICE_INFO_DS_H_
+#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_DEVICE_INFO_DS_H_
diff --git a/modules/video_capture/windows/device_info_mf.cc b/modules/video_capture/windows/device_info_mf.cc
index 3bdd755..4002f25 100644
--- a/modules/video_capture/windows/device_info_mf.cc
+++ b/modules/video_capture/windows/device_info_mf.cc
@@ -13,11 +13,9 @@
namespace webrtc {
namespace videocapturemodule {
-DeviceInfoMF::DeviceInfoMF() {
-}
+DeviceInfoMF::DeviceInfoMF() {}
-DeviceInfoMF::~DeviceInfoMF() {
-}
+DeviceInfoMF::~DeviceInfoMF() {}
int32_t DeviceInfoMF::Init() {
return -1;
@@ -27,14 +25,13 @@
return 0;
}
-int32_t DeviceInfoMF::GetDeviceName(
- uint32_t deviceNumber,
- char* deviceNameUTF8,
- uint32_t deviceNameLength,
- char* deviceUniqueIdUTF8,
- uint32_t deviceUniqueIdUTF8Length,
- char* productUniqueIdUTF8,
- uint32_t productUniqueIdUTF8Length) {
+int32_t DeviceInfoMF::GetDeviceName(uint32_t deviceNumber,
+ char* deviceNameUTF8,
+ uint32_t deviceNameLength,
+ char* deviceUniqueIdUTF8,
+ uint32_t deviceUniqueIdUTF8Length,
+ char* productUniqueIdUTF8,
+ uint32_t productUniqueIdUTF8Length) {
return -1;
}
diff --git a/modules/video_capture/windows/device_info_mf.h b/modules/video_capture/windows/device_info_mf.h
index 027f7c4..984d206 100644
--- a/modules/video_capture/windows/device_info_mf.h
+++ b/modules/video_capture/windows/device_info_mf.h
@@ -25,7 +25,8 @@
int32_t Init();
virtual uint32_t NumberOfDevices();
- virtual int32_t GetDeviceName(uint32_t deviceNumber, char* deviceNameUTF8,
+ virtual int32_t GetDeviceName(uint32_t deviceNumber,
+ char* deviceNameUTF8,
uint32_t deviceNameLength,
char* deviceUniqueIdUTF8,
uint32_t deviceUniqueIdUTF8Length,
@@ -33,8 +34,11 @@
uint32_t productUniqueIdUTF8Length);
virtual int32_t DisplayCaptureSettingsDialogBox(
- const char* deviceUniqueIdUTF8, const char* dialogTitleUTF8,
- void* parentWindow, uint32_t positionX, uint32_t positionY);
+ const char* deviceUniqueIdUTF8,
+ const char* dialogTitleUTF8,
+ void* parentWindow,
+ uint32_t positionX,
+ uint32_t positionY);
};
} // namespace videocapturemodule
diff --git a/modules/video_capture/windows/help_functions_ds.cc b/modules/video_capture/windows/help_functions_ds.cc
index 12deab0..ab85da9 100644
--- a/modules/video_capture/windows/help_functions_ds.cc
+++ b/modules/video_capture/windows/help_functions_ds.cc
@@ -16,104 +16,90 @@
#include <cguid.h>
-namespace webrtc
-{
-namespace videocapturemodule
-{
+namespace webrtc {
+namespace videocapturemodule {
// This returns minimum :), which will give max frame rate...
-LONGLONG GetMaxOfFrameArray(LONGLONG *maxFps, long size)
-{
- LONGLONG maxFPS = maxFps[0];
- for (int i = 0; i < size; i++)
- {
- if (maxFPS > maxFps[i])
- maxFPS = maxFps[i];
- }
- return maxFPS;
+LONGLONG GetMaxOfFrameArray(LONGLONG* maxFps, long size) {
+ LONGLONG maxFPS = maxFps[0];
+ for (int i = 0; i < size; i++) {
+ if (maxFPS > maxFps[i])
+ maxFPS = maxFps[i];
+ }
+ return maxFPS;
}
-IPin* GetInputPin(IBaseFilter* filter)
-{
- HRESULT hr;
- IPin* pin = NULL;
- IEnumPins* pPinEnum = NULL;
- filter->EnumPins(&pPinEnum);
- if (pPinEnum == NULL)
- {
- return NULL;
- }
-
- // get first unconnected pin
- hr = pPinEnum->Reset(); // set to first pin
-
- while (S_OK == pPinEnum->Next(1, &pin, NULL))
- {
- PIN_DIRECTION pPinDir;
- pin->QueryDirection(&pPinDir);
- if (PINDIR_INPUT == pPinDir) // This is an input pin
- {
- IPin* tempPin = NULL;
- if (S_OK != pin->ConnectedTo(&tempPin)) // The pint is not connected
- {
- pPinEnum->Release();
- return pin;
- }
- }
- pin->Release();
- }
- pPinEnum->Release();
+IPin* GetInputPin(IBaseFilter* filter) {
+ HRESULT hr;
+ IPin* pin = NULL;
+ IEnumPins* pPinEnum = NULL;
+ filter->EnumPins(&pPinEnum);
+ if (pPinEnum == NULL) {
return NULL;
+ }
+
+ // get first unconnected pin
+ hr = pPinEnum->Reset(); // set to first pin
+
+ while (S_OK == pPinEnum->Next(1, &pin, NULL)) {
+ PIN_DIRECTION pPinDir;
+ pin->QueryDirection(&pPinDir);
+ if (PINDIR_INPUT == pPinDir) // This is an input pin
+ {
+ IPin* tempPin = NULL;
+ if (S_OK != pin->ConnectedTo(&tempPin)) // The pint is not connected
+ {
+ pPinEnum->Release();
+ return pin;
+ }
+ }
+ pin->Release();
+ }
+ pPinEnum->Release();
+ return NULL;
}
-IPin* GetOutputPin(IBaseFilter* filter, REFGUID Category)
-{
- HRESULT hr;
- IPin* pin = NULL;
- IEnumPins* pPinEnum = NULL;
- filter->EnumPins(&pPinEnum);
- if (pPinEnum == NULL)
- {
- return NULL;
- }
- // get first unconnected pin
- hr = pPinEnum->Reset(); // set to first pin
- while (S_OK == pPinEnum->Next(1, &pin, NULL))
- {
- PIN_DIRECTION pPinDir;
- pin->QueryDirection(&pPinDir);
- if (PINDIR_OUTPUT == pPinDir) // This is an output pin
- {
- if (Category == GUID_NULL || PinMatchesCategory(pin, Category))
- {
- pPinEnum->Release();
- return pin;
- }
- }
- pin->Release();
- pin = NULL;
- }
- pPinEnum->Release();
+IPin* GetOutputPin(IBaseFilter* filter, REFGUID Category) {
+ HRESULT hr;
+ IPin* pin = NULL;
+ IEnumPins* pPinEnum = NULL;
+ filter->EnumPins(&pPinEnum);
+ if (pPinEnum == NULL) {
return NULL;
+ }
+ // get first unconnected pin
+ hr = pPinEnum->Reset(); // set to first pin
+ while (S_OK == pPinEnum->Next(1, &pin, NULL)) {
+ PIN_DIRECTION pPinDir;
+ pin->QueryDirection(&pPinDir);
+ if (PINDIR_OUTPUT == pPinDir) // This is an output pin
+ {
+ if (Category == GUID_NULL || PinMatchesCategory(pin, Category)) {
+ pPinEnum->Release();
+ return pin;
+ }
+ }
+ pin->Release();
+ pin = NULL;
+ }
+ pPinEnum->Release();
+ return NULL;
}
-BOOL PinMatchesCategory(IPin *pPin, REFGUID Category)
-{
- BOOL bFound = FALSE;
- IKsPropertySet *pKs = NULL;
- HRESULT hr = pPin->QueryInterface(IID_PPV_ARGS(&pKs));
- if (SUCCEEDED(hr))
- {
- GUID PinCategory;
- DWORD cbReturned;
- hr = pKs->Get(AMPROPSETID_Pin, AMPROPERTY_PIN_CATEGORY, NULL, 0, &PinCategory,
- sizeof(GUID), &cbReturned);
- if (SUCCEEDED(hr) && (cbReturned == sizeof(GUID)))
- {
- bFound = (PinCategory == Category);
- }
- pKs->Release();
+BOOL PinMatchesCategory(IPin* pPin, REFGUID Category) {
+ BOOL bFound = FALSE;
+ IKsPropertySet* pKs = NULL;
+ HRESULT hr = pPin->QueryInterface(IID_PPV_ARGS(&pKs));
+ if (SUCCEEDED(hr)) {
+ GUID PinCategory;
+ DWORD cbReturned;
+ hr = pKs->Get(AMPROPSETID_Pin, AMPROPERTY_PIN_CATEGORY, NULL, 0,
+ &PinCategory, sizeof(GUID), &cbReturned);
+ if (SUCCEEDED(hr) && (cbReturned == sizeof(GUID))) {
+ bFound = (PinCategory == Category);
}
- return bFound;
+ pKs->Release();
+ }
+ return bFound;
}
} // namespace videocapturemodule
} // namespace webrtc
diff --git a/modules/video_capture/windows/help_functions_ds.h b/modules/video_capture/windows/help_functions_ds.h
index 990f418..e77efd1 100644
--- a/modules/video_capture/windows/help_functions_ds.h
+++ b/modules/video_capture/windows/help_functions_ds.h
@@ -13,23 +13,45 @@
#include <dshow.h>
-DEFINE_GUID(MEDIASUBTYPE_I420, 0x30323449, 0x0000, 0x0010, 0x80, 0x00, 0x00,
- 0xAA, 0x00, 0x38, 0x9B, 0x71);
-DEFINE_GUID(MEDIASUBTYPE_HDYC, 0x43594448, 0x0000, 0x0010, 0x80, 0x00, 0x00,
- 0xAA, 0x00, 0x38, 0x9B, 0x71);
+DEFINE_GUID(MEDIASUBTYPE_I420,
+ 0x30323449,
+ 0x0000,
+ 0x0010,
+ 0x80,
+ 0x00,
+ 0x00,
+ 0xAA,
+ 0x00,
+ 0x38,
+ 0x9B,
+ 0x71);
+DEFINE_GUID(MEDIASUBTYPE_HDYC,
+ 0x43594448,
+ 0x0000,
+ 0x0010,
+ 0x80,
+ 0x00,
+ 0x00,
+ 0xAA,
+ 0x00,
+ 0x38,
+ 0x9B,
+ 0x71);
-#define RELEASE_AND_CLEAR(p) if (p) { (p) -> Release () ; (p) = NULL ; }
+#define RELEASE_AND_CLEAR(p) \
+ if (p) { \
+ (p)->Release(); \
+ (p) = NULL; \
+ }
-namespace webrtc
-{
-namespace videocapturemodule
-{
-LONGLONG GetMaxOfFrameArray(LONGLONG *maxFps, long size);
+namespace webrtc {
+namespace videocapturemodule {
+LONGLONG GetMaxOfFrameArray(LONGLONG* maxFps, long size);
IPin* GetInputPin(IBaseFilter* filter);
IPin* GetOutputPin(IBaseFilter* filter, REFGUID Category);
-BOOL PinMatchesCategory(IPin *pPin, REFGUID Category);
+BOOL PinMatchesCategory(IPin* pPin, REFGUID Category);
} // namespace videocapturemodule
} // namespace webrtc
-#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_HELP_FUNCTIONS_DS_H_
+#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_HELP_FUNCTIONS_DS_H_
diff --git a/modules/video_capture/windows/sink_filter_ds.h b/modules/video_capture/windows/sink_filter_ds.h
index 4f620f4..a73022d 100644
--- a/modules/video_capture/windows/sink_filter_ds.h
+++ b/modules/video_capture/windows/sink_filter_ds.h
@@ -11,85 +11,82 @@
#ifndef MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_SINK_FILTER_DS_H_
#define MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_SINK_FILTER_DS_H_
-#include <streams.h> // Include base DS filter header files
+#include <streams.h> // Include base DS filter header files
#include "modules/video_capture/video_capture_defines.h"
-namespace webrtc
-{
-namespace videocapturemodule
-{
-//forward declaration
+namespace webrtc {
+namespace videocapturemodule {
+// forward declaration
class CaptureSinkFilter;
/**
* input pin for camera input
*
*/
-class CaptureInputPin: public CBaseInputPin
-{
-public:
- VideoCaptureCapability _requestedCapability;
- VideoCaptureCapability _resultingCapability;
- HANDLE _threadHandle;
+class CaptureInputPin : public CBaseInputPin {
+ public:
+ VideoCaptureCapability _requestedCapability;
+ VideoCaptureCapability _resultingCapability;
+ HANDLE _threadHandle;
- CaptureInputPin(IN TCHAR* szName,
- IN CaptureSinkFilter* pFilter,
- IN CCritSec * pLock,
- OUT HRESULT * pHr,
- IN LPCWSTR pszName);
- virtual ~CaptureInputPin();
+ CaptureInputPin(IN TCHAR* szName,
+ IN CaptureSinkFilter* pFilter,
+ IN CCritSec* pLock,
+ OUT HRESULT* pHr,
+ IN LPCWSTR pszName);
+ virtual ~CaptureInputPin();
- HRESULT GetMediaType (IN int iPos, OUT CMediaType * pmt);
- HRESULT CheckMediaType (IN const CMediaType * pmt);
- STDMETHODIMP Receive (IN IMediaSample *);
- HRESULT SetMatchingMediaType(const VideoCaptureCapability& capability);
+ HRESULT GetMediaType(IN int iPos, OUT CMediaType* pmt);
+ HRESULT CheckMediaType(IN const CMediaType* pmt);
+ STDMETHODIMP Receive(IN IMediaSample*);
+ HRESULT SetMatchingMediaType(const VideoCaptureCapability& capability);
};
-class CaptureSinkFilter: public CBaseFilter
-{
+class CaptureSinkFilter : public CBaseFilter {
+ public:
+ CaptureSinkFilter(const IN TCHAR* tszName,
+ IN LPUNKNOWN punk,
+ OUT HRESULT* phr,
+ VideoCaptureExternal& captureObserver);
+ virtual ~CaptureSinkFilter();
-public:
- CaptureSinkFilter(const IN TCHAR * tszName,
- IN LPUNKNOWN punk,
- OUT HRESULT * phr,
- VideoCaptureExternal& captureObserver);
- virtual ~CaptureSinkFilter();
+ // --------------------------------------------------------------------
+ // class methods
- // --------------------------------------------------------------------
- // class methods
+ void ProcessCapturedFrame(unsigned char* pBuffer,
+ size_t length,
+ const VideoCaptureCapability& frameInfo);
+ // explicit receiver lock aquisition and release
+ void LockReceive() { m_crtRecv.Lock(); }
+ void UnlockReceive() { m_crtRecv.Unlock(); }
+ // explicit filter lock aquisition and release
+ void LockFilter() { m_crtFilter.Lock(); }
+ void UnlockFilter() { m_crtFilter.Unlock(); }
+ void SetFilterGraph(IGraphBuilder* graph); // Used if EVR
- void ProcessCapturedFrame(unsigned char* pBuffer, size_t length,
- const VideoCaptureCapability& frameInfo);
- // explicit receiver lock aquisition and release
- void LockReceive() { m_crtRecv.Lock();}
- void UnlockReceive() {m_crtRecv.Unlock();}
- // explicit filter lock aquisition and release
- void LockFilter() {m_crtFilter.Lock();}
- void UnlockFilter() { m_crtFilter.Unlock(); }
- void SetFilterGraph(IGraphBuilder* graph); // Used if EVR
+ // --------------------------------------------------------------------
+ // COM interfaces
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP SetMatchingMediaType(const VideoCaptureCapability& capability);
- // --------------------------------------------------------------------
- // COM interfaces
-DECLARE_IUNKNOWN ;
- STDMETHODIMP SetMatchingMediaType(const VideoCaptureCapability& capability);
+ // --------------------------------------------------------------------
+ // CBaseFilter methods
+ int GetPinCount();
+ CBasePin* GetPin(IN int Index);
+ STDMETHODIMP Pause();
+ STDMETHODIMP Stop();
+ STDMETHODIMP GetClassID(OUT CLSID* pCLSID);
+ // --------------------------------------------------------------------
+ // class factory calls this
+ static CUnknown* CreateInstance(IN LPUNKNOWN punk, OUT HRESULT* phr);
- // --------------------------------------------------------------------
- // CBaseFilter methods
- int GetPinCount ();
- CBasePin * GetPin ( IN int Index);
- STDMETHODIMP Pause ();
- STDMETHODIMP Stop ();
- STDMETHODIMP GetClassID ( OUT CLSID * pCLSID);
- // --------------------------------------------------------------------
- // class factory calls this
- static CUnknown * CreateInstance (IN LPUNKNOWN punk, OUT HRESULT * phr);
-private:
- CCritSec m_crtFilter; // filter lock
- CCritSec m_crtRecv; // receiver lock; always acquire before filter lock
- CaptureInputPin * m_pInput;
- VideoCaptureExternal& _captureObserver;
+ private:
+ CCritSec m_crtFilter; // filter lock
+ CCritSec m_crtRecv; // receiver lock; always acquire before filter lock
+ CaptureInputPin* m_pInput;
+ VideoCaptureExternal& _captureObserver;
};
} // namespace videocapturemodule
} // namespace webrtc
-#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_SINK_FILTER_DS_H_
+#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_SINK_FILTER_DS_H_
diff --git a/modules/video_capture/windows/video_capture_ds.h b/modules/video_capture/windows/video_capture_ds.h
index 86fa589..db3d34a 100644
--- a/modules/video_capture/windows/video_capture_ds.h
+++ b/modules/video_capture/windows/video_capture_ds.h
@@ -17,63 +17,57 @@
#define CAPTURE_FILTER_NAME L"VideoCaptureFilter"
#define SINK_FILTER_NAME L"SinkFilter"
-namespace webrtc
-{
-namespace videocapturemodule
-{
+namespace webrtc {
+namespace videocapturemodule {
// Forward declaraion
class CaptureSinkFilter;
-class VideoCaptureDS: public VideoCaptureImpl
-{
-public:
- VideoCaptureDS();
+class VideoCaptureDS : public VideoCaptureImpl {
+ public:
+ VideoCaptureDS();
- virtual int32_t Init(const char* deviceUniqueIdUTF8);
+ virtual int32_t Init(const char* deviceUniqueIdUTF8);
- /*************************************************************************
- *
- * Start/Stop
- *
- *************************************************************************/
- virtual int32_t
- StartCapture(const VideoCaptureCapability& capability);
- virtual int32_t StopCapture();
+ /*************************************************************************
+ *
+ * Start/Stop
+ *
+ *************************************************************************/
+ virtual int32_t StartCapture(const VideoCaptureCapability& capability);
+ virtual int32_t StopCapture();
- /**************************************************************************
- *
- * Properties of the set device
- *
- **************************************************************************/
+ /**************************************************************************
+ *
+ * Properties of the set device
+ *
+ **************************************************************************/
- virtual bool CaptureStarted();
- virtual int32_t CaptureSettings(VideoCaptureCapability& settings);
+ virtual bool CaptureStarted();
+ virtual int32_t CaptureSettings(VideoCaptureCapability& settings);
-protected:
- virtual ~VideoCaptureDS();
+ protected:
+ virtual ~VideoCaptureDS();
- // Help functions
+ // Help functions
- int32_t
- SetCameraOutput(const VideoCaptureCapability& requestedCapability);
- int32_t DisconnectGraph();
- HRESULT ConnectDVCamera();
+ int32_t SetCameraOutput(const VideoCaptureCapability& requestedCapability);
+ int32_t DisconnectGraph();
+ HRESULT ConnectDVCamera();
- DeviceInfoDS _dsInfo;
+ DeviceInfoDS _dsInfo;
- IBaseFilter* _captureFilter;
- IGraphBuilder* _graphBuilder;
- IMediaControl* _mediaControl;
- CaptureSinkFilter* _sinkFilter;
- IPin* _inputSendPin;
- IPin* _outputCapturePin;
+ IBaseFilter* _captureFilter;
+ IGraphBuilder* _graphBuilder;
+ IMediaControl* _mediaControl;
+ CaptureSinkFilter* _sinkFilter;
+ IPin* _inputSendPin;
+ IPin* _outputCapturePin;
- // Microsoft DV interface (external DV cameras)
- IBaseFilter* _dvFilter;
- IPin* _inputDvPin;
- IPin* _outputDvPin;
-
+ // Microsoft DV interface (external DV cameras)
+ IBaseFilter* _dvFilter;
+ IPin* _inputDvPin;
+ IPin* _outputDvPin;
};
} // namespace videocapturemodule
} // namespace webrtc
-#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_VIDEO_CAPTURE_DS_H_
+#endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_VIDEO_CAPTURE_DS_H_
diff --git a/modules/video_capture/windows/video_capture_mf.cc b/modules/video_capture/windows/video_capture_mf.cc
index 086b708..4c72ee9 100644
--- a/modules/video_capture/windows/video_capture_mf.cc
+++ b/modules/video_capture/windows/video_capture_mf.cc
@@ -20,8 +20,7 @@
return 0;
}
-int32_t VideoCaptureMF::StartCapture(
- const VideoCaptureCapability& capability) {
+int32_t VideoCaptureMF::StartCapture(const VideoCaptureCapability& capability) {
return -1;
}
@@ -33,8 +32,7 @@
return false;
}
-int32_t VideoCaptureMF::CaptureSettings(
- VideoCaptureCapability& settings) {
+int32_t VideoCaptureMF::CaptureSettings(VideoCaptureCapability& settings) {
return -1;
}
diff --git a/modules/video_capture/windows/video_capture_mf.h b/modules/video_capture/windows/video_capture_mf.h
index 896be4e..ed9c382 100644
--- a/modules/video_capture/windows/video_capture_mf.h
+++ b/modules/video_capture/windows/video_capture_mf.h
@@ -30,8 +30,7 @@
virtual int32_t StartCapture(const VideoCaptureCapability& capability);
virtual int32_t StopCapture();
virtual bool CaptureStarted();
- virtual int32_t CaptureSettings(
- VideoCaptureCapability& settings); // NOLINT
+ virtual int32_t CaptureSettings(VideoCaptureCapability& settings); // NOLINT
protected:
virtual ~VideoCaptureMF();
diff --git a/modules/video_coding/codecs/h264/h264_decoder_impl.h b/modules/video_coding/codecs/h264/h264_decoder_impl.h
index 1172f14..a709177 100644
--- a/modules/video_coding/codecs/h264/h264_decoder_impl.h
+++ b/modules/video_coding/codecs/h264/h264_decoder_impl.h
@@ -58,8 +58,9 @@
// Called by FFmpeg when it needs a frame buffer to store decoded frames in.
// The |VideoFrame| returned by FFmpeg at |Decode| originate from here. Their
// buffers are reference counted and freed by FFmpeg using |AVFreeBuffer2|.
- static int AVGetBuffer2(
- AVCodecContext* context, AVFrame* av_frame, int flags);
+ static int AVGetBuffer2(AVCodecContext* context,
+ AVFrame* av_frame,
+ int flags);
// Called by FFmpeg when it is done with a video frame, see |AVGetBuffer2|.
static void AVFreeBuffer2(void* opaque, uint8_t* data);
diff --git a/modules/video_coding/codecs/h264/h264_encoder_impl.cc b/modules/video_coding/codecs/h264/h264_encoder_impl.cc
index 67c5abc..eee954d 100644
--- a/modules/video_coding/codecs/h264/h264_encoder_impl.cc
+++ b/modules/video_coding/codecs/h264/h264_encoder_impl.cc
@@ -45,17 +45,17 @@
int NumberOfThreads(int width, int height, int number_of_cores) {
// TODO(hbos): In Chromium, multiple threads do not work with sandbox on Mac,
// see crbug.com/583348. Until further investigated, only use one thread.
-// if (width * height >= 1920 * 1080 && number_of_cores > 8) {
-// return 8; // 8 threads for 1080p on high perf machines.
-// } else if (width * height > 1280 * 960 && number_of_cores >= 6) {
-// return 3; // 3 threads for 1080p.
-// } else if (width * height > 640 * 480 && number_of_cores >= 3) {
-// return 2; // 2 threads for qHD/HD.
-// } else {
-// return 1; // 1 thread for VGA or less.
-// }
-// TODO(sprang): Also check sSliceArgument.uiSliceNum om GetEncoderPrams(),
-// before enabling multithreading here.
+ // if (width * height >= 1920 * 1080 && number_of_cores > 8) {
+ // return 8; // 8 threads for 1080p on high perf machines.
+ // } else if (width * height > 1280 * 960 && number_of_cores >= 6) {
+ // return 3; // 3 threads for 1080p.
+ // } else if (width * height > 640 * 480 && number_of_cores >= 3) {
+ // return 2; // 2 threads for qHD/HD.
+ // } else {
+ // return 1; // 1 thread for VGA or less.
+ // }
+ // TODO(sprang): Also check sSliceArgument.uiSliceNum om GetEncoderPrams(),
+ // before enabling multithreading here.
return 1;
}
@@ -139,10 +139,10 @@
// Because the sum of all layer lengths, |required_size|, fits in a
// |size_t|, we know that any indices in-between will not overflow.
RTC_DCHECK_GE(layerInfo.pNalLengthInByte[nal], 4);
- RTC_DCHECK_EQ(layerInfo.pBsBuf[layer_len+0], start_code[0]);
- RTC_DCHECK_EQ(layerInfo.pBsBuf[layer_len+1], start_code[1]);
- RTC_DCHECK_EQ(layerInfo.pBsBuf[layer_len+2], start_code[2]);
- RTC_DCHECK_EQ(layerInfo.pBsBuf[layer_len+3], start_code[3]);
+ RTC_DCHECK_EQ(layerInfo.pBsBuf[layer_len + 0], start_code[0]);
+ RTC_DCHECK_EQ(layerInfo.pBsBuf[layer_len + 1], start_code[1]);
+ RTC_DCHECK_EQ(layerInfo.pBsBuf[layer_len + 2], start_code[2]);
+ RTC_DCHECK_EQ(layerInfo.pBsBuf[layer_len + 3], start_code[3]);
frag_header->fragmentationOffset[frag] =
encoded_image->_length + layer_len + sizeof(start_code);
frag_header->fragmentationLength[frag] =
@@ -150,8 +150,7 @@
layer_len += layerInfo.pNalLengthInByte[nal];
}
// Copy the entire layer's data (including start codes).
- memcpy(encoded_image->_buffer + encoded_image->_length,
- layerInfo.pBsBuf,
+ memcpy(encoded_image->_buffer + encoded_image->_length, layerInfo.pBsBuf,
layer_len);
encoded_image->_length += layer_len;
}
@@ -190,8 +189,7 @@
int32_t number_of_cores,
size_t max_payload_size) {
ReportInit();
- if (!codec_settings ||
- codec_settings->codecType != kVideoCodecH264) {
+ if (!codec_settings || codec_settings->codecType != kVideoCodecH264) {
ReportError();
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
}
@@ -222,8 +220,7 @@
RTC_DCHECK(openh264_encoder_);
if (kOpenH264EncoderDetailedLogging) {
int trace_level = WELS_LOG_DETAIL;
- openh264_encoder_->SetOption(ENCODER_OPTION_TRACE_LEVEL,
- &trace_level);
+ openh264_encoder_->SetOption(ENCODER_OPTION_TRACE_LEVEL, &trace_level);
}
// else WELS_LOG_DEFAULT is used by default.
@@ -255,8 +252,7 @@
}
// TODO(pbos): Base init params on these values before submitting.
int video_format = EVideoFormatType::videoFormatI420;
- openh264_encoder_->SetOption(ENCODER_OPTION_DATAFORMAT,
- &video_format);
+ openh264_encoder_->SetOption(ENCODER_OPTION_DATAFORMAT, &video_format);
// Initialize encoded image. Default buffer size: size of unencoded data.
encoded_image_._size = CalcBufferSize(VideoType::kI420, codec_settings->width,
@@ -300,8 +296,7 @@
memset(&target_bitrate, 0, sizeof(SBitrateInfo));
target_bitrate.iLayer = SPATIAL_LAYER_ALL,
target_bitrate.iBitrate = target_bps_;
- openh264_encoder_->SetOption(ENCODER_OPTION_BITRATE,
- &target_bitrate);
+ openh264_encoder_->SetOption(ENCODER_OPTION_BITRATE, &target_bitrate);
openh264_encoder_->SetOption(ENCODER_OPTION_FRAME_RATE, &max_frame_rate_);
return WEBRTC_VIDEO_CODEC_OK;
}
@@ -485,8 +480,7 @@
if (has_reported_init_)
return;
RTC_HISTOGRAM_ENUMERATION("WebRTC.Video.H264EncoderImpl.Event",
- kH264EncoderEventInit,
- kH264EncoderEventMax);
+ kH264EncoderEventInit, kH264EncoderEventMax);
has_reported_init_ = true;
}
@@ -494,13 +488,12 @@
if (has_reported_error_)
return;
RTC_HISTOGRAM_ENUMERATION("WebRTC.Video.H264EncoderImpl.Event",
- kH264EncoderEventError,
- kH264EncoderEventMax);
+ kH264EncoderEventError, kH264EncoderEventMax);
has_reported_error_ = true;
}
-int32_t H264EncoderImpl::SetChannelParameters(
- uint32_t packet_loss, int64_t rtt) {
+int32_t H264EncoderImpl::SetChannelParameters(uint32_t packet_loss,
+ int64_t rtt) {
return WEBRTC_VIDEO_CODEC_OK;
}
diff --git a/modules/video_coding/codecs/multiplex/multiplex_decoder_adapter.cc b/modules/video_coding/codecs/multiplex/multiplex_decoder_adapter.cc
index de4352f..dcf99f1 100644
--- a/modules/video_coding/codecs/multiplex/multiplex_decoder_adapter.cc
+++ b/modules/video_coding/codecs/multiplex/multiplex_decoder_adapter.cc
@@ -126,8 +126,8 @@
int32_t rv = 0;
for (size_t i = 0; i < image.image_components.size(); i++) {
rv = decoders_[image.image_components[i].component_index]->Decode(
- image.image_components[i].encoded_image, missing_frames,
- nullptr, render_time_ms);
+ image.image_components[i].encoded_image, missing_frames, nullptr,
+ render_time_ms);
if (rv != WEBRTC_VIDEO_CODEC_OK)
return rv;
}
diff --git a/modules/video_coding/codecs/multiplex/test/multiplex_adapter_unittest.cc b/modules/video_coding/codecs/multiplex/test/multiplex_adapter_unittest.cc
index fbefd60..be5c2cc 100644
--- a/modules/video_coding/codecs/multiplex/test/multiplex_adapter_unittest.cc
+++ b/modules/video_coding/codecs/multiplex/test/multiplex_adapter_unittest.cc
@@ -128,9 +128,8 @@
ASSERT_TRUE(WaitForEncodedFrame(&encoded_frame, &codec_specific_info));
EXPECT_EQ(kVideoCodecMultiplex, codec_specific_info.codecType);
- EXPECT_EQ(
- WEBRTC_VIDEO_CODEC_OK,
- decoder_->Decode(encoded_frame, false, &codec_specific_info, -1));
+ EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
+ decoder_->Decode(encoded_frame, false, &codec_specific_info, -1));
std::unique_ptr<VideoFrame> decoded_frame;
absl::optional<uint8_t> decoded_qp;
ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp));
diff --git a/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc b/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc
index 5ac6986..394ee14 100644
--- a/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc
+++ b/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc
@@ -308,9 +308,9 @@
// TODO(kthelgason): Move this out of the test fixture impl and
// make available as a shared utility class.
-void VideoCodecTestFixtureImpl::H264KeyframeChecker::
- CheckEncodedFrame(webrtc::VideoCodecType codec,
- const EncodedImage& encoded_frame) const {
+void VideoCodecTestFixtureImpl::H264KeyframeChecker::CheckEncodedFrame(
+ webrtc::VideoCodecType codec,
+ const EncodedImage& encoded_frame) const {
EXPECT_EQ(kVideoCodecH264, codec);
bool contains_sps = false;
bool contains_pps = false;
@@ -390,8 +390,7 @@
decoder_factory_(std::move(decoder_factory)),
config_(config) {}
-VideoCodecTestFixtureImpl::
- ~VideoCodecTestFixtureImpl() = default;
+VideoCodecTestFixtureImpl::~VideoCodecTestFixtureImpl() = default;
// Processes all frames in the clip and verifies the result.
void VideoCodecTestFixtureImpl::RunTest(
diff --git a/modules/video_coding/codecs/test/videocodec_test_mediacodec.cc b/modules/video_coding/codecs/test/videocodec_test_mediacodec.cc
index fc49c92..f8580fc 100644
--- a/modules/video_coding/codecs/test/videocodec_test_mediacodec.cc
+++ b/modules/video_coding/codecs/test/videocodec_test_mediacodec.cc
@@ -70,8 +70,8 @@
TEST(VideoCodecTestMediaCodec, ForemanCif500kbpsH264CBP) {
auto config = CreateConfig();
- const auto frame_checker = rtc::MakeUnique<
- VideoCodecTestFixtureImpl::H264KeyframeChecker>();
+ const auto frame_checker =
+ rtc::MakeUnique<VideoCodecTestFixtureImpl::H264KeyframeChecker>();
config.encoded_frame_checker = frame_checker.get();
config.SetCodecSettings(cricket::kH264CodecName, 1, 1, 1, false, false, false,
352, 288);
@@ -95,8 +95,8 @@
// HW encoders that support CHP.
TEST(VideoCodecTestMediaCodec, DISABLED_ForemanCif500kbpsH264CHP) {
auto config = CreateConfig();
- const auto frame_checker = rtc::MakeUnique<
- VideoCodecTestFixtureImpl::H264KeyframeChecker>();
+ const auto frame_checker =
+ rtc::MakeUnique<VideoCodecTestFixtureImpl::H264KeyframeChecker>();
config.h264_codec_settings.profile = H264::kProfileConstrainedHigh;
config.encoded_frame_checker = frame_checker.get();
diff --git a/modules/video_coding/codecs/test/videocodec_test_openh264.cc b/modules/video_coding/codecs/test/videocodec_test_openh264.cc
index c8a6ba2..a0743d1 100644
--- a/modules/video_coding/codecs/test/videocodec_test_openh264.cc
+++ b/modules/video_coding/codecs/test/videocodec_test_openh264.cc
@@ -39,8 +39,8 @@
} // namespace
TEST(VideoCodecTestOpenH264, ConstantHighBitrate) {
- auto frame_checker = rtc::MakeUnique<
- VideoCodecTestFixtureImpl::H264KeyframeChecker>();
+ auto frame_checker =
+ rtc::MakeUnique<VideoCodecTestFixtureImpl::H264KeyframeChecker>();
auto config = CreateConfig();
config.SetCodecSettings(cricket::kH264CodecName, 1, 1, 1, false, true, false,
kCifWidth, kCifHeight);
@@ -60,8 +60,8 @@
// H264: Enable SingleNalUnit packetization mode. Encoder should split
// large frames into multiple slices and limit length of NAL units.
TEST(VideoCodecTestOpenH264, SingleNalUnit) {
- auto frame_checker = rtc::MakeUnique<
- VideoCodecTestFixtureImpl::H264KeyframeChecker>();
+ auto frame_checker =
+ rtc::MakeUnique<VideoCodecTestFixtureImpl::H264KeyframeChecker>();
auto config = CreateConfig();
config.h264_codec_settings.packetization_mode =
H264PacketizationMode::SingleNalUnit;
diff --git a/modules/video_coding/codecs/test/videocodec_test_videotoolbox.cc b/modules/video_coding/codecs/test/videocodec_test_videotoolbox.cc
index c91f340..a5667bc 100644
--- a/modules/video_coding/codecs/test/videocodec_test_videotoolbox.cc
+++ b/modules/video_coding/codecs/test/videocodec_test_videotoolbox.cc
@@ -37,8 +37,8 @@
VideoCodecTestFixture::Config config) {
auto decoder_factory = CreateObjCDecoderFactory();
auto encoder_factory = CreateObjCEncoderFactory();
- return CreateVideoCodecTestFixture(
- config, std::move(decoder_factory), std::move(encoder_factory));
+ return CreateVideoCodecTestFixture(config, std::move(decoder_factory),
+ std::move(encoder_factory));
}
} // namespace
@@ -53,8 +53,8 @@
// TODO(kthelgason): Use RC Thresholds when the internal bitrateAdjuster is no
// longer in use.
MAYBE_TEST(VideoCodecTestVideoToolbox, ForemanCif500kbpsH264CBP) {
- const auto frame_checker = rtc::MakeUnique<
- VideoCodecTestFixtureImpl::H264KeyframeChecker>();
+ const auto frame_checker =
+ rtc::MakeUnique<VideoCodecTestFixtureImpl::H264KeyframeChecker>();
auto config = CreateConfig();
config.SetCodecSettings(cricket::kH264CodecName, 1, 1, 1, false, false, false,
352, 288);
@@ -69,8 +69,8 @@
}
MAYBE_TEST(VideoCodecTestVideoToolbox, ForemanCif500kbpsH264CHP) {
- const auto frame_checker = rtc::MakeUnique<
- VideoCodecTestFixtureImpl::H264KeyframeChecker>();
+ const auto frame_checker =
+ rtc::MakeUnique<VideoCodecTestFixtureImpl::H264KeyframeChecker>();
auto config = CreateConfig();
config.h264_codec_settings.profile = H264::kProfileConstrainedHigh;
config.SetCodecSettings(cricket::kH264CodecName, 1, 1, 1, false, false, false,
diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc b/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc
index bd2c992..9df5544 100644
--- a/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc
+++ b/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc
@@ -8,7 +8,6 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-
#include <algorithm>
#include <string>
diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
index 0f8bc75..522c989 100644
--- a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
+++ b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
@@ -8,7 +8,6 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-
#include <algorithm>
#include <string>
#include <vector>
diff --git a/modules/video_coding/codecs/vp8/screenshare_layers.cc b/modules/video_coding/codecs/vp8/screenshare_layers.cc
index cd24490..f7f1019 100644
--- a/modules/video_coding/codecs/vp8/screenshare_layers.cc
+++ b/modules/video_coding/codecs/vp8/screenshare_layers.cc
@@ -37,8 +37,7 @@
// been exceeded. This prevents needless keyframe requests.
const int ScreenshareLayers::kMaxFrameIntervalMs = 2750;
-ScreenshareLayers::ScreenshareLayers(int num_temporal_layers,
- Clock* clock)
+ScreenshareLayers::ScreenshareLayers(int num_temporal_layers, Clock* clock)
: clock_(clock),
number_of_temporal_layers_(
std::min(kMaxNumTemporalLayers, num_temporal_layers)),
diff --git a/modules/video_coding/codecs/vp8/screenshare_layers.h b/modules/video_coding/codecs/vp8/screenshare_layers.h
index c1b5fa7..5185b45 100644
--- a/modules/video_coding/codecs/vp8/screenshare_layers.h
+++ b/modules/video_coding/codecs/vp8/screenshare_layers.h
@@ -28,8 +28,7 @@
static const double kAcceptableTargetOvershoot;
static const int kMaxFrameIntervalMs;
- ScreenshareLayers(int num_temporal_layers,
- Clock* clock);
+ ScreenshareLayers(int num_temporal_layers, Clock* clock);
virtual ~ScreenshareLayers();
// Returns the recommended VP8 encode flags needed. May refresh the decoder
diff --git a/modules/video_coding/codecs/vp8/simulcast_rate_allocator.cc b/modules/video_coding/codecs/vp8/simulcast_rate_allocator.cc
index 6eea837..f8cfe88 100644
--- a/modules/video_coding/codecs/vp8/simulcast_rate_allocator.cc
+++ b/modules/video_coding/codecs/vp8/simulcast_rate_allocator.cc
@@ -12,8 +12,8 @@
#include <algorithm>
#include <memory>
-#include <vector>
#include <utility>
+#include <vector>
#include "modules/video_coding/codecs/vp8/include/vp8_common_types.h"
#include "rtc_base/checks.h"
diff --git a/modules/video_coding/codecs/vp9/include/vp9_globals.h b/modules/video_coding/codecs/vp9/include/vp9_globals.h
index 3ee9952..aa532a6 100644
--- a/modules/video_coding/codecs/vp9/include/vp9_globals.h
+++ b/modules/video_coding/codecs/vp9/include/vp9_globals.h
@@ -181,12 +181,12 @@
bool beginning_of_frame; // True if this packet is the first in a VP9 layer
// frame.
bool end_of_frame; // True if this packet is the last in a VP9 layer frame.
- bool ss_data_available; // True if SS data is available in this payload
- // descriptor.
+ bool ss_data_available; // True if SS data is available in this payload
+ // descriptor.
bool non_ref_for_inter_layer_pred; // True for frame which is not used as
// reference for inter-layer prediction.
- int16_t picture_id; // PictureID index, 15 bits;
- // kNoPictureId if PictureID does not exist.
+ int16_t picture_id; // PictureID index, 15 bits;
+ // kNoPictureId if PictureID does not exist.
int16_t max_picture_id; // Maximum picture ID index; either 0x7F or 0x7FFF;
int16_t tl0_pic_idx; // TL0PIC_IDX, 8 bits;
// kNoTl0PicIdx means no value provided.
diff --git a/modules/video_coding/codecs/vp9/svc_config.cc b/modules/video_coding/codecs/vp9/svc_config.cc
index c4ec288..22902fe 100644
--- a/modules/video_coding/codecs/vp9/svc_config.cc
+++ b/modules/video_coding/codecs/vp9/svc_config.cc
@@ -85,7 +85,7 @@
spatial_layer.minBitrate =
std::max(static_cast<size_t>(min_bitrate), kMinVp9SvcBitrateKbps);
spatial_layer.maxBitrate =
- static_cast<int>((1.6 * num_pixels + 50 * 1000) / 1000);
+ static_cast<int>((1.6 * num_pixels + 50 * 1000) / 1000);
spatial_layer.targetBitrate =
(spatial_layer.minBitrate + spatial_layer.maxBitrate) / 2;
spatial_layers.push_back(spatial_layer);
diff --git a/modules/video_coding/codecs/vp9/vp9_impl.cc b/modules/video_coding/codecs/vp9/vp9_impl.cc
index 7a1e2ab..24f86aa 100644
--- a/modules/video_coding/codecs/vp9/vp9_impl.cc
+++ b/modules/video_coding/codecs/vp9/vp9_impl.cc
@@ -15,10 +15,10 @@
#include <limits>
#include <vector>
-#include "vpx/vpx_encoder.h"
-#include "vpx/vpx_decoder.h"
#include "vpx/vp8cx.h"
#include "vpx/vp8dx.h"
+#include "vpx/vpx_decoder.h"
+#include "vpx/vpx_encoder.h"
#include "common_video/include/video_frame_buffer.h"
#include "common_video/libyuv/include/webrtc_libyuv.h"
@@ -164,9 +164,8 @@
RTC_LOG(LS_ERROR) << "Scaling factors not specified!";
return false;
}
- rate_ratio[i] =
- static_cast<float>(svc_params_.scaling_factor_num[i]) /
- svc_params_.scaling_factor_den[i];
+ rate_ratio[i] = static_cast<float>(svc_params_.scaling_factor_num[i]) /
+ svc_params_.scaling_factor_den[i];
total += rate_ratio[i];
}
@@ -409,7 +408,7 @@
} else if (width * height >= 640 * 360 && number_of_cores > 2) {
return 2;
} else {
- // Use 2 threads for low res on ARM.
+// Use 2 threads for low res on ARM.
#if defined(WEBRTC_ARCH_ARM) || defined(WEBRTC_ARCH_ARM64) || \
defined(WEBRTC_ANDROID)
if (width * height >= 320 * 180 && number_of_cores > 2) {
@@ -531,7 +530,7 @@
vpx_codec_control(encoder_, VP9E_SET_ROW_MT, 1);
#if !defined(WEBRTC_ARCH_ARM) && !defined(WEBRTC_ARCH_ARM64) && \
- !defined(ANDROID)
+ !defined(ANDROID)
// Do not enable the denoiser on ARM since optimization is pending.
// Denoiser is on by default on other platforms.
vpx_codec_control(encoder_, VP9E_SET_NOISE_SENSITIVITY,
@@ -716,11 +715,9 @@
if (vp9_info->ss_data_available) {
vp9_info->spatial_layer_resolution_present = true;
for (size_t i = 0; i < vp9_info->num_spatial_layers; ++i) {
- vp9_info->width[i] = codec_.width *
- svc_params_.scaling_factor_num[i] /
+ vp9_info->width[i] = codec_.width * svc_params_.scaling_factor_num[i] /
svc_params_.scaling_factor_den[i];
- vp9_info->height[i] = codec_.height *
- svc_params_.scaling_factor_num[i] /
+ vp9_info->height[i] = codec_.height * svc_params_.scaling_factor_num[i] /
svc_params_.scaling_factor_den[i];
}
if (!vp9_info->flexible_mode) {
diff --git a/modules/video_coding/encoded_frame.h b/modules/video_coding/encoded_frame.h
index 80f0dcc..17c61d7 100644
--- a/modules/video_coding/encoded_frame.h
+++ b/modules/video_coding/encoded_frame.h
@@ -29,19 +29,19 @@
~VCMEncodedFrame();
/**
- * Delete VideoFrame and resets members to zero
- */
+ * Delete VideoFrame and resets members to zero
+ */
void Free();
/**
- * Set render time in milliseconds
- */
+ * Set render time in milliseconds
+ */
void SetRenderTime(const int64_t renderTimeMs) {
_renderTimeMs = renderTimeMs;
}
/**
- * Set the encoded frame size
- */
+ * Set the encoded frame size
+ */
void SetEncodedSize(uint32_t width, uint32_t height) {
_encodedWidth = width;
_encodedHeight = height;
@@ -52,34 +52,34 @@
}
/**
- * Get the encoded image
- */
+ * Get the encoded image
+ */
const webrtc::EncodedImage& EncodedImage() const {
return static_cast<const webrtc::EncodedImage&>(*this);
}
/**
- * Get pointer to frame buffer
- */
+ * Get pointer to frame buffer
+ */
const uint8_t* Buffer() const { return _buffer; }
/**
- * Get frame length
- */
+ * Get frame length
+ */
size_t Length() const { return _length; }
/**
- * Get frame timestamp (90kHz)
- */
+ * Get frame timestamp (90kHz)
+ */
uint32_t TimeStamp() const { return _timeStamp; }
/**
- * Get render time in milliseconds
- */
+ * Get render time in milliseconds
+ */
int64_t RenderTimeMs() const { return _renderTimeMs; }
/**
- * Get frame type
- */
+ * Get frame type
+ */
webrtc::FrameType FrameType() const { return _frameType; }
/**
- * Get frame rotation
- */
+ * Get frame rotation
+ */
VideoRotation rotation() const { return rotation_; }
/**
* Get video content type
@@ -94,30 +94,30 @@
*/
bool Complete() const { return _completeFrame; }
/**
- * True if there's a frame missing before this frame
- */
+ * True if there's a frame missing before this frame
+ */
bool MissingFrame() const { return _missingFrame; }
/**
- * Payload type of the encoded payload
- */
+ * Payload type of the encoded payload
+ */
uint8_t PayloadType() const { return _payloadType; }
/**
- * Get codec specific info.
- * The returned pointer is only valid as long as the VCMEncodedFrame
- * is valid. Also, VCMEncodedFrame owns the pointer and will delete
- * the object.
- */
+ * Get codec specific info.
+ * The returned pointer is only valid as long as the VCMEncodedFrame
+ * is valid. Also, VCMEncodedFrame owns the pointer and will delete
+ * the object.
+ */
const CodecSpecificInfo* CodecSpecific() const { return &_codecSpecificInfo; }
protected:
/**
- * Verifies that current allocated buffer size is larger than or equal to the
- * input size.
- * If the current buffer size is smaller, a new allocation is made and the old
- * buffer data
- * is copied to the new buffer.
- * Buffer size is updated to minimumSize.
- */
+ * Verifies that current allocated buffer size is larger than or equal to the
+ * input size.
+ * If the current buffer size is smaller, a new allocation is made and the old
+ * buffer data
+ * is copied to the new buffer.
+ * Buffer size is updated to minimumSize.
+ */
void VerifyAndAllocate(size_t minimumSize);
void Reset();
diff --git a/modules/video_coding/frame_buffer.h b/modules/video_coding/frame_buffer.h
index 2fc2d21..66f338a 100644
--- a/modules/video_coding/frame_buffer.h
+++ b/modules/video_coding/frame_buffer.h
@@ -14,8 +14,8 @@
#include <vector>
#include "modules/include/module_common_types.h"
-#include "modules/video_coding/include/video_coding.h"
#include "modules/video_coding/encoded_frame.h"
+#include "modules/video_coding/include/video_coding.h"
#include "modules/video_coding/jitter_buffer_common.h"
#include "modules/video_coding/session_info.h"
#include "typedefs.h" // NOLINT(build/include)
@@ -71,7 +71,6 @@
webrtc::FrameType FrameType() const;
-
private:
void SetState(VCMFrameBufferStateEnum state); // Set state of frame
diff --git a/modules/video_coding/generic_decoder.cc b/modules/video_coding/generic_decoder.cc
index 580bfc9..01500e7 100644
--- a/modules/video_coding/generic_decoder.cc
+++ b/modules/video_coding/generic_decoder.cc
@@ -32,8 +32,7 @@
_clock->CurrentNtpInMilliseconds() - _clock->TimeInMilliseconds();
}
-VCMDecodedFrameCallback::~VCMDecodedFrameCallback() {
-}
+VCMDecodedFrameCallback::~VCMDecodedFrameCallback() {}
void VCMDecodedFrameCallback::SetUserReceiveCallback(
VCMReceiveCallback* receiveCallback) {
@@ -141,8 +140,8 @@
_timing->SetTimingFrameInfo(timing_frame_info);
}
- decodedImage.set_timestamp_us(
- frameInfo->renderTimeMs * rtc::kNumMicrosecsPerMillisec);
+ decodedImage.set_timestamp_us(frameInfo->renderTimeMs *
+ rtc::kNumMicrosecsPerMillisec);
decodedImage.set_rotation(frameInfo->rotation);
_receiveCallback->FrameToRender(decodedImage, qp, frameInfo->content_type);
}
@@ -211,39 +210,39 @@
}
int32_t VCMGenericDecoder::Decode(const VCMEncodedFrame& frame, int64_t nowMs) {
- TRACE_EVENT1("webrtc", "VCMGenericDecoder::Decode", "timestamp",
- frame.EncodedImage()._timeStamp);
- _frameInfos[_nextFrameInfoIdx].decodeStartTimeMs = nowMs;
- _frameInfos[_nextFrameInfoIdx].renderTimeMs = frame.RenderTimeMs();
- _frameInfos[_nextFrameInfoIdx].rotation = frame.rotation();
- _frameInfos[_nextFrameInfoIdx].timing = frame.video_timing();
- // Set correctly only for key frames. Thus, use latest key frame
- // content type. If the corresponding key frame was lost, decode will fail
- // and content type will be ignored.
- if (frame.FrameType() == kVideoFrameKey) {
- _frameInfos[_nextFrameInfoIdx].content_type = frame.contentType();
- _last_keyframe_content_type = frame.contentType();
- } else {
- _frameInfos[_nextFrameInfoIdx].content_type = _last_keyframe_content_type;
- }
- _callback->Map(frame.TimeStamp(), &_frameInfos[_nextFrameInfoIdx]);
+ TRACE_EVENT1("webrtc", "VCMGenericDecoder::Decode", "timestamp",
+ frame.EncodedImage()._timeStamp);
+ _frameInfos[_nextFrameInfoIdx].decodeStartTimeMs = nowMs;
+ _frameInfos[_nextFrameInfoIdx].renderTimeMs = frame.RenderTimeMs();
+ _frameInfos[_nextFrameInfoIdx].rotation = frame.rotation();
+ _frameInfos[_nextFrameInfoIdx].timing = frame.video_timing();
+ // Set correctly only for key frames. Thus, use latest key frame
+ // content type. If the corresponding key frame was lost, decode will fail
+ // and content type will be ignored.
+ if (frame.FrameType() == kVideoFrameKey) {
+ _frameInfos[_nextFrameInfoIdx].content_type = frame.contentType();
+ _last_keyframe_content_type = frame.contentType();
+ } else {
+ _frameInfos[_nextFrameInfoIdx].content_type = _last_keyframe_content_type;
+ }
+ _callback->Map(frame.TimeStamp(), &_frameInfos[_nextFrameInfoIdx]);
- _nextFrameInfoIdx = (_nextFrameInfoIdx + 1) % kDecoderFrameMemoryLength;
- int32_t ret = decoder_->Decode(frame.EncodedImage(), frame.MissingFrame(),
- frame.CodecSpecific(), frame.RenderTimeMs());
+ _nextFrameInfoIdx = (_nextFrameInfoIdx + 1) % kDecoderFrameMemoryLength;
+ int32_t ret = decoder_->Decode(frame.EncodedImage(), frame.MissingFrame(),
+ frame.CodecSpecific(), frame.RenderTimeMs());
- _callback->OnDecoderImplementationName(decoder_->ImplementationName());
- if (ret < WEBRTC_VIDEO_CODEC_OK) {
- RTC_LOG(LS_WARNING) << "Failed to decode frame with timestamp "
- << frame.TimeStamp() << ", error code: " << ret;
- _callback->Pop(frame.TimeStamp());
- return ret;
- } else if (ret == WEBRTC_VIDEO_CODEC_NO_OUTPUT ||
- ret == WEBRTC_VIDEO_CODEC_REQUEST_SLI) {
- // No output
- _callback->Pop(frame.TimeStamp());
- }
+ _callback->OnDecoderImplementationName(decoder_->ImplementationName());
+ if (ret < WEBRTC_VIDEO_CODEC_OK) {
+ RTC_LOG(LS_WARNING) << "Failed to decode frame with timestamp "
+ << frame.TimeStamp() << ", error code: " << ret;
+ _callback->Pop(frame.TimeStamp());
return ret;
+ } else if (ret == WEBRTC_VIDEO_CODEC_NO_OUTPUT ||
+ ret == WEBRTC_VIDEO_CODEC_REQUEST_SLI) {
+ // No output
+ _callback->Pop(frame.TimeStamp());
+ }
+ return ret;
}
int32_t VCMGenericDecoder::RegisterDecodeCompleteCallback(
diff --git a/modules/video_coding/generic_decoder.h b/modules/video_coding/generic_decoder.h
index 8137b20..17d2897 100644
--- a/modules/video_coding/generic_decoder.h
+++ b/modules/video_coding/generic_decoder.h
@@ -81,20 +81,20 @@
~VCMGenericDecoder();
/**
- * Initialize the decoder with the information from the VideoCodec
- */
+ * Initialize the decoder with the information from the VideoCodec
+ */
int32_t InitDecode(const VideoCodec* settings, int32_t numberOfCores);
/**
- * Decode to a raw I420 frame,
- *
- * inputVideoBuffer reference to encoded video frame
- */
+ * Decode to a raw I420 frame,
+ *
+ * inputVideoBuffer reference to encoded video frame
+ */
int32_t Decode(const VCMEncodedFrame& inputFrame, int64_t nowMs);
/**
- * Set decode callback. Deregistering while decoding is illegal.
- */
+ * Set decode callback. Deregistering while decoding is illegal.
+ */
int32_t RegisterDecodeCompleteCallback(VCMDecodedFrameCallback* callback);
bool External() const;
diff --git a/modules/video_coding/generic_encoder.cc b/modules/video_coding/generic_encoder.cc
index 202cc86..7eb35e7 100644
--- a/modules/video_coding/generic_encoder.cc
+++ b/modules/video_coding/generic_encoder.cc
@@ -1,12 +1,12 @@
/*
-* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
-*
-* Use of this source code is governed by a BSD-style license
-* that can be found in the LICENSE file in the root of the source
-* tree. An additional intellectual property rights grant can be found
-* in the file PATENTS. All contributing project authors may
-* be found in the AUTHORS file in the root of the source tree.
-*/
+ * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
#include "modules/video_coding/generic_encoder.h"
@@ -70,8 +70,8 @@
if (encoder_->InitEncode(settings, number_of_cores, max_payload_size) != 0) {
RTC_LOG(LS_ERROR) << "Failed to initialize the encoder associated with "
"codec type: "
- << CodecTypeToPayloadString(settings->codecType)
- << " (" << settings->codecType <<")";
+ << CodecTypeToPayloadString(settings->codecType) << " ("
+ << settings->codecType << ")";
return -1;
}
vcm_encoded_frame_callback_->Reset();
@@ -151,9 +151,9 @@
// VideoSendStreamTest.VideoSendStreamStopSetEncoderRateToZero, set
// internal_source to true and use FakeEncoder. And the latter will
// happily encode this 1x1 frame and pass it on down the pipeline.
- return encoder_->Encode(VideoFrame(I420Buffer::Create(1, 1),
- kVideoRotation_0, 0),
- NULL, &frame_types);
+ return encoder_->Encode(
+ VideoFrame(I420Buffer::Create(1, 1), kVideoRotation_0, 0), NULL,
+ &frame_types);
return 0;
}
diff --git a/modules/video_coding/h264_sps_pps_tracker_unittest.cc b/modules/video_coding/h264_sps_pps_tracker_unittest.cc
index f88992f..0ad85ac 100644
--- a/modules/video_coding/h264_sps_pps_tracker_unittest.cc
+++ b/modules/video_coding/h264_sps_pps_tracker_unittest.cc
@@ -12,9 +12,9 @@
#include <vector>
+#include "common_video/h264/h264_common.h"
#include "modules/video_coding/packet.h"
#include "test/gtest.h"
-#include "common_video/h264/h264_common.h"
namespace webrtc {
namespace video_coding {
diff --git a/modules/video_coding/include/video_codec_interface.h b/modules/video_coding/include/video_codec_interface.h
index d61a926..1b5e155 100644
--- a/modules/video_coding/include/video_codec_interface.h
+++ b/modules/video_coding/include/video_codec_interface.h
@@ -37,8 +37,8 @@
struct CodecSpecificInfoVP9 {
bool first_frame_in_picture; // First frame, increment picture_id.
- bool inter_pic_predicted; // This layer frame is dependent on previously
- // coded frame(s).
+ bool inter_pic_predicted; // This layer frame is dependent on previously
+ // coded frame(s).
bool flexible_mode;
bool ss_data_available;
bool non_ref_for_inter_layer_pred;
diff --git a/modules/video_coding/include/video_coding.h b/modules/video_coding/include/video_coding.h
index 61ce66a..e5c30eb 100644
--- a/modules/video_coding/include/video_coding.h
+++ b/modules/video_coding/include/video_coding.h
@@ -72,8 +72,8 @@
static VideoCodingModule* Create(Clock* clock, EventFactory* event_factory);
/*
- * Sender
- */
+ * Sender
+ */
// Registers a codec to be used for encoding. Calling this
// API multiple times overwrites any previously registered codecs.
@@ -182,8 +182,8 @@
virtual int32_t EnableFrameDropper(bool enable) = 0;
/*
- * Receiver
- */
+ * Receiver
+ */
// Register possible receive codecs, can be called multiple times for
// different codecs.
diff --git a/modules/video_coding/jitter_buffer.cc b/modules/video_coding/jitter_buffer.cc
index 6e688fd..5f45ece 100644
--- a/modules/video_coding/jitter_buffer.cc
+++ b/modules/video_coding/jitter_buffer.cc
@@ -761,9 +761,8 @@
} else {
incomplete_frames_.InsertFrame(frame);
// If NACKs are enabled, keyframes are triggered by |GetNackList|.
- if (nack_mode_ == kNoNack &&
- NonContinuousOrIncompleteDuration() >
- 90 * kMaxDiscontinuousFramesTime) {
+ if (nack_mode_ == kNoNack && NonContinuousOrIncompleteDuration() >
+ 90 * kMaxDiscontinuousFramesTime) {
return kFlushIndicator;
}
}
@@ -777,9 +776,8 @@
} else {
incomplete_frames_.InsertFrame(frame);
// If NACKs are enabled, keyframes are triggered by |GetNackList|.
- if (nack_mode_ == kNoNack &&
- NonContinuousOrIncompleteDuration() >
- 90 * kMaxDiscontinuousFramesTime) {
+ if (nack_mode_ == kNoNack && NonContinuousOrIncompleteDuration() >
+ 90 * kMaxDiscontinuousFramesTime) {
return kFlushIndicator;
}
}
diff --git a/modules/video_coding/jitter_buffer_unittest.cc b/modules/video_coding/jitter_buffer_unittest.cc
index a1447c0..71c17ea 100644
--- a/modules/video_coding/jitter_buffer_unittest.cc
+++ b/modules/video_coding/jitter_buffer_unittest.cc
@@ -214,8 +214,7 @@
clock_.reset(new SimulatedClock(0));
jitter_buffer_.reset(new VCMJitterBuffer(
clock_.get(),
- std::unique_ptr<EventWrapper>(event_factory_.CreateEvent()),
- this,
+ std::unique_ptr<EventWrapper>(event_factory_.CreateEvent()), this,
this));
jitter_buffer_->Start();
seq_num_ = 1234;
@@ -333,8 +332,8 @@
oldest_packet_to_nack_ = 250;
jitter_buffer_ = new VCMJitterBuffer(
clock_.get(),
- std::unique_ptr<EventWrapper>(event_factory_.CreateEvent()),
- this, this);
+ std::unique_ptr<EventWrapper>(event_factory_.CreateEvent()), this,
+ this);
stream_generator_ = new StreamGenerator(0, clock_->TimeInMilliseconds());
jitter_buffer_->Start();
jitter_buffer_->SetNackSettings(max_nack_list_size_, oldest_packet_to_nack_,
diff --git a/modules/video_coding/jitter_estimator.cc b/modules/video_coding/jitter_estimator.cc
index 41db158..5e754f1 100644
--- a/modules/video_coding/jitter_estimator.cc
+++ b/modules/video_coding/jitter_estimator.cc
@@ -139,10 +139,10 @@
// Update the variance anyway since we want to capture cases where we only
// get
// key frames.
- _varFrameSize = VCM_MAX(_phi * _varFrameSize +
- (1 - _phi) * (frameSizeBytes - avgFrameSize) *
- (frameSizeBytes - avgFrameSize),
- 1.0);
+ _varFrameSize = VCM_MAX(
+ _phi * _varFrameSize + (1 - _phi) * (frameSizeBytes - avgFrameSize) *
+ (frameSizeBytes - avgFrameSize),
+ 1.0);
}
// Update max frameSize estimate
diff --git a/modules/video_coding/media_opt_util.cc b/modules/video_coding/media_opt_util.cc
index e3083b0..aea35b0 100644
--- a/modules/video_coding/media_opt_util.cc
+++ b/modules/video_coding/media_opt_util.cc
@@ -19,8 +19,8 @@
#include "modules/include/module_common_types.h"
#include "modules/video_coding/codecs/vp8/include/vp8_common_types.h"
-#include "modules/video_coding/include/video_coding_defines.h"
#include "modules/video_coding/fec_rate_table.h"
+#include "modules/video_coding/include/video_coding_defines.h"
#include "modules/video_coding/nack_fec_tables.h"
namespace webrtc {
@@ -285,9 +285,8 @@
// Average number of packets per frame (source and fec):
const uint8_t avgTotPackets = static_cast<uint8_t>(
std::min(static_cast<float>(std::numeric_limits<uint8_t>::max()),
- 1.5f +
- static_cast<float>(bitRatePerFrame) * 1000.0f /
- static_cast<float>(8.0 * _maxPayloadSize)));
+ 1.5f + static_cast<float>(bitRatePerFrame) * 1000.0f /
+ static_cast<float>(8.0 * _maxPayloadSize)));
// FEC rate parameters: for P and I frame
uint8_t codeRateDelta = 0;
diff --git a/modules/video_coding/media_optimization.cc b/modules/video_coding/media_optimization.cc
index ea70f3f..5433edb 100644
--- a/modules/video_coding/media_optimization.cc
+++ b/modules/video_coding/media_optimization.cc
@@ -30,8 +30,7 @@
memset(incoming_frame_times_, -1, sizeof(incoming_frame_times_));
}
-MediaOptimization::~MediaOptimization(void) {
-}
+MediaOptimization::~MediaOptimization(void) {}
void MediaOptimization::Reset() {
rtc::CritScope lock(&crit_sect_);
diff --git a/modules/video_coding/nack_module.h b/modules/video_coding/nack_module.h
index 5640ea8..fc2f2a7 100644
--- a/modules/video_coding/nack_module.h
+++ b/modules/video_coding/nack_module.h
@@ -12,8 +12,8 @@
#define MODULES_VIDEO_CODING_NACK_MODULE_H_
#include <map>
-#include <vector>
#include <set>
+#include <vector>
#include "modules/include/module.h"
#include "modules/include/module_common_types.h"
diff --git a/modules/video_coding/rtp_frame_reference_finder.cc b/modules/video_coding/rtp_frame_reference_finder.cc
index 9401243..396935c 100644
--- a/modules/video_coding/rtp_frame_reference_finder.cc
+++ b/modules/video_coding/rtp_frame_reference_finder.cc
@@ -572,7 +572,7 @@
last_picture_id = Add<kPicIdLength>(last_picture_id, 1);
while (last_picture_id != picture_id) {
- gof_idx = (gof_idx + 1) % gof_size;
+ gof_idx = (gof_idx + 1) % gof_size;
RTC_CHECK(gof_idx < kMaxVp9FramesInGof);
size_t temporal_idx = info->gof->temporal_idx[gof_idx];
diff --git a/modules/video_coding/rtp_frame_reference_finder.h b/modules/video_coding/rtp_frame_reference_finder.h
index 00e638d..d7d1c12 100644
--- a/modules/video_coding/rtp_frame_reference_finder.h
+++ b/modules/video_coding/rtp_frame_reference_finder.h
@@ -12,9 +12,9 @@
#define MODULES_VIDEO_CODING_RTP_FRAME_REFERENCE_FINDER_H_
#include <array>
+#include <deque>
#include <map>
#include <memory>
-#include <deque>
#include <set>
#include <utility>
diff --git a/modules/video_coding/test/test_util.h b/modules/video_coding/test/test_util.h
index 404e49e..a38fc58 100644
--- a/modules/video_coding/test/test_util.h
+++ b/modules/video_coding/test/test_util.h
@@ -18,6 +18,7 @@
virtual ~NullEventFactory() {}
webrtc::EventWrapper* CreateEvent() override { return new NullEvent; }
+
private:
// Private class to avoid more dependencies on it in tests.
class NullEvent : public webrtc::EventWrapper {
diff --git a/modules/video_coding/utility/ivf_file_writer.cc b/modules/video_coding/utility/ivf_file_writer.cc
index 4b2cf3d..d9342f6 100644
--- a/modules/video_coding/utility/ivf_file_writer.cc
+++ b/modules/video_coding/utility/ivf_file_writer.cc
@@ -122,8 +122,7 @@
if (!WriteHeader())
return false;
- const char* codec_name =
- CodecTypeToPayloadString(codec_type_);
+ const char* codec_name = CodecTypeToPayloadString(codec_type_);
RTC_LOG(LS_WARNING) << "Created IVF file for codec data of type "
<< codec_name << " at resolution " << width_ << " x "
<< height_ << ", using "
diff --git a/modules/video_coding/utility/quality_scaler_unittest.cc b/modules/video_coding/utility/quality_scaler_unittest.cc
index 58a381c..b17062d 100644
--- a/modules/video_coding/utility/quality_scaler_unittest.cc
+++ b/modules/video_coding/utility/quality_scaler_unittest.cc
@@ -28,16 +28,16 @@
static const size_t kDefaultTimeoutMs = 150;
} // namespace
-#define DO_SYNC(q, block) do { \
- rtc::Event event(false, false); \
- q->PostTask([this, &event] { \
- block; \
- event.Set(); \
- }); \
- RTC_CHECK(event.Wait(1000)); \
+#define DO_SYNC(q, block) \
+ do { \
+ rtc::Event event(false, false); \
+ q->PostTask([this, &event] { \
+ block; \
+ event.Set(); \
+ }); \
+ RTC_CHECK(event.Wait(1000)); \
} while (0)
-
class MockAdaptationObserver : public AdaptationObserverInterface {
public:
MockAdaptationObserver() : event(false, false) {}
@@ -87,7 +87,7 @@
}
~QualityScalerTest() {
- DO_SYNC(q_, {qs_.reset(nullptr);});
+ DO_SYNC(q_, { qs_.reset(nullptr); });
}
void TriggerScale(ScaleDirection scale_direction) {
diff --git a/modules/video_coding/utility/simulcast_rate_allocator_unittest.cc b/modules/video_coding/utility/simulcast_rate_allocator_unittest.cc
index f8c83d3..345fdcb 100644
--- a/modules/video_coding/utility/simulcast_rate_allocator_unittest.cc
+++ b/modules/video_coding/utility/simulcast_rate_allocator_unittest.cc
@@ -75,8 +75,8 @@
if (layer_bitrate == 0) {
EXPECT_FALSE(actual.IsSpatialLayerUsed(i));
}
- EXPECT_EQ(expected[i] * 1000U, layer_bitrate) << "Mismatch at index "
- << i;
+ EXPECT_EQ(expected[i] * 1000U, layer_bitrate)
+ << "Mismatch at index " << i;
sum += layer_bitrate;
}
EXPECT_EQ(sum, actual.get_sum_bps());
diff --git a/modules/video_coding/video_codec_initializer.cc b/modules/video_coding/video_codec_initializer.cc
index 8be04cd..7ef6cfe 100644
--- a/modules/video_coding/video_codec_initializer.cc
+++ b/modules/video_coding/video_codec_initializer.cc
@@ -33,8 +33,7 @@
if (config.codec_type == kVideoCodecMultiplex) {
VideoEncoderConfig associated_config = config.Copy();
associated_config.codec_type = kVideoCodecVP9;
- if (!SetupCodec(associated_config, streams, codec,
- bitrate_allocator)) {
+ if (!SetupCodec(associated_config, streams, codec, bitrate_allocator)) {
RTC_LOG(LS_ERROR) << "Failed to create stereo encoder configuration.";
return false;
}
@@ -42,8 +41,7 @@
return true;
}
- *codec =
- VideoEncoderConfigToVideoCodec(config, streams);
+ *codec = VideoEncoderConfigToVideoCodec(config, streams);
*bitrate_allocator = CreateBitrateAllocator(*codec);
return true;
diff --git a/modules/video_coding/video_codec_initializer_unittest.cc b/modules/video_coding/video_codec_initializer_unittest.cc
index 104b149..4edf31a 100644
--- a/modules/video_coding/video_codec_initializer_unittest.cc
+++ b/modules/video_coding/video_codec_initializer_unittest.cc
@@ -76,8 +76,7 @@
codec_out_ = VideoCodec();
bitrate_allocator_out_.reset();
temporal_layers_.clear();
- if (!VideoCodecInitializer::SetupCodec(config_, streams_,
- &codec_out_,
+ if (!VideoCodecInitializer::SetupCodec(config_, streams_, &codec_out_,
&bitrate_allocator_out_)) {
return false;
}
diff --git a/modules/video_coding/video_coding_impl.cc b/modules/video_coding/video_coding_impl.cc
index a0a3a7f..1127b0f 100644
--- a/modules/video_coding/video_coding_impl.cc
+++ b/modules/video_coding/video_coding_impl.cc
@@ -100,9 +100,7 @@
return receiver_time;
}
- void Process() override {
- receiver_.Process();
- }
+ void Process() override { receiver_.Process(); }
int32_t RegisterSendCodec(const VideoCodec* sendCodec,
uint32_t numberOfCores,
@@ -125,8 +123,7 @@
int32_t RegisterExternalEncoder(VideoEncoder* externalEncoder,
uint8_t /* payloadType */,
bool internalSource) override {
- sender_.RegisterExternalEncoder(externalEncoder,
- internalSource);
+ sender_.RegisterExternalEncoder(externalEncoder, internalSource);
return 0;
}
diff --git a/modules/video_coding/video_coding_impl.h b/modules/video_coding/video_coding_impl.h
index 4f96ad9..0f3903f 100644
--- a/modules/video_coding/video_coding_impl.h
+++ b/modules/video_coding/video_coding_impl.h
@@ -63,8 +63,7 @@
public:
typedef VideoCodingModule::SenderNackMode SenderNackMode;
- VideoSender(Clock* clock,
- EncodedImageCallback* post_encode_callback);
+ VideoSender(Clock* clock, EncodedImageCallback* post_encode_callback);
~VideoSender();
diff --git a/modules/video_coding/video_receiver.cc b/modules/video_coding/video_receiver.cc
index 25b2908..2ab6987 100644
--- a/modules/video_coding/video_receiver.cc
+++ b/modules/video_coding/video_receiver.cc
@@ -156,8 +156,7 @@
case kProtectionNackFEC: {
RTC_DCHECK(enable);
- _receiver.SetNackMode(kNack,
- media_optimization::kLowRttNackMs,
+ _receiver.SetNackMode(kNack, media_optimization::kLowRttNackMs,
media_optimization::kMaxRttDelayThreshold);
_receiver.SetDecodeErrorMode(kNoErrors);
break;
diff --git a/modules/video_coding/video_receiver_unittest.cc b/modules/video_coding/video_receiver_unittest.cc
index feca48e..2855f7a 100644
--- a/modules/video_coding/video_receiver_unittest.cc
+++ b/modules/video_coding/video_receiver_unittest.cc
@@ -76,7 +76,7 @@
EXPECT_EQ(0, receiver_->IncomingPacket(payload, length, *header));
++header->header.sequenceNumber;
EXPECT_CALL(packet_request_callback_, ResendPackets(_, _)).Times(0);
- receiver_->Process();;
+ receiver_->Process();
EXPECT_CALL(decoder_, Decode(_, _, _, _)).Times(1);
EXPECT_EQ(0, receiver_->Decode(100));
}
diff --git a/modules/video_coding/video_sender.cc b/modules/video_coding/video_sender.cc
index ec24a97..f10822d 100644
--- a/modules/video_coding/video_sender.cc
+++ b/modules/video_coding/video_sender.cc
@@ -8,7 +8,6 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-
#include <algorithm> // std::max
#include "common_types.h" // NOLINT(build/include)
@@ -137,8 +136,7 @@
}
return;
}
- _codecDataBase.RegisterExternalEncoder(externalEncoder,
- internalSource);
+ _codecDataBase.RegisterExternalEncoder(externalEncoder, internalSource);
}
EncoderParameters VideoSender::UpdateEncoderParameters(
@@ -291,8 +289,7 @@
RTC_LOG(LS_ERROR) << "Frame conversion failed, dropping frame.";
return VCM_PARAMETER_ERROR;
}
- converted_frame = VideoFrame(converted_buffer,
- converted_frame.timestamp(),
+ converted_frame = VideoFrame(converted_buffer, converted_frame.timestamp(),
converted_frame.render_time_ms(),
converted_frame.rotation());
}
diff --git a/modules/video_coding/video_sender_unittest.cc b/modules/video_coding/video_sender_unittest.cc
index 877eb99..7321a08 100644
--- a/modules/video_coding/video_sender_unittest.cc
+++ b/modules/video_coding/video_sender_unittest.cc
@@ -19,8 +19,8 @@
#include "modules/video_coding/include/mock/mock_vcm_callbacks.h"
#include "modules/video_coding/include/mock/mock_video_codec_interface.h"
#include "modules/video_coding/include/video_coding.h"
-#include "modules/video_coding/video_coding_impl.h"
#include "modules/video_coding/utility/default_video_bitrate_allocator.h"
+#include "modules/video_coding/video_coding_impl.h"
#include "system_wrappers/include/clock.h"
#include "test/frame_generator.h"
#include "test/gtest.h"
@@ -228,17 +228,16 @@
ExpectEncodeWithFrameTypes(stream, false);
}
- void ExpectInitialKeyFrames() {
- ExpectEncodeWithFrameTypes(-1, true);
- }
+ void ExpectInitialKeyFrames() { ExpectEncodeWithFrameTypes(-1, true); }
void ExpectEncodeWithFrameTypes(int intra_request_stream, bool first_frame) {
if (intra_request_stream == -1) {
// No intra request expected, keyframes on first frame.
FrameType frame_type = first_frame ? kVideoFrameKey : kVideoFrameDelta;
- EXPECT_CALL(encoder_,
- Encode(_, _, Pointee(ElementsAre(frame_type, frame_type,
- frame_type))))
+ EXPECT_CALL(
+ encoder_,
+ Encode(_, _,
+ Pointee(ElementsAre(frame_type, frame_type, frame_type))))
.Times(1)
.WillRepeatedly(Return(0));
return;
@@ -248,9 +247,10 @@
ASSERT_LT(intra_request_stream, kNumberOfStreams);
std::vector<FrameType> frame_types(kNumberOfStreams, kVideoFrameDelta);
frame_types[intra_request_stream] = kVideoFrameKey;
- EXPECT_CALL(encoder_,
- Encode(_, _, Pointee(ElementsAreArray(&frame_types[0],
- frame_types.size()))))
+ EXPECT_CALL(
+ encoder_,
+ Encode(_, _,
+ Pointee(ElementsAreArray(&frame_types[0], frame_types.size()))))
.Times(1)
.WillRepeatedly(Return(0));
}
diff --git a/modules/video_processing/test/denoiser_test.cc b/modules/video_processing/test/denoiser_test.cc
index 601ae0e..327b16e 100644
--- a/modules/video_processing/test/denoiser_test.cc
+++ b/modules/video_processing/test/denoiser_test.cc
@@ -14,8 +14,8 @@
#include "common_video/include/i420_buffer_pool.h"
#include "modules/video_processing/video_denoiser.h"
-#include "test/gtest.h"
#include "test/frame_utils.h"
+#include "test/gtest.h"
#include "test/testsupport/fileutils.h"
namespace webrtc {
diff --git a/modules/video_processing/util/denoiser_filter_sse2.cc b/modules/video_processing/util/denoiser_filter_sse2.cc
index 83b7e54..49d2548 100644
--- a/modules/video_processing/util/denoiser_filter_sse2.cc
+++ b/modules/video_processing/util/denoiser_filter_sse2.cc
@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include <emmintrin.h>
#include "modules/video_processing/util/denoiser_filter_sse2.h"
+#include <emmintrin.h>
namespace webrtc {
diff --git a/modules/video_processing/util/skin_detection.cc b/modules/video_processing/util/skin_detection.cc
index 8eaa2c5..c711a90 100644
--- a/modules/video_processing/util/skin_detection.cc
+++ b/modules/video_processing/util/skin_detection.cc
@@ -16,11 +16,14 @@
namespace webrtc {
// Fixed-point skin color model parameters.
-static const int skin_mean[5][2] = {
- {7463, 9614}, {6400, 10240}, {7040, 10240}, {8320, 9280}, {6800, 9614}};
+static const int skin_mean[5][2] = {{7463, 9614},
+ {6400, 10240},
+ {7040, 10240},
+ {8320, 9280},
+ {6800, 9614}};
static const int skin_inv_cov[4] = {4107, 1663, 1663, 2157}; // q16
-static const int skin_threshold[6] = {1570636, 1400000, 800000, 800000, 800000,
- 800000}; // q18
+static const int skin_threshold[6] = {1570636, 1400000, 800000,
+ 800000, 800000, 800000}; // q18
// Thresholds on luminance.
static const int y_low = 40;
@@ -39,10 +42,9 @@
const int cb_diff_q2 = (cb_diff_q12 + (1 << 9)) >> 10;
const int cbcr_diff_q2 = (cbcr_diff_q12 + (1 << 9)) >> 10;
const int cr_diff_q2 = (cr_diff_q12 + (1 << 9)) >> 10;
- const int skin_diff = skin_inv_cov[0] * cb_diff_q2 +
- skin_inv_cov[1] * cbcr_diff_q2 +
- skin_inv_cov[2] * cbcr_diff_q2 +
- skin_inv_cov[3] * cr_diff_q2;
+ const int skin_diff =
+ skin_inv_cov[0] * cb_diff_q2 + skin_inv_cov[1] * cbcr_diff_q2 +
+ skin_inv_cov[2] * cbcr_diff_q2 + skin_inv_cov[3] * cr_diff_q2;
return skin_diff;
}
diff --git a/modules/video_processing/util/skin_detection.h b/modules/video_processing/util/skin_detection.h
old mode 100755
new mode 100644
diff --git a/modules/video_processing/video_denoiser.cc b/modules/video_processing/video_denoiser.cc
index a87f249..cf262f0 100644
--- a/modules/video_processing/video_denoiser.cc
+++ b/modules/video_processing/video_denoiser.cc
@@ -31,10 +31,14 @@
const std::unique_ptr<uint8_t[]>& moving_edge_red,
const std::unique_ptr<uint8_t[]>& x_density,
const std::unique_ptr<uint8_t[]>& y_density,
- const uint8_t* u_src, int stride_u_src,
- const uint8_t* v_src, int stride_v_src,
- uint8_t* u_dst, int stride_u_dst,
- uint8_t* v_dst, int stride_v_dst,
+ const uint8_t* u_src,
+ int stride_u_src,
+ const uint8_t* v_src,
+ int stride_v_src,
+ uint8_t* u_dst,
+ int stride_u_dst,
+ uint8_t* v_dst,
+ int stride_v_dst,
int mb_rows_,
int mb_cols_) {
for (int mb_row = 0; mb_row < mb_rows_; ++mb_row) {
@@ -323,20 +327,17 @@
CopyLumaOnMargin(y_src, stride_y_src, y_dst, stride_y_dst);
// Copy u/v planes.
- libyuv::CopyPlane(frame->DataU(), frame->StrideU(),
- dst->MutableDataU(), dst->StrideU(),
- (width_ + 1) >> 1, (height_ + 1) >> 1);
- libyuv::CopyPlane(frame->DataV(), frame->StrideV(),
- dst->MutableDataV(), dst->StrideV(),
- (width_ + 1) >> 1, (height_ + 1) >> 1);
+ libyuv::CopyPlane(frame->DataU(), frame->StrideU(), dst->MutableDataU(),
+ dst->StrideU(), (width_ + 1) >> 1, (height_ + 1) >> 1);
+ libyuv::CopyPlane(frame->DataV(), frame->StrideV(), dst->MutableDataV(),
+ dst->StrideV(), (width_ + 1) >> 1, (height_ + 1) >> 1);
#if DISPLAY || DISPLAYNEON
// Show rectangular region
ShowRect(filter_, moving_edge_, moving_object_, x_density_, y_density_,
frame->DataU(), frame->StrideU(), frame->DataV(), frame->StrideV(),
- dst->MutableDataU(), dst->StrideU(),
- dst->MutableDataV(), dst->StrideV(),
- mb_rows_, mb_cols_);
+ dst->MutableDataU(), dst->StrideU(), dst->MutableDataV(),
+ dst->StrideV(), mb_rows_, mb_cols_);
#endif
prev_buffer_ = dst;
return dst;