From: Ganesh Ajjanagadde <gajjanaga...@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 <gajjanaga...@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 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel