From a331779a2841b02cc5d8eee337ac53089170d85b Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 13 Dec 2018 16:23:02 +0100 Subject: [PATCH] resample-peaks: fix peaks resampler Keep separate variable to check if we searched a complete chunk. --- spa/plugins/audioconvert/resample-peaks.h | 12 +++++------- spa/plugins/audioconvert/resample.c | 6 +++--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/spa/plugins/audioconvert/resample-peaks.h b/spa/plugins/audioconvert/resample-peaks.h index dde425bd7..6120a34c7 100644 --- a/spa/plugins/audioconvert/resample-peaks.h +++ b/spa/plugins/audioconvert/resample-peaks.h @@ -46,18 +46,16 @@ static void impl_peaks_process(struct resample *r, int channel, { struct peaks_data *pd = r->data; float *s = src, *d = dst; - int i, o, end; + int i, o, end, chunk; - i = ((uint64_t) pd->o_count * r->i_rate) / r->o_rate; - i = i > pd->i_count ? i - pd->i_count : 0; - o = 0; + o = i = 0; while (i < *in_len && o < *out_len) { - end = ((uint64_t) (pd->o_count + 1) * r->i_rate) / r->o_rate; + end = ((uint64_t) (pd->o_count + 1) * r->i_rate) / r->o_rate; end = end > pd->i_count ? end - pd->i_count : 0; - end = SPA_MIN(end, *in_len); + chunk = SPA_MIN(end, *in_len); - for (; i < end; i++) { + for (; i < chunk; i++) { float n = fabsf(s[i]); if (n > pd->max_f[channel]) pd->max_f[channel] = n; diff --git a/spa/plugins/audioconvert/resample.c b/spa/plugins/audioconvert/resample.c index 5146cd971..7fb9c5737 100644 --- a/spa/plugins/audioconvert/resample.c +++ b/spa/plugins/audioconvert/resample.c @@ -818,9 +818,9 @@ static int impl_node_process(struct spa_node *node) resample_process(&this->resample, i, src, &in_len, dst, &out_len); - spa_log_trace(this->log, NAME " %p: in %d/%ld %d out %d/%ld %d", - this, in_len, size / sizeof(float), inport->offset, - out_len, maxsize / sizeof(float), outport->offset); + spa_log_trace(this->log, NAME " %p: in %d/%d %ld %d out %d/%d %ld %d", + this, pin_len, in_len, size / sizeof(float), inport->offset, + pout_len, out_len, maxsize / sizeof(float), outport->offset); db->datas[i].chunk->offset = 0; db->datas[i].chunk->size = outport->offset + (out_len * sizeof(float));