diff options
author | Øyvind Kolås <pippin@gimp.org> | 2022-01-24 11:08:28 +0100 |
---|---|---|
committer | Øyvind Kolås <pippin@gimp.org> | 2022-01-25 06:45:51 +0100 |
commit | 3895c7d240edf918bed0558b0ae2f0058fce2a71 (patch) | |
tree | efbabe446f8193e3fa957f1de7daa1429d4328ee /tools | |
parent | 648d81731b74a6f68ff161ea54811a6d2fa5ef7a (diff) |
babl: also do auto LUTs for 3-3 bpp and 3-4bpp paths
Diffstat (limited to 'tools')
-rw-r--r-- | tools/babl-benchmark.c | 4 | ||||
-rw-r--r-- | tools/babl-lut-verify.c | 59 |
2 files changed, 61 insertions, 2 deletions
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 @@ -62,6 +62,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) { uint8_t *src = malloc (PIXELS*4); @@ -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) |