From 418e5768c68b8688c12e30f2e017688c97249e85 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 29 Jun 2014 14:23:49 +0200 Subject: [PATCH] swresample/resample_template: move division out of loop for float/double swri_resample_linear() Signed-off-by: Michael Niedermayer --- libswresample/resample_template.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libswresample/resample_template.c b/libswresample/resample_template.c index 5983d46b79..1982992e8a 100644 --- a/libswresample/resample_template.c +++ b/libswresample/resample_template.c @@ -32,7 +32,6 @@ # define DELEM double # define FELEM double # define FELEM2 double -# define FELEML double # define OUT(d, v) d = v # if defined(TEMPLATE_RESAMPLE_DBL) @@ -49,7 +48,6 @@ # define DELEM float # define FELEM float # define FELEM2 float -# define FELEML float # define OUT(d, v) d = v # if defined(TEMPLATE_RESAMPLE_FLT) @@ -158,6 +156,9 @@ int RENAME(swri_resample_linear)(ResampleContext *c, int index= c->index; int frac= c->frac; int sample_index = index >> c->phase_shift; +#if FILTER_SHIFT == 0 + double inv_src_incr = 1.0 / c->src_incr; +#endif index &= c->phase_mask; for (dst_index = 0; dst_index < n; dst_index++) { @@ -176,7 +177,11 @@ int RENAME(swri_resample_linear)(ResampleContext *c, #ifdef FELEML val += (v2 - val) * (FELEML) frac / c->src_incr; #else +# if FILTER_SHIFT == 0 + val += (v2 - val) * inv_src_incr * frac; +# else val += (v2 - val) / c->src_incr * frac; +# endif #endif OUT(dst[dst_index], val);