Avoid passing a very oversize outcount for the reasons given

This commit is contained in:
Chris Cannam
2020-10-21 16:50:19 +01:00
parent 3ddc35f7ae
commit ce5b79bb45

View File

@@ -699,6 +699,20 @@ D_SRC::resampleInterleaved(float *const R__ out,
data.input_frames = incount; data.input_frames = incount;
data.output_frames = outcount; data.output_frames = outcount;
// libsamplerate smooths the filter change over the duration of
// the processing block to avoid artifacts due to sudden changes,
// and it uses outcount to determine how long to smooth the change
// over. This is a good thing in principle, but it does mean (a)
// we should never pass outcount significantly longer than the
// actual expected output, and (b) when the ratio has just
// changed, we should aim to supply a shortish block next (this
// part still todo!)
if (data.output_frames > int(ceil(incount * ratio) + 10)) {
data.output_frames = int(ceil(incount * ratio) + 10);
}
data.src_ratio = ratio; data.src_ratio = ratio;
data.end_of_input = (final ? 1 : 0); data.end_of_input = (final ? 1 : 0);