From 8ea1a6dffc327d2f68a50e00aebd58000181853f Mon Sep 17 00:00:00 2001 From: TazyFoundSoup Date: Thu, 2 Apr 2026 21:07:10 +1100 Subject: feat(math): add math core and replace FF_ABS macro with ff_absi --- include/tinyff/common.h | 6 ------ include/tinyff/image/png.h | 1 + src/format/image/png.c | 6 +++--- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/include/tinyff/common.h b/include/tinyff/common.h index 678bda9..838caa3 100644 --- a/include/tinyff/common.h +++ b/include/tinyff/common.h @@ -64,10 +64,4 @@ typedef struct { ff_ctx* ff_init(ff_allocator* allocator); void ff_cleanup(ff_ctx* ctx); - -// Small math functions -// TODO: Implement a full math library for tinyff - -#define FF_ABS(a) (((a) < 0) ? -(a) : (a)) - #endif \ No newline at end of file diff --git a/include/tinyff/image/png.h b/include/tinyff/image/png.h index 82fba32..8ccc4e6 100644 --- a/include/tinyff/image/png.h +++ b/include/tinyff/image/png.h @@ -12,6 +12,7 @@ #include #include #include +#include diff --git a/src/format/image/png.c b/src/format/image/png.c index 755ba9b..cb7f08b 100644 --- a/src/format/image/png.c +++ b/src/format/image/png.c @@ -253,9 +253,9 @@ ff_result ff_png_data_handler(ff_ctx* ctx, uint8_t *buf, size_t len, ff_png_ctx case 4: // Paeth Predictor { int p = left + above - diagonal; - int pa = FF_ABS(p - left); - int pb = FF_ABS(p - above); - int pc = FF_ABS(p - diagonal); + int pa = ff_absi(p - left); + int pb = ff_absi(p - above); + int pc = ff_absi(p - diagonal); if (pa <= pb && pa <= pc) reconstructed_buf[x] = raw[x] + left; -- cgit v1.2.3