Ø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.
babl: set babl_rel_avg_error to a high value on NaN
In relation to bug #787441, if the sum of errors contain a nan the sum
is nan, we return pi as a much higher than expected average error to
indicate that this is not 0.0.
For now, also including symbols needed for internal tools and tests, that are
not part of the public API; the API promised by babl remains the public
headers, but this reduces the public dynamic loaders namespace a little.
babl: in babl_polynomial_approximate_gamma(), verify that x0 >= 0
Now that the previous commit (hopefully) makes us iPhone-proof, we
can add an assertion for this condition. If we want to replace the
assertions with some sort of bailing, we'll need to replace the rest
of them too anyway.
babl: avoid negative degree when shrinking a zero polynomial
When shrinking a zero polynomial, avoid trying to set its degree
to a negative value, and just keep it at 0, which is the minimal
degree we support.
Note that this also happens for polynomials whose coefficients are
all NaN, as is the case in bug 788093, so they also become zero
polynomials after shrinking, incidentally.
Also adds an optimized 26 entry LUT, as used in the creation of
http://pippin.gimp.org/sRGBz/
Please enter the commit message for your changes. Lines starting
This optimizes the coefficients of the matrix ensuring that a RGB 1.0 1.0 1.0
results in exactly CIE Lab 100.0 0.0 0.0 and that equal R,G,B triples yield 0.0
for CIE a, b. This is achieved by rounding to 16.16 fixed point precision,
which can be exactly represented by IEEE double, and then brute-force jittering
the coefficients +/- 1 for the best solution. This is also the rounding needed
for making the matrix well behaved when used in an ICC profile.
babl: replace a fprintf (stderr, ...) with babl_log().
It will make it visible in the logcat, for instance in Android Studio.
As a general rule, we should use babl_log() for anything which we
consider as "logs", unless we want to direct them to a given output for
sure (for instance in the case of CLI tools where we want the output to
be on standard I/O in terminal, fprintf() still is the best choice).
Formats based on custom primaries provided by applications are unknown to babl
at launch, we still want to keep the data though, since this list of most used
fishes first is useful resource in combination with the warnings about missing
fast paths.
Instead of extracting all meta-data of ICC profiles and attaching them to
BablSpaces, we provide an string key/value API to query meta data of in-memory
ICC profiles.
babl: avoid accidental matrix overwrite by long names
.. by increasing the static per space allocation to 512 bytes, these names need
to become shorter - or the name be allocated dynamically. This fixes problems
with parameterized lab / sRGB like TRCs - which yielded really long names.
It would be really nice if others, and prolifix people like
you, prepared git formatted patches, so that it is much saner
and easier to push and work with contributions as a maintainer
with a dirty tree, and in even more valuable bugs than this
one.. without needing to re-read and re-understand the entire
context of the fix, before fully reimplementing it.
This commit fixes bug #787441, where NaN is polluting the
computer error/tolerance.
They are propagated and instructions are spent on that, but their value are
never used. Some conversion functions in base even used the argument passed for
counting down to 0 and return 0 instead, to no ill effect.
Since we do not currently see external babl extensions, we can break extensions
API without bumping the library version, this is even a change where due to
varargs, old extensions will continue working until migrated.
Not going through/bench-marking chains that will make the number of components
drop below the input/output counts, and not permitting a temporary lack of
alpha both fixes bugs at higher tolerances and speeds up path selection.
babl: use _aligned_malloc() instead of aligned_alloc() on Win32.
Thanks to Lionel N. for raising the issue. It was failing to build for
Windows with:
> babl/babl-space.c:503: undefined reference to `aligned_alloc'
Windows has apparently a similar API, except that the size and alignment
parameters are inverted.
See https://msdn.microsoft.com/library/8z34s9c6.aspx
Many of the code paths are now duplicated, the duplication should decrease as
the SSE2/SIMD versions evolve further and stop resembling the code they were
cloned from.
Øyvind Kolås [Thu, 31 Aug 2017 22:02:32 +0000 (00:02 +0200)]
babl: change MAX_BUFFER_SIZE to 512
This is the value that determins the smaller size big buffers are broken up in
and processed chunk-by chunk for multi-path conversions.
With tools/babl-benchmark for a particular workload and machine the following
results were attained, all values are in mb/s. There seem to be two sweet-spots
one around 128 and one around 512. Now using 512 which probably has better
cache behavior on most cpus than the old value 2048.