resample: fix off-by-one

Don't use the previously skipped sample to calculate the remaining
amount of samples or else we remove one sample too much in some cases
and cause distortion, mostly when downsampling.

Fixes #1646
This commit is contained in:
Wim Taymans 2021-09-28 15:31:07 +02:00
parent b3646743c1
commit 4d85e6aead

View file

@ -261,10 +261,10 @@ static void impl_native_process(struct resample *r,
in = *in_len; in = *in_len;
data->func(r, src, skip, &in, dst, out, out_len); data->func(r, src, skip, &in, dst, out, out_len);
spa_log_trace_fp(r->log, "native %p: in:%d/%d out %d/%d", spa_log_trace_fp(r->log, "native %p: in:%d/%d out %d/%d skip:%d",
r, *in_len, in, *out_len, out); r, *in_len, in, *out_len, out, skip);
remain = *in_len - skip - in; remain = *in_len - in;
if (remain > 0 && remain <= n_taps) { if (remain > 0 && remain <= n_taps) {
/* not enough input data remaining for more output, /* not enough input data remaining for more output,
* copy to history */ * copy to history */