From dbe44230ae0d6dfcab1812bc4fea5b4e7d5c1f42 Mon Sep 17 00:00:00 2001 From: Dmitry Baryshev Date: Sun, 1 Oct 2023 18:04:18 +0300 Subject: [PATCH] COMMON: Added more float formats --- src/libsail-common/common.h | 6 ++++-- src/libsail-common/common_serialize.c | 8 ++++++-- src/libsail-common/utils.c | 6 ++++-- tests/sail-common/bytes_per_line.c | 16 ++++++++++++---- tests/sail-common/integrity.c | 12 ++++++++---- 5 files changed, 34 insertions(+), 14 deletions(-) diff --git a/src/libsail-common/common.h b/src/libsail-common/common.h index fb460796..6e9b28a5 100644 --- a/src/libsail-common/common.h +++ b/src/libsail-common/common.h @@ -133,10 +133,12 @@ enum SailPixelFormat { SAIL_PIXEL_FORMAT_BPP64_ABGR, /* - * Float formats. + * 32-bit single-precision floating point formats. */ - SAIL_PIXEL_FORMAT_BPP16_FLOAT, SAIL_PIXEL_FORMAT_BPP32_FLOAT, + SAIL_PIXEL_FORMAT_BPP64_FLOAT, + SAIL_PIXEL_FORMAT_BPP96_FLOAT, + SAIL_PIXEL_FORMAT_BPP128_FLOAT, /* * CMYK formats. diff --git a/src/libsail-common/common_serialize.c b/src/libsail-common/common_serialize.c index c7cf44f8..ec0fafbc 100644 --- a/src/libsail-common/common_serialize.c +++ b/src/libsail-common/common_serialize.c @@ -98,8 +98,10 @@ const char* sail_pixel_format_to_string(enum SailPixelFormat pixel_format) { case SAIL_PIXEL_FORMAT_BPP64_ARGB: return "BPP64-ARGB"; case SAIL_PIXEL_FORMAT_BPP64_ABGR: return "BPP64-ABGR"; - case SAIL_PIXEL_FORMAT_BPP16_FLOAT: return "BPP16-FLOAT"; case SAIL_PIXEL_FORMAT_BPP32_FLOAT: return "BPP32-FLOAT"; + case SAIL_PIXEL_FORMAT_BPP64_FLOAT: return "BPP64-FLOAT"; + case SAIL_PIXEL_FORMAT_BPP96_FLOAT: return "BPP96-FLOAT"; + case SAIL_PIXEL_FORMAT_BPP128_FLOAT: return "BPP128-FLOAT"; case SAIL_PIXEL_FORMAT_BPP32_CMYK: return "BPP32-CMYK"; case SAIL_PIXEL_FORMAT_BPP64_CMYK: return "BPP64-CMYK"; @@ -208,8 +210,10 @@ enum SailPixelFormat sail_pixel_format_from_string(const char *str) { case UINT64_C(8244605671673531226): return SAIL_PIXEL_FORMAT_BPP64_ARGB; case UINT64_C(8244605671673513818): return SAIL_PIXEL_FORMAT_BPP64_ABGR; - case UINT64_C(13817569922789251633): return SAIL_PIXEL_FORMAT_BPP16_FLOAT; case UINT64_C(13817570002860265711): return SAIL_PIXEL_FORMAT_BPP32_FLOAT; + case UINT64_C(13817570133298530580): return SAIL_PIXEL_FORMAT_BPP64_FLOAT; + case UINT64_C(13817570263736795449): return SAIL_PIXEL_FORMAT_BPP96_FLOAT; + case UINT64_C(13257949525762847397): return SAIL_PIXEL_FORMAT_BPP128_FLOAT; case UINT64_C(8244605667720923565): return SAIL_PIXEL_FORMAT_BPP32_CMYK; case UINT64_C(8244605671673598258): return SAIL_PIXEL_FORMAT_BPP64_CMYK; diff --git a/src/libsail-common/utils.c b/src/libsail-common/utils.c index b90a336b..4453fc02 100644 --- a/src/libsail-common/utils.c +++ b/src/libsail-common/utils.c @@ -312,8 +312,10 @@ unsigned sail_bits_per_pixel(enum SailPixelFormat pixel_format) { case SAIL_PIXEL_FORMAT_BPP64_ARGB: case SAIL_PIXEL_FORMAT_BPP64_ABGR: return 64; - case SAIL_PIXEL_FORMAT_BPP16_FLOAT: return 16; - case SAIL_PIXEL_FORMAT_BPP32_FLOAT: return 32; + case SAIL_PIXEL_FORMAT_BPP32_FLOAT: return 32; + case SAIL_PIXEL_FORMAT_BPP64_FLOAT: return 64; + case SAIL_PIXEL_FORMAT_BPP96_FLOAT: return 96; + case SAIL_PIXEL_FORMAT_BPP128_FLOAT: return 128; case SAIL_PIXEL_FORMAT_BPP32_CMYK: return 32; case SAIL_PIXEL_FORMAT_BPP64_CMYK: return 64; diff --git a/tests/sail-common/bytes_per_line.c b/tests/sail-common/bytes_per_line.c index cc2c4f61..8daa790c 100644 --- a/tests/sail-common/bytes_per_line.c +++ b/tests/sail-common/bytes_per_line.c @@ -171,14 +171,22 @@ static MunitResult test_float(const MunitParameter params[], void *user_data) { (void)params; (void)user_data; - /* 16-bit FLOAT. */ - munit_assert(sail_bytes_per_line(10, SAIL_PIXEL_FORMAT_BPP16_FLOAT) == 20); - munit_assert(sail_bytes_per_line(11, SAIL_PIXEL_FORMAT_BPP16_FLOAT) == 22); - /* 32-bit FLOAT. */ munit_assert(sail_bytes_per_line(10, SAIL_PIXEL_FORMAT_BPP32_FLOAT) == 40); munit_assert(sail_bytes_per_line(11, SAIL_PIXEL_FORMAT_BPP32_FLOAT) == 44); + /* 64-bit FLOAT. */ + munit_assert(sail_bytes_per_line(10, SAIL_PIXEL_FORMAT_BPP64_FLOAT) == 80); + munit_assert(sail_bytes_per_line(11, SAIL_PIXEL_FORMAT_BPP64_FLOAT) == 88); + + /* 96-bit FLOAT. */ + munit_assert(sail_bytes_per_line(10, SAIL_PIXEL_FORMAT_BPP96_FLOAT) == 120); + munit_assert(sail_bytes_per_line(11, SAIL_PIXEL_FORMAT_BPP96_FLOAT) == 132); + + /* 128-bit FLOAT. */ + munit_assert(sail_bytes_per_line(10, SAIL_PIXEL_FORMAT_BPP128_FLOAT) == 160); + munit_assert(sail_bytes_per_line(11, SAIL_PIXEL_FORMAT_BPP128_FLOAT) == 176); + return MUNIT_OK; } diff --git a/tests/sail-common/integrity.c b/tests/sail-common/integrity.c index 858a9089..ab54bb5e 100644 --- a/tests/sail-common/integrity.c +++ b/tests/sail-common/integrity.c @@ -133,8 +133,10 @@ static MunitResult test_pixel_format_to_string(const MunitParameter params[], vo munit_assert_string_equal(sail_pixel_format_to_string(SAIL_PIXEL_FORMAT_BPP64_ARGB), "BPP64-ARGB"); munit_assert_string_equal(sail_pixel_format_to_string(SAIL_PIXEL_FORMAT_BPP64_ABGR), "BPP64-ABGR"); - munit_assert_string_equal(sail_pixel_format_to_string(SAIL_PIXEL_FORMAT_BPP16_FLOAT), "BPP16-FLOAT"); - munit_assert_string_equal(sail_pixel_format_to_string(SAIL_PIXEL_FORMAT_BPP32_FLOAT), "BPP32-FLOAT"); + munit_assert_string_equal(sail_pixel_format_to_string(SAIL_PIXEL_FORMAT_BPP32_FLOAT), "BPP32-FLOAT"); + munit_assert_string_equal(sail_pixel_format_to_string(SAIL_PIXEL_FORMAT_BPP64_FLOAT), "BPP64-FLOAT"); + munit_assert_string_equal(sail_pixel_format_to_string(SAIL_PIXEL_FORMAT_BPP96_FLOAT), "BPP96-FLOAT"); + munit_assert_string_equal(sail_pixel_format_to_string(SAIL_PIXEL_FORMAT_BPP128_FLOAT), "BPP128-FLOAT"); munit_assert_string_equal(sail_pixel_format_to_string(SAIL_PIXEL_FORMAT_BPP32_CMYK), "BPP32-CMYK"); munit_assert_string_equal(sail_pixel_format_to_string(SAIL_PIXEL_FORMAT_BPP64_CMYK), "BPP64-CMYK"); @@ -230,8 +232,10 @@ static MunitResult test_pixel_format_from_string(const MunitParameter params[], munit_assert(sail_pixel_format_from_string("BPP64-ARGB") == SAIL_PIXEL_FORMAT_BPP64_ARGB); munit_assert(sail_pixel_format_from_string("BPP64-ABGR") == SAIL_PIXEL_FORMAT_BPP64_ABGR); - munit_assert(sail_pixel_format_from_string("BPP16-FLOAT") == SAIL_PIXEL_FORMAT_BPP16_FLOAT); - munit_assert(sail_pixel_format_from_string("BPP32-FLOAT") == SAIL_PIXEL_FORMAT_BPP32_FLOAT); + munit_assert(sail_pixel_format_from_string("BPP32-FLOAT") == SAIL_PIXEL_FORMAT_BPP32_FLOAT); + munit_assert(sail_pixel_format_from_string("BPP64-FLOAT") == SAIL_PIXEL_FORMAT_BPP64_FLOAT); + munit_assert(sail_pixel_format_from_string("BPP96-FLOAT") == SAIL_PIXEL_FORMAT_BPP96_FLOAT); + munit_assert(sail_pixel_format_from_string("BPP128-FLOAT") == SAIL_PIXEL_FORMAT_BPP128_FLOAT); munit_assert(sail_pixel_format_from_string("BPP32-CMYK") == SAIL_PIXEL_FORMAT_BPP32_CMYK); munit_assert(sail_pixel_format_from_string("BPP64-CMYK") == SAIL_PIXEL_FORMAT_BPP64_CMYK);