From c42b108ac874cd3e300a3e98bb98eb8dac3299fd Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 10 Dec 2018 12:58:10 +0100 Subject: [PATCH] resample: small optimization --- spa/plugins/audioconvert/resample-peaks.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spa/plugins/audioconvert/resample-peaks.h b/spa/plugins/audioconvert/resample-peaks.h index 8afd71fda..dde425bd7 100644 --- a/spa/plugins/audioconvert/resample-peaks.h +++ b/spa/plugins/audioconvert/resample-peaks.h @@ -55,8 +55,9 @@ static void impl_peaks_process(struct resample *r, int channel, while (i < *in_len && o < *out_len) { 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); - for (; i < end && i < *in_len; i++) { + for (; i < end; i++) { float n = fabsf(s[i]); if (n > pd->max_f[channel]) pd->max_f[channel] = n;