Øyvind Kolås [Mon, 27 Aug 2018 20:57:54 +0000 (22:57 +0200)]
babl-fish-reference: do some conversions in single precision float
This permits these conversions to go through floating point instead of double
precision when non of the involved format have more than 32bit precision,
this might be determinetal to u32 but is right for u8 and u16 which we rely
most on.
We also disable the missing fast path messages, since now many references;
through internal shortcuts are faster than some long chains, perhaps some
of these reference fast paths should be split out as new categories of fishes.
Øyvind Kolås [Fri, 24 Aug 2018 17:16:34 +0000 (19:16 +0200)]
base: preserve color in premutiplied alpha
Alpha values below BABL_ALPHA_FLOOR gets stored in the components
as BABL_ALPHA_FLOOR with alpha also set to BABL_ALPHA_FLOOR,
recovery from pre-multiplied to non-premultiplied is done as normal.
BABL_FLOOR is set to be 1/65536.0 with a hope that this gives us
approximately 8bit of color data preserved when using half-float.
Upon encountering exactly BABL_ALPHA_FLOOR in premultiplied conversion
to non-premultiplied interprets this as 0.0, making pure 0.0 values
round trip correctly from RGBA to RaGaBaA back to RGBA.
This makes a lot of extensions invalid - as expected but it already
allows testing the behavior of GEGL and GIMP with this additional
feature from babl.
Øyvind Kolås [Tue, 21 Aug 2018 16:08:47 +0000 (18:08 +0200)]
babl: add performance flag to intent, issue #21
Add BABL_ICC_INTENT_PERFORMANCE which can be ored into the intente
num when requesting that babl constructs a space using
babl_space_from_icc, when PERFORMANCE is requested babl will permit
matrix+trc over cLUT, and when it is an intent without a performance
modifier this does not apply.
The default behavior for Agryll when creating cLUT profiles seem to be
embedding an obviously incorrect XYZ matrix, meaning that for now we cannot use
the matrix for our relative colorimetric transform, and in the future the
profile will be incapable of doing dynamic trade-offs between performance and
accuracy by using matrix over cLUT during interactive operations.
We detect the swapped primaries in combination with presence of cLUTs and then
bail on constructing a valid babl space, as well as provide debug information
about why the profile cannot be used by babl.
Ell [Sat, 4 Aug 2018 06:18:37 +0000 (02:18 -0400)]
babl-cache: store reference fishes in the cache
When we only have a reference fish for a given conversion, and not
a path fish, store a corresponding entry in the cache, marked by a
"[reference]" tag in the fish's attributes line, and containing no
conversion list. When reloading the cache, make sure a reference
fish is created for the conversion without trying to construct a
path fish, so that we don't waste time trying to search for a
conversion path.
Note that we still show a "missing fast path" warning, even for
cached reference fishes.
Rely on any format string containing the substring "-space" that this
substring is the marker for the end of the encoding part of the format
name - which is what we want replicated in our new format with a different
color space.
We now do two iterations of +1 and +2 path lengths that take much longer than
the configured path lengths - and now complain with a debug output listing the
set of conversions taken to satisfy the request - giving hints on what parts
could possibly be shortened to fewer steps.
With this commit the first level of searching deeper also gets a debug message
which would cause GIMP to print a message in some places where it earlier
wouldnt have warned about missing fast paths.
babl: allow querying chromaticities for spaces made with matrix
Do this by computing the chromaticities coordinates of the colors
.. #ff0000 #00ff00 and #0000ff, this also harmonizes the serialized
name to always be chromaticities, white point and trcs.
Adding babl_chromaticities_make_space, babl_trc and
babl_trc_gamma to public api and ability to setup arbitrary
BablSpaces without loading from ICC profiles.
When viewing PNGs with attached ICC profiles the gegl binary produces black
if the two-table extension is active. Something is wrong in babl even accepting
these paths.
Øyvind Kolås [Wed, 20 Jun 2018 18:43:53 +0000 (20:43 +0200)]
babl: add ~ variants to gray color models
We do not add premultiplied sRGB trc variants even if this exists for RGB
since it is the type of premultiplied alpha cairo expects. The less code
that does non-linear compositing the better, excluding some possibilities
also reduces the combinatorial overhead of finding conversion paths in babl.
Øyvind Kolås [Wed, 20 Jun 2018 10:33:28 +0000 (12:33 +0200)]
babl: add R~G~B~ color models and pixel formats
From a given BablSpace which defines RGB chromaticities and
per component TRCs, the following are the defined formats:
R'G'B' with the TRCs applied
RGB linear data
and now a new one
R~G~B~ with the sRGB TRC, this permits any BablSpace to be the
native format of a buffer in an application while having both
a 'perceptual' in R~G~B~ and linear in RGB that is possible
to derive from it. Importantly it is also possible to recover
the babl space used to create the buffer.
Øyvind Kolås [Tue, 19 Jun 2018 17:29:48 +0000 (19:29 +0200)]
babl: rename functions that used to refer to specific gamma
The definitions of components and formats for linear and nonlinear formats in
model-rgb and model-gray are now using the TRC of a BablSpace, thus in the
format syntax ' now means nonlinear, not sRGB / 2.2 gamma - even though it ends
up meaning that for formats create without specifying the space.
Ell [Thu, 14 Jun 2018 05:54:52 +0000 (01:54 -0400)]
babl-fish: fix concurrent babl_fish()/process() calls with palette formats
In babl_fish(), don't call _babl_fish_rig_dispatch() on existing
path fishes during each lookup. We already call this function on
all path fishes upon creation (in particular, after commit b34a9672c8c9a42923a8f0b2650af30b1efe635c), so this isn't necessary.
This fixes an issue where the _babl_fish_rig_dispatch() call in
babl_fish() would temporarily modify the value of babl->fish.data,
causing a concurrent babl_process[_rows]() call in another thread
to pass the wrong 'data' value down to the conversion function. In
particular, this could cause palette conversions to segfault.
This API is internal only for now so we can change it, changing to use a
hard-coded pre-quantized chromaticities set for the internal sRGB space.
This preserve the gray axis matrix equalization performed for other spaces used
with babl, ideally we can improve the gray-axis equalization to match and
return to using it also for sRGB.
Ell [Wed, 30 May 2018 09:45:17 +0000 (05:45 -0400)]
babl-memory: allow babl_malloc(0) to succeed
Allow a babl_malloc() call with size == 0 to succeed, returning a
dummy allocation, instead of asserting on this condition. The new
babl-palette code tries to allocate an empty buffer for the radii
array when creating a single-color palette, which would previously
lead to a crash.
Ell [Fri, 18 May 2018 12:04:52 +0000 (08:04 -0400)]
babl-palette: speed up closest-color search
When constructing a palette format, calculate the distance between
each pair of colors in the palette, and for each color, construct a
list of all other colors and their distances from it, sorted by
distance. When searching for the closest palette color to a given
input pixel, based on the assumption that nearby pixels have
similar color, use the color list of the previous pixel's best
match, and use the triangle inequality to stop the search early.
Øyvind Kolås [Fri, 18 May 2018 09:02:04 +0000 (11:02 +0200)]
babl: use hashtable approach in double reference
Strictly speaking we should be doing the reference using
conversions to R'G'B'A double and using the distance metric
there; possibly getting a slight difference in result at
comparison ties.
In use GEGL ends up using both the really fast 8bit code paths
and the quite fast floating point code paths that use 8bit
hashtables for the lookup of conversion.
For working at acceptable performance with large indexed images, it is
recommended to run with BABL_TOLERANCE=0.0385 or highger set in the environment
when launching GIMP, this permits using a hashtable based optimization that
still isn't accurate enough according to babl-expectations.
Øyvind Kolås [Thu, 17 May 2018 10:53:42 +0000 (12:53 +0200)]
meson.build: synchronise with autotools version
WARNING: distributions should still not use meson to build packages - since
the meson build end up containing all instructions available on build host.