diff options
| author | lizzie <lizzie@eden-emu.dev> | 2026-08-05 21:56:18 +0200 |
|---|---|---|
| committer | crueter <crueter@eden-emu.dev> | 2026-08-05 21:56:18 +0200 |
| commit | a43664c0fd9bb56d2bb4ef3b4f1943a19b767066 (patch) | |
| tree | 31449248171388176c52a43033fdd1d5a91b29bd /src/audio_core/renderer/command/resample/resample.cpp | |
| parent | a0f1cd1baf9bd56b2897b3145401ba483355cb07 (diff) | |
[audio_core] Fix jamboree crash due to OOB access (#4252)
Signed-off-by: lizzie <lizzie@eden-emu.dev>
- [x] I have read and followed the [Contribution Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/CONTRIBUTING.md#code-contributions).
- [x] I have read and followed the [AI Policy](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/AI.md)
- [x] I have read and followed the [Coding Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/Coding.md) to the best of my ability.
-------------------
PLEASE test diablo 3 or ANY game that's sensitive to audio changes
Just TEST that there's NO regressions on the audio front
this fixes a rare Jamboree crash with audio DSP
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4252
Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
Reviewed-by: Shinmegumi <shinmegumi@eden-emu.dev>
Diffstat (limited to 'src/audio_core/renderer/command/resample/resample.cpp')
| -rw-r--r-- | src/audio_core/renderer/command/resample/resample.cpp | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/src/audio_core/renderer/command/resample/resample.cpp b/src/audio_core/renderer/command/resample/resample.cpp index 51f4ba39eb..c20b5aa4a8 100644 --- a/src/audio_core/renderer/command/resample/resample.cpp +++ b/src/audio_core/renderer/command/resample/resample.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -5,21 +8,13 @@ namespace AudioCore::Renderer { -static void ResampleLowQuality(std::span<s32> output, std::span<const s16> input, - const Common::FixedPoint<49, 15>& sample_rate_ratio, - Common::FixedPoint<49, 15>& fraction, const u32 samples_to_write) { - if (sample_rate_ratio == 1.0f) { - for (u32 i = 0; i < samples_to_write; i++) { - output[i] = input[i]; - } - } else { - u32 read_index{0}; - for (u32 i = 0; i < samples_to_write; i++) { - output[i] = input[read_index + (fraction >= 0.5f)]; - fraction += sample_rate_ratio; - read_index += static_cast<u32>(fraction.to_int_floor()); - fraction.clear_int(); - } +static void ResampleLowQuality(std::span<s32> output, std::span<const s16> input, const Common::FixedPoint<49, 15>& sample_rate_ratio, Common::FixedPoint<49, 15>& fraction, const u32 samples_to_write) { + u32 read_index{0}; + for (u32 i = 0; i < samples_to_write; i++) { + output[i] = input[read_index + (fraction >= 0.5f)]; + fraction += sample_rate_ratio; + read_index += u32(fraction.to_int_floor()); + fraction.clear_int(); } } @@ -295,7 +290,7 @@ static void ResampleNormalQuality(std::span<s32> output, std::span<const s16> in auto lut{get_lut()}; u32 read_index{0}; for (u32 i = 0; i < samples_to_write; i++) { - const auto lut_index{(fraction.get_frac() >> 8) * 4}; + const auto lut_index = ((fraction.get_frac() >> 8) << 2) & 511; const Common::FixedPoint<56, 8> sample0{input[read_index + 0] * lut[lut_index + 0]}; const Common::FixedPoint<56, 8> sample1{input[read_index + 1] * lut[lut_index + 1]}; const Common::FixedPoint<56, 8> sample2{input[read_index + 2] * lut[lut_index + 2]}; @@ -845,7 +840,7 @@ static void ResampleHighQuality(std::span<s32> output, std::span<const s16> inpu auto lut{get_lut()}; u32 read_index{0}; for (u32 i = 0; i < samples_to_write; i++) { - const auto lut_index{(fraction.get_frac() >> 8) * 8}; + const auto lut_index = ((fraction.get_frac() >> 8) << 3) & 1023; const Common::FixedPoint<56, 8> sample0{input[read_index + 0] * lut[lut_index + 0]}; const Common::FixedPoint<56, 8> sample1{input[read_index + 1] * lut[lut_index + 1]}; const Common::FixedPoint<56, 8> sample2{input[read_index + 2] * lut[lut_index + 2]}; |
