Skip to content
Commits on Source (29)
......@@ -3,7 +3,14 @@ The NEWS file in the babl source tree is the source location for
the news section both in the README and the webpage.
-->
2022-02-21 babl-0.1.90 </dt><dd>
2022-08-23 babl-0.1.96 </dt><dd>
Minor changes from 0.1.94, fixing build.
</dd><dt>
2022-08-21 babl-0.1.94 </dt><dd>
Fix of crash on non-aligned data for SIMD, add commandline tool, improve vala
compatibility of introspection info.
</dd><dt>
2022-03-22 babl-0.1.92 </dt><dd>
Fixes for avoiding load of wrong SIMD extensions.
</dd><dt>
2022-02-21 babl-0.1.90 </dt><dd>
......
......@@ -340,8 +340,8 @@ babl_extension_load_dir_list (const char *dir_list,
{
case '\0':
eos = 1;
/* don't break here, the path needs to be processed */
// the path needs to be processed.
// fall through
case BABL_PATH_SEPARATOR:
{
char *expanded_path = expand_path (path);
......
......@@ -287,7 +287,7 @@ static void measure_timings(void)
LUT_LOG("BABL_LUT_UNUSED_LIMIT=%.1f\n", lut_unused_minutes_limit);
LUT_LOG("measuring lut timings \n");
for (int p = 0; p < sizeof (pairs)/sizeof(pairs[0]);p++)
for (size_t p = 0; p < sizeof (pairs)/sizeof(pairs[0]);p++)
{
int source_bpp = pairs[p][0];
int dest_bpp = pairs[p][1];
......@@ -1365,7 +1365,7 @@ babl_process_rows (const Babl *fish,
#include <stdint.h>
#define BABL_ALIGN 16
static void inline *align_16 (unsigned char *ret)
static inline void *align_16 (unsigned char *ret)
{
int offset = BABL_ALIGN - ((uintptr_t) ret) % BABL_ALIGN;
ret = ret + offset;
......
......@@ -555,6 +555,7 @@ switch (trc->type)
break;
}
case BABL_TRC_FORMULA_SRGB:
// fall through
case BABL_TRC_FORMULA_CIE:
{
int lut_size = 512;
......@@ -1079,10 +1080,10 @@ babl_space_from_icc (const char *icc_data,
}
break;
case BABL_ICC_INTENT_ABSOLUTE_COLORIMETRIC:
*error = "absolute colormetric not implemented";
*error = "absolute colorimetric not implemented";
break;
case BABL_ICC_INTENT_SATURATION:
*error = "absolute stauration not supported";
*error = "saturation not supported";
break;
}
......@@ -1504,8 +1505,11 @@ ConvertUTF16toUTF8 (const UTF16 **sourceStart,
}
switch (bytesToWrite) { /* note: everything falls through. */
case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
// fall through
case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
// fall through
case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
// fall through
case 1: *--target = (UTF8)(ch | firstByteMark[bytesToWrite]);
}
target += bytesToWrite;
......
......@@ -318,8 +318,8 @@ babl_strcat (char *dest,
const char *src)
{
char *ret;
int src_len;
int dst_len;
size_t src_len;
size_t dst_len;
if (NULL == src)
return dest;
......
......@@ -306,7 +306,8 @@ universal_nonlinear_rgb_u8_converter_sse2 (const Babl *conversion,
uint8_t *rgb_in_u8 = (void*)src_char;
uint8_t *rgb_out_u8 = (void*)dst_char;
float rgba_out[4*samples];
// The alignment is necessary for SIMD intrinsics in babl_matrix_mul_vectorff_buf4_sse2()
float __attribute__ ((aligned (16))) rgba_out[4*samples];
for (i = 0; i < samples; i++)
{
......
......@@ -35,7 +35,7 @@ BABL_SIMD_SUFFIX (babl_formats_init) (void)
babl_type_from_id (BABL_U16),
babl_type_from_id (BABL_U32)
};
for (int i = 0; i < sizeof (types)/sizeof(types[0]);i++)
for (size_t i = 0; i < sizeof (types) / sizeof(types[0]); i++)
{
const Babl *type = types[i];
......
......@@ -69,7 +69,7 @@ convert_u32_double_scaled (BablConversion *c,
{
while (n--)
{
int u32val = *(uint32_t *) src;
uint32_t u32val = *(uint32_t *) src;
double dval;
if (u32val < min)
......@@ -154,7 +154,7 @@ convert_u32_float_scaled (BablConversion *c,
{
while (n--)
{
int u32val = *(uint32_t *) src;
uint32_t u32val = *(uint32_t *) src;
float dval;
if (u32val < min)
......
......@@ -138,7 +138,7 @@ babl = library(
link_args: babl_link_args,
link_with: simd_extra,
dependencies: babl_deps,
link_depends: version_script,
link_depends: version_script[0],
version: so_version,
install: true,
)
......@@ -156,6 +156,7 @@ if build_gir
namespace: 'Babl',
nsversion: api_version,
header: 'babl.h',
export_packages: 'babl-0.1',
install: true,
)
......@@ -165,4 +166,6 @@ if build_gir
install: true,
)
endif
else
babl_gir = []
endif
/* babl - dynamically extendable universal pixel conversion tool.
* Copyright (C) 2022 Jehan
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <babl/babl.h>
static const Babl * babl_cli_get_space (const char *path,
BablIccIntent intent);
static void babl_cli_print_usage (FILE *stream);
int
main (int argc,
char **argv)
{
const Babl *from_format;
const Babl *from_space = NULL;
const Babl *to_format;
const Babl *to_space = NULL;
const Babl *fish;
const char *from = NULL;
const char *to = NULL;
const char *from_profile = NULL;
const char *to_profile = NULL;
BablIccIntent intent = BABL_ICC_INTENT_RELATIVE_COLORIMETRIC;
char *source;
char *dest;
int set_from = 0;
int set_to = 0;
int set_from_profile = 0;
int set_to_profile = 0;
int set_intent = 0;
int brief_output = 0;
int options_ended = 0;
int n_components;
int data_index;
int c;
int i;
babl_init ();
if (argc == 1)
{
babl_cli_print_usage (stderr);
return 2;
}
/* Looping through arguments to get source and destination formats. */
for (i = 1; i < argc; i++)
{
if (set_from)
{
from = argv[i];
set_from = 0;
if (! babl_format_exists (from))
{
fprintf (stderr, "babl: unknown format: %s\n", from);
return 1;
}
}
else if (set_to)
{
to = argv[i];
set_to = 0;
if (! babl_format_exists (to))
{
fprintf (stderr, "babl: unknown format: %s\n", to);
return 1;
}
}
else if (set_from_profile)
{
set_from_profile = 0;
from_profile = argv[i];
}
else if (set_to_profile)
{
set_to_profile = 0;
to_profile = argv[i];
}
else if (set_intent)
{
set_intent = 0;
if (strcmp (argv[i], "perceptual") == 0)
{
intent = BABL_ICC_INTENT_PERCEPTUAL;
}
else if (strcmp (argv[i], "relative") == 0)
{
intent = BABL_ICC_INTENT_RELATIVE_COLORIMETRIC;
}
else if (strcmp (argv[i], "saturation") == 0)
{
intent = BABL_ICC_INTENT_SATURATION;
}
else if (strcmp (argv[i], "absolute") == 0)
{
intent = BABL_ICC_INTENT_ABSOLUTE_COLORIMETRIC;
}
else
{
fprintf (stderr, "babl: unknown intent: %s\n", argv[i]);
fprintf (stderr, "valid intents: perceptual, relative, saturation, absolute.\n");
return 2;
}
}
else if (strcmp (argv[i], "--") == 0)
{
break;
}
else if (strcmp (argv[i], "--help") == 0 ||
strcmp (argv[i], "-h") == 0)
{
babl_cli_print_usage (stdout);
return 0;
}
else if (strcmp (argv[i], "--from") == 0 ||
strcmp (argv[i], "-f") == 0)
{
set_from = 1;
}
else if (strcmp (argv[i], "--to") == 0 ||
strcmp (argv[i], "-t") == 0)
{
set_to = 1;
}
else if (strcmp (argv[i], "--input-profile") == 0 ||
strcmp (argv[i], "-i") == 0)
{
set_from_profile = 1;
}
else if (strcmp (argv[i], "--output-profile") == 0 ||
strcmp (argv[i], "-o") == 0)
{
set_to_profile = 1;
}
else if (strcmp (argv[i], "--intent") == 0 ||
strcmp (argv[i], "-r") == 0)
{
set_intent = 1;
}
else if (strcmp (argv[i], "--brief") == 0 ||
strcmp (argv[i], "-b") == 0)
{
brief_output = 1;
}
}
if (from_profile != NULL)
{
from_space = babl_cli_get_space (from_profile, intent);
if (! from_space)
return 6;
}
if (to_profile != NULL)
{
to_space = babl_cli_get_space (to_profile, intent);
if (! to_space)
return 6;
}
if (from == NULL)
{
if (babl_space_is_cmyk (from_space))
from = "CMYK float";
else if (babl_space_is_gray (from_space))
from = "Y' float";
else
from = "R'G'B' float";
}
if (to == NULL)
{
if (babl_space_is_cmyk (to_space))
to = "CMYK float";
else if (babl_space_is_gray (to_space))
to = "Y' float";
else
to = "R'G'B' float";
}
from_format = babl_format_with_space (from, from_space);
n_components = babl_format_get_n_components (from_format);
source = malloc (babl_format_get_bytes_per_pixel (from_format));
data_index = 0;
to_format = babl_format_with_space (to, to_space);
dest = malloc (babl_format_get_bytes_per_pixel (from_format));
/* Re-looping through arguments, to be more flexible with argument orders.
* In this second loop, we get the source components' values.
*/
set_from = set_to = set_to_profile = set_from_profile = 0;
for (i = 1, c = 0; i < argc; i++)
{
if (set_from)
{
set_from = 0;
/* Pass. */
}
else if (set_to)
{
set_to = 0;
/* Pass. */
}
else if (set_from_profile)
{
set_from_profile = 0;
/* Pass. */
}
else if (set_to_profile)
{
set_to_profile = 0;
/* Pass. */
}
else if (set_intent)
{
set_intent = 0;
/* Pass. */
}
else if (! options_ended && strncmp (argv[i], "-", 1) == 0)
{
if (strcmp (argv[i], "--") == 0)
{
options_ended = 1;
}
else if (strcmp (argv[i], "--help") == 0 ||
strcmp (argv[i], "-h") == 0)
{
/* Pass. */
}
else if (strcmp (argv[i], "--from") == 0 ||
strcmp (argv[i], "-f") == 0)
{
set_from = 1;
}
else if (strcmp (argv[i], "--to") == 0 ||
strcmp (argv[i], "-t") == 0)
{
set_to = 1;
}
else if (strcmp (argv[i], "--input-profile") == 0 ||
strcmp (argv[i], "-i") == 0)
{
set_from_profile = 1;
}
else if (strcmp (argv[i], "--output-profile") == 0 ||
strcmp (argv[i], "-o") == 0)
{
set_to_profile = 1;
}
else if (strcmp (argv[i], "--intent") == 0 ||
strcmp (argv[i], "-r") == 0)
{
set_intent = 1;
}
else if (strcmp (argv[i], "--brief") == 0 ||
strcmp (argv[i], "-b") == 0)
{
/* Pass. */
}
else
{
fprintf (stderr, "babl: unknown option: %s\n", argv[i]);
babl_cli_print_usage (stderr);
return 2;
}
}
else
{
const Babl *arg_type;
char *endptr = NULL;
if (c >= n_components)
{
fprintf (stderr, "babl: unexpected component: %s\n", argv[i]);
babl_cli_print_usage (stderr);
return 2;
}
arg_type = babl_format_get_type (from_format, c);
if (strcmp (babl_get_name (arg_type), "float") == 0)
{
float value = strtof (argv[i], &endptr);
float *fsrc = (float *) (source + data_index);
if (value == 0.0f && endptr == argv[i])
{
fprintf (stderr, "babl: expected type of component %d is '%s', invalid value: %s\n",
c, babl_get_name (arg_type), argv[i]);
return 3;
}
*fsrc = value;
data_index += 4;
}
else if (strncmp (babl_get_name (arg_type), "u", 1) == 0)
{
long int value = strtol (argv[i], &endptr, 10);
if (value == 0 && endptr == argv[i])
{
fprintf (stderr, "babl: expected type of component %d is '%s', invalid value: %s\n",
c, babl_get_name (arg_type), argv[i]);
return 3;
}
if (strcmp (babl_get_name (arg_type), "u8") == 0)
{
uint8_t *usrc = (uint8_t *) (source + data_index);
*usrc = value;
data_index += 1;
}
else if (strcmp (babl_get_name (arg_type), "u16") == 0)
{
uint16_t *usrc = (uint16_t *) (source + data_index);
*usrc = value;
data_index += 2;
}
else if (strcmp (babl_get_name (arg_type), "u32") == 0)
{
uint32_t *usrc = (uint32_t *) (source + data_index);
*usrc = value;
data_index += 4;
}
else
{
fprintf (stderr, "babl: unsupported unsigned type '%s' of component %d: %s\n",
babl_get_name (arg_type), c, argv[i]);
return 4;
}
}
else
{
fprintf (stderr, "babl: unsupported type '%s' of component %d: %s\n",
babl_get_name (arg_type), c, argv[i]);
return 4;
}
c++;
}
}
if (c != n_components)
{
fprintf (stderr, "babl: %d components expected, %d components were passed\n",
n_components, c);
babl_cli_print_usage (stderr);
return 2;
}
/* Actual processing. */
fish = babl_fish (from_format, to_format);
babl_process (fish, source, dest, 1);
/* Now displaying the result. */
n_components = babl_format_get_n_components (to_format);
data_index = 0;
if (! brief_output)
printf ("Converting from \"%s\" to \"%s\":\n",
babl_get_name (from_format),
babl_get_name (to_format));
for (c = 0; c < n_components; c++)
{
const Babl *arg_type = NULL;
arg_type = babl_format_get_type (to_format, c);
if (strcmp (babl_get_name (arg_type), "float") == 0)
{
float value = *((float *) (dest + data_index));
data_index += 4;
if (brief_output)
printf ("%s%f", c > 0 ? " ":"", value);
else
printf ("- %f\n", value);
}
else if (strcmp (babl_get_name (arg_type), "u8") == 0)
{
uint8_t value = *((uint8_t *) (dest + data_index));
data_index += 1;
if (brief_output)
printf ("%s%d", c > 0 ? " ":"", value);
else
printf ("- %d\n", value);
}
else if (strcmp (babl_get_name (arg_type), "u16") == 0)
{
uint16_t value = *((uint16_t *) (dest + data_index));
data_index += 2;
if (brief_output)
printf ("%s%d", c > 0 ? " ":"", value);
else
printf ("- %d\n", value);
}
else if (strcmp (babl_get_name (arg_type), "u32") == 0)
{
uint32_t value = *((uint32_t *) (dest + data_index));
data_index += 4;
if (brief_output)
printf ("%s%d", c > 0 ? " ":"", value);
else
printf ("- %d\n", value);
}
else
{
fprintf (stderr, "babl: unsupported type '%s' of returned component %d: %s\n",
babl_get_name (arg_type), c, argv[i]);
return 5;
}
}
babl_exit ();
free (source);
free (dest);
return 0;
}
static const Babl *
babl_cli_get_space (const char *path,
BablIccIntent intent)
{
const Babl *space;
FILE *f;
char *icc_data;
long icc_length;
const char *error = NULL;
f = fopen (path, "r");
if (f == NULL)
{
fprintf (stderr, "babl: failed to open '%s': %s\n",
path, strerror (errno));
return NULL;
}
fseek (f, 0, SEEK_END);
icc_length = ftell (f);
fseek (f, 0, SEEK_SET);
icc_data = malloc (icc_length);
fread (icc_data, icc_length, 1, f);
fclose (f);
space = babl_space_from_icc (icc_data, icc_length, intent, &error);
if (space == NULL)
{
fprintf (stderr, "babl: failed to load space from '%s': %s\n",
path, error);
return NULL;
}
return space;
}
static void
babl_cli_print_usage (FILE *stream)
{
fprintf (stream,
"Usage: babl [options] [c1 ..]\n"
"Convert color data from a specific Babl format and space to another.\n"
"\n"
" Options:\n"
" -h, --help this help information\n"
"\n"
" -f, --from input Babl format\n"
"\n"
" -t, --to output Babl format\n"
"\n"
" -i, --input-profile input profile\n"
"\n"
" -o, --output-profile output profile\n"
"\n"
" -r, --intent rendering intent\n"
" it only works with an output profile\n"
"\n"
" -b, --brief brief output\n"
" it can be re-entered as input for chain conversions\n"
"\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");
}
babl_sources = files(
'babl.c',
)
babl_bin = executable('babl',
babl_sources,
include_directories: [ rootInclude ],
link_with: babl,
install: true,
)
......@@ -6,6 +6,7 @@ no_cflags = []
babl_ext_dep = [
math,
thread,
lcms,
]
# Include directories
......
#ifndef __BABL_GIT_VERSION_H__
#define __BABL_GIT_VERSION_H__
#define BABL_GIT_VERSION "BABL_0_1_90-10-gbefaba5"
#define BABL_GIT_VERSION "BABL_0_1_96"
#endif /* __BABL_GIT_VERSION_H__ */
project('babl', 'c',
license: 'LGPL3+',
version: '0.1.92',
version: '0.1.96',
meson_version: '>=0.54.0',
default_options: [
'buildtype=debugoptimized'
......@@ -55,7 +55,7 @@ lib_name = meson.project_name() + '-' + api_version
stability_version_number = (major_version != 0 ? minor_version : micro_version)
stable = (stability_version_number % 2 == 0)
conf.set10('BABL_UNSTABLE', not stable, Description:
conf.set10('BABL_UNSTABLE', not stable, description:
'Define to 1 if this is an unstable version of BABL.')
conf.set ('BABL_MAJOR_VERSION', '@0@'.format(major_version))
......@@ -493,6 +493,7 @@ subdir('tools')
if build_docs
subdir('docs')
endif
subdir('bin')
# Create README file from web page
if w3m_bin.found() and build_docs
......@@ -531,13 +532,14 @@ babl_dep = declare_dependency(
link_with : babl,
sources: [
babl_version_h,
is_variable('babl_gir') ? babl_gir : []
build_gir ? babl_gir : []
],
variables: {
'babl_path' : babl_extensions_build_dir,
'babl_libdir' : babl_library_build_dir,
},
)
meson.override_dependency('babl', babl_dep)
################################################################################
# Build summary
......
[wrap-file]
directory = Little-CMS-2.12
source_url = https://github.com/mm2/Little-CMS/archive/refs/tags/2.12.tar.gz
source_filename = lcms2-2.12.tar.gz
source_hash = e501f1482fc424550ef3abbf86bf1c66090e1661249e89552d39ed5bf935df66
patch_filename = lcms2_2.12-2_patch.zip
patch_url = https://wrapdb.mesonbuild.com/v2/lcms2_2.12-2/get_patch
patch_hash = 3ac6944ac4b8d8507b85961d98cb287532945183d0e8f094c77810e793b6bebe
[provide]
lcms2 = liblcms2_dep
......@@ -100,8 +100,7 @@ test (void)
}
int
main (int argc,
char **argv)
main (void)
{
babl_init ();
if (test ())
......
......@@ -63,8 +63,7 @@ test (void)
}
int
main (int argc,
char **argv)
main (void)
{
babl_init ();
if (test ())
......
......@@ -69,8 +69,7 @@ test (void)
}
int
main (int argc,
char **argv)
main (void)
{
babl_init ();
if (test ())
......
......@@ -66,8 +66,7 @@ test (void)
}
int
main (int argc,
char **argv)
main (void)
{
babl_init ();
if (test ())
......
......@@ -23,8 +23,7 @@
int
main (int argc,
char **argv)
main (void)
{
int OK = 1;
......