summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2018-08-24 14:51:17 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2018-08-24 14:51:30 +0000
commit1d1205d27e9e313089bf1e14f82048e802b21cac (patch)
tree16eec68994f3086a687ddc765a784ea7707b2f4c
parentReleasing progress-linux version 0.1.50-1~dschinn1. (diff)
downloadbabl-1d1205d27e9e313089bf1e14f82048e802b21cac.zip
babl-1d1205d27e9e313089bf1e14f82048e802b21cac.tar.xz
Merging upstream version 0.1.54.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
-rw-r--r--INSTALL10
-rw-r--r--NEWS11
-rw-r--r--README704
-rw-r--r--babl/babl-cache.c2
-rw-r--r--babl/babl-class.h2
-rw-r--r--babl/babl-classes.h2
-rw-r--r--babl/babl-component.c2
-rw-r--r--babl/babl-component.h2
-rw-r--r--babl/babl-conversion.c2
-rw-r--r--babl/babl-conversion.h2
-rw-r--r--babl/babl-core.c2
-rw-r--r--babl/babl-cpuaccel.c2
-rw-r--r--babl/babl-cpuaccel.h2
-rw-r--r--babl/babl-db.c2
-rw-r--r--babl/babl-db.h2
-rw-r--r--babl/babl-extension.c2
-rw-r--r--babl/babl-extension.h2
-rw-r--r--babl/babl-fish-path.c22
-rw-r--r--babl/babl-fish-reference.c18
-rw-r--r--babl/babl-fish-simple.c2
-rw-r--r--babl/babl-fish.c3
-rw-r--r--babl/babl-fish.h2
-rw-r--r--babl/babl-format.c51
-rw-r--r--babl/babl-format.h3
-rw-r--r--babl/babl-hash-table.c2
-rw-r--r--babl/babl-hash-table.h2
-rw-r--r--babl/babl-icc.c65
-rw-r--r--babl/babl-ids.h47
-rw-r--r--babl/babl-image.c2
-rw-r--r--babl/babl-image.h2
-rw-r--r--babl/babl-internal.c2
-rw-r--r--babl/babl-internal.h94
-rw-r--r--babl/babl-introspect.c2
-rw-r--r--babl/babl-introspect.h2
-rw-r--r--babl/babl-list.c2
-rw-r--r--babl/babl-list.h2
-rw-r--r--babl/babl-macros.h2
-rw-r--r--babl/babl-memory.c4
-rw-r--r--babl/babl-memory.h2
-rw-r--r--babl/babl-model.c16
-rw-r--r--babl/babl-model.h2
-rw-r--r--babl/babl-mutex.c2
-rw-r--r--babl/babl-mutex.h2
-rw-r--r--babl/babl-palette.c106
-rw-r--r--babl/babl-polynomial.c2
-rw-r--r--babl/babl-polynomial.h2
-rw-r--r--babl/babl-ref-pixels.c2
-rw-r--r--babl/babl-ref-pixels.h2
-rw-r--r--babl/babl-ref-pixels.inc2
-rw-r--r--babl/babl-sampling.c2
-rw-r--r--babl/babl-sampling.h2
-rw-r--r--babl/babl-sanity.c2
-rw-r--r--babl/babl-space.c261
-rw-r--r--babl/babl-space.h7
-rw-r--r--babl/babl-trc.c2
-rw-r--r--babl/babl-trc.h2
-rw-r--r--babl/babl-type.c2
-rw-r--r--babl/babl-type.h2
-rw-r--r--babl/babl-types.h2
-rw-r--r--babl/babl-util.c2
-rw-r--r--babl/babl-util.h2
-rw-r--r--babl/babl-version.c2
-rw-r--r--babl/babl-version.h4
-rw-r--r--babl/babl-version.h.in2
-rw-r--r--babl/babl.c10
-rw-r--r--babl/babl.h167
-rw-r--r--babl/base/babl-base.c2
-rw-r--r--babl/base/babl-base.h2
-rw-r--r--babl/base/formats.c355
-rw-r--r--babl/base/model-gray.c282
-rw-r--r--babl/base/model-rgb.c527
-rw-r--r--babl/base/model-ycbcr.c14
-rw-r--r--babl/base/pow-24.c2
-rw-r--r--babl/base/pow-24.h2
-rw-r--r--babl/base/type-float.c2
-rw-r--r--babl/base/type-u15.c2
-rw-r--r--babl/base/type-u16.c2
-rw-r--r--babl/base/type-u32.c2
-rw-r--r--babl/base/type-u8.c2
-rw-r--r--babl/base/util.h2
-rwxr-xr-xconfigure67
-rw-r--r--configure.ac6
-rw-r--r--docs/COPYING4
-rw-r--r--export-symbols19
-rw-r--r--extensions/CIE.c94
-rw-r--r--extensions/HCY.c2
-rw-r--r--extensions/HSL.c2
-rw-r--r--extensions/HSV.c2
-rw-r--r--extensions/cairo.c2
-rw-r--r--extensions/double.c2
-rw-r--r--extensions/fast-float.c2
-rw-r--r--extensions/float.c221
-rw-r--r--extensions/gegl-fixups.c2
-rw-r--r--extensions/gggl-lies.c2
-rw-r--r--extensions/gggl-table-lies.c2
-rw-r--r--extensions/gggl-table.c2
-rw-r--r--extensions/gggl.c2
-rw-r--r--extensions/gimp-8bit.c2
-rw-r--r--extensions/grey.c2
-rw-r--r--extensions/half.c2
-rw-r--r--extensions/naive-CMYK.c2
-rw-r--r--extensions/sse-half.c2
-rw-r--r--extensions/sse2-float.c2
-rw-r--r--extensions/sse2-int16.c2
-rw-r--r--extensions/sse2-int8.c2
-rw-r--r--extensions/sse4-int8.c2
-rw-r--r--extensions/two-table.c4
-rw-r--r--extensions/u16.c16
-rw-r--r--extensions/u32.c68
-rw-r--r--extensions/util.h2
-rw-r--r--extensions/ycbcr.c2
-rw-r--r--tests/Makefile.am3
-rw-r--r--tests/Makefile.in45
-rw-r--r--tests/babl_class_name.c2
-rw-r--r--tests/cairo-RGB24.c2
-rw-r--r--tests/chromaticities.c2
-rw-r--r--tests/concurrency-stress-test.c2
-rw-r--r--tests/extract.c2
-rw-r--r--tests/float-to-8bit.c2
-rw-r--r--tests/floatclamp.c2
-rw-r--r--tests/format_with_space.c109
-rw-r--r--tests/grayscale_to_rgb.c2
-rw-r--r--tests/hsl.c2
-rw-r--r--tests/hsva.c2
-rw-r--r--tests/n_components.c2
-rw-r--r--tests/n_components_cast.c2
-rw-r--r--tests/nop.c2
-rw-r--r--tests/palette-concurrency-stress-test.c2
-rw-r--r--tests/palette.c2
-rw-r--r--tests/rgb_to_bgr.c2
-rw-r--r--tests/rgb_to_ycbcr.c2
-rw-r--r--tests/sanity.c2
-rw-r--r--tests/srgb_to_lab_u8.c2
-rw-r--r--tests/transparent.c2
-rw-r--r--tools/babl-benchmark.c2
-rw-r--r--tools/babl-gen-test-pixels.c4
-rw-r--r--tools/babl-html-dump.c2
-rw-r--r--tools/babl-icc-rewrite.c2
-rw-r--r--tools/introspect.c2
139 files changed, 2580 insertions, 1067 deletions
diff --git a/INSTALL b/INSTALL
index 1ec8aba..b12fa80 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,5 +1,5 @@
-babl 0.1.50
+babl 0.1.54
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.50.tar.bz2
- foo$ tar jxf babl-0.1.50.tar.gz
- foo$ cd babl-0.1.50
- foo/babl-0.1.50$ ./configure && make && sudo make install
+ foo$ wget ftp://ftp.gtk.org/pub/babl/0.1/babl-0.1.54.tar.bz2
+ foo$ tar jxf babl-0.1.54.tar.gz
+ foo$ cd babl-0.1.54
+ foo/babl-0.1.54$ ./configure && make && sudo make install
------------------------------------------------------------
diff --git a/NEWS b/NEWS
index 7348353..a2361bb 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,17 @@ The NEWS file in the babl source tree is the source location for
the news section both in the README and the webpage.
-->
+2018-07-23 babl-0.1.54 </dt><dd>
+Export babl_space_get_icc, babl_space_get, babl_model_with_space,
+babl_space_with_trc, babl_format_get_encoding, babl_model_is, SSE2 versions of
+YA float and Y float to CIE L float.
+ </dd><dt>
+2018-06-02 babl-0.1.52 </dt><dd>
+Concurrency fixes and fixes to handling of 0/1 entry palettes, do not
+pre-equalize XYZ conversion matrices for sRGB, internal clean-ups, pre-define
+ACES2065-1 and ACEScg BablSpaces, add R~G~B~ set of spaces, which for all
+BablSpaces mean use sRGB TRC.
+ </dd><dt>
2018-05-20 babl-0.1.50 </dt><dd>
Improvements to speed and precision of indexed code, improvements to meson
build.
diff --git a/README b/README
index f6e55b9..254bd88 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Babl-0.1.50
+Babl-0.1.54
Contents
@@ -63,6 +63,15 @@ 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.
+2018-07-23 babl-0.1.54
+ Export babl_space_get_icc, babl_space_get, babl_model_with_space,
+ babl_space_with_trc, babl_format_get_encoding, babl_model_is, SSE2
+ versions of YA float and Y float to CIE L float.
+2018-06-02 babl-0.1.52
+ Concurrency fixes and fixes to handling of 0/1 entry palettes, do
+ not pre-equalize XYZ conversion matrices for sRGB, internal
+ clean-ups, pre-define ACES2065-1 and ACEScg BablSpaces, add R~G~B~
+ set of spaces, which for all BablSpaces mean use sRGB TRC.
2018-05-20 babl-0.1.50
Improvements to speed and precision of indexed code, improvements
to meson build.
@@ -395,6 +404,14 @@ components
G'
B'
+R~G~B~
+
+components
+
+ R~
+ G~
+ B~
+
R'G'B'A
components
@@ -404,6 +421,15 @@ components
B'
A
+R~G~B~A
+
+components
+
+ R~
+ G~
+ B~
+ A
+
R'aG'aB'aA
components
@@ -413,6 +439,15 @@ components
B'a
A
+R~aG~aB~aA
+
+components
+
+ R~a
+ G~a
+ B~a
+ A
+
Y
components
@@ -453,6 +488,19 @@ components
Y'a
A
+Y~
+
+components
+
+ Y~
+
+Y~A
+
+components
+
+ Y~
+ A
+
Y'CbCr
components
@@ -657,6 +705,18 @@ components
double G'
double B'
+R~G~B~ double
+
+bytes/pixel
+ 24
+model
+ R~G~B~
+components
+
+ double R~
+ double G~
+ double B~
+
R'G'B'A double
bytes/pixel
@@ -670,6 +730,19 @@ components
double B'
double A
+R~G~B~A double
+
+bytes/pixel
+ 32
+model
+ R~G~B~A
+components
+
+ double R~
+ double G~
+ double B~
+ double A
+
R'aG'aB'aA double
bytes/pixel
@@ -683,6 +756,31 @@ components
double B'a
double A
+R~aG~aB~aA double
+
+bytes/pixel
+ 32
+model
+ R~aG~aB~aA
+components
+
+ double R~a
+ double G~a
+ double B~a
+ double A
+
+R~G~B~ u8
+
+bytes/pixel
+ 3
+model
+ R~G~B~
+components
+
+ u8 R~
+ u8 G~
+ u8 B~
+
R'G'B' u8
bytes/pixel
@@ -708,6 +806,19 @@ components
u8 B'
u8 A
+R~G~B~A u8
+
+bytes/pixel
+ 4
+model
+ R~G~B~A
+components
+
+ u8 R~
+ u8 G~
+ u8 B~
+ u8 A
+
RGBA float
bytes/pixel
@@ -809,6 +920,44 @@ components
half B'a
half A
+R~G~B~ half
+
+bytes/pixel
+ 6
+model
+ R~G~B~
+components
+
+ half R~
+ half G~
+ half B~
+
+R~G~B~A half
+
+bytes/pixel
+ 8
+model
+ R~G~B~A
+components
+
+ half R~
+ half G~
+ half B~
+ half A
+
+R~aG~aB~aA half
+
+bytes/pixel
+ 8
+model
+ R~aG~aB~aA
+components
+
+ half R~a
+ half G~a
+ half B~a
+ half A
+
RGB u15
bytes/pixel
@@ -961,6 +1110,44 @@ components
u32 B'a
u32 A
+R~G~B~ u32
+
+bytes/pixel
+ 12
+model
+ R~G~B~
+components
+
+ u32 R~
+ u32 G~
+ u32 B~
+
+R~G~B~A u32
+
+bytes/pixel
+ 16
+model
+ R~G~B~A
+components
+
+ u32 R~
+ u32 G~
+ u32 B~
+ u32 A
+
+R~aG~aB~aA u32
+
+bytes/pixel
+ 16
+model
+ R~aG~aB~aA
+components
+
+ u32 R~a
+ u32 G~a
+ u32 B~a
+ u32 A
+
Y double
bytes/pixel
@@ -1025,6 +1212,27 @@ components
double Y'a
double A
+Y~ double
+
+bytes/pixel
+ 8
+model
+ Y~
+components
+
+ double Y~
+
+Y~A double
+
+bytes/pixel
+ 16
+model
+ Y~A
+components
+
+ double Y~
+ double A
+
YA half
bytes/pixel
@@ -1254,94 +1462,101 @@ components
u8-chroma Cb
u8-chroma Cr
-R'G'B'A float
+R'aG'aB'aA float
bytes/pixel
16
model
- R'G'B'A
+ R'aG'aB'aA
components
- float R'
- float G'
- float B'
+ float R'a
+ float G'a
+ float B'a
float A
-R'G'B'A u16
+R~aG~aB~aA float
bytes/pixel
- 8
+ 16
model
- R'G'B'A
+ R~aG~aB~aA
components
- u16 R'
- u16 G'
- u16 B'
- u16 A
+ float R~a
+ float G~a
+ float B~a
+ float A
-R'aG'aB'aA float
+R'G'B'A float
bytes/pixel
16
model
- R'aG'aB'aA
+ R'G'B'A
components
- float R'a
- float G'a
- float B'a
+ float R'
+ float G'
+ float B'
float A
-R'aG'aB'aA u16
+R~G~B~A float
bytes/pixel
- 8
+ 16
model
- R'aG'aB'aA
+ R~G~B~A
components
- u16 R'a
- u16 G'a
- u16 B'a
- u16 A
+ float R~
+ float G~
+ float B~
+ float A
-R'aG'aB'aA u8
+R'G'B' float
bytes/pixel
- 4
+ 12
model
- R'aG'aB'aA
+ R'G'B'
components
- u8 R'a
- u8 G'a
- u8 B'a
- u8 A
+ float R'
+ float G'
+ float B'
-R'G'B' float
+R~G~B~ float
bytes/pixel
12
model
- R'G'B'
+ R~G~B~
components
- float R'
- float G'
- float B'
+ float R~
+ float G~
+ float B~
-R'G'B' u16
+Y' float
bytes/pixel
- 6
+ 4
model
- R'G'B'
+ Y'
components
- u16 R'
- u16 G'
- u16 B'
+ float Y'
+
+Y~ float
+
+bytes/pixel
+ 4
+model
+ Y~
+components
+
+ float Y~
Y'A float
@@ -1354,6 +1569,17 @@ components
float Y'
float A
+Y~A float
+
+bytes/pixel
+ 8
+model
+ Y~A
+components
+
+ float Y~
+ float A
+
Y'aA float
bytes/pixel
@@ -1365,68 +1591,96 @@ components
float Y'a
float A
-Y' float
+RaGaBaA float
bytes/pixel
- 4
+ 16
model
- Y'
+ RaGaBaA
components
- float Y'
+ float Ra
+ float Ga
+ float Ba
+ float A
-Y'A u16
+YA float
bytes/pixel
- 4
+ 8
model
- Y'A
+ YA
components
- u16 Y'
- u16 A
+ float Y
+ float A
-Y'aA u16
+YaA float
+
+bytes/pixel
+ 8
+model
+ YaA
+components
+
+ float Ya
+ float A
+
+Y float
bytes/pixel
4
model
- Y'aA
+ Y
components
- u16 Y'a
- u16 A
+ float Y
-Y' u16
+Y~ half
bytes/pixel
2
model
- Y'
+ Y~
components
- u16 Y'
+ half Y~
-Y'A u8
+Y~A half
bytes/pixel
- 2
+ 4
model
- Y'A
+ Y~A
components
- u8 Y'
+ half Y~
+ half A
+
+R'aG'aB'aA u8
+
+bytes/pixel
+ 4
+model
+ R'aG'aB'aA
+components
+
+ u8 R'a
+ u8 G'a
+ u8 B'a
u8 A
-Y'aA u8
+R~aG~aB~aA u8
bytes/pixel
- 2
+ 4
model
- Y'aA
+ R~aG~aB~aA
components
- u8 Y'a
+ u8 R~a
+ u8 G~a
+ u8 B~a
u8 A
Y' u8
@@ -1439,43 +1693,48 @@ components
u8 Y'
-Y'CbCr float
+Y~ u8
bytes/pixel
- 12
+ 1
model
- Y'CbCr
+ Y~
components
- float Y'
- float Cb
- float Cr
+ u8 Y~
-Y'CbCrA float
+Y'A u8
bytes/pixel
- 16
+ 2
model
- Y'CbCrA
+ Y'A
components
- float Y'
- float Cb
- float Cr
- float A
+ u8 Y'
+ u8 A
-RGBA u16
+Y~A u8
bytes/pixel
- 8
+ 2
model
- RGBA
+ Y~A
components
- u16 R
- u16 G
- u16 B
- u16 A
+ u8 Y~
+ u8 A
+
+Y'aA u8
+
+bytes/pixel
+ 2
+model
+ Y'aA
+components
+
+ u8 Y'a
+ u8 A
RGBA u8
@@ -1490,100 +1749,229 @@ components
u8 B
u8 A
-RaGaBaA float
+RGB u8
bytes/pixel
- 16
+ 3
model
- RaGaBaA
+ RGB
components
- float Ra
- float Ga
- float Ba
- float A
+ u8 R
+ u8 G
+ u8 B
-RaGaBaA u16
+RaGaBaA u8
bytes/pixel
- 8
+ 4
model
RaGaBaA
components
- u16 Ra
- u16 Ga
- u16 Ba
- u16 A
+ u8 Ra
+ u8 Ga
+ u8 Ba
+ u8 A
-RaGaBaA u8
+YA u8
bytes/pixel
- 4
+ 2
model
- RaGaBaA
+ YA
components
- u8 Ra
- u8 Ga
- u8 Ba
+ u8 Y
+ u8 A
+
+YaA u8
+
+bytes/pixel
+ 2
+model
+ YaA
+components
+
+ u8 Ya
u8 A
-RGB u16
+Y u8
bytes/pixel
- 6
+ 1
model
- RGB
+ Y
components
- u16 R
- u16 G
- u16 B
+ u8 Y
-RGB u8
+R'aG'aB'aA u16
bytes/pixel
- 3
+ 8
model
- RGB
+ R'aG'aB'aA
components
- u8 R
- u8 G
- u8 B
+ u16 R'a
+ u16 G'a
+ u16 B'a
+ u16 A
-YA float
+R~aG~aB~aA u16
bytes/pixel
8
model
- YA
+ R~aG~aB~aA
components
- float Y
- float A
+ u16 R~a
+ u16 G~a
+ u16 B~a
+ u16 A
-YaA float
+R'G'B'A u16
bytes/pixel
8
model
- YaA
+ R'G'B'A
components
- float Ya
- float A
+ u16 R'
+ u16 G'
+ u16 B'
+ u16 A
-Y float
+R~G~B~A u16
+
+bytes/pixel
+ 8
+model
+ R~G~B~A
+components
+
+ u16 R~
+ u16 G~
+ u16 B~
+ u16 A
+
+R'G'B' u16
+
+bytes/pixel
+ 6
+model
+ R'G'B'
+components
+
+ u16 R'
+ u16 G'
+ u16 B'
+
+R~G~B~ u16
+
+bytes/pixel
+ 6
+model
+ R~G~B~
+components
+
+ u16 R~
+ u16 G~
+ u16 B~
+
+Y' u16
+
+bytes/pixel
+ 2
+model
+ Y'
+components
+
+ u16 Y'
+
+Y~ u16
+
+bytes/pixel
+ 2
+model
+ Y~
+components
+
+ u16 Y~
+
+Y'A u16
bytes/pixel
4
model
- Y
+ Y'A
components
- float Y
+ u16 Y'
+ u16 A
+
+Y~A u16
+
+bytes/pixel
+ 4
+model
+ Y~A
+components
+
+ u16 Y~
+ u16 A
+
+Y'aA u16
+
+bytes/pixel
+ 4
+model
+ Y'aA
+components
+
+ u16 Y'a
+ u16 A
+
+RGBA u16
+
+bytes/pixel
+ 8
+model
+ RGBA
+components
+
+ u16 R
+ u16 G
+ u16 B
+ u16 A
+
+RGB u16
+
+bytes/pixel
+ 6
+model
+ RGB
+components
+
+ u16 R
+ u16 G
+ u16 B
+
+RaGaBaA u16
+
+bytes/pixel
+ 8
+model
+ RaGaBaA
+components
+
+ u16 Ra
+ u16 Ga
+ u16 Ba
+ u16 A
YA u16
@@ -1617,50 +2005,51 @@ components
u16 Y
-YA u8
+Y~ u32
bytes/pixel
- 2
+ 4
model
- YA
+ Y~
components
- u8 Y
- u8 A
+ u32 Y~
-YaA u8
+Y~A u32
bytes/pixel
- 2
+ 8
model
- YaA
+ Y~A
components
- u8 Ya
- u8 A
+ u32 Y~
+ u32 A
-Y u8
+Y'CbCr float
bytes/pixel
- 1
+ 12
model
- Y
+ Y'CbCr
components
- u8 Y
+ float Y'
+ float Cb
+ float Cr
-cairo-RGB24
+Y'CbCrA float
bytes/pixel
- 4
+ 16
model
- R'G'B'
+ Y'CbCrA
components
- u8 B'
- u8 G'
- u8 R'
- u8 PAD
+ float Y'
+ float Cb
+ float Cr
+ float A
CIE Lab double
@@ -1983,6 +2372,19 @@ components
u8 R'a
u8 A
+cairo-RGB24
+
+bytes/pixel
+ 4
+model
+ R'G'B'
+components
+
+ u8 B'
+ u8 G'
+ u8 R'
+ u8 PAD
+
cairo-A8
bytes/pixel
@@ -2287,4 +2689,4 @@ Ell
Félix Piédallu
Initial meson build
-/babl-0.1.50
+/babl-0.1.54
diff --git a/babl/babl-cache.c b/babl/babl-cache.c
index 33d030d..917f028 100644
--- a/babl/babl-cache.c
+++ b/babl/babl-cache.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifdef _WIN32
diff --git a/babl/babl-class.h b/babl/babl-class.h
index 47c783d..a1efa9d 100644
--- a/babl/babl-class.h
+++ b/babl/babl-class.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_CLASS_H
diff --git a/babl/babl-classes.h b/babl/babl-classes.h
index ea8d6b5..c25172a 100644
--- a/babl/babl-classes.h
+++ b/babl/babl-classes.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_CLASSES_H
diff --git a/babl/babl-component.c b/babl/babl-component.c
index c3b617e..ad9dfa1 100644
--- a/babl/babl-component.c
+++ b/babl/babl-component.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/babl/babl-component.h b/babl/babl-component.h
index 2c45cdc..483b840 100644
--- a/babl/babl-component.h
+++ b/babl/babl-component.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_COMPONENT_H
diff --git a/babl/babl-conversion.c b/babl/babl-conversion.c
index 8add99a..136d91f 100644
--- a/babl/babl-conversion.c
+++ b/babl/babl-conversion.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
diff --git a/babl/babl-conversion.h b/babl/babl-conversion.h
index 023625a..c187223 100644
--- a/babl/babl-conversion.h
+++ b/babl/babl-conversion.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_CONVERSION_H
diff --git a/babl/babl-core.c b/babl/babl-core.c
index d591d73..aab809a 100644
--- a/babl/babl-core.c
+++ b/babl/babl-core.c
@@ -12,7 +12,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/babl/babl-cpuaccel.c b/babl/babl-cpuaccel.c
index 59fdcdd..e048c97 100644
--- a/babl/babl-cpuaccel.c
+++ b/babl/babl-cpuaccel.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
/*
diff --git a/babl/babl-cpuaccel.h b/babl/babl-cpuaccel.h
index 8040d73..738bc59 100644
--- a/babl/babl-cpuaccel.h
+++ b/babl/babl-cpuaccel.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_CPU_ACCEL_H
diff --git a/babl/babl-db.c b/babl/babl-db.c
index fed9a05..7b45af0 100644
--- a/babl/babl-db.c
+++ b/babl/babl-db.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
/* Reimplementation of database code using redundant hash tables
diff --git a/babl/babl-db.h b/babl/babl-db.h
index d576e6c..9b170d1 100644
--- a/babl/babl-db.h
+++ b/babl/babl-db.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_DB_H
diff --git a/babl/babl-extension.c b/babl/babl-extension.c
index 8e85be5..3898ef0 100644
--- a/babl/babl-extension.c
+++ b/babl/babl-extension.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#define BABL_DYNAMIC_EXTENSIONS
diff --git a/babl/babl-extension.h b/babl/babl-extension.h
index b0b8b36..82e1d7e 100644
--- a/babl/babl-extension.h
+++ b/babl/babl-extension.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_EXTENSION_H
diff --git a/babl/babl-fish-path.c b/babl/babl-fish-path.c
index c5aca9b..30c4a68 100644
--- a/babl/babl-fish-path.c
+++ b/babl/babl-fish-path.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
@@ -568,8 +568,28 @@ babl_fish_path2 (const Babl *source,
/* 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, tolerance);
+ if (babl->fish_path.conversion_list->count)
+ {
+ fprintf (stderr, "babl is using a rather long chain, room exists for optimization here\n");
+ babl_list_each (babl->fish_path.conversion_list, show_item, NULL);
+ }
+ }
+
+ /* third attempt,. at path length + 2 */
+ if (babl->fish_path.conversion_list->count == 0 &&
+ max_path_length () + 2 <= BABL_HARD_MAX_PATH_LENGTH)
+ {
+ get_conversion_path (&pc, (Babl *) source, 0, max_path_length () + 2, tolerance);
+ if (babl->fish_path.conversion_list->count)
+ {
+ fprintf (stderr, "babl is using very long chain, should be optimized\n");
+ babl_list_each (babl->fish_path.conversion_list, show_item, NULL);
+ }
+ }
+
babl_in_fish_path--;
babl_free (pc.current_path);
}
diff --git a/babl/babl-fish-reference.c b/babl/babl-fish-reference.c
index 54ca110..27040ae 100644
--- a/babl/babl-fish-reference.c
+++ b/babl/babl-fish-reference.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
@@ -163,9 +163,9 @@ convert_to_double (BablFormat *source_fmt,
BablImage *dst_img;
src_img = (BablImage *) babl_image_new (
- babl_component_from_id (BABL_LUMINANCE), NULL, 1, 0, NULL);
+ babl_component_from_id (BABL_GRAY_LINEAR), NULL, 1, 0, NULL);
dst_img = (BablImage *) babl_image_new (
- babl_component_from_id (BABL_LUMINANCE), NULL, 1, 0, NULL);
+ babl_component_from_id (BABL_GRAY_LINEAR), NULL, 1, 0, NULL);
dst_img->type[0] = (BablType *) babl_type_from_id (BABL_DOUBLE);
dst_img->pitch[0] =
@@ -239,9 +239,9 @@ convert_from_double (BablFormat *destination_fmt,
BablImage *dst_img;
src_img = (BablImage *) babl_image_new (
- babl_component_from_id (BABL_LUMINANCE), NULL, 1, 0, NULL);
+ babl_component_from_id (BABL_GRAY_LINEAR), NULL, 1, 0, NULL);
dst_img = (BablImage *) babl_image_new (
- babl_component_from_id (BABL_LUMINANCE), NULL, 1, 0, NULL);
+ babl_component_from_id (BABL_GRAY_LINEAR), NULL, 1, 0, NULL);
src_img->type[0] = (BablType *) babl_type_from_id (BABL_DOUBLE);
src_img->pitch[0] = (src_img->type[0]->bits / 8) * destination_fmt->model->components;
@@ -290,9 +290,9 @@ ncomponent_convert_to_double (BablFormat *source_fmt,
BablImage *dst_img;
src_img = (BablImage *) babl_image_new (
- babl_component_from_id (BABL_LUMINANCE), NULL, 1, 0, NULL);
+ babl_component_from_id (BABL_GRAY_LINEAR), NULL, 1, 0, NULL);
dst_img = (BablImage *) babl_image_new (
- babl_component_from_id (BABL_LUMINANCE), NULL, 1, 0, NULL);
+ babl_component_from_id (BABL_GRAY_LINEAR), NULL, 1, 0, NULL);
dst_img->type[0] = (BablType *) babl_type_from_id (BABL_DOUBLE);
dst_img->pitch[0] = (dst_img->type[0]->bits / 8);
@@ -323,9 +323,9 @@ ncomponent_convert_from_double (BablFormat *destination_fmt,
BablImage *dst_img;
src_img = (BablImage *) babl_image_new (
- babl_component_from_id (BABL_LUMINANCE), NULL, 1, 0, NULL);
+ babl_component_from_id (BABL_GRAY_LINEAR), NULL, 1, 0, NULL);
dst_img = (BablImage *) babl_image_new (
- babl_component_from_id (BABL_LUMINANCE), NULL, 1, 0, NULL);
+ babl_component_from_id (BABL_GRAY_LINEAR), NULL, 1, 0, NULL);
src_img->type[0] = (BablType *) babl_type_from_id (BABL_DOUBLE);
src_img->pitch[0] = (src_img->type[0]->bits / 8);
diff --git a/babl/babl-fish-simple.c b/babl/babl-fish-simple.c
index a6a3730..7c2777a 100644
--- a/babl/babl-fish-simple.c
+++ b/babl/babl-fish-simple.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/babl/babl-fish.c b/babl/babl-fish.c
index 8c73a2b..8d31e1b 100644
--- a/babl/babl-fish.c
+++ b/babl/babl-fish.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
@@ -257,7 +257,6 @@ babl_fish (const void *source,
if (ffish.fish_path)
{
/* we have found suitable fish path in the database */
- _babl_fish_rig_dispatch (ffish.fish_path);
return ffish.fish_path;
}
diff --git a/babl/babl-fish.h b/babl/babl-fish.h
index db4e06f..35382f0 100644
--- a/babl/babl-fish.h
+++ b/babl/babl-fish.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_FISH_H
diff --git a/babl/babl-format.c b/babl/babl-format.c
index bc5ef6b..7b81cae 100644
--- a/babl/babl-format.c
+++ b/babl/babl-format.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
@@ -143,12 +143,13 @@ format_new_from_format_with_space (const Babl *format, const Babl *space)
ret = format_new (new_name,
0,
- format->format.planar, format->format.components,
+ 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);
-
+ ret->format.encoding = babl_get_name(format);
+ babl_db_insert (db, (void*)ret);
return ret;
}
@@ -710,12 +711,32 @@ const Babl * babl_format_get_space (const Babl *format)
BABL_CLASS_IMPLEMENT (format)
+const char *
+babl_format_get_encoding (const Babl *babl)
+{
+ if (!babl) return NULL;
+ if (babl->format.encoding) return babl->format.encoding;
+ return babl_get_name (babl);
+}
+
const Babl *
-babl_format_with_space (const char *name, const Babl *space)
+babl_format_with_space (const char *encoding, const Babl *space)
{
- const Babl *ret = NULL;
+ const Babl *example_format = (void*) encoding;
+ if (!encoding) return NULL;
+
+ if (BABL_IS_BABL (example_format))
+ {
+ encoding = babl_get_name (example_format);
+ if (babl_format_get_space (example_format) != babl_space ("sRGB"))
+ {
+ encoding = babl_format_get_encoding (example_format);
+ }
+ }
+
+ if (!space)
+ space = babl_space ("sRGB");
- if (!space) space = babl_space ("sRGB");
if (space->class_type == BABL_FORMAT)
{
space = space->format.space;
@@ -729,23 +750,9 @@ babl_format_with_space (const char *name, const 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));
+ return babl_format (encoding);
- ret = babl_db_exist_by_name (db, new_name);
-
- babl_free (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;
+ return format_new_from_format_with_space (babl_format (encoding), space);
}
int
diff --git a/babl/babl-format.h b/babl/babl-format.h
index 333b5ba..b3a4643 100644
--- a/babl/babl-format.h
+++ b/babl/babl-format.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_FORMAT_H
@@ -43,6 +43,7 @@ typedef struct
for conversion paths */
int format_n; /* whether the format is a format_n type or not */
int palette;
+ const char *encoding;
} BablFormat;
#endif
diff --git a/babl/babl-hash-table.c b/babl/babl-hash-table.c
index e1c2e56..8316db1 100644
--- a/babl/babl-hash-table.c
+++ b/babl/babl-hash-table.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
/* Implementation of hash table data structure based on coalesced hashing.
diff --git a/babl/babl-hash-table.h b/babl/babl-hash-table.h
index f56d02f..04a4698 100644
--- a/babl/babl-hash-table.h
+++ b/babl/babl-hash-table.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_HASH_TABLE_H
diff --git a/babl/babl-icc.c b/babl/babl-icc.c
index 2e934e4..7f38c99 100644
--- a/babl/babl-icc.c
+++ b/babl/babl-icc.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
@@ -165,12 +165,12 @@ static u8f8_t d_to_u8f8 (double value)
static double s15f16_to_d (s15f16_t fix)
{
- return fix.integer + fix.fraction / 65535.0;
+ return fix.integer + fix.fraction / 65536.0;
}
static double u8f8_to_d (u8f8_t fix)
{
- return fix.integer + fix.fraction / 255.0;
+ return fix.integer + fix.fraction / 256.0;
}
static void write_s15f16 (ICC *state, int offset, double value)
@@ -392,7 +392,10 @@ static const Babl *babl_trc_from_icc (ICC *state, int offset,
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;
+ while (state->no % 4 != 0)
+ state->no++;
+
+ 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);
@@ -484,14 +487,14 @@ switch (trc->type)
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)
+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];
+ char icc[65536];
int length=65535;
ICC *state = icc_state_new (icc, length, 10);
@@ -606,7 +609,25 @@ const char *babl_space_to_icc (const Babl *babl,
*ret_length = length;
babl_free (state);
- return icc;
+ {
+ char *ret = malloc (length);
+ memcpy (ret, icc, length);
+ return ret;
+ }
+}
+
+const char *babl_space_get_icc (const Babl *babl, int *length)
+{
+ if (!babl->space.icc_profile)
+ {
+ /* overriding constness of babl */
+ Babl *babl_noconst = (void*) babl;
+ babl_noconst->space.icc_profile = babl_space_to_icc (babl,
+ "babl profile", NULL, 0,
+ &babl_noconst->space.icc_length);
+ }
+ *length = babl->space.icc_length;
+ return babl->space.icc_profile;
}
@@ -700,7 +721,7 @@ static char *decode_string (ICC *state, const char *tag, const char *lang, const
}
const Babl *
-babl_icc_make_space (const char *icc_data,
+babl_space_from_icc (const char *icc_data,
int icc_length,
BablIccIntent intent,
const char **error)
@@ -844,6 +865,9 @@ babl_icc_make_space (const char *icc_data,
trc_red, trc_green, trc_blue);
babl_free (state);
+ ret->space.icc_length = icc_length;
+ ret->space.icc_profile = malloc (icc_length);
+ memcpy (ret->space.icc_profile, icc_data, icc_length);
return ret;
}
}
@@ -889,7 +913,12 @@ babl_icc_make_space (const char *icc_data,
red_x, red_y,
green_x, green_y,
blue_x, blue_y,
- trc_red, trc_green, trc_blue);
+ trc_red, trc_green, trc_blue, 1);
+
+ ret->space.icc_length = icc_length;
+ ret->space.icc_profile = malloc (icc_length);
+ memcpy (ret->space.icc_profile, icc_data, icc_length);
+
return ret;
}
}
@@ -899,6 +928,16 @@ babl_icc_make_space (const char *icc_data,
return NULL;
}
+/* NOTE: GIMP-2.10.0-4 releases depends on this symbol */
+const Babl *
+babl_icc_make_space (const char *icc_data,
+ int icc_length,
+ BablIccIntent intent,
+ const char **error)
+{
+ return babl_space_from_icc (icc_data, icc_length, intent, error);
+}
+
static void symmetry_test (ICC *state)
{
icc_write (s8, 8,-2);
diff --git a/babl/babl-ids.h b/babl/babl-ids.h
index a42d09b..6937ee4 100644
--- a/babl/babl-ids.h
+++ b/babl/babl-ids.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_IDS_H
@@ -45,12 +45,18 @@ enum {
BABL_RGB,
BABL_RGBA,
BABL_RGBA_PREMULTIPLIED,
- BABL_GRAY_GAMMA_2_2,
- BABL_GRAY_GAMMA_2_2_ALPHA,
- BABL_GRAY_GAMMA_2_2_ALPHA_PREMULTIPLIED,
- BABL_RGB_GAMMA_2_2,
- BABL_RGBA_GAMMA_2_2,
- BABL_RGBA_GAMMA_2_2_PREMULTIPLIED,
+ BABL_MODEL_GRAY_NONLINEAR,
+ BABL_MODEL_GRAY_NONLINEAR_ALPHA,
+ BABL_MODEL_GRAY_NONLINEAR_ALPHA_PREMULTIPLIED,
+ BABL_MODEL_GRAY_PERCEPTUAL,
+ BABL_MODEL_GRAY_PERCEPTUAL_ALPHA,
+ BABL_MODEL_GRAY_PERCEPTUAL_ALPHA_PREMULTIPLIED,
+ BABL_RGB_NONLINEAR,
+ BABL_RGBA_NONLINEAR,
+ BABL_RGBA_NONLINEAR_PREMULTIPLIED,
+ BABL_RGB_PERCEPTUAL,
+ BABL_RGBA_PERCEPTUAL,
+ BABL_RGBA_PERCEPTUAL_PREMULTIPLIED,
BABL_YCBCR,
BABL_YCBCR_ALPHA,
BABL_CIE_LAB,
@@ -58,8 +64,8 @@ enum {
BABL_MODEL_LAST_INTERNAL,
BABL_COMPONENT_BASE = 10000,
- BABL_LUMINANCE,
- BABL_LUMINANCE_MUL_ALPHA,
+ BABL_GRAY_LINEAR,
+ BABL_GRAY_LINEAR_MUL_ALPHA,
BABL_RED,
BABL_GREEN,
BABL_BLUE,
@@ -67,14 +73,21 @@ enum {
BABL_RED_MUL_ALPHA,
BABL_GREEN_MUL_ALPHA,
BABL_BLUE_MUL_ALPHA,
- BABL_LUMA,
- BABL_LUMA_MUL_ALPHA,
- BABL_RED_GAMMA_2_2,
- BABL_GREEN_GAMMA_2_2,
- BABL_BLUE_GAMMA_2_2,
- BABL_RED_GAMMA_2_2_MUL_ALPHA,
- BABL_GREEN_GAMMA_2_2_MUL_ALPHA,
- BABL_BLUE_GAMMA_2_2_MUL_ALPHA,
+ BABL_GRAY_PERCEPTUAL,
+ BABL_GRAY_NONLINEAR,
+ BABL_GRAY_NONLINEAR_MUL_ALPHA,
+ BABL_RED_NONLINEAR,
+ BABL_GREEN_NONLINEAR,
+ BABL_BLUE_NONLINEAR,
+ BABL_RED_NONLINEAR_MUL_ALPHA,
+ BABL_GREEN_NONLINEAR_MUL_ALPHA,
+ BABL_BLUE_NONLINEAR_MUL_ALPHA,
+ BABL_RED_PERCEPTUAL,
+ BABL_GREEN_PERCEPTUAL,
+ BABL_BLUE_PERCEPTUAL,
+ BABL_RED_PERCEPTUAL_MUL_ALPHA,
+ BABL_GREEN_PERCEPTUAL_MUL_ALPHA,
+ BABL_BLUE_PERCEPTUAL_MUL_ALPHA,
BABL_X,
diff --git a/babl/babl-image.c b/babl/babl-image.c
index b2c4c9a..04535a4 100644
--- a/babl/babl-image.c
+++ b/babl/babl-image.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/babl/babl-image.h b/babl/babl-image.h
index 0c93f49..ea7d05a 100644
--- a/babl/babl-image.h
+++ b/babl/babl-image.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_IMAGE_H
diff --git a/babl/babl-internal.c b/babl/babl-internal.c
index e0b4f7a..2f3c42e 100644
--- a/babl/babl-internal.c
+++ b/babl/babl-internal.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/babl/babl-internal.h b/babl/babl-internal.h
index 1a65fd3..a6f1196 100644
--- a/babl/babl-internal.h
+++ b/babl/babl-internal.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_INTERNAL_H
@@ -337,8 +337,6 @@ static inline double babl_parse_double (const char *str)
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,
@@ -386,83 +384,15 @@ const Babl *babl_space_match_trc_matrix (const Babl *trc_red,
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:
@@ -500,4 +430,24 @@ babl_conversion_process (const Babl *babl,
void _babl_fish_rig_dispatch (Babl *babl);
void _babl_fish_prepare_bpp (Babl *babl);
+
+/* 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).
+ *
+ * the result is allocated with malloc and you should free it when done.
+ */
+
+typedef enum {
+ BABL_ICC_DEFAULTS = 0,
+ BABL_ICC_COMPACT_TRC_LUT = 1,
+} BablICCFlags;
+
+char *babl_space_to_icc (const Babl *space,
+ const char *description,
+ const char *copyright,
+ BablICCFlags flags,
+ int *icc_length);
+
#endif
diff --git a/babl/babl-introspect.c b/babl/babl-introspect.c
index 5d0cb9d..6230f92 100644
--- a/babl/babl-introspect.c
+++ b/babl/babl-introspect.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/babl/babl-introspect.h b/babl/babl-introspect.h
index 6e32a2a..27f6626 100644
--- a/babl/babl-introspect.h
+++ b/babl/babl-introspect.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_INTROSPECT_H
diff --git a/babl/babl-list.c b/babl/babl-list.c
index beb7b61..6466a21 100644
--- a/babl/babl-list.c
+++ b/babl/babl-list.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
/* Implementation of list data structure.
diff --git a/babl/babl-list.h b/babl/babl-list.h
index 69af9fc..aad8862 100644
--- a/babl/babl-list.h
+++ b/babl/babl-list.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_LIST_H
diff --git a/babl/babl-macros.h b/babl/babl-macros.h
index 61d372b..010d97f 100644
--- a/babl/babl-macros.h
+++ b/babl/babl-macros.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_MACROS_H
diff --git a/babl/babl-memory.c b/babl/babl-memory.c
index d0229e4..658c495 100644
--- a/babl/babl-memory.c
+++ b/babl/babl-memory.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
@@ -111,8 +111,6 @@ babl_malloc (size_t size)
char *ret;
int offset;
- babl_assert (size);
-
functions_sanity ();
ret = malloc_f (BABL_ALLOC + BABL_ALIGN + size);
if (!ret)
diff --git a/babl/babl-memory.h b/babl/babl-memory.h
index 251f0c3..eb55c8d 100644
--- a/babl/babl-memory.h
+++ b/babl/babl-memory.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_MEMORY_H
diff --git a/babl/babl-model.c b/babl/babl-model.c
index 2156059..f5330fe 100644
--- a/babl/babl-model.c
+++ b/babl/babl-model.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
@@ -374,6 +374,20 @@ babl_remodel_with_space (const Babl *model, const Babl *space)
int i;
assert (BABL_IS_BABL (model));
+ 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 (model->model.space == space)
return (void*)model;
diff --git a/babl/babl-model.h b/babl/babl-model.h
index 0862379..ee0e51f 100644
--- a/babl/babl-model.h
+++ b/babl/babl-model.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_MODEL_H
diff --git a/babl/babl-mutex.c b/babl/babl-mutex.c
index 4fa5f29..3df646e 100644
--- a/babl/babl-mutex.c
+++ b/babl/babl-mutex.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/babl/babl-mutex.h b/babl/babl-mutex.h
index 57154b3..77cb798 100644
--- a/babl/babl-mutex.h
+++ b/babl/babl-mutex.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_MUTEX_H
diff --git a/babl/babl-palette.c b/babl/babl-palette.c
index 0f8ad0a..9b232ce 100644
--- a/babl/babl-palette.c
+++ b/babl/babl-palette.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
@@ -29,6 +29,29 @@
#define HASH_TABLE_SIZE 1111
+
+typedef struct BablPaletteRadius
+{
+ unsigned char idx;
+ unsigned short diff;
+} BablPaletteRadius;
+
+typedef struct BablPalette
+{
+ int count; /* number of palette entries */
+ const Babl *format; /* the pixel format the palette is stored in */
+ unsigned char *data; /* one linear segment of all the pixels
+ * representing the palette, in order
+ */
+ double *data_double;
+ unsigned char *data_u8;
+ BablPaletteRadius *radii;
+ volatile unsigned int hash[HASH_TABLE_SIZE];
+} BablPalette;
+
+
+static unsigned short ceil_sqrt_u8[3 * 255 * 255 + 1];
+
/* A default palette, containing standard ANSI / EGA colors
*
*/
@@ -51,44 +74,20 @@ static unsigned char defpal_data[4*16] =
0 ,255,255,255,
255,255,255,255,
};
-static double defpal_double[4*8*16];
-
-static unsigned short ceil_sqrt_u8[3 * 255 * 255 + 1];
+static double defpal_double[4*16];
+static BablPaletteRadius defpal_radii[15 * 16];
-typedef struct BablPaletteRadius
-{
- unsigned char idx;
- unsigned short diff;
-} BablPaletteRadius;
-
-typedef struct BablPalette
-{
- int count; /* number of palette entries */
- const Babl *format; /* the pixel format the palette is stored in */
- unsigned char *data; /* one linear segment of all the pixels
- * representing the palette, in order
- */
- double *data_double;
- unsigned char *data_u8;
- BablPaletteRadius *radii;
- volatile unsigned int hash[HASH_TABLE_SIZE];
-} BablPalette;
-
static void
init_ceil_sqrt_u8 (void)
{
int i;
- babl_mutex_lock (babl_format_mutex);
-
if (! ceil_sqrt_u8[1])
{
for (i = 0; i <= 3 * 255 * 255; i++)
ceil_sqrt_u8[i] = ceil (sqrt (i));
}
-
- babl_mutex_unlock (babl_format_mutex);
}
static inline int
@@ -115,18 +114,12 @@ babl_palette_init_radii (BablPalette *pal)
{
int i, j;
- init_ceil_sqrt_u8 ();
-
/* calculate the distance between each pair of colors in the palette, and, for
* each color, construct a list of all other colors and their distances from
* it, sorted by distance. we use these lists in babl_palette_lookup() to
* speed up the search, as described in the function.
*/
- pal->radii = babl_malloc (sizeof (BablPaletteRadius) *
- (pal->count - 1) *
- pal->count);
-
for (i = 0; i < pal->count; i++)
{
BablPaletteRadius *radii1 = pal->radii + (pal->count - 1) * i;
@@ -251,12 +244,18 @@ static BablPalette *make_pal (const Babl *format, const void *data, int count)
BablPalette *pal = NULL;
int bpp = babl_format_get_bytes_per_pixel (format);
+ babl_assert (count > 0);
+
pal = babl_malloc (sizeof (BablPalette));
pal->count = count;
pal->format = format;
pal->data = babl_malloc (bpp * count);
pal->data_double = babl_malloc (4 * sizeof(double) * count);
pal->data_u8 = babl_malloc (4 * sizeof(char) * count);
+ pal->radii = babl_malloc (sizeof (BablPaletteRadius) *
+ (pal->count - 1) *
+ pal->count);
+
memcpy (pal->data, data, bpp * count);
babl_process (babl_fish (format, babl_format ("RGBA double")),
@@ -284,10 +283,19 @@ static BablPalette *default_palette (void)
{
static BablPalette pal;
static int inited = 0;
+
+ babl_mutex_lock (babl_format_mutex);
+
if (inited)
- return &pal;
+ {
+ babl_mutex_unlock (babl_format_mutex);
+
+ return &pal;
+ }
+
+ init_ceil_sqrt_u8 ();
+
memset (&pal, 0, sizeof (pal));
- inited = 1;
pal.count = 16;
pal.format = babl_format ("R'G'B'A u8"); /* dynamically generated, so
the default palette can
@@ -296,12 +304,19 @@ static BablPalette *default_palette (void)
pal.data = defpal_data;
pal.data_double = defpal_double;
pal.data_u8 = defpal_data;
+ pal.radii = defpal_radii;
babl_process (babl_fish (pal.format, babl_format ("RGBA double")),
pal.data, pal.data_double, pal.count);
babl_palette_init_radii (&pal);
+
babl_palette_reset_hash (&pal);
+
+ inited = 1;
+
+ babl_mutex_unlock (babl_format_mutex);
+
return &pal;
}
@@ -857,7 +872,26 @@ babl_palette_set_palette (const Babl *babl,
{
BablPalette **palptr = babl_get_user_data (babl);
babl_palette_reset (babl);
- *palptr = make_pal (format, data, count);
+
+ if (count > 256)
+ {
+ babl_log ("attempt to create a palette with %d colors. "
+ "truncating to 256 colors.",
+ count);
+
+ count = 256;
+ }
+
+ if (count > 0)
+ {
+ *palptr = make_pal (format, data, count);
+ }
+ else
+ {
+ babl_log ("attempt to create a palette with %d colors. "
+ "using default palette instead.",
+ count);
+ }
}
void
diff --git a/babl/babl-polynomial.c b/babl/babl-polynomial.c
index d27c1bb..cf29567 100644
--- a/babl/babl-polynomial.c
+++ b/babl/babl-polynomial.c
@@ -16,7 +16,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifdef BABL_POLYNOMIAL_DEGREE
diff --git a/babl/babl-polynomial.h b/babl/babl-polynomial.h
index d883542..233c743 100644
--- a/babl/babl-polynomial.h
+++ b/babl/babl-polynomial.h
@@ -16,7 +16,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_POLYNOMIAL_H
diff --git a/babl/babl-ref-pixels.c b/babl/babl-ref-pixels.c
index a8f7109..265c1c8 100644
--- a/babl/babl-ref-pixels.c
+++ b/babl/babl-ref-pixels.c
@@ -14,7 +14,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "babl-ref-pixels.h"
diff --git a/babl/babl-ref-pixels.h b/babl/babl-ref-pixels.h
index fe2e595..cab49ed 100644
--- a/babl/babl-ref-pixels.h
+++ b/babl/babl-ref-pixels.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_REF_PIXELS_H
diff --git a/babl/babl-ref-pixels.inc b/babl/babl-ref-pixels.inc
index 1b1362b..b706da7 100644
--- a/babl/babl-ref-pixels.inc
+++ b/babl/babl-ref-pixels.inc
@@ -14,7 +14,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
/* THIS IS A GENERATED FILE - DO NOT EDIT */
diff --git a/babl/babl-sampling.c b/babl/babl-sampling.c
index 15b6532..e671078 100644
--- a/babl/babl-sampling.c
+++ b/babl/babl-sampling.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#define HORIZONTAL_MIN 1
diff --git a/babl/babl-sampling.h b/babl/babl-sampling.h
index 82e6d15..e3aa7ed 100644
--- a/babl/babl-sampling.h
+++ b/babl/babl-sampling.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_SAMPLING_H
diff --git a/babl/babl-sanity.c b/babl/babl-sanity.c
index 5eb74b4..2c18d56 100644
--- a/babl/babl-sanity.c
+++ b/babl/babl-sanity.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/babl/babl-space.c b/babl/babl-space.c
index b5557fb..9a78d38 100644
--- a/babl/babl-space.c
+++ b/babl/babl-space.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#define MAX_SPACES 100
@@ -167,7 +167,7 @@ static void babl_matrix_equalize (double *in_mat)
}
}
-static void babl_space_compute_matrices (BablSpace *space)
+static void babl_space_compute_matrices (BablSpace *space, BablSpaceFlags equalize_matrix)
{
#define _ space->
/* transform spaces xy(Y) specified data to XYZ */
@@ -196,7 +196,8 @@ static void babl_space_compute_matrices (BablSpace *space)
babl_matrix_mul_matrix (chad, mat, mat);
- babl_matrix_equalize (mat);
+ if (equalize_matrix)
+ babl_matrix_equalize (mat);
memcpy (space->RGBtoXYZ, mat, sizeof (mat));
@@ -229,18 +230,50 @@ babl_space_from_rgbxyz_matrix (const char *name,
const Babl *trc_blue)
{
int i=0;
- static BablSpace space;
+ 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;
+
+ /* transplant matrixes */
+
+ 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);
+
+ {
+ double red[3]={1.,.0,.0};
+ double xyz[3]={1.,.0,.0};
+ _babl_space_to_xyz ((Babl*)&space, &red[0], &xyz[0]);
+ space.xr = xyz[0] / (xyz[0] + xyz[1] + xyz[2]);
+ space.yr = xyz[1] / (xyz[0] + xyz[1] + xyz[2]);
+ }
+ {
+ double green[3]={0.,1.0,.0};
+ double xyz[3]={0.,1.0,.0};
+ _babl_space_to_xyz ((Babl*)&space, &green[0], &xyz[0]);
+ space.xg = xyz[0] / (xyz[0] + xyz[1] + xyz[2]);
+ space.yg = xyz[1] / (xyz[0] + xyz[1] + xyz[2]);
+ }
+ {
+ double blue[3]={0.,.0,1.0};
+ double xyz[3]={0.,1.0,.0};
+ _babl_space_to_xyz ((Babl*)&space, &blue[0], &xyz[0]);
+ space.xb = xyz[0] / (xyz[0] + xyz[1] + xyz[2]);
+ space.yb = xyz[1] / (xyz[0] + xyz[1] + xyz[2]);
+ }
+ space.xw = wx / (wx+wy+wz);
+ space.yw = wy / (wx+wy+wz);
space.whitepoint[0] = wx;
space.whitepoint[1] = wy;
@@ -265,49 +298,30 @@ babl_space_from_rgbxyz_matrix (const char *name,
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)
snprintf (space_db[i].name, sizeof (space_db[i].name), "%s", name);
else
- snprintf (space_db[i].name, sizeof (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]),
+ /* XXX: this can get longer than 256bytes ! */
+ snprintf (space_db[i].name, sizeof (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]));
-
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)
+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,
+ BablSpaceFlags flags)
{
int i=0;
static BablSpace space;
@@ -357,7 +371,7 @@ babl_space_from_chromaticities (const char *name,
babl_get_name(space.trc[1]), babl_get_name(space.trc[2]));
/* compute matrixes */
- babl_space_compute_matrices (&space_db[i]);
+ babl_space_compute_matrices (&space_db[i], flags);
return (Babl*)&space_db[i];
}
@@ -375,12 +389,23 @@ babl_space_class_for_each (BablEachFunction each_fun,
void
babl_space_class_init (void)
{
+#if 0
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_trc("sRGB"), NULL, NULL, 1);
+#else
+ babl_space_from_chromaticities ("sRGB",
+ 0.3127, 0.3290, /* D65 */
+ 0.639998686, 0.330010138,
+ 0.300003784, 0.600003357,
+ 0.150002046, 0.059997204,
+ babl_trc("sRGB"), NULL, NULL,
+ 0);
+ /* hard-coded pre-quantized values - to match exactly what is used in standards see issue #18 */
+#endif
babl_space_from_chromaticities ("Rec2020",
0.3127, 0.3290, /* D65 */
@@ -388,7 +413,7 @@ babl_space_class_init (void)
0.170, 0.797,
0.131, 0.046,
// XXX: is using sRGB TRC right?
- babl_trc("sRGB"), NULL, NULL);
+ babl_trc("sRGB"), NULL, NULL, 1);
babl_space_from_chromaticities (
"Adobish", /* a space that can be used as a place-holder for a sRGB like
@@ -400,7 +425,7 @@ computations of uniform gray axis */
0.6400, 0.3300,
0.2100, 0.7100,
0.1500, 0.0600,
- babl_trc("2.2"), NULL, NULL);
+ babl_trc("2.2"), NULL, NULL, 1);
babl_space_from_chromaticities (
"ProPhoto",
@@ -408,7 +433,7 @@ computations of uniform gray axis */
0.7347, 0.2653,
0.1596, 0.8404,
0.0366, 0.0001,
- babl_trc("1.8"), NULL, NULL);
+ babl_trc("1.8"), NULL, NULL, 1);
babl_space_from_chromaticities (
"Apple",
@@ -416,7 +441,7 @@ computations of uniform gray axis */
0.6250, 0.3400,
0.2800, 0.5950,
0.1550, 0.0700,
- babl_trc("1.8"), NULL, NULL);
+ babl_trc("1.8"), NULL, NULL, 1);
#if 0
babl_space_from_chromaticities (
@@ -425,7 +450,7 @@ computations of uniform gray axis */
0.7350, 0.2650,
0.1150, 0.8260,
0.1570, 0.0180,
- babl_trc("2.2"), NULL, NULL);
+ babl_trc("2.2"), NULL, NULL, 1);
babl_space_from_chromaticities (
"Best",
@@ -433,7 +458,7 @@ computations of uniform gray axis */
0.7347, 0.2653,
0.2150, 0.7750,
0.1300, 0.0350,
- babl_trc("2.2"), NULL, NULL);
+ babl_trc("2.2"), NULL, NULL, 1);
babl_space_from_chromaticities (
"Beta",
@@ -441,7 +466,7 @@ computations of uniform gray axis */
0.6888, 0.3112,
0.1986, 0.7551,
0.1265, 0.0352,
- babl_trc("2.2"), NULL, NULL);
+ babl_trc("2.2"), NULL, NULL, 1);
babl_space_from_chromaticities (
"Bruce",
@@ -457,7 +482,7 @@ computations of uniform gray axis */
0.6400, 0.3300,
0.2900, 0.6000,
0.1500, 0.0600,
- babl_trc("2.2"), NULL, NULL);
+ babl_trc("2.2"), NULL, NULL, 1);
babl_space_from_chromaticities (
"SMPTE-C",
@@ -465,7 +490,7 @@ computations of uniform gray axis */
0.6300, 0.3300,
0.3100, 0.5950,
0.1550, 0.0700,
- babl_trc("2.2"), NULL, NULL);
+ babl_trc("2.2"), NULL, NULL, 1);
babl_space_from_chromaticities (
"ColorMatch",
@@ -473,7 +498,7 @@ computations of uniform gray axis */
0.6300, 0.3400,
0.2950, 0.6050,
0.1500, 0.0750,
- babl_trc("1.8"), NULL, NULL);
+ babl_trc("1.8"), NULL, NULL, 1);
babl_space_from_chromaticities (
"Don RGB 4",
@@ -481,8 +506,25 @@ computations of uniform gray axis */
0.6960, 0.3000,
0.2150, 0.7650,
0.1300, 0.0350,
- babl_trc("1.8"), NULL, NULL);
+ babl_trc("1.8"), NULL, NULL, 1);
#endif
+
+ babl_space_from_chromaticities (
+ "ACEScg",
+ 0.32168, 0.33767,
+ 0.713, 0.293,
+ 0.165, 0.830,
+ 0.128, 0.044,
+ babl_trc("linear"), NULL, NULL, 1);
+
+ babl_space_from_chromaticities (
+ "ACES2065-1",
+ 0.32168, 0.33767,
+ 0.7347, 0.2653,
+ 0.0000, 1.0000,
+ 0.0001, -0.0770,
+ babl_trc("linear"), NULL, NULL, 1);
+
}
void babl_space_to_xyz (const Babl *space, const double *rgb, double *xyz)
@@ -509,7 +551,9 @@ static void prep_conversion (const Babl *babl)
const Babl *source_space = babl_conversion_get_source_space (conversion);
float *matrixf;
int i;
- float *lut;
+ float *lut_red;
+ float *lut_green;
+ float *lut_blue;
double matrix[9];
babl_matrix_mul_matrix (
@@ -517,15 +561,18 @@ static void prep_conversion (const Babl *babl)
(conversion->conversion.source)->format.space->space.RGBtoXYZ,
matrix);
- matrixf = babl_calloc (sizeof (float), 9 + 256); // we leak this matrix , which is a singleton
+ matrixf = babl_calloc (sizeof (float), 9 + 256 * 3); // we leak this matrix , which is a singleton
babl_matrix_to_float (matrix, matrixf);
conversion->conversion.data = matrixf;
- lut = matrixf + 9;
+ lut_red = matrixf + 9;
+ lut_green = lut_red + 256;
+ lut_blue = lut_green + 256;
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
+ lut_red[i] = babl_trc_to_linear (source_space->space.trc[0], i/255.0);
+ lut_green[i] = babl_trc_to_linear (source_space->space.trc[1], i/255.0);
+ lut_blue[i] = babl_trc_to_linear (source_space->space.trc[2], i/255.0);
}
}
@@ -610,7 +657,9 @@ universal_nonlinear_rgba_u8_converter (const Babl *conversion,unsigned char *src
const Babl *destination_space = conversion->conversion.destination->format.space;
float * matrixf = data;
- float * in_trc_lut = matrixf + 9;
+ float * in_trc_lut_red = matrixf + 9;
+ float * in_trc_lut_green = in_trc_lut_red + 256;
+ float * in_trc_lut_blue = in_trc_lut_green + 256;
int i;
uint8_t *rgba_in_u8 = (void*)src_char;
uint8_t *rgba_out_u8 = (void*)dst_char;
@@ -619,9 +668,9 @@ universal_nonlinear_rgba_u8_converter (const Babl *conversion,unsigned char *src
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]];
+ rgb[i*4+0]=in_trc_lut_red[rgba_in_u8[i*4+0]];
+ rgb[i*4+1]=in_trc_lut_green[rgba_in_u8[i*4+1]];
+ rgb[i*4+2]=in_trc_lut_blue[rgba_in_u8[i*4+2]];
rgba_out_u8[i*4+3] = rgba_in_u8[i*4+3];
}
@@ -669,7 +718,9 @@ universal_nonlinear_rgb_u8_converter (const Babl *conversion,unsigned char *src_
const Babl *destination_space = conversion->conversion.destination->format.space;
float * matrixf = data;
- float * in_trc_lut = matrixf + 9;
+ float * in_trc_lut_red = matrixf + 9;
+ float * in_trc_lut_green = in_trc_lut_red + 256;
+ float * in_trc_lut_blue = in_trc_lut_green + 256;
int i;
uint8_t *rgb_in_u8 = (void*)src_char;
uint8_t *rgb_out_u8 = (void*)dst_char;
@@ -678,9 +729,9 @@ universal_nonlinear_rgb_u8_converter (const Babl *conversion,unsigned char *src_
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]];
+ rgba_out[i*4+0]=in_trc_lut_red[rgb_in_u8[i*3+0]];
+ rgba_out[i*4+1]=in_trc_lut_green[rgb_in_u8[i*3+1]];
+ rgba_out[i*4+2]=in_trc_lut_blue[rgb_in_u8[i*3+2]];
rgba_out[i*4+3]=rgb_in_u8[i*3+2] * 255.5f;
}
@@ -763,7 +814,9 @@ universal_nonlinear_rgba_u8_converter_sse2 (const Babl *conversion,unsigned char
const Babl *destination_space = conversion->conversion.destination->format.space;
float * matrixf = data;
- float * in_trc_lut = matrixf + 9;
+ float * in_trc_lut_red = matrixf + 9;
+ float * in_trc_lut_green = in_trc_lut_red + 256;
+ float * in_trc_lut_blue = in_trc_lut_green + 256;
int i;
uint8_t *rgba_in_u8 = (void*)src_char;
uint8_t *rgba_out_u8 = (void*)dst_char;
@@ -772,9 +825,9 @@ universal_nonlinear_rgba_u8_converter_sse2 (const Babl *conversion,unsigned char
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[i+0]=in_trc_lut_red[rgba_in_u8[i+0]];
+ rgba_out[i+1]=in_trc_lut_green[rgba_in_u8[i+1]];
+ rgba_out[i+2]=in_trc_lut_blue[rgba_in_u8[i+2]];
rgba_out_u8[i+3] = rgba_in_u8[i+3];
}
@@ -798,7 +851,9 @@ universal_nonlinear_rgb_u8_converter_sse2 (const Babl *conversion,unsigned char
const Babl *destination_space = conversion->conversion.destination->format.space;
float * matrixf = data;
- float * in_trc_lut = matrixf + 9;
+ float * in_trc_lut_red = matrixf + 9;
+ float * in_trc_lut_green = in_trc_lut_red + 256;
+ float * in_trc_lut_blue = in_trc_lut_green + 256;
int i;
uint8_t *rgb_in_u8 = (void*)src_char;
uint8_t *rgb_out_u8 = (void*)dst_char;
@@ -807,9 +862,9 @@ universal_nonlinear_rgb_u8_converter_sse2 (const Babl *conversion,unsigned char
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]];
+ rgba_out[i*4+0]=in_trc_lut_red[rgb_in_u8[i*3+0]];
+ rgba_out[i*4+1]=in_trc_lut_green[rgb_in_u8[i*3+1]];
+ rgba_out[i*4+2]=in_trc_lut_blue[rgb_in_u8[i*3+2]];
}
babl_matrix_mul_vectorff_buf4_sse2 (matrixf, rgba_out, rgba_out, samples);
@@ -979,6 +1034,54 @@ const Babl *babl_space_match_trc_matrix (const Babl *trc_red,
return NULL;
}
+const Babl *babl_space_with_trc (const Babl *babl, const Babl *trc)
+{
+ double xw, yw, xr, yr, xg, yg, xb, yb;
+ const Babl *red_trc = NULL;
+ const Babl *green_trc = NULL;
+ const Babl *blue_trc = NULL;
+
+ babl_space_get (babl,
+ &xw, &yw,
+ &xr, &yr,
+ &xg, &yg,
+ &xb, &yb,
+ &red_trc, &green_trc, &blue_trc);
+ if (red_trc == trc && green_trc == trc && blue_trc == trc)
+ return babl;
+ return babl_space_from_chromaticities (NULL,
+ xw, yw, xr, yr, xg, yg, xb, yb, trc, trc, trc,
+ BABL_SPACE_FLAG_EQUALIZE);
+
+}
+
+void babl_space_get (const Babl *babl,
+ double *xw, double *yw,
+ double *xr, double *yr,
+ double *xg, double *yg,
+ double *xb, double *yb,
+ const Babl **red_trc,
+ const Babl **green_trc,
+ const Babl **blue_trc)
+{
+ const BablSpace *space = &babl->space;
+ /* XXX: note: for spaces set by matrix should be possible to derive
+ the chromaticities of r,g,b and thus even then keep this
+ is canonical data
+ */
+ if(xw)*xw = space->xw;
+ if(yw)*yw = space->yw;
+ if(xr)*xr = space->xr;
+ if(yr)*yr = space->yr;
+ if(xg)*xg = space->xg;
+ if(yg)*yg = space->yg;
+ if(xb)*xb = space->xb;
+ if(yb)*yb = space->yb;
+ if(red_trc)*red_trc = space->trc[0];
+ if(green_trc)*green_trc = space->trc[1];
+ if(blue_trc)*blue_trc = space->trc[2];
+}
+
/* Trademarks:
*
* International Color Consortium is a registered trademarks of the.
diff --git a/babl/babl-space.h b/babl/babl-space.h
index 6aeefb6..35fd2c3 100644
--- a/babl/babl-space.h
+++ b/babl/babl-space.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_SPACE_H
@@ -41,8 +41,6 @@ typedef struct
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.
@@ -61,9 +59,12 @@ typedef struct
* making it possible to round-trip data. Unless it is sRGB, when
* standard should win.
*/
+ char *icc_profile;
+ int icc_length;
} BablSpace;
+
static inline void babl_space_to_xyzf (const Babl *space, const float *rgb, float *xyz)
{
BablSpace *space_ = (void*)space;
diff --git a/babl/babl-trc.c b/babl/babl-trc.c
index 11f79a6..cf75eb9 100644
--- a/babl/babl-trc.c
+++ b/babl/babl-trc.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#define MAX_TRCS 100
diff --git a/babl/babl-trc.h b/babl/babl-trc.h
index e7e5da5..380a736 100644
--- a/babl/babl-trc.h
+++ b/babl/babl-trc.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_TRC_H
diff --git a/babl/babl-type.c b/babl/babl-type.c
index 86b1a3f..759d604 100644
--- a/babl/babl-type.c
+++ b/babl/babl-type.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/babl/babl-type.h b/babl/babl-type.h
index 8030fe5..fb451c5 100644
--- a/babl/babl-type.h
+++ b/babl/babl-type.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_TYPE_H
diff --git a/babl/babl-types.h b/babl/babl-types.h
index 3df81e7..c43ce1a 100644
--- a/babl/babl-types.h
+++ b/babl/babl-types.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_TYPES_H
diff --git a/babl/babl-util.c b/babl/babl-util.c
index 60b695d..cab9ab1 100644
--- a/babl/babl-util.c
+++ b/babl/babl-util.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/babl/babl-util.h b/babl/babl-util.h
index 05ebdf4..9caec36 100644
--- a/babl/babl-util.h
+++ b/babl/babl-util.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_UTIL_H
diff --git a/babl/babl-version.c b/babl/babl-version.c
index 81e4efd..9c757b5 100644
--- a/babl/babl-version.c
+++ b/babl/babl-version.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/babl/babl-version.h b/babl/babl-version.h
index 6fe2746..a8acf1b 100644
--- a/babl/babl-version.h
+++ b/babl/babl-version.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_VERSION_H
@@ -34,7 +34,7 @@
#define BABL_MAJOR_VERSION 0
#define BABL_MINOR_VERSION 1
-#define BABL_MICRO_VERSION 50
+#define BABL_MICRO_VERSION 54
/** Get the version information on the babl library */
void babl_get_version (int *major,
diff --git a/babl/babl-version.h.in b/babl/babl-version.h.in
index ab00824..6b44e0d 100644
--- a/babl/babl-version.h.in
+++ b/babl/babl-version.h.in
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_VERSION_H
diff --git a/babl/babl.c b/babl/babl.c
index c734fb3..979cd46 100644
--- a/babl/babl.c
+++ b/babl/babl.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
@@ -180,3 +180,11 @@ babl_exit (void)
#endif
}
}
+
+#undef babl_model_is
+
+int babl_model_is (const Babl *babl, const char *model)
+{
+ return ((babl)==babl_model_with_space(model, babl));
+}
+
diff --git a/babl/babl.h b/babl/babl.h
index 39cb097..baddd44 100644
--- a/babl/babl.h
+++ b/babl/babl.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_H
@@ -80,6 +80,15 @@ const Babl * babl_component (const char *name);
*/
const Babl * babl_model (const char *name);
+/**
+ * babl_model_with_space:
+ *
+ * The models for formats also have a space in babl, try to avoid code
+ * needing to use this.
+ */
+const Babl *
+babl_model_with_space (const char *name, const Babl *space);
+
/**
* babl_space:
@@ -99,7 +108,7 @@ typedef enum {
} BablIccIntent;
/**
- * babl_icc_make_space:
+ * babl_space_from_icc:
*
* @icc_data: pointer to icc profile in memory
* @icc_length: length of icc profile in bytes
@@ -121,6 +130,12 @@ typedef enum {
* containing a message describing why the provided data does not yield a babl
* space.
*/
+const Babl *babl_space_from_icc (const char *icc_data,
+ int icc_length,
+ BablIccIntent intent,
+ const char **error);
+
+// XXX : deprecated
const Babl *babl_icc_make_space (const char *icc_data,
int icc_length,
BablIccIntent intent,
@@ -152,18 +167,11 @@ char *babl_icc_get_key (const char *icc_data,
* 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".
+ * @name such as for example "RGB u8", "CMYK float" or "CIE Lab u16",
+ * creates a format using the sRGB space, to also specify the color space
+ * and TRCs for a format, see babl_format_with_space.
*/
-const Babl * babl_format (const char *name);
-
-/**
- * babl_format_exists:
- *
- * Returns 1 if the provided format name is known by babl or 0 if it is
- * not. Can also be used to verify that specific extension formats are
- * available (though this can also be inferred from the version of babl).
- */
-int babl_format_exists (const char *name);
+const Babl * babl_format (const char *encoding);
/**
* babl_format_with_space:
@@ -175,7 +183,16 @@ int babl_format_exists (const char *name);
* 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);
+const Babl * babl_format_with_space (const char *encoding, const Babl *space);
+
+/**
+ * babl_format_exists:
+ *
+ * Returns 1 if the provided format name is known by babl or 0 if it is
+ * not. Can also be used to verify that specific extension formats are
+ * available (though this can also be inferred from the version of babl).
+ */
+int babl_format_exists (const char *name);
/*
* babl_format_get_space:
@@ -192,14 +209,14 @@ const Babl * babl_format_get_space (const Babl *format);
* destination_format, source and destination can be either strings
* with the names of the formats or Babl-format objects.
*/
-const Babl * babl_fish (const void *source_format,
- const void *destination_format);
+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
+ * Create 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:
@@ -431,7 +448,6 @@ void babl_palette_set_palette (const Babl *babl,
void babl_palette_reset (const Babl *babl);
-
/**
* babl_set_user_data: (skip)
*
@@ -449,6 +465,121 @@ void babl_set_user_data (const Babl *babl, void *data);
*/
void * babl_get_user_data (const Babl *babl);
+typedef enum {
+ BABL_SPACE_FLAG_NONE = 0,
+ BABL_SPACE_FLAG_EQUALIZE = 1
+} BablSpaceFlags;
+
+/**
+ * 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,
+ BablSpaceFlags flags);
+
+
+/**
+ * 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" and "linear" are recognized
+ * strings in a stock babl configuration.
+ */
+const Babl * babl_trc (const char *name);
+
+/**
+ * babl_space_with_trc:
+ *
+ * Creates a variant of an existing space with different trc.
+ */
+const Babl *babl_space_with_trc (const Babl *space, const Babl *trc);
+
+/**
+ * babl_space_get:
+ *
+ * query the chromaticities of white point and primaries as well as trcs
+ * used for r g a nd b, all arguments mights be NULL.
+ */
+void babl_space_get (const Babl *space,
+ double *xw, double *yw,
+ double *xr, double *yr,
+ double *xg, double *yg,
+ double *xb, double *yb,
+ const Babl **red_trc,
+ const Babl **green_trc,
+ const Babl **blue_trc);
+
+
+/**
+ * babl_model_is:
+ *
+ * return 0 if the name of the model in babl does not correspond to the provided
+ * model name.
+ */
+int babl_model_is (const Babl *babl, const char *model_name);
+
+#define babl_model_is(babl,model) ((babl)==babl_model_with_space(model,babl))
+
+
+/**
+ * babl_space_get_icc:
+ *
+ * Return pointer to ICC profile for space note that this is
+ * the ICC profile for R'G'B', though in formats only supporting linear
+ * like EXR GEGL chooses to load this lienar data as RGB and use the sRGB
+ * TRC.
+ *
+ * @babl: a BablSpace
+ * @length: point to an integer where length of profile in bytes is stored.
+ *
+ * Returns pointer to ICC profile data.
+ */
+const char *babl_space_get_icc (const Babl *babl, int *length);
+
+/**
+ * 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_format_get_encoding:
+ *
+ * Returns the components and data type, without space suffix.
+ */
+const char * babl_format_get_encoding (const Babl *babl);
#ifdef __cplusplus
}
diff --git a/babl/base/babl-base.c b/babl/base/babl-base.c
index 3fe3cfc..a25a144 100644
--- a/babl/base/babl-base.c
+++ b/babl/base/babl-base.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/babl/base/babl-base.h b/babl/base/babl-base.h
index 588e2f1..80a5b54 100644
--- a/babl/base/babl-base.h
+++ b/babl/base/babl-base.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BABL_BASE_H
diff --git a/babl/base/formats.c b/babl/base/formats.c
index 65b3d77..99bf605 100644
--- a/babl/base/formats.c
+++ b/babl/base/formats.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
@@ -27,301 +27,184 @@
void
babl_formats_init (void)
{
- babl_format_new (
- babl_model_from_id (BABL_RGBA_GAMMA_2_2),
+ const Babl *types[]={
babl_type_from_id (BABL_DOUBLE),
- babl_component_from_id (BABL_RED_GAMMA_2_2),
- babl_component_from_id (BABL_GREEN_GAMMA_2_2),
- babl_component_from_id (BABL_BLUE_GAMMA_2_2),
- babl_component_from_id (BABL_ALPHA),
- NULL);
- babl_format_new (
- babl_model_from_id (BABL_RGBA_GAMMA_2_2),
babl_type_from_id (BABL_FLOAT),
- babl_component_from_id (BABL_RED_GAMMA_2_2),
- babl_component_from_id (BABL_GREEN_GAMMA_2_2),
- babl_component_from_id (BABL_BLUE_GAMMA_2_2),
- babl_component_from_id (BABL_ALPHA),
- NULL);
- babl_format_new (
- babl_model_from_id (BABL_RGBA_GAMMA_2_2),
- babl_type_from_id (BABL_U16),
- babl_component_from_id (BABL_RED_GAMMA_2_2),
- babl_component_from_id (BABL_GREEN_GAMMA_2_2),
- babl_component_from_id (BABL_BLUE_GAMMA_2_2),
- babl_component_from_id (BABL_ALPHA),
- NULL);
- babl_format_new (
- babl_model_from_id (BABL_RGBA_GAMMA_2_2),
+ babl_type_from_id (BABL_HALF),
babl_type_from_id (BABL_U8),
- babl_component_from_id (BABL_RED_GAMMA_2_2),
- babl_component_from_id (BABL_GREEN_GAMMA_2_2),
- babl_component_from_id (BABL_BLUE_GAMMA_2_2),
- babl_component_from_id (BABL_ALPHA),
- NULL);
- babl_format_new (
- babl_model_from_id (BABL_RGBA_GAMMA_2_2_PREMULTIPLIED),
- babl_type_from_id (BABL_FLOAT),
- babl_component_from_id (BABL_RED_GAMMA_2_2_MUL_ALPHA),
- babl_component_from_id (BABL_GREEN_GAMMA_2_2_MUL_ALPHA),
- babl_component_from_id (BABL_BLUE_GAMMA_2_2_MUL_ALPHA),
- babl_component_from_id (BABL_ALPHA),
- NULL);
- babl_format_new (
- babl_model_from_id (BABL_RGBA_GAMMA_2_2_PREMULTIPLIED),
babl_type_from_id (BABL_U16),
- babl_component_from_id (BABL_RED_GAMMA_2_2_MUL_ALPHA),
- babl_component_from_id (BABL_GREEN_GAMMA_2_2_MUL_ALPHA),
- babl_component_from_id (BABL_BLUE_GAMMA_2_2_MUL_ALPHA),
- babl_component_from_id (BABL_ALPHA),
- NULL);
- babl_format_new (
- babl_model_from_id (BABL_RGBA_GAMMA_2_2_PREMULTIPLIED),
- babl_type_from_id (BABL_U8),
- babl_component_from_id (BABL_RED_GAMMA_2_2_MUL_ALPHA),
- babl_component_from_id (BABL_GREEN_GAMMA_2_2_MUL_ALPHA),
- babl_component_from_id (BABL_BLUE_GAMMA_2_2_MUL_ALPHA),
- babl_component_from_id (BABL_ALPHA),
- NULL);
- babl_format_new (
- babl_model_from_id (BABL_RGB_GAMMA_2_2),
- babl_type_from_id (BABL_FLOAT),
- babl_component_from_id (BABL_RED_GAMMA_2_2),
- babl_component_from_id (BABL_GREEN_GAMMA_2_2),
- babl_component_from_id (BABL_BLUE_GAMMA_2_2),
- NULL);
- babl_format_new (
- babl_model_from_id (BABL_RGB_GAMMA_2_2),
- babl_type_from_id (BABL_U16),
- babl_component_from_id (BABL_RED_GAMMA_2_2),
- babl_component_from_id (BABL_GREEN_GAMMA_2_2),
- babl_component_from_id (BABL_BLUE_GAMMA_2_2),
- NULL);
- babl_format_new (
- babl_model_from_id (BABL_RGB_GAMMA_2_2),
- babl_type_from_id (BABL_U8),
- babl_component_from_id (BABL_RED_GAMMA_2_2),
- babl_component_from_id (BABL_GREEN_GAMMA_2_2),
- babl_component_from_id (BABL_BLUE_GAMMA_2_2),
- NULL);
- babl_format_new (
- babl_model_from_id (BABL_GRAY_GAMMA_2_2_ALPHA),
- babl_type_from_id (BABL_FLOAT),
- babl_component_from_id (BABL_LUMA),
- babl_component_from_id (BABL_ALPHA),
- NULL);
- babl_format_new (
- babl_model_from_id (BABL_GRAY_GAMMA_2_2_ALPHA_PREMULTIPLIED),
- babl_type_from_id (BABL_FLOAT),
- babl_component_from_id (BABL_LUMA_MUL_ALPHA),
- babl_component_from_id (BABL_ALPHA),
- NULL);
- babl_format_new (
- babl_model_from_id (BABL_GRAY_GAMMA_2_2),
- babl_type_from_id (BABL_FLOAT),
- babl_component_from_id (BABL_LUMA),
- NULL);
- babl_format_new (
- babl_model_from_id (BABL_GRAY_GAMMA_2_2_ALPHA),
- babl_type_from_id (BABL_U16),
- babl_component_from_id (BABL_LUMA),
- babl_component_from_id (BABL_ALPHA),
- NULL);
- babl_format_new (
- babl_model_from_id (BABL_GRAY_GAMMA_2_2_ALPHA_PREMULTIPLIED),
- babl_type_from_id (BABL_U16),
- babl_component_from_id (BABL_LUMA_MUL_ALPHA),
- babl_component_from_id (BABL_ALPHA),
- NULL);
+ babl_type_from_id (BABL_U32)
+ };
+ for (int i = 0; i < sizeof (types)/sizeof(types[0]);i++)
+ {
+ const Babl *type = types[i];
+
+ babl_format_new (
+ babl_model_from_id (BABL_RGBA_NONLINEAR_PREMULTIPLIED),
+ type,
+ babl_component_from_id (BABL_RED_NONLINEAR_MUL_ALPHA),
+ babl_component_from_id (BABL_GREEN_NONLINEAR_MUL_ALPHA),
+ babl_component_from_id (BABL_BLUE_NONLINEAR_MUL_ALPHA),
+ babl_component_from_id (BABL_ALPHA),
+ NULL);
+
+ babl_format_new (
+ babl_model_from_id (BABL_RGBA_PERCEPTUAL_PREMULTIPLIED),
+ type,
+ babl_component_from_id (BABL_RED_PERCEPTUAL_MUL_ALPHA),
+ babl_component_from_id (BABL_GREEN_PERCEPTUAL_MUL_ALPHA),
+ babl_component_from_id (BABL_BLUE_PERCEPTUAL_MUL_ALPHA),
+ babl_component_from_id (BABL_ALPHA),
+ NULL);
+
+ babl_format_new (
+ babl_model_from_id (BABL_RGBA_NONLINEAR),
+ type,
+ babl_component_from_id (BABL_RED_NONLINEAR),
+ babl_component_from_id (BABL_GREEN_NONLINEAR),
+ babl_component_from_id (BABL_BLUE_NONLINEAR),
+ babl_component_from_id (BABL_ALPHA),
+ NULL);
+
+ babl_format_new (
+ babl_model_from_id (BABL_RGBA_PERCEPTUAL),
+ type,
+ babl_component_from_id (BABL_RED_PERCEPTUAL),
+ babl_component_from_id (BABL_GREEN_PERCEPTUAL),
+ babl_component_from_id (BABL_BLUE_PERCEPTUAL),
+ babl_component_from_id (BABL_ALPHA),
+ NULL);
+
babl_format_new (
- babl_model_from_id (BABL_GRAY_GAMMA_2_2),
- babl_type_from_id (BABL_U16),
- babl_component_from_id (BABL_LUMA),
+ babl_model_from_id (BABL_RGB_NONLINEAR),
+ type,
+ babl_component_from_id (BABL_RED_NONLINEAR),
+ babl_component_from_id (BABL_GREEN_NONLINEAR),
+ babl_component_from_id (BABL_BLUE_NONLINEAR),
NULL);
babl_format_new (
- babl_model_from_id (BABL_GRAY_GAMMA_2_2_ALPHA),
- babl_type_from_id (BABL_U8),
- babl_component_from_id (BABL_LUMA),
- babl_component_from_id (BABL_ALPHA),
+ babl_model_from_id (BABL_RGB_NONLINEAR),
+ type,
+ babl_component_from_id (BABL_RED_NONLINEAR),
+ babl_component_from_id (BABL_GREEN_NONLINEAR),
+ babl_component_from_id (BABL_BLUE_NONLINEAR),
NULL);
+
babl_format_new (
- babl_model_from_id (BABL_GRAY_GAMMA_2_2_ALPHA_PREMULTIPLIED),
- babl_type_from_id (BABL_U8),
- babl_component_from_id (BABL_LUMA_MUL_ALPHA),
- babl_component_from_id (BABL_ALPHA),
+ babl_model_from_id (BABL_RGB_PERCEPTUAL),
+ type,
+ babl_component_from_id (BABL_RED_PERCEPTUAL),
+ babl_component_from_id (BABL_GREEN_PERCEPTUAL),
+ babl_component_from_id (BABL_BLUE_PERCEPTUAL),
NULL);
babl_format_new (
- babl_model_from_id (BABL_GRAY_GAMMA_2_2),
- babl_type_from_id (BABL_U8),
- babl_component_from_id (BABL_LUMA),
+ babl_model_from_id (BABL_RGB_PERCEPTUAL),
+ type,
+ babl_component_from_id (BABL_RED_PERCEPTUAL),
+ babl_component_from_id (BABL_GREEN_PERCEPTUAL),
+ babl_component_from_id (BABL_BLUE_PERCEPTUAL),
NULL);
- /* overriding name, since the generated name would be wrong due
- * to differing types
- */
babl_format_new (
- "name", "Y'CbCr u8",
- "planar",
- babl_model_from_id (BABL_YCBCR),
- babl_type_from_id (BABL_U8_LUMA),
- babl_sampling (1, 1),
- babl_component_from_id (BABL_LUMA),
- babl_type_from_id (BABL_U8_CHROMA),
- babl_sampling (2, 2),
- babl_component_from_id (BABL_CB),
- babl_sampling (2, 2),
- babl_component_from_id (BABL_CR),
+ babl_model_from_id (BABL_MODEL_GRAY_NONLINEAR),
+ type,
+ babl_component_from_id (BABL_GRAY_NONLINEAR),
NULL);
+
babl_format_new (
- babl_model_from_id (BABL_YCBCR),
- babl_type_from_id (BABL_FLOAT),
- babl_component_from_id (BABL_LUMA),
- babl_type_from_id (BABL_FLOAT),
- babl_component_from_id (BABL_CB),
- babl_component_from_id (BABL_CR),
+ babl_model_from_id (BABL_MODEL_GRAY_PERCEPTUAL),
+ type,
+ babl_component_from_id (BABL_GRAY_PERCEPTUAL),
NULL);
+
babl_format_new (
- babl_model_from_id (BABL_YCBCR_ALPHA),
- babl_type_from_id (BABL_FLOAT),
- babl_component_from_id (BABL_LUMA),
- babl_type_from_id (BABL_FLOAT),
- babl_component_from_id (BABL_CB),
- babl_component_from_id (BABL_CR),
+ babl_model_from_id (BABL_MODEL_GRAY_NONLINEAR_ALPHA),
+ type,
+ babl_component_from_id (BABL_GRAY_NONLINEAR),
babl_component_from_id (BABL_ALPHA),
NULL);
+
babl_format_new (
- 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),
+ babl_model_from_id (BABL_MODEL_GRAY_PERCEPTUAL_ALPHA),
+ type,
+ babl_component_from_id (BABL_GRAY_PERCEPTUAL),
babl_component_from_id (BABL_ALPHA),
NULL);
+
babl_format_new (
- babl_model_from_id (BABL_RGBA),
- babl_type_from_id (BABL_U16),
- babl_component_from_id (BABL_RED),
- babl_component_from_id (BABL_GREEN),
- babl_component_from_id (BABL_BLUE),
+ babl_model_from_id (BABL_MODEL_GRAY_NONLINEAR_ALPHA_PREMULTIPLIED),
+ type,
+ babl_component_from_id (BABL_GRAY_NONLINEAR_MUL_ALPHA),
babl_component_from_id (BABL_ALPHA),
NULL);
+
+
babl_format_new (
babl_model_from_id (BABL_RGBA),
- babl_type_from_id (BABL_DOUBLE),
+ type,
babl_component_from_id (BABL_RED),
babl_component_from_id (BABL_GREEN),
babl_component_from_id (BABL_BLUE),
babl_component_from_id (BABL_ALPHA),
NULL);
+
babl_format_new (
- babl_model_from_id (BABL_RGBA),
- babl_type_from_id (BABL_U8),
+ babl_model_from_id (BABL_RGB),
+ type,
babl_component_from_id (BABL_RED),
babl_component_from_id (BABL_GREEN),
babl_component_from_id (BABL_BLUE),
- babl_component_from_id (BABL_ALPHA),
- NULL);
- babl_format_new (
- babl_model_from_id (BABL_RGBA_PREMULTIPLIED),
- babl_type_from_id (BABL_FLOAT),
- babl_component_from_id (BABL_RED_MUL_ALPHA),
- babl_component_from_id (BABL_GREEN_MUL_ALPHA),
- babl_component_from_id (BABL_BLUE_MUL_ALPHA),
- babl_component_from_id (BABL_ALPHA),
- NULL);
- babl_format_new (
- babl_model_from_id (BABL_RGBA_PREMULTIPLIED),
- babl_type_from_id (BABL_U16),
- babl_component_from_id (BABL_RED_MUL_ALPHA),
- babl_component_from_id (BABL_GREEN_MUL_ALPHA),
- babl_component_from_id (BABL_BLUE_MUL_ALPHA),
- babl_component_from_id (BABL_ALPHA),
NULL);
+
babl_format_new (
babl_model_from_id (BABL_RGBA_PREMULTIPLIED),
- babl_type_from_id (BABL_U8),
+ type,
babl_component_from_id (BABL_RED_MUL_ALPHA),
babl_component_from_id (BABL_GREEN_MUL_ALPHA),
babl_component_from_id (BABL_BLUE_MUL_ALPHA),
babl_component_from_id (BABL_ALPHA),
NULL);
- babl_format_new (
- babl_model_from_id (BABL_RGB),
- babl_type_from_id (BABL_FLOAT),
- babl_component_from_id (BABL_RED),
- babl_component_from_id (BABL_GREEN),
- babl_component_from_id (BABL_BLUE),
- NULL);
- babl_format_new (
- babl_model_from_id (BABL_RGB),
- babl_type_from_id (BABL_U16),
- babl_component_from_id (BABL_RED),
- babl_component_from_id (BABL_GREEN),
- babl_component_from_id (BABL_BLUE),
- NULL);
- babl_format_new (
- babl_model_from_id (BABL_RGB),
- babl_type_from_id (BABL_U8),
- babl_component_from_id (BABL_RED),
- babl_component_from_id (BABL_GREEN),
- babl_component_from_id (BABL_BLUE),
- NULL);
- babl_format_new (
- babl_model_from_id (BABL_GRAY_ALPHA),
- babl_type_from_id (BABL_FLOAT),
- babl_component_from_id (BABL_LUMINANCE),
- babl_component_from_id (BABL_ALPHA),
- NULL);
- babl_format_new (
- babl_model_from_id (BABL_GRAY_ALPHA_PREMULTIPLIED),
- babl_type_from_id (BABL_FLOAT),
- babl_component_from_id (BABL_LUMINANCE_MUL_ALPHA),
- babl_component_from_id (BABL_ALPHA),
- NULL);
- babl_format_new (
- babl_model_from_id (BABL_GRAY),
- babl_type_from_id (BABL_FLOAT),
- babl_component_from_id (BABL_LUMINANCE),
- NULL);
+
babl_format_new (
babl_model_from_id (BABL_GRAY_ALPHA),
- babl_type_from_id (BABL_U16),
- babl_component_from_id (BABL_LUMINANCE),
+ type,
+ babl_component_from_id (BABL_GRAY_LINEAR),
babl_component_from_id (BABL_ALPHA),
NULL);
babl_format_new (
babl_model_from_id (BABL_GRAY_ALPHA_PREMULTIPLIED),
- babl_type_from_id (BABL_U16),
- babl_component_from_id (BABL_LUMINANCE_MUL_ALPHA),
+ type,
+ babl_component_from_id (BABL_GRAY_LINEAR_MUL_ALPHA),
babl_component_from_id (BABL_ALPHA),
NULL);
babl_format_new (
babl_model_from_id (BABL_GRAY),
- babl_type_from_id (BABL_U16),
- babl_component_from_id (BABL_LUMINANCE),
- NULL);
- babl_format_new (
- babl_model_from_id (BABL_GRAY_ALPHA),
- babl_type_from_id (BABL_U8),
- babl_component_from_id (BABL_LUMINANCE),
- babl_component_from_id (BABL_ALPHA),
- NULL);
- babl_format_new (
- babl_model_from_id (BABL_GRAY_ALPHA_PREMULTIPLIED),
- babl_type_from_id (BABL_U8),
- babl_component_from_id (BABL_LUMINANCE_MUL_ALPHA),
- babl_component_from_id (BABL_ALPHA),
+ type,
+ babl_component_from_id (BABL_GRAY_LINEAR),
NULL);
+
+ }
+
+ /* overriding name, since the generated name would be wrong due
+ * to differing types
+ */
babl_format_new (
- babl_model_from_id (BABL_GRAY),
- babl_type_from_id (BABL_U8),
- babl_component_from_id (BABL_LUMINANCE),
+ "name", "Y'CbCr u8",
+ "planar",
+ babl_model_from_id (BABL_YCBCR),
+ babl_type_from_id (BABL_U8_LUMA),
+ babl_sampling (1, 1),
+ babl_component_from_id (BABL_GRAY_NONLINEAR),
+ babl_type_from_id (BABL_U8_CHROMA),
+ babl_sampling (2, 2),
+ babl_component_from_id (BABL_CB),
+ babl_sampling (2, 2),
+ babl_component_from_id (BABL_CR),
NULL);
-
babl_format_new (
babl_model_from_id (BABL_YCBCR),
babl_type_from_id (BABL_FLOAT),
- babl_component_from_id (BABL_LUMA),
+ babl_component_from_id (BABL_GRAY_NONLINEAR),
babl_type_from_id (BABL_FLOAT),
babl_component_from_id (BABL_CB),
babl_component_from_id (BABL_CR),
@@ -329,7 +212,7 @@ babl_formats_init (void)
babl_format_new (
babl_model_from_id (BABL_YCBCR_ALPHA),
babl_type_from_id (BABL_FLOAT),
- babl_component_from_id (BABL_LUMA),
+ babl_component_from_id (BABL_GRAY_NONLINEAR),
babl_type_from_id (BABL_FLOAT),
babl_component_from_id (BABL_CB),
babl_component_from_id (BABL_CR),
diff --git a/babl/base/model-gray.c b/babl/base/model-gray.c
index 6a2764e..9d3677b 100644
--- a/babl/base/model-gray.c
+++ b/babl/base/model-gray.c
@@ -13,14 +13,13 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdlib.h>
-#include "babl-classes.h"
-#include "babl.h"
+#include "babl-internal.h"
#include "babl-ids.h"
#include "math.h"
#include "babl-base.h"
@@ -43,25 +42,31 @@ components (void)
{
babl_component_new (
"Y",
- "id", BABL_LUMINANCE,
+ "id", BABL_GRAY_LINEAR,
"luma",
NULL);
babl_component_new (
"Ya",
- "id", BABL_LUMINANCE_MUL_ALPHA,
+ "id", BABL_GRAY_LINEAR_MUL_ALPHA,
"luma",
NULL);
babl_component_new (
"Y'",
- "id", BABL_LUMA,
+ "id", BABL_GRAY_NONLINEAR,
"luma",
NULL);
babl_component_new (
"Y'a",
- "id", BABL_LUMA_MUL_ALPHA,
+ "id", BABL_GRAY_NONLINEAR_MUL_ALPHA,
+ "luma",
+ NULL);
+
+ babl_component_new (
+ "Y~",
+ "id", BABL_GRAY_PERCEPTUAL,
"luma",
NULL);
}
@@ -71,41 +76,51 @@ models (void)
{
babl_model_new (
"id", BABL_GRAY,
- babl_component_from_id (BABL_LUMINANCE),
+ babl_component_from_id (BABL_GRAY_LINEAR),
NULL);
babl_model_new (
"id", BABL_GRAY_ALPHA,
- babl_component_from_id (BABL_LUMINANCE),
+ babl_component_from_id (BABL_GRAY_LINEAR),
babl_component_from_id (BABL_ALPHA),
NULL);
babl_model_new (
"id", BABL_GRAY_ALPHA_PREMULTIPLIED,
- babl_component_from_id (BABL_LUMINANCE_MUL_ALPHA),
+ babl_component_from_id (BABL_GRAY_LINEAR_MUL_ALPHA),
babl_component_from_id (BABL_ALPHA),
NULL);
+ babl_model_new (
+ "id", BABL_MODEL_GRAY_NONLINEAR,
+ babl_component_from_id (BABL_GRAY_NONLINEAR),
+ NULL);
babl_model_new (
- "id", BABL_GRAY_GAMMA_2_2,
- babl_component_from_id (BABL_LUMA),
+ "id", BABL_MODEL_GRAY_NONLINEAR_ALPHA,
+ babl_component_from_id (BABL_GRAY_NONLINEAR),
+ babl_component_from_id (BABL_ALPHA),
NULL);
babl_model_new (
- "id", BABL_GRAY_GAMMA_2_2_ALPHA,
- babl_component_from_id (BABL_LUMA),
+ "id", BABL_MODEL_GRAY_NONLINEAR_ALPHA_PREMULTIPLIED,
+ babl_component_from_id (BABL_GRAY_NONLINEAR_MUL_ALPHA),
babl_component_from_id (BABL_ALPHA),
NULL);
babl_model_new (
- "id", BABL_GRAY_GAMMA_2_2_ALPHA_PREMULTIPLIED,
- babl_component_from_id (BABL_LUMA_MUL_ALPHA),
+ "id", BABL_MODEL_GRAY_PERCEPTUAL,
+ babl_component_from_id (BABL_GRAY_PERCEPTUAL),
+ NULL);
+
+ babl_model_new (
+ "id", BABL_MODEL_GRAY_PERCEPTUAL_ALPHA,
+ babl_component_from_id (BABL_GRAY_PERCEPTUAL),
babl_component_from_id (BABL_ALPHA),
NULL);
-}
+}
static void
rgba_to_graya (Babl *conversion,
@@ -171,15 +186,17 @@ rgba_to_gray (Babl *conversion,
}
}
+static const Babl *perceptual_trc = NULL;
+
static void
-rgb_to_gray_2_2 (Babl *conversion,
- int src_bands,
- char **src,
- int *src_pitch,
- int dst_bands,
- char **dst,
- int *dst_pitch,
- long n)
+rgb_to_gray_nonlinear (Babl *conversion,
+ int src_bands,
+ char **src,
+ int *src_pitch,
+ int dst_bands,
+ char **dst,
+ int *dst_pitch,
+ long n)
{
const Babl *space = babl_conversion_get_destination_space (conversion);
const Babl *trc = space->space.trc[0];
@@ -201,7 +218,7 @@ rgb_to_gray_2_2 (Babl *conversion,
else
alpha = 1.0;
- luminance = red * RGB_LUMINANCE_RED + // XXX: should be taken from BablSpace
+ luminance = red * RGB_LUMINANCE_RED +
green * RGB_LUMINANCE_GREEN +
blue * RGB_LUMINANCE_BLUE;
*(double *) dst[0] = babl_trc_from_linear (trc, luminance);
@@ -215,14 +232,14 @@ rgb_to_gray_2_2 (Babl *conversion,
static void
-gray_2_2_to_rgb (Babl *conversion,
- int src_bands,
- char **src,
- int *src_pitch,
- int dst_bands,
- char **dst,
- int *dst_pitch,
- long n)
+gray_nonlinear_to_rgb (Babl *conversion,
+ int src_bands,
+ char **src,
+ int *src_pitch,
+ int dst_bands,
+ char **dst,
+ int *dst_pitch,
+ long n)
{
const Babl *space = babl_conversion_get_source_space (conversion);
const Babl *trc = space->space.trc[0];
@@ -255,6 +272,88 @@ gray_2_2_to_rgb (Babl *conversion,
}
static void
+rgb_to_gray_perceptual (Babl *conversion,
+ int src_bands,
+ char **src,
+ int *src_pitch,
+ int dst_bands,
+ char **dst,
+ int *dst_pitch,
+ long n)
+{
+ const Babl *space = babl_conversion_get_destination_space (conversion);
+ const Babl *trc = perceptual_trc;
+ 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--)
+ {
+ double red, green, blue;
+ double luminance, alpha;
+
+ red = *(double *) src[0];
+ green = *(double *) src[1];
+ blue = *(double *) src[2];
+ if (src_bands > 3)
+ alpha = *(double *) src[3];
+ else
+ alpha = 1.0;
+
+ luminance = red * RGB_LUMINANCE_RED +
+ green * RGB_LUMINANCE_GREEN +
+ blue * RGB_LUMINANCE_BLUE;
+ *(double *) dst[0] = babl_trc_from_linear (trc, luminance);
+
+ if (dst_bands == 2)
+ *(double *) dst[1] = alpha;
+
+ BABL_PLANAR_STEP
+ }
+}
+
+static void
+gray_perceptual_to_rgb (Babl *conversion,
+ int src_bands,
+ char **src,
+ int *src_pitch,
+ int dst_bands,
+ char **dst,
+ int *dst_pitch,
+ long n)
+{
+ const Babl *trc = perceptual_trc;
+
+ BABL_PLANAR_SANITY
+ while (n--)
+ {
+ double luminance;
+ double red, green, blue;
+ double alpha;
+
+ luminance = babl_trc_to_linear (trc, *(double *) src[0]);
+ red = luminance;
+ green = luminance;
+ blue = luminance;
+ if (src_bands > 1)
+ alpha = *(double *) src[1];
+ else
+ alpha = 1.0;
+
+ *(double *) dst[0] = red;
+ *(double *) dst[1] = green;
+ *(double *) dst[2] = blue;
+
+ if (dst_bands > 3)
+ *(double *) dst[3] = alpha;
+
+ BABL_PLANAR_STEP
+ }
+}
+
+
+static void
graya_to_rgba (Babl *conversion,
char *src,
char *dst,
@@ -449,7 +548,7 @@ premultiplied_to_non_premultiplied (Babl *conversion,
}
static void
-rgba2gray_gamma_2_2_premultiplied (Babl *conversion,
+rgba2gray_nonlinear_premultiplied (Babl *conversion,
char *src,
char *dst,
long n)
@@ -485,7 +584,7 @@ rgba2gray_gamma_2_2_premultiplied (Babl *conversion,
static void
-gray_gamma_2_2_premultiplied2rgba (Babl *conversion,
+gray_nonlinear_premultiplied2rgba (Babl *conversion,
char *src,
char *dst,
long n)
@@ -516,53 +615,84 @@ gray_gamma_2_2_premultiplied2rgba (Babl *conversion,
}
}
-
static void
conversions (void)
{
+ perceptual_trc = babl_trc ("sRGB");
babl_conversion_new (
- babl_model_from_id (BABL_GRAY_GAMMA_2_2),
+ babl_model_from_id (BABL_MODEL_GRAY_NONLINEAR),
babl_model_from_id (BABL_RGBA),
- "planar", gray_2_2_to_rgb,
+ "planar", gray_nonlinear_to_rgb,
NULL
);
babl_conversion_new (
babl_model_from_id (BABL_RGBA),
- babl_model_from_id (BABL_GRAY_GAMMA_2_2),
- "planar", rgb_to_gray_2_2,
+ babl_model_from_id (BABL_MODEL_GRAY_NONLINEAR),
+ "planar", rgb_to_gray_nonlinear,
NULL
);
babl_conversion_new (
- babl_model_from_id (BABL_GRAY_GAMMA_2_2_ALPHA),
+ babl_model_from_id (BABL_MODEL_GRAY_NONLINEAR_ALPHA),
babl_model_from_id (BABL_RGBA),
- "planar", gray_2_2_to_rgb,
+ "planar", gray_nonlinear_to_rgb,
NULL
);
babl_conversion_new (
babl_model_from_id (BABL_RGBA),
- babl_model_from_id (BABL_GRAY_GAMMA_2_2_ALPHA),
- "planar", rgb_to_gray_2_2,
+ babl_model_from_id (BABL_MODEL_GRAY_NONLINEAR_ALPHA),
+ "planar", rgb_to_gray_nonlinear,
NULL
);
babl_conversion_new (
- babl_model_from_id (BABL_GRAY_GAMMA_2_2_ALPHA_PREMULTIPLIED),
+ babl_model_from_id (BABL_MODEL_GRAY_NONLINEAR_ALPHA_PREMULTIPLIED),
babl_model_from_id (BABL_RGBA),
- "linear", gray_gamma_2_2_premultiplied2rgba,
+ "linear", gray_nonlinear_premultiplied2rgba,
NULL
);
babl_conversion_new (
babl_model_from_id (BABL_RGBA),
- babl_model_from_id (BABL_GRAY_GAMMA_2_2_ALPHA_PREMULTIPLIED),
- "linear", rgba2gray_gamma_2_2_premultiplied,
+ babl_model_from_id (BABL_MODEL_GRAY_NONLINEAR_ALPHA_PREMULTIPLIED),
+ "linear", rgba2gray_nonlinear_premultiplied,
NULL
);
+
+
+ babl_conversion_new (
+ babl_model_from_id (BABL_MODEL_GRAY_PERCEPTUAL),
+ babl_model_from_id (BABL_RGBA),
+ "planar", gray_perceptual_to_rgb,
+ NULL
+ );
+
+ babl_conversion_new (
+ babl_model_from_id (BABL_RGBA),
+ babl_model_from_id (BABL_MODEL_GRAY_PERCEPTUAL),
+ "planar", rgb_to_gray_perceptual,
+ NULL
+ );
+
+ babl_conversion_new (
+ babl_model_from_id (BABL_MODEL_GRAY_PERCEPTUAL_ALPHA),
+ babl_model_from_id (BABL_RGBA),
+ "planar", gray_perceptual_to_rgb,
+ NULL
+ );
+
+ babl_conversion_new (
+ babl_model_from_id (BABL_RGBA),
+ babl_model_from_id (BABL_MODEL_GRAY_PERCEPTUAL_ALPHA),
+ "planar", rgb_to_gray_perceptual,
+ NULL
+ );
+
+
babl_conversion_new (
babl_model_from_id (BABL_GRAY),
babl_model_from_id (BABL_RGBA),
@@ -626,106 +756,106 @@ formats (void)
babl_format_new (
babl_model_from_id (BABL_GRAY_ALPHA),
babl_type_from_id (BABL_HALF),
- babl_component_from_id (BABL_LUMINANCE),
+ babl_component_from_id (BABL_GRAY_LINEAR),
babl_component_from_id (BABL_ALPHA),
NULL);
babl_format_new (
babl_model_from_id (BABL_GRAY_ALPHA_PREMULTIPLIED),
babl_type_from_id (BABL_HALF),
- babl_component_from_id (BABL_LUMINANCE_MUL_ALPHA),
+ babl_component_from_id (BABL_GRAY_LINEAR_MUL_ALPHA),
babl_component_from_id (BABL_ALPHA),
NULL);
babl_format_new (
babl_model_from_id (BABL_GRAY),
babl_type_from_id (BABL_HALF),
- babl_component_from_id (BABL_LUMINANCE),
+ babl_component_from_id (BABL_GRAY_LINEAR),
NULL);
babl_format_new (
- babl_model_from_id (BABL_GRAY_GAMMA_2_2_ALPHA),
+ babl_model_from_id (BABL_MODEL_GRAY_NONLINEAR_ALPHA),
babl_type_from_id (BABL_HALF),
- babl_component_from_id (BABL_LUMA),
+ babl_component_from_id (BABL_GRAY_NONLINEAR),
babl_component_from_id (BABL_ALPHA),
NULL);
babl_format_new (
- babl_model_from_id (BABL_GRAY_GAMMA_2_2_ALPHA_PREMULTIPLIED),
+ babl_model_from_id (BABL_MODEL_GRAY_NONLINEAR_ALPHA_PREMULTIPLIED),
babl_type_from_id (BABL_HALF),
- babl_component_from_id (BABL_LUMA_MUL_ALPHA),
+ babl_component_from_id (BABL_GRAY_NONLINEAR_MUL_ALPHA),
babl_component_from_id (BABL_ALPHA),
NULL);
babl_format_new (
- babl_model_from_id (BABL_GRAY_GAMMA_2_2),
+ babl_model_from_id (BABL_MODEL_GRAY_NONLINEAR),
babl_type_from_id (BABL_HALF),
- babl_component_from_id (BABL_LUMA),
+ babl_component_from_id (BABL_GRAY_NONLINEAR),
NULL);
/***********/
babl_format_new (
babl_model_from_id (BABL_GRAY_ALPHA),
babl_type ("u15"),
- babl_component_from_id (BABL_LUMINANCE),
+ babl_component_from_id (BABL_GRAY_LINEAR),
babl_component_from_id (BABL_ALPHA),
NULL);
babl_format_new (
babl_model_from_id (BABL_GRAY_ALPHA_PREMULTIPLIED),
babl_type ("u15"),
- babl_component_from_id (BABL_LUMINANCE_MUL_ALPHA),
+ babl_component_from_id (BABL_GRAY_LINEAR_MUL_ALPHA),
babl_component_from_id (BABL_ALPHA),
NULL);
babl_format_new (
babl_model_from_id (BABL_GRAY),
babl_type ("u15"),
- babl_component_from_id (BABL_LUMINANCE),
+ babl_component_from_id (BABL_GRAY_LINEAR),
NULL);
babl_format_new (
- babl_model_from_id (BABL_GRAY_GAMMA_2_2_ALPHA),
+ babl_model_from_id (BABL_MODEL_GRAY_NONLINEAR_ALPHA),
babl_type ("u15"),
- babl_component_from_id (BABL_LUMA),
+ babl_component_from_id (BABL_GRAY_NONLINEAR),
babl_component_from_id (BABL_ALPHA),
NULL);
babl_format_new (
- babl_model_from_id (BABL_GRAY_GAMMA_2_2_ALPHA_PREMULTIPLIED),
+ babl_model_from_id (BABL_MODEL_GRAY_NONLINEAR_ALPHA_PREMULTIPLIED),
babl_type ("u15"),
- babl_component_from_id (BABL_LUMA_MUL_ALPHA),
+ babl_component_from_id (BABL_GRAY_NONLINEAR_MUL_ALPHA),
babl_component_from_id (BABL_ALPHA),
NULL);
babl_format_new (
- babl_model_from_id (BABL_GRAY_GAMMA_2_2),
+ babl_model_from_id (BABL_MODEL_GRAY_NONLINEAR),
babl_type ("u15"),
- babl_component_from_id (BABL_LUMA),
+ babl_component_from_id (BABL_GRAY_NONLINEAR),
NULL);
babl_format_new (
babl_model_from_id (BABL_GRAY_ALPHA),
babl_type_from_id (BABL_U32),
- babl_component_from_id (BABL_LUMINANCE),
+ babl_component_from_id (BABL_GRAY_LINEAR),
babl_component_from_id (BABL_ALPHA),
NULL);
babl_format_new (
babl_model_from_id (BABL_GRAY_ALPHA_PREMULTIPLIED),
babl_type_from_id (BABL_U32),
- babl_component_from_id (BABL_LUMINANCE_MUL_ALPHA),
+ babl_component_from_id (BABL_GRAY_LINEAR_MUL_ALPHA),
babl_component_from_id (BABL_ALPHA),
NULL);
babl_format_new (
babl_model_from_id (BABL_GRAY),
babl_type_from_id (BABL_U32),
- babl_component_from_id (BABL_LUMINANCE),
+ babl_component_from_id (BABL_GRAY_LINEAR),
NULL);
babl_format_new (
- babl_model_from_id (BABL_GRAY_GAMMA_2_2_ALPHA),
+ babl_model_from_id (BABL_MODEL_GRAY_NONLINEAR_ALPHA),
babl_type_from_id (BABL_U32),
- babl_component_from_id (BABL_LUMA),
+ babl_component_from_id (BABL_GRAY_NONLINEAR),
babl_component_from_id (BABL_ALPHA),
NULL);
babl_format_new (
- babl_model_from_id (BABL_GRAY_GAMMA_2_2_ALPHA_PREMULTIPLIED),
+ babl_model_from_id (BABL_MODEL_GRAY_NONLINEAR_ALPHA_PREMULTIPLIED),
babl_type_from_id (BABL_U32),
- babl_component_from_id (BABL_LUMA_MUL_ALPHA),
+ babl_component_from_id (BABL_GRAY_NONLINEAR_MUL_ALPHA),
babl_component_from_id (BABL_ALPHA),
NULL);
babl_format_new (
- babl_model_from_id (BABL_GRAY_GAMMA_2_2),
+ babl_model_from_id (BABL_MODEL_GRAY_NONLINEAR),
babl_type_from_id (BABL_U32),
- babl_component_from_id (BABL_LUMA),
+ babl_component_from_id (BABL_GRAY_NONLINEAR),
NULL);
}
diff --git a/babl/base/model-rgb.c b/babl/base/model-rgb.c
index 7da204f..66e16ab 100644
--- a/babl/base/model-rgb.c
+++ b/babl/base/model-rgb.c
@@ -13,14 +13,14 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdlib.h>
#include <math.h>
-#include "babl.h"
+#include "babl-internal.h"
#include "babl-classes.h"
#include "babl-ids.h"
#include "babl-base.h"
@@ -66,42 +66,84 @@ components (void)
babl_component_new (
"R'",
- "id", BABL_RED_GAMMA_2_2,
+ "id", BABL_RED_NONLINEAR,
"luma",
"chroma",
NULL);
babl_component_new (
"G'",
- "id", BABL_GREEN_GAMMA_2_2,
+ "id", BABL_GREEN_NONLINEAR,
"luma",
"chroma",
NULL);
babl_component_new (
"B'",
- "id", BABL_BLUE_GAMMA_2_2,
+ "id", BABL_BLUE_NONLINEAR,
+ "luma",
+ "chroma",
+ NULL);
+
+ babl_component_new (
+ "R~",
+ "id", BABL_RED_PERCEPTUAL,
+ "luma",
+ "chroma",
+ NULL);
+
+ babl_component_new (
+ "G~",
+ "id", BABL_GREEN_PERCEPTUAL,
+ "luma",
+ "chroma",
+ NULL);
+
+ babl_component_new (
+ "B~",
+ "id", BABL_BLUE_PERCEPTUAL,
"luma",
"chroma",
NULL);
babl_component_new (
"R'a",
- "id", BABL_RED_GAMMA_2_2_MUL_ALPHA,
+ "id", BABL_RED_NONLINEAR_MUL_ALPHA,
"luma",
"chroma",
NULL);
babl_component_new (
"G'a",
- "id", BABL_GREEN_GAMMA_2_2_MUL_ALPHA,
+ "id", BABL_GREEN_NONLINEAR_MUL_ALPHA,
"luma",
"chroma",
NULL);
babl_component_new (
"B'a",
- "id", BABL_BLUE_GAMMA_2_2_MUL_ALPHA,
+ "id", BABL_BLUE_NONLINEAR_MUL_ALPHA,
+ "luma",
+ "chroma",
+ NULL);
+
+ babl_component_new (
+ "R~a",
+ "id", BABL_RED_PERCEPTUAL_MUL_ALPHA,
+ "luma",
+ "chroma",
+ NULL);
+
+ babl_component_new (
+ "G~a",
+ "id", BABL_GREEN_PERCEPTUAL_MUL_ALPHA,
+ "luma",
+ "chroma",
+ NULL);
+
+ babl_component_new (
+ "B~a",
+ "id", BABL_BLUE_PERCEPTUAL_MUL_ALPHA,
"luma",
"chroma",
NULL);
@@ -126,25 +168,48 @@ models (void)
NULL);
babl_model_new (
- "id", BABL_RGB_GAMMA_2_2,
- babl_component_from_id (BABL_RED_GAMMA_2_2),
- babl_component_from_id (BABL_GREEN_GAMMA_2_2),
- babl_component_from_id (BABL_BLUE_GAMMA_2_2),
+ "id", BABL_RGB_NONLINEAR,
+ babl_component_from_id (BABL_RED_NONLINEAR),
+ babl_component_from_id (BABL_GREEN_NONLINEAR),
+ babl_component_from_id (BABL_BLUE_NONLINEAR),
+ NULL);
+
+ babl_model_new (
+ "id", BABL_RGB_PERCEPTUAL,
+ babl_component_from_id (BABL_RED_PERCEPTUAL),
+ babl_component_from_id (BABL_GREEN_PERCEPTUAL),
+ babl_component_from_id (BABL_BLUE_PERCEPTUAL),
+ NULL);
+
+ babl_model_new (
+ "id", BABL_RGBA_NONLINEAR,
+ babl_component_from_id (BABL_RED_NONLINEAR),
+ babl_component_from_id (BABL_GREEN_NONLINEAR),
+ babl_component_from_id (BABL_BLUE_NONLINEAR),
+ babl_component_from_id (BABL_ALPHA),
NULL);
babl_model_new (
- "id", BABL_RGBA_GAMMA_2_2,
- babl_component_from_id (BABL_RED_GAMMA_2_2),
- babl_component_from_id (BABL_GREEN_GAMMA_2_2),
- babl_component_from_id (BABL_BLUE_GAMMA_2_2),
+ "id", BABL_RGBA_PERCEPTUAL,
+ babl_component_from_id (BABL_RED_PERCEPTUAL),
+ babl_component_from_id (BABL_GREEN_PERCEPTUAL),
+ babl_component_from_id (BABL_BLUE_PERCEPTUAL),
babl_component_from_id (BABL_ALPHA),
NULL);
babl_model_new (
- "id", BABL_RGBA_GAMMA_2_2_PREMULTIPLIED,
- babl_component_from_id (BABL_RED_GAMMA_2_2_MUL_ALPHA),
- babl_component_from_id (BABL_GREEN_GAMMA_2_2_MUL_ALPHA),
- babl_component_from_id (BABL_BLUE_GAMMA_2_2_MUL_ALPHA),
+ "id", BABL_RGBA_NONLINEAR_PREMULTIPLIED,
+ babl_component_from_id (BABL_RED_NONLINEAR_MUL_ALPHA),
+ babl_component_from_id (BABL_GREEN_NONLINEAR_MUL_ALPHA),
+ babl_component_from_id (BABL_BLUE_NONLINEAR_MUL_ALPHA),
+ babl_component_from_id (BABL_ALPHA),
+ NULL);
+
+ babl_model_new (
+ "id", BABL_RGBA_PERCEPTUAL_PREMULTIPLIED,
+ babl_component_from_id (BABL_RED_PERCEPTUAL_MUL_ALPHA),
+ babl_component_from_id (BABL_GREEN_PERCEPTUAL_MUL_ALPHA),
+ babl_component_from_id (BABL_BLUE_PERCEPTUAL_MUL_ALPHA),
babl_component_from_id (BABL_ALPHA),
NULL);
}
@@ -181,14 +246,14 @@ copy_strip_1 (Babl *conversion,
}
static void
-g3_gamma_2_2 (Babl *conversion,
- int src_bands,
- char **src,
- int *src_pitch,
- int dst_bands,
- char **dst,
- int *dst_pitch,
- long samples)
+g3_nonlinear_from_linear (Babl *conversion,
+ int src_bands,
+ char **src,
+ int *src_pitch,
+ int dst_bands,
+ char **dst,
+ int *dst_pitch,
+ long samples)
{
const Babl *space = babl_conversion_get_destination_space (conversion);
const Babl **trc = (void*)space->space.trc;
@@ -208,16 +273,15 @@ g3_gamma_2_2 (Babl *conversion,
}
}
-
static void
-g3_inv_gamma_2_2 (Babl *conversion,
- int src_bands,
- char **src,
- int *src_pitch,
- int dst_bands,
- char **dst,
- int *dst_pitch,
- long samples)
+g3_nonlinear_to_linear (Babl *conversion,
+ int src_bands,
+ char **src,
+ int *src_pitch,
+ int dst_bands,
+ char **dst,
+ int *dst_pitch,
+ long samples)
{
const Babl *space = babl_conversion_get_source_space (conversion);
const Babl **trc = (void*)space->space.trc;
@@ -309,7 +373,7 @@ premultiplied_to_non_premultiplied (Babl *conversion,
static void
-rgba2rgba_gamma_2_2_premultiplied (Babl *conversion,
+rgba2rgba_nonlinear_premultiplied (Babl *conversion,
char *src,
char *dst,
long samples)
@@ -332,7 +396,7 @@ rgba2rgba_gamma_2_2_premultiplied (Babl *conversion,
static void
-rgba_gamma_2_2_premultiplied2rgba (Babl *conversion,
+rgba_nonlinear_premultiplied2rgba (Babl *conversion,
char *src,
char *dst,
long samples)
@@ -365,7 +429,7 @@ rgba_gamma_2_2_premultiplied2rgba (Babl *conversion,
static void
-rgba2rgba_gamma_2_2 (Babl *conversion,
+rgba2rgba_nonlinear (Babl *conversion,
char *src,
char *dst,
long samples)
@@ -388,7 +452,7 @@ rgba2rgba_gamma_2_2 (Babl *conversion,
static void
-rgba_gamma_2_22rgba (Babl *conversion,
+rgba_nonlinear2rgba (Babl *conversion,
char *src,
char *dst,
long samples)
@@ -410,9 +474,171 @@ rgba_gamma_2_22rgba (Babl *conversion,
}
}
+
+static const Babl *perceptual_trc = NULL;
+
+static void
+g3_perceptual_from_linear (Babl *conversion,
+ int src_bands,
+ char **src,
+ int *src_pitch,
+ int dst_bands,
+ char **dst,
+ int *dst_pitch,
+ long samples)
+{
+ const Babl *trc = perceptual_trc;
+
+ long n = samples;
+
+ BABL_PLANAR_SANITY
+ while (n--)
+ {
+ int band;
+ for (band = 0; band < 3; band++)
+ *(double *) dst[band] = babl_trc_from_linear (trc, (*(double *) src[band]));
+ for (; band < dst_bands; band++)
+ *(double *) dst[band] = *(double *) src[band];
+
+ BABL_PLANAR_STEP
+ }
+}
+
+static void
+g3_perceptual_to_linear (Babl *conversion,
+ int src_bands,
+ char **src,
+ int *src_pitch,
+ int dst_bands,
+ char **dst,
+ int *dst_pitch,
+ long samples)
+{
+ const Babl *trc = perceptual_trc;
+ long n = samples;
+
+ BABL_PLANAR_SANITY
+ while (n--)
+ {
+ int band;
+ for (band = 0; band < 3; band++)
+ {
+ *(double *) dst[band] = babl_trc_to_linear (trc, (*(double *) src[band]));
+ }
+ for (; band < dst_bands; band++)
+ {
+ if (band < src_bands)
+ *(double *) dst[band] = *(double *) src[band];
+ else
+ *(double *) dst[band] = 1.0;
+ }
+ BABL_PLANAR_STEP
+ }
+}
+
+static void
+rgba2rgba_perceptual_premultiplied (Babl *conversion,
+ char *src,
+ char *dst,
+ long samples)
+{
+ const Babl *trc = perceptual_trc;
+ long n = samples;
+
+ while (n--)
+ {
+ double alpha = ((double *) src)[3];
+ ((double *) dst)[0] = babl_trc_from_linear (trc, ((double *) src)[0]) * alpha;
+ ((double *) dst)[1] = babl_trc_from_linear (trc, ((double *) src)[1]) * alpha;
+ ((double *) dst)[2] = babl_trc_from_linear (trc, ((double *) src)[2]) * alpha;
+ ((double *) dst)[3] = alpha;
+ src += 4 * sizeof (double);
+ dst += 4 * sizeof (double);
+ }
+}
+
+
+static void
+rgba_perceptual_premultiplied2rgba (Babl *conversion,
+ char *src,
+ char *dst,
+ long samples)
+{
+ const Babl *trc = perceptual_trc;
+ long n = samples;
+
+ while (n--)
+ {
+ double alpha = ((double *) src)[3];
+ if (alpha > BABL_ALPHA_THRESHOLD)
+ {
+ ((double *) dst)[0] = babl_trc_to_linear (trc, ((double *) src)[0] / alpha);
+ ((double *) dst)[1] = babl_trc_to_linear (trc, ((double *) src)[1] / alpha);
+ ((double *) dst)[2] = babl_trc_to_linear (trc, ((double *) src)[2] / alpha);
+ }
+ else
+ {
+ ((double *) dst)[0] = 0.0;
+ ((double *) dst)[1] = 0.0;
+ ((double *) dst)[2] = 0.0;
+ }
+ ((double *) dst)[3] = alpha;
+
+ src += 4 * sizeof (double);
+ dst += 4 * sizeof (double);
+ }
+}
+
+
+static void
+rgba2rgba_perceptual (Babl *conversion,
+ char *src,
+ char *dst,
+ long samples)
+{
+ const Babl *trc = perceptual_trc;
+ long n = samples;
+
+ while (n--)
+ {
+ double alpha = ((double *) src)[3];
+ ((double *) dst)[0] = babl_trc_from_linear (trc, ((double *) src)[0]);
+ ((double *) dst)[1] = babl_trc_from_linear (trc, ((double *) src)[1]);
+ ((double *) dst)[2] = babl_trc_from_linear (trc, ((double *) src)[2]);
+ ((double *) dst)[3] = alpha;
+ src += 4 * sizeof (double);
+ dst += 4 * sizeof (double);
+ }
+}
+
+static void
+rgba_perceptual2rgba (Babl *conversion,
+ char *src,
+ char *dst,
+ long samples)
+{
+ const Babl *trc = perceptual_trc;
+ long n = samples;
+
+ while (n--)
+ {
+ double alpha = ((double *) src)[3];
+ ((double *) dst)[0] = babl_trc_to_linear (trc, ((double *) src)[0]);
+ ((double *) dst)[1] = babl_trc_to_linear (trc, ((double *) src)[1]);
+ ((double *) dst)[2] = babl_trc_to_linear (trc, ((double *) src)[2]);
+ ((double *) dst)[3] = alpha;
+
+ src += 4 * sizeof (double);
+ dst += 4 * sizeof (double);
+ }
+}
+
static void
conversions (void)
{
+ if (!perceptual_trc)
+ perceptual_trc = babl_trc ("sRGB");
+
babl_conversion_new (
babl_model_from_id (BABL_RGBA),
babl_model_from_id (BABL_RGBA),
@@ -451,37 +677,73 @@ conversions (void)
babl_conversion_new (
babl_model_from_id (BABL_RGBA),
- babl_model_from_id (BABL_RGB_GAMMA_2_2),
- "planar", g3_gamma_2_2,
+ babl_model_from_id (BABL_RGB_NONLINEAR),
+ "planar", g3_nonlinear_from_linear,
+ NULL
+ );
+ babl_conversion_new (
+ babl_model_from_id (BABL_RGB_NONLINEAR),
+ babl_model_from_id (BABL_RGBA),
+ "planar", g3_nonlinear_to_linear,
+ NULL
+ );
+
+ babl_conversion_new (
+ babl_model_from_id (BABL_RGBA),
+ babl_model_from_id (BABL_RGBA_NONLINEAR),
+ "linear", rgba2rgba_nonlinear,
+ NULL);
+ babl_conversion_new (
+ babl_model_from_id (BABL_RGBA_NONLINEAR),
+ babl_model_from_id (BABL_RGBA),
+ "linear", rgba_nonlinear2rgba,
+ NULL);
+
+ babl_conversion_new (
+ babl_model_from_id (BABL_RGBA),
+ babl_model_from_id (BABL_RGBA_NONLINEAR_PREMULTIPLIED),
+ "linear", rgba2rgba_nonlinear_premultiplied,
+ NULL);
+ babl_conversion_new (
+ babl_model_from_id (BABL_RGBA_NONLINEAR_PREMULTIPLIED),
+ babl_model_from_id (BABL_RGBA),
+ "linear", rgba_nonlinear_premultiplied2rgba,
+ NULL);
+//////////
+
+ babl_conversion_new (
+ babl_model_from_id (BABL_RGBA),
+ babl_model_from_id (BABL_RGB_PERCEPTUAL),
+ "planar", g3_perceptual_from_linear,
NULL
);
babl_conversion_new (
- babl_model_from_id (BABL_RGB_GAMMA_2_2),
+ babl_model_from_id (BABL_RGB_PERCEPTUAL),
babl_model_from_id (BABL_RGBA),
- "planar", g3_inv_gamma_2_2,
+ "planar", g3_perceptual_to_linear,
NULL
);
babl_conversion_new (
babl_model_from_id (BABL_RGBA),
- babl_model_from_id (BABL_RGBA_GAMMA_2_2),
- "linear", rgba2rgba_gamma_2_2,
+ babl_model_from_id (BABL_RGBA_PERCEPTUAL),
+ "linear", rgba2rgba_perceptual,
NULL);
babl_conversion_new (
- babl_model_from_id (BABL_RGBA_GAMMA_2_2),
+ babl_model_from_id (BABL_RGBA_PERCEPTUAL),
babl_model_from_id (BABL_RGBA),
- "linear", rgba_gamma_2_22rgba,
+ "linear", rgba_perceptual2rgba,
NULL);
babl_conversion_new (
babl_model_from_id (BABL_RGBA),
- babl_model_from_id (BABL_RGBA_GAMMA_2_2_PREMULTIPLIED),
- "linear", rgba2rgba_gamma_2_2_premultiplied,
+ babl_model_from_id (BABL_RGBA_PERCEPTUAL_PREMULTIPLIED),
+ "linear", rgba2rgba_perceptual_premultiplied,
NULL);
babl_conversion_new (
- babl_model_from_id (BABL_RGBA_GAMMA_2_2_PREMULTIPLIED),
+ babl_model_from_id (BABL_RGBA_PERCEPTUAL_PREMULTIPLIED),
babl_model_from_id (BABL_RGBA),
- "linear", rgba_gamma_2_2_premultiplied2rgba,
+ "linear", rgba_perceptual_premultiplied2rgba,
NULL);
}
@@ -490,20 +752,36 @@ formats (void)
{
babl_format_new (
"id", BABL_SRGB,
- babl_model_from_id (BABL_RGB_GAMMA_2_2),
+ babl_model_from_id (BABL_RGB_PERCEPTUAL),
+ babl_type_from_id (BABL_U8),
+ babl_component_from_id (BABL_RED_PERCEPTUAL),
+ babl_component_from_id (BABL_GREEN_PERCEPTUAL),
+ babl_component_from_id (BABL_BLUE_PERCEPTUAL),
+ NULL);
+
+ babl_format_new (
+ babl_model_from_id (BABL_RGB_NONLINEAR),
babl_type_from_id (BABL_U8),
- babl_component_from_id (BABL_RED_GAMMA_2_2),
- babl_component_from_id (BABL_GREEN_GAMMA_2_2),
- babl_component_from_id (BABL_BLUE_GAMMA_2_2),
+ babl_component_from_id (BABL_RED_NONLINEAR),
+ babl_component_from_id (BABL_GREEN_NONLINEAR),
+ babl_component_from_id (BABL_BLUE_NONLINEAR),
NULL);
babl_format_new (
- "id", BABL_SRGBA,
- babl_model_from_id (BABL_RGBA_GAMMA_2_2),
+ babl_model_from_id (BABL_RGBA_NONLINEAR),
babl_type_from_id (BABL_U8),
- babl_component_from_id (BABL_RED_GAMMA_2_2),
- babl_component_from_id (BABL_GREEN_GAMMA_2_2),
- babl_component_from_id (BABL_BLUE_GAMMA_2_2),
+ babl_component_from_id (BABL_RED_NONLINEAR),
+ babl_component_from_id (BABL_GREEN_NONLINEAR),
+ babl_component_from_id (BABL_BLUE_NONLINEAR),
+ babl_component_from_id (BABL_ALPHA),
+ NULL);
+
+ babl_format_new (
+ babl_model_from_id (BABL_RGBA_PERCEPTUAL),
+ babl_type_from_id (BABL_U8),
+ babl_component_from_id (BABL_RED_PERCEPTUAL),
+ babl_component_from_id (BABL_GREEN_PERCEPTUAL),
+ babl_component_from_id (BABL_BLUE_PERCEPTUAL),
babl_component_from_id (BABL_ALPHA),
NULL);
@@ -555,28 +833,54 @@ formats (void)
NULL);
babl_format_new (
- babl_model_from_id (BABL_RGB_GAMMA_2_2),
+ babl_model_from_id (BABL_RGB_NONLINEAR),
babl_type_from_id (BABL_HALF),
- babl_component_from_id (BABL_RED_GAMMA_2_2),
- babl_component_from_id (BABL_GREEN_GAMMA_2_2),
- babl_component_from_id (BABL_BLUE_GAMMA_2_2),
+ babl_component_from_id (BABL_RED_NONLINEAR),
+ babl_component_from_id (BABL_GREEN_NONLINEAR),
+ babl_component_from_id (BABL_BLUE_NONLINEAR),
NULL);
babl_format_new (
- babl_model_from_id (BABL_RGBA_GAMMA_2_2),
+ babl_model_from_id (BABL_RGBA_NONLINEAR),
babl_type_from_id (BABL_HALF),
- babl_component_from_id (BABL_RED_GAMMA_2_2),
- babl_component_from_id (BABL_GREEN_GAMMA_2_2),
- babl_component_from_id (BABL_BLUE_GAMMA_2_2),
+ babl_component_from_id (BABL_RED_NONLINEAR),
+ babl_component_from_id (BABL_GREEN_NONLINEAR),
+ babl_component_from_id (BABL_BLUE_NONLINEAR),
babl_component_from_id (BABL_ALPHA),
NULL);
babl_format_new (
- babl_model_from_id (BABL_RGBA_GAMMA_2_2_PREMULTIPLIED),
+ babl_model_from_id (BABL_RGBA_NONLINEAR_PREMULTIPLIED),
babl_type_from_id (BABL_HALF),
- babl_component_from_id (BABL_RED_GAMMA_2_2_MUL_ALPHA),
- babl_component_from_id (BABL_GREEN_GAMMA_2_2_MUL_ALPHA),
- babl_component_from_id (BABL_BLUE_GAMMA_2_2_MUL_ALPHA),
+ babl_component_from_id (BABL_RED_NONLINEAR_MUL_ALPHA),
+ babl_component_from_id (BABL_GREEN_NONLINEAR_MUL_ALPHA),
+ babl_component_from_id (BABL_BLUE_NONLINEAR_MUL_ALPHA),
+ babl_component_from_id (BABL_ALPHA),
+ NULL);
+
+ babl_format_new (
+ babl_model_from_id (BABL_RGB_PERCEPTUAL),
+ babl_type_from_id (BABL_HALF),
+ babl_component_from_id (BABL_RED_PERCEPTUAL),
+ babl_component_from_id (BABL_GREEN_PERCEPTUAL),
+ babl_component_from_id (BABL_BLUE_PERCEPTUAL),
+ NULL);
+
+ babl_format_new (
+ babl_model_from_id (BABL_RGBA_PERCEPTUAL),
+ babl_type_from_id (BABL_HALF),
+ babl_component_from_id (BABL_RED_PERCEPTUAL),
+ babl_component_from_id (BABL_GREEN_PERCEPTUAL),
+ babl_component_from_id (BABL_BLUE_PERCEPTUAL),
+ babl_component_from_id (BABL_ALPHA),
+ NULL);
+
+ babl_format_new (
+ babl_model_from_id (BABL_RGBA_PERCEPTUAL_PREMULTIPLIED),
+ babl_type_from_id (BABL_HALF),
+ babl_component_from_id (BABL_RED_PERCEPTUAL_MUL_ALPHA),
+ babl_component_from_id (BABL_GREEN_PERCEPTUAL_MUL_ALPHA),
+ babl_component_from_id (BABL_BLUE_PERCEPTUAL_MUL_ALPHA),
babl_component_from_id (BABL_ALPHA),
NULL);
@@ -608,28 +912,28 @@ formats (void)
NULL);
babl_format_new (
- babl_model_from_id (BABL_RGB_GAMMA_2_2),
+ babl_model_from_id (BABL_RGB_NONLINEAR),
babl_type ("u15"),
- babl_component_from_id (BABL_RED_GAMMA_2_2),
- babl_component_from_id (BABL_GREEN_GAMMA_2_2),
- babl_component_from_id (BABL_BLUE_GAMMA_2_2),
+ babl_component_from_id (BABL_RED_NONLINEAR),
+ babl_component_from_id (BABL_GREEN_NONLINEAR),
+ babl_component_from_id (BABL_BLUE_NONLINEAR),
NULL);
babl_format_new (
- babl_model_from_id (BABL_RGBA_GAMMA_2_2),
+ babl_model_from_id (BABL_RGBA_NONLINEAR),
babl_type ("u15"),
- babl_component_from_id (BABL_RED_GAMMA_2_2),
- babl_component_from_id (BABL_GREEN_GAMMA_2_2),
- babl_component_from_id (BABL_BLUE_GAMMA_2_2),
+ babl_component_from_id (BABL_RED_NONLINEAR),
+ babl_component_from_id (BABL_GREEN_NONLINEAR),
+ babl_component_from_id (BABL_BLUE_NONLINEAR),
babl_component_from_id (BABL_ALPHA),
NULL);
babl_format_new (
- babl_model_from_id (BABL_RGBA_GAMMA_2_2_PREMULTIPLIED),
+ babl_model_from_id (BABL_RGBA_NONLINEAR_PREMULTIPLIED),
babl_type ("u15"),
- babl_component_from_id (BABL_RED_GAMMA_2_2_MUL_ALPHA),
- babl_component_from_id (BABL_GREEN_GAMMA_2_2_MUL_ALPHA),
- babl_component_from_id (BABL_BLUE_GAMMA_2_2_MUL_ALPHA),
+ babl_component_from_id (BABL_RED_NONLINEAR_MUL_ALPHA),
+ babl_component_from_id (BABL_GREEN_NONLINEAR_MUL_ALPHA),
+ babl_component_from_id (BABL_BLUE_NONLINEAR_MUL_ALPHA),
babl_component_from_id (BABL_ALPHA),
NULL);
@@ -661,28 +965,55 @@ formats (void)
NULL);
babl_format_new (
- babl_model_from_id (BABL_RGB_GAMMA_2_2),
+ babl_model_from_id (BABL_RGB_NONLINEAR),
+ babl_type_from_id (BABL_U32),
+ babl_component_from_id (BABL_RED_NONLINEAR),
+ babl_component_from_id (BABL_GREEN_NONLINEAR),
+ babl_component_from_id (BABL_BLUE_NONLINEAR),
+ NULL);
+
+ babl_format_new (
+ babl_model_from_id (BABL_RGBA_NONLINEAR),
+ babl_type_from_id (BABL_U32),
+ babl_component_from_id (BABL_RED_NONLINEAR),
+ babl_component_from_id (BABL_GREEN_NONLINEAR),
+ babl_component_from_id (BABL_BLUE_NONLINEAR),
+ babl_component_from_id (BABL_ALPHA),
+ NULL);
+
+ babl_format_new (
+ babl_model_from_id (BABL_RGBA_NONLINEAR_PREMULTIPLIED),
+ babl_type_from_id (BABL_U32),
+ babl_component_from_id (BABL_RED_NONLINEAR_MUL_ALPHA),
+ babl_component_from_id (BABL_GREEN_NONLINEAR_MUL_ALPHA),
+ babl_component_from_id (BABL_BLUE_NONLINEAR_MUL_ALPHA),
+ babl_component_from_id (BABL_ALPHA),
+ NULL);
+
+
+ babl_format_new (
+ babl_model_from_id (BABL_RGB_PERCEPTUAL),
babl_type_from_id (BABL_U32),
- babl_component_from_id (BABL_RED_GAMMA_2_2),
- babl_component_from_id (BABL_GREEN_GAMMA_2_2),
- babl_component_from_id (BABL_BLUE_GAMMA_2_2),
+ babl_component_from_id (BABL_RED_PERCEPTUAL),
+ babl_component_from_id (BABL_GREEN_PERCEPTUAL),
+ babl_component_from_id (BABL_BLUE_PERCEPTUAL),
NULL);
babl_format_new (
- babl_model_from_id (BABL_RGBA_GAMMA_2_2),
+ babl_model_from_id (BABL_RGBA_PERCEPTUAL),
babl_type_from_id (BABL_U32),
- babl_component_from_id (BABL_RED_GAMMA_2_2),
- babl_component_from_id (BABL_GREEN_GAMMA_2_2),
- babl_component_from_id (BABL_BLUE_GAMMA_2_2),
+ babl_component_from_id (BABL_RED_PERCEPTUAL),
+ babl_component_from_id (BABL_GREEN_PERCEPTUAL),
+ babl_component_from_id (BABL_BLUE_PERCEPTUAL),
babl_component_from_id (BABL_ALPHA),
NULL);
babl_format_new (
- babl_model_from_id (BABL_RGBA_GAMMA_2_2_PREMULTIPLIED),
+ babl_model_from_id (BABL_RGBA_PERCEPTUAL_PREMULTIPLIED),
babl_type_from_id (BABL_U32),
- babl_component_from_id (BABL_RED_GAMMA_2_2_MUL_ALPHA),
- babl_component_from_id (BABL_GREEN_GAMMA_2_2_MUL_ALPHA),
- babl_component_from_id (BABL_BLUE_GAMMA_2_2_MUL_ALPHA),
+ babl_component_from_id (BABL_RED_PERCEPTUAL_MUL_ALPHA),
+ babl_component_from_id (BABL_GREEN_PERCEPTUAL_MUL_ALPHA),
+ babl_component_from_id (BABL_BLUE_PERCEPTUAL_MUL_ALPHA),
babl_component_from_id (BABL_ALPHA),
NULL);
diff --git a/babl/base/model-ycbcr.c b/babl/base/model-ycbcr.c
index 6b34d20..1d6acb7 100644
--- a/babl/base/model-ycbcr.c
+++ b/babl/base/model-ycbcr.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
@@ -63,14 +63,14 @@ models (void)
{
babl_model_new (
"id", BABL_YCBCR,
- babl_component_from_id (BABL_LUMA),
+ babl_component_from_id (BABL_GRAY_NONLINEAR),
babl_component_from_id (BABL_CB),
babl_component_from_id (BABL_CR),
NULL);
babl_model_new (
"id", BABL_YCBCR_ALPHA,
- babl_component_from_id (BABL_LUMA),
+ babl_component_from_id (BABL_GRAY_NONLINEAR),
babl_component_from_id (BABL_CB),
babl_component_from_id (BABL_CR),
babl_component_from_id (BABL_ALPHA),
@@ -245,7 +245,7 @@ formats (void)
babl_model_from_id (BABL_YCBCR),
babl_type_from_id (BABL_U8_LUMA),
babl_sampling (1, 1),
- babl_component_from_id (BABL_LUMA),
+ babl_component_from_id (BABL_GRAY_NONLINEAR),
babl_type_from_id (BABL_U8_CHROMA),
babl_sampling (2, 2),
babl_component_from_id (BABL_CB),
@@ -263,7 +263,7 @@ if (0)
babl_model_from_id (BABL_YCBCR),
babl_type_from_id (BABL_U8_LUMA),
babl_sampling (1, 1),
- babl_component_from_id (BABL_LUMA),
+ babl_component_from_id (BABL_GRAY_NONLINEAR),
babl_type_from_id (BABL_U8_CHROMA),
babl_sampling (2, 2),
babl_component_from_id (BABL_CB),
@@ -279,7 +279,7 @@ if (0)
babl_model_from_id (BABL_YCBCR),
babl_type_from_id (BABL_U8_LUMA),
babl_sampling (1, 1),
- babl_component_from_id (BABL_LUMA),
+ babl_component_from_id (BABL_GRAY_NONLINEAR),
babl_type_from_id (BABL_U8_CHROMA),
babl_sampling (2, 1),
babl_component_from_id (BABL_CB),
@@ -294,7 +294,7 @@ if (0)
babl_model_from_id (BABL_YCBCR),
babl_type_from_id (BABL_U8_LUMA),
babl_sampling (1, 1),
- babl_component_from_id (BABL_LUMA),
+ babl_component_from_id (BABL_GRAY_NONLINEAR),
babl_type_from_id (BABL_U8_CHROMA),
babl_sampling (4, 1),
babl_component_from_id (BABL_CB),
diff --git a/babl/base/pow-24.c b/babl/base/pow-24.c
index 4587bf1..f691458 100644
--- a/babl/base/pow-24.c
+++ b/babl/base/pow-24.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include <math.h>
diff --git a/babl/base/pow-24.h b/babl/base/pow-24.h
index 3ea6984..ecd1282 100644
--- a/babl/base/pow-24.h
+++ b/babl/base/pow-24.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BASE_POW_24_H
diff --git a/babl/base/type-float.c b/babl/base/type-float.c
index 709c7fa..750d836 100644
--- a/babl/base/type-float.c
+++ b/babl/base/type-float.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/babl/base/type-u15.c b/babl/base/type-u15.c
index 355f875..1f1efe0 100644
--- a/babl/base/type-u15.c
+++ b/babl/base/type-u15.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/babl/base/type-u16.c b/babl/base/type-u16.c
index 4a7c8f1..104bdf4 100644
--- a/babl/base/type-u16.c
+++ b/babl/base/type-u16.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/babl/base/type-u32.c b/babl/base/type-u32.c
index 66a5654..3757925 100644
--- a/babl/base/type-u32.c
+++ b/babl/base/type-u32.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/babl/base/type-u8.c b/babl/base/type-u8.c
index d17590d..3d79229 100644
--- a/babl/base/type-u8.c
+++ b/babl/base/type-u8.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/babl/base/util.h b/babl/base/util.h
index 50bba74..b30c935 100644
--- a/babl/base/util.h
+++ b/babl/base/util.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _BASE_UTIL_H
diff --git a/configure b/configure
index 127978a..ab4121e 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.50.
+# Generated by GNU Autoconf 2.69 for babl 0.1.54.
#
#
# 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.50'
-PACKAGE_STRING='babl 0.1.50'
+PACKAGE_VERSION='0.1.54'
+PACKAGE_STRING='babl 0.1.54'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
@@ -1383,7 +1383,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.50 to adapt to many kinds of systems.
+\`configure' configures babl 0.1.54 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1455,7 +1455,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of babl 0.1.50:";;
+ short | recursive ) echo "Configuration of babl 0.1.54:";;
esac
cat <<\_ACEOF
@@ -1576,7 +1576,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-babl configure 0.1.50
+babl configure 0.1.54
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1941,7 +1941,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.50, which was
+It was created by babl $as_me 0.1.54, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -2297,11 +2297,11 @@ ac_config_headers="$ac_config_headers config.h"
BABL_MAJOR_VERSION=0
BABL_MINOR_VERSION=1
-BABL_MICRO_VERSION=50
+BABL_MICRO_VERSION=54
BABL_INTERFACE_AGE=1
-BABL_BINARY_AGE=150
-BABL_VERSION=0.1.50
-BABL_REAL_VERSION=0.1.50
+BABL_BINARY_AGE=154
+BABL_VERSION=0.1.54
+BABL_REAL_VERSION=0.1.54
BABL_API_VERSION=0.1
@@ -2336,7 +2336,7 @@ fi
-BABL_LIBRARY_VERSION="149:1:149"
+BABL_LIBRARY_VERSION="153:1:153"
BABL_CURRENT_MINUS_AGE=0
@@ -2968,7 +2968,7 @@ fi
# Define the identity of the package.
PACKAGE='babl'
- VERSION='0.1.50'
+ VERSION='0.1.54'
# Some tools Automake needs.
@@ -13170,41 +13170,8 @@ $as_echo "$extra_warnings_works" >&6; }
CFLAGS="$CFLAGS $extra_warnings"
-
- extra_warnings=
- for flag in '-Ofast' ; do
- if test -z "$extra_warnings"; then
- extra_warnings_save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $flag"
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands $flag" >&5
-$as_echo_n "checking whether $CC understands $flag... " >&6; }
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- extra_warnings_works=yes
-else
- extra_warnings_works=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $extra_warnings_works" >&5
-$as_echo "$extra_warnings_works" >&6; }
- CFLAGS="$extra_warnings_save_CFLAGS"
- if test "x$extra_warnings_works" = "xyes"; then
- extra_warnings="$flag"
- fi
- fi
- done
-
-CFLAGS="$CFLAGS $extra_warnings"
+#BABL_DETECT_CFLAGS(extra_warnings, '-Ofast' )
+#CFLAGS="$CFLAGS $extra_warnings"
fi
@@ -14983,7 +14950,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.50, which was
+This file was extended by babl $as_me 0.1.54, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -15049,7 +15016,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.50
+babl config.status 0.1.54
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/configure.ac b/configure.ac
index d05560f..187cede 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], [50])
+m4_define([babl_micro_version], [54])
m4_define([babl_real_version],
[babl_major_version.babl_minor_version.babl_micro_version])
m4_define([babl_version], [babl_real_version])
@@ -161,8 +161,8 @@ CFLAGS="$CFLAGS $extra_warnings"
BABL_DETECT_CFLAGS(extra_warnings, '-Wold-style-definition')
CFLAGS="$CFLAGS $extra_warnings"
-BABL_DETECT_CFLAGS(extra_warnings, '-Ofast' )
-CFLAGS="$CFLAGS $extra_warnings"
+#BABL_DETECT_CFLAGS(extra_warnings, '-Ofast' )
+#CFLAGS="$CFLAGS $extra_warnings"
fi
diff --git a/docs/COPYING b/docs/COPYING
index 94a9ed0..76525e7 100644
--- a/docs/COPYING
+++ b/docs/COPYING
@@ -645,7 +645,7 @@ the "copyright" line and a pointer to where the full notice is found.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
@@ -664,7 +664,7 @@ might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
-<http://www.gnu.org/licenses/>.
+<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
diff --git a/export-symbols b/export-symbols
index 301acce..476238e 100644
--- a/export-symbols
+++ b/export-symbols
@@ -14,6 +14,7 @@ babl_format_get_model
babl_format_get_n_components
babl_format_get_space
babl_format_get_type
+babl_format_get_encoding
babl_format_has_alpha
babl_format_is_format_n
babl_format_is_palette
@@ -25,12 +26,12 @@ 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_is
+babl_model_with_space
babl_model_new
babl_new_palette
babl_palette_reset
@@ -40,13 +41,23 @@ babl_process_rows
babl_sampling
babl_set_user_data
babl_space
-babl_space_from_xyz
+babl_space_from_rgbxyz_matrix
+babl_space_from_chromaticities
+babl_space_from_icc
+babl_space_get
babl_space_get_rgbtoxyz
+babl_space_get_icc
babl_space_to_xyz
+babl_space_from_xyz
+babl_space_to_icc
+babl_space_with_trc
+babl_icc_make_space
+babl_icc_get_key
babl_ticks
babl_type
babl_type_new
-babl_space_to_icc
+babl_trc
+babl_trc_gamma
babl_db_exist_by_name
babl_db_find
babl_db_init
diff --git a/extensions/CIE.c b/extensions/CIE.c
index b93b055..b96e124 100644
--- a/extensions/CIE.c
+++ b/extensions/CIE.c
@@ -16,7 +16,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
@@ -1124,6 +1124,85 @@ lab_r_to_f_sse2 (__m128 r)
}
static void
+Yf_to_Lf_sse2 (const Babl *conversion, const float *src, float *dst, long samples)
+{
+ long i = 0;
+ long remainder;
+
+ if (((uintptr_t) src % 16) + ((uintptr_t) dst % 16) == 0)
+ {
+ const long n = (samples / 4) * 4;
+
+ for ( ; i < n; i += 4)
+ {
+ __m128 Y = _mm_load_ps (src);
+
+ __m128 fy = lab_r_to_f_sse2 (Y);
+
+ __m128 L = _mm_sub_ps (_mm_mul_ps (_mm_set1_ps (116.0f), fy), _mm_set1_ps (16.0f));
+
+ _mm_store_ps (dst, L);
+
+ src += 4;
+ dst += 4;
+ }
+ }
+
+ remainder = samples - i;
+ while (remainder--)
+ {
+ float yr = src[0];
+ float L = yr > LAB_EPSILON ? 116.0f * _cbrtf (yr) - 16 : LAB_KAPPA * yr;
+
+ dst[0] = L;
+
+ src++;
+ dst++;
+ }
+}
+
+static void
+Yaf_to_Lf_sse2 (const Babl *conversion, const float *src, float *dst, long samples)
+{
+ long i = 0;
+ long remainder;
+
+ if (((uintptr_t) src % 16) + ((uintptr_t) dst % 16) == 0)
+ {
+ const long n = (samples / 4) * 4;
+
+ for ( ; i < n; i += 4)
+ {
+ __m128 YaYa0 = _mm_load_ps (src);
+ __m128 YaYa1 = _mm_load_ps (src + 4);
+
+ __m128 Y = _mm_shuffle_ps (YaYa0, YaYa1, _MM_SHUFFLE (2, 0, 2, 0));
+
+ __m128 fy = lab_r_to_f_sse2 (Y);
+
+ __m128 L = _mm_sub_ps (_mm_mul_ps (_mm_set1_ps (116.0f), fy), _mm_set1_ps (16.0f));
+
+ _mm_store_ps (dst, L);
+
+ src += 8;
+ dst += 4;
+ }
+ }
+
+ remainder = samples - i;
+ while (remainder--)
+ {
+ float yr = src[0];
+ float L = yr > LAB_EPSILON ? 116.0f * _cbrtf (yr) - 16 : LAB_KAPPA * yr;
+
+ dst[0] = L;
+
+ src += 2;
+ dst += 1;
+ }
+}
+
+static void
rgbaf_to_Lf_sse2 (const Babl *conversion, const float *src, float *dst, long samples)
{
const Babl *space = babl_conversion_get_source_space (conversion);
@@ -1474,7 +1553,18 @@ conversions (void)
"linear", rgbaf_to_Labaf_sse2,
NULL
);
-
+ babl_conversion_new (
+ babl_format ("Y float"),
+ babl_format ("CIE L float"),
+ "linear", Yf_to_Lf_sse2,
+ NULL
+ );
+ babl_conversion_new (
+ babl_format ("YA float"),
+ babl_format ("CIE L float"),
+ "linear", Yaf_to_Lf_sse2,
+ NULL
+ );
babl_conversion_new (
babl_format ("RGBA float"),
babl_format ("CIE L float"),
diff --git a/extensions/HCY.c b/extensions/HCY.c
index 82b1d69..e78d704 100644
--- a/extensions/HCY.c
+++ b/extensions/HCY.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
/*
diff --git a/extensions/HSL.c b/extensions/HSL.c
index 88f8705..76d263b 100644
--- a/extensions/HSL.c
+++ b/extensions/HSL.c
@@ -12,7 +12,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/extensions/HSV.c b/extensions/HSV.c
index f4bf01f..f486981 100644
--- a/extensions/HSV.c
+++ b/extensions/HSV.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
/*
diff --git a/extensions/cairo.c b/extensions/cairo.c
index b296751..77607c5 100644
--- a/extensions/cairo.c
+++ b/extensions/cairo.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
diff --git a/extensions/double.c b/extensions/double.c
index 98a3351..87b7e3b 100644
--- a/extensions/double.c
+++ b/extensions/double.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/extensions/fast-float.c b/extensions/fast-float.c
index b0b7dba..4162204 100644
--- a/extensions/fast-float.c
+++ b/extensions/fast-float.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/extensions/float.c b/extensions/float.c
index d700b14..bce0de7 100644
--- a/extensions/float.c
+++ b/extensions/float.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
@@ -26,8 +26,10 @@
#include "extensions/util.h"
#include "base/util.h"
+static const Babl *trc_srgb = NULL;
+
static void
-conv_rgbaF_linear_rgbAF_gamma (const Babl *conversion,unsigned char *src,
+conv_rgbaF_linear_rgbAF_nonlinear (const Babl *conversion,unsigned char *src,
unsigned char *dst,
long samples)
{
@@ -49,10 +51,30 @@ conv_rgbaF_linear_rgbAF_gamma (const Babl *conversion,unsigned char *src,
}
static void
-conv_rgbAF_linear_rgbAF_gamma (const Babl *conversion,
- unsigned char *src,
- unsigned char *dst,
- long samples)
+conv_rgbaF_linear_rgbAF_perceptual (const Babl *conversion,unsigned char *src,
+ unsigned char *dst,
+ long samples)
+{
+ float *fsrc = (float *) src;
+ float *fdst = (float *) dst;
+ int n = samples;
+
+ while (n--)
+ {
+ float alpha = fsrc[3];
+ *fdst++ = babl_trc_from_linear (trc_srgb, *fsrc++) * alpha;
+ *fdst++ = babl_trc_from_linear (trc_srgb, *fsrc++) * alpha;
+ *fdst++ = babl_trc_from_linear (trc_srgb, *fsrc++) * alpha;
+ *fdst++ = *fsrc++;
+ }
+}
+
+
+static void
+conv_rgbAF_linear_rgbAF_nonlinear (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;
@@ -91,9 +113,50 @@ conv_rgbAF_linear_rgbAF_gamma (const Babl *conversion,
}
static void
-conv_rgbaF_linear_rgbaF_gamma (const Babl *conversion,unsigned char *src,
- unsigned char *dst,
- long samples)
+conv_rgbAF_linear_rgbAF_perceptual (const Babl *conversion,
+ unsigned char *src,
+ unsigned char *dst,
+ long samples)
+{
+
+ float *fsrc = (float *) src;
+ float *fdst = (float *) dst;
+ int n = samples;
+
+ while (n--)
+ {
+ float alpha = fsrc[3];
+ if (alpha < BABL_ALPHA_THRESHOLD)
+ {
+ *fdst++ = 0.0;
+ *fdst++ = 0.0;
+ *fdst++ = 0.0;
+ *fdst++ = 0.0;
+ fsrc+=4;
+ }
+ else if (alpha >= 1.0)
+ {
+ *fdst++ = babl_trc_from_linear (trc_srgb, *fsrc++) * alpha;
+ *fdst++ = babl_trc_from_linear (trc_srgb, *fsrc++) * alpha;
+ *fdst++ = babl_trc_from_linear (trc_srgb, *fsrc++) * alpha;
+ *fdst++ = *fsrc++;
+ }
+ else
+ {
+ float alpha_recip = 1.0 / alpha;
+ *fdst++ = babl_trc_from_linear (trc_srgb, *fsrc++ * alpha_recip) * alpha;
+ *fdst++ = babl_trc_from_linear (trc_srgb, *fsrc++ * alpha_recip) * alpha;
+ *fdst++ = babl_trc_from_linear (trc_srgb, *fsrc++ * alpha_recip) * alpha;
+ *fdst++ = *fsrc++;
+ }
+ }
+}
+
+
+static void
+conv_rgbaF_linear_rgbaF_nonlinear (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;
@@ -112,9 +175,28 @@ conv_rgbaF_linear_rgbaF_gamma (const Babl *conversion,unsigned char *src,
}
static void
-conv_rgbF_linear_rgbF_gamma (const Babl *conversion,unsigned char *src,
- unsigned char *dst,
- long samples)
+conv_rgbaF_linear_rgbaF_perceptual (const Babl *conversion,unsigned char *src,
+ unsigned char *dst,
+ long samples)
+{
+ float *fsrc = (float *) src;
+ float *fdst = (float *) dst;
+ int n = samples;
+
+ while (n--)
+ {
+ *fdst++ = babl_trc_from_linear (trc_srgb, *fsrc++);
+ *fdst++ = babl_trc_from_linear (trc_srgb, *fsrc++);
+ *fdst++ = babl_trc_from_linear (trc_srgb, *fsrc++);
+ *fdst++ = *fsrc++;
+ }
+}
+
+
+static void
+conv_rgbF_linear_rgbF_nonlinear (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;
@@ -130,11 +212,28 @@ conv_rgbF_linear_rgbF_gamma (const Babl *conversion,unsigned char *src,
}
}
+static void
+conv_rgbF_linear_rgbF_perceptual (const Babl *conversion,unsigned char *src,
+ unsigned char *dst,
+ long samples)
+{
+ float *fsrc = (float *) src;
+ float *fdst = (float *) dst;
+ int n = samples;
+
+ while (n--)
+ {
+ *fdst++ = babl_trc_from_linear (trc_srgb, *fsrc++);
+ *fdst++ = babl_trc_from_linear (trc_srgb, *fsrc++);
+ *fdst++ = babl_trc_from_linear (trc_srgb, *fsrc++);
+ }
+}
+
static void
-conv_rgbaF_gamma_rgbaF_linear (const Babl *conversion,unsigned char *src,
- unsigned char *dst,
- long samples)
+conv_rgbaF_nonlinear_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;
@@ -152,9 +251,28 @@ conv_rgbaF_gamma_rgbaF_linear (const Babl *conversion,unsigned char *src,
}
static void
-conv_rgbF_gamma_rgbF_linear (const Babl *conversion,unsigned char *src,
- unsigned char *dst,
- long samples)
+conv_rgbaF_perceptual_rgbaF_linear (const Babl *conversion,unsigned char *src,
+ unsigned char *dst,
+ long samples)
+{
+ float *fsrc = (float *) src;
+ float *fdst = (float *) dst;
+ int n = samples;
+
+ while (n--)
+ {
+ *fdst++ = babl_trc_to_linear (trc_srgb, *fsrc++);
+ *fdst++ = babl_trc_to_linear (trc_srgb, *fsrc++);
+ *fdst++ = babl_trc_to_linear (trc_srgb, *fsrc++);
+ *fdst++ = *fsrc++;
+ }
+}
+
+
+static void
+conv_rgbF_nonlinear_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;
@@ -170,6 +288,24 @@ conv_rgbF_gamma_rgbF_linear (const Babl *conversion,unsigned char *src,
}
}
+static void
+conv_rgbF_perceptual_rgbF_linear (const Babl *conversion,unsigned char *src,
+ unsigned char *dst,
+ long samples)
+{
+ float *fsrc = (float *) src;
+ float *fdst = (float *) dst;
+ int n = samples;
+
+ while (n--)
+ {
+ *fdst++ = babl_trc_to_linear (trc_srgb, *fsrc++);
+ *fdst++ = babl_trc_to_linear (trc_srgb, *fsrc++);
+ *fdst++ = babl_trc_to_linear (trc_srgb, *fsrc++);
+ }
+}
+
+
#define o(src, dst) \
babl_conversion_new (src, dst, "linear", conv_ ## src ## _ ## dst, NULL)
@@ -194,7 +330,7 @@ init (void)
babl_component ("Ba"),
babl_component ("A"),
NULL);
- const Babl *rgbaF_gamma = babl_format_new (
+ const Babl *rgbaF_nonlinear = babl_format_new (
babl_model ("R'G'B'A"),
babl_type ("float"),
babl_component ("R'"),
@@ -202,7 +338,15 @@ init (void)
babl_component ("B'"),
babl_component ("A"),
NULL);
- const Babl *rgbAF_gamma = babl_format_new (
+ const Babl *rgbaF_perceptual = babl_format_new (
+ babl_model ("R~G~B~A"),
+ babl_type ("float"),
+ babl_component ("R~"),
+ babl_component ("G~"),
+ babl_component ("B~"),
+ babl_component ("A"),
+ NULL);
+ const Babl *rgbAF_nonlinear = babl_format_new (
babl_model ("R'aG'aB'aA"),
babl_type ("float"),
babl_component ("R'a"),
@@ -210,6 +354,14 @@ init (void)
babl_component ("B'a"),
babl_component ("A"),
NULL);
+ const Babl *rgbAF_perceptual = babl_format_new (
+ babl_model ("R~aG~aB~aA"),
+ babl_type ("float"),
+ babl_component ("R~a"),
+ babl_component ("G~a"),
+ babl_component ("B~a"),
+ babl_component ("A"),
+ NULL);
const Babl *rgbF_linear = babl_format_new (
babl_model ("RGB"),
babl_type ("float"),
@@ -217,20 +369,35 @@ init (void)
babl_component ("G"),
babl_component ("B"),
NULL);
- const Babl *rgbF_gamma = babl_format_new (
+ const Babl *rgbF_nonlinear = babl_format_new (
babl_model ("R'G'B'"),
babl_type ("float"),
babl_component ("R'"),
babl_component ("G'"),
babl_component ("B'"),
NULL);
+ const Babl *rgbF_perceptual = babl_format_new (
+ babl_model ("R~G~B~"),
+ babl_type ("float"),
+ babl_component ("R~"),
+ babl_component ("G~"),
+ babl_component ("B~"),
+ NULL);
+ trc_srgb = babl_trc("sRGB");
+
+ o (rgbAF_linear, rgbAF_nonlinear);
+ o (rgbaF_linear, rgbAF_nonlinear);
+ o (rgbaF_linear, rgbaF_nonlinear);
+ o (rgbaF_nonlinear, rgbaF_linear);
+ o (rgbF_linear, rgbF_nonlinear);
+ o (rgbF_nonlinear, rgbF_linear);
- o (rgbAF_linear, rgbAF_gamma);
- o (rgbaF_linear, rgbAF_gamma);
- o (rgbaF_linear, rgbaF_gamma);
- o (rgbaF_gamma, rgbaF_linear);
- o (rgbF_linear, rgbF_gamma);
- o (rgbF_gamma, rgbF_linear);
+ o (rgbAF_linear, rgbAF_perceptual);
+ o (rgbaF_linear, rgbAF_perceptual);
+ o (rgbaF_linear, rgbaF_perceptual);
+ o (rgbaF_perceptual, rgbaF_linear);
+ o (rgbF_linear, rgbF_perceptual);
+ o (rgbF_perceptual, rgbF_linear);
return 0;
}
diff --git a/extensions/gegl-fixups.c b/extensions/gegl-fixups.c
index 1fbb2bd..d866154 100644
--- a/extensions/gegl-fixups.c
+++ b/extensions/gegl-fixups.c
@@ -14,7 +14,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with GGGL; if not, see <http://www.gnu.org/licenses/>.
+ * along with GGGL; if not, see <https://www.gnu.org/licenses/>.
*
* Rights are granted to use this shared object in libraries covered by
* LGPL. (exception added, during import into babl CVS.)
diff --git a/extensions/gggl-lies.c b/extensions/gggl-lies.c
index c08dccd..02b3139 100644
--- a/extensions/gggl-lies.c
+++ b/extensions/gggl-lies.c
@@ -15,7 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with GGGL; if not, see <http://www.gnu.org/licenses/>.
+ * along with GGGL; if not, see <https://www.gnu.org/licenses/>.
*
* Rights are granted to use this shared object in libraries covered by
* LGPL. (exception added, during import into babl CVS.)
diff --git a/extensions/gggl-table-lies.c b/extensions/gggl-table-lies.c
index 88da9b6..5cca68d 100644
--- a/extensions/gggl-table-lies.c
+++ b/extensions/gggl-table-lies.c
@@ -15,7 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with GGGL; if not, see <http://www.gnu.org/licenses/>.
+ * along with GGGL; if not, see <https://www.gnu.org/licenses/>.
*
* Rights are granted to use this shared object in libraries covered by
* LGPL. (exception added, during import into babl CVS.)
diff --git a/extensions/gggl-table.c b/extensions/gggl-table.c
index 37d68dc..039ef2e 100644
--- a/extensions/gggl-table.c
+++ b/extensions/gggl-table.c
@@ -13,7 +13,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with GGGL; if not, see <http://www.gnu.org/licenses/>.
+ * along with GGGL; if not, see <https://www.gnu.org/licenses/>.
*
* Rights are granted to use this shared object in libraries covered by
* LGPL. (exception added, during import into babl CVS.)
diff --git a/extensions/gggl.c b/extensions/gggl.c
index 200caa3..1b0fed4 100644
--- a/extensions/gggl.c
+++ b/extensions/gggl.c
@@ -13,7 +13,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with GGGL; if not, see <http://www.gnu.org/licenses/>.
+ * along with GGGL; if not, see <https://www.gnu.org/licenses/>.
*
* Rights are granted to use this shared object in libraries covered by
* LGPL. (exception added, during import into babl CVS.)
diff --git a/extensions/gimp-8bit.c b/extensions/gimp-8bit.c
index a994298..000ce0e 100644
--- a/extensions/gimp-8bit.c
+++ b/extensions/gimp-8bit.c
@@ -16,7 +16,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/extensions/grey.c b/extensions/grey.c
index 8989fe5..6afcedb 100644
--- a/extensions/grey.c
+++ b/extensions/grey.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/extensions/half.c b/extensions/half.c
index c45ea85..1342f78 100644
--- a/extensions/half.c
+++ b/extensions/half.c
@@ -14,7 +14,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
/* Copyright: (c) 2009 by James Tursa, All Rights Reserved
diff --git a/extensions/naive-CMYK.c b/extensions/naive-CMYK.c
index ce76c4b..3b7a70c 100644
--- a/extensions/naive-CMYK.c
+++ b/extensions/naive-CMYK.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/extensions/sse-half.c b/extensions/sse-half.c
index 9f0dfe4..4b57392 100644
--- a/extensions/sse-half.c
+++ b/extensions/sse-half.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/extensions/sse2-float.c b/extensions/sse2-float.c
index 800ac97..6e7aaf1 100644
--- a/extensions/sse2-float.c
+++ b/extensions/sse2-float.c
@@ -15,7 +15,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/extensions/sse2-int16.c b/extensions/sse2-int16.c
index 24815b3..e7b870e 100644
--- a/extensions/sse2-int16.c
+++ b/extensions/sse2-int16.c
@@ -14,7 +14,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/extensions/sse2-int8.c b/extensions/sse2-int8.c
index d8bd187..246b251 100644
--- a/extensions/sse2-int8.c
+++ b/extensions/sse2-int8.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/extensions/sse4-int8.c b/extensions/sse4-int8.c
index 0eb0846..b74a7c6 100644
--- a/extensions/sse4-int8.c
+++ b/extensions/sse4-int8.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/extensions/two-table.c b/extensions/two-table.c
index 4b263cc..3202e69 100644
--- a/extensions/two-table.c
+++ b/extensions/two-table.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
@@ -203,6 +203,8 @@ init (void)
char *testchar = (char*) &testint;
int littleendian = (testchar[0] == 23);
+ return 0; // temporarily disable, it is interfering with space invasion
+
if (littleendian)
{
const Babl *f24 = babl_format_new (
diff --git a/extensions/u16.c b/extensions/u16.c
index ad0a35a..4cd37f7 100644
--- a/extensions/u16.c
+++ b/extensions/u16.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
@@ -76,6 +76,13 @@ init (void)
NULL);
babl_conversion_new (
+ babl_format ("R~G~B~ u16"),
+ babl_format ("R~G~B~A u16"),
+ "linear",
+ conv_rgbu16_rgbau16,
+ NULL);
+
+ babl_conversion_new (
babl_format ("Y' u16"),
babl_format ("Y'A u16"),
"linear",
@@ -83,6 +90,13 @@ init (void)
NULL);
babl_conversion_new (
+ babl_format ("Y~ u16"),
+ babl_format ("Y~A u16"),
+ "linear",
+ conv_yu16_yau16,
+ NULL);
+
+ babl_conversion_new (
babl_format ("RGB u16"),
babl_format ("RGBA u16"),
"linear",
diff --git a/extensions/u32.c b/extensions/u32.c
index 5e378cb..1f2148f 100644
--- a/extensions/u32.c
+++ b/extensions/u32.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
@@ -204,6 +204,18 @@ init (void)
conv_rgbu32_rgbu16,
NULL);
babl_conversion_new (
+ babl_format ("R~G~B~A u32"),
+ babl_format ("R~G~B~A u16"),
+ "linear",
+ conv_rgbau32_rgbau16,
+ NULL);
+ babl_conversion_new (
+ babl_format ("R~G~B~ u32"),
+ babl_format ("R~G~B~ u16"),
+ "linear",
+ conv_rgbu32_rgbu16,
+ NULL);
+ babl_conversion_new (
babl_format ("RGB u32"),
babl_format ("RGB u16"),
"linear",
@@ -216,6 +228,12 @@ init (void)
conv_rgbu16_rgbu32,
NULL);
babl_conversion_new (
+ babl_format ("R~G~B~ u16"),
+ babl_format ("R~G~B~ u32"),
+ "linear",
+ conv_rgbu16_rgbu32,
+ NULL);
+ babl_conversion_new (
babl_format ("RGB u16"),
babl_format ("RGB u32"),
"linear",
@@ -270,7 +288,18 @@ init (void)
"linear",
conv_rgb32_rgba32,
NULL);
-
+ babl_conversion_new (
+ babl_format ("R~G~B~A u32"),
+ babl_format ("R~G~B~ u32"),
+ "linear",
+ conv_rgba32_rgb32,
+ NULL);
+ babl_conversion_new (
+ babl_format ("R~G~B~ u32"),
+ babl_format ("R~G~B~A u32"),
+ "linear",
+ conv_rgb32_rgba32,
+ NULL);
babl_conversion_new (
babl_format ("Y u32"),
babl_format ("Y u16"),
@@ -284,6 +313,12 @@ init (void)
conv_u32_u16,
NULL);
babl_conversion_new (
+ babl_format ("Y~ u32"),
+ babl_format ("Y~ u16"),
+ "linear",
+ conv_u32_u16,
+ NULL);
+ babl_conversion_new (
babl_format ("Y u16"),
babl_format ("Y u32"),
"linear",
@@ -295,7 +330,12 @@ init (void)
"linear",
conv_u16_u32,
NULL);
-
+ babl_conversion_new (
+ babl_format ("Y~ u16"),
+ babl_format ("Y~ u32"),
+ "linear",
+ conv_u16_u32,
+ NULL);
babl_conversion_new (
babl_format ("YA u32"),
@@ -315,6 +355,13 @@ init (void)
"linear",
conv_yau32_yau16,
NULL);
+
+ babl_conversion_new (
+ babl_format ("Y~A u32"),
+ babl_format ("Y~A u16"),
+ "linear",
+ conv_yau32_yau16,
+ NULL);
babl_conversion_new (
babl_format ("Y'aA u32"),
babl_format ("Y'aA u16"),
@@ -339,14 +386,19 @@ init (void)
"linear",
conv_yau16_yau32,
NULL);
+
+ babl_conversion_new (
+ babl_format ("Y~A u16"),
+ babl_format ("Y~A u32"),
+ "linear",
+ conv_yau16_yau32,
+ NULL);
babl_conversion_new (
babl_format ("Y'aA u16"),
babl_format ("Y'aA u32"),
"linear",
conv_yau16_yau32,
NULL);
-
-
babl_conversion_new (
babl_format ("Y u32"),
babl_format ("YA u32"),
@@ -366,6 +418,12 @@ init (void)
conv_yu32_yau32,
NULL);
babl_conversion_new (
+ babl_format ("Y~ u32"),
+ babl_format ("Y~A u32"),
+ "linear",
+ conv_yu32_yau32,
+ NULL);
+ babl_conversion_new (
babl_format ("Y' u32"),
babl_format ("Y'aA u32"),
"linear",
diff --git a/extensions/util.h b/extensions/util.h
index cb872f8..d4d48ac 100644
--- a/extensions/util.h
+++ b/extensions/util.h
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#ifndef _UTIL_H
diff --git a/extensions/ycbcr.c b/extensions/ycbcr.c
index 5da49cb..200aa78 100644
--- a/extensions/ycbcr.c
+++ b/extensions/ycbcr.c
@@ -12,7 +12,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 98f4ae2..3f4af72 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -17,7 +17,8 @@ C_TESTS = \
float-to-8bit \
hsl \
hsva \
- types \
+ types \
+ format_with_space \
palette \
extract \
nop \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 983c454..489f95c 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -111,10 +111,10 @@ am__EXEEXT_2 = grayscale_to_rgb$(EXEEXT) chromaticities$(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) \
- n_components$(EXEEXT) n_components_cast$(EXEEXT) \
- models$(EXEEXT) cairo-RGB24$(EXEEXT) transparent$(EXEEXT) \
- $(am__EXEEXT_1)
+ types$(EXEEXT) format_with_space$(EXEEXT) palette$(EXEEXT) \
+ extract$(EXEEXT) nop$(EXEEXT) n_components$(EXEEXT) \
+ n_components_cast$(EXEEXT) models$(EXEEXT) \
+ cairo-RGB24$(EXEEXT) transparent$(EXEEXT) $(am__EXEEXT_1)
PROGRAMS = $(noinst_PROGRAMS)
babl_class_name_SOURCES = babl_class_name.c
babl_class_name_OBJECTS = babl_class_name.$(OBJEXT)
@@ -163,6 +163,12 @@ floatclamp_LDADD = $(LDADD)
floatclamp_DEPENDENCIES = \
$(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+format_with_space_SOURCES = format_with_space.c
+format_with_space_OBJECTS = format_with_space.$(OBJEXT)
+format_with_space_LDADD = $(LDADD)
+format_with_space_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)
@@ -289,16 +295,16 @@ am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
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
+ floatclamp.c format_with_space.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_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
+ floatclamp.c format_with_space.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 = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
@@ -698,7 +704,8 @@ C_TESTS = \
float-to-8bit \
hsl \
hsva \
- types \
+ types \
+ format_with_space \
palette \
extract \
nop \
@@ -787,6 +794,10 @@ floatclamp$(EXEEXT): $(floatclamp_OBJECTS) $(floatclamp_DEPENDENCIES) $(EXTRA_fl
@rm -f floatclamp$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(floatclamp_OBJECTS) $(floatclamp_LDADD) $(LIBS)
+format_with_space$(EXEEXT): $(format_with_space_OBJECTS) $(format_with_space_DEPENDENCIES) $(EXTRA_format_with_space_DEPENDENCIES)
+ @rm -f format_with_space$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(format_with_space_OBJECTS) $(format_with_space_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)
@@ -860,6 +871,7 @@ distclean-compile:
@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)/format_with_space.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@
@@ -1187,6 +1199,13 @@ types.log: types$(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)
+format_with_space.log: format_with_space$(EXEEXT)
+ @p='format_with_space$(EXEEXT)'; \
+ b='format_with_space'; \
+ $(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)
palette.log: palette$(EXEEXT)
@p='palette$(EXEEXT)'; \
b='palette'; \
diff --git a/tests/babl_class_name.c b/tests/babl_class_name.c
index 8a7bab1..c0724f0 100644
--- a/tests/babl_class_name.c
+++ b/tests/babl_class_name.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/tests/cairo-RGB24.c b/tests/cairo-RGB24.c
index a50eca1..31367f7 100644
--- a/tests/cairo-RGB24.c
+++ b/tests/cairo-RGB24.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/tests/chromaticities.c b/tests/chromaticities.c
index 2c8364a..a57cead 100644
--- a/tests/chromaticities.c
+++ b/tests/chromaticities.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/tests/concurrency-stress-test.c b/tests/concurrency-stress-test.c
index 7832c23..a02a519 100644
--- a/tests/concurrency-stress-test.c
+++ b/tests/concurrency-stress-test.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
diff --git a/tests/extract.c b/tests/extract.c
index f27662b..ffd9f5c 100644
--- a/tests/extract.c
+++ b/tests/extract.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/tests/float-to-8bit.c b/tests/float-to-8bit.c
index a93591c..1a3cafc 100644
--- a/tests/float-to-8bit.c
+++ b/tests/float-to-8bit.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/tests/floatclamp.c b/tests/floatclamp.c
index 4ba7992..7960e13 100644
--- a/tests/floatclamp.c
+++ b/tests/floatclamp.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/tests/format_with_space.c b/tests/format_with_space.c
new file mode 100644
index 0000000..34f5332
--- /dev/null
+++ b/tests/format_with_space.c
@@ -0,0 +1,109 @@
+/* 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
+ * <https://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+#include <math.h>
+#include "babl-internal.h"
+
+static int
+test2 (void)
+{
+ int OK = 1;
+ const Babl *sRGB = babl_space ("sRGB");
+ const Babl *fmt;
+
+ fmt = babl_format ("R'G'B' u8");
+ if (babl_format_get_space (fmt) != sRGB)
+ {
+ babl_log ("created space %s doesn't have sRGB when it should", babl_get_name (fmt));
+ OK = 0;
+ }
+ fmt = babl_format_with_space ("R'G'B' u8", NULL);
+ if (babl_format_get_space (fmt) != sRGB)
+ {
+ babl_log ("created space %s doesn't have sRGB when it should", babl_get_name (fmt));
+ OK = 0;
+ }
+ fmt = babl_format_with_space ("R'G'B' u8", sRGB);
+ if (babl_format_get_space (fmt) != sRGB)
+ {
+ babl_log ("created space %s doesn't have sRGB when it should", babl_get_name (fmt));
+ OK = 0;
+ }
+ fmt = babl_format_with_space ("CIE Lab float", sRGB);
+ if (babl_format_get_space (fmt) != sRGB)
+ {
+ babl_log ("created space %s doesn't have sRGB when it should", babl_get_name (fmt));
+ OK = 0;
+ }
+
+ if (!OK)
+ return -1;
+ return 0;
+}
+
+static int
+test3 (void)
+{
+ int OK = 1;
+ const Babl *apple = babl_space ("Apple");
+ const Babl *sRGB = babl_space ("sRGB");
+ const Babl *fmt;
+
+ fmt = babl_format ("R'G'B' u8");
+ if (babl_format_get_space (fmt) != sRGB)
+ {
+ babl_log ("created space %s doesn't have sRGB when it should", babl_get_name (fmt));
+ OK = 0;
+ }
+ fmt = babl_format_with_space ("R'G'B' u8", NULL);
+ if (babl_format_get_space (fmt) != sRGB)
+ {
+ babl_log ("created space %s doesn't have sRGB when it should", babl_get_name (fmt));
+ OK = 0;
+ }
+ fmt = babl_format_with_space ("R'G'B' u8", apple);
+ if (babl_format_get_space (fmt) != apple)
+ {
+ babl_log ("created space %s doesn't have apple when it should", babl_get_name (fmt));
+ OK = 0;
+ }
+ fmt = babl_format_with_space ("CIE Lab float", apple);
+ if (babl_format_get_space (fmt) != apple)
+ {
+ babl_log ("created space %s doesn't have apple when it should", babl_get_name (fmt));
+ OK = 0;
+ }
+
+ if (!OK)
+ return -1;
+ return 0;
+}
+
+int
+main (int argc,
+ char **argv)
+{
+ babl_init ();
+ if (test2 ())
+ return -1;
+ if (test3 ())
+ return -1;
+ babl_exit ();
+ return 0;
+}
diff --git a/tests/grayscale_to_rgb.c b/tests/grayscale_to_rgb.c
index b59da38..c3ec7c7 100644
--- a/tests/grayscale_to_rgb.c
+++ b/tests/grayscale_to_rgb.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/tests/hsl.c b/tests/hsl.c
index ab71747..0457c7f 100644
--- a/tests/hsl.c
+++ b/tests/hsl.c
@@ -12,7 +12,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include <stdio.h>
diff --git a/tests/hsva.c b/tests/hsva.c
index 6e1fbbb..66b93b8 100644
--- a/tests/hsva.c
+++ b/tests/hsva.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
/*
diff --git a/tests/n_components.c b/tests/n_components.c
index 0d62e7d..afe5d25 100644
--- a/tests/n_components.c
+++ b/tests/n_components.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
diff --git a/tests/n_components_cast.c b/tests/n_components_cast.c
index 4bb7d29..86c6437 100644
--- a/tests/n_components_cast.c
+++ b/tests/n_components_cast.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/tests/nop.c b/tests/nop.c
index 7d79dc4..0ea6fe0 100644
--- a/tests/nop.c
+++ b/tests/nop.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/tests/palette-concurrency-stress-test.c b/tests/palette-concurrency-stress-test.c
index 869cd90..a42b15d 100644
--- a/tests/palette-concurrency-stress-test.c
+++ b/tests/palette-concurrency-stress-test.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
diff --git a/tests/palette.c b/tests/palette.c
index ce21cf6..abf4756 100644
--- a/tests/palette.c
+++ b/tests/palette.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/tests/rgb_to_bgr.c b/tests/rgb_to_bgr.c
index 60fee1f..4e63222 100644
--- a/tests/rgb_to_bgr.c
+++ b/tests/rgb_to_bgr.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
diff --git a/tests/rgb_to_ycbcr.c b/tests/rgb_to_ycbcr.c
index 49ddee3..c02f743 100644
--- a/tests/rgb_to_ycbcr.c
+++ b/tests/rgb_to_ycbcr.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
diff --git a/tests/sanity.c b/tests/sanity.c
index d0141c8..28158ee 100644
--- a/tests/sanity.c
+++ b/tests/sanity.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/tests/srgb_to_lab_u8.c b/tests/srgb_to_lab_u8.c
index 8585645..8974660 100644
--- a/tests/srgb_to_lab_u8.c
+++ b/tests/srgb_to_lab_u8.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/tests/transparent.c b/tests/transparent.c
index 6ab64f4..7cbc6ea 100644
--- a/tests/transparent.c
+++ b/tests/transparent.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
/* Verify that conversion of fully-transparent pixels preserves color
diff --git a/tools/babl-benchmark.c b/tools/babl-benchmark.c
index 1f1f90c..e7cec51 100644
--- a/tools/babl-benchmark.c
+++ b/tools/babl-benchmark.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/tools/babl-gen-test-pixels.c b/tools/babl-gen-test-pixels.c
index 12b8040..9d4492e 100644
--- a/tools/babl-gen-test-pixels.c
+++ b/tools/babl-gen-test-pixels.c
@@ -14,7 +14,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
@@ -182,7 +182,7 @@ int main (int argc, char **argv)
" *\n"
" * You should have received a copy of the GNU Lesser General\n"
" * Public License along with this library; if not, see\n"
- " * <http://www.gnu.org/licenses/>.\n"
+ " * <https://www.gnu.org/licenses/>.\n"
" */\n"
"\n");
diff --git a/tools/babl-html-dump.c b/tools/babl-html-dump.c
index 4c01611..4f59b4d 100644
--- a/tools/babl-html-dump.c
+++ b/tools/babl-html-dump.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*
*/
diff --git a/tools/babl-icc-rewrite.c b/tools/babl-icc-rewrite.c
index bc83b25..e91499a 100644
--- a/tools/babl-icc-rewrite.c
+++ b/tools/babl-icc-rewrite.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"
diff --git a/tools/introspect.c b/tools/introspect.c
index b52ed9f..5cd667f 100644
--- a/tools/introspect.c
+++ b/tools/introspect.c
@@ -13,7 +13,7 @@
*
* 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/>.
+ * <https://www.gnu.org/licenses/>.
*/
#include "config.h"