We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2389

Summary: Resampling non-8-bit audio may result in garbage
Product: SDL Reporter: Dávid Nagy <nagydavid91>
Component: audioAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: major    
Priority: P1    
Version: 2.0.1   
Hardware: x86   
OS: Windows (XP)   
Attachments: Testcase demonstrating the bug and a possible fix
My proposed fix.

Description Dávid Nagy 2014-02-10 16:18:15 UTC
Created attachment 1554 [details]
Testcase demonstrating the bug and a possible fix

When resampling, the calculation of the new size ignores the size of the samples (and the number of channels).
    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
This might result in a size that is not a multiple of the sample size.
And since upsampling is done from the end to the beginning, the new samples will start at the wrong place.
Comment 1 Sam Lantinga 2014-02-23 01:48:29 UTC
Ryan, can you look at this for the 2.0.2 release?

Thanks!
Comment 2 Dávid Nagy 2014-06-04 16:47:22 UTC
Created attachment 1669 [details]
My proposed fix.

Apply to SDL2-2.0.1/src/audio/sdlgenaudiocvt.pl
Comment 3 Ryan C. Gordon 2014-06-10 23:40:10 UTC
(In reply to nagydavid91+sdl-bugzilla from comment #2)
> Created attachment 1669 [details]
> My proposed fix.

This patch is now https://hg.libsdl.org/SDL/rev/5da12bedaace ...thanks!

--ryan.