Reformat the WebRTC code base
Running clang-format with chromium's style guide. The goal is n-fold: * providing consistency and readability (that's what code guidelines are for) * preventing noise with presubmit checks and git cl format * building on the previous point: making it easier to automatically fix format issues * you name it Please consider using git-hyper-blame to ignore this commit. Bug: webrtc:9340 Change-Id: I694567c4cdf8cee2860958cfe82bfaf25848bb87 Reviewed-on: https://webrtc-review.googlesource.com/81185 Reviewed-by: Patrik Höglund <phoglund@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23660}
This commit is contained in:
@ -52,7 +52,8 @@ class NetEqIlbcQualityTest : public NetEqQualityTest {
|
||||
|
||||
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;
|
||||
|
||||
@ -30,8 +30,11 @@ class NetEqIsacQualityTest : public NetEqQualityTest {
|
||||
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 @@ NetEqIsacQualityTest::NetEqIsacQualityTest()
|
||||
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 @@ void NetEqIsacQualityTest::TearDown() {
|
||||
|
||||
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 @@ int NetEqIsacQualityTest::EncodeBlock(int16_t* in_data,
|
||||
// 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;
|
||||
|
||||
@ -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 @@ static const int kOpusSamplingKhz = 48;
|
||||
|
||||
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 @@ class NetEqOpusQualityTest : public NetEqQualityTest {
|
||||
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 @@ void NetEqOpusQualityTest::SetUp() {
|
||||
}
|
||||
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 @@ void NetEqOpusQualityTest::TearDown() {
|
||||
|
||||
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;
|
||||
|
||||
@ -52,7 +52,8 @@ class NetEqPcmuQualityTest : public NetEqQualityTest {
|
||||
|
||||
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;
|
||||
|
||||
@ -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 @@ TEST(NetEqPerformanceTest, Run) {
|
||||
: 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, Run) {
|
||||
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 @@ TEST(NetEqPerformanceTest, RunClean) {
|
||||
: 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);
|
||||
}
|
||||
|
||||
@ -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 @@ int main(int argc, char* argv[]) {
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user