From 06c8f776620f698dcc25fd623da69454057b096f Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Tue, 9 Sep 2014 15:02:34 +0200 Subject: [PATCH] Add ceil --- src/omv/img/fmath.c | 11 +++++++++++ src/omv/img/fmath.h | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/omv/img/fmath.c b/src/omv/img/fmath.c index 1fe61a5fd..180832966 100644 --- a/src/omv/img/fmath.c +++ b/src/omv/img/fmath.c @@ -31,6 +31,17 @@ int ALWAYS_INLINE fast_floorf(float x) return i; } +int ALWAYS_INLINE fast_ceilf(float x) +{ + int i; + x += 0.9999f; + asm volatile ( + "vcvt.S32.f32 %[r], %[x]\n" + : [r] "=t" (i) + : [x] "t" (x)); + return i; +} + int ALWAYS_INLINE fast_roundf(float x) { int i; diff --git a/src/omv/img/fmath.h b/src/omv/img/fmath.h index 193304bc7..9486a00b3 100644 --- a/src/omv/img/fmath.h +++ b/src/omv/img/fmath.h @@ -2,7 +2,8 @@ #define __FMATH_H__ #include float fast_sqrtf(float x); -int fast_floor(float x); +int fast_floorf(float x); +int fast_ceilf(float x); int fast_roundf(float x); float fast_atanf(float x); float fast_atan2f(float x, float y);