resampler: change calculation for in/out frames needed

This commit is contained in:
Alex Chronopoulos 2016-06-21 15:41:36 +03:00
Родитель e0acbf2e5e
Коммит 2d8eb6c05a
1 изменённых файлов: 5 добавлений и 4 удалений

Просмотреть файл

@ -215,8 +215,8 @@ public:
size_t output_for_input(uint32_t input_frames)
{
return size_t(ceilf(input_frames / resampling_ratio)
- resampling_in_buffer.length() / channels);
return (size_t)floorf((input_frames + samples_to_frames(resampling_in_buffer.length()))
/ resampling_ratio);
}
/** Returns a buffer containing exactly `output_frame_count` resampled frames.
@ -263,8 +263,9 @@ public:
* number of output frames will be exactly equal. */
uint32_t input_needed_for_output(uint32_t output_frame_count)
{
return uint32_t(ceilf(output_frame_count * resampling_ratio) + 1
- samples_to_frames(resampling_in_buffer.length()));
return (uint32_t)ceilf((output_frame_count - samples_to_frames(resampling_in_buffer.length()))
* resampling_ratio);
}
/** Returns a pointer to the input buffer, that contains empty space for at