From 728d9037c016c01295177fa700fc7927f0bb80bb Mon Sep 17 00:00:00 2001 From: Peter Kasting Date: Thu, 11 Jun 2015 14:31:38 -0700 Subject: [PATCH] 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} --- .../app/webrtc/test/fakeaudiocapturemodule.cc | 8 +- .../test/fakeaudiocapturemodule_unittest.cc | 36 ++++----- .../audio_ring_buffer_unittest.cc | 6 +- webrtc/common_audio/blocker.h | 2 +- webrtc/common_audio/fft4g.c | 8 +- webrtc/common_audio/fft4g.h | 1 - .../common_audio/lapped_transform_unittest.cc | 8 +- webrtc/common_audio/real_fourier_unittest.cc | 24 +++--- webrtc/common_audio/resampler/resampler.cc | 6 +- .../common_audio/resampler/sinc_resampler.cc | 12 ++- .../common_audio/signal_processing/energy.c | 3 +- .../filter_ar_fast_q12_armv7.S | 3 + .../include/signal_processing_library.h | 9 +-- .../signal_processing/resample_fractional.c | 9 +-- .../signal_processing_unittest.cc | 9 ++- webrtc/common_audio/vad/vad_unittest.cc | 11 ++- .../audio_coding/codecs/g711/g711_interface.c | 7 -- .../codecs/g711/include/g711_interface.h | 17 ----- .../audio_coding/codecs/g711/test/testG711.cc | 25 +++--- .../audio_coding/codecs/g722/g722_interface.c | 8 +- .../codecs/g722/include/g722_interface.h | 2 +- .../audio_coding/codecs/g722/test/testG722.cc | 32 ++++---- .../audio_coding/codecs/ilbc/abs_quant_loop.c | 5 +- .../codecs/ilbc/audio_encoder_ilbc.cc | 9 +-- .../audio_coding/codecs/ilbc/cb_mem_energy.c | 2 +- .../codecs/ilbc/cb_mem_energy_augmentation.c | 2 +- .../codecs/ilbc/cb_mem_energy_augmentation.h | 2 +- .../codecs/ilbc/cb_mem_energy_calc.c | 2 +- .../codecs/ilbc/cb_mem_energy_calc.h | 2 +- .../audio_coding/codecs/ilbc/cb_search.c | 16 ++-- .../modules/audio_coding/codecs/ilbc/decode.c | 11 +-- .../codecs/ilbc/enhancer_interface.c | 8 +- .../audio_coding/codecs/ilbc/my_corr.c | 6 +- .../audio_coding/codecs/ilbc/my_corr.h | 6 +- .../audio_coding/codecs/ilbc/test/iLBC_test.c | 6 +- .../codecs/ilbc/test/iLBC_testLib.c | 14 ++-- .../audio_coding/codecs/ilbc/xcorr_coef.c | 8 +- .../codecs/isac/fix/interface/isacfix.h | 8 +- .../codecs/isac/fix/source/codec.h | 6 +- .../codecs/isac/fix/source/decode_plc.c | 14 ++-- .../codecs/isac/fix/source/entropy_coding.c | 22 ++---- .../codecs/isac/fix/source/isacfix.c | 34 ++++----- .../codecs/isac/fix/source/lattice.c | 3 +- .../codecs/isac/fix/source/lattice_armv7.S | 6 +- .../codecs/isac/fix/source/pitch_filter.c | 13 ---- .../codecs/isac/fix/test/isac_speed_test.cc | 8 +- .../codecs/isac/fix/test/test_iSACfixfloat.c | 3 +- .../isac/main/source/bandwidth_estimator.c | 6 +- .../isac/main/source/bandwidth_estimator.h | 6 +- .../codecs/isac/main/source/lpc_analysis.c | 4 +- .../codecs/opus/audio_encoder_opus.cc | 6 +- .../audio_coding/codecs/opus/opus_unittest.cc | 6 +- .../main/acm2/acm_receive_test.cc | 8 +- .../audio_coding/main/acm2/acm_receive_test.h | 4 +- .../main/acm2/audio_coding_module_impl.cc | 4 +- .../audio_coding/main/test/opus_test.cc | 4 +- .../neteq/decision_logic_normal.h | 3 +- webrtc/modules/audio_coding/neteq/expand.cc | 32 ++++---- webrtc/modules/audio_coding/neteq/expand.h | 8 +- webrtc/modules/audio_coding/neteq/merge.cc | 10 +-- .../neteq/neteq_external_decoder_unittest.cc | 2 +- .../modules/audio_coding/neteq/neteq_impl.cc | 13 ++-- .../audio_coding/neteq/packet_buffer.cc | 12 +-- .../audio_coding/neteq/preemptive_expand.h | 6 +- .../neteq/statistics_calculator.cc | 2 +- .../audio_coding/neteq/test/RTPencode.cc | 2 +- .../neteq/tools/constant_pcm_packet_source.cc | 2 +- .../neteq/tools/neteq_performance_test.cc | 4 +- .../audio_coding/neteq/tools/neteq_rtpplay.cc | 4 +- .../audio_device/android/audio_common.h | 1 - .../audio_device/audio_device_buffer.cc | 11 +-- .../test/audio_device_test_api.cc | 76 +++++++++---------- .../audio_device/test/func_test_manager.cc | 26 +++---- .../audio_device/test/func_test_manager.h | 75 +++++++++--------- .../audio_processing/aec/aec_resampler.c | 3 +- .../audio_processing/aec/echo_cancellation.c | 2 +- .../audio_processing/agc/agc_audio_proc.h | 2 +- .../modules/audio_processing/audio_buffer.cc | 13 ++-- .../audio_processing/audio_processing_impl.h | 4 +- webrtc/modules/audio_processing/ns/ns_core.c | 18 ++--- webrtc/modules/audio_processing/ns/nsx_core.c | 6 +- .../splitting_filter_unittest.cc | 6 +- .../modules/interface/module_common_types.h | 9 ++- .../utility/source/file_recorder_impl.cc | 13 +--- .../utility/source/file_recorder_impl.h | 7 +- .../video_coding/main/test/release_test.h | 2 +- .../system_wrappers/interface/aligned_array.h | 8 -- webrtc/test/fake_audio_device.cc | 3 +- webrtc/tools/agc/activity_metric.cc | 2 +- .../auto_test/standard/external_media_test.cc | 9 ++- 90 files changed, 416 insertions(+), 490 deletions(-) diff --git a/talk/app/webrtc/test/fakeaudiocapturemodule.cc b/talk/app/webrtc/test/fakeaudiocapturemodule.cc index e52b686bc2..47f17a1739 100644 --- a/talk/app/webrtc/test/fakeaudiocapturemodule.cc +++ b/talk/app/webrtc/test/fakeaudiocapturemodule.cc @@ -623,8 +623,8 @@ bool FakeAudioCaptureModule::Initialize() { void FakeAudioCaptureModule::SetSendBuffer(int value) { Sample* buffer_ptr = reinterpret_cast(send_buffer_); - const int buffer_size_in_samples = sizeof(send_buffer_) / - kNumberBytesPerSample; + const int buffer_size_in_samples = + sizeof(send_buffer_) / kNumberBytesPerSample; for (int i = 0; i < buffer_size_in_samples; ++i) { buffer_ptr[i] = value; } @@ -636,8 +636,8 @@ void FakeAudioCaptureModule::ResetRecBuffer() { bool FakeAudioCaptureModule::CheckRecBuffer(int value) { const Sample* buffer_ptr = reinterpret_cast(rec_buffer_); - const int buffer_size_in_samples = sizeof(rec_buffer_) / - kNumberBytesPerSample; + const int buffer_size_in_samples = + sizeof(rec_buffer_) / kNumberBytesPerSample; for (int i = 0; i < buffer_size_in_samples; ++i) { if (buffer_ptr[i] >= value) return true; } diff --git a/talk/app/webrtc/test/fakeaudiocapturemodule_unittest.cc b/talk/app/webrtc/test/fakeaudiocapturemodule_unittest.cc index 821b44caa4..56f1d070ed 100644 --- a/talk/app/webrtc/test/fakeaudiocapturemodule_unittest.cc +++ b/talk/app/webrtc/test/fakeaudiocapturemodule_unittest.cc @@ -55,16 +55,16 @@ class FakeAdmTest : public testing::Test, // Callbacks inherited from webrtc::AudioTransport. // ADM is pushing data. - virtual int32_t RecordedDataIsAvailable(const void* audioSamples, - const uint32_t nSamples, - const uint8_t nBytesPerSample, - const uint8_t nChannels, - const uint32_t samplesPerSec, - const uint32_t totalDelayMS, - const int32_t clockDrift, - const uint32_t currentMicLevel, - const bool keyPressed, - uint32_t& newMicLevel) { + int32_t RecordedDataIsAvailable(const void* audioSamples, + const uint32_t nSamples, + const uint8_t nBytesPerSample, + const uint8_t nChannels, + const uint32_t samplesPerSec, + const uint32_t totalDelayMS, + const int32_t clockDrift, + const uint32_t currentMicLevel, + const bool keyPressed, + uint32_t& newMicLevel) override { rec_buffer_bytes_ = nSamples * nBytesPerSample; if ((rec_buffer_bytes_ == 0) || (rec_buffer_bytes_ > FakeAudioCaptureModule::kNumberSamples * @@ -79,14 +79,14 @@ class FakeAdmTest : public testing::Test, } // ADM is pulling data. - virtual int32_t NeedMorePlayData(const uint32_t nSamples, - const uint8_t nBytesPerSample, - const uint8_t nChannels, - const uint32_t samplesPerSec, - void* audioSamples, - uint32_t& nSamplesOut, - int64_t* elapsed_time_ms, - int64_t* ntp_time_ms) { + int32_t NeedMorePlayData(const uint32_t nSamples, + const uint8_t nBytesPerSample, + const uint8_t nChannels, + const uint32_t samplesPerSec, + void* audioSamples, + uint32_t& nSamplesOut, + int64_t* elapsed_time_ms, + int64_t* ntp_time_ms) override { ++pull_iterations_; const uint32_t audio_buffer_size = nSamples * nBytesPerSample; const uint32_t bytes_out = RecordedDataReceived() ? diff --git a/webrtc/common_audio/audio_ring_buffer_unittest.cc b/webrtc/common_audio/audio_ring_buffer_unittest.cc index cc1922c69a..65d7136de1 100644 --- a/webrtc/common_audio/audio_ring_buffer_unittest.cc +++ b/webrtc/common_audio/audio_ring_buffer_unittest.cc @@ -48,12 +48,14 @@ void ReadAndWriteTest(const ChannelBuffer& input, } // Write and read the last bit. - if (input_pos < total_frames) + if (input_pos < total_frames) { buf.Write(input.Slice(slice.get(), static_cast(input_pos)), num_channels, total_frames - input_pos); - if (buf.ReadFramesAvailable()) + } + if (buf.ReadFramesAvailable()) { buf.Read(output->Slice(slice.get(), static_cast(output_pos)), num_channels, buf.ReadFramesAvailable()); + } EXPECT_EQ(0u, buf.ReadFramesAvailable()); } diff --git a/webrtc/common_audio/blocker.h b/webrtc/common_audio/blocker.h index fbd7973837..00f372dfd0 100644 --- a/webrtc/common_audio/blocker.h +++ b/webrtc/common_audio/blocker.h @@ -72,7 +72,7 @@ class Blocker { BlockerCallback* callback); void ProcessChunk(const float* const* input, - int num_frames, + int chunk_size, int num_input_channels, int num_output_channels, float* const* output); diff --git a/webrtc/common_audio/fft4g.c b/webrtc/common_audio/fft4g.c index ad5f383e69..24d45eb6b3 100644 --- a/webrtc/common_audio/fft4g.c +++ b/webrtc/common_audio/fft4g.c @@ -289,7 +289,9 @@ Appendix : static void makewt(int nw, int *ip, float *w); static void makect(int nc, int *ip, float *c); static void bitrv2(int n, int *ip, float *a); +#if 0 // Not used. static void bitrv2conj(int n, int *ip, float *a); +#endif static void cftfsub(int n, float *a, float *w); static void cftbsub(int n, float *a, float *w); static void cft1st(int n, float *a, float *w); @@ -302,6 +304,7 @@ static void dstsub(int n, float *a, int nc, float *c) #endif +#if 0 // Not used. void WebRtc_cdft(int n, int isgn, float *a, int *ip, float *w) { if (n > (ip[0] << 2)) { @@ -319,6 +322,7 @@ void WebRtc_cdft(int n, int isgn, float *a, int *ip, float *w) cftfsub(n, a, w); } } +#endif void WebRtc_rdft(int n, int isgn, float *a, int *ip, float *w) @@ -789,7 +793,7 @@ static void bitrv2(int n, int *ip, float *a) } } - +#if 0 // Not used. static void bitrv2conj(int n, int *ip, float *a) { int j, j1, k, k1, l, m, m2; @@ -897,7 +901,7 @@ static void bitrv2conj(int n, int *ip, float *a) } } } - +#endif static void cftfsub(int n, float *a, float *w) { diff --git a/webrtc/common_audio/fft4g.h b/webrtc/common_audio/fft4g.h index 90fefa0207..2fe4299ed9 100644 --- a/webrtc/common_audio/fft4g.h +++ b/webrtc/common_audio/fft4g.h @@ -17,7 +17,6 @@ extern "C" { // Refer to fft4g.c for documentation. void WebRtc_rdft(int n, int isgn, float *a, int *ip, float *w); -void WebRtc_cdft(int n, int isgn, float *a, int *ip, float *w); #if defined(__cplusplus) } diff --git a/webrtc/common_audio/lapped_transform_unittest.cc b/webrtc/common_audio/lapped_transform_unittest.cc index 3becfe1381..a21398c2c9 100644 --- a/webrtc/common_audio/lapped_transform_unittest.cc +++ b/webrtc/common_audio/lapped_transform_unittest.cc @@ -25,7 +25,9 @@ class NoopCallback : public webrtc::LappedTransform::Callback { NoopCallback() : block_num_(0) {} virtual void ProcessAudioBlock(const complex* const* in_block, - int in_channels, int frames, int out_channels, + int in_channels, + int frames, + int out_channels, complex* const* out_block) { CHECK_EQ(in_channels, out_channels); for (int i = 0; i < out_channels; ++i) { @@ -47,7 +49,9 @@ class FftCheckerCallback : public webrtc::LappedTransform::Callback { FftCheckerCallback() : block_num_(0) {} virtual void ProcessAudioBlock(const complex* const* in_block, - int in_channels, int frames, int out_channels, + int in_channels, + int frames, + int out_channels, complex* const* out_block) { CHECK_EQ(in_channels, out_channels); diff --git a/webrtc/common_audio/real_fourier_unittest.cc b/webrtc/common_audio/real_fourier_unittest.cc index a66344187e..526f762baa 100644 --- a/webrtc/common_audio/real_fourier_unittest.cc +++ b/webrtc/common_audio/real_fourier_unittest.cc @@ -27,31 +27,31 @@ TEST(RealFourierStaticsTest, AllocatorAlignment) { real = RealFourier::AllocRealBuffer(3); ASSERT_TRUE(real.get() != nullptr); int64_t ptr_value = reinterpret_cast(real.get()); - EXPECT_EQ(ptr_value % RealFourier::kFftBufferAlignment, 0); + EXPECT_EQ(0, ptr_value % RealFourier::kFftBufferAlignment); } { RealFourier::fft_cplx_scoper cplx; cplx = RealFourier::AllocCplxBuffer(3); ASSERT_TRUE(cplx.get() != nullptr); int64_t ptr_value = reinterpret_cast(cplx.get()); - EXPECT_EQ(ptr_value % RealFourier::kFftBufferAlignment, 0); + EXPECT_EQ(0, ptr_value % RealFourier::kFftBufferAlignment); } } TEST(RealFourierStaticsTest, OrderComputation) { - EXPECT_EQ(RealFourier::FftOrder(13), 4); - EXPECT_EQ(RealFourier::FftOrder(32), 5); - EXPECT_EQ(RealFourier::FftOrder(2), 1); - EXPECT_EQ(RealFourier::FftOrder(1), 0); + EXPECT_EQ(4, RealFourier::FftOrder(13)); + EXPECT_EQ(5, RealFourier::FftOrder(32)); + EXPECT_EQ(1, RealFourier::FftOrder(2)); + EXPECT_EQ(0, RealFourier::FftOrder(1)); } TEST(RealFourierStaticsTest, ComplexLengthComputation) { - EXPECT_EQ(RealFourier::ComplexLength(1), 2); - EXPECT_EQ(RealFourier::ComplexLength(2), 3); - EXPECT_EQ(RealFourier::ComplexLength(3), 5); - EXPECT_EQ(RealFourier::ComplexLength(4), 9); - EXPECT_EQ(RealFourier::ComplexLength(5), 17); - EXPECT_EQ(RealFourier::ComplexLength(7), 65); + EXPECT_EQ(2, RealFourier::ComplexLength(1)); + EXPECT_EQ(3, RealFourier::ComplexLength(2)); + EXPECT_EQ(5, RealFourier::ComplexLength(3)); + EXPECT_EQ(9, RealFourier::ComplexLength(4)); + EXPECT_EQ(17, RealFourier::ComplexLength(5)); + EXPECT_EQ(65, RealFourier::ComplexLength(7)); } template diff --git a/webrtc/common_audio/resampler/resampler.cc b/webrtc/common_audio/resampler/resampler.cc index f65742e276..bfaeffcb71 100644 --- a/webrtc/common_audio/resampler/resampler.cc +++ b/webrtc/common_audio/resampler/resampler.cc @@ -840,8 +840,7 @@ int Resampler::Push(const int16_t * samplesIn, int lengthIn, outLen = lengthIn / 3; free(tmp_mem); // 4:2 - WebRtcSpl_DownsampleBy2(tmp, outLen, tmp_2, - (int32_t*) state2_); + WebRtcSpl_DownsampleBy2(tmp, outLen, tmp_2, (int32_t*) state2_); outLen = outLen / 2; free(tmp); // 2:1 @@ -900,7 +899,8 @@ int Resampler::Push(const int16_t * samplesIn, int lengthIn, } lengthIn = (lengthIn * 4) / 11; - WebRtcSpl_DownsampleBy2(tmp, lengthIn, samplesOut, (int32_t*)state2_); + WebRtcSpl_DownsampleBy2(tmp, lengthIn, samplesOut, + (int32_t*)state2_); outLen = lengthIn / 2; free(tmp_mem); diff --git a/webrtc/common_audio/resampler/sinc_resampler.cc b/webrtc/common_audio/resampler/sinc_resampler.cc index 1c259c5337..373ef4c76c 100644 --- a/webrtc/common_audio/resampler/sinc_resampler.cc +++ b/webrtc/common_audio/resampler/sinc_resampler.cc @@ -86,8 +86,6 @@ #define _USE_MATH_DEFINES #include "webrtc/common_audio/resampler/sinc_resampler.h" -#include "webrtc/system_wrappers/interface/cpu_features_wrapper.h" -#include "webrtc/typedefs.h" #include #include @@ -95,9 +93,13 @@ #include -namespace webrtc { +#include "webrtc/system_wrappers/interface/cpu_features_wrapper.h" +#include "webrtc/typedefs.h" -static double SincScaleFactor(double io_ratio) { +namespace webrtc { +namespace { + +double SincScaleFactor(double io_ratio) { // |sinc_scale_factor| is basically the normalized cutoff frequency of the // low-pass filter. double sinc_scale_factor = io_ratio > 1.0 ? 1.0 / io_ratio : 1.0; @@ -113,6 +115,8 @@ static double SincScaleFactor(double io_ratio) { return sinc_scale_factor; } +} // namespace + // If we know the minimum architecture at compile time, avoid CPU detection. #if defined(WEBRTC_ARCH_X86_FAMILY) #if defined(__SSE2__) diff --git a/webrtc/common_audio/signal_processing/energy.c b/webrtc/common_audio/signal_processing/energy.c index 0611ad3e92..1d1ed62845 100644 --- a/webrtc/common_audio/signal_processing/energy.c +++ b/webrtc/common_audio/signal_processing/energy.c @@ -21,7 +21,8 @@ int32_t WebRtcSpl_Energy(int16_t* vector, int vector_length, int* scale_factor) { int32_t en = 0; int i; - int scaling = WebRtcSpl_GetScalingSquare(vector, vector_length, vector_length); + int scaling = + WebRtcSpl_GetScalingSquare(vector, vector_length, vector_length); int looptimes = vector_length; int16_t *vectorptr = vector; diff --git a/webrtc/common_audio/signal_processing/filter_ar_fast_q12_armv7.S b/webrtc/common_audio/signal_processing/filter_ar_fast_q12_armv7.S index ff60cc6198..b72396e1c3 100644 --- a/webrtc/common_audio/signal_processing/filter_ar_fast_q12_armv7.S +++ b/webrtc/common_audio/signal_processing/filter_ar_fast_q12_armv7.S @@ -160,6 +160,9 @@ END: @ int i = 0; @ int j = 0; @ +@ assert(data_length > 0); +@ assert(coefficients_length > 1); +@ @ for (i = 0; i < data_length - 1; i += 2) { @ int32_t output1 = 0; @ int32_t sum1 = 0; diff --git a/webrtc/common_audio/signal_processing/include/signal_processing_library.h b/webrtc/common_audio/signal_processing/include/signal_processing_library.h index 745715dcea..f6ab352d85 100644 --- a/webrtc/common_audio/signal_processing/include/signal_processing_library.h +++ b/webrtc/common_audio/signal_processing/include/signal_processing_library.h @@ -844,14 +844,11 @@ void WebRtcSpl_ResetResample8khzTo22khz(WebRtcSpl_State8khzTo22khz* state); * ******************************************************************/ -void WebRtcSpl_Resample48khzTo32khz(const int32_t* In, int32_t* Out, - int32_t K); +void WebRtcSpl_Resample48khzTo32khz(const int32_t* In, int32_t* Out, int32_t K); -void WebRtcSpl_Resample32khzTo24khz(const int32_t* In, int32_t* Out, - int32_t K); +void WebRtcSpl_Resample32khzTo24khz(const int32_t* In, int32_t* Out, int32_t K); -void WebRtcSpl_Resample44khzTo32khz(const int32_t* In, int32_t* Out, - int32_t K); +void WebRtcSpl_Resample44khzTo32khz(const int32_t* In, int32_t* Out, int32_t K); /******************************************************************* * resample_48khz.c diff --git a/webrtc/common_audio/signal_processing/resample_fractional.c b/webrtc/common_audio/signal_processing/resample_fractional.c index c7b5edbffb..b8fb22bdf6 100644 --- a/webrtc/common_audio/signal_processing/resample_fractional.c +++ b/webrtc/common_audio/signal_processing/resample_fractional.c @@ -41,8 +41,7 @@ static const int16_t kCoefficients44To32[4][9] = { // output: int32_t (shifted 15 positions to the left, + offset 16384) :: size 2 * K // K: number of blocks -void WebRtcSpl_Resample48khzTo32khz(const int32_t *In, int32_t *Out, - int32_t K) +void WebRtcSpl_Resample48khzTo32khz(const int32_t *In, int32_t *Out, int32_t K) { ///////////////////////////////////////////////////////////// // Filter operation: @@ -87,8 +86,7 @@ void WebRtcSpl_Resample48khzTo32khz(const int32_t *In, int32_t *Out, // output: int32_t (shifted 15 positions to the left, + offset 16384) :: size 3 * K // K: number of blocks -void WebRtcSpl_Resample32khzTo24khz(const int32_t *In, int32_t *Out, - int32_t K) +void WebRtcSpl_Resample32khzTo24khz(const int32_t *In, int32_t *Out, int32_t K) { ///////////////////////////////////////////////////////////// // Filter operation: @@ -196,8 +194,7 @@ static void WebRtcSpl_ResampDotProduct(const int32_t *in1, const int32_t *in2, // output: int32_t (shifted 15 positions to the left, + offset 16384) :: size 8 * K // K: number of blocks -void WebRtcSpl_Resample44khzTo32khz(const int32_t *In, int32_t *Out, - int32_t K) +void WebRtcSpl_Resample44khzTo32khz(const int32_t *In, int32_t *Out, int32_t K) { ///////////////////////////////////////////////////////////// // Filter operation: diff --git a/webrtc/common_audio/signal_processing/signal_processing_unittest.cc b/webrtc/common_audio/signal_processing/signal_processing_unittest.cc index 12b2fffbee..cc05dfa88f 100644 --- a/webrtc/common_audio/signal_processing/signal_processing_unittest.cc +++ b/webrtc/common_audio/signal_processing/signal_processing_unittest.cc @@ -495,10 +495,11 @@ TEST_F(SplTest, AutoCorrelationTest) { const int32_t expected[kVector16Size] = {302681398, 14223410, -121705063, -85221647, -17104971, 61806945, 6644603, -669329, 43}; - EXPECT_EQ(-1, WebRtcSpl_AutoCorrelation(vector16, - kVector16Size, kVector16Size + 1, vector32, &scale)); - EXPECT_EQ(kVector16Size, WebRtcSpl_AutoCorrelation(vector16, - kVector16Size, kVector16Size - 1, vector32, &scale)); + EXPECT_EQ(-1, WebRtcSpl_AutoCorrelation(vector16, kVector16Size, + kVector16Size + 1, vector32, &scale)); + EXPECT_EQ(kVector16Size, + WebRtcSpl_AutoCorrelation(vector16, kVector16Size, + kVector16Size - 1, vector32, &scale)); EXPECT_EQ(3, scale); for (int i = 0; i < kVector16Size; ++i) { EXPECT_EQ(expected[i], vector32[i]); diff --git a/webrtc/common_audio/vad/vad_unittest.cc b/webrtc/common_audio/vad/vad_unittest.cc index ce0c745ec4..2c3e803cb6 100644 --- a/webrtc/common_audio/vad/vad_unittest.cc +++ b/webrtc/common_audio/vad/vad_unittest.cc @@ -14,6 +14,7 @@ #include "testing/gtest/include/gtest/gtest.h" +#include "webrtc/base/arraysize.h" #include "webrtc/base/checks.h" #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" #include "webrtc/common_audio/vad/include/webrtc_vad.h" @@ -129,18 +130,16 @@ TEST_F(VadTest, ValidRatesFrameLengths) { // This test verifies valid and invalid rate/frame_length combinations. We // loop through some sampling rates and frame lengths from negative values to // values larger than possible. - const int kNumRates = 12; - const int kRates[kNumRates] = { + const int kRates[] = { -8000, -4000, 0, 4000, 8000, 8001, 15999, 16000, 32000, 48000, 48001, 96000 }; - const int kNumFrameLengths = 13; - const int kFrameLengths[kNumFrameLengths] = { + const int kFrameLengths[] = { -10, 0, 80, 81, 159, 160, 240, 320, 480, 640, 960, 1440, 2000 }; - for (int i = 0; i < kNumRates; i++) { - for (int j = 0; j < kNumFrameLengths; j++) { + for (size_t i = 0; i < arraysize(kRates); i++) { + for (size_t j = 0; j < arraysize(kFrameLengths); j++) { if (ValidRatesAndFrameLengths(kRates[i], kFrameLengths[j])) { EXPECT_EQ(0, WebRtcVad_ValidRateAndFrameLength(kRates[i], kFrameLengths[j])); diff --git a/webrtc/modules/audio_coding/codecs/g711/g711_interface.c b/webrtc/modules/audio_coding/codecs/g711/g711_interface.c index 809a70e883..b5795209f7 100644 --- a/webrtc/modules/audio_coding/codecs/g711/g711_interface.c +++ b/webrtc/modules/audio_coding/codecs/g711/g711_interface.c @@ -52,13 +52,6 @@ int16_t WebRtcG711_DecodeU(const uint8_t* encoded, return len; } -int WebRtcG711_DurationEst(const uint8_t* payload, - int payload_length_bytes) { - (void) payload; - /* G.711 is one byte per sample, so we can just return the number of bytes. */ - return payload_length_bytes; -} - int16_t WebRtcG711_Version(char* version, int16_t lenBytes) { strncpy(version, "2.0.0", lenBytes); return 0; diff --git a/webrtc/modules/audio_coding/codecs/g711/include/g711_interface.h b/webrtc/modules/audio_coding/codecs/g711/include/g711_interface.h index 0b798a6b9d..5c71e9879c 100644 --- a/webrtc/modules/audio_coding/codecs/g711/include/g711_interface.h +++ b/webrtc/modules/audio_coding/codecs/g711/include/g711_interface.h @@ -111,23 +111,6 @@ int16_t WebRtcG711_DecodeU(const uint8_t* encoded, int16_t* decoded, int16_t* speechType); -/**************************************************************************** - * WebRtcG711_DurationEst(...) - * - * This function estimates the duration of a G711 packet in samples. - * - * Input: - * - payload : Encoded data - * - payloadLengthBytes : Bytes in encoded vector - * - * Return value : The duration of the packet in samples, which is - * just payload_length_bytes, since G.711 uses one - * byte per sample. - */ - -int WebRtcG711_DurationEst(const uint8_t* payload, - int payload_length_bytes); - /********************************************************************** * WebRtcG711_Version(...) * diff --git a/webrtc/modules/audio_coding/codecs/g711/test/testG711.cc b/webrtc/modules/audio_coding/codecs/g711/test/testG711.cc index 9511df7915..49c671c5a0 100644 --- a/webrtc/modules/audio_coding/codecs/g711/test/testG711.cc +++ b/webrtc/modules/audio_coding/codecs/g711/test/testG711.cc @@ -24,18 +24,12 @@ #define CLOCKS_PER_SEC_G711 1000 /* function for reading audio data from PCM file */ -int readframe(int16_t* data, FILE* inp, int length) { - - short k, rlen, status = 0; - - rlen = (short) fread(data, sizeof(int16_t), length, inp); - if (rlen < length) { - for (k = rlen; k < length; k++) - data[k] = 0; - status = 1; - } - - return status; +bool readframe(int16_t* data, FILE* inp, int length) { + short rlen = (short) 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[]) { @@ -43,7 +37,8 @@ int main(int argc, char* argv[]) { FILE* inp; FILE* outp; FILE* bitp = NULL; - int framecnt, endfile; + int framecnt; + bool endfile; int16_t framelength = 80; @@ -122,8 +117,8 @@ int main(int argc, char* argv[]) { /* Initialize encoder and decoder */ framecnt = 0; - endfile = 0; - while (endfile == 0) { + endfile = false; + while (!endfile) { framecnt++; /* Read speech block */ endfile = readframe(shortdata, inp, framelength); diff --git a/webrtc/modules/audio_coding/codecs/g722/g722_interface.c b/webrtc/modules/audio_coding/codecs/g722/g722_interface.c index d06c588d0d..25d75ee6e9 100644 --- a/webrtc/modules/audio_coding/codecs/g722/g722_interface.c +++ b/webrtc/modules/audio_coding/codecs/g722/g722_interface.c @@ -52,8 +52,8 @@ int16_t WebRtcG722_Encode(G722EncInst *G722enc_inst, { unsigned char *codechar = (unsigned char*) encoded; // Encode the input speech vector - return WebRtc_g722_encode((G722EncoderState*) G722enc_inst, - codechar, speechIn, len); + return WebRtc_g722_encode((G722EncoderState*) G722enc_inst, codechar, + speechIn, len); } int16_t WebRtcG722_CreateDecoder(G722DecInst **G722dec_inst) @@ -93,8 +93,8 @@ int16_t WebRtcG722_Decode(G722DecInst *G722dec_inst, { // Decode the G.722 encoder stream *speechType=G722_WEBRTC_SPEECH; - return WebRtc_g722_decode((G722DecoderState*) G722dec_inst, - decoded, encoded, len); + return WebRtc_g722_decode((G722DecoderState*) G722dec_inst, decoded, + encoded, len); } int16_t WebRtcG722_Version(char *versionStr, short len) diff --git a/webrtc/modules/audio_coding/codecs/g722/include/g722_interface.h b/webrtc/modules/audio_coding/codecs/g722/include/g722_interface.h index 7fe11a7eb3..711b991d9c 100644 --- a/webrtc/modules/audio_coding/codecs/g722/include/g722_interface.h +++ b/webrtc/modules/audio_coding/codecs/g722/include/g722_interface.h @@ -91,7 +91,7 @@ int16_t WebRtcG722_FreeEncoder(G722EncInst *G722enc_inst); * Output: * - encoded : The encoded data vector * - * Return value : Length (in bytes) of coded data + * Return value : Length (in bytes) of coded data */ int16_t WebRtcG722_Encode(G722EncInst* G722enc_inst, diff --git a/webrtc/modules/audio_coding/codecs/g722/test/testG722.cc b/webrtc/modules/audio_coding/codecs/g722/test/testG722.cc index 9b2f54cc49..6a6f03c31f 100644 --- a/webrtc/modules/audio_coding/codecs/g722/test/testG722.cc +++ b/webrtc/modules/audio_coding/codecs/g722/test/testG722.cc @@ -29,18 +29,13 @@ typedef struct WebRtcG722EncInst G722EncInst; typedef struct WebRtcG722DecInst G722DecInst; /* function for reading audio data from PCM file */ -int readframe(int16_t *data, FILE *inp, int length) +bool readframe(int16_t *data, FILE *inp, int length) { - short k, rlen, status = 0; - - rlen = (short)fread(data, sizeof(int16_t), length, inp); - if (rlen < length) { - for (k = rlen; k < length; k++) - data[k] = 0; - status = 1; - } - - return status; + short rlen = (short)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[]) @@ -48,7 +43,8 @@ int main(int argc, char* argv[]) char inname[60], outbit[40], outname[40]; FILE *inp, *outbitp, *outp; - int framecnt, endfile; + int framecnt; + bool endfile; int16_t framelength = 160; G722EncInst *G722enc_inst; G722DecInst *G722dec_inst; @@ -116,8 +112,8 @@ int main(int argc, char* argv[]) /* Initialize encoder and decoder */ framecnt = 0; - endfile = 0; - while (endfile == 0) { + endfile = false; + while (!endfile) { framecnt++; /* Read speech block */ @@ -139,13 +135,13 @@ int main(int argc, char* argv[]) printf("Error in encoder/decoder\n"); } else { /* Write coded bits to file */ - if (fwrite(streamdata, sizeof(short), stream_len/2, - outbitp) != static_cast(stream_len/2)) { + if (fwrite(streamdata, sizeof(short), stream_len / 2, outbitp) != + static_cast(stream_len / 2)) { return -1; } /* Write coded speech to file */ - if (fwrite(decoded, sizeof(short), framelength, - outp) != static_cast(framelength)) { + if (fwrite(decoded, sizeof(short), framelength, outp) != + static_cast(framelength)) { return -1; } } diff --git a/webrtc/modules/audio_coding/codecs/ilbc/abs_quant_loop.c b/webrtc/modules/audio_coding/codecs/ilbc/abs_quant_loop.c index 1a18a1d27f..d26fb5d6c9 100644 --- a/webrtc/modules/audio_coding/codecs/ilbc/abs_quant_loop.c +++ b/webrtc/modules/audio_coding/codecs/ilbc/abs_quant_loop.c @@ -23,7 +23,7 @@ void WebRtcIlbcfix_AbsQuantLoop(int16_t *syntOutIN, int16_t *in_weightedIN, int16_t *weightDenumIN, int16_t *quantLenIN, int16_t *idxVecIN ) { - int n, k1, k2; + int k1, k2; int16_t index; int32_t toQW32; int32_t toQ32; @@ -36,8 +36,6 @@ void WebRtcIlbcfix_AbsQuantLoop(int16_t *syntOutIN, int16_t *in_weightedIN, int16_t *quantLen = quantLenIN; int16_t *idxVec = idxVecIN; - n=0; - for(k1=0;k1<2;k1++) { for(k2=0;k2 kMaxSamplesPerPacket) - return false; - return true; + return (frame_size_ms == 20 || frame_size_ms == 30 || frame_size_ms == 40 || + frame_size_ms == 60) && + (kSampleRateHz / 100 * (frame_size_ms / 10)) <= kMaxSamplesPerPacket; } AudioEncoderIlbc::AudioEncoderIlbc(const Config& config) diff --git a/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy.c b/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy.c index f8a09334f2..8dfde213de 100644 --- a/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy.c +++ b/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy.c @@ -35,7 +35,7 @@ void WebRtcIlbcfix_CbMemEnergy( int16_t *energyW16, /* (o) Energy in the CB vectors */ int16_t *energyShifts, /* (o) Shift value of the energy */ int16_t scale, /* (i) The scaling of all energy values */ - int16_t base_size /* (i) Index to where the energy values should be stored */ + int16_t base_size /* (i) Index to where energy values should be stored */ ) { int16_t *ppi, *ppo, *pp; int32_t energy, tmp32; diff --git a/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.c b/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.c index 7e6daf921c..789d2d49f2 100644 --- a/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.c +++ b/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.c @@ -23,7 +23,7 @@ void WebRtcIlbcfix_CbMemEnergyAugmentation( int16_t *interpSamples, /* (i) The interpolated samples */ int16_t *CBmem, /* (i) The CB memory */ int16_t scale, /* (i) The scaling of all energy values */ - int16_t base_size, /* (i) Index to where the energy values should be stored */ + int16_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 */ ){ diff --git a/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.h b/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.h index 6c181bd0e1..9b5f85c731 100644 --- a/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.h +++ b/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.h @@ -23,7 +23,7 @@ void WebRtcIlbcfix_CbMemEnergyAugmentation( int16_t *interpSamples, /* (i) The interpolated samples */ int16_t *CBmem, /* (i) The CB memory */ int16_t scale, /* (i) The scaling of all energy values */ - int16_t base_size, /* (i) Index to where the energy values should be stored */ + int16_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 */ ); diff --git a/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.c b/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.c index b1c0f8cc33..ec2dcaa8f3 100644 --- a/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.c +++ b/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.c @@ -29,7 +29,7 @@ void WebRtcIlbcfix_CbMemEnergyCalc( int16_t *energyW16, /* (o) Energy in the CB vectors */ int16_t *energyShifts, /* (o) Shift value of the energy */ int16_t scale, /* (i) The scaling of all energy values */ - int16_t base_size /* (i) Index to where the energy values should be stored */ + int16_t base_size /* (i) Index to where energy values should be stored */ ) { int16_t j,shft; diff --git a/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.h b/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.h index c7e1e54178..64282695a1 100644 --- a/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.h +++ b/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.h @@ -27,7 +27,7 @@ void WebRtcIlbcfix_CbMemEnergyCalc( int16_t *energyW16, /* (o) Energy in the CB vectors */ int16_t *energyShifts, /* (o) Shift value of the energy */ int16_t scale, /* (i) The scaling of all energy values */ - int16_t base_size /* (i) Index to where the energy values should be stored */ + int16_t base_size /* (i) Index to where energy values should be stored */ ); #endif diff --git a/webrtc/modules/audio_coding/codecs/ilbc/cb_search.c b/webrtc/modules/audio_coding/codecs/ilbc/cb_search.c index 2ee9f6c25a..bc601492e8 100644 --- a/webrtc/modules/audio_coding/codecs/ilbc/cb_search.c +++ b/webrtc/modules/audio_coding/codecs/ilbc/cb_search.c @@ -147,7 +147,8 @@ void WebRtcIlbcfix_CbSearch( /* Compute the CB vectors' energies for the second cb section (filtered cb) */ WebRtcIlbcfix_CbMemEnergyAugmentation(interpSamplesFilt, cbvectors, - scale, (int16_t)(base_size+20), energyW16, energyShifts); + scale, (int16_t)(base_size + 20), + energyW16, energyShifts); /* Compute the CB vectors' energies and store them in the vector * energyW16. Also the corresponding shift values are stored. The @@ -238,9 +239,12 @@ void WebRtcIlbcfix_CbSearch( if (lTarget==SUBL) { i=sInd; if (sInd<20) { - WebRtcIlbcfix_AugmentedCbCorr(target, cbvectors+lMem, + WebRtcIlbcfix_AugmentedCbCorr(target, cbvectors + lMem, interpSamplesFilt, cDot, - (int16_t)(sInd+20), (int16_t)(WEBRTC_SPL_MIN(39, (eInd+20))), scale); + (int16_t)(sInd + 20), + (int16_t)(WEBRTC_SPL_MIN(39, + (eInd + 20))), + scale); i=20; cDotPtr = &cDot[20 - sInd]; } else { @@ -250,14 +254,16 @@ void WebRtcIlbcfix_CbSearch( cb_vecPtr = cbvectors+lMem-20-i; /* Calculate the cross correlations (main part of the filtered CB) */ - WebRtcSpl_CrossCorrelation(cDotPtr, target, cb_vecPtr, lTarget, (int16_t)(eInd-i+1), scale, -1); + WebRtcSpl_CrossCorrelation(cDotPtr, target, cb_vecPtr, lTarget, + (int16_t)(eInd - i + 1), scale, -1); } else { cDotPtr = cDot; cb_vecPtr = cbvectors+lMem-lTarget-sInd; /* Calculate the cross correlations (main part of the filtered CB) */ - WebRtcSpl_CrossCorrelation(cDotPtr, target, cb_vecPtr, lTarget, (int16_t)(eInd-sInd+1), scale, -1); + WebRtcSpl_CrossCorrelation(cDotPtr, target, cb_vecPtr, lTarget, + (int16_t)(eInd - sInd + 1), scale, -1); } diff --git a/webrtc/modules/audio_coding/codecs/ilbc/decode.c b/webrtc/modules/audio_coding/codecs/ilbc/decode.c index 035460bb20..9918de201e 100644 --- a/webrtc/modules/audio_coding/codecs/ilbc/decode.c +++ b/webrtc/modules/audio_coding/codecs/ilbc/decode.c @@ -103,9 +103,10 @@ void WebRtcIlbcfix_DecodeImpl( WebRtcIlbcfix_DecodeResidual(iLBCdec_inst, iLBCbits_inst, decresidual, syntdenum); /* preparing the plc for a future loss! */ - WebRtcIlbcfix_DoThePlc( PLCresidual, PLClpc, 0, - decresidual, syntdenum + (LPC_FILTERORDER + 1)*(iLBCdec_inst->nsub - 1), - (int16_t)(iLBCdec_inst->last_lag), iLBCdec_inst); + WebRtcIlbcfix_DoThePlc( + PLCresidual, PLClpc, 0, decresidual, + syntdenum + (LPC_FILTERORDER + 1) * (iLBCdec_inst->nsub - 1), + (int16_t)(iLBCdec_inst->last_lag), iLBCdec_inst); /* Use the output from doThePLC */ WEBRTC_SPL_MEMCPY_W16(decresidual, PLCresidual, iLBCdec_inst->blockl); @@ -120,8 +121,8 @@ void WebRtcIlbcfix_DecodeImpl( /* packet loss conceal */ - WebRtcIlbcfix_DoThePlc( PLCresidual, PLClpc, 1, - decresidual, syntdenum, (int16_t)(iLBCdec_inst->last_lag), iLBCdec_inst); + WebRtcIlbcfix_DoThePlc(PLCresidual, PLClpc, 1, decresidual, syntdenum, + (int16_t)(iLBCdec_inst->last_lag), iLBCdec_inst); WEBRTC_SPL_MEMCPY_W16(decresidual, PLCresidual, iLBCdec_inst->blockl); diff --git a/webrtc/modules/audio_coding/codecs/ilbc/enhancer_interface.c b/webrtc/modules/audio_coding/codecs/ilbc/enhancer_interface.c index 262a564322..6dca0b7ba2 100644 --- a/webrtc/modules/audio_coding/codecs/ilbc/enhancer_interface.c +++ b/webrtc/modules/audio_coding/codecs/ilbc/enhancer_interface.c @@ -336,8 +336,8 @@ int WebRtcIlbcfix_EnhancerInterface( /* (o) Estimated lag in end of in[] */ enh_bufPtr1, synt, &iLBCdec_inst->old_syntdenum[ - (iLBCdec_inst->nsub-1)*(LPC_FILTERORDER+1)], - LPC_FILTERORDER+1, lag); + (iLBCdec_inst->nsub-1)*(LPC_FILTERORDER+1)], + LPC_FILTERORDER+1, lag); WEBRTC_SPL_MEMCPY_W16(&synt[-LPC_FILTERORDER], &synt[lag-LPC_FILTERORDER], LPC_FILTERORDER); @@ -347,8 +347,8 @@ int WebRtcIlbcfix_EnhancerInterface( /* (o) Estimated lag in end of in[] */ WebRtcSpl_FilterARFastQ12( enh_bufPtr1, synt, &iLBCdec_inst->old_syntdenum[ - (iLBCdec_inst->nsub-1)*(LPC_FILTERORDER+1)], - LPC_FILTERORDER+1, lag); + (iLBCdec_inst->nsub-1)*(LPC_FILTERORDER+1)], + LPC_FILTERORDER+1, lag); WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->syntMem, &synt[lag-LPC_FILTERORDER], LPC_FILTERORDER); diff --git a/webrtc/modules/audio_coding/codecs/ilbc/my_corr.c b/webrtc/modules/audio_coding/codecs/ilbc/my_corr.c index ec3cf20a62..ab08001fc5 100644 --- a/webrtc/modules/audio_coding/codecs/ilbc/my_corr.c +++ b/webrtc/modules/audio_coding/codecs/ilbc/my_corr.c @@ -23,10 +23,10 @@ *---------------------------------------------------------------*/ void WebRtcIlbcfix_MyCorr( - int32_t *corr, /* (o) correlation of seq1 and seq2 */ - int16_t *seq1, /* (i) first sequence */ + int32_t* corr, /* (o) correlation of seq1 and seq2 */ + const int16_t* seq1, /* (i) first sequence */ int16_t dim1, /* (i) dimension first seq1 */ - const int16_t *seq2, /* (i) second sequence */ + const int16_t* seq2, /* (i) second sequence */ int16_t dim2 /* (i) dimension seq2 */ ){ int16_t max, scale, loops; diff --git a/webrtc/modules/audio_coding/codecs/ilbc/my_corr.h b/webrtc/modules/audio_coding/codecs/ilbc/my_corr.h index ee66998313..a74dd1e7d4 100644 --- a/webrtc/modules/audio_coding/codecs/ilbc/my_corr.h +++ b/webrtc/modules/audio_coding/codecs/ilbc/my_corr.h @@ -26,10 +26,10 @@ *---------------------------------------------------------------*/ void WebRtcIlbcfix_MyCorr( - int32_t *corr, /* (o) correlation of seq1 and seq2 */ - int16_t *seq1, /* (i) first sequence */ + int32_t* corr, /* (o) correlation of seq1 and seq2 */ + const int16_t* seq1, /* (i) first sequence */ int16_t dim1, /* (i) dimension first seq1 */ - const int16_t *seq2, /* (i) second sequence */ + const int16_t* seq2, /* (i) second sequence */ int16_t dim2 /* (i) dimension seq2 */ ); diff --git a/webrtc/modules/audio_coding/codecs/ilbc/test/iLBC_test.c b/webrtc/modules/audio_coding/codecs/ilbc/test/iLBC_test.c index 9c42037b2e..6ee3df4db6 100644 --- a/webrtc/modules/audio_coding/codecs/ilbc/test/iLBC_test.c +++ b/webrtc/modules/audio_coding/codecs/ilbc/test/iLBC_test.c @@ -52,6 +52,7 @@ int main(int argc, char* argv[]) int blockcount = 0; int packetlosscount = 0; int frameLen; + size_t len_i16s; int16_t speechType; IlbcEncoderInstance *Enc_Inst; IlbcDecoderInstance *Dec_Inst; @@ -173,9 +174,8 @@ int main(int argc, char* argv[]) /* write byte file */ - if (fwrite(encoded_data, sizeof(int16_t), - ((len+1)/sizeof(int16_t)), efileid) != - (size_t)(((len+1)/sizeof(int16_t)))) { + len_i16s = (len + 1) / sizeof(int16_t); + if (fwrite(encoded_data, sizeof(int16_t), len_i16s, efileid) != len_i16s) { return -1; } diff --git a/webrtc/modules/audio_coding/codecs/ilbc/test/iLBC_testLib.c b/webrtc/modules/audio_coding/codecs/ilbc/test/iLBC_testLib.c index df37bec111..3dcda29c87 100644 --- a/webrtc/modules/audio_coding/codecs/ilbc/test/iLBC_testLib.c +++ b/webrtc/modules/audio_coding/codecs/ilbc/test/iLBC_testLib.c @@ -42,6 +42,7 @@ int main(int argc, char* argv[]) FILE *ifileid,*efileid,*ofileid, *chfileid; short encoded_data[55], data[240], speechType; short len, mode, pli; + size_t readlen; int blockcount = 0; IlbcEncoderInstance *Enc_Inst; @@ -125,19 +126,16 @@ int main(int argc, char* argv[]) /* loop over input blocks */ #ifdef SPLIT_10MS - while(fread(data, sizeof(short), 80, ifileid) == 80) { + readlen = 80; #else - while((short)fread(data,sizeof(short),(mode<<3),ifileid)==(mode<<3)) { + readlen = (size_t)(mode << 3); #endif + while(fread(data, sizeof(short), readlen, ifileid) == readlen) { blockcount++; /* encoding */ fprintf(stderr, "--- Encoding block %i --- ",blockcount); -#ifdef SPLIT_10MS - len=WebRtcIlbcfix_Encode(Enc_Inst, data, 80, encoded_data); -#else - len=WebRtcIlbcfix_Encode(Enc_Inst, data, (short)(mode<<3), encoded_data); -#endif + len=WebRtcIlbcfix_Encode(Enc_Inst, data, (short)readlen, encoded_data); if (len < 0) { fprintf(stderr, "Error encoding\n"); exit(0); @@ -152,9 +150,7 @@ int main(int argc, char* argv[]) /* write byte file */ if(len != 0){ //len may be 0 in 10ms split case fwrite(encoded_data,1,len,efileid); - } - if(len != 0){ //len may be 0 in 10ms split case /* get channel data if provided */ if (argc==6) { if (fread(&pli, sizeof(int16_t), 1, chfileid)) { diff --git a/webrtc/modules/audio_coding/codecs/ilbc/xcorr_coef.c b/webrtc/modules/audio_coding/codecs/ilbc/xcorr_coef.c index 328a5feca7..53d95bfa3d 100644 --- a/webrtc/modules/audio_coding/codecs/ilbc/xcorr_coef.c +++ b/webrtc/modules/audio_coding/codecs/ilbc/xcorr_coef.c @@ -57,11 +57,11 @@ int WebRtcIlbcfix_XcorrCoef( if (step==1) { max=WebRtcSpl_MaxAbsValueW16(regressor, subl + searchLen - 1); rp_beg = regressor; - rp_end = ®ressor[subl]; + rp_end = regressor + subl; } else { /* step==-1 */ - max=WebRtcSpl_MaxAbsValueW16(®ressor[-searchLen], subl + searchLen - 1); - rp_beg = ®ressor[-1]; - rp_end = ®ressor[subl-1]; + max = WebRtcSpl_MaxAbsValueW16(regressor - searchLen, subl + searchLen - 1); + rp_beg = regressor - 1; + rp_end = regressor + subl - 1; } /* Introduce a scale factor on the Energy in int32_t in diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/interface/isacfix.h b/webrtc/modules/audio_coding/codecs/isac/fix/interface/isacfix.h index 961fd3fad5..421a08cc89 100644 --- a/webrtc/modules/audio_coding/codecs/isac/fix/interface/isacfix.h +++ b/webrtc/modules/audio_coding/codecs/isac/fix/interface/isacfix.h @@ -227,10 +227,10 @@ extern "C" { int16_t WebRtcIsacfix_UpdateBwEstimate(ISACFIX_MainStruct *ISAC_main_inst, const uint8_t* encoded, - int32_t packet_size, - uint16_t rtp_seq_number, - uint32_t send_ts, - uint32_t arr_ts); + int32_t packet_size, + uint16_t rtp_seq_number, + uint32_t send_ts, + uint32_t arr_ts); /**************************************************************************** * WebRtcIsacfix_Decode(...) diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/codec.h b/webrtc/modules/audio_coding/codecs/isac/fix/source/codec.h index 1270cc38f7..55623a2ff3 100644 --- a/webrtc/modules/audio_coding/codecs/isac/fix/source/codec.h +++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/codec.h @@ -36,9 +36,9 @@ int16_t WebRtcIsacfix_DecodeImpl(int16_t* signal_out16, IsacFixDecoderInstance* ISACdec_obj, int16_t* current_framesamples); -int16_t WebRtcIsacfix_DecodePlcImpl(int16_t* decoded, - IsacFixDecoderInstance* ISACdec_obj, - int16_t* current_framesample ); +void WebRtcIsacfix_DecodePlcImpl(int16_t* decoded, + IsacFixDecoderInstance* ISACdec_obj, + int16_t* current_framesample ); int WebRtcIsacfix_EncodeImpl(int16_t* in, IsacFixEncoderInstance* ISACenc_obj, diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/decode_plc.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/decode_plc.c index 1a7ff92a97..c3a89c3557 100644 --- a/webrtc/modules/audio_coding/codecs/isac/fix/source/decode_plc.c +++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/decode_plc.c @@ -175,7 +175,10 @@ static void MemshipValQ15( int16_t in, int16_t *A, int16_t *B ) -static void LinearResampler( int16_t *in, int16_t *out, int16_t lenIn, int16_t lenOut ) +static void LinearResampler(int16_t* in, + int16_t* out, + int16_t lenIn, + int16_t lenOut) { int32_t n = (lenIn - 1) * RESAMP_RES; int16_t resOut, i, j, relativePos, diff; /* */ @@ -230,12 +233,11 @@ static void LinearResampler( int16_t *in, int16_t *out, int16_t lenIn, int16_t l -int16_t WebRtcIsacfix_DecodePlcImpl(int16_t *signal_out16, - IsacFixDecoderInstance *ISACdec_obj, - int16_t *current_framesamples ) +void WebRtcIsacfix_DecodePlcImpl(int16_t *signal_out16, + IsacFixDecoderInstance *ISACdec_obj, + int16_t *current_framesamples ) { int subframecnt; - int16_t len = 0; int16_t* Vector_Word16_1; int16_t Vector_Word16_Extended_1[FRAMESAMPLES_HALF + NOISE_FILTER_LEN]; @@ -797,6 +799,4 @@ int16_t WebRtcIsacfix_DecodePlcImpl(int16_t *signal_out16, (ISACdec_obj->plcstr_obj).used = PLC_WAS_USED; *current_framesamples = 480; - - return len; } diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/entropy_coding.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/entropy_coding.c index 39653789ef..9f52c9dd75 100644 --- a/webrtc/modules/audio_coding/codecs/isac/fix/source/entropy_coding.c +++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/entropy_coding.c @@ -1675,7 +1675,7 @@ int WebRtcIsacfix_DecodePitchLag(Bitstr_dec *streamdata, int32_t meangainQ12; int32_t CQ11, CQ10,tmp32a,tmp32b; - int16_t shft,tmp16a,tmp16c; + int16_t shft; meangainQ12=0; for (k = 0; k < 4; k++) @@ -1725,22 +1725,19 @@ int WebRtcIsacfix_DecodePitchLag(Bitstr_dec *streamdata, CQ11 = WEBRTC_SPL_SHIFT_W32(CQ11,11-shft); // Scale with StepSize, Q11 for (k=0; k> 5); - PitchLags_Q7[k] = tmp16a; + PitchLags_Q7[k] = (int16_t)(tmp32a >> 5); } CQ10 = mean_val2Q10[index[1]]; for (k=0; k> 10; - tmp16c = (int16_t)(tmp32b >> 5); - PitchLags_Q7[k] += tmp16c; + PitchLags_Q7[k] += (int16_t)(tmp32b >> 5); } CQ10 = mean_val4Q10[index[3]]; for (k=0; k> 10; - tmp16c = (int16_t)(tmp32b >> 5); - PitchLags_Q7[k] += tmp16c; + PitchLags_Q7[k] += (int16_t)(tmp32b >> 5); } return 0; @@ -1761,7 +1758,7 @@ int WebRtcIsacfix_EncodePitchLag(int16_t* PitchLagsQ7, const int16_t *mean_val2Q10,*mean_val4Q10; const int16_t *lower_limit, *upper_limit; const uint16_t **cdf; - int16_t shft, tmp16a, tmp16b, tmp16c; + int16_t shft, tmp16b; int32_t tmp32b; int status = 0; @@ -1832,22 +1829,19 @@ int WebRtcIsacfix_EncodePitchLag(int16_t* PitchLagsQ7, for (k=0; k> 5); // Q7. - PitchLagsQ7[k] = tmp16a; + PitchLagsQ7[k] = (int16_t)(tmp32a >> 5); // Q7. } CQ10 = mean_val2Q10[index[1]]; for (k=0; k> 10; - tmp16c = (int16_t)(tmp32b >> 5); // Q7. - PitchLagsQ7[k] += tmp16c; + PitchLagsQ7[k] += (int16_t)(tmp32b >> 5); // Q7. } CQ10 = mean_val4Q10[index[3]]; for (k=0; k> 10; - tmp16c = (int16_t)(tmp32b >> 5); // Q7. - PitchLagsQ7[k] += tmp16c; + PitchLagsQ7[k] += (int16_t)(tmp32b >> 5); // Q7. } /* entropy coding of quantization pitch lags */ diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/isacfix.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/isacfix.c index 03bceecbfb..25076d8d67 100644 --- a/webrtc/modules/audio_coding/codecs/isac/fix/source/isacfix.c +++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/isacfix.c @@ -620,9 +620,9 @@ int16_t WebRtcIsacfix_DecoderInit(ISACFIX_MainStruct *ISAC_main_inst) int16_t WebRtcIsacfix_UpdateBwEstimate1(ISACFIX_MainStruct *ISAC_main_inst, const uint8_t* encoded, - int32_t packet_size, - uint16_t rtp_seq_number, - uint32_t arr_ts) + int32_t packet_size, + uint16_t rtp_seq_number, + uint32_t arr_ts) { ISACFIX_SubStruct *ISAC_inst; Bitstr_dec streamdata; @@ -692,10 +692,10 @@ int16_t WebRtcIsacfix_UpdateBwEstimate1(ISACFIX_MainStruct *ISAC_main_inst, int16_t WebRtcIsacfix_UpdateBwEstimate(ISACFIX_MainStruct *ISAC_main_inst, const uint8_t* encoded, - int32_t packet_size, - uint16_t rtp_seq_number, - uint32_t send_ts, - uint32_t arr_ts) + int32_t packet_size, + uint16_t rtp_seq_number, + uint32_t send_ts, + uint32_t arr_ts) { ISACFIX_SubStruct *ISAC_inst; Bitstr_dec streamdata; @@ -767,11 +767,11 @@ int16_t WebRtcIsacfix_UpdateBwEstimate(ISACFIX_MainStruct *ISAC_main_inst, */ -int16_t WebRtcIsacfix_Decode(ISACFIX_MainStruct *ISAC_main_inst, +int16_t WebRtcIsacfix_Decode(ISACFIX_MainStruct* ISAC_main_inst, const uint8_t* encoded, - int16_t len, - int16_t *decoded, - int16_t *speechType) + int16_t len, + int16_t* decoded, + int16_t* speechType) { ISACFIX_SubStruct *ISAC_inst; /* number of samples (480 or 960), output from decoder */ @@ -981,9 +981,8 @@ int16_t WebRtcIsacfix_DecodePlcNb(ISACFIX_MainStruct *ISAC_main_inst, declen = 0; while( noOfLostFrames > 0 ) { - ok = WebRtcIsacfix_DecodePlcImpl( outframeWB, &ISAC_inst->ISACdec_obj, &no_of_samples ); - if(ok) - return -1; + WebRtcIsacfix_DecodePlcImpl(outframeWB, &ISAC_inst->ISACdec_obj, + &no_of_samples); WebRtcIsacfix_SplitAndFilter2(outframeWB, &(outframeNB[k*240]), dummy, &ISAC_inst->ISACdec_obj.decimatorstr_obj); @@ -1029,7 +1028,7 @@ int16_t WebRtcIsacfix_DecodePlc(ISACFIX_MainStruct *ISAC_main_inst, int16_t noOfLostFrames) { - int16_t no_of_samples, declen, k, ok; + int16_t no_of_samples, declen, k; int16_t outframe16[MAX_FRAMESAMPLES]; ISACFIX_SubStruct *ISAC_inst; @@ -1044,9 +1043,8 @@ int16_t WebRtcIsacfix_DecodePlc(ISACFIX_MainStruct *ISAC_main_inst, declen = 0; while( noOfLostFrames > 0 ) { - ok = WebRtcIsacfix_DecodePlcImpl( &(outframe16[k*480]), &ISAC_inst->ISACdec_obj, &no_of_samples ); - if(ok) - return -1; + WebRtcIsacfix_DecodePlcImpl(&(outframe16[k*480]), &ISAC_inst->ISACdec_obj, + &no_of_samples); declen += no_of_samples; noOfLostFrames--; k++; diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/lattice.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/lattice.c index 3b26a9815e..7fcb9e3b7b 100644 --- a/webrtc/modules/audio_coding/codecs/isac/fix/source/lattice.c +++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/lattice.c @@ -279,7 +279,8 @@ void WebRtcIsacfix_NormLatticeFilterAr(int16_t orderCoef, ARfQ0vec[i] = (int16_t)WebRtcSpl_SatW32ToW16(tmp32); // Q0 } - for (i=orderCoef;i>0;i--) //get the state of f&g for the first input, for all orders + // Get the state of f & g for the first input, for all orders. + for (i = orderCoef; i > 0; i--) { tmp32 = (cthQ15[i - 1] * ARfQ0vec[0] - sthQ15[i - 1] * stateGQ0[i - 1] + 16384) >> 15; diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/lattice_armv7.S b/webrtc/modules/audio_coding/codecs/isac/fix/source/lattice_armv7.S index ccea467990..4a0d99f3b1 100644 --- a/webrtc/modules/audio_coding/codecs/isac/fix/source/lattice_armv7.S +++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/lattice_armv7.S @@ -55,9 +55,11 @@ ORDER_COEF_LOOP: @ for(k = order_coef ; k > 0; k--) smlabb r11, r7, r5, r12 @ sth_Q15[k - 1] * tmpAR + 16384 smlabb r10, r6, r5, r12 @ cth_Q15[k - 1] * tmpAR + 16384 smulbb r7, r7, r8 @ sth_Q15[k - 1] * ar_g_Q0[k - 1] - smlabb r11, r6, r8, r11 @ cth_Q15[k - 1]*ar_g_Q0[k - 1]+(sth_Q15[k - 1]*tmpAR+16384) + smlabb r11, r6, r8, r11 @ cth_Q15[k - 1] * ar_g_Q0[k - 1] + + @ (sth_Q15[k - 1] * tmpAR + 16384) - sub r10, r10, r7 @ cth_Q15[k - 1]*tmpAR+16384-(sth_Q15[k - 1]*ar_g_Q0[k - 1]) + sub r10, r10, r7 @ cth_Q15[k - 1] * tmpAR + 16384 - + @ (sth_Q15[k - 1] * ar_g_Q0[k - 1]) ssat r11, #16, r11, asr #15 ssat r5, #16, r10, asr #15 strh r11, [r0], #-2 @ Output: ar_g_Q0[k] diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/pitch_filter.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/pitch_filter.c index 1149d50b98..c787d6e368 100644 --- a/webrtc/modules/audio_coding/codecs/isac/fix/source/pitch_filter.c +++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/pitch_filter.c @@ -34,19 +34,6 @@ static const int16_t kIntrpCoef[PITCH_FRACS][PITCH_FRACORDER] = { { 271, -743, 1570, -3320, 12963, 7301, -2292, 953, -325} }; -// Function prototype for pitch filtering. -// TODO(Turaj): Add descriptions of input and output parameters. -void WebRtcIsacfix_PitchFilterCore(int loopNumber, - int16_t gain, - int index, - int16_t sign, - int16_t* inputState, - int16_t* outputBuf2, - const int16_t* coefficient, - int16_t* inputBuf, - int16_t* outputBuf, - int* index2); - static __inline int32_t CalcLrIntQ(int32_t fixVal, int16_t qDomain) { int32_t roundVal = 1 << (qDomain - 1); diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/test/isac_speed_test.cc b/webrtc/modules/audio_coding/codecs/isac/fix/test/isac_speed_test.cc index 3089f58261..8f073adf7e 100644 --- a/webrtc/modules/audio_coding/codecs/isac/fix/test/isac_speed_test.cc +++ b/webrtc/modules/audio_coding/codecs/isac/fix/test/isac_speed_test.cc @@ -83,14 +83,14 @@ float IsacSpeedTest::EncodeABlock(int16_t* in_data, uint8_t* bit_stream, return 1000.0 * clocks / CLOCKS_PER_SEC; } -float IsacSpeedTest::DecodeABlock(const uint8_t* bit_stream, int encoded_bytes, +float IsacSpeedTest::DecodeABlock(const uint8_t* bit_stream, + int encoded_bytes, int16_t* out_data) { int value; int16_t audio_type; clock_t clocks = clock(); - value = WebRtcIsacfix_Decode(ISACFIX_main_inst_, - bit_stream, - encoded_bytes, out_data, &audio_type); + value = WebRtcIsacfix_Decode(ISACFIX_main_inst_, bit_stream, encoded_bytes, + out_data, &audio_type); clocks = clock() - clocks; EXPECT_EQ(output_length_sample_, value); return 1000.0 * clocks / CLOCKS_PER_SEC; diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/test/test_iSACfixfloat.c b/webrtc/modules/audio_coding/codecs/isac/fix/test/test_iSACfixfloat.c index e2a778ad54..fae6d6aa0f 100644 --- a/webrtc/modules/audio_coding/codecs/isac/fix/test/test_iSACfixfloat.c +++ b/webrtc/modules/audio_coding/codecs/isac/fix/test/test_iSACfixfloat.c @@ -582,8 +582,7 @@ int main(int argc, char* argv[]) { totalsmpls += declen; totalbits += 8 * stream_len; - kbps = ((double)FS) / ((double)cur_framesmpls) * 8.0 * stream_len / - 1000.0; // kbits/s + kbps = ((double)FS) / ((double)cur_framesmpls) * 8.0 * stream_len / 1000.0; fy = fopen("bit_rate.dat", "a"); fprintf(fy, "Frame %i = %0.14f\n", framecnt, kbps); fclose(fy); diff --git a/webrtc/modules/audio_coding/codecs/isac/main/source/bandwidth_estimator.c b/webrtc/modules/audio_coding/codecs/isac/main/source/bandwidth_estimator.c index c4ceb59062..ce8ceb217a 100644 --- a/webrtc/modules/audio_coding/codecs/isac/main/source/bandwidth_estimator.c +++ b/webrtc/modules/audio_coding/codecs/isac/main/source/bandwidth_estimator.c @@ -132,12 +132,12 @@ int32_t WebRtcIsac_InitBandwidthEstimator( /* 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, + BwEstimatorstr* bwest_str, const uint16_t rtp_number, - const int32_t frame_length, + const int32_t frame_length, const uint32_t send_ts, const uint32_t arr_ts, - const int32_t pksize + const int32_t pksize /*, const uint16_t Index*/) { float weight = 0.0f; diff --git a/webrtc/modules/audio_coding/codecs/isac/main/source/bandwidth_estimator.h b/webrtc/modules/audio_coding/codecs/isac/main/source/bandwidth_estimator.h index edabdff5cf..8482a8c70e 100644 --- a/webrtc/modules/audio_coding/codecs/isac/main/source/bandwidth_estimator.h +++ b/webrtc/modules/audio_coding/codecs/isac/main/source/bandwidth_estimator.h @@ -90,12 +90,12 @@ extern "C" { /* 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, + BwEstimatorstr* bwest_str, const uint16_t rtp_number, - const int32_t frame_length, + const int32_t frame_length, const uint32_t send_ts, const uint32_t arr_ts, - const int32_t pksize); + const int32_t pksize); /* Update receiving estimates. Used when we only receive BWE index, no iSAC data packet. */ int16_t WebRtcIsac_UpdateUplinkBwImpl( diff --git a/webrtc/modules/audio_coding/codecs/isac/main/source/lpc_analysis.c b/webrtc/modules/audio_coding/codecs/isac/main/source/lpc_analysis.c index 5198ebfab8..4708a5c352 100644 --- a/webrtc/modules/audio_coding/codecs/isac/main/source/lpc_analysis.c +++ b/webrtc/modules/audio_coding/codecs/isac/main/source/lpc_analysis.c @@ -78,8 +78,8 @@ static const double kLpcCorrWindow[WINLEN] = { double WebRtcIsac_LevDurb(double *a, double *k, double *r, int order) { - double sum, alpha; - int m, m_h, i; + double sum, alpha; + int m, m_h, i; alpha = 0; //warning -DH a[0] = 1.0; if (r[0] < LEVINSON_EPS) { /* if r[0] <= 0, set LPC coeff. to zero */ diff --git a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc index e69b0c8fb3..17fa5b24b8 100644 --- a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc +++ b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc @@ -114,10 +114,10 @@ int AudioEncoderOpus::NumChannels() const { size_t AudioEncoderOpus::MaxEncodedBytes() const { // Calculate the number of bytes we expect the encoder to produce, // then multiply by two to give a wide margin for error. - int frame_size_ms = num_10ms_frames_per_packet_ * 10; size_t bytes_per_millisecond = - static_cast(bitrate_bps_ / (1000 * 8) + 1); - size_t approx_encoded_bytes = frame_size_ms * bytes_per_millisecond; + static_cast(bitrate_bps_ / (1000 * 8) + 1); + size_t approx_encoded_bytes = + num_10ms_frames_per_packet_ * 10 * bytes_per_millisecond; return 2 * approx_encoded_bytes; } diff --git a/webrtc/modules/audio_coding/codecs/opus/opus_unittest.cc b/webrtc/modules/audio_coding/codecs/opus/opus_unittest.cc index bb7bee97b8..028d2ec544 100644 --- a/webrtc/modules/audio_coding/codecs/opus/opus_unittest.cc +++ b/webrtc/modules/audio_coding/codecs/opus/opus_unittest.cc @@ -46,7 +46,7 @@ class OpusTest : public TestWithParam<::testing::tuple> { int EncodeDecode(WebRtcOpusEncInst* encoder, const int16_t* input_audio, - const int input_samples, + int input_samples, WebRtcOpusDecInst* decoder, int16_t* output_audio, int16_t* audio_type); @@ -98,7 +98,7 @@ void OpusTest::SetMaxPlaybackRate(WebRtcOpusEncInst* encoder, int OpusTest::EncodeDecode(WebRtcOpusEncInst* encoder, const int16_t* input_audio, - const int input_samples, + int input_samples, WebRtcOpusDecInst* decoder, int16_t* output_audio, int16_t* audio_type) { @@ -165,7 +165,7 @@ void OpusTest::TestDtxEffect(bool dtx) { EXPECT_EQ(0, opus_encoder_->in_dtx_mode); EXPECT_EQ(0, opus_decoder_->in_dtx_mode); EXPECT_EQ(0, audio_type); // Speech. - } else if (1 == encoded_bytes_) { + } else if (encoded_bytes_ == 1) { EXPECT_EQ(1, opus_encoder_->in_dtx_mode); EXPECT_EQ(1, opus_decoder_->in_dtx_mode); EXPECT_EQ(2, audio_type); // Comfort noise. diff --git a/webrtc/modules/audio_coding/main/acm2/acm_receive_test.cc b/webrtc/modules/audio_coding/main/acm2/acm_receive_test.cc index e74ce2270c..dc59984a95 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_receive_test.cc +++ b/webrtc/modules/audio_coding/main/acm2/acm_receive_test.cc @@ -25,12 +25,12 @@ namespace test { AcmReceiveTest::AcmReceiveTest(PacketSource* packet_source, AudioSink* audio_sink, int output_freq_hz, - NumOutputChannels exptected_output_channels) + NumOutputChannels expected_output_channels) : clock_(0), packet_source_(packet_source), audio_sink_(audio_sink), output_freq_hz_(output_freq_hz), - exptected_output_channels_(exptected_output_channels) { + expected_output_channels_(expected_output_channels) { webrtc::AudioCoding::Config config; config.clock = &clock_; config.playout_frequency_hz = output_freq_hz_; @@ -95,13 +95,13 @@ void AcmReceiveTest::Run() { EXPECT_EQ(output_freq_hz_, output_frame.sample_rate_hz_); const int samples_per_block = output_freq_hz_ * 10 / 1000; EXPECT_EQ(samples_per_block, output_frame.samples_per_channel_); - if (exptected_output_channels_ != kArbitraryChannels) { + if (expected_output_channels_ != kArbitraryChannels) { if (output_frame.speech_type_ == webrtc::AudioFrame::kPLC) { // Don't check number of channels for PLC output, since each test run // usually starts with a short period of mono PLC before decoding the // first packet. } else { - EXPECT_EQ(exptected_output_channels_, output_frame.num_channels_); + EXPECT_EQ(expected_output_channels_, output_frame.num_channels_); } } ASSERT_TRUE(audio_sink_->WriteAudioFrame(output_frame)); diff --git a/webrtc/modules/audio_coding/main/acm2/acm_receive_test.h b/webrtc/modules/audio_coding/main/acm2/acm_receive_test.h index 552a7486a8..a1e01423bc 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_receive_test.h +++ b/webrtc/modules/audio_coding/main/acm2/acm_receive_test.h @@ -35,7 +35,7 @@ class AcmReceiveTest { PacketSource* packet_source, AudioSink* audio_sink, int output_freq_hz, - NumOutputChannels exptected_output_channels); + NumOutputChannels expected_output_channels); virtual ~AcmReceiveTest() {} // Registers the codecs with default parameters from ACM. @@ -54,7 +54,7 @@ class AcmReceiveTest { PacketSource* packet_source_; AudioSink* audio_sink_; const int output_freq_hz_; - NumOutputChannels exptected_output_channels_; + NumOutputChannels expected_output_channels_; DISALLOW_COPY_AND_ASSIGN(AcmReceiveTest); }; diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc index ce98636ab2..4e665ea455 100644 --- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc +++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc @@ -339,8 +339,8 @@ int AudioCodingModuleImpl::Add10MsDataInternal(const AudioFrame& audio_frame, } // If the length and frequency matches. We currently just support raw PCM. - if ((audio_frame.sample_rate_hz_ / 100) - != audio_frame.samples_per_channel_) { + if ((audio_frame.sample_rate_hz_ / 100) != + audio_frame.samples_per_channel_) { WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, "Cannot Add 10 ms audio, input frequency and length doesn't" " match"); diff --git a/webrtc/modules/audio_coding/main/test/opus_test.cc b/webrtc/modules/audio_coding/main/test/opus_test.cc index 09301df51c..a407fc5d36 100644 --- a/webrtc/modules/audio_coding/main/test/opus_test.cc +++ b/webrtc/modules/audio_coding/main/test/opus_test.cc @@ -277,12 +277,12 @@ void OpusTest::Run(TestPackStereo* channel, int channels, int bitrate, bitstream_len_byte = WebRtcOpus_Encode( opus_mono_encoder_, &audio[read_samples], frame_length, kMaxBytes, bitstream); - ASSERT_GT(bitstream_len_byte, -1); + ASSERT_GE(bitstream_len_byte, 0); } else { bitstream_len_byte = WebRtcOpus_Encode( opus_stereo_encoder_, &audio[read_samples], frame_length, kMaxBytes, bitstream); - ASSERT_GT(bitstream_len_byte, -1); + ASSERT_GE(bitstream_len_byte, 0); } // Simulate packet loss by setting |packet_loss_| to "true" in diff --git a/webrtc/modules/audio_coding/neteq/decision_logic_normal.h b/webrtc/modules/audio_coding/neteq/decision_logic_normal.h index 0254839f49..047663f5b0 100644 --- a/webrtc/modules/audio_coding/neteq/decision_logic_normal.h +++ b/webrtc/modules/audio_coding/neteq/decision_logic_normal.h @@ -61,7 +61,8 @@ class DecisionLogicNormal : public DecisionLogic { virtual Operations FuturePacketAvailable( const SyncBuffer& sync_buffer, const Expand& expand, - int decoder_frame_length, Modes prev_mode, + int decoder_frame_length, + Modes prev_mode, uint32_t target_timestamp, uint32_t available_timestamp, bool play_dtmf); diff --git a/webrtc/modules/audio_coding/neteq/expand.cc b/webrtc/modules/audio_coding/neteq/expand.cc index d5f0f9c0a3..bde655917f 100644 --- a/webrtc/modules/audio_coding/neteq/expand.cc +++ b/webrtc/modules/audio_coding/neteq/expand.cc @@ -214,24 +214,24 @@ int Expand::Process(AudioMultiVector* output) { // Create combined signal by shifting in more and more of unvoiced part. temp_shift = 8 - temp_shift; // = getbits(mix_factor_increment). - size_t temp_lenght = (parameters.current_voice_mix_factor - + size_t temp_length = (parameters.current_voice_mix_factor - parameters.voice_mix_factor) >> temp_shift; - temp_lenght = std::min(temp_lenght, current_lag); - DspHelper::CrossFade(voiced_vector, unvoiced_vector, temp_lenght, + temp_length = std::min(temp_length, current_lag); + DspHelper::CrossFade(voiced_vector, unvoiced_vector, temp_length, ¶meters.current_voice_mix_factor, mix_factor_increment, temp_data); // End of cross-fading period was reached before end of expanded signal // path. Mix the rest with a fixed mixing factor. - if (temp_lenght < current_lag) { + if (temp_length < current_lag) { if (mix_factor_increment != 0) { parameters.current_voice_mix_factor = parameters.voice_mix_factor; } int16_t temp_scale = 16384 - parameters.current_voice_mix_factor; WebRtcSpl_ScaleAndAddVectorsWithRound( - voiced_vector + temp_lenght, parameters.current_voice_mix_factor, - unvoiced_vector + temp_lenght, temp_scale, 14, - temp_data + temp_lenght, static_cast(current_lag - temp_lenght)); + voiced_vector + temp_length, parameters.current_voice_mix_factor, + unvoiced_vector + temp_length, temp_scale, 14, + temp_data + temp_length, static_cast(current_lag - temp_length)); } // Select muting slope depending on how many consecutive expands we have @@ -428,13 +428,12 @@ void Expand::AnalyzeSignal(int16_t* random_vector) { // Calculate the exact best correlation in the range between // |correlation_lag| and |distortion_lag|. - correlation_length = distortion_lag + 10; - correlation_length = std::min(correlation_length, fs_mult_120); - correlation_length = std::max(correlation_length, 60 * fs_mult); + correlation_length = + std::max(std::min(distortion_lag + 10, fs_mult_120), 60 * fs_mult); int start_index = std::min(distortion_lag, correlation_lag); - int correlation_lags = WEBRTC_SPL_ABS_W16((distortion_lag-correlation_lag)) - + 1; + int correlation_lags = + WEBRTC_SPL_ABS_W16((distortion_lag-correlation_lag)) + 1; assert(correlation_lags <= 99 * fs_mult + 1); // Cannot be larger. for (size_t channel_ix = 0; channel_ix < num_channels_; ++channel_ix) { @@ -753,8 +752,10 @@ Expand::ChannelParameters::ChannelParameters() memset(ar_filter_state, 0, sizeof(ar_filter_state)); } -int16_t Expand::Correlation(const int16_t* input, size_t input_length, - int16_t* output, int16_t* output_scale) const { +void Expand::Correlation(const int16_t* input, + size_t input_length, + int16_t* output, + int16_t* output_scale) const { // Set parameters depending on sample rate. const int16_t* filter_coefficients; int16_t num_coefficients; @@ -818,7 +819,6 @@ int16_t Expand::Correlation(const int16_t* input, size_t input_length, norm_shift2); // Total scale factor (right shifts) of correlation value. *output_scale = 2 * norm_shift + kCorrelationShift + norm_shift2; - return kNumCorrelationLags; } void Expand::UpdateLagIndex() { @@ -850,7 +850,7 @@ void Expand::GenerateBackgroundNoise(int16_t* random_vector, int16_t* buffer) { static const int kNoiseLpcOrder = BackgroundNoise::kMaxLpcOrder; int16_t scaled_random_vector[kMaxSampleRate / 8000 * 125]; - assert(static_cast(kMaxSampleRate / 8000 * 125) >= num_noise_samples); + assert(num_noise_samples <= static_cast(kMaxSampleRate / 8000 * 125)); int16_t* noise_samples = &buffer[kNoiseLpcOrder]; if (background_noise_->initialized()) { // Use background noise parameters. diff --git a/webrtc/modules/audio_coding/neteq/expand.h b/webrtc/modules/audio_coding/neteq/expand.h index 0000642012..b015959e75 100644 --- a/webrtc/modules/audio_coding/neteq/expand.h +++ b/webrtc/modules/audio_coding/neteq/expand.h @@ -119,9 +119,11 @@ class Expand { // Calculate the auto-correlation of |input|, with length |input_length| // samples. The correlation is calculated from a downsampled version of // |input|, and is written to |output|. The scale factor is written to - // |output_scale|. Returns the length of the correlation vector. - int16_t Correlation(const int16_t* input, size_t input_length, - int16_t* output, int16_t* output_scale) const; + // |output_scale|. + void Correlation(const int16_t* input, + size_t input_length, + int16_t* output, + int16_t* output_scale) const; void UpdateLagIndex(); diff --git a/webrtc/modules/audio_coding/neteq/merge.cc b/webrtc/modules/audio_coding/neteq/merge.cc index 8399a78bc8..8e686ba49b 100644 --- a/webrtc/modules/audio_coding/neteq/merge.cc +++ b/webrtc/modules/audio_coding/neteq/merge.cc @@ -312,8 +312,8 @@ int16_t Merge::CorrelateAndPeakSearch(int16_t expanded_max, int16_t input_max, int expand_period) const { // Calculate correlation without any normalization. const int max_corr_length = kMaxCorrelationLength; - int stop_position_downsamp = std::min( - max_corr_length, expand_->max_lag() / (fs_mult_ * 2) + 1); + int stop_position_downsamp = + std::min(max_corr_length, expand_->max_lag() / (fs_mult_ * 2) + 1); int16_t correlation_shift = 0; if (expanded_max * input_max > 26843546) { correlation_shift = 3; @@ -367,9 +367,9 @@ int16_t Merge::CorrelateAndPeakSearch(int16_t expanded_max, int16_t input_max, // Ensure that underrun does not occur for 10ms case => we have to get at // least 10ms + overlap . (This should never happen thanks to the above // modification of peak-finding starting point.) - while ((best_correlation_index + input_length) < - static_cast(timestamps_per_call_ + expand_->overlap_length()) || - best_correlation_index + input_length < start_position) { + while (((best_correlation_index + input_length) < + static_cast(timestamps_per_call_ + expand_->overlap_length())) || + ((best_correlation_index + input_length) < start_position)) { assert(false); // Should never happen. best_correlation_index += expand_period; // Jump one lag ahead. } diff --git a/webrtc/modules/audio_coding/neteq/neteq_external_decoder_unittest.cc b/webrtc/modules/audio_coding/neteq/neteq_external_decoder_unittest.cc index 729dbf6c13..bf68b3b8e2 100644 --- a/webrtc/modules/audio_coding/neteq/neteq_external_decoder_unittest.cc +++ b/webrtc/modules/audio_coding/neteq/neteq_external_decoder_unittest.cc @@ -74,7 +74,7 @@ class NetEqExternalDecoderUnitTest : public test::NetEqExternalDecoderTest { return -1; } payload_size_bytes_ = WebRtcPcm16b_Encode(input_, frame_size_samples_, - encoded_);; + encoded_); int next_send_time = rtp_generator_->GetRtpHeader( kPayloadType, frame_size_samples_, &rtp_header_); diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl.cc b/webrtc/modules/audio_coding/neteq/neteq_impl.cc index 3a3ad9809b..29b8d1a0b3 100644 --- a/webrtc/modules/audio_coding/neteq/neteq_impl.cc +++ b/webrtc/modules/audio_coding/neteq/neteq_impl.cc @@ -315,9 +315,10 @@ NetEqPlayoutMode NetEqImpl::PlayoutMode() const { int NetEqImpl::NetworkStatistics(NetEqNetworkStatistics* stats) { CriticalSectionScoped lock(crit_sect_.get()); assert(decoder_database_.get()); - const int total_samples_in_buffers = packet_buffer_->NumSamplesInBuffer( - decoder_database_.get(), decoder_frame_length_) + - static_cast(sync_buffer_->FutureLength()); + const int total_samples_in_buffers = + packet_buffer_->NumSamplesInBuffer(decoder_database_.get(), + decoder_frame_length_) + + static_cast(sync_buffer_->FutureLength()); assert(delay_manager_.get()); assert(decision_logic_.get()); stats_.GetNetworkStatistics(fs_hz_, total_samples_in_buffers, @@ -704,8 +705,10 @@ int NetEqImpl::InsertPacketInternal(const WebRtcRTPHeader& rtp_header, return 0; } -int NetEqImpl::GetAudioInternal(size_t max_length, int16_t* output, - int* samples_per_channel, int* num_channels) { +int NetEqImpl::GetAudioInternal(size_t max_length, + int16_t* output, + int* samples_per_channel, + int* num_channels) { PacketList packet_list; DtmfEvent dtmf_event; Operations operation; diff --git a/webrtc/modules/audio_coding/neteq/packet_buffer.cc b/webrtc/modules/audio_coding/neteq/packet_buffer.cc index 08b237f846..5792b227ef 100644 --- a/webrtc/modules/audio_coding/neteq/packet_buffer.cc +++ b/webrtc/modules/audio_coding/neteq/packet_buffer.cc @@ -250,16 +250,12 @@ int PacketBuffer::NumSamplesInBuffer(DecoderDatabase* decoder_database, Packet* packet = (*it); AudioDecoder* decoder = decoder_database->GetDecoder(packet->header.payloadType); - if (decoder) { - int duration; - if (packet->sync_packet) { - duration = last_duration; - } else if (packet->primary) { - duration = - decoder->PacketDuration(packet->payload, packet->payload_length); - } else { + if (decoder && !packet->sync_packet) { + if (!packet->primary) { continue; } + int duration = + decoder->PacketDuration(packet->payload, packet->payload_length); if (duration >= 0) { last_duration = duration; // Save the most up-to-date (valid) duration. } diff --git a/webrtc/modules/audio_coding/neteq/preemptive_expand.h b/webrtc/modules/audio_coding/neteq/preemptive_expand.h index c583a48a5b..65da7032b8 100644 --- a/webrtc/modules/audio_coding/neteq/preemptive_expand.h +++ b/webrtc/modules/audio_coding/neteq/preemptive_expand.h @@ -52,9 +52,9 @@ class PreemptiveExpand : public TimeStretch { protected: // Sets the parameters |best_correlation| and |peak_index| to suitable // values when the signal contains no active speech. - void SetParametersForPassiveSpeech(size_t len, - int16_t* w16_bestCorr, - int* w16_bestIndex) const override; + void SetParametersForPassiveSpeech(size_t input_length, + int16_t* best_correlation, + int* peak_index) const override; // Checks the criteria for performing the time-stretching operation and, // if possible, performs the time-stretching. diff --git a/webrtc/modules/audio_coding/neteq/statistics_calculator.cc b/webrtc/modules/audio_coding/neteq/statistics_calculator.cc index f637eb8e9e..ce800dd065 100644 --- a/webrtc/modules/audio_coding/neteq/statistics_calculator.cc +++ b/webrtc/modules/audio_coding/neteq/statistics_calculator.cc @@ -149,7 +149,7 @@ void StatisticsCalculator::GetNetworkStatistics( stats->speech_expand_rate = CalculateQ14Ratio(expanded_speech_samples_, - timestamps_since_last_report_); + timestamps_since_last_report_); stats->secondary_decoded_rate = CalculateQ14Ratio(secondary_decoded_samples_, diff --git a/webrtc/modules/audio_coding/neteq/test/RTPencode.cc b/webrtc/modules/audio_coding/neteq/test/RTPencode.cc index 192d3748af..f25a279f9c 100644 --- a/webrtc/modules/audio_coding/neteq/test/RTPencode.cc +++ b/webrtc/modules/audio_coding/neteq/test/RTPencode.cc @@ -152,7 +152,7 @@ void stereoInterleave(unsigned char* data, int dataLen, int stride); #ifdef NETEQ_ISACFIX_CODEC #include "isacfix.h" #ifdef CODEC_ISAC -#error Cannot have both ISAC and ISACfix defined. Please de-select one in the beginning of RTPencode.cpp +#error Cannot have both ISAC and ISACfix defined. Please de-select one. #endif #endif #ifdef CODEC_G722 diff --git a/webrtc/modules/audio_coding/neteq/tools/constant_pcm_packet_source.cc b/webrtc/modules/audio_coding/neteq/tools/constant_pcm_packet_source.cc index 65c4e9dc82..af4b8e130f 100644 --- a/webrtc/modules/audio_coding/neteq/tools/constant_pcm_packet_source.cc +++ b/webrtc/modules/audio_coding/neteq/tools/constant_pcm_packet_source.cc @@ -32,7 +32,7 @@ ConstantPcmPacketSource::ConstantPcmPacketSource(size_t payload_len_samples, timestamp_(0), payload_ssrc_(0xABCD1234) { int encoded_len = WebRtcPcm16b_Encode(&sample_value, 1, encoded_sample_); - CHECK_EQ(encoded_len, 2); + CHECK_EQ(2, encoded_len); } Packet* ConstantPcmPacketSource::NextPacket() { diff --git a/webrtc/modules/audio_coding/neteq/tools/neteq_performance_test.cc b/webrtc/modules/audio_coding/neteq/tools/neteq_performance_test.cc index 080b99bf03..1c76d761e9 100644 --- a/webrtc/modules/audio_coding/neteq/tools/neteq_performance_test.cc +++ b/webrtc/modules/audio_coding/neteq/tools/neteq_performance_test.cc @@ -103,8 +103,8 @@ int64_t NetEqPerformanceTest::Run(int runtime_ms, static const int kMaxChannels = 1; static const int kMaxSamplesPerMs = 48000 / 1000; static const int kOutputBlockSizeMs = 10; - static const int kOutDataLen = kOutputBlockSizeMs * kMaxSamplesPerMs * - kMaxChannels; + static const int kOutDataLen = + kOutputBlockSizeMs * kMaxSamplesPerMs * kMaxChannels; int16_t out_data[kOutDataLen]; int num_channels; int samples_per_channel; diff --git a/webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc b/webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc index 11dd20a8f9..6bcd717279 100644 --- a/webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc +++ b/webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc @@ -552,8 +552,8 @@ int main(int argc, char* argv[]) { // Check if it is time to get output audio. if (time_now_ms >= next_output_time_ms) { - static const int kOutDataLen = kOutputBlockSizeMs * kMaxSamplesPerMs * - kMaxChannels; + static const int kOutDataLen = + kOutputBlockSizeMs * kMaxSamplesPerMs * kMaxChannels; int16_t out_data[kOutDataLen]; int num_channels; int samples_per_channel; diff --git a/webrtc/modules/audio_device/android/audio_common.h b/webrtc/modules/audio_device/android/audio_common.h index e987f8fe17..cb259830b9 100644 --- a/webrtc/modules/audio_device/android/audio_common.h +++ b/webrtc/modules/audio_device/android/audio_common.h @@ -16,7 +16,6 @@ namespace webrtc { enum { kDefaultSampleRate = 44100, kNumChannels = 1, - kDefaultBufSizeInSamples = kDefaultSampleRate * 10 / 1000, // Number of bytes per audio frame. // Example: 16-bit PCM in mono => 1*(16/8)=2 [bytes/frame] kBytesPerFrame = kNumChannels * (16 / 8), diff --git a/webrtc/modules/audio_device/audio_device_buffer.cc b/webrtc/modules/audio_device/audio_device_buffer.cc index 18a242f8e0..12b28b3ab3 100644 --- a/webrtc/modules/audio_device/audio_device_buffer.cc +++ b/webrtc/modules/audio_device/audio_device_buffer.cc @@ -406,12 +406,6 @@ int32_t AudioDeviceBuffer::SetRecordedBuffer(const void* audioBuffer, return -1; } - if (nSamples != _recSamples) - { - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "invalid number of recorded samples (%d)", nSamples); - return -1; - } - if (_recChannel == AudioDeviceModule::kChannelBoth) { // (default) copy the complete input buffer to the local buffer @@ -576,8 +570,9 @@ int32_t AudioDeviceBuffer::GetPlayoutData(void* audioBuffer) if (_playSize > kMaxBufferSizeBytes) { - WEBRTC_TRACE(kTraceError, kTraceUtility, _id, "_playSize %i exceeds " - "kMaxBufferSizeBytes in AudioDeviceBuffer::GetPlayoutData", _playSize); + WEBRTC_TRACE(kTraceError, kTraceUtility, _id, + "_playSize %i exceeds kMaxBufferSizeBytes in " + "AudioDeviceBuffer::GetPlayoutData", _playSize); assert(false); return -1; } diff --git a/webrtc/modules/audio_device/test/audio_device_test_api.cc b/webrtc/modules/audio_device/test/audio_device_test_api.cc index 455d69378e..923d39ac73 100644 --- a/webrtc/modules/audio_device/test/audio_device_test_api.cc +++ b/webrtc/modules/audio_device/test/audio_device_test_api.cc @@ -82,17 +82,16 @@ class AudioTransportAPI: public AudioTransport { ~AudioTransportAPI() {} - virtual int32_t RecordedDataIsAvailable( - const void* audioSamples, - const uint32_t nSamples, - const uint8_t nBytesPerSample, - const uint8_t nChannels, - const uint32_t sampleRate, - const uint32_t totalDelay, - const int32_t clockSkew, - const uint32_t currentMicLevel, - const bool keyPressed, - uint32_t& newMicLevel) { + int32_t RecordedDataIsAvailable(const void* audioSamples, + const uint32_t nSamples, + const uint8_t nBytesPerSample, + const uint8_t nChannels, + const uint32_t sampleRate, + const uint32_t totalDelay, + const int32_t clockSkew, + const uint32_t currentMicLevel, + const bool keyPressed, + uint32_t& newMicLevel) override { rec_count_++; if (rec_count_ % 100 == 0) { if (nChannels == 1) { @@ -109,15 +108,14 @@ class AudioTransportAPI: public AudioTransport { return 0; } - virtual int32_t NeedMorePlayData( - const uint32_t nSamples, - const uint8_t nBytesPerSample, - const uint8_t nChannels, - const uint32_t sampleRate, - void* audioSamples, - uint32_t& nSamplesOut, - int64_t* elapsed_time_ms, - int64_t* ntp_time_ms) { + int32_t NeedMorePlayData(const uint32_t nSamples, + const uint8_t nBytesPerSample, + const uint8_t nChannels, + const uint32_t sampleRate, + void* audioSamples, + uint32_t& nSamplesOut, + int64_t* elapsed_time_ms, + int64_t* ntp_time_ms) override { play_count_++; if (play_count_ % 100 == 0) { if (nChannels == 1) { @@ -130,29 +128,29 @@ class AudioTransportAPI: public AudioTransport { return 0; } - virtual int OnDataAvailable(const int voe_channels[], - int number_of_voe_channels, - const int16_t* audio_data, - int sample_rate, - int number_of_channels, - int number_of_frames, - int audio_delay_milliseconds, - int current_volume, - bool key_pressed, - bool need_audio_processing) { + int OnDataAvailable(const int voe_channels[], + int number_of_voe_channels, + const int16_t* audio_data, + int sample_rate, + int number_of_channels, + int number_of_frames, + int audio_delay_milliseconds, + int current_volume, + bool key_pressed, + bool need_audio_processing) override { return 0; } - virtual void PushCaptureData(int voe_channel, const void* audio_data, - int bits_per_sample, int sample_rate, - int number_of_channels, - int number_of_frames) {} + void PushCaptureData(int voe_channel, const void* audio_data, + int bits_per_sample, int sample_rate, + int number_of_channels, + int number_of_frames) override {} - virtual void PullRenderData(int bits_per_sample, int sample_rate, - int number_of_channels, int number_of_frames, - void* audio_data, - int64_t* elapsed_time_ms, - int64_t* ntp_time_ms) {} + void PullRenderData(int bits_per_sample, int sample_rate, + int number_of_channels, int number_of_frames, + void* audio_data, + int64_t* elapsed_time_ms, + int64_t* ntp_time_ms) override {} private: uint32_t rec_count_; uint32_t play_count_; diff --git a/webrtc/modules/audio_device/test/func_test_manager.cc b/webrtc/modules/audio_device/test/func_test_manager.cc index efb7e7d924..ae3cd2c186 100644 --- a/webrtc/modules/audio_device/test/func_test_manager.cc +++ b/webrtc/modules/audio_device/test/func_test_manager.cc @@ -367,8 +367,7 @@ int32_t AudioTransportImpl::NeedMorePlayData( const uint16_t nSamplesIn = packet->nSamples; const uint8_t nChannelsIn = packet->nChannels; const uint32_t samplesPerSecIn = packet->samplesPerSec; - const uint16_t nBytesPerSampleIn = - packet->nBytesPerSample; + const uint16_t nBytesPerSampleIn = packet->nBytesPerSample; int32_t fsInHz(samplesPerSecIn); int32_t fsOutHz(samplesPerSec); @@ -389,15 +388,14 @@ int32_t AudioTransportImpl::NeedMorePlayData( { _resampler.Push( (const int16_t*) packet->dataBuffer, - 2 * nSamplesIn, - (int16_t*) audioSamples, 2 - * nSamples, lenOut); + 2 * nSamplesIn, (int16_t*) audioSamples, + 2 * nSamples, lenOut); } else { _resampler.Push( (const int16_t*) packet->dataBuffer, - 2 * nSamplesIn, tmpBuf_96kHz, 2 - * nSamples, lenOut); + 2 * nSamplesIn, tmpBuf_96kHz, 2 * nSamples, + lenOut); ptr16In = &tmpBuf_96kHz[0]; ptr16Out = (int16_t*) audioSamples; @@ -429,16 +427,13 @@ int32_t AudioTransportImpl::NeedMorePlayData( if (nChannels == 1) { _resampler.Push( - (const int16_t*) packet->dataBuffer, - nSamplesIn, - (int16_t*) audioSamples, - nSamples, lenOut); + (const int16_t*) packet->dataBuffer, nSamplesIn, + (int16_t*) audioSamples, nSamples, lenOut); } else { _resampler.Push( - (const int16_t*) packet->dataBuffer, - nSamplesIn, tmpBuf_96kHz, nSamples, - lenOut); + (const int16_t*) packet->dataBuffer, nSamplesIn, + tmpBuf_96kHz, nSamples, lenOut); ptr16In = &tmpBuf_96kHz[0]; ptr16Out = (int16_t*) audioSamples; @@ -472,8 +467,7 @@ int32_t AudioTransportImpl::NeedMorePlayData( int16_t fileBuf[480]; // read mono-file - int32_t len = _playFile.Read((int8_t*) fileBuf, 2 - * nSamples); + int32_t len = _playFile.Read((int8_t*) fileBuf, 2 * nSamples); if (len != 2 * (int32_t) nSamples) { _playFile.Rewind(); diff --git a/webrtc/modules/audio_device/test/func_test_manager.h b/webrtc/modules/audio_device/test/func_test_manager.h index 5ff62cd90a..f5ddd3a21d 100644 --- a/webrtc/modules/audio_device/test/func_test_manager.h +++ b/webrtc/modules/audio_device/test/func_test_manager.h @@ -85,48 +85,47 @@ public: class AudioTransportImpl: public AudioTransport { public: - virtual int32_t - RecordedDataIsAvailable(const void* audioSamples, - const uint32_t nSamples, - const uint8_t nBytesPerSample, - const uint8_t nChannels, - const uint32_t samplesPerSec, - const uint32_t totalDelayMS, - const int32_t clockDrift, - const uint32_t currentMicLevel, - const bool keyPressed, - uint32_t& newMicLevel); + int32_t RecordedDataIsAvailable(const void* audioSamples, + const uint32_t nSamples, + const uint8_t nBytesPerSample, + const uint8_t nChannels, + const uint32_t samplesPerSec, + const uint32_t totalDelayMS, + const int32_t clockDrift, + const uint32_t currentMicLevel, + const bool keyPressed, + uint32_t& newMicLevel) override; - virtual int32_t NeedMorePlayData(const uint32_t nSamples, - const uint8_t nBytesPerSample, - const uint8_t nChannels, - const uint32_t samplesPerSec, - void* audioSamples, - uint32_t& nSamplesOut, - int64_t* elapsed_time_ms, - int64_t* ntp_time_ms); + int32_t NeedMorePlayData(const uint32_t nSamples, + const uint8_t nBytesPerSample, + const uint8_t nChannels, + const uint32_t samplesPerSec, + void* audioSamples, + uint32_t& nSamplesOut, + int64_t* elapsed_time_ms, + int64_t* ntp_time_ms) override; - virtual int OnDataAvailable(const int voe_channels[], - int number_of_voe_channels, - const int16_t* audio_data, - int sample_rate, - int number_of_channels, - int number_of_frames, - int audio_delay_milliseconds, - int current_volume, - bool key_pressed, - bool need_audio_processing); + int OnDataAvailable(const int voe_channels[], + int number_of_voe_channels, + const int16_t* audio_data, + int sample_rate, + int number_of_channels, + int number_of_frames, + int audio_delay_milliseconds, + int current_volume, + bool key_pressed, + bool need_audio_processing) override; - virtual void PushCaptureData(int voe_channel, const void* audio_data, - int bits_per_sample, int sample_rate, - int number_of_channels, - int number_of_frames); + void PushCaptureData(int voe_channel, const void* audio_data, + int bits_per_sample, int sample_rate, + int number_of_channels, + int number_of_frames) override; - virtual void PullRenderData(int bits_per_sample, int sample_rate, - int number_of_channels, int number_of_frames, - void* audio_data, - int64_t* elapsed_time_ms, - int64_t* ntp_time_ms); + void PullRenderData(int bits_per_sample, int sample_rate, + int number_of_channels, int number_of_frames, + void* audio_data, + int64_t* elapsed_time_ms, + int64_t* ntp_time_ms) override; AudioTransportImpl(AudioDeviceModule* audioDevice); ~AudioTransportImpl(); diff --git a/webrtc/modules/audio_processing/aec/aec_resampler.c b/webrtc/modules/audio_processing/aec/aec_resampler.c index cef262edc1..62a830ba65 100644 --- a/webrtc/modules/audio_processing/aec/aec_resampler.c +++ b/webrtc/modules/audio_processing/aec/aec_resampler.c @@ -74,7 +74,8 @@ void WebRtcAec_ResampleLinear(void* resampInst, 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 ec16aaf1d3..a39fd2c9d5 100644 --- a/webrtc/modules/audio_processing/aec/echo_cancellation.c +++ b/webrtc/modules/audio_processing/aec/echo_cancellation.c @@ -270,7 +270,7 @@ int32_t WebRtcAec_BufferFarend(void* aecInst, 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 8c8fc31552..e5eb390170 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 @@ class AgcAudioProc { 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 ec5e2279ce..04dcaea799 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 @@ AudioBuffer::AudioBuffer(int input_num_frames, 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 @@ int AudioBuffer::num_bands() const { // 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 dbc1f25db9..895294dc60 100644 --- a/webrtc/modules/audio_processing/audio_processing_impl.h +++ b/webrtc/modules/audio_processing/audio_processing_impl.h @@ -49,9 +49,7 @@ class Event; 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 1bd7af4adf..652f0fea00 100644 --- a/webrtc/modules/audio_processing/ns/ns_core.c +++ b/webrtc/modules/audio_processing/ns/ns_core.c @@ -606,8 +606,8 @@ static void ComputeSpectralDifference(NoiseSuppressionC* self, // 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 @@ static void ComputeSpectralDifference(NoiseSuppressionC* self, (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 @@ void WebRtcNs_AnalyzeCore(NoiseSuppressionC* self, const float* speechFrame) { } } } - signalEnergy = signalEnergy / ((float)self->magnLen); + signalEnergy /= self->magnLen; self->signalEnergy = signalEnergy; self->sumMagn = sumMagn; @@ -1108,9 +1108,9 @@ void WebRtcNs_AnalyzeCore(NoiseSuppressionC* self, const float* speechFrame) { // 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 @@ void WebRtcNs_AnalyzeCore(NoiseSuppressionC* self, const float* speechFrame) { } 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 f6711b5be3..0f9894e9fc 100644 --- a/webrtc/modules/audio_processing/ns/nsx_core.c +++ b/webrtc/modules/audio_processing/ns/nsx_core.c @@ -1215,7 +1215,8 @@ void WebRtcNsx_DataAnalysis(NoiseSuppressionFixedC* inst, 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 @@ void WebRtcNsx_DataSynthesis(NoiseSuppressionFixedC* inst, short* outFrame) { 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 22b4ff1f72..0498cc688a 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 diff --git a/webrtc/modules/interface/module_common_types.h b/webrtc/modules/interface/module_common_types.h index 9222155185..1202eee043 100644 --- a/webrtc/modules/interface/module_common_types.h +++ b/webrtc/modules/interface/module_common_types.h @@ -427,11 +427,14 @@ inline void AudioFrame::Reset() { interleaved_ = true; } -inline void AudioFrame::UpdateFrame(int id, uint32_t timestamp, +inline void AudioFrame::UpdateFrame(int id, + uint32_t timestamp, const int16_t* data, - int samples_per_channel, int sample_rate_hz, + int samples_per_channel, + int sample_rate_hz, SpeechType speech_type, - VADActivity vad_activity, int num_channels, + VADActivity vad_activity, + int num_channels, uint32_t energy) { id_ = id; timestamp_ = timestamp; diff --git a/webrtc/modules/utility/source/file_recorder_impl.cc b/webrtc/modules/utility/source/file_recorder_impl.cc index 0a2c9a0886..e86afc6972 100644 --- a/webrtc/modules/utility/source/file_recorder_impl.cc +++ b/webrtc/modules/utility/source/file_recorder_impl.cc @@ -227,11 +227,7 @@ int32_t FileRecorderImpl::RecordAudioToFile( // will be available. Wait until then. if (encodedLenInBytes) { - uint16_t msOfData = - ptrAudioFrame->samples_per_channel_ / - uint16_t(ptrAudioFrame->sample_rate_hz_ / 1000); - if (WriteEncodedAudioData(_audioBuffer, encodedLenInBytes, msOfData, - playoutTS) == -1) + if (WriteEncodedAudioData(_audioBuffer, encodedLenInBytes) == -1) { return -1; } @@ -264,11 +260,8 @@ int32_t FileRecorderImpl::codec_info(CodecInst& codecInst) const return 0; } -int32_t FileRecorderImpl::WriteEncodedAudioData( - const int8_t* audioBuffer, - size_t bufferLength, - uint16_t /*millisecondsOfData*/, - const TickTime* /*playoutTS*/) +int32_t FileRecorderImpl::WriteEncodedAudioData(const int8_t* audioBuffer, + size_t bufferLength) { return _moduleFile->IncomingAudioData(audioBuffer, bufferLength); } diff --git a/webrtc/modules/utility/source/file_recorder_impl.h b/webrtc/modules/utility/source/file_recorder_impl.h index 70aa9f4a5e..1e83899be4 100644 --- a/webrtc/modules/utility/source/file_recorder_impl.h +++ b/webrtc/modules/utility/source/file_recorder_impl.h @@ -77,11 +77,8 @@ public: } protected: - virtual int32_t WriteEncodedAudioData( - const int8_t* audioBuffer, - size_t bufferLength, - uint16_t millisecondsOfData, - const TickTime* playoutTS); + int32_t WriteEncodedAudioData(const int8_t* audioBuffer, + size_t bufferLength); int32_t SetUpAudioEncoder(); diff --git a/webrtc/modules/video_coding/main/test/release_test.h b/webrtc/modules/video_coding/main/test/release_test.h index 25781602c1..e90dcaef01 100644 --- a/webrtc/modules/video_coding/main/test/release_test.h +++ b/webrtc/modules/video_coding/main/test/release_test.h @@ -14,4 +14,4 @@ int ReleaseTest(); int ReleaseTestPart2(); -#endif \ No newline at end of file +#endif diff --git a/webrtc/system_wrappers/interface/aligned_array.h b/webrtc/system_wrappers/interface/aligned_array.h index 4b5c276d43..0acf53f481 100644 --- a/webrtc/system_wrappers/interface/aligned_array.h +++ b/webrtc/system_wrappers/interface/aligned_array.h @@ -68,14 +68,6 @@ template class AlignedArray { return Row(row)[col]; } - int rows() const { - return rows_; - } - - int cols() const { - return cols_; - } - private: int rows_; int cols_; diff --git a/webrtc/test/fake_audio_device.cc b/webrtc/test/fake_audio_device.cc index bf89860f0b..bea125b14c 100644 --- a/webrtc/test/fake_audio_device.cc +++ b/webrtc/test/fake_audio_device.cc @@ -115,9 +115,10 @@ void FakeAudioDevice::CaptureAudio() { uint32_t samples_needed = kFrequencyHz / 100; int64_t now_ms = clock_->TimeInMilliseconds(); uint32_t time_since_last_playout_ms = now_ms - last_playout_ms_; - if (last_playout_ms_ > 0 && time_since_last_playout_ms > 0) + if (last_playout_ms_ > 0 && time_since_last_playout_ms > 0) { samples_needed = std::min(kFrequencyHz / time_since_last_playout_ms, kBufferSizeBytes / 2); + } uint32_t samples_out = 0; int64_t elapsed_time_ms = -1; int64_t ntp_time_ms = -1; diff --git a/webrtc/tools/agc/activity_metric.cc b/webrtc/tools/agc/activity_metric.cc index a51216acd9..57e2ad615f 100644 --- a/webrtc/tools/agc/activity_metric.cc +++ b/webrtc/tools/agc/activity_metric.cc @@ -292,7 +292,7 @@ void void_main(int argc, char* argv[]) { ASSERT_GE(ret_val, 0); if (ret_val > 0) { - ASSERT_TRUE(ret_val == true_vad_index); + ASSERT_EQ(true_vad_index, ret_val); for (int n = 0; n < ret_val; n++) { if (true_vad[n] == 1) { total_active++; diff --git a/webrtc/voice_engine/test/auto_test/standard/external_media_test.cc b/webrtc/voice_engine/test/auto_test/standard/external_media_test.cc index af81499892..f586b0e42d 100644 --- a/webrtc/voice_engine/test/auto_test/standard/external_media_test.cc +++ b/webrtc/voice_engine/test/auto_test/standard/external_media_test.cc @@ -8,6 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include "webrtc/base/arraysize.h" #include "webrtc/modules/interface/module_common_types.h" #include "webrtc/voice_engine/include/voe_external_media.h" #include "webrtc/voice_engine/test/auto_test/fakes/fake_media_process.h" @@ -81,8 +82,8 @@ TEST_F(ExternalMediaTest, EXPECT_EQ(0, voe_xmedia_->SetExternalMixing(channel_, true)); ResumePlaying(); EXPECT_EQ(0, voe_xmedia_->GetAudioFrame(channel_, 0, &frame)); - EXPECT_LT(0, frame.sample_rate_hz_); - EXPECT_LT(0, frame.samples_per_channel_); + EXPECT_GT(frame.sample_rate_hz_, 0); + EXPECT_GT(frame.samples_per_channel_, 0); PausePlaying(); EXPECT_EQ(0, voe_xmedia_->SetExternalMixing(channel_, false)); ResumePlaying(); @@ -95,7 +96,7 @@ TEST_F(ExternalMediaTest, PausePlaying(); EXPECT_EQ(0, voe_xmedia_->SetExternalMixing(channel_, true)); ResumePlaying(); - for (size_t i = 0; i < sizeof(kValidFrequencies) / sizeof(int); i++) { + for (size_t i = 0; i < arraysize(kValidFrequencies); i++) { int f = kValidFrequencies[i]; EXPECT_EQ(0, voe_xmedia_->GetAudioFrame(channel_, f, &frame)) << "Resampling succeeds for freq=" << f; @@ -114,7 +115,7 @@ TEST_F(ExternalMediaTest, PausePlaying(); EXPECT_EQ(0, voe_xmedia_->SetExternalMixing(channel_, true)); ResumePlaying(); - for (size_t i = 0; i < sizeof(kInvalidFrequencies) / sizeof(int); i++) { + for (size_t i = 0; i < arraysize(kInvalidFrequencies); i++) { int f = kInvalidFrequencies[i]; EXPECT_EQ(-1, voe_xmedia_->GetAudioFrame(channel_, f, &frame)) << "Resampling fails for freq=" << f;