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 - Resampling non-8-bit audio may result in garbage
Summary: Resampling non-8-bit audio may result in garbage
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: audio (show other bugs)
Version: 2.0.1
Hardware: x86 Windows (XP)
: P1 major
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-10 16:18 UTC by Dávid Nagy
Modified: 2014-06-10 23:40 UTC (History)
0 users

See Also:


Attachments
Testcase demonstrating the bug and a possible fix (1.57 KB, application/zip)
2014-02-10 16:18 UTC, Dávid Nagy
Details
My proposed fix. (639 bytes, patch)
2014-06-04 16:47 UTC, Dávid Nagy
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.