Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package babl for openSUSE:Leap:16.0 checked in at 2025-04-24 10:16:57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Leap:16.0/babl (Old) and /work/SRC/openSUSE:Leap:16.0/.babl.new.30101 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "babl" Thu Apr 24 10:16:57 2025 rev:2 rq:1267644 version:0.1.112 Changes: -------- --- /work/SRC/openSUSE:Leap:16.0/babl/babl.changes 2025-03-19 11:39:49.820342249 +0100 +++ /work/SRC/openSUSE:Leap:16.0/.babl.new.30101/babl.changes 2025-04-24 10:16:58.750426542 +0200 @@ -1,0 +2,16 @@ +Mon Mar 17 11:31:38 UTC 2025 - Marcus Rueckert <mrueck...@suse.de> + +- Update to 0.1.112: + - Fix crash for locales using neither '.' nor ',' as decimal + seperator. + +------------------------------------------------------------------- +Wed Nov 6 22:47:27 UTC 2024 - Marcus Rueckert <mrueck...@suse.de> + +- Update to 0.1.110: + - Build improvements. + - Fixes to alpha componet in HCY, HSL, HSV and YCbCr models. + - Use same CIE Lab conversion for start/end as rest with SIMD. + - Remove reliance on set rounding mode. + +------------------------------------------------------------------- Old: ---- babl-0.1.108.tar.xz New: ---- babl-0.1.112.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ babl.spec ++++++ --- /var/tmp/diff_new_pack.C3FdYU/_old 2025-04-24 10:16:59.030438320 +0200 +++ /var/tmp/diff_new_pack.C3FdYU/_new 2025-04-24 10:16:59.034438488 +0200 @@ -1,7 +1,7 @@ # # spec file for package babl # -# Copyright (c) 2023 SUSE LLC +# Copyright (c) 2025 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,7 +19,7 @@ %define debug_package_requires libbabl-0_1-0 = %{version}-%{release} Name: babl -Version: 0.1.108 +Version: 0.1.112 Release: 0 Summary: Dynamic Pixel Format Translation Library License: GPL-3.0-or-later AND LGPL-3.0-or-later ++++++ babl-0.1.108.tar.xz -> babl-0.1.112.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/NEWS new/babl-0.1.112/NEWS --- old/babl-0.1.108/NEWS 2024-02-09 17:48:36.000000000 +0100 +++ new/babl-0.1.112/NEWS 2025-03-10 12:54:03.000000000 +0100 @@ -3,6 +3,16 @@ the news section both in the README and the webpage. --> +2025-03-10 babl-0.1.112 </dt><dd> +Fix crash for locales using neither '.' nor ',' as decimal seperator. +Fix crash for locales using neither '.' nor ',' as decimal seperator. + </dd><dt> +2024-09-27 babl-0.1.110 </dt><dd> +Build improvements. +Fixes to alpha componet in HCY, HSL, HSV and YCbCr models. +Use same CIE Lab conversion for start/end as rest with SIMD. +Remove reliance on set rounding mode. + </dd><dt> 2024-02-09 babl-0.1.108 </dt><dd> "double" and "half" support in cli-tool, build fixes. </dd><dt> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/babl/babl-core.c new/babl-0.1.112/babl/babl-core.c --- old/babl-0.1.108/babl/babl-core.c 2024-02-09 17:48:36.000000000 +0100 +++ new/babl-0.1.112/babl/babl-core.c 2025-03-10 12:54:03.000000000 +0100 @@ -186,7 +186,6 @@ double f) { char name[128]; - int i; float params[7]={g, a, b, c, d, e, f}; if (fabs (g - 2.400) < 0.01 && @@ -199,9 +198,15 @@ ) return babl_trc ("sRGB"); - snprintf (name, sizeof (name), "%.6f %.6f %.4f %.4f %.4f %.4f %.4f", g, a, b, c, d, e, f); - for (i = 0; name[i]; i++) - if (name[i] == ',') name[i] = '.'; + snprintf (name, sizeof (name)-1, "%i.%06i %i.%06i %i.%04i %i.%04i %i.%04i %i.%04i %i.%04i", + (int)(g), (int)((g-(int)g) * 1000000), + (int)(a), (int)((a-(int)a) * 1000000), + (int)(b), (int)((b-(int)b) * 10000), + (int)(c), (int)((c-(int)c) * 10000), + (int)(d), (int)((d-(int)d) * 10000), + (int)(e), (int)((e-(int)e) * 10000), + (int)(f), (int)((f-(int)f) * 10000)); + while (name[strlen(name)-1]=='0') name[strlen(name)-1]='\0'; return babl_trc_new (name, BABL_TRC_FORMULA_SRGB, g, 0, params); @@ -214,12 +219,14 @@ double c) { char name[128]; - int i; float params[4]={g, a, b, c}; - snprintf (name, sizeof (name), "%.6f %.6f %.4f %.4f", g, a, b, c); - for (i = 0; name[i]; i++) - if (name[i] == ',') name[i] = '.'; + snprintf (name, sizeof (name)-1, "%i.%06i %i.%06i %i.%04i %i.%04i", + (int)(g), (int)((g-(int)g) * 1000000), + (int)(a), (int)((a-(int)a) * 1000000), + (int)(b), (int)((b-(int)b) * 10000), + (int)(c), (int)((c-(int)c) * 10000)); + while (name[strlen(name)-1]=='0') name[strlen(name)-1]='\0'; return babl_trc_new (name, BABL_TRC_FORMULA_CIE, g, 0, params); @@ -230,13 +237,12 @@ babl_trc_gamma (double gamma) { char name[32]; - int i; if (fabs (gamma - 1.0) < 0.01) return babl_trc_new ("linear", BABL_TRC_LINEAR, 1.0, 0, NULL); - snprintf (name, sizeof (name), "%.6f", gamma); - for (i = 0; name[i]; i++) - if (name[i] == ',') name[i] = '.'; + snprintf (name, sizeof (name)-1, "%i.%06i", + (int)(gamma), (int)((gamma-(int)gamma) * 1000000)); + while (name[strlen(name)-1]=='0') name[strlen(name)-1]='\0'; return babl_trc_new (name, BABL_TRC_FORMULA_GAMMA, gamma, 0, NULL); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/babl/babl-icc.c new/babl-0.1.112/babl/babl-icc.c --- old/babl-0.1.108/babl/babl-icc.c 2024-02-09 17:48:36.000000000 +0100 +++ new/babl-0.1.112/babl/babl-icc.c 2025-03-10 12:54:03.000000000 +0100 @@ -474,10 +474,9 @@ } ret = babl_trc_lut_find (lut, count); - if (ret) - return ret; + if (ret == NULL) + ret = babl_trc_lut (NULL, count, lut); - ret = babl_trc_lut (NULL, count, lut); babl_free (lut); return ret; } @@ -605,6 +604,7 @@ int length=65535; ICC *state = icc_state_new (icc, length, 10); + memset (icc, 0, sizeof (icc)); icc[length]=0; symmetry_test (state); @@ -735,6 +735,7 @@ int length=65535; ICC *state = icc_state_new (icc, length, 10); + memset (icc, 0, sizeof (icc)); icc[length]=0; symmetry_test (state); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/babl/babl-internal.h new/babl-0.1.112/babl/babl-internal.h --- old/babl-0.1.108/babl/babl-internal.h 2024-02-09 17:48:36.000000000 +0100 +++ new/babl-0.1.112/babl/babl-internal.h 2025-03-10 12:54:03.000000000 +0100 @@ -55,11 +55,6 @@ #include "babl-cpuaccel.h" #include "babl-polynomial.h" -/* fallback to floor function when rint is not around */ -#ifndef HAVE_RINT -# define rint(f) (floor (((double) (f)) + 0.5)) -#endif - #ifdef __ANDROID_API__ #include <android/log.h> #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/babl/babl.h new/babl-0.1.112/babl/babl.h --- old/babl-0.1.108/babl/babl.h 2024-02-09 17:48:36.000000000 +0100 +++ new/babl-0.1.112/babl/babl.h 2025-03-10 12:54:03.000000000 +0100 @@ -669,7 +669,7 @@ * like EXR GEGL chooses to load this lienar data as RGB and use the sRGB * TRC. * - * Returns: pointer to ICC profile data. + * Returns: (transfer none) (array length=length) (element-type guint8): pointer to ICC profile data. */ const char *babl_space_get_icc (const Babl *babl, int *length); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/babl/base/meson.build new/babl-0.1.112/babl/base/meson.build --- old/babl-0.1.108/babl/base/meson.build 2024-02-09 17:48:36.000000000 +0100 +++ new/babl-0.1.112/babl/base/meson.build 2025-03-10 12:54:03.000000000 +0100 @@ -21,7 +21,7 @@ babl_base = static_library('babl_base', babl_base_sources, include_directories: [rootInclude, bablInclude], - dependencies: [math, lcms], + dependencies: [math, lcms, log], c_args: common_c_flags + [sse2_cflags] ) @@ -30,14 +30,14 @@ babl_base_x86_64_v2 = static_library('babl_base-x86-64-v2', babl_base_sources, include_directories: [rootInclude, bablInclude], - dependencies: [math, lcms], + dependencies: [math, lcms, log], c_args: common_c_flags + x86_64_v2_flags ) babl_base_x86_64_v3 = static_library('babl_base-x86-64-v3', babl_base_sources, include_directories: [rootInclude, bablInclude], - dependencies: [math, lcms], + dependencies: [math, lcms, log], c_args: common_c_flags + x86_64_v3_flags ) @@ -49,7 +49,7 @@ babl_base_arm_neon = static_library('babl_base-arm-neon', babl_base_sources, include_directories: [rootInclude, bablInclude], - dependencies: [math, lcms], + dependencies: [math, lcms, log], c_args: common_c_flags + arm_neon_flags ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/babl/base/type-u15.c new/babl-0.1.112/babl/base/type-u15.c --- old/babl-0.1.108/babl/base/type-u15.c 2024-02-09 17:48:36.000000000 +0100 +++ new/babl-0.1.112/babl/base/type-u15.c 2025-03-10 12:54:03.000000000 +0100 @@ -48,7 +48,7 @@ else if (dval > max_val) u15val = max; else - u15val = rint ((dval - min_val) / (max_val - min_val) * (max - min) + min); + u15val = (dval - min_val) / (max_val - min_val) * (max - min) + min + 0.5; *(uint16_t *) dst = u15val; dst += dst_pitch; @@ -134,7 +134,7 @@ else if (dval > max_val) u15val = max; else - u15val = rint ((dval - min_val) / (max_val - min_val) * (max - min) + min); + u15val = (dval - min_val) / (max_val - min_val) * (max - min) + min + 0.5f; *(uint16_t *) dst = u15val; dst += dst_pitch; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/babl/base/type-u16.c new/babl-0.1.112/babl/base/type-u16.c --- old/babl-0.1.108/babl/base/type-u16.c 2024-02-09 17:48:36.000000000 +0100 +++ new/babl-0.1.112/babl/base/type-u16.c 2025-03-10 12:54:03.000000000 +0100 @@ -48,7 +48,7 @@ else if (dval > max_val) u16val = max; else - u16val = rint ((dval - min_val) / (max_val - min_val) * (max - min) + min); + u16val = (dval - min_val) / (max_val - min_val) * (max - min) + min + 0.5; *(uint16_t *) dst = u16val; dst += dst_pitch; @@ -132,7 +132,7 @@ else if (dval > max_val) u16val = max; else - u16val = rint ((dval - min_val) / (max_val - min_val) * (max - min) + min); + u16val = (dval - min_val) / (max_val - min_val) * (max - min) + min + 0.5f; *(uint16_t *) dst = u16val; dst += dst_pitch; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/babl/base/type-u32.c new/babl-0.1.112/babl/base/type-u32.c --- old/babl-0.1.108/babl/base/type-u32.c 2024-02-09 17:48:36.000000000 +0100 +++ new/babl-0.1.112/babl/base/type-u32.c 2025-03-10 12:54:03.000000000 +0100 @@ -47,7 +47,7 @@ else if (dval > max_val) u32val = max; else - u32val = rint ((dval - min_val) / (max_val - min_val) * (max - min) + min); + u32val = (dval - min_val) / (max_val - min_val) * (max - min) + min + 0.5; *(uint32_t *) dst = u32val; dst += dst_pitch; @@ -132,7 +132,7 @@ else if (dval > max_val) u32val = max; else - u32val = rint ((dval - min_val) / (max_val - min_val) * (max - min) + min); + u32val = (dval - min_val) / (max_val - min_val) * (max - min) + min + 0.5f; *(uint32_t *) dst = u32val; dst += dst_pitch; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/babl/base/type-u8.c new/babl-0.1.112/babl/base/type-u8.c --- old/babl-0.1.108/babl/base/type-u8.c 2024-02-09 17:48:36.000000000 +0100 +++ new/babl-0.1.112/babl/base/type-u8.c 2025-03-10 12:54:03.000000000 +0100 @@ -47,7 +47,7 @@ else if (dval > max_val) u8val = max; else - u8val = rint ((dval - min_val) / (max_val - min_val) * (max - min) + min); + u8val = ((dval - min_val) / (max_val - min_val) * (max - min) + min) + 0.5; *(unsigned char *) dst = u8val; src += src_pitch; @@ -135,7 +135,7 @@ else if (dval > max_val) u8val = max; else - u8val = rint ((dval - min_val) / (max_val - min_val) * (max - min) + min); + u8val = (dval - min_val) / (max_val - min_val) * (max - min) + min + 0.5f; *(unsigned char *) dst = u8val; src += src_pitch; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/babl/meson.build new/babl-0.1.112/babl/meson.build --- old/babl-0.1.108/babl/meson.build 2024-02-09 17:48:36.000000000 +0100 +++ new/babl-0.1.112/babl/meson.build 2025-03-10 12:54:03.000000000 +0100 @@ -118,7 +118,7 @@ subdir('babl') endif -babl_deps = [math, thread, dl, lcms] +babl_deps = [math, thread, dl, lcms, log] babl_includes = [rootInclude, bablBaseInclude] if host_cpu_family == 'x86_64' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/bin/babl.c new/babl-0.1.112/bin/babl.c --- old/babl-0.1.108/bin/babl.c 2024-02-09 17:48:36.000000000 +0100 +++ new/babl-0.1.112/bin/babl.c 2025-03-10 12:54:03.000000000 +0100 @@ -151,14 +151,22 @@ { set_to = 1; } - else if (strcmp (argv[i], "--input-profile") == 0 || + else if (strcmp (argv[i], "--input-space") == 0 || + /* Deprecated option name, but keep compatibility. */ + strcmp (argv[i], "--input-profile") == 0 || strcmp (argv[i], "-i") == 0) { + if (strcmp (argv[i], "--input-profile") == 0) + fprintf (stderr, "babl: warning: --input-profile option renamed --input-space\n"); set_from_profile = 1; } - else if (strcmp (argv[i], "--output-profile") == 0 || + else if (strcmp (argv[i], "--output-space") == 0 || + /* Deprecated option name, but keep compatibility. */ + strcmp (argv[i], "--output-profile") == 0 || strcmp (argv[i], "-o") == 0) { + if (strcmp (argv[i], "--output-profile") == 0) + fprintf (stderr, "babl: warning: --output-profile option renamed --output-space\n"); set_to_profile = 1; } else if (strcmp (argv[i], "--intent") == 0 || @@ -175,18 +183,56 @@ if (from_profile != NULL) { - from_space = babl_cli_get_space (from_profile, intent); + if (strlen (from_profile) > 2 && *from_profile == '*') + { + if (from_profile[1] != '*') + from_space = babl_space (from_profile + 1); + else + from_space = babl_cli_get_space (from_profile + 1, intent); + } + else + { + from_space = babl_cli_get_space (from_profile, intent); + } if (! from_space) - return 6; + { + if (strlen (from_profile) > 2 && *from_profile == '*' && from_profile[1] != '*') + { + fprintf (stderr, "babl: unknown named space '%s'\n", + from_profile + 1); + fprintf (stderr, " Known spaces: sRGB, scRGB (sRGB with linear TRCs), Rec2020, " + "Adobish, Apple, ProPhoto, ACEScg and ACES2065-1.\n"); + } + return 6; + } } if (to_profile != NULL) { - to_space = babl_cli_get_space (to_profile, intent); + if (strlen (to_profile) > 2 && *to_profile == '*') + { + if (to_profile[1] != '*') + to_space = babl_space (to_profile + 1); + else + to_space = babl_cli_get_space (to_profile + 1, intent); + } + else + { + to_space = babl_cli_get_space (to_profile, intent); + } if (! to_space) - return 6; + { + if (strlen (to_profile) > 2 && *to_profile == '*' && to_profile[1] != '*') + { + fprintf (stderr, "babl: unknown named space '%s'\n", + to_profile + 1); + fprintf (stderr, " Known spaces: sRGB, scRGB (sRGB with linear TRCs), Rec2020, " + "Adobish, Apple, ProPhoto, ACEScg and ACES2065-1.\n"); + } + return 6; + } } if (from == NULL) @@ -269,11 +315,13 @@ set_to = 1; } else if (strcmp (argv[i], "--input-profile") == 0 || + strcmp (argv[i], "--input-space") == 0 || strcmp (argv[i], "-i") == 0) { set_from_profile = 1; } else if (strcmp (argv[i], "--output-profile") == 0 || + strcmp (argv[i], "--output-space") == 0 || strcmp (argv[i], "-o") == 0) { set_to_profile = 1; @@ -569,9 +617,13 @@ "\n" " -t, --to output Babl format\n" "\n" - " -i, --input-profile input profile\n" + " -i, --input-space input profile or named space\n" + " named spaced are asterisk-prefixed, i.e. '*Rec2020'\n" + " as special-case, double the first asterisk if your profile path starts with '*'\n" "\n" - " -o, --output-profile output profile\n" + " -o, --output-space output profile or named space\n" + " named spaced are asterisk-prefixed, i.e. '*Rec2020'\n" + " as special-case, double the first asterisk if your profile path starts with '*'\n" "\n" " -r, --intent rendering intent\n" " it only works with an output profile\n" @@ -581,7 +633,12 @@ "\n" "All parameters following -- are considered components values. " "This is useful to input negative components.\n\n" - "The tool expects exactly the number of components expected by your input format.\n\n" - "The default input and output formats are \"R'G'B' float\" and default space is " - "sRGB for RGB formats, or the naive CMYK space for CMYK formats.\n"); + "The tool expects exactly the number of components of your input format.\n\n" + "The default input and output formats are \"R'G'B' float\" (respectively \"CMYK float\" " + "or \"Y' float\" if you specified a CMYK or grayscale profile).\n\n" + "The default space is sRGB for RGB formats or a naive CMYK space for CMYK formats.\n" + "Other spaces can be specified through an ICC profile or a named space prefixed by " + "an asterisk.\n" + "Known spaces: sRGB, scRGB (sRGB with linear TRCs), Rec2020, Adobish, Apple, ProPhoto, " + "ACEScg and ACES2065-1.\n"); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/docs/meson.build new/babl-0.1.112/docs/meson.build --- old/babl-0.1.108/docs/meson.build 2024-02-09 17:48:36.000000000 +0100 +++ new/babl-0.1.112/docs/meson.build 2025-03-10 12:54:03.000000000 +0100 @@ -40,7 +40,7 @@ TOC = files('toc') html_files = { - 'index': [index_static_html, [ + 'index': ['index-static.html.in', [ ['AUTHORS', authors_file], ['TODO', todo_file], ['NEWS', news_file], diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/extensions/CIE.c new/babl-0.1.112/extensions/CIE.c --- old/babl-0.1.108/extensions/CIE.c 2024-02-09 17:48:36.000000000 +0100 +++ new/babl-0.1.112/extensions/CIE.c 2025-03-10 12:54:03.000000000 +0100 @@ -2441,10 +2441,10 @@ } static void -rgbaf_to_Labaf_sse2 (const Babl *conversion, - const float *src, - float *dst, - long samples) +rgbaf_to_Labaf_sse2_aligned_4mult (const Babl *conversion, + const float *src, + float *dst, + long samples) { const Babl *space = babl_conversion_get_source_space (conversion); const float m_0_0 = space->space.RGBtoXYZf[0] / D50_WHITE_REF_Xf; @@ -2456,100 +2456,124 @@ const float m_2_0 = space->space.RGBtoXYZf[6] / D50_WHITE_REF_Zf; const float m_2_1 = space->space.RGBtoXYZf[7] / D50_WHITE_REF_Zf; const float m_2_2 = space->space.RGBtoXYZf[8] / D50_WHITE_REF_Zf; - long i = 0; - long remainder; + long i = 0; + + const __m128 m_0_0_v = _mm_set1_ps (m_0_0); + const __m128 m_0_1_v = _mm_set1_ps (m_0_1); + const __m128 m_0_2_v = _mm_set1_ps (m_0_2); + const __m128 m_1_0_v = _mm_set1_ps (m_1_0); + const __m128 m_1_1_v = _mm_set1_ps (m_1_1); + const __m128 m_1_2_v = _mm_set1_ps (m_1_2); + const __m128 m_2_0_v = _mm_set1_ps (m_2_0); + const __m128 m_2_1_v = _mm_set1_ps (m_2_1); + const __m128 m_2_2_v = _mm_set1_ps (m_2_2); - if (((uintptr_t) src % 16) + ((uintptr_t) dst % 16) == 0) + assert (((uintptr_t) src % 16) + ((uintptr_t) dst % 16) == 0); + assert (samples % 4 == 0); + + for ( ; i < samples; i += 4) { - const long n = (samples / 4) * 4; - const __m128 m_0_0_v = _mm_set1_ps (m_0_0); - const __m128 m_0_1_v = _mm_set1_ps (m_0_1); - const __m128 m_0_2_v = _mm_set1_ps (m_0_2); - const __m128 m_1_0_v = _mm_set1_ps (m_1_0); - const __m128 m_1_1_v = _mm_set1_ps (m_1_1); - const __m128 m_1_2_v = _mm_set1_ps (m_1_2); - const __m128 m_2_0_v = _mm_set1_ps (m_2_0); - const __m128 m_2_1_v = _mm_set1_ps (m_2_1); - const __m128 m_2_2_v = _mm_set1_ps (m_2_2); + __m128 Laba0; + __m128 Laba1; + __m128 Laba2; + __m128 Laba3; + + __m128 rgba0 = _mm_load_ps (src); + __m128 rgba1 = _mm_load_ps (src + 4); + __m128 rgba2 = _mm_load_ps (src + 8); + __m128 rgba3 = _mm_load_ps (src + 12); + + __m128 r = rgba0; + __m128 g = rgba1; + __m128 b = rgba2; + __m128 a = rgba3; + _MM_TRANSPOSE4_PS (r, g, b, a); - for ( ; i < n; i += 4) { - __m128 Laba0; - __m128 Laba1; - __m128 Laba2; - __m128 Laba3; - - __m128 rgba0 = _mm_load_ps (src); - __m128 rgba1 = _mm_load_ps (src + 4); - __m128 rgba2 = _mm_load_ps (src + 8); - __m128 rgba3 = _mm_load_ps (src + 12); - - __m128 r = rgba0; - __m128 g = rgba1; - __m128 b = rgba2; - __m128 a = rgba3; - _MM_TRANSPOSE4_PS (r, g, b, a); - - { - __m128 xr = _mm_add_ps (_mm_add_ps (_mm_mul_ps (m_0_0_v, r), _mm_mul_ps (m_0_1_v, g)), - _mm_mul_ps (m_0_2_v, b)); - __m128 yr = _mm_add_ps (_mm_add_ps (_mm_mul_ps (m_1_0_v, r), _mm_mul_ps (m_1_1_v, g)), - _mm_mul_ps (m_1_2_v, b)); - __m128 zr = _mm_add_ps (_mm_add_ps (_mm_mul_ps (m_2_0_v, r), _mm_mul_ps (m_2_1_v, g)), - _mm_mul_ps (m_2_2_v, b)); - - __m128 fx = lab_r_to_f_sse2 (xr); - __m128 fy = lab_r_to_f_sse2 (yr); - __m128 fz = lab_r_to_f_sse2 (zr); - - __m128 L = _mm_sub_ps (_mm_mul_ps (_mm_set1_ps (116.0f), fy), _mm_set1_ps (16.0f)); - __m128 A = _mm_mul_ps (_mm_set1_ps (500.0f), _mm_sub_ps (fx, fy)); - __m128 B = _mm_mul_ps (_mm_set1_ps (200.0f), _mm_sub_ps (fy, fz)); - - Laba0 = L; - Laba1 = A; - Laba2 = B; - Laba3 = a; - _MM_TRANSPOSE4_PS (Laba0, Laba1, Laba2, Laba3); - } - - _mm_store_ps (dst, Laba0); - _mm_store_ps (dst + 4, Laba1); - _mm_store_ps (dst + 8, Laba2); - _mm_store_ps (dst + 12, Laba3); - - src += 16; - dst += 16; + __m128 xr = _mm_add_ps (_mm_add_ps (_mm_mul_ps (m_0_0_v, r), _mm_mul_ps (m_0_1_v, g)), + _mm_mul_ps (m_0_2_v, b)); + __m128 yr = _mm_add_ps (_mm_add_ps (_mm_mul_ps (m_1_0_v, r), _mm_mul_ps (m_1_1_v, g)), + _mm_mul_ps (m_1_2_v, b)); + __m128 zr = _mm_add_ps (_mm_add_ps (_mm_mul_ps (m_2_0_v, r), _mm_mul_ps (m_2_1_v, g)), + _mm_mul_ps (m_2_2_v, b)); + + __m128 fx = lab_r_to_f_sse2 (xr); + __m128 fy = lab_r_to_f_sse2 (yr); + __m128 fz = lab_r_to_f_sse2 (zr); + + __m128 L = _mm_sub_ps (_mm_mul_ps (_mm_set1_ps (116.0f), fy), _mm_set1_ps (16.0f)); + __m128 A = _mm_mul_ps (_mm_set1_ps (500.0f), _mm_sub_ps (fx, fy)); + __m128 B = _mm_mul_ps (_mm_set1_ps (200.0f), _mm_sub_ps (fy, fz)); + + Laba0 = L; + Laba1 = A; + Laba2 = B; + Laba3 = a; + _MM_TRANSPOSE4_PS (Laba0, Laba1, Laba2, Laba3); } + + _mm_store_ps (dst, Laba0); + _mm_store_ps (dst + 4, Laba1); + _mm_store_ps (dst + 8, Laba2); + _mm_store_ps (dst + 12, Laba3); + + src += 16; + dst += 16; } +} + +static void +rgbaf_to_Labaf_sse2 (const Babl *conversion, + const float *src, + float *dst, + long samples) +{ + if (((uintptr_t) src % 16) + ((uintptr_t) dst % 16) == 0 || + samples < 4) + { + long first_samples = samples / 4 * 4; + long remainder; + + rgbaf_to_Labaf_sse2_aligned_4mult (conversion, src, dst, first_samples); + remainder = samples - first_samples; - remainder = samples - i; - while (remainder--) + if (remainder) + { + float __attribute__ ((aligned (16))) aligned_src[16]; + float __attribute__ ((aligned (16))) aligned_dest[16]; + + memcpy (aligned_src, src + first_samples * 4, remainder * 16); + memset (aligned_src + remainder * 4, 0, 4 * 16 - (remainder * 16)); + rgbaf_to_Labaf_sse2_aligned_4mult (conversion, (const float *) aligned_src, aligned_dest, 4); + memcpy (dst + first_samples * 4, aligned_dest, remainder * 16); + } + } + else { - float r = src[0]; - float g = src[1]; - float b = src[2]; - float a = src[3]; - - float xr = m_0_0 * r + m_0_1 * g + m_0_2 * b; - float yr = m_1_0 * r + m_1_1 * g + m_1_2 * b; - float zr = m_2_0 * r + m_2_1 * g + m_2_2 * b; - - float fx = xr > LAB_EPSILONf ? _cbrtf (xr) : (LAB_KAPPAf * xr + 16.0f) / 116.0f; - float fy = yr > LAB_EPSILONf ? _cbrtf (yr) : (LAB_KAPPAf * yr + 16.0f) / 116.0f; - float fz = zr > LAB_EPSILONf ? _cbrtf (zr) : (LAB_KAPPAf * zr + 16.0f) / 116.0f; - - float L = 116.0f * fy - 16.0f; - float A = 500.0f * (fx - fy); - float B = 200.0f * (fy - fz); - - dst[0] = L; - dst[1] = A; - dst[2] = B; - dst[3] = a; + float __attribute__ ((aligned (16))) _aligned_src[4 * samples]; + float __attribute__ ((aligned (16))) _aligned_dst[4 * samples]; + float *aligned_src; + float *aligned_dst; + + if (((uintptr_t) src % 16) != 0) + { + aligned_src = _aligned_src; + memcpy (aligned_src, src, samples * 16); + } + else + { + aligned_src = (float *) src; + } + + if (((uintptr_t) dst % 16) != 0) + aligned_dst = _aligned_dst; + else + aligned_dst = dst; + + rgbaf_to_Labaf_sse2 (conversion, aligned_src, aligned_dst, samples); - src += 4; - dst += 4; + if (((uintptr_t) dst % 16) != 0) + memcpy (dst, aligned_dst, samples * 16); } } @@ -3097,7 +3121,7 @@ else if (dval > max_val) u8val = max; else - u8val = rint ((dval - min_val) / (max_val - min_val) * (max - min) + min); + u8val = ((dval - min_val) / (max_val - min_val) * (max - min) + min) + 0.5; *(unsigned char *) dst = u8val; src += src_pitch; @@ -3187,7 +3211,7 @@ else if (dval > max_val) u8val = max; else - u8val = rint ((dval - min_val) / (max_val - min_val) * (max - min) + min); + u8val = ((dval - min_val) / (max_val - min_val) * (max - min) + min) + 0.5f; *(unsigned char *) dst = u8val; src += src_pitch; @@ -3353,7 +3377,7 @@ else if (dval > max_val) u16val = max; else - u16val = rint ((dval - min_val) / (max_val - min_val) * (max - min) + min); + u16val = ((dval - min_val) / (max_val - min_val) * (max - min) + min) + 0.5f; *(unsigned short *) dst = u16val; dst += dst_pitch; @@ -3441,7 +3465,7 @@ else if (dval > max_val) u16val = max; else - u16val = rint ((dval - min_val) / (max_val - min_val) * (max - min) + min); + u16val = ((dval - min_val) / (max_val - min_val) * (max - min) + min) + 0.5f; *(unsigned short *) dst = u16val; dst += dst_pitch; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/extensions/HCY.c new/babl-0.1.112/extensions/HCY.c --- old/babl-0.1.108/extensions/HCY.c 2024-02-09 17:48:36.000000000 +0100 +++ new/babl-0.1.112/extensions/HCY.c 2025-03-10 12:54:03.000000000 +0100 @@ -86,7 +86,7 @@ babl_component_new ("hue", NULL); babl_component_new ("HCY chroma", "chroma", NULL); babl_component_new ("HCY luma", "luma", NULL); - babl_component_new ("alpha", NULL); + babl_component_new ("alpha", "alpha", NULL); } static void diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/extensions/HSL.c new/babl-0.1.112/extensions/HSL.c --- old/babl-0.1.108/extensions/HSL.c 2024-02-09 17:48:36.000000000 +0100 +++ new/babl-0.1.112/extensions/HSL.c 2025-03-10 12:54:03.000000000 +0100 @@ -55,12 +55,55 @@ static void hsl_to_rgb_step (double *src, double *dst); - -static inline double + +static inline double hue2cpn (double p, double q, double hue); - + +/* Defined through macros below */ + +static inline void +rgb_nonlinear_to_hsl_step_double (double *src, + double *dst); +static inline void +hsl_to_rgb_nonlinear_step_double (double *src, + double *dst); + +static inline void +rgb_nonlinear_to_hsl_step_float (float *src, + float *dst); +static inline void +hsl_to_rgb_nonlinear_step_float (float *src, + float *dst); + +/* Non-Linear RGB conversion: double variants */ + +static void +rgba_nonlinear_to_hsla (const Babl *conversion, + char *src, + char *dst, + long samples); +static void +hsla_to_rgba_nonlinear (const Babl *conversion, + char *src, + char *dst, + long samples); + +/* Non-Linear RGB conversion: float variants */ + +static void +rgba_nonlinear_to_hsla_float (const Babl *conversion, + char *src, + char *dst, + long samples); +static void +hsla_to_rgba_nonlinear_float (const Babl *conversion, + char *src, + char *dst, + long samples); + + int init (void); int @@ -69,7 +112,7 @@ babl_component_new ("hue", NULL); babl_component_new ("saturation", NULL); babl_component_new ("lightness", NULL); - babl_component_new ("alpha", NULL); + babl_component_new ("alpha", "alpha", NULL); babl_model_new ("name", "HSL", "doc", "HSL - Hue Saturation Lightness, an improvement over HSV; which uses lightness; defined as (MAX(R,G,B) + MIN(R,G,B))/2 for the grayscale axis; better than HSV, but look into the CIE based spaces for better perceptual uniformity. The HSL space is relative to the RGB space associated with the format.", @@ -104,6 +147,16 @@ "linear", hsl_to_rgba, NULL); + babl_conversion_new (babl_model ("R'G'B'A"), + babl_model ("HSLA"), + "linear", rgba_nonlinear_to_hsla, + NULL); + + babl_conversion_new (babl_model ("HSLA"), + babl_model ("R'G'B'A"), + "linear", hsla_to_rgba_nonlinear, + NULL); + babl_format_new ("name", "HSLA float", babl_model ("HSLA"), babl_type ("float"), @@ -119,58 +172,83 @@ babl_component ("saturation"), babl_component ("lightness"), NULL); + + babl_conversion_new (babl_format ("R'G'B'A float"), + babl_format ("HSLA float"), + "linear", rgba_nonlinear_to_hsla_float, + NULL); + babl_conversion_new (babl_format ("HSLA float"), + babl_format ("R'G'B'A float"), + "linear", hsla_to_rgba_nonlinear_float, + NULL); + return 0; } +#define DEFINE_RGB_NL_TO_HSL_STEP(ctype) \ +static inline void \ +rgb_nonlinear_to_hsl_step_##ctype (ctype* src, \ + ctype* dst) \ +{ \ + ctype min, max; \ + ctype hue, saturation, lightness; \ + int cpn_max; \ + \ + ctype red = src[0]; \ + ctype green = src[1]; \ + ctype blue = src[2]; \ + \ + max = MAX (red, MAX (green, blue)); \ + min = MIN (red, MIN (green, blue)); \ + \ + if (max - red < EPSILON) \ + cpn_max = 0; \ + else if (max - green < EPSILON) \ + cpn_max = 1; \ + else \ + cpn_max = 2; \ + \ + lightness = (max + min) / 2.0; \ + \ + if (max - min < EPSILON) \ + { \ + hue = saturation = 0; \ + } \ + else \ + { \ + ctype diff = max - min; \ + ctype sum = max + min; \ + saturation = lightness > 0.5 ? diff / (2.0 - sum) : diff / sum; \ + switch (cpn_max) \ + { \ + case 0: hue = (green - blue) / diff + (green < blue ? 6.0 : 0.0); break; \ + case 1: hue = (blue - red) / diff + 2.0; break; \ + case 2: hue = (red - green) / diff + 4.0; break; \ + default: hue = 0.0; \ + break; \ + } \ + hue /= 6.0; \ + } \ + \ + dst[0] = hue; \ + dst[1] = saturation; \ + dst[2] = lightness; \ +} + +DEFINE_RGB_NL_TO_HSL_STEP(double) +DEFINE_RGB_NL_TO_HSL_STEP(float) static inline void rgb_to_hsl_step (double* src, double* dst) { + double nonlinear_rgb[3]; + + nonlinear_rgb[0] = linear_to_gamma_2_2 (src[0]); + nonlinear_rgb[1] = linear_to_gamma_2_2 (src[1]); + nonlinear_rgb[2] = linear_to_gamma_2_2 (src[2]); - double min, max; - double hue, saturation, lightness; - int cpn_max; - - double red = linear_to_gamma_2_2 (src[0]); - double green = linear_to_gamma_2_2 (src[1]); - double blue = linear_to_gamma_2_2 (src[2]); - - max = MAX (red, MAX (green, blue)); - min = MIN (red, MIN (green, blue)); - - if (max - red < EPSILON) - cpn_max = 0; - else if (max - green < EPSILON) - cpn_max = 1; - else - cpn_max = 2; - - lightness = (max + min) / 2.0; - - if (max - min < EPSILON) - { - hue = saturation = 0; - } - else - { - double diff = max - min; - double sum = max + min; - saturation = lightness > 0.5 ? diff / (2.0 - sum) : diff / sum; - switch (cpn_max) - { - case 0: hue = (green - blue) / diff + (green < blue ? 6.0 : 0.0); break; - case 1: hue = (blue - red) / diff + 2.0; break; - case 2: hue = (red - green) / diff + 4.0; break; - default: hue = 0.0; - break; - } - hue /= 6.0; - } - - dst[0] = hue; - dst[1] = saturation; - dst[2] = lightness; + rgb_nonlinear_to_hsl_step_double (nonlinear_rgb, dst); } @@ -228,39 +306,48 @@ } +#define DEFINE_HSL_TO_RBG_NONLINEAR_STEP(ctype) \ +static inline void \ +hsl_to_rgb_nonlinear_step_##ctype (ctype *src, \ + ctype *dst) \ +{ \ + ctype hue = src[0]; \ + ctype saturation = src[1]; \ + ctype lightness = src[2]; \ + \ + if (saturation < 1e-7) \ + { \ + dst[0] = dst[1] = dst[2] = lightness; \ + } \ + else \ + { \ + ctype q = lightness < 0.5 ? \ + lightness * (1 + saturation) : \ + lightness + saturation - lightness * saturation; \ + \ + ctype p = 2 * lightness - q; \ + \ + hue = fmod (hue, 1.0); \ + hue += hue < 0.0; \ + \ + dst[0] = hue2cpn (p, q, hue + 1.0/3.0); \ + dst[1] = hue2cpn (p, q, hue); \ + dst[2] = hue2cpn (p, q, hue - 1.0/3.0); \ + } \ +} + +DEFINE_HSL_TO_RBG_NONLINEAR_STEP(double) +DEFINE_HSL_TO_RBG_NONLINEAR_STEP(float) + static void hsl_to_rgb_step (double *src, double *dst) { - double hue = src[0]; - double saturation = src[1]; - double lightness = src[2]; - - double red = 0, green = 0, blue = 0; + hsl_to_rgb_nonlinear_step_double (src, dst); - if (saturation < 1e-7) - { - red = green = blue = lightness; - } - else - { - double q = lightness < 0.5 ? - lightness * (1 + saturation) : - lightness + saturation - lightness * saturation; - - double p = 2 * lightness - q; - - hue = fmod (hue, 1.0); - hue += hue < 0.0; - - red = hue2cpn (p, q, hue + 1.0/3.0); - green = hue2cpn (p, q, hue); - blue = hue2cpn (p, q, hue - 1.0/3.0); - } - - dst[0] = gamma_2_2_to_linear (red); - dst[1] = gamma_2_2_to_linear (green); - dst[2] = gamma_2_2_to_linear (blue); + dst[0] = gamma_2_2_to_linear (dst[0]); + dst[1] = gamma_2_2_to_linear (dst[1]); + dst[2] = gamma_2_2_to_linear (dst[2]); } @@ -304,3 +391,89 @@ dst += 4 * sizeof (double); } } + +static void +rgba_nonlinear_to_hsla (const Babl *conversion, + char *src, + char *dst, + long samples) +{ + long n = samples; + + while (n--) + { + double alpha = ((double *) src)[3]; + + rgb_nonlinear_to_hsl_step_double ((double *) src, (double *) dst); + + ((double *) dst)[3] = alpha; + + src += 4 * sizeof (double); + dst += 4 * sizeof (double); + } +} + +static void +hsla_to_rgba_nonlinear (const Babl *conversion, + char *src, + char *dst, + long samples) +{ + long n = samples; + + while (n--) + { + double alpha = ((double *) src)[3]; + + hsl_to_rgb_nonlinear_step_double ((double *) src, (double *) dst); + + ((double *) dst)[3] = alpha; + + src += 4 * sizeof (double); + dst += 4 * sizeof (double); + } +} + +/** Float variants **/ + +static void +rgba_nonlinear_to_hsla_float (const Babl *conversion, + char *src, + char *dst, + long samples) +{ + long n = samples; + + while (n--) + { + float alpha = ((float *) src)[3]; + + rgb_nonlinear_to_hsl_step_float ((float *) src, (float *) dst); + + ((float *) dst)[3] = alpha; + + src += 4 * sizeof (float); + dst += 4 * sizeof (float); + } +} + +static void +hsla_to_rgba_nonlinear_float (const Babl *conversion, + char *src, + char *dst, + long samples) +{ + long n = samples; + + while (n--) + { + float alpha = ((float *) src)[3]; + + hsl_to_rgb_nonlinear_step_float ((float *) src, (float *) dst); + + ((float *) dst)[3] = alpha; + + src += 4 * sizeof (float); + dst += 4 * sizeof (float); + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/extensions/HSV.c new/babl-0.1.112/extensions/HSV.c --- old/babl-0.1.108/extensions/HSV.c 2024-02-09 17:48:36.000000000 +0100 +++ new/babl-0.1.112/extensions/HSV.c 2025-03-10 12:54:03.000000000 +0100 @@ -89,7 +89,7 @@ babl_component_new ("hue", NULL); babl_component_new ("saturation", NULL); babl_component_new ("value", NULL); - babl_component_new ("alpha", NULL); + babl_component_new ("alpha", "alpha", NULL); } static void diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/extensions/avx2-int8.c new/babl-0.1.112/extensions/avx2-int8.c --- old/babl-0.1.108/extensions/avx2-int8.c 2024-02-09 17:48:36.000000000 +0100 +++ new/babl-0.1.112/extensions/avx2-int8.c 2025-03-10 12:54:03.000000000 +0100 @@ -23,6 +23,7 @@ /* AVX 2 */ #include <immintrin.h> +#include <math.h> #include <stdint.h> #include <stdlib.h> @@ -39,12 +40,12 @@ { \ float x = *src; \ \ - if (x < 0.0f) \ + if (isnan (x) || x > 1.0f) \ + *dst = 255; \ + else if (x < 0.0f) \ *dst = 0; \ - else if (x <= 1.0f) \ + else \ *dst = linear_to_gamma[(int) (SCALE * x + 0.5f)]; \ - else /* x > 1.0f || isnan (x) */ \ - *dst = 255; \ \ src++; \ dst++; \ @@ -56,12 +57,12 @@ { \ float x = *src; \ \ - if (x < 0.0f) \ + if (isnan (x) || x > 1.0f) \ + *dst = 255; \ + else if (x < 0.0f) \ *dst = 0; \ - else if (x <= 1.0f) \ + else \ *dst = 255.0f * x + 0.5f; \ - else /* x > 1.0f || isnan (x) */ \ - *dst = 255; \ \ src++; \ dst++; \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/extensions/gggl-lies.c new/babl-0.1.112/extensions/gggl-lies.c --- old/babl-0.1.108/extensions/gggl-lies.c 2024-02-09 17:48:36.000000000 +0100 +++ new/babl-0.1.112/extensions/gggl-lies.c 2025-03-10 12:54:03.000000000 +0100 @@ -69,7 +69,7 @@ } else { - *(unsigned char *) dst = lrint (f * 255.0f); + *(unsigned char *) dst = f * 255.0f + 0.5f; } dst += 1; src += 4; @@ -97,7 +97,7 @@ } else { - *(unsigned short *) dst = lrint (f * 65535.0f); + *(unsigned short *) dst = f * 65535.0f + 0.5f; } dst += 2; src += 4; @@ -649,11 +649,11 @@ for (c = 0; c < 3; c++) { - *(unsigned char *) dst = lrint (((*(float *) src) * alpha) * 255.0f); + *(unsigned char *) dst = ((*(float *) src) * alpha) * 255.0f + 0.5f; dst += 1; src += 4; } - *(unsigned char *) dst = lrint (alpha * 255.0f); + *(unsigned char *) dst = alpha * 255.0f + 0.5f; dst++; src += 4; } @@ -673,7 +673,7 @@ for (c = 0; c < 3; c++) { - *(unsigned char *) dst = lrint ((*(float *) src) * 255.0f); + *(unsigned char *) dst = (*(float *) src) * 255.0f + 0.5f; dst += 1; src += 4; } @@ -695,7 +695,7 @@ for (c = 0; c < 3; c++) { - *(unsigned short *) dst = lrint ((*(float *) src) * 65535.0f); + *(unsigned short *) dst = (*(float *) src) * 65535.0f + 0.5f; dst += 2; src += 4; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/extensions/gggl.c new/babl-0.1.112/extensions/gggl.c --- old/babl-0.1.108/extensions/gggl.c 2024-02-09 17:48:36.000000000 +0100 +++ new/babl-0.1.112/extensions/gggl.c 2025-03-10 12:54:03.000000000 +0100 @@ -61,7 +61,7 @@ while (n--) { float f = ((*(float *) src)); - int uval = lrint (f * 255.0f); + int uval = f * 255.0f + 0.5f; if (uval < 0) uval = 0; if (uval > 255) uval = 255; @@ -93,7 +93,7 @@ } else { - *(unsigned short *) dst = lrint (f * 65535.0f); + *(unsigned short *) dst = f * 65535.0f + 0.5f; } dst += 2; src += 4; @@ -146,7 +146,7 @@ for (c = 0; c < 3; c++) { - int val = rint ((*(float *) src) * 255.0f); + int val = (*(float *) src) * 255.0f + 0.5f; if (val < 0) *(unsigned char *) dst = 0; else if (val > 255) @@ -679,11 +679,11 @@ for (c = 0; c < 3; c++) { - *(unsigned char *) dst = lrint (((*(float *) src) * alpha) * 255.0f); + *(unsigned char *) dst = ((*(float *) src) * alpha) * 255.0f + 0.5f; dst += 1; src += 4; } - *(unsigned char *) dst = lrint (alpha * 255.0f); + *(unsigned char *) dst = alpha * 255.0f + 0.5f; dst++; src += 4; } @@ -708,7 +708,7 @@ else if ((*(float *) src) <=0) *(unsigned short *) dst = 0; else - *(unsigned short *) dst = lrint ((*(float *) src) * 65535.0f); + *(unsigned short *) dst = (*(float *) src) * 65535.0f + 0.5f; dst += 2; src += 4; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/extensions/gimp-8bit.c new/babl-0.1.112/extensions/gimp-8bit.c --- old/babl-0.1.108/extensions/gimp-8bit.c 2024-02-09 17:48:36.000000000 +0100 +++ new/babl-0.1.112/extensions/gimp-8bit.c 2025-03-10 12:54:03.000000000 +0100 @@ -366,13 +366,13 @@ while (n--) { - v = rint (*fsrc++ * 255.0f); + v = *fsrc++ * 255.0f + 0.5f; *dst++ = (v < 0) ? 0 : ((v > 255) ? 255 : v); - v = rint (*fsrc++ * 255.0f); + v = *fsrc++ * 255.0f + 0.5f; *dst++ = (v < 0) ? 0 : ((v > 255) ? 255 : v); - v = rint (*fsrc++ * 255.0f); + v = *fsrc++ * 255.0f + 0.5f; *dst++ = (v < 0) ? 0 : ((v > 255) ? 255 : v); fsrc++; @@ -391,16 +391,16 @@ while (n--) { - v = rint (*fsrc++ * 255.0f); + v = *fsrc++ * 255.0f + 0.5f; *dst++ = (v < 0) ? 0 : ((v > 255) ? 255 : v); - v = rint (*fsrc++ * 255.0f); + v = *fsrc++ * 255.0f + 0.5f; *dst++ = (v < 0) ? 0 : ((v > 255) ? 255 : v); - v = rint (*fsrc++ * 255.0f); + v = *fsrc++ * 255.0f + 0.5f; *dst++ = (v < 0) ? 0 : ((v > 255) ? 255 : v); - v = rint (*fsrc++ * 255.0f); + v = *fsrc++ * 255.0f + 0.5f; *dst++ = (v < 0) ? 0 : ((v > 255) ? 255 : v); } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/extensions/grey.c new/babl-0.1.112/extensions/grey.c --- old/babl-0.1.108/extensions/grey.c 2024-02-09 17:48:36.000000000 +0100 +++ new/babl-0.1.112/extensions/grey.c 2025-03-10 12:54:03.000000000 +0100 @@ -48,7 +48,7 @@ value += *s++ * RGB_LUMINANCE_BLUE_FLOAT; s++; - v = rint (value * 255.0f); + v = value * 255.0f + 0.5f; *dst++ = (v < 0) ? 0 : ((v > 255) ? 255 : v); } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/extensions/simple.c new/babl-0.1.112/extensions/simple.c --- old/babl-0.1.108/extensions/simple.c 2024-02-09 17:48:36.000000000 +0100 +++ new/babl-0.1.112/extensions/simple.c 2025-03-10 12:54:03.000000000 +0100 @@ -168,10 +168,10 @@ float b = src[2]; float a = src[3]; - dst[0] = (r >= 1.0f) ? 0xFFFFFFFF : ((r <= 0.0f) ? 0x0 : 0xFFFFFFFF * r + 0.5f); - dst[1] = (g >= 1.0f) ? 0xFFFFFFFF : ((g <= 0.0f) ? 0x0 : 0xFFFFFFFF * g + 0.5f); - dst[2] = (b >= 1.0f) ? 0xFFFFFFFF : ((b <= 0.0f) ? 0x0 : 0xFFFFFFFF * b + 0.5f); - dst[3] = (a >= 1.0f) ? 0xFFFFFFFF : ((a <= 0.0f) ? 0x0 : 0xFFFFFFFF * a + 0.5f); + dst[0] = (r >= 1.0f) ? 0xFFFFFFFF : ((r <= 0.0f) ? 0x0 : (float)0xFFFFFFFF * r + 0.5f); + dst[1] = (g >= 1.0f) ? 0xFFFFFFFF : ((g <= 0.0f) ? 0x0 : (float)0xFFFFFFFF * g + 0.5f); + dst[2] = (b >= 1.0f) ? 0xFFFFFFFF : ((b <= 0.0f) ? 0x0 : (float)0xFFFFFFFF * b + 0.5f); + dst[3] = (a >= 1.0f) ? 0xFFFFFFFF : ((a <= 0.0f) ? 0x0 : (float)0xFFFFFFFF * a + 0.5f); dst += 4; src += 4; @@ -192,7 +192,7 @@ { float r = src[0]; - dst[0] = (r >= 1.0f) ? 0xFFFFFFFF : ((r <= 0.0f) ? 0x0 : 0xFFFFFFFF * r + 0.5f); + dst[0] = (r >= 1.0f) ? 0xFFFFFFFF : ((r <= 0.0f) ? 0x0 : ((float)0xFFFFFFFF) * r + 0.5f); dst += 1; src += 1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/extensions/two-table.c new/babl-0.1.112/extensions/two-table.c --- old/babl-0.1.108/extensions/two-table.c 2024-02-09 17:48:36.000000000 +0100 +++ new/babl-0.1.112/extensions/two-table.c 2025-03-10 12:54:03.000000000 +0100 @@ -178,7 +178,7 @@ long int alpha; *dst++ = conv_float_u8_two_table_map (*src++); - alpha = rint (*src++ * 255.0); + alpha = *src++ * 255.0 + 0.5f; *dst++ = (alpha < 0) ? 0 : ((alpha > 255) ? 255 : alpha); } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/extensions/util.h new/babl-0.1.112/extensions/util.h --- old/babl-0.1.108/extensions/util.h 2024-02-09 17:48:36.000000000 +0100 +++ new/babl-0.1.112/extensions/util.h 2025-03-10 12:54:03.000000000 +0100 @@ -26,10 +26,6 @@ #error "config.h must be included prior to util.h" #endif -#ifndef HAVE_RINT -# define rint(f) (floor (((double) (f)) + 0.5)) -#endif - #define BABL_PLANAR_SANITY \ { \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/extensions/ycbcr.c new/babl-0.1.112/extensions/ycbcr.c --- old/babl-0.1.108/extensions/ycbcr.c 2024-02-09 17:48:36.000000000 +0100 +++ new/babl-0.1.112/extensions/ycbcr.c 2025-03-10 12:54:03.000000000 +0100 @@ -49,7 +49,7 @@ static void components (void) { - babl_component_new ("alpha", NULL); + babl_component_new ("alpha", "alpha", NULL); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/git-version.h new/babl-0.1.112/git-version.h --- old/babl-0.1.108/git-version.h 2024-02-09 17:48:44.061389200 +0100 +++ new/babl-0.1.112/git-version.h 2025-03-10 12:54:16.210522000 +0100 @@ -1,6 +1,6 @@ #ifndef __BABL_GIT_VERSION_H__ #define __BABL_GIT_VERSION_H__ -#define BABL_GIT_VERSION "BABL_0_1_106-17-gd3337db" +#define BABL_GIT_VERSION "BABL_0_1_110-7-g937c0a4" #endif /* __BABL_GIT_VERSION_H__ */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/meson.build new/babl-0.1.112/meson.build --- old/babl-0.1.108/meson.build 2024-02-09 17:48:36.000000000 +0100 +++ new/babl-0.1.112/meson.build 2025-03-10 12:54:03.000000000 +0100 @@ -1,6 +1,6 @@ project('babl', 'c', license: 'LGPL3+', - version: '0.1.108', + version: '0.1.112', meson_version: '>=0.55.0', default_options: [ 'buildtype=debugoptimized' @@ -110,11 +110,6 @@ host_os.startswith('windows')) platform_osx = host_os.startswith('darwin') -if platform_osx - if cc.get_id() != 'clang' - error('You should use Clang/Clang++ on OSX.') - endif -endif platform_android = host_os.contains('android') @@ -161,10 +156,8 @@ # Compiler arguments common_c_flags = [] +common_l_flags = [] -if buildtype == 'debugoptimized' or buildtype == 'release' - common_c_flags += cc.get_supported_arguments(['-Ofast']) -endif common_c_flags += cc.get_supported_arguments( ['-fno-unsafe-math-optimizations','-ftree-vectorize'] ) @@ -180,6 +173,22 @@ ] common_c_flags += cc.get_supported_arguments(extra_warnings_list) +# Generate .pdb (CodeView) debug symbols (makes possible to debug with DIA SDK) +#pdb_support = cc.has_argument('-gcodeview') and cc.has_link_argument('-Wl,--pdb=') +#if platform_win32 and pdb_support +# common_c_flags += '-gcodeview' +# common_l_flags += '-Wl,--pdb=' +#endif + +if platform_win32 and cc.get_id() == 'clang' + # Optimize DWARF symbols to Dr. Mingw + # https://github.com/jrfonseca/drmingw/issues/42 + common_c_flags += '-gdwarf-aranges' + # Workaround to get colored output + # https://github.com/msys2/MINGW-packages/issues/2988 + common_c_flags += '-fansi-escape-codes' +endif + add_project_arguments(common_c_flags, language: 'c') # Linker arguments @@ -200,9 +209,11 @@ arm_neon_flags = cc.get_supported_arguments(['-mfpu=neon-vfpv4']) arm_neon_flags += '-DARM_NEON' elif host_cpu_family == 'aarch64' - common_c_flags += cc.get_supported_arguments(['-mfpu=neon-fp-armv8']) + common_c_flags += cc.get_supported_arguments(['-mfpu=neon-fp-armv8', '-ftree-vectorize']) endif +add_project_link_arguments(common_l_flags, language: 'c') + ################################################################################ # Check for compiler CPU extensions @@ -324,7 +335,6 @@ # general check_functions = [ ['HAVE_GETTIMEOFDAY', 'gettimeofday', '<sys/time.h>'], - ['HAVE_RINT', 'rint' , '<math.h>'], ['HAVE_SRANDOM', 'srandom' , '<stdlib.h>'], ] foreach func: check_functions @@ -498,6 +508,15 @@ gen_babl_map_file = files('gen_babl_map.py') ################################################################################ +# Install debug data (.pdb) on Windows +# Ideally meson should take care of it automatically. +# See: https://github.com/mesonbuild/meson/issues/12977 +#if platform_win32 and pdb_support +# install_win_debug_script = find_program('./meson_install_win_debug.sh') +# meson.add_install_script(install_win_debug_script) +#endif + +################################################################################ # Subdirs subdir('babl') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/meson_install_win_debug.sh new/babl-0.1.112/meson_install_win_debug.sh --- old/babl-0.1.108/meson_install_win_debug.sh 1970-01-01 01:00:00.000000000 +0100 +++ new/babl-0.1.112/meson_install_win_debug.sh 2025-03-10 12:54:03.000000000 +0100 @@ -0,0 +1,20 @@ +#!/bin/sh + +find . \( -iname '*.dll' -or -iname '*.exe' \) | \ +while IFS= read -r build_bin; +do + build_bin_name="${build_bin##*/}" + installed_bin=$(find ${MESON_INSTALL_DESTDIR_PREFIX} -iname "$build_bin_name") + if [ x"$installed_bin" != "x" ]; then + install_dir=$(dirname ${installed_bin}) + pdb_debug=$(echo $build_bin|sed 's/\.\(dll\|exe\)$/.pdb/') + if [ -f "$pdb_debug" ]; then + # Note: meson hides script outputs anyway on success. But this can be + # useful when debugging. + echo Installing $pdb_debug to $install_dir + if [ -z "$MESON_INSTALL_DRY_RUN" ]; then + cp -f $pdb_debug $install_dir + fi + fi + fi +done; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/tests/meson.build new/babl-0.1.112/tests/meson.build --- old/babl-0.1.108/tests/meson.build 2024-02-09 17:48:36.000000000 +0100 +++ new/babl-0.1.112/tests/meson.build 2025-03-10 12:54:03.000000000 +0100 @@ -42,7 +42,7 @@ test_name + '.c', include_directories: [rootInclude, bablInclude], link_with: babl, - dependencies: [thread, lcms], + dependencies: [thread, lcms, log], export_dynamic: true, install: false, ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/babl-0.1.108/tools/meson.build new/babl-0.1.112/tools/meson.build --- old/babl-0.1.108/tools/meson.build 2024-02-09 17:48:36.000000000 +0100 +++ new/babl-0.1.112/tools/meson.build 2025-03-10 12:54:03.000000000 +0100 @@ -18,7 +18,7 @@ tool_name + '.c', include_directories: [rootInclude, bablInclude], link_with: babl, - dependencies: [math, thread, lcms], + dependencies: [math, thread, lcms, log], install: false, )