From 941636b87bf288114a69c67161bb714eae2751f6 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 13 Mar 2023 12:27:10 +0100 Subject: [PATCH] pcm/Normalizer: eliminate local variable `ap` --- src/pcm/Normalizer.cxx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/pcm/Normalizer.cxx b/src/pcm/Normalizer.cxx index 866c11d49..025c44be9 100644 --- a/src/pcm/Normalizer.cxx +++ b/src/pcm/Normalizer.cxx @@ -7,7 +7,6 @@ void PcmNormalizer::ProcessS16(int16_t *audio, std::size_t count) noexcept { - int16_t *ap; std::size_t i; int curGain = gain[pos]; int newGain; @@ -18,10 +17,9 @@ PcmNormalizer::ProcessS16(int16_t *audio, std::size_t count) noexcept std::size_t ramp = count; int delta; - ap = audio; for (i = 0; i < count; i++) { - int val = *ap++; + int val = audio[i]; if (val < 0) val = -val; if (val > peakVal) @@ -73,14 +71,13 @@ PcmNormalizer::ProcessS16(int16_t *audio, std::size_t count) noexcept curGain = 1 << 10; delta = (newGain - curGain) / (int)ramp; - ap = audio; *clipped_ = 0; for (i = 0; i < count; i++) { int sample; //! Amplify the sample - sample = *ap*curGain >> 10; + sample = audio[i] * curGain >> 10; if (sample < -32768) { *clipped_ += -32768 - sample; @@ -90,7 +87,7 @@ PcmNormalizer::ProcessS16(int16_t *audio, std::size_t count) noexcept *clipped_ += sample - 32767; sample = 32767; } - *ap++ = sample; + audio[i] = sample; //! Adjust the gain if (i < ramp)