mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-20 22:16:49 +01:00
audio: clamp resampler interpolation values to prevent buffer overflow.
Partially fixes Bugzilla #3848.
This commit is contained in:
parent
0085f917e0
commit
763c387149
@ -501,10 +501,9 @@ SDL_ResampleAudio(const int chans, const int inrate, const int outrate,
|
|||||||
const int srcindex = (int) (outtime * inrate);
|
const int srcindex = (int) (outtime * inrate);
|
||||||
const float intime = ((float) srcindex) / finrate;
|
const float intime = ((float) srcindex) / finrate;
|
||||||
const float innexttime = ((float) (srcindex + 1)) / finrate;
|
const float innexttime = ((float) (srcindex + 1)) / finrate;
|
||||||
|
const float interpolation1 = SDL_max(0.0f, 1.0f - (innexttime - outtime) / (innexttime - intime));
|
||||||
const float interpolation1 = 1.0f - (innexttime - outtime) / (innexttime - intime);
|
|
||||||
const int filterindex1 = (int) (interpolation1 * RESAMPLER_SAMPLES_PER_ZERO_CROSSING);
|
const int filterindex1 = (int) (interpolation1 * RESAMPLER_SAMPLES_PER_ZERO_CROSSING);
|
||||||
const float interpolation2 = 1.0f - interpolation1;
|
const float interpolation2 = SDL_max(0.0f, 1.0f - interpolation1);
|
||||||
const int filterindex2 = (int) (interpolation2 * RESAMPLER_SAMPLES_PER_ZERO_CROSSING);
|
const int filterindex2 = (int) (interpolation2 * RESAMPLER_SAMPLES_PER_ZERO_CROSSING);
|
||||||
|
|
||||||
for (chan = 0; chan < chans; chan++) {
|
for (chan = 0; chan < chans; chan++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user