diff options
| author | 2018-01-11 19:21:20 -0700 | |
|---|---|---|
| committer | 2018-01-12 19:11:03 -0700 | |
| commit | ebf9a784a9f7f4148a669dbb39e7cd50df779a14 (patch) | |
| tree | d585685a1c0a34b903af1d086d62560bf56bb29f /src/audio_core/interpolate.cpp | |
| parent | config: Default CPU core to Unicorn. (diff) | |
| download | yuzu-ebf9a784a9f7f4148a669dbb39e7cd50df779a14.tar.gz yuzu-ebf9a784a9f7f4148a669dbb39e7cd50df779a14.tar.xz yuzu-ebf9a784a9f7f4148a669dbb39e7cd50df779a14.zip | |
Massive removal of unused modules
Diffstat (limited to 'src/audio_core/interpolate.cpp')
| -rw-r--r-- | src/audio_core/interpolate.cpp | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/src/audio_core/interpolate.cpp b/src/audio_core/interpolate.cpp deleted file mode 100644 index 83573d772..000000000 --- a/src/audio_core/interpolate.cpp +++ /dev/null | |||
| @@ -1,76 +0,0 @@ | |||
| 1 | // Copyright 2016 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "audio_core/interpolate.h" | ||
| 6 | #include "common/assert.h" | ||
| 7 | #include "common/math_util.h" | ||
| 8 | |||
| 9 | namespace AudioInterp { | ||
| 10 | |||
| 11 | // Calculations are done in fixed point with 24 fractional bits. | ||
| 12 | // (This is not verified. This was chosen for minimal error.) | ||
| 13 | constexpr u64 scale_factor = 1 << 24; | ||
| 14 | constexpr u64 scale_mask = scale_factor - 1; | ||
| 15 | |||
| 16 | /// Here we step over the input in steps of rate, until we consume all of the input. | ||
| 17 | /// Three adjacent samples are passed to fn each step. | ||
| 18 | template <typename Function> | ||
| 19 | static void StepOverSamples(State& state, StereoBuffer16& input, float rate, | ||
| 20 | DSP::HLE::StereoFrame16& output, size_t& outputi, Function fn) { | ||
| 21 | ASSERT(rate > 0); | ||
| 22 | |||
| 23 | if (input.empty()) | ||
| 24 | return; | ||
| 25 | |||
| 26 | input.insert(input.begin(), {state.xn2, state.xn1}); | ||
| 27 | |||
| 28 | const u64 step_size = static_cast<u64>(rate * scale_factor); | ||
| 29 | u64 fposition = state.fposition; | ||
| 30 | size_t inputi = 0; | ||
| 31 | |||
| 32 | while (outputi < output.size()) { | ||
| 33 | inputi = static_cast<size_t>(fposition / scale_factor); | ||
| 34 | |||
| 35 | if (inputi + 2 >= input.size()) { | ||
| 36 | inputi = input.size() - 2; | ||
| 37 | break; | ||
| 38 | } | ||
| 39 | |||
| 40 | u64 fraction = fposition & scale_mask; | ||
| 41 | output[outputi++] = fn(fraction, input[inputi], input[inputi + 1], input[inputi + 2]); | ||
| 42 | |||
| 43 | fposition += step_size; | ||
| 44 | } | ||
| 45 | |||
| 46 | state.xn2 = input[inputi]; | ||
| 47 | state.xn1 = input[inputi + 1]; | ||
| 48 | state.fposition = fposition - inputi * scale_factor; | ||
| 49 | |||
| 50 | input.erase(input.begin(), std::next(input.begin(), inputi + 2)); | ||
| 51 | } | ||
| 52 | |||
| 53 | void None(State& state, StereoBuffer16& input, float rate, DSP::HLE::StereoFrame16& output, | ||
| 54 | size_t& outputi) { | ||
| 55 | StepOverSamples( | ||
| 56 | state, input, rate, output, outputi, | ||
| 57 | [](u64 fraction, const auto& x0, const auto& x1, const auto& x2) { return x0; }); | ||
| 58 | } | ||
| 59 | |||
| 60 | void Linear(State& state, StereoBuffer16& input, float rate, DSP::HLE::StereoFrame16& output, | ||
| 61 | size_t& outputi) { | ||
| 62 | // Note on accuracy: Some values that this produces are +/- 1 from the actual firmware. | ||
| 63 | StepOverSamples(state, input, rate, output, outputi, | ||
| 64 | [](u64 fraction, const auto& x0, const auto& x1, const auto& x2) { | ||
| 65 | // This is a saturated subtraction. (Verified by black-box fuzzing.) | ||
| 66 | s64 delta0 = MathUtil::Clamp<s64>(x1[0] - x0[0], -32768, 32767); | ||
| 67 | s64 delta1 = MathUtil::Clamp<s64>(x1[1] - x0[1], -32768, 32767); | ||
| 68 | |||
| 69 | return std::array<s16, 2>{ | ||
| 70 | static_cast<s16>(x0[0] + fraction * delta0 / scale_factor), | ||
| 71 | static_cast<s16>(x0[1] + fraction * delta1 / scale_factor), | ||
| 72 | }; | ||
| 73 | }); | ||
| 74 | } | ||
| 75 | |||
| 76 | } // namespace AudioInterp | ||