Reformat existing code. There should be no functional effects.
This includes changes like:
* Attempt to break lines at better positions
* Use "override" in more places, don't use "virtual" with it
* Use {} where the body is more than one line
* Make declaration and definition arg names match
* Eliminate unused code
* EXPECT_EQ(expected, actual) (but use (actual, expected) for e.g. _GT)
* Correct #include order
* Use anonymous namespaces in preference to "static" for file-scoping
* Eliminate unnecessary casts
* Update reference code in comments of ARM assembly sources to match actual current C code
* Fix indenting to be more style-guide compliant
* Use arraysize() in more places
* Use bool instead of int for "boolean" values (0/1)
* Shorten and simplify code
* Spaces around operators
* 80 column limit
* Use const more consistently
* Space goes after '*' in type name, not before
* Remove unnecessary return values
* Use "(var == const)", not "(const == var)"
* Spelling
* Prefer true, typed constants to "enum hack" constants
* Avoid "virtual" on non-overridden functions
* ASSERT(x == y) -> ASSERT_EQ(y, x)
BUG=none
R=andrew@webrtc.org, asapersson@webrtc.org, henrika@webrtc.org, juberti@webrtc.org, kjellander@webrtc.org, kwiberg@webrtc.org
Review URL: https://codereview.webrtc.org/1172163004
Cr-Commit-Position: refs/heads/master@{#9420}
diff --git a/webrtc/modules/audio_processing/aec/aec_resampler.c b/webrtc/modules/audio_processing/aec/aec_resampler.c
index cef262e..62a830b 100644
--- a/webrtc/modules/audio_processing/aec/aec_resampler.c
+++ b/webrtc/modules/audio_processing/aec/aec_resampler.c
@@ -74,7 +74,8 @@
float be, tnew;
int tn, mm;
- assert(!(size < 0 || size > 2 * FRAME_LEN));
+ assert(size >= 0);
+ assert(size <= 2 * FRAME_LEN);
assert(resampInst != NULL);
assert(inspeech != NULL);
assert(outspeech != NULL);
diff --git a/webrtc/modules/audio_processing/aec/echo_cancellation.c b/webrtc/modules/audio_processing/aec/echo_cancellation.c
index ec16aaf..a39fd2c 100644
--- a/webrtc/modules/audio_processing/aec/echo_cancellation.c
+++ b/webrtc/modules/audio_processing/aec/echo_cancellation.c
@@ -270,7 +270,7 @@
const float* farend,
int16_t nrOfSamples) {
Aec* aecpc = aecInst;
- int newNrOfSamples = (int)nrOfSamples;
+ int newNrOfSamples = nrOfSamples;
float new_farend[MAX_RESAMP_LEN];
const float* farend_ptr = farend;
diff --git a/webrtc/modules/audio_processing/agc/agc_audio_proc.h b/webrtc/modules/audio_processing/agc/agc_audio_proc.h
index 8c8fc31..e5eb390 100644
--- a/webrtc/modules/audio_processing/agc/agc_audio_proc.h
+++ b/webrtc/modules/audio_processing/agc/agc_audio_proc.h
@@ -37,7 +37,7 @@
private:
void PitchAnalysis(double* pitch_gains, double* pitch_lags_hz, int length);
- void SubframeCorrelation(double* corr, int lenght_corr, int subframe_index);
+ void SubframeCorrelation(double* corr, int length_corr, int subframe_index);
void GetLpcPolynomials(double* lpc, int length_lpc);
void FindFirstSpectralPeaks(double* f_peak, int length_f_peak);
void Rms(double* rms, int length_rms);
diff --git a/webrtc/modules/audio_processing/audio_buffer.cc b/webrtc/modules/audio_processing/audio_buffer.cc
index ec5e227..04dcaea 100644
--- a/webrtc/modules/audio_processing/audio_buffer.cc
+++ b/webrtc/modules/audio_processing/audio_buffer.cc
@@ -19,11 +19,9 @@
namespace webrtc {
namespace {
-enum {
- kSamplesPer16kHzChannel = 160,
- kSamplesPer32kHzChannel = 320,
- kSamplesPer48kHzChannel = 480
-};
+const int kSamplesPer16kHzChannel = 160;
+const int kSamplesPer32kHzChannel = 320;
+const int kSamplesPer48kHzChannel = 480;
bool HasKeyboardChannel(AudioProcessing::ChannelLayout layout) {
switch (layout) {
@@ -84,8 +82,7 @@
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_)),
+ num_split_frames_(rtc::CheckedDivExact(proc_num_frames_, num_bands_)),
mixed_low_pass_valid_(false),
reference_copied_(false),
activity_(AudioFrame::kVadUnknown),
@@ -399,7 +396,7 @@
// The resampler is only for supporting 48kHz to 16kHz in the reverse stream.
void AudioBuffer::DeinterleaveFrom(AudioFrame* frame) {
assert(frame->num_channels_ == num_input_channels_);
- assert(frame->samples_per_channel_ == input_num_frames_);
+ assert(frame->samples_per_channel_ == input_num_frames_);
InitForNewData();
// Initialized lazily because there's a different condition in CopyFrom.
if ((input_num_frames_ != proc_num_frames_) && !input_buffer_) {
diff --git a/webrtc/modules/audio_processing/audio_processing_impl.h b/webrtc/modules/audio_processing/audio_processing_impl.h
index dbc1f25..895294d 100644
--- a/webrtc/modules/audio_processing/audio_processing_impl.h
+++ b/webrtc/modules/audio_processing/audio_processing_impl.h
@@ -49,9 +49,7 @@
class AudioRate {
public:
- explicit AudioRate(int sample_rate_hz)
- : rate_(sample_rate_hz),
- samples_per_channel_(AudioProcessing::kChunkSizeMs * rate_ / 1000) {}
+ explicit AudioRate(int sample_rate_hz) { set(sample_rate_hz); }
virtual ~AudioRate() {}
void set(int rate) {
diff --git a/webrtc/modules/audio_processing/ns/ns_core.c b/webrtc/modules/audio_processing/ns/ns_core.c
index 1bd7af4..652f0fe 100644
--- a/webrtc/modules/audio_processing/ns/ns_core.c
+++ b/webrtc/modules/audio_processing/ns/ns_core.c
@@ -606,8 +606,8 @@
// Conservative smooth noise spectrum from pause frames.
avgPause += self->magnAvgPause[i];
}
- avgPause = avgPause / ((float)self->magnLen);
- avgMagn = avgMagn / ((float)self->magnLen);
+ avgPause /= self->magnLen;
+ avgMagn /= self->magnLen;
covMagnPause = 0.0;
varPause = 0.0;
@@ -619,9 +619,9 @@
(self->magnAvgPause[i] - avgPause) * (self->magnAvgPause[i] - avgPause);
varMagn += (magnIn[i] - avgMagn) * (magnIn[i] - avgMagn);
}
- covMagnPause = covMagnPause / ((float)self->magnLen);
- varPause = varPause / ((float)self->magnLen);
- varMagn = varMagn / ((float)self->magnLen);
+ covMagnPause /= self->magnLen;
+ varPause /= self->magnLen;
+ varMagn /= self->magnLen;
// Update of average magnitude spectrum.
self->featureData[6] += self->signalEnergy;
@@ -1099,7 +1099,7 @@
}
}
}
- signalEnergy = signalEnergy / ((float)self->magnLen);
+ signalEnergy /= self->magnLen;
self->signalEnergy = signalEnergy;
self->sumMagn = sumMagn;
@@ -1108,9 +1108,9 @@
// Compute simplified noise model during startup.
if (self->blockInd < END_STARTUP_SHORT) {
// Estimate White noise.
- self->whiteNoiseLevel += sumMagn / ((float)self->magnLen) * self->overdrive;
+ self->whiteNoiseLevel += sumMagn / self->magnLen * self->overdrive;
// Estimate Pink noise parameters.
- tmpFloat1 = sum_log_i_square * ((float)(self->magnLen - kStartBand));
+ tmpFloat1 = sum_log_i_square * (self->magnLen - kStartBand);
tmpFloat1 -= (sum_log_i * sum_log_i);
tmpFloat2 =
(sum_log_i_square * sum_log_magn - sum_log_i * sum_log_i_log_magn);
@@ -1121,7 +1121,7 @@
}
self->pinkNoiseNumerator += tmpFloat3;
tmpFloat2 = (sum_log_i * sum_log_magn);
- tmpFloat2 -= ((float)(self->magnLen - kStartBand)) * sum_log_i_log_magn;
+ tmpFloat2 -= (self->magnLen - kStartBand) * sum_log_i_log_magn;
tmpFloat3 = tmpFloat2 / tmpFloat1;
// Constrain the pink noise power to be in the interval [0, 1].
if (tmpFloat3 < 0.f) {
diff --git a/webrtc/modules/audio_processing/ns/nsx_core.c b/webrtc/modules/audio_processing/ns/nsx_core.c
index f6711b5..0f9894e 100644
--- a/webrtc/modules/audio_processing/ns/nsx_core.c
+++ b/webrtc/modules/audio_processing/ns/nsx_core.c
@@ -1215,7 +1215,8 @@
WebRtcNsx_AnalysisUpdate(inst, winData, speechFrame);
// Get input energy
- inst->energyIn = WebRtcSpl_Energy(winData, (int)inst->anaLen, &(inst->scaleEnergyIn));
+ inst->energyIn =
+ WebRtcSpl_Energy(winData, inst->anaLen, &inst->scaleEnergyIn);
// Reset zero input flag
inst->zeroInputSignal = 0;
@@ -1460,7 +1461,8 @@
if (inst->gainMap == 1 &&
inst->blockIndex > END_STARTUP_LONG &&
inst->energyIn > 0) {
- energyOut = WebRtcSpl_Energy(inst->real, (int)inst->anaLen, &scaleEnergyOut); // Q(-scaleEnergyOut)
+ // Q(-scaleEnergyOut)
+ energyOut = WebRtcSpl_Energy(inst->real, inst->anaLen, &scaleEnergyOut);
if (scaleEnergyOut == 0 && !(energyOut & 0x7f800000)) {
energyOut = WEBRTC_SPL_SHIFT_W32(energyOut, 8 + scaleEnergyOut
- inst->scaleEnergyIn);
diff --git a/webrtc/modules/audio_processing/splitting_filter_unittest.cc b/webrtc/modules/audio_processing/splitting_filter_unittest.cc
index 22b4ff1..0498cc6 100644
--- a/webrtc/modules/audio_processing/splitting_filter_unittest.cc
+++ b/webrtc/modules/audio_processing/splitting_filter_unittest.cc
@@ -20,10 +20,8 @@
namespace webrtc {
namespace {
-enum {
- kSamplesPer16kHzChannel = 160,
- kSamplesPer48kHzChannel = 480
-};
+const int kSamplesPer16kHzChannel = 160;
+const int kSamplesPer48kHzChannel = 480;
} // namespace