Skip to content
Permalink
Browse files

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.
  • Loading branch information
icculus committed Dec 17, 2016
1 parent b515b34 commit f956df23bbbf1b7f633e48c3eee6c8cd91aa3c37
Showing with 4 additions and 4 deletions.
  1. +4 −4 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);
}

0 comments on commit f956df2

Please sign in to comment.