aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/vf_blend.c
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/vf_blend.c
parentdde8e5ad02ad60b149d9a532e67587f45f3aecc5 (diff)
downloadffmpeg-8507b98c10d948653375400e2b0a3d4389f74be4.tar.gz
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/vf_blend.c')
-rw-r--r--libavfilter/vf_blend.c4
1 files changed, 2 insertions, 2 deletions
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)