summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTazyFoundSoup <gardendistrict0x0@outlook.com>2026-04-02 21:07:10 +1100
committerTazyFoundSoup <gardendistrict0x0@outlook.com>2026-04-02 21:07:10 +1100
commit8ea1a6dffc327d2f68a50e00aebd58000181853f (patch)
tree40962baad102163cb881afcc743715b775d01f42
parent69b4c8a7b8fbf1ed9fa4422ea6bbd4865297166f (diff)
feat(math): add math core and replace FF_ABS macro with ff_absi
-rw-r--r--include/tinyff/common.h6
-rw-r--r--include/tinyff/image/png.h1
-rw-r--r--src/format/image/png.c6
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 <tinyff/stream.h>
#include <tinyff/image/generic.h>
#include <tinyff/dbg.h>
+#include <tinyff/math/core.h>
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;