pcm/SoxrResampler: round output buffer size up
The old formula calculates the output buffer size with "regular" rounding (to the nearest integer), however sometimes, that is insufficient and the last sample cannot be resampled. This causes audible distortions. By changing the formula to consider the worst case (always round up), this problem is eliminated.
This commit is contained in:
parent
8ff0d99092
commit
8d036c4b7c
1
NEWS
1
NEWS
|
@ -9,6 +9,7 @@ ver 0.19.3 (not yet released)
|
|||
- audiofile: fix crash while playing streams
|
||||
- audiofile: fix bit rate calculation
|
||||
- ffmpeg: support opus
|
||||
* fix distorted audio with soxr resampler
|
||||
|
||||
ver 0.19.2 (2014/11/02)
|
||||
* input
|
||||
|
|
|
@ -147,7 +147,8 @@ SoxrPcmResampler::Resample(ConstBuffer<void> src, Error &error)
|
|||
|
||||
const size_t n_frames = src.size / frame_size;
|
||||
|
||||
const size_t o_frames = size_t(n_frames * ratio + 0.5);
|
||||
/* always round up: worst case output buffer size */
|
||||
const size_t o_frames = size_t(n_frames * ratio) + 1;
|
||||
|
||||
float *output_buffer = (float *)buffer.Get(o_frames * frame_size);
|
||||
|
||||
|
|
Loading…
Reference in New Issue