diff options
author | Yuri Kunde Schlesner <yuriks@yuriks.net> | 2016-09-21 11:29:48 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-21 11:29:48 -0700 |
commit | d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a (patch) | |
tree | 8a22ca73ff838f3f0090b29a548ae81087fc90ed /src/audio_core/interpolate.cpp | |
parent | 2a910a6d883f2227edc74aacf5b93a58a3dea07c (diff) | |
parent | 0e3f0120a8ec2996e73bb6b7b6c9d7531f7a7eb1 (diff) |
Merge pull request #2086 from linkmauve/clang-format
Add clang-format as part of our {commit,travis}-time checks
Diffstat (limited to 'src/audio_core/interpolate.cpp')
-rw-r--r-- | src/audio_core/interpolate.cpp | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/audio_core/interpolate.cpp b/src/audio_core/interpolate.cpp index fcd3aa066..8a5d4181a 100644 --- a/src/audio_core/interpolate.cpp +++ b/src/audio_core/interpolate.cpp @@ -3,7 +3,6 @@ // Refer to the license.txt file included. #include "audio_core/interpolate.h" - #include "common/assert.h" #include "common/math_util.h" @@ -17,7 +16,8 @@ constexpr u64 scale_mask = scale_factor - 1; /// Here we step over the input in steps of rate_multiplier, until we consume all of the input. /// Three adjacent samples are passed to fn each step. template <typename Function> -static StereoBuffer16 StepOverSamples(State& state, const StereoBuffer16& input, float rate_multiplier, Function fn) { +static StereoBuffer16 StepOverSamples(State& state, const StereoBuffer16& input, + float rate_multiplier, Function fn) { ASSERT(rate_multiplier > 0); if (input.size() < 2) @@ -63,23 +63,24 @@ static StereoBuffer16 StepOverSamples(State& state, const StereoBuffer16& input, } StereoBuffer16 None(State& state, const StereoBuffer16& input, float rate_multiplier) { - return StepOverSamples(state, input, rate_multiplier, [](u64 fraction, const auto& x0, const auto& x1, const auto& x2) { - return x0; - }); + return StepOverSamples( + state, input, rate_multiplier, + [](u64 fraction, const auto& x0, const auto& x1, const auto& x2) { return x0; }); } StereoBuffer16 Linear(State& state, const StereoBuffer16& input, float rate_multiplier) { // Note on accuracy: Some values that this produces are +/- 1 from the actual firmware. - return StepOverSamples(state, input, rate_multiplier, [](u64 fraction, const auto& x0, const auto& x1, const auto& x2) { - // This is a saturated subtraction. (Verified by black-box fuzzing.) - s64 delta0 = MathUtil::Clamp<s64>(x1[0] - x0[0], -32768, 32767); - s64 delta1 = MathUtil::Clamp<s64>(x1[1] - x0[1], -32768, 32767); - - return std::array<s16, 2> { - static_cast<s16>(x0[0] + fraction * delta0 / scale_factor), - static_cast<s16>(x0[1] + fraction * delta1 / scale_factor) - }; - }); + return StepOverSamples(state, input, rate_multiplier, + [](u64 fraction, const auto& x0, const auto& x1, const auto& x2) { + // This is a saturated subtraction. (Verified by black-box fuzzing.) + s64 delta0 = MathUtil::Clamp<s64>(x1[0] - x0[0], -32768, 32767); + s64 delta1 = MathUtil::Clamp<s64>(x1[1] - x0[1], -32768, 32767); + + return std::array<s16, 2>{ + static_cast<s16>(x0[0] + fraction * delta0 / scale_factor), + static_cast<s16>(x0[1] + fraction * delta1 / scale_factor), + }; + }); } } // namespace AudioInterp |