From f956df23bbbf1b7f633e48c3eee6c8cd91aa3c37 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 17 Dec 2016 16:15:24 -0500 Subject: [PATCH] audio: fixed arbitrary upsampling (thanks, Sylvain!). This was a leftover of simplifying the resamplers down from autogenerated code; I forgot to make something that the generator hardcoded into something variable. Fixes Bugzilla #3507. --- src/audio/SDL_audiotypecvt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/audio/SDL_audiotypecvt.c b/src/audio/SDL_audiotypecvt.c index 384f50faad7b9..cddcda8e697f4 100644 --- a/src/audio/SDL_audiotypecvt.c +++ b/src/audio/SDL_audiotypecvt.c @@ -222,8 +222,8 @@ SDL_Upsample_Arbitrary(SDL_AudioCVT *cvt, const int channels) const int srcsize = cvt->len_cvt - (64 * channels); const int dstsize = (int) (((double)(cvt->len_cvt/(channels*4))) * cvt->rate_incr) * (channels*4); register int eps = 0; - float *dst = ((float *) (cvt->buf + dstsize)) - 8; - const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8; + float *dst = ((float *) (cvt->buf + dstsize)) - channels; + const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - channels; const float *target = ((const float *) cvt->buf); const size_t cpy = sizeof (float) * channels; float last_sample[8]; @@ -241,10 +241,10 @@ SDL_Upsample_Arbitrary(SDL_AudioCVT *cvt, const int channels) while (dst > target) { SDL_memcpy(dst, sample, cpy); - dst -= 8; + dst -= channels; eps += srcsize; if ((eps << 1) >= dstsize) { - src -= 8; + src -= channels; for (i = 0; i < channels; i++) { sample[i] = (float) ((((double) src[i]) + ((double) last_sample[i])) * 0.5); }