resample: completely fill resampler

start with a completely filled resampler so that the first
input byte immediately gives an output sample. When then have
n_taps/2 leading (almost) 0 samples.

Also make the passthrough resampler act like the real resampler
by introducing an n_taps/2 delay.
This commit is contained in:
Wim Taymans 2019-09-05 13:10:00 +02:00
parent b1bfc900d6
commit a232e67dd8
2 changed files with 4 additions and 3 deletions

View file

@ -59,7 +59,7 @@ void do_resample_##type##_##arch(struct resample *r, \
DEFINE_RESAMPLER(copy,arch) \ DEFINE_RESAMPLER(copy,arch) \
{ \ { \
struct native_data *data = r->data; \ struct native_data *data = r->data; \
uint32_t index, n_taps = data->n_taps; \ uint32_t index, n_taps = data->n_taps, n_taps2 = n_taps/2; \
uint32_t c, olen = *out_len, ilen = *in_len; \ uint32_t c, olen = *out_len, ilen = *in_len; \
\ \
if (r->channels == 0) \ if (r->channels == 0) \
@ -72,7 +72,8 @@ DEFINE_RESAMPLER(copy,arch) \
for (c = 0; c < r->channels; c++) { \ for (c = 0; c < r->channels; c++) { \
const float *s = src[c]; \ const float *s = src[c]; \
float *d = dst[c]; \ float *d = dst[c]; \
memcpy(&d[offs], &s[index], to_copy * sizeof(float)); \ memcpy(&d[offs], &s[index + n_taps2], \
to_copy * sizeof(float)); \
} \ } \
index += to_copy; \ index += to_copy; \
offs += to_copy; \ offs += to_copy; \

View file

@ -243,7 +243,7 @@ static void impl_native_reset (struct resample *r)
{ {
struct native_data *d = r->data; struct native_data *d = r->data;
memset(d->hist_mem, 0, r->channels * sizeof(float) * d->n_taps * 2); memset(d->hist_mem, 0, r->channels * sizeof(float) * d->n_taps * 2);
d->hist = d->n_taps / 2; d->hist = d->n_taps - 1;
d->phase = 0; d->phase = 0;
} }