From ca214e6cd61a6f035d18ae7e96e6d63064b22859 Mon Sep 17 00:00:00 2001 From: TazyFoundSoup Date: Fri, 3 Apr 2026 18:31:41 +1100 Subject: refactor(common): Change endianess function names to ff_le32 and ff_be32 --- include/tinyff/common.h | 21 ++++++++++----------- src/format/image/png.c | 5 +++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/tinyff/common.h b/include/tinyff/common.h index 838caa3..39265a3 100644 --- a/include/tinyff/common.h +++ b/include/tinyff/common.h @@ -16,19 +16,18 @@ typedef bool ff_flag; // Functions -static inline uint32_t get_big_endian(const uint8_t *buffer) { - return (uint32_t)(buffer[0] << 24) | - (uint32_t)(buffer[1] << 16) | - (uint32_t)(buffer[2] << 8) | - (uint32_t)(buffer[3]); +static inline uint32_t ff_be32(const uint8_t *b) { + return ((uint32_t)b[0] << 24) | + ((uint32_t)b[1] << 16) | + ((uint32_t)b[2] << 8) | + ((uint32_t)b[3]); } -static inline uint32_t get_little_endian(const uint8_t *buffer) -{ - return (uint32_t)(buffer[0]) | - (uint32_t)(buffer[1] << 8) | - (uint32_t)(buffer[2] << 16) | - (uint32_t)(buffer[3] << 24); +static inline uint32_t ff_le32(const uint8_t *b) { + return ((uint32_t)b[0]) | + ((uint32_t)b[1] << 8) | + ((uint32_t)b[2] << 16) | + ((uint32_t)b[3] << 24); } diff --git a/src/format/image/png.c b/src/format/image/png.c index cb7f08b..af04243 100644 --- a/src/format/image/png.c +++ b/src/format/image/png.c @@ -1,3 +1,4 @@ +#include #include // External @@ -115,8 +116,8 @@ ff_result ff_png_header_handler(ff_ctx* ctx, uint8_t *buf, size_t len, ff_png_ct return FF_RESULT_ERROR_INVALID_FILE; } - uint32_t w = get_big_endian(buf); - uint32_t h = get_big_endian(buf + 4); + uint32_t w = ff_be32(buf); + uint32_t h = ff_be32(buf + 4); // TODO: Do formatting. //ff_dprintf("Width: %u\n", w); -- cgit v1.2.3