Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 f956df2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/audio/SDL_audiotypecvt.c
Expand Up @@ -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];
Expand All @@ -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);
}
Expand Down

0 comments on commit f956df2

Please sign in to comment.