From 3895c7d240edf918bed0558b0ae2f0058fce2a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Mon, 24 Jan 2022 11:08:28 +0100 Subject: babl: also do auto LUTs for 3-3 bpp and 3-4bpp paths --- tools/babl-benchmark.c | 4 ++-- tools/babl-lut-verify.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/babl-benchmark.c b/tools/babl-benchmark.c index f2a90f3..895cfc2 100644 --- a/tools/babl-benchmark.c +++ b/tools/babl-benchmark.c @@ -25,8 +25,8 @@ #define random rand #endif -int ITERATIONS = 20; -#define N_PIXELS (512*256) // a too small batch makes the test set live +int ITERATIONS = 5; +#define N_PIXELS (1024*1024) // a too small batch makes the test set live // in l2 cache skewing results // we could also add a cache purger.. diff --git a/tools/babl-lut-verify.c b/tools/babl-lut-verify.c index 5f79682..65a6d00 100644 --- a/tools/babl-lut-verify.c +++ b/tools/babl-lut-verify.c @@ -61,6 +61,57 @@ test_u8_premul (void) } +static double +test_rgb (void) +{ + uint8_t *src = malloc (PIXELS*4); + uint8_t *dst = malloc (PIXELS*4); + uint8_t *dst2 = malloc (PIXELS*4); + double error = 0.0; + + for (int i = 0; i < PIXELS; i++) + for (int c = 0; c < 4; c++) + src[i*4+c] = random(); + + babl_process ( + babl_fish ( + babl_format_with_space ("R'G'B' u8", babl_space("Apple")), + babl_format_with_space ("R'G'B' u8", babl_space("ProPhoto"))), + src, dst, PIXELS); + babl_process ( + babl_fish ( + babl_format_with_space ("R'G'B' u8", babl_space("Apple")), + babl_format_with_space ("R'G'B' u8", babl_space("ProPhoto"))), + src, dst2, PIXELS); + babl_process ( + babl_fish ( + babl_format_with_space ("R'G'B' u8", babl_space("Apple")), + babl_format_with_space ("R'G'B' u8", babl_space("ProPhoto"))), + src, dst2, PIXELS); + babl_process ( + babl_fish ( + babl_format_with_space ("R'G'B' u8", babl_space("Apple")), + babl_format_with_space ("R'G'B' u8", babl_space("ProPhoto"))), + src, dst2, PIXELS); + + for (int i = 0; i < PIXELS; i++) + { + error += sqrt ((dst[i*3+0] - dst2[i*3+0])* + (dst[i*3+0] - dst2[i*3+0])+ + (dst[i*3+1] - dst2[i*3+1])* + (dst[i*3+1] - dst2[i*3+1])+ + (dst[i*3+2] - dst2[i*3+2])* + (dst[i*3+2] - dst2[i*3+2])); + } + + free (src); + free (dst); + free (dst2); + + return error; +} + + static double test_u8 (void) { @@ -391,6 +442,14 @@ int main (int argc, char **argv) else fprintf (stdout, "OK\n"); + fprintf (stdout, "R'G'B u8 "); + error = test_rgb (); + if (error != 0.0) + fprintf (stdout, "%.20f\n", error/(PIXELS*4)); + else + fprintf (stdout, "OK\n"); + + fprintf (stdout, "u8 premul "); error = test_u8_premul (); if (error != 0.0) -- cgit v1.2.3