[FFmpeg-devel] [PATCH] lavu/common: make FF_CEIL_RSHIFT faster when shift is constant.

Clément Bœsch ubitux at gmail.com
Sun May 12 13:33:35 CEST 2013


See "[PATCH] lavfi/lut: use FF_CEIL_RSHIFT for chroma w/h rounding."
thread for more information.
---
Forcing one form or another seems to pass FATE.
---
 libavutil/common.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavutil/common.h b/libavutil/common.h
index 9091070..531cf81 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)))
-- 
1.8.2.3



More information about the ffmpeg-devel mailing list