aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClément Bœsch <ubitux@gmail.com>2013-05-12 13:29:23 +0200
committerClément Bœsch <ubitux@gmail.com>2013-05-13 17:53:16 +0200
commitb3c263e20925628eabf785afae5a9d7cc5d8bb4d (patch)
treecee3a515805ae61682c42d691ce31d9097d257ce
parent45150f90e7dcb12a07780244c1cc5efac5cb8f53 (diff)
downloadffmpeg-b3c263e20925628eabf785afae5a9d7cc5d8bb4d.tar.gz
lavu/common: make FF_CEIL_RSHIFT faster when shift is constant.
See "[PATCH] lavfi/lut: use FF_CEIL_RSHIFT for chroma w/h rounding." thread for more information.
-rw-r--r--libavutil/common.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/libavutil/common.h b/libavutil/common.h
index 9091070a01..c7c32fd363 100644
--- a/libavutil/common.h
+++ b/libavutil/common.h
@@ -49,7 +49,8 @@
/* assume b>0 */
#define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b))
/* assume a>0 and b>0 */
-#define FF_CEIL_RSHIFT(a,b) (-((-(a)) >> (b)))
+#define FF_CEIL_RSHIFT(a,b) (!av_builtin_constant_p(b) ? -((-(a)) >> (b)) \
+ : ((a) + (1<<(b)) - 1) >> (b))
#define FFUDIV(a,b) (((a)>0 ?(a):(a)-(b)+1) / (b))
#define FFUMOD(a,b) ((a)-(b)*FFUDIV(a,b))
#define FFABS(a) ((a) >= 0 ? (a) : (-(a)))