diff options
| author | 2016-09-21 11:29:48 -0700 | |
|---|---|---|
| committer | 2016-09-21 11:29:48 -0700 | |
| commit | d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a (patch) | |
| tree | 8a22ca73ff838f3f0090b29a548ae81087fc90ed /src/audio_core/interpolate.cpp | |
| parent | README: Specify master branch for Travis CI badge (diff) | |
| parent | Fix Travis clang-format check (diff) | |
| download | yuzu-d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a.tar.gz yuzu-d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a.tar.xz yuzu-d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a.zip | |
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 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "audio_core/interpolate.h" | 5 | #include "audio_core/interpolate.h" |
| 6 | |||
| 7 | #include "common/assert.h" | 6 | #include "common/assert.h" |
| 8 | #include "common/math_util.h" | 7 | #include "common/math_util.h" |
| 9 | 8 | ||
| @@ -17,7 +16,8 @@ constexpr u64 scale_mask = scale_factor - 1; | |||
| 17 | /// Here we step over the input in steps of rate_multiplier, until we consume all of the input. | 16 | /// Here we step over the input in steps of rate_multiplier, until we consume all of the input. |
| 18 | /// Three adjacent samples are passed to fn each step. | 17 | /// Three adjacent samples are passed to fn each step. |
| 19 | template <typename Function> | 18 | template <typename Function> |
| 20 | static StereoBuffer16 StepOverSamples(State& state, const StereoBuffer16& input, float rate_multiplier, Function fn) { | 19 | static StereoBuffer16 StepOverSamples(State& state, const StereoBuffer16& input, |
| 20 | float rate_multiplier, Function fn) { | ||
| 21 | ASSERT(rate_multiplier > 0); | 21 | ASSERT(rate_multiplier > 0); |
| 22 | 22 | ||
| 23 | if (input.size() < 2) | 23 | if (input.size() < 2) |
| @@ -63,23 +63,24 @@ static StereoBuffer16 StepOverSamples(State& state, const StereoBuffer16& input, | |||
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | StereoBuffer16 None(State& state, const StereoBuffer16& input, float rate_multiplier) { | 65 | StereoBuffer16 None(State& state, const StereoBuffer16& input, float rate_multiplier) { |
| 66 | return StepOverSamples(state, input, rate_multiplier, [](u64 fraction, const auto& x0, const auto& x1, const auto& x2) { | 66 | return StepOverSamples( |
| 67 | return x0; | 67 | state, input, rate_multiplier, |
| 68 | }); | 68 | [](u64 fraction, const auto& x0, const auto& x1, const auto& x2) { return x0; }); |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | StereoBuffer16 Linear(State& state, const StereoBuffer16& input, float rate_multiplier) { | 71 | StereoBuffer16 Linear(State& state, const StereoBuffer16& input, float rate_multiplier) { |
| 72 | // Note on accuracy: Some values that this produces are +/- 1 from the actual firmware. | 72 | // Note on accuracy: Some values that this produces are +/- 1 from the actual firmware. |
| 73 | return StepOverSamples(state, input, rate_multiplier, [](u64 fraction, const auto& x0, const auto& x1, const auto& x2) { | 73 | return StepOverSamples(state, input, rate_multiplier, |
| 74 | // This is a saturated subtraction. (Verified by black-box fuzzing.) | 74 | [](u64 fraction, const auto& x0, const auto& x1, const auto& x2) { |
| 75 | s64 delta0 = MathUtil::Clamp<s64>(x1[0] - x0[0], -32768, 32767); | 75 | // This is a saturated subtraction. (Verified by black-box fuzzing.) |
| 76 | s64 delta1 = MathUtil::Clamp<s64>(x1[1] - x0[1], -32768, 32767); | 76 | s64 delta0 = MathUtil::Clamp<s64>(x1[0] - x0[0], -32768, 32767); |
| 77 | 77 | s64 delta1 = MathUtil::Clamp<s64>(x1[1] - x0[1], -32768, 32767); | |
| 78 | return std::array<s16, 2> { | 78 | |
| 79 | static_cast<s16>(x0[0] + fraction * delta0 / scale_factor), | 79 | return std::array<s16, 2>{ |
| 80 | static_cast<s16>(x0[1] + fraction * delta1 / scale_factor) | 80 | static_cast<s16>(x0[0] + fraction * delta0 / scale_factor), |
| 81 | }; | 81 | static_cast<s16>(x0[1] + fraction * delta1 / scale_factor), |
| 82 | }); | 82 | }; |
| 83 | }); | ||
| 83 | } | 84 | } |
| 84 | 85 | ||
| 85 | } // namespace AudioInterp | 86 | } // namespace AudioInterp |