[FFmpeg-devel] [PATCH 2/3] lavu/rational: use av_unlikely in av_d2q
Ganesh Ajjanagadde
gajjanag at gmail.com
Thu Feb 25 03:20:10 CET 2016
From: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
Merely a simple illustration of av_unlikely's utility; there are
certainly more interesting use cases.
Actual performance benefit is impossible to accurately quantify due to the
context-dependence of the branch predictor. Nonetheless, as a ballpark
estimate, it yields ~ 5% improvements in testing via FATE on x86-64, Haswell+GCC.
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
---
libavutil/rational.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavutil/rational.c b/libavutil/rational.c
index 6b3f50a..3e841ad 100644
--- a/libavutil/rational.c
+++ b/libavutil/rational.c
@@ -108,9 +108,9 @@ AVRational av_d2q(double d, int max)
AVRational a;
int exponent;
int64_t den;
- if (isnan(d))
+ if (av_unlikely(isnan(d)))
return (AVRational) { 0,0 };
- if (fabs(d) > INT_MAX + 3LL)
+ if (av_unlikely(fabs(d) > INT_MAX + 3LL))
return (AVRational) { d < 0 ? -1 : 1, 0 };
frexp(d, &exponent);
exponent = FFMAX(exponent-1, 0);
--
2.7.1
More information about the ffmpeg-devel
mailing list