From 8507b98c10d948653375400e2b0a3d4389f74be4 Mon Sep 17 00:00:00 2001 From: Ganesh Ajjanagadde Date: Mon, 12 Oct 2015 01:30:22 -0400 Subject: avfilter,swresample,swscale: use fabs, fabsf instead of FFABS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is well known that fabs and fabsf are at least as fast and sometimes faster than the FFABS macro, at least on the gcc+glibc combination. For instance, see the reference: http://patchwork.sourceware.org/patch/6735/. This was a patch to glibc in order to remove their usages of a macro. The reason essentially boils down to fabs using the __builtin_fabs of the compiler, while FFABS needs to infer to not use a branch and to simply change the sign bit. Usually the inference works, but sometimes it does not. This may be easily checked by looking at the asm. This also has the added benefit of reducing macro usage, which has problems with side-effects. Note that avcodec is not handled here, as it is huge and most things there are integer arithmetic anyway. Tested with FATE. Reviewed-by: Clément Bœsch Signed-off-by: Ganesh Ajjanagadde --- libavfilter/avf_showfreqs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libavfilter/avf_showfreqs.c') diff --git a/libavfilter/avf_showfreqs.c b/libavfilter/avf_showfreqs.c index 0f2ae22c4a..a3665ef4bb 100644 --- a/libavfilter/avf_showfreqs.c +++ b/libavfilter/avf_showfreqs.c @@ -163,7 +163,7 @@ static void generate_window_func(float *lut, int N, int win_func, float *overlap break; case WFUNC_BARTLETT: for (n = 0; n < N; n++) - lut[n] = 1.-FFABS((n-(N-1)/2.)/((N-1)/2.)); + lut[n] = 1.-fabs((n-(N-1)/2.)/((N-1)/2.)); *overlap = 0.5; break; case WFUNC_HANNING: @@ -207,7 +207,7 @@ static void generate_window_func(float *lut, int N, int win_func, float *overlap break; case WFUNC_BHANN: for (n = 0; n < N; n++) - lut[n] = 0.62-0.48*FFABS(n/(double)(N-1)-.5)-0.38*cos(2*M_PI*n/(N-1)); + lut[n] = 0.62-0.48*fabs(n/(double)(N-1)-.5)-0.38*cos(2*M_PI*n/(N-1)); *overlap = 0.5; break; case WFUNC_SINE: -- cgit v1.2.3