Øyvind Kolås [Tue, 30 Jan 2018 15:35:28 +0000 (16:35 +0100)]
babl: fix icc matrix profile fast paths
For core members, babl relies on shared data layout between fish and
conversion to be able to do dispatch, and have source/target match -
though only for simple fishes.
The ICC fast path conversions also used the user data - but directly
instead of throug the argument, changing this makes the matrix and
luts work again - and let the conversions be used.
Øyvind Kolås [Sat, 20 Jan 2018 17:41:12 +0000 (18:41 +0100)]
babl: initialize the bpp of fishes loaded from cache
The cache loading code manually constructs path fishes, which did not
get their bpp initialized, this resulted in conversions of long runs to
fail, not crash - but stop processing after MAX_BUFFER_SIZE pixels.
Øyvind Kolås [Wed, 17 Jan 2018 02:57:23 +0000 (03:57 +0100)]
babl: add a test iteration multiplier
On my system many of the conversions got measured to costs of 3 4 and 5, these
makes a big room for measurement errors, to increase reliability the tests are
now run 4 times - making it a ranking of contenders with fewer collisions.
This will slightly increase incurred delayed on search for conversions.
Øyvind Kolås [Wed, 17 Jan 2018 02:46:59 +0000 (03:46 +0100)]
babl: make pixel-count instrumentation opt-in
Checking if an integer is 0/1 is lower overhead than incrementing a long stored
kt a memory location. As a side effect, the entries in
~/.cache/babl/babl-fishes will not be sorted by most used to least used unless
the BABL_INSTRUMENT environment variable is set to a value.
Øyvind Kolås [Sun, 14 Jan 2018 21:49:40 +0000 (22:49 +0100)]
babl: refactor code to get rid of more branches in babl_process
In the best case scenario now, babl_process increments instrumentation
counters and directly calls the relevant registered fast path function,
with no additional call stack frames in-between.
Ell [Sat, 13 Jan 2018 09:02:24 +0000 (04:02 -0500)]
sse2-float: use same TRC for "leftover" samples
The SSE2 versions of the gamma <-> linear TRC functions can produce
slightly different results than the scalar ones. Consequently,
last commit didn't resolve all discrepancies between the main and
leftover samples (and didn't address the gamma -> linear
direction).
Use the same SSE2 TRC functions for converting the leftover
samples, rather than the scalar functions, to fix that.
Ell [Thu, 11 Jan 2018 14:22:46 +0000 (09:22 -0500)]
sse2-float: use babl_linear_to_gamma_2_2f() (instead of double)
Use the single-precision babl_linear_to_gamma_2_2f() function,
instead of the double-precision version, when converting "leftover"
samples, so that the result is consistent with the vectorized
samples.
Øyvind Kolås [Wed, 3 Jan 2018 16:12:41 +0000 (17:12 +0100)]
palette: expect palettes/formats to be gamma corrected in 8bit
A correctness correction related to bug #763581 the formats wanted
by GIMP and expected are gamma corrected not linear, I expect this
fix either does not much for GIMP or fixes an unknown 8bit linear
vs gamma quantization problem that has been lurking in INDEXED mode.
Debarshi Ray [Thu, 21 Dec 2017 09:14:53 +0000 (10:14 +0100)]
CIE: Use a faster cbrtf implementation
This is the approximate cube root of an IEEE float implementation from
Hacker's Delight. The elimination of all conditional branches probably
makes it a better candidate for future SIMD accelerated code paths.
On an Intel i7 Haswell, it now takes 0.27s to convert a 15 megapixel
buffer from "RGBA float" to "CIE Lab alpha float" instead of the
earlier 0.35s. A "Y float" to "CIE L float" conversion takes 0.085s
instead of 0.102s.
Original code: http://www.hackersdelight.org/hdcodetxt/acbrt.c.txt
Permissions: http://www.hackersdelight.org/permissions.htm
Øyvind Kolås [Sat, 9 Dec 2017 19:51:38 +0000 (20:51 +0100)]
CIE: add CIE XYZ and CIE XYZ alpha models
Even more useful now with custom RGB primaries - and being able to use babl for
conversions when needed is convenient. This is with reference paths - which
means fast paths for double precision float - single precision would have to be
added for it to be used and higher throughput in most common scenarios.
Jehan [Mon, 4 Dec 2017 02:33:47 +0000 (03:33 +0100)]
tests: not all UNIX-like OSes have a libpthread.
In particular Android systems don't need to link with -lpthread
(actually the link would fail with "ld: cannot find -lpthread").
Use the $(THREAD_LIB) variable which is set correctly during configure
since commit c02af82.
Debarshi Ray [Thu, 9 Nov 2017 06:48:26 +0000 (07:48 +0100)]
CIE: Add "CIE L float"
Some of these conversions will be leveraged by gegl:shadows-highlights
which needs to go from "Y float" or "YaA float" to "CIE L float".
The conversion from "RGBA float" was added to aid "YaA float" to
"CIE L float" fishes. They go via:
"YaA float" to "RaGaBaA float"
"RaGaBaA float" to "RGBA float"
"RGBA float" to "Y float"
"Y float" to "CIE L float"
A direct conversion from "YaA float" to "Y float" in simple C is
hindered by the need to check every pixel's alpha value to avoid
dividing by zero. The pipeline stalls make it lose out to the look-up
table and SIMD based RGB conversions to unassociated alpha.
However, we can trivially cut out the third step and still reduce some
memory traffic.
Ell [Tue, 7 Nov 2017 20:44:39 +0000 (15:44 -0500)]
babl, sse2-float: fall back to slow, accurate path for large pow-2.4 inputs
The approximations we use for pow_24() and pow_1_24() diverge from
the actual function for large-enough input values. This can lead
not just to inaccurate results, but also to infinities and NaNs,
especially when multiple conversions are strung in a row.
When the input value is large enough to produce notable divergence
(the difference between the approximate and actual values is ~1% at
the chosen limits,) fall back to a slower, but more accurate
version.
For the SSE2 float conversions, this results in an increase of ~5%
in conversion time, when all values are below the limit. When most
values are above the limit, performance can be 10x slower or worse.
Øyvind Kolås [Tue, 31 Oct 2017 19:48:23 +0000 (20:48 +0100)]
babl: add babl_format_exists
A function to check if a specific format - by name - is already known by babl.
Should be used in conjunction with babl_format() for user supplied format
strings.
Debarshi Ray [Tue, 31 Oct 2017 08:43:53 +0000 (09:43 +0100)]
CIE: Make the RGB to Lab fast paths as accurate as the reference
The matrices used by the fast paths to convert from RGB to XYZ didn't
exactly match the reference matrices in the Babl space. This caused a
measurable error in their output.
Debarshi Ray [Tue, 31 Oct 2017 08:36:39 +0000 (09:36 +0100)]
CIE: Use cbrt instead of pow for the reference XYZ to LAB conversion
The fast-paths use an inlining-friendly version of cbrt(3). Using
something similar removes superficial differences between the two
conversion paths. It's not like the C library's cbrt(3) will perform
any worse than its own pow(3).
Debarshi Ray [Sun, 29 Oct 2017 12:52:26 +0000 (13:52 +0100)]
CIE: Add conversion from "RGBA float" to "CIE Lab float"
Conversions from "RaGaBaA float" to "CIE Lab float", as seen when
using gegl:shadows-highlights" go via:
"RaGaBaA float" to "RGBA float"
"RGBA float" to "RGB float"
"RGB float" to "CIE Lab float"
A direct conversion from "RaGaBaA float" to "CIE Lab float" in simple
C is hindered by the need to check every pixel's alpha value to avoid
dividing by zero. The pipeline stalls make it lose out to the look-up
table and SIMD based conversions to unassociated alpha.
However, we can trivially cut out the second step and still reduce
some memory traffic.
The function strncpy(3) does not guarantee to end the destination string
with NUL character if not enough space was available. This could happen
on systems which allow paths which are longer than 4096 characters.
Øyvind Kolås [Tue, 3 Oct 2017 13:54:19 +0000 (15:54 +0200)]
babl: rename babl_space_from_icc to babl_icc_make_space
Thus being more consistent that functions that take icc_data + length have the
prefix babl_icc_, since each icc space in the future potentially can have more
spaces than the relative-colorimetric space defined, _make_ seems better than
_to_ or _new_.
Ell [Tue, 3 Oct 2017 14:01:58 +0000 (10:01 -0400)]
babl: fix clang warnings in babl-polynomial
Cast the input polynomial from BablPolynomial* to
BablBigPolynomial* in the evaluator functions, so that clang
doesn't warn us about out-of-bounds access to its coefficient
array.