summaryrefslogtreecommitdiff
path: root/libavfilter
diff options
context:
space:
mode:
authorGanesh Ajjanagadde <gajjanagadde@gmail.com>2015-10-12 01:30:22 -0400
committerGanesh Ajjanagadde <gajjanagadde@gmail.com>2015-10-22 16:13:26 -0400
commit8507b98c10d948653375400e2b0a3d4389f74be4 (patch)
tree2b17e0bd420990847602cc352c87328abace3483 /libavfilter
parentdde8e5ad02ad60b149d9a532e67587f45f3aecc5 (diff)
avfilter,swresample,swscale: use fabs, fabsf instead of FFABS
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 <u@pkh.me> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/af_stereotools.c2
-rw-r--r--libavfilter/avf_avectorscope.c4
-rw-r--r--libavfilter/avf_showcqt.c2
-rw-r--r--libavfilter/avf_showfreqs.c4
-rw-r--r--libavfilter/f_ebur128.c6
-rw-r--r--libavfilter/vf_blend.c4
-rw-r--r--libavfilter/vf_dctdnoiz.c4
-rw-r--r--libavfilter/vf_framerate.c4
-rw-r--r--libavfilter/vf_hqdn3d.c2
9 files changed, 16 insertions, 16 deletions
diff --git a/libavfilter/af_stereotools.c b/libavfilter/af_stereotools.c
index e19ada47d0..a22efb02ea 100644
--- a/libavfilter/af_stereotools.c
+++ b/libavfilter/af_stereotools.c
@@ -146,7 +146,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
double *buffer = s->buffer;
AVFrame *out;
double *dst;
- int nbuf = inlink->sample_rate * (FFABS(delay) / 1000.);
+ int nbuf = inlink->sample_rate * (fabs(delay) / 1000.);
int n;
nbuf -= nbuf % 2;
diff --git a/libavfilter/avf_avectorscope.c b/libavfilter/avf_avectorscope.c
index 30985f3d49..38dd97ec1c 100644
--- a/libavfilter/avf_avectorscope.c
+++ b/libavfilter/avf_avectorscope.c
@@ -220,7 +220,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
cx = sx * sqrtf(1 - 0.5*sy*sy);
cy = sy * sqrtf(1 - 0.5*sx*sx);
x = hw + hw * FFSIGN(cx + cy) * (cx - cy) * .7;
- y = s->h - s->h * FFABS(cx + cy) * .7;
+ y = s->h - s->h * fabsf(cx + cy) * .7;
}
draw_dot(s, x, y);
@@ -244,7 +244,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
cx = sx * sqrtf(1 - 0.5 * sy * sy);
cy = sy * sqrtf(1 - 0.5 * sx * sx);
x = hw + hw * FFSIGN(cx + cy) * (cx - cy) * .7;
- y = s->h - s->h * FFABS(cx + cy) * .7;
+ y = s->h - s->h * fabsf(cx + cy) * .7;
}
draw_dot(s, x, y);
diff --git a/libavfilter/avf_showcqt.c b/libavfilter/avf_showcqt.c
index ce42cd645a..2bd772ec0f 100644
--- a/libavfilter/avf_showcqt.c
+++ b/libavfilter/avf_showcqt.c
@@ -371,7 +371,7 @@ static int config_output(AVFilterLink *outlink)
tlength = s->timeclamp;
}
- volume = FFABS(av_expr_eval(volume_expr, expr_vars_val, NULL));
+ volume = fabs(av_expr_eval(volume_expr, expr_vars_val, NULL));
if (isnan(volume)) {
av_log(ctx, AV_LOG_WARNING, "at freq %g: volume is nan, setting it to 0\n", freq);
volume = VOLUME_MIN;
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:
diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c
index b9ea11bb84..9e115fcf17 100644
--- a/libavfilter/f_ebur128.c
+++ b/libavfilter/f_ebur128.c
@@ -558,9 +558,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
ebur128->true_peaks_per_frame[ch] = 0.0;
for (idx_insample = 0; idx_insample < ret; idx_insample++) {
for (ch = 0; ch < nb_channels; ch++) {
- ebur128->true_peaks[ch] = FFMAX(ebur128->true_peaks[ch], FFABS(*swr_samples));
+ ebur128->true_peaks[ch] = FFMAX(ebur128->true_peaks[ch], fabs(*swr_samples));
ebur128->true_peaks_per_frame[ch] = FFMAX(ebur128->true_peaks_per_frame[ch],
- FFABS(*swr_samples));
+ fabs(*swr_samples));
swr_samples++;
}
}
@@ -586,7 +586,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
double bin;
if (ebur128->peak_mode & PEAK_MODE_SAMPLES_PEAKS)
- ebur128->sample_peaks[ch] = FFMAX(ebur128->sample_peaks[ch], FFABS(*samples));
+ ebur128->sample_peaks[ch] = FFMAX(ebur128->sample_peaks[ch], fabs(*samples));
ebur128->x[ch * 3] = *samples++; // set X[i]
diff --git a/libavfilter/vf_blend.c b/libavfilter/vf_blend.c
index 7b5e51b7e6..f2c4b84f01 100644
--- a/libavfilter/vf_blend.c
+++ b/libavfilter/vf_blend.c
@@ -241,7 +241,7 @@ DEFINE_BLEND8(lighten, FFMAX(A, B))
DEFINE_BLEND8(divide, av_clip_uint8(((float)A / ((float)B) * 255)))
DEFINE_BLEND8(dodge, DODGE(A, B))
DEFINE_BLEND8(burn, BURN(A, B))
-DEFINE_BLEND8(softlight, (A > 127) ? B + (255 - B) * (A - 127.5) / 127.5 * (0.5 - FFABS(B - 127.5) / 255): B - B * ((127.5 - A) / 127.5) * (0.5 - FFABS(B - 127.5)/255))
+DEFINE_BLEND8(softlight, (A > 127) ? B + (255 - B) * (A - 127.5) / 127.5 * (0.5 - fabs(B - 127.5) / 255): B - B * ((127.5 - A) / 127.5) * (0.5 - fabs(B - 127.5)/255))
DEFINE_BLEND8(exclusion, A + B - 2 * A * B / 255)
DEFINE_BLEND8(pinlight, (B < 128) ? FFMIN(A, 2 * B) : FFMAX(A, 2 * (B - 128)))
DEFINE_BLEND8(phoenix, FFMIN(A, B) - FFMAX(A, B) + 255)
@@ -280,7 +280,7 @@ DEFINE_BLEND16(lighten, FFMAX(A, B))
DEFINE_BLEND16(divide, av_clip_uint16(((float)A / ((float)B) * 65535)))
DEFINE_BLEND16(dodge, DODGE(A, B))
DEFINE_BLEND16(burn, BURN(A, B))
-DEFINE_BLEND16(softlight, (A > 32767) ? B + (65535 - B) * (A - 32767.5) / 32767.5 * (0.5 - FFABS(B - 32767.5) / 65535): B - B * ((32767.5 - A) / 32767.5) * (0.5 - FFABS(B - 32767.5)/65535))
+DEFINE_BLEND16(softlight, (A > 32767) ? B + (65535 - B) * (A - 32767.5) / 32767.5 * (0.5 - fabs(B - 32767.5) / 65535): B - B * ((32767.5 - A) / 32767.5) * (0.5 - fabs(B - 32767.5)/65535))
DEFINE_BLEND16(exclusion, A + B - 2 * A * B / 65535)
DEFINE_BLEND16(pinlight, (B < 32768) ? FFMIN(A, 2 * B) : FFMAX(A, 2 * (B - 32768)))
DEFINE_BLEND16(phoenix, FFMIN(A, B) - FFMAX(A, B) + 65535)
diff --git a/libavfilter/vf_dctdnoiz.c b/libavfilter/vf_dctdnoiz.c
index 37306bb582..6957f19aea 100644
--- a/libavfilter/vf_dctdnoiz.c
+++ b/libavfilter/vf_dctdnoiz.c
@@ -367,10 +367,10 @@ static av_always_inline void filter_freq_##bsize(const float *src, int src_lines
float *b = &tmp_block2[i]; \
/* frequency filtering */ \
if (expr) { \
- var_values[VAR_C] = FFABS(*b); \
+ var_values[VAR_C] = fabsf(*b); \
*b *= av_expr_eval(expr, var_values, NULL); \
} else { \
- if (FFABS(*b) < sigma_th) \
+ if (fabsf(*b) < sigma_th) \
*b = 0; \
} \
} \
diff --git a/libavfilter/vf_framerate.c b/libavfilter/vf_framerate.c
index e8fba285d8..237a4873b3 100644
--- a/libavfilter/vf_framerate.c
+++ b/libavfilter/vf_framerate.c
@@ -223,7 +223,7 @@ static int blend_frames16(AVFilterContext *ctx, float interpolate,
}
// decide if the shot-change detection allows us to blend two frames
if (interpolate_scene_score < s->scene_score && copy_src2) {
- uint16_t src2_factor = FFABS(interpolate) * (1 << (s->bitdepth - 8));
+ uint16_t src2_factor = fabsf(interpolate) * (1 << (s->bitdepth - 8));
uint16_t src1_factor = s->max - src2_factor;
const int half = s->max / 2;
const int uv = (s->max + 1) * half;
@@ -287,7 +287,7 @@ static int blend_frames8(AVFilterContext *ctx, float interpolate,
}
// decide if the shot-change detection allows us to blend two frames
if (interpolate_scene_score < s->scene_score && copy_src2) {
- uint16_t src2_factor = FFABS(interpolate);
+ uint16_t src2_factor = fabsf(interpolate);
uint16_t src1_factor = 256 - src2_factor;
int plane, line, pixel;
diff --git a/libavfilter/vf_hqdn3d.c b/libavfilter/vf_hqdn3d.c
index 6c76c5c176..5b367fff79 100644
--- a/libavfilter/vf_hqdn3d.c
+++ b/libavfilter/vf_hqdn3d.c
@@ -182,7 +182,7 @@ static int16_t *precalc_coefs(double dist25, int depth)
for (i = -256<<LUT_BITS; i < 256<<LUT_BITS; i++) {
double f = ((i<<(9-LUT_BITS)) + (1<<(8-LUT_BITS)) - 1) / 512.0; // midpoint of the bin
- simil = FFMAX(0, 1.0 - FFABS(f) / 255.0);
+ simil = FFMAX(0, 1.0 - fabs(f) / 255.0);
C = pow(simil, gamma) * 256.0 * f;
ct[(256<<LUT_BITS)+i] = lrint(C);
}