summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMerry <git@mary.rs>2023-01-14 16:19:11 +0100
committerMerry <git@mary.rs>2023-01-14 16:19:11 +0100
commit122a8faa38be83c55a7ab0eaee548b1dffcf9c05 (patch)
tree3a172d939894fa198a14e16149435531aff85e58
parentMerge pull request #9605 from german77/mouse_mapping (diff)
downloadyuzu-122a8faa38be83c55a7ab0eaee548b1dffcf9c05.tar
yuzu-122a8faa38be83c55a7ab0eaee548b1dffcf9c05.tar.gz
yuzu-122a8faa38be83c55a7ab0eaee548b1dffcf9c05.tar.bz2
yuzu-122a8faa38be83c55a7ab0eaee548b1dffcf9c05.tar.lz
yuzu-122a8faa38be83c55a7ab0eaee548b1dffcf9c05.tar.xz
yuzu-122a8faa38be83c55a7ab0eaee548b1dffcf9c05.tar.zst
yuzu-122a8faa38be83c55a7ab0eaee548b1dffcf9c05.zip
-rw-r--r--src/audio_core/renderer/command/resample/upsample.cpp45
1 files changed, 12 insertions, 33 deletions
diff --git a/src/audio_core/renderer/command/resample/upsample.cpp b/src/audio_core/renderer/command/resample/upsample.cpp
index 6c3ff31f7..1e5fd3e28 100644
--- a/src/audio_core/renderer/command/resample/upsample.cpp
+++ b/src/audio_core/renderer/command/resample/upsample.cpp
@@ -94,49 +94,28 @@ static void SrcProcessFrame(std::span<s32> output, std::span<const s32> input,
auto calculate_sample = [&state](std::span<const Common::FixedPoint<24, 8>> coeffs1,
std::span<const Common::FixedPoint<24, 8>> coeffs2) -> s32 {
auto output_index{state->history_output_index};
- auto start_pos{output_index - state->history_start_index + 1U};
- auto end_pos{10U};
+ u64 result{0};
- if (start_pos < 10) {
- end_pos = start_pos;
- }
-
- u64 prev_contrib{0};
- u32 coeff_index{0};
- for (; coeff_index < end_pos; coeff_index++, output_index--) {
- prev_contrib += static_cast<u64>(state->history[output_index].to_raw()) *
- coeffs1[coeff_index].to_raw();
- }
+ for (u32 coeff_index = 0; coeff_index < 10; coeff_index++) {
+ result += static_cast<u64>(state->history[output_index].to_raw()) *
+ coeffs1[coeff_index].to_raw();
- auto end_index{state->history_end_index};
- for (; start_pos < 9; start_pos++, coeff_index++, end_index--) {
- prev_contrib += static_cast<u64>(state->history[end_index].to_raw()) *
- coeffs1[coeff_index].to_raw();
+ output_index = output_index == state->history_start_index ? state->history_end_index
+ : output_index - 1;
}
output_index =
static_cast<u16>((state->history_output_index + 1) % UpsamplerState::HistorySize);
- start_pos = state->history_end_index - output_index + 1U;
- end_pos = 10U;
- if (start_pos < 10) {
- end_pos = start_pos;
- }
-
- u64 next_contrib{0};
- coeff_index = 0;
- for (; coeff_index < end_pos; coeff_index++, output_index++) {
- next_contrib += static_cast<u64>(state->history[output_index].to_raw()) *
- coeffs2[coeff_index].to_raw();
- }
+ for (u32 coeff_index = 0; coeff_index < 10; coeff_index++) {
+ result += static_cast<u64>(state->history[output_index].to_raw()) *
+ coeffs2[coeff_index].to_raw();
- auto start_index{state->history_start_index};
- for (; start_pos < 9; start_pos++, start_index++, coeff_index++) {
- next_contrib += static_cast<u64>(state->history[start_index].to_raw()) *
- coeffs2[coeff_index].to_raw();
+ output_index = output_index == state->history_end_index ? state->history_start_index
+ : output_index + 1;
}
- return static_cast<s32>(((prev_contrib >> 15) + (next_contrib >> 15)) >> 8);
+ return static_cast<s32>(result >> (8 + 15));
};
switch (state->ratio.to_int_floor()) {