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);