summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2018-05-11 17:10:17 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2018-05-11 17:10:28 +0000
commit9eb2ff03c3a21fa012f34578cf5ed627ec3153fc (patch)
treee3fd670d7cc5b3eed936b179d11e6579f14cc3a5
parentReleasing progress-linux version 0.1.30-1~dschinn1. (diff)
downloadbabl-9eb2ff03c3a21fa012f34578cf5ed627ec3153fc.zip
babl-9eb2ff03c3a21fa012f34578cf5ed627ec3153fc.tar.xz
Merging upstream version 0.1.34.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
-rw-r--r--AUTHORS2
-rw-r--r--INSTALL10
-rw-r--r--Makefile.am3
-rw-r--r--Makefile.in4
-rw-r--r--NEWS9
-rw-r--r--README463
-rw-r--r--TODO8
-rw-r--r--babl/Makefile.am44
-rw-r--r--babl/Makefile.in357
-rw-r--r--babl/babl-cache.c49
-rw-r--r--babl/babl-classes.h6
-rw-r--r--babl/babl-conversion.c127
-rw-r--r--babl/babl-conversion.h23
-rw-r--r--babl/babl-core.c18
-rw-r--r--babl/babl-extension.c9
-rw-r--r--babl/babl-fish-path.c309
-rw-r--r--babl/babl-fish-reference.c39
-rw-r--r--babl/babl-fish.c54
-rw-r--r--babl/babl-format.c115
-rw-r--r--babl/babl-format.h1
-rw-r--r--babl/babl-icc.c1124
-rw-r--r--babl/babl-internal.c2
-rw-r--r--babl/babl-internal.h169
-rw-r--r--babl/babl-introspect.c26
-rw-r--r--babl/babl-list.c2
-rw-r--r--babl/babl-macros.h2
-rw-r--r--babl/babl-matrix.h195
-rw-r--r--babl/babl-model.c69
-rw-r--r--babl/babl-model.h14
-rw-r--r--babl/babl-palette.c81
-rw-r--r--babl/babl-polynomial.c541
-rw-r--r--babl/babl-polynomial.h79
-rw-r--r--babl/babl-space.c988
-rw-r--r--babl/babl-space.h96
-rw-r--r--babl/babl-trc.c543
-rw-r--r--babl/babl-trc.h106
-rw-r--r--babl/babl-types.h9
-rw-r--r--babl/babl-util.c45
-rw-r--r--babl/babl-version.h2
-rw-r--r--babl/babl.c2
-rw-r--r--babl/babl.h146
-rw-r--r--babl/base/Makefile.am1
-rw-r--r--babl/base/Makefile.in2
-rw-r--r--babl/base/model-gray.c128
-rw-r--r--babl/base/model-rgb.c106
-rw-r--r--babl/base/model-ycbcr.c25
-rw-r--r--babl/base/pow-24.h2
-rw-r--r--babl/base/rgb-constants.h32
-rw-r--r--babl/base/type-float.c12
-rw-r--r--babl/base/type-half.c20
-rw-r--r--babl/base/type-u15.c47
-rw-r--r--babl/base/type-u16.c28
-rw-r--r--babl/base/type-u32.c28
-rw-r--r--babl/base/type-u8.c28
-rw-r--r--babl/base/util.h3
-rwxr-xr-xconfigure34
-rw-r--r--configure.ac5
-rw-r--r--docs/Makefile.am6
-rw-r--r--docs/Makefile.in7
-rw-r--r--docs/graphics/Makefile.in1
-rw-r--r--docs/index-static.html.in134
-rw-r--r--export-symbols69
-rw-r--r--extensions/16bit.c12
-rw-r--r--extensions/CIE.c342
-rw-r--r--extensions/HCY.c32
-rw-r--r--extensions/HSL.c35
-rw-r--r--extensions/HSV.c32
-rw-r--r--extensions/Makefile.am4
-rw-r--r--extensions/Makefile.in5
-rw-r--r--extensions/cairo.c96
-rw-r--r--extensions/fast-float.c50
-rw-r--r--extensions/float-half.c224
-rw-r--r--extensions/float.c95
-rw-r--r--extensions/gegl-fixups.c74
-rw-r--r--extensions/gggl-lies.c260
-rw-r--r--extensions/gggl-table-lies.c104
-rw-r--r--extensions/gggl-table.c111
-rw-r--r--extensions/gggl.c289
-rw-r--r--extensions/gimp-8bit.c207
-rw-r--r--extensions/grey.c50
-rw-r--r--extensions/naive-CMYK.c28
-rw-r--r--extensions/simple.c141
-rw-r--r--extensions/sse-half.c48
-rw-r--r--extensions/sse2-float.c74
-rw-r--r--extensions/sse2-int16.c12
-rw-r--r--extensions/sse2-int8.c30
-rw-r--r--extensions/sse4-int8.c26
-rw-r--r--extensions/two-table.c35
-rw-r--r--extensions/ycbcr.c20
-rw-r--r--tests/Makefile.am12
-rw-r--r--tests/Makefile.in112
-rw-r--r--tests/chromaticities.c77
-rw-r--r--tests/grayscale_to_rgb.c4
-rw-r--r--tools/Makefile.am13
-rw-r--r--tools/Makefile.in125
-rw-r--r--tools/babl-benchmark.c186
-rw-r--r--tools/babl-gen-test-pixels.c5
-rw-r--r--tools/babl-html-dump.c (renamed from tests/babl-html-dump.c)0
-rw-r--r--tools/babl-icc-dump.c674
-rw-r--r--tools/babl-icc-rewrite.c191
-rw-r--r--tools/babl_fish_path_fitness.c (renamed from tests/babl_fish_path_fitness.c)0
-rw-r--r--tools/conversions.c (renamed from tests/conversions.c)0
-rw-r--r--tools/formats.c (renamed from tests/formats.c)0
-rw-r--r--tools/introspect.c (renamed from tests/introspect.c)0
-rw-r--r--tools/trc-validator.c219
105 files changed, 8382 insertions, 2281 deletions
diff --git a/AUTHORS b/AUTHORS
index 04ad3ae..d574ee0 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -67,7 +67,7 @@
<dd>Verification and improvements to accuracy of color space
conversions.</dd>
<dt>Thomas Manni</dt>
- <dd>CIE related fixups</dd?
+ <dd>CIE related fixups</dd>
<dt>Roman Lebedev</dt>
<dd>Stability/crasher fixes</dd>
<dt>Jon Nordby</dt>
diff --git a/INSTALL b/INSTALL
index 925472f..ea3004f 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,5 +1,5 @@
-babl 0.1.30
+babl 0.1.34
Dynamic; any to any, pixel format conversion library.
@@ -12,10 +12,10 @@ From a released version the following is the expected method of
installation (or a variation on this theme):
------------------------------------------------------------
- foo$ wget ftp://ftp.gtk.org/pub/babl/0.1/babl-0.1.30.tar.bz2
- foo$ tar jxf babl-0.1.30.tar.gz
- foo$ cd babl-0.1.30
- foo/babl-0.1.30$ ./configure && make && sudo make install
+ foo$ wget ftp://ftp.gtk.org/pub/babl/0.1/babl-0.1.34.tar.bz2
+ foo$ tar jxf babl-0.1.34.tar.gz
+ foo$ cd babl-0.1.34
+ foo/babl-0.1.34$ ./configure && make && sudo make install
------------------------------------------------------------
diff --git a/Makefile.am b/Makefile.am
index e46014c..ffa9645 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -23,7 +23,8 @@ EXTRA_DIST = \
NEWS \
TODO \
autogen.sh \
- babl.pc.in
+ babl.pc.in \
+ export-symbols
DISTCLEANFILES = \
$(built_dist_files) \
diff --git a/Makefile.in b/Makefile.in
index 98b34ed..97334f6 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -292,6 +292,7 @@ LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
+LOG_LIB = @LOG_LIB@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAINT = @MAINT@
@@ -400,7 +401,8 @@ EXTRA_DIST = \
NEWS \
TODO \
autogen.sh \
- babl.pc.in
+ babl.pc.in \
+ export-symbols
DISTCLEANFILES = \
$(built_dist_files) \
diff --git a/NEWS b/NEWS
index dd961c0..c50a4ef 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,15 @@ the news section both in the README and the webpage.
-->
+2017-10-06 babl-0.1.34 </dt><dd>
+Brown paper bag release, Fix indexed / custom primaries conflict, and re-export
+a symbol used by old GEGL/GIMPs.
+ </dd><dt>
+2017-10-03 babl-0.1.32 </dt><dd>
+Added custom primaries and TRC support through ICC parsing, improved
+float<->half performance, rewrite of all conversions functions to adhere to new
+signature.
+ </dd><dt>
2017-07-15 babl-0.1.30 </dt><dd>
Thread stability for palette modes, stricter alpha preservation, now
cross-compilable on android.
diff --git a/README b/README
index f03ed98..6472d36 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Babl-0.1.30
+Babl-0.1.34
Contents
@@ -21,23 +21,26 @@ babl is a dynamic, any to any, pixel format translation library.
It allows converting between different methods of storing pixels known
as pixel formats that have with different bitdepths and other data
-representations, color models and component permutations.
+representations, color models, color spaces and component permutations.
A vocabulary to formulate new pixel formats from existing primitives is
-provided as well as the framework to add new color models and data
-types.
+provided as well as the framework to add new color models, spaces and
+data types.
Features
- • Fast.
- • Accurate.
- • Stable, small API.
- • Self profiling and optimizing.
- • ANSI C, works on win32, linux and mac, 32bit and 64bit systems.
+ • ANSI C without external dependencies, works on win32, linux and
+ mac, 32bit and 64bit systems.
+ • Stable, small API, with singleton objects returned.
• Extendable with new formats, color models, components and
datatypes.
+ • Can load color spaces from ICC v2 and v4 profiles containing RGB
+ matrix + TRC.
• Reference 64bit floating point conversions for datatypes and color
models.
+ • Self profiling and optimizing, optimizing accuracy and performance
+ at runtime when the best performing single or multi-step conversion
+ path is chosen.
GEGL through GeglBuffer provides tiled buffers with on disk storage as
well as linear buffers with accessor functions for efficient data
@@ -54,11 +57,20 @@ browsed online and cloned with:
git clone git://git.gnome.org/babl
+NEWS
+
The following is a list of the major changes that have gone into each
babl release. If there are significant improvements to babl when a GEGL
release is done a babl release is most often put out just prior to the
GEGL release.
+2017-10-06 babl-0.1.34
+ Brown paper bag release, Fix indexed / custom primaries conflict,
+ and re-export a symbol used by old GEGL/GIMPs.
+2017-10-03 babl-0.1.32
+ Added custom primaries and TRC support through ICC parsing,
+ improved float<->half performance, rewrite of all conversions
+ functions to adhere to new signature.
2017-07-15 babl-0.1.30
Thread stability for palette modes, stricter alpha preservation,
now cross-compilable on android.
@@ -196,6 +208,33 @@ const Babl *format = babl_format_new (babl_model ("R'G'B'"),
babl_component ("R'"),
NULL);
+Color Management
+
+By default the babl API is assuming data to be (unbounded) sRGB data,
+data being sRGB defines the conversion to and from gray-scale as well
+as the gamma - or Transfer Response Curve, TRC, used for converting
+between linear and non-linear variants of the data.
+
+There is also a babl API call for creating a format for a specific
+space. babl_format_with_space("R'G'B' u16", babl_space ("Rec2020"))
+creates a 16 bit integer format for the Rec2020 color space. Babl knows
+internally about "sRGB", "Rec2020", "Adobe", "Apple" and "ProPhoto"
+spaces, as they are defined with constants on their wikipedia pages.
+
+Additional spaces can be loaded from monitor-class matrix+TRC ICC v2
+and v4 profiles. Using babl_icc_make_space (see babl.h for details).
+The space of a babl format can also be queried with
+babl_format_get_space.
+
+The conversions babl does with ICC profiles are according to what is
+known as the relative-colorimetric intent, monitor profiles containing
+both the matrices used by babl and 3d CLUTs (color look up tables) most
+often also do relative-colorimetric transfer for the "perceptual"
+intent CLUTs, but with a more flexible and possibly higher accuracy
+conversions. If babl adds support for loading and using CLUTs it will
+be thus the perceptual intent will by babl be considered a different
+albeit more accurate relative-colorimetric RGB space.
+
Vocabulary
@@ -402,40 +441,6 @@ components
Cr
A
-HSVA
-
-components
-
- hue
- saturation
- value
- alpha
-
-HSV
-
-components
-
- hue
- saturation
- value
-
-CMYK
-
-components
-
- cyan
- magenta
- yellow
- key
-
-CMY
-
-components
-
- cyan
- magenta
- yellow
-
CIE Lab
components
@@ -470,6 +475,23 @@ components
CIE H(ab)
A
+HCYA
+
+components
+
+ hue
+ HCY chroma
+ HCY luma
+ alpha
+
+HCY
+
+components
+
+ hue
+ HCY chroma
+ HCY luma
+
HSLA
components
@@ -504,22 +526,39 @@ components
Cr
alpha
-HCYA
+HSVA
components
hue
- HCY chroma
- HCY luma
+ saturation
+ value
alpha
-HCY
+HSV
components
hue
- HCY chroma
- HCY luma
+ saturation
+ value
+
+CMYK
+
+components
+
+ cyan
+ magenta
+ yellow
+ key
+
+CMY
+
+components
+
+ cyan
+ magenta
+ yellow
Pixel formats
RGBA double
@@ -1577,132 +1616,6 @@ components
u8 R'
u8 PAD
-HSVA double
-
-bytes/pixel
- 32
-model
- HSVA
-components
-
- double hue
- double saturation
- double value
- double alpha
-
-HSV double
-
-bytes/pixel
- 24
-model
- HSV
-components
-
- double hue
- double saturation
- double value
-
-HSVA float
-
-bytes/pixel
- 16
-model
- HSVA
-components
-
- float hue
- float saturation
- float value
- float alpha
-
-HSV float
-
-bytes/pixel
- 12
-model
- HSV
-components
-
- float hue
- float saturation
- float value
-
-B'aG'aR'aA u8
-
-bytes/pixel
- 4
-model
- R'aG'aB'aA
-components
-
- u8 B'a
- u8 G'a
- u8 R'a
- u8 A
-
-CMYK double
-
-bytes/pixel
- 32
-model
- CMYK
-components
-
- double cyan
- double magenta
- double yellow
- double key
-
-CMY double
-
-bytes/pixel
- 24
-model
- CMY
-components
-
- double cyan
- double magenta
- double yellow
-
-CMYK float
-
-bytes/pixel
- 16
-model
- CMYK
-components
-
- float cyan
- float magenta
- float yellow
- float key
-
-CMY float
-
-bytes/pixel
- 12
-model
- CMY
-components
-
- float cyan
- float magenta
- float yellow
-
-CMYK u8
-
-bytes/pixel
- 4
-model
- CMYK
-components
-
- u8 cyan
- u8 magenta
- u8 yellow
- u8 key
-
CIE Lab double
bytes/pixel
@@ -1838,6 +1751,69 @@ components
float CIE H(ab)
float A
+HCYA double
+
+bytes/pixel
+ 32
+model
+ HCYA
+components
+
+ double hue
+ double HCY chroma
+ double HCY luma
+ double alpha
+
+HCY double
+
+bytes/pixel
+ 24
+model
+ HCY
+components
+
+ double hue
+ double HCY chroma
+ double HCY luma
+
+HCYA float
+
+bytes/pixel
+ 16
+model
+ HCYA
+components
+
+ float hue
+ float HCY chroma
+ float HCY luma
+ float alpha
+
+HCY float
+
+bytes/pixel
+ 12
+model
+ HCY
+components
+
+ float hue
+ float HCY chroma
+ float HCY luma
+
+B'aG'aR'aA u8
+
+bytes/pixel
+ 4
+model
+ R'aG'aB'aA
+components
+
+ u8 B'a
+ u8 G'a
+ u8 R'a
+ u8 A
+
HSLA double
bytes/pixel
@@ -1888,6 +1864,29 @@ components
float saturation
float lightness
+cairo-ARGB32
+
+bytes/pixel
+ 4
+model
+ R'aG'aB'aA
+components
+
+ u8 B'a
+ u8 G'a
+ u8 R'a
+ u8 A
+
+cairo-A8
+
+bytes/pixel
+ 1
+model
+ YA
+components
+
+ u8 A
+
Y'CbCr709 double
bytes/pixel
@@ -1938,78 +1937,118 @@ components
float Cb
float Cr
-HCYA double
+HSVA double
bytes/pixel
32
model
- HCYA
+ HSVA
components
double hue
- double HCY chroma
- double HCY luma
+ double saturation
+ double value
double alpha
-HCY double
+HSV double
bytes/pixel
24
model
- HCY
+ HSV
components
double hue
- double HCY chroma
- double HCY luma
+ double saturation
+ double value
-HCYA float
+HSVA float
bytes/pixel
16
model
- HCYA
+ HSVA
components
float hue
- float HCY chroma
- float HCY luma
+ float saturation
+ float value
float alpha
-HCY float
+HSV float
bytes/pixel
12
model
- HCY
+ HSV
components
float hue
- float HCY chroma
- float HCY luma
+ float saturation
+ float value
-cairo-ARGB32
+CMYK double
bytes/pixel
- 4
+ 32
model
- R'aG'aB'aA
+ CMYK
components
- u8 B'a
- u8 G'a
- u8 R'a
- u8 A
+ double cyan
+ double magenta
+ double yellow
+ double key
-cairo-A8
+CMY double
bytes/pixel
- 1
+ 24
model
- YA
+ CMY
components
- u8 A
+ double cyan
+ double magenta
+ double yellow
+
+CMYK float
+
+bytes/pixel
+ 16
+model
+ CMYK
+components
+
+ float cyan
+ float magenta
+ float yellow
+ float key
+
+CMY float
+
+bytes/pixel
+ 12
+model
+ CMY
+components
+
+ float cyan
+ float magenta
+ float yellow
+
+CMYK u8
+
+bytes/pixel
+ 4
+model
+ CMYK
+components
+
+ u8 cyan
+ u8 magenta
+ u8 yellow
+ u8 key
Shortcut Coverage
@@ -2020,12 +2059,6 @@ chain of conversions.
Environment
-If the environment variable BABL_STATS is set containting a html pixel
-format conversion usage matrix will be written to /tmp/babl-stats.html.
-This allows figuring out which conversions is taking up time during
-processing, and what shortcuts extensions might be created or improved
-to make babl do it's job faster.
-
Through the environment variable BABL_TOLERANCE you can control a speed
/performance trade off that by default is set very low (0.000001)
values in the range 0.01-0.1 can provide reasonable preview performance
@@ -2033,6 +2066,9 @@ by allowing lower numerical accuracy
.
+BABL_PATH contains the path of the directory, containing the .so
+extensions to babl.
+
Extending
For samples of how the current internal API specification of data
@@ -2061,12 +2097,8 @@ babl-dist-root
TODO
• Support for conversions between formats that have higher
- dimensionality than RGBA. (arbitrary meaningless components)
+ dimensionality than RGBA.
• Support for datatypes that are not a multiple of 8bit.
- • dynamic data attached to format, or internal handling of icc
- through a registered set of profiles
- • handling of custom RGB primaries and gamma
- • dithering
Copyright
@@ -2144,7 +2176,8 @@ Elle Stone
Verification and improvements to accuracy of color space
conversions.
Thomas Manni
- CIE related fixupsRoman Lebedev
+ CIE related fixups
+Roman Lebedev
Stability/crasher fixes
Jon Nordby
Portability, Stability and more
@@ -2153,4 +2186,4 @@ Massimo Valentini
Ell
fast paths
-/babl-0.1.30
+/babl-0.1.34
diff --git a/TODO b/TODO
index 6707b94..843cef1 100644
--- a/TODO
+++ b/TODO
@@ -1,10 +1,6 @@
<h2>TODO</h2>
-
+
<ul>
- <li>Support for conversions between formats that have higher dimensionality than RGBA. (arbitrary meaningless components)</li>
+ <li>Support for conversions between formats that have higher dimensionality than RGBA.</li>
<li>Support for datatypes that are not a multiple of 8bit.</li>
- <li>dynamic data attached to format, or internal handling of icc through
- a registered set of profiles</li>
- <li>handling of custom RGB primaries and gamma</li>
- <li>dithering</li>
</ul>
diff --git a/babl/Makefile.am b/babl/Makefile.am
index 9c697a3..98b822b 100644
--- a/babl/Makefile.am
+++ b/babl/Makefile.am
@@ -1,7 +1,7 @@
## Source directory
if PLATFORM_WIN32
-no_undefined = -no-undefined
+win32_no_undefined = -no-undefined
endif
SUBDIRS = base
@@ -20,6 +20,7 @@ c_sources = \
babl-fish.c \
babl-format.c \
babl-hash-table.c \
+ babl-icc.c \
babl-image.c \
babl-internal.c \
babl-introspect.c \
@@ -27,10 +28,13 @@ c_sources = \
babl-memory.c \
babl-model.c \
babl-mutex.c \
- babl-palette.c \
+ babl-palette.c \
+ babl-polynomial.c \
babl-ref-pixels.c \
babl-sampling.c \
babl-sanity.c \
+ babl-space.c \
+ babl-trc.c \
babl-type.c \
babl-util.c \
babl-cpuaccel.c \
@@ -56,40 +60,54 @@ h_sources = \
babl-macros.h \
babl-memory.h \
babl-model.h \
+ babl-matrix.h \
babl-mutex.h \
+ babl-polynomial.h \
babl-ref-pixels.h \
babl-sampling.h \
+ babl-space.h \
+ babl-trc.h \
babl-type.h \
babl-types.h \
babl-util.h
library_includedir=$(includedir)/babl-$(BABL_API_VERSION)/babl
libinc_hdrs = \
- babl-introspect.h \
- babl-macros.h \
- babl-types.h \
+ babl-introspect.h \
+ babl-macros.h \
+ babl-types.h \
babl.h
-libinc_generated_hdrs = \
+
+libinc_generated_hdrs = \
babl-version.h
-library_include_HEADERS = \
+
+library_include_HEADERS = \
$(libinc_hdrs) $(libinc_generated_hdrs)
-AM_CPPFLAGS = \
+AM_CPPFLAGS = \
-DLIBDIR=\""$(libdir)"\" \
-I$(top_srcdir) \
-I$(top_srcdir)/babl/base
lib_LTLIBRARIES= libbabl-@BABL_API_VERSION@.la
+
libbabl_@BABL_API_VERSION@_la_SOURCES= $(h_sources) $(c_sources)
-libbabl_@BABL_API_VERSION@_la_LIBADD=\
- base/libbase.la \
+libbabl_@BABL_API_VERSION@_la_CFLAGS= $(SSE2_EXTRA_CFLAGS)
+
+libbabl_@BABL_API_VERSION@_la_LIBADD= \
+ base/libbase.la \
@LTLIBOBJS@
-libbabl_@BABL_API_VERSION@_la_LDFLAGS= \
- ${no_undefined} $(MATH_LIB) $(THREAD_LIB) \
+libbabl_la_LDFLAGS= \
+ $(MATH_LIB) $(THREAD_LIB) $(LOG_LIB)
+
+libbabl_@BABL_API_VERSION@_la_LDFLAGS= \
+ ${win32_no_undefined} \
+ $(MATH_LIB) $(THREAD_LIB) $(LOG_LIB) \
+ -export-symbols $(top_srcdir)/export-symbols \
-version-info $(BABL_LIBRARY_VERSION)
-EXTRA_DIST = babl-ref-pixels.inc
+EXTRA_DIST = babl-ref-pixels.inc
# If git is available, always check if git-version.h should be
diff --git a/babl/Makefile.in b/babl/Makefile.in
index e888c4f..0c871d6 100644
--- a/babl/Makefile.in
+++ b/babl/Makefile.in
@@ -137,14 +137,38 @@ LTLIBRARIES = $(lib_LTLIBRARIES)
libbabl_@BABL_API_VERSION@_la_DEPENDENCIES = base/libbase.la \
@LTLIBOBJS@ $(am__empty)
am__objects_1 =
-am__objects_2 = babl.lo babl-cache.lo babl-component.lo \
- babl-conversion.lo babl-core.lo babl-db.lo babl-extension.lo \
- babl-fish-path.lo babl-fish-reference.lo babl-fish-simple.lo \
- babl-fish.lo babl-format.lo babl-hash-table.lo babl-image.lo \
- babl-internal.lo babl-introspect.lo babl-list.lo \
- babl-memory.lo babl-model.lo babl-mutex.lo babl-palette.lo \
- babl-ref-pixels.lo babl-sampling.lo babl-sanity.lo \
- babl-type.lo babl-util.lo babl-cpuaccel.lo babl-version.lo
+am__objects_2 = libbabl_@BABL_API_VERSION@_la-babl.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-cache.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-component.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-conversion.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-core.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-db.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-extension.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-fish-path.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-fish-reference.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-fish-simple.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-fish.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-format.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-hash-table.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-icc.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-image.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-internal.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-introspect.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-list.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-memory.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-model.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-mutex.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-palette.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-polynomial.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-ref-pixels.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-sampling.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-sanity.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-space.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-trc.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-type.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-util.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-cpuaccel.lo \
+ libbabl_@BABL_API_VERSION@_la-babl-version.lo
am_libbabl_@BABL_API_VERSION@_la_OBJECTS = $(am__objects_1) \
$(am__objects_2)
libbabl_@BABL_API_VERSION@_la_OBJECTS = \
@@ -155,7 +179,7 @@ am__v_lt_0 = --silent
am__v_lt_1 =
libbabl_@BABL_API_VERSION@_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
- $(AM_CFLAGS) $(CFLAGS) \
+ $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) \
$(libbabl_@BABL_API_VERSION@_la_LDFLAGS) $(LDFLAGS) -o $@
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
@@ -317,6 +341,7 @@ LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
+LOG_LIB = @LOG_LIB@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAINT = @MAINT@
@@ -412,7 +437,7 @@ target_vendor = @target_vendor@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-@PLATFORM_WIN32_TRUE@no_undefined = -no-undefined
+@PLATFORM_WIN32_TRUE@win32_no_undefined = -no-undefined
SUBDIRS = base
c_sources = \
babl.c \
@@ -428,6 +453,7 @@ c_sources = \
babl-fish.c \
babl-format.c \
babl-hash-table.c \
+ babl-icc.c \
babl-image.c \
babl-internal.c \
babl-introspect.c \
@@ -435,10 +461,13 @@ c_sources = \
babl-memory.c \
babl-model.c \
babl-mutex.c \
- babl-palette.c \
+ babl-palette.c \
+ babl-polynomial.c \
babl-ref-pixels.c \
babl-sampling.c \
babl-sanity.c \
+ babl-space.c \
+ babl-trc.c \
babl-type.c \
babl-util.c \
babl-cpuaccel.c \
@@ -464,18 +493,22 @@ h_sources = \
babl-macros.h \
babl-memory.h \
babl-model.h \
+ babl-matrix.h \
babl-mutex.h \
+ babl-polynomial.h \
babl-ref-pixels.h \
babl-sampling.h \
+ babl-space.h \
+ babl-trc.h \
babl-type.h \
babl-types.h \
babl-util.h
library_includedir = $(includedir)/babl-$(BABL_API_VERSION)/babl
libinc_hdrs = \
- babl-introspect.h \
- babl-macros.h \
- babl-types.h \
+ babl-introspect.h \
+ babl-macros.h \
+ babl-types.h \
babl.h
libinc_generated_hdrs = \
@@ -491,15 +524,21 @@ AM_CPPFLAGS = \
lib_LTLIBRARIES = libbabl-@BABL_API_VERSION@.la
libbabl_@BABL_API_VERSION@_la_SOURCES = $(h_sources) $(c_sources)
+libbabl_@BABL_API_VERSION@_la_CFLAGS = $(SSE2_EXTRA_CFLAGS)
libbabl_@BABL_API_VERSION@_la_LIBADD = \
- base/libbase.la \
+ base/libbase.la \
@LTLIBOBJS@
+libbabl_la_LDFLAGS = \
+ $(MATH_LIB) $(THREAD_LIB) $(LOG_LIB)
+
libbabl_@BABL_API_VERSION@_la_LDFLAGS = \
- ${no_undefined} $(MATH_LIB) $(THREAD_LIB) \
+ ${win32_no_undefined} \
+ $(MATH_LIB) $(THREAD_LIB) $(LOG_LIB) \
+ -export-symbols $(top_srcdir)/export-symbols \
-version-info $(BABL_LIBRARY_VERSION)
-EXTRA_DIST = babl-ref-pixels.inc
+EXTRA_DIST = babl-ref-pixels.inc
# If git is available, always check if git-version.h should be
# updated. If git is not available, don't do anything if git-version.h
@@ -590,34 +629,38 @@ distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/gettimeofday.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-cache.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-component.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-conversion.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-core.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-cpuaccel.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-db.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-extension.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-fish-path.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-fish-reference.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-fish-simple.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-fish.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-format.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-hash-table.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-image.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-internal.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-introspect.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-list.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-memory.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-model.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-mutex.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-palette.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-ref-pixels.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-sampling.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-sanity.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-type.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-util.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-version.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-cache.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-component.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-conversion.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-core.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-cpuaccel.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-db.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-extension.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-fish-path.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-fish-reference.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-fish-simple.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-fish.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-format.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-hash-table.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-icc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-image.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-internal.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-introspect.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-list.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-memory.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-model.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-mutex.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-palette.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-polynomial.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-ref-pixels.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-sampling.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-sanity.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-space.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-trc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-type.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-util.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-version.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl.Plo@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -640,6 +683,230 @@ distclean-compile:
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+libbabl_@BABL_API_VERSION@_la-babl.lo: babl.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl.lo `test -f 'babl.c' || echo '$(srcdir)/'`babl.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl.c' object='libbabl_@BABL_API_VERSION@_la-babl.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl.lo `test -f 'babl.c' || echo '$(srcdir)/'`babl.c
+
+libbabl_@BABL_API_VERSION@_la-babl-cache.lo: babl-cache.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-cache.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-cache.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-cache.lo `test -f 'babl-cache.c' || echo '$(srcdir)/'`babl-cache.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-cache.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-cache.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-cache.c' object='libbabl_@BABL_API_VERSION@_la-babl-cache.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-cache.lo `test -f 'babl-cache.c' || echo '$(srcdir)/'`babl-cache.c
+
+libbabl_@BABL_API_VERSION@_la-babl-component.lo: babl-component.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-component.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-component.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-component.lo `test -f 'babl-component.c' || echo '$(srcdir)/'`babl-component.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-component.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-component.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-component.c' object='libbabl_@BABL_API_VERSION@_la-babl-component.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-component.lo `test -f 'babl-component.c' || echo '$(srcdir)/'`babl-component.c
+
+libbabl_@BABL_API_VERSION@_la-babl-conversion.lo: babl-conversion.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-conversion.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-conversion.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-conversion.lo `test -f 'babl-conversion.c' || echo '$(srcdir)/'`babl-conversion.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-conversion.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-conversion.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-conversion.c' object='libbabl_@BABL_API_VERSION@_la-babl-conversion.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-conversion.lo `test -f 'babl-conversion.c' || echo '$(srcdir)/'`babl-conversion.c
+
+libbabl_@BABL_API_VERSION@_la-babl-core.lo: babl-core.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-core.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-core.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-core.lo `test -f 'babl-core.c' || echo '$(srcdir)/'`babl-core.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-core.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-core.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-core.c' object='libbabl_@BABL_API_VERSION@_la-babl-core.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-core.lo `test -f 'babl-core.c' || echo '$(srcdir)/'`babl-core.c
+
+libbabl_@BABL_API_VERSION@_la-babl-db.lo: babl-db.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-db.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-db.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-db.lo `test -f 'babl-db.c' || echo '$(srcdir)/'`babl-db.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-db.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-db.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-db.c' object='libbabl_@BABL_API_VERSION@_la-babl-db.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-db.lo `test -f 'babl-db.c' || echo '$(srcdir)/'`babl-db.c
+
+libbabl_@BABL_API_VERSION@_la-babl-extension.lo: babl-extension.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-extension.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-extension.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-extension.lo `test -f 'babl-extension.c' || echo '$(srcdir)/'`babl-extension.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-extension.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-extension.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-extension.c' object='libbabl_@BABL_API_VERSION@_la-babl-extension.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-extension.lo `test -f 'babl-extension.c' || echo '$(srcdir)/'`babl-extension.c
+
+libbabl_@BABL_API_VERSION@_la-babl-fish-path.lo: babl-fish-path.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-fish-path.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-fish-path.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-fish-path.lo `test -f 'babl-fish-path.c' || echo '$(srcdir)/'`babl-fish-path.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-fish-path.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-fish-path.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-fish-path.c' object='libbabl_@BABL_API_VERSION@_la-babl-fish-path.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-fish-path.lo `test -f 'babl-fish-path.c' || echo '$(srcdir)/'`babl-fish-path.c
+
+libbabl_@BABL_API_VERSION@_la-babl-fish-reference.lo: babl-fish-reference.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-fish-reference.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-fish-reference.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-fish-reference.lo `test -f 'babl-fish-reference.c' || echo '$(srcdir)/'`babl-fish-reference.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-fish-reference.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-fish-reference.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-fish-reference.c' object='libbabl_@BABL_API_VERSION@_la-babl-fish-reference.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-fish-reference.lo `test -f 'babl-fish-reference.c' || echo '$(srcdir)/'`babl-fish-reference.c
+
+libbabl_@BABL_API_VERSION@_la-babl-fish-simple.lo: babl-fish-simple.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-fish-simple.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-fish-simple.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-fish-simple.lo `test -f 'babl-fish-simple.c' || echo '$(srcdir)/'`babl-fish-simple.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-fish-simple.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-fish-simple.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-fish-simple.c' object='libbabl_@BABL_API_VERSION@_la-babl-fish-simple.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-fish-simple.lo `test -f 'babl-fish-simple.c' || echo '$(srcdir)/'`babl-fish-simple.c
+
+libbabl_@BABL_API_VERSION@_la-babl-fish.lo: babl-fish.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-fish.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-fish.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-fish.lo `test -f 'babl-fish.c' || echo '$(srcdir)/'`babl-fish.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-fish.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-fish.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-fish.c' object='libbabl_@BABL_API_VERSION@_la-babl-fish.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-fish.lo `test -f 'babl-fish.c' || echo '$(srcdir)/'`babl-fish.c
+
+libbabl_@BABL_API_VERSION@_la-babl-format.lo: babl-format.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-format.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-format.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-format.lo `test -f 'babl-format.c' || echo '$(srcdir)/'`babl-format.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-format.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-format.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-format.c' object='libbabl_@BABL_API_VERSION@_la-babl-format.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-format.lo `test -f 'babl-format.c' || echo '$(srcdir)/'`babl-format.c
+
+libbabl_@BABL_API_VERSION@_la-babl-hash-table.lo: babl-hash-table.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-hash-table.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-hash-table.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-hash-table.lo `test -f 'babl-hash-table.c' || echo '$(srcdir)/'`babl-hash-table.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-hash-table.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-hash-table.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-hash-table.c' object='libbabl_@BABL_API_VERSION@_la-babl-hash-table.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-hash-table.lo `test -f 'babl-hash-table.c' || echo '$(srcdir)/'`babl-hash-table.c
+
+libbabl_@BABL_API_VERSION@_la-babl-icc.lo: babl-icc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-icc.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-icc.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-icc.lo `test -f 'babl-icc.c' || echo '$(srcdir)/'`babl-icc.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-icc.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-icc.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-icc.c' object='libbabl_@BABL_API_VERSION@_la-babl-icc.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-icc.lo `test -f 'babl-icc.c' || echo '$(srcdir)/'`babl-icc.c
+
+libbabl_@BABL_API_VERSION@_la-babl-image.lo: babl-image.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-image.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-image.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-image.lo `test -f 'babl-image.c' || echo '$(srcdir)/'`babl-image.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-image.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-image.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-image.c' object='libbabl_@BABL_API_VERSION@_la-babl-image.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-image.lo `test -f 'babl-image.c' || echo '$(srcdir)/'`babl-image.c
+
+libbabl_@BABL_API_VERSION@_la-babl-internal.lo: babl-internal.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-internal.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-internal.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-internal.lo `test -f 'babl-internal.c' || echo '$(srcdir)/'`babl-internal.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-internal.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-internal.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-internal.c' object='libbabl_@BABL_API_VERSION@_la-babl-internal.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-internal.lo `test -f 'babl-internal.c' || echo '$(srcdir)/'`babl-internal.c
+
+libbabl_@BABL_API_VERSION@_la-babl-introspect.lo: babl-introspect.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-introspect.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-introspect.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-introspect.lo `test -f 'babl-introspect.c' || echo '$(srcdir)/'`babl-introspect.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-introspect.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-introspect.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-introspect.c' object='libbabl_@BABL_API_VERSION@_la-babl-introspect.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-introspect.lo `test -f 'babl-introspect.c' || echo '$(srcdir)/'`babl-introspect.c
+
+libbabl_@BABL_API_VERSION@_la-babl-list.lo: babl-list.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-list.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-list.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-list.lo `test -f 'babl-list.c' || echo '$(srcdir)/'`babl-list.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-list.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-list.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-list.c' object='libbabl_@BABL_API_VERSION@_la-babl-list.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-list.lo `test -f 'babl-list.c' || echo '$(srcdir)/'`babl-list.c
+
+libbabl_@BABL_API_VERSION@_la-babl-memory.lo: babl-memory.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-memory.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-memory.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-memory.lo `test -f 'babl-memory.c' || echo '$(srcdir)/'`babl-memory.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-memory.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-memory.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-memory.c' object='libbabl_@BABL_API_VERSION@_la-babl-memory.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-memory.lo `test -f 'babl-memory.c' || echo '$(srcdir)/'`babl-memory.c
+
+libbabl_@BABL_API_VERSION@_la-babl-model.lo: babl-model.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-model.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-model.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-model.lo `test -f 'babl-model.c' || echo '$(srcdir)/'`babl-model.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-model.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-model.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-model.c' object='libbabl_@BABL_API_VERSION@_la-babl-model.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-model.lo `test -f 'babl-model.c' || echo '$(srcdir)/'`babl-model.c
+
+libbabl_@BABL_API_VERSION@_la-babl-mutex.lo: babl-mutex.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-mutex.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-mutex.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-mutex.lo `test -f 'babl-mutex.c' || echo '$(srcdir)/'`babl-mutex.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-mutex.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-mutex.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-mutex.c' object='libbabl_@BABL_API_VERSION@_la-babl-mutex.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-mutex.lo `test -f 'babl-mutex.c' || echo '$(srcdir)/'`babl-mutex.c
+
+libbabl_@BABL_API_VERSION@_la-babl-palette.lo: babl-palette.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-palette.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-palette.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-palette.lo `test -f 'babl-palette.c' || echo '$(srcdir)/'`babl-palette.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-palette.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-palette.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-palette.c' object='libbabl_@BABL_API_VERSION@_la-babl-palette.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-palette.lo `test -f 'babl-palette.c' || echo '$(srcdir)/'`babl-palette.c
+
+libbabl_@BABL_API_VERSION@_la-babl-polynomial.lo: babl-polynomial.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-polynomial.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-polynomial.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-polynomial.lo `test -f 'babl-polynomial.c' || echo '$(srcdir)/'`babl-polynomial.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-polynomial.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-polynomial.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-polynomial.c' object='libbabl_@BABL_API_VERSION@_la-babl-polynomial.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-polynomial.lo `test -f 'babl-polynomial.c' || echo '$(srcdir)/'`babl-polynomial.c
+
+libbabl_@BABL_API_VERSION@_la-babl-ref-pixels.lo: babl-ref-pixels.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-ref-pixels.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-ref-pixels.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-ref-pixels.lo `test -f 'babl-ref-pixels.c' || echo '$(srcdir)/'`babl-ref-pixels.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-ref-pixels.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-ref-pixels.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-ref-pixels.c' object='libbabl_@BABL_API_VERSION@_la-babl-ref-pixels.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-ref-pixels.lo `test -f 'babl-ref-pixels.c' || echo '$(srcdir)/'`babl-ref-pixels.c
+
+libbabl_@BABL_API_VERSION@_la-babl-sampling.lo: babl-sampling.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-sampling.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-sampling.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-sampling.lo `test -f 'babl-sampling.c' || echo '$(srcdir)/'`babl-sampling.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-sampling.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-sampling.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-sampling.c' object='libbabl_@BABL_API_VERSION@_la-babl-sampling.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-sampling.lo `test -f 'babl-sampling.c' || echo '$(srcdir)/'`babl-sampling.c
+
+libbabl_@BABL_API_VERSION@_la-babl-sanity.lo: babl-sanity.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-sanity.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-sanity.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-sanity.lo `test -f 'babl-sanity.c' || echo '$(srcdir)/'`babl-sanity.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-sanity.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-sanity.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-sanity.c' object='libbabl_@BABL_API_VERSION@_la-babl-sanity.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-sanity.lo `test -f 'babl-sanity.c' || echo '$(srcdir)/'`babl-sanity.c
+
+libbabl_@BABL_API_VERSION@_la-babl-space.lo: babl-space.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-space.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-space.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-space.lo `test -f 'babl-space.c' || echo '$(srcdir)/'`babl-space.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-space.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-space.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-space.c' object='libbabl_@BABL_API_VERSION@_la-babl-space.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-space.lo `test -f 'babl-space.c' || echo '$(srcdir)/'`babl-space.c
+
+libbabl_@BABL_API_VERSION@_la-babl-trc.lo: babl-trc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-trc.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-trc.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-trc.lo `test -f 'babl-trc.c' || echo '$(srcdir)/'`babl-trc.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-trc.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-trc.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-trc.c' object='libbabl_@BABL_API_VERSION@_la-babl-trc.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-trc.lo `test -f 'babl-trc.c' || echo '$(srcdir)/'`babl-trc.c
+
+libbabl_@BABL_API_VERSION@_la-babl-type.lo: babl-type.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-type.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-type.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-type.lo `test -f 'babl-type.c' || echo '$(srcdir)/'`babl-type.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-type.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-type.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-type.c' object='libbabl_@BABL_API_VERSION@_la-babl-type.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-type.lo `test -f 'babl-type.c' || echo '$(srcdir)/'`babl-type.c
+
+libbabl_@BABL_API_VERSION@_la-babl-util.lo: babl-util.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-util.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-util.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-util.lo `test -f 'babl-util.c' || echo '$(srcdir)/'`babl-util.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-util.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-util.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-util.c' object='libbabl_@BABL_API_VERSION@_la-babl-util.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-util.lo `test -f 'babl-util.c' || echo '$(srcdir)/'`babl-util.c
+
+libbabl_@BABL_API_VERSION@_la-babl-cpuaccel.lo: babl-cpuaccel.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-cpuaccel.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-cpuaccel.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-cpuaccel.lo `test -f 'babl-cpuaccel.c' || echo '$(srcdir)/'`babl-cpuaccel.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-cpuaccel.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-cpuaccel.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-cpuaccel.c' object='libbabl_@BABL_API_VERSION@_la-babl-cpuaccel.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-cpuaccel.lo `test -f 'babl-cpuaccel.c' || echo '$(srcdir)/'`babl-cpuaccel.c
+
+libbabl_@BABL_API_VERSION@_la-babl-version.lo: babl-version.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -MT libbabl_@BABL_API_VERSION@_la-babl-version.lo -MD -MP -MF $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-version.Tpo -c -o libbabl_@BABL_API_VERSION@_la-babl-version.lo `test -f 'babl-version.c' || echo '$(srcdir)/'`babl-version.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-version.Tpo $(DEPDIR)/libbabl_@BABL_API_VERSION@_la-babl-version.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='babl-version.c' object='libbabl_@BABL_API_VERSION@_la-babl-version.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbabl_@BABL_API_VERSION@_la_CFLAGS) $(CFLAGS) -c -o libbabl_@BABL_API_VERSION@_la-babl-version.lo `test -f 'babl-version.c' || echo '$(srcdir)/'`babl-version.c
+
mostlyclean-libtool:
-rm -f *.lo
diff --git a/babl/babl-cache.c b/babl/babl-cache.c
index abd6f0a..fa3f387 100644
--- a/babl/babl-cache.c
+++ b/babl/babl-cache.c
@@ -195,45 +195,6 @@ void babl_store_db (void)
free (tmpp);
}
-static int
-babl_file_get_contents (const char *path,
- char **contents,
- long *length,
- void *error)
-{
- FILE *file;
- long size;
- char *buffer;
-
- file = fopen (path,"rb");
-
- if (!file)
- return -1;
-
- fseek (file, 0, SEEK_END);
- size = ftell (file);
- if (length) *length = size;
- rewind (file);
- buffer = malloc(size + 8);
-
- if (!buffer)
- {
- fclose(file);
- return -1;
- }
-
- size -= fread (buffer, 1, size, file);
- if (size)
- {
- fclose (file);
- free (buffer);
- return -1;
- }
- fclose (file);
- *contents = buffer;
- return 0;
-}
-
int
_babl_fish_path_destroy (void *data);
@@ -259,7 +220,7 @@ void babl_init_db (void)
if (getenv ("BABL_DEBUG_CONVERSIONS"))
return;
- babl_file_get_contents (path, &contents, &length, NULL);
+ _babl_file_get_contents (path, &contents, &length, NULL);
if (!contents)
return;
@@ -296,7 +257,7 @@ void babl_init_db (void)
}
break;
case '\t':
- if (strchr (token, '='))
+ if (to_format && strchr (token, '='))
{
char seps2[] = " ";
char *tokp2;
@@ -346,7 +307,7 @@ void babl_init_db (void)
token2 = strtok_r (NULL, seps2, &tokp2);
}
}
- else
+ else if (to_format)
{
Babl *conv = (void*)babl_db_find(babl_conversion_db(), &token[1]);
if (!conv)
@@ -361,14 +322,10 @@ void babl_init_db (void)
if (!from_format)
{
from_format = (void*)babl_db_find(babl_format_db(), token);
- if (!from_format)
- return;
}
else
{
to_format = (void*)babl_db_find(babl_format_db(), token);
- if (!to_format)
- return;
}
break;
}
diff --git a/babl/babl-classes.h b/babl/babl-classes.h
index fa25c4e..ea8d6b5 100644
--- a/babl/babl-classes.h
+++ b/babl/babl-classes.h
@@ -35,9 +35,11 @@ enum {
BABL_TYPE_INTEGER,
BABL_TYPE_FLOAT,
BABL_SAMPLING,
+ BABL_TRC,
BABL_COMPONENT,
BABL_MODEL,
BABL_FORMAT,
+ BABL_SPACE,
BABL_CONVERSION,
BABL_CONVERSION_LINEAR,
@@ -57,6 +59,8 @@ enum {
#include "babl-type.h"
#include "babl-sampling.h"
+#include "babl-trc.h"
+#include "babl-space.h"
#include "babl-component.h"
#include "babl-model.h"
#include "babl-format.h"
@@ -75,6 +79,8 @@ typedef union _Babl
BablInstance instance;
BablType type;
BablSampling sampling;
+ BablSpace space;
+ BablTRC trc;
BablComponent component;
BablModel model;
BablFormat format;
diff --git a/babl/babl-conversion.c b/babl/babl-conversion.c
index dbdce50..75e5c93 100644
--- a/babl/babl-conversion.c
+++ b/babl/babl-conversion.c
@@ -26,15 +26,23 @@
#include "babl-db.h"
#include "babl-ref-pixels.h"
-static Babl *
-conversion_new (const char *name,
- int id,
- Babl *source,
- Babl *destination,
- BablFuncLinear linear,
- BablFuncPlane plane,
- BablFuncPlanar planar,
- void *user_data)
+static int model_is_rgba (const Babl *model)
+{
+ const Babl *RGBA = babl_model_from_id (BABL_RGBA);
+ if (model == RGBA || model->model.model == RGBA)
+ return 1;
+ return 0;
+}
+
+Babl *
+_conversion_new (const char *name,
+ int id,
+ const Babl *source,
+ const Babl *destination,
+ BablFuncLinear linear,
+ BablFuncPlane plane,
+ BablFuncPlanar planar,
+ void *user_data)
{
Babl *babl = NULL;
@@ -112,19 +120,16 @@ conversion_new (const char *name,
{
const Babl *src_format = NULL;
const Babl *dst_format = NULL;
- if (BABL (babl->conversion.source) == babl_model_from_id (BABL_RGBA))
- {
- src_format = babl_format_from_id (BABL_RGBA_DOUBLE);
- dst_format = babl_format_with_model_as_type (
- BABL (babl->conversion.destination),
- babl_type_from_id (BABL_DOUBLE));
- }
- else if (BABL (babl->conversion.destination) == babl_model_from_id (BABL_RGBA))
+
+ if (model_is_rgba (BABL (babl->conversion.source)) ||
+ model_is_rgba (BABL (babl->conversion.destination)))
{
src_format = babl_format_with_model_as_type (
BABL (babl->conversion.source),
babl_type_from_id (BABL_DOUBLE));
- dst_format = babl_format_from_id (BABL_RGBA_DOUBLE);
+ dst_format = babl_format_with_model_as_type (
+ BABL (babl->conversion.destination),
+ babl_type_from_id (BABL_DOUBLE));
}
else
{
@@ -161,16 +166,40 @@ create_name (Babl *source, Babl *destination, int type)
}
else
{
- snprintf (buf, 512 - 1, "%s %s to %s",
+ snprintf (buf, 512 - 1, "%s %s to %s %i",
type == BABL_CONVERSION_LINEAR ? "" :
type == BABL_CONVERSION_PLANE ? "plane " :
type == BABL_CONVERSION_PLANAR ? "planar " : "Eeeek! ",
source->instance.name,
- destination->instance.name);
+ destination->instance.name,
+ collisions);
buf[511] = '\0';
}
return buf;
}
+const char *
+babl_conversion_create_name (Babl *source, Babl *destination, int type);
+
+const char *
+babl_conversion_create_name (Babl *source, Babl *destination, int type)
+{
+ Babl *babl;
+ char *name;
+ int id = 0;
+ collisions = 0;
+ name = create_name (source, destination, type);
+ babl = babl_db_exist (db, id, name);
+ while (babl)
+ {
+ /* we allow multiple conversions to be registered per extender, each
+ of them ending up with their own unique name
+ */
+ collisions++;
+ name = create_name (source, destination, type);
+ babl = babl_db_exist (db, id, name);
+ }
+ return name;
+}
const Babl *
babl_conversion_new (const void *first_arg,
@@ -267,21 +296,9 @@ babl_conversion_new (const void *first_arg,
type = BABL_CONVERSION_PLANAR;
}
- collisions = 0;
- name = create_name (source, destination, type);
-
- babl = babl_db_exist (db, id, name);
- while (babl)
- {
- /* we allow multiple conversions to be registered per extender, each
- of them ending up with their own unique name
- */
- collisions++;
- name = create_name (source, destination, type);
- babl = babl_db_exist (db, id, name);
- }
+ name = (void*) babl_conversion_create_name (source, destination, type);
- babl = conversion_new (name, id, source, destination, linear, plane, planar,
+ babl = _conversion_new (name, id, source, destination, linear, plane, planar,
user_data);
/* Since there is not an already registered instance by the required
@@ -294,16 +311,16 @@ babl_conversion_new (const void *first_arg,
return babl;
}
-static long
+static void
babl_conversion_linear_process (BablConversion *conversion,
const void *source,
void *destination,
long n)
{
- return conversion->function.linear (source, destination, n, conversion->data);
+ conversion->function.linear ((void*)conversion, source, destination, n, conversion->data);
}
-static long
+static void
babl_conversion_plane_process (BablConversion *conversion,
const void *source,
void *destination,
@@ -311,13 +328,13 @@ babl_conversion_plane_process (BablConversion *conversion,
int dst_pitch,
long n)
{
- return conversion->function.plane (source, destination,
- src_pitch, dst_pitch,
- n,
- conversion->data);
+ conversion->function.plane ((void*)conversion, source, destination,
+ src_pitch, dst_pitch,
+ n,
+ conversion->data);
}
-static long
+static void
babl_conversion_planar_process (BablConversion *conversion,
BablImage *source,
BablImage *destination,
@@ -333,8 +350,8 @@ babl_conversion_planar_process (BablConversion *conversion,
memcpy (src_data, source->data, sizeof (void *) * source->components);
memcpy (dst_data, destination->data, sizeof (void *) * destination->components);
-
- return conversion->function.planar (source->components,
+ conversion->function.planar ((void*)conversion,
+ source->components,
src_data,
source->pitch,
destination->components,
@@ -446,14 +463,8 @@ babl_conversion_error (BablConversion *conversion)
Babl *fmt_source;
Babl *fmt_destination;
- const Babl *fmt_rgba_double = babl_format_new (babl_model ("RGBA"),
- babl_type ("double"),
- babl_component ("R"),
- babl_component ("G"),
- babl_component ("B"),
- babl_component ("A"),
- NULL);
-
+ const Babl *fmt_rgba_double = babl_format_with_space ("RGBA double",
+ conversion->destination->format.space);
double error = 0.0;
long ticks_start = 0;
long ticks_end = 0;
@@ -499,7 +510,7 @@ babl_conversion_error (BablConversion *conversion)
fmt_source->class_type == BABL_FORMAT &&
fmt_destination->class_type == BABL_FORMAT))
{
- conversion->error = 0.000042;
+ conversion->error = 0.0000042;
}
source = babl_calloc (test_pixels, fmt_source->format.bytes_per_pixel);
@@ -548,4 +559,14 @@ babl_conversion_error (BablConversion *conversion)
return error;
}
+const Babl *babl_conversion_get_source_space (const Babl *conversion)
+{
+ return conversion->conversion.source->format.space;
+}
+
+const Babl *babl_conversion_get_destination_space (const Babl *conversion)
+{
+ return conversion->conversion.destination->format.space;
+}
+
BABL_CLASS_IMPLEMENT (conversion)
diff --git a/babl/babl-conversion.h b/babl/babl-conversion.h
index 902beb5..1f8f8ab 100644
--- a/babl/babl-conversion.h
+++ b/babl/babl-conversion.h
@@ -23,19 +23,22 @@ BABL_CLASS_DECLARE (conversion);
const Babl * babl_conversion (const char *name);
+typedef struct _BablConversion BablConversion;
+
+
/* Signature of functions registered for reference type
* conversions,
*/
-typedef long (*BablFuncPlane) (const char *src,
- char *dst,
- int src_pitch,
- int dst_pitch,
- long n,
- void *user_data);
-
+typedef void (*BablFuncPlane) (BablConversion *conversion,
+ const char *src,
+ char *dst,
+ int src_pitch,
+ int dst_pitch,
+ long n,
+ void *user_data);
-typedef struct
-BablConversion {
+struct
+_BablConversion {
BablInstance instance;
const Babl *source;
const Babl *destination;
@@ -50,6 +53,6 @@ BablConversion {
void *data; /* user data */
int processings;
long pixels;
-} BablConversion;
+};
#endif
diff --git a/babl/babl-core.c b/babl/babl-core.c
index 00e43e8..d591d73 100644
--- a/babl/babl-core.c
+++ b/babl/babl-core.c
@@ -22,11 +22,12 @@
#include "util.h"
static long
-convert_double_double (char *src,
- char *dst,
- int src_pitch,
- int dst_pitch,
- long n)
+convert_double_double (const Babl *babl,
+ char *src,
+ char *dst,
+ int src_pitch,
+ int dst_pitch,
+ long n)
{
if (src_pitch == 64 &&
dst_pitch == 64)
@@ -77,9 +78,10 @@ convert_double_double (char *src,
*/
static long
-rgba_to_rgba (char *src,
- char *dst,
- long n)
+rgba_to_rgba (const Babl *babl,
+ char *src,
+ char *dst,
+ long n)
{
memcpy (dst, src, n * sizeof (double) * 4);
return n;
diff --git a/babl/babl-extension.c b/babl/babl-extension.c
index 8edb60d..8e85be5 100644
--- a/babl/babl-extension.c
+++ b/babl/babl-extension.c
@@ -348,11 +348,10 @@ babl_extension_load_dir_list (const char *dir_list)
babl_free (path);
if (babl_db_count (db) <= 1)
{
- fprintf (stderr,
-"WARNING: the babl installation seems broken, no extensions found in queried\n"
-"BABL_PATH (%s) this means no SIMD/instructions/special case fast paths and\n"
-"only slow reference conversions are available, applications might still\n"
-"run but software relying on babl for conversions will be slow\n", dir_list);
+ babl_log ("WARNING: the babl installation seems broken, no extensions found in queried\n"
+ "BABL_PATH (%s) this means no SIMD/instructions/special case fast paths and\n"
+ "only slow reference conversions are available, applications might still\n"
+ "run but software relying on babl for conversions will be slow\n", dir_list);
}
}
diff --git a/babl/babl-fish-path.c b/babl/babl-fish-path.c
index 77671ff..6a1e194 100644
--- a/babl/babl-fish-path.c
+++ b/babl/babl-fish-path.c
@@ -21,7 +21,7 @@
#include "babl-internal.h"
#include "babl-ref-pixels.h"
-#define BABL_TOLERANCE 0.000001
+#define BABL_TOLERANCE 0.000005
#define BABL_MAX_COST_VALUE 2000000
#define BABL_HARD_MAX_PATH_LENGTH 8
#define BABL_MAX_NAME_LEN 1024
@@ -31,7 +31,7 @@
#endif
#define NUM_TEST_PIXELS (babl_get_num_path_test_pixels ())
-#define MAX_BUFFER_SIZE 2048 /* XXX: reasonable size for this should be profiled */
+#define MAX_BUFFER_SIZE 512
int babl_in_fish_path = 0;
@@ -84,9 +84,10 @@ process_conversion_path (BablList *path,
static void
get_conversion_path (PathContext *pc,
- Babl *current_format,
- int current_length,
- int max_length);
+ Babl *current_format,
+ int current_length,
+ int max_length,
+ double legal_error);
char *
_babl_fish_create_name (char *buf,
@@ -134,7 +135,7 @@ static int max_path_length (void)
if (env)
max_length = atoi (env);
else
- max_length = 3; /* reducing this number makes finding short fishes much
+ max_length = 4; /* reducing this number makes finding short fishes much
faster - even if we lose out on some of the fast
bigger fish
*/
@@ -150,6 +151,32 @@ int _babl_max_path_len (void)
return max_path_length ();
}
+static int
+bad_idea (const Babl *from, const Babl *to, const Babl *format)
+{
+ if (babl_format_has_alpha (from) &&
+ babl_format_has_alpha (to) &&
+ !babl_format_has_alpha (format))
+ {
+ return 1;
+ }
+ if (from->format.components > format->format.components &&
+ to->format.components > format->format.components)
+ {
+ return 1;
+ }
+ if (from->format.type[0]->bits > format->format.type[0]->bits &&
+ to->format.type[0]->bits > format->format.type[0]->bits)
+ {
+ /* XXX: perhaps we especially avoid going to half-float, when
+ * going between u16 formats as well? */
+ return 1;
+ }
+
+ return 0;
+}
+
+
/* The task of BablFishPath construction is to compute
* the shortest path in a graph where formats are the vertices
* and conversions are the edges. However, there is an additional
@@ -163,12 +190,12 @@ int _babl_max_path_len (void)
* implemented by recursive function get_conversion_path ().
*/
-
static void
get_conversion_path (PathContext *pc,
Babl *current_format,
int current_length,
- int max_length)
+ int max_length,
+ double legal_error)
{
if (current_length > max_length)
{
@@ -183,16 +210,17 @@ get_conversion_path (PathContext *pc,
double path_cost = 0.0;
double ref_cost = 0.0;
double path_error = 1.0;
+#if 0
int i;
-
for (i = 0; i < babl_list_size (pc->current_path); i++)
{
path_error *= (1.0 + babl_conversion_error ((BablConversion *) pc->current_path->items[i]));
}
- if (path_error - 1.0 <= _babl_legal_error ())
+ if (path_error - 1.0 <= legal_error )
/* check this before the more accurate measurement of error -
to bail earlier */
+#endif
{
FishPathInstrumentation fpi;
memset (&fpi, 0, sizeof (fpi));
@@ -202,16 +230,13 @@ get_conversion_path (PathContext *pc,
get_path_instrumentation (&fpi, pc->current_path, &path_cost, &ref_cost, &path_error);
if(debug_conversions && current_length == 1)
- fprintf (stderr, "%s error:%f cost:%f \n",
- babl_get_name (pc->current_path->items[0]),
- /*babl_get_name (pc->fish_path->fish.source),
- babl_get_name (pc->fish_path->fish.destination),*/
- path_error,
- path_cost /*, current_length*/);
+ fprintf (stderr, "%s error:%f cost:%f \n",
+ babl_get_name (pc->current_path->items[0]), path_error, path_cost);
if ((path_cost < ref_cost) && /* do not use paths that took longer to compute than reference */
- (path_cost < pc->fish_path->fish_path.cost) &&
- (path_error <= _babl_legal_error ()))
+ (path_cost < pc->fish_path->fish_path.cost) && // best thus far
+ (path_error <= legal_error ) // within tolerance
+ )
{
/* We have found the best path so far,
* let's copy it into our new fish */
@@ -227,7 +252,7 @@ get_conversion_path (PathContext *pc,
else
{
/*
- * Bummer, we have to search deeper...
+ * we have to search deeper...
*/
BablList *list;
int i;
@@ -243,11 +268,11 @@ get_conversion_path (PathContext *pc,
{
Babl *next_conversion = BABL (list->items[i]);
Babl *next_format = BABL (next_conversion->conversion.destination);
- if (!next_format->format.visited)
+ if (!next_format->format.visited && !bad_idea (current_format, pc->to_format, next_format))
{
/* next_format is not in the current path, we can pay a visit */
babl_list_insert_last (pc->current_path, next_conversion);
- get_conversion_path (pc, next_format, current_length + 1, max_length);
+ get_conversion_path (pc, next_format, current_length + 1, max_length, legal_error);
babl_list_remove_last (pc->current_path);
}
}
@@ -265,8 +290,8 @@ _babl_fish_create_name (char *buf,
int is_reference)
{
/* fish names are intentionally kept short */
- snprintf (buf, BABL_MAX_NAME_LEN, "%s %p %p", "",
- source, destination);
+ snprintf (buf, BABL_MAX_NAME_LEN, "%s %p %p %i", "",
+ source, destination, is_reference);
return buf;
}
@@ -283,16 +308,146 @@ _babl_fish_path_destroy (void *data)
return 0;
}
-Babl *
-babl_fish_path (const Babl *source,
- const Babl *destination)
+static int
+show_item (Babl *babl,
+ void *user_data)
+{
+ BablConversion *conv = (void *)babl;
+
+ if (conv->destination->class_type == BABL_FORMAT)
+ {
+ fprintf (stderr, "%s : %.12f\n", babl_get_name (babl), babl_conversion_error(conv));
+ }
+
+ return 0;
+}
+
+static int
+alias_conversion (Babl *babl,
+ void *user_data)
+{
+ BablConversion *conv = (void *)babl;
+ BablSpace *space = user_data;
+
+ if ((conv->source->class_type == BABL_FORMAT) &&
+ (conv->destination->class_type == BABL_FORMAT) &&
+ (!babl_format_is_palette (conv->source)) &&
+ (!babl_format_is_palette (conv->destination)))
+ {
+ if ((conv->source->format.space == (void*)babl_space ("sRGB")) &&
+ (conv->destination->format.space == babl_space ("sRGB")))
+ {
+ switch (conv->instance.class_type)
+ {
+ case BABL_CONVERSION_LINEAR:
+ babl_conversion_new (
+ babl_format_with_space (
+ (void*)conv->source->instance.name, (void*)space),
+ babl_format_with_space (
+ (void*)conv->destination->instance.name, (void*)space),
+ "linear", conv->function.linear,
+ "data", conv->data,
+ NULL);
+ break;
+ case BABL_CONVERSION_PLANAR:
+ babl_conversion_new (
+ babl_format_with_space (
+ (void*)conv->source->instance.name, (void*)space),
+ babl_format_with_space (
+ (void*)conv->destination->instance.name, (void*)space),
+ "planar", conv->function.planar,
+ "data", conv->data,
+ NULL);
+ break;
+ case BABL_CONVERSION_PLANE:
+ babl_conversion_new (
+ babl_format_with_space (
+ (void*)conv->source->instance.name, (void*)space),
+ babl_format_with_space (
+ (void*)conv->destination->instance.name, (void*)space),
+ "plane", conv->function.plane,
+ "data", conv->data,
+ NULL);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ else
+ if ((conv->source->class_type == BABL_MODEL) &&
+ (conv->destination->class_type == BABL_MODEL))
+ {
+ if ((conv->source->model.space == (void*)babl_space ("sRGB")) &&
+ (conv->destination->model.space == babl_space ("sRGB")))
+ {
+ switch (conv->instance.class_type)
+ {
+ case BABL_CONVERSION_LINEAR:
+ babl_conversion_new (
+ babl_remodel_with_space (
+ (void*)conv->source, (void*)space),
+ babl_remodel_with_space (
+ (void*)conv->destination, (void*)space),
+ "linear", conv->function,
+ NULL);
+ break;
+ case BABL_CONVERSION_PLANAR:
+ babl_conversion_new (
+ babl_remodel_with_space (
+ (void*)conv->source, (void*)space),
+ babl_remodel_with_space (
+ (void*)conv->destination, (void*)space),
+ "planar", conv->function,
+ NULL);
+ break;
+ case BABL_CONVERSION_PLANE:
+ babl_conversion_new (
+ babl_remodel_with_space (
+ (void*)conv->source, (void*)space),
+ babl_remodel_with_space (
+ (void*)conv->destination, (void*)space),
+ "plane", conv->function,
+ NULL);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ else
+ if ((conv->source->class_type == BABL_TYPE) &&
+ (conv->destination->class_type == BABL_TYPE))
+ {
+ }
+ return 0;
+}
+
+
+static Babl *
+babl_fish_path2 (const Babl *source,
+ const Babl *destination,
+ double tolerance)
{
Babl *babl = NULL;
+ const Babl *sRGB = babl_space ("sRGB");
char name[BABL_MAX_NAME_LEN];
+ int is_fast = 0;
_babl_fish_create_name (name, source, destination, 1);
babl_mutex_lock (babl_format_mutex);
babl = babl_db_exist_by_name (babl_fish_db (), name);
+
+ if (tolerance <= 0.0)
+ {
+ is_fast = 0;
+ tolerance = _babl_legal_error ();
+ }
+ else
+ is_fast = 1;
+
+ if (!is_fast)
+ {
if (babl)
{
/* There is an instance already registered by the required name,
@@ -301,6 +456,43 @@ babl_fish_path (const Babl *source,
babl_mutex_unlock (babl_format_mutex);
return babl;
}
+ }
+
+ if ((source->format.space != sRGB) ||
+ (destination->format.space != sRGB))
+ {
+ static const Babl *run_once[512]={NULL};
+ int i;
+ int done = 0;
+ for (i = 0; run_once[i]; i++)
+ {
+ if (run_once[i] == source->format.space)
+ done |= 1;
+ else if (run_once[i] == destination->format.space)
+ done |= 2;
+ }
+
+ if ((done & 1) == 0 && (source->format.space != sRGB))
+ {
+ run_once[i++] = source->format.space;
+ babl_conversion_class_for_each (alias_conversion, (void*)source->format.space);
+
+ _babl_space_add_universal_rgb (source->format.space);
+ }
+ if ((done & 2) == 0 && (destination->format.space != source->format.space) && (destination->format.space != sRGB))
+ {
+ run_once[i++] = destination->format.space;
+ babl_conversion_class_for_each (alias_conversion, (void*)destination->format.space);
+
+ _babl_space_add_universal_rgb (destination->format.space);
+ }
+
+ if (!done && 0)
+ {
+ babl_conversion_class_for_each (show_item, (void*)source->format.space);
+ }
+
+ }
babl = babl_calloc (1, sizeof (BablFishPath) +
strlen (name) + 1);
@@ -331,12 +523,12 @@ babl_fish_path (const Babl *source,
*/
babl_in_fish_path++;
- get_conversion_path (&pc, (Babl *) source, 0, max_path_length ());
+ get_conversion_path (&pc, (Babl *) source, 0, max_path_length (), tolerance);
/* second attempt,. at path length + 1*/
if (babl->fish_path.conversion_list->count == 0 &&
max_path_length () + 1 <= BABL_HARD_MAX_PATH_LENGTH)
- get_conversion_path (&pc, (Babl *) source, 0, max_path_length () + 1);
+ get_conversion_path (&pc, (Babl *) source, 0, max_path_length () + 1, tolerance);
babl_in_fish_path--;
babl_free (pc.current_path);
@@ -364,7 +556,7 @@ babl_fish_path (const Babl *source,
"programmatically by babl based on format description\n"
"\n");
- fprintf (stderr, "*WARNING*: missing babl fast path(s) between formats \"%s\" and \"%s\"\n",
+ fprintf (stderr, "*WARNING* missing babl fast path(s): \"%s\" to \"%s\"\n",
babl_get_name (source),
babl_get_name (destination));
@@ -375,11 +567,45 @@ babl_fish_path (const Babl *source,
/* Since there is not an already registered instance by the required
* name, inserting newly created class into database.
*/
- babl_db_insert (babl_fish_db (), babl);
+ if (!is_fast)
+ {
+ babl_db_insert (babl_fish_db (), babl);
+ }
babl_mutex_unlock (babl_format_mutex);
return babl;
}
+const Babl * babl_fast_fish (const void *source_format,
+ const void *destination_format,
+ const char *performance)
+{
+ double tolerance = 0.0;
+
+ if (!performance || !strcmp (performance, "default"))
+ tolerance = 0.0; // note: not _babl_legal_error() to trigger,
+ // right code paths in babl_fish_path2
+ else if (!strcmp (performance, "exact"))
+ tolerance=0.0000000001;
+ else if (!strcmp (performance, "precise"))
+ tolerance=0.00001;
+ if (!strcmp (performance, "fast"))
+ tolerance=0.001;
+ else if (!strcmp (performance, "glitch"))
+ tolerance=0.01;
+ else {
+ tolerance = babl_parse_double (performance);
+ }
+
+ return babl_fish_path2 (source_format, destination_format, tolerance);
+}
+
+Babl *
+babl_fish_path (const Babl *source,
+ const Babl *destination)
+{
+ return babl_fish_path2 (source, destination, 0.0);
+}
+
static long
babl_fish_path_process (Babl *babl,
const void *source,
@@ -543,9 +769,6 @@ process_conversion_path (BablList *path,
temp_buffer2 = align_16 (alloca (MIN(n, MAX_BUFFER_SIZE) * sizeof (double) * 5 + 16));
}
-
-
-
for (j = 0; j < n; j+= MAX_BUFFER_SIZE)
{
long c = MIN (n - j, MAX_BUFFER_SIZE);
@@ -600,14 +823,8 @@ init_path_instrumentation (FishPathInstrumentation *fpi,
if (!fpi->fmt_rgba_double)
{
- fpi->fmt_rgba_double = babl_format_new (
- babl_model ("RGBA"),
- babl_type ("double"),
- babl_component ("R"),
- babl_component ("G"),
- babl_component ("B"),
- babl_component ("A"),
- NULL);
+ fpi->fmt_rgba_double = babl_format_with_space ("RGBA double",
+ fmt_destination->format.space);
}
fpi->num_test_pixels = babl_get_num_path_test_pixels ();
@@ -727,15 +944,5 @@ get_path_instrumentation (FishPathInstrumentation *fpi,
fpi->ref_destination_rgba_double,
fpi->num_test_pixels * 4);
-#if 0
- fpi->fish_rgba_to_source->fish.processings--;
- fpi->fish_reference->fish.processings--;
- fpi->fish_destination_to_rgba->fish.processings -= 2;
-
- fpi->fish_rgba_to_source->fish.pixels -= fpi->num_test_pixels;
- fpi->fish_reference->fish.pixels -= fpi->num_test_pixels;
- fpi->fish_destination_to_rgba->fish.pixels -= 2 * fpi->num_test_pixels;
-#endif
-
*ref_cost = fpi->reference_cost;
}
diff --git a/babl/babl-fish-reference.c b/babl/babl-fish-reference.c
index 00ff6be..d97cca3 100644
--- a/babl/babl-fish-reference.c
+++ b/babl/babl-fish-reference.c
@@ -26,7 +26,8 @@ assert_conversion_find (const void *source,
Babl *ret = babl_conversion_find (source, destination);
if (!ret)
- babl_fatal ("failed, aborting");
+ babl_fatal ("failed finding conversion between %s and %s aborting",
+ babl_get_name (source), babl_get_name (destination));
return ret;
}
@@ -176,6 +177,7 @@ convert_to_double (BablFormat *source_fmt,
src_img->pitch[0] = source_fmt->bytes_per_pixel;
src_img->stride[0] = 0;
+ {
/* i is source position */
for (i = 0; i < source_fmt->components; i++)
{
@@ -200,6 +202,7 @@ convert_to_double (BablFormat *source_fmt,
src_img->data[0] += src_img->type[0]->bits / 8;
}
+ }
babl_free (src_img);
babl_free (dst_img);
}
@@ -366,7 +369,6 @@ process_to_n_component (const Babl *babl,
return 0;
}
-
static int
process_same_model (const Babl *babl,
const char *source,
@@ -433,17 +435,17 @@ babl_fish_reference_process (const Babl *babl,
Babl *rgba_image;
Babl *destination_image;
-
- if (BABL (babl->fish.source)->format.model ==
- BABL (babl->fish.destination)->format.model)
+ if ((BABL (babl->fish.source)->format.model ==
+ BABL (babl->fish.destination)->format.model) &&
+ (BABL (babl->fish.source)->format.space ==
+ BABL (babl->fish.destination)->format.space)
+ )
return process_same_model (babl, source, destination, n);
if (babl_format_is_format_n (BABL (babl->fish.destination)))
{
return process_to_n_component (babl, source, destination, n);
}
-
-
source_double_buf = babl_malloc (sizeof (double) * n *
BABL (babl->fish.source)->format.model->components);
@@ -454,7 +456,8 @@ babl_fish_reference_process (const Babl *babl,
source_image = babl_image_from_linear (
source_double_buf, BABL (BABL ((babl->fish.source))->format.model));
rgba_image = babl_image_from_linear (
- rgba_double_buf, babl_model_from_id (BABL_RGBA));
+ rgba_double_buf, babl_remodel_with_space (babl_model_from_id (BABL_RGBA),
+ BABL (BABL ((babl->fish.source))->format.space)) );
destination_image = babl_image_from_linear (
destination_double_buf, BABL (BABL ((babl->fish.destination))->format.model));
@@ -469,7 +472,8 @@ babl_fish_reference_process (const Babl *babl,
Babl *conv =
assert_conversion_find (
BABL (babl->fish.source)->format.model,
- babl_model_from_id (BABL_RGBA)
+ babl_remodel_with_space (babl_model_from_id (BABL_RGBA),
+ BABL (BABL ((babl->fish.source))->format.space))
);
if (conv->class_type == BABL_CONVERSION_PLANAR)
{
@@ -488,10 +492,24 @@ babl_fish_reference_process (const Babl *babl,
else babl_fatal ("oops");
}
+ if (((babl->fish.source)->format.space !=
+ ((babl->fish.destination)->format.space)))
+ {
+ double matrix[9];
+ double *rgba = rgba_double_buf;
+ babl_matrix_mul_matrix (
+ (babl->fish.destination)->format.space->space.XYZtoRGB,
+ (babl->fish.source)->format.space->space.RGBtoXYZ,
+ matrix);
+
+ babl_matrix_mul_vector_buf4 (matrix, rgba, rgba, n);
+ }
+
{
Babl *conv =
assert_conversion_find (
- babl_model_from_id (BABL_RGBA),
+ babl_remodel_with_space (babl_model_from_id (BABL_RGBA),
+ BABL (BABL ((babl->fish.destination))->format.space)),
BABL (babl->fish.destination)->format.model);
if (conv->class_type == BABL_CONVERSION_PLANAR)
{
@@ -526,4 +544,3 @@ babl_fish_reference_process (const Babl *babl,
babl_free (source_double_buf);
return n;
}
-
diff --git a/babl/babl-fish.c b/babl/babl-fish.c
index 96c69c3..749b075 100644
--- a/babl/babl-fish.c
+++ b/babl/babl-fish.c
@@ -112,16 +112,54 @@ match_conversion (Babl *conversion,
return 0;
}
+
+
Babl *
babl_conversion_find (const void *source,
const void *destination)
{
void *data = (void*)destination;
-
babl_list_each (BABL (source)->type.from_list, match_conversion, &data);
- if (data == (void*)destination) /* didn't change */
- return NULL;
- return data;
+ if (data != (void*)destination) /* didn't change */
+ return data;
+ data = NULL;
+
+ if (BABL (source)->class_type == BABL_MODEL)
+ {
+ const Babl *srgb_source = BABL (source)->model.model ? BABL (source)->model.model:source;
+ const Babl *srgb_destination = BABL (destination)->model.model ? BABL (destination)->model.model:destination;
+ Babl *reference = babl_conversion_find (srgb_source, srgb_destination);
+
+ /* when conversions are sought between models, with non-sRGB chromaticities,
+ we create the needed conversions from existing ones on the fly, and
+ register them. The conversions registered by the models should pick up the
+ RGB chromaticities, and TRC to use from the space on the model instead of
+ hard-coding it.
+ */
+
+ switch (reference->instance.class_type)
+ {
+ case BABL_CONVERSION_LINEAR:
+ return _conversion_new ("", 0, (void*)source, (void*)destination,
+ reference->conversion.function.linear,
+ NULL,
+ NULL,
+ reference->conversion.data);
+ case BABL_CONVERSION_PLANE:
+ return _conversion_new ("", 0, source, destination,
+ NULL,
+ reference->conversion.function.plane,
+ NULL,
+ reference->conversion.data);
+ case BABL_CONVERSION_PLANAR:
+ return _conversion_new ("", 0, source, destination,
+ NULL,
+ NULL,
+ reference->conversion.function.planar,
+ reference->conversion.data);
+ }
+ }
+ return NULL;
}
int
@@ -131,9 +169,9 @@ babl_fish_get_id (const Babl *source,
/* value of 'id' will be used as argument for hash function,
* substraction serves as simple combination of
* source/destination values. */
- ptrdiff_t id = source - destination;
+ int id = (((size_t)source * 93)) ^ ((size_t)destination);
/* instances with id 0 won't be inserted into database */
- id *= ((((size_t) (source))) % 37);
+ id *= ((((size_t) (destination))) % 37);
if (id == 0)
id = 1;
@@ -216,12 +254,12 @@ babl_fish (const void *source,
* path.
*/
babl_hash_table_find (id_htable, hashval, find_fish_path, (void *) &ffish);
-
if (ffish.fish_path)
{
/* we have found suitable fish path in the database */
return ffish.fish_path;
}
+
if (!ffish.fish_fish)
{
/* we haven't tried to search for suitable path yet */
@@ -231,6 +269,7 @@ babl_fish (const void *source,
{
return fish_path;
}
+#if 1
else
{
/* there isn't a suitable path for requested formats,
@@ -249,6 +288,7 @@ babl_fish (const void *source,
fish->fish.destination = destination_format;
babl_db_insert (babl_fish_db (), fish);
}
+#endif
}
}
diff --git a/babl/babl-format.c b/babl/babl-format.c
index 60a916e..4ed14d0 100644
--- a/babl/babl-format.c
+++ b/babl/babl-format.c
@@ -26,6 +26,7 @@
#include "babl-db.h"
#include "babl-ref-pixels.h"
+
static int babl_format_destruct (void *babl)
{
BablFormat *format = babl;
@@ -42,11 +43,12 @@ static int babl_format_destruct (void *babl)
}
static Babl *
-format_new (const char *name,
- int id,
- int planar,
- int components,
- BablModel *model,
+format_new (const char *name,
+ int id,
+ int planar,
+ int components,
+ BablModel *model,
+ const Babl *space,
BablComponent **component,
BablSampling **sampling,
const BablType **type)
@@ -83,6 +85,7 @@ format_new (const char *name,
sizeof (BablType *) * (components) +
sizeof (int) * (components) +
sizeof (int) * (components));
+
babl_set_destructor (babl, babl_format_destruct);
babl->format.from_list = NULL;
@@ -96,9 +99,13 @@ format_new (const char *name,
strcpy (babl->instance.name, name);
- babl->format.model = model;
babl->format.components = components;
+ if (space == babl_space ("sRGB"))
+ babl->format.model = model;
+ else
+ babl->format.model = (void*)babl_remodel_with_space ((void*)model, space);
+
memcpy (babl->format.component, component, sizeof (BablComponent *) * components);
memcpy (babl->format.type, type, sizeof (BablType *) * components);
memcpy (babl->format.sampling, sampling, sizeof (BablSampling *) * components);
@@ -118,9 +125,33 @@ format_new (const char *name,
babl->format.format_n = 0;
babl->format.palette = 0;
+ babl->format.space = (void*)space;
+
return babl;
}
+Babl *
+format_new_from_format_with_space (const Babl *format, const Babl *space)
+{
+ Babl *ret;
+ char new_name[256];
+ sprintf (new_name, "%s-%s", babl_get_name ((void*)format),
+ babl_get_name ((void*)space));
+ ret = babl_db_find (babl_format_db(), new_name);
+ if (ret)
+ return ret;
+
+ ret = format_new (new_name,
+ 0,
+ format->format.planar, format->format.components,
+ (void*)babl_remodel_with_space (BABL(format->format.model), space),
+ space,
+ format->format.component, format->format.sampling, (void*)format->format.type);
+
+
+ return ret;
+}
+
static char *
create_name (const BablModel *model,
@@ -190,7 +221,6 @@ create_name (const BablModel *model,
return babl_strdup (buf);
}
-
static char *
ncomponents_create_name (const Babl *type,
int components)
@@ -244,6 +274,7 @@ babl_format_n (const Babl *btype,
babl = format_new (name,
id,
planar, components, model,
+ babl_space("sRGB"),
component, sampling, type);
babl_format_set_is_format_n (babl);
@@ -264,12 +295,12 @@ babl_format_is_format_n (const Babl *format)
return 0;
}
-
static int
is_format_duplicate (Babl *babl,
int planar,
int components,
BablModel *model,
+ const Babl *space,
BablComponent **component,
BablSampling **sampling,
const BablType **type)
@@ -278,7 +309,8 @@ is_format_duplicate (Babl *babl,
if (babl->format.planar != planar ||
babl->format.components != components ||
- babl->format.model != model)
+ babl->format.model != model ||
+ babl->format.space != (void*)space)
return 0;
for (i = 0; i < components; i++)
@@ -301,6 +333,7 @@ babl_format_new (const void *first_arg,
int planar = 0;
int components = 0;
BablModel *model = NULL;
+ const Babl * space = babl_space ("sRGB");
BablComponent *component [BABL_MAX_COMPONENTS];
BablSampling *sampling [BABL_MAX_COMPONENTS];
const BablType*type [BABL_MAX_COMPONENTS];
@@ -370,6 +403,10 @@ babl_format_new (const void *first_arg,
current_sampling = (BablSampling *) arg;
break;
+ case BABL_SPACE:
+ space = (Babl*) arg;
+ break;
+
case BABL_MODEL:
if (model)
{
@@ -415,6 +452,15 @@ babl_format_new (const void *first_arg,
if (!name)
name = create_name (model, components, component, type);
+ if (space != babl_space ("sRGB"))
+ {
+ char *new_name = babl_malloc (strlen (name) +
+ strlen (babl_get_name ((Babl*)space)) + 1);
+ sprintf (new_name, "%s-%s", name, babl_get_name ((Babl*)space));
+ babl_free (name);
+ name = new_name;
+ }
+
if (!model)
{
babl_log ("no model specified for format '%s'", name);
@@ -438,7 +484,7 @@ babl_format_new (const void *first_arg,
/* There is an instance already registered by the required id/name,
* returning the preexistent one instead if it doesn't differ.
*/
- if (!is_format_duplicate (babl, planar, components, model,
+ if(0)if (!is_format_duplicate (babl, planar, components, model, space,
component, sampling, type))
babl_fatal ("BablFormat '%s' already registered "
"with different content!", name);
@@ -447,9 +493,9 @@ babl_format_new (const void *first_arg,
return babl;
}
- babl = format_new (name,
+ babl = format_new ((void*)name,
id,
- planar, components, model,
+ planar, components, model, space,
component, sampling, type);
babl_db_insert (db, babl);
@@ -649,6 +695,51 @@ babl_format_get_model (const Babl *format)
return NULL;
}
+const Babl * babl_format_get_space (const Babl *format)
+{
+ if (format->class_type == BABL_FORMAT)
+ {
+ return (Babl*)format->format.space;
+ }
+ return NULL;
+}
+
BABL_CLASS_IMPLEMENT (format)
+const Babl *
+babl_format_with_space (const char *name, const Babl *space)
+{
+ const Babl *ret = NULL;
+
+ if (!space) space = babl_space ("sRGB");
+ if (space->class_type == BABL_FORMAT)
+ {
+ space = space->format.space;
+ }
+ else if (space->class_type == BABL_MODEL)
+ {
+ space = space->model.space;
+ }
+ else if (space->class_type != BABL_SPACE)
+ {
+ return NULL;
+ }
+ if (space == babl_space("sRGB"))
+ return babl_format (name);
+
+ {
+ char *new_name = babl_malloc (strlen (name) +
+ strlen (babl_get_name ((Babl*)space)) + 2);
+ sprintf (new_name, "%s-%s", name, babl_get_name ((Babl*)space));
+
+ ret = babl_db_exist_by_name (db, new_name);
+ if (ret)
+ return ret;
+
+ ret = format_new_from_format_with_space (babl_format (name), space);
+ babl_db_insert (db, (void*)ret);
+ }
+ return ret;
+}
+
diff --git a/babl/babl-format.h b/babl/babl-format.h
index bc78f42..333b5ba 100644
--- a/babl/babl-format.h
+++ b/babl/babl-format.h
@@ -29,6 +29,7 @@ typedef struct
BablComponent **component;
BablType **type;
void *model_data;
+ const Babl *space;
void *image_template; /* image template for use with
linear (non-planer) images */
diff --git a/babl/babl-icc.c b/babl/babl-icc.c
new file mode 100644
index 0000000..45ba8fa
--- /dev/null
+++ b/babl/babl-icc.c
@@ -0,0 +1,1124 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2017, Øyvind Kolås.
+ *
+ * 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
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+#include "babl-internal.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+typedef struct ICC {
+ char *data;
+ int length;
+
+ int tags;
+ int headpos;
+ int o, no;
+ int p;
+ int psize;
+} ICC;
+
+ICC *icc_state_new (char *data, int length, int tags);
+
+ICC *icc_state_new (char *data, int length, int tags)
+{
+ ICC *ret = babl_calloc (sizeof (ICC), 1);
+ ret->data = data;
+ ret->length = length;
+ ret->tags = tags;
+
+ return ret;
+}
+
+#define ICC_HEADER_LEN 128
+#define TAG_COUNT_OFF ICC_HEADER_LEN
+
+typedef struct {
+ int16_t integer;
+ uint16_t fraction;
+} s15f16_t;
+
+typedef struct {
+ int16_t integer;
+ uint16_t fraction;
+} u8f8_t;
+
+typedef struct {
+ char str[5];
+} sign_t;
+
+#define icc_write(type, offset, value) write_##type(state,offset,value)
+#define icc_read(type, offset) read_##type(state,offset)
+
+static void write_u8 (ICC *state, int offset, uint8_t value)
+{
+ if (offset < 0 || offset >= state->length)
+ return;
+ *(uint8_t*) (&state->data[offset]) = value;
+}
+
+static void write_s8 (ICC *state, int offset, int8_t value)
+{
+ if (offset < 0 || offset >= state->length)
+ return;
+ *(int8_t*) (&state->data[offset]) = value;
+}
+
+static int read_u8 (ICC *state, int offset)
+{
+/* all reading functions take both the char *pointer and the length of the
+ * buffer, and all reads thus gets protected by this condition.
+ */
+ if (offset < 0 || offset > state->length)
+ return 0;
+
+ return *(uint8_t*) (&state->data[offset]);
+}
+
+static int read_s8 (ICC *state, int offset)
+{
+ if (offset < 0 || offset > state->length)
+ return 0;
+
+ return *(int8_t*) (&state->data[offset]);
+}
+
+static void write_s16 (ICC *state, int offset, int16_t value)
+{
+ write_s8 (state, offset + 0, value >> 8);
+ write_u8 (state, offset + 1, value & 0xff);
+}
+
+static int16_t read_s16 (ICC *state, int offset)
+{
+ return icc_read (u8, offset + 1) +
+ (read_s8 (state, offset + 0) << 8); //XXX: transform to icc_read macro
+}
+
+static uint16_t read_u16 (ICC *state, int offset)
+{
+ return icc_read (u8, offset + 1) +
+ (icc_read (u8, offset + 0) << 8);
+}
+
+static void write_u16 (ICC *state, int offset, uint16_t value)
+{
+ write_u8 (state, offset + 0, value >> 8);
+ write_u8 (state, offset + 1, value & 0xff);
+}
+
+static u8f8_t read_u8f8_ (ICC *state, int offset)
+{
+ u8f8_t ret ={icc_read (u8, offset),
+ icc_read (u8, offset + 1)};
+ return ret;
+}
+
+static s15f16_t read_s15f16_ (ICC *state, int offset)
+{
+ s15f16_t ret ={icc_read (s16, offset),
+ icc_read (u16, offset + 2)};
+ return ret;
+}
+
+static void write_u8f8_ (ICC *state, int offset, u8f8_t val)
+{
+ icc_write (u8, offset, val.integer),
+ icc_write (u8, offset + 1, val.fraction);
+}
+
+static void write_s15f16_ (ICC *state, int offset, s15f16_t val)
+{
+ icc_write (s16, offset, val.integer),
+ icc_write (u16, offset + 2, val.fraction);
+}
+
+static s15f16_t d_to_s15f16 (double value)
+{
+ s15f16_t ret;
+ ret.integer = floor (value);
+ ret.fraction = fmod(value, 1.0) * 65536.0;
+ return ret;
+}
+
+static u8f8_t d_to_u8f8 (double value)
+{
+ u8f8_t ret;
+ ret.integer = floor (value);
+ ret.fraction = fmod(value, 1.0) * 256.0;
+ return ret;
+}
+
+static double s15f16_to_d (s15f16_t fix)
+{
+ return fix.integer + fix.fraction / 65535.0;
+}
+
+static double u8f8_to_d (u8f8_t fix)
+{
+ return fix.integer + fix.fraction / 255.0;
+}
+
+static void write_s15f16 (ICC *state, int offset, double value)
+{
+ write_s15f16_ (state, offset, d_to_s15f16 (value));
+}
+
+static void write_u8f8 (ICC *state, int offset, double value)
+{
+ write_u8f8_ (state, offset, d_to_u8f8 (value));
+}
+
+
+static double read_s15f16 (ICC *state, int offset)
+{
+ return s15f16_to_d (read_s15f16_ (state, offset));
+}
+
+static double read_u8f8 (ICC *state, int offset)
+{
+ return u8f8_to_d (read_u8f8_ (state, offset));
+}
+
+#if 0
+static inline void print_u8f8 (u8f8_t fix)
+{
+ int i;
+ uint32_t foo;
+ foo = fix.fraction;
+ fprintf (stdout, "%i.", fix.integer);
+ for (i = 0; i < 18; i++)
+ {
+ foo *= 10;
+ fprintf (stdout, "%i", (foo / 256) % 10);
+ foo = foo & 0xff;
+ }
+}
+
+static inline void print_s15f16 (s15f16_t fix)
+{
+ int i;
+ uint32_t foo;
+ foo = fix.fraction;
+ if (fix.integer < 0)
+ {
+ if (fix.integer == -1)
+ fprintf (stdout, "-");
+ fprintf (stdout, "%i.", fix.integer + 1);
+ foo = 65535-fix.fraction;
+ for (i = 0; i < 18; i++)
+ {
+ foo *= 10;
+ fprintf (stdout, "%i", (foo / 65536) % 10);
+ foo = foo & 0xffff;
+ }
+ }
+ else
+ {
+ fprintf (stdout, "%i.", fix.integer);
+ for (i = 0; i < 18; i++)
+ {
+ foo *= 10;
+ fprintf (stdout, "%i", (foo / 65536) % 10);
+ foo = foo & 0xffff;
+ }
+ }
+}
+#endif
+
+static void write_u32 (ICC *state, int offset, uint32_t value)
+{
+ int i;
+ for (i = 0; i < 4; i ++)
+ {
+ write_u8 (state, offset + i,
+ (value & 0xff000000) >> 24
+ );
+ value <<= 8;
+ }
+}
+
+static uint32_t read_u32 (ICC *state, int offset)
+{
+ return icc_read (u8, offset + 3) +
+ (icc_read (u8, offset + 2) << 8) +
+ (icc_read (u8, offset + 1) << 16) +
+ (icc_read (u8, offset + 0) << 24);
+}
+
+static sign_t read_sign (ICC *state, int offset)
+{
+ sign_t ret;
+ ret.str[0]=icc_read (u8, offset);
+ ret.str[1]=icc_read (u8, offset + 1);
+ ret.str[2]=icc_read (u8, offset + 2);
+ ret.str[3]=icc_read (u8, offset + 3);
+ ret.str[4]=0;
+ return ret;
+}
+
+static void write_sign (ICC *state, int offset, const char *sign)
+{
+ int i;
+ for (i = 0; i < 4; i ++)
+ icc_write (u8, offset + i, sign[i]);
+}
+
+/* looks up offset and length for a specific icc tag
+ */
+static int icc_tag (ICC *state,
+ const char *tag, int *offset, int *el_length)
+{
+ int tag_count = icc_read (u32, TAG_COUNT_OFF);
+ int t;
+
+ for (t = 0; t < tag_count; t++)
+ {
+ sign_t sign = icc_read (sign, TAG_COUNT_OFF + 4 + 12 * t);
+ if (!strcmp (sign.str, tag))
+ {
+ if (offset)
+ *offset = icc_read (u32, TAG_COUNT_OFF + 4 + 12* t + 4);
+ if (el_length)
+ *el_length = icc_read (u32, TAG_COUNT_OFF + 4 + 12* t + 4*2);
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static const Babl *babl_trc_from_icc (ICC *state, int offset,
+ const char **error)
+{
+ {
+ int count = icc_read (u32, offset + 8);
+ int i;
+ if (!strcmp (state->data + offset, "para"))
+ {
+ int function_type = icc_read (u16, offset + 8);
+ float g;
+ switch (function_type)
+ {
+ case 0:
+ g = icc_read (s15f16, offset + 12 + 4 * 0);
+ return babl_trc_gamma (g);
+ break;
+ case 3:
+ {
+ float a,b,c,d;
+ g = icc_read (s15f16, offset + 12 + 4 * 0);
+ a = icc_read (s15f16, offset + 12 + 4 * 1);
+ b = icc_read (s15f16, offset + 12 + 4 * 2);
+ c = icc_read (s15f16, offset + 12 + 4 * 3);
+ d = icc_read (s15f16, offset + 12 + 4 * 4);
+ //fprintf (stderr, "%f %f %f %f %f\n", g, a, b, c, d);
+ return babl_trc_formula_srgb (g, a, b, c, d);
+ }
+ break;
+ case 4:
+ {
+ float a,b,c,d,e,f;
+ g = icc_read (s15f16, offset + 12 + 4 * 0);
+ a = icc_read (s15f16, offset + 12 + 4 * 1);
+ b = icc_read (s15f16, offset + 12 + 4 * 2);
+ c = icc_read (s15f16, offset + 12 + 4 * 3);
+ d = icc_read (s15f16, offset + 12 + 4 * 4);
+ e = icc_read (s15f16, offset + 12 + 4 * 5);
+ f = icc_read (s15f16, offset + 12 + 4 * 6);
+ fprintf (stderr, "%f %f %f %f %f %f %f\n",
+ g, a, b, c, d, e, f);
+ {
+ fprintf (stdout, "unhandled parametric sRGB formula TRC type %i\n", function_type);
+ *error = "unhandled sRGB formula like TRC";
+ return babl_trc_gamma (2.2);
+ }
+ }
+ break;
+ default:
+ *error = "unhandled parametric TRC";
+ fprintf (stdout, "unhandled parametric TRC type %i\n", function_type);
+ return babl_trc_gamma (2.2);
+ break;
+ }
+ }
+ else
+ {
+ if (count == 0)
+ {
+ return babl_trc_gamma (1.0);
+ }
+ else if (count == 1)
+ {
+ return babl_trc_gamma (icc_read (u8f8, offset + 12));
+ }
+ else
+ {
+ const Babl *ret;
+ float *lut;
+
+ lut = babl_malloc (sizeof (float) * count);
+
+ for (i = 0; i < count; i ++)
+ {
+ lut[i] = icc_read (u16, offset + 12 + i * 2) / 65535.0;
+ }
+
+ ret = babl_trc_lut_find (lut, count);
+ if (ret)
+ return ret;
+
+ ret = babl_trc_lut (NULL, count, lut);
+ babl_free (lut);
+ return ret;
+ }
+ }
+ }
+ return NULL;
+}
+
+static void icc_allocate_tag (ICC *state, const char *tag, int size)
+{
+ state->no+=((4-state->o)%4);state->o = state->no;state->psize = size;
+ icc_write (sign, 128 + 4 + 4 * state->headpos++, tag);
+ icc_write (u32, 128 + 4 + 4 * state->headpos++, state->o);
+ icc_write (u32, 128 + 4 + 4 * state->headpos++, size);
+ state->p = state->no;\
+ state->no+=size;
+}
+
+static void icc_duplicate_tag(ICC *state, const char *tag)
+{
+ icc_write (sign, 128 + 4 + 4 * state->headpos++, tag);
+ icc_write (u32, 128 + 4 + 4 * state->headpos++, state->p);
+ icc_write (u32, 128 + 4 + 4 * state->headpos++, state->psize);
+}
+
+/* brute force optimized 26 entry sRGB LUT */
+static const uint16_t lut_srgb_26[]={0,202,455,864,1423,2154,3060,4156,5454,6960,8689,10637,12821,15247,17920,20855,24042,27501,31233,35247,39549,44132,49018,54208,59695,65535};
+
+
+void write_trc (ICC *state,
+ const char *name,
+ const BablTRC *trc,
+ BablICCFlags flags);
+void write_trc (ICC *state,
+ const char *name,
+ const BablTRC *trc,
+ BablICCFlags flags)
+{
+switch (trc->type)
+{
+ case BABL_TRC_LINEAR:
+ icc_allocate_tag (state, name, 13);
+ icc_write (sign, state->o, "curv");
+ icc_write (u32, state->o + 4, 0);
+ icc_write (u32, state->o + 8, 0);
+ break;
+ case BABL_TRC_FORMULA_GAMMA:
+ icc_allocate_tag (state, name, 14);
+ icc_write (sign, state->o, "curv");
+ icc_write (u32, state->o + 4, 0);
+ icc_write (u32, state->o + 8, 1);
+ icc_write (u8f8, state->o + 12, trc->gamma);
+ break;
+ case BABL_TRC_LUT:
+ icc_allocate_tag (state, name, 12 + trc->lut_size * 2);
+ icc_write (sign, state->o, "curv");
+ icc_write (u32, state->o + 4, 0);
+ icc_write (u32, state->o + 8, trc->lut_size);
+ {
+ int j;
+ for (j = 0; j < trc->lut_size; j ++)
+ icc_write (u16, state->o + 12 + j * 2, (int)(trc->lut[j]*65535.5f));
+ }
+ break;
+ // this is the case catching things not directly representable in v2
+ case BABL_TRC_SRGB:
+ if (flags == BABL_ICC_COMPACT_TRC_LUT)
+ {
+ int lut_size = 26;
+ icc_allocate_tag (state, name, 12 + lut_size * 2);
+ icc_write (sign, state->o, "curv");
+ icc_write (u32, state->o + 4, 0);
+ icc_write (u32, state->o + 8, lut_size);
+ {
+ int j;
+ for (j = 0; j < lut_size; j ++)
+ icc_write (u16, state->o + 12 + j * 2, lut_srgb_26[j]);
+ }
+ break;
+ }
+ case BABL_TRC_FORMULA_SRGB:
+ {
+ int lut_size = 512;
+ if (flags == BABL_ICC_COMPACT_TRC_LUT)
+ lut_size = 128;
+
+ icc_allocate_tag (state, name, 12 + lut_size * 2);
+ icc_write (sign, state->o, "curv");
+ icc_write (u32, state->o + 4, 0);
+ icc_write (u32, state->o + 8, lut_size);
+ {
+ int j;
+ for (j = 0; j < lut_size; j ++)
+ icc_write (u16, state->o + 12 + j * 2,
+ babl_trc_to_linear ((void*)trc, j / (lut_size-1.0)) * 65535.5);
+ }
+ }
+}
+}
+
+static void symmetry_test (ICC *state);
+
+const char *babl_space_to_icc (const Babl *babl,
+ const char *description,
+ const char *copyright,
+ BablICCFlags flags,
+ int *ret_length)
+{
+ const BablSpace *space = &babl->space;
+ static char icc[65536];
+ int length=65535;
+ ICC *state = icc_state_new (icc, length, 10);
+
+ icc[length]=0;
+
+ symmetry_test (state);
+
+ icc_write (sign, 4, "babl"); // ICC verison
+ icc_write (u8, 8, 2); // ICC verison
+ icc_write (u8, 9, 0x20); // 2.2 for now..
+ icc_write (u32,64, 0); // rendering intent
+
+ icc_write (s15f16,68, 0.96421); // Illuminant
+ icc_write (s15f16,72, 1.0);
+ icc_write (s15f16,76, 0.82491);
+
+ icc_write (sign, 80, "babl"); // creator
+
+ icc_write (sign, 12, "mntr");
+ icc_write (sign, 16, "RGB ");
+ icc_write (sign, 20, "XYZ ");
+
+ icc_write (u16, 24, 2222); // babl profiles
+ icc_write (u16, 26, 11); // should
+ icc_write (u16, 28, 11); // use a fixed
+ icc_write (u16, 30, 3); // date
+ icc_write (u16, 32, 44); // that gets updated
+ icc_write (u16, 34, 55); // when the generator changes
+
+ icc_write (sign, 36, "acsp"); // changes
+
+ {
+ state->tags = 9; /* note: we could reserve a couple of spots and
+ still use a very simple allocator and
+ still be valid - albeit with tiny waste of
+ space.
+ */
+ state->no = state->o = 128 + 4 + 12 * state->tags;
+
+ icc_write (u32, 128, state->tags);
+
+ icc_allocate_tag (state, "wtpt", 20);
+ icc_write (sign, state->o, "XYZ ");
+ icc_write (u32, state->o + 4, 0);
+ icc_write (s15f16, state->o + 8, space->whitepoint[0]);
+ icc_write (s15f16, state->o + 12, space->whitepoint[1]);
+ icc_write (s15f16, state->o + 16, space->whitepoint[2]);
+
+ icc_allocate_tag (state, "rXYZ", 20);
+ icc_write (sign, state->o, "XYZ ");
+ icc_write (u32, state->o + 4, 0);
+ icc_write (s15f16, state->o + 8, space->RGBtoXYZ[0]);
+ icc_write (s15f16, state->o + 12, space->RGBtoXYZ[3]);
+ icc_write (s15f16, state->o + 16, space->RGBtoXYZ[6]);
+
+ icc_allocate_tag (state, "gXYZ", 20);
+ icc_write (sign, state->o, "XYZ ");
+ icc_write (u32, state->o + 4, 0);
+ icc_write (s15f16, state->o + 8, space->RGBtoXYZ[1]);
+ icc_write (s15f16, state->o + 12, space->RGBtoXYZ[4]);
+ icc_write (s15f16, state->o + 16, space->RGBtoXYZ[7]);
+
+ icc_allocate_tag (state, "bXYZ", 20);
+ icc_write (sign, state->o, "XYZ ");
+ icc_write (u32, state->o + 4, 0);
+ icc_write (s15f16, state->o + 8, space->RGBtoXYZ[2]);
+ icc_write (s15f16, state->o + 12, space->RGBtoXYZ[5]);
+ icc_write (s15f16, state->o + 16, space->RGBtoXYZ[8]);
+
+ write_trc (state, "rTRC", &space->trc[0]->trc, flags);
+
+ if (space->trc[0] == space->trc[1] &&
+ space->trc[0] == space->trc[2])
+ {
+ icc_duplicate_tag (state, "gTRC");
+ icc_duplicate_tag (state, "bTRC");
+ }
+ else
+ {
+ write_trc (state, "gTRC", &space->trc[1]->trc, flags);
+ write_trc (state, "bTRC", &space->trc[2]->trc, flags);
+ }
+
+ {
+ char str[128]="CC0/public domain";
+ int i;
+ if (!copyright) copyright = str;
+ icc_allocate_tag(state, "cprt", 8 + strlen (copyright) + 1);
+ icc_write (sign, state->o, "text");
+ icc_write (u32, state->o + 4, 0);
+ for (i = 0; copyright[i]; i++)
+ icc_write (u8, state->o + 8 + i, copyright[i]);
+ }
+ {
+ char str[128]="babl";
+ int i;
+ if (!description) description = str;
+ icc_allocate_tag(state, "desc", 90 + strlen (description) + 0);
+ icc_write (sign, state->o,"desc");
+ icc_write (u32, state->o + 4, 0);
+ icc_write (u32, state->o + 8, strlen(description) + 1);
+ for (i = 0; description[i]; i++)
+ icc_write (u8, state->o + 12 + i, description[i]);
+ }
+
+
+ icc_write (u32, 0, state->no + 0);
+ length = state->no + 0;
+ }
+
+ if (ret_length)
+ *ret_length = length;
+
+ babl_free (state);
+ return icc;
+}
+
+
+typedef uint32_t UTF32;
+typedef uint16_t UTF16;
+typedef uint8_t UTF8;
+
+typedef enum {
+ strictConversion = 0,
+ lenientConversion
+} ConversionFlags;
+
+static int ConvertUTF16toUTF8 (const UTF16** sourceStart,
+ const UTF16* sourceEnd,
+ UTF8** targetStart,
+ UTF8* targetEnd,
+ ConversionFlags flags);
+
+static char *icc_decode_mluc (ICC *state,
+ int offset,
+ int element_length,
+ const char *lang,
+ const char *country)
+{
+ int n_records = icc_read (u32, offset + 8);
+ int record_size = icc_read (u32, offset + 12);
+ int i;
+ int o = 16;
+ for (i = 0; i < n_records; i++)
+ {
+ char icountry[3]=" ";
+ char ilang[3]=" ";
+
+ ilang[0] = icc_read(u8, offset + o + 0);
+ ilang[1] = icc_read(u8, offset + o + 1);
+ icountry[0] = icc_read(u8, offset + o + 2);
+ icountry[1] = icc_read(u8, offset + o + 3);
+
+ if (((!lang || !strcmp (lang, ilang)) &&
+ (!country || !strcmp (country, icountry))) ||
+ (i == n_records - 1))
+ {
+ int slength = (icc_read(u32, offset + o + 4))/2;
+ int soffset = icc_read(u32, offset + o + 8);
+ UTF16 *tmp_ret = babl_calloc (sizeof (uint16_t), slength + 1);
+ UTF16 *tmp_ret2 = tmp_ret;
+ unsigned char *ret = babl_calloc (1, slength * 4 + 1); // worst case scenario
+ unsigned char *ret2 = ret;
+ int j;
+
+ for (j = 0; j < slength; j++)
+ {
+ tmp_ret[j] = icc_read(u16, offset + soffset + j * 2);
+ }
+ tmp_ret[j] = 0;
+ memset (ret, 0, slength * 4 + 1);
+ ConvertUTF16toUTF8 ((void*)&tmp_ret2, tmp_ret + slength, &ret2, ret + slength, lenientConversion);
+ babl_free(tmp_ret);
+ { // trim down to actually used utf8
+ unsigned char *tmp = (void*)strdup ((void*)ret);
+ babl_free (ret);
+ ret = tmp;
+ }
+ return (void*)ret;
+ }
+ o+=record_size;
+ }
+ return NULL;
+}
+
+static char *decode_string (ICC *state, const char *tag, const char *lang, const char *country)
+{
+ int offset, element_size;
+
+ if (!icc_tag (state, tag, &offset, &element_size))
+ return NULL;
+
+ if (!strcmp (state->data + offset, "mluc"))
+ {
+ return icc_decode_mluc (state, offset, element_size, lang, country);
+ }
+ else if (!strcmp (state->data + offset, "text"))
+ {
+ return strdup (state->data + offset + 8);
+ }
+ else if (!strcmp (state->data + offset, "desc"))
+ {
+ return strdup (state->data + offset + 12);
+ }
+ return NULL;
+}
+
+const Babl *
+babl_icc_make_space (const char *icc_data,
+ int icc_length,
+ BablIccIntent intent,
+ const char **error)
+{
+ ICC *state = icc_state_new ((char*)icc_data, icc_length, 0);
+ int profile_size = icc_read (u32, 0);
+ //int icc_ver_major = icc_read (u8, 8);
+ const Babl *trc_red = NULL;
+ const Babl *trc_green = NULL;
+ const Babl *trc_blue = NULL;
+ const char *int_err;
+ Babl *ret = NULL;
+
+ sign_t profile_class, color_space;
+
+
+ if (!error) error = &int_err;
+ *error = NULL;
+
+ if (profile_size != icc_length)
+ {
+ *error = "icc profile length inconsistency";
+ }
+#if 0
+ else if (icc_ver_major > 2)
+ {
+ *error = "only ICC v2 profiles supported";
+ }
+#endif
+ else
+ {
+ profile_class = icc_read (sign, 12);
+ if (strcmp (profile_class.str, "mntr"))
+ *error = "not a monitor-class profile";
+ else
+ {
+ color_space = icc_read (sign, 16);
+ if (strcmp (color_space.str, "RGB "))
+ *error = "not defining an RGB space";
+ }
+ }
+
+ switch (intent)
+ {
+ case BABL_ICC_INTENT_RELATIVE_COLORIMETRIC:
+ /* that is what we do well */
+ break;
+ case BABL_ICC_INTENT_PERCEPTUAL:
+ /* if there is an A2B0 and B2A0 tags, we do not do what that
+ * profile is capable of - since the CLUT code is work in progress
+ * not in git master yet.
+ */
+ if (icc_tag (state, "A2B0", NULL, NULL) &&
+ icc_tag (state, "B2A0", NULL, NULL))
+ {
+ *error = "profile contains perceptual luts and perceptual was explicitly asked for, babl does not yet support CLUTs";
+ }
+ else
+ {
+ intent = BABL_ICC_INTENT_RELATIVE_COLORIMETRIC;
+ }
+ break;
+ case BABL_ICC_INTENT_ABSOLUTE_COLORIMETRIC:
+ *error = "absolute colormetric not implemented";
+ break;
+ case BABL_ICC_INTENT_SATURATION:
+ *error = "absolute stauration not supported";
+ break;
+ }
+
+ {
+ int offset, element_size;
+ if (!*error && icc_tag (state, "rTRC", &offset, &element_size))
+ {
+ trc_red = babl_trc_from_icc (state, offset, error);
+ }
+ if (!*error && icc_tag (state, "gTRC", &offset, &element_size))
+ {
+ trc_green = babl_trc_from_icc (state, offset, error);
+ }
+ if (!*error && icc_tag (state, "bTRC", &offset, &element_size))
+ {
+ trc_blue = babl_trc_from_icc (state, offset, error);
+ }
+ }
+
+ if (!*error && (!trc_red || !trc_green || !trc_blue))
+ {
+ *error = "missing TRCs";
+ }
+
+ if (*error)
+ {
+ babl_free (state);
+ return NULL;
+ }
+
+ if (icc_tag (state, "rXYZ", NULL, NULL) &&
+ icc_tag (state, "gXYZ", NULL, NULL) &&
+ icc_tag (state, "bXYZ", NULL, NULL) &&
+ icc_tag (state, "wtpt", NULL, NULL))
+ {
+ int offset, element_size;
+ double rx, gx, bx;
+ double ry, gy, by;
+ double rz, gz, bz;
+
+ double wX, wY, wZ;
+
+ icc_tag (state, "rXYZ", &offset, &element_size);
+ rx = icc_read (s15f16, offset + 8 + 4 * 0);
+ ry = icc_read (s15f16, offset + 8 + 4 * 1);
+ rz = icc_read (s15f16, offset + 8 + 4 * 2);
+ icc_tag (state, "gXYZ", &offset, &element_size);
+ gx = icc_read (s15f16, offset + 8 + 4 * 0);
+ gy = icc_read (s15f16, offset + 8 + 4 * 1);
+ gz = icc_read (s15f16, offset + 8 + 4 * 2);
+ icc_tag (state, "bXYZ", &offset, &element_size);
+ bx = icc_read (s15f16, offset + 8 + 4 * 0);
+ by = icc_read (s15f16, offset + 8 + 4 * 1);
+ bz = icc_read (s15f16, offset + 8 + 4 * 2);
+ icc_tag (state, "wtpt", &offset, &element_size);
+ wX = icc_read (s15f16, offset + 8);
+ wY = icc_read (s15f16, offset + 8 + 4);
+ wZ = icc_read (s15f16, offset + 8 + 4 * 2);
+
+ ret = (void*)babl_space_match_trc_matrix (trc_red, trc_green, trc_blue,
+ rx, ry, rz, gx, gy, gz, bx, by, bz);
+ if (ret)
+ {
+ babl_free (state);
+ return ret;
+ }
+
+ {
+ ret = (void*)babl_space_from_rgbxyz_matrix (NULL,
+ wX, wY, wZ,
+ rx, gx, bx,
+ ry, gy, by,
+ rz, gz, bz,
+ trc_red, trc_green, trc_blue);
+
+ babl_free (state);
+ return ret;
+ }
+ }
+ else if (icc_tag (state, "chrm", NULL, NULL) &&
+ icc_tag (state, "wtpt", NULL, NULL))
+ {
+ int offset, element_size;
+ double red_x, red_y, green_x, green_y, blue_x, blue_y;
+ int channels, phosporant;
+
+ icc_tag (state, "chrm", &offset, &element_size);
+ channels = icc_read (u16, offset + 8);
+ phosporant = icc_read (u16, offset + 10);
+
+ if (phosporant != 0)
+ {
+ *error = "unhandled phosporants, please report bug against babl with profile";
+ return NULL;
+ }
+ if (channels != 3)
+ {
+ *error = "unexpected non 3 count of channels";
+ return NULL;
+ }
+
+ red_x = icc_read (s15f16, offset + 12);
+ red_y = icc_read (s15f16, offset + 12 + 4);
+ green_x = icc_read (s15f16, offset + 20);
+ green_y = icc_read (s15f16, offset + 20 + 4);
+ blue_x = icc_read (s15f16, offset + 28);
+ blue_y = icc_read (s15f16, offset + 28 + 4);
+
+ icc_tag (state, "wtpt", &offset, &element_size);
+ {
+ double wX = icc_read (s15f16, offset + 8);
+ double wY = icc_read (s15f16, offset + 8 + 4);
+ double wZ = icc_read (s15f16, offset + 8 + 4 * 2);
+ babl_free (state);
+
+ ret = (void*) babl_space_from_chromaticities (NULL,
+ wX / (wX + wY + wZ),
+ wY / (wX + wY + wZ),
+ red_x, red_y,
+ green_x, green_y,
+ blue_x, blue_y,
+ trc_red, trc_green, trc_blue);
+ return ret;
+ }
+ }
+
+ *error = "didnt find RGB primaries";
+ babl_free (state);
+ return NULL;
+}
+
+static void symmetry_test (ICC *state)
+{
+ icc_write (s8, 8,-2);
+ assert (icc_read (s8, 8) == -2);
+ icc_write (s8, 8, 3);
+ assert (icc_read (s8, 8) == 3);
+
+ icc_write (u8, 8, 2);
+ assert (icc_read (u8, 8) == 2);
+
+ icc_write (u16, 8, 3);
+ assert (icc_read (u16, 8) == 3);
+
+ icc_write (s16, 8, -3);
+ assert (icc_read (s16, 8) == -3);
+
+ icc_write (s16, 8, 9);
+ assert (icc_read (s16, 8) == 9);
+
+ icc_write (u32, 8, 4);
+ assert (icc_read (u32, 8) == 4);
+}
+
+char *babl_icc_get_key (const char *icc_data,
+ int icc_length,
+ const char *key,
+ const char *language,
+ const char *country)
+{
+ char *ret = NULL;
+ ICC *state = icc_state_new ((void*)icc_data, icc_length, 0);
+
+ if (!state)
+ return ret;
+
+ if (!strcmp (key, "copyright") ||
+ !strcmp (key, "cprt"))
+ {
+ ret = decode_string (state, "cprt", language, country);
+
+ } else if (!strcmp (key, "description") ||
+ !strcmp (key, "profileDescriptionTag") ||
+ !strcmp (key, "desc"))
+ {
+ ret = decode_string (state, "desc", language, country);
+
+ } else if (!strcmp (key, "manufacturer") ||
+ !strcmp (key, "deviceMfgDescTag") ||
+ !strcmp (key, "dmnd"))
+ {
+ ret = decode_string (state, "dmnd", language, country);
+
+ } else if (!strcmp (key, "device") ||
+ !strcmp (key, "deviceModelDescTag") ||
+ !strcmp (key, "dmdd"))
+ {
+ ret = decode_string (state, "dmdd", language, country);
+ } else if (!strcmp (key, "class") ||
+ !strcmp (key, "profile-class"))
+ {
+ sign_t tag = icc_read (sign, 12);
+ return strdup (tag.str);
+ } else if (!strcmp (key, "color-space"))
+ {
+ sign_t tag = icc_read (sign, 16);
+ return strdup (tag.str);
+ } else if (!strcmp (key, "pcs"))
+ {
+ sign_t tag = icc_read (sign, 20);
+ return strdup (tag.str);
+ } else if (!strcmp (key, "intent"))
+ {
+ char tag[5];
+ int val = icc_read (u32, 64);
+ sprintf (tag, "%i", val);
+ return strdup (tag);
+ } else if (!strcmp (key, "tags"))
+ {
+ char tag[4096]="NYI";
+ return strdup (tag);
+ }
+ babl_free (state);
+ return ret;
+}
+
+
+/*
+ * Copyright 2001-2004 Unicode, Inc.
+ *
+ * Disclaimer
+ *
+ * This source code is provided as is by Unicode, Inc. No claims are
+ * made as to fitness for any particular purpose. No warranties of any
+ * kind are expressed or implied. The recipient agrees to determine
+ * applicability of information provided. If this file has been
+ * purchased on magnetic or optical media from Unicode, Inc., the
+ * sole remedy for any claim will be exchange of defective media
+ * within 90 days of receipt.
+ *
+ * Limitations on Rights to Redistribute This Code
+ *
+ * Unicode, Inc. hereby grants the right to freely use the information
+ * supplied in this file in the creation of products supporting the
+ * Unicode Standard, and to make copies of this file in any form
+ * for internal or external distribution as long as this notice
+ * remains attached.
+ */
+/* ---------------------------------------------------------------------
+
+ Conversions between UTF32, UTF-16, and UTF-8. Source code file.
+ Author: Mark E. Davis, 1994.
+ Rev History: Rick McGowan, fixes & updates May 2001.
+ Sept 2001: fixed const & error conditions per
+ mods suggested by S. Parent & A. Lillich.
+ June 2002: Tim Dodd added detection and handling of incomplete
+ source sequences, enhanced error detection, added casts
+ to eliminate compiler warnings.
+ July 2003: slight mods to back out aggressive FFFE detection.
+ Jan 2004: updated switches in from-UTF8 conversions.
+ Oct 2004: updated to use UNI_MAX_LEGAL_UTF32 in UTF-32 conversions.
+ Sep 2017: copied only the bits neccesary for utf16toutf8 into babl,
+ otherwise unchanged from upstream.
+
+ See the header file "ConvertUTF.h" for complete documentation.
+
+------------------------------------------------------------------------ */
+
+typedef uint32_t UTF32; /* at least 32 bits */
+typedef unsigned short UTF16; /* at least 16 bits */
+typedef unsigned char UTF8; /* typically 8 bits */
+typedef unsigned char Boolean; /* 0 or 1 */
+typedef enum {
+ conversionOK, /* conversion successful */
+ sourceExhausted, /* partial character in source, but hit end */
+ targetExhausted, /* insuff. room in target for conversion */
+ sourceIllegal /* source sequence is illegal/malformed */
+} ConversionResult;
+
+#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD
+
+
+#define UNI_SUR_HIGH_START (UTF32)0xD800
+#define UNI_SUR_HIGH_END (UTF32)0xDBFF
+#define UNI_SUR_LOW_START (UTF32)0xDC00
+#define UNI_SUR_LOW_END (UTF32)0xDFFF
+static const int halfShift = 10; /* used for shifting by 10 bits */
+
+static const UTF32 halfBase = 0x0010000UL;
+static const UTF8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
+
+static int ConvertUTF16toUTF8 (const UTF16** sourceStart, const UTF16* sourceEnd,
+ UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags)
+{
+ ConversionResult result = conversionOK;
+ const UTF16* source = *sourceStart;
+ UTF8* target = *targetStart;
+ while (source < sourceEnd) {
+ UTF32 ch;
+ unsigned short bytesToWrite = 0;
+ const UTF32 byteMask = 0xBF;
+ const UTF32 byteMark = 0x80;
+ const UTF16* oldSource = source; /* In case we have to back up because of target overflow. */
+ ch = *source++;
+ /* If we have a surrogate pair, convert to UTF32 first. */
+ if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) {
+ /* If the 16 bits following the high surrogate are in the source buffer... */
+ if (source < sourceEnd) {
+ UTF32 ch2 = *source;
+ /* If it's a low surrogate, convert to UTF32. */
+ if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) {
+ ch = ((ch - UNI_SUR_HIGH_START) << halfShift)
+ + (ch2 - UNI_SUR_LOW_START) + halfBase;
+ ++source;
+ } else if (flags == strictConversion) { /* it's an unpaired high surrogate */
+ --source; /* return to the illegal value itself */
+ result = sourceIllegal;
+ break;
+ }
+ } else { /* We don't have the 16 bits following the high surrogate. */
+ --source; /* return to the high surrogate */
+ result = sourceExhausted;
+ break;
+ }
+ } else if (flags == strictConversion) {
+ /* UTF-16 surrogate values are illegal in UTF-32 */
+ if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) {
+ --source; /* return to the illegal value itself */
+ result = sourceIllegal;
+ break;
+ }
+ }
+ /* Figure out how many bytes the result will require */
+ if (ch < (UTF32)0x80) { bytesToWrite = 1;
+ } else if (ch < (UTF32)0x800) { bytesToWrite = 2;
+ } else if (ch < (UTF32)0x10000) { bytesToWrite = 3;
+ } else if (ch < (UTF32)0x110000) { bytesToWrite = 4;
+ } else { bytesToWrite = 3;
+ ch = UNI_REPLACEMENT_CHAR;
+ }
+
+ target += bytesToWrite;
+ if (target > targetEnd) {
+ source = oldSource; /* Back up source pointer! */
+ target -= bytesToWrite; result = targetExhausted; break;
+ }
+ switch (bytesToWrite) { /* note: everything falls through. */
+ case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
+ case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
+ case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
+ case 1: *--target = (UTF8)(ch | firstByteMark[bytesToWrite]);
+ }
+ target += bytesToWrite;
+ }
+ *sourceStart = source;
+ *targetStart = target;
+ return result;
+}
+
+/* Trademarks:
+ *
+ * International Color Consortium is a registered trademarks of the.
+ * International Color Consortium.
+ */
diff --git a/babl/babl-internal.c b/babl/babl-internal.c
index 64168cf..0589e3f 100644
--- a/babl/babl-internal.c
+++ b/babl/babl-internal.c
@@ -27,9 +27,11 @@ static const char *class_names[] =
"BablTypeInteger",
"BablTypeFloat",
"BablSampling",
+ "BablTRC",
"BablComponent",
"BablModel",
"BablFormat",
+ "BablSpace",
"BablConversion",
"BablConversionLinear",
"BablConversionPlane",
diff --git a/babl/babl-internal.h b/babl/babl-internal.h
index 78f2b56..3362563 100644
--- a/babl/babl-internal.h
+++ b/babl/babl-internal.h
@@ -28,7 +28,7 @@
#endif
#define BABL_MAX_COMPONENTS 32
-#define BABL_CONVERSIONS 5
+#define BABL_CONVERSIONS 5
#include <stdlib.h>
#include <stdio.h>
@@ -51,13 +51,16 @@
#include "babl-memory.h"
#include "babl-mutex.h"
#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
Babl * babl_conversion_find (const void *source,
const void *destination);
@@ -122,15 +125,31 @@ real_babl_log_va(const char *file,
if (extender != babl_extension_quiet_log())
{
if (babl_extender())
- fprintf (stdout, "When loading %s:\n\t", babl_extender()->instance.name);
+ {
+#ifdef __ANDROID_API__
+ __android_log_print (ANDROID_LOG_DEBUG, "BABL",
+ "When loading %s:\n\t", babl_extender()->instance.name);
+#else
+ fprintf (stdout, "When loading %s:\n\t", babl_extender()->instance.name);
+#endif
+ }
+#ifdef __ANDROID_API__
+ __android_log_print (ANDROID_LOG_DEBUG, "BABL",
+ "%s:%i %s()", file, line, function);
+#else
fprintf (stdout, "%s:%i %s()\n\t", file, line, function);
+#endif
}
+#ifdef __ANDROID_API__
+ __android_log_vprint (ANDROID_LOG_DEBUG, "BABL",
+ fmt, varg);
+#else
vfprintf (stdout, fmt, varg);
-
fprintf (stdout, "\n");
fflush (NULL);
+#endif
return;
}
@@ -319,10 +338,152 @@ static inline double babl_parse_double (const char *str)
return result;
}
+const Babl *
+babl_remodel_with_space (const Babl *model, const Babl *space);
+const Babl *
+babl_model_with_space (const char *name, const Babl *space);
+Babl *
+_conversion_new (const char *name,
+ int id,
+ const Babl *source,
+ const Babl *destination,
+ BablFuncLinear linear,
+ BablFuncPlane plane,
+ BablFuncPlanar planar,
+ void *user_data);
double _babl_legal_error (void);
void babl_init_db (void);
void babl_store_db (void);
int _babl_max_path_len (void);
+
+const Babl *
+babl_trc_new (const char *name,
+ BablTRCType type,
+ double gamma,
+ int n_lut,
+ float *lut);
+
+void babl_space_to_xyz (const Babl *space, const double *rgb, double *xyz);
+void babl_space_from_xyz (const Babl *space, const double *xyz, double *rgb);
+
+const Babl *babl_trc_lut_find (float *lut, int lut_size);
+const Babl *babl_trc_lut (const char *name, int n, float *entries);
+
+Babl * format_new_from_format_with_space (const Babl *format, const Babl *space);
+
+int babl_list_destroy (void *data);
+
+const char *
+babl_conversion_create_name (Babl *source, Babl *destination, int is_reference);
+void _babl_space_add_universal_rgb (const Babl *space);
+const Babl *
+babl_trc_formula_srgb (double gamma, double a, double b, double c, double d);
+
+
+const Babl *babl_space_match_trc_matrix (const Babl *trc_red,
+ const Babl *trc_green,
+ const Babl *trc_blue,
+ float rx, float ry, float rz,
+ float gx, float gy, float gz,
+ float bx, float by, float bz);
+
+/**
+ * babl_space_from_chromaticities:
+ *
+ * Creates a new babl-space/ RGB matrix color space definition with the
+ * specified CIE xy(Y) values for white point: wx, wy and primary
+ * chromaticities: rx,ry,gx,gy,bx,by and TRCs to be used. After registering a
+ * new babl-space it can be used with babl_space() passing its name;
+ *
+ * Internally this does the math to derive the RGBXYZ matrix as used in an ICC
+ * profile.
+ */
+const Babl * babl_space_from_chromaticities (const char *name,
+ double wx, double wy,
+ double rx, double ry,
+ double gx, double gy,
+ double bx, double by,
+ const Babl *trc_red,
+ const Babl *trc_green,
+ const Babl *trc_blue);
+
+/**
+ * babl_space_from_rgbxyz_matrix:
+ *
+ * Creates a new RGB matrix color space definition using a precomputed D50
+ * adapted 3x3 matrix and associated CIE XYZ whitepoint, as possibly read from
+ * an ICC profile.
+ */
+const Babl *
+babl_space_from_rgbxyz_matrix (const char *name,
+ double wx, double wy, double wz,
+ double rx, double gx, double bx,
+ double ry, double gy, double by,
+ double rz, double gz, double bz,
+ const Babl *trc_red,
+ const Babl *trc_green,
+ const Babl *trc_blue);
+
+/**
+ * babl_trc_gamma:
+ *
+ * Creates a Babl TRC for a specific gamma value, it will be given
+ * a name that is a short string representation of the value.
+ */
+const Babl * babl_trc_gamma (double gamma);
+
+/**
+ * babl_trc:
+ *
+ * Look up a TRC by name, "sRGB" "1.0" "linear" and "2.2" are recognized
+ * strings in a stock babl configuration.
+ */
+const Babl * babl_trc (const char *name);
+
+int _babl_file_get_contents (const char *path,
+ char **contents,
+ long *length,
+ void *error);
+
+typedef enum {
+ BABL_ICC_DEFAULTS = 0,
+ BABL_ICC_COMPACT_TRC_LUT = 1,
+} BablICCFlags;
+
+/* babl_space_to_icc:
+ *
+ * Creates an ICCv2 RGB matrix profile for a babl space. The profiles strive to
+ * be as small and compact as possible, TRCs are stored as 1024 entry LUT(s).
+ *
+ * you should make a copy of the profile before making another call to this
+ * function.
+ */
+
+const char *babl_space_to_icc (const Babl *space,
+ const char *description,
+ const char *copyright,
+ BablICCFlags flags,
+ int *icc_length);
+
+/* babl_space_get_rgbtoxyz:
+
+ Returns the double-precision 3x3 matrix used to convert linear
+ RGB data to CIE XYZ.
+ */
+const double * babl_space_get_rgbtoxyz (const Babl *space);
+
+/* babl_space_to_xyz:
+ *
+ * converts a double triplet from linear RGB to CIE XYZ.
+ */
+void babl_space_to_xyz (const Babl *space, const double *rgb, double *xyz);
+
+/* babl_space_from_xyz:
+ *
+ * converts double triplet from CIE XYZ to linear RGB
+ */
+void babl_space_from_xyz (const Babl *space, const double *xyz, double *rgb);
+
#endif
diff --git a/babl/babl-introspect.c b/babl/babl-introspect.c
index d969192..03cfef1 100644
--- a/babl/babl-introspect.c
+++ b/babl/babl-introspect.c
@@ -67,6 +67,12 @@ babl_introspect (Babl *babl)
babl_log ("conversions:");
babl_conversion_class_for_each (each_introspect, NULL);
babl_log ("");
+ babl_log ("trcs:");
+ babl_trc_class_for_each (each_introspect, NULL);
+ babl_log ("");
+ babl_log ("spaces:");
+ babl_space_class_for_each (each_introspect, NULL);
+ babl_log ("");
babl_log ("extensions:");
babl_extension_class_for_each (each_introspect, NULL);
babl_log ("");
@@ -127,6 +133,17 @@ sampling_introspect (Babl *babl)
babl->sampling.vertical);
}
+static void
+space_introspect (Babl *babl)
+{
+ // XXX: print TRCs and matrix, possibly if we have an icc and intent
+}
+
+static void
+trc_introspect (Babl *babl)
+{
+ // XXX: print type, and parameters
+}
static void
format_introspect (Babl *babl)
@@ -203,9 +220,16 @@ each_introspect (Babl *babl,
case BABL_SAMPLING:
sampling_introspect (babl);
- item_conversions_introspect (babl);
break;
+ case BABL_SPACE:
+ space_introspect (babl);
+ break;
+
+ case BABL_TRC:
+ trc_introspect (babl);
+ break;
+
case BABL_CONVERSION:
case BABL_CONVERSION_PLANE:
case BABL_CONVERSION_PLANAR:
diff --git a/babl/babl-list.c b/babl/babl-list.c
index 49647bb..beb7b61 100644
--- a/babl/babl-list.c
+++ b/babl/babl-list.c
@@ -31,7 +31,7 @@ babl_list_init (void)
return babl_list_init_with_size (BABL_LIST_INITIAL_SIZE);
}
-static int
+int
babl_list_destroy (void *data)
{
BablList *list = data;
diff --git a/babl/babl-macros.h b/babl/babl-macros.h
index f022d9f..61d372b 100644
--- a/babl/babl-macros.h
+++ b/babl/babl-macros.h
@@ -20,7 +20,7 @@
#define _BABL_MACROS_H
#if !defined(BABL_INSIDE_BABL_H) && !defined(BABL_IS_BEING_COMPILED)
-#error "babl-version.h must not be included directly, include babl.h instead."
+#error "babl-macros.h must not be included directly, include babl.h instead."
#endif
diff --git a/babl/babl-matrix.h b/babl/babl-matrix.h
new file mode 100644
index 0000000..8f331a5
--- /dev/null
+++ b/babl/babl-matrix.h
@@ -0,0 +1,195 @@
+#ifndef _BABL_MATRIX_H_
+#define _BABL_MATRIX_H_
+
+#include <stdio.h>
+
+#define m(matr, j, i) matr[j*3+i]
+
+static inline void babl_matrix_mul_matrix (const double *matA_,
+ const double *matB_,
+ double *out)
+{
+ int i, j;
+ double matA[9];
+ double matB[9];
+ double t1, t2, t3;
+ memcpy (matA, matA_, sizeof (matA));
+ memcpy (matB, matB_, sizeof (matB));
+
+ for (i = 0; i < 3; i++)
+ {
+ t1 = m(matA, i, 0);
+ t2 = m(matA, i, 1);
+ t3 = m(matA, i, 2);
+
+ for (j = 0; j < 3; j ++)
+ {
+ m(out,i,j) = t1 * m(matB, 0, j);
+ m(out,i,j) += t2 * m(matB, 1, j);
+ m(out,i,j) += t3 * m(matB, 2, j);
+ }
+ }
+}
+
+static inline void babl_matrix_to_float (const double *in, float *out)
+{
+ int i;
+ for (i = 0; i < 9; i ++)
+ out[i] = in[i];
+}
+
+static inline void babl_matrix_invert (const double *in, double *out)
+{
+ double mat[9];
+ double det, invdet;
+ memcpy (mat, in, sizeof (mat));
+ det = m(mat, 0, 0) * (m(mat, 1, 1) *m(mat, 2, 2) - m(mat, 2, 1)*m(mat, 1, 2)) -
+ m(mat, 0, 1) * (m(mat, 1, 0) *m(mat, 2, 2) - m(mat, 1, 2)*m(mat, 2, 0)) +
+ m(mat, 0, 2) * (m(mat, 1, 0) *m(mat, 2, 1) - m(mat, 1, 1)*m(mat, 2, 0));
+ invdet = 1.0 / det;
+ m(out, 0, 0) = (m(mat, 1, 1) * m(mat, 2, 2) - m(mat, 2, 1) * m(mat, 1, 2)) * invdet;
+ m(out, 0, 1) = (m(mat, 0, 2) * m(mat, 2, 1) - m(mat, 0, 1) * m(mat, 2, 2)) * invdet;
+ m(out, 0, 2) = (m(mat, 0, 1) * m(mat, 1, 2) - m(mat, 0, 2) * m(mat, 1, 1)) * invdet;
+ m(out, 1, 0) = (m(mat, 1, 2) * m(mat, 2, 0) - m(mat, 1, 0) * m(mat, 2, 2)) * invdet;
+ m(out, 1, 1) = (m(mat, 0, 0) * m(mat, 2, 2) - m(mat, 0, 2) * m(mat, 2, 0)) * invdet;
+ m(out, 1, 2) = (m(mat, 1, 0) * m(mat, 0, 2) - m(mat, 0, 0) * m(mat, 1, 2)) * invdet;
+ m(out, 2, 0) = (m(mat, 1, 0) * m(mat, 2, 1) - m(mat, 2, 0) * m(mat, 1, 1)) * invdet;
+ m(out, 2, 1) = (m(mat, 2, 0) * m(mat, 0, 1) - m(mat, 0, 0) * m(mat, 2, 1)) * invdet;
+ m(out, 2, 2) = (m(mat, 0, 0) * m(mat, 1, 1) - m(mat, 1, 0) * m(mat, 0, 1)) * invdet;
+}
+
+
+static inline void babl_matrix_mul_vector (const double *mat, const double *v_in, double *v_out)
+{
+ double a = v_in[0], b = v_in[1], c = v_in[2];
+ double m_0_0 = m(mat, 0, 0);
+ double m_0_1 = m(mat, 0, 1);
+ double m_0_2 = m(mat, 0, 2);
+ double m_1_0 = m(mat, 1, 0);
+ double m_1_1 = m(mat, 1, 1);
+ double m_1_2 = m(mat, 1, 2);
+ double m_2_0 = m(mat, 2, 0);
+ double m_2_1 = m(mat, 2, 1);
+ double m_2_2 = m(mat, 2, 2);
+
+ v_out[0] = m_0_0 * a + m_0_1 * b + m_0_2 * c;
+ v_out[1] = m_1_0 * a + m_1_1 * b + m_1_2 * c;
+ v_out[2] = m_2_0 * a + m_2_1 * b + m_2_2 * c;
+}
+
+static inline void babl_matrix_mul_vectorf (const double *mat, const float *v_in, float *v_out)
+{
+ float a = v_in[0], b = v_in[1], c = v_in[2];
+ float m_0_0 = m(mat, 0, 0);
+ float m_0_1 = m(mat, 0, 1);
+ float m_0_2 = m(mat, 0, 2);
+ float m_1_0 = m(mat, 1, 0);
+ float m_1_1 = m(mat, 1, 1);
+ float m_1_2 = m(mat, 1, 2);
+ float m_2_0 = m(mat, 2, 0);
+ float m_2_1 = m(mat, 2, 1);
+ float m_2_2 = m(mat, 2, 2);
+
+ v_out[0] = m_0_0 * a + m_0_1 * b + m_0_2 * c;
+ v_out[1] = m_1_0 * a + m_1_1 * b + m_1_2 * c;
+ v_out[2] = m_2_0 * a + m_2_1 * b + m_2_2 * c;
+}
+
+static inline void babl_matrix_mul_vectorff (const float *mat, const float *v_in, float *v_out)
+{
+ const float a = v_in[0], b = v_in[1], c = v_in[2];
+ const float m_0_0 = m(mat, 0, 0);
+ const float m_0_1 = m(mat, 0, 1);
+ const float m_0_2 = m(mat, 0, 2);
+ const float m_1_0 = m(mat, 1, 0);
+ const float m_1_1 = m(mat, 1, 1);
+ const float m_1_2 = m(mat, 1, 2);
+ const float m_2_0 = m(mat, 2, 0);
+ const float m_2_1 = m(mat, 2, 1);
+ const float m_2_2 = m(mat, 2, 2);
+
+ v_out[0] = m_0_0 * a + m_0_1 * b + m_0_2 * c;
+ v_out[1] = m_1_0 * a + m_1_1 * b + m_1_2 * c;
+ v_out[2] = m_2_0 * a + m_2_1 * b + m_2_2 * c;
+}
+
+static inline void babl_matrix_mul_vectorff_buf3 (const float *mat, const float *v_in, float *v_out,
+ int samples)
+{
+ int i;
+ const float m_0_0 = m(mat, 0, 0);
+ const float m_0_1 = m(mat, 0, 1);
+ const float m_0_2 = m(mat, 0, 2);
+ const float m_1_0 = m(mat, 1, 0);
+ const float m_1_1 = m(mat, 1, 1);
+ const float m_1_2 = m(mat, 1, 2);
+ const float m_2_0 = m(mat, 2, 0);
+ const float m_2_1 = m(mat, 2, 1);
+ const float m_2_2 = m(mat, 2, 2);
+ for (i = 0; i < samples; i ++)
+ {
+ const float a = v_in[0], b = v_in[1], c = v_in[2];
+
+ v_out[0] = m_0_0 * a + m_0_1 * b + m_0_2 * c;
+ v_out[1] = m_1_0 * a + m_1_1 * b + m_1_2 * c;
+ v_out[2] = m_2_0 * a + m_2_1 * b + m_2_2 * c;
+ v_in += 3;
+ v_out += 3;
+ }
+}
+
+static inline void babl_matrix_mul_vectorff_buf4 (const float *mat, const float *v_in, float *v_out,
+ int samples)
+{
+ const float m_0_0 = m(mat, 0, 0);
+ const float m_0_1 = m(mat, 0, 1);
+ const float m_0_2 = m(mat, 0, 2);
+ const float m_1_0 = m(mat, 1, 0);
+ const float m_1_1 = m(mat, 1, 1);
+ const float m_1_2 = m(mat, 1, 2);
+ const float m_2_0 = m(mat, 2, 0);
+ const float m_2_1 = m(mat, 2, 1);
+ const float m_2_2 = m(mat, 2, 2);
+ int i;
+ for (i = 0; i < samples; i ++)
+ {
+ float a = v_in[0], b = v_in[1], c = v_in[2];
+
+ v_out[0] = m_0_0 * a + m_0_1 * b + m_0_2 * c;
+ v_out[1] = m_1_0 * a + m_1_1 * b + m_1_2 * c;
+ v_out[2] = m_2_0 * a + m_2_1 * b + m_2_2 * c;
+ v_out[3] = v_in[3];
+ v_in += 4;
+ v_out += 4;
+ }
+}
+
+static inline void babl_matrix_mul_vector_buf4 (const double *mat, const double *v_in, double *v_out,
+ int samples)
+{
+ int i;
+ const double m_0_0 = m(mat, 0, 0);
+ const double m_0_1 = m(mat, 0, 1);
+ const double m_0_2 = m(mat, 0, 2);
+ const double m_1_0 = m(mat, 1, 0);
+ const double m_1_1 = m(mat, 1, 1);
+ const double m_1_2 = m(mat, 1, 2);
+ const double m_2_0 = m(mat, 2, 0);
+ const double m_2_1 = m(mat, 2, 1);
+ const double m_2_2 = m(mat, 2, 2);
+ for (i = 0; i < samples; i ++)
+ {
+ const double a = v_in[0], b = v_in[1], c = v_in[2];
+
+ v_out[0] = m_0_0 * a + m_0_1 * b + m_0_2 * c;
+ v_out[1] = m_1_0 * a + m_1_1 * b + m_1_2 * c;
+ v_out[2] = m_2_0 * a + m_2_1 * b + m_2_2 * c;
+ v_out[3] = v_in[3];
+ v_in += 4;
+ v_out += 4;
+ }
+}
+
+
+#undef m
+#endif
diff --git a/babl/babl-model.c b/babl/babl-model.c
index 02f3c0b..d553aca 100644
--- a/babl/babl-model.c
+++ b/babl/babl-model.c
@@ -33,7 +33,7 @@ babl_model_destroy (void *data)
Babl *babl = data;
if (babl->model.from_list)
babl_free (babl->model.from_list);
- return 0;
+ return 0;
}
static char *
@@ -53,6 +53,7 @@ babl_model_create_name (int components,
static Babl *
model_new (const char *name,
+ const Babl *space,
int id,
int components,
BablComponent **component)
@@ -69,6 +70,9 @@ model_new (const char *name,
babl->class_type = BABL_MODEL;
babl->instance.id = id;
babl->model.components = components;
+ babl->model.space = space;
+ babl->model.data = NULL;
+ babl->model.model = NULL;
strcpy (babl->instance.name, name);
memcpy (babl->model.component, component, sizeof (BablComponent *) * components);
@@ -77,10 +81,13 @@ model_new (const char *name,
}
static int
-is_model_duplicate (Babl *babl, int components, BablComponent **component)
+is_model_duplicate (Babl *babl, const Babl *space, int components, BablComponent **component)
{
int i;
+ if (babl->model.space != space)
+ return 0;
+
if (babl->model.components != components)
return 0;
@@ -105,6 +112,7 @@ babl_model_new (void *first_argument,
const char *arg = first_argument;
const char *assigned_name = NULL;
char *name = NULL;
+ const Babl *space = babl_space ("sRGB");
BablComponent *component [BABL_MAX_COMPONENTS];
va_start (varg, first_argument);
@@ -143,6 +151,10 @@ babl_model_new (void *first_argument,
babl_log ("submodels not handled yet");
break;
+ case BABL_SPACE:
+ space = bablc;
+ break;
+
case BABL_TYPE:
case BABL_TYPE_INTEGER:
case BABL_TYPE_FLOAT:
@@ -172,7 +184,7 @@ babl_model_new (void *first_argument,
else
{
babl_fatal ("unhandled argument '%s' for babl_model '%s'",
- arg, assigned_name ? assigned_name : "(unnamed)");
+ arg, assigned_name ? assigned_name : "(unnamed)");
}
arg = va_arg (varg, char *);
@@ -199,13 +211,13 @@ babl_model_new (void *first_argument,
if (! babl)
{
- babl = model_new (name, id, components, component);
+ babl = model_new (name, space, id, components, component);
babl_db_insert (db, babl);
construct_double_format (babl);
}
else
{
- if (!is_model_duplicate (babl, components, component))
+ if (!is_model_duplicate (babl, space, components, component))
babl_fatal ("BablModel '%s' already registered "
"with different components!", name);
}
@@ -350,3 +362,50 @@ babl_model_is_symmetric (const Babl *cbabl)
}
BABL_CLASS_IMPLEMENT (model)
+
+/* XXX: probably better to do like with babl_format, add a -suffix and
+ * insert in normal database than to have this static cache list
+ */
+static const Babl *babl_remodels[512]={NULL,};
+int babl_n_remodels = 0;
+
+const Babl *
+babl_remodel_with_space (const Babl *model, const Babl *space)
+{
+ Babl *ret;
+ int i;
+ assert (BABL_IS_BABL (model));
+
+ if (model->model.space == space)
+ return (void*)model;
+
+ assert (BABL_IS_BABL (model));
+
+ /* get back to the sRGB model if we are in a COW clone of it */
+ if (model->model.model)
+ model = (void*)model->model.model;
+
+ assert (BABL_IS_BABL (model));
+
+ for (i = 0; i < babl_n_remodels; i++)
+ {
+ if (babl_remodels[i]->model.model == model &&
+ babl_remodels[i]->model.space == space)
+ return babl_remodels[i];
+ }
+
+ ret = babl_calloc (sizeof (BablModel), 1);
+ memcpy (ret, model, sizeof (BablModel));
+ ret->model.space = space;
+ ret->model.model = (void*)model; /* use the data as a backpointer to original model */
+ return babl_remodels[babl_n_remodels++] = ret;
+ return (Babl*)ret;
+}
+
+const Babl *
+babl_model_with_space (const char *name, const Babl *space)
+{
+ return babl_remodel_with_space (babl_model (name), space);
+}
+
+
diff --git a/babl/babl-model.h b/babl/babl-model.h
index 4561fdb..0862379 100644
--- a/babl/babl-model.h
+++ b/babl/babl-model.h
@@ -23,13 +23,15 @@ BABL_CLASS_DECLARE (model);
typedef struct
{
- BablInstance instance;
+ BablInstance instance;
BablList *from_list;
- int components;
- BablComponent **component;
- BablType **type; /*< must be doubles,
- used here for convenience in code */
- void *data; /* used for palette */
+ int components;
+ BablComponent **component;
+ BablType **type; /*< must be doubles,
+ used here for convenience in code */
+ void *data; /* user-data, used for palette */
+ const Babl *space;
+ void *model; /* back pointer to model with sRGB space */
} BablModel;
#endif
diff --git a/babl/babl-palette.c b/babl/babl-palette.c
index ad90608..823ff0c 100644
--- a/babl/babl-palette.c
+++ b/babl/babl-palette.c
@@ -176,8 +176,9 @@ static BablPalette *default_palette (void)
return &pal;
}
-static long
-rgba_to_pal (char *src,
+static void
+rgba_to_pal (Babl *conversion,
+ char *src,
char *dst,
long n,
void *dst_model_data)
@@ -214,11 +215,11 @@ rgba_to_pal (char *src,
src += sizeof (double) * 4;
dst += sizeof (double) * 1;
}
- return n;
}
-static long
-rgba_to_pala (char *src,
+static void
+rgba_to_pala (Babl *conversion,
+ char *src,
char *dst,
long n,
void *dst_model_data)
@@ -260,11 +261,11 @@ rgba_to_pala (char *src,
src += sizeof (double) * 4;
dst += sizeof (double) * 2;
}
- return n;
}
-static long
-pal_to_rgba (char *src,
+static void
+pal_to_rgba (Babl *conversion,
+ char *src,
char *dst,
long n,
void *src_model_data)
@@ -286,11 +287,11 @@ pal_to_rgba (char *src,
src += sizeof (double) * 1;
dst += sizeof (double) * 4;
}
- return n;
}
-static long
-pala_to_rgba (char *src,
+static void
+pala_to_rgba (Babl *conversion,
+ char *src,
char *dst,
long n,
void *src_model_data)
@@ -316,14 +317,14 @@ pala_to_rgba (char *src,
src += sizeof (double) * 2;
dst += sizeof (double) * 4;
}
- return n;
}
-static long
-rgba_u8_to_pal (unsigned char *src,
+static void
+rgba_u8_to_pal (Babl *conversion,
+ unsigned char *src,
unsigned char *dst,
- long n,
- void *src_model_data)
+ long n,
+ void *src_model_data)
{
BablPalette **palptr = src_model_data;
BablPalette *pal;
@@ -337,15 +338,14 @@ rgba_u8_to_pal (unsigned char *src,
src += sizeof (char) * 4;
dst += sizeof (char) * 1;
}
-
- return n;
}
-static long
-rgba_u8_to_pal_a (char *src,
- char *dst,
- long n,
- void *src_model_data)
+static void
+rgba_u8_to_pal_a (Babl *conversion,
+ unsigned char *src,
+ unsigned char *dst,
+ long n,
+ void *src_model_data)
{
BablPalette **palptr = src_model_data;
BablPalette *pal;
@@ -360,14 +360,14 @@ rgba_u8_to_pal_a (char *src,
src += sizeof (char) * 4;
dst += sizeof (char) * 2;
}
- return n;
}
static long
-pal_u8_to_rgba_u8 (char *src,
- char *dst,
- long n,
- void *src_model_data)
+pal_u8_to_rgba_u8 (Babl *conversion,
+ unsigned char *src,
+ unsigned char *dst,
+ long n,
+ void *src_model_data)
{
BablPalette **palptr = src_model_data;
BablPalette *pal;
@@ -376,13 +376,13 @@ pal_u8_to_rgba_u8 (char *src,
assert(pal);
while (n--)
{
- int idx = (((unsigned char *) src)[0]);
+ int idx = src[0];
unsigned char *palpx;
if (idx < 0) idx = 0;
if (idx >= pal->count) idx = pal->count-1;
- palpx = ((unsigned char*)pal->data_u8) + idx * 4;
+ palpx = pal->data_u8 + idx * 4;
memcpy (dst, palpx, sizeof(char)*4);
src += sizeof (char) * 1;
@@ -392,10 +392,11 @@ pal_u8_to_rgba_u8 (char *src,
}
static long
-pala_u8_to_rgba_u8 (char *src,
- char *dst,
- long n,
- void *src_model_data)
+pala_u8_to_rgba_u8 (Babl *conversion,
+ unsigned char *src,
+ unsigned char *dst,
+ long n,
+ void *src_model_data)
{
BablPalette **palptr = src_model_data;
BablPalette *pal;
@@ -404,15 +405,15 @@ pala_u8_to_rgba_u8 (char *src,
assert(pal);
while (n--)
{
- int idx = (((unsigned char *) src)[0]);
+ int idx = src[0];
unsigned char *palpx;
if (idx < 0) idx = 0;
if (idx >= pal->count) idx = pal->count-1;
- palpx = ((unsigned char*)pal->data_u8) + idx * 4;
+ palpx = pal->data_u8 + idx * 4;
memcpy (dst, palpx, sizeof(char)*4);
- dst[3] = (dst[3] * src[1]) >> 8;
+ dst[3] = (dst[3] * src[1] + 128) / 255;
src += sizeof (char) * 2;
dst += sizeof (char) * 4;
@@ -424,7 +425,8 @@ pala_u8_to_rgba_u8 (char *src,
#include "base/util.h"
static inline long
-conv_pal8_pala8 (unsigned char *src, unsigned char *dst, long samples)
+conv_pal8_pala8 (Babl *conversion,
+ unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -439,7 +441,8 @@ conv_pal8_pala8 (unsigned char *src, unsigned char *dst, long samples)
}
static inline long
-conv_pala8_pal8 (unsigned char *src, unsigned char *dst, long samples)
+conv_pala8_pal8 (Babl *conversion,
+ unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
diff --git a/babl/babl-polynomial.c b/babl/babl-polynomial.c
new file mode 100644
index 0000000..d27c1bb
--- /dev/null
+++ b/babl/babl-polynomial.c
@@ -0,0 +1,541 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2017, Øyvind Kolås and others.
+ *
+ * babl-polynomial.c
+ * Copyright (C) 2017 Ell
+ *
+ * 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
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef BABL_POLYNOMIAL_DEGREE
+
+BABL_POLYNOMIAL_DEGREE ( 0, __)
+BABL_POLYNOMIAL_DEGREE ( 1, 0)
+BABL_POLYNOMIAL_DEGREE ( 2, 1)
+BABL_POLYNOMIAL_DEGREE ( 3, 2)
+BABL_POLYNOMIAL_DEGREE ( 4, 3)
+BABL_POLYNOMIAL_DEGREE ( 5, 4)
+BABL_POLYNOMIAL_DEGREE ( 6, 5)
+BABL_POLYNOMIAL_DEGREE ( 7, 6)
+BABL_POLYNOMIAL_DEGREE ( 8, 7)
+BABL_POLYNOMIAL_DEGREE ( 9, 8)
+BABL_POLYNOMIAL_DEGREE (10, 9)
+BABL_POLYNOMIAL_DEGREE (11, 10)
+BABL_POLYNOMIAL_DEGREE (12, 11)
+BABL_POLYNOMIAL_DEGREE (13, 12)
+BABL_POLYNOMIAL_DEGREE (14, 13)
+BABL_POLYNOMIAL_DEGREE (15, 14)
+BABL_POLYNOMIAL_DEGREE (16, 15)
+BABL_POLYNOMIAL_DEGREE (17, 16)
+BABL_POLYNOMIAL_DEGREE (18, 17)
+BABL_POLYNOMIAL_DEGREE (19, 18)
+BABL_POLYNOMIAL_DEGREE (20, 19)
+BABL_POLYNOMIAL_DEGREE (21, 20)
+BABL_POLYNOMIAL_DEGREE (22, 21)
+
+#undef BABL_POLYNOMIAL_DEGREE
+
+#else
+
+#include "config.h"
+#include <string.h>
+#include <math.h>
+#include "babl-internal.h"
+
+
+#define BABL_BIG_POLYNOMIAL_MAX_DEGREE (2 * BABL_POLYNOMIAL_MAX_DEGREE + BABL_POLYNOMIAL_MAX_SCALE)
+#define EPSILON 1e-10
+
+
+typedef struct
+{
+ BablPolynomialEvalFunc eval;
+ int degree;
+ int scale;
+ double coeff[BABL_BIG_POLYNOMIAL_MAX_DEGREE + 1];
+} BablBigPolynomial;
+
+
+#define BABL_POLYNOMIAL_EVAL___(poly, x) 0.0
+#define BABL_POLYNOMIAL_EVAL_0(poly, x) ( (poly)->coeff[0])
+#define BABL_POLYNOMIAL_EVAL_1(poly, x) ( (poly)->coeff[1])
+#define BABL_POLYNOMIAL_EVAL_2(poly, x) (BABL_POLYNOMIAL_EVAL_0 (poly, x) * (x) + (poly)->coeff[2])
+#define BABL_POLYNOMIAL_EVAL_3(poly, x) (BABL_POLYNOMIAL_EVAL_1 (poly, x) * (x) + (poly)->coeff[3])
+#define BABL_POLYNOMIAL_EVAL_4(poly, x) (BABL_POLYNOMIAL_EVAL_2 (poly, x) * (x) + (poly)->coeff[4])
+#define BABL_POLYNOMIAL_EVAL_5(poly, x) (BABL_POLYNOMIAL_EVAL_3 (poly, x) * (x) + (poly)->coeff[5])
+#define BABL_POLYNOMIAL_EVAL_6(poly, x) (BABL_POLYNOMIAL_EVAL_4 (poly, x) * (x) + (poly)->coeff[6])
+#define BABL_POLYNOMIAL_EVAL_7(poly, x) (BABL_POLYNOMIAL_EVAL_5 (poly, x) * (x) + (poly)->coeff[7])
+#define BABL_POLYNOMIAL_EVAL_8(poly, x) (BABL_POLYNOMIAL_EVAL_6 (poly, x) * (x) + (poly)->coeff[8])
+#define BABL_POLYNOMIAL_EVAL_9(poly, x) (BABL_POLYNOMIAL_EVAL_7 (poly, x) * (x) + (poly)->coeff[9])
+#define BABL_POLYNOMIAL_EVAL_10(poly, x) (BABL_POLYNOMIAL_EVAL_8 (poly, x) * (x) + (poly)->coeff[10])
+#define BABL_POLYNOMIAL_EVAL_11(poly, x) (BABL_POLYNOMIAL_EVAL_9 (poly, x) * (x) + (poly)->coeff[11])
+#define BABL_POLYNOMIAL_EVAL_12(poly, x) (BABL_POLYNOMIAL_EVAL_10 (poly, x) * (x) + (poly)->coeff[12])
+#define BABL_POLYNOMIAL_EVAL_13(poly, x) (BABL_POLYNOMIAL_EVAL_11 (poly, x) * (x) + (poly)->coeff[13])
+#define BABL_POLYNOMIAL_EVAL_14(poly, x) (BABL_POLYNOMIAL_EVAL_12 (poly, x) * (x) + (poly)->coeff[14])
+#define BABL_POLYNOMIAL_EVAL_15(poly, x) (BABL_POLYNOMIAL_EVAL_13 (poly, x) * (x) + (poly)->coeff[15])
+#define BABL_POLYNOMIAL_EVAL_16(poly, x) (BABL_POLYNOMIAL_EVAL_14 (poly, x) * (x) + (poly)->coeff[16])
+#define BABL_POLYNOMIAL_EVAL_17(poly, x) (BABL_POLYNOMIAL_EVAL_15 (poly, x) * (x) + (poly)->coeff[17])
+#define BABL_POLYNOMIAL_EVAL_18(poly, x) (BABL_POLYNOMIAL_EVAL_16 (poly, x) * (x) + (poly)->coeff[18])
+#define BABL_POLYNOMIAL_EVAL_19(poly, x) (BABL_POLYNOMIAL_EVAL_17 (poly, x) * (x) + (poly)->coeff[19])
+#define BABL_POLYNOMIAL_EVAL_20(poly, x) (BABL_POLYNOMIAL_EVAL_18 (poly, x) * (x) + (poly)->coeff[20])
+#define BABL_POLYNOMIAL_EVAL_21(poly, x) (BABL_POLYNOMIAL_EVAL_19 (poly, x) * (x) + (poly)->coeff[21])
+#define BABL_POLYNOMIAL_EVAL_22(poly, x) (BABL_POLYNOMIAL_EVAL_20 (poly, x) * (x) + (poly)->coeff[22])
+
+#define BABL_POLYNOMIAL_DEGREE(i, i_1) \
+ static double \
+ babl_polynomial_eval_1_##i (const BablPolynomial *poly, \
+ double x) \
+ { \
+ /* quiet clang warnings */ \
+ const BablBigPolynomial *const big_poly = (const BablBigPolynomial *) poly;\
+ \
+ const double x2 = x * x; \
+ (void) x2; \
+ \
+ return BABL_POLYNOMIAL_EVAL_##i (big_poly, x2) + \
+ BABL_POLYNOMIAL_EVAL_##i_1 (big_poly, x2) * x; \
+ }
+#include "babl-polynomial.c"
+
+#define BABL_POLYNOMIAL_DEGREE(i, i_1) \
+ static double \
+ babl_polynomial_eval_2_##i (const BablPolynomial *poly, \
+ double x) \
+ { \
+ /* quiet clang warnings */ \
+ const BablBigPolynomial *const big_poly = (const BablBigPolynomial *) poly;\
+ \
+ return BABL_POLYNOMIAL_EVAL_##i (big_poly, x) + \
+ BABL_POLYNOMIAL_EVAL_##i_1 (big_poly, x) * sqrt (x); \
+ }
+#include "babl-polynomial.c"
+
+static const BablPolynomialEvalFunc babl_polynomial_eval_funcs[BABL_POLYNOMIAL_MAX_SCALE]
+ [BABL_BIG_POLYNOMIAL_MAX_DEGREE + 1] =
+{
+ {
+ #define BABL_POLYNOMIAL_DEGREE(i, i_1) babl_polynomial_eval_1_##i,
+ #include "babl-polynomial.c"
+ },
+ {
+ #define BABL_POLYNOMIAL_DEGREE(i, i_1) babl_polynomial_eval_2_##i,
+ #include "babl-polynomial.c"
+ }
+};
+
+
+static void
+babl_polynomial_set_degree (BablPolynomial *poly,
+ int degree,
+ int scale)
+{
+ babl_assert (degree >= BABL_POLYNOMIAL_MIN_DEGREE &&
+ degree <= BABL_BIG_POLYNOMIAL_MAX_DEGREE);
+ babl_assert (scale >= BABL_POLYNOMIAL_MIN_SCALE &&
+ scale <= BABL_POLYNOMIAL_MAX_SCALE);
+
+ poly->eval = babl_polynomial_eval_funcs[scale - 1][degree];
+ poly->degree = degree;
+ poly->scale = scale;
+}
+
+static double
+babl_polynomial_get (const BablPolynomial *poly,
+ int i)
+
+{
+ return poly->coeff[poly->degree - i];
+}
+
+static void
+babl_polynomial_set (BablPolynomial *poly,
+ int i,
+ double c)
+
+{
+ poly->coeff[poly->degree - i] = c;
+}
+
+static void
+babl_polynomial_copy (BablPolynomial *poly,
+ const BablPolynomial *rpoly)
+{
+ poly->eval = rpoly->eval;
+ poly->degree = rpoly->degree;
+ poly->scale = rpoly->scale;
+ memcpy (poly->coeff, rpoly->coeff, (rpoly->degree + 1) * sizeof (double));
+}
+
+static void
+babl_polynomial_reset (BablPolynomial *poly,
+ int scale)
+{
+ babl_polynomial_set_degree (poly, 0, scale);
+ babl_polynomial_set (poly, 0, 0.0);
+}
+
+static void
+babl_polynomial_shrink (BablPolynomial *poly)
+{
+ int i;
+
+ for (i = 0; i <= poly->degree; i++)
+ {
+ if (fabs (poly->coeff[i]) > EPSILON)
+ break;
+ }
+
+ if (i == poly->degree + 1)
+ {
+ babl_polynomial_reset (poly, poly->scale);
+ }
+ else if (i > 0)
+ {
+ memmove (poly->coeff, &poly->coeff[i],
+ (poly->degree - i + 1) * sizeof (double));
+
+ babl_polynomial_set_degree (poly, poly->degree - i, poly->scale);
+ }
+}
+
+static void
+babl_polynomial_add (BablPolynomial *poly,
+ const BablPolynomial *rpoly)
+{
+ int i;
+
+ babl_assert (poly->scale == rpoly->scale);
+
+ if (poly->degree >= rpoly->degree)
+ {
+ for (i = 0; i <= rpoly->degree; i++)
+ {
+ babl_polynomial_set (poly, i, babl_polynomial_get (poly, i) +
+ babl_polynomial_get (rpoly, i));
+ }
+ }
+ else
+ {
+ int orig_degree = poly->degree;
+
+ babl_polynomial_set_degree (poly, rpoly->degree, poly->scale);
+
+ for (i = 0; i <= orig_degree; i++)
+ {
+ babl_polynomial_set (poly, i, poly->coeff[orig_degree - i] +
+ babl_polynomial_get (rpoly, i));
+ }
+
+ for (; i <= rpoly->degree; i++)
+ babl_polynomial_set (poly, i, babl_polynomial_get (rpoly, i));
+ }
+}
+
+static void
+babl_polynomial_sub (BablPolynomial *poly,
+ const BablPolynomial *rpoly)
+{
+ int i;
+
+ babl_assert (poly->scale == rpoly->scale);
+
+ if (poly->degree >= rpoly->degree)
+ {
+ for (i = 0; i <= rpoly->degree; i++)
+ {
+ babl_polynomial_set (poly, i, babl_polynomial_get (poly, i) -
+ babl_polynomial_get (rpoly, i));
+ }
+ }
+ else
+ {
+ int orig_degree = poly->degree;
+
+ babl_polynomial_set_degree (poly, rpoly->degree, poly->scale);
+
+ for (i = 0; i <= orig_degree; i++)
+ {
+ babl_polynomial_set (poly, i, poly->coeff[orig_degree - i] -
+ babl_polynomial_get (rpoly, i));
+ }
+
+ for (; i <= rpoly->degree; i++)
+ babl_polynomial_set (poly, i, -babl_polynomial_get (rpoly, i));
+ }
+}
+
+static void
+babl_polynomial_scalar_mul (BablPolynomial *poly,
+ double a)
+{
+ int i;
+
+ for (i = 0; i <= poly->degree; i++)
+ poly->coeff[i] *= a;
+}
+
+static void
+babl_polynomial_scalar_div (BablPolynomial *poly,
+ double a)
+{
+ int i;
+
+ for (i = 0; i <= poly->degree; i++)
+ poly->coeff[i] /= a;
+}
+
+static void
+babl_polynomial_mul_copy (BablPolynomial *poly,
+ const BablPolynomial *poly1,
+ const BablPolynomial *poly2)
+{
+ int i;
+ int j;
+
+ babl_assert (poly1->scale == poly2->scale);
+
+ babl_polynomial_set_degree (poly, poly1->degree + poly2->degree, poly1->scale);
+
+ memset (poly->coeff, 0, (poly->degree + 1) * sizeof (double));
+
+ for (i = poly1->degree; i >= 0; i--)
+ {
+ for (j = poly2->degree; j >= 0; j--)
+ {
+ babl_polynomial_set (poly, i + j, babl_polynomial_get (poly, i + j) +
+ babl_polynomial_get (poly1, i) *
+ babl_polynomial_get (poly2, j));
+ }
+ }
+}
+
+static void
+babl_polynomial_integrate (BablPolynomial *poly)
+{
+ int i;
+
+ babl_polynomial_set_degree (poly, poly->degree + poly->scale, poly->scale);
+
+ for (i = 0; i <= poly->degree - poly->scale; i++)
+ {
+ poly->coeff[i] *= poly->scale;
+ poly->coeff[i] /= poly->degree - i;
+ }
+
+ for (; i <= poly->degree; i++)
+ poly->coeff[i] = 0.0;
+}
+
+static void
+babl_polynomial_gamma_integrate (BablPolynomial *poly,
+ double gamma)
+{
+ int i;
+
+ babl_polynomial_set_degree (poly, poly->degree + poly->scale, poly->scale);
+
+ gamma *= poly->scale;
+
+ for (i = 0; i <= poly->degree - poly->scale; i++)
+ {
+ poly->coeff[i] *= poly->scale;
+ poly->coeff[i] /= poly->degree - i + gamma;
+ }
+
+ for (; i <= poly->degree; i++)
+ poly->coeff[i] = 0.0;
+}
+
+static double
+babl_polynomial_inner_product (const BablPolynomial *poly1,
+ const BablPolynomial *poly2,
+ double x0,
+ double x1)
+{
+ BablBigPolynomial temp;
+
+ babl_polynomial_mul_copy ((BablPolynomial *) &temp, poly1, poly2);
+ babl_polynomial_integrate ((BablPolynomial *) &temp);
+
+ return babl_polynomial_eval ((BablPolynomial *) &temp, x1) -
+ babl_polynomial_eval ((BablPolynomial *) &temp, x0);
+}
+
+static double
+babl_polynomial_gamma_inner_product (const BablPolynomial *poly,
+ double gamma,
+ double x0,
+ double x1)
+{
+ BablBigPolynomial temp;
+
+ babl_polynomial_copy ((BablPolynomial *) &temp, poly);
+ babl_polynomial_gamma_integrate ((BablPolynomial *) &temp, gamma);
+
+ return babl_polynomial_eval ((BablPolynomial *) &temp, x1) * pow (x1, gamma) -
+ babl_polynomial_eval ((BablPolynomial *) &temp, x0) * pow (x0, gamma);
+}
+
+static double
+babl_polynomial_norm (const BablPolynomial *poly,
+ double x0,
+ double x1)
+{
+ return sqrt (babl_polynomial_inner_product (poly, poly, x0, x1));
+}
+
+static void
+babl_polynomial_normalize (BablPolynomial *poly,
+ double x0,
+ double x1)
+{
+ double norm;
+
+ norm = babl_polynomial_norm (poly, x0, x1);
+
+ if (norm > EPSILON)
+ babl_polynomial_scalar_div (poly, norm);
+}
+
+static void
+babl_polynomial_project_copy (BablPolynomial *poly,
+ const BablPolynomial *rpoly,
+ const BablPolynomial *basis,
+ int basis_n,
+ double x0,
+ double x1)
+{
+ int i;
+
+ babl_assert (basis_n > 0);
+
+ babl_polynomial_reset (poly, basis[0].scale);
+
+ for (i = 0; i < basis_n; i++)
+ {
+ BablPolynomial temp;
+
+ babl_polynomial_copy (&temp, &basis[i]);
+ babl_polynomial_scalar_mul (&temp,
+ babl_polynomial_inner_product (&temp, rpoly,
+ x0, x1));
+ babl_polynomial_add (poly, &temp);
+ }
+}
+
+static void
+babl_polynomial_gamma_project_copy (BablPolynomial *poly,
+ double gamma,
+ const BablPolynomial *basis,
+ int basis_n,
+ double x0,
+ double x1)
+{
+ int i;
+
+ babl_assert (basis_n > 0);
+
+ babl_polynomial_reset (poly, basis[0].scale);
+
+ for (i = 0; i < basis_n; i++)
+ {
+ BablPolynomial temp;
+
+ babl_polynomial_copy (&temp, &basis[i]);
+ babl_polynomial_scalar_mul (&temp,
+ babl_polynomial_gamma_inner_product (&temp,
+ gamma,
+ x0, x1));
+ babl_polynomial_add (poly, &temp);
+ }
+}
+
+static void
+babl_polynomial_gram_schmidt (BablPolynomial *basis,
+ int basis_n,
+ double x0,
+ double x1)
+{
+ int i;
+
+ for (i = 0; i < basis_n; i++)
+ {
+ if (i > 0)
+ {
+ BablPolynomial temp;
+
+ babl_polynomial_project_copy (&temp, &basis[i], basis, i, x0, x1);
+ babl_polynomial_sub (&basis[i], &temp);
+ }
+
+ babl_polynomial_normalize (&basis[i], x0, x1);
+ }
+}
+
+static void
+babl_polynomial_basis (BablPolynomial *basis,
+ int basis_n,
+ int scale)
+{
+ int i;
+
+ for (i = 0; i < basis_n; i++)
+ {
+ babl_polynomial_set_degree (&basis[i], i, scale);
+
+ basis[i].coeff[0] = 1.0;
+ memset (&basis[i].coeff[1], 0, i * sizeof (double));
+ }
+}
+
+static void
+babl_polynomial_orthonormal_basis (BablPolynomial *basis,
+ int basis_n,
+ double x0,
+ double x1,
+ int scale)
+{
+ babl_polynomial_basis (basis, basis_n, scale);
+ babl_polynomial_gram_schmidt (basis, basis_n, x0, x1);
+}
+
+void
+babl_polynomial_approximate_gamma (BablPolynomial *poly,
+ double gamma,
+ double x0,
+ double x1,
+ int degree,
+ int scale)
+{
+ BablPolynomial *basis;
+
+ babl_assert (poly != NULL);
+ babl_assert (gamma >= 0.0);
+ babl_assert (x0 >= 0.0);
+ babl_assert (x0 < x1);
+ babl_assert (degree >= BABL_POLYNOMIAL_MIN_DEGREE &&
+ degree <= BABL_POLYNOMIAL_MAX_DEGREE);
+ babl_assert (scale >= BABL_POLYNOMIAL_MIN_SCALE &&
+ scale <= BABL_POLYNOMIAL_MAX_SCALE);
+
+ basis = alloca ((degree + 1) * sizeof (BablPolynomial));
+
+ babl_polynomial_orthonormal_basis (basis, degree + 1, x0, x1, scale);
+
+ babl_polynomial_gamma_project_copy (poly, gamma, basis, degree + 1, x0, x1);
+ babl_polynomial_shrink (poly);
+}
+
+#endif
diff --git a/babl/babl-polynomial.h b/babl/babl-polynomial.h
new file mode 100644
index 0000000..d883542
--- /dev/null
+++ b/babl/babl-polynomial.h
@@ -0,0 +1,79 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2017, Øyvind Kolås and others.
+ *
+ * babl-polynomial.h
+ * Copyright (C) 2017 Ell
+ *
+ * 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
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _BABL_POLYNOMIAL_H
+#define _BABL_POLYNOMIAL_H
+
+
+/* BablPolynomial is an opaque type representing a real polynomial of a real
+ * variable. In addition to a degree, polynomials have an associated *scale*,
+ * which divides the exponents of the polynomial's terms. For example, a
+ * polynomial of degree 3 and of scale 1 has the form
+ * `c0*x^0 + c1*x^1 + c2*x^2 + c3*x^3`, while a polynomial of degree 3 and of
+ * scale 2 has the form `c0*x^0 + c1*x^0.5 + c2*x^1 + c3*x^1.5`.
+ */
+
+
+#define BABL_POLYNOMIAL_MIN_DEGREE 0
+#define BABL_POLYNOMIAL_MAX_DEGREE 10
+
+#define BABL_POLYNOMIAL_MIN_SCALE 1
+#define BABL_POLYNOMIAL_MAX_SCALE 2
+
+
+typedef struct BablPolynomial BablPolynomial;
+
+typedef double (* BablPolynomialEvalFunc) (const BablPolynomial *poly,
+ double x);
+
+
+struct BablPolynomial
+{
+ BablPolynomialEvalFunc eval;
+ int degree;
+ int scale;
+ double coeff[BABL_POLYNOMIAL_MAX_DEGREE + 1];
+};
+
+
+/* evaluates `poly` at `x`. */
+static inline double
+babl_polynomial_eval (const BablPolynomial *poly,
+ double x)
+{
+ return poly->eval (poly, x);
+}
+
+
+/* calculates the polynomial of maximal degree `degree` and of scale `scale`,
+ * that minimizes the total error w.r.t. the gamma function `gamma`, over the
+ * range `[x0, x1]`.
+ */
+void
+babl_polynomial_approximate_gamma (BablPolynomial *poly,
+ double gamma,
+ double x0,
+ double x1,
+ int degree,
+ int scale);
+
+
+#endif
diff --git a/babl/babl-space.c b/babl/babl-space.c
new file mode 100644
index 0000000..adc9e7a
--- /dev/null
+++ b/babl/babl-space.c
@@ -0,0 +1,988 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2017 Øyvind Kolås.
+ *
+ * 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
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#define MAX_SPACES 100
+
+#include "config.h"
+#include "babl-internal.h"
+#include "base/util.h"
+
+static BablSpace space_db[MAX_SPACES];
+
+static void babl_chromatic_adaptation_matrix (const double *whitepoint,
+ const double *target_whitepoint,
+ double *chad_matrix)
+{
+ double bradford[9]={ 0.8951000, 0.2664000, -0.1614000,
+ -0.7502000, 1.7135000, 0.0367000,
+ 0.0389000, -0.0685000, 1.0296000};
+ double bradford_inv[9]={0.9869929,-0.1470543, 0.1599627,
+ 0.4323053, 0.5183603, 0.0492912,
+ -0.0085287, 0.0400428, 0.9684867};
+
+ double vec_a[3];
+ double vec_b[3];
+
+ babl_matrix_mul_vector (bradford, whitepoint, vec_a);
+ babl_matrix_mul_vector (bradford, target_whitepoint, vec_b);
+
+ memset (chad_matrix, 0, sizeof (double) * 9);
+
+ chad_matrix[0] = vec_b[0] / vec_a[0];
+ chad_matrix[4] = vec_b[1] / vec_a[1];
+ chad_matrix[8] = vec_b[2] / vec_a[2];
+
+ babl_matrix_mul_matrix (bradford_inv, chad_matrix, chad_matrix);
+ babl_matrix_mul_matrix (chad_matrix, bradford, chad_matrix);
+}
+
+#define LAB_EPSILON (216.0f / 24389.0f)
+#define LAB_KAPPA (24389.0f / 27.0f)
+
+#if 1
+#define D50_WHITE_REF_X 0.964202880f
+#define D50_WHITE_REF_Y 1.000000000f
+#define D50_WHITE_REF_Z 0.824905400f
+#else
+#define D50_WHITE_REF_X 0.964200000f
+#define D50_WHITE_REF_Y 1.000000000f
+#define D50_WHITE_REF_Z 0.824900000f
+#endif
+
+static inline void
+XYZ_to_LAB (double X,
+ double Y,
+ double Z,
+ double *to_L,
+ double *to_a,
+ double *to_b)
+{
+ double f_x, f_y, f_z;
+
+ double x_r = X / D50_WHITE_REF_X;
+ double y_r = Y / D50_WHITE_REF_Y;
+ double z_r = Z / D50_WHITE_REF_Z;
+
+ if (x_r > LAB_EPSILON) f_x = pow(x_r, 1.0 / 3.0);
+ else ( f_x = ((LAB_KAPPA * x_r) + 16) / 116.0 );
+
+ if (y_r > LAB_EPSILON) f_y = pow(y_r, 1.0 / 3.0);
+ else ( f_y = ((LAB_KAPPA * y_r) + 16) / 116.0 );
+
+ if (z_r > LAB_EPSILON) f_z = pow(z_r, 1.0 / 3.0);
+ else ( f_z = ((LAB_KAPPA * z_r) + 16) / 116.0 );
+
+ *to_L = (116.0 * f_y) - 16.0;
+ *to_a = 500.0 * (f_x - f_y);
+ *to_b = 200.0 * (f_y - f_z);
+}
+
+/* round all values to s15f16 precision and brute-force
+ * jitter +/- 1 all entries for best uniform gray axis - this
+ * also optimizes the accuracy of the matrix for floating point
+ * computations.
+ *
+ * the inverse matrix should be equalized against the original
+ * matrix looking for the bit-exact inverse of this integer-solution.
+ *
+ */
+static void babl_matrix_equalize (double *in_mat)
+{
+ double mat[9];
+ int j[9];
+ int best_j[9];
+ double in[12] = {1.0, 1.0, 1.0, // white
+ 0.0, 0.0, 0.0, // black
+ 0.5, 0.5, 0.5, // gray
+ 0.33, 0.33, 0.33}; // grey
+ double out[12] = {};
+ double lab[12] = {};
+ double best_error = 1000000.0;
+ int i;
+
+ for (i = 0; i < 9; i++)
+ best_j[i] = 0;
+
+ for (j[0] = -1; j[0] <= 1; j[0]++)
+ for (j[1] = -1; j[1] <= 1; j[1]++)
+ for (j[2] = -1; j[2] <= 1; j[2]++)
+ for (j[3] = -1; j[3] <= 1; j[3]++)
+ for (j[4] = -1; j[4] <= 1; j[4]++)
+ for (j[5] = -1; j[5] <= 1; j[5]++)
+ for (j[6] = -1; j[6] <= 1; j[6]++)
+ for (j[7] = -1; j[7] <= 1; j[7]++)
+ for (j[8] = -1; j[8] <= 1; j[8]++)
+ {
+ double error = 0;
+
+ for (i = 0; i < 9; i++)
+ {
+ int32_t val = in_mat[i] * 65536.0 + 0.5f;
+ mat[i] = val / 65536.0 + j[i] / 65536.0;
+ }
+ for (i = 0; i < 4; i++)
+ {
+ babl_matrix_mul_vector (mat, &in[i*3], &out[i*3]);
+ }
+ for (i = 0; i < 4; i++)
+ {
+ XYZ_to_LAB (out[i*3+0], out[i*3+1], out[i*3+2],
+ &lab[i*3+0], &lab[i*3+1], &lab[i*3+2]);
+ }
+#define square(a) ((a)*(a))
+ error += square (lab[0*3+0]-100.0f); // L white = 100.0
+ error += square (lab[1*3+0]-0.0f); // L black = 0.0
+
+ for (i = 0; i < 4; i++)
+ {
+ error += square (lab[i*3+1]); // a = 0.0
+ error += square (lab[i*3+2]); // b = 0.0
+ }
+#undef square
+ if (error <= best_error)
+ {
+ best_error = error;
+ memcpy (&best_j[0], &j[0], sizeof (best_j));
+ }
+ }
+ for (i = 0; i < 9; i++)
+ {
+ int32_t val = in_mat[i] * 65536.0 + 0.5f;
+ in_mat[i] = val / 65536.0 + best_j[i] / 65536.0;
+ }
+}
+
+static void babl_space_compute_matrices (BablSpace *space)
+{
+#define _ space->
+ /* transform spaces xy(Y) specified data to XYZ */
+ double red_XYZ[3] = { _ xr / _ yr, 1.0, ( 1.0 - _ xr - _ yr) / _ yr};
+ double green_XYZ[3] = { _ xg / _ yg, 1.0, ( 1.0 - _ xg - _ yg) / _ yg};
+ double blue_XYZ[3] = { _ xb / _ yb, 1.0, ( 1.0 - _ xb - _ yb) / _ yb};
+ double whitepoint_XYZ[3] = { _ xw / _ yw, 1.0, ( 1.0 - _ xw - _ yw) / _ yw};
+ double D50_XYZ[3] = {0.96420288, 1.0, 0.82490540};
+#undef _
+
+ double mat[9] = {red_XYZ[0], green_XYZ[0], blue_XYZ[0],
+ red_XYZ[1], green_XYZ[1], blue_XYZ[1],
+ red_XYZ[2], green_XYZ[2], blue_XYZ[2]};
+ double inv_mat[9];
+ double S[3];
+ double chad[9];
+
+ babl_matrix_invert (mat, inv_mat);
+ babl_matrix_mul_vector (inv_mat, whitepoint_XYZ, S);
+
+ mat[0] *= S[0]; mat[1] *= S[1]; mat[2] *= S[2];
+ mat[3] *= S[0]; mat[4] *= S[1]; mat[5] *= S[2];
+ mat[6] *= S[0]; mat[7] *= S[1]; mat[8] *= S[2];
+
+ babl_chromatic_adaptation_matrix (whitepoint_XYZ, D50_XYZ, chad);
+
+ babl_matrix_mul_matrix (chad, mat, mat);
+
+ babl_matrix_equalize (mat);
+
+ memcpy (space->RGBtoXYZ, mat, sizeof (mat));
+
+ babl_matrix_invert (mat, inv_mat);
+
+ memcpy (space->XYZtoRGB, inv_mat, sizeof (mat));
+
+ babl_matrix_to_float (space->RGBtoXYZ, space->RGBtoXYZf);
+ babl_matrix_to_float (space->XYZtoRGB, space->XYZtoRGBf);
+}
+
+const Babl *
+babl_space (const char *name)
+{
+ int i;
+ for (i = 0; space_db[i].instance.class_type; i++)
+ if (!strcmp (space_db[i].instance.name, name))
+ return (Babl*)&space_db[i];
+ return NULL;
+}
+
+const Babl *
+babl_space_from_rgbxyz_matrix (const char *name,
+ double wx, double wy, double wz,
+ double rx, double gx, double bx,
+ double ry, double gy, double by,
+ double rz, double gz, double bz,
+ const Babl *trc_red,
+ const Babl *trc_green,
+ const Babl *trc_blue)
+{
+ int i=0;
+ static BablSpace space;
+ space.instance.class_type = BABL_SPACE;
+ space.instance.id = 0;
+ space.xr = rx;
+ space.yr = gx;
+ space.xg = bx;
+ space.yg = ry;
+ space.xb = gy;
+ space.yb = by;
+ space.xw = rz;
+ space.yw = gz;
+ space.pad = bz;
+
+ space.whitepoint[0] = wx;
+ space.whitepoint[1] = wy;
+ space.whitepoint[2] = wz;
+
+ space.trc[0] = trc_red;
+ space.trc[1] = trc_green?trc_green:trc_red;
+ space.trc[2] = trc_blue?trc_blue:trc_red;
+
+ for (i = 0; space_db[i].instance.class_type; i++)
+ {
+ int offset = ((char*)&space_db[i].xr) - (char*)(&space_db[i]);
+ int size = ((char*)&space_db[i].trc) + sizeof(space_db[i].trc) - ((char*)&space_db[i].xr);
+
+ if (memcmp ((char*)(&space_db[i]) + offset, ((char*)&space) + offset, size)==0)
+ {
+ return (void*)&space_db[i];
+ }
+ }
+ if (i >= MAX_SPACES-1)
+ {
+ babl_log ("too many BablSpaces");
+ return NULL;
+ }
+ /* transplant matrixes */
+ //babl_space_compute_matrices (&space_db[i]);
+ space.RGBtoXYZ[0] = rx;
+ space.RGBtoXYZ[1] = gx;
+ space.RGBtoXYZ[2] = bx;
+ space.RGBtoXYZ[3] = ry;
+ space.RGBtoXYZ[4] = gy;
+ space.RGBtoXYZ[5] = by;
+ space.RGBtoXYZ[6] = rz;
+ space.RGBtoXYZ[7] = gz;
+ space.RGBtoXYZ[8] = bz;
+
+ babl_matrix_invert (space.RGBtoXYZ, space.XYZtoRGB);
+
+ babl_matrix_to_float (space.RGBtoXYZ, space.RGBtoXYZf);
+ babl_matrix_to_float (space.XYZtoRGB, space.XYZtoRGBf);
+
+ space_db[i]=space;
+ space_db[i].instance.name = space_db[i].name;
+ if (name)
+ sprintf (space_db[i].name, "%s", name);
+ else
+ sprintf (space_db[i].name, "space-%.4f,%.4f_%.4f,%.4f_%.4f_%.4f,%.4f_%.4f,%.4f_%s,%s,%s",
+ rx, gx, bx,
+ ry, gy, by,
+ rz, gz, bz,
+ babl_get_name (space.trc[0]),
+ babl_get_name(space.trc[1]), babl_get_name(space.trc[2]));
+
+
+ return (Babl*)&space_db[i];
+}
+
+
+const Babl *
+babl_space_from_chromaticities (const char *name,
+ double wx, double wy,
+ double rx, double ry,
+ double gx, double gy,
+ double bx, double by,
+ const Babl *trc_red,
+ const Babl *trc_green,
+ const Babl *trc_blue)
+{
+ int i=0;
+ static BablSpace space;
+ space.instance.class_type = BABL_SPACE;
+ space.instance.id = 0;
+
+ space.xr = rx;
+ space.yr = ry;
+ space.xg = gx;
+ space.yg = gy;
+ space.xb = bx;
+ space.yb = by;
+ space.xw = wx;
+ space.yw = wy;
+ space.trc[0] = trc_red;
+ space.trc[1] = trc_green?trc_green:trc_red;
+ space.trc[2] = trc_blue?trc_blue:trc_red;
+
+ space.whitepoint[0] = wx / wy;
+ space.whitepoint[1] = 1.0;
+ space.whitepoint[2] = (1.0 - wx - wy) / wy;
+
+ for (i = 0; space_db[i].instance.class_type; i++)
+ {
+ int offset = ((char*)&space_db[i].xr) - (char*)(&space_db[i]);
+ int size = ((char*)&space_db[i].trc) + sizeof(space_db[i].trc) - ((char*)&space_db[i].xr);
+
+ if (memcmp ((char*)(&space_db[i]) + offset, ((char*)&space) + offset, size)==0)
+ {
+ return (void*)&space_db[i];
+ }
+ }
+ if (i >= MAX_SPACES-1)
+ {
+ babl_log ("too many BablSpaces");
+ return NULL;
+ }
+ space_db[i]=space;
+ space_db[i].instance.name = space_db[i].name;
+ if (name)
+ sprintf (space_db[i].name, "%s", name);
+ else
+ /* XXX: this can get longer than 256bytes ! */
+ sprintf (space_db[i].name, "space-%.4f,%.4f_%.4f,%.4f_%.4f,%.4f_%.4f,%.4f_%s,%s,%s",
+ wx,wy,rx,ry,bx,by,gx,gy,babl_get_name (space.trc[0]),
+ babl_get_name(space.trc[1]), babl_get_name(space.trc[2]));
+
+ /* compute matrixes */
+ babl_space_compute_matrices (&space_db[i]);
+
+ return (Babl*)&space_db[i];
+}
+
+void
+babl_space_class_for_each (BablEachFunction each_fun,
+ void *user_data)
+{
+ int i=0;
+ for (i = 0; space_db[i].instance.class_type; i++)
+ if (each_fun (BABL (&space_db[i]), user_data))
+ return;
+}
+
+void
+babl_space_class_init (void)
+{
+ babl_space_from_chromaticities ("sRGB",
+ 0.3127, 0.3290, /* D65 */
+ 0.6400, 0.3300,
+ 0.3000, 0.6000,
+ 0.1500, 0.0600,
+ babl_trc("sRGB"), NULL, NULL);
+
+ babl_space_from_chromaticities ("Rec2020",
+ 0.3127, 0.3290, /* D65 */
+ 0.708, 0.292,
+ 0.170, 0.797,
+ 0.131, 0.046,
+ // XXX: is using sRGB TRC right?
+ babl_trc("sRGB"), NULL, NULL);
+
+ babl_space_from_chromaticities (
+ "Adobish", /* a space that can be used as a place-holder for a sRGB like
+space with displaced green coordinates from a big graphics software vendor that
+would rather not it's name be directly used when referring to this color space,
+this color space isn't exactly like theirs but close enough with babls own
+computations of uniform gray axis */
+ 0.3127, 0.3290, /* D65 */
+ 0.6400, 0.3300,
+ 0.2100, 0.7100,
+ 0.1500, 0.0600,
+ babl_trc("2.2"), NULL, NULL);
+
+ babl_space_from_chromaticities (
+ "ProPhoto",
+ 0.34567, 0.3585, /* D50 */
+ 0.7347, 0.2653,
+ 0.1596, 0.8404,
+ 0.0366, 0.0001,
+ babl_trc("1.8"), NULL, NULL);
+
+ babl_space_from_chromaticities (
+ "Apple",
+ 0.3127, 0.3290, /* D65 */
+ 0.6250, 0.3400,
+ 0.2800, 0.5950,
+ 0.1550, 0.0700,
+ babl_trc("1.8"), NULL, NULL);
+
+#if 0
+ babl_space_from_chromaticities (
+ "WideGamut",
+ 0.34567, 0.3585, /* D50 */
+ 0.7350, 0.2650,
+ 0.1150, 0.8260,
+ 0.1570, 0.0180,
+ babl_trc("2.2"), NULL, NULL);
+
+ babl_space_from_chromaticities (
+ "Best",
+ 0.34567, 0.3585, /* D50 */
+ 0.7347, 0.2653,
+ 0.2150, 0.7750,
+ 0.1300, 0.0350,
+ babl_trc("2.2"), NULL, NULL);
+
+ babl_space_from_chromaticities (
+ "Beta",
+ 0.34567, 0.3585, /* D50 */
+ 0.6888, 0.3112,
+ 0.1986, 0.7551,
+ 0.1265, 0.0352,
+ babl_trc("2.2"), NULL, NULL);
+
+ babl_space_from_chromaticities (
+ "Bruce",
+ 0.3127, 0.3290, /* D65 */
+ 0.6400, 0.3300,
+ 0.2800, 0.6500,
+ 0.1500, 0.0600,
+ babl_trc("1.8"), NULL, NULL);
+
+ babl_space_from_chromaticities (
+ "PAL",
+ 0.3127, 0.3290, /* D65 */
+ 0.6400, 0.3300,
+ 0.2900, 0.6000,
+ 0.1500, 0.0600,
+ babl_trc("2.2"), NULL, NULL);
+
+ babl_space_from_chromaticities (
+ "SMPTE-C",
+ 0.3127, 0.3290, /* D65 */
+ 0.6300, 0.3300,
+ 0.3100, 0.5950,
+ 0.1550, 0.0700,
+ babl_trc("2.2"), NULL, NULL);
+
+ babl_space_from_chromaticities (
+ "ColorMatch",
+ 0.34567, 0.3585, /* D50 */
+ 0.6300, 0.3400,
+ 0.2950, 0.6050,
+ 0.1500, 0.0750,
+ babl_trc("1.8"), NULL, NULL);
+
+ babl_space_from_chromaticities (
+ "Don RGB 4",
+ 0.34567, 0.3585, /* D50 */
+ 0.6960, 0.3000,
+ 0.2150, 0.7650,
+ 0.1300, 0.0350,
+ babl_trc("1.8"), NULL, NULL);
+#endif
+}
+
+void babl_space_to_xyz (const Babl *space, const double *rgb, double *xyz)
+{
+ _babl_space_to_xyz (space, rgb, xyz);
+}
+
+void babl_space_from_xyz (const Babl *space, const double *xyz, double *rgb)
+{
+ _babl_space_from_xyz (space, xyz, rgb);
+}
+
+const double * babl_space_get_rgbtoxyz (const Babl *space)
+{
+ return space->space.RGBtoXYZ;
+}
+
+///////////////////
+
+
+static void prep_conversion (const Babl *babl)
+{
+ Babl *conversion = (void*) babl;
+ const Babl *source_space = babl_conversion_get_source_space (conversion);
+ float *matrixf;
+ int i;
+ float *lut;
+
+ double matrix[9];
+ babl_matrix_mul_matrix (
+ (conversion->conversion.destination)->format.space->space.XYZtoRGB,
+ (conversion->conversion.source)->format.space->space.RGBtoXYZ,
+ matrix);
+
+ matrixf = babl_calloc (sizeof (float), 9 + 256); // we leak this matrix , which is a singleton
+ babl_matrix_to_float (matrix, matrixf);
+ conversion->conversion.data = matrixf;
+
+ lut = matrixf + 9;
+ for (i = 0; i < 256; i++)
+ {
+ lut[i] = babl_trc_to_linear (source_space->space.trc[0], i/255.0);
+ // XXX: should have green and blue luts as well
+ }
+}
+
+#define TRC_IN(rgba_in, rgba_out) do{ int i;\
+ for (i = 0; i < samples; i++) \
+ { \
+ rgba_out[i*4+3] = rgba_in[i*4+3]; \
+ } \
+ if ((source_space->space.trc[0] == source_space->space.trc[1]) && \
+ (source_space->space.trc[1] == source_space->space.trc[2])) \
+ { \
+ const Babl *trc = (void*)source_space->space.trc[0]; \
+ babl_trc_to_linear_buf(trc, rgba_in, rgba_out, 4, 4, 3, samples); \
+ } \
+ else \
+ { \
+ int c; \
+ for (c = 0; c < 3; c ++) \
+ { \
+ const Babl *trc = (void*)source_space->space.trc[c]; \
+ babl_trc_to_linear_buf(trc, rgba_in + c, rgba_out + c, 4, 4, 1, samples); \
+ } \
+ } \
+}while(0)
+
+#define TRC_OUT(rgba_in, rgba_out) do{\
+ { \
+ int c; \
+ if ((destination_space->space.trc[0] == destination_space->space.trc[1]) && \
+ (destination_space->space.trc[1] == destination_space->space.trc[2])) \
+ { \
+ const Babl *trc = (void*)destination_space->space.trc[0]; \
+ babl_trc_from_linear_buf(trc, rgba_in, rgba_out, 4, 4, 3, samples); \
+ } \
+ else \
+ { \
+ for (c = 0; c < 3; c ++) \
+ { \
+ const Babl *trc = (void*)destination_space->space.trc[c]; \
+ babl_trc_from_linear_buf(trc, rgba_in + c, rgba_out + c, 4, 4, 1, samples); \
+ } \
+ } \
+ }\
+} while(0)
+
+
+
+
+static inline void
+universal_nonlinear_rgb_converter (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+ const Babl *source_space = babl_conversion_get_source_space (conversion);
+ const Babl *destination_space = babl_conversion_get_destination_space (conversion);
+
+ float * matrixf = conversion->conversion.data;
+ float *rgba_in = (void*)src_char;
+ float *rgba_out = (void*)dst_char;
+
+ TRC_IN(rgba_in, rgba_out);
+
+ babl_matrix_mul_vectorff_buf4 (matrixf, rgba_out, rgba_out, samples);
+
+ TRC_OUT(rgba_out, rgba_out);
+}
+
+static inline void
+universal_nonlinear_rgb_linear_converter (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+ const Babl *source_space = babl_conversion_get_source_space (conversion);
+ float * matrixf = conversion->conversion.data;
+ float *rgba_in = (void*)src_char;
+ float *rgba_out = (void*)dst_char;
+
+ TRC_IN(rgba_in, rgba_out);
+
+ babl_matrix_mul_vectorff_buf4 (matrixf, rgba_out, rgba_out, samples);
+}
+
+static inline void
+universal_nonlinear_rgba_u8_converter (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+ const Babl *destination_space = conversion->conversion.destination->format.space;
+
+ float * matrixf = conversion->conversion.data;
+ float * in_trc_lut = matrixf + 9;
+ int i;
+ uint8_t *rgba_in_u8 = (void*)src_char;
+ uint8_t *rgba_out_u8 = (void*)dst_char;
+
+ float *rgb = babl_malloc (sizeof(float) * 4 * samples);
+
+ for (i = 0; i < samples; i++)
+ {
+ rgb[i*4+0]=in_trc_lut[rgba_in_u8[i*4+0]];
+ rgb[i*4+1]=in_trc_lut[rgba_in_u8[i*4+1]];
+ rgb[i*4+2]=in_trc_lut[rgba_in_u8[i*4+2]];
+ rgba_out_u8[i*4+3] = rgba_in_u8[i*4+3];
+ }
+
+ babl_matrix_mul_vectorff_buf4 (matrixf, rgb, rgb, samples);
+
+ {
+ const Babl *from_trc_red = (void*)destination_space->space.trc[0];
+ const Babl *from_trc_green = (void*)destination_space->space.trc[1];
+ const Babl *from_trc_blue = (void*)destination_space->space.trc[2];
+ for (i = 0; i < samples * 4; i+=4)
+ {
+ rgba_out_u8[i+0] = babl_trc_from_linear (from_trc_red, rgb[i+0]) * 255.5f;
+ rgba_out_u8[i+1] = babl_trc_from_linear (from_trc_green, rgb[i+1]) * 255.5f;
+ rgba_out_u8[i+2] = babl_trc_from_linear (from_trc_blue, rgb[i+2]) * 255.5f;
+ }
+ }
+ babl_free (rgb);
+}
+
+
+static inline void
+universal_rgba_converter (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+ float *matrixf = conversion->conversion.data;
+ float *rgba_in = (void*)src_char;
+ float *rgba_out = (void*)dst_char;
+
+ babl_matrix_mul_vectorff_buf4 (matrixf, rgba_in, rgba_out, samples);
+}
+
+static inline void
+universal_rgb_converter (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+ float *matrixf = conversion->conversion.data;
+ float *rgb_in = (void*)src_char;
+ float *rgb_out = (void*)dst_char;
+
+ babl_matrix_mul_vectorff_buf3 (matrixf, rgb_in, rgb_out, samples);
+}
+
+
+static inline void
+universal_nonlinear_rgb_u8_converter (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+ const Babl *destination_space = conversion->conversion.destination->format.space;
+
+ float * matrixf = conversion->conversion.data;
+ float * in_trc_lut = matrixf + 9;
+ int i;
+ uint8_t *rgb_in_u8 = (void*)src_char;
+ uint8_t *rgb_out_u8 = (void*)dst_char;
+
+ float *rgba_out = babl_malloc (sizeof(float) * 4 * samples);
+
+ for (i = 0; i < samples; i++)
+ {
+ rgba_out[i*4+0]=in_trc_lut[rgb_in_u8[i*3+0]];
+ rgba_out[i*4+1]=in_trc_lut[rgb_in_u8[i*3+1]];
+ rgba_out[i*4+2]=in_trc_lut[rgb_in_u8[i*3+2]];
+ }
+
+ babl_matrix_mul_vectorff_buf4 (matrixf, rgba_out, rgba_out, samples);
+
+ {
+ int c;
+ TRC_OUT(rgba_out, rgba_out);
+
+ for (i = 0; i < samples; i++)
+ for (c = 0; c < 3; c ++)
+ rgb_out_u8[i*3+c] = rgba_out[i*4+c] * 255.5f;
+ }
+
+ babl_free (rgba_out);
+}
+
+
+#if defined(USE_SSE2)
+
+#define m(matr, j, i) matr[j*3+i]
+
+#include <emmintrin.h>
+
+static inline void babl_matrix_mul_vectorff_buf4_sse2 (const float *mat,
+ const float *v_in,
+ float *v_out,
+ int samples)
+{
+ const __v4sf m___0 = {m(mat, 0, 0), m(mat, 1, 0), m(mat, 2, 0), 0};
+ const __v4sf m___1 = {m(mat, 0, 1), m(mat, 1, 1), m(mat, 2, 1), 0};
+ const __v4sf m___2 = {m(mat, 0, 2), m(mat, 1, 2), m(mat, 2, 2), 1};
+ int i;
+ for (i = 0; i < samples; i ++)
+ {
+ __v4sf a, b, c = _mm_load_ps(&v_in[0]);
+ a = (__v4sf) _mm_shuffle_epi32((__m128i)c, _MM_SHUFFLE(0,0,0,0));
+ b = (__v4sf) _mm_shuffle_epi32((__m128i)c, _MM_SHUFFLE(1,1,1,1));
+ c = (__v4sf) _mm_shuffle_epi32((__m128i)c, _MM_SHUFFLE(3,2,2,2));
+ _mm_store_ps (v_out, m___0 * a + m___1 * b + m___2 * c);
+ v_out += 4;
+ v_in += 4;
+ }
+ _mm_empty ();
+}
+
+#undef m
+
+
+static inline void
+universal_nonlinear_rgb_converter_sse2 (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+ const Babl *source_space = babl_conversion_get_source_space (conversion);
+ const Babl *destination_space = babl_conversion_get_destination_space (conversion);
+ float * matrixf = conversion->conversion.data;
+ float *rgba_in = (void*)src_char;
+ float *rgba_out = (void*)dst_char;
+
+ TRC_IN(rgba_in, rgba_out);
+
+ babl_matrix_mul_vectorff_buf4_sse2 (matrixf, rgba_out, rgba_out, samples);
+
+ TRC_OUT(rgba_out, rgba_out);
+}
+
+
+static inline void
+universal_rgba_converter_sse2 (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+ float *matrixf = conversion->conversion.data;
+ float *rgba_in = (void*)src_char;
+ float *rgba_out = (void*)dst_char;
+
+ babl_matrix_mul_vectorff_buf4_sse2 (matrixf, rgba_in, rgba_out, samples);
+}
+
+static inline void
+universal_nonlinear_rgba_u8_converter_sse2 (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+ const Babl *destination_space = conversion->conversion.destination->format.space;
+
+ float * matrixf = conversion->conversion.data;
+ float * in_trc_lut = matrixf + 9;
+ int i;
+ uint8_t *rgba_in_u8 = (void*)src_char;
+ uint8_t *rgba_out_u8 = (void*)dst_char;
+
+ float *rgba_out = babl_malloc (sizeof(float) * 4 * samples);
+
+ for (i = 0; i < samples * 4; i+= 4)
+ {
+ rgba_out[i+0]=in_trc_lut[rgba_in_u8[i+0]];
+ rgba_out[i+1]=in_trc_lut[rgba_in_u8[i+1]];
+ rgba_out[i+2]=in_trc_lut[rgba_in_u8[i+2]];
+ rgba_out_u8[i+3] = rgba_in_u8[i+3];
+ }
+
+ babl_matrix_mul_vectorff_buf4_sse2 (matrixf, rgba_out, rgba_out, samples);
+
+ {
+ int c;
+ TRC_OUT(rgba_out, rgba_out);
+
+ for (i = 0; i < samples * 4; i+= 4)
+ for (c = 0; c < 3; c ++)
+ rgba_out_u8[i+c] = rgba_out[i+c] * 255.5f;
+ }
+
+ babl_free (rgba_out);
+}
+
+static inline void
+universal_nonlinear_rgb_u8_converter_sse2 (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+ const Babl *destination_space = conversion->conversion.destination->format.space;
+
+ float * matrixf = conversion->conversion.data;
+ float * in_trc_lut = matrixf + 9;
+ int i;
+ uint8_t *rgb_in_u8 = (void*)src_char;
+ uint8_t *rgb_out_u8 = (void*)dst_char;
+
+ float *rgba_out = babl_malloc (sizeof(float) * 4 * samples);
+
+ for (i = 0; i < samples; i++)
+ {
+ rgba_out[i*4+0]=in_trc_lut[rgb_in_u8[i*3+0]];
+ rgba_out[i*4+1]=in_trc_lut[rgb_in_u8[i*3+1]];
+ rgba_out[i*4+2]=in_trc_lut[rgb_in_u8[i*3+2]];
+ }
+
+ babl_matrix_mul_vectorff_buf4_sse2 (matrixf, rgba_out, rgba_out, samples);
+
+ {
+ int c;
+ TRC_OUT(rgba_out, rgba_out);
+
+ for (i = 0; i < samples; i++)
+ for (c = 0; c < 3; c ++)
+ rgb_out_u8[i*3+c] = rgba_out[i*4+c] * 255.5f;
+ }
+
+ babl_free (rgba_out);
+}
+
+
+static inline void
+universal_nonlinear_rgb_linear_converter_sse2 (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
+{
+ const Babl *source_space = babl_conversion_get_source_space (conversion);
+ float * matrixf = conversion->conversion.data;
+ float *rgba_in = (void*)src_char;
+ float *rgba_out = (void*)dst_char;
+
+ TRC_IN(rgba_in, rgba_out);
+
+ babl_matrix_mul_vectorff_buf4_sse2 (matrixf, rgba_out, rgba_out, samples);
+}
+#endif
+
+
+static int
+add_rgb_adapter (Babl *babl,
+ void *space)
+{
+ if (babl != space)
+ {
+
+#if defined(USE_SSE2)
+ if ((babl_cpu_accel_get_support () & BABL_CPU_ACCEL_X86_SSE) &&
+ (babl_cpu_accel_get_support () & BABL_CPU_ACCEL_X86_SSE2))
+ {
+ prep_conversion(babl_conversion_new(babl_format_with_space("RGBA float", space),
+ babl_format_with_space("RGBA float", babl),
+ "linear", universal_rgba_converter_sse2,
+ NULL));
+ prep_conversion(babl_conversion_new(babl_format_with_space("RGBA float", babl),
+ babl_format_with_space("RGBA float", space),
+ "linear", universal_rgba_converter_sse2,
+ NULL));
+ prep_conversion(babl_conversion_new(babl_format_with_space("R'G'B'A float", space),
+ babl_format_with_space("R'G'B'A float", babl),
+ "linear", universal_nonlinear_rgb_converter_sse2,
+ NULL));
+ prep_conversion(babl_conversion_new(babl_format_with_space("R'G'B'A float", babl),
+ babl_format_with_space("R'G'B'A float", space),
+ "linear", universal_nonlinear_rgb_converter_sse2,
+ NULL));
+ prep_conversion(babl_conversion_new(babl_format_with_space("R'G'B'A u8", space),
+ babl_format_with_space("R'G'B'A u8", babl),
+ "linear", universal_nonlinear_rgba_u8_converter_sse2,
+ NULL));
+ prep_conversion(babl_conversion_new(babl_format_with_space("R'G'B'A u8", babl),
+ babl_format_with_space("R'G'B'A u8", space),
+ "linear", universal_nonlinear_rgba_u8_converter_sse2,
+ NULL));
+
+ prep_conversion(babl_conversion_new(babl_format_with_space("R'G'B' u8", space),
+ babl_format_with_space("R'G'B' u8", babl),
+ "linear", universal_nonlinear_rgb_u8_converter_sse2,
+ NULL));
+ prep_conversion(babl_conversion_new(babl_format_with_space("R'G'B' u8", babl),
+ babl_format_with_space("R'G'B' u8", space),
+ "linear", universal_nonlinear_rgb_u8_converter_sse2,
+ NULL));
+ }
+ //else
+#endif
+ {
+ prep_conversion(babl_conversion_new(babl_format_with_space("RGBA float", space),
+ babl_format_with_space("RGBA float", babl),
+ "linear", universal_rgba_converter,
+ NULL));
+ prep_conversion(babl_conversion_new(babl_format_with_space("RGBA float", babl),
+ babl_format_with_space("RGBA float", space),
+ "linear", universal_rgba_converter,
+ NULL));
+ prep_conversion(babl_conversion_new(babl_format_with_space("R'G'B'A float", space),
+ babl_format_with_space("R'G'B'A float", babl),
+ "linear", universal_nonlinear_rgb_converter,
+ NULL));
+ prep_conversion(babl_conversion_new(babl_format_with_space("R'G'B'A float", babl),
+ babl_format_with_space("R'G'B'A float", space),
+ "linear", universal_nonlinear_rgb_converter,
+ NULL));
+ prep_conversion(babl_conversion_new(babl_format_with_space("R'G'B'A u8", space),
+ babl_format_with_space("R'G'B'A u8", babl),
+ "linear", universal_nonlinear_rgba_u8_converter,
+ NULL));
+ prep_conversion(babl_conversion_new(babl_format_with_space("R'G'B'A u8", babl),
+ babl_format_with_space("R'G'B'A u8", space),
+ "linear", universal_nonlinear_rgba_u8_converter,
+ NULL));
+
+ prep_conversion(babl_conversion_new(babl_format_with_space("R'G'B' u8", space),
+ babl_format_with_space("R'G'B' u8", babl),
+ "linear", universal_nonlinear_rgb_u8_converter,
+ NULL));
+ prep_conversion(babl_conversion_new(babl_format_with_space("R'G'B' u8", babl),
+ babl_format_with_space("R'G'B' u8", space),
+ "linear", universal_nonlinear_rgb_u8_converter,
+ NULL));
+ }
+
+ prep_conversion(babl_conversion_new(babl_format_with_space("RGB float", space),
+ babl_format_with_space("RGB float", babl),
+ "linear", universal_rgb_converter,
+ NULL));
+ prep_conversion(babl_conversion_new(babl_format_with_space("RGB float", babl),
+ babl_format_with_space("RGB float", space),
+ "linear", universal_rgb_converter,
+ NULL));
+ }
+ return 0;
+}
+
+/* The first time a new Babl space is used - for creation of a fish, is when
+ * this function is called, it adds conversions hooks that provides its formats
+ * with conversions internally as well as for conversions to and from other RGB
+ * spaces.
+ */
+void _babl_space_add_universal_rgb (const Babl *space)
+{
+ babl_space_class_for_each (add_rgb_adapter, (void*)space);
+}
+
+
+const Babl *babl_space_match_trc_matrix (const Babl *trc_red,
+ const Babl *trc_green,
+ const Babl *trc_blue,
+ float rx, float ry, float rz,
+ float gx, float gy, float gz,
+ float bx, float by, float bz)
+{
+ int i;
+ double delta = 0.001;
+ for (i = 0; space_db[i].instance.class_type; i++)
+ {
+ BablSpace *space = &space_db[i];
+ if (trc_red == space->trc[0] &&
+ trc_green == space->trc[1] &&
+ trc_blue == space->trc[2] &&
+ fabs(rx - space->RGBtoXYZ[0]) < delta &&
+ fabs(ry - space->RGBtoXYZ[3]) < delta &&
+ fabs(rz - space->RGBtoXYZ[6]) < delta &&
+ fabs(gx - space->RGBtoXYZ[1]) < delta &&
+ fabs(gy - space->RGBtoXYZ[4]) < delta &&
+ fabs(gz - space->RGBtoXYZ[7]) < delta &&
+ fabs(bx - space->RGBtoXYZ[2]) < delta &&
+ fabs(by - space->RGBtoXYZ[5]) < delta &&
+ fabs(bz - space->RGBtoXYZ[8]) < delta)
+ {
+ return (void*)&space_db[i];
+ }
+ }
+ return NULL;
+}
+
+/* Trademarks:
+ *
+ * International Color Consortium is a registered trademarks of the.
+ * International Color Consortium.
+ * Apple is a trademark or registered trademark of Apple Inc in many countries.
+ * Adobish is meant to concisely convey resemblence/compatibility with Adobe
+ * RGB- without actualy being it, Adobe is a trademark or registered trademark
+ * of Adobe Systems Incorporated in many countires.
+ */
diff --git a/babl/babl-space.h b/babl/babl-space.h
new file mode 100644
index 0000000..6aeefb6
--- /dev/null
+++ b/babl/babl-space.h
@@ -0,0 +1,96 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2017, Øyvind Kolås and others.
+ *
+ * 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
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _BABL_SPACE_H
+#define _BABL_SPACE_H
+
+#include <math.h>
+#include <string.h>
+#include "base/util.h"
+#include "babl-matrix.h"
+
+BABL_CLASS_DECLARE (space);
+
+typedef struct
+{
+ BablInstance instance;
+ double xw; // white-point chromaticity
+ double yw;
+
+ double xr; // red primary chromaticity
+ double yr;
+
+ double xg; // green primary chromaticity
+ double yg;
+
+ double xb; // blue primary chromaticity
+ double yb;
+
+ double pad; // for when the numbers represent a matrix
+
+ const Babl *trc[3];
+ char name[512]; // XXX: allocate this dynamically instead -
+ // or use iccv4 style hashes for name.
+ double whitepoint[3]; /* CIE XYZ whitepoint */
+
+ double RGBtoXYZ[9]; /* matrices for conversions */
+ double XYZtoRGB[9];
+ float RGBtoXYZf[9]; /* matrices for conversions */
+ float XYZtoRGBf[9];
+
+ /* the space should contain matrix to/from XYZ */
+ /* and before converting a span, all that needs to be
+ rigged is merging matrices */
+
+ /* we should here also add more things read from ICC profile,
+ * making it possible to round-trip data. Unless it is sRGB, when
+ * standard should win.
+ */
+
+} BablSpace;
+
+static inline void babl_space_to_xyzf (const Babl *space, const float *rgb, float *xyz)
+{
+ BablSpace *space_ = (void*)space;
+ babl_matrix_mul_vectorff (space_->RGBtoXYZf, rgb, xyz);
+}
+
+static inline void babl_space_from_xyzf (const Babl *space, const float *xyz, float *rgb)
+{
+ BablSpace *space_ = (void*)space;
+ babl_matrix_mul_vectorff (space_->XYZtoRGBf, xyz, rgb);
+}
+
+static inline void _babl_space_to_xyz (const Babl *space, const double *rgb, double *xyz)
+{
+ BablSpace *space_ = (void*)space;
+ babl_matrix_mul_vector (space_->RGBtoXYZ, rgb, xyz);
+}
+
+static inline void _babl_space_from_xyz (const Babl *space, const double *xyz, double *rgb)
+{
+ BablSpace *space_ = (void*)space;
+ babl_matrix_mul_vector (space_->XYZtoRGB, xyz, rgb);
+}
+
+void
+babl_space_class_init (void);
+
+
+
+#endif
diff --git a/babl/babl-trc.c b/babl/babl-trc.c
new file mode 100644
index 0000000..7524ef8
--- /dev/null
+++ b/babl/babl-trc.c
@@ -0,0 +1,543 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2017 Øyvind Kolås.
+ *
+ * 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
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#define MAX_TRCS 100
+
+/* FIXME: choose parameters more intelligently */
+#define POLY_GAMMA_X0 ( 0.5 / 255.0)
+#define POLY_GAMMA_X1 (254.5 / 255.0)
+#define POLY_GAMMA_DEGREE 6
+#define POLY_GAMMA_SCALE 2
+
+#include "config.h"
+#include "babl-internal.h"
+#include "base/util.h"
+
+static BablTRC trc_db[MAX_TRCS];
+
+static inline float _babl_trc_linear (const Babl *trc_, float value)
+{
+ return value;
+}
+
+static inline float babl_trc_lut_from_linear (const Babl *trc_, float x)
+{
+ BablTRC *trc = (void*)trc_;
+ int entry;
+ float ret, diff;
+
+ entry = x * (trc->lut_size-1);
+ diff = ( (x * (trc->lut_size-1)) - entry);
+
+ if (entry >= trc->lut_size -1)
+ {
+ entry = trc->lut_size - 1;
+ diff = 0.0;
+ }
+ else if (entry < 0) entry = 0;
+
+ if (diff > 0.0)
+ {
+ ret = trc->inv_lut[entry] * (1.0 - diff) + trc->inv_lut[entry+1] * diff;
+ }
+ else
+ {
+ ret = trc->inv_lut[entry];
+ }
+ return ret;
+}
+
+static inline float babl_trc_lut_to_linear (const Babl *trc_, float x)
+{
+ BablTRC *trc = (void*)trc_;
+ int entry;
+ float ret, diff;
+
+ entry = x * (trc->lut_size-1);
+ diff = ( (x * (trc->lut_size-1)) - entry);
+
+ if (entry >= trc->lut_size) entry = trc->lut_size - 1;
+ else if (entry < 0) entry = 0;
+
+ if (diff > 0.0 && entry < trc->lut_size - 1)
+ {
+ ret = trc->lut[entry] * (1.0 - diff) + trc->lut[entry+1] * diff;
+ }
+ else
+ {
+ ret = trc->lut[entry];
+ }
+ return ret;
+}
+
+static inline float _babl_trc_gamma_to_linear (const Babl *trc_, float value)
+{
+ BablTRC *trc = (void*)trc_;
+ if (value >= trc->poly_gamma_to_linear_x0 &&
+ value <= trc->poly_gamma_to_linear_x1)
+ {
+ return babl_polynomial_eval (&trc->poly_gamma_to_linear, value);
+ }
+ else if (value > 0.0f)
+ {
+ return powf (value, trc->gamma);
+ }
+ return 0.0f;
+}
+
+static inline float _babl_trc_gamma_from_linear (const Babl *trc_, float value)
+{
+ BablTRC *trc = (void*)trc_;
+ if (value >= trc->poly_gamma_from_linear_x0 &&
+ value <= trc->poly_gamma_from_linear_x1)
+ {
+ return babl_polynomial_eval (&trc->poly_gamma_from_linear, value);
+ }
+ else if (value > 0.0f)
+ {
+ return powf (value, trc->rgamma);
+ }
+ return 0.0f;
+}
+
+static inline void _babl_trc_gamma_to_linear_buf (const Babl *trc_, const float *in, float *out, int in_gap, int out_gap, int components, int count)
+{
+ int i, c;
+ for (i = 0; i < count; i ++)
+ for (c = 0; c < components; c ++)
+ out[out_gap * i + c] = _babl_trc_gamma_to_linear (trc_, in[in_gap *i + c]);
+}
+
+static inline void _babl_trc_gamma_from_linear_buf (const Babl *trc_, const float *in, float *out, int in_gap, int out_gap, int components, int count)
+{
+ int i, c;
+ for (i = 0; i < count; i ++)
+ for (c = 0; c < components; c ++)
+ out[out_gap * i + c] = _babl_trc_gamma_from_linear (trc_, in[in_gap *i + c]);
+}
+
+static inline float _babl_trc_formula_srgb_from_linear (const Babl *trc_, float value)
+{
+ BablTRC *trc = (void*)trc_;
+ float x= value;
+ float a = trc->lut[1];
+ float b = trc->lut[2];
+ float c = trc->lut[3];
+ float d = trc->lut[4];
+ if (x > c * d) // XXX: verify that this math is the correct inverse
+ {
+ float v = _babl_trc_gamma_from_linear ((Babl *) trc, x);
+ v = (v-b)/a;
+ if (v < 0.0 || v >= 0.0)
+ return v;
+ return 0.0;
+ }
+ if (c > 0.0)
+ return x / c;
+ return 0.0;
+}
+
+static inline float _babl_trc_formula_srgb_to_linear (const Babl *trc_, float value)
+{
+ BablTRC *trc = (void*)trc_;
+ float x= value;
+ float a = trc->lut[1];
+ float b = trc->lut[2];
+ float c = trc->lut[3];
+ float d = trc->lut[4];
+
+ if (x >= d)
+ {
+ return _babl_trc_gamma_to_linear ((Babl *) trc, a * x + b);
+ }
+ return c * x;
+}
+
+static inline float _babl_trc_srgb_to_linear (const Babl *trc_, float value)
+{
+ return babl_gamma_2_2_to_linearf (value);
+}
+
+static inline float _babl_trc_srgb_from_linear (const Babl *trc_, float value)
+{
+ return babl_linear_to_gamma_2_2f (value);
+}
+
+static inline void _babl_trc_srgb_to_linear_buf (const Babl *trc_, const float *in, float *out, int in_gap, int out_gap, int components, int count)
+{
+ int i, c;
+ for (i = 0; i < count; i ++)
+ for (c = 0; c < components; c++)
+ out[out_gap * i + c] = babl_gamma_2_2_to_linearf (in[in_gap * i + c]);
+}
+
+static inline void _babl_trc_srgb_from_linear_buf (const Babl *trc_,
+ const float *in, float *out,
+ int in_gap, int out_gap,
+ int components,
+ int count)
+{
+ int i, c;
+ for (i = 0; i < count; i ++)
+ for (c = 0; c < components; c++)
+ out[out_gap * i + c] = babl_linear_to_gamma_2_2f (in[in_gap * i + c]);
+}
+
+static inline void _babl_trc_to_linear_buf_generic (const Babl *trc_, const float *in, float *out, int in_gap, int out_gap, int components, int count)
+{
+ int i, c;
+ BablTRC *trc = (void*)trc_;
+ for (i = 0; i < count; i ++)
+ for (c = 0; c < components; c ++)
+ out[out_gap * i + c] = trc->fun_to_linear (trc_, in[in_gap * i + c]);
+}
+
+static inline void _babl_trc_from_linear_buf_generic (const Babl *trc_,
+ const float *in, float *out,
+ int in_gap, int out_gap,
+ int components,
+ int count)
+{
+ int i, c;
+ BablTRC *trc = (void*)trc_;
+ for (i = 0; i < count; i ++)
+ for (c = 0; c < components; c ++)
+ out[out_gap * i + c] = trc->fun_from_linear (trc_, in[in_gap * i + c]);
+}
+
+static inline void _babl_trc_linear_buf (const Babl *trc_,
+ const float *in, float *out,
+ int in_gap, int out_gap,
+ int components,
+ int count)
+{
+ int i, c;
+ for (i = 0; i < count; i ++)
+ for (c = 0; c < components; c ++)
+ out[i * out_gap + c] = in[i * in_gap + c];
+}
+
+
+const Babl *
+babl_trc (const char *name)
+{
+ int i;
+ for (i = 0; trc_db[i].instance.class_type; i++)
+ if (!strcmp (trc_db[i].instance.name, name))
+ {
+ return (Babl*)&trc_db[i];
+ }
+ babl_log("failed to find trc '%s'\n", name);
+ return NULL;
+}
+
+const Babl *
+babl_trc_new (const char *name,
+ BablTRCType type,
+ double gamma,
+ int n_lut,
+ float *lut)
+{
+ int i=0;
+ static BablTRC trc;
+ trc.instance.class_type = BABL_TRC;
+ trc.instance.id = 0;
+ trc.type = type;
+ trc.gamma = gamma > 0.0 ? gamma : 0.0;
+ trc.rgamma = gamma > 0.0001 ? 1.0 / gamma : 0.0;
+
+ if (n_lut )
+ {
+ for (i = 0; trc_db[i].instance.class_type; i++)
+ {
+ if ( trc_db[i].lut_size == n_lut &&
+ (memcmp (trc_db[i].lut, lut, sizeof (float) * n_lut)==0)
+ )
+ {
+ return (void*)&trc_db[i];
+ }
+ }
+ }
+ else
+ for (i = 0; trc_db[i].instance.class_type; i++)
+ {
+ int offset = ((char*)&trc_db[i].type) - (char*)(&trc_db[i]);
+ int size = ((char*)&trc_db[i].gamma + sizeof(double)) - ((char*)&trc_db[i].type);
+
+ if (memcmp ((char*)(&trc_db[i]) + offset, ((char*)&trc) + offset, size)==0)
+ {
+ return (void*)&trc_db[i];
+ }
+ }
+ if (i >= MAX_TRCS-1)
+ {
+ babl_log ("too many BablTRCs");
+ return NULL;
+ }
+ trc_db[i]=trc;
+ trc_db[i].instance.name = trc_db[i].name;
+ if (name)
+ sprintf (trc_db[i].name, "%s", name);
+ else if (n_lut)
+ sprintf (trc_db[i].name, "lut-trc");
+ else
+ sprintf (trc_db[i].name, "trc-%i-%f", type, gamma);
+
+ if (n_lut)
+ {
+ int j;
+ trc_db[i].lut_size = n_lut;
+ trc_db[i].lut = babl_calloc (sizeof (float), n_lut);
+ memcpy (trc_db[i].lut, lut, sizeof (float) * n_lut);
+ trc_db[i].inv_lut = babl_calloc (sizeof (float), n_lut);
+
+ for (j = 0; j < n_lut; j++)
+ {
+ int k;
+ double min = 0.0;
+ double max = 1.0;
+ for (k = 0; k < 16; k++)
+ {
+ double guess = (min + max) / 2;
+ float reversed_index = babl_trc_lut_to_linear (BABL(&trc_db[i]), guess) * (n_lut-1.0);
+
+ if (reversed_index < j)
+ {
+ min = guess;
+ }
+ else if (reversed_index > j)
+ {
+ max = guess;
+ }
+ }
+ trc_db[i].inv_lut[j] = (min + max) / 2;
+ }
+ }
+
+ trc_db[i].fun_to_linear_buf = _babl_trc_to_linear_buf_generic;
+ trc_db[i].fun_from_linear_buf = _babl_trc_from_linear_buf_generic;
+
+ switch (trc_db[i].type)
+ {
+ case BABL_TRC_LINEAR:
+ trc_db[i].fun_to_linear = _babl_trc_linear;
+ trc_db[i].fun_from_linear = _babl_trc_linear;
+ trc_db[i].fun_from_linear_buf = _babl_trc_linear_buf;
+ trc_db[i].fun_to_linear_buf = _babl_trc_linear_buf;
+ break;
+ case BABL_TRC_FORMULA_GAMMA:
+ trc_db[i].fun_to_linear = _babl_trc_gamma_to_linear;
+ trc_db[i].fun_from_linear = _babl_trc_gamma_from_linear;
+ trc_db[i].fun_to_linear_buf = _babl_trc_gamma_to_linear_buf;
+ trc_db[i].fun_from_linear_buf = _babl_trc_gamma_from_linear_buf;
+
+ trc_db[i].poly_gamma_to_linear_x0 = POLY_GAMMA_X0;
+ trc_db[i].poly_gamma_to_linear_x1 = POLY_GAMMA_X1;
+ babl_polynomial_approximate_gamma (&trc_db[i].poly_gamma_to_linear,
+ trc_db[i].gamma,
+ trc_db[i].poly_gamma_to_linear_x0,
+ trc_db[i].poly_gamma_to_linear_x1,
+ POLY_GAMMA_DEGREE, POLY_GAMMA_SCALE);
+
+ trc_db[i].poly_gamma_from_linear_x0 = POLY_GAMMA_X0;
+ trc_db[i].poly_gamma_from_linear_x1 = POLY_GAMMA_X1;
+ babl_polynomial_approximate_gamma (&trc_db[i].poly_gamma_from_linear,
+ trc_db[i].rgamma,
+ trc_db[i].poly_gamma_from_linear_x0,
+ trc_db[i].poly_gamma_from_linear_x1,
+ POLY_GAMMA_DEGREE, POLY_GAMMA_SCALE);
+ break;
+ case BABL_TRC_FORMULA_SRGB:
+ trc_db[i].lut = babl_calloc (sizeof (float), 5);
+ {
+ int j;
+ for (j = 0; j < 5; j++)
+ trc_db[i].lut[j] = lut[j];
+ }
+ trc_db[i].fun_to_linear = _babl_trc_formula_srgb_to_linear;
+ trc_db[i].fun_from_linear = _babl_trc_formula_srgb_from_linear;
+
+ trc_db[i].poly_gamma_to_linear_x0 = lut[4];
+ trc_db[i].poly_gamma_to_linear_x1 = POLY_GAMMA_X1;
+ babl_polynomial_approximate_gamma (&trc_db[i].poly_gamma_to_linear,
+ trc_db[i].gamma,
+ trc_db[i].poly_gamma_to_linear_x0,
+ trc_db[i].poly_gamma_to_linear_x1,
+ POLY_GAMMA_DEGREE, POLY_GAMMA_SCALE);
+
+ trc_db[i].poly_gamma_from_linear_x0 = lut[3] * lut[4];
+ trc_db[i].poly_gamma_from_linear_x1 = POLY_GAMMA_X1;
+ babl_polynomial_approximate_gamma (&trc_db[i].poly_gamma_from_linear,
+ trc_db[i].rgamma,
+ trc_db[i].poly_gamma_from_linear_x0,
+ trc_db[i].poly_gamma_from_linear_x1,
+ POLY_GAMMA_DEGREE, POLY_GAMMA_SCALE);
+ break;
+ case BABL_TRC_SRGB:
+ trc_db[i].fun_to_linear = _babl_trc_srgb_to_linear;
+ trc_db[i].fun_from_linear = _babl_trc_srgb_from_linear;
+ trc_db[i].fun_from_linear_buf = _babl_trc_srgb_from_linear_buf;
+ trc_db[i].fun_to_linear_buf = _babl_trc_srgb_to_linear_buf;
+ break;
+ case BABL_TRC_LUT:
+ trc_db[i].fun_to_linear = babl_trc_lut_to_linear;
+ trc_db[i].fun_from_linear = babl_trc_lut_from_linear;
+ break;
+ }
+ return (Babl*)&trc_db[i];
+}
+
+const Babl * babl_trc_lut (const char *name, int n, float *entries)
+{
+ return babl_trc_new (name, BABL_TRC_LUT, 0, n, entries);
+}
+
+void
+babl_trc_class_for_each (BablEachFunction each_fun,
+ void *user_data)
+{
+ int i=0;
+ for (i = 0; trc_db[i].instance.class_type; i++)
+ if (each_fun (BABL (&trc_db[i]), user_data))
+ return;
+}
+
+const Babl *
+babl_trc_formula_srgb (double g, double a, double b, double c, double d)
+{
+ char name[128];
+ int i;
+ float params[5]={g, a, b, c, d};
+
+ if (fabs (g - 2.40) < 0.01 &&
+ fabs (a - 26214) < 0.01 &&
+ fabs (b - 0.947875) < 0.01 &&
+ fabs (c - (-3417)) < 0.01)
+ return babl_trc ("sRGB");
+
+ sprintf (name, "%.6f %.6f %.4f %.4f %.4f", g, a, b, c, d);
+ for (i = 0; name[i]; i++)
+ if (name[i] == ',') name[i] = '.';
+ while (name[strlen(name)-1]=='0')
+ name[strlen(name)-1]='\0';
+ return babl_trc_new (name, BABL_TRC_FORMULA_SRGB, g, 0, params);
+}
+
+const Babl *
+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);
+
+ sprintf (name, "%.6f", gamma);
+ for (i = 0; name[i]; i++)
+ if (name[i] == ',') name[i] = '.';
+ while (name[strlen(name)-1]=='0')
+ name[strlen(name)-1]='\0';
+ return babl_trc_new (name, BABL_TRC_FORMULA_GAMMA, gamma, 0, NULL);
+}
+
+void
+babl_trc_class_init (void)
+{
+ babl_trc_new ("sRGB", BABL_TRC_SRGB, 2.2, 0, NULL);
+ babl_trc_gamma (2.2);
+ babl_trc_gamma (1.8);
+ babl_trc_gamma (1.0);
+ babl_trc_new ("linear", BABL_TRC_LINEAR, 1.0, 0, NULL);
+}
+
+#if 0
+float babl_trc_from_linear (const Babl *trc_, float value)
+{
+ return babl_trc_from_linear (trc_, value);
+}
+
+float babl_trc_to_linear (const Babl *trc_, float value)
+{
+ return babl_trc_to_linear (trc_, value);
+}
+#endif
+
+static int
+babl_lut_match_gamma (float *lut, int lut_size, float gamma)
+{
+ int match = 1;
+ int i;
+ if (lut_size > 1024)
+ {
+ for (i = 0; match && i < lut_size; i++)
+ {
+ if (fabs (lut[i] - pow ((i / (lut_size-1.0)), gamma)) > 0.0001)
+ match = 0;
+ }
+ }
+ else
+ {
+ for (i = 0; match && i < lut_size; i++)
+ {
+ if (fabs (lut[i] - pow ((i / (lut_size-1.0)), gamma)) > 0.001)
+ match = 0;
+ }
+ }
+ return match;
+}
+
+const Babl *babl_trc_lut_find (float *lut, int lut_size)
+{
+ int i;
+ int match = 1;
+
+ /* look for linear match */
+ for (i = 0; match && i < lut_size; i++)
+ if (fabs (lut[i] - i / (lut_size-1.0)) > 0.015)
+ match = 0;
+ if (match)
+ return babl_trc_gamma (1.0);
+
+ /* look for sRGB match: */
+ match = 1;
+ if (lut_size > 1024)
+ {
+ for (i = 0; match && i < lut_size; i++)
+ {
+ if (fabs (lut[i] - gamma_2_2_to_linear (i / (lut_size-1.0))) > 0.0001)
+ match = 0;
+ }
+ }
+ else
+ {
+ for (i = 0; match && i < lut_size; i++)
+ {
+ if (fabs (lut[i] - gamma_2_2_to_linear (i / (lut_size-1.0))) > 0.001)
+ match = 0;
+ }
+ }
+ if (match)
+ return babl_trc ("sRGB");
+
+ if (babl_lut_match_gamma (lut, lut_size, 2.2))
+ return babl_trc_gamma(2.2);
+
+ if (babl_lut_match_gamma (lut, lut_size, 1.8))
+ return babl_trc_gamma(1.8);
+
+ return NULL;
+}
diff --git a/babl/babl-trc.h b/babl/babl-trc.h
new file mode 100644
index 0000000..e7e5da5
--- /dev/null
+++ b/babl/babl-trc.h
@@ -0,0 +1,106 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2017, Øyvind Kolås and others.
+ *
+ * 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
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _BABL_TRC_H
+#define _BABL_TRC_H
+
+#include <math.h>
+#include <string.h>
+#include "base/util.h"
+#include "babl-polynomial.h"
+
+BABL_CLASS_DECLARE (trc);
+
+typedef enum {BABL_TRC_LINEAR,
+ BABL_TRC_FORMULA_GAMMA,
+ BABL_TRC_SRGB,
+ BABL_TRC_FORMULA_SRGB,
+ BABL_TRC_LUT}
+BablTRCType;
+
+typedef struct
+{
+ BablInstance instance;
+ BablTRCType type;
+ int lut_size;
+ double gamma;
+ float rgamma;
+ float (*fun_to_linear)(const Babl *trc, float val);
+ float (*fun_from_linear)(const Babl *trc, float val);
+
+ void (*fun_to_linear_buf)(const Babl *trc,
+ const float *in,
+ float *out,
+ int in_gap,
+ int out_gap,
+ int components,
+ int count);
+ void (*fun_from_linear_buf)(const Babl *trc,
+ const float *in,
+ float *out,
+ int in_gap,
+ int out_gap,
+ int components,
+ int count);
+ BablPolynomial poly_gamma_to_linear;
+ float poly_gamma_to_linear_x0;
+ float poly_gamma_to_linear_x1;
+ BablPolynomial poly_gamma_from_linear;
+ float poly_gamma_from_linear_x0;
+ float poly_gamma_from_linear_x1;
+ float *lut;
+ float *inv_lut;
+ char name[128];
+} BablTRC;
+
+static inline void babl_trc_from_linear_buf (const Babl *trc_,
+ const float *in, float *out,
+ int in_gap, int out_gap,
+ int components,
+ int count)
+{
+ BablTRC *trc = (void*)trc_;
+ trc->fun_from_linear_buf (trc_, in, out, in_gap, out_gap, components, count);
+}
+
+static inline void babl_trc_to_linear_buf (const Babl *trc_,
+ const float *in, float *out,
+ int in_gap, int out_gap,
+ int components,
+ int count)
+{
+ BablTRC *trc = (void*)trc_;
+ trc->fun_to_linear_buf (trc_, in, out, in_gap, out_gap, components, count);
+}
+
+static inline float babl_trc_from_linear (const Babl *trc_, float value)
+{
+ BablTRC *trc = (void*)trc_;
+ return trc->fun_from_linear (trc_, value);
+}
+
+static inline float babl_trc_to_linear (const Babl *trc_, float value)
+{
+ BablTRC *trc = (void*)trc_;
+ return trc->fun_to_linear (trc_, value);
+}
+
+void
+babl_trc_class_init (void);
+
+#endif
diff --git a/babl/babl-types.h b/babl/babl-types.h
index 252a382..3df81e7 100644
--- a/babl/babl-types.h
+++ b/babl/babl-types.h
@@ -20,7 +20,7 @@
#define _BABL_TYPES_H
#if !defined(BABL_INSIDE_BABL_H) && !defined(BABL_IS_BEING_COMPILED)
-#error "babl-version.h must not be included directly, include babl.h instead."
+#error "babl-types.h must not be included directly, include babl.h instead."
#endif
/**
@@ -33,16 +33,19 @@
**/
typedef union _Babl Babl;
+
/* Conversion function between linear data of a either a data types or
* color formats.
*/
-typedef long (*BablFuncLinear) (const char *src,
+typedef void (*BablFuncLinear) (const Babl *conversion,
+ const char *src,
char *dst,
long n,
void *user_data);
/* TypePlanar,ModelPlanar and FormatPlanar */
-typedef long (*BablFuncPlanar) (int src_bands,
+typedef void (*BablFuncPlanar) (const Babl *conversion,
+ int src_bands,
const char *src[],
int src_pitch[],
int dst_bands,
diff --git a/babl/babl-util.c b/babl/babl-util.c
index 01a5e97..23c1513 100644
--- a/babl/babl-util.c
+++ b/babl/babl-util.c
@@ -91,11 +91,52 @@ babl_rel_avg_error (const double *imgA,
for (i = 0; i < samples; i++)
error += fabs (imgA[i] - imgB[i]);
- if (error >= 0.000001)
+ if (error >= 0.0000001)
error /= samples;
- else
+ else if (error <= 0.0)
error = 0.0;
+ else
+ error = M_PI;
return error;
}
+int
+_babl_file_get_contents (const char *path,
+ char **contents,
+ long *length,
+ void *error)
+{
+ FILE *file;
+ long size;
+ char *buffer;
+
+ file = fopen (path,"rb");
+
+ if (!file)
+ return -1;
+
+ fseek (file, 0, SEEK_END);
+ size = ftell (file);
+ if (length) *length = size;
+ rewind (file);
+ buffer = calloc(size + 8, 1);
+
+ if (!buffer)
+ {
+ fclose(file);
+ return -1;
+ }
+
+ size -= fread (buffer, 1, size, file);
+ if (size)
+ {
+ fclose (file);
+ free (buffer);
+ return -1;
+ }
+ fclose (file);
+ *contents = buffer;
+ return 0;
+}
+
diff --git a/babl/babl-version.h b/babl/babl-version.h
index 1045ac6..4d1e2da 100644
--- a/babl/babl-version.h
+++ b/babl/babl-version.h
@@ -34,7 +34,7 @@
#define BABL_MAJOR_VERSION 0
#define BABL_MINOR_VERSION 1
-#define BABL_MICRO_VERSION 30
+#define BABL_MICRO_VERSION 34
/** Get the version information on the babl library */
void babl_get_version (int *major,
diff --git a/babl/babl.c b/babl/babl.c
index 9924fa7..c734fb3 100644
--- a/babl/babl.c
+++ b/babl/babl.c
@@ -137,6 +137,8 @@ babl_init (void)
babl_internal_init ();
babl_sampling_class_init ();
babl_type_db ();
+ babl_trc_class_init ();
+ babl_space_class_init ();
babl_component_db ();
babl_model_db ();
babl_format_db ();
diff --git a/babl/babl.h b/babl/babl.h
index 546fad6..5e299a7 100644
--- a/babl/babl.h
+++ b/babl/babl.h
@@ -63,6 +63,7 @@ const Babl * babl_type (const char *name);
const Babl * babl_sampling (int horizontal,
int vertical);
+
/**
* babl_component:
*
@@ -79,13 +80,101 @@ const Babl * babl_component (const char *name);
*/
const Babl * babl_model (const char *name);
+
+/**
+ * babl_space:
+ *
+ * Returns the babl object representing the specific RGB matrix color
+ * working space referred to by name. Babl knows of:
+ * sRGB, Rec2020, Adobish, Apple and ProPhoto
+ *
+ */
+const Babl * babl_space (const char *name);
+
+typedef enum {
+ BABL_ICC_INTENT_PERCEPTUAL = 0,
+ BABL_ICC_INTENT_RELATIVE_COLORIMETRIC = 1,
+ BABL_ICC_INTENT_SATURATION = 2,
+ BABL_ICC_INTENT_ABSOLUTE_COLORIMETRIC = 3
+} BablIccIntent;
+
+/**
+ * babl_icc_make_space:
+ *
+ * @icc_data: pointer to icc profile in memory
+ * @icc_length: length of icc profile in bytes
+ * @intent: the intent from the ICC profile to use.
+ *
+ " @error: pointer to a string where decoding errors can be stored,
+ * if an error occurs, NULL is returned and an error message
+ * is provided in error.
+ *
+ * Create a babl space from an in memory ICC profile, the profile does no
+ * longer need to be loaded for the space to work, multiple calls with the same
+ * icc profile and same intent will result in the same babl space.
+ *
+ * On a profile that doesn't contain A2B0 and B2A0 CLUTs perceptual and
+ * relative-colorimetric intents are treated the same.
+ *
+ * If a BablSpace cannot be created from the profile NULL is returned and a
+ * static string is set on the const char *value pointed at with &value
+ * containing a message describing why the provided data does not yield a babl
+ * space.
+ */
+const Babl *babl_icc_make_space (const char *icc_data,
+ int icc_length,
+ BablIccIntent intent,
+ const char **error);
+
+
+/* babl_icc_get_key:
+ *
+ * @icc_data: pointer to in-memory icc profile
+ * @icc_length: length of icc profile in bytes
+ * @key: the key we want to quey, see below for some supported values
+ * @language: 2 char code for language to extract or NULL
+ * @country: 2 char country code or NULL
+ *
+ * Returns NULL if key not found or a malloc allocated utf8 string of the key
+ * when found, free with free() when done. Supported keys: "description",
+ * "copyright", "manufacturer", "device", "profile-class", "color-space" and
+ * "pcs".
+ */
+
+char *babl_icc_get_key (const char *icc_data,
+ int icc_length,
+ const char *key,
+ const char *language,
+ const char *counter);
+
+
/**
* babl_format:
*
* Returns the babl object representing the color format given by
* @name such as for example "RGB u8", "CMYK float" or "CIE Lab u16".
*/
-const Babl * babl_format (const char *name);
+const Babl * babl_format (const char *name);
+
+/**
+ * babl_format_with_space:
+ *
+ * Returns the babl object representing the color format given by
+ * @name such as for example "RGB u8", "R'G'B'A float", "Y float" with
+ * a specific RGB working space used as the space, the resulting format
+ * has -space suffixed to it, unless the space requested is sRGB then
+ * the unsuffixed version is used. If a format is passed in as space
+ * the space of the format is used.
+ */
+const Babl * babl_format_with_space (const char *name, const Babl *space);
+
+/*
+ * babl_format_get_space:
+ *
+ * Retrieve the RGB color space used for a pixel format.
+ */
+const Babl * babl_format_get_space (const Babl *format);
+
/**
* babl_fish:
@@ -97,6 +186,25 @@ const Babl * babl_format (const char *name);
const Babl * babl_fish (const void *source_format,
const void *destination_format);
+
+/**
+ * babl_fast_fish:
+ *
+ * Creae a faster than normal fish with specified performance (and thus
+ * corresponding precision tradeoff), values tolerance can hold: NULL and
+ * "default", means do same as babl_fish(), other values understood in
+ * increasing order of speed gain are:
+ * "exact" "precise" "fast" "glitch"
+ *
+ * Fast fishes should be cached, since they are not internally kept track
+ * of/made into singletons by babl and many creations of fast fishes will
+ * otherwise be a leak.
+ *
+ */
+const Babl * babl_fast_fish (const void *source_format,
+ const void *destination_format,
+ const char *performance);
+
/**
* babl_process:
*
@@ -112,7 +220,7 @@ long babl_process (const Babl *babl_fish,
/**
* babl_get_name:
*
- * Returns a string decsribing a Babl object.
+ * Returns a string describing a Babl object.
*/
const char * babl_get_name (const Babl *babl);
@@ -251,6 +359,19 @@ int babl_format_is_format_n (const Babl *format);
const Babl * babl_conversion_new (const void *first_arg,
...) BABL_ARG_NULL_TERMINATED;
+/**
+ * babl_conversion_get_source_space:
+ *
+ * Returns the RGB space defined for the source of conversion.
+ */
+const Babl *babl_conversion_get_source_space (const Babl *conversion);
+
+/**
+ * babl_conversion_get_destination_space:
+ *
+ * Returns the RGB space defined for the destination of conversion.
+ */
+const Babl *babl_conversion_get_destination_space (const Babl *conversion);
/**
* babl_new_palette:
@@ -311,19 +432,18 @@ void babl_set_user_data (const Babl *babl, void *data);
void * babl_get_user_data (const Babl *babl);
-
-/*
- * Backwards compatibility stuff
- *
- * NOTE: will most likely be removed in the first stable release!
- */
-#ifndef BABL_DISABLE_DEPRECATED
-#define babl_destroy babl_exit
-#endif
-
-
#ifdef __cplusplus
}
#endif
#endif
+
+/* Trademarks:
+ *
+ * International Color Consortium is a registered trademarks of the.
+ * International Color Consortium.
+ * Apple is a trademark or registered trademark of Apple Inc in many countries.
+ * Adobish is meant to concisely convey resemblence/compatibility with Adobe
+ * RGB- without actualy being it, Adobe is a trademark or registered trademark
+ * of Adobe Systems Incorporated in many countires.
+ */
diff --git a/babl/base/Makefile.am b/babl/base/Makefile.am
index 5b92521..1b0fabe 100644
--- a/babl/base/Makefile.am
+++ b/babl/base/Makefile.am
@@ -23,7 +23,6 @@ libbase_la_SOURCES= $(h_sources) $(c_sources)
libbase_la_LIBADD = $(MATH_LIB)
EXTRA_DIST = \
- rgb-constants.h \
util.h \
pow-24.h
diff --git a/babl/base/Makefile.in b/babl/base/Makefile.in
index 7958cb1..89aeca6 100644
--- a/babl/base/Makefile.in
+++ b/babl/base/Makefile.in
@@ -231,6 +231,7 @@ LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
+LOG_LIB = @LOG_LIB@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAINT = @MAINT@
@@ -348,7 +349,6 @@ noinst_LTLIBRARIES = libbase.la
libbase_la_SOURCES = $(h_sources) $(c_sources)
libbase_la_LIBADD = $(MATH_LIB)
EXTRA_DIST = \
- rgb-constants.h \
util.h \
pow-24.h
diff --git a/babl/base/model-gray.c b/babl/base/model-gray.c
index 239333e..6a2764e 100644
--- a/babl/base/model-gray.c
+++ b/babl/base/model-gray.c
@@ -22,8 +22,6 @@
#include "babl-classes.h"
#include "babl.h"
#include "babl-ids.h"
-#include "util.h"
-#include "rgb-constants.h"
#include "math.h"
#include "babl-base.h"
@@ -109,11 +107,17 @@ models (void)
}
-static long
-rgba_to_graya (char *src,
+static void
+rgba_to_graya (Babl *conversion,
+ char *src,
char *dst,
long n)
{
+ const Babl *space = babl_conversion_get_source_space (conversion);
+ double RGB_LUMINANCE_RED = space->space.RGBtoXYZ[3];
+ double RGB_LUMINANCE_GREEN = space->space.RGBtoXYZ[4];
+ double RGB_LUMINANCE_BLUE = space->space.RGBtoXYZ[5];
+
while (n--)
{
double red, green, blue;
@@ -134,14 +138,19 @@ rgba_to_graya (char *src,
src += sizeof (double) * 4;
dst += sizeof (double) * 2;
}
- return n;
}
-static long
-rgba_to_gray (char *src,
+static void
+rgba_to_gray (Babl *conversion,
+ char *src,
char *dst,
long n)
{
+ const Babl *space = babl_conversion_get_source_space (conversion);
+ double RGB_LUMINANCE_RED = space->space.RGBtoXYZ[3];
+ double RGB_LUMINANCE_GREEN = space->space.RGBtoXYZ[4];
+ double RGB_LUMINANCE_BLUE = space->space.RGBtoXYZ[5];
+
while (n--)
{
double red, green, blue;
@@ -160,12 +169,11 @@ rgba_to_gray (char *src,
src += sizeof (double) * 4;
dst += sizeof (double) * 1;
}
- return n;
}
-
-static long
-rgb_to_gray_2_2 (int src_bands,
+static void
+rgb_to_gray_2_2 (Babl *conversion,
+ int src_bands,
char **src,
int *src_pitch,
int dst_bands,
@@ -173,6 +181,12 @@ rgb_to_gray_2_2 (int src_bands,
int *dst_pitch,
long n)
{
+ const Babl *space = babl_conversion_get_destination_space (conversion);
+ const Babl *trc = space->space.trc[0];
+ double RGB_LUMINANCE_RED = space->space.RGBtoXYZ[3];
+ double RGB_LUMINANCE_GREEN = space->space.RGBtoXYZ[4];
+ double RGB_LUMINANCE_BLUE = space->space.RGBtoXYZ[5];
+
BABL_PLANAR_SANITY
while (n--)
{
@@ -187,22 +201,22 @@ rgb_to_gray_2_2 (int src_bands,
else
alpha = 1.0;
- luminance = red * RGB_LUMINANCE_RED +
+ luminance = red * RGB_LUMINANCE_RED + // XXX: should be taken from BablSpace
green * RGB_LUMINANCE_GREEN +
- blue * RGB_LUMINANCE_BLUE;
- *(double *) dst[0] = linear_to_gamma_2_2 (luminance);
+ blue * RGB_LUMINANCE_BLUE;
+ *(double *) dst[0] = babl_trc_from_linear (trc, luminance);
if (dst_bands == 2)
*(double *) dst[1] = alpha;
BABL_PLANAR_STEP
}
- return n;
}
-static long
-gray_2_2_to_rgb (int src_bands,
+static void
+gray_2_2_to_rgb (Babl *conversion,
+ int src_bands,
char **src,
int *src_pitch,
int dst_bands,
@@ -210,6 +224,9 @@ gray_2_2_to_rgb (int src_bands,
int *dst_pitch,
long n)
{
+ const Babl *space = babl_conversion_get_source_space (conversion);
+ const Babl *trc = space->space.trc[0];
+
BABL_PLANAR_SANITY
while (n--)
{
@@ -217,7 +234,7 @@ gray_2_2_to_rgb (int src_bands,
double red, green, blue;
double alpha;
- luminance = gamma_2_2_to_linear (*(double *) src[0]);
+ luminance = babl_trc_to_linear (trc, *(double *) src[0]);
red = luminance;
green = luminance;
blue = luminance;
@@ -235,13 +252,11 @@ gray_2_2_to_rgb (int src_bands,
BABL_PLANAR_STEP
}
- return n;
}
-
-
-static long
-graya_to_rgba (char *src,
+static void
+graya_to_rgba (Babl *conversion,
+ char *src,
char *dst,
long n)
{
@@ -265,12 +280,12 @@ graya_to_rgba (char *src,
src += sizeof (double) * 2;
dst += sizeof (double) * 4;
}
- return n;
}
-static long
-gray_to_rgba (char *src,
+static void
+gray_to_rgba (Babl *conversion,
+ char *src,
char *dst,
long n)
{
@@ -292,11 +307,11 @@ gray_to_rgba (char *src,
src += sizeof (double) * 1;
dst += sizeof (double) * 4;
}
- return n;
}
-static long
-gray_alpha_premultiplied_to_rgba (int src_bands,
+static void
+gray_alpha_premultiplied_to_rgba (Babl *conversion,
+ int src_bands,
char **src,
int *src_pitch,
int dst_bands,
@@ -328,12 +343,12 @@ gray_alpha_premultiplied_to_rgba (int src_bands,
*(double *) dst[3] = alpha;
BABL_PLANAR_STEP
}
- return n;
}
-static long
-rgba_to_gray_alpha_premultiplied (int src_bands,
+static void
+rgba_to_gray_alpha_premultiplied (Babl *conversion,
+ int src_bands,
char **src,
int *src_pitch,
int dst_bands,
@@ -341,6 +356,11 @@ rgba_to_gray_alpha_premultiplied (int src_bands,
int *dst_pitch,
long n)
{
+ const Babl *space = babl_conversion_get_source_space (conversion);
+ double RGB_LUMINANCE_RED = space->space.RGBtoXYZ[3];
+ double RGB_LUMINANCE_GREEN = space->space.RGBtoXYZ[4];
+ double RGB_LUMINANCE_BLUE = space->space.RGBtoXYZ[5];
+
BABL_PLANAR_SANITY;
assert (src_bands == 4);
assert (dst_bands == 2);
@@ -363,11 +383,11 @@ rgba_to_gray_alpha_premultiplied (int src_bands,
*(double *) dst[1] = alpha;
BABL_PLANAR_STEP
}
- return n;
}
-static long
-non_premultiplied_to_premultiplied (int src_bands,
+static void
+non_premultiplied_to_premultiplied (Babl *conversion,
+ int src_bands,
char **src,
int *src_pitch,
int dst_bands,
@@ -391,11 +411,11 @@ non_premultiplied_to_premultiplied (int src_bands,
BABL_PLANAR_STEP
}
- return n;
}
-static long
-premultiplied_to_non_premultiplied (int src_bands,
+static void
+premultiplied_to_non_premultiplied (Babl *conversion,
+ int src_bands,
char **src,
int *src_pitch,
int dst_bands,
@@ -426,14 +446,20 @@ premultiplied_to_non_premultiplied (int src_bands,
BABL_PLANAR_STEP
}
- return n;
}
-static long
-rgba2gray_gamma_2_2_premultiplied (char *src,
+static void
+rgba2gray_gamma_2_2_premultiplied (Babl *conversion,
+ char *src,
char *dst,
long n)
{
+ const Babl *space = babl_conversion_get_destination_space (conversion);
+ const Babl *trc = space->space.trc[0];
+ double RGB_LUMINANCE_RED = space->space.RGBtoXYZ[3];
+ double RGB_LUMINANCE_GREEN = space->space.RGBtoXYZ[4];
+ double RGB_LUMINANCE_BLUE = space->space.RGBtoXYZ[5];
+
while (n--)
{
double red = ((double *) src)[0];
@@ -447,7 +473,7 @@ rgba2gray_gamma_2_2_premultiplied (char *src,
luminance = red * RGB_LUMINANCE_RED +
green * RGB_LUMINANCE_GREEN +
blue * RGB_LUMINANCE_BLUE;
- luma = linear_to_gamma_2_2 (luminance);
+ luma = babl_trc_from_linear (trc, luminance);
((double *) dst)[0] = luma * alpha;
((double *) dst)[1] = alpha;
@@ -455,23 +481,30 @@ rgba2gray_gamma_2_2_premultiplied (char *src,
src += 4 * sizeof (double);
dst += 2 * sizeof (double);
}
- return n;
}
-static long
-gray_gamma_2_2_premultiplied2rgba (char *src,
+static void
+gray_gamma_2_2_premultiplied2rgba (Babl *conversion,
+ char *src,
char *dst,
long n)
{
+ const Babl *space = babl_conversion_get_destination_space (conversion);
+ const Babl *trc = space->space.trc[0];
+
while (n--)
{
double luma = ((double *) src)[0];
double alpha = ((double *) src)[1];
double luminance;
- luma = luma / alpha;
- luminance = gamma_2_2_to_linear (luma);
+ if (alpha > BABL_ALPHA_THRESHOLD)
+ luma = luma / alpha;
+ else
+ luma = 0.0;
+
+ luminance = babl_trc_to_linear (trc, luma);
((double *) dst)[0] = luminance;
((double *) dst)[1] = luminance;
@@ -481,7 +514,6 @@ gray_gamma_2_2_premultiplied2rgba (char *src,
src += 2 * sizeof (double);
dst += 4 * sizeof (double);
}
- return n;
}
diff --git a/babl/base/model-rgb.c b/babl/base/model-rgb.c
index 4ba6f7d..7da204f 100644
--- a/babl/base/model-rgb.c
+++ b/babl/base/model-rgb.c
@@ -23,7 +23,6 @@
#include "babl.h"
#include "babl-classes.h"
#include "babl-ids.h"
-#include "util.h"
#include "babl-base.h"
static void models (void);
@@ -150,8 +149,9 @@ models (void)
NULL);
}
-static long
-copy_strip_1 (int src_bands,
+static void
+copy_strip_1 (Babl *conversion,
+ int src_bands,
char **src,
int *src_pitch,
int dst_bands,
@@ -178,11 +178,11 @@ copy_strip_1 (int src_bands,
BABL_PLANAR_STEP
}
- return samples;
}
-static long
-g3_gamma_2_2 (int src_bands,
+static void
+g3_gamma_2_2 (Babl *conversion,
+ int src_bands,
char **src,
int *src_pitch,
int dst_bands,
@@ -190,6 +190,9 @@ g3_gamma_2_2 (int src_bands,
int *dst_pitch,
long samples)
{
+ const Babl *space = babl_conversion_get_destination_space (conversion);
+ const Babl **trc = (void*)space->space.trc;
+
long n = samples;
BABL_PLANAR_SANITY
@@ -197,18 +200,18 @@ g3_gamma_2_2 (int src_bands,
{
int band;
for (band = 0; band < 3; band++)
- *(double *) dst[band] = linear_to_gamma_2_2 (*(double *) src[band]);
+ *(double *) dst[band] = babl_trc_from_linear (trc[band], (*(double *) src[band]));
for (; band < dst_bands; band++)
*(double *) dst[band] = *(double *) src[band];
BABL_PLANAR_STEP
}
- return samples;
}
-static long
-g3_inv_gamma_2_2 (int src_bands,
+static void
+g3_inv_gamma_2_2 (Babl *conversion,
+ int src_bands,
char **src,
int *src_pitch,
int dst_bands,
@@ -216,6 +219,8 @@ g3_inv_gamma_2_2 (int src_bands,
int *dst_pitch,
long samples)
{
+ const Babl *space = babl_conversion_get_source_space (conversion);
+ const Babl **trc = (void*)space->space.trc;
long n = samples;
BABL_PLANAR_SANITY
@@ -224,7 +229,7 @@ g3_inv_gamma_2_2 (int src_bands,
int band;
for (band = 0; band < 3; band++)
{
- *(double *) dst[band] = gamma_2_2_to_linear (*(double *) src[band]);
+ *(double *) dst[band] = babl_trc_to_linear (trc[band], (*(double *) src[band]));
}
for (; band < dst_bands; band++)
{
@@ -235,11 +240,11 @@ g3_inv_gamma_2_2 (int src_bands,
}
BABL_PLANAR_STEP
}
- return samples;
}
-static long
-non_premultiplied_to_premultiplied (int src_bands,
+static void
+non_premultiplied_to_premultiplied (Babl *conversion,
+ int src_bands,
char **src,
int *src_pitch,
int dst_bands,
@@ -264,11 +269,11 @@ non_premultiplied_to_premultiplied (int src_bands,
BABL_PLANAR_STEP
}
- return samples;
}
-static long
-premultiplied_to_non_premultiplied (int src_bands,
+static void
+premultiplied_to_non_premultiplied (Babl *conversion,
+ int src_bands,
char **src,
int *src_pitch,
int dst_bands,
@@ -300,37 +305,40 @@ premultiplied_to_non_premultiplied (int src_bands,
BABL_PLANAR_STEP
}
- return samples;
}
-
-static long
-rgba2rgba_gamma_2_2_premultiplied (char *src,
+static void
+rgba2rgba_gamma_2_2_premultiplied (Babl *conversion,
+ char *src,
char *dst,
long samples)
{
+ const Babl *space = babl_conversion_get_destination_space (conversion);
+ const Babl **trc = (void*)space->space.trc;
long n = samples;
while (n--)
{
double alpha = ((double *) src)[3];
- ((double *) dst)[0] = linear_to_gamma_2_2 (((double *) src)[0]) * alpha;
- ((double *) dst)[1] = linear_to_gamma_2_2 (((double *) src)[1]) * alpha;
- ((double *) dst)[2] = linear_to_gamma_2_2 (((double *) src)[2]) * alpha;
+ ((double *) dst)[0] = babl_trc_from_linear (trc[0], ((double *) src)[0]) * alpha;
+ ((double *) dst)[1] = babl_trc_from_linear (trc[1], ((double *) src)[1]) * alpha;
+ ((double *) dst)[2] = babl_trc_from_linear (trc[2], ((double *) src)[2]) * alpha;
((double *) dst)[3] = alpha;
src += 4 * sizeof (double);
dst += 4 * sizeof (double);
}
- return samples;
}
-static long
-rgba_gamma_2_2_premultiplied2rgba (char *src,
- char *dst,
- long samples)
+static void
+rgba_gamma_2_2_premultiplied2rgba (Babl *conversion,
+ char *src,
+ char *dst,
+ long samples)
{
+ const Babl *space = babl_conversion_get_source_space (conversion);
+ const Babl **trc = (void*)space->space.trc;
long n = samples;
while (n--)
@@ -338,9 +346,9 @@ rgba_gamma_2_2_premultiplied2rgba (char *src,
double alpha = ((double *) src)[3];
if (alpha > BABL_ALPHA_THRESHOLD)
{
- ((double *) dst)[0] = gamma_2_2_to_linear (((double *) src)[0] / alpha);
- ((double *) dst)[1] = gamma_2_2_to_linear (((double *) src)[1] / alpha);
- ((double *) dst)[2] = gamma_2_2_to_linear (((double *) src)[2] / alpha);
+ ((double *) dst)[0] = babl_trc_to_linear (trc[0], ((double *) src)[0] / alpha);
+ ((double *) dst)[1] = babl_trc_to_linear (trc[1], ((double *) src)[1] / alpha);
+ ((double *) dst)[2] = babl_trc_to_linear (trc[2], ((double *) src)[2] / alpha);
}
else
{
@@ -353,50 +361,53 @@ rgba_gamma_2_2_premultiplied2rgba (char *src,
src += 4 * sizeof (double);
dst += 4 * sizeof (double);
}
- return samples;
}
-static long
-rgba2rgba_gamma_2_2 (char *src,
+static void
+rgba2rgba_gamma_2_2 (Babl *conversion,
+ char *src,
char *dst,
long samples)
{
+ const Babl *space = babl_conversion_get_destination_space (conversion);
+ const Babl **trc = (void*)space->space.trc;
long n = samples;
while (n--)
{
double alpha = ((double *) src)[3];
- ((double *) dst)[0] = linear_to_gamma_2_2 (((double *) src)[0]);
- ((double *) dst)[1] = linear_to_gamma_2_2 (((double *) src)[1]);
- ((double *) dst)[2] = linear_to_gamma_2_2 (((double *) src)[2]);
+ ((double *) dst)[0] = babl_trc_from_linear (trc[0], ((double *) src)[0]);
+ ((double *) dst)[1] = babl_trc_from_linear (trc[1], ((double *) src)[1]);
+ ((double *) dst)[2] = babl_trc_from_linear (trc[2], ((double *) src)[2]);
((double *) dst)[3] = alpha;
src += 4 * sizeof (double);
dst += 4 * sizeof (double);
}
- return samples;
}
-static long
-rgba_gamma_2_22rgba (char *src,
+static void
+rgba_gamma_2_22rgba (Babl *conversion,
+ char *src,
char *dst,
long samples)
{
+ const Babl *space = babl_conversion_get_source_space (conversion);
+ const Babl **trc = (void*)(space->space.trc);
long n = samples;
while (n--)
{
double alpha = ((double *) src)[3];
- ((double *) dst)[0] = gamma_2_2_to_linear (((double *) src)[0]);
- ((double *) dst)[1] = gamma_2_2_to_linear (((double *) src)[1]);
- ((double *) dst)[2] = gamma_2_2_to_linear (((double *) src)[2]);
+ ((double *) dst)[0] = babl_trc_to_linear (trc[0], ((double *) src)[0]);
+ ((double *) dst)[1] = babl_trc_to_linear (trc[1], ((double *) src)[1]);
+ ((double *) dst)[2] = babl_trc_to_linear (trc[2], ((double *) src)[2]);
((double *) dst)[3] = alpha;
src += 4 * sizeof (double);
dst += 4 * sizeof (double);
}
- return samples;
}
static void
@@ -478,7 +489,6 @@ static void
formats (void)
{
babl_format_new (
- /*"name", "srgb",*/
"id", BABL_SRGB,
babl_model_from_id (BABL_RGB_GAMMA_2_2),
babl_type_from_id (BABL_U8),
@@ -499,8 +509,8 @@ formats (void)
babl_format_new (
"id", BABL_RGBA_FLOAT,
- babl_model_from_id (BABL_RGBA),
- babl_type_from_id (BABL_FLOAT),
+ babl_model_from_id (BABL_RGBA),
+ babl_type_from_id (BABL_FLOAT),
babl_component_from_id (BABL_RED),
babl_component_from_id (BABL_GREEN),
babl_component_from_id (BABL_BLUE),
diff --git a/babl/base/model-ycbcr.c b/babl/base/model-ycbcr.c
index 6a6370e..6b34d20 100644
--- a/babl/base/model-ycbcr.c
+++ b/babl/base/model-ycbcr.c
@@ -77,8 +77,9 @@ models (void)
NULL);
}
-static long
-rgba_to_ycbcra (char *src,
+static void
+rgba_to_ycbcra (BablConversion *conversion,
+ char *src,
char *dst,
long n)
{
@@ -107,12 +108,12 @@ rgba_to_ycbcra (char *src,
src += sizeof (double) * 4;
dst += sizeof (double) * 4;
}
- return n;
}
-static long
-rgba_to_ycbcr (char *src,
+static void
+rgba_to_ycbcr (BablConversion *conversion,
+ char *src,
char *dst,
long n)
{
@@ -139,11 +140,11 @@ rgba_to_ycbcr (char *src,
src += sizeof (double) * 4;
dst += sizeof (double) * 3;
}
- return n;
}
-static long
-ycbcra_to_rgba (char *src,
+static void
+ycbcra_to_rgba (BablConversion *conversion,
+ char *src,
char *dst,
long n)
{
@@ -172,12 +173,11 @@ ycbcra_to_rgba (char *src,
src += sizeof (double) * 4;
dst += sizeof (double) * 4;
}
- return n;
}
-
-static long
-ycbcr_to_rgba (char *src,
+static void
+ycbcr_to_rgba (BablConversion *conversion,
+ char *src,
char *dst,
long n)
{
@@ -205,7 +205,6 @@ ycbcr_to_rgba (char *src,
src += sizeof (double) * 3;
dst += sizeof (double) * 4;
}
- return n;
}
static void
diff --git a/babl/base/pow-24.h b/babl/base/pow-24.h
index 0defef6..a55c029 100644
--- a/babl/base/pow-24.h
+++ b/babl/base/pow-24.h
@@ -120,7 +120,7 @@ static inline float babl_frexpf(float x, int *e)
static inline float
init_newtonf (float x, float exponent, float c0, float c1, float c2)
{
- int iexp;
+ int iexp = 0;
float y = babl_frexpf(x, &iexp);
y = 2*y+(iexp-2);
c1 *= M_LN2*exponent;
diff --git a/babl/base/rgb-constants.h b/babl/base/rgb-constants.h
deleted file mode 100644
index 03810d6..0000000
--- a/babl/base/rgb-constants.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* babl - dynamically extendable universal pixel conversion library.
- * Copyright (C) 2005, Øyvind Kolås.
- *
- * 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
- * <http://www.gnu.org/licenses/>.
- */
-
-/*
- * These sRGB Y values have been adapted to the ICC spec D50 illuminant.
- * They match the Y values in the GEGL and GIMP built-in sRGB profiles,
- * which match the Y values in the ArgyllCMS sRGB.icm profile.
- *
- * For more information, see this thread and these bug reports:
- * https://mail.gnome.org/archives/gimp-developer-list/2013-September/msg00113.html
- * https://bugzilla.gnome.org/show_bug.cgi?id=723787
- * https://bugzilla.gnome.org/show_bug.cgi?id=724822
- */
-
-#define RGB_LUMINANCE_RED (0.22248840)
-#define RGB_LUMINANCE_GREEN (0.71690369)
-#define RGB_LUMINANCE_BLUE (0.06060791)
diff --git a/babl/base/type-float.c b/babl/base/type-float.c
index ce7e407..709c7fa 100644
--- a/babl/base/type-float.c
+++ b/babl/base/type-float.c
@@ -25,8 +25,9 @@
#include "babl-ids.h"
#include "babl-base.h"
-static long
-convert_double_float (char *src,
+static void
+convert_double_float (BablConversion *conversion,
+ char *src,
char *dst,
int src_pitch,
int dst_pitch,
@@ -38,11 +39,11 @@ convert_double_float (char *src,
dst += dst_pitch;
src += src_pitch;
}
- return n;
}
-static long
-convert_float_double (char *src,
+static void
+convert_float_double (BablConversion *conversion,
+ char *src,
char *dst,
int src_pitch,
int dst_pitch,
@@ -54,7 +55,6 @@ convert_float_double (char *src,
dst += dst_pitch;
src += src_pitch;
}
- return n;
}
void
diff --git a/babl/base/type-half.c b/babl/base/type-half.c
index 61a63ca..93d5e5b 100644
--- a/babl/base/type-half.c
+++ b/babl/base/type-half.c
@@ -183,8 +183,9 @@ static void halfp2doubles(void *target, void *source, long numel)
}
}
-static long
-convert_double_half (char *src,
+static void
+convert_double_half (BablConversion *conversion,
+ char *src,
char *dst,
int src_pitch,
int dst_pitch,
@@ -196,15 +197,15 @@ convert_double_half (char *src,
dst += dst_pitch;
src += src_pitch;
}
- return n;
}
-static long
-convert_half_double (char *src,
- char *dst,
- int src_pitch,
- int dst_pitch,
- long n)
+static void
+convert_half_double (BablConversion *conversion,
+ char *src,
+ char *dst,
+ int src_pitch,
+ int dst_pitch,
+ long n)
{
while (n--)
{
@@ -212,7 +213,6 @@ convert_half_double (char *src,
dst += dst_pitch;
src += src_pitch;
}
- return n;
}
void
diff --git a/babl/base/type-u15.c b/babl/base/type-u15.c
index 47e3878..355f875 100644
--- a/babl/base/type-u15.c
+++ b/babl/base/type-u15.c
@@ -26,16 +26,17 @@
#include "babl-base.h"
-static inline long
-convert_double_u15_scaled (double min_val,
- double max_val,
- uint16_t min,
- uint16_t max,
- char *src,
- char *dst,
- int src_pitch,
- int dst_pitch,
- long n)
+static inline void
+convert_double_u15_scaled (BablConversion *conversion,
+ double min_val,
+ double max_val,
+ uint16_t min,
+ uint16_t max,
+ char *src,
+ char *dst,
+ int src_pitch,
+ int dst_pitch,
+ long n)
{
while (n--)
{
@@ -53,12 +54,12 @@ convert_double_u15_scaled (double min_val,
dst += dst_pitch;
src += src_pitch;
}
- return n;
}
-static inline long
-convert_u15_double_scaled (double min_val,
- double max_val,
+static inline void
+convert_u15_double_scaled (BablConversion *conversion,
+ double min_val,
+ double max_val,
uint16_t min,
uint16_t max,
char *src,
@@ -83,29 +84,29 @@ convert_u15_double_scaled (double min_val,
dst += dst_pitch;
src += src_pitch;
}
- return n;
}
#define MAKE_CONVERSIONS(name, min_val, max_val, min, max) \
- static long \
- convert_ ## name ## _double (void *src, \
+ static void \
+ convert_ ## name ## _double (BablConversion *conversion, \
+ void *src, \
void *dst, \
int src_pitch, \
int dst_pitch, \
long n) \
{ \
- return convert_u15_double_scaled (min_val, max_val, min, max, \
- src, dst, src_pitch, dst_pitch, n); \
+ convert_u15_double_scaled (conversion, min_val, max_val, min, max, \
+ src, dst, src_pitch, dst_pitch, n); \
} \
- static long \
- convert_double_ ## name (void *src, \
+ static void \
+ convert_double_ ## name (BablConversion *conversion, void *src, \
void *dst, \
int src_pitch, \
int dst_pitch, \
long n) \
{ \
- return convert_double_u15_scaled (min_val, max_val, min, max, \
- src, dst, src_pitch, dst_pitch, n); \
+ convert_double_u15_scaled (conversion, min_val, max_val, min, max, \
+ src, dst, src_pitch, dst_pitch, n); \
}
MAKE_CONVERSIONS (u15, 0.0, 1.0, 0, (1<<15))
diff --git a/babl/base/type-u16.c b/babl/base/type-u16.c
index 9fcad8b..4a7c8f1 100644
--- a/babl/base/type-u16.c
+++ b/babl/base/type-u16.c
@@ -26,8 +26,9 @@
#include "babl-base.h"
-static inline long
-convert_double_u16_scaled (double min_val,
+static inline void
+convert_double_u16_scaled (BablConversion *conversion,
+ double min_val,
double max_val,
uint16_t min,
uint16_t max,
@@ -53,11 +54,11 @@ convert_double_u16_scaled (double min_val,
dst += dst_pitch;
src += src_pitch;
}
- return n;
}
-static inline long
-convert_u16_double_scaled (double min_val,
+static inline void
+convert_u16_double_scaled (BablConversion *conversion,
+ double min_val,
double max_val,
uint16_t min,
uint16_t max,
@@ -83,29 +84,28 @@ convert_u16_double_scaled (double min_val,
dst += dst_pitch;
src += src_pitch;
}
- return n;
}
#define MAKE_CONVERSIONS(name, min_val, max_val, min, max) \
- static long \
- convert_ ## name ## _double (void *src, \
+ static void \
+ convert_ ## name ## _double (BablConversion *c, void *src, \
void *dst, \
int src_pitch, \
int dst_pitch, \
long n) \
{ \
- return convert_u16_double_scaled (min_val, max_val, min, max, \
- src, dst, src_pitch, dst_pitch, n); \
+ convert_u16_double_scaled (c, min_val, max_val, min, max, \
+ src, dst, src_pitch, dst_pitch, n); \
} \
- static long \
- convert_double_ ## name (void *src, \
+ static void \
+ convert_double_ ## name (BablConversion *c, void *src, \
void *dst, \
int src_pitch, \
int dst_pitch, \
long n) \
{ \
- return convert_double_u16_scaled (min_val, max_val, min, max, \
- src, dst, src_pitch, dst_pitch, n); \
+ convert_double_u16_scaled (c, min_val, max_val, min, max, \
+ src, dst, src_pitch, dst_pitch, n); \
}
MAKE_CONVERSIONS (u16, 0.0, 1.0, 0, UINT16_MAX)
diff --git a/babl/base/type-u32.c b/babl/base/type-u32.c
index fc38a01..66a5654 100644
--- a/babl/base/type-u32.c
+++ b/babl/base/type-u32.c
@@ -25,8 +25,9 @@
#include "babl-internal.h"
#include "babl-base.h"
-static inline long
-convert_double_u32_scaled (double min_val,
+static inline void
+convert_double_u32_scaled (BablConversion *c,
+ double min_val,
double max_val,
uint32_t min,
uint32_t max,
@@ -52,11 +53,11 @@ convert_double_u32_scaled (double min_val,
dst += dst_pitch;
src += src_pitch;
}
- return n;
}
-static inline long
-convert_u32_double_scaled (double min_val,
+static inline void
+convert_u32_double_scaled (BablConversion *c,
+ double min_val,
double max_val,
uint32_t min,
uint32_t max,
@@ -82,29 +83,28 @@ convert_u32_double_scaled (double min_val,
dst += dst_pitch;
src += src_pitch;
}
- return n;
}
#define MAKE_CONVERSIONS(name, min_val, max_val, min, max) \
- static long \
- convert_ ## name ## _double (void *src, \
+ static void \
+ convert_ ## name ## _double (BablConversion *c, void *src, \
void *dst, \
int src_pitch, \
int dst_pitch, \
long n) \
{ \
- return convert_u32_double_scaled (min_val, max_val, min, max, \
- src, dst, src_pitch, dst_pitch, n); \
+ convert_u32_double_scaled (c, min_val, max_val, min, max, \
+ src, dst, src_pitch, dst_pitch, n); \
} \
- static long \
- convert_double_ ## name (void *src, \
+ static void \
+ convert_double_ ## name (BablConversion *c, void *src, \
void *dst, \
int src_pitch, \
int dst_pitch, \
long n) \
{ \
- return convert_double_u32_scaled (min_val, max_val, min, max, \
- src, dst, src_pitch, dst_pitch, n); \
+ convert_double_u32_scaled (c, min_val, max_val, min, max, \
+ src, dst, src_pitch, dst_pitch, n); \
}
MAKE_CONVERSIONS (u32, 0.0, 1.0, 0, UINT32_MAX)
diff --git a/babl/base/type-u8.c b/babl/base/type-u8.c
index 9a67a0e..8eeaf65 100644
--- a/babl/base/type-u8.c
+++ b/babl/base/type-u8.c
@@ -25,8 +25,9 @@
#include "babl-base.h"
#include <math.h>
-static inline long
-convert_double_u8_scaled (double min_val,
+static inline void
+convert_double_u8_scaled (BablConversion *c,
+ double min_val,
double max_val,
unsigned char min,
unsigned char max,
@@ -52,11 +53,11 @@ convert_double_u8_scaled (double min_val,
src += src_pitch;
dst += dst_pitch;
}
- return n;
}
-static inline long
-convert_u8_double_scaled (double min_val,
+static inline void
+convert_u8_double_scaled (BablConversion *c,
+ double min_val,
double max_val,
unsigned char min,
unsigned char max,
@@ -83,29 +84,28 @@ convert_u8_double_scaled (double min_val,
dst += dst_pitch;
src += src_pitch;
}
- return n;
}
#define MAKE_CONVERSIONS(name, min_val, max_val, min, max) \
- static long \
- convert_ ## name ## _double (void *src, \
+ static void \
+ convert_ ## name ## _double (BablConversion *c, void *src, \
void *dst, \
int src_pitch, \
int dst_pitch, \
long n) \
{ \
- return convert_u8_double_scaled (min_val, max_val, min, max, \
- src, dst, src_pitch, dst_pitch, n); \
+ convert_u8_double_scaled (c, min_val, max_val, min, max, \
+ src, dst, src_pitch, dst_pitch, n); \
} \
- static long \
- convert_double_ ## name (void *src, \
+ static void \
+ convert_double_ ## name (BablConversion *c, void *src, \
void *dst, \
int src_pitch, \
int dst_pitch, \
long n) \
{ \
- return convert_double_u8_scaled (min_val, max_val, min, max, \
- src, dst, src_pitch, dst_pitch, n); \
+ convert_double_u8_scaled (c, min_val, max_val, min, max, \
+ src, dst, src_pitch, dst_pitch, n); \
}
MAKE_CONVERSIONS (u8, 0.0, 1.0, 0x00, UINT8_MAX)
diff --git a/babl/base/util.h b/babl/base/util.h
index 2d346b4..e273087 100644
--- a/babl/base/util.h
+++ b/babl/base/util.h
@@ -51,7 +51,6 @@
dst[i]+=dst_pitch[i]; \
}
-#endif
#define BABL_USE_SRGB_GAMMA
@@ -109,3 +108,5 @@ babl_gamma_2_2_to_linearf (float value)
#define babl_linear_to_gamma_2_2f(value) (powf((value), (1.0f/2.2f)))
#define babl_gamma_2_2_to_linearf(value) (powf((value), 2.2f))
#endif
+
+#endif
diff --git a/configure b/configure
index d3dbcab..c808fee 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for babl 0.1.30.
+# Generated by GNU Autoconf 2.69 for babl 0.1.34.
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -587,8 +587,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='babl'
PACKAGE_TARNAME='babl'
-PACKAGE_VERSION='0.1.30'
-PACKAGE_STRING='babl 0.1.30'
+PACKAGE_VERSION='0.1.34'
+PACKAGE_STRING='babl 0.1.34'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
@@ -645,6 +645,7 @@ OS_UNIX_FALSE
OS_UNIX_TRUE
OS_WIN32_FALSE
OS_WIN32_TRUE
+LOG_LIB
THREAD_LIB
MATH_LIB
DIR_SEP
@@ -1380,7 +1381,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures babl 0.1.30 to adapt to many kinds of systems.
+\`configure' configures babl 0.1.34 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1452,7 +1453,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of babl 0.1.30:";;
+ short | recursive ) echo "Configuration of babl 0.1.34:";;
esac
cat <<\_ACEOF
@@ -1572,7 +1573,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-babl configure 0.1.30
+babl configure 0.1.34
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1937,7 +1938,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by babl $as_me 0.1.30, which was
+It was created by babl $as_me 0.1.34, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -2293,11 +2294,11 @@ ac_config_headers="$ac_config_headers config.h"
BABL_MAJOR_VERSION=0
BABL_MINOR_VERSION=1
-BABL_MICRO_VERSION=30
+BABL_MICRO_VERSION=34
BABL_INTERFACE_AGE=1
-BABL_BINARY_AGE=130
-BABL_VERSION=0.1.30
-BABL_REAL_VERSION=0.1.30
+BABL_BINARY_AGE=134
+BABL_VERSION=0.1.34
+BABL_REAL_VERSION=0.1.34
BABL_API_VERSION=0.1
@@ -2332,7 +2333,7 @@ fi
-BABL_LIBRARY_VERSION="129:1:129"
+BABL_LIBRARY_VERSION="133:1:133"
BABL_CURRENT_MINUS_AGE=0
@@ -2964,7 +2965,7 @@ fi
# Define the identity of the package.
PACKAGE='babl'
- VERSION='0.1.30'
+ VERSION='0.1.34'
# Some tools Automake needs.
@@ -13392,6 +13393,7 @@ fi
MATH_LIB=-lm
THREAD_LIB=-lpthread
+LOG_LIB=
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for native Win32" >&5
$as_echo_n "checking for native Win32... " >&6; }
case "$target_or_host" in
@@ -13407,6 +13409,7 @@ case "$target_or_host" in
PATH_SEP=':'
DIR_SEP='/'
THREAD_LIB=
+ LOG_LIB='-llog'
;;
*)
os_win32=no
@@ -13421,6 +13424,7 @@ $as_echo "$os_win32" >&6; }
+
if test "$os_win32" = "yes"; then
OS_WIN32_TRUE=
OS_WIN32_FALSE='#'
@@ -14860,7 +14864,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by babl $as_me 0.1.30, which was
+This file was extended by babl $as_me 0.1.34, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -14926,7 +14930,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-babl config.status 0.1.30
+babl config.status 0.1.34
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/configure.ac b/configure.ac
index 309fa48..dda45b1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -14,7 +14,7 @@ AC_PREREQ(2.54)
m4_define([babl_major_version], [0])
m4_define([babl_minor_version], [1])
-m4_define([babl_micro_version], [30])
+m4_define([babl_micro_version], [34])
m4_define([babl_real_version],
[babl_major_version.babl_minor_version.babl_micro_version])
m4_define([babl_version], [babl_real_version])
@@ -255,6 +255,7 @@ AM_CONDITIONAL(PLATFORM_WIN32, test "$platform_win32" = "yes")
MATH_LIB=-lm
THREAD_LIB=-lpthread
+LOG_LIB=
AC_MSG_CHECKING([for native Win32])
case "$target_or_host" in
*-*-mingw*)
@@ -269,6 +270,7 @@ case "$target_or_host" in
PATH_SEP=':'
DIR_SEP='/'
THREAD_LIB=
+ LOG_LIB='-llog'
;;
*)
os_win32=no
@@ -281,6 +283,7 @@ AC_SUBST(PATH_SEP)
AC_SUBST(DIR_SEP)
AC_SUBST(MATH_LIB)
AC_SUBST(THREAD_LIB)
+AC_SUBST(LOG_LIB)
AM_CONDITIONAL(OS_WIN32, test "$os_win32" = "yes")
AM_CONDITIONAL(OS_UNIX, test "$os_win32" != "yes")
diff --git a/docs/Makefile.am b/docs/Makefile.am
index e53d9a9..e612c7c 100644
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -1,7 +1,7 @@
# programs used for doc creation
-babl_fish_path_dhtml = $(top_builddir)/tests/babl_fish_path_dhtml$(EXEEXT)
-babl_fish_path_fitness = $(top_builddir)/tests/babl_fish_path_fitness$(EXEEXT)
-babl_html_dump = $(top_builddir)/tests/babl-html-dump$(EXEEXT)
+babl_fish_path_dhtml = $(top_builddir)/tools/babl_fish_path_dhtml$(EXEEXT)
+babl_fish_path_fitness = $(top_builddir)/tools/babl_fish_path_fitness$(EXEEXT)
+babl_html_dump = $(top_builddir)/tools/babl-html-dump$(EXEEXT)
.SILENT:
SUBDIRS= graphics
diff --git a/docs/Makefile.in b/docs/Makefile.in
index 8327ea8..94efe66 100644
--- a/docs/Makefile.in
+++ b/docs/Makefile.in
@@ -237,6 +237,7 @@ LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
+LOG_LIB = @LOG_LIB@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAINT = @MAINT@
@@ -334,9 +335,9 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
# programs used for doc creation
-babl_fish_path_dhtml = $(top_builddir)/tests/babl_fish_path_dhtml$(EXEEXT)
-babl_fish_path_fitness = $(top_builddir)/tests/babl_fish_path_fitness$(EXEEXT)
-babl_html_dump = $(top_builddir)/tests/babl-html-dump$(EXEEXT)
+babl_fish_path_dhtml = $(top_builddir)/tools/babl_fish_path_dhtml$(EXEEXT)
+babl_fish_path_fitness = $(top_builddir)/tools/babl_fish_path_fitness$(EXEEXT)
+babl_html_dump = $(top_builddir)/tools/babl-html-dump$(EXEEXT)
SUBDIRS = graphics
DIST_SUBDIRS = graphics
diff --git a/docs/graphics/Makefile.in b/docs/graphics/Makefile.in
index 235e296..93fe732 100644
--- a/docs/graphics/Makefile.in
+++ b/docs/graphics/Makefile.in
@@ -177,6 +177,7 @@ LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
+LOG_LIB = @LOG_LIB@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAINT = @MAINT@
diff --git a/docs/index-static.html.in b/docs/index-static.html.in
index 64a1267..a84422d 100644
--- a/docs/index-static.html.in
+++ b/docs/index-static.html.in
@@ -101,47 +101,31 @@
<strong>babl is a dynamic, any to any, pixel format translation library</strong>.
<br/>
</p>
-
- <p>It allows converting between different methods of storing <a href='http://en.wikipedia.org/wiki/Pixel'>pixels</a> known as <em>pixel formats</em> that have
- with different bitdepths and other data representations, color models and
- component permutations.</p>
-
- <p> A vocabulary to formulate new <em>pixel formats</em> from existing
- primitives is provided as well as the framework to add new color models and
- data types.
- </p>
-
-
-
- <!--<a name='Background'></a>
- <h2>Background</h2>
- <p> When creating various libraries and small tools that deal with
- computer graphics I have often created functions for converting
- raster images between different representations.
- </p>
-
- <p>Libraries to help with such conversions already do exist, but no
- extendable candidates have surfaced in my searches.
- </p>
-
- <p>The vocabulary developed in babl will most likely be part of
- <a href='http://www.gegl.org/'>GEGL</a>'s vocabulary to describe image
- buffers.
- </p>-->
+ <p>It allows converting between different methods of storing <a
+ href='http://en.wikipedia.org/wiki/Pixel'>pixels</a> known as
+ <em>pixel formats</em> that have with different bitdepths and other data
+ representations, color models, color spaces and component permutations.</p>
+ <p> A vocabulary to formulate new <em>pixel formats</em> from existing
+ primitives is provided as well as the framework to add new color models,
+ spaces and data types. </p>
<a name='Features'></a>
<h2>Features</h2>
<ul>
- <li>Fast.</li>
- <li>Accurate.</li>
- <li>Stable, small API.</li>
- <li>Self profiling and optimizing.</li>
- <li>ANSI C, works on win32, linux and mac, 32bit and 64bit systems.</li>
+ <li>ANSI C without external dependencies, works on win32, linux and mac,
+ 32bit and 64bit systems.</li>
+ <li>Stable, small API, with singleton objects returned.</li>
<li>Extendable with new formats, color models, components
and datatypes.</li>
- <li>Reference 64bit floating point conversions for datatypes and color models.</li>
+ <li>Can load color spaces from ICC v2 and v4 profiles containing RGB
+ matrix + TRC.</li>
+ <li>Reference 64bit floating point conversions for datatypes and color
+ models.</li>
+ <li>Self profiling and optimizing, optimizing accuracy and performance at
+ runtime when the best performing single or multi-step conversion
+ path is chosen.</li>
</ul>
<p><a href='http://www.gegl.org/'>GEGL</a> through <a
@@ -162,6 +146,10 @@
</p>
<pre>git clone git://git.gnome.org/babl</pre>
+
+ <a name='NEWS'></a>
+ <h2>NEWS</h2>
+
<p>The following is a list of the major changes that have gone into
each babl release. If there are significant improvements to babl when
a GEGL release is done a babl release is most often put out just prior
@@ -241,7 +229,7 @@ lab_buffer = malloc (pixel_count * 3 * sizeof (float));
lab_buffer, srgb_buffer, pixel_count<span class='paren'>);</span>
/* the data has now been transformed back to srgb data */</pre>
-
+
<p>If the existing pixel formats are not sufficient for your conversion
needs, new ones can be created on the fly. The constructor
will provide the prior created one if duplicates are registered. </p>
@@ -269,12 +257,41 @@ lab_buffer = malloc (pixel_count * 3 * sizeof (float));
</pre>
-->
-
- <a name='Vocabulary'></a>
- <h3 style='margin-bottom:0em;'>Vocabulary</h3>
+ <a name='ColorManagement'></a>
+ <h2>Color Management</h2>
+
+ <p>By default the babl API is assuming data to be (unbounded) sRGB data, data
+ being sRGB defines the conversion to and from gray-scale as well as the gamma
+ - or Transfer Response Curve, TRC, used for converting between linear and
+ non-linear variants of the data.
+ </p>
+
+ <p>There is also a babl API call for creating a format for a specific space.
+ <tt>babl_format_with_space("R'G'B' u16", babl_space ("Rec2020"))</tt> creates
+ a 16 bit integer format for the Rec2020 color space. Babl knows internally
+ about "sRGB", "Rec2020", "Adobe", "Apple" and "ProPhoto" spaces, as they are
+ defined with constants on their wikipedia pages.
+ </p>
+
+ <p>Additional spaces can be loaded from monitor-class matrix+TRC ICC v2 and
+ v4 profiles. Using babl_icc_make_space (see babl.h for details). The space of
+ a babl format can also be queried with babl_format_get_space.
+ </p>
+
+ <p>The conversions babl does with ICC profiles are according to what is known
+ as the relative-colorimetric intent, monitor profiles containing both the
+ matrices used by babl and 3d CLUTs (color look up tables) most often also do
+ relative-colorimetric transfer for the "perceptual" intent CLUTs, but with
+ a more flexible and possibly higher accuracy conversions. If babl adds support
+ for loading and using CLUTs it will be thus the perceptual
+ intent will by babl be considered a different albeit more accurate
+ relative-colorimetric RGB space.</p>
+
+ <a name='Vocabulary'></a>
+ <h3 style='margin-bottom:0em;'>Vocabulary</h3>
<!--BablBase-->
-<!--
+<!--
<a name='Extensions'></a>
<h3>Extensions</h3>
<p>
@@ -304,19 +321,13 @@ lab_buffer = malloc (pixel_count * 3 * sizeof (float));
<a name='Environment'></a>
<h2>Environment</h2>
- <p>If the environment variable <tt>BABL_STATS</tt> is set containting
- a html pixel format conversion usage matrix will be written to
- <tt>/tmp/babl-stats.html</tt>. This allows figuring out which
- conversions is taking up time during processing, and what shortcuts <a
- href='#Extending'>extensions</a> might be created or improved to
- make babl do it's job faster.
- </p>
-
<p>Through the environment variable <tt>BABL_TOLERANCE</tt> you can control
a speed/performance trade off that by default is set very low (0.000001)
values in the range 0.01-0.1 can provide reasonable preview performance
by allowing lower numerical accuracy</p>.
+ <p><tt>BABL_PATH</tt> contains the path of the directory, containing the .so extensions to babl.
+ </p>
<a name='Extending'></a>
<h2>Extending</h2>
@@ -355,32 +366,19 @@ lab_buffer = malloc (pixel_count * 3 * sizeof (float));
-->
- <!--
- <a name='ColorManagement'></a>
- <h2>Color Management</h2>
- <p> Babl is not a color management system, since it doesn't deal with
- ICC profiles. Babl is designed primarily for internal use when the
- color space is already known (sRGB, CIE Lab, Luminance or similar).</p>
-
- <p>
- It is also possible to register new color models that are managed by a
- color management system like <em>lcms</em>, take a look at the <em>lcms-lab</em>
- extensions for an example.</p>
- -->
-
- <a name='TODO'></a>
+ <a name='TODO'></a>
<!--TODO-->
- <a name='Copyright'></a>
- <h2>Copyright</h2>
+ <a name='Copyright'></a>
+ <h2>Copyright</h2>
- <p> Babl is free software; you can redistribute it and/or modify it
- under the terms of the <a href='COPYING.LESSER'>GNU Lesser General Public
- License</a> as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version. </p>
+ <p> Babl is free software; you can redistribute it and/or modify it
+ under the terms of the <a href='COPYING.LESSER'>GNU Lesser General Public
+ License</a> as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version. </p>
- <a name='Authors'></a>
- <h3>Authors</h3>
+ <a name='Authors'></a>
+ <h3>Authors</h3>
<!--AUTHORS-->
diff --git a/export-symbols b/export-symbols
new file mode 100644
index 0000000..2ba4bb8
--- /dev/null
+++ b/export-symbols
@@ -0,0 +1,69 @@
+babl_component
+babl_component_new
+babl_conversion_get_destination_space
+babl_conversion_get_source_space
+babl_conversion_new
+babl_cpu_accel_get_support
+babl_exit
+babl_fast_fish
+babl_fish
+babl_format
+babl_format_get_bytes_per_pixel
+babl_format_get_model
+babl_format_get_n_components
+babl_format_get_space
+babl_format_get_type
+babl_format_has_alpha
+babl_format_is_format_n
+babl_format_is_palette
+babl_format_n
+babl_format_new
+babl_format_with_space
+babl_free
+babl_get_name
+babl_get_name
+babl_get_user_data
+babl_get_version
+babl_icc_make_space
+babl_icc_get_key
+babl_init
+babl_introspect
+babl_malloc
+babl_model
+babl_model_new
+babl_new_palette
+babl_palette_reset
+babl_palette_set_palette
+babl_process
+babl_process
+babl_sampling
+babl_set_user_data
+babl_space
+babl_space_from_xyz
+babl_space_get_rgbtoxyz
+babl_space_to_xyz
+babl_ticks
+babl_type
+babl_type_new
+babl_space_to_icc
+babl_db_exist_by_name
+babl_db_find
+babl_db_init
+babl_db_exist_by_id
+babl_db_each
+babl_formats_count
+babl_format_class_for_each
+babl_model_class_for_each
+babl_type_class_for_each
+babl_conversion_class_for_each
+babl_set_extender
+babl_extension_quiet_log
+babl_fish_path
+babl_extender
+babl_class_name
+babl_sanity
+babl_type_is_symmetric
+babl_model_is_symmetric
+babl_fish_db
+babl_polynomial_approximate_gamma
+babl_backtrack
diff --git a/extensions/16bit.c b/extensions/16bit.c
index 96701ef..f8cdd21 100644
--- a/extensions/16bit.c
+++ b/extensions/16bit.c
@@ -25,8 +25,8 @@
#include "base/util.h"
#include "extensions/util.h"
-static inline long
-conv_rgbu16_rgbau16 (unsigned char *src,
+static inline void
+conv_rgbu16_rgbau16 (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
@@ -43,12 +43,10 @@ conv_rgbu16_rgbau16 (unsigned char *src,
*dst16++ = *src16++;
*dst16++ = 0xffff;
}
-
- return samples;
}
-static inline long
-conv_yu16_yau16 (unsigned char *src,
+static inline void
+conv_yu16_yau16 (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
@@ -63,8 +61,6 @@ conv_yu16_yau16 (unsigned char *src,
*dst16++ = *src16++;
*dst16++ = 0xffff;
}
-
- return samples;
}
int init (void);
diff --git a/extensions/CIE.c b/extensions/CIE.c
index 040c03c..d16d862 100644
--- a/extensions/CIE.c
+++ b/extensions/CIE.c
@@ -22,7 +22,7 @@
#include <math.h>
#include <string.h>
-#include "babl.h"
+#include "babl-internal.h"
#include "extensions/util.h"
#define DEGREES_PER_RADIAN (180 / 3.14159265358979323846)
@@ -137,13 +137,6 @@ static inline void CHab_to_ab (double C,
double H,
double *to_a,
double *to_b);
-
-static inline void RGB_to_XYZ (double R,
- double G,
- double B,
- double *to_X,
- double *to_Y,
- double *to_Z);
static inline void XYZ_to_LAB (double X,
double Y,
@@ -161,82 +154,6 @@ static inline void LAB_to_XYZ (double L,
double *to_Z
);
-static inline void XYZ_to_RGB (double X,
- double Y,
- double Z,
- double *to_R,
- double *to_G,
- double *to_B);
-
-static inline void
-RGB_to_XYZ (double R,
- double G,
- double B,
- double *to_X,
- double *to_Y,
- double *to_Z)
-{
- double RGBtoXYZ[3][3];
-
-/*
- * The variables below hard-code the D50-adapted sRGB RGB to XYZ matrix.
- *
- * In a properly ICC profile color-managed application, this matrix
- * is retrieved from the image's ICC profile's RGB colorants.
- *
- * */
- RGBtoXYZ[0][0]= 0.43603516;
- RGBtoXYZ[0][1]= 0.38511658;
- RGBtoXYZ[0][2]= 0.14305115;
- RGBtoXYZ[1][0]= 0.22248840;
- RGBtoXYZ[1][1]= 0.71690369;
- RGBtoXYZ[1][2]= 0.06060791;
- RGBtoXYZ[2][0]= 0.01391602;
- RGBtoXYZ[2][1]= 0.09706116;
- RGBtoXYZ[2][2]= 0.71392822;
-
-/* Convert RGB to XYZ */
- *to_X = RGBtoXYZ[0][0]*R + RGBtoXYZ[0][1]*G + RGBtoXYZ[0][2]*B;
- *to_Y = RGBtoXYZ[1][0]*R + RGBtoXYZ[1][1]*G + RGBtoXYZ[1][2]*B;
- *to_Z = RGBtoXYZ[2][0]*R + RGBtoXYZ[2][1]*G + RGBtoXYZ[2][2]*B;
-
-}
-
-static inline void
-XYZ_to_RGB (double X,
- double Y,
- double Z,
- double *to_R,
- double *to_G,
- double *to_B)
-{
- double XYZtoRGB[3][3];
-
-/*
- * The variables below hard-code the inverse of
- * the D50-adapted sRGB RGB to XYZ matrix.
- *
- * In a properly ICC profile color-managed application,
- * this matrix is the inverse of the matrix
- * retrieved from the image's ICC profile's RGB colorants.
- *
- */
- XYZtoRGB[0][0]= 3.134274799724;
- XYZtoRGB[0][1]= -1.617275708956;
- XYZtoRGB[0][2]= -0.490724283042;
- XYZtoRGB[1][0]= -0.978795575994;
- XYZtoRGB[1][1]= 1.916161689117;
- XYZtoRGB[1][2]= 0.033453331711;
- XYZtoRGB[2][0]= 0.071976988401;
- XYZtoRGB[2][1]= -0.228984974402;
- XYZtoRGB[2][2]= 1.405718224383;
-
-/* Convert XYZ to RGB */
- *to_R = XYZtoRGB[0][0] * X + XYZtoRGB[0][1] * Y + XYZtoRGB[0][2] * Z;
- *to_G = XYZtoRGB[1][0] * X + XYZtoRGB[1][1] * Y + XYZtoRGB[1][2] * Z;
- *to_B = XYZtoRGB[2][0] * X + XYZtoRGB[2][1] * Y + XYZtoRGB[2][2] * Z;
-}
-
static inline void
XYZ_to_LAB (double X,
double Y,
@@ -299,23 +216,24 @@ LAB_to_XYZ (double L,
*to_Z = zr * D50_WHITE_REF_Z;
}
-static long
-rgba_to_lab (char *src,
+static void
+rgba_to_lab (const Babl *conversion,char *src,
char *dst,
long n)
{
+ const Babl *space = babl_conversion_get_source_space (conversion);
while (n--)
{
- double R = ((double *) src)[0];
- double G = ((double *) src)[1];
- double B = ((double *) src)[2];
- double X, Y, Z, L, a, b;
-
+ double RGB[3] = {((double *) src)[0],
+ ((double *) src)[1],
+ ((double *) src)[2] };
+ double XYZ[3], L, a, b;
+
//convert RGB to XYZ
- RGB_to_XYZ (R, G, B, &X, &Y, &Z);
-
+ babl_space_to_xyz (space, RGB, XYZ);
+
//convert XYZ to Lab
- XYZ_to_LAB (X, Y, Z, &L, &a, &b);
+ XYZ_to_LAB (XYZ[0], XYZ[1], XYZ[2], &L, &a, &b);
((double *) dst)[0] = L;
((double *) dst)[1] = a;
@@ -324,14 +242,14 @@ rgba_to_lab (char *src,
src += sizeof (double) * 4;
dst += sizeof (double) * 3;
}
- return n;
}
-static long
-lab_to_rgba (char *src,
+static void
+lab_to_rgba (const Babl *conversion,char *src,
char *dst,
long n)
{
+ const Babl *space = babl_conversion_get_destination_space (conversion);
while (n--)
{
double L = ((double *) src)[0];
@@ -344,7 +262,15 @@ lab_to_rgba (char *src,
LAB_to_XYZ (L, a, b, &X, &Y, &Z);
//convert XYZ to RGB
- XYZ_to_RGB (X, Y, Z, &R, &G, &B);
+ {
+ double XYZ[3] = {X,Y,Z};
+ double RGB[3];
+ babl_space_from_xyz (space, XYZ, RGB);
+ R = RGB[0];
+ G = RGB[1];
+ B = RGB[2];
+ }
+
((double *) dst)[0] = R;
((double *) dst)[1] = G;
((double *) dst)[2] = B;
@@ -353,27 +279,27 @@ lab_to_rgba (char *src,
src += sizeof (double) * 3;
dst += sizeof (double) * 4;
}
- return n;
}
-static long
-rgba_to_laba (char *src,
+static void
+rgba_to_laba (const Babl *conversion,char *src,
char *dst,
long n)
{
+ const Babl *space = babl_conversion_get_source_space (conversion);
while (n--)
{
- double R = ((double *) src)[0];
- double G = ((double *) src)[1];
- double B = ((double *) src)[2];
+ double RGB[3] = {((double *) src)[0],
+ ((double *) src)[1],
+ ((double *) src)[2] };
double alpha = ((double *) src)[3];
- double X, Y, Z, L, a, b;
+ double XYZ[3], L, a, b;
//convert RGB to XYZ
- RGB_to_XYZ (R, G, B, &X, &Y, &Z);
+ babl_space_to_xyz (space, RGB, XYZ);
//convert XYZ to Lab
- XYZ_to_LAB (X, Y, Z, &L, &a, &b);
+ XYZ_to_LAB (XYZ[0], XYZ[1], XYZ[2], &L, &a, &b);
((double *) dst)[0] = L;
((double *) dst)[1] = a;
@@ -383,14 +309,14 @@ rgba_to_laba (char *src,
src += sizeof (double) * 4;
dst += sizeof (double) * 4;
}
- return n;
}
-static long
-laba_to_rgba (char *src,
+static void
+laba_to_rgba (const Babl *conversion,char *src,
char *dst,
long n)
{
+ const Babl *space = babl_conversion_get_destination_space (conversion);
while (n--)
{
double L = ((double *) src)[0];
@@ -404,7 +330,17 @@ laba_to_rgba (char *src,
LAB_to_XYZ (L, a, b, &X, &Y, &Z);
//convert XYZ to RGB
- XYZ_to_RGB (X, Y, Z, &R, &G, &B);
+ //XYZ_to_RGB (X, Y, Z, &R, &G, &B);
+
+ {
+ double XYZ[3] = {X,Y,Z};
+ double RGB[3];
+ babl_space_from_xyz (space, XYZ, RGB);
+ R = RGB[0];
+ G = RGB[1];
+ B = RGB[2];
+ }
+
((double *) dst)[0] = R;
((double *) dst)[1] = G;
((double *) dst)[2] = B;
@@ -413,7 +349,6 @@ laba_to_rgba (char *src,
src += sizeof (double) * 4;
dst += sizeof (double) * 4;
}
- return n;
}
static inline void
@@ -440,23 +375,26 @@ ab_to_CHab (double a,
*to_H += 360;
}
-static long
-rgba_to_lchab (char *src,
+static void
+rgba_to_lchab (const Babl *conversion,char *src,
char *dst,
long n)
{
+ const Babl *space = babl_conversion_get_source_space (conversion);
+
while (n--)
{
- double R = ((double *) src)[0];
- double G = ((double *) src)[1];
- double B = ((double *) src)[2];
- double X, Y, Z, L, a, b, C, H;
+ double RGB[3] = {((double *) src)[0],
+ ((double *) src)[1],
+ ((double *) src)[2] };
+ double XYZ[3], L, a, b, C, H;
//convert RGB to XYZ
- RGB_to_XYZ (R, G, B, &X, &Y, &Z);
+ babl_space_to_xyz (space, RGB, XYZ);
//convert XYZ to Lab
- XYZ_to_LAB (X, Y, Z, &L, &a, &b);
+ XYZ_to_LAB (XYZ[0], XYZ[1], XYZ[2], &L, &a, &b);
+
//convert Lab to LCH(ab)
ab_to_CHab (a, b, &C, &H);
@@ -468,14 +406,15 @@ rgba_to_lchab (char *src,
src += sizeof (double) * 4;
dst += sizeof (double) * 3;
}
- return n;
}
-static long
-lchab_to_rgba (char *src,
+static void
+lchab_to_rgba (const Babl *conversion,char *src,
char *dst,
long n)
{
+ const Babl *space = babl_conversion_get_source_space (conversion);
+
while (n--)
{
double L = ((double *) src)[0];
@@ -490,7 +429,15 @@ lchab_to_rgba (char *src,
LAB_to_XYZ (L, a, b, &X, &Y, &Z);
//Convert XYZ to RGB
- XYZ_to_RGB (X, Y, Z, &R, &G, &B);
+ {
+ double XYZ[3] = {X,Y,Z};
+ double RGB[3];
+ babl_space_from_xyz (space, XYZ, RGB);
+ R = RGB[0];
+ G = RGB[1];
+ B = RGB[2];
+ }
+
((double *) dst)[0] = R;
((double *) dst)[1] = G;
@@ -500,27 +447,28 @@ lchab_to_rgba (char *src,
src += sizeof (double) * 3;
dst += sizeof (double) * 4;
}
- return n;
}
-static long
-rgba_to_lchaba (char *src,
+static void
+rgba_to_lchaba (const Babl *conversion,char *src,
char *dst,
long n)
{
+ const Babl *space = babl_conversion_get_source_space (conversion);
+
while (n--)
{
- double R = ((double *) src)[0];
- double G = ((double *) src)[1];
- double B = ((double *) src)[2];
+ double RGB[3] = {((double *) src)[0],
+ ((double *) src)[1],
+ ((double *) src)[2] };
double alpha = ((double *) src)[3];
- double X, Y, Z, L, a, b, C, H;
+ double XYZ[3], L, a, b, C, H;
//convert RGB to XYZ
- RGB_to_XYZ (R, G, B, &X, &Y, &Z);
+ babl_space_to_xyz (space, RGB, XYZ);
//convert XYZ to Lab
- XYZ_to_LAB (X, Y, Z, &L, &a, &b);
+ XYZ_to_LAB (XYZ[0], XYZ[1], XYZ[2], &L, &a, &b);
//convert Lab to LCH(ab)
ab_to_CHab (a, b, &C, &H);
@@ -533,14 +481,14 @@ rgba_to_lchaba (char *src,
src += sizeof (double) * 4;
dst += sizeof (double) * 4;
}
- return n;
}
-static long
-lchaba_to_rgba (char *src,
+static void
+lchaba_to_rgba (const Babl *conversion,char *src,
char *dst,
long n)
{
+ const Babl *space = babl_conversion_get_destination_space (conversion);
while (n--)
{
double L = ((double *) src)[0];
@@ -556,7 +504,14 @@ lchaba_to_rgba (char *src,
LAB_to_XYZ (L, a, b, &X, &Y, &Z);
//Convert XYZ to RGB
- XYZ_to_RGB (X, Y, Z, &R, &G, &B);
+ {
+ double XYZ[3] = {X,Y,Z};
+ double RGB[3];
+ babl_space_from_xyz (space, XYZ, RGB);
+ R = RGB[0];
+ G = RGB[1];
+ B = RGB[2];
+ }
((double *) dst)[0] = R;
((double *) dst)[1] = G;
@@ -566,7 +521,6 @@ lchaba_to_rgba (char *src,
src += sizeof (double) * 4;
dst += sizeof (double) * 4;
}
- return n;
}
@@ -637,8 +591,8 @@ cubef (float f)
return f * f * f;
}
-static long
-Yaf_to_Laf (float *src,
+static void
+Yaf_to_Laf (const Babl *conversion,float *src,
float *dst,
long samples)
{
@@ -656,12 +610,10 @@ Yaf_to_Laf (float *src,
src += 2;
dst += 2;
}
-
- return samples;
}
-static long
-rgbf_to_Labf (float *src,
+static void
+rgbf_to_Labf (const Babl *conversion,float *src,
float *dst,
long samples)
{
@@ -692,12 +644,10 @@ rgbf_to_Labf (float *src,
src += 3;
dst += 3;
}
-
- return samples;
}
-static long
-rgbaf_to_Labaf (float *src,
+static void
+rgbaf_to_Labaf (const Babl *conversion,float *src,
float *dst,
long samples)
{
@@ -730,12 +680,10 @@ rgbaf_to_Labaf (float *src,
src += 4;
dst += 4;
}
-
- return samples;
}
-static long
-Labf_to_rgbf (float *src,
+static void
+Labf_to_rgbf (const Babl *conversion,float *src,
float *dst,
long samples)
{
@@ -766,12 +714,10 @@ Labf_to_rgbf (float *src,
src += 3;
dst += 3;
}
-
- return samples;
}
-static long
-Labaf_to_rgbaf (float *src,
+static void
+Labaf_to_rgbaf (const Babl *conversion,float *src,
float *dst,
long samples)
{
@@ -804,12 +750,10 @@ Labaf_to_rgbaf (float *src,
src += 4;
dst += 4;
}
-
- return samples;
}
-static long
-Labf_to_Lchabf (float *src,
+static void
+Labf_to_Lchabf (const Babl *conversion,float *src,
float *dst,
long samples)
{
@@ -835,12 +779,10 @@ Labf_to_Lchabf (float *src,
src += 3;
dst += 3;
}
-
- return samples;
}
-static long
-Lchabf_to_Labf (float *src,
+static void
+Lchabf_to_Labf (const Babl *conversion,float *src,
float *dst,
long samples)
{
@@ -862,12 +804,10 @@ Lchabf_to_Labf (float *src,
src += 3;
dst += 3;
}
-
- return samples;
}
-static long
-Labaf_to_Lchabaf (float *src,
+static void
+Labaf_to_Lchabaf (const Babl *conversion,float *src,
float *dst,
long samples)
{
@@ -895,12 +835,10 @@ Labaf_to_Lchabaf (float *src,
src += 4;
dst += 4;
}
-
- return samples;
}
-static long
-Lchabaf_to_Labaf (float *src,
+static void
+Lchabaf_to_Labaf (const Babl *conversion,float *src,
float *dst,
long samples)
{
@@ -924,8 +862,6 @@ Lchabaf_to_Labaf (float *src,
src += 4;
dst += 4;
}
-
- return samples;
}
static void
@@ -1142,9 +1078,10 @@ formats (void)
/******** begin integer RGB/CIE color space conversions **************/
-static inline long
-convert_double_u8_scaled (double min_val,
- double max_val,
+static inline void
+convert_double_u8_scaled (const Babl *conversion,
+ double min_val,
+ double max_val,
unsigned char min,
unsigned char max,
char *src,
@@ -1169,11 +1106,11 @@ convert_double_u8_scaled (double min_val,
src += src_pitch;
dst += dst_pitch;
}
- return n;
}
-static inline long
-convert_u8_double_scaled (double min_val,
+static inline void
+convert_u8_double_scaled (const Babl *conversion,
+ double min_val,
double max_val,
unsigned char min,
unsigned char max,
@@ -1200,29 +1137,28 @@ convert_u8_double_scaled (double min_val,
dst += dst_pitch;
src += src_pitch;
}
- return n;
}
#define MAKE_CONVERSIONS(name, min_val, max_val, min, max) \
- static long \
- convert_ ## name ## _double (char *src, \
+ static void \
+ convert_ ## name ## _double (const Babl *c, char *src, \
char *dst, \
int src_pitch, \
int dst_pitch, \
long n) \
{ \
- return convert_u8_double_scaled (min_val, max_val, min, max, \
- src, dst, src_pitch, dst_pitch, n); \
+ convert_u8_double_scaled (c, min_val, max_val, min, max, \
+ src, dst, src_pitch, dst_pitch, n); \
} \
- static long \
- convert_double_ ## name (char *src, \
+ static void \
+ convert_double_ ## name (const Babl *c, char *src, \
char *dst, \
int src_pitch, \
int dst_pitch, \
long n) \
{ \
- return convert_double_u8_scaled (min_val, max_val, min, max, \
- src, dst, src_pitch, dst_pitch, n); \
+ convert_double_u8_scaled (c, min_val, max_val, min, max, \
+ src, dst, src_pitch, dst_pitch, n); \
}
/* source ICC.1:2004-10 */
@@ -1282,8 +1218,9 @@ types_u8 (void)
);
}
-static inline long
-convert_double_u16_scaled (double min_val,
+static inline void
+convert_double_u16_scaled (const Babl *conversion,
+ double min_val,
double max_val,
unsigned short min,
unsigned short max,
@@ -1309,11 +1246,11 @@ convert_double_u16_scaled (double min_val,
dst += dst_pitch;
src += src_pitch;
}
- return n;
}
-static inline long
-convert_u16_double_scaled (double min_val,
+static inline void
+convert_u16_double_scaled (const Babl *conversion,
+ double min_val,
double max_val,
unsigned short min,
unsigned short max,
@@ -1339,29 +1276,28 @@ convert_u16_double_scaled (double min_val,
dst += dst_pitch;
src += src_pitch;
}
- return n;
}
#define MAKE_CONVERSIONS(name, min_val, max_val, min, max) \
- static long \
- convert_ ## name ## _double (char *src, \
+ static void \
+ convert_ ## name ## _double (const Babl *c, char *src, \
char *dst, \
int src_pitch, \
int dst_pitch, \
long n) \
{ \
- return convert_u16_double_scaled (min_val, max_val, min, max, \
- src, dst, src_pitch, dst_pitch, n); \
+ convert_u16_double_scaled (c, min_val, max_val, min, max, \
+ src, dst, src_pitch, dst_pitch, n); \
} \
- static long \
- convert_double_ ## name (char *src, \
+ static void \
+ convert_double_ ## name (const Babl *c, char *src, \
char *dst, \
int src_pitch, \
int dst_pitch, \
long n) \
{ \
- return convert_double_u16_scaled (min_val, max_val, min, max, \
- src, dst, src_pitch, dst_pitch, n); \
+ convert_double_u16_scaled (c, min_val, max_val, min, max, \
+ src, dst, src_pitch, dst_pitch, n); \
}
MAKE_CONVERSIONS (u16_l, 0.0, 100.0, 0x00, 0xffff)
diff --git a/extensions/HCY.c b/extensions/HCY.c
index 0993842..82b1d69 100644
--- a/extensions/HCY.c
+++ b/extensions/HCY.c
@@ -35,19 +35,19 @@
#define RGB_LUMA_BLUE 0.114 //0.0722
#define EPSILON 1e-10
-static long rgba_to_hcya (char *src,
+static void rgba_to_hcya (const Babl *conversion,char *src,
char *dst,
long samples);
-static long hcya_to_rgba (char *src,
+static void hcya_to_rgba (const Babl *conversion,char *src,
char *dst,
long samples);
-static long rgba_to_hcy (char *src,
+static void rgba_to_hcy (const Babl *conversion,char *src,
char *dst,
long samples);
-static long hcy_to_rgba (char *src,
+static void hcy_to_rgba (const Babl *conversion,char *src,
char *dst,
long samples);
@@ -286,8 +286,8 @@ hcy_to_rgba_step (char *src,
((double *) dst)[2] = gamma_2_2_to_linear (blue);
}
-static long
-rgba_to_hcya (char *src,
+static void
+rgba_to_hcya (const Babl *conversion,char *src,
char *dst,
long samples)
{
@@ -304,12 +304,10 @@ rgba_to_hcya (char *src,
src += 4 * sizeof (double);
dst += 4 * sizeof (double);
}
-
- return samples;
}
-static long
-hcya_to_rgba (char *src,
+static void
+hcya_to_rgba (const Babl *conversion,char *src,
char *dst,
long samples)
{
@@ -326,12 +324,10 @@ hcya_to_rgba (char *src,
src += 4 * sizeof (double);
dst += 4 * sizeof (double);
}
-
- return samples;
}
-static long
-rgba_to_hcy (char *src,
+static void
+rgba_to_hcy (const Babl *conversion,char *src,
char *dst,
long samples)
{
@@ -344,12 +340,10 @@ rgba_to_hcy (char *src,
src += 4 * sizeof (double);
dst += 3 * sizeof (double);
}
-
- return samples;
}
-static long
-hcy_to_rgba (char *src,
+static void
+hcy_to_rgba (const Babl *conversion,char *src,
char *dst,
long samples)
{
@@ -364,6 +358,4 @@ hcy_to_rgba (char *src,
src += 3 * sizeof (double);
dst += 4 * sizeof (double);
}
-
- return samples;
}
diff --git a/extensions/HSL.c b/extensions/HSL.c
index 827e028..88f8705 100644
--- a/extensions/HSL.c
+++ b/extensions/HSL.c
@@ -27,16 +27,16 @@
#define MAX(a,b) ((a < b) ? b : a)
#define EPSILON 1.0e-10
-static long rgba_to_hsla (char *src,
+static void rgba_to_hsla (const Babl *conversion,char *src,
char *dst,
long samples);
-static long hsla_to_rgba (char *src,
+static void hsla_to_rgba (const Babl *conversion,char *src,
char *dst,
long samples);
-static long rgba_to_hsl (char *src,
+static void rgba_to_hsl (const Babl *conversion,char *src,
char *dst,
long samples);
-static long hsl_to_rgba (char *src,
+static void hsl_to_rgba (const Babl *conversion,char *src,
char *dst,
long samples);
static void rgb_to_hsl_step (double *src,
@@ -145,7 +145,8 @@ rgb_to_hsl_step (double* src,
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: break;
+ default: hue = 0.0;
+ break;
}
hue /= 6.0;
}
@@ -156,8 +157,8 @@ rgb_to_hsl_step (double* src,
}
-static long
-rgba_to_hsla (char *src,
+static void
+rgba_to_hsla (const Babl *conversion,char *src,
char *dst,
long samples)
{
@@ -174,13 +175,11 @@ rgba_to_hsla (char *src,
src += 4 * sizeof (double);
dst += 4 * sizeof (double);
}
-
- return samples;
}
-static long
-rgba_to_hsl (char *src,
+static void
+rgba_to_hsl (const Babl *conversion,char *src,
char *dst,
long samples)
{
@@ -193,8 +192,6 @@ rgba_to_hsl (char *src,
src += 4 * sizeof (double);
dst += 3 * sizeof (double);
}
-
- return samples;
}
@@ -243,8 +240,8 @@ hsl_to_rgb_step (double *src,
}
-static long
-hsla_to_rgba (char *src,
+static void
+hsla_to_rgba (const Babl *conversion,char *src,
char *dst,
long samples)
{
@@ -261,13 +258,11 @@ hsla_to_rgba (char *src,
src += 4 * sizeof (double);
dst += 4 * sizeof (double);
}
-
- return samples;
}
-static long
-hsl_to_rgba (char *src,
+static void
+hsl_to_rgba (const Babl *conversion,char *src,
char *dst,
long samples)
{
@@ -282,6 +277,4 @@ hsl_to_rgba (char *src,
src += 3 * sizeof (double);
dst += 4 * sizeof (double);
}
-
- return samples;
}
diff --git a/extensions/HSV.c b/extensions/HSV.c
index c830a0c..f4bf01f 100644
--- a/extensions/HSV.c
+++ b/extensions/HSV.c
@@ -32,19 +32,19 @@
#define MAX(a,b) (a < b) ? b : a;
#define EPSILON 1.0e-10
-static long rgba_to_hsva (char *src,
+static void rgba_to_hsva (const Babl *conversion,char *src,
char *dst,
long samples);
-static long hsva_to_rgba (char *src,
+static void hsva_to_rgba (const Babl *conversion,char *src,
char *dst,
long samples);
-static long rgba_to_hsv (char *src,
+static void rgba_to_hsv (const Babl *conversion,char *src,
char *dst,
long samples);
-static long hsv_to_rgba (char *src,
+static void hsv_to_rgba (const Babl *conversion,char *src,
char *dst,
long samples);
@@ -274,8 +274,8 @@ hsv_to_rgba_step (char *src,
((double *) dst)[2] = gamma_2_2_to_linear (blue);
}
-static long
-rgba_to_hsva (char *src,
+static void
+rgba_to_hsva (const Babl *conversion,char *src,
char *dst,
long samples)
{
@@ -292,12 +292,10 @@ rgba_to_hsva (char *src,
src += 4 * sizeof (double);
dst += 4 * sizeof (double);
}
-
- return samples;
}
-static long
-hsva_to_rgba (char *src,
+static void
+hsva_to_rgba (const Babl *conversion,char *src,
char *dst,
long samples)
{
@@ -314,12 +312,10 @@ hsva_to_rgba (char *src,
src += 4 * sizeof (double);
dst += 4 * sizeof (double);
}
-
- return samples;
}
-static long
-rgba_to_hsv (char *src,
+static void
+rgba_to_hsv (const Babl *conversion,char *src,
char *dst,
long samples)
{
@@ -332,12 +328,10 @@ rgba_to_hsv (char *src,
src += 4 * sizeof (double);
dst += 3 * sizeof (double);
}
-
- return samples;
}
-static long
-hsv_to_rgba (char *src,
+static void
+hsv_to_rgba (const Babl *conversion,char *src,
char *dst,
long samples)
{
@@ -352,6 +346,4 @@ hsv_to_rgba (char *src,
src += 3 * sizeof (double);
dst += 4 * sizeof (double);
}
-
- return samples;
}
diff --git a/extensions/Makefile.am b/extensions/Makefile.am
index f09ec87..b103c93 100644
--- a/extensions/Makefile.am
+++ b/extensions/Makefile.am
@@ -66,8 +66,8 @@ ycbcr_la_SOURCES = ycbcr.c
float_la_SOURCES = float.c
fast_float_la_SOURCES = fast-float.c
-LIBS = $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la $(MATH_LIB) \
- $(THREAD_LIB)
+LIBS = $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
+ $(MATH_LIB) $(THREAD_LIB)
sse2_float_la_CFLAGS = $(SSE2_EXTRA_CFLAGS)
sse2_int8_la_CFLAGS = $(SSE2_EXTRA_CFLAGS)
diff --git a/extensions/Makefile.in b/extensions/Makefile.in
index 75c9e3e..104f9ba 100644
--- a/extensions/Makefile.in
+++ b/extensions/Makefile.in
@@ -362,12 +362,13 @@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
-LIBS = $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la $(MATH_LIB) \
- $(THREAD_LIB)
+LIBS = $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
+ $(MATH_LIB) $(THREAD_LIB)
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
+LOG_LIB = @LOG_LIB@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAINT = @MAINT@
diff --git a/extensions/cairo.c b/extensions/cairo.c
index 4f82e8d..114194a 100644
--- a/extensions/cairo.c
+++ b/extensions/cairo.c
@@ -19,14 +19,15 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
-#include "babl.h"
+#include "config.h"
+#include "babl-internal.h"
#include "base/util.h"
int init (void);
-static inline long
-conv_rgba8_cairo24_le (unsigned char *src, unsigned char *dst, long samples)
+static inline void
+conv_rgba8_cairo24_le (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
uint32_t *srci = (void *)src;
@@ -41,11 +42,10 @@ conv_rgba8_cairo24_le (unsigned char *src, unsigned char *dst, long samples)
uint32_t blue = red_blue >> 16;
*dsti++ = green_alpha | red | blue | 0xff000000;
}
- return samples;
}
-static inline long
-conv_rgb8_cairo24_le (unsigned char *src, unsigned char *dst, long samples)
+static inline void
+conv_rgb8_cairo24_le (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
while (n--)
@@ -58,14 +58,13 @@ conv_rgb8_cairo24_le (unsigned char *src, unsigned char *dst, long samples)
*dst++ = red;
*dst++ = 255;
}
- return samples;
}
#if 0
-static inline long
-conv_rgbA8_premul_cairo32_le (unsigned char *src, unsigned char *dst, long samples)
+static inline void
+conv_rgbA8_premul_cairo32_le (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
while (n--)
@@ -80,12 +79,11 @@ conv_rgbA8_premul_cairo32_le (unsigned char *src, unsigned char *dst, long sampl
*dst++ = red;
*dst++ = alpha;
}
- return samples;
}
#else
-static inline long
-conv_rgbA8_premul_cairo32_le (unsigned char *src, unsigned char *dst, long samples)
+static inline void
+conv_rgbA8_premul_cairo32_le (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
uint32_t *srci = (void *)src;
@@ -100,11 +98,10 @@ conv_rgbA8_premul_cairo32_le (unsigned char *src, unsigned char *dst, long sampl
uint32_t blue = red_blue >> 16;
*dsti++ = green_alpha | red | blue;
}
- return samples;
}
#endif
-static long conv_cairo32_rgbA8_premul_le (unsigned char *src, unsigned char *dst, long samples)
+static void conv_cairo32_rgbA8_premul_le (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
while (n--)
@@ -119,11 +116,10 @@ static long conv_cairo32_rgbA8_premul_le (unsigned char *src, unsigned char *dst
*dst++ = blue;
*dst++ = alpha;
}
- return samples;
}
-static long conv_cairo32_rgbAF_premul_le (unsigned char *src, unsigned char *dst_char, long samples)
+static void conv_cairo32_rgbAF_premul_le (const Babl *conversion,unsigned char *src, unsigned char *dst_char, long samples)
{
long n = samples;
float *dst = (void*)dst_char;
@@ -139,11 +135,10 @@ static long conv_cairo32_rgbAF_premul_le (unsigned char *src, unsigned char *dst
*dst++ = blue / 255.0;
*dst++ = alpha / 255.0;
}
- return samples;
}
-static inline long
-conv_rgbA8_cairo32_le (unsigned char *src, unsigned char *dst, long samples)
+static inline void
+conv_rgbA8_cairo32_le (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
while (n--)
@@ -159,11 +154,10 @@ conv_rgbA8_cairo32_le (unsigned char *src, unsigned char *dst, long samples)
*dst++ = div_255 (red * alpha);
*dst++ = alpha;
}
- return samples;
}
-static inline long
-conv_rgb8_cairo32_le (unsigned char *src, unsigned char *dst, long samples)
+static inline void
+conv_rgb8_cairo32_le (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
while (n--)
@@ -177,14 +171,13 @@ conv_rgb8_cairo32_le (unsigned char *src, unsigned char *dst, long samples)
*dst++ = red;
*dst++ = 0xff;
}
- return samples;
}
-static inline long
-conv_yA8_cairo32_le (unsigned char *src, unsigned char *dst, long samples)
+static inline void
+conv_yA8_cairo32_le (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
while (n--)
@@ -200,11 +193,10 @@ conv_yA8_cairo32_le (unsigned char *src, unsigned char *dst, long samples)
*dst++ = val;
*dst++ = alpha;
}
- return samples;
}
-static inline long
-conv_yA16_cairo32_le (unsigned char *src, unsigned char *dst, long samples)
+static inline void
+conv_yA16_cairo32_le (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
uint16_t *ssrc = (void*) src;
@@ -218,11 +210,10 @@ conv_yA16_cairo32_le (unsigned char *src, unsigned char *dst, long samples)
*dst++ = (alpha * 0xff + 0.5f);
ssrc+=2;
}
- return samples;
}
-static inline long
-conv_y8_cairo32_le (unsigned char *src, unsigned char *dst, long samples)
+static inline void
+conv_y8_cairo32_le (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
while (n--)
@@ -233,11 +224,10 @@ conv_y8_cairo32_le (unsigned char *src, unsigned char *dst, long samples)
*dst++ = val;
*dst++ = 0xff;
}
- return samples;
}
-static inline long
-conv_y16_cairo32_le (unsigned char *src, unsigned char *dst, long samples)
+static inline void
+conv_y16_cairo32_le (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
uint16_t *s16 = (void*)src;
@@ -252,11 +242,10 @@ conv_y16_cairo32_le (unsigned char *src, unsigned char *dst, long samples)
*dst++ = val;
*dst++ = 0xff;
}
- return samples;
}
-static long
-conv_rgbA_gamma_float_cairo32_le (unsigned char *src,
+static void
+conv_rgbA_gamma_float_cairo32_le (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
@@ -276,14 +265,16 @@ conv_rgbA_gamma_float_cairo32_le (unsigned char *src,
*cdst++ = val >= 0xff ? 0xff : val <= 0 ? 0 : val;
fsrc+=4;
}
- return samples;
}
-static long
-conv_rgbafloat_cairo32_le (unsigned char *src,
+static void
+conv_rgbafloat_cairo32_le (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
+ const Babl *space = babl_conversion_get_destination_space (conversion);
+ const Babl **trc = (void*)space->space.trc;
+
float *fsrc = (float *) src;
unsigned char *cdst = (unsigned char *) dst;
int n = samples;
@@ -296,11 +287,11 @@ conv_rgbafloat_cairo32_le (unsigned char *src,
float alpha = *fsrc++;
if (alpha >= 1.0)
{
- int val = babl_linear_to_gamma_2_2f (blue) * 0xff + 0.5f;
+ int val = babl_trc_from_linear (trc[2], blue) * 0xff + 0.5f;
*cdst++ = val >= 0xff ? 0xff : val <= 0 ? 0 : val;
- val = babl_linear_to_gamma_2_2f (green) * 0xff + 0.5f;
+ val = babl_trc_from_linear (trc[1], green) * 0xff + 0.5f;
*cdst++ = val >= 0xff ? 0xff : val <= 0 ? 0 : val;
- val = babl_linear_to_gamma_2_2f (red) * 0xff + 0.5f;
+ val = babl_trc_from_linear (trc[0], red) * 0xff + 0.5f;
*cdst++ = val >= 0xff ? 0xff : val <= 0 ? 0 : val;
*cdst++ = 0xff;
}
@@ -312,24 +303,25 @@ conv_rgbafloat_cairo32_le (unsigned char *src,
else
{
float balpha = alpha * 0xff;
- int val = babl_linear_to_gamma_2_2f (blue) * balpha + 0.5f;
+ int val = babl_trc_from_linear (trc[2], blue) * balpha + 0.5f;
*cdst++ = val >= 0xff ? 0xff : val <= 0 ? 0 : val;
- val = babl_linear_to_gamma_2_2f (green) * balpha + 0.5f;
+ val = babl_trc_from_linear (trc[1], green) * balpha + 0.5f;
*cdst++ = val >= 0xff ? 0xff : val <= 0 ? 0 : val;
- val = babl_linear_to_gamma_2_2f (red) * balpha + 0.5f;
+ val = babl_trc_from_linear (trc[0], red) * balpha + 0.5f;
*cdst++ = val >= 0xff ? 0xff : val <= 0 ? 0 : val;
*cdst++ = balpha + 0.5f;
}
}
- return samples;
}
-static long
-conv_yafloat_cairo32_le (unsigned char *src,
+static void
+conv_yafloat_cairo32_le (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
+ const Babl *space = babl_conversion_get_destination_space (conversion);
+ const Babl **trc = (void*)space->space.trc;
float *fsrc = (float *) src;
unsigned char *cdst = (unsigned char *) dst;
int n = samples;
@@ -340,7 +332,7 @@ conv_yafloat_cairo32_le (unsigned char *src,
float alpha = *fsrc++;
if (alpha >= 1.0)
{
- int val = babl_linear_to_gamma_2_2f (gray) * 0xff + 0.5f;
+ int val = babl_trc_from_linear (trc[0], gray) * 0xff + 0.5f;
val = val >= 0xff ? 0xff : val <= 0 ? 0 : val;
*cdst++ = val;
*cdst++ = val;
@@ -355,7 +347,7 @@ conv_yafloat_cairo32_le (unsigned char *src,
else
{
float balpha = alpha * 0xff;
- int val = babl_linear_to_gamma_2_2f (gray) * balpha + 0.5f;
+ int val = babl_trc_from_linear (trc[0], gray) * balpha + 0.5f;
val = val >= 0xff ? 0xff : val <= 0 ? 0 : val;
*cdst++ = val;
*cdst++ = val;
@@ -363,7 +355,6 @@ conv_yafloat_cairo32_le (unsigned char *src,
*cdst++ = balpha + 0.5f;
}
}
- return samples;
}
int
@@ -418,7 +409,6 @@ init (void)
babl_conversion_new (babl_format ("Y'A u16"), f32, "linear",
conv_yA16_cairo32_le, NULL);
-
babl_conversion_new (babl_format ("Y' u8"), f32, "linear",
conv_y8_cairo32_le, NULL);
babl_conversion_new (babl_format ("Y' u16"), f32, "linear",
diff --git a/extensions/fast-float.c b/extensions/fast-float.c
index 163ffe8..328cbff 100644
--- a/extensions/fast-float.c
+++ b/extensions/fast-float.c
@@ -287,8 +287,8 @@ babl_lookup_free (BablLookup *lookup)
}
#endif
-static INLINE long
-conv_rgbaF_linear_rgbAF_gamma (unsigned char *src,
+static INLINE void
+conv_rgbaF_linear_rgbAF_gamma (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
@@ -324,13 +324,12 @@ conv_rgbaF_linear_rgbAF_gamma (unsigned char *src,
*fdst++ = alpha;
}
}
- return samples;
}
-static INLINE long
-conv_rgbaF_linear_rgba8_gamma (unsigned char *src,
+static INLINE void
+conv_rgbaF_linear_rgba8_gamma (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
@@ -363,11 +362,10 @@ conv_rgbaF_linear_rgba8_gamma (unsigned char *src,
*cdst++ = val >= 0xff ? 0xff : val <= 0 ? 0 : val;
}
}
- return samples;
}
-static INLINE long
-conv_rgbaF_linear_rgbA8_gamma (unsigned char *src,
+static INLINE void
+conv_rgbaF_linear_rgbA8_gamma (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
@@ -408,11 +406,10 @@ conv_rgbaF_linear_rgbA8_gamma (unsigned char *src,
*cdst++ = balpha + 0.5f;
}
}
- return samples;
}
-static INLINE long
-conv_yaF_linear_rgbA8_gamma (unsigned char *src,
+static INLINE void
+conv_yaF_linear_rgbA8_gamma (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
@@ -447,13 +444,12 @@ conv_yaF_linear_rgbA8_gamma (unsigned char *src,
*cdst++ = balpha + 0.5f;
}
}
- return samples;
}
-static long
-conv_rgbaF_linear_rgbA8_gamma_cairo (unsigned char *src,
+static void
+conv_rgbaF_linear_rgbA8_gamma_cairo (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
@@ -494,11 +490,10 @@ conv_rgbaF_linear_rgbA8_gamma_cairo (unsigned char *src,
*cdst++ = balpha + 0.5f;
}
}
- return samples;
}
-static INLINE long
-conv_rgbAF_linear_rgbAF_gamma (unsigned char *src,
+static INLINE void
+conv_rgbAF_linear_rgbAF_gamma (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
@@ -535,11 +530,10 @@ conv_rgbAF_linear_rgbAF_gamma (unsigned char *src,
*fdst++ = alpha;
}
}
- return samples;
}
-static INLINE long
-conv_rgbaF_linear_rgbaF_gamma (unsigned char *src,
+static INLINE void
+conv_rgbaF_linear_rgbaF_gamma (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
@@ -554,11 +548,10 @@ conv_rgbaF_linear_rgbaF_gamma (unsigned char *src,
*fdst++ = linear_to_gamma_2_2_lut (*fsrc++);
*fdst++ = *fsrc++;
}
- return samples;
}
-static INLINE long
-conv_rgbF_linear_rgbF_gamma (unsigned char *src,
+static INLINE void
+conv_rgbF_linear_rgbF_gamma (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
@@ -572,12 +565,11 @@ conv_rgbF_linear_rgbF_gamma (unsigned char *src,
*fdst++ = linear_to_gamma_2_2_lut (*fsrc++);
*fdst++ = linear_to_gamma_2_2_lut (*fsrc++);
}
- return samples;
}
-static INLINE long
-conv_rgbaF_gamma_rgbaF_linear (unsigned char *src,
+static INLINE void
+conv_rgbaF_gamma_rgbaF_linear (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
@@ -592,11 +584,10 @@ conv_rgbaF_gamma_rgbaF_linear (unsigned char *src,
*fdst++ = gamma_2_2_to_linear_lut (*fsrc++);
*fdst++ = *fsrc++;
}
- return samples;
}
-static INLINE long
-conv_rgbF_gamma_rgbF_linear (unsigned char *src,
+static INLINE void
+conv_rgbF_gamma_rgbF_linear (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
@@ -610,7 +601,6 @@ conv_rgbF_gamma_rgbF_linear (unsigned char *src,
*fdst++ = gamma_2_2_to_linear_lut (*fsrc++);
*fdst++ = gamma_2_2_to_linear_lut (*fsrc++);
}
- return samples;
}
#define o(src, dst) \
diff --git a/extensions/float-half.c b/extensions/float-half.c
index ff37625..2c09ba0 100644
--- a/extensions/float-half.c
+++ b/extensions/float-half.c
@@ -75,7 +75,7 @@
#include "babl.h"
#include "extensions/util.h"
-static void halfp2singles(void *target, const void *source, long numel)
+static void halfp2singles_fun(void *target, const void *source, long numel)
{
uint16_t *hp = (uint16_t *) source; // Type pun input as an unsigned 16-bit int
uint32_t *xp = (uint32_t *) target; // Type pun output as an unsigned 32-bit int
@@ -122,8 +122,162 @@ static void halfp2singles(void *target, const void *source, long numel)
}
}
+static float half_float_table[65536];
+
+static void halfp2singles(void *target, const void *source, long numel)
+{
+ uint16_t *src = (uint16_t *) source;
+ float *dst = (float *) target;
+ int i;
+ for (i = 0; i < numel; i++)
+ {
+ dst[i] = half_float_table[src[i]];
+ }
+}
+
+/* from table based approach from qcms/blink/webkit */
+
+const unsigned short half_float_base_table[512] = {
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,1,2,4,8,16,32,64,128,256,
+512,1024,2048,3072,4096,5120,6144,7168,8192,9216,10240,11264,12288,13312,14336,15360,
+16384,17408,18432,19456,20480,21504,22528,23552,24576,25600,26624,27648,28672,29696,30720,31744,
+31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,
+31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,
+31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,
+31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,
+31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,
+31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,
+31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,31744,
+32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,
+32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,
+32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,
+32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,
+32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,
+32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,32768,
+32768,32768,32768,32768,32768,32768,32768,32769,32770,32772,32776,32784,32800,32832,32896,33024,
+33280,33792,34816,35840,36864,37888,38912,39936,40960,41984,43008,44032,45056,46080,47104,48128,
+49152,50176,51200,52224,53248,54272,55296,56320,57344,58368,59392,60416,61440,62464,63488,64512,
+64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,
+64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,
+64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,
+64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,
+64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,
+64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,
+64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512,64512
+};
+
+const unsigned char half_float_shift_table[512] = {
+24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
+24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
+24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
+24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
+24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
+24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
+24,24,24,24,24,24,24,23,22,21,20,19,18,17,16,15,
+14,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,
+13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,24,
+24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
+24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
+24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
+24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
+24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
+24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
+24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,13,
+24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
+24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
+24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
+24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
+24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
+24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
+24,24,24,24,24,24,24,23,22,21,20,19,18,17,16,15,
+14,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,
+13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,24,
+24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
+24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
+24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
+24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
+24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
+24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
+24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,13
+};
+
+static inline unsigned short float_to_half_float(float f)
+{
+ // See Blink::Source/platform/graphics/gpu/WebGLImageConversion.cpp::convertFloatToHalfFloat() and http://crbug.com/491784
+ union {
+ float f;
+ uint32_t u;
+ } u;
+ unsigned int temp;
+ unsigned int signexp;
+ u.f = f;
+ temp = u.u;
+ signexp = (temp >> 23) & 0x1ff;
+ return half_float_base_table[signexp] + ((temp & 0x007fffff) >> half_float_shift_table[signexp]);
+}
+
static void singles2halfp(void *target, const void *source, long numel)
{
+ const float *src = source;
+ uint16_t *dst = target;
+ int i;
+ for (i = 0; i < numel; i++)
+ dst[i] = float_to_half_float (src[i]);
+}
+
+static inline void
+conv_yHalf_yF (const Babl *conversion,const uint16_t *src, float *dst, long samples)
+{
+ halfp2singles(dst, src, samples);
+}
+
+static void
+conv_yaHalf_yaF (const Babl *conversion,const uint16_t *src, float *dst, long samples)
+{
+ conv_yHalf_yF (conversion, src, dst, samples * 2);
+}
+
+static void
+conv_rgbHalf_rgbF (const Babl *conversion,const uint16_t *src, float *dst, long samples)
+{
+ conv_yHalf_yF (conversion, src, dst, samples * 3);
+}
+
+static void
+conv_rgbaHalf_rgbaF (const Babl *conversion,const uint16_t *src, float *dst, long samples)
+{
+ conv_yHalf_yF (conversion, src, dst, samples * 4);
+}
+
+static inline void
+conv_yF_yHalf (const Babl *conversion,const float *src, uint16_t *dst, long samples)
+{
+ singles2halfp (dst, src, samples);
+}
+
+static void
+conv_yaF_yaHalf (const Babl *conversion,const float *src, uint16_t *dst, long samples)
+{
+ conv_yF_yHalf (conversion, src, dst, samples * 2);
+}
+
+static void
+conv_rgbF_rgbHalf (const Babl *conversion,const float *src, uint16_t *dst, long samples)
+{
+ conv_yF_yHalf (conversion, src, dst, samples * 3);
+}
+
+static void
+conv_rgbaF_rgbaHalf (const Babl *conversion,const float *src, uint16_t *dst, long samples)
+{
+ conv_yF_yHalf (conversion, src, dst, samples * 4);
+}
+
+static void singles2halfp2(void *target, const void *source, long numel)
+{
uint16_t *hp = (uint16_t *) target; // Type pun output as an unsigned 16-bit int
uint32_t *xp = (uint32_t *) source; // Type pun input as an unsigned 32-bit int
uint16_t hs, he, hm;
@@ -177,54 +331,28 @@ static void singles2halfp(void *target, const void *source, long numel)
}
}
-static inline long
-conv_yHalf_yF (const uint16_t *src, float *dst, long samples)
+static inline void
+conv2_yF_yHalf (const Babl *conversion,const float *src, uint16_t *dst, long samples)
{
- halfp2singles(dst, src, samples);
- return samples;
+ singles2halfp2 (dst, src, samples);
}
-static long
-conv_yaHalf_yaF (const uint16_t *src, float *dst, long samples)
+static void
+conv2_yaF_yaHalf (const Babl *conversion,const float *src, uint16_t *dst, long samples)
{
- return conv_yHalf_yF (src, dst, samples * 2) / 2;
+ conv2_yF_yHalf (conversion, src, dst, samples * 2);
}
-static long
-conv_rgbHalf_rgbF (const uint16_t *src, float *dst, long samples)
+static void
+conv2_rgbF_rgbHalf (const Babl *conversion,const float *src, uint16_t *dst, long samples)
{
- return conv_yHalf_yF (src, dst, samples * 3) / 3;
+ conv2_yF_yHalf (conversion, src, dst, samples * 3);
}
-static long
-conv_rgbaHalf_rgbaF (const uint16_t *src, float *dst, long samples)
+static void
+conv2_rgbaF_rgbaHalf (const Babl *conversion,const float *src, uint16_t *dst, long samples)
{
- return conv_yHalf_yF (src, dst, samples * 4) / 4;
-}
-
-static inline long
-conv_yF_yHalf (const float *src, uint16_t *dst, long samples)
-{
- singles2halfp (dst, src, samples);
- return samples;
-}
-
-static long
-conv_yaF_yaHalf (const float *src, uint16_t *dst, long samples)
-{
- return conv_yF_yHalf (src, dst, samples * 2) / 2;
-}
-
-static long
-conv_rgbF_rgbHalf (const float *src, uint16_t *dst, long samples)
-{
- return conv_yF_yHalf (src, dst, samples * 3) / 3;
-}
-
-static long
-conv_rgbaF_rgbaHalf (const float *src, uint16_t *dst, long samples)
-{
- return conv_yF_yHalf (src, dst, samples * 4) / 4;
+ conv2_yF_yHalf (conversion, src, dst, samples * 4);
}
int init (void);
@@ -232,6 +360,7 @@ int init (void);
int
init (void)
{
+ int i;
const Babl *rgbaF_linear = babl_format_new (
babl_model ("RGBA"),
babl_type ("float"),
@@ -337,11 +466,24 @@ init (void)
babl_component ("Y'"),
NULL);
+ for (i = 0; i < 65536; i++)
+ {
+ uint16_t buf[2] = {i, i};
+ float fbuf[2];
+ halfp2singles_fun(fbuf, buf, 1);
+ half_float_table[i] = fbuf[0];
+ }
+
#define CONV(src, dst) \
{ \
babl_conversion_new (src ## _linear, dst ## _linear, "linear", conv_ ## src ## _ ## dst, NULL); \
babl_conversion_new (src ## _gamma, dst ## _gamma, "linear", conv_ ## src ## _ ## dst, NULL); \
}
+#define CONV2(src, dst) \
+{ \
+ babl_conversion_new (src ## _linear, dst ## _linear, "linear", conv2_ ## src ## _ ## dst, NULL); \
+ babl_conversion_new (src ## _gamma, dst ## _gamma, "linear", conv2_ ## src ## _ ## dst, NULL); \
+}
CONV(rgbaHalf, rgbaF);
CONV(rgbHalf, rgbF);
@@ -351,6 +493,10 @@ init (void)
CONV(rgbF, rgbHalf);
CONV(yaF, yaHalf);
CONV(yF, yHalf);
+ CONV2(rgbaF, rgbaHalf);
+ CONV2(rgbF, rgbHalf);
+ CONV2(yaF, yaHalf);
+ CONV2(yF, yHalf);
return 0;
}
diff --git a/extensions/float.c b/extensions/float.c
index 9460804..e832e2e 100644
--- a/extensions/float.c
+++ b/extensions/float.c
@@ -21,19 +21,23 @@
#include <stdint.h>
#include <stdlib.h>
-#include "babl.h"
+#include "babl-internal.h"
#include "babl-cpuaccel.h"
#include "extensions/util.h"
#include "base/util.h"
+
#define INLINE inline
-static INLINE long
-conv_rgbaF_linear_rgbAF_gamma (unsigned char *src,
- unsigned char *dst,
+static INLINE void
+conv_rgbaF_linear_rgbAF_gamma (const Babl *conversion,unsigned char *src,
+ unsigned char *dst,
long samples)
{
+ const Babl *space = babl_conversion_get_destination_space (conversion);
+ const Babl **trc = (void*)space->space.trc;
+
float *fsrc = (float *) src;
float *fdst = (float *) dst;
int n = samples;
@@ -41,19 +45,22 @@ conv_rgbaF_linear_rgbAF_gamma (unsigned char *src,
while (n--)
{
float alpha = fsrc[3];
- *fdst++ = babl_linear_to_gamma_2_2f (*fsrc++) * alpha;
- *fdst++ = babl_linear_to_gamma_2_2f (*fsrc++) * alpha;
- *fdst++ = babl_linear_to_gamma_2_2f (*fsrc++) * alpha;
+ *fdst++ = babl_trc_from_linear (trc[0], *fsrc++) * alpha;
+ *fdst++ = babl_trc_from_linear (trc[1], *fsrc++) * alpha;
+ *fdst++ = babl_trc_from_linear (trc[2], *fsrc++) * alpha;
*fdst++ = *fsrc++;
}
- return samples;
}
-static INLINE long
-conv_rgbAF_linear_rgbAF_gamma (unsigned char *src,
- unsigned char *dst,
+static INLINE void
+conv_rgbAF_linear_rgbAF_gamma (const Babl *conversion,
+ unsigned char *src,
+ unsigned char *dst,
long samples)
{
+ const Babl *space = babl_conversion_get_destination_space (conversion);
+ const Babl **trc = (void*)space->space.trc;
+
float *fsrc = (float *) src;
float *fdst = (float *) dst;
int n = samples;
@@ -71,96 +78,100 @@ conv_rgbAF_linear_rgbAF_gamma (unsigned char *src,
}
else if (alpha >= 1.0)
{
- *fdst++ = babl_linear_to_gamma_2_2f (*fsrc++);
- *fdst++ = babl_linear_to_gamma_2_2f (*fsrc++);
- *fdst++ = babl_linear_to_gamma_2_2f (*fsrc++);
+ *fdst++ = babl_trc_from_linear (trc[0], *fsrc++) * alpha;
+ *fdst++ = babl_trc_from_linear (trc[1], *fsrc++) * alpha;
+ *fdst++ = babl_trc_from_linear (trc[2], *fsrc++) * alpha;
*fdst++ = *fsrc++;
}
else
{
float alpha_recip = 1.0 / alpha;
- *fdst++ = babl_linear_to_gamma_2_2f (*fsrc++ * alpha_recip) * alpha;
- *fdst++ = babl_linear_to_gamma_2_2f (*fsrc++ * alpha_recip) * alpha;
- *fdst++ = babl_linear_to_gamma_2_2f (*fsrc++ * alpha_recip) * alpha;
+ *fdst++ = babl_trc_from_linear (trc[0], *fsrc++ * alpha_recip) * alpha;
+ *fdst++ = babl_trc_from_linear (trc[1], *fsrc++ * alpha_recip) * alpha;
+ *fdst++ = babl_trc_from_linear (trc[2], *fsrc++ * alpha_recip) * alpha;
*fdst++ = *fsrc++;
}
}
- return samples;
}
-static INLINE long
-conv_rgbaF_linear_rgbaF_gamma (unsigned char *src,
+static INLINE void
+conv_rgbaF_linear_rgbaF_gamma (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
+ const Babl *space = babl_conversion_get_destination_space (conversion);
+ const Babl **trc = (void*)space->space.trc;
+
float *fsrc = (float *) src;
float *fdst = (float *) dst;
int n = samples;
while (n--)
{
- *fdst++ = babl_linear_to_gamma_2_2f (*fsrc++);
- *fdst++ = babl_linear_to_gamma_2_2f (*fsrc++);
- *fdst++ = babl_linear_to_gamma_2_2f (*fsrc++);
+ *fdst++ = babl_trc_from_linear (trc[0], *fsrc++);
+ *fdst++ = babl_trc_from_linear (trc[1], *fsrc++);
+ *fdst++ = babl_trc_from_linear (trc[2], *fsrc++);
*fdst++ = *fsrc++;
}
- return samples;
}
-static INLINE long
-conv_rgbF_linear_rgbF_gamma (unsigned char *src,
+static INLINE void
+conv_rgbF_linear_rgbF_gamma (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
+ const Babl *space = babl_conversion_get_destination_space (conversion);
+ const Babl **trc = (void*)space->space.trc;
float *fsrc = (float *) src;
float *fdst = (float *) dst;
int n = samples;
while (n--)
{
- *fdst++ = babl_linear_to_gamma_2_2f (*fsrc++);
- *fdst++ = babl_linear_to_gamma_2_2f (*fsrc++);
- *fdst++ = babl_linear_to_gamma_2_2f (*fsrc++);
+ *fdst++ = babl_trc_from_linear (trc[0], *fsrc++);
+ *fdst++ = babl_trc_from_linear (trc[1], *fsrc++);
+ *fdst++ = babl_trc_from_linear (trc[2], *fsrc++);
}
- return samples;
}
-static INLINE long
-conv_rgbaF_gamma_rgbaF_linear (unsigned char *src,
+static INLINE void
+conv_rgbaF_gamma_rgbaF_linear (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
+ const Babl *space = babl_conversion_get_destination_space (conversion);
+ const Babl **trc = (void*)space->space.trc;
float *fsrc = (float *) src;
float *fdst = (float *) dst;
int n = samples;
while (n--)
{
- *fdst++ = babl_gamma_2_2_to_linearf (*fsrc++);
- *fdst++ = babl_gamma_2_2_to_linearf (*fsrc++);
- *fdst++ = babl_gamma_2_2_to_linearf (*fsrc++);
+ *fdst++ = babl_trc_to_linear (trc[0], *fsrc++);
+ *fdst++ = babl_trc_to_linear (trc[1], *fsrc++);
+ *fdst++ = babl_trc_to_linear (trc[2], *fsrc++);
*fdst++ = *fsrc++;
}
- return samples;
}
-static INLINE long
-conv_rgbF_gamma_rgbF_linear (unsigned char *src,
+static INLINE void
+conv_rgbF_gamma_rgbF_linear (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
+ const Babl *space = babl_conversion_get_destination_space (conversion);
+ const Babl **trc = (void*)space->space.trc;
float *fsrc = (float *) src;
float *fdst = (float *) dst;
int n = samples;
while (n--)
{
- *fdst++ = babl_gamma_2_2_to_linearf (*fsrc++);
- *fdst++ = babl_gamma_2_2_to_linearf (*fsrc++);
- *fdst++ = babl_gamma_2_2_to_linearf (*fsrc++);
+ *fdst++ = babl_trc_to_linear (trc[0], *fsrc++);
+ *fdst++ = babl_trc_to_linear (trc[1], *fsrc++);
+ *fdst++ = babl_trc_to_linear (trc[2], *fsrc++);
}
- return samples;
}
#define o(src, dst) \
diff --git a/extensions/gegl-fixups.c b/extensions/gegl-fixups.c
index c32968c..e3bb836 100644
--- a/extensions/gegl-fixups.c
+++ b/extensions/gegl-fixups.c
@@ -145,8 +145,8 @@ gggl_float_to_index16 (float f)
return (u.s >> 15) & ((1 << 17)-1);
}
-static INLINE long
-conv_F_8 (unsigned char *src, unsigned char *dst, long samples)
+static INLINE void
+conv_F_8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -159,12 +159,11 @@ conv_F_8 (unsigned char *src, unsigned char *dst, long samples)
dst += 1;
src += 4;
}
- return samples;
}
-static INLINE long
-conv_F_8g (unsigned char *src, unsigned char *dst, long samples)
+static INLINE void
+conv_F_8g (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -177,12 +176,11 @@ conv_F_8g (unsigned char *src, unsigned char *dst, long samples)
dst += 1;
src += 4;
}
- return samples;
}
-static INLINE long __attribute__((unused))
-conv_8_F (unsigned char *src, unsigned char *dst, long samples)
+static INLINE void __attribute__((unused))
+conv_8_F (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -194,12 +192,11 @@ conv_8_F (unsigned char *src, unsigned char *dst, long samples)
dst += 4;
src += 1;
}
- return samples;
}
-static INLINE long
-conv_rgbaF_rgb8 (unsigned char *src, unsigned char *dst, long samples)
+static INLINE void
+conv_rgbaF_rgb8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -222,12 +219,11 @@ conv_rgbaF_rgb8 (unsigned char *src, unsigned char *dst, long samples)
src += 4;
}
- return samples;
}
-static INLINE long __attribute__((unused))
-conv_rgbaF_rgba8 (unsigned char *src, unsigned char *dst, long samples)
+static INLINE void __attribute__((unused))
+conv_rgbaF_rgba8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -253,23 +249,20 @@ conv_rgbaF_rgba8 (unsigned char *src, unsigned char *dst, long samples)
src += 4;
dst += 1;
}
- return samples;
}
#define conv_rgbaF_rgbP8 conv_rgbaF_rgba8
-static INLINE long __attribute__((unused))
-conv_rgbF_rgb8 (unsigned char *src, unsigned char *dst, long samples)
+static INLINE void __attribute__((unused))
+conv_rgbF_rgb8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_F_8g (src, dst, samples * 3);
- return samples;
+ conv_F_8g (conversion, src, dst, samples * 3);
}
-static INLINE long __attribute__((unused))
-conv_gaF_ga8 (unsigned char *src, unsigned char *dst, long samples)
+static INLINE void __attribute__((unused))
+conv_gaF_ga8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_F_8 (src, dst, samples * 2);
- return samples;
+ conv_F_8 (conversion, src, dst, samples * 2);
}
#define conv_rgbAF_rgbA8 conv_rgbaF_rgba8
@@ -277,8 +270,8 @@ conv_gaF_ga8 (unsigned char *src, unsigned char *dst, long samples)
#define conv_gAF_gA8 conv_gaF_ga8
-static INLINE long
-conv_rgba8_rgbaF (unsigned char *src, unsigned char *dst, long samples)
+static INLINE void
+conv_rgba8_rgbaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -300,11 +293,10 @@ conv_rgba8_rgbaF (unsigned char *src, unsigned char *dst, long samples)
dst += 4;
src += 1;
}
- return samples;
}
-static INLINE long
-conv_rgb8_rgbaF (unsigned char *src, unsigned char *dst, long samples)
+static INLINE void
+conv_rgb8_rgbaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -325,11 +317,10 @@ conv_rgb8_rgbaF (unsigned char *src, unsigned char *dst, long samples)
(*(float *) dst) = 1.0;
dst += 4;
}
- return samples;
}
-static long
-conv_rgbAF_rgb8 (unsigned char *srcc,
+static void
+conv_rgbAF_rgb8 (const Babl *conversion,unsigned char *srcc,
unsigned char *dstc,
long samples)
{
@@ -356,11 +347,10 @@ conv_rgbAF_rgb8 (unsigned char *srcc,
src += 4;
dst += 3;
}
- return samples;
}
-static long
-conv_bgrA8_rgba8 (unsigned char *srcc,
+static void
+conv_bgrA8_rgba8 (const Babl *conversion,unsigned char *srcc,
unsigned char *dstc,
long samples)
{
@@ -378,11 +368,10 @@ conv_bgrA8_rgba8 (unsigned char *srcc,
src += 4;
dst += 4;
}
- return samples;
}
-static long
-conv_rgbaF_rgbAF (unsigned char *srcc,
+static void
+conv_rgbaF_rgbAF (const Babl *conversion,unsigned char *srcc,
unsigned char *dstc,
long samples)
{
@@ -400,11 +389,10 @@ conv_rgbaF_rgbAF (unsigned char *srcc,
src += 4;
dst += 4;
}
- return samples;
}
-static long
-conv_rgbAF_rgbaF (unsigned char *srcc,
+static void
+conv_rgbAF_rgbaF (const Babl *conversion,unsigned char *srcc,
unsigned char *dstc,
long samples)
{
@@ -427,12 +415,11 @@ conv_rgbAF_rgbaF (unsigned char *srcc,
src += 4;
dst += 4;
}
- return samples;
}
-static long
-conv_rgbAF_lrgba8 (unsigned char *srcc,
+static void
+conv_rgbAF_lrgba8 (const Babl *conversion,unsigned char *srcc,
unsigned char *dstc,
long samples)
{
@@ -458,7 +445,6 @@ conv_rgbAF_lrgba8 (unsigned char *srcc,
src += 4;
dst += 4;
}
- return samples;
}
#define conv_rgb8_rgbAF conv_rgb8_rgbaF
diff --git a/extensions/gggl-lies.c b/extensions/gggl-lies.c
index 3d1627f..b34f8ef 100644
--- a/extensions/gggl-lies.c
+++ b/extensions/gggl-lies.c
@@ -48,8 +48,8 @@
*
*/
-static long
-conv_F_8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_F_8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -71,11 +71,10 @@ conv_F_8 (unsigned char *src, unsigned char *dst, long samples)
dst += 1;
src += 4;
}
- return samples;
}
-static long
-conv_F_16 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_F_16 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -97,13 +96,12 @@ conv_F_16 (unsigned char *src, unsigned char *dst, long samples)
dst += 2;
src += 4;
}
- return samples;
}
-static long
-conv_8_F (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_8_F (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -113,11 +111,10 @@ conv_8_F (unsigned char *src, unsigned char *dst, long samples)
dst += 4;
src += 1;
}
- return samples;
}
-static long
-conv_16_F (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_16_F (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -127,11 +124,10 @@ conv_16_F (unsigned char *src, unsigned char *dst, long samples)
dst += 4;
src += 2;
}
- return samples;
}
-static long
-conv_F_D (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_F_D (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -141,11 +137,10 @@ conv_F_D (unsigned char *src, unsigned char *dst, long samples)
dst += 8;
src += 4;
}
- return samples;
}
-static long
-conv_D_F (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_D_F (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -155,10 +150,9 @@ conv_D_F (unsigned char *src, unsigned char *dst, long samples)
dst += 4;
src += 8;
}
- return samples;
}
-static long
-conv_16_8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_16_8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -169,11 +163,10 @@ conv_16_8 (unsigned char *src, unsigned char *dst, long samples)
dst += 1;
src += 2;
}
- return samples;
}
-static long
-conv_8_16 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_8_16 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -183,70 +176,61 @@ conv_8_16 (unsigned char *src, unsigned char *dst, long samples)
dst += 2;
src += 1;
}
- return samples;
}
/*********/
-static long
-conv_rgbaF_rgba8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbaF_rgba8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_F_8 (src, dst, samples * 4);
- return samples;
+ conv_F_8 (conversion, src, dst, samples * 4);
}
#define conv_rgbaF_rgbP8 conv_rgbaF_rgba8
-static long
-conv_rgbF_rgb8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbF_rgb8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_F_8 (src, dst, samples * 3);
- return samples;
+ conv_F_8 (conversion, src, dst, samples * 3);
}
-static long
-conv_gaF_ga8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_gaF_ga8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_F_8 (src, dst, samples * 2);
- return samples;
+ conv_F_8 (conversion, src, dst, samples * 2);
}
#define conv_rgbAF_rgbA8 conv_rgbaF_rgba8
#define conv_gF_g8 conv_F_8
#define conv_gAF_gA8 conv_gaF_ga8
-static long
-conv_rgbaF_rgba16 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbaF_rgba16 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_F_16 (src, dst, samples * 4);
- return samples;
+ conv_F_16 (conversion, src, dst, samples * 4);
}
-static long
-conv_rgbaF_rgbaD (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbaF_rgbaD (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_F_D (src, dst, samples * 4);
- return samples;
+ conv_F_D (conversion, src, dst, samples * 4);
}
-static long
-conv_rgbaD_rgbaF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbaD_rgbaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_D_F (src, dst, samples * 4);
- return samples;
+ conv_D_F (conversion, src, dst, samples * 4);
}
-static long
-conv_rgbF_rgb16 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbF_rgb16 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_F_16 (src, dst, samples * 3);
- return samples;
+ conv_F_16 (conversion, src, dst, samples * 3);
}
-static long
-conv_gaF_ga16 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_gaF_ga16 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_F_16 (src, dst, samples * 2);
- return samples;
+ conv_F_16 (conversion, src, dst, samples * 2);
}
#define conv_rgbAF_rgbAD conv_rgbaF_rgbaD
@@ -255,100 +239,88 @@ conv_gaF_ga16 (unsigned char *src, unsigned char *dst, long samples)
#define conv_gF_g16 conv_F_16
#define conv_gAF_gA16 conv_gaF_ga16
-static long
-conv_rgba8_rgbaF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgba8_rgbaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_8_F (src, dst, samples * 4);
- return samples;
+ conv_8_F (conversion, src, dst, samples * 4);
}
-static long
-conv_rgb8_rgbF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgb8_rgbF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_8_F (src, dst, samples * 3);
- return samples;
+ conv_8_F (conversion, src, dst, samples * 3);
}
-static long
-conv_ga8_gaF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_ga8_gaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_8_F (src, dst, samples * 2);
- return samples;
+ conv_8_F (conversion, src, dst, samples * 2);
}
#define conv_rgbA8_rgbAF conv_rgba8_rgbaF
#define conv_gA8_gAF conv_ga8_gaF
#define conv_g8_gF conv_8_F
-static long
-conv_rgba16_rgbaF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgba16_rgbaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_16_F (src, dst, samples * 4);
- return samples;
+ conv_16_F (conversion, src, dst, samples * 4);
}
-static long
-conv_rgb16_rgbF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgb16_rgbF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_16_F (src, dst, samples * 3);
- return samples;
+ conv_16_F (conversion, src, dst, samples * 3);
}
-static long
-conv_ga16_gaF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_ga16_gaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_16_F (src, dst, samples * 2);
- return samples;
+ conv_16_F (conversion, src, dst, samples * 2);
}
#define conv_rgbA16_rgbAF conv_rgba16_rgbaF
#define conv_gA16_gAF conv_ga16_gaF
#define conv_g16_gF conv_16_F
-static long
-conv_rgba16_rgba8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgba16_rgba8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_16_8 (src, dst, samples * 4);
- return samples;
+ conv_16_8 (conversion, src, dst, samples * 4);
}
-static long
-conv_rgb16_rgb8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgb16_rgb8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_16_8 (src, dst, samples * 3);
- return samples;
+ conv_16_8 (conversion, src, dst, samples * 3);
}
-static long
-conv_ga16_ga8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_ga16_ga8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_16_8 (src, dst, samples * 2);
- return samples;
+ conv_16_8 (conversion, src, dst, samples * 2);
}
#define conv_rgbA16_rgbA8 conv_rgba16_rgba8
#define conv_gA16_gA8 conv_ga16_ga8
#define conv_g16_g8 conv_16_8
-static long
-conv_rgba8_rgba16 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgba8_rgba16 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_8_16 (src, dst, samples * 4);
- return samples;
+ conv_8_16 (conversion, src, dst, samples * 4);
}
-static long
-conv_rgb8_rgb16 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgb8_rgb16 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_8_16 (src, dst, samples * 3);
- return samples;
+ conv_8_16 (conversion, src, dst, samples * 3);
}
-static long
-conv_ga8_ga16 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_ga8_ga16 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_8_16 (src, dst, samples * 2);
- return samples;
+ conv_8_16 (conversion, src, dst, samples * 2);
}
#define conv_rgbA8_rgbA16 conv_rgba8_rgba16
@@ -357,8 +329,8 @@ conv_ga8_ga16 (unsigned char *src, unsigned char *dst, long samples)
/* alpha conversions */
-static long
-conv_gaF_gAF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_gaF_gAF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -373,11 +345,10 @@ conv_gaF_gAF (unsigned char *src, unsigned char *dst, long samples)
dst += 4;
src += 4;
}
- return samples;
}
-static long
-conv_gAF_gaF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_gAF_gaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -392,13 +363,12 @@ conv_gAF_gaF (unsigned char *src, unsigned char *dst, long samples)
dst += 4;
src += 4;
}
- return samples;
}
/* alpha stripping and adding */
-static long
-conv_rgbaF_rgbF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbaF_rgbF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -415,12 +385,11 @@ conv_rgbaF_rgbF (unsigned char *src, unsigned char *dst, long samples)
src += 4;
src += 4;
}
- return samples;
}
-static long
-conv_gF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_gF_rgbaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -436,13 +405,12 @@ conv_gF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
dst += 4;
src += 4;
}
- return samples;
}
#define conv_gF_rgbAF conv_gF_rgbaF
-static long
-conv_rgbF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbF_rgbaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -460,11 +428,10 @@ conv_rgbF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
*(float *) dst = 1.0;
dst += 4;
}
- return samples;
}
-static long
-conv_gaF_gF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_gaF_gF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -475,11 +442,10 @@ conv_gaF_gF (unsigned char *src, unsigned char *dst, long samples)
src += 4;
src += 4;
}
- return samples;
}
-static long
-conv_gF_gaF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_gF_gaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -491,7 +457,6 @@ conv_gF_gaF (unsigned char *src, unsigned char *dst, long samples)
*(float *) dst = 1.0;
dst += 4;
}
- return samples;
}
#define conv_gF_gAF conv_gF_gaF
@@ -500,8 +465,8 @@ conv_gF_gaF (unsigned char *src, unsigned char *dst, long samples)
/* colorchannel dropping and adding */
-static long
-conv_gF_rgbF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_gF_rgbF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -516,11 +481,10 @@ conv_gF_rgbF (unsigned char *src, unsigned char *dst, long samples)
}
src += 4;
}
- return samples;
}
-static long
-conv_gaF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_gaF_rgbaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -538,15 +502,14 @@ conv_gaF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
dst += 4;
src += 4;
}
- return samples;
}
#define conv_gAF_rgbAF conv_gaF_rgbaF
/* other conversions coded for some optimisation reason or sumthin */
-static long
-conv_rgbaF_rgbA8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbaF_rgbA8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -565,11 +528,10 @@ conv_rgbaF_rgbA8 (unsigned char *src, unsigned char *dst, long samples)
dst++;
src += 4;
}
- return samples;
}
-static long
-conv_rgbaF_rgb8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbaF_rgb8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -585,11 +547,10 @@ conv_rgbaF_rgb8 (unsigned char *src, unsigned char *dst, long samples)
}
src += 4;
}
- return samples;
}
-static long
-conv_rgbaF_rgb16 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbaF_rgb16 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -605,11 +566,10 @@ conv_rgbaF_rgb16 (unsigned char *src, unsigned char *dst, long samples)
}
src += 4;
}
- return samples;
}
-static long
-conv_rgba8_rgbA8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgba8_rgbA8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -634,11 +594,10 @@ conv_rgba8_rgbA8 (unsigned char *src, unsigned char *dst, long samples)
dst += 4;
src += 4;
}
- return samples;
}
-static long
-conv_rgbA8_rgba8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbA8_rgba8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -664,11 +623,10 @@ conv_rgbA8_rgba8 (unsigned char *src, unsigned char *dst, long samples)
}
src += 4;
}
- return samples;
}
-static long
-conv_rgb8_rgba8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgb8_rgba8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -682,13 +640,12 @@ conv_rgb8_rgba8 (unsigned char *src, unsigned char *dst, long samples)
dst += 4;
}
- return samples;
}
#define conv_rgb8_rgbA8 conv_rgb8_rgba8
-static long
-conv_rgba8_rgb8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgba8_rgb8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -700,7 +657,6 @@ conv_rgba8_rgb8 (unsigned char *src, unsigned char *dst, long samples)
src += 4;
dst += 3;
}
- return samples;
}
int init (void);
diff --git a/extensions/gggl-table-lies.c b/extensions/gggl-table-lies.c
index 3e79a6f..6cce2ba 100644
--- a/extensions/gggl-table-lies.c
+++ b/extensions/gggl-table-lies.c
@@ -149,8 +149,8 @@ gggl_float_to_index16 (float f)
}
-static long
-conv_F_8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_F_8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -163,11 +163,10 @@ conv_F_8 (unsigned char *src, unsigned char *dst, long samples)
dst += 1;
src += 4;
}
- return samples;
}
-static long
-conv_F_16 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_F_16 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -180,11 +179,10 @@ conv_F_16 (unsigned char *src, unsigned char *dst, long samples)
dst += 2;
src += 4;
}
- return samples;
}
-static long
-conv_8_F (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_8_F (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -196,11 +194,10 @@ conv_8_F (unsigned char *src, unsigned char *dst, long samples)
dst += 4;
src += 1;
}
- return samples;
}
-static long
-conv_16_F (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_16_F (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -212,106 +209,93 @@ conv_16_F (unsigned char *src, unsigned char *dst, long samples)
dst += 4;
src += 2;
}
- return samples;
}
/*********/
-static long
-conv_rgbaF_rgba8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbaF_rgba8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_F_8 (src, dst, samples * 4);
- return samples;
+ conv_F_8 (conversion, src, dst, samples * 4);
}
#define conv_rgbaF_rgbP8 conv_rgbaF_rgba8
-static long
-conv_rgbF_rgb8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbF_rgb8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_F_8 (src, dst, samples * 3);
- return samples;
+ conv_F_8 (conversion, src, dst, samples * 3);
}
-static long
-conv_gaF_ga8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_gaF_ga8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_F_8 (src, dst, samples * 2);
- return samples;
+ conv_F_8 (conversion, src, dst, samples * 2);
}
#define conv_rgbAF_rgbA8 conv_rgbaF_rgba8
#define conv_gF_g8 conv_F_8
#define conv_gAF_gA8 conv_gaF_ga8
-static long
-conv_rgbaF_rgba16 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbaF_rgba16 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_F_16 (src, dst, samples * 4);
- return samples;
+ conv_F_16 (conversion, src, dst, samples * 4);
}
-static long
-conv_rgbF_rgb16 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbF_rgb16 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_F_16 (src, dst, samples * 3);
- return samples;
+ conv_F_16 (conversion, src, dst, samples * 3);
}
-static long
-conv_gaF_ga16 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_gaF_ga16 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_F_16 (src, dst, samples * 2);
- return samples;
+ conv_F_16 (conversion, src, dst, samples * 2);
}
#define conv_rgbAF_rgbA16 conv_rgbaF_rgba16
#define conv_gF_g16 conv_F_16
#define conv_gAF_gA16 conv_gaF_ga16
-static long
-conv_rgba8_rgbaF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgba8_rgbaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_8_F (src, dst, samples * 4);
- return samples;
+ conv_8_F (conversion, src, dst, samples * 4);
}
-static long
-conv_rgb8_rgbF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgb8_rgbF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_8_F (src, dst, samples * 3);
- return samples;
+ conv_8_F (conversion, src, dst, samples * 3);
}
-static long
-conv_ga8_gaF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_ga8_gaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_8_F (src, dst, samples * 2);
- return samples;
+ conv_8_F (conversion, src, dst, samples * 2);
}
#define conv_rgbA8_rgbAF conv_rgba8_rgbaF
#define conv_gA8_gAF conv_ga8_gaF
#define conv_g8_gF conv_8_F
-static long
-conv_rgba16_rgbaF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgba16_rgbaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_16_F (src, dst, samples * 4);
- return samples;
+ conv_16_F (conversion, src, dst, samples * 4);
}
-static long
-conv_rgb16_rgbF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgb16_rgbF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_16_F (src, dst, samples * 3);
- return samples;
+ conv_16_F (conversion, src, dst, samples * 3);
}
-static long
-conv_ga16_gaF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_ga16_gaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_16_F (src, dst, samples * 2);
- return samples;
+ conv_16_F (conversion, src, dst, samples * 2);
}
#define conv_rgbA16_rgbAF conv_rgba16_rgbaF
diff --git a/extensions/gggl-table.c b/extensions/gggl-table.c
index 071167d..0ce0353 100644
--- a/extensions/gggl-table.c
+++ b/extensions/gggl-table.c
@@ -148,8 +148,8 @@ gggl_float_to_index16 (float f)
return u.s[1];
}
-static long
-conv_F_8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_F_8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -162,11 +162,10 @@ conv_F_8 (unsigned char *src, unsigned char *dst, long samples)
dst += 1;
src += 4;
}
- return samples;
}
-static long
-conv_F_16 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_F_16 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -179,11 +178,10 @@ conv_F_16 (unsigned char *src, unsigned char *dst, long samples)
dst += 2;
src += 4;
}
- return samples;
}
-static long
-conv_8_F (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_8_F (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -195,11 +193,10 @@ conv_8_F (unsigned char *src, unsigned char *dst, long samples)
dst += 4;
src += 1;
}
- return samples;
}
-static long
-conv_rgb8_rgbaF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgb8_rgbaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -219,11 +216,10 @@ conv_rgb8_rgbaF (unsigned char *src, unsigned char *dst, long samples)
(*(float *) dst) = 1.0;
dst += 4;
}
- return samples;
}
-static long
-conv_16_F (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_16_F (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -235,11 +231,10 @@ conv_16_F (unsigned char *src, unsigned char *dst, long samples)
dst += 4;
src += 2;
}
- return samples;
}
-static long
-conv_rgbaF_rgb8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbaF_rgb8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -262,103 +257,93 @@ conv_rgbaF_rgb8 (unsigned char *src, unsigned char *dst, long samples)
src += 4;
}
- return samples;
}
/*********/
-static long
-conv_rgbaF_rgba8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbaF_rgba8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_F_8 (src, dst, samples * 4);
- return samples;
+ conv_F_8 (conversion, src, dst, samples * 4);
}
-static long
-conv_rgbF_rgb8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbF_rgb8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_F_8 (src, dst, samples * 3);
- return samples;
+ conv_F_8 (conversion, src, dst, samples * 3);
}
-static long
-conv_gaF_ga8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_gaF_ga8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_F_8 (src, dst, samples * 2);
- return samples;
+ conv_F_8 (conversion, src, dst, samples * 2);
}
#define conv_rgbAF_rgbA8 conv_rgbaF_rgba8
#define conv_gF_g8 conv_F_8
#define conv_gAF_gA8 conv_gaF_ga8
-static long
-conv_rgbaF_rgba16 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbaF_rgba16 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_F_16 (src, dst, samples * 4);
- return samples;
+ conv_F_16 (conversion, src, dst, samples * 4);
}
-static long
-conv_rgbF_rgb16 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbF_rgb16 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_F_16 (src, dst, samples * 3);
- return samples;
+ conv_F_16 (conversion, src, dst, samples * 3);
}
-static long
-conv_gaF_ga16 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_gaF_ga16 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_F_16 (src, dst, samples * 2);
- return samples;
+ conv_F_16 (conversion, src, dst, samples * 2);
}
#define conv_rgbAF_rgbA16 conv_rgbaF_rgba16
#define conv_gF_g16 conv_F_16
#define conv_gAF_gA16 conv_gaF_ga16
-static long
-conv_rgba8_rgbaF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgba8_rgbaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- return conv_8_F (src, dst, samples * 4) / 4;
+ conv_8_F (conversion, src, dst, samples * 4);
}
-static long
-conv_rgb8_rgbF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgb8_rgbF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- return conv_8_F (src, dst, samples * 3) / 3;
+ conv_8_F (conversion, src, dst, samples * 3);
}
-static long
-conv_ga8_gaF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_ga8_gaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- return conv_8_F (src, dst, samples * 2) / 2;
+ conv_8_F (conversion, src, dst, samples * 2);
}
#define conv_rgbA8_rgbAF conv_rgba8_rgbaF
#define conv_gA8_gAF conv_ga8_gaF
#define conv_g8_gF conv_8_F
-static long
-conv_rgba16_rgbaF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgba16_rgbaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_16_F (src, dst, samples * 4);
- return samples;
+ conv_16_F (conversion, src, dst, samples * 4);
}
-static long
-conv_rgb16_rgbF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgb16_rgbF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_16_F (src, dst, samples * 3);
- return samples;
+ conv_16_F (conversion, src, dst, samples * 3);
}
-static long
-conv_ga16_gaF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_ga16_gaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_16_F (src, dst, samples * 2);
- return samples;
+ conv_16_F (conversion, src, dst, samples * 2);
}
#define conv_rgbA16_rgbAF conv_rgba16_rgbaF
diff --git a/extensions/gggl.c b/extensions/gggl.c
index b01659f..83352d2 100644
--- a/extensions/gggl.c
+++ b/extensions/gggl.c
@@ -49,8 +49,8 @@
* gamma correction (not really,. gamma correction belongs in seperate ops,.
*/
-static long
-conv_F_8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_F_8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -66,11 +66,10 @@ conv_F_8 (unsigned char *src, unsigned char *dst, long samples)
dst += 1;
src += 4;
}
- return samples;
}
-static long
-conv_F_16 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_F_16 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -92,11 +91,10 @@ conv_F_16 (unsigned char *src, unsigned char *dst, long samples)
dst += 2;
src += 4;
}
- return samples;
}
-static long
-conv_8_F (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_8_F (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -106,11 +104,10 @@ conv_8_F (unsigned char *src, unsigned char *dst, long samples)
dst += 4;
src += 1;
}
- return samples;
}
-static long
-conv_16_F (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_16_F (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -120,11 +117,10 @@ conv_16_F (unsigned char *src, unsigned char *dst, long samples)
dst += 4;
src += 2;
}
- return samples;
}
-static long
-conv_rgbaF_rgb8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbaF_rgb8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -146,11 +142,10 @@ conv_rgbaF_rgb8 (unsigned char *src, unsigned char *dst, long samples)
}
src += 4;
}
- return samples;
}
-static long
-conv_F_D (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_F_D (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -160,11 +155,10 @@ conv_F_D (unsigned char *src, unsigned char *dst, long samples)
dst += 8;
src += 4;
}
- return samples;
}
-static long
-conv_D_F (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_D_F (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -174,11 +168,10 @@ conv_D_F (unsigned char *src, unsigned char *dst, long samples)
dst += 4;
src += 8;
}
- return samples;
}
-static long
-conv_16_8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_16_8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -189,11 +182,10 @@ conv_16_8 (unsigned char *src, unsigned char *dst, long samples)
dst += 1;
src += 2;
}
- return samples;
}
-static long
-conv_8_16 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_8_16 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -203,167 +195,149 @@ conv_8_16 (unsigned char *src, unsigned char *dst, long samples)
dst += 2;
src += 1;
}
- return samples;
}
/*********/
-static long
-conv_rgbaF_rgba8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbaF_rgba8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_F_8 (src, dst, samples * 4);
- return samples;
+ conv_F_8 (conversion, src, dst, samples * 4);
}
-static long
-conv_rgbF_rgb8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbF_rgb8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_F_8 (src, dst, samples * 3);
- return samples;
+ conv_F_8 (conversion, src, dst, samples * 3);
}
-static long
-conv_gaF_ga8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_gaF_ga8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_F_8 (src, dst, samples * 2);
- return samples;
+ conv_F_8 (conversion, src, dst, samples * 2);
}
#define conv_rgbAF_rgbA8 conv_rgbaF_rgba8
#define conv_gF_g8 conv_F_8
#define conv_gAF_gA8 conv_gaF_ga8
-static long
-conv_rgbaF_rgba16 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbaF_rgba16 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_F_16 (src, dst, samples * 4);
- return samples;
+ conv_F_16 (conversion, src, dst, samples * 4);
}
-static long
-conv_rgbF_rgb16 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbF_rgb16 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_F_16 (src, dst, samples * 3);
- return samples;
+ conv_F_16 (conversion, src, dst, samples * 3);
}
-static long
-conv_gaF_ga16 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_gaF_ga16 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_F_16 (src, dst, samples * 2);
- return samples;
+ conv_F_16 (conversion, src, dst, samples * 2);
}
#define conv_rgbAF_rgbA16 conv_rgbaF_rgba16
#define conv_gF_g16 conv_F_16
#define conv_gAF_gA16 conv_gaF_ga16
-static long
-conv_rgba8_rgbaF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgba8_rgbaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- return conv_8_F (src, dst, samples * 4) / 4;
+ conv_8_F (conversion, src, dst, samples * 4);
}
-static long
-conv_rgb8_rgbF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgb8_rgbF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- return conv_8_F (src, dst, samples * 3) / 3;
+ conv_8_F (conversion, src, dst, samples * 3);
}
-static long
-conv_ga8_gaF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_ga8_gaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- return conv_8_F (src, dst, samples * 2) / 2;
+ conv_8_F (conversion, src, dst, samples * 2);
}
#define conv_rgbA8_rgbAF conv_rgba8_rgbaF
#define conv_gA8_gAF conv_ga8_gaF
#define conv_g8_gF conv_8_F
-static long
-conv_rgbaF_rgbaD (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbaF_rgbaD (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_F_D (src, dst, samples * 4);
- return samples;
+ conv_F_D (conversion, src, dst, samples * 4);
}
-static long
-conv_rgbaD_rgbaF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbaD_rgbaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_D_F (src, dst, samples * 4);
- return samples;
+ conv_D_F (conversion, src, dst, samples * 4);
}
-static long
-conv_rgba16_rgbaF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgba16_rgbaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_16_F (src, dst, samples * 4);
- return samples;
+ conv_16_F (conversion, src, dst, samples * 4);
}
-static long
-conv_rgb16_rgbF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgb16_rgbF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_16_F (src, dst, samples * 3);
- return samples;
+ conv_16_F (conversion, src, dst, samples * 3);
}
-static long
-conv_ga16_gaF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_ga16_gaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_16_F (src, dst, samples * 2);
- return samples;
+ conv_16_F (conversion, src, dst, samples * 2);
}
#define conv_rgbA16_rgbAF conv_rgba16_rgbaF
#define conv_gA16_gAF conv_ga16_gaF
#define conv_g16_gF conv_16_F
-static long
-conv_rgba16_rgba8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgba16_rgba8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_16_8 (src, dst, samples * 4);
- return samples;
+ conv_16_8 (conversion, src, dst, samples * 4);
}
-static long
-conv_rgb16_rgb8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgb16_rgb8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_16_8 (src, dst, samples * 3);
- return samples;
+ conv_16_8 (conversion, src, dst, samples * 3);
}
-static long
-conv_ga16_ga8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_ga16_ga8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_16_8 (src, dst, samples * 2);
- return samples;
+ conv_16_8 (conversion, src, dst, samples * 2);
}
#define conv_rgbA16_rgbA8 conv_rgba16_rgba8
#define conv_gA16_gA8 conv_ga16_ga8
#define conv_g16_g8 conv_16_8
-static long
-conv_rgba8_rgba16 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgba8_rgba16 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_8_16 (src, dst, samples * 4);
- return samples;
+ conv_8_16 (conversion, src, dst, samples * 4);
}
-static long
-conv_rgb8_rgb16 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgb8_rgb16 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_8_16 (src, dst, samples * 3);
- return samples;
+ conv_8_16 (conversion, src, dst, samples * 3);
}
-static long
-conv_ga8_ga16 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_ga8_ga16 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
- conv_8_16 (src, dst, samples * 2);
- return samples;
+ conv_8_16 (conversion, src, dst, samples * 2);
}
#define conv_rgbA8_rgbA16 conv_rgba8_rgba16
@@ -372,8 +346,8 @@ conv_ga8_ga16 (unsigned char *src, unsigned char *dst, long samples)
/* alpha conversions */
-static long
-conv_gaF_gAF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_gaF_gAF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -388,11 +362,10 @@ conv_gaF_gAF (unsigned char *src, unsigned char *dst, long samples)
dst += 4;
src += 4;
}
- return samples;
}
-static long
-conv_gAF_gaF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_gAF_gaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -407,13 +380,12 @@ conv_gAF_gaF (unsigned char *src, unsigned char *dst, long samples)
dst += 4;
src += 4;
}
- return samples;
}
/* alpha stripping and adding */
-static long
-conv_rgbaF_rgbF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbaF_rgbF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -430,11 +402,10 @@ conv_rgbaF_rgbF (unsigned char *src, unsigned char *dst, long samples)
src += 4;
src += 4;
}
- return samples;
}
-static long
-conv_rgbF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbF_rgbaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -452,14 +423,13 @@ conv_rgbF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
*(float *) dst = 1.0;
dst += 4;
}
- return samples;
}
#define conv_rgbF_rgbAF conv_rgbF_rgbaF
-static long
-conv_gaF_gF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_gaF_gF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -470,11 +440,10 @@ conv_gaF_gF (unsigned char *src, unsigned char *dst, long samples)
src += 4;
src += 4;
}
- return samples;
}
-static long
-conv_gF_gaF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_gF_gaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -486,7 +455,6 @@ conv_gF_gaF (unsigned char *src, unsigned char *dst, long samples)
*(float *) dst = 1.0;
dst += 4;
}
- return samples;
}
#define conv_gF_gAF conv_gF_gaF
@@ -495,8 +463,8 @@ conv_gF_gaF (unsigned char *src, unsigned char *dst, long samples)
/* colorchannel dropping and adding */
-static long
-conv_gF_rgbF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_gF_rgbF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -511,11 +479,10 @@ conv_gF_rgbF (unsigned char *src, unsigned char *dst, long samples)
}
src += 4;
}
- return samples;
}
-static long
-conv_gaF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_gaF_rgbaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -533,7 +500,6 @@ conv_gaF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
dst += 4;
src += 4;
}
- return samples;
}
#define conv_gAF_rgbAF conv_gaF_rgbaF
@@ -541,8 +507,8 @@ conv_gaF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
/* other conversions coded for some optimisation reason or sumthin */
-static long
-conv_rgbaF_rgbA8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbaF_rgbA8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -561,11 +527,10 @@ conv_rgbaF_rgbA8 (unsigned char *src, unsigned char *dst, long samples)
dst++;
src += 4;
}
- return samples;
}
-static long
-conv_rgbaF_rgb16 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbaF_rgb16 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -581,11 +546,10 @@ conv_rgbaF_rgb16 (unsigned char *src, unsigned char *dst, long samples)
}
src += 4;
}
- return samples;
}
-static long
-conv_rgbA16_rgbaF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbA16_rgbaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -604,11 +568,10 @@ conv_rgbA16_rgbaF (unsigned char *src, unsigned char *dst, long samples)
dst += 4;
src += 2;
}
- return samples;
}
-static long
-conv_gF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_gF_rgbaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -624,13 +587,12 @@ conv_gF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
dst += 4;
src += 4;
}
- return samples;
}
#define conv_gF_rgbAF conv_gF_rgbaF
/*
- static long
+ static void
conv_rgb8_rgbaF (unsigned char *src,
unsigned char *dst,
int samples)
@@ -647,10 +609,9 @@ conv_gF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
(*(float *) dst) = 1.0;
dst += 4;
}
- return samples;
}
- static long
+ static void
conv_g8_rgbaF (unsigned char *src,
unsigned char *dst,
int samples)
@@ -667,10 +628,9 @@ conv_gF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
(*(float *) dst) = 1.0;
dst += 4;
}
- return samples;
}
- static long
+ static void
conv_rgb16_rgbaF (unsigned char *src,
unsigned char *dst,
int samples)
@@ -688,10 +648,9 @@ conv_gF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
src += 2;
dst += 4;
}
- return samples;
}
- static long
+ static void
conv_gF_rgbaF (unsigned char *src,
unsigned char *dst,
int samples)
@@ -709,11 +668,10 @@ conv_gF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
src += 4;
}
- return samples;
}
*/
-static long
-conv_rgba8_rgbA8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgba8_rgbA8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -738,11 +696,10 @@ conv_rgba8_rgbA8 (unsigned char *src, unsigned char *dst, long samples)
dst += 4;
src += 4;
}
- return samples;
}
-static long
-conv_rgbA8_rgba8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbA8_rgba8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -768,11 +725,10 @@ conv_rgbA8_rgba8 (unsigned char *src, unsigned char *dst, long samples)
}
src += 4;
}
- return samples;
}
-static long
-conv_rgb8_rgba8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgb8_rgba8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples-1;
while (n--)
@@ -785,13 +741,12 @@ conv_rgb8_rgba8 (unsigned char *src, unsigned char *dst, long samples)
dst[1] = src[1];
dst[2] = src[2];
dst[3] = 255;
- return samples;
}
#define conv_rgb8_rgbA8 conv_rgb8_rgba8
-static long
-conv_rgba8_rgb8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgba8_rgb8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -803,11 +758,10 @@ conv_rgba8_rgb8 (unsigned char *src, unsigned char *dst, long samples)
src += 4;
dst += 3;
}
- return samples;
}
-static long
-conv_rgbA8_rgb8 (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_rgbA8_rgb8 (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -835,7 +789,6 @@ conv_rgbA8_rgb8 (unsigned char *src, unsigned char *dst, long samples)
}
src += 4;
}
- return samples;
}
#ifndef byteclamp
@@ -862,8 +815,8 @@ conv_rgbA8_rgb8 (unsigned char *src, unsigned char *dst, long samples)
- static long
-conv_yuvaF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
+ static void
+conv_yuvaF_rgbaF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
float *src_f = (float *) src;
float *dst_f = (float *) dst;
@@ -890,12 +843,11 @@ conv_yuvaF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
dst_f += 4;
src_f += 4;
}
- return samples;
}
-static long
-conv_yuvF_rgbF (unsigned char *src, unsigned char *dst, long samples)
+static void
+conv_yuvF_rgbF (const Babl *conversion,unsigned char *src, unsigned char *dst, long samples)
{
float *src_f = (float *) src;
float *dst_f = (float *) dst;
@@ -921,7 +873,6 @@ conv_yuvF_rgbF (unsigned char *src, unsigned char *dst, long samples)
dst_f += 3;
src_f += 3;
}
- return samples;
}
int init (void);
diff --git a/extensions/gimp-8bit.c b/extensions/gimp-8bit.c
index 55bd95c..3db0be7 100644
--- a/extensions/gimp-8bit.c
+++ b/extensions/gimp-8bit.c
@@ -22,7 +22,7 @@
#include "config.h"
#include <stdio.h>
-#include "babl.h"
+#include "babl-internal.h"
#include "base/util.h"
#include "extensions/util.h"
@@ -32,27 +32,45 @@
/* lookup tables used in conversion */
+#define MAX_SPACES 32
+static const Babl *spaces[MAX_SPACES]={NULL,};
+
static float lut_linear[1 << 8];
-static float lut_gamma_2_2[1 << 8];
+static float lut_gamma_2_2[MAX_SPACES][1 << 8];
-static void
-tables_init (void)
+static int
+tables_init (const Babl *space)
{
- int i;
+ int i, j;
+
+ for (j = 0; spaces[j]; j++)
+ {
+ if (spaces[j] == space)
+ return j;
+ }
+ spaces[j] = space;
/* fill tables for conversion from 8 bit integer to float */
+ if (j == 0)
for (i = 0; i < 1 << 8; i++)
{
double value = i / 255.0;
-
lut_linear[i] = value;
- lut_gamma_2_2[i] = gamma_2_2_to_linear (value);
}
+
+ /* fill tables for conversion from 8 bit integer to float */
+ for (i = 0; i < 1 << 8; i++)
+ {
+ double value = i / 255.0;
+ lut_gamma_2_2[j][i] = babl_trc_to_linear (space->space.trc[0], value);
+ }
+
+ return j;
}
-static INLINE long
-u8_linear_to_float_linear (unsigned char *src,
+static INLINE void
+u8_linear_to_float_linear (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
@@ -61,13 +79,11 @@ u8_linear_to_float_linear (unsigned char *src,
while (n--)
*d++ = lut_linear[*src++];
-
- return samples;
}
-static INLINE long
-u8_linear_to_float_linear_premul (unsigned char *src,
+static INLINE void
+u8_linear_to_float_linear_premul (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
@@ -84,85 +100,74 @@ u8_linear_to_float_linear_premul (unsigned char *src,
src += 4;
d += 4;
}
- return samples;
}
-static INLINE long
-u8_gamma_2_2_to_float_linear (unsigned char *src,
+static INLINE void
+u8_gamma_2_2_to_float_linear (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
+ int space_no = tables_init (conversion->conversion.source->format.space);
float *d = (float *) dst;
long n = samples;
while (n--)
- *d++ = lut_gamma_2_2[*src++];
-
- return samples;
+ *d++ = lut_gamma_2_2[space_no][*src++];
}
-static INLINE long
-conv_rgba8_linear_rgbaF_linear (unsigned char *src,
+static INLINE void
+conv_rgba8_linear_rgbaF_linear (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
- u8_linear_to_float_linear (src, dst, samples * 4);
-
- return samples;
+ u8_linear_to_float_linear (conversion, src, dst, samples * 4);
}
-static INLINE long
-conv_rgba8_linear_ragabaaF_linear (unsigned char *src,
+static INLINE void
+conv_rgba8_linear_ragabaaF_linear (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
- u8_linear_to_float_linear_premul (src, dst, samples);
-
- return samples;
+ u8_linear_to_float_linear_premul (conversion, src, dst, samples);
}
-static INLINE long
-conv_rgba8_gamma_2_2_rgbaF_linear (unsigned char *src,
+static INLINE void
+conv_rgba8_gamma_2_2_rgbaF_linear (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
+ int space_no = tables_init (conversion->conversion.source->format.space);
float *d = (float *) dst;
long n = samples;
while (n--)
{
- *d++ = lut_gamma_2_2[*src++];
- *d++ = lut_gamma_2_2[*src++];
- *d++ = lut_gamma_2_2[*src++];
+ *d++ = lut_gamma_2_2[space_no][*src++];
+ *d++ = lut_gamma_2_2[space_no][*src++];
+ *d++ = lut_gamma_2_2[space_no][*src++];
*d++ = lut_linear[*src++];
}
-
- return samples;
}
-static INLINE long
-conv_rgb8_linear_rgbF_linear (unsigned char *src,
+static INLINE void
+conv_rgb8_linear_rgbF_linear (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
- u8_linear_to_float_linear (src, dst, samples * 3);
-
- return samples;
+ u8_linear_to_float_linear (conversion, src, dst, samples * 3);
}
-static INLINE long
-conv_rgb8_gamma_2_2_rgbF_linear (unsigned char *src,
+static INLINE void
+conv_rgb8_gamma_2_2_rgbF_linear (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
- u8_gamma_2_2_to_float_linear (src, dst, samples * 3);
-
- return samples;
+ u8_gamma_2_2_to_float_linear (conversion, src, dst, samples * 3);
}
-static INLINE long
-conv_rgb8_linear_rgbaF_linear (unsigned char *src,
+static INLINE void
+conv_rgb8_linear_rgbaF_linear (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
@@ -176,60 +181,54 @@ conv_rgb8_linear_rgbaF_linear (unsigned char *src,
*d++ = lut_linear[*src++];
*d++ = 1.0;
}
-
- return samples;
}
#define conv_rgb8_linear_ragabaaF_linear conv_rgb8_linear_rgbaF_linear
-static INLINE long
-conv_rgb8_gamma_2_2_rgbaF_linear (unsigned char *src,
+static INLINE void
+conv_rgb8_gamma_2_2_rgbaF_linear (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
+ int space_no = tables_init (conversion->conversion.source->format.space);
float *d = (float *) dst;
long n = samples;
while (n--)
{
- *d++ = lut_gamma_2_2[*src++];
- *d++ = lut_gamma_2_2[*src++];
- *d++ = lut_gamma_2_2[*src++];
+ *d++ = lut_gamma_2_2[space_no][*src++];
+ *d++ = lut_gamma_2_2[space_no][*src++];
+ *d++ = lut_gamma_2_2[space_no][*src++];
*d++ = 1.0;
}
-
- return samples;
}
-static INLINE long
-conv_ga8_linear_gaF_linear (unsigned char *src,
+static INLINE void
+conv_ga8_linear_gaF_linear (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
- u8_linear_to_float_linear (src, dst, samples * 2);
-
- return samples;
+ u8_linear_to_float_linear (conversion, src, dst, samples * 2);
}
-static INLINE long
-conv_ga8_gamma_2_2_gaF_linear (unsigned char *src,
+static INLINE void
+conv_ga8_gamma_2_2_gaF_linear (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
+ int space_no = tables_init (conversion->conversion.source->format.space);
float *d = (float *) dst;
long n = samples;
while (n--)
{
- *d++ = lut_gamma_2_2[*src++];
+ *d++ = lut_gamma_2_2[space_no][*src++];
*d++ = lut_linear[*src++];
}
-
- return samples;
}
-static INLINE long
-conv_ga8_gamma_2_2_rgba8_gamma_2_2 (unsigned char *src,
+static INLINE void
+conv_ga8_gamma_2_2_rgba8_gamma_2_2 (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
@@ -242,12 +241,10 @@ conv_ga8_gamma_2_2_rgba8_gamma_2_2 (unsigned char *src,
*dst++ = *src++;
*dst++ = *src++;
}
-
- return samples;
}
-static INLINE long
-conv_ga8_linear_rgbaF_linear (unsigned char *src,
+static INLINE void
+conv_ga8_linear_rgbaF_linear (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
@@ -263,53 +260,46 @@ conv_ga8_linear_rgbaF_linear (unsigned char *src,
*d++ = value;
*d++ = lut_linear[*src++];
}
-
- return samples;
}
-static INLINE long
-conv_ga8_gamma_2_2_rgbaF_linear (unsigned char *src,
+static INLINE void
+conv_ga8_gamma_2_2_rgbaF_linear (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
+ int space_no = tables_init (conversion->conversion.source->format.space);
float *d = (float *) dst;
long n = samples;
while (n--)
{
- float value = lut_gamma_2_2[*src++];
+ float value = lut_gamma_2_2[space_no][*src++];
*d++ = value;
*d++ = value;
*d++ = value;
*d++ = lut_linear[*src++];
}
-
- return samples;
}
-static INLINE long
-conv_g8_linear_gF_linear (unsigned char *src,
+static INLINE void
+conv_g8_linear_gF_linear (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
- u8_linear_to_float_linear (src, dst, samples);
-
- return samples;
+ u8_linear_to_float_linear (conversion, src, dst, samples);
}
-static INLINE long
-conv_g8_gamma_2_2_gF_linear (unsigned char *src,
+static INLINE void
+conv_g8_gamma_2_2_gF_linear (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
- u8_gamma_2_2_to_float_linear (src, dst, samples);
-
- return samples;
+ u8_gamma_2_2_to_float_linear (conversion, src, dst, samples);
}
-static INLINE long
-conv_g8_linear_rgbaF_linear (unsigned char *src,
+static INLINE void
+conv_g8_linear_rgbaF_linear (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
@@ -325,33 +315,30 @@ conv_g8_linear_rgbaF_linear (unsigned char *src,
*d++ = value;
*d++ = 1.0;
}
-
- return samples;
}
-static INLINE long
-conv_g8_gamma_2_2_rgbaF_linear (unsigned char *src,
+static INLINE void
+conv_g8_gamma_2_2_rgbaF_linear (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
+ int space_no = tables_init (conversion->conversion.source->format.space);
float *d = (float *) dst;
long n = samples;
while (n--)
{
- float value = lut_gamma_2_2[*src++];
+ float value = lut_gamma_2_2[space_no][*src++];
*d++ = value;
*d++ = value;
*d++ = value;
*d++ = 1.0;
}
-
- return samples;
}
-static INLINE long
-conv_rgbaF_linear_rgb8_linear (unsigned char *src,
- unsigned char *dst,
+static INLINE void
+conv_rgbaF_linear_rgb8_linear (const Babl *conversion,unsigned char *src,
+ unsigned char *dst,
long samples)
{
float *fsrc = (float *) src;
@@ -365,19 +352,17 @@ conv_rgbaF_linear_rgb8_linear (unsigned char *src,
v = rint (*fsrc++ * 255.0);
*dst++ = (v < 0) ? 0 : ((v > 255) ? 255 : v);
-
+
v = rint (*fsrc++ * 255.0);
*dst++ = (v < 0) ? 0 : ((v > 255) ? 255 : v);
fsrc++;
}
-
- return samples;
}
-static INLINE long
-conv_rgbaF_linear_rgba8_linear (unsigned char *src,
- unsigned char *dst,
+static INLINE void
+conv_rgbaF_linear_rgba8_linear (const Babl *conversion,unsigned char *src,
+ unsigned char *dst,
long samples)
{
float *fsrc = (float *) src;
@@ -391,15 +376,13 @@ conv_rgbaF_linear_rgba8_linear (unsigned char *src,
v = rint (*fsrc++ * 255.0);
*dst++ = (v < 0) ? 0 : ((v > 255) ? 255 : v);
-
+
v = rint (*fsrc++ * 255.0);
*dst++ = (v < 0) ? 0 : ((v > 255) ? 255 : v);
v = rint (*fsrc++ * 255.0);
*dst++ = (v < 0) ? 0 : ((v > 255) ? 255 : v);
}
-
- return samples;
}
int init (void);
@@ -494,7 +477,7 @@ init (void)
babl_component ("Y'"),
NULL);
- tables_init ();
+ tables_init (babl_space("sRGB"));
#define o(src, dst) \
babl_conversion_new (src, dst, "linear", conv_ ## src ## _ ## dst, NULL)
diff --git a/extensions/grey.c b/extensions/grey.c
index a6fef28..8989fe5 100644
--- a/extensions/grey.c
+++ b/extensions/grey.c
@@ -19,31 +19,21 @@
#include "config.h"
#include <stdio.h>
-#include "babl.h"
+#include "babl-internal.h"
#include "base/util.h"
-#include "base/rgb-constants.h"
#include "extensions/util.h"
-/* There was some debate on #gimp about whether these constants
- * are accurate, for now I've elected to just follow whatever
- * babl/base does.
- * - Daniel
- */
-
-/* Float versions of the double constants in rgb-constants.h */
-static const float RGB_LUMINANCE_RED_FLOAT = RGB_LUMINANCE_RED;
-static const float RGB_LUMINANCE_GREEN_FLOAT = RGB_LUMINANCE_GREEN;
-static const float RGB_LUMINANCE_BLUE_FLOAT = RGB_LUMINANCE_BLUE;
-
-static long
-conv_rgbaF_linear_y8_linear (unsigned char *src,
+static void
+conv_rgbaF_linear_y8_linear (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
- static const float RGB_LUMINANCE_RED_FLOAT = RGB_LUMINANCE_RED;
- static const float RGB_LUMINANCE_GREEN_FLOAT = RGB_LUMINANCE_GREEN;
- static const float RGB_LUMINANCE_BLUE_FLOAT = RGB_LUMINANCE_BLUE;
+ const Babl *space = babl_conversion_get_source_space (conversion);
+ const double *rgbtoxyz = babl_space_get_rgbtoxyz (space);
+ const float RGB_LUMINANCE_RED_FLOAT = rgbtoxyz[3];
+ const float RGB_LUMINANCE_GREEN_FLOAT = rgbtoxyz[4];
+ const float RGB_LUMINANCE_BLUE_FLOAT = rgbtoxyz[5];
float *s = (float *) src;
long n = samples;
@@ -60,15 +50,18 @@ conv_rgbaF_linear_y8_linear (unsigned char *src,
v = rint (value * 255.0);
*dst++ = (v < 0) ? 0 : ((v > 255) ? 255 : v);
}
-
- return samples;
}
-static long
-conv_rgbaF_linear_yF_linear (unsigned char *src,
+static void
+conv_rgbaF_linear_yF_linear (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
+ const Babl *space = babl_conversion_get_source_space (conversion);
+ const double *rgbtoxyz = babl_space_get_rgbtoxyz (space);
+ const float RGB_LUMINANCE_RED_FLOAT = rgbtoxyz[3];
+ const float RGB_LUMINANCE_GREEN_FLOAT = rgbtoxyz[4];
+ const float RGB_LUMINANCE_BLUE_FLOAT = rgbtoxyz[5];
float *s = (float *) src;
float *d = (float *) dst;
@@ -83,15 +76,18 @@ conv_rgbaF_linear_yF_linear (unsigned char *src,
s++;
*d++ = value;
}
-
- return samples;
}
-static long
-conv_rgbaF_linear_yaF_linear (unsigned char *src,
+static void
+conv_rgbaF_linear_yaF_linear (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
+ const Babl *space = babl_conversion_get_source_space (conversion);
+ const double *rgbtoxyz = babl_space_get_rgbtoxyz (space);
+ const float RGB_LUMINANCE_RED_FLOAT = rgbtoxyz[3];
+ const float RGB_LUMINANCE_GREEN_FLOAT = rgbtoxyz[4];
+ const float RGB_LUMINANCE_BLUE_FLOAT = rgbtoxyz[5];
float *s = (float *) src;
float *d = (float *) dst;
@@ -106,8 +102,6 @@ conv_rgbaF_linear_yaF_linear (unsigned char *src,
*d++ = value;
*d++ = *s++; /* alpha */
}
-
- return samples;
}
int init (void);
diff --git a/extensions/naive-CMYK.c b/extensions/naive-CMYK.c
index f92b0d2..ce76c4b 100644
--- a/extensions/naive-CMYK.c
+++ b/extensions/naive-CMYK.c
@@ -24,19 +24,19 @@
#include "base/util.h"
-static long rgba_to_cmyk (char *src,
+static void rgba_to_cmyk (const Babl *conversion,char *src,
char *dst,
long n);
-static long cmyk_to_rgba (char *src,
+static void cmyk_to_rgba (const Babl *conversion,char *src,
char *dst,
long n);
-static long rgba_to_cmy (char *src,
+static void rgba_to_cmy (const Babl *conversion,char *src,
char *dst,
long n);
-static long cmy_to_rgba (char *src,
+static void cmy_to_rgba (const Babl *conversion,char *src,
char *dst,
long n);
@@ -126,8 +126,8 @@ init (void)
}
-static long
-rgba_to_cmyk (char *src,
+static void
+rgba_to_cmyk (const Babl *conversion,char *src,
char *dst,
long n)
{
@@ -173,11 +173,10 @@ rgba_to_cmyk (char *src,
src += 4 * sizeof (double);
dst += 4 * sizeof (double);
}
- return n;
}
-static long
-cmyk_to_rgba (char *src,
+static void
+cmyk_to_rgba (const Babl *conversion,char *src,
char *dst,
long n)
{
@@ -214,11 +213,10 @@ cmyk_to_rgba (char *src,
src += 4 * sizeof (double);
dst += 4 * sizeof (double);
}
- return n;
}
-static long
-rgba_to_cmy (char *src,
+static void
+rgba_to_cmy (const Babl *conversion,char *src,
char *dst,
long n)
{
@@ -241,11 +239,10 @@ rgba_to_cmy (char *src,
src += 4 * sizeof (double);
dst += 3 * sizeof (double);
}
- return n;
}
-static long
-cmy_to_rgba (char *src,
+static void
+cmy_to_rgba (const Babl *conversion,char *src,
char *dst,
long n)
{
@@ -270,5 +267,4 @@ cmy_to_rgba (char *src,
src += 3 * sizeof (double);
dst += 4 * sizeof (double);
}
- return n;
}
diff --git a/extensions/simple.c b/extensions/simple.c
index 1430ab1..1d8e750 100644
--- a/extensions/simple.c
+++ b/extensions/simple.c
@@ -5,8 +5,8 @@
int init (void);
-static inline long
-float_to_u8_x1 (unsigned char *src_char, unsigned char *dst, long samples)
+static inline void
+float_to_u8_x1 (const Babl *conversion,unsigned char *src_char, unsigned char *dst, long samples)
{
float *src = (float *)src_char;
long n = samples;
@@ -17,31 +17,30 @@ float_to_u8_x1 (unsigned char *src_char, unsigned char *dst, long samples)
dst += 1;
src += 1;
}
- return samples;
}
-static inline long
-float_to_u8_x4 (unsigned char *src_char, unsigned char *dst, long samples)
+static inline void
+float_to_u8_x4 (const Babl *conversion,unsigned char *src_char, unsigned char *dst, long samples)
{
- return float_to_u8_x1 (src_char, dst, samples * 4);
+ float_to_u8_x1 (conversion, src_char, dst, samples * 4);
}
-static inline long
-float_to_u8_x3 (unsigned char *src_char, unsigned char *dst, long samples)
+static inline void
+float_to_u8_x3 (const Babl *conversion,unsigned char *src_char, unsigned char *dst, long samples)
{
- return float_to_u8_x1 (src_char, dst, samples * 3);
+ float_to_u8_x1 (conversion, src_char, dst, samples * 3);
}
-static inline long
-float_to_u8_x2 (unsigned char *src_char, unsigned char *dst, long samples)
+static inline void
+float_to_u8_x2 (const Babl *conversion,unsigned char *src_char, unsigned char *dst, long samples)
{
- return float_to_u8_x1 (src_char, dst, samples * 2);
+ float_to_u8_x1 (conversion, src_char, dst, samples * 2);
}
-static inline long
-float_pre_to_u8_pre (unsigned char *src_char, unsigned char *dst, long samples)
+static inline void
+float_pre_to_u8_pre (const Babl *conversion,unsigned char *src_char, unsigned char *dst, long samples)
{
float *src = (float *)src_char;
long n = samples;
@@ -68,11 +67,10 @@ float_pre_to_u8_pre (unsigned char *src_char, unsigned char *dst, long samples)
src += 4;
}
- return samples;
}
-static inline long
-float_to_u16_x1 (unsigned char *src_char, unsigned char *dst_char, long samples)
+static inline void
+float_to_u16_x1 (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
{
float *src = (float *)src_char;
uint16_t *dst = (uint16_t *)dst_char;
@@ -84,26 +82,25 @@ float_to_u16_x1 (unsigned char *src_char, unsigned char *dst_char, long samples)
dst += 1;
src += 1;
}
- return samples;
}
-static inline long
-float_to_u16_x2 (unsigned char *src_char, unsigned char *dst_char, long samples)
+static inline void
+float_to_u16_x2 (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
{
- return float_to_u16_x1 (src_char, dst_char, samples * 2);
+ float_to_u16_x1 (conversion, src_char, dst_char, samples * 2);
}
-static inline long
-float_to_u16_x3 (unsigned char *src_char, unsigned char *dst_char, long samples)
+static inline void
+float_to_u16_x3 (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
{
- return float_to_u16_x1 (src_char, dst_char, samples * 3);
+ float_to_u16_x1 (conversion, src_char, dst_char, samples * 3);
}
-static inline long
-float_to_u16_x4 (unsigned char *src_char, unsigned char *dst_char, long samples)
+static inline void
+float_to_u16_x4 (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
{
- return float_to_u16_x1 (src_char, dst_char, samples * 4);
+ float_to_u16_x1 (conversion, src_char, dst_char, samples * 4);
}
-static inline long
-float_pre_to_u16_pre (unsigned char *src_char, unsigned char *dst_char, long samples)
+static inline void
+float_pre_to_u16_pre (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
{
float *src = (float *)src_char;
uint16_t *dst = (uint16_t *)dst_char;
@@ -130,11 +127,10 @@ float_pre_to_u16_pre (unsigned char *src_char, unsigned char *dst_char, long sam
dst += 4;
src += 4;
}
- return samples;
}
-static inline long
-float_pre_to_u32_pre (unsigned char *src_char, unsigned char *dst_char, long samples)
+static inline void
+float_pre_to_u32_pre (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
{
float *src = (float *)src_char;
uint32_t *dst = (uint32_t *)dst_char;
@@ -161,12 +157,11 @@ float_pre_to_u32_pre (unsigned char *src_char, unsigned char *dst_char, long sam
dst += 4;
src += 4;
}
- return samples;
}
-static inline long
-float_to_u32_x1 (unsigned char *src_char, unsigned char *dst_char, long samples)
+static inline void
+float_to_u32_x1 (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
{
float *src = (float *)src_char;
uint32_t *dst = (uint32_t *)dst_char;
@@ -180,27 +175,26 @@ float_to_u32_x1 (unsigned char *src_char, unsigned char *dst_char, long samples)
dst += 1;
src += 1;
}
- return samples;
}
-static inline long
-float_to_u32_x2 (unsigned char *src_char, unsigned char *dst_char, long samples)
+static inline void
+float_to_u32_x2 (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
{
- return float_to_u32_x1 (src_char, dst_char, samples * 2);
+ float_to_u32_x1 (conversion, src_char, dst_char, samples * 2);
}
-static inline long
-float_to_u32_x3 (unsigned char *src_char, unsigned char *dst_char, long samples)
+static inline void
+float_to_u32_x3 (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
{
- return float_to_u32_x1 (src_char, dst_char, samples * 3);
+ float_to_u32_x1 (conversion, src_char, dst_char, samples * 3);
}
-static inline long
-float_to_u32_x4 (unsigned char *src_char, unsigned char *dst_char, long samples)
+static inline void
+float_to_u32_x4 (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
{
- return float_to_u32_x1 (src_char, dst_char, samples * 4);
+ float_to_u32_x1 (conversion, src_char, dst_char, samples * 4);
}
-static inline long
-u32_to_float (unsigned char *src_char, unsigned char *dst_char, long samples)
+static inline void
+u32_to_float (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
{
uint32_t *src = (uint32_t *)src_char;
float *dst = (float *)dst_char;
@@ -211,34 +205,30 @@ u32_to_float (unsigned char *src_char, unsigned char *dst_char, long samples)
dst ++;
src ++;
}
- return samples;
}
-static inline long
-u32_to_float_x4 (unsigned char *src_char, unsigned char *dst_char, long samples)
+static inline void
+u32_to_float_x4 (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
{
- u32_to_float (src_char, dst_char, samples * 4);
- return samples;
+ u32_to_float (conversion, src_char, dst_char, samples * 4);
}
-static inline long
-u32_to_float_x3 (unsigned char *src_char, unsigned char *dst_char, long samples)
+static inline void
+u32_to_float_x3 (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
{
- u32_to_float (src_char, dst_char, samples * 3);
- return samples;
+ u32_to_float (conversion, src_char, dst_char, samples * 3);
}
-static inline long
-u32_to_float_x2 (unsigned char *src_char, unsigned char *dst_char, long samples)
+static inline void
+u32_to_float_x2 (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
{
- u32_to_float (src_char, dst_char, samples * 2);
- return samples;
+ u32_to_float (conversion, src_char, dst_char, samples * 2);
}
-static inline long
-u16_to_float (unsigned char *src_char, unsigned char *dst_char, long samples)
+static inline void
+u16_to_float (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
{
uint16_t *src = (uint16_t *)src_char;
float *dst = (float *)dst_char;
@@ -249,33 +239,29 @@ u16_to_float (unsigned char *src_char, unsigned char *dst_char, long samples)
dst ++;
src ++;
}
- return samples;
}
-static inline long
-u16_to_float_x4 (unsigned char *src_char, unsigned char *dst_char, long samples)
+static inline void
+u16_to_float_x4 (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
{
- u16_to_float (src_char, dst_char, samples * 4);
- return samples;
+ u16_to_float (conversion, src_char, dst_char, samples * 4);
}
-static inline long
-u16_to_float_x3 (unsigned char *src_char, unsigned char *dst_char, long samples)
+static inline void
+u16_to_float_x3 (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
{
- u16_to_float (src_char, dst_char, samples * 3);
- return samples;
+ u16_to_float (conversion, src_char, dst_char, samples * 3);
}
-static inline long
-u16_to_float_x2 (unsigned char *src_char, unsigned char *dst_char, long samples)
+static inline void
+u16_to_float_x2 (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
{
- u16_to_float (src_char, dst_char, samples * 2);
- return samples;
+ u16_to_float (conversion, src_char, dst_char, samples * 2);
}
-static inline long
-yau16_rgbaf (unsigned char *src_char, unsigned char *dst_char, long samples)
+static inline void
+yau16_rgbaf (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples)
{
uint16_t *src = (uint16_t *)src_char;
float *dst = (float *)dst_char;
@@ -289,7 +275,6 @@ yau16_rgbaf (unsigned char *src_char, unsigned char *dst_char, long samples)
dst +=4;
src +=2;
}
- return samples;
}
diff --git a/extensions/sse-half.c b/extensions/sse-half.c
index e20c214..9f0dfe4 100644
--- a/extensions/sse-half.c
+++ b/extensions/sse-half.c
@@ -29,8 +29,8 @@
#include "babl-cpuaccel.h"
#include "extensions/util.h"
-static inline long
-conv_yHalf_yF (const uint16_t *src, float *dst, long samples)
+static inline void
+conv_yHalf_yF (const Babl *conversion,const uint16_t *src, float *dst, long samples)
{
const uint64_t *s_vec;
__v4sf *d_vec;
@@ -58,30 +58,28 @@ conv_yHalf_yF (const uint16_t *src, float *dst, long samples)
_mm_store_ss(dst++, out_val);
n -= 1;
}
-
- return samples;
}
-static long
-conv_yaHalf_yaF (const uint16_t *src, float *dst, long samples)
+static void
+conv_yaHalf_yaF (const Babl *conversion,const uint16_t *src, float *dst, long samples)
{
- return conv_yHalf_yF (src, dst, samples * 2) / 2;
+ conv_yHalf_yF (conversion, src, dst, samples * 2);
}
-static long
-conv_rgbHalf_rgbF (const uint16_t *src, float *dst, long samples)
+static void
+conv_rgbHalf_rgbF (const Babl *conversion,const uint16_t *src, float *dst, long samples)
{
- return conv_yHalf_yF (src, dst, samples * 3) / 3;
+ conv_yHalf_yF (conversion, src, dst, samples * 3);
}
-static long
-conv_rgbaHalf_rgbaF (const uint16_t *src, float *dst, long samples)
+static void
+conv_rgbaHalf_rgbaF (const Babl *conversion,const uint16_t *src, float *dst, long samples)
{
- return conv_yHalf_yF (src, dst, samples * 4) / 4;
+ conv_yHalf_yF (conversion, src, dst, samples * 4);
}
-static inline long
-conv_yF_yHalf (const float *src, uint16_t *dst, long samples)
+static inline void
+conv_yF_yHalf (const Babl *conversion,const float *src, uint16_t *dst, long samples)
{
const __v4sf *s_vec;
uint64_t *d_vec;
@@ -109,26 +107,24 @@ conv_yF_yHalf (const float *src, uint16_t *dst, long samples)
*dst++ = _mm_extract_epi16(out_val, 0);
n -= 1;
}
-
- return samples;
}
-static long
-conv_yaF_yaHalf (const float *src, uint16_t *dst, long samples)
+static void
+conv_yaF_yaHalf (const Babl *conversion,const float *src, uint16_t *dst, long samples)
{
- return conv_yF_yHalf (src, dst, samples * 2) / 2;
+ conv_yF_yHalf (conversion, src, dst, samples * 2);
}
-static long
-conv_rgbF_rgbHalf (const float *src, uint16_t *dst, long samples)
+static void
+conv_rgbF_rgbHalf (const Babl *conversion,const float *src, uint16_t *dst, long samples)
{
- return conv_yF_yHalf (src, dst, samples * 3) / 3;
+ conv_yF_yHalf (conversion, src, dst, samples * 3);
}
-static long
-conv_rgbaF_rgbaHalf (const float *src, uint16_t *dst, long samples)
+static void
+conv_rgbaF_rgbaHalf (const Babl *conversion,const float *src, uint16_t *dst, long samples)
{
- return conv_yF_yHalf (src, dst, samples * 4) / 4;
+ conv_yF_yHalf (conversion, src, dst, samples * 4);
}
#endif /* defined(USE_SSE4_1) && defined(USE_F16C) && defined(ARCH_X86_64) */
diff --git a/extensions/sse2-float.c b/extensions/sse2-float.c
index 71fa008..d26073c 100644
--- a/extensions/sse2-float.c
+++ b/extensions/sse2-float.c
@@ -37,8 +37,8 @@
static const float BABL_ALPHA_THRESHOLD_FLOAT = (float)BABL_ALPHA_THRESHOLD;
-static long
-conv_rgbaF_linear_rgbAF_linear (const float *src, float *dst, long samples)
+static void
+conv_rgbaF_linear_rgbAF_linear (const Babl *conversion,const float *src, float *dst, long samples)
{
long i = 0;
long remainder;
@@ -91,12 +91,10 @@ conv_rgbaF_linear_rgbAF_linear (const float *src, float *dst, long samples)
src += 4;
dst += 4;
}
-
- return samples;
}
-static long
-conv_rgbAF_linear_rgbaF_linear_shuffle (const float *src, float *dst, long samples)
+static void
+conv_rgbAF_linear_rgbaF_linear_shuffle (const Babl *conversion,const float *src, float *dst, long samples)
{
long i = 0;
long remainder;
@@ -159,12 +157,10 @@ conv_rgbAF_linear_rgbaF_linear_shuffle (const float *src, float *dst, long sampl
src += 4;
dst += 4;
}
-
- return samples;
}
-static long
-conv_rgbAF_linear_rgbaF_linear_spin (const float *src, float *dst, long samples)
+static void
+conv_rgbAF_linear_rgbaF_linear_spin (const Babl *conversion,const float *src, float *dst, long samples)
{
long i = 0;
long remainder;
@@ -234,8 +230,6 @@ conv_rgbAF_linear_rgbaF_linear_spin (const float *src, float *dst, long samples)
src += 4;
dst += 4;
}
-
- return samples;
}
#define splat4f(x) ((__v4sf){x,x,x,x})
@@ -296,8 +290,8 @@ gamma_2_2_to_linear_sse2 (__v4sf x)
}
#define GAMMA_RGBA(func, munge) \
-static inline long \
-func (const float *src, float *dst, long samples)\
+static inline void \
+func (const Babl *conversion,const float *src, float *dst, long samples)\
{\
int i = samples;\
if (((uintptr_t)src % 16) + ((uintptr_t)dst % 16) == 0)\
@@ -347,18 +341,16 @@ func (const float *src, float *dst, long samples)\
dst[3] = a;\
}\
}\
- return samples;\
}
GAMMA_RGBA(conv_rgbaF_linear_rgbaF_gamma, linear_to_gamma_2_2_sse2)
GAMMA_RGBA(conv_rgbaF_gamma_rgbaF_linear, gamma_2_2_to_linear_sse2)
-static long conv_rgbaF_linear_rgbAF_gamma (const float *src, float *dst, long samples)
+static void conv_rgbaF_linear_rgbAF_gamma (const Babl *conversion,const float *src, float *dst, long samples)
{
float *tmp = alloca (sizeof(float)*4*samples);
- conv_rgbaF_linear_rgbaF_gamma (src, tmp, samples);
- conv_rgbaF_linear_rgbAF_linear (tmp, dst, samples);
- return samples;
+ conv_rgbaF_linear_rgbaF_gamma (conversion, src, tmp, samples);
+ conv_rgbaF_linear_rgbAF_linear (conversion, tmp, dst, samples);
}
#define YA_APPLY(load, store, convert) \
@@ -379,11 +371,9 @@ static long conv_rgbaF_linear_rgbAF_gamma (const float *src, float *dst, long sa
store ((float *)d++, yaya1); \
}\
-static long
-conv_yaF_linear_yaF_gamma (const float *src, float *dst, long samples)
+static void
+conv_yaF_linear_yaF_gamma (const Babl *conversion,const float *src, float *dst, long samples)
{
- long total = samples;
-
const __v4sf *s = (const __v4sf*)src;
__v4sf *d = (__v4sf*)dst;
@@ -412,16 +402,12 @@ conv_yaF_linear_yaF_gamma (const float *src, float *dst, long samples)
*dst++ = babl_linear_to_gamma_2_2 (*src++);
*dst++ = *src++;
}
-
- return total;
}
-static long
-conv_yaF_gamma_yaF_linear (const float *src, float *dst, long samples)
+static void
+conv_yaF_gamma_yaF_linear (const Babl *conversion,const float *src, float *dst, long samples)
{
- long total = samples;
-
const __v4sf *s = (const __v4sf*)src;
__v4sf *d = (__v4sf*)dst;
@@ -450,15 +436,11 @@ conv_yaF_gamma_yaF_linear (const float *src, float *dst, long samples)
*dst++ = babl_gamma_2_2_to_linear (*src++);
*dst++ = *src++;
}
-
- return total;
}
-static inline long
-conv_yF_linear_yF_gamma (const float *src, float *dst, long samples)
+static inline void
+conv_yF_linear_yF_gamma (const Babl *conversion,const float *src, float *dst, long samples)
{
- long total = samples;
-
const __v4sf *s = (const __v4sf*)src;
__v4sf *d = (__v4sf*)dst;
@@ -490,15 +472,11 @@ conv_yF_linear_yF_gamma (const float *src, float *dst, long samples)
{
*dst++ = babl_linear_to_gamma_2_2 (*src++);
}
-
- return total;
}
-static inline long
-conv_yF_gamma_yF_linear (const float *src, float *dst, long samples)
+static inline void
+conv_yF_gamma_yF_linear (const Babl *conversion,const float *src, float *dst, long samples)
{
- long total = samples;
-
const __v4sf *s = (const __v4sf*)src;
__v4sf *d = (__v4sf*)dst;
@@ -530,22 +508,20 @@ conv_yF_gamma_yF_linear (const float *src, float *dst, long samples)
{
*dst++ = babl_gamma_2_2_to_linear (*src++);
}
-
- return total;
}
-static long
-conv_rgbF_linear_rgbF_gamma (const float *src, float *dst, long samples)
+static void
+conv_rgbF_linear_rgbF_gamma (const Babl *conversion,const float *src, float *dst, long samples)
{
- return conv_yF_linear_yF_gamma (src, dst, samples * 3) / 3;
+ conv_yF_linear_yF_gamma (conversion, src, dst, samples * 3);
}
-static long
-conv_rgbF_gamma_rgbF_linear (const float *src, float *dst, long samples)
+static void
+conv_rgbF_gamma_rgbF_linear (const Babl *conversion,const float *src, float *dst, long samples)
{
- return conv_yF_gamma_yF_linear (src, dst, samples * 3) / 3;
+ conv_yF_gamma_yF_linear (conversion, src, dst, samples * 3);
}
#endif /* defined(USE_SSE2) */
diff --git a/extensions/sse2-int16.c b/extensions/sse2-int16.c
index 843e030..24815b3 100644
--- a/extensions/sse2-int16.c
+++ b/extensions/sse2-int16.c
@@ -34,8 +34,8 @@
#define Q(a) { a, a, a, a }
static const __v4sf u16_float = Q (1.f / 65535);
-static long
-conv_rgba16_rgbaF (const uint16_t *src, float *dst, long samples)
+static void
+conv_rgba16_rgbaF (const Babl *conversion,const uint16_t *src, float *dst, long samples)
{
long i = 0;
@@ -66,12 +66,10 @@ conv_rgba16_rgbaF (const uint16_t *src, float *dst, long samples)
for (i *= 2 * 4; i != 4 * samples; i++)
dst[i] = src[i] * (1.f / 65535);
-
- return samples;
}
-static long
-conv_rgba16_rgbAF (const uint16_t *src, float *dst, long samples)
+static void
+conv_rgba16_rgbAF (const Babl *conversion,const uint16_t *src, float *dst, long samples)
{
long i = 0;
long remainder;
@@ -131,8 +129,6 @@ conv_rgba16_rgbAF (const uint16_t *src, float *dst, long samples)
src += 4;
dst += 4;
}
-
- return samples;
}
#endif /* defined(USE_SSE2) */
diff --git a/extensions/sse2-int8.c b/extensions/sse2-int8.c
index 5353de6..d8bd187 100644
--- a/extensions/sse2-int8.c
+++ b/extensions/sse2-int8.c
@@ -30,8 +30,8 @@
#include "babl-cpuaccel.h"
#include "extensions/util.h"
-static inline long
-conv_yF_y8 (const float *src, uint8_t *dst, long samples)
+static inline void
+conv_yF_y8 (const Babl *conversion,const float *src, uint8_t *dst, long samples)
{
const __v4sf *s_vec;
__m128i *d_vec;
@@ -123,33 +123,31 @@ conv_yF_y8 (const float *src, uint8_t *dst, long samples)
n -= 1;
}
-
- return samples;
}
-static long
-conv_yaF_ya8 (const float *src, uint8_t *dst, long samples)
+static void
+conv_yaF_ya8 (const Babl *conversion,const float *src, uint8_t *dst, long samples)
{
- return conv_yF_y8 (src, dst, samples * 2) / 2;
+ conv_yF_y8 (conversion, src, dst, samples * 2);
}
-static long
-conv_rgbF_rgb8 (const float *src, uint8_t *dst, long samples)
+static void
+conv_rgbF_rgb8 (const Babl *conversion,const float *src, uint8_t *dst, long samples)
{
- return conv_yF_y8 (src, dst, samples * 3) / 3;
+ conv_yF_y8 (conversion, src, dst, samples * 3);
}
-static long
-conv_rgbaF_rgba8 (const float *src, uint8_t *dst, long samples)
+static void
+conv_rgbaF_rgba8 (const Babl *conversion,const float *src, uint8_t *dst, long samples)
{
- return conv_yF_y8 (src, dst, samples * 4) / 4;
+ conv_yF_y8 (conversion, src, dst, samples * 4);
}
-static long
-conv_rgbAF_rgbA8 (const float *src, uint8_t *dst, long samples)
+static void
+conv_rgbAF_rgbA8 (const Babl *conversion,const float *src, uint8_t *dst, long samples)
{
- return conv_yF_y8 (src, dst, samples * 4) / 4;
+ conv_yF_y8 (conversion, src, dst, samples * 4);
}
#endif
diff --git a/extensions/sse4-int8.c b/extensions/sse4-int8.c
index 73f63e3..0eb0846 100644
--- a/extensions/sse4-int8.c
+++ b/extensions/sse4-int8.c
@@ -30,8 +30,8 @@
#include "babl-cpuaccel.h"
#include "extensions/util.h"
-static inline long
-conv_y8_yF (const uint8_t *src, float *dst, long samples)
+static inline void
+conv_y8_yF (const Babl *conversion,const uint8_t *src, float *dst, long samples)
{
const float factor = 1.0f / 255.0f;
const __v4sf factor_vec = {1.0f / 255.0f, 1.0f / 255.0f, 1.0f / 255.0f, 1.0f / 255.0f};
@@ -47,7 +47,7 @@ conv_y8_yF (const uint8_t *src, float *dst, long samples)
{
__m128i in_val;
__v4sf out_val;
- in_val = _mm_insert_epi32 (in_val, *s_vec++, 0);
+ in_val = _mm_insert_epi32 ((__m128i)_mm_setzero_ps(), *s_vec++, 0);
in_val = _mm_cvtepu8_epi32 (in_val);
out_val = _mm_cvtepi32_ps (in_val) * factor_vec;
_mm_storeu_ps ((float *)d_vec++, out_val);
@@ -62,26 +62,24 @@ conv_y8_yF (const uint8_t *src, float *dst, long samples)
*dst++ = (float)(*src++) * factor;
n -= 1;
}
-
- return samples;
}
-static long
-conv_ya8_yaF (const uint8_t *src, float *dst, long samples)
+static void
+conv_ya8_yaF (const Babl *conversion,const uint8_t *src, float *dst, long samples)
{
- return conv_y8_yF (src, dst, samples * 2) / 2;
+ conv_y8_yF (conversion, src, dst, samples * 2);
}
-static long
-conv_rgb8_rgbF (const uint8_t *src, float *dst, long samples)
+static void
+conv_rgb8_rgbF (const Babl *conversion,const uint8_t *src, float *dst, long samples)
{
- return conv_y8_yF (src, dst, samples * 3) / 3;
+ conv_y8_yF (conversion, src, dst, samples * 3);
}
-static long
-conv_rgba8_rgbaF (const uint8_t *src, float *dst, long samples)
+static void
+conv_rgba8_rgbaF (const Babl *conversion,const uint8_t *src, float *dst, long samples)
{
- return conv_y8_yF (src, dst, samples * 4) / 4;
+ conv_y8_yF (conversion, src, dst, samples * 4);
}
#endif
diff --git a/extensions/two-table.c b/extensions/two-table.c
index 6be18ca..4b263cc 100644
--- a/extensions/two-table.c
+++ b/extensions/two-table.c
@@ -42,8 +42,8 @@ conv_float_u8_two_table_map (float value)
return result;
}
-static long
-conv_rgbafloat_linear_cairo24_le (unsigned char *src_char,
+static void
+conv_rgbafloat_linear_cairo24_le (const Babl *conversion,unsigned char *src_char,
unsigned char *dst,
long samples)
{
@@ -65,11 +65,10 @@ conv_rgbafloat_linear_cairo24_le (unsigned char *src_char,
src += 4;
dst += 4;
}
- return samples;
}
-static long
-conv_rgbfloat_linear_cairo24_le (unsigned char *src_char,
+static void
+conv_rgbfloat_linear_cairo24_le (const Babl *conversion,unsigned char *src_char,
unsigned char *dst,
long samples)
{
@@ -85,11 +84,10 @@ conv_rgbfloat_linear_cairo24_le (unsigned char *src_char,
src += 3;
dst += 4;
}
- return samples;
}
-static long
-conv_rgbafloat_linear_rgbu8_gamma (unsigned char *src_char,
+static void
+conv_rgbafloat_linear_rgbu8_gamma (const Babl *conversion,unsigned char *src_char,
unsigned char *dst,
long samples)
{
@@ -113,12 +111,11 @@ conv_rgbafloat_linear_rgbu8_gamma (unsigned char *src_char,
src += 4;
dst += 3;
}
- return samples;
}
-static long
-conv_rgbafloat_linear_rgbau8_gamma (unsigned char *src_char,
+static void
+conv_rgbafloat_linear_rgbau8_gamma (const Babl *conversion,unsigned char *src_char,
unsigned char *dst,
long samples)
{
@@ -144,11 +141,10 @@ conv_rgbafloat_linear_rgbau8_gamma (unsigned char *src_char,
src += 4;
dst += 4;
}
- return samples;
}
-static long
-conv_rgbfloat_linear_rgbu8_gamma (unsigned char *src_char,
+static void
+conv_rgbfloat_linear_rgbu8_gamma (const Babl *conversion,unsigned char *src_char,
unsigned char *dst,
long samples)
{
@@ -164,11 +160,10 @@ conv_rgbfloat_linear_rgbu8_gamma (unsigned char *src_char,
src += 3;
dst += 3;
}
- return samples;
}
-static long
-conv_yfloat_linear_yu8_gamma (unsigned char *src_char,
+static void
+conv_yfloat_linear_yu8_gamma (const Babl *conversion,unsigned char *src_char,
unsigned char *dst,
long samples)
{
@@ -179,11 +174,10 @@ conv_yfloat_linear_yu8_gamma (unsigned char *src_char,
{
*dst++ = conv_float_u8_two_table_map (*src++);
}
- return samples;
}
-static long
-conv_yafloat_linear_yau8_gamma (unsigned char *src_char,
+static void
+conv_yafloat_linear_yau8_gamma (const Babl *conversion,unsigned char *src_char,
unsigned char *dst,
long samples)
{
@@ -198,7 +192,6 @@ conv_yafloat_linear_yau8_gamma (unsigned char *src_char,
alpha = rint (*src++ * 255.0);
*dst++ = (alpha < 0) ? 0 : ((alpha > 255) ? 255 : alpha);
}
- return samples;
}
int init (void);
diff --git a/extensions/ycbcr.c b/extensions/ycbcr.c
index 11db563..5da49cb 100644
--- a/extensions/ycbcr.c
+++ b/extensions/ycbcr.c
@@ -71,8 +71,8 @@ models (void)
}
-static long
-rgba_to_ycbcra709 (char *src,
+static void
+rgba_to_ycbcra709 (const Babl *conversion,char *src,
char *dst,
long n)
{
@@ -101,12 +101,11 @@ rgba_to_ycbcra709 (char *src,
src += sizeof (double) * 4;
dst += sizeof (double) * 4;
}
- return n;
}
-static long
-rgba_to_ycbcr709 (char *src,
+static void
+rgba_to_ycbcr709 (const Babl *conversion,char *src,
char *dst,
long n)
{
@@ -133,12 +132,11 @@ rgba_to_ycbcr709 (char *src,
src += sizeof (double) * 4;
dst += sizeof (double) * 3;
}
- return n;
}
-static long
-ycbcra709_to_rgba (char *src,
+static void
+ycbcra709_to_rgba (const Babl *conversion,char *src,
char *dst,
long n)
{
@@ -167,12 +165,11 @@ ycbcra709_to_rgba (char *src,
src += sizeof (double) * 4;
dst += sizeof (double) * 4;
}
- return n;
}
-static long
-ycbcr709_to_rgba (char *src,
+static void
+ycbcr709_to_rgba (const Babl *conversion,char *src,
char *dst,
long n)
{
@@ -200,7 +197,6 @@ ycbcr709_to_rgba (char *src,
src += sizeof (double) * 3;
dst += sizeof (double) * 4;
}
- return n;
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0db0ccd..59bb296 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -6,6 +6,7 @@ endif
C_TESTS = \
grayscale_to_rgb \
+ chromaticities \
rgb_to_bgr \
rgb_to_ycbcr \
srgb_to_lab_u8 \
@@ -34,18 +35,17 @@ TESTS_ENVIRONMENT = LD_LIBRARY_PATH=$(top_builddir)/babl:$LD_LIBRARY_PATH GI_TYP
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/babl
if OS_UNIX
-AM_LDFLAGS = -pthread
+AM_LDFLAGS = -lpthread -no-install
+else
+
+AM_LDFLAGS = -no-install
endif
+
LDADD = $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
$(MATH_LIB) $(THREAD_LIB)
EXTRA_DIST=common.inc
noinst_PROGRAMS = \
- introspect \
- babl_fish_path_fitness \
- babl-html-dump \
- conversions \
- formats \
$(C_TESTS)
diff --git a/tests/Makefile.in b/tests/Makefile.in
index aa150fd..9b68b9e 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -90,9 +90,7 @@ build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
TESTS = $(am__EXEEXT_2)
-noinst_PROGRAMS = introspect$(EXEEXT) babl_fish_path_fitness$(EXEEXT) \
- babl-html-dump$(EXEEXT) conversions$(EXEEXT) formats$(EXEEXT) \
- $(am__EXEEXT_2)
+noinst_PROGRAMS = $(am__EXEEXT_2)
subdir = tests
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
@@ -108,8 +106,9 @@ CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
@OS_UNIX_TRUE@am__EXEEXT_1 = concurrency-stress-test$(EXEEXT) \
@OS_UNIX_TRUE@ palette-concurrency-stress-test$(EXEEXT)
-am__EXEEXT_2 = grayscale_to_rgb$(EXEEXT) rgb_to_bgr$(EXEEXT) \
- rgb_to_ycbcr$(EXEEXT) srgb_to_lab_u8$(EXEEXT) sanity$(EXEEXT) \
+am__EXEEXT_2 = grayscale_to_rgb$(EXEEXT) chromaticities$(EXEEXT) \
+ rgb_to_bgr$(EXEEXT) rgb_to_ycbcr$(EXEEXT) \
+ srgb_to_lab_u8$(EXEEXT) sanity$(EXEEXT) \
babl_class_name$(EXEEXT) extract$(EXEEXT) floatclamp$(EXEEXT) \
float-to-8bit$(EXEEXT) hsl$(EXEEXT) hsva$(EXEEXT) \
types$(EXEEXT) palette$(EXEEXT) extract$(EXEEXT) nop$(EXEEXT) \
@@ -117,47 +116,35 @@ am__EXEEXT_2 = grayscale_to_rgb$(EXEEXT) rgb_to_bgr$(EXEEXT) \
models$(EXEEXT) cairo-RGB24$(EXEEXT) transparent$(EXEEXT) \
$(am__EXEEXT_1)
PROGRAMS = $(noinst_PROGRAMS)
-babl_html_dump_SOURCES = babl-html-dump.c
-babl_html_dump_OBJECTS = babl-html-dump.$(OBJEXT)
-babl_html_dump_LDADD = $(LDADD)
+babl_class_name_SOURCES = babl_class_name.c
+babl_class_name_OBJECTS = babl_class_name.$(OBJEXT)
+babl_class_name_LDADD = $(LDADD)
am__DEPENDENCIES_1 =
-babl_html_dump_DEPENDENCIES = \
+babl_class_name_DEPENDENCIES = \
$(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
-babl_class_name_SOURCES = babl_class_name.c
-babl_class_name_OBJECTS = babl_class_name.$(OBJEXT)
-babl_class_name_LDADD = $(LDADD)
-babl_class_name_DEPENDENCIES = \
- $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
- $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
-babl_fish_path_fitness_SOURCES = babl_fish_path_fitness.c
-babl_fish_path_fitness_OBJECTS = babl_fish_path_fitness.$(OBJEXT)
-babl_fish_path_fitness_LDADD = $(LDADD)
-babl_fish_path_fitness_DEPENDENCIES = \
- $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
- $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
cairo_RGB24_SOURCES = cairo-RGB24.c
cairo_RGB24_OBJECTS = cairo-RGB24.$(OBJEXT)
cairo_RGB24_LDADD = $(LDADD)
cairo_RGB24_DEPENDENCIES = \
$(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+chromaticities_SOURCES = chromaticities.c
+chromaticities_OBJECTS = chromaticities.$(OBJEXT)
+chromaticities_LDADD = $(LDADD)
+chromaticities_DEPENDENCIES = \
+ $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
concurrency_stress_test_SOURCES = concurrency-stress-test.c
concurrency_stress_test_OBJECTS = concurrency-stress-test.$(OBJEXT)
concurrency_stress_test_LDADD = $(LDADD)
concurrency_stress_test_DEPENDENCIES = \
$(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
-conversions_SOURCES = conversions.c
-conversions_OBJECTS = conversions.$(OBJEXT)
-conversions_LDADD = $(LDADD)
-conversions_DEPENDENCIES = \
- $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
- $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
extract_SOURCES = extract.c
extract_OBJECTS = extract.$(OBJEXT)
extract_LDADD = $(LDADD)
@@ -176,12 +163,6 @@ floatclamp_LDADD = $(LDADD)
floatclamp_DEPENDENCIES = \
$(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
-formats_SOURCES = formats.c
-formats_OBJECTS = formats.$(OBJEXT)
-formats_LDADD = $(LDADD)
-formats_DEPENDENCIES = \
- $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
- $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
grayscale_to_rgb_SOURCES = grayscale_to_rgb.c
grayscale_to_rgb_OBJECTS = grayscale_to_rgb.$(OBJEXT)
grayscale_to_rgb_LDADD = $(LDADD)
@@ -199,12 +180,6 @@ hsva_LDADD = $(LDADD)
hsva_DEPENDENCIES = \
$(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
-introspect_SOURCES = introspect.c
-introspect_OBJECTS = introspect.$(OBJEXT)
-introspect_LDADD = $(LDADD)
-introspect_DEPENDENCIES = \
- $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
- $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
models_SOURCES = models.c
models_OBJECTS = models.$(OBJEXT)
models_LDADD = $(LDADD)
@@ -312,19 +287,16 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
-SOURCES = babl-html-dump.c babl_class_name.c babl_fish_path_fitness.c \
- cairo-RGB24.c concurrency-stress-test.c conversions.c \
- extract.c float-to-8bit.c floatclamp.c formats.c \
- grayscale_to_rgb.c hsl.c hsva.c introspect.c models.c \
+SOURCES = babl_class_name.c cairo-RGB24.c chromaticities.c \
+ concurrency-stress-test.c extract.c float-to-8bit.c \
+ floatclamp.c grayscale_to_rgb.c hsl.c hsva.c models.c \
n_components.c n_components_cast.c nop.c palette.c \
palette-concurrency-stress-test.c rgb_to_bgr.c rgb_to_ycbcr.c \
sanity.c srgb_to_lab_u8.c transparent.c types.c
-DIST_SOURCES = babl-html-dump.c babl_class_name.c \
- babl_fish_path_fitness.c cairo-RGB24.c \
- concurrency-stress-test.c conversions.c extract.c \
- float-to-8bit.c floatclamp.c formats.c grayscale_to_rgb.c \
- hsl.c hsva.c introspect.c models.c n_components.c \
- n_components_cast.c nop.c palette.c \
+DIST_SOURCES = babl_class_name.c cairo-RGB24.c chromaticities.c \
+ concurrency-stress-test.c extract.c float-to-8bit.c \
+ floatclamp.c grayscale_to_rgb.c hsl.c hsva.c models.c \
+ n_components.c n_components_cast.c nop.c palette.c \
palette-concurrency-stress-test.c rgb_to_bgr.c rgb_to_ycbcr.c \
sanity.c srgb_to_lab_u8.c transparent.c types.c
am__can_run_installinfo = \
@@ -612,6 +584,7 @@ LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
+LOG_LIB = @LOG_LIB@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAINT = @MAINT@
@@ -713,6 +686,7 @@ top_srcdir = @top_srcdir@
C_TESTS = \
grayscale_to_rgb \
+ chromaticities \
rgb_to_bgr \
rgb_to_ycbcr \
srgb_to_lab_u8 \
@@ -736,7 +710,8 @@ C_TESTS = \
TESTS_ENVIRONMENT = LD_LIBRARY_PATH=$(top_builddir)/babl:$LD_LIBRARY_PATH GI_TYPELIB_PATH=$(top_builddir)/babl BABL_PATH=$(top_builddir)/extensions/.libs
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/babl
-@OS_UNIX_TRUE@AM_LDFLAGS = -pthread
+@OS_UNIX_FALSE@AM_LDFLAGS = -no-install
+@OS_UNIX_TRUE@AM_LDFLAGS = -lpthread -no-install
LDADD = $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
$(MATH_LIB) $(THREAD_LIB)
@@ -784,30 +759,22 @@ clean-noinstPROGRAMS:
echo " rm -f" $$list; \
rm -f $$list
-babl-html-dump$(EXEEXT): $(babl_html_dump_OBJECTS) $(babl_html_dump_DEPENDENCIES) $(EXTRA_babl_html_dump_DEPENDENCIES)
- @rm -f babl-html-dump$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(babl_html_dump_OBJECTS) $(babl_html_dump_LDADD) $(LIBS)
-
babl_class_name$(EXEEXT): $(babl_class_name_OBJECTS) $(babl_class_name_DEPENDENCIES) $(EXTRA_babl_class_name_DEPENDENCIES)
@rm -f babl_class_name$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(babl_class_name_OBJECTS) $(babl_class_name_LDADD) $(LIBS)
-babl_fish_path_fitness$(EXEEXT): $(babl_fish_path_fitness_OBJECTS) $(babl_fish_path_fitness_DEPENDENCIES) $(EXTRA_babl_fish_path_fitness_DEPENDENCIES)
- @rm -f babl_fish_path_fitness$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(babl_fish_path_fitness_OBJECTS) $(babl_fish_path_fitness_LDADD) $(LIBS)
-
cairo-RGB24$(EXEEXT): $(cairo_RGB24_OBJECTS) $(cairo_RGB24_DEPENDENCIES) $(EXTRA_cairo_RGB24_DEPENDENCIES)
@rm -f cairo-RGB24$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(cairo_RGB24_OBJECTS) $(cairo_RGB24_LDADD) $(LIBS)
+chromaticities$(EXEEXT): $(chromaticities_OBJECTS) $(chromaticities_DEPENDENCIES) $(EXTRA_chromaticities_DEPENDENCIES)
+ @rm -f chromaticities$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(chromaticities_OBJECTS) $(chromaticities_LDADD) $(LIBS)
+
concurrency-stress-test$(EXEEXT): $(concurrency_stress_test_OBJECTS) $(concurrency_stress_test_DEPENDENCIES) $(EXTRA_concurrency_stress_test_DEPENDENCIES)
@rm -f concurrency-stress-test$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(concurrency_stress_test_OBJECTS) $(concurrency_stress_test_LDADD) $(LIBS)
-conversions$(EXEEXT): $(conversions_OBJECTS) $(conversions_DEPENDENCIES) $(EXTRA_conversions_DEPENDENCIES)
- @rm -f conversions$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(conversions_OBJECTS) $(conversions_LDADD) $(LIBS)
-
extract$(EXEEXT): $(extract_OBJECTS) $(extract_DEPENDENCIES) $(EXTRA_extract_DEPENDENCIES)
@rm -f extract$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(extract_OBJECTS) $(extract_LDADD) $(LIBS)
@@ -820,10 +787,6 @@ floatclamp$(EXEEXT): $(floatclamp_OBJECTS) $(floatclamp_DEPENDENCIES) $(EXTRA_fl
@rm -f floatclamp$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(floatclamp_OBJECTS) $(floatclamp_LDADD) $(LIBS)
-formats$(EXEEXT): $(formats_OBJECTS) $(formats_DEPENDENCIES) $(EXTRA_formats_DEPENDENCIES)
- @rm -f formats$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(formats_OBJECTS) $(formats_LDADD) $(LIBS)
-
grayscale_to_rgb$(EXEEXT): $(grayscale_to_rgb_OBJECTS) $(grayscale_to_rgb_DEPENDENCIES) $(EXTRA_grayscale_to_rgb_DEPENDENCIES)
@rm -f grayscale_to_rgb$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(grayscale_to_rgb_OBJECTS) $(grayscale_to_rgb_LDADD) $(LIBS)
@@ -836,10 +799,6 @@ hsva$(EXEEXT): $(hsva_OBJECTS) $(hsva_DEPENDENCIES) $(EXTRA_hsva_DEPENDENCIES)
@rm -f hsva$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(hsva_OBJECTS) $(hsva_LDADD) $(LIBS)
-introspect$(EXEEXT): $(introspect_OBJECTS) $(introspect_DEPENDENCIES) $(EXTRA_introspect_DEPENDENCIES)
- @rm -f introspect$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(introspect_OBJECTS) $(introspect_LDADD) $(LIBS)
-
models$(EXEEXT): $(models_OBJECTS) $(models_DEPENDENCIES) $(EXTRA_models_DEPENDENCIES)
@rm -f models$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(models_OBJECTS) $(models_LDADD) $(LIBS)
@@ -894,20 +853,16 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-html-dump.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl_class_name.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl_fish_path_fitness.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cairo-RGB24.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chromaticities.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/concurrency-stress-test.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conversions.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/extract.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/float-to-8bit.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/floatclamp.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/formats.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grayscale_to_rgb.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hsl.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hsva.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/introspect.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/models.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/n_components.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/n_components_cast.Po@am__quote@
@@ -1148,6 +1103,13 @@ grayscale_to_rgb.log: grayscale_to_rgb$(EXEEXT)
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
+chromaticities.log: chromaticities$(EXEEXT)
+ @p='chromaticities$(EXEEXT)'; \
+ b='chromaticities'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
rgb_to_bgr.log: rgb_to_bgr$(EXEEXT)
@p='rgb_to_bgr$(EXEEXT)'; \
b='rgb_to_bgr'; \
diff --git a/tests/chromaticities.c b/tests/chromaticities.c
new file mode 100644
index 0000000..2c8364a
--- /dev/null
+++ b/tests/chromaticities.c
@@ -0,0 +1,77 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, 2017 Øyvind Kolås.
+ *
+ * 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
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+#include <math.h>
+#include "babl-internal.h"
+
+#define PIXELS 6
+#define TOLERANCE 0
+
+unsigned char source_buf [PIXELS * 3] =
+{ 0, 0, 0,
+ 127, 127, 127,
+ 255, 255, 255,
+ 255, 0.0, 0.0,
+ 0.0, 255, 0.0,
+ 0.0, 0.0, 255 };
+
+unsigned char reference_buf [PIXELS * 3] =
+{ 0, 0, 0,
+ 145, 145, 145,
+ 255, 255, 255,
+ 255, 43, 6,
+ 0.0, 250, 48,
+ 25, 34, 251};
+
+unsigned char destination_buf [PIXELS * 3];
+
+static int
+test (void)
+{
+ int i;
+ int OK = 1;
+
+ babl_process (babl_fish (babl_format_with_space ("R'G'B' u8", babl_space("Apple")), "R'G'B' u8"),
+ source_buf, destination_buf,
+ PIXELS);
+
+ for (i = 0; i < PIXELS * 3; i++)
+ {
+ if (abs (destination_buf[i] - reference_buf[i]) > TOLERANCE)
+ {
+ babl_log ("%2i (%2i%%3=%i, %2i/3=%i) is %i should be %i",
+ i, i, i % 3, i, i / 3, destination_buf[i], reference_buf[i]);
+ OK = 0;
+ }
+ }
+ if (!OK)
+ return -1;
+ return 0;
+}
+
+int
+main (int argc,
+ char **argv)
+{
+ babl_init ();
+ if (test ())
+ return -1;
+ babl_exit ();
+ return 0;
+}
diff --git a/tests/grayscale_to_rgb.c b/tests/grayscale_to_rgb.c
index 7da0c86..b59da38 100644
--- a/tests/grayscale_to_rgb.c
+++ b/tests/grayscale_to_rgb.c
@@ -59,9 +59,9 @@ test (void)
for (i = 0; i < PIXELS * 3; i++)
{
- if (rgb_buf[i] != rgb_buf_ref[i])
+ if (fabs (rgb_buf[i] - rgb_buf_ref[i]) > 0.0000001)
{
- babl_log ("index %i is problematic : %f instead of %f",
+ babl_log ("index %i is problematic : %.12f instead of %.12f",
i, rgb_buf[i], rgb_buf_ref[i]);
OK = 0;
}
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 1d50751..dcd549f 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -1,9 +1,20 @@
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/babl
+AM_LDFLAGS = -no-install
LDADD = $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
$(MATH_LIB) $(THREAD_LIB)
-noinst_PROGRAMS = babl-verify
+noinst_PROGRAMS = \
+ babl-verify \
+ babl-benchmark \
+ babl-icc-dump \
+ babl-icc-rewrite \
+ trc-validator \
+ introspect \
+ babl_fish_path_fitness \
+ babl-html-dump \
+ conversions \
+ formats
if HAVE_SRANDOM
noinst_PROGRAMS += \
babl-gen-test-pixels
diff --git a/tools/Makefile.in b/tools/Makefile.in
index 222159f..2a189c4 100644
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -89,7 +89,11 @@ POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
-noinst_PROGRAMS = babl-verify$(EXEEXT) $(am__EXEEXT_1)
+noinst_PROGRAMS = babl-verify$(EXEEXT) babl-benchmark$(EXEEXT) \
+ babl-icc-dump$(EXEEXT) babl-icc-rewrite$(EXEEXT) \
+ trc-validator$(EXEEXT) introspect$(EXEEXT) \
+ babl_fish_path_fitness$(EXEEXT) babl-html-dump$(EXEEXT) \
+ conversions$(EXEEXT) formats$(EXEEXT) $(am__EXEEXT_1)
@HAVE_SRANDOM_TRUE@am__append_1 = \
@HAVE_SRANDOM_TRUE@ babl-gen-test-pixels
@@ -108,23 +112,77 @@ CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
@HAVE_SRANDOM_TRUE@am__EXEEXT_1 = babl-gen-test-pixels$(EXEEXT)
PROGRAMS = $(noinst_PROGRAMS)
-babl_gen_test_pixels_SOURCES = babl-gen-test-pixels.c
-babl_gen_test_pixels_OBJECTS = babl-gen-test-pixels.$(OBJEXT)
-babl_gen_test_pixels_LDADD = $(LDADD)
+babl_benchmark_SOURCES = babl-benchmark.c
+babl_benchmark_OBJECTS = babl-benchmark.$(OBJEXT)
+babl_benchmark_LDADD = $(LDADD)
am__DEPENDENCIES_1 =
-babl_gen_test_pixels_DEPENDENCIES = \
+babl_benchmark_DEPENDENCIES = \
$(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
+babl_gen_test_pixels_SOURCES = babl-gen-test-pixels.c
+babl_gen_test_pixels_OBJECTS = babl-gen-test-pixels.$(OBJEXT)
+babl_gen_test_pixels_LDADD = $(LDADD)
+babl_gen_test_pixels_DEPENDENCIES = \
+ $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+babl_html_dump_SOURCES = babl-html-dump.c
+babl_html_dump_OBJECTS = babl-html-dump.$(OBJEXT)
+babl_html_dump_LDADD = $(LDADD)
+babl_html_dump_DEPENDENCIES = \
+ $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+babl_icc_dump_SOURCES = babl-icc-dump.c
+babl_icc_dump_OBJECTS = babl-icc-dump.$(OBJEXT)
+babl_icc_dump_LDADD = $(LDADD)
+babl_icc_dump_DEPENDENCIES = \
+ $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+babl_icc_rewrite_SOURCES = babl-icc-rewrite.c
+babl_icc_rewrite_OBJECTS = babl-icc-rewrite.$(OBJEXT)
+babl_icc_rewrite_LDADD = $(LDADD)
+babl_icc_rewrite_DEPENDENCIES = \
+ $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
babl_verify_SOURCES = babl-verify.c
babl_verify_OBJECTS = babl-verify.$(OBJEXT)
babl_verify_LDADD = $(LDADD)
babl_verify_DEPENDENCIES = \
$(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+babl_fish_path_fitness_SOURCES = babl_fish_path_fitness.c
+babl_fish_path_fitness_OBJECTS = babl_fish_path_fitness.$(OBJEXT)
+babl_fish_path_fitness_LDADD = $(LDADD)
+babl_fish_path_fitness_DEPENDENCIES = \
+ $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+conversions_SOURCES = conversions.c
+conversions_OBJECTS = conversions.$(OBJEXT)
+conversions_LDADD = $(LDADD)
+conversions_DEPENDENCIES = \
+ $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+formats_SOURCES = formats.c
+formats_OBJECTS = formats.$(OBJEXT)
+formats_LDADD = $(LDADD)
+formats_DEPENDENCIES = \
+ $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+introspect_SOURCES = introspect.c
+introspect_OBJECTS = introspect.$(OBJEXT)
+introspect_LDADD = $(LDADD)
+introspect_DEPENDENCIES = \
+ $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+trc_validator_SOURCES = trc-validator.c
+trc_validator_OBJECTS = trc-validator.$(OBJEXT)
+trc_validator_LDADD = $(LDADD)
+trc_validator_DEPENDENCIES = \
+ $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
@@ -159,8 +217,14 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
-SOURCES = babl-gen-test-pixels.c babl-verify.c
-DIST_SOURCES = babl-gen-test-pixels.c babl-verify.c
+SOURCES = babl-benchmark.c babl-gen-test-pixels.c babl-html-dump.c \
+ babl-icc-dump.c babl-icc-rewrite.c babl-verify.c \
+ babl_fish_path_fitness.c conversions.c formats.c introspect.c \
+ trc-validator.c
+DIST_SOURCES = babl-benchmark.c babl-gen-test-pixels.c \
+ babl-html-dump.c babl-icc-dump.c babl-icc-rewrite.c \
+ babl-verify.c babl_fish_path_fitness.c conversions.c formats.c \
+ introspect.c trc-validator.c
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
@@ -241,6 +305,7 @@ LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
+LOG_LIB = @LOG_LIB@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAINT = @MAINT@
@@ -337,6 +402,7 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/babl
+AM_LDFLAGS = -no-install
LDADD = $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
$(MATH_LIB) $(THREAD_LIB)
@@ -383,22 +449,67 @@ clean-noinstPROGRAMS:
echo " rm -f" $$list; \
rm -f $$list
+babl-benchmark$(EXEEXT): $(babl_benchmark_OBJECTS) $(babl_benchmark_DEPENDENCIES) $(EXTRA_babl_benchmark_DEPENDENCIES)
+ @rm -f babl-benchmark$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(babl_benchmark_OBJECTS) $(babl_benchmark_LDADD) $(LIBS)
+
babl-gen-test-pixels$(EXEEXT): $(babl_gen_test_pixels_OBJECTS) $(babl_gen_test_pixels_DEPENDENCIES) $(EXTRA_babl_gen_test_pixels_DEPENDENCIES)
@rm -f babl-gen-test-pixels$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(babl_gen_test_pixels_OBJECTS) $(babl_gen_test_pixels_LDADD) $(LIBS)
+babl-html-dump$(EXEEXT): $(babl_html_dump_OBJECTS) $(babl_html_dump_DEPENDENCIES) $(EXTRA_babl_html_dump_DEPENDENCIES)
+ @rm -f babl-html-dump$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(babl_html_dump_OBJECTS) $(babl_html_dump_LDADD) $(LIBS)
+
+babl-icc-dump$(EXEEXT): $(babl_icc_dump_OBJECTS) $(babl_icc_dump_DEPENDENCIES) $(EXTRA_babl_icc_dump_DEPENDENCIES)
+ @rm -f babl-icc-dump$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(babl_icc_dump_OBJECTS) $(babl_icc_dump_LDADD) $(LIBS)
+
+babl-icc-rewrite$(EXEEXT): $(babl_icc_rewrite_OBJECTS) $(babl_icc_rewrite_DEPENDENCIES) $(EXTRA_babl_icc_rewrite_DEPENDENCIES)
+ @rm -f babl-icc-rewrite$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(babl_icc_rewrite_OBJECTS) $(babl_icc_rewrite_LDADD) $(LIBS)
+
babl-verify$(EXEEXT): $(babl_verify_OBJECTS) $(babl_verify_DEPENDENCIES) $(EXTRA_babl_verify_DEPENDENCIES)
@rm -f babl-verify$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(babl_verify_OBJECTS) $(babl_verify_LDADD) $(LIBS)
+babl_fish_path_fitness$(EXEEXT): $(babl_fish_path_fitness_OBJECTS) $(babl_fish_path_fitness_DEPENDENCIES) $(EXTRA_babl_fish_path_fitness_DEPENDENCIES)
+ @rm -f babl_fish_path_fitness$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(babl_fish_path_fitness_OBJECTS) $(babl_fish_path_fitness_LDADD) $(LIBS)
+
+conversions$(EXEEXT): $(conversions_OBJECTS) $(conversions_DEPENDENCIES) $(EXTRA_conversions_DEPENDENCIES)
+ @rm -f conversions$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(conversions_OBJECTS) $(conversions_LDADD) $(LIBS)
+
+formats$(EXEEXT): $(formats_OBJECTS) $(formats_DEPENDENCIES) $(EXTRA_formats_DEPENDENCIES)
+ @rm -f formats$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(formats_OBJECTS) $(formats_LDADD) $(LIBS)
+
+introspect$(EXEEXT): $(introspect_OBJECTS) $(introspect_DEPENDENCIES) $(EXTRA_introspect_DEPENDENCIES)
+ @rm -f introspect$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(introspect_OBJECTS) $(introspect_LDADD) $(LIBS)
+
+trc-validator$(EXEEXT): $(trc_validator_OBJECTS) $(trc_validator_DEPENDENCIES) $(EXTRA_trc_validator_DEPENDENCIES)
+ @rm -f trc-validator$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(trc_validator_OBJECTS) $(trc_validator_LDADD) $(LIBS)
+
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-benchmark.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-gen-test-pixels.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-html-dump.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-icc-dump.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-icc-rewrite.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl-verify.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/babl_fish_path_fitness.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conversions.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/formats.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/introspect.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/trc-validator.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
diff --git a/tools/babl-benchmark.c b/tools/babl-benchmark.c
new file mode 100644
index 0000000..1f1f90c
--- /dev/null
+++ b/tools/babl-benchmark.c
@@ -0,0 +1,186 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, 2017 Øyvind Kolås.
+ *
+ * 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
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+#include <math.h>
+#include "babl-internal.h"
+
+#ifndef HAVE_SRANDOM
+#define srandom srand
+#define random rand
+#endif
+
+int ITERATIONS = 2;
+#define N_PIXELS (512*1024) // a too small batch makes the test set live
+ // in l2 cache skewing results
+
+ // we could also add a cache purger..
+
+
+#define N_BYTES N_PIXELS * (4 * 8)
+
+static const char *unicode_hbar (int width, double fraction)
+{
+ static char ret[200]="";
+ const char *block[9]= {" ", "▏", "▎", "▍", "▌", "▋", "▊", "▉","█"};
+ int i;
+ if (width > 100) width = 100;
+
+ ret[0]=0;
+ for (i = 0; i < width; i++)
+ {
+ double start = i * 1.0 / width;
+ if (start < fraction)
+ strcat (ret, block[8]);
+ else
+ {
+ double miss = (start - fraction) * width;
+ if (miss < 1.0)
+ strcat (ret, block[(int)((1.0-miss) * 8.999)]);
+ else
+ strcat (ret, block[0]);
+ }
+ }
+ return ret;
+}
+
+static int
+test (void)
+{
+ int i, j;
+ int OK = 1;
+
+ char *src_data = babl_malloc (N_BYTES);
+ char *dst_data = babl_malloc (N_BYTES);
+ double sum = 0;
+
+
+ const Babl *formats[]={
+#if 0
+ babl_format("R'G'B'A u8"),
+ babl_format("Y float"),
+ babl_format("R'G'B'A u16"),
+ babl_format_with_space("RGBA float", babl_space("ProPhoto")),
+ babl_format_with_space("R'G'B' u16", babl_space("ProPhoto")),
+#endif
+ //babl_format("R'G'B'A u8"),
+ //babl_format("R'G'B'A u16"),
+ babl_format_with_space("R'G'B'A u8", babl_space("ProPhoto")),
+ babl_format_with_space("R'G'B'A half", babl_space("ProPhoto")),
+ babl_format_with_space("R'G'B'A float", babl_space("ProPhoto")),
+ babl_format_with_space("R'G'B'A double", babl_space("ProPhoto")),
+ babl_format_with_space("cairo-RGB24", babl_space("Adobe")),
+ babl_format_with_space("cairo-ARGB32", babl_space("Adobe")),
+
+ };
+ int n_formats = sizeof (formats) / sizeof (formats[0]);
+ const Babl *fishes[50 * 50];
+ double mbps[50 * 50] = {0,};
+ int n;
+ double max = 0.0;
+
+ assert (n_formats < 50);
+
+ for (i = 0; i < N_BYTES; i++)
+ src_data[i] = random();
+
+
+ fprintf (stdout,"%i iterations of %i pixels, mb/s is for sum of source and destinations bytes\n", ITERATIONS, N_PIXELS);
+
+ n = 0;
+ for (i = 0; i < n_formats; i++)
+ for (j = 0; j < n_formats; j++)
+ if (i != j)
+ {
+ const Babl *fish = babl_fish (formats[i], formats[j]);
+ long end, start;
+ int iters = ITERATIONS;
+
+ fprintf (stderr, "%s to %s \r", babl_get_name (formats[i]),
+ babl_get_name (formats[j]));
+ fflush (0);
+
+ /* a quarter round of warmup */
+ babl_process (fish, src_data, dst_data, N_PIXELS * 0.25);
+ start = babl_ticks ();
+ while (iters--)
+ {
+ babl_process (fish, src_data, dst_data, N_PIXELS);
+ }
+ end = babl_ticks ();
+ fishes[n] = fish;
+ mbps [n] = (babl_format_get_bytes_per_pixel (formats[i]) +
+ babl_format_get_bytes_per_pixel (formats[j])) *
+ (N_PIXELS * ITERATIONS / 1024.0 / 1024.0) / ((end-start)/(1000.0*1000.0));
+
+ sum += mbps[n];
+ if (mbps[n] > max)
+ max = mbps[n];
+ n++;
+ }
+
+ n = 0;
+ for (i = 0; i < n_formats; i++)
+ for (j = 0; j < n_formats; j++)
+ if (i != j)
+ {
+ fprintf (stdout, "%s %03.1f mb/s\t%s to %s %.9f",
+ unicode_hbar(16, mbps[n] / max),
+ mbps[n],
+ babl_get_name (formats[i]),
+ babl_get_name (formats[j]),
+ fishes[n]->fish.error);
+ if (fishes[n]->class_type == BABL_FISH_REFERENCE)
+ {
+ fprintf (stdout, "[R]");
+ }
+ else if (fishes[n]->class_type == BABL_FISH_PATH)
+ {
+ int k;
+ //fprintf (stdout, "[%d]", fishes[n]->fish_path.conversion_list->count);
+ for (k = 0; k < fishes[n]->fish_path.conversion_list->count; k++)
+ {
+ fprintf (stdout, "\n\t\t\t\t%s", babl_get_name (
+ fishes[n]->fish_path.conversion_list->items[k]));
+ }
+ }
+ fprintf (stdout, "\n");
+ n++;
+ }
+ fprintf (stdout, "\n%s %03.1f mb/s\taverage\n",
+ unicode_hbar(16, sum / (n_formats * n_formats - n_formats) / max),
+ sum / (n_formats * n_formats - n_formats));
+
+ fflush (0);
+
+ if (!OK)
+ return -1;
+ return 0;
+}
+
+int
+main (int argc,
+ char **argv)
+{
+ if (argv[1]) ITERATIONS = atoi (argv[1]);
+ babl_init ();
+ if (test ())
+ return -1;
+ babl_exit ();
+ return 0;
+}
diff --git a/tools/babl-gen-test-pixels.c b/tools/babl-gen-test-pixels.c
index 59e3176..12b8040 100644
--- a/tools/babl-gen-test-pixels.c
+++ b/tools/babl-gen-test-pixels.c
@@ -20,6 +20,11 @@
#include <stdlib.h>
#include <stdio.h>
+#ifndef HAVE_SRANDOM
+#define srandom srand
+#define random rand
+#endif
+
#define BABL_PATH_NUM_TEST_PIXELS 3072
#define BABL_CONVERSION_NUM_TEST_PIXELS 128
#define BABL_FROMAT_NUM_TEST_PIXELS 256
diff --git a/tests/babl-html-dump.c b/tools/babl-html-dump.c
index 4c01611..4c01611 100644
--- a/tests/babl-html-dump.c
+++ b/tools/babl-html-dump.c
diff --git a/tools/babl-icc-dump.c b/tools/babl-icc-dump.c
new file mode 100644
index 0000000..4b549ef
--- /dev/null
+++ b/tools/babl-icc-dump.c
@@ -0,0 +1,674 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+
+static int
+file_get_contents (const char *path,
+ char **contents,
+ long *length,
+ void *error);
+
+typedef struct {
+ int16_t integer;
+ uint16_t fraction;
+} s15f16_t;
+
+typedef struct {
+ int16_t integer;
+ uint16_t fraction;
+} u8f8_t;
+
+#define ICC_HEADER_LEN 128
+#define TAG_COUNT_OFF ICC_HEADER_LEN
+
+static int load_u8 (const char *icc, int length, int offset)
+{
+/* all reading functions take both the char *pointer and the length of the
+ * buffer, and all reads thus gets protected by this condition.
+ */
+ if (offset < 0 || offset > length)
+ return 0;
+
+ return *(uint8_t*) (&icc[offset]);
+}
+
+static int load_s8 (const char *icc, int length, int offset)
+{
+ if (offset < 0 || offset > length)
+ return 0;
+
+ return *(int8_t*) (&icc[offset]);
+}
+
+static int16_t load_u1f15 (const char *icc, int length, int offset)
+{
+ return load_u8 (icc, length, offset + 1) +
+ (load_s8 (icc, length, offset + 0) << 8);
+}
+
+static uint16_t load_u16 (const char *icc, int length, int offset)
+{
+ return load_u8 (icc, length, offset + 1) +
+ (load_u8 (icc, length, offset + 0) << 8);
+}
+
+static u8f8_t load_u8f8_ (const char *icc, int length, int offset)
+{
+ u8f8_t ret ={load_u8 (icc, length, offset),
+ load_u8 (icc, length, offset + 1)};
+ return ret;
+}
+
+static s15f16_t load_s15f16_ (const char *icc, int length, int offset)
+{
+ s15f16_t ret ={load_u1f15 (icc, length, offset),
+ load_u16 (icc, length, offset + 2)};
+ return ret;
+}
+
+static double s15f16_to_d (s15f16_t fix)
+{
+ return fix.integer + fix.fraction / 65535.0;
+}
+
+static double u8f8_to_d (u8f8_t fix)
+{
+ return fix.integer + fix.fraction / 255.0;
+}
+
+static double load_s15f16 (const char *icc, int length, int offset)
+{
+ return s15f16_to_d (load_s15f16_ (icc, length, offset));
+}
+
+static double load_u8f8 (const char *icc, int length, int offset)
+{
+ return u8f8_to_d (load_u8f8_ (icc, length, offset));
+}
+
+static void print_u8f8 (u8f8_t fix)
+{
+ int i;
+ uint32_t foo;
+ foo = fix.fraction;
+ fprintf (stdout, "%i.", fix.integer);
+ for (i = 0; i < 18; i++)
+ {
+ foo *= 10;
+ fprintf (stdout, "%i", (foo / 256) % 10);
+ foo = foo & 0xff;
+ }
+}
+
+static void print_s15f16 (s15f16_t fix)
+{
+ int i;
+ uint32_t foo;
+ foo = fix.fraction;
+ if (fix.integer < 0)
+ {
+ if (fix.integer == -1)
+ fprintf (stdout, "-");
+ fprintf (stdout, "%i.", fix.integer + 1);
+ foo = 65535-fix.fraction;
+ for (i = 0; i < 18; i++)
+ {
+ foo *= 10;
+ fprintf (stdout, "%i", (foo / 65536) % 10);
+ foo = foo & 0xffff;
+ }
+ }
+ else
+ {
+ fprintf (stdout, "%i.", fix.integer);
+ for (i = 0; i < 18; i++)
+ {
+ foo *= 10;
+ fprintf (stdout, "%i", (foo / 65536) % 10);
+ foo = foo & 0xffff;
+ }
+ }
+}
+
+static uint32_t load_u32 (const char *icc, int length, int offset)
+{
+ return load_u8 (icc, length, offset + 3) +
+ (load_u8 (icc, length, offset + 2) << 8) +
+ (load_u8 (icc, length, offset + 1) << 16) +
+ (load_u8 (icc, length, offset + 0) << 24);
+}
+
+static void load_sign (const char *icc, int length,
+ int offset, char *sign)
+{
+ sign[0]=load_u8(icc, length, offset);
+ sign[1]=load_u8(icc, length, offset + 1);
+ sign[2]=load_u8(icc, length, offset + 2);
+ sign[3]=load_u8(icc, length, offset + 3);
+ sign[4]=0;
+}
+
+/* looks up offset and length for a specific icc tag
+ */
+static int icc_tag (const char *icc, int length,
+ const char *tag, int *offset, int *el_length)
+{
+ int tag_count = load_u32 (icc, length, TAG_COUNT_OFF);
+ int t;
+
+ for (t = 0; t < tag_count; t++)
+ {
+ char tag_signature[5];
+ load_sign (icc, length, TAG_COUNT_OFF + 4 + 12 * t, tag_signature);
+ if (!strcmp (tag_signature, tag))
+ {
+ if (offset)
+ *offset = load_u32 (icc, length, TAG_COUNT_OFF + 4 + 12* t + 4);
+ if (el_length)
+ *el_length = load_u32 (icc, length, TAG_COUNT_OFF + 4 + 12* t + 4*2);
+ return 1;
+ }
+ }
+ return 0;
+}
+
+#if 0
+
+#define ICC_HEADER_LEN 128
+#define TAG_COUNT_OFF ICC_HEADER_LEN
+
+static int load_u8 (const char *icc, int offset)
+{
+ return *(uint8_t*) (&icc[offset]);
+}
+
+static int16_t load_u1Fixed15 (const char *icc, int offset)
+{
+ return load_u8 (icc, offset + 1) +
+ (load_u8 (icc, offset + 0) << 8);
+}
+
+static uint16_t load_u16 (const char *icc, int offset)
+{
+ return load_u8 (icc, offset + 1) +
+ (load_u8 (icc, offset + 0) << 8);
+}
+
+static double load_s15f16 (const char *icc, int offset)
+{
+ return load_u1Fixed15 (icc, offset) + load_u16 (icc, offset + 2) / 65535.0f;
+}
+
+static double load_u16f16 (const char *icc, int offset)
+{
+ return load_u16 (icc, offset) + load_u16 (icc, offset + 2) / 65535.0;
+}
+
+static uint32_t load_u32 (const char *icc, int offset)
+{
+ return load_u8 (icc, offset + 3) +
+ (load_u8 (icc, offset + 2) << 8) +
+ (load_u8 (icc, offset + 1) << 16) +
+ (load_u8 (icc, offset + 0) << 24);
+}
+
+static float load_float32 (const char *icc, int offset)
+{
+ char buf[4]={load_u8 (icc, offset + 3),
+ load_u8 (icc, offset + 2),
+ load_u8 (icc, offset + 1),
+ load_u8 (icc, offset + 0)};
+ float *val = (float*)(&buf[0]);
+ return *val;
+}
+
+static uint64_t load_uint64 (const char *icc, int offset)
+{
+ return ((uint64_t)load_u8 (icc, offset + 7) << (8*0)) +
+ ((uint64_t)load_u8 (icc, offset + 6) << (8*1)) +
+ ((uint64_t)load_u8 (icc, offset + 5) << (8*2)) +
+ ((uint64_t)load_u8 (icc, offset + 4) << (8*3)) +
+ ((uint64_t)load_u8 (icc, offset + 3) << (8*4)) +
+ ((uint64_t)load_u8 (icc, offset + 2) << (8*5)) +
+ ((uint64_t)load_u8 (icc, offset + 1) << (8*6)) +
+ ((uint64_t)load_u8 (icc, offset + 0) << (8*7));
+}
+
+static void load_sign (const char *icc, int offset, char *sign)
+{
+ sign[0]=load_u8(icc, offset);
+ sign[1]=load_u8(icc, offset + 1);
+ sign[2]=load_u8(icc, offset + 2);
+ sign[3]=load_u8(icc, offset + 3);
+ sign[4]=0;
+}
+
+static int icc_tag (const char *icc, const char *tag, int *offset, int *length)
+{
+ int tag_count = load_u32 (icc, TAG_COUNT_OFF);
+ int profile_size = load_u32 (icc, 0);
+ int t;
+
+ for (t = 0; t < tag_count; t++)
+ {
+ char tag_signature[5];
+ load_sign (icc, TAG_COUNT_OFF + 4 + 12 * t, tag_signature);
+ if (!strcmp (tag_signature, tag))
+ {
+ *offset = load_u32 (icc, TAG_COUNT_OFF + 4 + 12* t + 4);
+ *length = load_u32 (icc, TAG_COUNT_OFF + 4 + 12* t + 4 * 2);
+ /* avert potential for maliciousnes.. */
+ if (*offset >= profile_size)
+ {
+ *offset = profile_size - 1;
+ }
+ if (*offset + *length >= profile_size)
+ {
+ *length = profile_size - *offset - 1;
+ }
+ return 1;
+ }
+ }
+ return 0;
+}
+#endif
+
+int exact = 0;
+
+static int load_icc_from_memory (const char *icc, long length, char **error)
+{
+ int tag_count = load_u32 (icc, length, TAG_COUNT_OFF);
+ int profile_size = load_u32 (icc, length, 0);
+ int profile_version_major = load_u8 (icc, length, 8);
+ int profile_version_minor = load_u8 (icc, length, 9) >> 4;
+ int profile_version_micro = load_u8 (icc, length, 9) & 0xf;
+ char profile_class[5];
+ char color_space[5];
+ char pcs_space[5];
+ int rendering_intent = load_u32 (icc, length, 64);
+ int t;
+ // 64..67 rendering intent
+ // 68..79 XYZ of D50
+
+ load_sign (icc, length, 16, color_space);
+ load_sign (icc, length, 20, pcs_space);
+ load_sign (icc, length, 12, profile_class);
+
+ if (strcmp (profile_class, "mntr"))
+ {
+ *error = "not a monitor-class profile";
+ return -1;
+ }
+ if (strcmp (color_space, "RGB "))
+ {
+ *error = "not defining an RGB space";
+ return -1;
+ }
+#if 0
+ if (profile_version_major > 2)
+ {
+ *error = "only ICC v2 profiles supported";
+ return -1;
+ }
+#endif
+ {
+ int offset, element_size;
+ icc_tag (icc, length, "desc", &offset, &element_size);
+ if (!strcmp (icc + offset, "mluc"))
+ {
+ fprintf (stdout, "desc: [babl-icc doesnt decode unicode]\n");
+ }
+ else
+ if (!strcmp (icc + offset, "desc"))
+ fprintf (stdout, "desc: %s\n", icc + offset + 12);
+ }
+ {
+ int offset, element_size;
+ icc_tag (icc, length, "cprt", &offset, &element_size);
+ fprintf (stdout, "copyright: %s\n", icc + offset + 8);
+ }
+
+#if 1
+ fprintf (stdout, "icc version: %i.%i.%i\n", profile_version_major, profile_version_minor, profile_version_micro);
+ fprintf (stdout, "profile-size: %i\n", profile_size);
+ fprintf (stdout, "profile-class: %s\n", profile_class);
+ fprintf (stdout, "color-space: %s\n", color_space);
+ fprintf (stdout, "rendering-intent: %i\n", rendering_intent);
+ fprintf (stdout, "pcs-space: %s\n", pcs_space);
+ fprintf (stdout, "length: %li\n", length);
+#if 0
+ fprintf (stdout, "tag-count: %i\n", tag_count);
+
+ for (t = 0; t < tag_count; t++)
+ {
+ char tag_signature[5];
+ int offset, element_size;
+ load_sign (icc, length, TAG_COUNT_OFF + 4 + 12 * t, tag_signature);
+ icc_tag (icc, length, tag_signature, &offset, &element_size);
+ fprintf (stdout, "tag %i %s %i %i\n", t, tag_signature, offset, element_size);
+ }
+#endif
+#endif
+ fprintf (stdout, "tags: ");
+ for (t = 0; t < tag_count; t++)
+ {
+ char tag_signature[5];
+ int offset, element_size;
+ load_sign (icc, length, TAG_COUNT_OFF + 4 + 12 * t, tag_signature);
+ icc_tag (icc, length, tag_signature, &offset, &element_size);
+ fprintf (stdout, "%s[%i@%i] ", tag_signature, element_size, offset);
+ }
+ fprintf (stdout, "\n");
+ fprintf (stdout, "\n");
+
+
+ {
+ int offset, element_size;
+ if (icc_tag (icc, length, "chrm", &offset, &element_size))
+ {
+ int channels = load_u16 (icc, length, offset + 8);
+ int phosporant = load_u16 (icc, length, offset + 10);
+ double redX = load_s15f16 (icc, length, offset + 12);
+ double redY = load_s15f16 (icc, length, offset + 12 + 4);
+ double greenX = load_s15f16 (icc, length, offset + 20);
+ double greenY = load_s15f16 (icc, length, offset + 20 + 4);
+ double blueX = load_s15f16 (icc, length, offset + 28);
+ double blueY = load_s15f16 (icc, length, offset + 28 + 4);
+ fprintf (stdout, "chromaticity:\n");
+ fprintf (stdout, " channels: %i\n", channels);
+ fprintf (stdout, " phosphorant: %i\n", phosporant);
+ fprintf (stdout, " CIE xy red: %.6f %.6f\n", redX, redY);
+ fprintf (stdout, " CIE xy green: %.6f %.6f\n", greenX, greenY);
+ fprintf (stdout, " CIE xy blue: %.6f %.6f\n", blueX, blueY);
+ if (exact)
+ {
+ fprintf (stdout, " exact: ");
+ print_s15f16 (load_s15f16_ (icc, length, offset + 12));
+ fprintf (stdout, " ");
+ print_s15f16 (load_s15f16_ (icc, length, offset + 12 + 4));
+ fprintf (stdout, "\n");
+
+ fprintf (stdout, " ");
+ print_s15f16 (load_s15f16_ (icc, length, offset + 20));
+ fprintf (stdout, " ");
+ print_s15f16 (load_s15f16_ (icc, length, offset + 20 + 4));
+ fprintf (stdout, "\n");
+
+ fprintf (stdout, " ");
+ print_s15f16 (load_s15f16_ (icc, length, offset + 28));
+ fprintf (stdout, " ");
+ print_s15f16 (load_s15f16_ (icc, length, offset + 28 + 4));
+ fprintf (stdout, "\n");
+ }
+
+ }
+ }
+
+ {
+ int offset, element_size;
+ if (icc_tag (icc, length, "bkpt", &offset, &element_size))
+ {
+ double wX = load_s15f16 (icc, length, offset + 8);
+ double wY = load_s15f16 (icc, length, offset + 8 + 4);
+ double wZ = load_s15f16 (icc, length, offset + 8 + 4 * 2);
+ fprintf (stdout, "blackpoint CIE XYZ: %.6f %.6f %.6f\n", wX, wY, wZ);
+
+ if (exact)
+ {
+ fprintf (stdout, "exact: ");
+ print_s15f16 (load_s15f16_ (icc, length, offset + 8));
+ fprintf (stdout, " ");
+ print_s15f16 (load_s15f16_ (icc, length, offset + 8 + 4));
+ fprintf (stdout, " ");
+ print_s15f16 (load_s15f16_ (icc, length, offset + 8 + 4 * 2));
+ fprintf (stdout, "\n");
+ }
+ }
+
+ }
+
+ {
+ int offset, element_size;
+ if (icc_tag (icc, length, "wtpt", &offset, &element_size))
+ {
+ double wX = load_s15f16 (icc, length, offset + 8);
+ double wY = load_s15f16 (icc, length, offset + 8 + 4);
+ double wZ = load_s15f16 (icc, length, offset + 8 + 4 * 2);
+ fprintf (stdout, "whitepoint CIE XYZ: %.6f %.6f %.6f\n", wX, wY, wZ);
+
+ if (exact)
+ {
+ fprintf (stdout, "exact: ");
+ print_s15f16 (load_s15f16_ (icc, length, offset + 8));
+ fprintf (stdout, " ");
+ print_s15f16 (load_s15f16_ (icc, length, offset + 8 + 4));
+ fprintf (stdout, " ");
+ print_s15f16 (load_s15f16_ (icc, length, offset + 8 + 4 * 2));
+ fprintf (stdout, "\n");
+ }
+
+ }
+ }
+
+
+ {
+ int offset, element_size;
+ if (icc_tag (icc, length, "rXYZ", &offset, &element_size))
+ {
+ double wX = load_s15f16 (icc, length, offset + 8);
+ double wY = load_s15f16 (icc, length, offset + 8 + 4);
+ double wZ = load_s15f16 (icc, length, offset + 8 + 4 * 2);
+ fprintf (stdout, "red CIE XYZ: %.6f %.6f %.6f\n", wX, wY, wZ);
+ }
+ if (icc_tag (icc, length, "gXYZ", &offset, &element_size))
+ {
+ double wX = load_s15f16 (icc, length, offset + 8);
+ double wY = load_s15f16 (icc, length, offset + 8 + 4);
+ double wZ = load_s15f16 (icc, length, offset + 8 + 4 * 2);
+ fprintf (stdout, "green CIE XYZ: %.6f %.6f %.6f\n", wX, wY, wZ);
+ }
+ if (icc_tag (icc, length, "bXYZ", &offset, &element_size))
+ {
+ double wX = load_s15f16 (icc, length, offset + 8);
+ double wY = load_s15f16 (icc, length, offset + 8 + 4);
+ double wZ = load_s15f16 (icc, length, offset + 8 + 4 * 2);
+ fprintf (stdout, "blue CIE XYZ: %.6f %.6f %.6f\n", wX, wY, wZ);
+ }
+ }
+ if(exact){
+ int offset, element_size;
+ if (icc_tag (icc, length, "rXYZ", &offset, &element_size))
+ {
+ fprintf (stdout, "exact: ");
+ print_s15f16 (load_s15f16_ (icc, length, offset + 8));
+ fprintf (stdout, " ");
+ print_s15f16 (load_s15f16_ (icc, length, offset + 8 + 4));
+ fprintf (stdout, " ");
+ print_s15f16 (load_s15f16_ (icc, length, offset + 8 + 4 * 2));
+ fprintf (stdout, "\n");
+ }
+ if (icc_tag (icc, length, "gXYZ", &offset, &element_size))
+ {
+ fprintf (stdout, " ");
+ print_s15f16 (load_s15f16_ (icc, length, offset + 8));
+ fprintf (stdout, " ");
+ print_s15f16 (load_s15f16_ (icc, length, offset + 8 + 4));
+ fprintf (stdout, " ");
+ print_s15f16 (load_s15f16_ (icc, length, offset + 8 + 4 * 2));
+ fprintf (stdout, "\n");
+ }
+ if (icc_tag (icc, length, "bXYZ", &offset, &element_size))
+ {
+ fprintf (stdout, " ");
+ print_s15f16 (load_s15f16_ (icc, length, offset + 8));
+ fprintf (stdout, " ");
+ print_s15f16 (load_s15f16_ (icc, length, offset + 8 + 4));
+ fprintf (stdout, " ");
+ print_s15f16 (load_s15f16_ (icc, length, offset + 8 + 4 * 2));
+ fprintf (stdout, "\n");
+ }
+ }
+
+ if (1) {
+ int offset, element_size;
+ if (icc_tag (icc, length, "rTRC", &offset, &element_size))
+ {
+ int count = load_u32 (icc, length, offset + 8);
+ int i;
+ if (!strcmp (icc + offset, "para"))
+ {
+ int function_type = load_u16 (icc, length, offset + 8);
+ float g,a,b,c,d,e,f;
+ switch (function_type)
+ {
+ case 0:
+ g = load_s15f16 (icc, length, offset + 12 + 2 * 0);
+ fprintf (stdout, "parametric TRC gamma type %.6f\n", g);
+ if (exact)
+ {
+ fprintf (stdout, " exact:");
+ print_s15f16 (load_s15f16_ (icc, length, offset + 12 + 2 * 0));
+ fprintf (stdout, "\n");
+ }
+
+ break;
+
+ case 3:
+ g = load_s15f16 (icc, length, offset + 12 + 2 * 0);
+ a = load_s15f16 (icc, length, offset + 12 + 2 * 1);
+ b = load_s15f16 (icc, length, offset + 12 + 2 * 2);
+ c = load_s15f16 (icc, length, offset + 12 + 2 * 3);
+ d = load_s15f16 (icc, length, offset + 12 + 2 * 4);
+ e = load_s15f16 (icc, length, offset + 12 + 2 * 5);
+ f = load_s15f16 (icc, length, offset + 12 + 2 * 6);
+ fprintf (stdout, "parametric TRC sRGB type %.6f %.6f %.6f %.6f %.6f %.6f %.6f\n", g, a, b, c, d, e, f);
+ if (exact)
+ {
+ int i;
+ fprintf (stdout, " exact:");
+ for (i = 0; i < 7; i++)
+ {
+ print_s15f16 (load_s15f16_ (icc, length, offset + 12 + 2 * i));
+ fprintf (stdout, " ");
+ }
+ fprintf (stdout, "\n");
+ }
+ break;
+ default:
+ fprintf (stdout, "unhandled parametric TRC type %i\n", function_type);
+ break;
+ }
+ }
+ else
+ {
+ fprintf (stdout, "rTRC count: %i %s\n", count, icc + offset);
+ if (count == 0)
+ {
+ fprintf (stdout, "linear TRC\n");
+ }
+ else if (count == 1)
+ {
+ fprintf (stdout, "gamma TRC of: %.6f\n",
+ load_u8f8 (icc,length, offset + 12));
+ if (exact)
+ {
+ fprintf (stdout, " exact: ");
+ print_u8f8 (load_u8f8_ (icc,length, offset + 12));
+ fprintf (stdout, "\n");
+
+ }
+ }
+ else for (i = 0; i < count && i < 10; i ++)
+ {
+ fprintf (stdout, "%i=%i ", i, load_u16 (icc, length, offset + 12 + i * 2));
+ if (i % 7 == 0)
+ fprintf (stdout, "\n");
+ }
+ }
+ }
+ }
+ return 0;
+}
+
+static int load_icc (const char *path, char **error)
+{
+ char *icc = NULL;
+ long length = 0;
+ int ret = 0;
+ file_get_contents (path, &icc, &length, NULL);
+ if (icc)
+ {
+ ret = load_icc_from_memory (icc, length, error);
+ free (icc);
+ }
+ return ret;
+}
+
+static int
+file_get_contents (const char *path,
+ char **contents,
+ long *length,
+ void *error)
+{
+ FILE *file;
+ long size;
+ char *buffer;
+
+ file = fopen (path,"rb");
+
+ if (!file)
+ return -1;
+
+ fseek (file, 0, SEEK_END);
+ *length = size = ftell (file);
+ rewind (file);
+ buffer = malloc(size + 8);
+
+ if (!buffer)
+ {
+ fclose(file);
+ return -1;
+ }
+
+ size -= fread (buffer, 1, size, file);
+ if (size)
+ {
+ fclose (file);
+ free (buffer);
+ return -1;
+ }
+ fclose (file);
+ *contents = buffer;
+ return 0;
+}
+
+int main (int argc, char **argv)
+{
+ int i = 1;
+ if (argc < 2)
+ {
+ fprintf (stdout, "usage: babl-icc-dump [options] <file1.icc [file2.icc ...]>\n");
+ return -1;
+ }
+
+ if (argv[i] && (!strcmp (argv[i], "-e") ||
+ !strcmp (argv[i], "--exact")))
+ {
+ exact = 1;
+ i++;
+ }
+
+ for (; argv[i]; i++)
+ {
+ char *error = NULL;
+ fprintf (stdout, "\nfile: %s\n", argv[i]);
+ load_icc (argv[i], &error);
+ if (error)
+ {
+ fprintf (stdout, "icc-parse-problem: %s\n", error);
+ }
+ }
+
+ return 0;
+}
diff --git a/tools/babl-icc-rewrite.c b/tools/babl-icc-rewrite.c
new file mode 100644
index 0000000..bc83b25
--- /dev/null
+++ b/tools/babl-icc-rewrite.c
@@ -0,0 +1,191 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, 2017 Øyvind Kolås.
+ *
+ * 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
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+#include <math.h>
+#include "../babl/babl-internal.h"
+
+static int
+file_get_contents (const char *path,
+ char **contents,
+ long *length,
+ void *error);
+
+void file_set_contents (const char *path, const char *data, long length);
+
+int
+main (int argc,
+ char **argv)
+{
+ BablICCFlags flags = 0;
+ const Babl *babl;
+ char *icc_data = NULL;
+ long icc_len;
+ int genlen;
+ char *description = NULL;
+ char *copyright = NULL;
+ const char *error;
+ const char *la = NULL;
+ const char *co = NULL;
+
+ const char *input = NULL;
+ const char *output = NULL;
+ int i;
+
+ babl_init ();
+
+
+ for (i = 1; argv[i]; i++)
+ {
+ if (!strcmp (argv[i], "-d") ||
+ !strcmp (argv[i], "--description"))
+ {
+ description = argv[++i];
+ }
+ else if (!strcmp (argv[i], "-c") ||
+ !strcmp (argv[i], "--copyright"))
+ {
+ copyright = argv[++i];
+ }
+ else if (!strcmp (argv[i], "--compact-trc"))
+ {
+ flags |= BABL_ICC_COMPACT_TRC_LUT;
+ }
+ else if (argv[i][0] == '-')
+ {
+ fprintf (stderr, "unknown option %s\n", argv[i]);
+ return -1;
+ }
+ else
+ {
+ if (!input) input = argv[i];
+ else if (!output) output = argv[i];
+ }
+ }
+
+ if (!input || !output)
+ {
+ fprintf (stderr, "usage: %s [options] <input.icc> <output.icc>\n", argv[0]);
+ fprintf (stderr, " where recognized options are: \n");
+ fprintf (stderr, " -d <description>\n");
+ fprintf (stderr, " -c <copyright>\n");
+ fprintf (stderr, " --compact-trc\n");
+ return -1;
+ }
+
+ if (file_get_contents (input, &icc_data, &icc_len, NULL))
+ return -1;
+
+ if (!description)
+ {
+ description = babl_icc_get_key (icc_data, icc_len, "description", la, co);
+ if (description)
+ fprintf (stderr, "description: %s\n", description);
+ }
+
+ if (!copyright)
+ {
+ copyright = babl_icc_get_key (icc_data, icc_len, "copyright", la, co);
+ if (copyright)
+ {
+ fprintf (stderr, "copyright: %s\n", copyright);
+ }
+ }
+ {
+ char *str = babl_icc_get_key (icc_data, icc_len, "device", la, co);
+ if (str)
+ {
+ fprintf (stderr, "device: %s\n", str);
+ free (str);
+ }
+ }
+ {
+ char *str = babl_icc_get_key (icc_data, icc_len, "manufacturer", la, co);
+ if (str)
+ {
+ fprintf (stderr, "manufacturer: %s\n", str);
+ free (str);
+ }
+ }
+ babl = babl_icc_make_space (icc_data, icc_len, 0, &error);
+ free (icc_data);
+ if (error || !babl)
+ {
+ fprintf (stderr, "%s error %s", argv[0], error);
+ return -1;
+ }
+
+ icc_data = (char *)babl_space_to_icc (babl, description,
+ copyright, flags,
+ &genlen);
+ if (icc_data)
+ {
+ file_set_contents (output, icc_data, genlen);
+ }
+ fprintf (stderr, "[%s]\n", output);
+
+ babl_exit ();
+ return 0;
+}
+
+static int
+file_get_contents (const char *path,
+ char **contents,
+ long *length,
+ void *error)
+{
+ FILE *file;
+ long size;
+ char *buffer;
+
+ file = fopen (path,"rb");
+
+ if (!file)
+ return -1;
+
+ fseek (file, 0, SEEK_END);
+ *length = size = ftell (file);
+ rewind (file);
+ buffer = malloc(size + 8);
+
+ if (!buffer)
+ {
+ fclose(file);
+ return -1;
+ }
+
+ size -= fread (buffer, 1, size, file);
+ if (size)
+ {
+ fclose (file);
+ free (buffer);
+ return -1;
+ }
+ fclose (file);
+ *contents = buffer;
+ return 0;
+}
+
+void file_set_contents (const char *path, const char *data, long length)
+{
+ FILE *fp = fopen (path, "wb");
+ if (length == -1)
+ length = strlen (data);
+ fwrite(data, length, 1, fp);
+ fclose (fp);
+}
diff --git a/tests/babl_fish_path_fitness.c b/tools/babl_fish_path_fitness.c
index 93e1287..93e1287 100644
--- a/tests/babl_fish_path_fitness.c
+++ b/tools/babl_fish_path_fitness.c
diff --git a/tests/conversions.c b/tools/conversions.c
index 946bfb9..946bfb9 100644
--- a/tests/conversions.c
+++ b/tools/conversions.c
diff --git a/tests/formats.c b/tools/formats.c
index 8f481bb..8f481bb 100644
--- a/tests/formats.c
+++ b/tools/formats.c
diff --git a/tests/introspect.c b/tools/introspect.c
index b52ed9f..b52ed9f 100644
--- a/tests/introspect.c
+++ b/tools/introspect.c
diff --git a/tools/trc-validator.c b/tools/trc-validator.c
new file mode 100644
index 0000000..fffbe94
--- /dev/null
+++ b/tools/trc-validator.c
@@ -0,0 +1,219 @@
+// utility program for validating lolremez approximation constants, and
+// BablPolynomial based approximations, for TRCs
+// the currently used apprimxations for 1.8 and 2.2 gamma pow functions are
+// validated to be loss-less when coded for 8bit.
+
+#include "config.h"
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <math.h>
+#include "babl-internal.h"
+
+#if 0
+
+#define GAMMA 2.2
+
+static inline float from_linear (float x)
+{
+ if (x >= 0.01f && x < 0.25f)
+ {
+ double u = -1.1853049266795914e+8;
+ u = u * x + 1.6235355750617304e+8;
+ u = u * x + -9.6434183855508922e+7;
+ u = u * x + 3.2595749146174438e+7;
+ u = u * x + -6.9216734175519044e+6;
+ u = u * x + 9.6337373983643336e+5;
+ u = u * x + -8.9295299887376452e+4;
+ u = u * x + 5.5387559329470092e+3;
+ u = u * x + -2.3522564268245811e+2;
+ u = u * x + 8.8234901614165394;
+ return u * x + 5.3919966190648492e-2;
+ } else if (x >= 0.25f && x < 1.0f)
+ {
+ double u = -2.1065242890384543e-1;
+ u = u * x + 1.7554867367832886;
+ u = u * x + -6.6371047248064382;
+ u = u * x + 1.5049549954517457e+1;
+ u = u * x + -2.279671781745644e+1;
+ u = u * x + 2.4331499227325978e+1;
+ u = u * x + -1.8839523095731037e+1;
+ u = u * x + 1.0802279176589768e+1;
+ u = u * x + -4.7776729355620852;
+ u = u * x + 2.1410886948010769;
+ return u * x + 1.817672123838504e-1;
+ }
+ return powf (x, 1.0f/2.2f);
+}
+
+static inline float to_linear (float x)
+{
+ if (x >= 0.01f && x < 1.0f)
+ {
+ double u = -1.7565198334207539;
+ u = u * x + 9.4503605497836926;
+ u = u * x + -2.2016178903082791e+1;
+ u = u * x + 2.9177361786084179e+1;
+ u = u * x + -2.4368251609523336e+1;
+ u = u * x + 1.3522663223248737e+1;
+ u = u * x + -5.253344907664925;
+ u = u * x + 1.7182864905042889;
+ u = u * x + 5.2860458501353106e-1;
+ u = u * x + -3.0000031884069502e-3;
+ return u * x + 1.6952727496833812e-5;
+ }
+ return powf (x, 2.2);
+}
+#endif
+
+#if 0
+
+#define GAMMA 1.8
+
+static inline float from_linear (float x)
+{
+ if (x >= 0.01f && x < 0.25f)
+ {
+ double u = -7.0287082190390287e+7;
+ u = u * x + 9.6393346352028194e+7;
+ u = u * x + -5.734540040993472e+7;
+ u = u * x + 1.9423130902481005e+7;
+ u = u * x + -4.1360185772523716e+6;
+ u = u * x + 5.7798684366021459e+5;
+ u = u * x + -5.3914765738125787e+4;
+ u = u * x + 3.3827381495697474e+3;
+ u = u * x + -1.4758049734050082e+2;
+ u = u * x + 6.34823684277896;
+ return u * x + 2.5853366952641552e-2;
+ } else if (x >= 0.25f && x < 1.1f)
+ {
+ double u = -1.0514013917303294;
+ u = u * x + 7.7742547018698687;
+ u = u * x + -2.5688463052927626e+1;
+ u = u * x + 5.009448068094152e+1;
+ u = u * x + -6.4160579394623318e+1;
+ u = u * x + 5.6890996491836047e+1;
+ u = u * x + -3.5956430472666212e+1;
+ u = u * x + 1.6565821666356617e+1;
+ u = u * x + -5.8508167212560416;
+ u = u * x + 2.2859969154731878;
+ return u * x + 9.6140522367339399e-2;
+ }
+ return powf (x, 1.0f/1.8f);
+}
+
+static inline float to_linear (float x)
+{
+ if (x >= 0.01f && x < 0.7f)
+ {
+ double u = -1.326432065236105e+1;
+ u = u * x + 7.7192973347868776e+1;
+ u = u * x + -1.9639662782311719e+2;
+ u = u * x + 2.8719828602066411e+2;
+ u = u * x + -2.6718118019754855e+2;
+ u = u * x + 1.6562450069335532e+2;
+ u = u * x + -6.9988172743274441e+1;
+ u = u * x + 2.0568254985551865e+1;
+ u = u * x + -4.5302829214271245;
+ u = u * x + 1.7636048338730889;
+ u = u * x + 1.3015451332543148e-2;
+ return u * x + -5.4445726922508747e-5;
+ }
+ else if (x >= 0.7f && x < 1.4f)
+ {
+ double u = 2.4212422421184617e-3;
+ u = u * x + -2.0853930731707795e-2;
+ u = u * x + 8.2416801461966525e-2;
+ u = u * x + -2.1755799369117727e-1;
+ u = u * x + 1.0503926510667593;
+ u = u * x + 1.1196374095271941e-1;
+ return u * x + -8.7825075945914206e-3;
+ }
+ return powf (x, 1.8);
+}
+#endif
+
+#if 1
+
+#define GAMMA 2.2
+#define X0 ( 0.5f / 255.0f)
+#define X1 (254.5f / 255.0f)
+#define DEGREE 6
+#define SCALE 2
+
+static inline float from_linear (float x)
+{
+ if (x >= X0 && x <= X1)
+ {
+ BablPolynomial poly;
+
+ babl_polynomial_approximate_gamma (&poly,
+ 1.0 / GAMMA, X0, X1, DEGREE, SCALE);
+
+ return babl_polynomial_eval (&poly, x);
+ }
+ return powf (x, 1.0f/GAMMA);
+}
+
+static inline float to_linear (float x)
+{
+ if (x >= X0 && x <= X1)
+ {
+ BablPolynomial poly;
+
+ babl_polynomial_approximate_gamma (&poly,
+ GAMMA, X0, X1, DEGREE, SCALE);
+
+ return babl_polynomial_eval (&poly, x);
+ }
+ return powf (x, GAMMA);
+}
+#endif
+
+static inline float from_linear_ref (float x)
+{
+ return powf (x, 1.0/GAMMA);
+}
+
+static inline float to_linear_ref (float x)
+{
+ return powf (x, GAMMA);
+}
+
+int main (int argc, char **argv)
+{
+ int i;
+ float max_diff = 0.0;
+ int max_diff_u8 = 0;
+ int u8_diff_count = 0;
+
+ for (i = 0; i < 256; i++)
+ {
+ float val = i / 255.0;
+ float from_ref = from_linear_ref (val);
+ float to_ref = to_linear_ref (val);
+ float from = from_linear (val);
+ float to = to_linear (val);
+ int from_ref_u8 = from_ref * 255.5;
+ int to_ref_u8 = to_ref * 255.5;
+ int from_u8 = from * 255.5;
+ int to_u8 = to * 255.5;
+ float from_diff = fabs (from_ref - from);
+ float to_diff = fabs (to_ref - to);
+ int from_diff_u8 = abs (from_u8 -from_ref_u8);
+ int to_diff_u8 = abs (to_u8 -to_ref_u8);
+
+ if (max_diff < from_diff) max_diff = from_diff;
+ if (max_diff < to_diff) max_diff = to_diff;
+
+ if (from_diff_u8 || to_diff_u8)
+ {
+ u8_diff_count ++;
+ if (from_diff_u8 > max_diff_u8) max_diff_u8 = from_diff_u8;
+ if (to_diff_u8 > max_diff_u8) max_diff_u8 = to_diff_u8;
+ }
+ }
+ fprintf (stderr, "diffs: %i max-u8-diff: %i: max-diff: %f(%f)\n", u8_diff_count, max_diff_u8, max_diff, max_diff * 256.0);
+}
+
+