aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore21
-rw-r--r--COPYING674
-rw-r--r--DEPENDENCIES22
-rw-r--r--INSTALL77
-rw-r--r--LICENSE15
-rw-r--r--Makefile62
-rw-r--r--Makefile.in87
-rw-r--r--NEWS5
-rw-r--r--TODO4
-rw-r--r--config.mk6
-rwxr-xr-xconfigure48
-rw-r--r--convert-template.c1162
-rw-r--r--doc/info/appx/fdl.texinfo505
-rw-r--r--doc/info/appx/free-software-needs-free-documentation.texinfo31
-rw-r--r--doc/info/appx/gpl.texinfo717
-rw-r--r--doc/info/chap/colour-spaces.texinfo759
-rw-r--r--doc/info/chap/functions.texinfo79
-rw-r--r--doc/info/chap/illuminants.texinfo113
-rw-r--r--doc/info/chap/overview.texinfo20
-rw-r--r--doc/info/content.texinfo69
-rw-r--r--doc/info/hardcopy-copying.texinfo70
-rw-r--r--doc/info/libcolour.texinfo103
-rw-r--r--doc/info/reusable/macros.texinfo48
-rw-r--r--doc/info/reusable/paper.texinfo109
-rw-r--r--doc/info/reusable/titlepage.texinfo79
-rw-r--r--doc/info/titlepage-data.texinfo23
-rw-r--r--double.c82
-rw-r--r--float.c82
-rw-r--r--libcolour-template.c731
-rw-r--r--libcolour.h445
-rw-r--r--long-double.c82
-rw-r--r--mk/README71
-rw-r--r--mk/all.mk32
-rw-r--r--mk/clean.mk45
-rw-r--r--mk/configure732
-rw-r--r--mk/copy.mk78
-rw-r--r--mk/dist.mk189
-rw-r--r--mk/empty.mk103
-rw-r--r--mk/i18n.mk111
-rw-r--r--mk/lang-c.mk307
-rw-r--r--mk/lowerpath.mk279
-rw-r--r--mk/man.mk111
-rw-r--r--mk/path.mk176
-rw-r--r--mk/prologue.mk16
-rw-r--r--mk/shell.mk233
-rw-r--r--mk/tags.mk25
-rw-r--r--mk/texinfo.mk294
-rw-r--r--mk/tools.mk163
-rw-r--r--src/convert.c1068
-rw-r--r--src/libcolour.c717
-rw-r--r--src/libcolour.h301
-rw-r--r--src/test.c657
-rw-r--r--test.c658
53 files changed, 3333 insertions, 9363 deletions
diff --git a/.gitignore b/.gitignore
index 892d3ac..2a188aa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,23 +1,12 @@
-_/
-/bin/
-/aux/
-/obj/
\#*\#
-.*
-!.git*
+.\#*
*~
*.bak
-*.new
*.swo
*.swp
-*.out
*.o
*.su
-*.gch
-*.info
-*.pdf
-*.ps
-*.dvi
-/config.status
-/Makefile
-
+*.so.*
+*.so
+*.a
+/test
diff --git a/COPYING b/COPYING
deleted file mode 100644
index 94a9ed0..0000000
--- a/COPYING
+++ /dev/null
@@ -1,674 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program 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 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/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- <program> Copyright (C) <year> <name of author>
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-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/>.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/DEPENDENCIES b/DEPENDENCIES
deleted file mode 100644
index cfd6079..0000000
--- a/DEPENDENCIES
+++ /dev/null
@@ -1,22 +0,0 @@
-RUNTIME DEPENDENCIES:
-
- libc
-
-
-BUILD DEPENDENCIES:
-
- make
- coreutils
- cc
- texinfo>=4.11 (opt-out, for info, pdf, dvi, ps, and html manuals)
- texlive-plainextra (opt-in, for pdf, dvi, and ps manuals)
-
- texinfo<4.11 can be used if '@frenchspacing on' is removed.
-
-
-INSTALL DEPENDENCIES:
-
- make
- coreutils
- texinfo (opt-out, for dir-entry of info manual)
-
diff --git a/INSTALL b/INSTALL
deleted file mode 100644
index 2bdaa0a..0000000
--- a/INSTALL
+++ /dev/null
@@ -1,77 +0,0 @@
-Type './configure --help' for configuration options. The normal settings for a
-GNU package should work. If not, please make a bug report.
-
- On a common GNU/Linux distribution the following should
- be sufficient for most users:
-
- ./configure --prefix=/usr
- make
- make install DESTDIR="somewhere you want the files for now"
- # Now let the package manager put the files in place...
-
- Or for an unstaged install:
-
- ./configure --prefix=/usr
- make
- sudo make install
-
-By default any applicable pre-install, post-install, pre-uninstall, and
-post-install commands is run. This suppress these, run 'make' with 'N=true'
-or 'N=:'. IF you want to know which these commands are, you can use the
-methods specificed in the GNU Coding Standards. Another method is found in
-mk/README. However, for this packages, these will be:
-
- infodir="usr/local/share/info" ## Assuming default prefix.
-
- post_install () {
- install-info -- "${infodir}/libcolour.info" "${infodir}/dir"
- }
-
- pre_uninstall () {
- install-info --delete -- "${infodir}/libcolour.info" "${infodir}/dir"
- }
-
-
-────────────────────────────────────────────────────────────────────────────────
-CUSTOMISED COMPILATION
-────────────────────────────────────────────────────────────────────────────────
-
-The makefile is configured to compile the C code with -O2 -g, you can
-change this by setting OPTIMISE, or with CFLAGS and LDFLAGS if you want
-to change all optional flags compiling and linking flags:
-
- ./configure OPTIMISE="-Og -g"
-
-
-────────────────────────────────────────────────────────────────────────────────
-CUSTOMISED INSTALLATION
-────────────────────────────────────────────────────────────────────────────────
-
-If you want to install absolutely everything, you can
-instead use the commands below:
-
- make everything
- make install-everything DESTDIR="pkg"
-
-Or if you only want to absolute basics:
-
- make base
- make install-base DESTDIR="pkg"
-
-You can select freely what parts of the package to install and not
-to install. This rules are available:
-
-┌─────────────┬─────────────────────┬────────────────────────────────────────────┐
-│ COMPILATION │ INSTALLATION │ DESCRIPTION │
-├─────────────┼─────────────────────┼────────────────────────────────────────────┤
-│ base │ install-base │ Install the basics: │
-│ │ install-lib │ Install the libcolour library. │
-│ │ install-copyright │ Install the the GPL v3 license. │
-│ doc │ install-doc │ Include all manuals: │
-│ info │ install-info │ Include info manual. (Texinfo) │
-│ dvi │ install-dvi │ Include DVI manual. (Texinfo) │
-│ pdf │ install-pdf │ Include PDF manual. (Texinfo) │
-│ ps │ install-ps │ Include PostScript manual. (Texinfo) │
-│ html │ install-html │ Include multifile HTML manual. (Texinfo) │
-└─────────────┴─────────────────────┴────────────────────────────────────────────┘
-
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..383201c
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,15 @@
+ISC License
+
+© 2016, 2017 Mattias Andrée <maandree@kth.se>
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..acfc5b5
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,62 @@
+.POSIX:
+
+include config.mk
+
+OBJ =\
+ float.o\
+ double.o\
+ long-double.o
+
+HDR =\
+ libcolour.h
+
+TEMPLATES =\
+ convert-template.c\
+ libcolour-template.c
+
+
+all: libcolour.a libcolour.so.$(VERSION_MAJOR).$(VERSION_MINOR) test
+
+
+float.o: float.c $(TEMPLATES) $(HDR)
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ float.c
+
+double.o: double.c $(TEMPLATES) $(HDR)
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ double.c
+
+long-double.o: long-double.c $(TEMPLATES) $(HDR)
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ long-double.c
+
+
+float.pic.o: float.c $(TEMPLATES) $(HDR)
+ $(CC) $(CFLAGS) $(CPPFLAGS) -fPIC -c -o $@ float.c
+
+double.pic.o: double.c $(TEMPLATES) $(HDR)
+ $(CC) $(CFLAGS) $(CPPFLAGS) -fPIC -c -o $@ double.c
+
+long-double.pic.o: long-double.c $(TEMPLATES) $(HDR)
+ $(CC) $(CFLAGS) $(CPPFLAGS) -fPIC -c -o $@ long-double.c
+
+
+libcolour.a: $(OBJ)
+ $(AR) rc $@ $?
+ $(AR) -s $@
+
+libcolour.so.$(VERSION_MAJOR).$(VERSION_MINOR): $(OBJ:.o=.pic.o)
+ $(CC) -shared -Wl,-soname,libcolour.so.$(VERSION_MAJOR) -o $@ $(LDFLAGS) $^
+
+
+test.o: test.c libcolour.h
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ test.c
+
+test: test.o libcolour.a
+ $(CC) -o $@ $^ $(LDFLAGS)
+
+
+check: test
+ ./test
+
+clean:
+ -rm -- *.o *.a *.so *.so.* test
+
+.PHONY: all clean check
diff --git a/Makefile.in b/Makefile.in
deleted file mode 100644
index 6620bf2..0000000
--- a/Makefile.in
+++ /dev/null
@@ -1,87 +0,0 @@
-# Copyright (C) 2016 Mattias Andrée <maandree@kth.se>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-### This file will be stored to Makefile once you have run ./configure. ###
-### See INSTALL for information on how to install this package. ###
-
-
-
-##### What is below this line is configurable, but is seldom useful. #####
-
-
-# Additional options for compiling info and HTML manuals.
-INFO_FLAGS =
-
-# Additional options for compiling DVI, PDF, and PostScript manuals.
-TEXINFO_FLAGS =
-
-# The name of the package as it should be installed.
-PKGNAME = libcolour
-
-
-
-##### Nothing interesting below this. #####
-
-
-# In case you want add some configurations. Primarily
-# intended for maintainers. Perhaps add GPG_KEY here.
-# Of course, you can declare everthing with ./configure,
-# but with this you are less likely to forget it.
--include .make-configurations
-
-
-# YOU, AS A USER, SHOULD NOT CHANGE THESE VARIABLES. {{
-# They specify how the reusable makefiles in mk/ shall behave.
-
-# Package information.
-_PROJECT = libcolour
-_VERSION = 1.0
-
-# Used by mk/lang-c.mk
-_C_STD = c99
-_H = libcolour
-_HEADER_DIRLEVELS = 1
-_LIB = libcolour
-_OBJ_libcolour = libcolour convert
-_SO_VERSION_libcolour = $(_VERSION)
-_SO_MAJOR_libcolour = $(shell echo $(_SO_VERSION_libcolour) | cut -d . -f 1)
-
-# Used by mk/texinfo.mk
-_TEXINFO_DIRLEVELS = 2
-_INFOPARTS = 0
-_HAVE_TEXINFO_MANUAL = yes
-_HTML_FILES = Free-Software-Needs-Free-Documentation.html GNU-Free-Documentation-License.html \
- GNU-General-Public-License.html index.html Overview.html Colour-Spaces.html \
- Illuminants.html Functions.html CIE-1960-UCS.html CIELAB.html CIELCh.html \
- CIELUV.html CIEUVW.html CIExyY.html CIEXYZ.html RGB.html sRGB.html YCgCo.html \
- YDbDr.html YIQ.html YPbPr.html YUV.html
-
-# Used by mk/man.mk
-#_MAN_PAGE_SECTIONS = 0 3 7
-#_MAN_0 = libcolour.h
-#_MAN_3 =
-#_MAN_7 = libcolour
-
-# Used by mk/copy.mk
-_COPYING = COPYING
-
-# Used by mk/dist.mk
-___EVERYTHING_INFO = autohaltd titlepage-data content hardcopy-copying \
- appx/fdl appx/free-software-needs-free-documentation appx/gpl \
- reusable/macros reusable/paper reusable/titlepage \
- chap/overview chap/colour-spaces.texinfo chap/illuminants.texinfo \
- chap/functions.texinfo
-_EVERYTHING = $(__EVERYTHING_ALL_COMMON) DEPENDENCIES INSTALL NEWS \
- $(foreach F,$(___EVERYTHING_INFO),doc/info/$(F).texinfo) libcolour.h
-
-# }}
-
-
-# Reusable make rules and the configurations.
-include $(v)mk/all.mk
-
diff --git a/NEWS b/NEWS
deleted file mode 100644
index 3ec8ed1..0000000
--- a/NEWS
+++ /dev/null
@@ -1,5 +0,0 @@
-libcolour NEWS -*- outline -*-
-
-* Noteworthy changes in release 1.0 (2016-12-20) [stable]
-
- Initial release.
diff --git a/TODO b/TODO
index 9e66677..500b995 100644
--- a/TODO
+++ b/TODO
@@ -24,5 +24,7 @@ Support for generic subtractive colour spaces (3 channels and more)
GPU accelerated functions:
int libcolour_convert_en_masse_f(const libcolour_colour_t* from, const libcolour_colour_t* to, size_t n, ...)
Where `...` normally is `float* ch1, float* ch2, float* ch3`.
- int libcolour_convert_en_masse_d(const libcolour_colour_t* from, const libcolour_colour_t* to, size_t n, ...)
+ int libcolour_convert_en_masse_lf(const libcolour_colour_t* from, const libcolour_colour_t* to, size_t n, ...)
Where `...` normally is `double* ch1, double* ch2, double* ch3`.
+ int libcolour_convert_en_masse_llf(const libcolour_colour_t* from, const libcolour_colour_t* to, size_t n, ...)
+ Where `...` normally is `long double* ch1, long double* ch2, long double* ch3`.
diff --git a/config.mk b/config.mk
new file mode 100644
index 0000000..1f61799
--- /dev/null
+++ b/config.mk
@@ -0,0 +1,6 @@
+VERSION_MAJOR = 2
+VERSION_MINOR = 0
+
+CFLAGS = -Wall -pedantic -std=c11 -g
+CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE
+LDFLAGS = -lm
diff --git a/configure b/configure
deleted file mode 100755
index d1cad10..0000000
--- a/configure
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/bin/sh
-
-# Copyright (C) 2016 Mattias Andrée <maandree@kth.se>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-# Run './configure --help' for usage information.
-
-
-PKGNAME=libcolour
-MAN_SECTION_SUFFIX=
-
-
-list_optional_features_help ()
-{
- true
-}
-
-unrecognised_argument ()
-{
- option="${1}"
- case "${option}" in
- (--build | --target | --host)
- incomplete="${option}" ;;
- (--build=*)
- ;;
- (--target=*)
- ;;
- (--host=*)
- ;;
- (*)
- ;;
- esac
-}
-
-. "$(dirname "${0}")"/mk/configure
-
-
-cat <<EOF
-
-You can now run 'make && make install'.
-
-EOF
-
diff --git a/convert-template.c b/convert-template.c
new file mode 100644
index 0000000..d06ccc0
--- /dev/null
+++ b/convert-template.c
@@ -0,0 +1,1162 @@
+/* See LICENSE file for copyright and license details. */
+
+#if defined(__GNUC__) && !defined(__clang__)
+# pragma GCC diagnostic ignored "-Wfloat-equal"
+#elif defined(__clang__)
+# pragma clang diagnostic ignored "-Wcomma"
+# pragma clang diagnostic ignored "-Wfloat-equal"
+# pragma clang diagnostic ignored "-Wvla"
+# pragma clang diagnostic ignored "-Wtautological-compare"
+# pragma clang diagnostic ignored "-Wcovered-switch-default"
+# pragma clang diagnostic ignored "-Wfloat-conversion"
+# pragma clang diagnostic ignored "-Wconversion"
+# pragma clang diagnostic ignored "-Wdouble-promotion"
+# pragma clang diagnostic ignored "-Wswitch-enum"
+# pragma clang diagnostic ignored "-Wcast-align"
+#endif
+
+
+#define PI D(3.14159265358979323846)
+#define PI2 (2 * D(3.14159265358979323846))
+#define WASDIV0(X) (xisinf(X) || xisnan(X))
+
+#define REGULAR(S, T) ((T) <= (S)->transition ? (S)->slope * (T) : (1 + (S)->offset) * xpow((T), 1 / (S)->gamma) - (S)->offset)
+#define INVREGULAR(S, T) ((T) <= (S)->transitioninv ? (T) / (S)->slope : xpow(((T) + (S)->offset) / (1 + (S)->offset), (S)->gamma))
+
+#define TRANSFORM(X, Y, Z, A, B, C, R1C1, R1C2, R1C3, R2C1, R2C2, R2C3, R3C1, R3C2, R3C3)\
+ do {\
+ TYPE a__ = (A), b__ = (B), c__ = (C);\
+ (X) = D(R1C1) * a__ + D(R1C2) * b__ + D(R1C3) * c__;\
+ (Y) = D(R2C1) * a__ + D(R2C2) * b__ + D(R2C3) * c__;\
+ (Z) = D(R3C1) * a__ + D(R3C2) * b__ + D(R3C3) * c__;\
+ } while (0)
+
+
+
+static void to_rgb(const libcolour_colour_t *restrict from, libcolour_rgb_t *restrict to);
+static void to_srgb(const libcolour_colour_t *restrict from, libcolour_srgb_t *restrict to);
+static void to_ciexyy(const libcolour_colour_t *restrict from, libcolour_ciexyy_t *restrict to);
+static void to_ciexyz(const libcolour_colour_t *restrict from, libcolour_ciexyz_t *restrict to);
+static void to_cielab(const libcolour_colour_t *restrict from, libcolour_cielab_t *restrict to);
+static void to_cieluv(const libcolour_colour_t *restrict from, libcolour_cieluv_t *restrict to);
+static void to_cielchuv(const libcolour_colour_t *restrict from, libcolour_cielchuv_t *restrict to);
+static void to_yiq(const libcolour_colour_t *restrict from, libcolour_yiq_t *restrict to);
+static void to_ydbdr(const libcolour_colour_t *restrict from, libcolour_ydbdr_t *restrict to);
+static void to_yuv(const libcolour_colour_t *restrict from, libcolour_yuv_t *restrict to);
+static void to_ypbpr(const libcolour_colour_t *restrict from, libcolour_ypbpr_t *restrict to);
+static void to_ycgco(const libcolour_colour_t *restrict from, libcolour_ycgco_t *restrict to);
+static void to_cie1960ucs(const libcolour_colour_t *restrict from, libcolour_cie1960ucs_t *restrict to);
+static void to_cieuvw(const libcolour_colour_t *restrict from, libcolour_cieuvw_t *restrict to);
+
+
+
+static void
+ciexyz_to_rgb(const libcolour_ciexyz_t *restrict from, libcolour_rgb_t *restrict to)
+{
+ TYPE X = from->X, Y = from->Y, Z = from->Z;
+ to->R = to->Minv[0][0] * X + to->Minv[0][1] * Y + to->Minv[0][2] * Z;
+ to->G = to->Minv[1][0] * X + to->Minv[1][1] * Y + to->Minv[1][2] * Z;
+ to->B = to->Minv[2][0] * X + to->Minv[2][1] * Y + to->Minv[2][2] * Z;
+}
+
+
+static void
+rgb_encode(libcolour_rgb_t *restrict colour, const libcolour_rgb_t *restrict space)
+{
+ TYPE r_sign = 1, g_sign = 1, b_sign = 1;
+ switch (space->encoding_type) {
+ case LIBCOLOUR_ENCODING_TYPE_LINEAR:
+ break;
+ case LIBCOLOUR_ENCODING_TYPE_SIMPLE:
+ case LIBCOLOUR_ENCODING_TYPE_REGULAR:
+ if (colour->R < 0) r_sign = -1, colour->R = -colour->R;
+ if (colour->G < 0) g_sign = -1, colour->G = -colour->G;
+ if (colour->B < 0) b_sign = -1, colour->B = -colour->B;
+ if (space->encoding_type == LIBCOLOUR_ENCODING_TYPE_SIMPLE) {
+ colour->R = xpow(colour->R, 1 / space->gamma);
+ colour->G = xpow(colour->G, 1 / space->gamma);
+ colour->B = xpow(colour->B, 1 / space->gamma);
+ } else {
+ colour->R = REGULAR(space, colour->R);
+ colour->G = REGULAR(space, colour->G);
+ colour->B = REGULAR(space, colour->B);
+ }
+ colour->R *= r_sign;
+ colour->G *= g_sign;
+ colour->B *= b_sign;
+ break;
+ case LIBCOLOUR_ENCODING_TYPE_CUSTOM:
+ colour->R = (space->to_encoded_red)(colour->R);
+ colour->G = (space->to_encoded_green)(colour->G);
+ colour->B = (space->to_encoded_blue)(colour->B);
+ break;
+ default:
+ fprintf(stderr, "libcolour: invalid encoding type\n");
+ abort();
+ }
+}
+
+static void
+rgb_decode(libcolour_rgb_t *restrict colour, const libcolour_rgb_t *restrict space)
+{
+ TYPE r_sign = 1, g_sign = 1, b_sign = 1;
+ switch (space->encoding_type) {
+ case LIBCOLOUR_ENCODING_TYPE_LINEAR:
+ break;
+ case LIBCOLOUR_ENCODING_TYPE_SIMPLE:
+ case LIBCOLOUR_ENCODING_TYPE_REGULAR:
+ if (colour->R < 0) r_sign = -1, colour->R = -colour->R;
+ if (colour->G < 0) g_sign = -1, colour->G = -colour->G;
+ if (colour->B < 0) b_sign = -1, colour->B = -colour->B;
+ if (space->encoding_type == LIBCOLOUR_ENCODING_TYPE_SIMPLE) {
+ colour->R = xpow(colour->R, space->gamma);
+ colour->G = xpow(colour->G, space->gamma);
+ colour->B = xpow(colour->B, space->gamma);
+ } else {
+ colour->R = INVREGULAR(space, colour->R);
+ colour->G = INVREGULAR(space, colour->G);
+ colour->B = INVREGULAR(space, colour->B);
+ }
+ colour->R *= r_sign;
+ colour->G *= g_sign;
+ colour->B *= b_sign;
+ break;
+ case LIBCOLOUR_ENCODING_TYPE_CUSTOM:
+ colour->R = (space->to_decoded_red)(colour->R);
+ colour->G = (space->to_decoded_green)(colour->G);
+ colour->B = (space->to_decoded_blue)(colour->B);
+ break;
+ default:
+ fprintf(stderr, "libcolour: invalid encoding type\n");
+ abort();
+ }
+}
+
+static int
+rgb_same_transfer(const libcolour_rgb_t *restrict a, const libcolour_rgb_t *restrict b)
+{
+ if (a->encoding_type != b->encoding_type)
+ return 0;
+ switch (a->encoding_type) {
+ case LIBCOLOUR_ENCODING_TYPE_SIMPLE:
+ return a->gamma == b->gamma;
+ case LIBCOLOUR_ENCODING_TYPE_REGULAR:
+ return a->gamma == b->gamma &&
+ a->offset == b->offset &&
+ a->slope == b->slope &&
+ a->transition == b->transition;
+ case LIBCOLOUR_ENCODING_TYPE_CUSTOM:
+ return a->to_encoded_red == b->to_encoded_red &&
+ a->to_encoded_green == b->to_encoded_green &&
+ a->to_encoded_blue == b->to_encoded_blue &&
+ a->to_decoded_red == b->to_decoded_red &&
+ a->to_decoded_green == b->to_decoded_green &&
+ a->to_decoded_blue == b->to_decoded_blue;
+ default:
+ return 1;
+ }
+}
+
+static void
+to_rgb(const libcolour_colour_t *restrict from, libcolour_rgb_t *restrict to)
+{
+ int have_transfer = 0, with_transfer = to->with_transfer;
+ libcolour_ciexyz_t tmp;
+ switch (from->model) {
+ case LIBCOLOUR_CIEXYZ:
+ ciexyz_to_rgb(&from->ciexyz, to);
+ break;
+ case LIBCOLOUR_RGB:
+ if (!memcmp(from->rgb.M, to->M, sizeof(TYPE[3][3]))) {
+ have_transfer = from->rgb.with_transfer;
+ to->R = from->rgb.R;
+ to->G = from->rgb.G;
+ to->B = from->rgb.B;
+ if (have_transfer && with_transfer && !rgb_same_transfer(&from->rgb, to))
+ rgb_decode(to, &from->rgb), have_transfer = 0;
+ break;
+ }
+ /* fall through */
+ default:
+ tmp.model = LIBCOLOUR_CIEXYZ;
+ to_ciexyz(from, &tmp);
+ ciexyz_to_rgb(&tmp, to);
+ break;
+ }
+
+ if (have_transfer != with_transfer) {
+ if (with_transfer)
+ rgb_encode(to, to);
+ else
+ rgb_decode(to, &from->rgb);
+ }
+}
+
+
+static void
+ciexyz_to_srgb(const libcolour_ciexyz_t *restrict from, libcolour_srgb_t *restrict to)
+{
+ TRANSFORM(to->R, to->G, to->B, from->X, from->Y, from->Z,
+ 3.240446254647737500675930277794, -1.537134761820080575134284117667, -0.498530193022728718155178739835,
+ -0.969266606244679751469561779231, 1.876011959788370209167851498933, 0.041556042214430065351304932619,
+ 0.055643503564352832235773149705, -0.204026179735960239147729566866, 1.057226567722703292062647051353);
+}
+
+static inline TYPE
+srgb_encode(TYPE t)
+{
+ TYPE sign = 1;
+ if (t < 0) {
+ t = -t;
+ sign = -1;
+ }
+ t = t <= D(0.0031306684425217108) ? D(12.92) * t
+ : D(1.055) * xpow(t, 1 / D(2.4)) - D(0.055);
+ return t * sign;
+}
+
+static inline TYPE
+srgb_decode(TYPE t)
+{
+ TYPE sign = 1;
+ if (t < 0) {
+ t = -t;
+ sign = -1;
+ }
+ t = t <= D(0.0031306684425217108) * D(12.92) ? t / D(12.92)
+ : xpow((t + D(0.055)) / D(1.055), D(2.4));
+ return t * sign;
+}
+
+static void
+srgb_to_srgb(const libcolour_srgb_t *restrict from, libcolour_srgb_t *restrict to)
+{
+ if (from->with_transfer == to->with_transfer) {
+ *to = *from;
+ } else if (to->with_transfer) {
+ to->R = srgb_encode(from->R);
+ to->G = srgb_encode(from->G);
+ to->B = srgb_encode(from->B);
+ } else {
+ to->R = srgb_decode(from->R);
+ to->G = srgb_decode(from->G);
+ to->B = srgb_decode(from->B);
+ }
+}
+
+static void
+yiq_to_srgb(const libcolour_yiq_t *restrict from, libcolour_srgb_t *restrict to)
+{
+ TRANSFORM(to->R, to->G, to->B, from->Y, from->I, from->Q,
+ 1, 0.95629483232089407263032398986979387700557708740234, 0.62102512544472865396727456754888407886028289794922,
+ 1, -0.27212147408397735492968649850809015333652496337891, -0.64738095351761570928061928498209454119205474853516,
+ 1, -1.10698990856712820018969978264067322015762329101562, 1.70461497549882934343656870623817667365074157714844);
+ /* ⎛1 1000 cos 33° / 877 1000 sin 33° / 877 ⎞
+ ⎜1 9500 sin 33° / 24067 - 299000 * cos 33° / 514799 -9500 cos 33° / 24067 - 299000 * sin 33° / 514799⎟
+ ⎝1 -250 sin 33° / 123 250 cos 33° / 123 ⎠
+ */
+}
+
+static void
+ydbdr_to_srgb(const libcolour_ydbdr_t *restrict from, libcolour_srgb_t *restrict to)
+{
+ TRANSFORM(to->R, to->G, to->B, from->Y, from->Db, from->Dr,
+ 1, 0.000092303716148, -0.525912630661865,
+ 1, -0.129132898890509, 0.267899328207599,
+ 1, 0.664679059978955, -0.000079202543533);
+}
+
+static void
+ypbpr_to_srgb(const libcolour_ypbpr_t *restrict from, libcolour_srgb_t *restrict to)
+{
+ TYPE Y = from->Y, Pb = from->Pb, Pr = from->Pr;
+ to->R = Pr + Y;
+ to->B = Pb + Y;
+ to->G = (Y - to->R * D(0.2126) - to->B * D(0.0722)) / D(0.7152);
+}
+
+static void
+yuv_to_srgb(const libcolour_yuv_t *restrict from, libcolour_srgb_t *restrict to)
+{
+ TRANSFORM(to->R, to->G, to->B, from->Y, from->U, from->V,
+ 1, 0.00028328010485821202317155420580263580632163211703, 1.14070449590558520291949662350816652178764343261719,
+ 1, -0.39630886669497211727275498560629785060882568359375, -0.58107364288228224857846271333983168005943298339844,
+ 1, 2.03990003507541306504435851820744574069976806640625, 0.00017179031692307700847528739718228507626918144524);
+}
+
+static void
+ycgco_to_srgb(const libcolour_ycgco_t *restrict from, libcolour_srgb_t *restrict to)
+{
+ TYPE Y = from->Y, Cg = from->Cg, Co = from->Co;
+ to->R = Y - Cg + Co;
+ to->G = Y + Cg;
+ to->B = Y - Cg - Co;
+}
+
+static void
+other_to_srgb(const libcolour_colour_t *restrict from, libcolour_srgb_t *restrict to)
+{
+ libcolour_ciexyz_t tmp;
+ tmp.model = LIBCOLOUR_CIEXYZ;
+ to_ciexyz(from, &tmp);
+ ciexyz_to_srgb(&tmp, to);
+}
+
+static void
+to_srgb(const libcolour_colour_t *restrict from, libcolour_srgb_t *restrict to)
+{
+ libcolour_srgb_t tmp;
+ switch (from->model) {
+ case LIBCOLOUR_CIEXYZ:
+ ciexyz_to_srgb(&from->ciexyz, to);
+ break;
+ case LIBCOLOUR_SRGB:
+ srgb_to_srgb(&from->srgb, to);
+ return;
+ case LIBCOLOUR_YIQ:
+ yiq_to_srgb(&from->yiq, to);
+ break;
+ case LIBCOLOUR_YDBDR:
+ ydbdr_to_srgb(&from->ydbdr, to);
+ break;
+ case LIBCOLOUR_YPBPR:
+ ypbpr_to_srgb(&from->ypbpr, to);
+ break;
+ case LIBCOLOUR_YUV:
+ yuv_to_srgb(&from->yuv, to);
+ break;
+ case LIBCOLOUR_YCGCO:
+ ycgco_to_srgb(&from->ycgco, to);
+ break;
+ default:
+ other_to_srgb(from, to);
+ break;
+ }
+ if (to->with_transfer) {
+ tmp = *to;
+ tmp.with_transfer = 0;
+ srgb_to_srgb(&tmp, to);
+ }
+}
+
+
+static void
+ciexyz_to_ciexyy(const libcolour_ciexyz_t *restrict from, libcolour_ciexyy_t *restrict to)
+{
+ TYPE X = from->X, Y = from->Y, Z = from->Z;
+ TYPE s = X + Y + Z;
+ to->x = X / s;
+ to->y = Y / s;
+ to->Y = Y;
+ if (WASDIV0(to->x) || WASDIV0(to->y))
+ to->x = to->y = 0;
+}
+
+static void
+other_to_ciexyy(const libcolour_colour_t *restrict from, libcolour_ciexyy_t *restrict to)
+{
+ libcolour_ciexyz_t tmp;
+ tmp.model = LIBCOLOUR_CIEXYZ;
+ to_ciexyz(from, &tmp);
+ ciexyz_to_ciexyy(&tmp, to);
+}
+
+static void
+srgb_to_ciexyy(const libcolour_srgb_t *restrict from, libcolour_ciexyy_t *restrict to)
+{
+ libcolour_srgb_t tmp;
+ tmp.model = LIBCOLOUR_SRGB;
+ if (from->with_transfer) {
+ tmp.with_transfer = 0;
+ to_srgb((const libcolour_colour_t*)from, &tmp);
+ } else {
+ tmp = *from;
+ }
+ if (tmp.R == 0 && tmp.G == 0 && tmp.B == 0) {
+ to->x = D(0.31272660439158);
+ to->y = D(0.32902315240275);
+ to->Y = 0;
+ } else {
+ other_to_ciexyy((const libcolour_colour_t*)&tmp, to);
+ }
+}
+
+static void
+to_ciexyy(const libcolour_colour_t *restrict from, libcolour_ciexyy_t *restrict to)
+{
+ switch (from->model) {
+ case LIBCOLOUR_CIEXYY:
+ *to = from->ciexyy;
+ return;
+ case LIBCOLOUR_CIEXYZ:
+ ciexyz_to_ciexyy(&from->ciexyz, to);
+ return;
+ case LIBCOLOUR_SRGB:
+ srgb_to_ciexyy(&from->srgb, to);
+ return;
+ default:
+ other_to_ciexyy(from, to);
+ return;
+ }
+}
+
+
+static void
+rgb_to_ciexyz(const libcolour_rgb_t *restrict from, libcolour_ciexyz_t *restrict to)
+{
+ libcolour_rgb_t tmp;
+ TYPE R, G, B;
+ if (from->with_transfer) {
+ tmp = *from;
+ tmp.with_transfer = 0;
+ to_rgb((const libcolour_colour_t *)from, &tmp);
+ R = tmp.R, G = tmp.G, B = tmp.B;
+ } else {
+ R = from->R, G = from->G, B = from->B;
+ }
+ to->X = from->M[0][0] * R + from->M[0][1] * G + from->M[0][2] * B;
+ to->Y = from->M[1][0] * R + from->M[1][1] * G + from->M[1][2] * B;
+ to->Z = from->M[2][0] * R + from->M[2][1] * G + from->M[2][2] * B;
+}
+
+static void srgb_to_ciexyz(const libcolour_srgb_t *restrict from, libcolour_ciexyz_t *restrict to)
+{
+ libcolour_srgb_t tmp;
+ TYPE R, G, B;
+ if (from->with_transfer) {
+ tmp.model = LIBCOLOUR_SRGB;
+ tmp.with_transfer = 0;
+ to_srgb((const libcolour_colour_t*)from, &tmp);
+ R = tmp.R, G = tmp.G, B = tmp.B;
+ } else {
+ R = from->R, G = from->G, B = from->B;
+ }
+ TRANSFORM(to->X, to->Y, to->Z, R, G, B,
+ 0.412457445582367576708548995157, 0.357575865245515878143578447634, 0.180437247826399665973085006954,
+ 0.212673370378408277403536885686, 0.715151730491031756287156895269, 0.072174899130559869164791564344,
+ 0.019333942761673460208893260415, 0.119191955081838593666354597644, 0.950302838552371742508739771438);
+}
+
+static void
+ciexyy_to_ciexyz(const libcolour_ciexyy_t *restrict from, libcolour_ciexyz_t *restrict to)
+{
+ TYPE x = from->x, y = from->y, Y = from->Y;
+ TYPE Yy = Y / y;
+ if (WASDIV0(Yy)) {
+ to->X = to->Y = to->Z = Y;
+ } else {
+ to->X = x * Yy;
+ to->Y = Y;
+ to->Z = (1 - x - y) * Yy;
+ }
+}
+
+static inline TYPE
+cielab_finv(TYPE t)
+{
+ return (t > D(6.) / D(29.)) ? t * t * t : (t - D(4.) / D(29.)) * 108 / 841;
+}
+
+static void
+cielab_to_ciexyz(const libcolour_cielab_t *restrict from, libcolour_ciexyz_t *restrict to)
+{
+ TYPE L = from->L, a = from->a, b = from->b;
+ to->Y = (L + 16) / 116;
+ to->X = to->Y + a / 500;
+ to->Z = to->Y - b / 200;
+ to->X = cielab_finv(to->X) * D(0.95047);
+ to->Y = cielab_finv(to->Y);
+ to->Z = cielab_finv(to->Z) * D(1.08883);
+}
+
+static void
+cieluv_to_ciexyz(const libcolour_cieluv_t *restrict from, libcolour_ciexyz_t *restrict to)
+{
+ TYPE X = from->white.X, Y = from->white.Y, L = from->L, L13 = from->L * 13;
+ TYPE t = X + 15 * Y + 3 * from->white.Z;
+ TYPE u = from->u / L13 + 4 * X / t;
+ TYPE v = from->v / L13 + 9 * Y / t;
+ if (L <= 8) {
+ Y *= L * 27 / 24389;
+ } else {
+ L = (L + 16) / 116;
+ Y *= L * L * L;
+ }
+ to->X = D(2.25) * Y * u / v;
+ to->Y = Y;
+ to->Z = Y * (3 / v - D(0.75) * u / v - 5);
+}
+
+static void
+cielchuv_to_ciexyz(const libcolour_cielchuv_t *restrict from, libcolour_ciexyz_t *restrict to)
+{
+ libcolour_cieluv_t tmp;
+ tmp.model = LIBCOLOUR_CIELUV;
+ tmp.white = from->white;
+ to_cieluv((const libcolour_colour_t*)from, &tmp);
+ cieluv_to_ciexyz(&tmp, to);
+}
+
+static void
+yiq_to_ciexyz(const libcolour_yiq_t *restrict from, libcolour_ciexyz_t *restrict to)
+{
+ TRANSFORM(to->X, to->Y, to->Z, from->Y, from->I, from->Q,
+ 0.95047055865428309306963683411595411598682403564453,
+ 0.09738463974178063198294807989441324025392532348633,
+ 0.33223466706854809515903070860076695680618286132812,
+ 0.99999999999999988897769753748434595763683319091797,
+ -0.07112658301916767455974621725545148365199565887451,
+ -0.20786968876398304040264974901219829916954040527344,
+ 1.08882873639588373393394249433185905218124389648438,
+ -1.06592139332461721679123911599162966012954711914062,
+ 1.55474471255181900808395312196807935833930969238281);
+}
+
+static void
+ydbdr_to_ciexyz(const libcolour_ydbdr_t *restrict from, libcolour_ciexyz_t *restrict to)
+{
+ TRANSFORM(to->X, to->Y, to->Z, from->Y, from->Db, from->Dr,
+ 0.95047055865428309306963683411595411598682403564453,
+ 0.07379612357298576119646327242662664502859115600586,
+ -0.12113653724874726136384595065464964136481285095215,
+ 0.99999999999999988897769753748434595763683319091797,
+ -0.04435684145428285540813106990754022262990474700928,
+ 0.07973534004202506575431641522300196811556816101074,
+ 1.08882873639588373393394249433185905218124389648438,
+ 0.61625657933494271123464613992837257683277130126953,
+ 0.02168821359337728266192257819966471288353204727173);
+}
+
+static void
+yuv_to_ciexyz(const libcolour_yuv_t *restrict from, libcolour_ciexyz_t *restrict to)
+{
+ TRANSFORM(to->X, to->Y, to->Z, from->Y, from->U, from->V,
+ 0.95047055865428309306963683411595411598682403564453,
+ 0.22648030324549334180161963558930438011884689331055,
+ 0.26274514929253273143316960158699657768011093139648,
+ 0.99999999999999988897769753748434595763683319091797,
+ -0.13613114642319409930415474718756740912795066833496,
+ -0.17294595255115238763288232348713790997862815856934,
+ 1.08882873639588373393394249433185905218124389648438,
+ 1.89129144197893928058817891724174842238426208496094,
+ -0.04704173528403532422714761196402832865715026855469);
+}
+
+static void
+ypbpr_to_ciexyz(const libcolour_ypbpr_t *restrict from, libcolour_ciexyz_t *restrict to)
+{
+ TRANSFORM(to->X, to->Y, to->Z, from->Y, from->Pb, from->Pr,
+ 0.95047055865428298204733437160030007362365722656250,
+ 0.14433968424876231217979238863335922360420227050781,
+ 0.30616461986760712399302519770571961998939514160156,
+ 0.99999999999999977795539507496869191527366638183594,
+ -0.00002022802471486617736928792510298080742359161377,
+ 0.00008771894888734421691367515450110659003257751465,
+ 1.08882873639588373393394249433185905218124389648438,
+ 0.93827031735982591165168287261622026562690734863281,
+ -0.01609699914324668607035206946420657914131879806519);
+}
+
+static void
+ycgco_to_ciexyz(const libcolour_ycgco_t *restrict from, libcolour_ciexyz_t *restrict to)
+{
+ TRANSFORM(to->X, to->Y, to->Z, from->Y, from->Cg, from->Co,
+ 0.95047055865428309306963683411595411598682403564453,
+ -0.23531882816325136453805555447615915909409523010254,
+ 0.23202019775596791073546398820326430723071098327637,
+ 0.99999999999999988897769753748434595763683319091797,
+ 0.43030346098206362359661625305307097733020782470703,
+ 0.14049847124784842211653312915586866438388824462891,
+ 1.08882873639588373393394249433185905218124389648438,
+ -0.85044482623220662986796014592982828617095947265625,
+ -0.93096889579069830311652822274481877684593200683594);
+}
+
+static void
+cie1960ucs_to_ciexyz(const libcolour_cie1960ucs_t *restrict from, libcolour_ciexyz_t *restrict to)
+{
+ TYPE u = from->u, v = from->v, Y = from->Y;
+ to->X = D(1.5) * Y * u / v;
+ to->Y = Y;
+ to->Z = (4 * Y - Y * u - 10 * Y * v) / (2 * v);
+}
+
+static void
+cieuvw_to_ciexyz(const libcolour_cieuvw_t *restrict from, libcolour_ciexyz_t *restrict to)
+{
+ libcolour_cie1960ucs_t tmp;
+ tmp.model = LIBCOLOUR_CIE1960UCS;
+ to_cie1960ucs((const libcolour_colour_t *)from, &tmp);
+ cie1960ucs_to_ciexyz(&tmp, to);
+}
+
+static void
+other_to_ciexyz(const libcolour_colour_t *restrict from, libcolour_ciexyz_t *restrict to)
+{
+ libcolour_srgb_t tmp;
+ tmp.model = LIBCOLOUR_SRGB;
+ tmp.with_transfer = 0;
+ to_srgb(from, &tmp);
+ srgb_to_ciexyz(&tmp, to);
+}
+
+static void to_ciexyz(const libcolour_colour_t *restrict from, libcolour_ciexyz_t *restrict to)
+{
+ switch (from->model) {
+ case LIBCOLOUR_RGB:
+ rgb_to_ciexyz(&from->rgb, to);
+ break;
+ case LIBCOLOUR_SRGB:
+ srgb_to_ciexyz(&from->srgb, to);
+ break;
+ case LIBCOLOUR_CIEXYY:
+ ciexyy_to_ciexyz(&from->ciexyy, to);
+ break;
+ case LIBCOLOUR_CIEXYZ:
+ *to = from->ciexyz;
+ break;
+ case LIBCOLOUR_CIELAB:
+ cielab_to_ciexyz(&from->cielab, to);
+ break;
+ case LIBCOLOUR_CIELUV:
+ cieluv_to_ciexyz(&from->cieluv, to);
+ break;
+ case LIBCOLOUR_CIELCHUV:
+ cielchuv_to_ciexyz(&from->cielchuv, to);
+ break;
+ case LIBCOLOUR_YIQ:
+ yiq_to_ciexyz(&from->yiq, to);
+ break;
+ case LIBCOLOUR_YDBDR:
+ ydbdr_to_ciexyz(&from->ydbdr, to);
+ break;
+ case LIBCOLOUR_YUV:
+ yuv_to_ciexyz(&from->yuv, to);
+ break;
+ case LIBCOLOUR_YPBPR:
+ ypbpr_to_ciexyz(&from->ypbpr, to);
+ break;
+ case LIBCOLOUR_YCGCO:
+ ycgco_to_ciexyz(&from->ycgco, to);
+ break;
+ case LIBCOLOUR_CIE1960UCS:
+ cie1960ucs_to_ciexyz(&from->cie1960ucs, to);
+ break;
+ case LIBCOLOUR_CIEUVW:
+ cieuvw_to_ciexyz(&from->cieuvw, to);
+ break;
+ default:
+ other_to_ciexyz(from, to);
+ break;
+ }
+}
+
+
+static inline TYPE
+cielab_f(TYPE t)
+{
+ return (t > D(216.) / D(24389.)) ? xcbrt(t) : t * D(841.) / D(108.) + D(4.) / D(29.);
+}
+
+static void
+ciexyz_to_cielab(const libcolour_ciexyz_t *restrict from, libcolour_cielab_t *restrict to)
+{
+ TYPE X = from->X, Y = from->Y, Z = from->Z;
+ X /= D(0.95047);
+ Z /= D(1.08883);
+ Y = cielab_f(Y);
+ to->L = 116 * Y - 16;
+ to->a = 500 * (cielab_f(X) - Y);
+ to->b = 200 * (Y - cielab_f(Z));
+}
+
+static void
+other_to_cielab(const libcolour_colour_t *restrict from, libcolour_cielab_t *restrict to)
+{
+ libcolour_ciexyz_t tmp;
+ tmp.model = LIBCOLOUR_CIEXYZ;
+ to_ciexyz(from, &tmp);
+ ciexyz_to_cielab(&tmp, to);
+}
+
+static void
+to_cielab(const libcolour_colour_t *restrict from, libcolour_cielab_t *restrict to)
+{
+ switch (from->model) {
+ case LIBCOLOUR_CIEXYZ:
+ ciexyz_to_cielab(&from->ciexyz, to);
+ return;
+ case LIBCOLOUR_CIELAB:
+ *to = from->cielab;
+ return;
+ default:
+ other_to_cielab(from, to);
+ return;
+ }
+}
+
+
+static void
+ciexyz_to_cieluv(const libcolour_ciexyz_t *restrict from, libcolour_cieluv_t *restrict to)
+{
+ TYPE t, u, v, y, y2;
+ t = to->white.X + 15 * to->white.Y + 3 * to->white.Z;
+ u = 4 * to->white.X / t;
+ v = 9 * to->white.Y / t;
+ t = from->X + 15 * from->Y + 3 * from->Z;
+ u = 4 * from->X / t - u;
+ v = 9 * from->Y / t - v;
+ y = from->Y / to->white.Y;
+ y2 = y * 24389;
+ y = y2 <= 216 ? y2 / 27 : xcbrt(y) * 116 - 16;
+ to->L = y;
+ y *= 13;
+ to->u = u * y;
+ to->v = v * y;
+}
+
+static void
+cielchuv_to_cieluv(const libcolour_cielchuv_t *restrict from, libcolour_cieluv_t *restrict to)
+{
+ libcolour_ciexyz_t tmp;
+ libcolour_cielchuv_t tmp2;
+ TYPE L, C, h;
+ if (to->white.X != from->white.X || to->white.Y != from->white.Y || to->white.Z != from->white.Z) {
+ tmp.model = LIBCOLOUR_CIEXYZ;
+ tmp2.model = LIBCOLOUR_CIELCHUV;
+ tmp2.white = to->white;
+ tmp2.one_revolution = PI2;
+ to_ciexyz((const libcolour_colour_t*)from, &tmp);
+ to_cielchuv((const libcolour_colour_t*)&tmp, &tmp2);
+ L = tmp2.L, C = tmp2.C, h = tmp2.h;
+ } else {
+ L = from->L, C = from->C, h = from->h * PI2 / from->one_revolution;
+ }
+ to->L = L;
+ to->u = C * xcos(h);
+ to->v = C * xsin(h);
+}
+
+static void
+other_to_cieluv(const libcolour_colour_t *restrict from, libcolour_cieluv_t *restrict to)
+{
+ libcolour_ciexyz_t tmp;
+ tmp.model = LIBCOLOUR_CIEXYZ;
+ to_ciexyz(from, &tmp);
+ ciexyz_to_cieluv(&tmp, to);
+}
+
+static void
+to_cieluv(const libcolour_colour_t *restrict from, libcolour_cieluv_t *restrict to)
+{
+ switch (from->model) {
+ case LIBCOLOUR_CIEXYZ:
+ ciexyz_to_cieluv(&from->ciexyz, to);
+ break;
+ case LIBCOLOUR_CIELCHUV:
+ cielchuv_to_cieluv(&from->cielchuv, to);
+ break;
+ case LIBCOLOUR_CIELUV:
+ if (to->white.X == from->cieluv.white.X &&
+ to->white.Y == from->cieluv.white.Y &&
+ to->white.Z == from->cieluv.white.Z) {
+ *to = from->cieluv;
+ break;
+ }
+ /* fall through */
+ default:
+ other_to_cieluv(from, to);
+ break;
+ }
+}
+
+
+static void
+cieluv_to_cielchuv(const libcolour_cieluv_t *restrict from, libcolour_cielchuv_t *restrict to)
+{
+ libcolour_cieluv_t tmp;
+ TYPE L, u, v;
+ if (to->white.X != from->white.X || to->white.Y != from->white.Y || to->white.Z != from->white.Z) {
+ tmp.model = LIBCOLOUR_CIELUV;
+ tmp.white = to->white;
+ to_cieluv((const libcolour_colour_t *)from, &tmp);
+ L = tmp.L, u = tmp.u, v = tmp.v;
+ } else {
+ L = from->L, u = from->u, v = from->v;
+ }
+ to->L = L;
+ to->C = xsqrt(u * u + v * v);
+ to->h = xatan2(v, u) / PI2 * to->one_revolution;
+ if (!WASDIV0(to->h) && (to->h < 0))
+ to->h += to->one_revolution;
+}
+
+static void
+other_to_cielchuv(const libcolour_colour_t *restrict from, libcolour_cielchuv_t *restrict to)
+{
+ libcolour_cieluv_t tmp;
+ tmp.model = LIBCOLOUR_CIELUV;
+ tmp.white = to->white;
+ to_cieluv(from, &tmp);
+ cieluv_to_cielchuv(&tmp, to);
+}
+
+static void
+to_cielchuv(const libcolour_colour_t *restrict from, libcolour_cielchuv_t *restrict to)
+{
+ TYPE one_revolution;
+ switch (from->model) {
+ case LIBCOLOUR_CIELUV:
+ cieluv_to_cielchuv(&from->cieluv, to);
+ break;
+ case LIBCOLOUR_CIELCHUV:
+ if (to->white.X == from->cielchuv.white.X &&
+ to->white.Y == from->cielchuv.white.Y &&
+ to->white.Z == from->cielchuv.white.Z) {
+ if (to->one_revolution == from->cielchuv.one_revolution) {
+ *to = from->cielchuv;
+ } else {
+ one_revolution = to->one_revolution;
+ *to = from->cielchuv;
+ to->one_revolution = one_revolution;
+ to->h = to->h / from->cielchuv.one_revolution * one_revolution;
+ }
+ break;
+ }
+ /* fall through */
+ default:
+ other_to_cielchuv(from, to);
+ break;
+ }
+}
+
+
+static void
+to_yiq(const libcolour_colour_t *restrict from, libcolour_yiq_t *restrict to)
+{
+ libcolour_colour_t tmp = *from;
+ switch (from->model) {
+ case LIBCOLOUR_YIQ:
+ *to = from->yiq;
+ break;
+ case LIBCOLOUR_SRGB:
+ if (tmp.srgb.with_transfer) {
+ tmp.srgb.with_transfer = 0;
+ to_srgb(from, &tmp.srgb);
+ }
+ TRANSFORM(to->Y, to->I, to->Q, tmp.srgb.R, tmp.srgb.G, tmp.srgb.B, 0.299, 0.587, 0.114,
+ 0.59571613491277464191853141528554260730743408203125, /* (0.877 cos 33°)(1 - 0.299) - (0.492 sin 33°)(-0.299) */
+ -0.27445283783925644716106262421817518770694732666016, /* (0.877 cos 33°)(-0.587) - (0.492 sin 33°)(-0.587) */
+ -0.32126329707351808373516632855171337723731994628906, /* (0.877 cos 33°)(-0.114) - (0.492 sin 33°)(1 - 0.114) */
+ 0.21145640212011795888713550084503367543220520019531, /* (0.877 sin 33°)(1 - 0.299) + (0.492 cos 33°)(-0.299) */
+ -0.52259104529161115593183239980135113000869750976562, /* (0.877 sin 33°)(-0.587) + (0.492 cos 33°)(-0.587) */
+ 0.31113464317149330806699936147197149693965911865234); /* (0.877 sin 33°)(-0.114) + (0.492 cos 33°)(1 - 0.114) */
+ break;
+ default:
+ tmp.model = LIBCOLOUR_CIEXYZ;
+ to_ciexyz(from, &tmp.ciexyz);
+ /* fall through */
+ case LIBCOLOUR_CIEXYZ:
+ TRANSFORM(to->Y, to->I, to->Q, tmp.ciexyz.X, tmp.ciexyz.Y, tmp.ciexyz.Z,
+ 0.40627729168038273499519164033699780702590942382812,
+ 0.61835674212166968910509012857801280915737152099609,
+ -0.00414330221353725880462093300593551248311996459961,
+ 2.17852787350219845308174626552499830722808837890625,
+ -1.36502666214454104753883711964590474963188171386719,
+ -0.64803574634025240541745915834326297044754028320312,
+ 1.20905577682138853923277110880007967352867126464844,
+ -1.36890364998339797431015085749095305800437927246094,
+ 0.20180559439597040016778350945969577878713607788086);
+ break;
+ }
+}
+
+
+static void
+to_ydbdr(const libcolour_colour_t *restrict from, libcolour_ydbdr_t *restrict to)
+{
+ libcolour_colour_t tmp = *from;
+ switch (from->model) {
+ case LIBCOLOUR_YDBDR:
+ *to = from->ydbdr;
+ break;
+ case LIBCOLOUR_SRGB:
+ if (tmp.srgb.with_transfer) {
+ tmp.srgb.with_transfer = 0;
+ to_srgb(from, &tmp.srgb);
+ }
+ TRANSFORM(to->Y, to->Db, to->Dr, tmp.srgb.R, tmp.srgb.G, tmp.srgb.B,
+ 0.299, 0.587, 0.114,
+ -0.450, -0.883, 1.333,
+ -1.333, 1.116, 0.217);
+ break;
+ case LIBCOLOUR_YUV:
+ to->Y = tmp.yuv.Y;
+ to->Db = tmp.yuv.U * D(3.069);
+ to->Dr = -tmp.yuv.V * D(2.169);
+ break;
+ default:
+ tmp.model = LIBCOLOUR_CIEXYZ;
+ to_ciexyz(from, &tmp.ciexyz);
+ /* fall through */
+ case LIBCOLOUR_CIEXYZ:
+ TRANSFORM(to->Y, to->Db, to->Dr, tmp.ciexyz.X, tmp.ciexyz.Y, tmp.ciexyz.Z,
+ 0.40627729168038273499519164033699780702590942382812,
+ 0.61835674212166968910509012857801280915737152099609,
+ -0.00414330221353725880462093300593551248311996459961,
+ -0.52816561102614745237815441214479506015777587890625,
+ -1.23677481526212962315014465275453403592109680175781,
+ 1.59692761635924940222253098909277468919754028320312,
+ -5.38914174974103143966885909321717917919158935546875,
+ 4.09835630362728497999569299281574785709381103515625,
+ 0.94033545560642795013706063400604762136936187744141);
+ break;
+ }
+}
+
+
+static void
+to_yuv(const libcolour_colour_t *restrict from, libcolour_yuv_t *restrict to)
+{
+ libcolour_colour_t tmp = *from;
+ switch (from->model) {
+ case LIBCOLOUR_YUV:
+ *to = from->yuv;
+ break;
+ case LIBCOLOUR_YDBDR:
+ to->Y = from->ydbdr.Y;
+ to->U = from->ydbdr.Db / D(3.069);
+ to->V = from->ydbdr.Dr / D(-2.169);
+ break;
+ case LIBCOLOUR_SRGB:
+ if (tmp.srgb.with_transfer) {
+ tmp.srgb.with_transfer = 0;
+ to_srgb(from, &tmp.srgb);
+ }
+ TRANSFORM(to->Y, to->U, to->V, tmp.srgb.R, tmp.srgb.G, tmp.srgb.B,
+ 0.29899999999999998800959133404830936342477798461914,
+ 0.58699999999999996624922005139524117112159729003906,
+ 0.11400000000000000410782519111307919956743717193604,
+ -0.14662756598240470062854967636667424812912940979004,
+ -0.28771586836102963635752871596196200698614120483398,
+ 0.43434343434343436474165400795754976570606231689453,
+ 0.61456892577224520035628074765554629266262054443359,
+ -0.51452282157676354490405401520547457039356231689453,
+ -0.10004610419548178035231700278018251992762088775635);
+ break;
+ default:
+ tmp.model = LIBCOLOUR_CIEXYZ;
+ to_ciexyz(from, &tmp.ciexyz);
+ /* fall through */
+ case LIBCOLOUR_CIEXYZ:
+ TRANSFORM(to->Y, to->U, to->V, tmp.ciexyz.X, tmp.ciexyz.Y, tmp.ciexyz.Z,
+ 0.40627729168038273499519164033699780702590942382812,
+ 0.61835674212166968910509012857801280915737152099609,
+ -0.00414330221353725880462093300593551248311996459961,
+ -0.17209697328971895746718701047939248383045196533203,
+ -0.40298951295605395239718404809536878019571304321289,
+ 0.52034135430408912093014350830344483256340026855469,
+ 2.48462044709130047692724474472925066947937011718750,
+ -1.88951420176453876997868519538315013051033020019531,
+ -0.43353409663735725798616726933687459677457809448242);
+ break;
+ }
+}
+
+
+static void
+to_ypbpr(const libcolour_colour_t *restrict from, libcolour_ypbpr_t *restrict to)
+{
+ libcolour_colour_t tmp = *from;
+ switch (from->model) {
+ case LIBCOLOUR_YPBPR:
+ *to = from->ypbpr;
+ break;
+ case LIBCOLOUR_SRGB:
+ if (tmp.srgb.with_transfer) {
+ tmp.srgb.with_transfer = 0;
+ to_srgb(from, &tmp.srgb);
+ }
+ to->Y = tmp.srgb.R * D(0.2126) +
+ tmp.srgb.G * D(0.7152) +
+ tmp.srgb.B * D(0.0722);
+ to->Pb = tmp.srgb.B - to->Y;
+ to->Pr = tmp.srgb.R - to->Y;
+ break;
+ default:
+ tmp.model = LIBCOLOUR_CIEXYZ;
+ to_ciexyz(from, &tmp.ciexyz);
+ /* fall through */
+ case LIBCOLOUR_CIEXYZ:
+ TRANSFORM(to->Y, to->Pb, to->Pr, tmp.ciexyz.X, tmp.ciexyz.Y, tmp.ciexyz.Z,
+ -0.00028314209073960778378920011277841695118695497513,
+ 1.00019821310075673892470149439759552478790283203125,
+ 0.00006512054470741990286342115723527967929840087891,
+ 0.05592664565509243568275365987574332393705844879150,
+ -1.20422439283671711685030913940863683819770812988281,
+ 1.05716144717799576113748116767965257167816162109375,
+ 3.24072939673847715269516811531502753496170043945312,
+ -2.53733297492083753610359053709544241428375244140625,
+ -0.49859531356743613805804216099204495549201965332031);
+ break;
+ }
+}
+
+
+static void
+to_ycgco(const libcolour_colour_t *restrict from, libcolour_ycgco_t *restrict to)
+{
+ libcolour_colour_t tmp = *from;
+ switch (from->model) {
+ case LIBCOLOUR_YCGCO:
+ *to = from->ycgco;
+ break;
+ case LIBCOLOUR_SRGB:
+ if (tmp.srgb.with_transfer) {
+ tmp.srgb.with_transfer = 0;
+ to_srgb(from, &tmp.srgb);
+ }
+ to->Y = tmp.srgb.R / 4 + tmp.srgb.G / 2 + tmp.srgb.B / 4;
+ to->Cg = -tmp.srgb.R / 4 + tmp.srgb.G / 2 - tmp.srgb.B / 4;
+ to->Co = tmp.srgb.R / 2 - tmp.srgb.B / 2;
+ break;
+ default:
+ tmp.model = LIBCOLOUR_CIEXYZ;
+ to_ciexyz(from, &tmp.ciexyz);
+ /* fall through */
+ case LIBCOLOUR_CIEXYZ:
+ TRANSFORM(to->Y, to->Cg, to->Co, tmp.ciexyz.X, tmp.ciexyz.Y, tmp.ciexyz.Z,
+ 0.33938913643068269188063368346774950623512268066406,
+ 0.50271574450517486631895280879689380526542663574219,
+ 0.16045211478220866574417868832824751734733581542969,
+ -1.30865574267536244335019546269904822111129760742188,
+ 1.37329621528319534284889869013568386435508728027344,
+ -0.11889607256777862120955546743061859160661697387695,
+ 1.59240137554169236544510113162687048316001892089844,
+ -0.66655429104206020962664069884340278804302215576172,
+ -0.77787838037271606062006412685150280594825744628906);
+ break;
+ }
+}
+
+
+static void
+to_cie1960ucs(const libcolour_colour_t *restrict from, libcolour_cie1960ucs_t *restrict to)
+{
+ libcolour_colour_t tmp = *from;
+ TYPE u, v, w, y;
+ switch (from->model) {
+ case LIBCOLOUR_CIE1960UCS:
+ *to = from->cie1960ucs;
+ return;
+ case LIBCOLOUR_CIEUVW:
+ u = from->cieuvw.U, v = from->cieuvw.V, w = from->cieuvw.W;
+ y = (w + 17) / 25;
+ y *= y * y;
+ w *= 13;
+ to->u = u / w + from->cieuvw.u0;
+ to->v = v / w + from->cieuvw.v0;
+ to->Y = y;
+ return;
+ default:
+ tmp.model = LIBCOLOUR_CIEXYZ;
+ to_ciexyz(from, &tmp.ciexyz);
+ /* fall through */
+ case LIBCOLOUR_CIEXYZ:
+ w = tmp.ciexyz.X + 15 * tmp.ciexyz.Y + 3 * tmp.ciexyz.Z;
+ to->u = 4 * tmp.ciexyz.X / w;
+ to->v = 6 * tmp.ciexyz.Y / w;
+ to->Y = tmp.ciexyz.Y;
+ return;
+ }
+}
+
+
+static void
+to_cieuvw(const libcolour_colour_t *restrict from, libcolour_cieuvw_t *restrict to)
+{
+ TYPE U, V, W, w;
+ libcolour_colour_t tmp = *from;
+ switch (from->model) {
+ case LIBCOLOUR_CIEUVW:
+ U = from->cieuvw.U, V = from->cieuvw.V, W = from->cieuvw.W;
+ w = W * 13;
+ U += w * (from->cieuvw.u0 - to->u0);
+ V += w * (from->cieuvw.v0 - to->v0);
+ to->U = U, to->V = V, to->W = W;
+ break;
+ default:
+ tmp.model = LIBCOLOUR_CIE1960UCS;
+ to_cie1960ucs(from, &tmp.cie1960ucs);
+ /* fall through */
+ case LIBCOLOUR_CIE1960UCS:
+ U = tmp.cie1960ucs.u, V = tmp.cie1960ucs.v, W = tmp.cie1960ucs.Y;
+ W = 25 * xcbrt(W) - 17;
+ w = W * 13;
+ to->U = w * (U - to->u0);
+ to->V = w * (V - to->v0);
+ to->W = W;
+ break;
+ }
+}
+
+
+
+int
+libcolour_convert(const libcolour_colour_t *restrict from, libcolour_colour_t *restrict to)
+{
+#define X(C, T, N) 1 +
+ if (from->model < 0 || from->model > LIST_MODELS(X) 0) {
+#undef X
+ errno = EINVAL;
+ return -1;
+ }
+ switch (to->model) {
+ case LIBCOLOUR_RGB:
+ to_rgb(from, &to->rgb);
+ break;
+ case LIBCOLOUR_SRGB:
+ to_srgb(from, &to->srgb);
+ break;
+ case LIBCOLOUR_CIEXYY:
+ to_ciexyy(from, &to->ciexyy);
+ break;
+ case LIBCOLOUR_CIEXYZ:
+ to_ciexyz(from, &to->ciexyz);
+ break;
+ case LIBCOLOUR_CIELAB:
+ to_cielab(from, &to->cielab);
+ break;
+ case LIBCOLOUR_CIELUV:
+ to_cieluv(from, &to->cieluv);
+ break;
+ case LIBCOLOUR_CIELCHUV:
+ to_cielchuv(from, &to->cielchuv);
+ break;
+ case LIBCOLOUR_YIQ:
+ to_yiq(from, &to->yiq);
+ break;
+ case LIBCOLOUR_YDBDR:
+ to_ydbdr(from, &to->ydbdr);
+ break;
+ case LIBCOLOUR_YUV:
+ to_yuv(from, &to->yuv);
+ break;
+ case LIBCOLOUR_YPBPR:
+ to_ypbpr(from, &to->ypbpr);
+ break;
+ case LIBCOLOUR_YCGCO:
+ to_ycgco(from, &to->ycgco);
+ break;
+ case LIBCOLOUR_CIE1960UCS:
+ to_cie1960ucs(from, &to->cie1960ucs);
+ break;
+ case LIBCOLOUR_CIEUVW:
+ to_cieuvw(from, &to->cieuvw);
+ break;
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+ return 0;
+}
diff --git a/doc/info/appx/fdl.texinfo b/doc/info/appx/fdl.texinfo
deleted file mode 100644
index cb71f05..0000000
--- a/doc/info/appx/fdl.texinfo
+++ /dev/null
@@ -1,505 +0,0 @@
-@c The GNU Free Documentation License.
-@center Version 1.3, 3 November 2008
-
-@c This file is intended to be included within another document,
-@c hence no sectioning command or @node.
-
-@display
-Copyright @copyright{} 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
-@uref{http://fsf.org/}
-
-Everyone is permitted to copy and distribute verbatim copies
-of this license document, but changing it is not allowed.
-@end display
-
-@enumerate 0
-@item
-PREAMBLE
-
-The purpose of this License is to make a manual, textbook, or other
-functional and useful document @dfn{free} in the sense of freedom: to
-assure everyone the effective freedom to copy and redistribute it,
-with or without modifying it, either commercially or noncommercially.
-Secondarily, this License preserves for the author and publisher a way
-to get credit for their work, while not being considered responsible
-for modifications made by others.
-
-This License is a kind of ``copyleft'', which means that derivative
-works of the document must themselves be free in the same sense. It
-complements the GNU General Public License, which is a copyleft
-license designed for free software.
-
-We have designed this License in order to use it for manuals for free
-software, because free software needs free documentation: a free
-program should come with manuals providing the same freedoms that the
-software does. But this License is not limited to software manuals;
-it can be used for any textual work, regardless of subject matter or
-whether it is published as a printed book. We recommend this License
-principally for works whose purpose is instruction or reference.
-
-@item
-APPLICABILITY AND DEFINITIONS
-
-This License applies to any manual or other work, in any medium, that
-contains a notice placed by the copyright holder saying it can be
-distributed under the terms of this License. Such a notice grants a
-world-wide, royalty-free license, unlimited in duration, to use that
-work under the conditions stated herein. The ``Document'', below,
-refers to any such manual or work. Any member of the public is a
-licensee, and is addressed as ``you''. You accept the license if you
-copy, modify or distribute the work in a way requiring permission
-under copyright law.
-
-A ``Modified Version'' of the Document means any work containing the
-Document or a portion of it, either copied verbatim, or with
-modifications and/or translated into another language.
-
-A ``Secondary Section'' is a named appendix or a front-matter section
-of the Document that deals exclusively with the relationship of the
-publishers or authors of the Document to the Document's overall
-subject (or to related matters) and contains nothing that could fall
-directly within that overall subject. (Thus, if the Document is in
-part a textbook of mathematics, a Secondary Section may not explain
-any mathematics.) The relationship could be a matter of historical
-connection with the subject or with related matters, or of legal,
-commercial, philosophical, ethical or political position regarding
-them.
-
-The ``Invariant Sections'' are certain Secondary Sections whose titles
-are designated, as being those of Invariant Sections, in the notice
-that says that the Document is released under this License. If a
-section does not fit the above definition of Secondary then it is not
-allowed to be designated as Invariant. The Document may contain zero
-Invariant Sections. If the Document does not identify any Invariant
-Sections then there are none.
-
-The ``Cover Texts'' are certain short passages of text that are listed,
-as Front-Cover Texts or Back-Cover Texts, in the notice that says that
-the Document is released under this License. A Front-Cover Text may
-be at most 5 words, and a Back-Cover Text may be at most 25 words.
-
-A ``Transparent'' copy of the Document means a machine-readable copy,
-represented in a format whose specification is available to the
-general public, that is suitable for revising the document
-straightforwardly with generic text editors or (for images composed of
-pixels) generic paint programs or (for drawings) some widely available
-drawing editor, and that is suitable for input to text formatters or
-for automatic translation to a variety of formats suitable for input
-to text formatters. A copy made in an otherwise Transparent file
-format whose markup, or absence of markup, has been arranged to thwart
-or discourage subsequent modification by readers is not Transparent.
-An image format is not Transparent if used for any substantial amount
-of text. A copy that is not ``Transparent'' is called ``Opaque''.
-
-Examples of suitable formats for Transparent copies include plain
-ASCII without markup, Texinfo input format, La@TeX{} input
-format, SGML or XML using a publicly available
-DTD, and standard-conforming simple HTML,
-PostScript or PDF designed for human modification. Examples
-of transparent image formats include PNG, XCF and
-JPG. Opaque formats include proprietary formats that can be
-read and edited only by proprietary word processors, SGML or
-XML for which the DTD and/or processing tools are
-not generally available, and the machine-generated HTML,
-PostScript or PDF produced by some word processors for
-output purposes only.
-
-The ``Title Page'' means, for a printed book, the title page itself,
-plus such following pages as are needed to hold, legibly, the material
-this License requires to appear in the title page. For works in
-formats which do not have any title page as such, ``Title Page'' means
-the text near the most prominent appearance of the work's title,
-preceding the beginning of the body of the text.
-
-The ``publisher'' means any person or entity that distributes copies
-of the Document to the public.
-
-A section ``Entitled XYZ'' means a named subunit of the Document whose
-title either is precisely XYZ or contains XYZ in parentheses following
-text that translates XYZ in another language. (Here XYZ stands for a
-specific section name mentioned below, such as ``Acknowledgements'',
-``Dedications'', ``Endorsements'', or ``History''.) To ``Preserve the Title''
-of such a section when you modify the Document means that it remains a
-section ``Entitled XYZ'' according to this definition.
-
-The Document may include Warranty Disclaimers next to the notice which
-states that this License applies to the Document. These Warranty
-Disclaimers are considered to be included by reference in this
-License, but only as regards disclaiming warranties: any other
-implication that these Warranty Disclaimers may have is void and has
-no effect on the meaning of this License.
-
-@item
-VERBATIM COPYING
-
-You may copy and distribute the Document in any medium, either
-commercially or noncommercially, provided that this License, the
-copyright notices, and the license notice saying this License applies
-to the Document are reproduced in all copies, and that you add no other
-conditions whatsoever to those of this License. You may not use
-technical measures to obstruct or control the reading or further
-copying of the copies you make or distribute. However, you may accept
-compensation in exchange for copies. If you distribute a large enough
-number of copies you must also follow the conditions in section 3.
-
-You may also lend copies, under the same conditions stated above, and
-you may publicly display copies.
-
-@item
-COPYING IN QUANTITY
-
-If you publish printed copies (or copies in media that commonly have
-printed covers) of the Document, numbering more than 100, and the
-Document's license notice requires Cover Texts, you must enclose the
-copies in covers that carry, clearly and legibly, all these Cover
-Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
-the back cover. Both covers must also clearly and legibly identify
-you as the publisher of these copies. The front cover must present
-the full title with all words of the title equally prominent and
-visible. You may add other material on the covers in addition.
-Copying with changes limited to the covers, as long as they preserve
-the title of the Document and satisfy these conditions, can be treated
-as verbatim copying in other respects.
-
-If the required texts for either cover are too voluminous to fit
-legibly, you should put the first ones listed (as many as fit
-reasonably) on the actual cover, and continue the rest onto adjacent
-pages.
-
-If you publish or distribute Opaque copies of the Document numbering
-more than 100, you must either include a machine-readable Transparent
-copy along with each Opaque copy, or state in or with each Opaque copy
-a computer-network location from which the general network-using
-public has access to download using public-standard network protocols
-a complete Transparent copy of the Document, free of added material.
-If you use the latter option, you must take reasonably prudent steps,
-when you begin distribution of Opaque copies in quantity, to ensure
-that this Transparent copy will remain thus accessible at the stated
-location until at least one year after the last time you distribute an
-Opaque copy (directly or through your agents or retailers) of that
-edition to the public.
-
-It is requested, but not required, that you contact the authors of the
-Document well before redistributing any large number of copies, to give
-them a chance to provide you with an updated version of the Document.
-
-@item
-MODIFICATIONS
-
-You may copy and distribute a Modified Version of the Document under
-the conditions of sections 2 and 3 above, provided that you release
-the Modified Version under precisely this License, with the Modified
-Version filling the role of the Document, thus licensing distribution
-and modification of the Modified Version to whoever possesses a copy
-of it. In addition, you must do these things in the Modified Version:
-
-@enumerate A
-@item
-Use in the Title Page (and on the covers, if any) a title distinct
-from that of the Document, and from those of previous versions
-(which should, if there were any, be listed in the History section
-of the Document). You may use the same title as a previous version
-if the original publisher of that version gives permission.
-
-@item
-List on the Title Page, as authors, one or more persons or entities
-responsible for authorship of the modifications in the Modified
-Version, together with at least five of the principal authors of the
-Document (all of its principal authors, if it has fewer than five),
-unless they release you from this requirement.
-
-@item
-State on the Title page the name of the publisher of the
-Modified Version, as the publisher.
-
-@item
-Preserve all the copyright notices of the Document.
-
-@item
-Add an appropriate copyright notice for your modifications
-adjacent to the other copyright notices.
-
-@item
-Include, immediately after the copyright notices, a license notice
-giving the public permission to use the Modified Version under the
-terms of this License, in the form shown in the Addendum below.
-
-@item
-Preserve in that license notice the full lists of Invariant Sections
-and required Cover Texts given in the Document's license notice.
-
-@item
-Include an unaltered copy of this License.
-
-@item
-Preserve the section Entitled ``History'', Preserve its Title, and add
-to it an item stating at least the title, year, new authors, and
-publisher of the Modified Version as given on the Title Page. If
-there is no section Entitled ``History'' in the Document, create one
-stating the title, year, authors, and publisher of the Document as
-given on its Title Page, then add an item describing the Modified
-Version as stated in the previous sentence.
-
-@item
-Preserve the network location, if any, given in the Document for
-public access to a Transparent copy of the Document, and likewise
-the network locations given in the Document for previous versions
-it was based on. These may be placed in the ``History'' section.
-You may omit a network location for a work that was published at
-least four years before the Document itself, or if the original
-publisher of the version it refers to gives permission.
-
-@item
-For any section Entitled ``Acknowledgements'' or ``Dedications'', Preserve
-the Title of the section, and preserve in the section all the
-substance and tone of each of the contributor acknowledgements and/or
-dedications given therein.
-
-@item
-Preserve all the Invariant Sections of the Document,
-unaltered in their text and in their titles. Section numbers
-or the equivalent are not considered part of the section titles.
-
-@item
-Delete any section Entitled ``Endorsements''. Such a section
-may not be included in the Modified Version.
-
-@item
-Do not retitle any existing section to be Entitled ``Endorsements'' or
-to conflict in title with any Invariant Section.
-
-@item
-Preserve any Warranty Disclaimers.
-@end enumerate
-
-If the Modified Version includes new front-matter sections or
-appendices that qualify as Secondary Sections and contain no material
-copied from the Document, you may at your option designate some or all
-of these sections as invariant. To do this, add their titles to the
-list of Invariant Sections in the Modified Version's license notice.
-These titles must be distinct from any other section titles.
-
-You may add a section Entitled ``Endorsements'', provided it contains
-nothing but endorsements of your Modified Version by various
-parties---for example, statements of peer review or that the text has
-been approved by an organization as the authoritative definition of a
-standard.
-
-You may add a passage of up to five words as a Front-Cover Text, and a
-passage of up to 25 words as a Back-Cover Text, to the end of the list
-of Cover Texts in the Modified Version. Only one passage of
-Front-Cover Text and one of Back-Cover Text may be added by (or
-through arrangements made by) any one entity. If the Document already
-includes a cover text for the same cover, previously added by you or
-by arrangement made by the same entity you are acting on behalf of,
-you may not add another; but you may replace the old one, on explicit
-permission from the previous publisher that added the old one.
-
-The author(s) and publisher(s) of the Document do not by this License
-give permission to use their names for publicity for or to assert or
-imply endorsement of any Modified Version.
-
-@item
-COMBINING DOCUMENTS
-
-You may combine the Document with other documents released under this
-License, under the terms defined in section 4 above for modified
-versions, provided that you include in the combination all of the
-Invariant Sections of all of the original documents, unmodified, and
-list them all as Invariant Sections of your combined work in its
-license notice, and that you preserve all their Warranty Disclaimers.
-
-The combined work need only contain one copy of this License, and
-multiple identical Invariant Sections may be replaced with a single
-copy. If there are multiple Invariant Sections with the same name but
-different contents, make the title of each such section unique by
-adding at the end of it, in parentheses, the name of the original
-author or publisher of that section if known, or else a unique number.
-Make the same adjustment to the section titles in the list of
-Invariant Sections in the license notice of the combined work.
-
-In the combination, you must combine any sections Entitled ``History''
-in the various original documents, forming one section Entitled
-``History''; likewise combine any sections Entitled ``Acknowledgements'',
-and any sections Entitled ``Dedications''. You must delete all
-sections Entitled ``Endorsements.''
-
-@item
-COLLECTIONS OF DOCUMENTS
-
-You may make a collection consisting of the Document and other documents
-released under this License, and replace the individual copies of this
-License in the various documents with a single copy that is included in
-the collection, provided that you follow the rules of this License for
-verbatim copying of each of the documents in all other respects.
-
-You may extract a single document from such a collection, and distribute
-it individually under this License, provided you insert a copy of this
-License into the extracted document, and follow this License in all
-other respects regarding verbatim copying of that document.
-
-@item
-AGGREGATION WITH INDEPENDENT WORKS
-
-A compilation of the Document or its derivatives with other separate
-and independent documents or works, in or on a volume of a storage or
-distribution medium, is called an ``aggregate'' if the copyright
-resulting from the compilation is not used to limit the legal rights
-of the compilation's users beyond what the individual works permit.
-When the Document is included in an aggregate, this License does not
-apply to the other works in the aggregate which are not themselves
-derivative works of the Document.
-
-If the Cover Text requirement of section 3 is applicable to these
-copies of the Document, then if the Document is less than one half of
-the entire aggregate, the Document's Cover Texts may be placed on
-covers that bracket the Document within the aggregate, or the
-electronic equivalent of covers if the Document is in electronic form.
-Otherwise they must appear on printed covers that bracket the whole
-aggregate.
-
-@item
-TRANSLATION
-
-Translation is considered a kind of modification, so you may
-distribute translations of the Document under the terms of section 4.
-Replacing Invariant Sections with translations requires special
-permission from their copyright holders, but you may include
-translations of some or all Invariant Sections in addition to the
-original versions of these Invariant Sections. You may include a
-translation of this License, and all the license notices in the
-Document, and any Warranty Disclaimers, provided that you also include
-the original English version of this License and the original versions
-of those notices and disclaimers. In case of a disagreement between
-the translation and the original version of this License or a notice
-or disclaimer, the original version will prevail.
-
-If a section in the Document is Entitled ``Acknowledgements'',
-``Dedications'', or ``History'', the requirement (section 4) to Preserve
-its Title (section 1) will typically require changing the actual
-title.
-
-@item
-TERMINATION
-
-You may not copy, modify, sublicense, or distribute the Document
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense, or distribute it is void, and
-will automatically terminate your rights under this License.
-
-However, if you cease all violation of this License, then your license
-from a particular copyright holder is reinstated (a) provisionally,
-unless and until the copyright holder explicitly and finally
-terminates your license, and (b) permanently, if the copyright holder
-fails to notify you of the violation by some reasonable means prior to
-60 days after the cessation.
-
-Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
-Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, receipt of a copy of some or all of the same material does
-not give you any rights to use it.
-
-@item
-FUTURE REVISIONS OF THIS LICENSE
-
-The Free Software Foundation may publish new, revised versions
-of the GNU Free Documentation License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns. See
-@uref{http://www.gnu.org/copyleft/}.
-
-Each version of the License is given a distinguishing version number.
-If the Document specifies that a particular numbered version of this
-License ``or any later version'' applies to it, you have the option of
-following the terms and conditions either of that specified version or
-of any later version that has been published (not as a draft) by the
-Free Software Foundation. If the Document does not specify a version
-number of this License, you may choose any version ever published (not
-as a draft) by the Free Software Foundation. If the Document
-specifies that a proxy can decide which future versions of this
-License can be used, that proxy's public statement of acceptance of a
-version permanently authorizes you to choose that version for the
-Document.
-
-@item
-RELICENSING
-
-``Massive Multiauthor Collaboration Site'' (or ``MMC Site'') means any
-World Wide Web server that publishes copyrightable works and also
-provides prominent facilities for anybody to edit those works. A
-public wiki that anybody can edit is an example of such a server. A
-``Massive Multiauthor Collaboration'' (or ``MMC'') contained in the
-site means any set of copyrightable works thus published on the MMC
-site.
-
-``CC-BY-SA'' means the Creative Commons Attribution-Share Alike 3.0
-license published by Creative Commons Corporation, a not-for-profit
-corporation with a principal place of business in San Francisco,
-California, as well as future copyleft versions of that license
-published by that same organization.
-
-``Incorporate'' means to publish or republish a Document, in whole or
-in part, as part of another Document.
-
-An MMC is ``eligible for relicensing'' if it is licensed under this
-License, and if all works that were first published under this License
-somewhere other than this MMC, and subsequently incorporated in whole
-or in part into the MMC, (1) had no cover texts or invariant sections,
-and (2) were thus incorporated prior to November 1, 2008.
-
-The operator of an MMC Site may republish an MMC contained in the site
-under CC-BY-SA on the same site at any time before August 1, 2009,
-provided the MMC is eligible for relicensing.
-
-@end enumerate
-
-@page
-@heading ADDENDUM: How to use this License for your documents
-
-To use this License in a document you have written, include a copy of
-the License in the document and put the following copyright and
-license notices just after the title page:
-
-@smallexample
-@group
- Copyright (C) @var{year} @var{your name}.
- Permission is granted to copy, distribute and/or modify this document
- under the terms of the GNU Free Documentation License, Version 1.3
- or any later version published by the Free Software Foundation;
- with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
- Texts. A copy of the license is included in the section entitled ``GNU
- Free Documentation License''.
-@end group
-@end smallexample
-
-If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
-replace the ``with@dots{}Texts.''@: line with this:
-
-@smallexample
-@group
- with the Invariant Sections being @var{list their titles}, with
- the Front-Cover Texts being @var{list}, and with the Back-Cover Texts
- being @var{list}.
-@end group
-@end smallexample
-
-If you have Invariant Sections without Cover Texts, or some other
-combination of the three, merge those two alternatives to suit the
-situation.
-
-If your document contains nontrivial examples of program code, we
-recommend releasing these examples in parallel under your choice of
-free software license, such as the GNU General Public License,
-to permit their use in free software.
-
-@c Local Variables:
-@c ispell-local-pdict: "ispell-dict"
-@c End:
diff --git a/doc/info/appx/free-software-needs-free-documentation.texinfo b/doc/info/appx/free-software-needs-free-documentation.texinfo
deleted file mode 100644
index 8800993..0000000
--- a/doc/info/appx/free-software-needs-free-documentation.texinfo
+++ /dev/null
@@ -1,31 +0,0 @@
-@node Free Software Needs Free Documentation
-@appendix Free Software Needs Free Documentation
-
-@indent
-@i{The following article was written by Richard Stallman, founder of the GNU Project.}
-@*
-
-@noindent
-The biggest deficiency in the free software community today is not in the software --- it is the lack of good free documentation that we can include with the free software. Many of our most important programs do not come with free reference manuals and free introductory texts. Documentation is an essential part of any software package; when an important free software package does not come with a free manual and a free tutorial, that is a major gap. We have many such gaps today.
-
-Consider Perl, for instance. The tutorial manuals that people normally use are non-free. How did this come about? Because the authors of those manuals published them with restrictive terms --- no copying, no modification, source files not available --- which exclude them from the free software world.
-
-That wasn't the first time this sort of thing happened, and it was far from the last. Many times we have heard a @sc{GNU} user eagerly describe a manual that he is writing, his intended contribution to the community, only to learn that he had ruined everything by signing a publication contract to make it non-free.
-
-Free documentation, like free software, is a matter of freedom, not price. The problem with the non-free manual is not that publishers charge a price for printed copies --- that in itself is fine. (The Free Software Foundation sells printed copies of manuals, too.) The problem is the restrictions on the use of the manual. Free manuals are available in source code form, and give you permission to copy and modify. Non-free manuals do not allow this.
-
-The criteria of freedom for a free manual are roughly the same as for free software. Redistribution (including the normal kinds of commercial redistribution) must be permitted, so that the manual can accompany every copy of the program, both on-line and on paper.
-
-Permission for modification of the technical content is crucial too. When people modify the software, adding or changing features, if they are conscientious they will change the manual too --- so they can provide accurate and clear documentation for the modified program. A manual that leaves you no choice but to write a new manual to document a changed version of the program is not really available to our community.
-
-Some kinds of limits on the way modification is handled are acceptable. For example, requirements to preserve the original author's copyright notice, the distribution terms, or the list of authors, are ok. It is also no problem to require modified versions to include notice that they were modified. Even entire sections that may not be deleted or changed are acceptable, as long as they deal with nontechnical topics (like this one). These kinds of restrictions are acceptable because they don't obstruct the community's normal use of the manual.
-
-However, it must be possible to modify all the technical content of the manual, and then distribute the result in all the usual media, through all the usual channels. Otherwise, the restrictions obstruct the use of the manual, it is not free, and we need another manual to replace it.
-
-Please spread the word about this issue. Our community continues to lose manuals to proprietary publishing. If we spread the word that free software needs free reference manuals and free tutorials, perhaps the next person who wants to contribute by writing documentation will realize, before it is too late, that only free manuals contribute to the free software community.
-
-If you are writing documentation, please insist on publishing it under the @sc{GNU} Free Documentation License or another free documentation license. Remember that this decision requires your approval --- you don't have to let the publisher decide. Some commercial publishers will use a free license if you insist, but they will not propose the option; it is up to you to raise the issue and say firmly that this is what you want. If the publisher you are dealing with refuses, please try other publishers. If you're not sure whether a proposed license is free, write to licensing@@gnu.org.
-
-You can encourage commercial publishers to sell more free, copylefted manuals and tutorials by buying them, and particularly by buying copies from the publishers that paid for their writing or for major improvements. Meanwhile, try to avoid buying non-free documentation at all. Check the distribution terms of a manual before you buy it, and insist that whoever seeks your business must respect your freedom. Check the history of the book, and try reward the publishers that have paid or pay the authors to work on it.
-
-The Free Software Foundation maintains a list of free documentation published by other publishers, at @url{http://www.fsf.org/doc/other-free-books.html}.
diff --git a/doc/info/appx/gpl.texinfo b/doc/info/appx/gpl.texinfo
deleted file mode 100644
index c773b1d..0000000
--- a/doc/info/appx/gpl.texinfo
+++ /dev/null
@@ -1,717 +0,0 @@
-@c The GNU General Public License.
-@center Version 3, 29 June 2007
-
-@c This file is intended to be included within another document,
-@c hence no sectioning command or @node.
-
-@display
-Copyright @copyright{} 2007 Free Software Foundation, Inc. @url{http://fsf.org/}
-
-Everyone is permitted to copy and distribute verbatim copies of this
-license document, but changing it is not allowed.
-@end display
-
-@heading Preamble
-
-The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
-The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom
-to share and change all versions of a program---to make sure it remains
-free software for all its users. We, the Free Software Foundation,
-use the GNU General Public License for most of our software; it
-applies also to any other work released this way by its authors. You
-can apply it to your programs, too.
-
-When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
-To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you
-have certain responsibilities if you distribute copies of the
-software, or if you modify it: responsibilities to respect the freedom
-of others.
-
-For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too,
-receive or can get the source code. And you must show them these
-terms so they know their rights.
-
-Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
-For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
-Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the
-manufacturer can do so. This is fundamentally incompatible with the
-aim of protecting users' freedom to change the software. The
-systematic pattern of such abuse occurs in the area of products for
-individuals to use, which is precisely where it is most unacceptable.
-Therefore, we have designed this version of the GPL to prohibit the
-practice for those products. If such problems arise substantially in
-other domains, we stand ready to extend this provision to those
-domains in future versions of the GPL, as needed to protect the
-freedom of users.
-
-Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish
-to avoid the special danger that patents applied to a free program
-could make it effectively proprietary. To prevent this, the GPL
-assures that patents cannot be used to render the program non-free.
-
-The precise terms and conditions for copying, distribution and
-modification follow.
-
-@heading TERMS AND CONDITIONS
-
-@enumerate 0
-@item Definitions.
-
-``This License'' refers to version 3 of the GNU General Public License.
-
-``Copyright'' also means copyright-like laws that apply to other kinds
-of works, such as semiconductor masks.
-
-``The Program'' refers to any copyrightable work licensed under this
-License. Each licensee is addressed as ``you''. ``Licensees'' and
-``recipients'' may be individuals or organizations.
-
-To ``modify'' a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of
-an exact copy. The resulting work is called a ``modified version'' of
-the earlier work or a work ``based on'' the earlier work.
-
-A ``covered work'' means either the unmodified Program or a work based
-on the Program.
-
-To ``propagate'' a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
-To ``convey'' a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user
-through a computer network, with no transfer of a copy, is not
-conveying.
-
-An interactive user interface displays ``Appropriate Legal Notices'' to
-the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
-@item Source Code.
-
-The ``source code'' for a work means the preferred form of the work for
-making modifications to it. ``Object code'' means any non-source form
-of a work.
-
-A ``Standard Interface'' means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
-The ``System Libraries'' of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-``Major Component'', in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
-The ``Corresponding Source'' for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
-The Corresponding Source need not include anything that users can
-regenerate automatically from other parts of the Corresponding Source.
-
-The Corresponding Source for a work in source code form is that same
-work.
-
-@item Basic Permissions.
-
-All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
-You may make, run and propagate covered works that you do not convey,
-without conditions so long as your license otherwise remains in force.
-You may convey covered works to others for the sole purpose of having
-them make modifications exclusively for you, or provide you with
-facilities for running those works, provided that you comply with the
-terms of this License in conveying all material for which you do not
-control copyright. Those thus making or running the covered works for
-you must do so exclusively on your behalf, under your direction and
-control, on terms that prohibit them from making any copies of your
-copyrighted material outside their relationship with you.
-
-Conveying under any other circumstances is permitted solely under the
-conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
-@item Protecting Users' Legal Rights From Anti-Circumvention Law.
-
-No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
-When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such
-circumvention is effected by exercising rights under this License with
-respect to the covered work, and you disclaim any intention to limit
-operation or modification of the work as a means of enforcing, against
-the work's users, your or third parties' legal rights to forbid
-circumvention of technological measures.
-
-@item Conveying Verbatim Copies.
-
-You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
-You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
-@item Conveying Modified Source Versions.
-
-You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these
-conditions:
-
-@enumerate a
-@item
-The work must carry prominent notices stating that you modified it,
-and giving a relevant date.
-
-@item
-The work must carry prominent notices stating that it is released
-under this License and any conditions added under section 7. This
-requirement modifies the requirement in section 4 to ``keep intact all
-notices''.
-
-@item
-You must license the entire work, as a whole, under this License to
-anyone who comes into possession of a copy. This License will
-therefore apply, along with any applicable section 7 additional terms,
-to the whole of the work, and all its parts, regardless of how they
-are packaged. This License gives no permission to license the work in
-any other way, but it does not invalidate such permission if you have
-separately received it.
-
-@item
-If the work has interactive user interfaces, each must display
-Appropriate Legal Notices; however, if the Program has interactive
-interfaces that do not display Appropriate Legal Notices, your work
-need not make them do so.
-@end enumerate
-
-A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-``aggregate'' if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
-@item Conveying Non-Source Forms.
-
-You may convey a covered work in object code form under the terms of
-sections 4 and 5, provided that you also convey the machine-readable
-Corresponding Source under the terms of this License, in one of these
-ways:
-
-@enumerate a
-@item
-Convey the object code in, or embodied in, a physical product
-(including a physical distribution medium), accompanied by the
-Corresponding Source fixed on a durable physical medium customarily
-used for software interchange.
-
-@item
-Convey the object code in, or embodied in, a physical product
-(including a physical distribution medium), accompanied by a written
-offer, valid for at least three years and valid for as long as you
-offer spare parts or customer support for that product model, to give
-anyone who possesses the object code either (1) a copy of the
-Corresponding Source for all the software in the product that is
-covered by this License, on a durable physical medium customarily used
-for software interchange, for a price no more than your reasonable
-cost of physically performing this conveying of source, or (2) access
-to copy the Corresponding Source from a network server at no charge.
-
-@item
-Convey individual copies of the object code with a copy of the written
-offer to provide the Corresponding Source. This alternative is
-allowed only occasionally and noncommercially, and only if you
-received the object code with such an offer, in accord with subsection
-6b.
-
-@item
-Convey the object code by offering access from a designated place
-(gratis or for a charge), and offer equivalent access to the
-Corresponding Source in the same way through the same place at no
-further charge. You need not require recipients to copy the
-Corresponding Source along with the object code. If the place to copy
-the object code is a network server, the Corresponding Source may be
-on a different server (operated by you or a third party) that supports
-equivalent copying facilities, provided you maintain clear directions
-next to the object code saying where to find the Corresponding Source.
-Regardless of what server hosts the Corresponding Source, you remain
-obligated to ensure that it is available for as long as needed to
-satisfy these requirements.
-
-@item
-Convey the object code using peer-to-peer transmission, provided you
-inform other peers where the object code and Corresponding Source of
-the work are being offered to the general public at no charge under
-subsection 6d.
-
-@end enumerate
-
-A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
-A ``User Product'' is either (1) a ``consumer product'', which means any
-tangible personal property which is normally used for personal,
-family, or household purposes, or (2) anything designed or sold for
-incorporation into a dwelling. In determining whether a product is a
-consumer product, doubtful cases shall be resolved in favor of
-coverage. For a particular product received by a particular user,
-``normally used'' refers to a typical or common use of that class of
-product, regardless of the status of the particular user or of the way
-in which the particular user actually uses, or expects or is expected
-to use, the product. A product is a consumer product regardless of
-whether the product has substantial commercial, industrial or
-non-consumer uses, unless such uses represent the only significant
-mode of use of the product.
-
-``Installation Information'' for a User Product means any methods,
-procedures, authorization keys, or other information required to
-install and execute modified versions of a covered work in that User
-Product from a modified version of its Corresponding Source. The
-information must suffice to ensure that the continued functioning of
-the modified object code is in no case prevented or interfered with
-solely because modification has been made.
-
-If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
-The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or
-updates for a work that has been modified or installed by the
-recipient, or for the User Product in which it has been modified or
-installed. Access to a network may be denied when the modification
-itself materially and adversely affects the operation of the network
-or violates the rules and protocols for communication across the
-network.
-
-Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
-@item Additional Terms.
-
-``Additional permissions'' are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
-When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
-Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders
-of that material) supplement the terms of this License with terms:
-
-@enumerate a
-@item
-Disclaiming warranty or limiting liability differently from the terms
-of sections 15 and 16 of this License; or
-
-@item
-Requiring preservation of specified reasonable legal notices or author
-attributions in that material or in the Appropriate Legal Notices
-displayed by works containing it; or
-
-@item
-Prohibiting misrepresentation of the origin of that material, or
-requiring that modified versions of such material be marked in
-reasonable ways as different from the original version; or
-
-@item
-Limiting the use for publicity purposes of names of licensors or
-authors of the material; or
-
-@item
-Declining to grant rights under trademark law for use of some trade
-names, trademarks, or service marks; or
-
-@item
-Requiring indemnification of licensors and authors of that material by
-anyone who conveys the material (or modified versions of it) with
-contractual assumptions of liability to the recipient, for any
-liability that these contractual assumptions directly impose on those
-licensors and authors.
-@end enumerate
-
-All other non-permissive additional terms are considered ``further
-restrictions'' within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
-If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
-Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions; the
-above requirements apply either way.
-
-@item Termination.
-
-You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
-However, if you cease all violation of this License, then your license
-from a particular copyright holder is reinstated (a) provisionally,
-unless and until the copyright holder explicitly and finally
-terminates your license, and (b) permanently, if the copyright holder
-fails to notify you of the violation by some reasonable means prior to
-60 days after the cessation.
-
-Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
-Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
-@item Acceptance Not Required for Having Copies.
-
-You are not required to accept this License in order to receive or run
-a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
-@item Automatic Licensing of Downstream Recipients.
-
-Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
-An ``entity transaction'' is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
-You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
-@item Patents.
-
-A ``contributor'' is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's ``contributor version''.
-
-A contributor's ``essential patent claims'' are all patent claims owned
-or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, ``control'' includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
-Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
-In the following three paragraphs, a ``patent license'' is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To ``grant'' such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
-If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. ``Knowingly relying'' means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
-If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
-A patent license is ``discriminatory'' if it does not include within the
-scope of its coverage, prohibits the exercise of, or is conditioned on
-the non-exercise of one or more of the rights that are specifically
-granted under this License. You may not convey a covered work if you
-are a party to an arrangement with a third party that is in the
-business of distributing software, under which you make payment to the
-third party based on the extent of your activity of conveying the
-work, and under which the third party grants, to any of the parties
-who would receive the covered work from you, a discriminatory patent
-license (a) in connection with copies of the covered work conveyed by
-you (or copies made from those copies), or (b) primarily for and in
-connection with specific products or compilations that contain the
-covered work, unless you entered into that arrangement, or that patent
-license was granted, prior to 28 March 2007.
-
-Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
-@item No Surrender of Others' Freedom.
-
-If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey
-a covered work so as to satisfy simultaneously your obligations under
-this License and any other pertinent obligations, then as a
-consequence you may not convey it at all. For example, if you agree
-to terms that obligate you to collect a royalty for further conveying
-from those to whom you convey the Program, the only way you could
-satisfy both those terms and this License would be to refrain entirely
-from conveying the Program.
-
-@item Use with the GNU Affero General Public License.
-
-Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
-@item Revised Versions of this License.
-
-The Free Software Foundation may publish revised and/or new versions
-of the GNU General Public License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies that a certain numbered version of the GNU General Public
-License ``or any later version'' applies to it, you have the option of
-following the terms and conditions either of that numbered version or
-of any later version published by the Free Software Foundation. If
-the Program does not specify a version number of the GNU General
-Public License, you may choose any version ever published by the Free
-Software Foundation.
-
-If the Program specifies that a proxy can decide which future versions
-of the GNU General Public License can be used, that proxy's public
-statement of acceptance of a version permanently authorizes you to
-choose that version for the Program.
-
-Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
-@item Disclaimer of Warranty.
-
-THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW@. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM ``AS IS'' WITHOUT
-WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE@. THE ENTIRE RISK AS TO THE QUALITY AND
-PERFORMANCE OF THE PROGRAM IS WITH YOU@. SHOULD THE PROGRAM PROVE
-DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
-CORRECTION@.
-
-@item Limitation of Liability.
-
-IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
-CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
-ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
-NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
-LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
-TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
-PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES@.
-
-@item Interpretation of Sections 15 and 16.
-
-If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
-@end enumerate
-
-@heading END OF TERMS AND CONDITIONS
-
-@heading How to Apply These Terms to Your New Programs
-
-If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these
-terms.
-
-To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the ``copyright'' line and a pointer to where the full notice is found.
-
-@smallexample
-@var{one line to give the program's name and a brief idea of what it does.}
-Copyright (C) @var{year} @var{name of author}
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or (at
-your option) any later version.
-
-This program 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
-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 @url{http://www.gnu.org/licenses/}.
-@end smallexample
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
-@smallexample
-@var{program} Copyright (C) @var{year} @var{name of author}
-This program comes with ABSOLUTELY NO WARRANTY; for details type @samp{show w}.
-This is free software, and you are welcome to redistribute it
-under certain conditions; type @samp{show c} for details.
-@end smallexample
-
-The hypothetical commands @samp{show w} and @samp{show c} should show
-the appropriate parts of the General Public License. Of course, your
-program's commands 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
-@url{http://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 may consider it more useful to permit linking proprietary
-applications with the library. If this is what you want to do, use
-the GNU Lesser General Public License instead of this License. But
-first, please read @url{http://www.gnu.org/philosophy/why-not-lgpl.html}.
diff --git a/doc/info/chap/colour-spaces.texinfo b/doc/info/chap/colour-spaces.texinfo
deleted file mode 100644
index 9455bbc..0000000
--- a/doc/info/chap/colour-spaces.texinfo
+++ /dev/null
@@ -1,759 +0,0 @@
-@node Colour Spaces
-@chapter Colour Spaces
-
-@menu
-* RGB:: Generic RGB colour spaces.
-* sRGB:: The Standard RGB colour space.
-* CIExyY:: The CIE xyY colour model.
-* CIEXYZ:: The CIE 1931 XYZ colour model.
-* CIELAB:: The CIE L*a*b* colour model.
-* CIELUV:: The CIE 1976 (L*, u*, v*) colour model.
-* CIELChuv:: The CIE LCh@sub{uv} colour model.
-* YIQ:: The YIQ colour model.
-* YDbDr:: The YDbDr colour model.
-* YUV:: The YUV colour model.
-* YPbPr:: The YPbPr colour model.
-* YCgCo:: The YCgCo colour model.
-* CIE 1960 UCS:: The CIE 1960 UCS colour model.
-* CIEUVW:: The CIE 1964 (U*, V*, W*) colour model.
-@end menu
-
-
-
-A colour in @command{libcolour} is represented using
-
-@example
-typedef union libcolour_colour @{
- enum libcolour_model model;
- struct libcolour_rgb rgb;
- struct libcolour_srgb srgb;
- struct libcolour_ciexyy ciexyy;
- struct libcolour_ciexyz ciexyz;
- struct libcolour_cielab cielab;
- struct libcolour_cieluv cieluv;
- struct libcolour_cielchuv cielchuv;
- struct libcolour_yiq yiq;
- struct libcolour_ydbdr ydbdr;
- struct libcolour_yuv yuv;
- struct libcolour_ypbpr ypbpr;
- struct libcolour_ycgco ycgco;
- struct libcolour_cie1960ucs cie1960ucs;
- struct libcolour_cieuvw cieuvw;
-@} libcolour_colour_t;
-@end example
-
-@noindent
-where @code{.model} is used to select colour model.
-Each @code{enum} and @code{struct} is also @code{typedef}:ed
-to the same name but with an @code{_t} suffix.
-
-The macro @code{LIBCOLOUR_LIST_MODELS} can be used to list
-all available colour models. It expands to a list of
-calls to @code{X} with the appropriate value for @code{.model}
-as the first argument and the @code{struct}, using the
-@code{typedef} name with the @code{_t} suffix, which is used
-to represent colours in that colour model as the second
-argument. It can used like this:
-
-@example
-void print_libcolour_srgb_t(libcolour_srgb* colour)
-@{
- printf("sRGB(%lf, %lf, %lf, with_gamma = %i)\n",
- colour->R, colour->G, colour->B, colour->with_gamma);
-@}
-
-/* ... */
-
-void print_colour(libcolour_colour_t* colour)
-@{
-#define X(MODEL, TYPE)\
- case MODEL:\
- print_##TYPE((TYPE*)colour);\
- break;
-#undef X
- switch (colour->model) @{
- LIBCOLOUR_LIST_MODELS
- default:
- printf("Unknown colour model!\n");
- break;
- @}
-@}
-@end example
-
-To convert between a colour into another colour space,
-the function @code{libcolour_convert} is used. It takes
-two arguments, both if the type @code{libcolour_colour_t*}.
-The first parameter is @code{const}, it shall be the
-colour you want to convert. The second parameter shall
-be a different pointer, and it shall have it's @code{.model}
-set to the wanted colour model, and any colour space
-specific parameter for that model shall also be set. It
-can be used like this:
-
-@example
-int to_srgb(const libcolour_colour* from, libcolour_srgb_t* to)
-@{
- to->model = LIBCOLOUR_SRGB;
- to->with_gamma = 1;
- return libcolour_convert(from, to);
-@}
-@end example
-
-@code{libcolour_convert} return 0 on success, on error @math{-1}
-is returned and @code{errno} is to indicate the error. Possible
-errors are:
-@table @code
-@item EINVAL
-Invalid colour model.
-@end table
-
-Colours obtained by conversion can be out of gamut. In RGB
-colour spaces, including sRGB, this means that at least one
-of the values (@code{.R}, @code{.G}, or @code{.B}) is less
-than 0 or greater than 1. @command{libcolour} does not provide
-any colour-matching functions for finding an in-gamut colour.
-
-
-
-@node RGB
-@section Generic RGB
-
-RGB colours, of any RGB colour space, are presented with
-@code{struct libcolour_rgb} (@code{libcolour_rgb_t}), and the
-@code{.model} member shall be set to @code{LIBCOLOUR_RGB}. In
-@code{union libcolour_colour}, @code{.rgb} are used for RGB
-colours. RGB colours are additive.
-
-@code{struct libcolour_rgb} has the following members
-@table @code
-@item enum libcolour_model model
-Shall be set to @code{LIBCOLOUR_RGB}.
-@item double R
-The red value. In-gamut values are between 0 and 1, inclusively.
-@item double G
-The green value. In-gamut values are between 0 and 1, inclusively.
-@item double B
-The blue value. In-gamut values are between 0 and 1, inclusively.
-@item int with_gamma
-Whether the the transfer function is applied to the values
-of @code{.R}, @code{.G}, and @code{.B}, which makes them non-linear.
-@item enum libcolour_encoding_type encoding_type
-One of the following:
-@table @code
-@item LIBCOLOUR_ENCODING_TYPE_LINEAR
-The colour space does not have a transfer function.
-@item LIBCOLOUR_ENCODING_TYPE_SIMPLE
-The colour space uses a simple gamma transfer function
-that only uses the gamma parameter.
-@item LIBCOLOUR_ENCODING_TYPE_REGULAR
-The colour space uses a linear–gamma hybrid transfer
-function that uses the gamma, offset, slope, and
-transition parameters.
-@item LIBCOLOUR_ENCODING_TYPE_CUSTOM
-The colour space uses a custom transfer function.
-@end table
-@item double gamma
-The gamma parameter of the transfer function.
-Ignored unless @code{.encoding_type} is
-@code{LIBCOLOUR_ENCODING_TYPE_SIMPLE} or
-@code{LIBCOLOUR_ENCODING_TYPE_REGULAR}.
-@item double offset
-The offset parameter of the transfer function.
-Ignored unless @code{.encoding_type} is
-@code{LIBCOLOUR_ENCODING_TYPE_REGULAR}.
-@item double slope
-The slope parameter of the transfer function.
-Ignored unless @code{.encoding_type} is
-@code{LIBCOLOUR_ENCODING_TYPE_REGULAR}.
-@item double transition
-The transition parameter of the transfer
-function. Ignored unless @code{.encoding_type}
-is @code{LIBCOLOUR_ENCODING_TYPE_REGULAR}.
-@item double transitioninv
-The inverse value of the transition parameter
-of the transfer function, that is, where the
-transition takes place in the encoded, rather
-than linear, values. This value is set
-automatically. Ignored unless @code{.encoding_type}
-is @code{LIBCOLOUR_ENCODING_TYPE_REGULAR}.
-@item double (*to_encoded_red)(double)
-Function used to apply the red channels transfer function
-to a value. Ignored unless @code{.encoding_type} is
-@code{LIBCOLOUR_ENCODING_TYPE_CUSTOM}.
-@item double (*to_decoded_red)(double)
-Function used to unapply the red channels transfer function
-from a value. Ignored unless @code{.encoding_type} is
-@code{LIBCOLOUR_ENCODING_TYPE_CUSTOM}.
-@item double (*to_encoded_green)(double)
-Function used to apply the green channels transfer function
-to a value. Ignored unless @code{.encoding_type} is
-@code{LIBCOLOUR_ENCODING_TYPE_CUSTOM}.
-@item double (*to_decoded_green)(double)
-Function used to unapply the green channels transfer function
-from a value. Ignored unless @code{.encoding_type} is
-@code{LIBCOLOUR_ENCODING_TYPE_CUSTOM}.
-@item double (*to_encoded_blue)(double)
-Function used to apply the blue channels transfer function
-to a value. Ignored unless @code{.encoding_type} is
-@code{LIBCOLOUR_ENCODING_TYPE_CUSTOM}.
-@item double (*to_decoded_blue)(double)
-Function used to unapply the blue channels transfer function
-from a value. Ignored unless @code{.encoding_type} is
-@code{LIBCOLOUR_ENCODING_TYPE_CUSTOM}.
-@item struct libcolour_ciexyy red
-The CIE xyY value of the red primarily.
-@item struct libcolour_ciexyy green
-The CIE xyY value of the green primarily.
-@item struct libcolour_ciexyy blue
-The CIE xyY value of the blue primarily.
-@item struct libcolour_ciexyy white
-The CIE xyY value of the white point, the Y value
-should usually be 1.
-@item double white_r
-The red value of the white point, should usually by 1.
-@item double white_g
-The green value of the white point, should usually by 1.
-@item double white_b
-The blue value of the white point, should usually by 1.
-@item double M[3][3]
-Matrix used to convert a colour to CIE 1931 XYZ.
-@item double Minv[3][3]
-Matrix used to convert a colour from CIE 1931 XYZ.
-@item enum libcolour_rgb_colour_space colour_space
-The colour space. Set automatically.
-@end table
-
-@code{libcolour_get_rgb_colour_space} is set the
-values in a @code{libcolour_rgb_t} to the those used
-to represent a specified RGB colour space.
-@code{libcolour_get_rgb_colour_space} has two arguments:
-@table @code
-@item libcolour_rgb_t*
-The @code{struct} whose members shall be set to represent
-to selected colour space.
-@item enum libcolour_rgb_colour_space
-The selected colour space.
-@end table
-
-@code{libcolour_get_rgb_colour_space} return 0 on success,
-on error @math{-1} is returned and @code{errno} is to indicate
-the error. Possible errors are:
-@table @code
-@item EINVAL
-Invalid colour space.
-@item EDOM
-The specified colour space parameters cannot be used
-as it results in matematical errors.
-@end table
-
-The following values are available for
-@code{enum libcolour_rgb_colour_space} (@code{libcolour_rgb_colour_space_t}):
-
-@table @code
-@item LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_MEASUREMENTS
-A custom colour space. @code{.red}, @code{.green}, @code{.blue},
-@code{.white}, @code{.white_r}, @code{.white_g} and @code{.white_b}
-must be set. The transfer functions, and parameters, must be set
-manually. @code{.colour_space} must be set to any negative value,
-@code{LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_MEASUREMENTS} (zero),
-@code{LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_MATRIX}, or
-@code{LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_INV_MATRIX}.
-@code{.red.Y}, @code{.green.Y}, @code{.blue.Y} can be any value.
-@item LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_MATRIX
-A custom colour space. @code{.M}, @code{.white_r}, @code{.white_g}
-and @code{.white_b} must be set. The transfer functions, and
-parameters, must be set manually. @code{.colour_space} must be
-set to any negative value,
-@code{LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_MEASUREMENTS} (zero),
-@code{LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_MATRIX}, or
-@code{LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_INV_MATRIX}.
-@item LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_INV_MATRIX
-A custom colour space. @code{.Minv}, @code{.white_r}, @code{.white_g}
-and @code{.white_b} must be set. The transfer functions, and
-parameters, must be set manually. @code{.colour_space} must be
-set to any negative value,
-@code{LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_MEASUREMENTS} (zero),
-@code{LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_MATRIX}, or
-@code{LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_INV_MATRIX}.
-@item LIBCOLOUR_RGB_COLOUR_SPACE_SRGB
-The sRGB colour space.
-@item LIBCOLOUR_RGB_COLOUR_SPACE_ADOBE_RGB
-The Adobe RGB colour space.
-@item LIBCOLOUR_RGB_COLOUR_SPACE_APPLE_RGB
-The Apple RGB (1998) colour space.
-@item LIBCOLOUR_RGB_COLOUR_SPACE_BEST_RGB
-The Best RGB colour space.
-@item LIBCOLOUR_RGB_COLOUR_SPACE_BETA_RGB
-The Beta RGB colour space.
-@item LIBCOLOUR_RGB_COLOUR_SPACE_BRUCE_RGB
-The Bruce RGB colour space.
-@item LIBCOLOUR_RGB_COLOUR_SPACE_CIE_RGB
-The CIE 1931 RGB colour space.
-@item LIBCOLOUR_RGB_COLOUR_SPACE_COLORMATCH_RGB
-The ColorMatch RGB colour space.
-@item LIBCOLOUR_RGB_COLOUR_SPACE_DCI_P3_D65
-The DCI-P3 D65 colour space.
-@item LIBCOLOUR_RGB_COLOUR_SPACE_DCI_P3_THEATER
-The DCI-P3 Theater colour space.
-@item LIBCOLOUR_RGB_COLOUR_SPACE_DON_RGB_4
-The Don RGB 4 colour space.
-@item LIBCOLOUR_RGB_COLOUR_SPACE_ECI_RGB
-The ECI RGB colour space.
-@item LIBCOLOUR_RGB_COLOUR_SPACE_ECI_RGB_V2
-The ECI RGB v2 colour space.
-@item LIBCOLOUR_RGB_COLOUR_SPACE_EKTA_SPACE_PS5
-The Ekta Space PS5 colour space.
-@item LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_601_625_LINE
-The ITU-R Recommendation BT.601, 625 line colour space.
-@item LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_601_525_LINE
-The ITU-R Recommendation BT.601, 525 line colour space.
-@item LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_709
-The ITU-R Recommendation BT.709 colour space.
-@item LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2020
-The ITU-R Recommendation BT.2020 colour space.
-@item LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_EOTF_PQ
-The ITU-R Recommendation BT.2100 colour space,
-using the perceptual quantization (PQ) elctro-optical
-transfer function (EOTF).
-@item LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OOTF_PQ
-The ITU-R Recommendation BT.2100 colour space,
-using the perceptual quantization (PQ) opto-optical
-transfer function (OOTF).
-@item LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OETF_PQ
-The ITU-R Recommendation BT.2100 colour space,
-using the perceptual quantization (PQ) opto-electronic
-transfer function (OETF).
-@item LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_EOTF_HLG
-The ITU-R Recommendation BT.2100 colour space,
-using the Hybrid Log-Gamma (HLG) elctro-optical
-transfer function (EOTF).
-@item LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OOTF_HLG
-The ITU-R Recommendation BT.2100 colour space,
-using the Hybrid Log-Gamma (HLG) opto-optical
-transfer function (OOTF).
-@item LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OETF_HLG
-The ITU-R Recommendation BT.2100 colour space,
-using the Hybrid Log-Gamma (HLG) opto-electronic
-transfer function (OETF).
-@item LIBCOLOUR_RGB_COLOUR_SPACE_LIGHTROOM_RGB
-The Lightroom RGB colour space.
-@item LIBCOLOUR_RGB_COLOUR_SPACE_NTSC_RGB
-The NTSC RGB colour space.
-@item LIBCOLOUR_RGB_COLOUR_SPACE_PAL_SECAM_RGB
-The PAL/SECAM RGB colour space.
-@item LIBCOLOUR_RGB_COLOUR_SPACE_PROPHOTO_RGB
-The ProPhoto RGB colour space.
-@item LIBCOLOUR_RGB_COLOUR_SPACE_SGI_RGB
-The SGI RGB colour space.
-@item LIBCOLOUR_RGB_COLOUR_SPACE_SMPTE_240M_RGB
-The SMPTE 240M RGB colour space.
-@item LIBCOLOUR_RGB_COLOUR_SPACE_SMPTE_C_RGB
-The SMPTE C RGB colour space.
-@item LIBCOLOUR_RGB_COLOUR_SPACE_WIDE_GAMUT_RGB
-The wide-gamut RGB colour space, also known as
-Adobe Wide Gamut RGB.
-@end table
-
-The call @code{libcolour_proper(&c)} on a
-@code{struct libcolour_rgb_t c} (done automatically for
-predefined colour spaces) sets @code{c.red.model},
-@code{c.green.model}, and @code{c.blue.model} to
-@code{LIBCOLOUR_CIEXYY}, and calculate and sets the Y
-values for @code{c.red}, @code{c.green}, and @code{c.blue}.
-Zero is always normally returned, but of there is something
-wrong with with the values of the primaries, @math{-1}
-is returned and @code{errno} is set to @code{EDOM}.
-
-
-
-@node sRGB
-@section Standard RGB
-
-sRGB colours are presented with @code{struct libcolour_srgb}
-(@code{libcolour_srgb_t}), and the @code{.model} member shall
-be set to @code{LIBCOLOUR_SRGB}. In @code{union libcolour_colour},
-@code{.srgb} are used for sRGB colours. This is the colour model
-and colour space normally used on computers, it is however not
-the colour space your monitor have, although it is close to it.
-sRGB is designed after the human eye, but fails to take into
-account how the brain process the input to figure out which
-colour it actually receives.
-
-@code{struct libcolour_srgb} has the following members
-@table @code
-@item enum libcolour_model model
-Shall be set to @code{LIBCOLOUR_SRGB}.
-@item double R
-The red value. In-gamut values are between 0 and 1, inclusively.
-@item double G
-The green value. In-gamut values are between 0 and 1, inclusively.
-@item double B
-The blue value. In-gamut values are between 0 and 1, inclusively.
-@item int with_gamma
-Whether the the transfer function is applied to the values of
-@code{.R}, @code{.G}, and @code{.B}, which makes them non-linear.
-@end table
-
-The RGB color model, of which sRGB is a specific colour space,
-is an additive colour model.
-
-For your convenience, the sRGB transfer function and its inverse
-function is available for your use:
-
-@table @code
-@item double libcolour_srgb_encode(double x)
-Applies the sRGB transfer function.
-@item double libcolour_srgb_decode(double x)
-Unapplies the sRGB transfer function.
-@end table
-
-
-
-@node CIExyY
-@section CIE xyY
-
-CIE xyY colours are presented with @code{struct libcolour_ciexyy}
-(@code{libcolour_ciexyy_t}), and the @code{.model} member shall
-be set to @code{LIBCOLOUR_CIEXYY}. In @code{union libcolour_colour},
-@code{.ciexyy} are used for CIE xyY colours. This colour space is
-derived from CIE 1931 XYZ and is primarily used for representing
-chromaticities.
-
-@code{struct libcolour_ciexyy} has the following members
-@table @code
-@item enum libcolour_model model
-Shall be set to @code{LIBCOLOUR_CIEXYY}.
-@item double x
-The x value.
-@item double y
-The y value.
-@item double Y
-The Y value.
-@end table
-
-CIE xyY is not additive. CIE xyY is defined by
-@math{x = X/(X + Y + Z)}, @math{y = Y/(X + Y + Z)}
-where X, Y, and Z are CIE XYZ values.
-
-
-@node CIEXYZ
-@section CIE 1931 XYZ
-
-CIE 1931 XYZ colours are presented with @code{struct libcolour_ciexyz}
-(@code{libcolour_ciexyz_t}), and the @code{.model} member shall
-be set to @code{LIBCOLOUR_CIEXYZ}. In @code{union libcolour_colour},
-@code{.ciexyz} are used for CIE 1931 XYZ colours. This colour space
-is derived from CIE 1931 RGB and is used as an intermediary
-representation when converting between many colour spaces and
-colour models, making it very useful for device independent colour
-representation.
-
-@code{struct libcolour_ciexyz} has the following members
-@table @code
-@item enum libcolour_model model
-Shall be set to @code{LIBCOLOUR_CIEXYZ}.
-@item double X
-The X value.
-@item double Y
-The Y value.
-@item double Z
-The Z value.
-@end table
-
-CIE 1931 XYZ is additive, since it is defined by matrix
-multiplication with CIE 1932 RGB which is additive because
-it is an RGB colour space.
-
-
-
-@node CIELAB
-@section CIE L*a*b*
-
-CIE L*a*b* colours are presented with @code{struct libcolour_cielab}
-(@code{libcolour_cielab_t}), and the @code{.model} member shall
-be set to @code{LIBCOLOUR_CIELAB}. In @code{union libcolour_colour},
-@code{.cielab} are used for CIE L*a*b* colours. CIE L*a*b*
-approximates human colour perception with a lightness parameter
-(L*) and two chromaticity parameters (a* and b*), it is therefore
-useful in image manipulation applications.
-
-@code{struct libcolour_cielab} has the following members
-@table @code
-@item enum libcolour_model model
-Shall be set to @code{LIBCOLOUR_CIELAB}.
-@item double L
-The L* value. 0 is black, 100 is white.
-@item double a
-The a* value. Negative values are green, positive values are red.
-@item double b
-The b* value. Negative values are blue, positive values are yellow.
-@end table
-
-CIE L*a*b* is not additive, since conversion from
-CIE 1931 XYZ is non-linear. It's white point is the CIE Standard
-Illuminant D50.
-
-
-
-@node CIELUV
-@section CIE 1976 (L*, u*, v*)
-
-CIE 1976 (L*, u*, v*) colours are presented with @code{struct libcolour_cieluv}
-(@code{libcolour_cieluv_t}), and the @code{.model} member shall be set to
-@code{LIBCOLOUR_CIELUV}. In @code{union libcolour_colour}, @code{.cieluv}
-are used for CIE 1976 (L*, u*, v*) colours. CIE 1976 (L*, u*, v*)
-approximates uniform human colour perception.
-
-@code{struct libcolour_cieluv} has the following members
-@table @code
-@item enum libcolour_model model
-Shall be set to @code{LIBCOLOUR_CIELUV}.
-@item double L
-The L* value. 0 is black, 100 is white.
-@item double u
-The u* value.
-@item double v
-The v* value.
-@item struct libcolour_ciexyz white
-The white point.
-@end table
-
-CIE L*u*v* is not additive, since conversion from
-CIE 1931 XYZ is non-linear.
-
-The call @code{libcolour_proper(&c)} on a
-@code{struct libcolour_cieluv_t c} sets
-@code{c.white.model} to @code{LIBCOLOUR_CIEXYZ}.
-Zero is always returned in this case.
-
-
-
-@node CIELChuv
-@section CIE LCh@sub{uv}
-
-CIE LCh@sub{uv} (also known as CIE HLC@sub{uv}) colours are presented
-with @code{struct libcolour_cielchuv} (@code{libcolour_cielchuv_t}), and
-the @code{.model} member shall be set to @code{LIBCOLOUR_CIELCHUV}. In
-@code{union libcolour_colour}, @code{.cielchuv} are used for CIE LCh@sub{uv}
-colours. CIE LCh@sub{uv} approximates uniform human colour perception
-using cylindrical representation.
-
-@code{struct libcolour_cielchuv} has the following members
-@table @code
-@item enum libcolour_model model
-Shall be set to @code{LIBCOLOUR_CIELCHUV}.
-@item double L
-The L* value. 0 is black, 100 is white.
-@item double C
-@iftex
-The @math{{\rm C}^{*}_{\rm uv}} value, the chroma.
-@end iftex
-@ifnottex
-The C*@sub{uv} value, the chroma.
-@end ifnottex
-@item double h
-The h@sub{uv} value, the hue.
-@item struct libcolour_ciexyz white
-The white point.
-@item double one_revolution
-The value lowest positive values of @code{h} that is equivalent to 0.
-360 if the hue is measured in degrees, 400 if the hue is measured in
-gon, and 2 pi if the hue is measured radian. Any value can be used.
-@end table
-
-CIE LCh@sub{uv} is not additive. It is a cylindrical
-representation of CIE 1976 (L*, u*, v*).
-
-The call @code{libcolour_proper(&c)} on a
-@code{struct libcolour_cielchuv_t c} sets
-@code{c.white.model} to @code{LIBCOLOUR_CIEXYZ},
-and if @code{c.one_revolution} is 0, it is set
-to 360. Zero is always returned in this case.
-
-
-@node YIQ
-@section YIQ
-
-YIQ colours are presented with @code{struct libcolour_yiq}
-(@code{libcolour_yiq_t}), and the @code{.model} member shall
-be set to @code{LIBCOLOUR_YIQ}. In @code{union libcolour_colour},
-@code{.yiq} are used for YIQ colours.
-
-@code{struct libcolour_yiq} has the following members
-@table @code
-@item enum libcolour_model model
-Shall be set to @code{LIBCOLOUR_YIQ}.
-@item double Y
-The Y value, the luma. 0 is black, 1 is white.
-@item double I
-The I (in-phase) value. Negative values are blue, positive values are orange.
-@item double Q
-The Q (quadrature) value. Negative values are green, positive values are purple.
-@end table
-
-YIQ is additive, since conversion from CIE 1931 XYZ is done
-with a matrix multiplication. It's white point is the CIE
-Standard Illuminant D65.
-
-
-
-@node YDbDr
-@section YDbDr
-
-YDbDr colours are presented with @code{struct libcolour_ydbdr}
-(@code{libcolour_ydbdr_t}), and the @code{.model} member shall
-be set to @code{LIBCOLOUR_YDBDR}. In @code{union libcolour_colour},
-@code{.ydbdr} are used for YDbDr colours.
-
-@code{struct libcolour_ydbdr} has the following members
-@table @code
-@item enum libcolour_model model
-Shall be set to @code{LIBCOLOUR_YDBDR}.
-@item double Y
-The Y value, the luma. 0 is black, 1 is white.
-@item double Db
-The Db value. Difference (with a factor) between Y and blue.
-@item double Dr
-The Dr value. Difference (with a factor) between Y and red.
-@end table
-
-YDbDr is additive, since conversion from CIE 1931 XYZ is done
-with a matrix multiplication. It's white point is the CIE
-Standard Illuminant D65.
-
-
-
-@node YUV
-@section YUV
-
-YUV colours are presented with @code{struct libcolour_yuv}
-(@code{libcolour_yuv_t}), and the @code{.model} member shall
-be set to @code{LIBCOLOUR_YUV}. In @code{union libcolour_colour},
-@code{.yuv} are used for YUV colours.
-
-@code{struct libcolour_yuv} has the following members
-@table @code
-@item enum libcolour_model model
-Shall be set to @code{LIBCOLOUR_YUV}.
-@item double Y
-The Y value, the luma. 0 is black, 1 is white.
-@item double U
-The U value. Difference (with a factor) between Y and blue.
-@item double V
-The V value. Difference (with a factor) between Y and red.
-@end table
-
-YUV is additive, since conversion from YDbDr is done
-with a diagonal matrix multiplication. It's white point is
-the CIE Standard Illuminant D65.
-
-
-
-@node YPbPr
-@section YP@sub{B}P@sub{R}
-
-YP@sub{B}P@sub{R} colours are presented with @code{struct libcolour_ypbpr}
-(@code{libcolour_ypbpr_t}), and the @code{.model} member shall
-be set to @code{LIBCOLOUR_YPBPR}. In @code{union libcolour_colour},
-@code{.ypbpr} are used for YP@sub{B}P@sub{R} colours.
-
-@code{struct libcolour_ypbpr} has the following members
-@table @code
-@item enum libcolour_model model
-Shall be set to @code{LIBCOLOUR_YPBPR}.
-@item double Y
-The Y value, the luma. 0 is black, 1 is white.
-@item double Pb
-The P@sub{B} value. Difference between Y and blue.
-@item double Pr
-The P@sub{R} value. Difference between Y and red.
-@end table
-
-YPbPr is additive, since conversion from CIE 1931 XYZ is done
-with a matrix multiplication. It's white point is the CIE
-Standard Illuminant D65.
-
-
-
-@node YCgCo
-@section YCgCo
-
-YCgCo colours are presented with @code{struct libcolour_ycgco}
-(@code{libcolour_ycgco_t}), and the @code{.model} member shall
-be set to @code{LIBCOLOUR_YCGCO}. In @code{union libcolour_colour},
-@code{.ycgco} are used for YCgCo colours.
-
-@code{struct libcolour_ycgco} has the following members
-@table @code
-@item enum libcolour_model model
-Shall be set to @code{LIBCOLOUR_YCGCO}.
-@item double Y
-The Y value, the luminance. 0 is black, 1 is white.
-@item double Cg
-The Cg (chrominance green) value.
-@item double co
-The Co (chrominance orange) value.
-@end table
-
-YCgCo is additive, since conversion from CIE 1931 XYZ is done
-with a matrix multiplication. It's white point is the CIE
-Standard Illuminant D65.
-
-
-
-@node CIE 1960 UCS
-@section CIE 1960 UCS
-
-CIE 1960 UCS colours are presented with @code{struct libcolour_cie1960ucs}
-(@code{libcolour_cie1960ucs_t}), and the @code{.model} member shall
-be set to @code{LIBCOLOUR_CIE1960UCS}. In @code{union libcolour_colour},
-@code{.cie1960ucs} are used for CIE 1960 UCS colours.
-
-@code{struct libcolour_cie1960ucs} has the following members
-@table @code
-@item enum libcolour_model model
-Shall be set to @code{LIBCOLOUR_CIE1960UCS}.
-@item double u
-The u value.
-@item double v
-The v value.
-@item double Y
-The Y value, the luminance.
-@end table
-
-CIE 1960 UCS is not additive. CIE 1960 UCS is defined by
-@math{u = 4X/(X + 15Y + 3Z)}, @math{v = 6Y/(X + 15Y + 3Z)}
-where X, Y, and Z are CIE XYZ values.
-
-
-
-@node CIEUVW
-@section CIE 1964 (U*, V*, W*)
-
-CIE 1964 (U*, V*, W*) colours are presented with @code{struct libcolour_cieuvw}
-(@code{libcolour_cieuvw_t}), and the @code{.model} member shall
-be set to @code{LIBCOLOUR_CIEUVW}. In @code{union libcolour_colour},
-@code{.cieuvw} are used for CIE 1964 (U*, V*, W*) colours.
-
-@code{struct libcolour_cieuvw} has the following members
-@table @code
-@item enum libcolour_model model
-Shall be set to @code{LIBCOLOUR_CIEUVW}.
-@item double U
-The U* value.
-@item double V
-The V* value.
-@item double W
-The W* value.
-@item double u0
-The u' chromaticity coordinate of a ``specified white object''.
-u' is defined as @math{4X/(X + 15Y + 3Z)} where X, Y, and Z
-are CIE 1931 XYZ values.
-@item double v0
-The v' chromaticity coordinate of a ``specified white object''.
-u' is defined as @math{9Y/(X + 15Y + 3Z)} where X, Y, and Z
-are CIE 1931 XYZ values.
-@end table
-
-CIE 1960 UCS is not additive.
-
diff --git a/doc/info/chap/functions.texinfo b/doc/info/chap/functions.texinfo
deleted file mode 100644
index 9ddefdf..0000000
--- a/doc/info/chap/functions.texinfo
+++ /dev/null
@@ -1,79 +0,0 @@
-@node Functions
-@chapter Functions
-
-The following functions are available in @command{libcolour}:
-
-@table @code
-@item int libcolour_convert(const libcolour_colour_t* restrict, libcolour_colour_t* restrict)
-Colour space and colour model conversion.
-Described in @ref{Colour Spaces}.
-
-@item double libcolour_srgb_encode(double)
-Apply the sRGB transfer function.
-Described in @ref{sRGB}.
-
-@item double libcolour_srgb_decode(double)
-Unapply the sRGB transfer function.
-Described in @ref{sRGB}.
-
-@item int libcolour_delta_e(const libcolour_colour_t*, const libcolour_colour_t*, double*)
-Calculates the @math{\Delta E^*_{ab}} distance
-(the distance in CIE L*a*b*) of two colours,
-and outputs it to the last parameter.
-Returns 0 on success and @math{-1} one error.
-This function fails if and only if
-@code{libcolour_convert} fails.
-
-@item int libcolour_proper(libcolour_colour_t*)
-Sets any member or submember that may be
-incorrectly set. Returns 0 on success, and
-@math{-1} on error. On error @code{errno}
-set appropriately. Error is only possible
-is there is something wrong with the described
-colour space that cannot be fixed.
-
-@item int libcolour_get_rgb_colour_space(libcolour_rgb_t*, libcolour_rgb_colour_space_t)
-Selects RGB colour space.
-Described in @ref{RGB}.
-
-@item size_t libcolour_marshal(const libcolour_colour_t*, void*)
-Store a colour into a buffer, and returns the number
-of bytes written. If @code{NULL} is given instead of
-a buffer, the number of bytes that would have been
-written is returned.
-
-This function will always write an @code{int} that
-is used to identify the version of @command{libcolour}
-so it can be decoded by future versions.
-
-In addition to this @code{int}, all the content of
-the structure is copied, so uninitialised values
-can be copied. However, it will never copy more than
-the size of the structure used to represent colours
-with used colour model. For example, is the @code{.model}
-member if the colour is set to @code{LIBCOLOUR_SRGB},
-no more than @code{sizeof(libcolour_srgb_t)} is written
-in addition to the initial @code{int}. If the value
-of @code{.model} is invalid, 0 is returned and
-@code{errno} is set to @code{EINVAL}.
-
-The written data is machine architecture specific.
-
-@item size_t libcolour_unmarshal(libcolour_colour_t*, const void*)
-Restores a colour from a buffer, and returns the number
-of bytes read. If @code{NULL} is given instead of
-an output pointer for the colour, the number of bytes
-that would have been read is returned.
-
-If the stored @code{int} at the beginning does
-not match a recognised version of @command{libcolour},
-0 is returned and errno is set to @code{EINVAL}, this
-also happens if the stored colour does not used
-a recognised colour model.
-
-If the stored colour uses a custom (not pre-defined)
-RGB colour space with custom a transfer function, the
-user must set them after calling @code{libcolour_unmarshal}.
-
-@end table
-
diff --git a/doc/info/chap/illuminants.texinfo b/doc/info/chap/illuminants.texinfo
deleted file mode 100644
index e99f671..0000000
--- a/doc/info/chap/illuminants.texinfo
+++ /dev/null
@@ -1,113 +0,0 @@
-@node Illuminants
-@chapter Illuminants
-
-@command{libcolour} provides a number of initialisers
-macros for standard illuminants. The following macros
-expand to a @code{libcolour_ciexyy_t} with the standard
-2 degrees observer value in CIE xyY, each have a
-supplementary 10 degrees observer counterpart using
-suffix @code{_10DEG_OBS}, both with the Y value set
-to 1.
-
-@table @code
-@item LIBCOLOUR_ILLUMINANT_A
-CIE Standard Illuminant A.@*
-Incandescent/Tungsten.@*
-2855.54 K (2848 K in old definition of 1 K).
-
-@item LIBCOLOUR_ILLUMINANT_B
-CIE Standard Illuminant B.@*
-Direct sunlight at noon (obsolete).@*
-4874 K.
-
-@item LIBCOLOUR_ILLUMINANT_C
-CIE Standard Illuminant C.@*
-Average/north sky daylight (obsolete).@*
-6774 K.
-
-@item LIBCOLOUR_ILLUMINANT_D50
-CIE Standard Illuminant D50.@*
-Horizon Light.@*
-5002.78 K (5000 K in old definition of 1 K).
-
-@item LIBCOLOUR_ILLUMINANT_D55
-CIE Standard Illuminant D55.@*
-Mid-morning/mid-afternoon daylight.@*
-5503.06 K (5500 K in old definition of 1 K).
-
-@item LIBCOLOUR_ILLUMINANT_D65
-CIE Standard Illuminant D65.@*
-Noon daylight.@*
-6503.62 K (6500 K in old definition of 1 K).
-
-@item LIBCOLOUR_ILLUMINANT_D75
-CIE Standard Illuminant D75.@*
-North sky daylight.@*
-7504.17 K (7500 K in old definition of 1 K).
-
-@item LIBCOLOUR_ILLUMINANT_E
-CIE Standard Illuminant E.@*
-Equal energy.@*
-5454 K.
-
-@item LIBCOLOUR_ILLUMINANT_F1
-CIE Standard Illuminant F1.@*
-Daylight fluorescent.@*
-6430 K.
-
-@item LIBCOLOUR_ILLUMINANT_F2
-CIE Standard Illuminant F2.@*
-Cool white fluorescent.@*
-4230 K.
-
-@item LIBCOLOUR_ILLUMINANT_F3
-CIE Standard Illuminant F3.@*
-White fluorescent.@*
-3450 K.
-
-@item LIBCOLOUR_ILLUMINANT_F4
-CIE Standard Illuminant F4.@*
-Warm white fluorescent.@*
-2940 K.
-
-@item LIBCOLOUR_ILLUMINANT_F5
-CIE Standard Illuminant F5.@*
-Daylight fluorescent.@*
-6350 K.
-
-@item LIBCOLOUR_ILLUMINANT_F6
-CIE Standard Illuminant F6.@*
-Lite white fluorescent.@*
-4150 K.
-
-@item LIBCOLOUR_ILLUMINANT_F7
-CIE Standard Illuminant F7.@*
-D65 simulator, daylight simulator.@*
-6500 K.
-
-@item LIBCOLOUR_ILLUMINANT_F8
-CIE Standard Illuminant F8.@*
-D50 simulator, Sylvania F40 Design 50.@*
-5000 K.
-
-@item LIBCOLOUR_ILLUMINANT_F9
-CIE Standard Illuminant F9.@*
-Cool white deluxe fluorescent.@*
-4150 K.
-
-@item LIBCOLOUR_ILLUMINANT_F10
-CIE Standard Illuminant F10.@*
-Philips TL85, Ultralume 50.@*
-5000 K.
-
-@item LIBCOLOUR_ILLUMINANT_F11
-CIE Standard Illuminant F11.@*
-Philips TL84, Ultralume 40.@*
-4000 K.
-
-@item LIBCOLOUR_ILLUMINANT_F12
-CIE Standard Illuminant F12.@*
-Philips TL83, Ultralume 30.@*
-3000 K.
-
-@end table
diff --git a/doc/info/chap/overview.texinfo b/doc/info/chap/overview.texinfo
deleted file mode 100644
index 71321aa..0000000
--- a/doc/info/chap/overview.texinfo
+++ /dev/null
@@ -1,20 +0,0 @@
-@node Overview
-@chapter Overview
-
-@command{libcolour} is colour space C library.
-@command{libcolour} is used by including
-the header @file{<libcolour.h>} and by linking
-with @option{-lcolour}.
-
-@command{libcolour} provides conversion between
-a large number of colour spaces, including many
-different RGB colour spaces. It also supports
-encode and non-encoded representations.
-@command{libcolour} futhermore provides access
-to custom RGB colour spaces.
-@ignore
-and custom arbitrary
-additive and subtractive colour spaces, with
-any number of primaries, as long as their
-conversion to CIE XYZ is linear.
-@end ignore
diff --git a/doc/info/content.texinfo b/doc/info/content.texinfo
deleted file mode 100644
index c8e7811..0000000
--- a/doc/info/content.texinfo
+++ /dev/null
@@ -1,69 +0,0 @@
-@c This file includes everything after the titlepage.
-
-
-@ifnothtml
-@c @shortcontents @c (if the table of content gets too large.)
-@contents
-@end ifnothtml
-
-
-@menu
-* Overview:: Brief overview of @command{libcolour}.
-* Colour Spaces:: Colour-space conversion.
-* Illuminants:: Illuminant initialisers.
-* Functions:: Functions available in @command{libcolour}.
-
-* Free Software Needs Free Documentation:: Why free documentation is important.
-* GNU General Public License:: Copying and sharing @command{libcolour}.
-* GNU Free Documentation License:: Copying and sharing this manual.
-
-@detailmenu
- --- The Detailed Node Listing ---
-
-Overview
-
-Colour Spaces
-* RGB:: Generic RGB colour spaces.
-* sRGB:: The Standard RGB colour space.
-* CIExyY:: The CIE xyY colour model.
-* CIEXYZ:: The CIE 1931 XYZ colour model.
-* CIELAB:: The CIE L*a*b* colour model.
-* CIELUV:: The CIE 1976 (L*, u*, v*) colour model.
-* CIELChuv:: The CIE LCh@sub{uv} colour model.
-* YIQ:: The YIQ colour model.
-* YDbDr:: The YDbDr colour model.
-* YUV:: The YUV colour model.
-* YPbPr:: The YPbPr colour model.
-* YCgCo:: The YCgCo colour model.
-* CIE 1960 UCS:: The CIE 1960 UCS colour model.
-* CIEUVW:: The CIE 1964 (U*, V*, W*) colour model.
-
-Illuminants
-
-Functions
-
-Free Software Needs Free Documentation
-
-GNU General Public License
-
-GNU Free Documentation License
-@end detailmenu
-@end menu
-@c In GNU Emacs a @detailmenu can be created with `C-c C-u m`.
-
-
-@include chap/overview.texinfo
-@include chap/colour-spaces.texinfo
-@include chap/illuminants.texinfo
-@include chap/functions.texinfo
-
-@include appx/free-software-needs-free-documentation.texinfo
-
-@node GNU General Public License
-@appendix GNU General Public License
-@include appx/gpl.texinfo
-
-@node GNU Free Documentation License
-@appendix GNU Free Documentation License
-@include appx/fdl.texinfo
-
diff --git a/doc/info/hardcopy-copying.texinfo b/doc/info/hardcopy-copying.texinfo
deleted file mode 100644
index cb6f624..0000000
--- a/doc/info/hardcopy-copying.texinfo
+++ /dev/null
@@ -1,70 +0,0 @@
-@c --- This is a template for the hardcopy-copying.texinfo file. ---
-
-@c Uncomment this when dead tree editions can be ordered.
-@c @set HARDCOPY_AVAILABLE
-
-
-@set PRINTINGNUMBER First
-@set PRINTINGDATE Januari 0000
-@set ISBNNUMBER 0000000000
-
-@ifset HARDCOPY
-@copying
-@ifset VERSION
-This manual documents @value{programnamewiththe} version @value{VERSION}@.
-@end ifset
-@ifclear VERSION
-This manual documents @value{programnamewiththe}.
-@end ifclear
-@*
-@ifset EDITION
-@sc{ISBN} @value{ISBNNUMBER}, @value{EDITION} Edition, @value{PRINTINGNUMBER} Printing, @value{PRINTINGDATE}.
-@end ifset
-@ifclear EDITION
-@sc{ISBN} @value{ISBNNUMBER}, @value{PRINTINGNUMBER} Printing, @value{PRINTINGDATE}.
-@end ifclear
-@*
-
-Printed by:
-@*
-
-X
-
-@*@*
-Copyright @copyright{} 2016 Mattias Andrée @e{maandree@@kth.se}
-@*
-
-@c The copyright information from the main file, add any required
-@c Invariant Sections being used on the dead tree edition.
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version@tie{}1.3 or
-any later version published by the Free Software Foundation;
-with the Invariant Sections being
-``Free Software Needs Free Documentation'',
-the ``GNU General Public License'',
-the ``GNU Free Documentation License'',
-with no Front-Cover Texts,
-and with no Back-Cover Texts.
-A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
-@c THIS WAS LAST UPPDATE 2016-DECEMBER-12 UTC
-@c AUTHORITATIVE COPYRIGHT INFORMATION IS AVAILABLE
-@c IN libclut.texinfo. THIS FILL MUST BE UPDATED
-@c BEFORE PRINTING.
-
-@*
-Cover art by XY Z. Cover design by XY Z. Printed in XYZ.
-@end copying
-@end ifset
-
-
-
-@ifclear HARDCOPY
-@ifset HARDCOPY_AVAILABLE
-@macro orderhardcopy{}
-If you prefer a dead tree edition, you can order one from
-...
-@endif
-@end ifset
-@end ifclear
-
diff --git a/doc/info/libcolour.texinfo b/doc/info/libcolour.texinfo
deleted file mode 100644
index d9eb269..0000000
--- a/doc/info/libcolour.texinfo
+++ /dev/null
@@ -1,103 +0,0 @@
-\input texinfo @c -*-texinfo-*-
-@c %**start of header
-@documentencoding UTF-8
-@include reusable/macros.texinfo
-@copying
-@c --------------------------------------------------------------------------------
-Copyright @copyright{} 2016 @w{Mattias Andrée @e{maandree@@kth.se}}
-
-@quotation
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version@tie{}1.3 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``Free Software Needs Free Documentation'', the
-``GNU General Public License'', the ``GNU Free Documentation License'',
-with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the
-license is included in the section entitled ``GNU Free Documentation License''.
-@end quotation
-@c THIS WAS LAST CHANGED 2016-DECEMBER-12 UTC
-@c When updated, please remember to update hardcopy-copying.texinfo too.
-@c --------------------------------------------------------------------------------
-@end copying
-
-@setfilename libcolour.info
-@settitle libcolour
-@documentlanguage en_GB
-@include titlepage-data.texinfo
-
-@c You can change the title of the document in dir by compiling with
-@c INFO_FLAGS='-c CATEGORY=your_new_category'
-@ifclear CATEGORY
-@set CATEGORY Library
-@end ifclear
-
-@dircategory @value{CATEGORY}
-@direntry
-* libcolour: (libcolour). @value{subtitle}
-@end direntry
-
-@documentdescription
-Reference manual for libcolour.
-A colour space library.
-@end documentdescription
-@c %**end of header
-
-
-@iftex
-@c @set USLETTER
-@c @set AFOURPAPER
-@c @set AFIVEPAPER
-@c @set SMALLBOOK
-
-@c @set HARDCOPY
-@c @set CROPMARKS
-@c @set SKIPCHAPTERNEWPAGE
-@c @set SKIPFONTTEXTSIZE
-@end iftex
-@c @set LOGO
-@c @set DOUBLEHEADINGS
-@c @set SINGLEHEADINGS
-@c @set AMERICANSPACING
-@c @set NOFINALOUT
-
-@ignore
-
- CROPMARKS has no effect unless HARDCOPY is set. CROPMARKS
- and AFIVEPAPER (or actually @cropmarks and @afivepaper) does
- not play well together.
-
- You can configure how TeX output files should look by uncommenting
- @set commands above. Do not uncomment more than one of the paper
- sizes (USLETTER, AFOURPAPER, AFIVEPAPER and SMALLBOOK); if none is
- uncomment AFOURPAPER will be set unless HARDCOPY is set, in which
- case SMALLBOOK will be set. However, if you do not want to modify
- this source file, you can run `make` with for example
- `TEXINFO_FLAGS='--texinfo="@set HARDCOPY"'`.
-
- Finally, you can include, on the front page, the version of libcolour
- that the manual is up to date with, by setting the value of VERSION
- to the version of libcolour, as well as date of the last update by
- setting DATE, and edition by setting EDITION. This is intended for
- printed manuals. The date is recommended to not be more accurate,
- or less accurate, than to the month. The edition should be formatted
- as, for example, ``1@sup{st}''.
-
-@end ignore
-
-@comment You can see these too with TEXINFO_FLAGS.
-@c @paragraphindent asis
-@c @firstparagraphindent none
-@c @exampleindent asis
-@c @kbdinputstyle distinct
-
-@include reusable/paper.texinfo
-
-
-@include hardcopy-copying.texinfo
-@include reusable/titlepage.texinfo
-@setheadings{}
-
-@include content.texinfo
-
-@bye
-
diff --git a/doc/info/reusable/macros.texinfo b/doc/info/reusable/macros.texinfo
deleted file mode 100644
index 8d95983..0000000
--- a/doc/info/reusable/macros.texinfo
+++ /dev/null
@@ -1,48 +0,0 @@
-@c GENERAL ADVICE.
-@c Because of an previous regression bug in Texinfo
-@c it is a good idea to use @w around lines using
-@c macros.
-
-
-@c Use this comment to get a good looking e-mail
-@c address in both the info output and the TeX
-@c processed output.
-@iftex
-@macro e{a}
-(@email{\a\})
-@end macro
-@end iftex
-@ifnottex
-@macro e{a}
-@email{\a\}
-@end macro
-@end ifnottex
-
-@c This is intented do be used inside @example.
-@c At the beginning of non-code text in a source
-@c code comment, use this macro to make it look
-@c good in TeX processed output. End with @xtt.
-@iftex
-@macro xrm{}
-@rm{}
-@end macro
-@end iftex
-@ifnottex
-@macro xrm{}
-@end macro
-@end ifnottex
-
-@c This is intented do be used inside @example.
-@c At the end of non-code text in a source code
-@c comment, use this macro to make it look
-@c good in TeX processed output.
-@iftex
-@macro xtt{}
-@tt{}
-@end macro
-@end iftex
-@ifnottex
-@macro xtt{}
-@end macro
-@end ifnottex
-
diff --git a/doc/info/reusable/paper.texinfo b/doc/info/reusable/paper.texinfo
deleted file mode 100644
index 5a6aca8..0000000
--- a/doc/info/reusable/paper.texinfo
+++ /dev/null
@@ -1,109 +0,0 @@
-@c This file is used, by inclusion, to allow the
-@c builder to specify how output shall be formatted.
-
-@c On dead tree editions we defailt to smallbook format.
-@ifset HARDCOPY
-@ifclear USLETTER
-@ifclear AFOURPAPER
-@ifclear AFIVEPAPER
-@ifclear SMALLBOOK
-@set SMALLBOOK
-@end ifclear
-@end ifclear
-@end ifclear
-@end ifclear
-@end ifset
-
-@c On dead tree editions the heading on the left page
-@c is different from the heading on the right page.
-@c On online editions the heading is identical on the
-@c left pages and on the right pages.
-@ifclear SINGLE_HEADINGS
-@ifclear DOUBLE_HEADINGS
-@ifclear HARDCOPY
-@set SINGLE_HEADINGS
-@end ifclear
-@ifset HARDCOPY
-@set DOUBLE_HEADINGS
-@end ifset
-@end ifclear
-@end ifclear
-
-@c Apply paper format. Default to A4. (Remember
-@c dead tree editions defaulted to smallbook.)
-@ifset AFIVEPAPER
-@afivepaper
-@end ifset
-@ifset SMALLBOOK
-@smallbook
-@end ifset
-@ifclear AFIVEPAPER
-@ifclear SMALLBOOK
-@ifclear USLETTER
-@afourpaper
-@set AFOURPAPER
-@end ifclear
-@end ifclear
-@end ifclear
-@c (Texinfo defaults to US letter, thus nothing is
-@c done for USLETTER.)
-
-@c Only on dead tree editions: optionally add
-@c cropmarks, and by default, chapters begin
-@c on odd page numbers (the right side.)
-@ifset HARDCOPY
-@ifset CROPMARKS
-@cropmarks
-@end ifset
-@ifclear SKIPCHAPTERNEWPAGE
-@setchapternewpage odd
-@end ifclear
-@end ifset
-
-@c Apply font size. On smallbook and A5 default to
-@c 10 points, on A4 and US letter we default to
-@c 11 points.
-@ifclear SKIPFONTTEXTSIZE
-@ifset SMALLBOOK
-@set SMALLFONT
-@end ifset
-@ifset AFIVEPAPER
-@set SMALLFONT
-@end ifset
-@end ifclear
-@ifset SMALLFONT
-@fonttextsize 10
-@end ifset
-@ifclear SMALLFONT
-@iftex @c Because of bug in Texinfo<=4.13
-@fonttextsize 11
-@end iftex
-@end ifclear
-
-@c In America it is customary to have two spaces after
-@c a period. It is not elsewhere. (@frenchspacing is a
-@c misnomer)
-@ifclear AMERICANSPACING
-@frenchspacing on
-@end ifclear
-
-@c This should only be used when writting the document.
-@c It is used to locate overflows. It should be be used
-@c in a printed version. It can be used in an online come
-@c use users can easier detect overflows and report them.
-@ifclear NOFINALOUT
-@finalout
-@end ifclear
-
-
-@c Call this macro after the title page, but before the
-@c table of content, or the short table of content.
-@macro setheadings{}
-@ifset DOUBLEHEADINGS
-@headings double
-@end ifset
-@ifset SINGLEHEADINGS
-@headings single
-@end ifset
-@end macro
-
diff --git a/doc/info/reusable/titlepage.texinfo b/doc/info/reusable/titlepage.texinfo
deleted file mode 100644
index 55981f7..0000000
--- a/doc/info/reusable/titlepage.texinfo
+++ /dev/null
@@ -1,79 +0,0 @@
-@c This file @top or @titlepage.
-
-@ifnottex
-@node Top
-@top @value{title} -- @value{subtitle}
-@insertcopying
-@end ifnottex
-
-@titlepage
-@title @value{title}
-@subtitle @value{subtitle}
-
-@c Date, edition, and version of the program.
-@c Should be set on dead tree editions. Not too
-@c important on online editions.
-@ifset DATE
-@ifset VERSION
-@ifset EDITION
-@subtitle @value{DATE}, @value{programname} version@tie{}@value{VERSION}, @value{EDITION} edition
-@end ifset
-@ifclear EDITION
-@subtitle @value{DATE}, @value{programname} version@tie{}@value{VERSION}
-@end ifclear
-@end ifset
-@ifclear VERSION
-@ifset EDITION
-@subtitle @value{DATE}, @value{EDITION} edition
-@end ifset
-@ifclear EDITION
-@subtitle @value{DATE}
-@end ifclear
-@end ifclear
-@end ifset
-@ifclear DATE
-@ifset VERSION
-@ifset EDITION
-@subtitle @value{programname} version@tie{}@value{VERSION}, @value{EDITION} edition
-@end ifset
-@ifclear EDITION
-@subtitle @value{programname} version@tie{}@value{VERSION}
-@end ifclear
-@end ifset
-@ifclear VERSION
-@ifset EDITION
-@subtitle @value{EDITION} edition
-@end ifset
-@end ifclear
-@end ifclear
-
-@ifset LOGO
-@vskip 0pt plus 1filll
-@c This way, it is centered exactly in pdf and approximently
-@c in dvi and ps. @center does not work for @image in dvi and ps.
-@multitable @columnfractions 0.15 0.7
-@item @tab @center @image{../logo,250px}
-@end multitable
-@vskip 0pt plus 2filll
-@end ifset
-@authors{}
-
-@page
-@ifset HARDCOPY
-@vskip 0pt plus 1filll
-@insertcopying
-@page
-@end ifset
-@ifset HAVE_DEDICATION
-@dedication{}
-@end ifset
-@ifclear HARDCOPY
-@vskip 0pt plus 1filll
-@ifset HARDCOPY_AVAILABLE
-@orderhardcopy{}
-@*
-@end ifset
-@insertcopying
-@end ifclear
-@end titlepage
-
diff --git a/doc/info/titlepage-data.texinfo b/doc/info/titlepage-data.texinfo
deleted file mode 100644
index 6a3ae5c..0000000
--- a/doc/info/titlepage-data.texinfo
+++ /dev/null
@@ -1,23 +0,0 @@
-@c The title and the subtitle of the manual.
-@set title libcolour
-@set subtitle A colour space library
-
-@c The full name of the documented program or package.
-@set programname @command{libcolour}
-@set programnamewiththe @command{libcolour}
-
-
-@c Authors of the manual. Included at the bottom
-@c of the titlepage on TeX processed output.
-@macro authors{}
-@author by Mattias Andrée (maandree)
-@end macro
-
-
-@c Dedication for TeX processed output.
-@c @set HAVE_DEDICATION
-@c @macro dedication{}
-@c @center `'
-@c @end macro
-@c (I don't use dedications, I use quotes.)
-
diff --git a/double.c b/double.c
new file mode 100644
index 0000000..8bc25de
--- /dev/null
+++ b/double.c
@@ -0,0 +1,82 @@
+/* See LICENSE file for copyright and license details. */
+#include "libcolour.h"
+
+#include <alloca.h>
+#include <errno.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define libcolour_colour_t libcolour_colour_lf_t
+#define libcolour_rgb_t libcolour_rgb_lf_t
+#define libcolour_srgb_t libcolour_srgb_lf_t
+#define libcolour_ciexyy_t libcolour_ciexyy_lf_t
+#define libcolour_ciexyz_t libcolour_ciexyz_lf_t
+#define libcolour_cielab_t libcolour_cielab_lf_t
+#define libcolour_cieluv_t libcolour_cieluv_lf_t
+#define libcolour_cielchuv_t libcolour_cielchuv_lf_t
+#define libcolour_yiq_t libcolour_yiq_lf_t
+#define libcolour_ydbdr_t libcolour_ydbdr_lf_t
+#define libcolour_yuv_t libcolour_yuv_lf_t
+#define libcolour_ypbpr_t libcolour_ypbpr_lf_t
+#define libcolour_ycgco_t libcolour_ycgco_lf_t
+#define libcolour_cie1960ucs_t libcolour_cie1960ucs_lf_t
+#define libcolour_cieuvw_t libcolour_cieuvw_lf_t
+
+#define TYPE double
+#define LIST_MODELS(X) LIBCOLOUR_LIST_MODELS(X, lf)
+#define D(X) ((TYPE)(X))
+
+#define LIBCOLOUR_ILLUMINANT_A LIBCOLOUR_ILLUMINANT_A_LF
+#define LIBCOLOUR_ILLUMINANT_B LIBCOLOUR_ILLUMINANT_B_LF
+#define LIBCOLOUR_ILLUMINANT_C LIBCOLOUR_ILLUMINANT_C_LF
+#define LIBCOLOUR_ILLUMINANT_D50 LIBCOLOUR_ILLUMINANT_D50_LF
+#define LIBCOLOUR_ILLUMINANT_D55 LIBCOLOUR_ILLUMINANT_D55_LF
+#define LIBCOLOUR_ILLUMINANT_D65 LIBCOLOUR_ILLUMINANT_D65_LF
+#define LIBCOLOUR_ILLUMINANT_D75 LIBCOLOUR_ILLUMINANT_D75_LF
+#define LIBCOLOUR_ILLUMINANT_E LIBCOLOUR_ILLUMINANT_E_LF
+#define LIBCOLOUR_ILLUMINANT_F1 LIBCOLOUR_ILLUMINANT_F1_LF
+#define LIBCOLOUR_ILLUMINANT_F2 LIBCOLOUR_ILLUMINANT_F2_LF
+#define LIBCOLOUR_ILLUMINANT_F3 LIBCOLOUR_ILLUMINANT_F3_LF
+#define LIBCOLOUR_ILLUMINANT_F4 LIBCOLOUR_ILLUMINANT_F4_LF
+#define LIBCOLOUR_ILLUMINANT_F5 LIBCOLOUR_ILLUMINANT_F5_LF
+#define LIBCOLOUR_ILLUMINANT_F6 LIBCOLOUR_ILLUMINANT_F6_LF
+#define LIBCOLOUR_ILLUMINANT_F7 LIBCOLOUR_ILLUMINANT_F7_LF
+#define LIBCOLOUR_ILLUMINANT_F8 LIBCOLOUR_ILLUMINANT_F8_LF
+#define LIBCOLOUR_ILLUMINANT_F9 LIBCOLOUR_ILLUMINANT_F9_LF
+#define LIBCOLOUR_ILLUMINANT_F10 LIBCOLOUR_ILLUMINANT_F10_LF
+#define LIBCOLOUR_ILLUMINANT_F11 LIBCOLOUR_ILLUMINANT_F11_LF
+#define LIBCOLOUR_ILLUMINANT_F12 LIBCOLOUR_ILLUMINANT_F12_LF
+
+#define xisinf(X) (isinf(X))
+#define xisnan(X) (isnan(X))
+#define xpow(X, Y) (pow((X), (Y)))
+#define xcbrt(X) (cbrt(X))
+#define xsqrt(X) (sqrt(X))
+#define xlog(X) (log(X))
+#define xexp(X) (exp(X))
+#define xsin(X) (sin(X))
+#define xcos(X) (cos(X))
+#define xatan2(X, Y) (atan2((X), (Y)))
+
+#undef libcolour_convert
+#undef libcolour_srgb_encode
+#undef libcolour_srgb_decode
+#undef libcolour_delta_e
+#undef libcolour_proper
+#undef libcolour_get_rgb_colour_space
+#undef libcolour_marshal
+#undef libcolour_unmarshal
+
+#define libcolour_convert libcolour_convert_lf
+#define libcolour_srgb_encode libcolour_srgb_encode_lf
+#define libcolour_srgb_decode libcolour_srgb_decode_lf
+#define libcolour_delta_e libcolour_delta_e_lf
+#define libcolour_proper libcolour_proper_lf
+#define libcolour_get_rgb_colour_space libcolour_get_rgb_colour_space_lf
+#define libcolour_marshal libcolour_marshal_lf
+#define libcolour_unmarshal libcolour_unmarshal_lf
+
+#include "convert-template.c"
+#include "libcolour-template.c"
diff --git a/float.c b/float.c
new file mode 100644
index 0000000..019152c
--- /dev/null
+++ b/float.c
@@ -0,0 +1,82 @@
+/* See LICENSE file for copyright and license details. */
+#include "libcolour.h"
+
+#include <alloca.h>
+#include <errno.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define libcolour_colour_t libcolour_colour_f_t
+#define libcolour_rgb_t libcolour_rgb_f_t
+#define libcolour_srgb_t libcolour_srgb_f_t
+#define libcolour_ciexyy_t libcolour_ciexyy_f_t
+#define libcolour_ciexyz_t libcolour_ciexyz_f_t
+#define libcolour_cielab_t libcolour_cielab_f_t
+#define libcolour_cieluv_t libcolour_cieluv_f_t
+#define libcolour_cielchuv_t libcolour_cielchuv_f_t
+#define libcolour_yiq_t libcolour_yiq_f_t
+#define libcolour_ydbdr_t libcolour_ydbdr_f_t
+#define libcolour_yuv_t libcolour_yuv_f_t
+#define libcolour_ypbpr_t libcolour_ypbpr_f_t
+#define libcolour_ycgco_t libcolour_ycgco_f_t
+#define libcolour_cie1960ucs_t libcolour_cie1960ucs_f_t
+#define libcolour_cieuvw_t libcolour_cieuvw_f_t
+
+#define TYPE float
+#define LIST_MODELS(X) LIBCOLOUR_LIST_MODELS(X, f)
+#define D(X) ((TYPE)(X))
+
+#define LIBCOLOUR_ILLUMINANT_A LIBCOLOUR_ILLUMINANT_A_F
+#define LIBCOLOUR_ILLUMINANT_B LIBCOLOUR_ILLUMINANT_B_F
+#define LIBCOLOUR_ILLUMINANT_C LIBCOLOUR_ILLUMINANT_C_F
+#define LIBCOLOUR_ILLUMINANT_D50 LIBCOLOUR_ILLUMINANT_D50_F
+#define LIBCOLOUR_ILLUMINANT_D55 LIBCOLOUR_ILLUMINANT_D55_F
+#define LIBCOLOUR_ILLUMINANT_D65 LIBCOLOUR_ILLUMINANT_D65_F
+#define LIBCOLOUR_ILLUMINANT_D75 LIBCOLOUR_ILLUMINANT_D75_F
+#define LIBCOLOUR_ILLUMINANT_E LIBCOLOUR_ILLUMINANT_E_F
+#define LIBCOLOUR_ILLUMINANT_F1 LIBCOLOUR_ILLUMINANT_F1_F
+#define LIBCOLOUR_ILLUMINANT_F2 LIBCOLOUR_ILLUMINANT_F2_F
+#define LIBCOLOUR_ILLUMINANT_F3 LIBCOLOUR_ILLUMINANT_F3_F
+#define LIBCOLOUR_ILLUMINANT_F4 LIBCOLOUR_ILLUMINANT_F4_F
+#define LIBCOLOUR_ILLUMINANT_F5 LIBCOLOUR_ILLUMINANT_F5_F
+#define LIBCOLOUR_ILLUMINANT_F6 LIBCOLOUR_ILLUMINANT_F6_F
+#define LIBCOLOUR_ILLUMINANT_F7 LIBCOLOUR_ILLUMINANT_F7_F
+#define LIBCOLOUR_ILLUMINANT_F8 LIBCOLOUR_ILLUMINANT_F8_F
+#define LIBCOLOUR_ILLUMINANT_F9 LIBCOLOUR_ILLUMINANT_F9_F
+#define LIBCOLOUR_ILLUMINANT_F10 LIBCOLOUR_ILLUMINANT_F10_F
+#define LIBCOLOUR_ILLUMINANT_F11 LIBCOLOUR_ILLUMINANT_F11_F
+#define LIBCOLOUR_ILLUMINANT_F12 LIBCOLOUR_ILLUMINANT_F12_F
+
+#define xisinf(X) (isinff(X))
+#define xisnan(X) (isnanf(X))
+#define xpow(X, Y) (powf((X), (Y)))
+#define xcbrt(X) (cbrtf(X))
+#define xsqrt(X) (sqrtf(X))
+#define xlog(X) (logf(X))
+#define xexp(X) (expf(X))
+#define xsin(X) (sinf(X))
+#define xcos(X) (cosf(X))
+#define xatan2(X, Y) (atan2f((X), (Y)))
+
+#undef libcolour_convert
+#undef libcolour_srgb_encode
+#undef libcolour_srgb_decode
+#undef libcolour_delta_e
+#undef libcolour_proper
+#undef libcolour_get_rgb_colour_space
+#undef libcolour_marshal
+#undef libcolour_unmarshal
+
+#define libcolour_convert libcolour_convert_f
+#define libcolour_srgb_encode libcolour_srgb_encode_f
+#define libcolour_srgb_decode libcolour_srgb_decode_f
+#define libcolour_delta_e libcolour_delta_e_f
+#define libcolour_proper libcolour_proper_f
+#define libcolour_get_rgb_colour_space libcolour_get_rgb_colour_space_f
+#define libcolour_marshal libcolour_marshal_f
+#define libcolour_unmarshal libcolour_unmarshal_f
+
+#include "convert-template.c"
+#include "libcolour-template.c"
diff --git a/libcolour-template.c b/libcolour-template.c
new file mode 100644
index 0000000..3862fce
--- /dev/null
+++ b/libcolour-template.c
@@ -0,0 +1,731 @@
+/* See LICENSE file for copyright and license details. */
+
+#if defined(__GNUC__) && !defined(__clang__)
+# pragma GCC diagnostic ignored "-Wfloat-equal"
+#elif defined(__clang__)
+# pragma clang diagnostic ignored "-Wcomma"
+# pragma clang diagnostic ignored "-Wfloat-equal"
+# pragma clang diagnostic ignored "-Wvla"
+# pragma clang diagnostic ignored "-Wtautological-compare"
+# pragma clang diagnostic ignored "-Wcovered-switch-default"
+# pragma clang diagnostic ignored "-Wfloat-conversion"
+# pragma clang diagnostic ignored "-Wconversion"
+# pragma clang diagnostic ignored "-Wdouble-promotion"
+# pragma clang diagnostic ignored "-Wswitch-enum"
+# pragma clang diagnostic ignored "-Wcast-align"
+#endif
+
+
+#define MARSHAL_VERSION 0
+
+
+TYPE
+libcolour_srgb_encode(TYPE t)
+{
+ TYPE sign = 1;
+ if (t < 0) {
+ t = -t;
+ sign = -1;
+ }
+ t = t <= D(0.0031306684425217108) ? D(12.92) * t :
+ D(1.055) * xpow(t, 1 / D(2.4)) - D(0.055);
+ return t * sign;
+}
+
+TYPE
+libcolour_srgb_decode(TYPE t)
+{
+ TYPE sign = 1;
+ if (t < 0) {
+ t = -t;
+ sign = -1;
+ }
+ t = t <= D(0.0031306684425217108) * D(12.92) ? t / D(12.92) :
+ xpow((t + D(0.055)) / D(1.055), D(2.4));
+ return t * sign;
+}
+
+
+int
+libcolour_delta_e(const libcolour_colour_t *a, const libcolour_colour_t *b, TYPE *e)
+{
+ libcolour_cielab_t u, v;
+ u.model = v.model = LIBCOLOUR_CIELAB;
+ if (libcolour_convert(a, (libcolour_colour_t *)&u))
+ return -1;
+ if (libcolour_convert(b, (libcolour_colour_t *)&v))
+ return -1;
+ u.L -= v.L, u.L *= u.L;
+ u.a -= v.a, u.a *= u.a;
+ u.b -= v.b, u.b *= u.b;
+ *e = xsqrt(u.L + u.a + u.b);
+ return 0;
+}
+
+
+#define eliminate(M, n, m) eliminate_(n, m, &(M))
+static int
+eliminate_(size_t n, size_t m, TYPE (*Mp)[n][m])
+{
+#define M (*Mp)
+ size_t r1, r2, c;
+ TYPE d;
+ TYPE *R1;
+ TYPE *R2;
+ for (r1 = 0; r1 < n; r1++) {
+ R1 = M[r1];
+ if (R1[r1] == 0) {
+ for (r2 = r1 + 1; r2 < n; r2++)
+ if (M[r2][r1] != 0)
+ break;
+ if (r2 == n) {
+ errno = EDOM;
+ return -1;
+ }
+ R2 = M[r2];
+ for (c = 0; c < m; c++)
+ d = R1[c], R1[c] = R2[c], R2[c] = d;
+ }
+ d = R1[r1];
+ for (c = 0; c < m; c++)
+ R1[c] /= d;
+ for (r2 = r1 + 1; r2 < n; r2++) {
+ R2 = M[r2];
+ d = R2[r1];
+ for (c = 0; c < m; c++)
+ R2[c] -= R1[c] * d;
+ }
+ }
+ for (r1 = n; --r1;) {
+ R1 = M[r1];
+ for (r2 = r1; r2--;) {
+ R2 = M[r2];
+ d = R2[r1];
+ for (c = 0; c < m; c++)
+ R2[c] -= R1[c] * d;
+ }
+ }
+ return 0;
+#undef M
+}
+
+
+int
+libcolour_proper(libcolour_colour_t *colour)
+{
+ libcolour_colour_t r, g, b, w;
+ TYPE m[3][4];
+ switch (colour->model) {
+ case LIBCOLOUR_CIELUV:
+ colour->cieluv.white.model = LIBCOLOUR_CIEXYZ;
+ break;
+ case LIBCOLOUR_CIELCHUV:
+ colour->cielchuv.white.model = LIBCOLOUR_CIEXYZ;
+ if (!colour->cielchuv.one_revolution)
+ colour->cielchuv.one_revolution = D(360.);
+ break;
+ case LIBCOLOUR_RGB:
+ colour->rgb.red.model = LIBCOLOUR_CIEXYY;
+ colour->rgb.green.model = LIBCOLOUR_CIEXYY;
+ colour->rgb.blue.model = LIBCOLOUR_CIEXYY;
+ colour->rgb.white.model = LIBCOLOUR_CIEXYY;
+ colour->rgb.red.Y = 1;
+ colour->rgb.green.Y = 1;
+ colour->rgb.blue.Y = 1;
+ r.model = g.model = b.model = w.model = LIBCOLOUR_CIEXYZ;
+ libcolour_convert((const libcolour_colour_t *)&colour->rgb.red, &r);
+ libcolour_convert((const libcolour_colour_t *)&colour->rgb.green, &g);
+ libcolour_convert((const libcolour_colour_t *)&colour->rgb.blue, &b);
+ libcolour_convert((const libcolour_colour_t *)&colour->rgb.white, &w);
+ m[0][0] = r.ciexyz.X, m[0][1] = g.ciexyz.X, m[0][2] = b.ciexyz.X, m[0][3] = w.ciexyz.X;
+ m[1][0] = r.ciexyz.Y, m[1][1] = g.ciexyz.Y, m[1][2] = b.ciexyz.Y, m[1][3] = w.ciexyz.Y;
+ m[2][0] = r.ciexyz.Z, m[2][1] = g.ciexyz.Z, m[2][2] = b.ciexyz.Z, m[2][3] = w.ciexyz.Z;
+ if (eliminate(m, 3, 4))
+ return -1;
+ colour->rgb.red.Y = m[0][3];
+ colour->rgb.green.Y = m[1][3];
+ colour->rgb.blue.Y = m[2][3];
+ break;
+ default:
+ break;
+ }
+ return 0;
+}
+
+
+static int
+get_primaries(libcolour_rgb_t *cs)
+{
+ libcolour_colour_t r, g, b, w;
+ TYPE Sr, Sg, Sb;
+ TYPE M[3][6];
+
+ r.model = g.model = b.model = w.model = LIBCOLOUR_CIEXYZ;
+ r.ciexyz.Y = 1;
+ g.ciexyz.Y = 1;
+ b.ciexyz.Y = 1;
+
+ Sr = cs->M[1][0] * cs->white_r;
+ Sg = cs->M[1][1] * cs->white_g;
+ Sb = cs->M[1][2] * cs->white_b;
+
+ r.ciexyz.X = cs->M[0][0] / Sr, r.ciexyz.Z = cs->M[2][0] / Sr;
+ g.ciexyz.X = cs->M[0][1] / Sg, g.ciexyz.Z = cs->M[2][1] / Sg;
+ b.ciexyz.X = cs->M[0][2] / Sb, b.ciexyz.Z = cs->M[2][2] / Sb;
+
+ M[0][0] = r.ciexyz.X, M[0][1] = g.ciexyz.X, M[0][2] = b.ciexyz.X, M[0][3] = 1, M[0][4] = 0, M[0][5] = 0;
+ M[1][0] = r.ciexyz.Y, M[1][1] = g.ciexyz.Y, M[1][2] = b.ciexyz.Y, M[1][3] = 0, M[1][4] = 1, M[1][5] = 0;
+ M[2][0] = r.ciexyz.Z, M[2][1] = g.ciexyz.Z, M[2][2] = b.ciexyz.Z, M[2][3] = 0, M[2][4] = 0, M[2][5] = 1;
+
+ if (eliminate(M, 3, 6))
+ return -1;
+
+ memcpy(M[0], M[0] + 3, 3 * sizeof(TYPE)), M[0][3] = Sr;
+ memcpy(M[1], M[1] + 3, 3 * sizeof(TYPE)), M[1][3] = Sg;
+ memcpy(M[2], M[2] + 3, 3 * sizeof(TYPE)), M[2][3] = Sb;
+
+ if (eliminate(M, 3, 4))
+ return -1;
+
+ w.ciexyz.X = M[0][3];
+ w.ciexyz.Y = M[1][3];
+ w.ciexyz.Z = M[2][3];
+
+ cs->red.model = LIBCOLOUR_CIEXYY;
+ cs->green.model = LIBCOLOUR_CIEXYY;
+ cs->blue.model = LIBCOLOUR_CIEXYY;
+ cs->white.model = LIBCOLOUR_CIEXYY;
+
+ libcolour_convert(&r, (libcolour_colour_t *)&cs->red);
+ libcolour_convert(&g, (libcolour_colour_t *)&cs->green);
+ libcolour_convert(&b, (libcolour_colour_t *)&cs->blue);
+ libcolour_convert(&w, (libcolour_colour_t *)&cs->white);
+
+ return 0;
+}
+
+
+static int
+get_matrices(libcolour_rgb_t *cs)
+{
+ libcolour_colour_t r, g, b, w;
+ TYPE M[3][6];
+ TYPE Sr, Sg, Sb;
+
+ r.model = g.model = b.model = LIBCOLOUR_CIEXYZ;
+ w.model = LIBCOLOUR_CIEXYY;
+ libcolour_convert((const libcolour_colour_t *)&cs->red, &w), w.ciexyy.Y = 1, libcolour_convert(&w, &r);
+ libcolour_convert((const libcolour_colour_t *)&cs->green, &w), w.ciexyy.Y = 1, libcolour_convert(&w, &g);
+ libcolour_convert((const libcolour_colour_t *)&cs->blue, &w), w.ciexyy.Y = 1, libcolour_convert(&w, &b);
+ w.model = LIBCOLOUR_CIEXYZ;
+ libcolour_convert((const libcolour_colour_t *)&cs->white, &w);
+
+ M[0][0] = r.ciexyz.X, M[0][1] = g.ciexyz.X, M[0][2] = b.ciexyz.X, M[0][3] = 1, M[0][4] = 0, M[0][5] = 0;
+ M[1][0] = r.ciexyz.Y, M[1][1] = g.ciexyz.Y, M[1][2] = b.ciexyz.Y, M[1][3] = 0, M[1][4] = 1, M[1][5] = 0;
+ M[2][0] = r.ciexyz.Z, M[2][1] = g.ciexyz.Z, M[2][2] = b.ciexyz.Z, M[2][3] = 0, M[2][4] = 0, M[2][5] = 1;
+
+ if (eliminate(M, 3, 6))
+ return -1;
+
+ Sr = M[0][3] * w.ciexyz.X + M[0][4] * w.ciexyz.Y + M[0][5] * w.ciexyz.Z;
+ Sg = M[1][3] * w.ciexyz.X + M[1][4] * w.ciexyz.Y + M[1][5] * w.ciexyz.Z;
+ Sb = M[2][3] * w.ciexyz.X + M[2][4] * w.ciexyz.Y + M[2][5] * w.ciexyz.Z;
+
+ Sr /= cs->white_r;
+ Sg /= cs->white_g;
+ Sb /= cs->white_b;
+
+ cs->M[0][0] = Sr * r.ciexyz.X, cs->M[0][1] = Sg * g.ciexyz.X, cs->M[0][2] = Sb * b.ciexyz.X;
+ cs->M[1][0] = Sr * r.ciexyz.Y, cs->M[1][1] = Sg * g.ciexyz.Y, cs->M[1][2] = Sb * b.ciexyz.Y;
+ cs->M[2][0] = Sr * r.ciexyz.Z, cs->M[2][1] = Sg * g.ciexyz.Z, cs->M[2][2] = Sb * b.ciexyz.Z;
+
+ memcpy(M[0], cs->M[0], 3 * sizeof(TYPE)), M[0][3] = 1, M[0][4] = 0, M[0][5] = 0;
+ memcpy(M[1], cs->M[1], 3 * sizeof(TYPE)), M[1][3] = 0, M[1][4] = 1, M[1][5] = 0;
+ memcpy(M[2], cs->M[2], 3 * sizeof(TYPE)), M[2][3] = 0, M[2][4] = 0, M[2][5] = 1;
+
+ if (eliminate(M, 3, 6))
+ return -1;
+
+ memcpy(cs->Minv[0], M[0] + 3, 3 * sizeof(TYPE));
+ memcpy(cs->Minv[1], M[1] + 3, 3 * sizeof(TYPE));
+ memcpy(cs->Minv[2], M[2] + 3, 3 * sizeof(TYPE));
+
+ return 0;
+}
+
+
+#define invert(Minv, M, n) invert_(n, &(Minv), &(M))
+static int
+invert_(size_t n, TYPE (*Minvp)[n][n], TYPE (*Mp)[n][n])
+{
+#define Minv (*Minvp)
+#define M (*Mp)
+#define J (*Jp)
+ TYPE J[n][2 * n] = alloca(sizeof(TYPE[n][2 * n]));
+ size_t i;
+ for (i = 0; i < n; i++) {
+ memcpy(J[i], M[i], n * sizeof(TYPE));
+ memset(J[i] + n, 0, n * sizeof(TYPE));
+ J[i][n + i] = 1;
+ }
+ if (eliminate(J, n, 2 * n))
+ return -1;
+ for (i = 0; i < n; i++)
+ memcpy(Minv[i], J[i] + n, n * sizeof(TYPE));
+ return 0;
+#undef J
+#undef M
+#undef Minv
+}
+
+
+static TYPE
+transfer_function_l_star(TYPE t)
+{
+ TYPE sign = 1;
+ if (t < 0) {
+ t = -t;
+ sign = -1;
+ }
+ t = t > D(216.) / D(24389.) ? D(1.16) * xcbrt(t) - D(0.16) : t * D(24389.) / D(2700.);
+ return t * sign;
+}
+
+static TYPE
+invtransfer_function_l_star(TYPE t)
+{
+ TYPE sign = 1;
+ if (t < 0) {
+ t = -t;
+ sign = -1;
+ }
+ t = t > D(0.08) ? (((D(1000000.) * t + D(480000.)) * t +
+ D(76800.)) * t + D(4096.)) / D(1560896.) :
+ t * D(2700.) / D(24389.);
+ return t * sign;
+}
+
+static TYPE
+transfer_function_oetf_hlg(TYPE t)
+{
+ TYPE sign = 1;
+ if (t < 0) {
+ t = -t;
+ sign = -1;
+ }
+ t = 12 * t <= 1 ? xsqrt(3 * t) :
+ D(0.17883277) * xlog(t - D(0.02372241)) + D(1.004293468902569985701234145381);
+ return t * sign;
+}
+
+static TYPE
+invtransfer_function_oetf_hlg(TYPE t)
+{
+ TYPE sign = 1;
+ if (t < 0) {
+ t = -t;
+ sign = -1;
+ }
+ t = t <= D(0.5) ? t * t / 3 :
+ xexp(t - D(1.004293468902569985701234145381)) / D(0.17883277) + D(0.02372241);
+ return t * sign;
+}
+
+
+static void
+get_transfer_function(libcolour_colour_t *cs)
+{
+ if (cs->model == LIBCOLOUR_RGB) {
+ switch (cs->rgb.colour_space) {
+ case LIBCOLOUR_RGB_COLOUR_SPACE_ECI_RGB_V2:
+ cs->rgb.to_encoded_red = cs->rgb.to_encoded_green = cs->rgb.to_encoded_blue = transfer_function_l_star;
+ cs->rgb.to_decoded_red = cs->rgb.to_decoded_green = cs->rgb.to_decoded_blue = invtransfer_function_l_star;
+ break;
+ case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_EOTF_PQ:
+ case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OOTF_PQ:
+ case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OETF_PQ:
+ case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_EOTF_HLG:
+ case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OOTF_HLG:
+ /* TODO http://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.2100-0-201607-I!!PDF-E.pdf */
+ break;
+ case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OETF_HLG:
+ cs->rgb.to_encoded_red = cs->rgb.to_encoded_green = cs->rgb.to_encoded_blue = transfer_function_oetf_hlg;
+ cs->rgb.to_decoded_red = cs->rgb.to_decoded_green = cs->rgb.to_decoded_blue = invtransfer_function_oetf_hlg;
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+
+int
+libcolour_get_rgb_colour_space(libcolour_rgb_t *cs, libcolour_rgb_colour_space_t space)
+{
+#define XYY(XVALUE, YVALUE) (libcolour_ciexyy_t){.model = LIBCOLOUR_CIEXYY, .x = D(XVALUE), .y = D(YVALUE), .Y = 1}
+
+ switch (space) {
+ case LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_MEASUREMENTS:
+ if (get_matrices(cs))
+ return -1;
+ if (cs->encoding_type == LIBCOLOUR_ENCODING_TYPE_REGULAR)
+ cs->transitioninv = cs->transition * cs->slope;
+ return 0;
+
+ case LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_MATRIX:
+ if (invert(cs->Minv, cs->M, 3) || get_primaries(cs))
+ return -1;
+ if (cs->encoding_type == LIBCOLOUR_ENCODING_TYPE_REGULAR)
+ cs->transitioninv = cs->transition * cs->slope;
+ return 0;
+
+ case LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_INV_MATRIX:
+ if (invert(cs->M, cs->Minv, 3) || get_primaries(cs))
+ return -1;
+ if (cs->encoding_type == LIBCOLOUR_ENCODING_TYPE_REGULAR)
+ cs->transitioninv = cs->transition * cs->slope;
+ return 0;
+
+ case LIBCOLOUR_RGB_COLOUR_SPACE_SRGB:
+ cs->red = XYY(0.6400, 0.3300);
+ cs->green = XYY(0.3000, 0.6000);
+ cs->blue = XYY(0.1500, 0.0600);
+ cs->white = LIBCOLOUR_ILLUMINANT_D65;
+ cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_REGULAR;
+ cs->offset = D(0.055);
+ cs->gamma = D(2.4);
+ cs->slope = D(12.92);
+ cs->transition = D(0.0031306684425217108);
+ break;
+
+ case LIBCOLOUR_RGB_COLOUR_SPACE_ADOBE_RGB:
+ cs->red = XYY(0.6400, 0.3300);
+ cs->green = XYY(0.2100, 0.7100);
+ cs->blue = XYY(0.1500, 0.0600);
+ cs->white = LIBCOLOUR_ILLUMINANT_D65;
+ cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
+ cs->gamma = D(2.2);
+ break;
+
+ case LIBCOLOUR_RGB_COLOUR_SPACE_APPLE_RGB:
+ cs->red = XYY(0.6250, 0.3400);
+ cs->green = XYY(0.2800, 0.5950);
+ cs->blue = XYY(0.1550, 0.0700);
+ cs->white = LIBCOLOUR_ILLUMINANT_D65;
+ cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
+ cs->gamma = D(1.8);
+ break;
+
+ case LIBCOLOUR_RGB_COLOUR_SPACE_BEST_RGB:
+ cs->red = XYY(0.7347, 0.2653);
+ cs->green = XYY(0.2150, 0.7750);
+ cs->blue = XYY(0.1300, 0.0350);
+ cs->white = LIBCOLOUR_ILLUMINANT_D50;
+ cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
+ cs->gamma = D(2.2);
+ break;
+
+ case LIBCOLOUR_RGB_COLOUR_SPACE_BETA_RGB:
+ cs->red = XYY(0.6888, 0.3112);
+ cs->green = XYY(0.1986, 0.7551);
+ cs->blue = XYY(0.1265, 0.0352);
+ cs->white = LIBCOLOUR_ILLUMINANT_D50;
+ cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
+ cs->gamma = D(2.2);
+ break;
+
+ case LIBCOLOUR_RGB_COLOUR_SPACE_BRUCE_RGB:
+ cs->red = XYY(0.6400, 0.3300);
+ cs->green = XYY(0.2800, 0.6500);
+ cs->blue = XYY(0.1500, 0.0600);
+ cs->white = LIBCOLOUR_ILLUMINANT_D65;
+ cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
+ cs->gamma = D(2.2);
+ break;
+
+ case LIBCOLOUR_RGB_COLOUR_SPACE_CIE_RGB:
+ cs->red = XYY(0.7350, 0.2650);
+ cs->green = XYY(0.2740, 0.7170);
+ cs->blue = XYY(0.1670, 0.0090);
+ cs->white = LIBCOLOUR_ILLUMINANT_E;
+ cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
+ cs->gamma = D(2.2);
+ break;
+
+ case LIBCOLOUR_RGB_COLOUR_SPACE_COLORMATCH_RGB:
+ cs->red = XYY(0.6300, 0.3400);
+ cs->green = XYY(0.2950, 0.6050);
+ cs->blue = XYY(0.1500, 0.0750);
+ cs->white = LIBCOLOUR_ILLUMINANT_D50;
+ cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
+ cs->gamma = D(1.8);
+ break;
+
+ case LIBCOLOUR_RGB_COLOUR_SPACE_DCI_P3_D65:
+ cs->red = XYY(0.6380, 0.3200);
+ cs->green = XYY(0.2650, 0.6900);
+ cs->blue = XYY(0.1500, 0.0600);
+ cs->white = LIBCOLOUR_ILLUMINANT_D65;
+ cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
+ cs->gamma = D(2.6);
+ break;
+
+ case LIBCOLOUR_RGB_COLOUR_SPACE_DCI_P3_THEATER:
+ cs->red = XYY(0.6380, 0.3200);
+ cs->green = XYY(0.2650, 0.6900);
+ cs->blue = XYY(0.1500, 0.0600);
+ cs->white = XYY(0.314, 0.351);
+ cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
+ cs->gamma = D(2.6);
+ break;
+
+ case LIBCOLOUR_RGB_COLOUR_SPACE_DON_RGB_4:
+ cs->red = XYY(0.6960, 0.3000);
+ cs->green = XYY(0.2150, 0.7650);
+ cs->blue = XYY(0.1300, 0.0350);
+ cs->white = LIBCOLOUR_ILLUMINANT_D50;
+ cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
+ cs->gamma = D(2.2);
+ break;
+
+ case LIBCOLOUR_RGB_COLOUR_SPACE_ECI_RGB:
+ cs->red = XYY(0.6700, 0.3300);
+ cs->green = XYY(0.2100, 0.7100);
+ cs->blue = XYY(0.1400, 0.0800);
+ cs->white = LIBCOLOUR_ILLUMINANT_D50;
+ cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
+ cs->gamma = D(1.8);
+ break;
+
+ case LIBCOLOUR_RGB_COLOUR_SPACE_ECI_RGB_V2:
+ cs->red = XYY(0.6700, 0.3300);
+ cs->green = XYY(0.2100, 0.7100);
+ cs->blue = XYY(0.1400, 0.0800);
+ cs->white = LIBCOLOUR_ILLUMINANT_D50;
+ cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_CUSTOM;
+ break;
+
+ case LIBCOLOUR_RGB_COLOUR_SPACE_EKTA_SPACE_PS5:
+ cs->red = XYY(0.6950, 0.3050);
+ cs->green = XYY(0.2600, 0.7000);
+ cs->blue = XYY(0.1100, 0.0050);
+ cs->white = LIBCOLOUR_ILLUMINANT_D50;
+ cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
+ cs->gamma = D(2.2);
+ break;
+
+ case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_601_625_LINE:
+ cs->red = XYY(0.6400, 0.3300);
+ cs->green = XYY(0.2900, 0.6000);
+ cs->blue = XYY(0.1500, 0.0060);
+ cs->white = LIBCOLOUR_ILLUMINANT_D65;
+ cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_REGULAR;
+ cs->gamma = 1 / D(0.45);
+ cs->offset = D(0.09929682680944);
+ cs->slope = D(4.5);
+ cs->transition = D(0.018053968510807);
+ break;
+
+ case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_601_525_LINE:
+ cs->red = XYY(0.6300, 0.3400);
+ cs->green = XYY(0.3100, 0.5950);
+ cs->blue = XYY(0.1550, 0.0700);
+ cs->white = LIBCOLOUR_ILLUMINANT_D65;
+ cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_REGULAR;
+ cs->gamma = 1 / D(0.45);
+ cs->offset = D(0.09929682680944);
+ cs->slope = D(4.5);
+ cs->transition = D(0.018053968510807);
+ break;
+
+ case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_709:
+ cs->red = XYY(0.6300, 0.3300);
+ cs->green = XYY(0.3000, 0.6000);
+ cs->blue = XYY(0.1500, 0.0600);
+ cs->white = LIBCOLOUR_ILLUMINANT_D65;
+ cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_REGULAR;
+ cs->gamma = 1 / D(0.45);
+ cs->offset = D(0.09929682680944);
+ cs->slope = D(4.5);
+ cs->transition = D(0.018053968510807);
+ break;
+
+ case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2020:
+ cs->red = XYY(0.7080, 0.2920);
+ cs->green = XYY(0.1700, 0.7970);
+ cs->blue = XYY(0.1310, 0.0460);
+ cs->white = LIBCOLOUR_ILLUMINANT_D65;
+ cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_REGULAR;
+ cs->gamma = 1 / D(0.45);
+ cs->offset = D(0.09929682680944);
+ cs->slope = D(4.5);
+ cs->transition = D(0.018053968510807);
+ break;
+
+ case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_EOTF_PQ:
+ case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OOTF_PQ:
+ case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OETF_PQ:
+ case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_EOTF_HLG:
+ case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OOTF_HLG:
+ case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OETF_HLG:
+ cs->red = XYY(0.7080, 0.2920);
+ cs->green = XYY(0.1700, 0.7970);
+ cs->blue = XYY(0.1310, 0.0460);
+ cs->white = LIBCOLOUR_ILLUMINANT_D65;
+ cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_CUSTOM;
+ break;
+
+ case LIBCOLOUR_RGB_COLOUR_SPACE_LIGHTROOM_RGB:
+ cs->red = XYY(0.7347, 0.2653);
+ cs->green = XYY(0.1596, 0.8404);
+ cs->blue = XYY(0.0366, 0.0001);
+ cs->white = LIBCOLOUR_ILLUMINANT_D50;
+ cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_LINEAR;
+ break;
+
+ case LIBCOLOUR_RGB_COLOUR_SPACE_NTSC_RGB:
+ cs->red = XYY(0.6700, 0.3300);
+ cs->green = XYY(0.2100, 0.7100);
+ cs->blue = XYY(0.1400, 0.0800);
+ cs->white = LIBCOLOUR_ILLUMINANT_C;
+ cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_REGULAR;
+ cs->gamma = 1 / D(0.45);
+ cs->offset = D(0.09929682680944);
+ cs->slope = D(4.5);
+ cs->transition = D(0.018053968510807);
+ break;
+
+ case LIBCOLOUR_RGB_COLOUR_SPACE_PAL_SECAM_RGB:
+ cs->red = XYY(0.6400, 0.3300);
+ cs->green = XYY(0.2900, 0.6000);
+ cs->blue = XYY(0.1500, 0.0600);
+ cs->white = LIBCOLOUR_ILLUMINANT_D65;
+ cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_REGULAR;
+ cs->gamma = 1 / D(0.45);
+ cs->offset = D(0.09929682680944);
+ cs->slope = D(4.5);
+ cs->transition = D(0.018053968510807);
+ break;
+
+ case LIBCOLOUR_RGB_COLOUR_SPACE_PROPHOTO_RGB:
+ cs->red = XYY(0.7347, 0.2653);
+ cs->green = XYY(0.1596, 0.8404);
+ cs->blue = XYY(0.0366, 0.0001);
+ cs->white = LIBCOLOUR_ILLUMINANT_D50;
+ cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
+ cs->gamma = D(1.8);
+ break;
+
+ case LIBCOLOUR_RGB_COLOUR_SPACE_SGI_RGB:
+ cs->red = XYY(0.6250, 0.3400);
+ cs->green = XYY(0.2800, 0.5950);
+ cs->blue = XYY(0.1550, 0.0700);
+ cs->white = LIBCOLOUR_ILLUMINANT_D50;
+ cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
+ cs->gamma = D(1.47);
+ break;
+
+ case LIBCOLOUR_RGB_COLOUR_SPACE_SMPTE_240M_RGB:
+ cs->red = XYY(0.6300, 0.3400);
+ cs->green = XYY(0.3100, 0.5950);
+ cs->blue = XYY(0.1550, 0.0700);
+ cs->white = LIBCOLOUR_ILLUMINANT_D65;
+ cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_REGULAR;
+ cs->gamma = 1 / D(0.45);
+ cs->offset = D(0.1115721957735072);
+ cs->slope = D(4.0);
+ cs->transition = D(0.022821585552393633);
+ break;
+
+ case LIBCOLOUR_RGB_COLOUR_SPACE_SMPTE_C_RGB:
+ cs->red = XYY(0.6300, 0.3400);
+ cs->green = XYY(0.3100, 0.5950);
+ cs->blue = XYY(0.1550, 0.0700);
+ cs->white = LIBCOLOUR_ILLUMINANT_D65;
+ cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_REGULAR;
+ cs->gamma = 1 / D(0.45);
+ cs->offset = D(0.09929682680944);
+ cs->slope = D(4.5);
+ cs->transition = D(0.018053968510807);
+ break;
+
+ case LIBCOLOUR_RGB_COLOUR_SPACE_WIDE_GAMUT_RGB:
+ cs->red = XYY(0.7350, 0.2650);
+ cs->green = XYY(0.1150, 0.8260);
+ cs->blue = XYY(0.1570, 0.0180);
+ cs->white = LIBCOLOUR_ILLUMINANT_D50;
+ cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
+ cs->gamma = D(2.19921875);
+ break;
+
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+ if (cs->encoding_type == LIBCOLOUR_ENCODING_TYPE_REGULAR)
+ cs->transitioninv = cs->transition * cs->slope;
+ cs->colour_space = space;
+ cs->white_r = cs->white_g = cs->white_b = 1;
+ if (get_matrices(cs) || libcolour_proper((libcolour_colour_t *)cs))
+ return -1;
+ get_transfer_function((libcolour_colour_t *)cs);
+ return 0;
+
+#undef XYY
+}
+
+
+size_t
+libcolour_marshal(const libcolour_colour_t *colour, void *buf)
+{
+ if (buf)
+ *(int *)buf = MARSHAL_VERSION;
+ switch (colour->model) {
+#define X(C, T, N)\
+ case C:\
+ if (buf)\
+ memcpy((char *)buf + sizeof(int), colour, sizeof(T));\
+ return sizeof(int) + sizeof(T);
+ LIST_MODELS(X)
+#undef X
+ default:
+ errno = EINVAL;
+ return 0;
+ }
+}
+
+
+size_t
+libcolour_unmarshal(libcolour_colour_t *colour, const void *buf)
+{
+ enum libcolour_model model;
+ size_t r;
+ int ver;
+ ver = *(const int *)buf;
+ if (ver != MARSHAL_VERSION) {
+ errno = EINVAL;
+ return 0;
+ }
+ model = *(const enum libcolour_model *)((const char *)buf + sizeof(int));
+ switch (model) {
+#define X(C, T, N)\
+ case C:\
+ if (colour)\
+ memcpy(colour, (const char *)buf + sizeof(int), sizeof(T));\
+ r = sizeof(int) + sizeof(T);\
+ break;
+ LIST_MODELS(X)
+#undef X
+ default:
+ errno = EINVAL;
+ return 0;
+ }
+ if (colour) {
+ if (colour->model == LIBCOLOUR_RGB) {
+ colour->rgb.to_encoded_red = colour->rgb.to_encoded_green = colour->rgb.to_encoded_blue = NULL;
+ colour->rgb.to_decoded_red = colour->rgb.to_decoded_green = colour->rgb.to_decoded_blue = NULL;
+ }
+ get_transfer_function(colour);
+ }
+ return r;
+}
diff --git a/libcolour.h b/libcolour.h
new file mode 100644
index 0000000..0ea98a7
--- /dev/null
+++ b/libcolour.h
@@ -0,0 +1,445 @@
+/* See LICENSE file for copyright and license details. */
+#ifndef LIBCOLOUR_H
+#define LIBCOLOUR_H
+
+#include <stddef.h>
+
+
+#if defined(__GNUC__) && !defined(__clang__)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wpadded"
+#elif defined(__clang__)
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wpadded"
+#endif
+
+
+#define LIBCOLOUR_ILL__(S, T, X_, Y_) (S){.model = LIBCOLOUR_CIEXYY, .x = (T)(X_), .y = (T)(Y_), .Y = 1}
+#define LIBCOLOUR_F__(X_, Y_) LIBCOLOUR_ILL__(libcolour_ciexyy_f_t, float, (X_), (Y_))
+#define LIBCOLOUR_LF__(X_, Y_) LIBCOLOUR_ILL__(libcolour_ciexyy_lf_t, double, (X_), (Y_))
+#define LIBCOLOUR_LLF__(X_, Y_) LIBCOLOUR_ILL__(libcolour_ciexyy_llf_t, long double, (X_), (Y_))
+
+/* 2-degrees observer standard illuminants */
+#define LIBCOLOUR_ILLUMINANT_A_F LIBCOLOUR_F__(0.447573514098910552050369915378, 0.407439444306660847328060981454)
+#define LIBCOLOUR_ILLUMINANT_B_F LIBCOLOUR_F__(0.348407693041403399014654951316, 0.351617234807268863594487129376)
+#define LIBCOLOUR_ILLUMINANT_C_F LIBCOLOUR_F__(0.310058473730255412803558101587, 0.316149707523236456196968902077)
+#define LIBCOLOUR_ILLUMINANT_D50_F LIBCOLOUR_F__(0.345668037029273123028616510055, 0.358496838937619077825047497754)
+#define LIBCOLOUR_ILLUMINANT_D55_F LIBCOLOUR_F__(0.332424102468830251488896010414, 0.347428039087666229445261478759)
+#define LIBCOLOUR_ILLUMINANT_D65_F LIBCOLOUR_F__(0.312726871026564878786047074755, 0.329023206641284038376227272238)
+#define LIBCOLOUR_ILLUMINANT_D75_F LIBCOLOUR_F__(0.299022300412497055166483050925, 0.314852737888341893679466920730)
+#define LIBCOLOUR_ILLUMINANT_E_F LIBCOLOUR_F__(1. / 3, 1. / 3)
+#define LIBCOLOUR_ILLUMINANT_F1_F LIBCOLOUR_F__(0.313062433035651010992950205036, 0.337106477918307445573731229160)
+#define LIBCOLOUR_ILLUMINANT_F2_F LIBCOLOUR_F__(0.372068154452825539113547392844, 0.375122558203110079144693145281)
+#define LIBCOLOUR_ILLUMINANT_F3_F LIBCOLOUR_F__(0.409090035308107391465171076561, 0.394117134255365986206243178458)
+#define LIBCOLOUR_ILLUMINANT_F4_F LIBCOLOUR_F__(0.440181095827666568620628595454, 0.403090691158138336724903183494)
+#define LIBCOLOUR_ILLUMINANT_F5_F LIBCOLOUR_F__(0.313756583095696484075887155996, 0.345160794752101929283583103825)
+#define LIBCOLOUR_ILLUMINANT_F6_F LIBCOLOUR_F__(0.377882361062687466279896852939, 0.388192885537868959122675960316)
+#define LIBCOLOUR_ILLUMINANT_F7_F LIBCOLOUR_F__(0.312852472915475354753311876266, 0.329174178033567632617462095368)
+#define LIBCOLOUR_ILLUMINANT_F8_F LIBCOLOUR_F__(0.345805753550315952971061506105, 0.358617583214377477762724311106)
+#define LIBCOLOUR_ILLUMINANT_F9_F LIBCOLOUR_F__(0.374105245592801061160770359493, 0.372672400924498159469067104510)
+#define LIBCOLOUR_ILLUMINANT_F10_F LIBCOLOUR_F__(0.346086913993929323751785886998, 0.358751605952200347537939251197)
+#define LIBCOLOUR_ILLUMINANT_F11_F LIBCOLOUR_F__(0.380537485483030235577928124258, 0.376915309293930078649026427229)
+#define LIBCOLOUR_ILLUMINANT_F12_F LIBCOLOUR_F__(0.437023901312296902954557253906, 0.404214327891585678553809657387)
+
+#define LIBCOLOUR_ILLUMINANT_A_LF LIBCOLOUR_LF__(0.447573514098910552050369915378, 0.407439444306660847328060981454)
+#define LIBCOLOUR_ILLUMINANT_B_LF LIBCOLOUR_LF__(0.348407693041403399014654951316, 0.351617234807268863594487129376)
+#define LIBCOLOUR_ILLUMINANT_C_LF LIBCOLOUR_LF__(0.310058473730255412803558101587, 0.316149707523236456196968902077)
+#define LIBCOLOUR_ILLUMINANT_D50_LF LIBCOLOUR_LF__(0.345668037029273123028616510055, 0.358496838937619077825047497754)
+#define LIBCOLOUR_ILLUMINANT_D55_LF LIBCOLOUR_LF__(0.332424102468830251488896010414, 0.347428039087666229445261478759)
+#define LIBCOLOUR_ILLUMINANT_D65_LF LIBCOLOUR_LF__(0.312726871026564878786047074755, 0.329023206641284038376227272238)
+#define LIBCOLOUR_ILLUMINANT_D75_LF LIBCOLOUR_LF__(0.299022300412497055166483050925, 0.314852737888341893679466920730)
+#define LIBCOLOUR_ILLUMINANT_E_LF LIBCOLOUR_LF__(1. / 3, 1. / 3)
+#define LIBCOLOUR_ILLUMINANT_F1_LF LIBCOLOUR_LF__(0.313062433035651010992950205036, 0.337106477918307445573731229160)
+#define LIBCOLOUR_ILLUMINANT_F2_LF LIBCOLOUR_LF__(0.372068154452825539113547392844, 0.375122558203110079144693145281)
+#define LIBCOLOUR_ILLUMINANT_F3_LF LIBCOLOUR_LF__(0.409090035308107391465171076561, 0.394117134255365986206243178458)
+#define LIBCOLOUR_ILLUMINANT_F4_LF LIBCOLOUR_LF__(0.440181095827666568620628595454, 0.403090691158138336724903183494)
+#define LIBCOLOUR_ILLUMINANT_F5_LF LIBCOLOUR_LF__(0.313756583095696484075887155996, 0.345160794752101929283583103825)
+#define LIBCOLOUR_ILLUMINANT_F6_LF LIBCOLOUR_LF__(0.377882361062687466279896852939, 0.388192885537868959122675960316)
+#define LIBCOLOUR_ILLUMINANT_F7_LF LIBCOLOUR_LF__(0.312852472915475354753311876266, 0.329174178033567632617462095368)
+#define LIBCOLOUR_ILLUMINANT_F8_LF LIBCOLOUR_LF__(0.345805753550315952971061506105, 0.358617583214377477762724311106)
+#define LIBCOLOUR_ILLUMINANT_F9_LF LIBCOLOUR_LF__(0.374105245592801061160770359493, 0.372672400924498159469067104510)
+#define LIBCOLOUR_ILLUMINANT_F10_LF LIBCOLOUR_LF__(0.346086913993929323751785886998, 0.358751605952200347537939251197)
+#define LIBCOLOUR_ILLUMINANT_F11_LF LIBCOLOUR_LF__(0.380537485483030235577928124258, 0.376915309293930078649026427229)
+#define LIBCOLOUR_ILLUMINANT_F12_LF LIBCOLOUR_LF__(0.437023901312296902954557253906, 0.404214327891585678553809657387)
+
+#define LIBCOLOUR_ILLUMINANT_A_LLF LIBCOLOUR_LLF__(0.447573514098910552050369915378, 0.407439444306660847328060981454)
+#define LIBCOLOUR_ILLUMINANT_B_LLF LIBCOLOUR_LLF__(0.348407693041403399014654951316, 0.351617234807268863594487129376)
+#define LIBCOLOUR_ILLUMINANT_C_LLF LIBCOLOUR_LLF__(0.310058473730255412803558101587, 0.316149707523236456196968902077)
+#define LIBCOLOUR_ILLUMINANT_D50_LLF LIBCOLOUR_LLF__(0.345668037029273123028616510055, 0.358496838937619077825047497754)
+#define LIBCOLOUR_ILLUMINANT_D55_LLF LIBCOLOUR_LLF__(0.332424102468830251488896010414, 0.347428039087666229445261478759)
+#define LIBCOLOUR_ILLUMINANT_D65_LLF LIBCOLOUR_LLF__(0.312726871026564878786047074755, 0.329023206641284038376227272238)
+#define LIBCOLOUR_ILLUMINANT_D75_LLF LIBCOLOUR_LLF__(0.299022300412497055166483050925, 0.314852737888341893679466920730)
+#define LIBCOLOUR_ILLUMINANT_E_LLF LIBCOLOUR_LLF__(1. / 3, 1. / 3)
+#define LIBCOLOUR_ILLUMINANT_F1_LLF LIBCOLOUR_LLF__(0.313062433035651010992950205036, 0.337106477918307445573731229160)
+#define LIBCOLOUR_ILLUMINANT_F2_LLF LIBCOLOUR_LLF__(0.372068154452825539113547392844, 0.375122558203110079144693145281)
+#define LIBCOLOUR_ILLUMINANT_F3_LLF LIBCOLOUR_LLF__(0.409090035308107391465171076561, 0.394117134255365986206243178458)
+#define LIBCOLOUR_ILLUMINANT_F4_LLF LIBCOLOUR_LLF__(0.440181095827666568620628595454, 0.403090691158138336724903183494)
+#define LIBCOLOUR_ILLUMINANT_F5_LLF LIBCOLOUR_LLF__(0.313756583095696484075887155996, 0.345160794752101929283583103825)
+#define LIBCOLOUR_ILLUMINANT_F6_LLF LIBCOLOUR_LLF__(0.377882361062687466279896852939, 0.388192885537868959122675960316)
+#define LIBCOLOUR_ILLUMINANT_F7_LLF LIBCOLOUR_LLF__(0.312852472915475354753311876266, 0.329174178033567632617462095368)
+#define LIBCOLOUR_ILLUMINANT_F8_LLF LIBCOLOUR_LLF__(0.345805753550315952971061506105, 0.358617583214377477762724311106)
+#define LIBCOLOUR_ILLUMINANT_F9_LLF LIBCOLOUR_LLF__(0.374105245592801061160770359493, 0.372672400924498159469067104510)
+#define LIBCOLOUR_ILLUMINANT_F10_LLF LIBCOLOUR_LLF__(0.346086913993929323751785886998, 0.358751605952200347537939251197)
+#define LIBCOLOUR_ILLUMINANT_F11_LLF LIBCOLOUR_LLF__(0.380537485483030235577928124258, 0.376915309293930078649026427229)
+#define LIBCOLOUR_ILLUMINANT_F12_LLF LIBCOLOUR_LLF__(0.437023901312296902954557253906, 0.404214327891585678553809657387)
+
+/* 10-degrees observer standard illuminants */
+#define LIBCOLOUR_ILLUMINANT_A_10DEG_OBS_F LIBCOLOUR_F__(0.451173939693730152722395132514, 0.405936604212625562482230634487)
+#define LIBCOLOUR_ILLUMINANT_B_10DEG_OBS_F LIBCOLOUR_F__(0.349819801494100579564161535018, 0.352687989927865819250740742063)
+#define LIBCOLOUR_ILLUMINANT_C_10DEG_OBS_F LIBCOLOUR_F__(0.310388663270034004248998371622, 0.319050711366790695766582075521)
+#define LIBCOLOUR_ILLUMINANT_D50_10DEG_OBS_F LIBCOLOUR_F__(0.347729429961154856698613002663, 0.359522508516545380441442603114)
+#define LIBCOLOUR_ILLUMINANT_D55_10DEG_OBS_F LIBCOLOUR_F__(0.334116336430253457745465084372, 0.348766090975953568786849245953)
+#define LIBCOLOUR_ILLUMINANT_D65_10DEG_OBS_F LIBCOLOUR_F__(0.313823646938709621689866935412, 0.330998985489933561510156323493)
+#define LIBCOLOUR_ILLUMINANT_D75_10DEG_OBS_F LIBCOLOUR_F__(0.299679971345752860223399238748, 0.317403239854836705102769656150)
+#define LIBCOLOUR_ILLUMINANT_E_10DEG_OBS_F LIBCOLOUR_F__(1. / 3, 1. / 3)
+#define LIBCOLOUR_ILLUMINANT_F1_10DEG_OBS_F LIBCOLOUR_F__(0.318098801070991199502202562144, 0.335489451474129951602520804954)
+#define LIBCOLOUR_ILLUMINANT_F2_10DEG_OBS_F LIBCOLOUR_F__(0.379274832262508854174853922814, 0.367227934400669309145115448700)
+#define LIBCOLOUR_ILLUMINANT_F3_10DEG_OBS_F LIBCOLOUR_F__(0.417644682102624287267644831445, 0.383124504918675723441623404142)
+#define LIBCOLOUR_ILLUMINANT_F4_10DEG_OBS_F LIBCOLOUR_F__(0.449247699162001246087072559021, 0.390605475879083674506375700730)
+#define LIBCOLOUR_ILLUMINANT_F5_10DEG_OBS_F LIBCOLOUR_F__(0.319739939104951298443069163113, 0.342367055369128092667807550242)
+#define LIBCOLOUR_ILLUMINANT_F6_10DEG_OBS_F LIBCOLOUR_F__(0.386626908526034762658696308790, 0.378372201588893453116924092683)
+#define LIBCOLOUR_ILLUMINANT_F7_10DEG_OBS_F LIBCOLOUR_F__(0.315645637312390425766039925293, 0.329508145132134222521358424274)
+#define LIBCOLOUR_ILLUMINANT_F8_10DEG_OBS_F LIBCOLOUR_F__(0.348965563721531868424108324689, 0.359317299140994528272585739614)
+#define LIBCOLOUR_ILLUMINANT_F9_10DEG_OBS_F LIBCOLOUR_F__(0.378258900384649654480284652891, 0.370371375730762564248976786985)
+#define LIBCOLOUR_ILLUMINANT_F10_10DEG_OBS_F LIBCOLOUR_F__(0.350893389986753234666139178444, 0.354302210111646531665030579461)
+#define LIBCOLOUR_ILLUMINANT_F11_10DEG_OBS_F LIBCOLOUR_F__(0.385435391037903751776383387551, 0.371094786781121399599214782938)
+#define LIBCOLOUR_ILLUMINANT_F12_10DEG_OBS_F LIBCOLOUR_F__(0.442654456042513022584472537346, 0.397060737666593277506166259627)
+
+#define LIBCOLOUR_ILLUMINANT_A_10DEG_OBS_LF LIBCOLOUR_LF__(0.451173939693730152722395132514, 0.405936604212625562482230634487)
+#define LIBCOLOUR_ILLUMINANT_B_10DEG_OBS_LF LIBCOLOUR_LF__(0.349819801494100579564161535018, 0.352687989927865819250740742063)
+#define LIBCOLOUR_ILLUMINANT_C_10DEG_OBS_LF LIBCOLOUR_LF__(0.310388663270034004248998371622, 0.319050711366790695766582075521)
+#define LIBCOLOUR_ILLUMINANT_D50_10DEG_OBS_LF LIBCOLOUR_LF__(0.347729429961154856698613002663, 0.359522508516545380441442603114)
+#define LIBCOLOUR_ILLUMINANT_D55_10DEG_OBS_LF LIBCOLOUR_LF__(0.334116336430253457745465084372, 0.348766090975953568786849245953)
+#define LIBCOLOUR_ILLUMINANT_D65_10DEG_OBS_LF LIBCOLOUR_LF__(0.313823646938709621689866935412, 0.330998985489933561510156323493)
+#define LIBCOLOUR_ILLUMINANT_D75_10DEG_OBS_LF LIBCOLOUR_LF__(0.299679971345752860223399238748, 0.317403239854836705102769656150)
+#define LIBCOLOUR_ILLUMINANT_E_10DEG_OBS_LF LIBCOLOUR_LF__(1. / 3, 1. / 3)
+#define LIBCOLOUR_ILLUMINANT_F1_10DEG_OBS_LF LIBCOLOUR_LF__(0.318098801070991199502202562144, 0.335489451474129951602520804954)
+#define LIBCOLOUR_ILLUMINANT_F2_10DEG_OBS_LF LIBCOLOUR_LF__(0.379274832262508854174853922814, 0.367227934400669309145115448700)
+#define LIBCOLOUR_ILLUMINANT_F3_10DEG_OBS_LF LIBCOLOUR_LF__(0.417644682102624287267644831445, 0.383124504918675723441623404142)
+#define LIBCOLOUR_ILLUMINANT_F4_10DEG_OBS_LF LIBCOLOUR_LF__(0.449247699162001246087072559021, 0.390605475879083674506375700730)
+#define LIBCOLOUR_ILLUMINANT_F5_10DEG_OBS_LF LIBCOLOUR_LF__(0.319739939104951298443069163113, 0.342367055369128092667807550242)
+#define LIBCOLOUR_ILLUMINANT_F6_10DEG_OBS_LF LIBCOLOUR_LF__(0.386626908526034762658696308790, 0.378372201588893453116924092683)
+#define LIBCOLOUR_ILLUMINANT_F7_10DEG_OBS_LF LIBCOLOUR_LF__(0.315645637312390425766039925293, 0.329508145132134222521358424274)
+#define LIBCOLOUR_ILLUMINANT_F8_10DEG_OBS_LF LIBCOLOUR_LF__(0.348965563721531868424108324689, 0.359317299140994528272585739614)
+#define LIBCOLOUR_ILLUMINANT_F9_10DEG_OBS_LF LIBCOLOUR_LF__(0.378258900384649654480284652891, 0.370371375730762564248976786985)
+#define LIBCOLOUR_ILLUMINANT_F10_10DEG_OBS_LF LIBCOLOUR_LF__(0.350893389986753234666139178444, 0.354302210111646531665030579461)
+#define LIBCOLOUR_ILLUMINANT_F11_10DEG_OBS_LF LIBCOLOUR_LF__(0.385435391037903751776383387551, 0.371094786781121399599214782938)
+#define LIBCOLOUR_ILLUMINANT_F12_10DEG_OBS_LF LIBCOLOUR_LF__(0.442654456042513022584472537346, 0.397060737666593277506166259627)
+
+#define LIBCOLOUR_ILLUMINANT_A_10DEG_OBS_LLF LIBCOLOUR_LLF__(0.451173939693730152722395132514, 0.405936604212625562482230634487)
+#define LIBCOLOUR_ILLUMINANT_B_10DEG_OBS_LLF LIBCOLOUR_LLF__(0.349819801494100579564161535018, 0.352687989927865819250740742063)
+#define LIBCOLOUR_ILLUMINANT_C_10DEG_OBS_LLF LIBCOLOUR_LLF__(0.310388663270034004248998371622, 0.319050711366790695766582075521)
+#define LIBCOLOUR_ILLUMINANT_D50_10DEG_OBS_LLF LIBCOLOUR_LLF__(0.347729429961154856698613002663, 0.359522508516545380441442603114)
+#define LIBCOLOUR_ILLUMINANT_D55_10DEG_OBS_LLF LIBCOLOUR_LLF__(0.334116336430253457745465084372, 0.348766090975953568786849245953)
+#define LIBCOLOUR_ILLUMINANT_D65_10DEG_OBS_LLF LIBCOLOUR_LLF__(0.313823646938709621689866935412, 0.330998985489933561510156323493)
+#define LIBCOLOUR_ILLUMINANT_D75_10DEG_OBS_LLF LIBCOLOUR_LLF__(0.299679971345752860223399238748, 0.317403239854836705102769656150)
+#define LIBCOLOUR_ILLUMINANT_E_10DEG_OBS_LLF LIBCOLOUR_LLF__(1. / 3, 1. / 3)
+#define LIBCOLOUR_ILLUMINANT_F1_10DEG_OBS_LLF LIBCOLOUR_LLF__(0.318098801070991199502202562144, 0.335489451474129951602520804954)
+#define LIBCOLOUR_ILLUMINANT_F2_10DEG_OBS_LLF LIBCOLOUR_LLF__(0.379274832262508854174853922814, 0.367227934400669309145115448700)
+#define LIBCOLOUR_ILLUMINANT_F3_10DEG_OBS_LLF LIBCOLOUR_LLF__(0.417644682102624287267644831445, 0.383124504918675723441623404142)
+#define LIBCOLOUR_ILLUMINANT_F4_10DEG_OBS_LLF LIBCOLOUR_LLF__(0.449247699162001246087072559021, 0.390605475879083674506375700730)
+#define LIBCOLOUR_ILLUMINANT_F5_10DEG_OBS_LLF LIBCOLOUR_LLF__(0.319739939104951298443069163113, 0.342367055369128092667807550242)
+#define LIBCOLOUR_ILLUMINANT_F6_10DEG_OBS_LLF LIBCOLOUR_LLF__(0.386626908526034762658696308790, 0.378372201588893453116924092683)
+#define LIBCOLOUR_ILLUMINANT_F7_10DEG_OBS_LLF LIBCOLOUR_LLF__(0.315645637312390425766039925293, 0.329508145132134222521358424274)
+#define LIBCOLOUR_ILLUMINANT_F8_10DEG_OBS_LLF LIBCOLOUR_LLF__(0.348965563721531868424108324689, 0.359317299140994528272585739614)
+#define LIBCOLOUR_ILLUMINANT_F9_10DEG_OBS_LLF LIBCOLOUR_LLF__(0.378258900384649654480284652891, 0.370371375730762564248976786985)
+#define LIBCOLOUR_ILLUMINANT_F10_10DEG_OBS_LLF LIBCOLOUR_LLF__(0.350893389986753234666139178444, 0.354302210111646531665030579461)
+#define LIBCOLOUR_ILLUMINANT_F11_10DEG_OBS_LLF LIBCOLOUR_LLF__(0.385435391037903751776383387551, 0.371094786781121399599214782938)
+#define LIBCOLOUR_ILLUMINANT_F12_10DEG_OBS_LLF LIBCOLOUR_LLF__(0.442654456042513022584472537346, 0.397060737666593277506166259627)
+
+
+#define LIBCOLOUR_LIST_MODELS_N(_, RES, ...)\
+ _(LIBCOLOUR_RGB, libcolour_rgb_##RES##_t, rgb, __VA_ARGS__)\
+ _(LIBCOLOUR_SRGB, libcolour_srgb_##RES##_t, srgb, __VA_ARGS__)\
+ _(LIBCOLOUR_CIEXYY, libcolour_ciexyy_##RES##_t, ciexyy, __VA_ARGS__)\
+ _(LIBCOLOUR_CIEXYZ, libcolour_ciexyz_##RES##_t, ciexyz, __VA_ARGS__)\
+ _(LIBCOLOUR_CIELAB, libcolour_cielab_##RES##_t, cielab, __VA_ARGS__)\
+ _(LIBCOLOUR_CIELUV, libcolour_cieluv_##RES##_t, cieluv, __VA_ARGS__)\
+ _(LIBCOLOUR_CIELCHUV, libcolour_cielchuv_##RES##_t, cielchuv, __VA_ARGS__)\
+ _(LIBCOLOUR_YIQ, libcolour_yiq_##RES##_t, yiq, __VA_ARGS__)\
+ _(LIBCOLOUR_YDBDR, libcolour_ydbdr_##RES##_t, ydbdr, __VA_ARGS__)\
+ _(LIBCOLOUR_YUV, libcolour_yuv_##RES##_t, yuv, __VA_ARGS__)\
+ _(LIBCOLOUR_YPBPR, libcolour_ypbpr_##RES##_t, ypbpr, __VA_ARGS__)\
+ _(LIBCOLOUR_YCGCO, libcolour_ycgco_##RES##_t, ycgco, __VA_ARGS__)\
+ _(LIBCOLOUR_CIE1960UCS, libcolour_cie1960ucs_##RES##_t, cie1960ucs, __VA_ARGS__)\
+ _(LIBCOLOUR_CIEUVW, libcolour_cieuvw_##RES##_t, cieuvw, __VA_ARGS__)
+
+#define LIBCOLOUR_LIST_MODELS(_, RES)\
+ _(LIBCOLOUR_RGB, libcolour_rgb_##RES##_t, rgb)\
+ _(LIBCOLOUR_SRGB, libcolour_srgb_##RES##_t, srgb)\
+ _(LIBCOLOUR_CIEXYY, libcolour_ciexyy_##RES##_t, ciexyy)\
+ _(LIBCOLOUR_CIEXYZ, libcolour_ciexyz_##RES##_t, ciexyz)\
+ _(LIBCOLOUR_CIELAB, libcolour_cielab_##RES##_t, cielab)\
+ _(LIBCOLOUR_CIELUV, libcolour_cieluv_##RES##_t, cieluv)\
+ _(LIBCOLOUR_CIELCHUV, libcolour_cielchuv_##RES##_t, cielchuv)\
+ _(LIBCOLOUR_YIQ, libcolour_yiq_##RES##_t, yiq)\
+ _(LIBCOLOUR_YDBDR, libcolour_ydbdr_##RES##_t, ydbdr)\
+ _(LIBCOLOUR_YUV, libcolour_yuv_##RES##_t, yuv)\
+ _(LIBCOLOUR_YPBPR, libcolour_ypbpr_##RES##_t, ypbpr)\
+ _(LIBCOLOUR_YCGCO, libcolour_ycgco_##RES##_t, ycgco)\
+ _(LIBCOLOUR_CIE1960UCS, libcolour_cie1960ucs_##RES##_t, cie1960ucs)\
+ _(LIBCOLOUR_CIEUVW, libcolour_cieuvw_##RES##_t, cieuvw)
+
+
+typedef enum libcolour_model {
+#define LIBCOLOUR_X(C, T, N) C,
+ LIBCOLOUR_LIST_MODELS(LIBCOLOUR_X,)
+#undef LIBCOLOUR_X
+} libcolour_model_t;
+
+
+typedef enum libcolour_encoding_type {
+ LIBCOLOUR_ENCODING_TYPE_LINEAR,
+ LIBCOLOUR_ENCODING_TYPE_SIMPLE,
+ LIBCOLOUR_ENCODING_TYPE_REGULAR,
+ LIBCOLOUR_ENCODING_TYPE_CUSTOM
+} libcolour_encoding_type_t;
+
+
+typedef enum libcolour_rgb_colour_space {
+ LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_MEASUREMENTS,
+ LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_MATRIX,
+ LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_INV_MATRIX,
+ LIBCOLOUR_RGB_COLOUR_SPACE_SRGB,
+ LIBCOLOUR_RGB_COLOUR_SPACE_ADOBE_RGB,
+ LIBCOLOUR_RGB_COLOUR_SPACE_APPLE_RGB,
+ LIBCOLOUR_RGB_COLOUR_SPACE_BEST_RGB,
+ LIBCOLOUR_RGB_COLOUR_SPACE_BETA_RGB,
+ LIBCOLOUR_RGB_COLOUR_SPACE_BRUCE_RGB,
+ LIBCOLOUR_RGB_COLOUR_SPACE_CIE_RGB,
+ LIBCOLOUR_RGB_COLOUR_SPACE_COLORMATCH_RGB,
+ LIBCOLOUR_RGB_COLOUR_SPACE_DCI_P3_D65,
+ LIBCOLOUR_RGB_COLOUR_SPACE_DCI_P3_THEATER,
+ LIBCOLOUR_RGB_COLOUR_SPACE_DON_RGB_4,
+ LIBCOLOUR_RGB_COLOUR_SPACE_ECI_RGB,
+ LIBCOLOUR_RGB_COLOUR_SPACE_ECI_RGB_V2,
+ LIBCOLOUR_RGB_COLOUR_SPACE_EKTA_SPACE_PS5,
+ LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_601_625_LINE,
+ LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_601_525_LINE,
+ LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_709,
+ LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2020,
+ LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_EOTF_PQ,
+ LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OOTF_PQ,
+ LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OETF_PQ,
+ LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_EOTF_HLG,
+ LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OOTF_HLG,
+ LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OETF_HLG,
+ LIBCOLOUR_RGB_COLOUR_SPACE_LIGHTROOM_RGB,
+ LIBCOLOUR_RGB_COLOUR_SPACE_NTSC_RGB,
+ LIBCOLOUR_RGB_COLOUR_SPACE_PAL_SECAM_RGB,
+ LIBCOLOUR_RGB_COLOUR_SPACE_PROPHOTO_RGB,
+ LIBCOLOUR_RGB_COLOUR_SPACE_SGI_RGB,
+ LIBCOLOUR_RGB_COLOUR_SPACE_SMPTE_240M_RGB,
+ LIBCOLOUR_RGB_COLOUR_SPACE_SMPTE_C_RGB,
+ LIBCOLOUR_RGB_COLOUR_SPACE_WIDE_GAMUT_RGB
+} libcolour_rgb_colour_space_t;
+
+
+#define LIBCOLOUR_X(C, T, N) T N;
+#define LIBCOLOUR_DEF(TYPE, RES) \
+typedef struct libcolour_srgb_##RES {\
+ enum libcolour_model model;\
+ TYPE R;\
+ TYPE G;\
+ TYPE B;\
+ int with_transfer;\
+} libcolour_srgb_##RES##_t;\
+\
+typedef struct libcolour_ciexyy_##RES {\
+ enum libcolour_model model;\
+ TYPE x;\
+ TYPE y;\
+ TYPE Y;\
+} libcolour_ciexyy_##RES##_t;\
+\
+typedef struct libcolour_ciexyz_##RES {\
+ enum libcolour_model model;\
+ TYPE X;\
+ TYPE Y;\
+ TYPE Z;\
+} libcolour_ciexyz_##RES##_t;\
+\
+typedef struct libcolour_cielab_##RES {\
+ enum libcolour_model model;\
+ TYPE L;\
+ TYPE a;\
+ TYPE b;\
+} libcolour_cielab_##RES##_t;\
+\
+typedef struct libcolour_yiq_##RES {\
+ enum libcolour_model model;\
+ TYPE Y;\
+ TYPE I;\
+ TYPE Q;\
+} libcolour_yiq_##RES##_t;\
+\
+typedef struct libcolour_ydbdr_##RES {\
+ enum libcolour_model model;\
+ TYPE Y;\
+ TYPE Db;\
+ TYPE Dr;\
+} libcolour_ydbdr_##RES##_t;\
+\
+typedef struct libcolour_yuv_##RES {\
+ enum libcolour_model model;\
+ TYPE Y;\
+ TYPE U;\
+ TYPE V;\
+} libcolour_yuv_##RES##_t;\
+\
+typedef struct libcolour_ypbpr_##RES {\
+ enum libcolour_model model;\
+ TYPE Y;\
+ TYPE Pb;\
+ TYPE Pr;\
+} libcolour_ypbpr_##RES##_t;\
+\
+typedef struct libcolour_ycgco_##RES {\
+ enum libcolour_model model;\
+ TYPE Y;\
+ TYPE Cg;\
+ TYPE Co;\
+} libcolour_ycgco_##RES##_t;\
+\
+typedef struct libcolour_cie1960ucs_##RES {\
+ enum libcolour_model model;\
+ TYPE u;\
+ TYPE v;\
+ TYPE Y;\
+} libcolour_cie1960ucs_##RES##_t;\
+\
+typedef struct libcolour_cieuvw_##RES {\
+ enum libcolour_model model;\
+ TYPE U;\
+ TYPE V;\
+ TYPE W;\
+ TYPE u0;\
+ TYPE v0;\
+} libcolour_cieuvw_##RES##_t;\
+\
+typedef struct libcolour_cieluv_##RES {\
+ enum libcolour_model model;\
+ TYPE L;\
+ TYPE u;\
+ TYPE v;\
+ struct libcolour_ciexyz_##RES white;\
+} libcolour_cieluv_##RES##_t;\
+\
+typedef struct libcolour_cielchuv_##RES {\
+ enum libcolour_model model;\
+ TYPE L;\
+ TYPE C;\
+ TYPE h;\
+ struct libcolour_ciexyz_##RES white;\
+ TYPE one_revolution;\
+} libcolour_cielchuv_##RES##_t;\
+\
+typedef struct libcolour_rgb_##RES {\
+ enum libcolour_model model;\
+ TYPE R;\
+ TYPE G;\
+ TYPE B;\
+ int with_transfer;\
+ enum libcolour_encoding_type encoding_type;\
+ TYPE gamma;\
+ TYPE offset;\
+ TYPE slope;\
+ TYPE transition;\
+ TYPE transitioninv;\
+ TYPE (*to_encoded_red)(TYPE);\
+ TYPE (*to_decoded_red)(TYPE);\
+ TYPE (*to_encoded_green)(TYPE);\
+ TYPE (*to_decoded_green)(TYPE);\
+ TYPE (*to_encoded_blue)(TYPE);\
+ TYPE (*to_decoded_blue)(TYPE);\
+ struct libcolour_ciexyy_##RES red;\
+ struct libcolour_ciexyy_##RES green;\
+ struct libcolour_ciexyy_##RES blue;\
+ struct libcolour_ciexyy_##RES white;\
+ TYPE white_r;\
+ TYPE white_g;\
+ TYPE white_b;\
+ TYPE M[3][3];\
+ TYPE Minv[3][3];\
+ enum libcolour_rgb_colour_space colour_space;\
+} libcolour_rgb_##RES##_t;\
+\
+\
+typedef union libcolour_colour_##RES {\
+ enum libcolour_model model;\
+ LIBCOLOUR_LIST_MODELS(LIBCOLOUR_X, RES)\
+} libcolour_colour_##RES##_t;\
+\
+\
+int libcolour_convert_##RES(const libcolour_colour_##RES##_t *restrict from, libcolour_colour_##RES##_t *restrict to);\
+TYPE libcolour_srgb_encode_##RES(TYPE);\
+TYPE libcolour_srgb_decode_##RES(TYPE);\
+int libcolour_delta_e_##RES(const libcolour_colour_##RES##_t *, const libcolour_colour_##RES##_t *, TYPE *);\
+int libcolour_proper_##RES(libcolour_colour_##RES##_t *);\
+int libcolour_get_rgb_colour_space_##RES(libcolour_rgb_##RES##_t *, libcolour_rgb_colour_space_t);\
+size_t libcolour_marshal_##RES(const libcolour_colour_##RES##_t *, void *);\
+size_t libcolour_unmarshal_##RES(libcolour_colour_##RES##_t *, const void *);
+
+LIBCOLOUR_DEF(float, f)
+LIBCOLOUR_DEF(double, lf)
+LIBCOLOUR_DEF(long double, llf)
+
+#undef LIBCOLOUR_DEF
+#undef LIBCOLOUR_X
+
+
+
+#define LIBCOLOUR_GENERIC___(C, TYPE, N, CALL)\
+ TYPE *: (CALL),\
+ const TYPE *: (CALL),
+
+#define LIBCOLOUR_GENERIC__(TYPE, RES, CALL)\
+ LIBCOLOUR_LIST_MODELS_N(LIBCOLOUR_GENERIC___, RES, (CALL))\
+ TYPE: (CALL),\
+ TYPE *: (CALL),\
+ const TYPE: (CALL),\
+ const TYPE *: (CALL),\
+ libcolour_colour_##RES##_t *: (CALL),\
+ const libcolour_colour_##RES##_t *: (CALL)
+
+#define LIBCOLOUR_GENERIC(FUNC, REF, ...)\
+ (_Generic((REF),\
+ LIBCOLOUR_GENERIC__(long double, llf, FUNC##_llf(__VA_ARGS__)),\
+ LIBCOLOUR_GENERIC__(double, lf, FUNC##_lf(__VA_ARGS__)),\
+ LIBCOLOUR_GENERIC__(float, f, FUNC##_f(__VA_ARGS__))))
+
+
+#define libcolour_convert(FROM, TO)\
+ LIBCOLOUR_GENERIC(libcolour_convert, (FROM), (const void *)(FROM), (void *)(TO))
+
+#define libcolour_srgb_encode(VALUE)\
+ LIBCOLOUR_GENERIC(libcolour_srgb_encode, (VALUE), (VALUE))
+
+#define libcolour_srgb_decode(VALUE)\
+ LIBCOLOUR_GENERIC(libcolour_srgb_decode, (VALUE), (VALUE))
+
+#define libcolour_delta_e(A, B, E)\
+ LIBCOLOUR_GENERIC(libcolour_delta_e, (A), (const void *)(A), (const void *)(B), (void *)(E))
+
+#define libcolour_proper(COLOUR)\
+ LIBCOLOUR_GENERIC(libcolour_delta_e, (COLOUR), (const void *)(COLOUR))
+
+#define libcolour_get_rgb_colour_space(CS, SPACE)\
+ LIBCOLOUR_GENERIC(libcolour_get_rgb_colour_space, (CS), (void *)(CS), (SPACE))
+
+#define libcolour_marshal(COLOUR, BUF)\
+ LIBCOLOUR_GENERIC(libcolour_marshal, (COLOUR), (const void *)(COLOUR), (void *)(BUF))
+
+#define libcolour_unmarshal(COLOUR, BUF)\
+ LIBCOLOUR_GENERIC(libcolour_unmarshal, (COLOUR), (void *)(COLOUR), (const void *)(BUF))
+
+
+
+#if defined(__GNUC__) && !defined(__clang__)
+# pragma GCC diagnostic pop
+#elif defined(__clang__)
+# pragma clang diagnostic pop
+#endif
+
+
+#endif
diff --git a/long-double.c b/long-double.c
new file mode 100644
index 0000000..ec43c96
--- /dev/null
+++ b/long-double.c
@@ -0,0 +1,82 @@
+/* See LICENSE file for copyright and license details. */
+#include "libcolour.h"
+
+#include <alloca.h>
+#include <errno.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define libcolour_colour_t libcolour_colour_llf_t
+#define libcolour_rgb_t libcolour_rgb_llf_t
+#define libcolour_srgb_t libcolour_srgb_llf_t
+#define libcolour_ciexyy_t libcolour_ciexyy_llf_t
+#define libcolour_ciexyz_t libcolour_ciexyz_llf_t
+#define libcolour_cielab_t libcolour_cielab_llf_t
+#define libcolour_cieluv_t libcolour_cieluv_llf_t
+#define libcolour_cielchuv_t libcolour_cielchuv_llf_t
+#define libcolour_yiq_t libcolour_yiq_llf_t
+#define libcolour_ydbdr_t libcolour_ydbdr_llf_t
+#define libcolour_yuv_t libcolour_yuv_llf_t
+#define libcolour_ypbpr_t libcolour_ypbpr_llf_t
+#define libcolour_ycgco_t libcolour_ycgco_llf_t
+#define libcolour_cie1960ucs_t libcolour_cie1960ucs_llf_t
+#define libcolour_cieuvw_t libcolour_cieuvw_llf_t
+
+#define TYPE long double
+#define LIST_MODELS(X) LIBCOLOUR_LIST_MODELS(X, llf)
+#define D(X) ((TYPE)(X##L))
+
+#define LIBCOLOUR_ILLUMINANT_A LIBCOLOUR_ILLUMINANT_A_LLF
+#define LIBCOLOUR_ILLUMINANT_B LIBCOLOUR_ILLUMINANT_B_LLF
+#define LIBCOLOUR_ILLUMINANT_C LIBCOLOUR_ILLUMINANT_C_LLF
+#define LIBCOLOUR_ILLUMINANT_D50 LIBCOLOUR_ILLUMINANT_D50_LLF
+#define LIBCOLOUR_ILLUMINANT_D55 LIBCOLOUR_ILLUMINANT_D55_LLF
+#define LIBCOLOUR_ILLUMINANT_D65 LIBCOLOUR_ILLUMINANT_D65_LLF
+#define LIBCOLOUR_ILLUMINANT_D75 LIBCOLOUR_ILLUMINANT_D75_LLF
+#define LIBCOLOUR_ILLUMINANT_E LIBCOLOUR_ILLUMINANT_E_LLF
+#define LIBCOLOUR_ILLUMINANT_F1 LIBCOLOUR_ILLUMINANT_F1_LLF
+#define LIBCOLOUR_ILLUMINANT_F2 LIBCOLOUR_ILLUMINANT_F2_LLF
+#define LIBCOLOUR_ILLUMINANT_F3 LIBCOLOUR_ILLUMINANT_F3_LLF
+#define LIBCOLOUR_ILLUMINANT_F4 LIBCOLOUR_ILLUMINANT_F4_LLF
+#define LIBCOLOUR_ILLUMINANT_F5 LIBCOLOUR_ILLUMINANT_F5_LLF
+#define LIBCOLOUR_ILLUMINANT_F6 LIBCOLOUR_ILLUMINANT_F6_LLF
+#define LIBCOLOUR_ILLUMINANT_F7 LIBCOLOUR_ILLUMINANT_F7_LLF
+#define LIBCOLOUR_ILLUMINANT_F8 LIBCOLOUR_ILLUMINANT_F8_LLF
+#define LIBCOLOUR_ILLUMINANT_F9 LIBCOLOUR_ILLUMINANT_F9_LLF
+#define LIBCOLOUR_ILLUMINANT_F10 LIBCOLOUR_ILLUMINANT_F10_LLF
+#define LIBCOLOUR_ILLUMINANT_F11 LIBCOLOUR_ILLUMINANT_F11_LLF
+#define LIBCOLOUR_ILLUMINANT_F12 LIBCOLOUR_ILLUMINANT_F12_LLF0
+
+#define xisinf(X) (isinfl(X))
+#define xisnan(X) (isnanl(X))
+#define xpow(X, Y) (powl((X), (Y)))
+#define xcbrt(X) (cbrtl(X))
+#define xsqrt(X) (sqrtl(X))
+#define xlog(X) (logl(X))
+#define xexp(X) (expl(X))
+#define xsin(X) (sinl(X))
+#define xcos(X) (cosl(X))
+#define xatan2(X, Y) (atan2l((X), (Y)))
+
+#undef libcolour_convert
+#undef libcolour_srgb_encode
+#undef libcolour_srgb_decode
+#undef libcolour_delta_e
+#undef libcolour_proper
+#undef libcolour_get_rgb_colour_space
+#undef libcolour_marshal
+#undef libcolour_unmarshal
+
+#define libcolour_convert libcolour_convert_llf
+#define libcolour_srgb_encode libcolour_srgb_encode_llf
+#define libcolour_srgb_decode libcolour_srgb_decode_llf
+#define libcolour_delta_e libcolour_delta_e_llf
+#define libcolour_proper libcolour_proper_llf
+#define libcolour_get_rgb_colour_space libcolour_get_rgb_colour_space_llf
+#define libcolour_marshal libcolour_marshal_llf
+#define libcolour_unmarshal libcolour_unmarshal_llf
+
+#include "convert-template.c"
+#include "libcolour-template.c"
diff --git a/mk/README b/mk/README
deleted file mode 100644
index e79926d..0000000
--- a/mk/README
+++ /dev/null
@@ -1,71 +0,0 @@
-This is a collection of generic enough makefiles.
-Please feel free to use them in your project.
-
-Usage:
- Include all.mk from your makefile.
-
- Read the top of each file for details.
-
- Define the variables:
-
- _VERSION
- This version of the package.
-
- _PROJECT
- The name of the project. Must only include [a-z0-9_-].
-
- _PROJECT_FULL
- The name of the project. May include any character.
-
- _SRC
- All source code files. This list is used when
- generating the translation template file.
-
- _COPYRIGHT_HOLDER
- The copyright holder's full name and e-mail address.
-
- COMMAND
- The name of the command. Must not be declared if
- the package does not include exactly one runnable
- command.
-
- PKGNAME
- The name of the package.
-
- Variables beginning with __ are used internally by
- the files where they appear, or in rare cases,
- internally between these files.
-
- Variables beginning with _ but not __ are set in the
- makefile to specify for these files how they should
- behave. They should not be changed by a user of the
- package.
-
- Variables that do not begin with _ are configurable
- by the user of the package.
-
- Do no use single character variables in your Makefile.
-
- To suppress pre-install, post-install, pre-uninstall,
- and post-uninstall instructions, set N=true.
- PRE_INSTALL, POST_INSTALL, PRE_UNINSTALL, and
- POST_UNINSTALL are supportered as specified by the
- GNU coding standardars.
-
- To figure out what pre-install commands to run in your package, run:
- make -n a=% install | sed -e 's/\\$//' -e 's/^ *//' | sed -n '/^% /s/^..//p'
-
- To figure out what post-install commands to run in your package, run:
- make -n z=% uninstall | sed -e 's/\\$//' -e 's/^ *//' | sed -n '/^% /s/^..//p'
-
- To figure out what pre-uninstall commands to run in your package, run:
- make -n a=% uninstall | sed -e 's/\\$//' -e 's/^ *//' | sed -n '/^% /s/^..//p'
-
- To figure out what post-uninstall commands to run in your package, run:
- make -n z=% uninstall | sed -e 's/\\$//' -e 's/^ *//' | sed -n '/^% /s/^..//p'
-
- To suppress verbatim which commands Make runs,
- set Q=@. (Excluding the period.)
-
-Developers should use DEBUG=1 when running make, when possible.
-
diff --git a/mk/all.mk b/mk/all.mk
deleted file mode 100644
index 032718d..0000000
--- a/mk/all.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-#=== This file includes all the other files in appropriate order. ===#
-
-
-ifndef Q
-A = \e[35m
-Z = 
-endif
-
-include $(v)mk/path.mk
-include .config.mk
-include $(v)mk/path.mk
-include $(v)mk/lowerpath.mk
-include $(v)mk/empty.mk
-include $(v)mk/tools.mk
-include $(v)mk/copy.mk
-include $(v)mk/lang-c.mk
-include $(v)mk/texinfo.mk
-include $(v)mk/man.mk
-include $(v)mk/i18n.mk
-include $(v)mk/clean.mk
-include $(v)mk/dist.mk
-include $(v)mk/tags.mk
-include $(v)mk/prologue.mk
-
diff --git a/mk/clean.mk b/mk/clean.mk
deleted file mode 100644
index 1ae4fdc..0000000
--- a/mk/clean.mk
+++ /dev/null
@@ -1,45 +0,0 @@
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-#=== These rules are used for cleaning the repository of generated files. ===#
-
-
-# Delete all files are normally created during a build.
-.PHONY: clean
-clean: clean-dist
- @$(PRINTF_INFO) '\e[00;01;31mCLEANING BUILT FILES\e[34m\e[00m\n'
- -$(Q)$(RM) -r -- bin aux *.su src/*.su src/*/*.su src/*/*/*.su src/*/*/*/*.su
- @$(ECHO)
-
-# Delete all files that are created during configuration or building.
-.PHONY: distclean
-distclean: clean
- @$(PRINTF_INFO) '\e[00;01;31mCLEANING CONFIGURATIONS\e[34m\e[00m\n'
- -$(Q)$(RM) -- .config.mk config.status Makefile
- @$(ECHO)
-
-# Like `make clean` but do not remove massive binaries
-# that are seldom recompiled.
-.PHONY: mostlyclean
-mostlyclean: clean
-
-# Delete everything except ./configure
-.PHONY: maintainer-clean
-maintainer-clean: clean distclean
- @$(ECHO)
- @$(ECHO) 'This command is intended for maintainers to use; it'
- @$(ECHO) 'deletes files that may need special tools to rebuild.'
- @$(ECHO)
-
-# Delete all files generated by `make dist`
-.PHONY: clean-dist
-clean-dist:
- @$(PRINTF_INFO) '\e[00;01;31mCLEANING RELEASES\e[34m\e[00m\n'
- -$(Q)$(RM) -r -- $(_PROJECT)-*.tar* $(_PROJECT)-*.checksums* $(_PROJECT)-*
- @$(ECHO)
-
diff --git a/mk/configure b/mk/configure
deleted file mode 100644
index 4b6e61a..0000000
--- a/mk/configure
+++ /dev/null
@@ -1,732 +0,0 @@
-# -*- shell-script -*-
-
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-# Run './configure --help' for usage information.
-
-
-# FOR DEVELOPERS USING THIS SCRIPT:
-# This file is used by include this file, via the . builtin,
-# in your ./configure. Before doing so, you must declare
-# PKGNAME=the_name_of_your_package
-# MAN_SECTION_SUFFIX=default_suffix_to_append_to_man_page_section # (usually empty)
-# MAN_SECTION=the_section_your_man_page_is_in # (do no declare if you do not use exacly one section)
-# Define the function list_optional_features_help, see the help output.
-# Define the function unrecognised_argument to deal with any unrecognised argument.
-
-
-
-# Store command for rebuilding Makefile to config.status.
-exec 10>config.status
-
-# Store configurations to .config.mk.
-exec 20>.config.mk
-
-
-# Print a quoted (if necessary) version of a string
-quote ()
-{
- value="$1"
- if ! test "${value%%\'*}" = "${value}"; then
- value="'$(echo "${value}" | sed "s/'/'\\\\''/g")'"
- elif ! test "$(printf '%s' ${value})" = "${value}"; then
- value="'${value}'"
- elif ! test "$(echo ${value}) | tr -d a-zA-Z0-9+_@%/=-" = ""; then
- value="'${value}'"
- fi
- echo "${value}"
-}
-
-
-# Parse command line.
-incomplete=
-dashed=
-f_help=
-f_gnulinux=
-f_bin_merger=
-for option; do
- if test -n "${incomplete}"; then
- option="${incomplete}=${option}"
- incomplete=
- fi
-
- # For --{with{,out},{en,dis}able}-*.
- feature="${option#--*}"
- feature="${feature#*-}"
- feature="$(echo "${feature}" | tr a-z- A-Z_)"
-
- # For directories and filename tweaks.
- nodash=_novar
-
- case "${dashed}${option}" in
-# general
- (--)
- dashed=yes ;;
- (--help)
- f_help=yes ;;
- (--destdir | --destdir=* | --pkgdir | --pkgdir=*)
- nodash=destdir ;;
- (--srcdir | --srcdir)
- nodash=srcdir ;;
-
-# directory automation
- (--gnu-linux)
- f_gnulinux=yes ;;
- (--bin-merger)
- f_bin_merger=yes ;;
-
-# directories and filenames
- (--prefix | --prefix=*)
- nodash=prefix ;;
- (--exec-prefix | --exec-prefix=* | --exec_prefix | --exec_prefix=*)
- nodash=exec_prefix ;;
- (--bindir | --bindir=*)
- nodash=bindir ;;
- (--sbindir | --sbindir=*)
- nodash=sbindir ;;
- (--libexecdir | --libexecdir=*)
- nodash=libexecdir ;;
- (--libdir | --libdir=*)
- nodash=libdir ;;
- (--includedir | --includedir=*)
- nodash=includedir ;;
- (--oldincludedir | --oldincludedir=*)
- nodash=oldincludedir ;;
- (--datarootdir | --datarootdir=*)
- nodash=datarootdir ;;
- (--datadir | --datadir=*)
- nodash=datadir ;;
- (--libdatarootdir | --libdatarootdir=*)
- nodash=libdatarootdir ;;
- (--libdatadir | --libdatadir=*)
- nodash=libdatadir ;;
- (--sysconfdir | --sysconfdir=*)
- nodash=sysconfdir ;;
- (--sharedstatedir | --=sharedstatedir*)
- nodash=sharedstatedir ;;
- (--localstatedir | --localstatedir=*)
- nodash=localstatedir ;;
- (--runstatedir | --runstatedir=*)
- nodash=runstatedir ;;
- (--lispdir | --lispdir=*)
- nodash=lispdir ;;
- (--localedir | --localedir=*)
- nodash=localedir ;;
- (--licensedir | --licensedir=*)
- nodash=licensedir ;;
- (--emptydir | --emptydir=*)
- nodash=emptydir ;;
- (--cachedir | --cachedir=*)
- nodash=cachedir ;;
- (--spooldir | --spooldir=*)
- nodash=spooldir ;;
- (--logdir | --logdir=*)
- nodash=logdir ;;
- (--statedir | --statedir=*)
- nodash=statedir ;;
- (--gamedir | --gamedir=*)
- nodash=gamedir ;;
- (--sharedcachedir | --sharedcachedir=*)
- nodash=sharedcachedir ;;
- (--sharedspooldir | --sharedspooldir=*)
- nodash=sharedspooldir ;;
- (--sharedlogdir | --sharedlogdir=*)
- nodash=sharedlogdir ;;
- (--sharedstatedir | --sharedstatedir=*)
- nodash=sharedstatedir ;;
- (--sharedgamedir | --sharedgamedir=*)
- nodash=sharedgamedir ;;
- (--tmpdir | --tmpdir=*)
- nodash=tmpdir ;;
- (--localtmpdir | --localtmpdir=*)
- nodash=localtmpdir ;;
- (--sharedtmpdir | --sharedtmpdir=*)
- nodash=sharedtmpdir ;;
- (--lockdir | --lockdir=*)
- nodash=lockdir ;;
- (--skeldir | --skeldir=*)
- nodash=skeldir ;;
- (--devdir | --devdir=*)
- nodash=devdir ;;
- (--sysdir | --sysdir=*)
- nodash=sysdir ;;
- (--procdir | --procdir=*)
- nodash=procdir ;;
- (--selfprocdir | --selfprocdir=*)
- nodash=selfprocdir ;;
- (--docdir | --docdir=*)
- nodash=docdir ;;
- (--infodir | --infodir=*)
- nodash=infodir ;;
- (--dvidir | --dvidir=*)
- nodash=dvidir ;;
- (--pdfdir | --pdfdir=*)
- nodash=pdfdir ;;
- (--psdir | --psdir=*)
- nodash=psdir ;;
- (--htmldir | --htmldir=*)
- nodash=htmldir ;;
- (--mandir | --mandir=*)
- nodash=mandir ;;
- (--man0 | --man0=*)
- nodash=man0 ;;
- (--man1 | --man1=*)
- nodash=man1 ;;
- (--man2 | --man2=*)
- nodash=man2 ;;
- (--man3 | --man3=*)
- nodash=man3 ;;
- (--man4 | --man4=*)
- nodash=man4 ;;
- (--man5 | --man5=*)
- nodash=man5 ;;
- (--man6 | --man6=*)
- nodash=man6 ;;
- (--man7 | --man7=*)
- nodash=man7 ;;
- (--man8 | --man8=*)
- nodash=man8 ;;
- (--man9 | --man9=*)
- nodash=man9 ;;
- (--man0ext | --man0ext=*)
- nodash=man0ext ;;
- (--man1ext | --man1ext=*)
- nodash=man1ext ;;
- (--man2ext | --man2ext=*)
- nodash=man2ext ;;
- (--man3ext | --man3ext=*)
- nodash=man3ext ;;
- (--man4ext | --man4ext=*)
- nodash=man4ext ;;
- (--man5ext | --man5ext=*)
- nodash=man5ext ;;
- (--man6ext | --man6ext=*)
- nodash=man6ext ;;
- (--man7ext | --man7ext=*)
- nodash=man7ext ;;
- (--man8ext | --man8ext=*)
- nodash=man8ext ;;
- (--man9ext | --man9ext=*)
- nodash=man9ext ;;
- (--manext | --manext=*)
- if test -n "${MAN_SECTION}"; then
- nodash=manext
- else
- printf "\e[01;31m%s: warning: ignoring: %s\e[00m\n" "${0}" "${option}" >&2
- sleep 1
- fi
- ;;
-
-# ignored
- # Unrecognised directories, and settings that cannot be used with internationalisation.
- (--*dir=* | --*dir | --man?dir | --man?dir=*)
- printf "\e[01;31m%s: warning: ignoring: %s\e[00m\n" "${0}" "${option}" >&2
- sleep 1
- ;;
-
-# feature tweaking
- (--with-*)
- feature="WITH_${feature}"
- echo "${feature}" = yes >&20
- export "${feature}"=yes
- option="${option}=x"
- ;;
-
- (--without-*)
- feature="WITHOUT_${feature}"
- echo "${feature}" = yes >&20
- export "${feature}"=yes
- option="${option}=x"
- ;;
-
- (--enable-*=*)
- param="${feature#*=}"
- feature="${feature%%=*}"
- if ! test "${param}" = "no"; then
- feature="ENABLE_${feature}"
- else
- feature="DISABLE_${feature}"
- param=yes
- fi
- echo "${feature}" = "${param}" >&20
- export "${feature}"="${param}"
- ;;
-
- (--enable-*)
- feature="DISABLE_${feature}"
- echo "${feature}" = yes >&20
- export "${feature}"=yes
- option="${option}=x"
- ;;
-
- (--disable-*)
- feature="DISABLE_${feature}"
- echo "${feature}" = yes >&20
- export "${feature}"=yes
- option="${option}=x"
- ;;
-
-# unrecognised
- (${dashed}--*)
- unrecognised_argument "${option}"
- ;;
-
-# variables
- (${dashed}*=*)
- var="${option%%=*}"
- val="${option#*=}"
- if test -n "$(echo "${var}" | tr -d '[_a-zA-Z0-9-]')"; then
- # Variable is not used and is potentially not
- # formatted in a compatible way.
- printf "\e[01;31m%s: warning: ignoring because of bad format: %s\e[00m\n" "${0}" "${option}" >&2
- sleep 1
- fi
- echo "${var}" = "${val}" >&20
- ;;
-
-# unrecognised
- (*)
- unrecognised_argument "${option}"
- ;;
- esac
-
- if test "${option%%=*}" = "${option}"; then
- incomplete="${option}"
- else
- eval "${nodash}=$(quote "${option#*=}")"
- eval "have_${nodash}=yes"
- fi
-done
-
-
-# Print usage information. This is parsed by
-# the auto-completion script for ./configure.
-if test -n "${f_help}"; then
- cat <<EOF
-Configure the package (${PKGNAME}) before building and installing.
-
-OPTIONS
-
-general
- --help Print usage information.
- --destdir=DIR Output directory for staged install.
- --srcdir=DIR The directory for the sources being compiled.
- VARIABLE=VALUE Override a variable in the Makefile.
-
-directory automation
- --gnu-linux Use default configurations for GNU/Linux.
- --bin-merger The OS distribution has symlinked sbin to bin for the select exec-prefix.
-
-tweaking of features
-EOF
- list_optional_features_help
- cat <<EOF
-
-tweaking of directories and filenames
- --prefix=DIR Prefix used for other directories than.
- --exec-prefix=DIR Prefix used for /bin, /sbin, /libexec, and /lib.
- --bindir=DIR Executable programs that users can run.
- --sbindir=DIR Executable administrative programs.
- --libexecdir=DIR Executable programs run by other programs and not be users.
- --libdir=DIR Object files and libraries of object code.
- --includedir=DIR Header files.
- --oldincludedir=DIR Header files. Should have the prefix /usr if the canonical prefix is /usr/local.
- --datarootdir=DIR Architecture-independent data files.
- --datadir=DIR Architecture-independent resource files.
- --libdatarootdir=DIR Architecture-dependent data files.
- --libdatadir=DIR Architecture-dependent resource files.
- --sysconfdir=DIR Machine-local configuration files.
- --sharedstatedir=DIR Network-shared architecture-independent state files.
- --localstatedir=DIR Machine-local architecture-independent state files.
- --runstatedir=DIR Machine-local runtime state files.
- --lispdir=DIR Emacs LISP files.
- --localedir=DIR Locale-specific message catalogues.
- --licensedir=DIR License files.
- --emptydir=DIR An always empty directory.
- --cachedir=DIR Machine-local cached files.
- --spooldir=DIR Machine-local spooled files.
- --logdir=DIR Machine-local log files
- --statedir=DIR Machine-local persistent state files
- --gamedir=DIR Machine-local highscore files.
- --sharedcachedir=DIR Network-shared cached files.
- --sharedspooldir=DIR Network-shared spooled files.
- --sharedlogdir=DIR Network-shared log files
- --sharedstatedir=DIR Network-shared persistent state files
- --sharedgamedir=DIR Network-shared highscore files.
- --tmpdir=DIR Machine-local volatile temporary files.
- --localtmpdir=DIR Machine-local persistent temporary files.
- --sharedtmpdir=DIR Network-shared temporary files.
- --lockdir=DIR Lock files.
- --skeldir=DIR User skeleton.
- --devdir=DIR Devices and pseudo-devices.
- --sysdir=DIR System-information logical file.
- --procdir=DIR Process-information logical file.
- --selfprocdir=DIR Process-information logical file for the process itself.
- --docdir=DIR Documentation files, other then info manuals and man pages.
- --infodir=DIR Info manuals.
- --dvidir=DIR DVI manuals.
- --pdfdir=DIR PDF manuals.
- --psdir=DIR PostScript manuals.
- --htmldir=DIR HTML manuals.
- --mandir=DIR Top-level directory for man pages.
- --man0=DIR Basename of the directory for section 0 man pages.
- --man1=DIR Basename of the directory for section 1 man pages.
- --man2=DIR Basename of the directory for section 2 man pages.
- --man3=DIR Basename of the directory for section 3 man pages.
- --man4=DIR Basename of the directory for section 4 man pages.
- --man5=DIR Basename of the directory for section 5 man pages.
- --man6=DIR Basename of the directory for section 6 man pages.
- --man7=DIR Basename of the directory for section 7 man pages.
- --man8=DIR Basename of the directory for section 8 man pages.
- --man9=DIR Basename of the directory for section 9 man pages.
-EOF
- if test -n "${MAN_SECTION}"; then
- cat <<EOF
- --manext=EXT Filename suffix for the man page.
-EOF
- fi
- cat <<EOF
- --man0ext=EXT Filename suffix for section 0 man pages.
- --man1ext=EXT Filename suffix for section 1 man pages.
- --man2ext=EXT Filename suffix for section 2 man pages.
- --man3ext=EXT Filename suffix for section 3 man pages.
- --man4ext=EXT Filename suffix for section 4 man pages.
- --man5ext=EXT Filename suffix for section 5 man pages.
- --man6ext=EXT Filename suffix for section 6 man pages.
- --man7ext=EXT Filename suffix for section 7 man pages.
- --man8ext=EXT Filename suffix for section 8 man pages.
- --man9ext=EXT Filename suffix for section 9 man pages.
-EOF
- exit 0
-fi
-
-
-# Set unset directories to their default.
-defdir ()
-{
- p="$(quote "${2}")"
- if ! test -n "$(eval echo '${have_'"${1}"'}')"; then
- eval "${1}=${p}"
- fi
-}
-if test -n "${f_gnulinux}"; then
- defdir prefix "/usr"
- _prefix=
- case ${prefix} in
- ('' | / | /usr | /usr/ | /games | /games | /usr/games | /usr/games/)
- _infix=
- ;;
- (/usr/local | /usr/local/ | /usr/local/games | /usr/local/games/)
- _infix=/local
- ;;
- (/opt/*)
- _infix=${prefix}
- ;;
- (*)
- # This probably means somewhere in /home, we do not
- # checked because we do not know what else to do.
- _infix=
- _prefix="${prefix}"
- ;;
- esac
- defdir sysconfdir "${_prefix}/etc${_infix}"
- defdir sharedstatedir "${_prefix}/com${_infix}"
- defdir localstatedir "${_prefix}/var${_infix}"
- defdir runstatedir "${_prefix}/run${_infix}"
- defdir tmpdir "${_prefix}/tmp${_infix}"
-else
- defdir prefix "/usr/local"
- defdir sysconfdir "${prefix}/etc"
- defdir sharedstatedir "${prefix}/com"
- defdir localstatedir "${prefix}/var"
- defdir runstatedir "${localstatedir}/run"
- defdir tmpdir "${prefix}/tmp"
-fi
-defdir exec_prefix "${prefix}"
-defdir bindir "${exec_prefix}/bin"
-if test -n "${f_bin_merger}"; then
- defdir sbindir "${bindir}"
-else
- defdir sbindir "${exec_prefix}/sbin"
-fi
-defdir libexecdir "${exec_prefix}/libexec"
-defdir libdir "${exec_prefix}/lib"
-defdir includedir "${prefix}/include"
-defdir oldincludedir "${includedir}"
-defdir datarootdir "${prefix}/share"
-defdir datadir "${datarootdir}"
-defdir libdatarootdir "${libdir}"
-defdir libdatadir "${libdir}"
-defdir lispdir "${datarootdir}/emacs/site-lisp"
-defdir localedir "${datarootdir}/locale"
-defdir licensedir "${datarootdir}/licenses"
-defdir cachedir "${localstatedir}/cache"
-defdir spooldir "${localstatedir}/spool"
-defdir emptydir "${localstatedir}/empty"
-defdir logdir "${localstatedir}/log"
-defdir statedir "${localstatedir}/lib"
-defdir gamedir "${localstatedir}/games"
-defdir sharedcachedir "${sharedstatedir}/cache"
-defdir sharedpooldir "${sharedstatedir}/spool"
-defdir sharedlogdir "${sharedstatedir}/log"
-defdir sharedstatedir "${sharedstatedir}/lib"
-defdir sharedgamedir "${sharedstatedir}/games"
-defdir localtmpdir "${localstatedir}/tmp"
-defdir sharedtmpdir "${sharedstatedir}/tmp"
-defdir lockdir "${runstatedir}/lock"
-defdir skeldir "${sysconfdir}/skel"
-defdir devdir "/dev"
-defdir sysdir "/sys"
-defdir procdir "/proc"
-defdir selfprocdir "${procdir}/self"
-defdir docdir "${datarootdir}/doc/${PKGNAME}"
-defdir infodir "${datarootdir}/info"
-defdir dvidir "${docdir}"
-defdir pdfdir "${docdir}"
-defdir psdir "${docdir}"
-defdir htmldir "${docdir}"
-defdir mandir "${datarootdir}/man"
-defdir man0 "man0${MAN_SECTION_SUFFIX}"
-defdir man1 "man1${MAN_SECTION_SUFFIX}"
-defdir man2 "man2${MAN_SECTION_SUFFIX}"
-defdir man3 "man3${MAN_SECTION_SUFFIX}"
-defdir man4 "man4${MAN_SECTION_SUFFIX}"
-defdir man5 "man5${MAN_SECTION_SUFFIX}"
-defdir man6 "man6${MAN_SECTION_SUFFIX}"
-defdir man7 "man7${MAN_SECTION_SUFFIX}"
-defdir man8 "man8${MAN_SECTION_SUFFIX}"
-defdir man9 "man9${MAN_SECTION_SUFFIX}"
-if test -n "${MAN_SECTION}" && ! test -n "$(eval echo '${man'"${MAN_SECTION}"'ext}')"; then
- defdir "man${MAN_SECTION}ext" "$(eval echo '${man'"${MAN_SECTION}"'ext}')"
-fi
-defdir man0ext ".0"
-defdir man1ext ".1"
-defdir man2ext ".2"
-defdir man3ext ".3"
-defdir man4ext ".4"
-defdir man5ext ".5"
-defdir man6ext ".6"
-defdir man7ext ".7"
-defdir man8ext ".8"
-defdir man9ext ".9"
-
-# Found source directory.
-if ! test -n "${srcdir}"; then
- if test -f "Makefile.in"; then
- :
- elif test -f "${PWD}/Makefile.in"; then
- srcdir="${PWD}"
- elif test -f "${PWD}/../Makefile.in"; then
- srcdir="${PWD}/.."
- fi
-fi
-if test -n "${srcdir}"; then
- srcdir="$(realpath "${srcdir}")/"
- srcdir_proper="${srcdir}"
- srcdir="$(quote "${srcdir}")"
-fi
-if ! test -f "${srcdir_proper}Makefile.in"; then
- echo "${0}: error: cannot found source directory."
- exit 1
-fi
-
-
-# Add shebang and "generated"-comment to config.status.
-echo '#!/bin/sh' >&10
-echo >&10
-echo '# This file was generated by ./configure, its purpose is two-fold:' >&10
-echo '# 1) It lets you rebuild Makefile with the same configurations you' >&10
-echo '# used last time you run ./configure.' >&10
-echo '# 2) It lets Makefile rebuild itself transparently when out of date.' >&10
-echo >&10
-
-# config.status should adjust CWD.
-echo 'cd "$(dirname "${0}")"' >&10
-
-# config.status calls ./configure with all arguments you called ./configure.
-printf "exec %s" "${0}" >&10
-for option; do
- printf " %s" "$(quote "${option}")" >&10
-done
-echo >&10
-
-# Close config.status.
-exec 10>&-
-
-
-# Store environment (with restrictions).
-env | while read line; do
- var="${line%%=*}"
- val="${line#*=}"
- if test "${var}" = "${line}"; then
- # Malformated variables. (Can happen!, sigh...)
- continue
- elif test -n "$(echo "${var}" | tr -d '[_a-zA-Z0-9-]')"; then
- # Variable is not used and is potentially not
- # formatted in a compatible way.
- continue
- fi
- case "${var}" in
- (_ | PWD | SHELL | SHLVL | TERM | COLORTERM | MAKEFLAGS)
- # We do not want to propagate these.
- ;;
- (*)
- echo "${var}" = "${val}" >&20
- ;;
- esac
-done
-
-# Store directories and filenames.
-if test -n "${destdir}"; then
- echo DESTDIR = "${destdir}" >&20
-fi
-echo PREFIX = "${prefix}" >&20
-echo SYSCONFDIR = "${sysconfdir}" >&20
-echo COMDIR = "${sharedstatedir}" >&20
-echo VARDIR = "${localstatedir}" >&20
-echo RUNDIR = "${runstatedir}" >&20
-echo TMPDIR = "${tmpdir}" >&20
-echo DEVDIR = "${devdir}" >&20
-echo SYSDIR = "${sysdir}" >&20
-echo PROCDIR = "${procdir}" >&20
-echo EXEC_PREFIX = "${exec_prefix}" >&20
-echo BINDIR = "${bindir}" >&20
-echo SBINDIR = "${sbindir}" >&20
-echo LIBEXECDIR = "${libexecdir}" >&20
-echo LIBDIR = "${libdir}" >&20
-echo INCLUDEDIR = "${includedir}" >&20
-echo OLDINCLUDEDIR = "${oldincludedir}" >&20
-echo DATADIR = "${datarootdir}" >&20
-echo RESDIR = "${datadir}" >&20
-echo SYSDEPDATADIR = "${libdatarootdir}" >&20
-echo SYSDEPRESDIR = "${libdatadir}" >&20
-echo LISPDIR = "${lispdir}" >&20
-echo LOCALEDIR = "${localedir}" >&20
-echo LICENSEDIR = "${licensedir}" >&20
-echo CACHEDIR = "${cachedir}" >&20
-echo SPOOLDIR = "${spooldir}" >&20
-echo EMPTYDIR = "${emptydir}" >&20
-echo LOGDIR = "${logdir}" >&20
-echo STATEDIR = "${statedir}" >&20
-echo GAMEDIR = "${gamedir}" >&20
-echo COMCACHEDIR = "${sharedcachedir}" >&20
-echo COMPOOLDIR = "${sharedpooldir}" >&20
-echo COMLOGDIR = "${sharedlogdir}" >&20
-echo COMSTATEDIR = "${sharedstatedir}" >&20
-echo COMGAMEDIR = "${sharedgamedir}" >&20
-echo LOCALTMPDIR = "${localtmpdir}" >&20
-echo SHAREDTMPDIR = "${sharedtmpdir}" >&20
-echo LOCKDIR = "${lockdir}" >&20
-echo SKELDIR = "${skeldir}" >&20
-echo SELFPROCDIR = "${selfprocdir}" >&20
-echo DOCDIR = "${docdir}" >&20
-echo INFODIR = "${infodir}" >&20
-echo DVIDIR = "${dvidir}" >&20
-echo PDFDIR = "${pdfdir}" >&20
-echo PSDIR = "${psdir}" >&20
-echo HTMLDIR = "${htmldir}" >&20
-echo MANDIR = "${mandir}" >&20
-echo MAN0 = "${man0}" >&20
-echo MAN1 = "${man1}" >&20
-echo MAN2 = "${man2}" >&20
-echo MAN3 = "${man3}" >&20
-echo MAN4 = "${man4}" >&20
-echo MAN5 = "${man5}" >&20
-echo MAN6 = "${man6}" >&20
-echo MAN7 = "${man7}" >&20
-echo MAN8 = "${man8}" >&20
-echo MAN9 = "${man9}" >&20
-echo MAN0EXT = "${man0ext}" >&20
-echo MAN1EXT = "${man1ext}" >&20
-echo MAN2EXT = "${man2ext}" >&20
-echo MAN3EXT = "${man3ext}" >&20
-echo MAN4EXT = "${man4ext}" >&20
-echo MAN5EXT = "${man5ext}" >&20
-echo MAN6EXT = "${man6ext}" >&20
-echo MAN7EXT = "${man7ext}" >&20
-echo MAN8EXT = "${man8ext}" >&20
-echo MAN9EXT = "${man9ext}" >&20
-
-# Close .config.mk.
-exec 20>&-
-
-# Now, make Makefile available.
-if test -f Makefile; then
- chmod u+w Makefile # This scripts makes it read-only.
-fi
-exec 30>Makefile
-echo "# ----------------------------------------------------- #" >&30
-echo "# This file was created by ./configure from Makefile.in #" >&30
-echo "# ----------------------------------------------------- #" >&30
-echo >&30
-if test -n "${srcdir}"; then
- echo v = "${srcdir}" >&30
-fi
-cat "${srcdir_proper}"Makefile.in >&30
-exec 30>&-
-
-
-# config.status should be executable.
-chmod a+x config.status
-
-# Makefile should be read-only to ones does not edit it by mistake.
-chmod a-w Makefile
-
-
-# Help functions for the parent script.
-test_with ()
-{
- with="$(eval echo '${WITH_'"${1}"'}')"
- without="$(eval echo '${WITHOUT_'"${1}"'}')"
- if ! test -n "${with}" && ! test -n "${without}"; then
- echo "${2}"
- elif ! test -n "${with}" && test -n "${without}"; then
- echo "no"
- elif test -n "${with}" && ! test -n "${without}"; then
- echo "yes"
- elif test "${2}" = yes; then
- echo "no"
- else
- echo "yes"
- fi
-}
-test_enable ()
-{
- enable="$(eval echo '${ENABLE_'"${1}"'}')"
- disable="$(eval echo '${DISABLE_'"${1}"'}')"
- if ! test -n "${enable}" && ! test -n "${disable}"; then
- echo "${2}"
- elif ! test -n "${enable}" && test -n "${disable}"; then
- echo "no"
- elif test -n "${enable}" && ! test -n "${disable}"; then
- echo "${enable}"
- elif test "${2}" = yes ; then
- echo "no"
- else
- echo "${enable}"
- fi
-}
-
-
-# After including this file, you may want
-# to do something like:
-#
-# cat <<EOF
-#
-# Enabled features, see ${0} for more infomation:
-#
-# Internationalisation $(test_with GETTEXT yes)
-# GNU Bash tab-completion $(test_with BASH yes)
-# Fish tab-completion $(test_with FISH yes)
-# Z shell tab-completion $(test_with ZSH yes)
-#
-# You can now run 'make && make install'.
-#
-# EOF
-
diff --git a/mk/copy.mk b/mk/copy.mk
deleted file mode 100644
index c9067a4..0000000
--- a/mk/copy.mk
+++ /dev/null
@@ -1,78 +0,0 @@
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-#=== These rules are used for legal files. ===#
-
-
-# Enables the rules:
-# install-copyright Install all files in _COPYING and _LICENSE
-# install-copying Install all files in _COPYING
-# install-license Install all files in _LICENSE
-
-
-# WHEN TO BUILD, INSTALL, AND UNINSTALL:
-
-install-base: install-copyright
-uninstall: uninstall-copyright
-
-
-# INSTALL RULES:
-
-.PHONY: install-copyright
-install-copyright:
-
-ifdef _COPYING
-.PHONY: install-copyright
-install-copyright: install-copying
-
-.PHONY: install-copying
-install-copying: $(foreach F,$(_COPYING),$(v)$(F))
- @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
- $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
- $(Q)$(INSTALL_DATA) $^ -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
- @$(ECHO_EMPTY)
-endif
-
-ifdef _LICENSE
-.PHONY: install-copyright
-install-copyright: install-license
-
-.PHONY: install-license
-install-license: $(foreach F,$(_LICENSE),$(v)$(F))
- @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
- $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
- $(Q)$(INSTALL_DATA) $^ -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
- @$(ECHO_EMPTY)
-endif
-
-
-# UNINSTALL RULES:
-
-.PHONY: uninstall-copyright
-uninstall-copyright:
-
-ifdef _COPYING
-.PHONY: uninstall-copyright
-uninstall-copyright: uninstall-copying
-
-.PHONY: uninstall-copying
-uninstall-copying:
- -$(Q)$(RM) -- $(foreach F,$(_COPYING),"$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/$(F)")
- -$(Q)$(RMDIR) -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
-endif
-
-ifdef _LICENSE
-.PHONY: uninstall-copyright
-uninstall-copyright: uninstall-license
-
-.PHONY: uninstall-license
-uninstall-license:
- -$(Q)$(RM) -- $(foreach F,$(_LICENSE),"$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/$(F)")
- -$(Q)$(RMDIR) -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
-endif
-
diff --git a/mk/dist.mk b/mk/dist.mk
deleted file mode 100644
index 9f8c48b..0000000
--- a/mk/dist.mk
+++ /dev/null
@@ -1,189 +0,0 @@
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-#=== These rules are used for making releases. ===#
-
-
-# CONFIGURATIONS:
-
-# Formats for packages to generate.
-DIST_FORMATS = tar tar.xz tar.bz2 tar.gz
-
-# Define DO_NOT_SIGN if you do not want sign the release.
-
-# You can select checksums to generate:
-# Declaring NO_BSD_SUM will omit `sum -r`.
-# Declaring NO_SYSV_SUM will omit `sum -s`.
-# List all checksum programs, that do not require any flags, in DIST_CHECKSUMS.
-
-# Any missing flags for GnuPG?
-GPG_FLAGS =
-
-# What key should be used for signing?
-GPG_KEY ?=
-
-# You should define _EVERYTHING to enumerate all files that belong in
-# the release tarball, lest 'git archive' will be used as a fallback.
-
-
-
-# HELP VARIALES:
-
-# You may use these to help list all files in _EVERYTHING
-__EVERYTHING_COMMON = $(_COPYING) $(_LICENSE) README
-__EVERYTHING_SRC = $(foreach F,$(_SRC),src/$(F))
-__EVERYTHING_LOCALE = $(foreach L,$(LOCALES),po/$(L).po)
-__EVERYTHING_SHELL = $(foreach F,$(_AUTO_COMPLETE),src/$(F).auto-completion) \
- $(foreach F,$(_AUTO_COMPLETE),$(foreac F,$(_SHELL_LOCALES),src/$(F).$(L),auto-completion))
-__EVERYTHING_MK_ = all clean copy dist empty i18n lang-c lowerpath man path prologue shell tags texinfo tools
-__EVERYTHING_MK = $(foreach F,$(__EVERYTHING_MK_),mk/$(F).mk) mk/configure mk/README configure Makefile.in
-__EVERYTHING_MAN = $(foreach S,$(_MAN_PAGE_SECTIONS),$(foreach P,$(_MAN_$(S)),doc/man/$(P).$(S))) \
- $(foreach S,$(_MAN_PAGE_SECTIONS),$(foreach L,$(MAN_LOCALES),$(foreach P,$(_MAN_$(L)_$(S)),doc/man/$(P).$(L).$(S))))
-__EVERYTHING_ALL_COMMON = $(__EVERYTHING_COMMON) $(__EVERYTHING_MK) $(__EVERYTHING_MAN) \
- $(__EVERYTHING_LOCALE) $(__EVERYTHING_SRC) $(__EVERYTHING_SHELL)
-# This one (__todo) if you have a todo file, but do not want it to be greped.
-__TO__ = TO
-__DO__ = DO
-__todo = $(__TO__)$(__DO__)
-
-
-# The packages and there detached signatures (if any.)
-ifndef DO_NOT_SIGN
-__DIST_FILES = $(foreach F,$(DIST_FORMATS),$(_PROJECT)-$(_VERSION).$(F) $(_PROJECT)-$(_VERSION).$(F).sig)
-endif
-ifdef DO_NOT_SIGN
-__DIST_FILES = $(foreach F,$(DIST_FORMATS),$(_PROJECT)-$(_VERSION).$(F))
-endif
-
-# All known checksum programs that are unambiguous.
-__DIST_CHECKSUMS_ALL = cksum md2sum md4sum md5sum md6sum sha0sum sha1sum sha224sum \
- sha256sum sha384sum sha512sum sha512-224sum sha512-256sum \
- sha3-224sum sha3-256sum sha3-384sum sha3-512sum shake256sum \
- shake512sum rawshake256sum rawshake512sum keccak-224sum \
- keccak-256sum keccak-384sum keccak-512sum keccaksum
-
-# All installed checksum programs that are unambiguous.
-DIST_CHECKSUMS = $(foreach C,$(__DIST_CHECKSUMS_ALL),$(shell if command -v $(C) >/dev/null; then $(ECHO) $(C); fi))
-
-
-
-# MAKE RULES:
-
-# Generate release files. (Tarballs, compressed and uncompressed; signatures; checksums.)
-.PHONY: dist
-dist: dist-balls dist-checksums
-
-
-
-# HELP MAKE RULES:
-
-# Generate tarballs, compressed and uncompressed,
-.PHONY: dist-balls
-dist-balls: $(__DIST_FILES)
-
-ifndef DO_NOT_SIGN
-# Generate checksums and signature of checksums.
-.PHONY: dist-checksums
-dist-checksums: $(_PROJECT)-$(_VERSION).checksums $(_PROJECT)-$(_VERSION).checksums.sig
-
-# Generate uncompressed tarball and signature of it.
-.PHONY: dist-tar
-dist-tar: $(_PROJECT)-$(_VERSION).tar $(_PROJECT)-$(_VERSION).tar.sig
-
-# Generate xz-copressed tarball and signature of it.
-.PHONY: dist-xz
-dist-xz: $(_PROJECT)-$(_VERSION).tar.xz $(_PROJECT)-$(_VERSION).tar.xz.sig
-
-# Generate bz2-copressed tarball and signature of it.
-.PHONY: dist-bzip2
-dist-bz2: $(_PROJECT)-$(_VERSION).tar.bz2 $(_PROJECT)-$(_VERSION).tar.bz2.sig
-
-# Generate gzip-copressed tarball and signature of it.
-.PHONY: dist-gz
-dist-gz: $(_PROJECT)-$(_VERSION).tar.gz $(_PROJECT)-$(_VERSION).tar.sig
-endif
-ifdef DO_NOT_SIGN
-# Generate checksums, but no signature.
-.PHONY: dist-checksums
-dist-checksums: $(_PROJECT)-$(_VERSION).checksums
-
-# Generate uncompressed tarball, but no signature.
-.PHONY: dist-tar
-dist-tar: $(_PROJECT)-$(_VERSION).tar
-
-# Generate xz-compressed tarball, but no signature.
-.PHONY: dist-xz
-dist-xz: $(_PROJECT)-$(_VERSION).tar.xz
-
-# Generate bzip2-compressed tarball, but no signature.
-.PHONY: dist-bz2
-dist-bz2: $(_PROJECT)-$(_VERSION).tar.bz2
-
-# Generate gzip-compressed tarball, but no signature.
-.PHONY: dist-gz
-dist-gz: $(_PROJECT)-$(_VERSION).tar.gz
-endif
-
-# Generate the tarball for the release.
-ifdef v
-__GIT_DIR = --git-dir=$(v)
-endif
-$(_PROJECT)-$(_VERSION).tar: $(foreach F,$(_EVERYTHING),$(v)$(F))
- @$(PRINTF_INFO) '\e[00;01;31mTAR\e[34m %s\e[00m$A\n' "$@"
- @if $(TEST) -f $@; then $(RM) $@; fi
-ifndef _EVERYTHING
- $(Q)git archive --prefix=$(_PROJECT)-$(_VERSION)/ --format=tar $(__GIT_DIR) $(_VERSION) -o $@ #$Z
-endif
-ifdef _EVERYTHING
- $(Q)$(LN) -s . $(_PROJECT)-$(_VERSION)
- $(Q)$(TAR) c -- $(foreach F,$(_EVERYTHING),$(v)$(_PROJECT)-$(_VERSION)/$(F)) > $@
- $(Q)$(RM) $(_PROJECT)-$(_VERSION)
-endif
- @$(ECHO_EMPTY)
-
-# Compression rule for xz-compression. Used on the tarball.
-%.xz: %
- @$(PRINTF_INFO) '\e[00;01;31mXZ\e[34m %s\e[00m$A\n' "$@"
- @if $(TEST) -f $@; then $(RM) $@; fi
- $(Q)$(XZ_COMPRESS) $< #$Z
- @$(ECHO_EMPTY)
-
-# Compression rule for bzip2-compression. Used on the tarball.
-%.bz2: %
- @$(PRINTF_INFO) '\e[00;01;31mBZIP2\e[34m %s\e[00m$A\n' "$@"
- @if $(TEST) -f $@; then $(RM) $@; fi
- $(Q)$(BZIP2_COMPRESS) $< #$Z
- @$(ECHO_EMPTY)
-
-# Compression rule for gzip-compression. Used on the tarball.
-%.gz: %
- @$(PRINTF_INFO) '\e[00;01;31mGZIP\e[34m %s\e[00m$A\n' "$@"
- @if $(TEST) -f $@; then $(RM) $@; fi
- $(Q)$(GZIP_COMPRESS) $< #$Z
- @$(ECHO_EMPTY)
-
-# Generate checksums of tarballs, compressed and uncompressed, and of their detached signatures.
-$(_PROJECT)-$(_VERSION).checksums: $(__DIST_FILES)
- @$(PRINTF_INFO) '\e[00;01;31mCHECKSUM\e[34m %s\e[00m\n' "$@"
- @$(PRINTF) '' > $@
-ifndef NO_BSD_SUM
- @if ! ($(ECHO) ':: sum -r ::' && sum -r $^ && $(ECHO)) >> $@ ; then $(PRINTF) '' > $@; fi
-endif
-ifndef NO_SYSV_SUM
- @if ! ($(ECHO) ':: sum -s ::' && sum -s $^ && $(ECHO)) >> $@ ; then $(PRINTF) '' > $@; fi
-endif
- @$(foreach C,$(DIST_CHECKSUMS),$(ECHO) ':: $(C) ::' >> $@ && $(C) $^ | $(GREP) -v '^--' >> $@ && $(ECHO) >> $@ &&) $(TRUE)
- @$(ECHO_EMPTY)
-
-# Signing rule. Used on the tarballs, compressed and uncompressed, and on the checksum file.
-%.sig: %
- @$(PRINTF_INFO) '\e[00;01;31mSIG\e[34m %s\e[00m$A\n' "$@"
- @if $(TEST) -f $@; then $(RM) $@; fi
- $(Q)$(GPG) $(GPG_FLAGS) --local-user $(GPG_KEY) --detach-sign --armor --output $@ < $< #$Z
- @$(ECHO_EMPTY)
-
diff --git a/mk/empty.mk b/mk/empty.mk
deleted file mode 100644
index fd684f6..0000000
--- a/mk/empty.mk
+++ /dev/null
@@ -1,103 +0,0 @@
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-#=== This file includes empty rules that are filled by other files. ===#
-
-
-.PHONY: all
-all:
-
-.PHONY: everything
-everything:
-
-.PHONY: base
-base:
-
-.PHONY: cmd
-cmd:
-
-.PHONY: lib
-lib:
-
-.PHONY: doc
-doc:
-
-
-.PHONY: check
-check:
-
-
-.PHONY: install
-install:
-
-.PHONY: install-everything
-install-everything:
-
-.PHONY: install-base
-install-base:
-
-.PHONY: install-cmd
-install-cmd:
-
-.PHONY: install-lib
-install-lib:
-
-.PHONY: install-doc
-install-doc:
-
-
-.PHONY: installcheck
-installcheck:
-
-
-.PHONY: uninstall
-uninstall:
-
-
-
-.PHONY: all
-all: base
-
-.PHONY: everything
-everything: base
-
-.PHONY: base
-base: cmd lib
-
-
-.PHONY: install
-install: install-base
-
-.PHONY: install-everything
-install-everything: install-base
-
-.PHONY: install-base
-install-base: install-cmd install-lib
-
-
-
-.PHONY: install-strip
-install-strip: __STRIP = -s
-install-strip: install
-
-.PHONY: install-everything-strip
-install-everything-strip: __STRIP = -s
-install-everything-strip: install-everything
-
-.PHONY: install-base-strip
-install-base-strip: __STRIP = -s
-install-base-strip: install-base
-
-.PHONY: install-cmd-strip
-install-cmd-strip: __STRIP = -s
-install-cmd-strip: install-cmd
-
-.PHONY: install-lib-strip
-install-lib-strip: __STRIP = -s
-install-lib-strip: install-lib
-
diff --git a/mk/i18n.mk b/mk/i18n.mk
deleted file mode 100644
index ed6ec79..0000000
--- a/mk/i18n.mk
+++ /dev/null
@@ -1,111 +0,0 @@
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-#=== These rules are used for internationalisation. ===#
-
-
-# Enables the rules:
-# locale Build all translations.
-# update-po Update all .po files for further translation.
-# install-locale Install all locales.
-#
-# "All locales" are those listed in LOCALES.
-# If LOCALES is not defined, this file is ignored.
-#
-# If WITHOUT_GETTEXT is defined, `locale` and
-# `install-locale` will not do anything.
-#
-# _SRC should list all sources files, excluding the src/
-# at the beginning of the pathnames.
-
-
-ifdef LOCALES
-
-
-# WHEN TO BUILD, INSTALL, AND UNINSTALL:
-
-all: locale
-everything: locale
-install: install-locale
-install-everything: install-locale
-uninstall: uninstall-locale
-
-
-# BUILD RULES:
-
-# Build all translations.
-ifdef WITHOUT_GETTEXT
-.PHONY: locale
-locale:
-endif
-ifndef WITHOUT_GETTEXT
-.PHONY: locale
-locale: $(foreach L,$(LOCALES),bin/mo/$(L)/messages.mo)
-endif
-
-# Update all translation files for further translation.
-.PHONY: update-po
-update-po: $(foreach L,$(LOCALES),po/$(L).po)
-
-# Generate template for translations.
-aux/$(_PROJECT).pot: $(foreach S,$(_SRC),$(v)src/$(S))
- @$(PRINTF_INFO) '\e[00;01;31mPOT\e[34m %s\e[00m$A\n' "$@"
- @$(MKDIR) -p aux
- $(Q)$(CPP) -DUSE_GETTEXT=1 $^ | \
- $(XGETTEXT) -o "$@" -Lc --from-code utf-8 --package-name "$(_PROJECT_FULL)" \
- --package-version $(_VERSION) --no-wrap --force-po \
- --copyright-holder '$(_COPYRIGHT_HOLDER)' - #$Z
- @$(ECHO_EMPTY)
-
-# Create or update a translation file.
-po/%.po: aux/$(_PROJECT).pot
- @$(PRINTF_INFO) '\e[00;01;31mPO\e[34m %s\e[00m$A\n' "$@"
- @$(MKDIR) -p po
- $(Q)if ! $(TEST) -e $@; then \
- $(MSGINIT) --no-translator --no-wrap -i aux/$(_PROJECT).pot -o $@ -l $*; \
- else \
- $(MSGMERGE) --no-wrap -U $@ aux/$(_PROJECT).pot; \
- fi #$Z
- @$(TOUCH) $@
- @$(ECHO_EMPTY)
-
-# Compile a translation file.
-bin/mo/%/messages.mo: $(v)po/%.po
- @$(PRINTF_INFO) '\e[00;01;31mMO\e[34m %s\e[00m$A\n' "$@"
- @$(MKDIR) -p bin/mo/$*
- $(Q)cd bin/mo/$* && $(MSGFMT) $(__back3unless_v)$< #$Z
- @$(ECHO_EMPTY)
-
-
-# INSTALL RULES:
-
-# Install all locales.
-ifdef WITHOUT_GETTEXT
-.PHONY: install-locale
-install-locale:
-endif
-ifndef WITHOUT_GETTEXT
-.PHONY: install-locale
-install-locale: $(foreach L,$(LOCALES),bin/mo/$(L)/messages.mo)
- @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
- $(Q)$(INSTALL) -dm755 -- $(foreach L,$(LOCALES),"$(DESTDIR)$(LOCALEDIR)/$(L)/LC_MESSAGES")
- $(Q)$(foreach L,$(LOCALES),$(INSTALL_DATA) bin/mo/$(L)/messages.mo -- "$(DESTDIR)$(LOCALEDIR)/$(L)/LC_MESSAGES/$(PKGNAME).mo" &&) $(TRUE)
- @$(ECHO_EMPTY)
-endif
-
-
-# UNINSTALL RULES:
-
-# Uninstall all locales.
-.PHONY: uninstall-locale
-uninstall-locale:
- -$(Q)$(RM) -- $(foreach L,$(LOCALES),"$(DESTDIR)$(LOCALEDIR)/$(L)/LC_MESSAGES/$(PKGNAME).mo")
-
-
-endif
-
diff --git a/mk/lang-c.mk b/mk/lang-c.mk
deleted file mode 100644
index e96c0b3..0000000
--- a/mk/lang-c.mk
+++ /dev/null
@@ -1,307 +0,0 @@
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-#=== This file includes rules for C programs. ===#
-
-
-# This file is ignored unless _C_STD is defined.
-# _C_STD should be set the the version of C that
-# is used.
-#
-# If you want to compile with -pedantic, define
-# the variable _PEDANTIC.
-#
-# Define _CPPFLAGS with any additional CPP
-# flags to use, _CFLAGS with any additional CC
-# flags to use, and _LDFLAGS with any additional
-# LD flags to use.
-#
-# Defined in path.mk, you can change _ALL_DIRS
-# if you do not want CPP definitions for all
-# directories.
-#
-# Define _HEADER_DIRLEVELS to specify the directory
-# nesting level in src. It is assumed that all
-# directories contain header files. Set to '0' if
-# there are no header files.
-#
-# _BIN shall list all commands to build. These
-# should be the basenames. For each command
-# you should be the variable _OBJ_$(COMMAND)
-# that lists all objects files (without the
-# suffix and without the aux/ prefix) that
-# are required to build the command.
-#
-# Binary you want installed to /sbin rather than
-# /bin shall be listed in _SBIN rather than in
-# _BIN. _SBIN and _BIN may not list binaries
-# with identical names. Analogically, you may
-# add _LIBEXEC for binary to be installed to
-# /libexec.
-#
-# If you only have one binary, you may select
-# to define _BINDIR to name the variable with
-# the pathname for the directory the binary
-# shall be installed. For example, if you want
-# the binary to be installed to /usr/sbin,
-# define _BINDIR = SBINDIR.
-#
-# List libraries to compile in in _LIB. For each
-# library, sould should also define
-# _SO_VERSION_$(LIBRARY) and _SO_MAJOR_$(LIBRARY)
-# with the full version number and the major
-# version number, respectively. Additionally,
-# list all header files that shall be installed
-# in _H, these should not contain the 'src/' prefix
-# or the '.h' suffix.
-
-
-ifdef _C_STD
-
-
-
-# HELP VARIABLES:
-
-# Figure out whether the GCC is being used.
-ifeq ($(shell $(PRINTF) '%s\n' ${CC} | $(HEAD) -n 1),gcc)
-__USING_GCC = 1
-endif
-
-# Are there any commands?
-ifdef _BIN
-__HAVE_CMD_C = 1
-endif
-ifdef _SBIN
-__HAVE_CMD_C = 1
-endif
-ifdef _LIBEXEC
-__HAVE_CMD_C = 1
-endif
-
-
-# WHEN TO BUILD, INSTALL, AND UNINSTALL:
-
-ifdef __HAVE_CMD_C
-cmd: cmd-c
-install-cmd: install-cmd-c
-uninstall: uninstall-cmd-c
-endif
-ifdef _LIB
-lib: lib-c
-install-lib: install-lib-c
-uninstall: uninstall-lib-c
-endif
-
-
-# BUILD VARIABLES:
-
-# Optimisation settings for C code compilation.
-ifndef OPTIMISE
-ifndef DEBUG
-OPTIMISE = -O2 -g
-endif
-ifdef DEBUG
-ifdef __USING_GCC
-OPTIMISE = -Og -g
-endif
-ifndef __USING_GCC
-OPTIMISE = -g
-endif
-endif
-endif
-
-# Warning settings for C code compilation.
-ifdef _PEDANTIC
-_PEDANTIC = -pedantic
-endif
-ifndef WARN
-ifndef DEBUG
-WARN = -Wall
-endif
-ifdef DEBUG
-ifdef __USING_GCC
-WARN = -Wall -Wextra $(_PEDANTIC) -Wdouble-promotion -Wformat=2 -Winit-self -Wmissing-include-dirs \
- -Wtrampolines -Wmissing-prototypes -Wmissing-declarations -Wnested-externs \
- -Wno-variadic-macros -Wsync-nand -Wunsafe-loop-optimizations -Wcast-align \
- -Wdeclaration-after-statement -Wundef -Wbad-function-cast -Wwrite-strings -Wlogical-op \
- -Wstrict-prototypes -Wold-style-definition -Wpacked -Wvector-operation-performance \
- -Wunsuffixed-float-constants -Wsuggest-attribute=const -Wsuggest-attribute=noreturn \
- -Wsuggest-attribute=format -Wnormalized=nfkc -fstrict-aliasing -fipa-pure-const -ftree-vrp \
- -fstack-usage -funsafe-loop-optimizations -Wshadow -Wredundant-decls -Winline -Wcast-qual \
- -Wsign-conversion -Wstrict-overflow=5 -Wconversion -Wsuggest-attribute=pure -Wswitch-default \
- -Wstrict-aliasing=1 -fstrict-overflow -Wfloat-equal -Wpadded -Waggregate-return \
- -Wtraditional-conversion
-endif
-ifndef __USING_GCC
-WARN = -Wall -Wextra $(_PEDANTIC)
-endif
-endif
-endif
-
-# Support for internationalisation?
-ifndef WITHOUT_GETTEXT
-_CPPFLAGS += -D'USE_GETTEXT=1'
-endif
-
-# Add CPP definitions for all directories.
-_CPPFLAGS += $(foreach D,$(_ALL_DIRS),-D'$(D)="$($(D))"')
-
-# Compilation and linking flags, and command.
-ifndef CPPFLAGS
-CPPFLAGS =
-endif
-ifndef CFLAGS
-CFLAGS = $(OPTIMISE) $(WARN)
-endif
-ifndef LDFLAGS
-LDFLAGS = $(OPTIMISE) $(WARN)
-endif
-__CC = $(CC) -std=$(_C_STD) -c $(_CPPFLAGS) $(_CFLAGS)
-__LD = $(CC) -std=$(_C_STD) $(_LDFLAGS)
-__CC_POST = $(CPPFLAGS) $(CFLAGS) $(EXTRA_CPPFLAGS) $(EXTRA_CFLAGS)
-__LD_POST = $(LDFLAGS) $(EXTRA_LDFLAGS)
-
-# Header files.
-__H =
-ifdef _HEADER_DIRLEVELS
-ifeq ($(_HEADER_DIRLEVELS),1)
-__H += src/*.h
-endif
-ifneq ($(_HEADER_DIRLEVELS),1)
-ifeq ($(_HEADER_DIRLEVELS),2)
-__H += src/*.h
-__H += src/*/*.h
-endif
-ifneq ($(_HEADER_DIRLEVELS),2)
-ifneq ($(_HEADER_DIRLEVELS),0)
-__H += $(foreach W,$(shell $(SEQ) $(_HEADER_DIRLEVELS) | while read n; do $(ECHO) $$($(SEQ) $$n)" " | $(SED) 's/[^ ]* /\/\*/g'; done | $(XARGS) $(ECHO)),src$(W).h)
-endif
-endif
-endif
-endif
-
-# Directory for the binary if there is only one binary.
-ifndef _BINDIR
-_BINDIR = BINDIR
-endif
-
-
-# BUILD RULES:
-
-.PHONY: cmd-c
-cmd-c: $(foreach B,$(_BIN) $(_SBIN) $(_LIBEXEC),bin/$(B))
-
-.PHONY: lib-c
-lib-c: $(foreach B,$(_LIB),bin/$(B).so)
-
-# Compile a C file into an object file for a command.
-aux/%.o: $(v)src/%.c $(foreach H,$(__H),$(v)$(H))
- @$(PRINTF_INFO) '\e[00;01;31mCC\e[34m %s\e[00m$A\n' "$@"
- @$(MKDIR) -p $(shell $(DIRNAME) $@)
- $(Q)$(__CC) -o $@ $< $(__CC_POST) #$Z
- @$(ECHO_EMPTY)
-
-# Compile a C file into an object file for a library.
-aux/%.pic.o: $(v)src/%.c $(foreach H,$(__H),$(v)$(H))
- @$(PRINTF_INFO) '\e[00;01;31mCC\e[34m %s\e[00m$A\n' "$@"
- @$(MKDIR) -p $(shell $(DIRNAME) $@)
- $(Q)$(__CC) -fPIC -o $@ $< $(__CC_POST) #$Z
- @$(ECHO_EMPTY)
-
-# Link object files into a library.
-# Dependencies are declared below.
-bin/%.so:
- @$(PRINTF_INFO) '\e[00;01;31mLD\e[34m %s\e[00;32m$A\n' "$@"
- @$(MKDIR) -p bin
- $(Q)$(__LD) -shared -Wl,-soname,$*.so.$(_SO_MAJOR_$*) -o $@ $^ $(__LD_POST) #$Z
- @$(ECHO_EMPTY)
-
-# Link object files into a command.
-# Dependencies are declared below.
-bin/%:
- @$(PRINTF_INFO) '\e[00;01;31mLD\e[34m %s\e[00;32m$A\n' "$@"
- @$(MKDIR) -p bin
- $(Q)$(__LD) -o $@ $^ $(__LD_POST) #$Z
- @$(ECHO_EMPTY)
-
-# Dependencies for the rule above.
-include aux/lang-c.mk
-aux/lang-c.mk: Makefile
- @$(MKDIR) -p aux
- @$(ECHO) > aux/lang-c.mk
- @$(foreach B,$(_BIN) $(_SBIN) $(_LIBEXEC),$(ECHO) bin/$(B): $(foreach O,$(_OBJ_$(B)),aux/$(O).o) >> aux/lang-c.mk &&) $(TRUE)
- @$(foreach B,$(_LIB),$(ECHO) bin/$(B).so: $(foreach O,$(_OBJ_$(B)),aux/$(O).pic.o) >> aux/lang-c.mk &&) $(TRUE)
-
-
-# INSTALL RULES:
-
-.PHONY: install-cmd-c
-install-cmd-c: $(foreach B,$(_BIN) $(_SBIN) $(_LIBEXEC),bin/$(B))
- @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
-ifndef COMMAND
-ifdef _BIN
- $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(BINDIR)"
- $(Q)$(INSTALL_PROGRAM) $(__STRIP) $(foreach B,$(_BIN),bin/$(B)) -- "$(DESTDIR)$(BINDIR)"
-endif
-ifdef _SBIN
- $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(SBINDIR)"
- $(Q)$(INSTALL_PROGRAM) $(__STRIP) $(foreach B,$(_SBIN),bin/$(B)) -- "$(DESTDIR)$(SBINDIR)"
-endif
-ifdef _LIBEXEC
- $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(LIBEXECDIR)/$(PKGNAME)"
- $(Q)$(INSTALL_PROGRAM) $(__STRIP) $(foreach B,$(_LIBEXEC),bin/$(B)) -- "$(DESTDIR)$(LIBEXECDIR)/$(PKGNAME)"
-endif
-endif
-ifdef COMMAND
- $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$($(_BINDIR))"
- $(Q)$(INSTALL_PROGRAM) $(__STRIP) $^ -- "$(DESTDIR)$($(_BINDIR))/$(COMMAND)"
-endif
- @$(ECHO_EMPTY)
-
-.PHONY: install-lib-c
-install-lib-c: $(foreach B,$(_LIB),bin/$(B).so)
- @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
- $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(LIBDIR)"
- $(Q)$(foreach B,$(_LIB),$(LN) -sf -- "$(B).so.$(_SO_VERSION_$(B))" "$(DESTDIR)$(LIBDIR)/$(B).so.$(_SO_MAJOR_$(B))" &&) $(TRUE)
- $(Q)$(foreach B,$(_LIB),$(INSTALL_PROGRAM) $(foreach B,$(_LIB),bin/$(B).so) -- "$(DESTDIR)$(LIBDIR)/$(B).so.$(_SO_VERSION_$(B))" &&) $(TRUE)
- $(Q)$(foreach B,$(_LIB),$(LN) -sf -- "$(B).so.$(_SO_VERSION_$(B))" "$(DESTDIR)$(LIBDIR)/$(B).so" &&) $(TRUE)
- $(Q)$(INSTALL_DIR) -- $(foreach H,$(_H),"$(DESTDIR)$(INCLUDEDIR)/$(shell $(DIRNAME) "$(H)")")
- $(Q)$(foreach H,$(_H),$(INSTALL_DATA) "src/$(H).h" -- "$(DESTDIR)$(INCLUDEDIR)/$(H).h" &&) $(TRUE)
- @$(ECHO_EMPTY)
-
-
-# UNINSTALL RULES:
-
-.PHONY: uninstall-cmd-c
-uninstall-cmd-c:
-ifdef COMMAND
- -$(Q)$(RM) -- "$(DESTDIR)$($(_BINDIR))/$(COMMAND)"
-endif
-ifndef COMMAND
-ifdef _BIN
- -$(Q)$(RM) -- $(foreach B,$(_BIN),"$(DESTDIR)$(BINDIR)/$(B)")
-endif
-ifdef _SBIN
- -$(Q)$(RM) -- $(foreach B,$(_SBIN),"$(DESTDIR)$(SBINDIR)/$(B)")
-endif
-ifdef _LIBEXEC
- -$(Q)$(RM) -- $(foreach B,$(_LIBEXEC),"$(DESTDIR)$(LIBEXECDIR)/$(PKGNAME)/$(B)")
- -$(Q)$(RMDIR) -- "$(DESTDIR)$(LIBEXECDIR)/$(PKGNAME)"
-endif
-endif
-
-.PHONY: uninstall-lib-c
-uninstall-lib-c:
- -$(Q)$(RM) -- $(foreach B,$(_LIB),"$(DESTDIR)$(LIBDIR)/$(B).so")
- -$(Q)$(RM) -- $(foreach B,$(_LIB),"$(DESTDIR)$(LIBDIR)/$(B).so.$(_SO_MAJOR_$(B))")
- -$(Q)$(RM) -- $(foreach B,$(_LIB),"$(DESTDIR)$(LIBDIR)/$(B).so.$(_SO_VERSION_$(B))")
- -$(Q)$(RM) -- $(foreach H,$(_H),"$(DESTDIR)$(INCLUDEDIR)/$(H).h")
- -$(Q)$(foreach H,$(_H),if ! $(TEST) "$(shell $(ECHO) "$(H)" | $(CUT) -d / -f 1)" = "$(H)"; then $(RMDIR) -- "$(DESTDIR)$(INCLUDEDIR)/$(shell $(DIRNAME) "$(H)")"; fi;)
-
-endif
-
diff --git a/mk/lowerpath.mk b/mk/lowerpath.mk
deleted file mode 100644
index 77b3542..0000000
--- a/mk/lowerpath.mk
+++ /dev/null
@@ -1,279 +0,0 @@
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-#=== This file overrides values uppercase path variables with values lowercase path variables. ===#
-
-
-ifdef srcdir
-VPATH = $(srcdir)
-endif
-
-ifdef prefix
-PREFIX = $(prefix)
-endif
-
-ifdef sysconfdir
-SYSCONFDIR = $(sysconfdir)
-endif
-
-ifdef sharedstatedir
-COMDIR = $(sharedstatedir)
-endif
-
-ifdef localstatedir
-VARDIR = $(localstatedir)
-endif
-
-ifdef runstatedir
-RUNDIR = $(runstatedir)
-endif
-
-ifdef tmpdir
-TMPDIR = $(tmpdir)
-endif
-
-ifdef devdir
-DEVDIR = $(devdir)
-endif
-
-ifdef sysdir
-SYSDIR = $(sysdir)
-endif
-
-ifdef procdir
-PROCDIR = $(procdir)
-endif
-
-ifdef exec_prefix
-EXEC_PREFIX = $(exec_prefix)
-endif
-
-ifdef bindir
-BINDIR = $(bindir)
-endif
-
-ifdef sbindir
-SBINDIR = $(sbindir)
-endif
-
-ifdef libexecdir
-LIBEXECDIR = $(libexecdir)
-endif
-
-ifdef libdir
-LIBDIR = $(libdir)
-endif
-
-ifdef includedir
-INCLUDEDIR = $(includedir)
-endif
-
-ifdef oldincludedir
-OLDINCLUDEDIR = $(oldincludedir)
-endif
-
-ifdef datarootdir
-DATADIR = $(datarootdir)
-endif
-
-ifdef datadir
-RESDIR = $(datadir)
-endif
-
-ifdef libdatarootdir
-SYSDEPDATADIR = $(libdatarootdir)
-endif
-
-ifdef libdatadir
-SYSDEPRESDIR = $(libdatadir)
-endif
-
-ifdef lispdir
-LISPDIR = $(lispdir)
-endif
-
-ifdef localedir
-LOCALEDIR = $(localedir)
-endif
-
-ifdef licensedir
-LICENSEDIR = $(licensedir)
-endif
-
-ifdef cachedir
-CACHEDIR = $(cachedir)
-endif
-
-ifdef spooldir
-SPOOLDIR = $(spooldir)
-endif
-
-ifdef emptydir
-EMPTYDIR = $(emptydir)
-endif
-
-ifdef logdir
-LOGDIR = $(logdir)
-endif
-
-ifdef statedir
-STATEDIR = $(statedir)
-endif
-
-ifdef gamedir
-GAMEDIR = $(gamedir)
-endif
-
-ifdef sharedcachedir
-COMCACHEDIR = $(sharedcachedir)
-endif
-
-ifdef sharedpooldir
-COMPOOLDIR = $(sharedpooldir)
-endif
-
-ifdef sharedlogdir
-COMLOGDIR = $(sharedlogdir)
-endif
-
-ifdef sharedlogdir
-COMSTATEDIR = $(sharedstatedir)
-endif
-
-ifdef sharedgamedir
-COMGAMEDIR = $(sharedgamedir)
-endif
-
-ifdef localtmpdir
-VARTMPDIR = $(localtmpdir)
-endif
-
-ifdef sharedtmpdir
-COMTMPDIR = $(sharedtmpdir)
-endif
-
-ifdef lockdir
-LOCKDIR = $(lockdir)
-endif
-
-ifdef skeldir
-SKELDIR = $(skeldir)
-endif
-
-ifdef selfprocdir
-SELFPROCDIR = $(selfprocdir)
-endif
-
-ifdef docdir
-DOCDIR = $(docdir)
-endif
-
-ifdef infodir
-INFODIR = $(infodir)
-endif
-
-ifdef dvidir
-DVIDIR = $(dvidir)
-endif
-
-ifdef pdfdir
-PDFDIR = $(pdfdir)
-endif
-
-ifdef psdir
-PSDIR = $(psdir)
-endif
-
-ifdef htmldir
-HTMLDIR = $(htmldir)
-endif
-
-ifdef mandir
-MANDIR = $(mandir)
-endif
-
-ifdef man0
-MAN0 = $(man0)
-endif
-
-ifdef man1
-MAN1 = $(man1)
-endif
-
-ifdef man2
-MAN2 = $(man2)
-endif
-
-ifdef man3
-MAN3 = $(man3)
-endif
-
-ifdef man4
-MAN4 = $(man4)
-endif
-
-ifdef man5
-MAN5 = $(man5)
-endif
-
-ifdef man6
-MAN6 = $(man6)
-endif
-
-ifdef man7
-MAN7 = $(man7)
-endif
-
-ifdef man8
-MAN8 = $(man8)
-endif
-
-ifdef man9
-MAN9 = $(man9)
-endif
-
-ifdef man0ext
-MAN0EXT = $(man0ext)
-endif
-
-ifdef man1ext
-MAN1EXT = $(man1ext)
-endif
-
-ifdef man2ext
-MAN2EXT = $(man2ext)
-endif
-
-ifdef man3ext
-MAN3EXT = $(man3ext)
-endif
-
-ifdef man4ext
-MAN4EXT = $(man4ext)
-endif
-
-ifdef man5ext
-MAN5EXT = $(man5ext)
-endif
-
-ifdef man6ext
-MAN6EXT = $(man6ext)
-endif
-
-ifdef man7ext
-MAN7EXT = $(man7ext)
-endif
-
-ifdef man8ext
-MAN8EXT = $(man8ext)
-endif
-
-ifdef man9ext
-MAN9EXT = $(man9ext)
-endif
-
diff --git a/mk/man.mk b/mk/man.mk
deleted file mode 100644
index acde35e..0000000
--- a/mk/man.mk
+++ /dev/null
@@ -1,111 +0,0 @@
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-#=== These rules are used for man pages. ===#
-
-
-# Enables the rules:
-# install-man Install all man page
-# install-man-untranslated Install untranslated man page
-# install-man-locale Install translated man page
-#
-# This file is ignored unless _MAN_PAGE_SECTIONS
-# is defined. _MAN_PAGE_SECTIONS should list all
-# used man page sections. For all used sections
-# there should also be a variable named
-# _MAN_$(SECTION) that lists the suffixless
-# basename of all man pages in that section.
-#
-# The pathname of a man page should look
-# like this: doc/man/$(DOCUMENT).$(SECTION)
-# Translations looks like this:
-# doc/man/$(DOCUMENT).$(LANGUAGE).$(SECTION)
-#
-# For each language and section, there should
-# be a variable _MAN_$(LANGUAGE)_$(SECTION)
-# that lists all translated documents in that
-# section and for that lanuage. These should
-# be suffixless basenames. The lanuage counts
-# as a suffix.
-#
-# The translations of the man pages to
-# install should be specified, by language,
-# in the variable MAN_LOCALES.
-
-
-ifdef _MAN_PAGE_SECTIONS
-
-
-# WHEN TO BUILD, INSTALL, AND UNINSTALL:
-
-install: install-man
-install-everything: install-man
-install-doc: install-man
-uninstall: uninstall-man
-
-
-# HELP VARIABLES
-
-# Customisable man page filename.
-ifdef COMMAND
-ifeq ($(shell $(PRINTF) '%s\n' $(COMMAND) | $(WC) -l),1)
-ifeq ($(shell $(PRINTF) '%s\n' $(_MAN_PAGE_SECTIONS) | $(WC) -l),1)
-ifeq ($(shell $(PRINTF) '%s\n' $(_MAN_$(_MAN_PAGE_SECTIONS)) | $(WC) -l),1)
-__MAN_COMMAND = $(COMMAND)$(MAN$(_MAN_PAGE_SECTIONS)EXT)
-endif
-endif
-endif
-endif
-
-
-# INSTALL RULES:
-
-.PHONY: install-man
-install-man: install-man-untranslated install-man-locale
-
-.PHONY: install-man-untranslated
-install-man-untranslated:
- @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
- $(Q)$(INSTALL_DIR) -- $(foreach S,$(_MAN_PAGE_SECTIONS),"$(DESTDIR)$(MANDIR)/$(MAN$(S))")
-ifndef __MAN_COMMAND
- $(Q)$(foreach S,$(_MAN_PAGE_SECTIONS),$(foreach P,$(_MAN_$(S)),$(INSTALL_DATA) $(v)doc/man/$(P).$(S) -- "$(DESTDIR)$(MANDIR)/$(MAN$(S))/$(P)$(MAN$(S)EXT)" &&)) $(TRUE)
-endif
-ifdef __MAN_COMMAND
- $(Q)$(foreach S,$(_MAN_PAGE_SECTIONS),$(foreach P,$(_MAN_$(S)),$(INSTALL_DATA) $(v)doc/man/$(P).$(S) -- "$(DESTDIR)$(MANDIR)/$(MAN$(S))/$(__MAN_COMMAND)" &&)) $(TRUE)
-endif
- @$(ECHO_EMPTY)
-
-.PHONY: install-man-locale
-install-man-locale:
- @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
- $(Q)$(foreach L,$(MAN_LOCALES),$(INSTALL_DIR) -- $(foreach S,$(_MAN_PAGE_SECTIONS),"$(DESTDIR)$(MANDIR)/$(L)/$(MAN$(S))") &&) $(TRUE)
-ifndef __MAN_COMMAND
- $(Q)$(foreach L,$(MAN_LOCALES),$(foreach S,$(_MAN_PAGE_SECTIONS),$(foreach P,$(_MAN_$(L)_$(S)),$(INSTALL_DATA) $(v)doc/man/$(P).$(L).$(S) -- "$(DESTDIR)$(MANDIR)/$(L)/$(MAN$(S))/$(P)$(MAN$(S)EXT)" &&))) $(TRUE)
-endif
-ifdef __MAN_COMMAND
- $(Q)$(foreach L,$(MAN_LOCALES),$(foreach S,$(_MAN_PAGE_SECTIONS),$(foreach P,$(_MAN_$(L)_$(S)),$(INSTALL_DATA) $(v)doc/man/$(P).$(L).$(S) -- "$(DESTDIR)$(MANDIR)/$(L)/$(MAN$(S))/$(__MAN_COMMAND)" &&))) $(TRUE)
-endif
- @$(ECHO_EMPTY)
-
-
-# UNINSTALL RULES:
-
-.PHONY: uninstall-man
-uninstall-man:
-ifndef __MAN_COMMAND
- -$(Q)$(RM) -- $(foreach S,$(_MAN_PAGE_SECTIONS),$(foreach P,$(_MAN_$(S)),"$(DESTDIR)$(MANDIR)/$(MAN$(S))/$(P).$(MAN$(S)EXT)"))
- -$(Q)$(RM) -- $(foreach L,$(MAN_LOCALES),$(foreach S,$(_MAN_PAGE_SECTIONS),$(foreach P,$(_MAN_$(L)_$(S)),"$(DESTDIR)$(MANDIR)/$(L)/$(MAN$(S))/$(P)$(MAN$(S)EXT)")))
-endif
-ifdef __MAN_COMMAND
- -$(Q)$(RM) -- "$(DESTDIR)$(MANDIR)/$(MAN$(_MAN_PAGE_SECTIONS))/$(__MAN_COMMAND)"
- -$(Q)$(RM) -- $(foreach L,$(MAN_LOCALES),$(foreach S,$(_MAN_PAGE_SECTIONS),$(foreach P,$(_MAN_$(L)_$(S)),"$(DESTDIR)$(MANDIR)/$(L)/$(MAN$(S))/$(__MAN_COMMAND)")))
-endif
-
-
-endif
-
diff --git a/mk/path.mk b/mk/path.mk
deleted file mode 100644
index 9d9d855..0000000
--- a/mk/path.mk
+++ /dev/null
@@ -1,176 +0,0 @@
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-#=== This file define path variables. ===#
-
-
-ifndef __PATH_MK_INCLUDED
-__PATH_MK_INCLUDED = 1
-
-
-# DIRECTORIES:
-
-# The package path prefix, if you want to install to another root, set DESTDIR to that root.
-PREFIX = /usr
-# The package path prefix for /bin, /sbin, /lib and /libexec.
-EXEC_PREFIX = /usr
-# The command path excluding prefix.
-BIN = /bin
-# The administration command path excluding prefix.
-SBIN = /sbin
-# The library path excluding prefix.
-LIB = /lib
-# The executable library path excluding prefix.
-LIBEXEC = /libexec
-# The header-file path excluding prefix.
-INCLUDE = /include
-# The resource path excluding prefix.
-DATA = /share
-# The man page sections path excluding prefix.
-MAN0 = /man0
-MAN1 = /man1
-MAN2 = /man2
-MAN3 = /man3
-MAN4 = /man4
-MAN5 = /man5
-MAN6 = /man6
-MAN7 = /man7
-MAN8 = /man8
-MAN9 = /man9
-
-# The command path including prefix.
-BINDIR = $(EXEC_PREFIX)$(BIN)
-# The administration command path including prefix.
-SBINDIR = $(EXEC_PREFIX)$(SBIN)
-# The library path including prefix.
-LIBDIR = $(EXEC_PREFIX)$(LIB)
-# The executable library path including prefix.
-LIBEXECDIR = $(EXEC_PREFIX)$(LIBEXEC)
-# The header-file path including prefix.
-INCLUDEDIR = $(PREFIX)$(INCLUDE)
-# The header-file path including prefix. Must not be /usr/local.
-ifeq ($(PREFIX),/usr/lcoal)
-OLDINCLUDEDIR = /usr$(INCLUDE)
-endif
-ifneq ($(PREFIX),/usr/lcoal)
-OLDINCLUDEDIR = $(PREFIX)$(INCLUDE)
-endif
-# The data path including prefix.
-DATADIR = $(PREFIX)$(DATA)
-# The architecture-dependent data path including prefix.
-SYSDEPDATADIR = $(DATADIR)
-# The resource path including prefix.
-RESDIR = $(DATADIR)
-# The architecture-dependent resource path including prefix.
-SYSDEPRESDIR = $(RESDIR)
-# The generic documentation path including prefix.
-DOCDIR = $(DATADIR)/doc/$(PKGNAME)
-# The info manual documentation path including prefix.
-INFODIR = $(DATADIR)/info
-# The DVI documentation path including prefix.
-DVIDIR = $(DOCDIR)
-# The PDF documentation path including prefix.
-PDFDIR = $(DOCDIR)
-# The PostScript documentation path including prefix.
-PSDIR = $(DOCDIR)
-# The HTML documentation path including prefix.
-HTMLDIR = $(DOCDIR)
-# The man page documentation path including prefix.
-MANDIR = $(DATADIR)/man
-# The Emacs LISP path including prefix.
-LISPDIR = $(DATADIR)/emacs/site-lisp
-# The locale path including prefix.
-LOCALEDIR = $(DATADIR)/locale
-# The license base path including prefix.
-LICENSEDIR = $(DATADIR)/licenses
-# The persistent variable data directory.
-VARDIR = /var
-# The persistent directory for temporary files.
-VARTMPDIR = $(VARDIR)/tmp
-# The network-common persistent variable data directory.
-COMDIR = /com
-# The network-common persistent directory for temporary files.
-COMTMPDIR = $(COMDIR)/tmp
-# The transient directory for temporary files.
-TMPDIR = /tmp
-# The transient directory for runtime files.
-RUNDIR = /run
-# The directory for site-specific configurations.
-SYSCONFDIR = /etc
-# The directory for pseudo-devices.
-DEVDIR = /dev
-# The /sys directory.
-SYSDIR = /sys
-# The /proc directory
-PROCDIR = /proc
-# The /proc/self directory
-SELFPROCDIR = $(PROCDIR)/self
-# The cache directory.
-CACHEDIR = $(VARDIR)/cache
-# The spool directory.
-SPOOLDIR = $(VARDIR)/spool
-# The empty directory.
-EMPTYDIR = $(VARDIR)/empty
-# The logfile directory.
-LOGDIR = $(VARDIR)/log
-# The state directory.
-STATEDIR = $(VARDIR)/lib
-# The highscore directory.
-GAMEDIR = $(VARDIR)/games
-# The lockfile directory.
-LOCKDIR = $(RUNDIR)/lock
-# The user skeleton directory.
-SKELDIR = $(SYSCONFDIR)/skel
-# The network-common cache directory.
-COMCACHEDIR = $(COMDIR)/cache
-# The network-common spool directory.
-COMSPOOLDIR = $(COMDIR)/spool
-# The network-common logfile directory.
-COMLOGDIR = $(COMDIR)/log
-# The network-common state directory.
-COMSTATEDIR = $(COMDIR)/lib
-# The network-common highscore directory.
-COMGAMEDIR = $(COMDIR)/games
-
-
-# FILENAME SUFFIXES:
-
-# Filename suffixes for man pages by section.
-MAN0EXT = .0
-MAN1EXT = .1
-MAN2EXT = .2
-MAN3EXT = .3
-MAN4EXT = .4
-MAN5EXT = .5
-MAN6EXT = .6
-MAN7EXT = .7
-MAN8EXT = .8
-MAN9EXT = .9
-
-
-# HELP VARIABLES:
-
-# All path variables that includes the prefix,
-# or are unaffected by the prefix.
-_ALL_DIRS = BINDIR SBINDIR LIBDIR LIBEXECDIR INCLUDEDIR DATADIR SYSDEPDATADIR DOCDIR \
- INFODIR DVIDIR PDFDIR PSDIR HTMLDIR MANDIR LOCALEDIR LICENSEDIR VARDIR \
- RESDIR VARTMPDIR COMDIR COMTMPDIR TMPDIR RUNDIR SYSCONFDIR DEVDIR SYSDIR \
- PROCDIR SELFPROCDIR CACHEDIR SPOOLDIR EMPTYDIR LOGDIR STATEDIR GAMEDIR \
- LOCKDIR SKELDIR COMCACHEDIR COMSPOOLDIR COMLOGDIR COMSTATEDIR COMGAMEDIR \
- SYSDEPRESDIR OLDINCLUDEDIR
-
-# ../, ../../, and ../../../, ignored if v is used, which if an absolute path.
-ifndef v
-__back1unless_v = ../
-__back2unless_v = ../../
-__back3unless_v = ../../../
-endif
-
-
-endif
-
diff --git a/mk/prologue.mk b/mk/prologue.mk
deleted file mode 100644
index 5d9a558..0000000
--- a/mk/prologue.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-#=== This file includes rules for automatically rebuilding the makefile. ===#
-
-
-base: Makefile
-
-Makefile: $(v)Makefile.in config.status $(v)configure $(v)mk/configure
- ./config.status
-
diff --git a/mk/shell.mk b/mk/shell.mk
deleted file mode 100644
index 2747152..0000000
--- a/mk/shell.mk
+++ /dev/null
@@ -1,233 +0,0 @@
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-#=== These rules are used for shell tab-completion using auto-auto-complete. ===#
-
-
-# Enables the rules:
-# shell Build tab-completion for all supported shells
-# bash Build GNU Bash tab-completion
-# fish Build fish tab-completion
-# zhs Build Z shell tab-completion
-# install-shell Install tab-completion for all supported shells
-# install-bash Install GNU Bash tab-completion
-# install-fish Install fish tab-completion
-# install-zsh Install Z shell tab-completion
-#
-# This file is ignored unless
-# _AUTO_COMPLETE is defined.
-#
-# _AUTO_COMPLETE shall list all commands that
-# have an auto-auto-complete. These should be
-# named src/$(COMMAND).auto-completion, where
-# $(COMMAND) is the command with the script.
-# If all auto-auto-complete scripts translations
-# named src/$(COMMAND).$(LOCALE).auto-completion,
-# SHELL_LOCALE can be set to install exactly
-# on translation in place of the non-translated
-# versions.
-#
-# Although not used by this file, you should
-# define _SHELL_LOCALES that lists all available
-# translations. (it is used by dist.mk.)
-#
-# You should also define _WITH_SHELL if you
-# want shell tab-completion unless the user
-# specifies otherwise. If you want it for
-# just some shells, define _WITH_$(SHELL)
-# for those shells instead of _WITH_SHELL.
-
-
-ifdef _AUTO_COMPLETE
-
-
-# HELP VARIABLES:
-
-# Include all that were not explicitly excluded?
-ifdef _WITH_SHELL
-_WITH_BASH = 1
-_WITH_FISH = 1
-_WITH_ZSH = 1
-endif
-
-# Include for GNU Bash?
-ifdef WITH_BASH
-__WITH_BASH = 1
-endif
-ifndef WITH_BASH
-ifndef WITHOUT_BASH
-ifdef _WITH_BASH
-__WITH_BASH = 1
-endif
-endif
-endif
-
-# Include for fish?
-ifdef WITH_FISH
-__WITH_FISH = 1
-endif
-ifndef WITH_FISH
-ifndef WITHOUT_FISH
-ifdef _WITH_FISH
-__WITH_FISH = 1
-endif
-endif
-endif
-
-# Include for Z Shell?
-ifdef WITH_ZSH
-__WITH_ZSH = 1
-endif
-ifndef WITH_ZSH
-ifndef WITHOUT_ZSH
-ifdef _WITH_ZSH
-__WITH_ZSH = 1
-endif
-endif
-endif
-
-# WHEN TO BUILD, INSTALL, AND UNINSTALL:
-
-all: shell
-everything: shell
-install: install-shell
-install-doc: install-info install-dvi install-pdf install-ps install-html
-uninstall: uninstall-shell
-
-shell:
-install-shell:
-
-ifdef __WITH_BASH
-shell: bash
-install-shell: install-bash
-endif
-ifdef __WITH_FISH
-shell: fish
-install-shell: install-fish
-endif
-ifdef __WITH_ZSH
-shell: zsh
-install-shell: install-zsh
-endif
-
-
-# HELP VARIABLES:
-
-# Affixes on the source files.
-ifdef SHELL_LOCALE
-__AAC_L = .$(SHELL_LOCALE)
-endif
-__AAC = $(__AAC_L).auto-completion
-
-# Customised command name.
-ifdef COMMAND
-ifeq ($(shell $(PRINTF) '%s\n' $(COMMAND) | $(WC) -l),1)
-ifeq ($(shell $(PRINTF) '%s\n' $(_AUTO_COMPLETE) | $(WC) -l),1)
-__SHELL_COMMAND = "command=$(COMMAND)"
-endif
-endif
-endif
-
-
-# BUILD RULES:
-
-# Built tab-completion scripts for GNU Bash.
-.PHONY: bash
-bash: $(foreach F,$(_AUTO_COMPLETE),bin/$(F).bash-completion)
-
-# Built tab-completion scripts for fish.
-.PHONY: fish
-fish: $(foreach F,$(_AUTO_COMPLETE),bin/$(F).fish-completion)
-
-# Built tab-completion scripts for Z shell.
-.PHONY: zsh
-zsh: $(foreach F,$(_AUTO_COMPLETE),bin/$(F).zsh-completion)
-
-# Built a tab-completion script for GNU Bash.
-bin/%.bash-completion: $(v)src/%$(__AAC)
- @$(PRINTF_INFO) '\e[00;01;31mAUTO-AUTO-COMPLETE\e[34m %s\e[00m$A\n' "$@"
- @$(MKDIR) -p bin
- $(Q)$(AUTO_AUTO_COMPLETE) bash -o $@ -s $< $(__SHELL_COMMAND) #$Z
- @$(ECHO_EMPTY)
-
-# Built a tab-completion script for fish.
-bin/%.fish-completion: $(v)src/%$(__AAC)
- @$(PRINTF_INFO) '\e[00;01;31mAUTO-AUTO-COMPLETE\e[34m %s\e[00m$A\n' "$@"
- @$(MKDIR) -p bin
- $(Q)$(AUTO_AUTO_COMPLETE) fish -o $@ -s $< $(__SHELL_COMMAND) #$Z
- @$(ECHO_EMPTY)
-
-# Built a tab-completion script for Z shell.
-bin/%.zsh-completion: $(v)src/%$(__AAC)
- @$(PRINTF_INFO) '\e[00;01;31mAUTO-AUTO-COMPLETE\e[34m %s\e[00m$A\n' "$@"
- @$(MKDIR) -p bin
- $(Q)$(AUTO_AUTO_COMPLETE) zsh -o $@ -s $< $(__SHELL_COMMAND) #$Z
- @$(ECHO_EMPTY)
-
-
-# INSTALL RULES:
-
-# Install tab-completion scripts for GNU Bash.
-.PHONY: install-bash
-install-bash: $(foreach F,$(_AUTO_COMPLETE),bin/$(F).bash-completion)
- @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
- $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(DATADIR)/bash-completion/completions"
-ifndef __SHELL_COMMAND
- $(Q)$(foreach F,$(_AUTO_COMPLETE),$(INSTALL_DATA) bin/$(F).bash-completion -- "$(DESTDIR)$(DATADIR)/bash-completion/completions/$(F)" &&) $(TRUE)
-endif
-ifdef __SHELL_COMMAND
- $(Q)$(INSTALL_DATA) $^ -- "$(DESTDIR)$(DATADIR)/bash-completion/completions/$(COMMAND)"
-endif
- @$(ECHO_EMPTY)
-
-# Install tab-completion scripts for fish.
-.PHONY: install-fish
-install-fish: $(foreach F,$(_AUTO_COMPLETE),bin/$(F).fish-completion)
- @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
- $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(DATADIR)/fish/completions"
-ifndef __SHELL_COMMAND
- $(Q)$(foreach F,$(_AUTO_COMPLETE),$(INSTALL_DATA) bin/$(F).fish-completion -- "$(DESTDIR)$(DATADIR)/fish/completions/$(F).fish" &&) $(TRUE)
-endif
-ifdef __SHELL_COMMAND
- $(Q)$(INSTALL_DATA) $^ -- "$(DESTDIR)$(DATADIR)/fish/completions/$(COMMAND).fish"
-endif
- @$(ECHO_EMPTY)
-
-# Install tab-completion scripts for Z shell.
-.PHONY: install-zsh
-install-zsh: $(foreach F,$(_AUTO_COMPLETE),bin/$(F).zsh-completion)
- @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
- $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(DATADIR)/zsh/site-functions"
-ifndef __SHELL_COMMAND
- $(Q)$(foreach F,$(_AUTO_COMPLETE),$(INSTALL_DATA) bin/$(F).zsh-completion -- "$(DESTDIR)$(DATADIR)/zsh/site-functions/_$(F)" &&) $(TRUE)
-endif
-ifdef __SHELL_COMMAND
- $(Q)$(INSTALL_DATA) $^ -- "$(DESTDIR)$(DATADIR)/zsh/site-functions/_$(COMMAND)"
-endif
- @$(ECHO_EMPTY)
-
-
-# UNINSTALL RULES:
-
-# Uninstall tab-completion.
-.PHONY: uninstall-shell
-uninstall-shell:
-ifndef __SHELL_COMMAND
- -$(Q)$(RM) -- $(foreach F,$(_AUTO_COMPLETE),"$(DESTDIR)$(DATADIR)/bash-completion/completions/$(F)")
- -$(Q)$(RM) -- $(foreach F,$(_AUTO_COMPLETE),"$(DESTDIR)$(DATADIR)/fish/completions/$(F).fish")
- -$(Q)$(RM) -- $(foreach F,$(_AUTO_COMPLETE),"$(DESTDIR)$(DATADIR)/zsh/site-functions/_$(F)")
-endif
-ifdef __SHELL_COMMAND
- -$(Q)$(RM) -- "$(DESTDIR)$(DATADIR)/bash-completion/completions/$(COMMAND)"
- -$(Q)$(RM) -- "$(DESTDIR)$(DATADIR)/fish/completions/$(COMMAND).fish"
- -$(Q)$(RM) -- "$(DESTDIR)$(DATADIR)/zsh/site-functions/_$(COMMAND)"
-endif
-
-
-endif
-
diff --git a/mk/tags.mk b/mk/tags.mk
deleted file mode 100644
index 926cb5d..0000000
--- a/mk/tags.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-#=== These rules are used for generate etags- and ctags-tablse. ===#
-
-
-# Generate etags-table.
-.PHONY: TAGS
-TAGS:
- @$(ECHO)
- @$(ECHO) "TAGS is not implemented. Did not see the need. Feel free to implement if you want."
- @$(ECHO)
-
-# Generate ctags-table
-.PHONY: tags
-tags:
- @$(ECHO)
- @$(ECHO) "tags is not implemented. Did not see the need. Feel free to implement if you want."
- @$(ECHO)
-
diff --git a/mk/texinfo.mk b/mk/texinfo.mk
deleted file mode 100644
index e2ccb12..0000000
--- a/mk/texinfo.mk
+++ /dev/null
@@ -1,294 +0,0 @@
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-# TODO ((support translations))
-#=== These rules are used for Texinfo manuals. ===#
-
-
-# Enables the rules:
-# info Build info manual
-# dvi Build DVI manual
-# pdf Build PDF manual
-# ps Build PostScript manual
-# html Build HTML manual
-# install-info Install info manual
-# install-dvi Install DVI manual
-# install-pdf Install PDF manual
-# install-ps Install PostScript manual
-# install-html Install HTML manual
-#
-# This file is ignored unless
-# _HAVE_TEXINFO_MANUAL is defined.
-#
-# This file can only build output for
-# one Texinfo manual. This manual must
-# be named doc/info/$(_PROJECT).texinfo.
-# Additional sourced are set by specifing
-# how man directories deep doc/info nests
-# in the variable _TEXINFO_DIRLEVELS.
-#
-# If the info manual splits, specify the
-# split-number, of the file with the highest
-# split-number, in the variable _INFOPARTS.
-#
-# If the project has a logo, _LOGO should
-# name the suffixless basename of the SVG
-# files that contains the logo. This file
-# must be located in doc/.
-#
-# _HTML_FILES should the basename (with
-# suffix) of all files generated by `html`.
-#
-# The user may define TEXINFO_FLAGS that
-# adds additional flags when compiling
-# DVI, PDF, and PostScript manuals. The
-# user may also define INFO_FLAGS that
-# adds additional flags when compiling
-# info and HTML manuals.
-
-
-ifdef _HAVE_TEXINFO_MANUAL
-
-
-# WHEN TO BUILD, INSTALL, AND UNINSTALL:
-
-all: info
-everything: info dvi pdf ps html
-doc: info dvi pdf ps html
-install: install-info
-install-everything: install-info install-dvi install-pdf install-ps install-html
-install-doc: install-info install-dvi install-pdf install-ps install-html
-uninstall: uninstall-info uninstall-dvi uninstall-pdf uninstall-ps uninstall-html
-
-
-# HELP VARIABLES:
-
-# Files from which the Texinfo manuals are built.
-ifdef _TEXINFO_DIRLEVELS
-ifeq ($(_TEXINFO_DIRLEVELS),1)
-__TEXI_SRC_ = *.texinfo
-endif
-ifeq ($(_TEXINFO_DIRLEVELS),2)
-__TEXI_SRC_ = *.texinfo */*.texinfo
-endif
-ifeq ($(_TEXINFO_DIRLEVELS),3)
-__TEXI_SRC_ = *.texinfo */*.texinfo */*/*.texinfo
-endif
-ifneq ($(_TEXINFO_DIRLEVELS),1)
-ifneq ($(_TEXINFO_DIRLEVELS),2)
-ifneq ($(_TEXINFO_DIRLEVELS),3)
-__TEXI_SRC_ = $(foreach W,$(shell $(SEQ) $(_TEXINFO_DIRLEVELS) | while read n; do $(ECHO) $$($(SEQ) $$n)" " | $(SED) 's/[^ ]* /\/\*/g'; done | $(XARGS) $(ECHO)),$(shell $(ECHO) $(W).texinfo | $(SED) 's/^.//'))
-endif
-endif
-endif
-__TEXI_SRC = $(foreach S,$(__TEXI_SRC_),$(foreach F,$(shell cd $(v)doc/info && $(ECHO) $(S)),aux/doc/$(F)))
-endif
-
-# Split parts of the info manual.
-ifdef _INFOPARTS
-ifneq ($(_INFOPARTS),0)
-__INFOPARTS = $(shell $(SEQ))
-endif
-endif
-
-# Flags for TeX processed output.
-__TEXINFO_FLAGS = $(TEXINFO_FLAGS)
-ifdef _LOGO
-__TEXINFO_FLAGS += '--texinfo="@set LOGO $(_LOGO)"'
-endif
-
-
-# BUILD RULES:
-
-ifdef _LOGO
-# Prepare conversion of logo.
-aux/$(_LOGO).svg: $(v)doc/$(_LOGO).svg
- @$(PRINTF_INFO) '\e[00;01;31mCP\e[34m %s\e[00m$A\n' "$@"
- @$(MKDIR) -p aux
- $(Q)$(CP) $^ $@ #$Z
- @$(ECHO_EMPTY)
-
-# Intermediate format for the logo for DVI and PostScript manuals.
-aux/$(_LOGO).ps: $(v)doc/$(_LOGO).svg
- @$(PRINTF_INFO) '\e[00;01;31mPS\e[34m %s\e[00m$A\n' "$@"
- @$(MKDIR) -p aux
- $(Q)$(SVG2PS) $^ > $@ #$Z
- @$(ECHO_EMPTY)
-
-# Logo for DVI and PostScript manuals.
-aux/$(_LOGO).eps: aux/$(_LOGO).ps
- @$(PRINTF_INFO) '\e[00;01;31mEPS\e[34m %s\e[00m$A\n' "$@"
- $(Q)$(PS2EPS) $^ #$Z
- @$(ECHO_EMPTY)
-
-# Logo for PDF manual.
-aux/$(_LOGO).pdf: $(v)doc/$(_LOGO).svg
- @$(PRINTF_INFO) '\e[00;01;31mPDF\e[34m %s\e[00m$A\n' "$@"
- @$(MKDIR) -p aux
- $(Q)$(SVG2PDF) $^ > $@ #$Z
- @$(ECHO_EMPTY)
-endif
-
-# Copy texinfo files to aux/doc.
-aux/doc/%.texinfo: $(v)doc/info/%.texinfo
- @$(PRINTF_INFO) '\e[00;01;31mCP\e[34m %s\e[00m$A\n' "$@"
- @$(MKDIR) -p $(shell $(DIRNAME) $@)
- $(Q)$(CP) $< $@ #$Z
- @$(ECHO_EMPTY)
-
-# Build info manual.
-.PHONY: info
-info: $(__TEXI_SRC) bin/$(_PROJECT).info
-bin/%.info $(foreach P,$(__INFOPARTS),bin/%.info-$(P)): aux/doc/%.texinfo $(__TEXI_SRC)
- @$(PRINTF_INFO) '\e[00;01;31mTEXI\e[34m %s\e[00m$A\n' "$@"
- @$(MKDIR) -p bin
- $(Q)$(MAKEINFO) $(INFO_FLAGS) $< #$Z
- @$(PRINTF_INFO) '$A'
- $(Q)$(MV) $*.info $@ #$Z
- @$(ECHO_EMPTY)
-
-# Build DVI manual.
-.PHONY: dvi
-dvi: $(__TEXI_SRC) bin/$(_PROJECT).dvi
-bin/%.dvi: aux/doc/%.texinfo $(__TEXI_SRC) $(foreach L,$(_LOGO),aux/$(L).eps)
- @$(PRINTF_INFO) '\e[00;01;31mTEXI\e[34m %s\e[00m$A\n' "$@"
- @! $(TEST) -d aux/dvi/$* || $(RM) -rf aux/dvi/$*
- @$(MKDIR) -p aux/dvi/$* bin
- $(Q)cd aux/dvi/$* && $(TEXI2DVI) $(__back3unless_v)$< $(__TEXINFO_FLAGS) < /dev/null #$Z
- @$(PRINTF_INFO) '$A'
- $(Q)$(MV) aux/dvi/$*/$*.dvi $@ #$Z
- @$(ECHO_EMPTY)
-
-# Build PDF manual.
-.PHONY: pdf
-pdf: $(__TEXI_SRC) bin/$(_PROJECT).pdf
-bin/%.pdf: aux/doc/%.texinfo $(__TEXI_SRC) $(foreach L,$(_LOGO),aux/$(L).pdf)
- @$(PRINTF_INFO) '\e[00;01;31mTEXI\e[34m %s\e[00m$A\n' "$@"
- @! $(TEST) -d aux/pdf/$* || $(RM) -rf aux/pdf/$*
- @$(MKDIR) -p aux/pdf/$* bin
- $(Q)cd aux/pdf/$* && $(TEXI2PDF) $(__back3unless_v)$< $(__TEXINFO_FLAGS) < /dev/null #$Z
- @$(PRINTF_INFO) '$A'
- $(Q)$(MV) aux/pdf/$*/$*.pdf $@ #$Z
- @$(ECHO_EMPTY)
-
-# Build PostScript manual.
-.PHONY: ps
-ps: $(__TEXI_SRC) bin/$(_PROJECT).ps
-bin/%.ps: aux/doc/%.texinfo $(__TEXI_SRC) $(foreach L,$(_LOGO),aux/$(L).eps)
- @$(PRINTF_INFO) '\e[00;01;31mTEXI\e[34m %s\e[00m$A\n' "$@"
- @! $(TEST) -d aux/ps/$* || $(RM) -rf aux/ps/$*
- @$(MKDIR) -p aux/ps/$* bin
- $(Q)cd aux/ps/$* && $(TEXI2PS) $(__back3unless_v)$< $(__TEXINFO_FLAGS) < /dev/null #$Z
- @$(PRINTF_INFO) '$A'
- $(Q)$(MV) aux/ps/$*/$*.ps $@ #$Z
- @$(ECHO_EMPTY)
-
-# Build HTML manual.
-.PHONY: html
-html: $(__TEXI_SRC) bin/html/$(_PROJECT)/index.html
-bin/html/%/index.html: aux/doc/%.texinfo $(__TEXI_SRC)
- @$(PRINTF_INFO) '\e[00;01;31mTEXI\e[34m %s\e[00m$A\n' "$@"
- @! $(TEST) -d bin/html/$* || $(RM) -rf bin/html/$*
- @$(MKDIR) -p bin/html
- $(Q)cd bin/html && $(MAKEINFO_HTML) $(INFO_FLAGS) $(__back2unless_v)$< < /dev/null #$Z
- @$(ECHO_EMPTY)
-
-
-# INSTALL RULES:
-
-# Install info manual.
-.PHONY: install-info
-install-info: bin/$(_PROJECT).info $(foreach P,$(__INFOPARTS),bin/%.info-$(P))
- @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
- $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(INFODIR)"
- $(Q)$(INSTALL_DATA) bin/$(_PROJECT).info -- "$(DESTDIR)$(INFODIR)/$(PKGNAME).info"
- $(Q)$(forearch P,$(__INFOPARTS),$(INSTALL_DATA) bin/$*.info-$(P) -- "$(DESTDIR)$(INFODIR)/$(PKGNAME).info-$(P)" &&) $(TRUE)
-ifdef POST_INSTALL
- $(POST_INSTALL)
-endif
- $(Q)if $(SHELL) -c '$(N) $(INSTALL_INFO) --version' > /dev/null 2>&1; then \
- $(N)$(z) $(INSTALL_INFO) -- "${DESTDIR}${INFODIR}/$(PKGNAME).info" "${DESTDIR}${INFODIR}/dir"; \
- else \
- $(TRUE); \
- fi
-ifdef POST_INSTALL
- $(NORMAL_INSTALL)
-endif
- @$(ECHO_EMPTY)
-
-# Install DVI manual.
-.PHONY: install-dvi
-install-dvi: bin/$(_PROJECT).dvi
- @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
- $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(DVIDIR)"
- $(Q)$(INSTALL_DATA) $^ -- "$(DESTDIR)$(DVIDIR)/$(PKGNAME).dvi"
- @$(ECHO_EMPTY)
-
-# Install PDF manual.
-.PHONY: install-pdf
-install-pdf: bin/$(_PROJECT).pdf
- @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
- $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(PDFDIR)"
- $(Q)$(INSTALL_DATA) $^ -- "$(DESTDIR)$(PDFDIR)/$(PKGNAME).pdf"
- @$(ECHO_EMPTY)
-
-# Install PostScript manual.
-.PHONY: install-ps
-install-ps: bin/$(_PROJECT).ps
- @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
- $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(PSDIR)"
- $(Q)$(INSTALL_DATA) $^ -- "$(DESTDIR)$(PSDIR)/$(PKGNAME).ps"
- @$(ECHO_EMPTY)
-
-# Install HTML manual.
-.PHONY: install-html
-install-html: $(foreach F,$(_HTML_FILES),bin/html/$(_PROJECT)/$(F))
- @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
- $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(HTMLDIR)/$(PKGNAME)"
- $(Q)$(INSTALL_DATA) $^ -- "$(DESTDIR)$(HTMLDIR)/$(PKGNAME)/"
- @$(ECHO_EMPTY)
-
-
-# UNINSTALL RULES:
-
-# Uninstall info manual.
-.PHONY: uninstall-info
-uninstall-info:
-ifdef PRE_UNINSTALL
- $(PRE_UNINSTALL)
-endif
- -$(Q)$(N)$(a) $(INSTALL_INFO) --delete -- "${DESTDIR}${INFODIR}/$(PKGNAME).info" "${DESTDIR}${INFODIR}/dir"
-ifdef PRE_UNINSTALL
- $(NORMAL_UNINSTALL)
-endif
- -$(Q)$(RM) -- "$(DESTDIR)$(INFODIR)/$(PKGNAME).info" $(forearch P,$(__INFOPARTS),"$(DESTDIR)$(INFODIR)/$(PKGNAME).info-$(P)")
-
-# Uninstall DVI manual.
-.PHONY: uninstall-dvi
-uninstall-dvi:
- -$(Q)$(RM) -- "$(DESTDIR)$(DVIDIR)/$(PKGNAME).dvi"
-
-# Uninstall PDF manual.
-.PHONY: uninstall-pdf
-uninstall-pdf:
- -$(Q)$(RM) -- "$(DESTDIR)$(PDFDIR)/$(PKGNAME).pdf"
-
-# Uninstall PostScript manual.
-.PHONY: uninstall-ps
-uninstall-ps:
- -$(Q)$(RM) -- "$(DESTDIR)$(PSDIR)/$(PKGNAME).ps"
-
-# Uninstall HTML manual.
-.PHONY: uninstall-html
-uninstall-html:
- -$(Q)$(RM) -- $(foreach F,$(_HTML_FILES),"$(DESTDIR)$(HTMLDIR)/$(PKGNAME)/$(F)")
- -$(Q)$(RM) -- "$(DESTDIR)$(HTMLDIR)/$(PKGNAME)"
-
-
-endif
-
diff --git a/mk/tools.mk b/mk/tools.mk
deleted file mode 100644
index e3d9bfe..0000000
--- a/mk/tools.mk
+++ /dev/null
@@ -1,163 +0,0 @@
-# Copyright (C) 2015, 2016 Mattias Andrée <maandree@member.fsf.org>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-#=== This file defines variables for all used commands. ===#
-
-
-# Part of GNU Coreutils:
-BASENAME ?= basename
-CHGRP ?= chgrp
-CHMOD ?= chmod
-CHOWN ?= chown
-CP ?= cp
-CPLIT ?= cplit
-CUT ?= cut
-DATE ?= date
-DIRNAME ?= dirname
-ECHO ?= echo
-ENV ?= env
-EXPAND ?= expand
-EXPR ?= expr
-FALS ?= false
-FMT ?= fmt
-FOLD ?= fold
-HEAD ?= head
-INSTALL ?= install
-INSTALL_DATA ?= $(INSTALL) -m644
-INSTALL_DIR ?= $(INSTALL) -dm755
-INSTALL_PROGRAM ?= $(INSTALL) -m755
-JOIN ?= join
-LN ?= ln
-MKDIR ?= mkdir
-MKFIFO ?= mkfifo
-MKNOD ?= mknod
-MV ?= mv
-NL ?= nl
-NPROC ?= nproc
-NUMFMT ?= numfmt
-OD ?= od
-PASTE ?= paste
-PATHCHK ?= pathchk
-PR ?= pr
-PRINTF ?= printf
-READLINK ?= readlink
-REALPATH ?= realpath
-RM ?= rm
-RMDIR ?= rmdir
-SEQ ?= seq
-SLEEP ?= sleep
-SORT ?= sort
-SPLIT ?= split
-STAT ?= stat
-TAC ?= tac
-TAIL ?= tail
-TEE ?= tee
-TEST ?= test
-TOUCH ?= touch
-TR ?= tr
-TRUE ?= true
-TRUNCATE ?= truncate
-TSORT ?= tsort
-UNAME ?= uname
-UNEXPAND ?= unexpand
-UNIQ ?= uniq
-WC ?= wc
-YES ?= yes
-
-# Part of GNU help2man:
-HELP2MAN ?= help2man
-
-# Part of GNU tar:
-TAR ?= tar
-
-# Part of GNU Findutils:
-FIND ?= find
-XARGS ?= xargs
-
-# Part of GNU Grep:
-GREP ?= grep
-EGREP ?= egrep
-FGREP ?= fgrep
-
-# Part of GNU Sed:
-SED ?= sed
-
-# Part of GNU Privacy Guard:
-GPG ?= gpg
-
-# Part of Texinfo:
-MAKEINFO ?= makeinfo
-MAKEINFO_HTML ?= $(MAKEINFO) --html
-INSTALL_INFO ?= install-info
-
-# Part of Texlive-plainextra:
-TEXI2PDF ?= texi2pdf
-TEXI2DVI ?= texi2dvi
-TEXI2PS ?= texi2pdf --ps
-
-# Part of Texlive-core:
-PS2EPS ?= ps2eps
-
-# Part of librsvg:
-RSVG_CONVERT ?= rsvg-convert
-SVG2PS ?= $(RSVG_CONVERT) --format=ps
-SVG2PDF ?= $(RSVG_CONVERT) --format=pdf
-
-# Part of GNU Compiler Collection:
-CC ?= cc
-CPP ?= cpp
-CXX ?= c++
-
-# Part of GNU Binutils:
-AR ?= ar
-LD ?= ld
-RANLIB ?= ranlib
-
-# Part of GNU Bison:
-BISON ?= bison
-YACC ?= yacc
-
-# Part of Flex:
-FLEX ?= FLEX
-LEX ?= lex
-
-# Part of GNU C Library:
-LDCONFIG ?= ldconfig
-
-# Part of GNU Gettext:
-XGETTEXT ?= xgettext
-MSGFMT ?= msgfmt
-MSGMERGE ?= msgmerge
-MSGINIT ?= msginit
-
-# Part of gzip:
-GZIP ?= gzip
-GZIP_COMPRESS ?= $(GZIP) -k9
-
-# Part of bzip2:
-BZIP2 ?= bzip2
-BZIP2_COMPRESS ?= $(BZIP2) -k9
-
-# Part of xz:
-XZ ?= xz
-XZ_COMPRESS ?= $(XZ) -ke9
-
-# Part of auto-auto-complete:
-AUTO_AUTO_COMPLETE ?= auto-auto-complete
-
-
-# Change to $(TRUE) to suppress the bold red and blue output.
-ifndef PRINTF_INFO
-PRINTF_INFO = $(PRINTF)
-endif
-
-# Change to $(TRUE) to suppress empty lines
-ifndef ECHO_EMPTY
-ECHO_EMPTY = $(ECHO)
-endif
-
diff --git a/src/convert.c b/src/convert.c
deleted file mode 100644
index 6d9be16..0000000
--- a/src/convert.c
+++ /dev/null
@@ -1,1068 +0,0 @@
-/**
- * Copyright © 2016 Mattias Andrée <maandree@kth.se>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 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/>.
- */
-#include "libcolour.h"
-
-#include <errno.h>
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-
-#define WASDIV0(x) (isinf(x) || isnan(x))
-#define PI (3.14159265358979323846)
-#define PI2 (2 * PI)
-
-
-
-static void to_rgb(const libcolour_colour_t* restrict from, libcolour_rgb_t* restrict to);
-static void to_srgb(const libcolour_colour_t* restrict from, libcolour_srgb_t* restrict to);
-static void to_ciexyy(const libcolour_colour_t* restrict from, libcolour_ciexyy_t* restrict to);
-static void to_ciexyz(const libcolour_colour_t* restrict from, libcolour_ciexyz_t* restrict to);
-static void to_cielab(const libcolour_colour_t* restrict from, libcolour_cielab_t* restrict to);
-static void to_cieluv(const libcolour_colour_t* restrict from, libcolour_cieluv_t* restrict to);
-static void to_cielchuv(const libcolour_colour_t* restrict from, libcolour_cielchuv_t* restrict to);
-static void to_yiq(const libcolour_colour_t* restrict from, libcolour_yiq_t* restrict to);
-static void to_ydbdr(const libcolour_colour_t* restrict from, libcolour_ydbdr_t* restrict to);
-static void to_yuv(const libcolour_colour_t* restrict from, libcolour_yuv_t* restrict to);
-static void to_ypbpr(const libcolour_colour_t* restrict from, libcolour_ypbpr_t* restrict to);
-static void to_ycgco(const libcolour_colour_t* restrict from, libcolour_ycgco_t* restrict to);
-static void to_cie1960ucs(const libcolour_colour_t* restrict from, libcolour_cie1960ucs_t* restrict to);
-static void to_cieuvw(const libcolour_colour_t* restrict from, libcolour_cieuvw_t* restrict to);
-
-
-static void ciexyz_to_rgb(const libcolour_ciexyz_t* restrict from, libcolour_rgb_t* restrict to)
-{
- double X = from->X, Y = from->Y, Z = from->Z;
- to->R = to->Minv[0][0] * X + to->Minv[0][1] * Y + to->Minv[0][2] * Z;
- to->G = to->Minv[1][0] * X + to->Minv[1][1] * Y + to->Minv[1][2] * Z;
- to->B = to->Minv[2][0] * X + to->Minv[2][1] * Y + to->Minv[2][2] * Z;
-}
-
-#define REGULAR(s, t) ((t) <= (s)->transition ? (s)->slope * (t) : (1 + (s)->offset) * pow((t), 1 / (s)->gamma) - (s)->offset)
-#define INVREGULAR(s, t) ((t) <= (s)->transitioninv ? (t) / (s)->slope : pow(((t) + (s)->offset) / (1 + (s)->offset), (s)->gamma))
-
-static void rgb_encode(libcolour_rgb_t* restrict colour, const libcolour_rgb_t* restrict space)
-{
- double r_sign = 1, g_sign = 1, b_sign = 1;
- switch (space->encoding_type) {
- case LIBCOLOUR_ENCODING_TYPE_LINEAR:
- break;
- case LIBCOLOUR_ENCODING_TYPE_SIMPLE:
- case LIBCOLOUR_ENCODING_TYPE_REGULAR:
- if (colour->R < 0) r_sign = -1, colour->R = -colour->R;
- if (colour->G < 0) g_sign = -1, colour->G = -colour->G;
- if (colour->B < 0) b_sign = -1, colour->B = -colour->B;
- if (space->encoding_type == LIBCOLOUR_ENCODING_TYPE_SIMPLE) {
- colour->R = pow(colour->R, 1 / space->gamma);
- colour->G = pow(colour->G, 1 / space->gamma);
- colour->B = pow(colour->B, 1 / space->gamma);
- } else {
- colour->R = REGULAR(space, colour->R);
- colour->G = REGULAR(space, colour->G);
- colour->B = REGULAR(space, colour->B);
- }
- colour->R *= r_sign;
- colour->G *= g_sign;
- colour->B *= b_sign;
- break;
- case LIBCOLOUR_ENCODING_TYPE_CUSTOM:
- colour->R = (space->to_encoded_red)(colour->R);
- colour->G = (space->to_encoded_green)(colour->G);
- colour->B = (space->to_encoded_blue)(colour->B);
- break;
- default:
- fprintf(stderr, "libcolour: invalid encoding type\n");
- abort();
- }
-}
-
-static void rgb_decode(libcolour_rgb_t* restrict colour, const libcolour_rgb_t* restrict space)
-{
- double r_sign = 1, g_sign = 1, b_sign = 1;
- switch (space->encoding_type) {
- case LIBCOLOUR_ENCODING_TYPE_LINEAR:
- break;
- case LIBCOLOUR_ENCODING_TYPE_SIMPLE:
- case LIBCOLOUR_ENCODING_TYPE_REGULAR:
- if (colour->R < 0) r_sign = -1, colour->R = -colour->R;
- if (colour->G < 0) g_sign = -1, colour->G = -colour->G;
- if (colour->B < 0) b_sign = -1, colour->B = -colour->B;
- if (space->encoding_type == LIBCOLOUR_ENCODING_TYPE_SIMPLE) {
- colour->R = pow(colour->R, space->gamma);
- colour->G = pow(colour->G, space->gamma);
- colour->B = pow(colour->B, space->gamma);
- } else {
- colour->R = INVREGULAR(space, colour->R);
- colour->G = INVREGULAR(space, colour->G);
- colour->B = INVREGULAR(space, colour->B);
- }
- colour->R *= r_sign;
- colour->G *= g_sign;
- colour->B *= b_sign;
- break;
- case LIBCOLOUR_ENCODING_TYPE_CUSTOM:
- colour->R = (space->to_decoded_red)(colour->R);
- colour->G = (space->to_decoded_green)(colour->G);
- colour->B = (space->to_decoded_blue)(colour->B);
- break;
- default:
- fprintf(stderr, "libcolour: invalid encoding type\n");
- abort();
- }
-}
-
-#undef REGULAR
-#undef INVREGULAR
-
-static int rgb_same_gamma(const libcolour_rgb_t* restrict a, const libcolour_rgb_t* restrict b)
-{
- if (a->encoding_type != b->encoding_type)
- return 0;
- switch (a->encoding_type) {
- case LIBCOLOUR_ENCODING_TYPE_SIMPLE:
- return a->gamma == b->gamma;
- case LIBCOLOUR_ENCODING_TYPE_REGULAR:
- return a->gamma == b->gamma &&
- a->offset == b->offset &&
- a->slope == b->slope &&
- a->transition == b->transition;
- case LIBCOLOUR_ENCODING_TYPE_CUSTOM:
- return a->to_encoded_red == b->to_encoded_red &&
- a->to_encoded_green == b->to_encoded_green &&
- a->to_encoded_blue == b->to_encoded_blue &&
- a->to_decoded_red == b->to_decoded_red &&
- a->to_decoded_green == b->to_decoded_green &&
- a->to_decoded_blue == b->to_decoded_blue;
- default:
- return 1;
- }
-}
-
-static void to_rgb(const libcolour_colour_t* restrict from, libcolour_rgb_t* restrict to)
-{
- int have_gamma = 0, with_gamma = to->with_gamma;
- libcolour_ciexyz_t tmp;
- switch (from->model) {
- case LIBCOLOUR_CIEXYZ:
- ciexyz_to_rgb(&from->ciexyz, to);
- break;
- case LIBCOLOUR_RGB:
- if (!memcmp(from->rgb.M, to->M, sizeof(double[3][3]))) {
- have_gamma = from->rgb.with_gamma;
- to->R = from->rgb.R;
- to->G = from->rgb.G;
- to->B = from->rgb.B;
- if (have_gamma && with_gamma && !rgb_same_gamma(&from->rgb, to))
- rgb_decode(to, &from->rgb), have_gamma = 0;
- break;
- }
- /* fall through */
- default:
- tmp.model = LIBCOLOUR_CIEXYZ;
- to_ciexyz(from, &tmp);
- ciexyz_to_rgb(&tmp, to);
- break;
- }
-
- if (have_gamma != with_gamma) {
- if (with_gamma) {
- rgb_encode(to, to);
- } else {
- rgb_decode(to, &from->rgb);
- }
- }
-}
-
-
-static void ciexyz_to_srgb(const libcolour_ciexyz_t* restrict from, libcolour_srgb_t* restrict to)
-{
- double X = from->X, Y = from->Y, Z = from->Z;
-#define MULTIPLY(CX, CY, CZ) ((CX) * X + (CY) * Y + (CZ) * Z)
- to->R = MULTIPLY(3.240446254647737500675930277794, -1.537134761820080575134284117667, -0.498530193022728718155178739835);
- to->G = MULTIPLY(-0.969266606244679751469561779231, 1.876011959788370209167851498933, 0.041556042214430065351304932619);
- to->B = MULTIPLY(0.055643503564352832235773149705, -0.204026179735960239147729566866, 1.057226567722703292062647051353);
-#undef MULTIPLY
-}
-
-static inline double srgb_encode(double t)
-{
- double sign = 1;
- if (t < 0) {
- t = -t;
- sign = -1;
- }
- t = t <= 0.0031306684425217108 ? 12.92 * t : 1.055 * pow(t, 1 / 2.4) - 0.055;
- return t * sign;
-}
-
-static inline double srgb_decode(double t)
-{
- double sign = 1;
- if (t < 0) {
- t = -t;
- sign = -1;
- }
- t = t <= 0.0031306684425217108 * 12.92 ? t / 12.92 : pow((t + 0.055) / 1.055, 2.4);
- return t * sign;
-}
-
-static void srgb_to_srgb(const libcolour_srgb_t* restrict from, libcolour_srgb_t* restrict to)
-{
- if (from->with_gamma == to->with_gamma) {
- *to = *from;
- } else if (to->with_gamma) {
- to->R = srgb_encode(from->R);
- to->G = srgb_encode(from->G);
- to->B = srgb_encode(from->B);
- } else {
- to->R = srgb_decode(from->R);
- to->G = srgb_decode(from->G);
- to->B = srgb_decode(from->B);
- }
-}
-
-static void yiq_to_srgb(const libcolour_yiq_t* restrict from, libcolour_srgb_t* restrict to)
-{
- double Y = from->Y, I = from->I, Q = from->Q;
- to->R = Y + I * 0.95629483232089407263032398986979387700557708740234 + Q * 0.62102512544472865396727456754888407886028289794922;
- to->G = Y - I * 0.27212147408397735492968649850809015333652496337891 - Q * 0.64738095351761570928061928498209454119205474853516;
- to->B = Y - I * 1.10698990856712820018969978264067322015762329101562 + Q * 1.70461497549882934343656870623817667365074157714844;
- /* ⎛1 1000 cos 33° / 877 1000 sin 33° / 877 ⎞
- ⎜1 9500 sin 33° / 24067 - 299000 * cos 33° / 514799 -9500 cos 33° / 24067 - 299000 * sin 33° / 514799⎟
- ⎝1 -250 sin 33° / 123 250 cos 33° / 123 ⎠
- */
-}
-
-static void ydbdr_to_srgb(const libcolour_ydbdr_t* restrict from, libcolour_srgb_t* restrict to)
-{
- double Y = from->Y, Db = from->Db, Dr = from->Dr;
- to->R = Y + Db * 0.000092303716148 - Dr * 0.525912630661865;
- to->G = Y - Db * 0.129132898890509 + Dr * 0.267899328207599;
- to->B = Y + Db * 0.664679059978955 - Dr * 0.000079202543533;
-}
-
-static void ypbpr_to_srgb(const libcolour_ypbpr_t* restrict from, libcolour_srgb_t* restrict to)
-{
- double Y = from->Y, Pb = from->Pb, Pr = from->Pr;
- to->R = Pr + Y;
- to->B = Pb + Y;
- to->G = (Y - to->R * 0.2126 - to->B * 0.0722) / 0.7152;
-}
-
-static void yuv_to_srgb(const libcolour_yuv_t* restrict from, libcolour_srgb_t* restrict to)
-{
- double Y = from->Y, U = from->U, V = from->V;
- to->R = Y + U * 0.00028328010485821202317155420580263580632163211703 + V * 1.14070449590558520291949662350816652178764343261719;
- to->G = Y - U * 0.39630886669497211727275498560629785060882568359375 - V * 0.58107364288228224857846271333983168005943298339844;
- to->B = Y + U * 2.03990003507541306504435851820744574069976806640625 + V * 0.00017179031692307700847528739718228507626918144524;
-}
-
-static void ycgco_to_srgb(const libcolour_ycgco_t* restrict from, libcolour_srgb_t* restrict to)
-{
- double Y = from->Y, Cg = from->Cg, Co = from->Co;
- to->R = Y - Cg + Co;
- to->G = Y + Cg;
- to->B = Y - Cg - Co;
-}
-
-static void other_to_srgb(const libcolour_colour_t* restrict from, libcolour_srgb_t* restrict to)
-{
- libcolour_ciexyz_t tmp;
- tmp.model = LIBCOLOUR_CIEXYZ;
- to_ciexyz(from, &tmp);
- ciexyz_to_srgb(&tmp, to);
-}
-
-static void to_srgb(const libcolour_colour_t* restrict from, libcolour_srgb_t* restrict to)
-{
- libcolour_srgb_t tmp;
- switch (from->model) {
- case LIBCOLOUR_CIEXYZ:
- ciexyz_to_srgb(&from->ciexyz, to);
- break;
- case LIBCOLOUR_SRGB:
- srgb_to_srgb(&from->srgb, to);
- return;
- case LIBCOLOUR_YIQ:
- yiq_to_srgb(&from->yiq, to);
- break;
- case LIBCOLOUR_YDBDR:
- ydbdr_to_srgb(&from->ydbdr, to);
- break;
- case LIBCOLOUR_YPBPR:
- ypbpr_to_srgb(&from->ypbpr, to);
- break;
- case LIBCOLOUR_YUV:
- yuv_to_srgb(&from->yuv, to);
- break;
- case LIBCOLOUR_YCGCO:
- ycgco_to_srgb(&from->ycgco, to);
- break;
- default:
- other_to_srgb(from, to);
- break;
- }
- if (to->with_gamma) {
- tmp = *to;
- tmp.with_gamma = 0;
- srgb_to_srgb(&tmp, to);
- }
-}
-
-
-static void ciexyz_to_ciexyy(const libcolour_ciexyz_t* restrict from, libcolour_ciexyy_t* restrict to)
-{
- double X = from->X, Y = from->Y, Z = from->Z;
- double s = X + Y + Z;
- to->x = X / s;
- to->y = Y / s;
- to->Y = Y;
- if (WASDIV0(to->x) || WASDIV0(to->y))
- to->x = to->y = 0;
-}
-
-static void other_to_ciexyy(const libcolour_colour_t* restrict from, libcolour_ciexyy_t* restrict to)
-{
- libcolour_ciexyz_t tmp;
- tmp.model = LIBCOLOUR_CIEXYZ;
- to_ciexyz(from, &tmp);
- ciexyz_to_ciexyy(&tmp, to);
-}
-
-static void srgb_to_ciexyy(const libcolour_srgb_t* restrict from, libcolour_ciexyy_t* restrict to)
-{
- libcolour_srgb_t tmp;
- tmp.model = LIBCOLOUR_SRGB;
- if (from->with_gamma) {
- tmp.with_gamma = 0;
- to_srgb((const libcolour_colour_t*)from, &tmp);
- } else {
- tmp = *from;
- }
- if (tmp.R == 0 && tmp.G == 0 && tmp.B == 0) {
- to->x = 0.31272660439158;
- to->y = 0.32902315240275;
- to->Y = 0;
- } else {
- other_to_ciexyy((const libcolour_colour_t*)&tmp, to);
- }
-}
-
-static void to_ciexyy(const libcolour_colour_t* restrict from, libcolour_ciexyy_t* restrict to)
-{
- switch (from->model) {
- case LIBCOLOUR_CIEXYY:
- *to = from->ciexyy;
- return;
- case LIBCOLOUR_CIEXYZ:
- ciexyz_to_ciexyy(&from->ciexyz, to);
- return;
- case LIBCOLOUR_SRGB:
- srgb_to_ciexyy(&from->srgb, to);
- return;
- default:
- other_to_ciexyy(from, to);
- return;
- }
-}
-
-
-static void rgb_to_ciexyz(const libcolour_rgb_t* restrict from, libcolour_ciexyz_t* restrict to)
-{
- libcolour_rgb_t tmp;
- double R, G, B;
- if (from->with_gamma) {
- tmp = *from;
- tmp.with_gamma = 0;
- to_rgb((const libcolour_colour_t*)from, &tmp);
- R = tmp.R, G = tmp.G, B = tmp.B;
- } else {
- R = from->R, G = from->G, B = from->B;
- }
- to->X = from->M[0][0] * R + from->M[0][1] * G + from->M[0][2] * B;
- to->Y = from->M[1][0] * R + from->M[1][1] * G + from->M[1][2] * B;
- to->Z = from->M[2][0] * R + from->M[2][1] * G + from->M[2][2] * B;
-}
-
-static void srgb_to_ciexyz(const libcolour_srgb_t* restrict from, libcolour_ciexyz_t* restrict to)
-{
- libcolour_srgb_t tmp;
- double R, G, B;
- if (from->with_gamma) {
- tmp.model = LIBCOLOUR_SRGB;
- tmp.with_gamma = 0;
- to_srgb((const libcolour_colour_t*)from, &tmp);
- R = tmp.R, G = tmp.G, B = tmp.B;
- } else {
- R = from->R, G = from->G, B = from->B;
- }
-#define MULTIPLIY(CR, CG, CB) ((CR) * R + (CG) * G + (CB) * B)
- to->X = MULTIPLIY(0.412457445582367576708548995157, 0.357575865245515878143578447634, 0.180437247826399665973085006954);
- to->Y = MULTIPLIY(0.212673370378408277403536885686, 0.715151730491031756287156895269, 0.072174899130559869164791564344);
- to->Z = MULTIPLIY(0.019333942761673460208893260415, 0.119191955081838593666354597644, 0.950302838552371742508739771438);
-#undef MULTIPLIY
-}
-
-static void ciexyy_to_ciexyz(const libcolour_ciexyy_t* restrict from, libcolour_ciexyz_t* restrict to)
-{
- double x = from->x, y = from->y, Y = from->Y;
- double Yy = Y / y;
- if (WASDIV0(Yy)) {
- to->X = to->Y = to->Z = Y;
- } else {
- to->X = x * Yy;
- to->Y = Y;
- to->Z = (1 - x - y) * Yy;
- }
-}
-
-static inline double cielab_finv(double t)
-{
- return (t > 6. / 29.) ? t * t * t : (t - 4. / 29.) * 108 / 841;
-}
-
-static void cielab_to_ciexyz(const libcolour_cielab_t* restrict from, libcolour_ciexyz_t* restrict to)
-{
- double L = from->L, a = from->a, b = from->b;
- to->Y = (L + 16) / 116;
- to->X = to->Y + a / 500;
- to->Z = to->Y - b / 200;
- to->X = cielab_finv(to->X) * 0.95047;
- to->Y = cielab_finv(to->Y);
- to->Z = cielab_finv(to->Z) * 1.08883;
-}
-
-static void cieluv_to_ciexyz(const libcolour_cieluv_t* restrict from, libcolour_ciexyz_t* restrict to)
-{
- double X = from->white.X, Y = from->white.Y, L = from->L, L13 = from->L * 13;
- double t = X + 15 * Y + 3 * from->white.Z;
- double u = from->u / L13 + 4 * X / t;
- double v = from->v / L13 + 9 * Y / t;
- if (L <= 8) {
- Y *= L * 27 / 24389;
- } else {
- L = (L + 16) / 116;
- Y *= L * L * L;
- }
- to->X = 2.25 * Y * u / v;
- to->Y = Y;
- to->Z = Y * (3 / v - 0.75 * u / v - 5);
-}
-
-static void cielchuv_to_ciexyz(const libcolour_cielchuv_t* restrict from, libcolour_ciexyz_t* restrict to)
-{
- libcolour_cieluv_t tmp;
- tmp.model = LIBCOLOUR_CIELUV;
- tmp.white = from->white;
- to_cieluv((const libcolour_colour_t*)from, &tmp);
- cieluv_to_ciexyz(&tmp, to);
-}
-
-static void yiq_to_ciexyz(const libcolour_yiq_t* restrict from, libcolour_ciexyz_t* restrict to)
-{
-#define MULTIPLIY(CY, CI, CQ) ((CY) * from->Y + (CI) * from->I + (CQ) * from->Q)
- to->X = MULTIPLIY(0.95047055865428309306963683411595411598682403564453, 0.09738463974178063198294807989441324025392532348633, 0.33223466706854809515903070860076695680618286132812);
- to->Y = MULTIPLIY(0.99999999999999988897769753748434595763683319091797, -0.07112658301916767455974621725545148365199565887451, -0.20786968876398304040264974901219829916954040527344);
- to->Z = MULTIPLIY(1.08882873639588373393394249433185905218124389648438, -1.06592139332461721679123911599162966012954711914062, 1.55474471255181900808395312196807935833930969238281);
-#undef MULTIPLIY
-}
-
-static void ydbdr_to_ciexyz(const libcolour_ydbdr_t* restrict from, libcolour_ciexyz_t* restrict to)
-{
-#define MULTIPLIY(CY, CDB, CDR) ((CY) * from->Y + (CDB) * from->Db + (CDR) * from->Dr)
- to->X = MULTIPLIY(0.95047055865428309306963683411595411598682403564453, 0.07379612357298576119646327242662664502859115600586, -0.12113653724874726136384595065464964136481285095215);
- to->Y = MULTIPLIY(0.99999999999999988897769753748434595763683319091797, -0.04435684145428285540813106990754022262990474700928, 0.07973534004202506575431641522300196811556816101074);
- to->Z = MULTIPLIY(1.08882873639588373393394249433185905218124389648438, 0.61625657933494271123464613992837257683277130126953, 0.02168821359337728266192257819966471288353204727173);
-#undef MULTIPLIY
-}
-
-static void yuv_to_ciexyz(const libcolour_yuv_t* restrict from, libcolour_ciexyz_t* restrict to)
-{
-#define MULTIPLIY(CY, CU, CV) ((CY) * from->Y + (CU) * from->U + (CV) * from->V)
- to->X = MULTIPLIY(0.95047055865428309306963683411595411598682403564453, 0.22648030324549334180161963558930438011884689331055, 0.26274514929253273143316960158699657768011093139648);
- to->Y = MULTIPLIY(0.99999999999999988897769753748434595763683319091797, -0.13613114642319409930415474718756740912795066833496, -0.17294595255115238763288232348713790997862815856934);
- to->Z = MULTIPLIY(1.08882873639588373393394249433185905218124389648438, 1.89129144197893928058817891724174842238426208496094, -0.04704173528403532422714761196402832865715026855469);
-#undef MULTIPLIY
-}
-
-static void ypbpr_to_ciexyz(const libcolour_ypbpr_t* restrict from, libcolour_ciexyz_t* restrict to)
-{
-#define MULTIPLIY(CY, CPB, CPR) ((CY) * from->Y + (CPB) * from->Pb + (CPR) * from->Pr)
- to->X = MULTIPLIY(0.95047055865428298204733437160030007362365722656250, 0.14433968424876231217979238863335922360420227050781, 0.30616461986760712399302519770571961998939514160156);
- to->Y = MULTIPLIY(0.99999999999999977795539507496869191527366638183594, -0.00002022802471486617736928792510298080742359161377, 0.00008771894888734421691367515450110659003257751465);
- to->Z = MULTIPLIY(1.08882873639588373393394249433185905218124389648438, 0.93827031735982591165168287261622026562690734863281, -0.01609699914324668607035206946420657914131879806519);
-#undef MULTIPLIY
-}
-
-static void ycgco_to_ciexyz(const libcolour_ycgco_t* restrict from, libcolour_ciexyz_t* restrict to)
-{
-#define MULTIPLIY(CY, CCG, CCO) ((CY) * from->Y + (CCG) * from->Cg + (CCO) * from->Co)
- to->X = MULTIPLIY(0.95047055865428309306963683411595411598682403564453, -0.23531882816325136453805555447615915909409523010254, 0.23202019775596791073546398820326430723071098327637);
- to->Y = MULTIPLIY(0.99999999999999988897769753748434595763683319091797, 0.43030346098206362359661625305307097733020782470703, 0.14049847124784842211653312915586866438388824462891);
- to->Z = MULTIPLIY(1.08882873639588373393394249433185905218124389648438, -0.85044482623220662986796014592982828617095947265625, -0.93096889579069830311652822274481877684593200683594);
-#undef MULTIPLIY
-}
-
-static void cie1960ucs_to_ciexyz(const libcolour_cie1960ucs_t* restrict from, libcolour_ciexyz_t* restrict to)
-{
- double u = from->u, v = from->v, Y = from->Y;
- to->X = 1.5 * Y * u / v;
- to->Y = Y;
- to->Z = (4 * Y - Y * u - 10 * Y * v) / (2 * v);
-}
-
-static void cieuvw_to_ciexyz(const libcolour_cieuvw_t* restrict from, libcolour_ciexyz_t* restrict to)
-{
- libcolour_cie1960ucs_t tmp;
- tmp.model = LIBCOLOUR_CIE1960UCS;
- to_cie1960ucs((const libcolour_colour_t*)from, &tmp);
- cie1960ucs_to_ciexyz(&tmp, to);
-}
-
-static void other_to_ciexyz(const libcolour_colour_t* restrict from, libcolour_ciexyz_t* restrict to)
-{
- libcolour_srgb_t tmp;
- tmp.model = LIBCOLOUR_SRGB;
- tmp.with_gamma = 0;
- to_srgb(from, &tmp);
- srgb_to_ciexyz(&tmp, to);
-}
-
-static void to_ciexyz(const libcolour_colour_t* restrict from, libcolour_ciexyz_t* restrict to)
-{
- switch (from->model) {
- case LIBCOLOUR_RGB:
- rgb_to_ciexyz(&from->rgb, to);
- break;
- case LIBCOLOUR_SRGB:
- srgb_to_ciexyz(&from->srgb, to);
- break;
- case LIBCOLOUR_CIEXYY:
- ciexyy_to_ciexyz(&from->ciexyy, to);
- break;
- case LIBCOLOUR_CIEXYZ:
- *to = from->ciexyz;
- break;
- case LIBCOLOUR_CIELAB:
- cielab_to_ciexyz(&from->cielab, to);
- break;
- case LIBCOLOUR_CIELUV:
- cieluv_to_ciexyz(&from->cieluv, to);
- break;
- case LIBCOLOUR_CIELCHUV:
- cielchuv_to_ciexyz(&from->cielchuv, to);
- break;
- case LIBCOLOUR_YIQ:
- yiq_to_ciexyz(&from->yiq, to);
- break;
- case LIBCOLOUR_YDBDR:
- ydbdr_to_ciexyz(&from->ydbdr, to);
- break;
- case LIBCOLOUR_YUV:
- yuv_to_ciexyz(&from->yuv, to);
- break;
- case LIBCOLOUR_YPBPR:
- ypbpr_to_ciexyz(&from->ypbpr, to);
- break;
- case LIBCOLOUR_YCGCO:
- ycgco_to_ciexyz(&from->ycgco, to);
- break;
- case LIBCOLOUR_CIE1960UCS:
- cie1960ucs_to_ciexyz(&from->cie1960ucs, to);
- break;
- case LIBCOLOUR_CIEUVW:
- cieuvw_to_ciexyz(&from->cieuvw, to);
- break;
- default:
- other_to_ciexyz(from, to);
- break;
- }
-}
-
-
-static inline double cielab_f(double t)
-{
- return (t > 216. / 24389.) ? cbrt(t) : t * 841. / 108. + 4. / 29.;
-}
-
-static void ciexyz_to_cielab(const libcolour_ciexyz_t* restrict from, libcolour_cielab_t* restrict to)
-{
- double X = from->X, Y = from->Y, Z = from->Z;
- X /= 0.95047;
- Z /= 1.08883;
- Y = cielab_f(Y);
- to->L = 116 * Y - 16;
- to->a = 500 * (cielab_f(X) - Y);
- to->b = 200 * (Y - cielab_f(Z));
-}
-
-static void other_to_cielab(const libcolour_colour_t* restrict from, libcolour_cielab_t* restrict to)
-{
- libcolour_ciexyz_t tmp;
- tmp.model = LIBCOLOUR_CIEXYZ;
- to_ciexyz(from, &tmp);
- ciexyz_to_cielab(&tmp, to);
-}
-
-static void to_cielab(const libcolour_colour_t* restrict from, libcolour_cielab_t* restrict to)
-{
- switch (from->model) {
- case LIBCOLOUR_CIEXYZ:
- ciexyz_to_cielab(&from->ciexyz, to);
- return;
- case LIBCOLOUR_CIELAB:
- *to = from->cielab;
- return;
- default:
- other_to_cielab(from, to);
- return;
- }
-}
-
-
-static void ciexyz_to_cieluv(const libcolour_ciexyz_t* restrict from, libcolour_cieluv_t* restrict to)
-{
- double t, u, v, y, y2;
- t = to->white.X + 15 * to->white.Y + 3 * to->white.Z;
- u = 4 * to->white.X / t;
- v = 9 * to->white.Y / t;
- t = from->X + 15 * from->Y + 3 * from->Z;
- u = 4 * from->X / t - u;
- v = 9 * from->Y / t - v;
- y = from->Y / to->white.Y;
- y2 = y * 24389;
- y = y2 <= 216 ? y2 / 27 : cbrt(y) * 116 - 16;
- to->L = y;
- y *= 13;
- to->u = u * y;
- to->v = v * y;
-}
-
-static void cielchuv_to_cieluv(const libcolour_cielchuv_t* restrict from, libcolour_cieluv_t* restrict to)
-{
- libcolour_ciexyz_t tmp;
- libcolour_cielchuv_t tmp2;
- double L, C, h;
- if (to->white.X != from->white.X || to->white.Y != from->white.Y || to->white.Z != from->white.Z) {
- tmp.model = LIBCOLOUR_CIEXYZ;
- tmp2.model = LIBCOLOUR_CIELCHUV;
- tmp2.white = to->white;
- tmp2.one_revolution = PI2;
- to_ciexyz((const libcolour_colour_t*)from, &tmp);
- to_cielchuv((const libcolour_colour_t*)&tmp, &tmp2);
- L = tmp2.L, C = tmp2.C, h = tmp2.h;
- } else {
- L = from->L, C = from->C, h = from->h * PI2 / from->one_revolution;
- }
- to->L = L;
- to->u = C * cos(h);
- to->v = C * sin(h);
-}
-
-static void other_to_cieluv(const libcolour_colour_t* restrict from, libcolour_cieluv_t* restrict to)
-{
- libcolour_ciexyz_t tmp;
- tmp.model = LIBCOLOUR_CIEXYZ;
- to_ciexyz(from, &tmp);
- ciexyz_to_cieluv(&tmp, to);
-}
-
-static void to_cieluv(const libcolour_colour_t* restrict from, libcolour_cieluv_t* restrict to)
-{
- switch (from->model) {
- case LIBCOLOUR_CIEXYZ:
- ciexyz_to_cieluv(&from->ciexyz, to);
- break;
- case LIBCOLOUR_CIELCHUV:
- cielchuv_to_cieluv(&from->cielchuv, to);
- break;
- case LIBCOLOUR_CIELUV:
- if (to->white.X == from->cieluv.white.X &&
- to->white.Y == from->cieluv.white.Y &&
- to->white.Z == from->cieluv.white.Z) {
- *to = from->cieluv;
- break;
- }
- /* fall through */
- default:
- other_to_cieluv(from, to);
- break;
- }
-}
-
-
-static void cieluv_to_cielchuv(const libcolour_cieluv_t* restrict from, libcolour_cielchuv_t* restrict to)
-{
- libcolour_cieluv_t tmp;
- double L, u, v;
- if (to->white.X != from->white.X || to->white.Y != from->white.Y || to->white.Z != from->white.Z) {
- tmp.model = LIBCOLOUR_CIELUV;
- tmp.white = to->white;
- to_cieluv((const libcolour_colour_t*)from, &tmp);
- L = tmp.L, u = tmp.u, v = tmp.v;
- } else {
- L = from->L, u = from->u, v = from->v;
- }
- to->L = L;
- to->C = sqrt(u * u + v * v);
- to->h = atan2(v, u) / PI2 * to->one_revolution;
- if (!isnan(to->h) && !isinf(to->h) && (to->h < 0))
- to->h += to->one_revolution;
-}
-
-static void other_to_cielchuv(const libcolour_colour_t* restrict from, libcolour_cielchuv_t* restrict to)
-{
- libcolour_cieluv_t tmp;
- tmp.model = LIBCOLOUR_CIELUV;
- tmp.white = to->white;
- to_cieluv(from, &tmp);
- cieluv_to_cielchuv(&tmp, to);
-}
-
-static void to_cielchuv(const libcolour_colour_t* restrict from, libcolour_cielchuv_t* restrict to)
-{
- double one_revolution;
- switch (from->model) {
- case LIBCOLOUR_CIELUV:
- cieluv_to_cielchuv(&from->cieluv, to);
- break;
- case LIBCOLOUR_CIELCHUV:
- if (to->white.X == from->cielchuv.white.X &&
- to->white.Y == from->cielchuv.white.Y &&
- to->white.Z == from->cielchuv.white.Z) {
- if (to->one_revolution == from->cielchuv.one_revolution) {
- *to = from->cielchuv;
- } else {
- one_revolution = to->one_revolution;
- *to = from->cielchuv;
- to->one_revolution = one_revolution;
- to->h = to->h / from->cielchuv.one_revolution * one_revolution;
- }
- break;
- }
- /* fall through */
- default:
- other_to_cielchuv(from, to);
- break;
- }
-}
-
-
-static void to_yiq(const libcolour_colour_t* restrict from, libcolour_yiq_t* restrict to)
-{
- double x, y, z;
- libcolour_colour_t tmp = *from;
- switch (from->model) {
- case LIBCOLOUR_YIQ:
- *to = from->yiq;
- break;
- case LIBCOLOUR_SRGB:
- if (tmp.srgb.with_gamma) {
- tmp.srgb.with_gamma = 0;
- to_srgb(from, &tmp.srgb);
- }
- x = tmp.srgb.R;
- y = tmp.srgb.G;
- z = tmp.srgb.B;
- to->Y = x * 0.299 + y * 0.587 + z * 0.114;
- to->I = x * 0.59571613491277464191853141528554260730743408203125 /* (0.877 cos 33°)(1 - 0.299) - (0.492 sin 33°)(-0.299) */
- - y * 0.27445283783925644716106262421817518770694732666016 /* (0.877 cos 33°)(-0.587) - (0.492 sin 33°)(-0.587) */
- - z * 0.32126329707351808373516632855171337723731994628906; /* (0.877 cos 33°)(-0.114) - (0.492 sin 33°)(1 - 0.114) */
- to->Q = x * 0.21145640212011795888713550084503367543220520019531 /* (0.877 sin 33°)(1 - 0.299) + (0.492 cos 33°)(-0.299) */
- - y * 0.52259104529161115593183239980135113000869750976562 /* (0.877 sin 33°)(-0.587) + (0.492 cos 33°)(-0.587) */
- + z * 0.31113464317149330806699936147197149693965911865234; /* (0.877 sin 33°)(-0.114) + (0.492 cos 33°)(1 - 0.114) */
- break;
- default:
- tmp.model = LIBCOLOUR_CIEXYZ;
- to_ciexyz(from, &tmp.ciexyz);
- /* fall through */
- case LIBCOLOUR_CIEXYZ:
- x = tmp.ciexyz.X;
- y = tmp.ciexyz.Y;
- z = tmp.ciexyz.Z;
-#define MULTIPLIY(CX, CY, CZ) ((CX) * x + (CY) * y + (CZ) * z)
- to->Y = MULTIPLIY(0.40627729168038273499519164033699780702590942382812, 0.61835674212166968910509012857801280915737152099609, -0.00414330221353725880462093300593551248311996459961);
- to->I = MULTIPLIY(2.17852787350219845308174626552499830722808837890625, -1.36502666214454104753883711964590474963188171386719, -0.64803574634025240541745915834326297044754028320312);
- to->Q = MULTIPLIY(1.20905577682138853923277110880007967352867126464844, -1.36890364998339797431015085749095305800437927246094, 0.20180559439597040016778350945969577878713607788086);
-#undef MULTIPLIY
- break;
- }
-}
-
-
-static void to_ydbdr(const libcolour_colour_t* restrict from, libcolour_ydbdr_t* restrict to)
-{
- double x, y, z;
- libcolour_colour_t tmp = *from;
- switch (from->model) {
- case LIBCOLOUR_YDBDR:
- *to = from->ydbdr;
- break;
- case LIBCOLOUR_SRGB:
- if (tmp.srgb.with_gamma) {
- tmp.srgb.with_gamma = 0;
- to_srgb(from, &tmp.srgb);
- }
- x = tmp.srgb.R;
- y = tmp.srgb.G;
- z = tmp.srgb.B;
- to->Y = x * 0.299 + y * 0.587 + z * 0.114;
- to->Db = -x * 0.450 - y * 0.883 + z * 1.333;
- to->Dr = -x * 1.333 + y * 1.116 + z * 0.217;
- break;
- case LIBCOLOUR_YUV:
- to->Y = tmp.yuv.Y;
- to->Db = tmp.yuv.U * 3.069;
- to->Dr = -tmp.yuv.V * 2.169;
- break;
- default:
- tmp.model = LIBCOLOUR_CIEXYZ;
- to_ciexyz(from, &tmp.ciexyz);
- /* fall through */
- case LIBCOLOUR_CIEXYZ:
- x = tmp.ciexyz.X;
- y = tmp.ciexyz.Y;
- z = tmp.ciexyz.Z;
-#define MULTIPLY(CX, CY, CZ) ((CX) * x + (CY) * y + (CZ) * z)
- to->Y = MULTIPLY(0.40627729168038273499519164033699780702590942382812, 0.61835674212166968910509012857801280915737152099609, -0.00414330221353725880462093300593551248311996459961);
- to->Db = MULTIPLY(-0.52816561102614745237815441214479506015777587890625, -1.23677481526212962315014465275453403592109680175781, 1.59692761635924940222253098909277468919754028320312);
- to->Dr = MULTIPLY(-5.38914174974103143966885909321717917919158935546875, 4.09835630362728497999569299281574785709381103515625, 0.94033545560642795013706063400604762136936187744141);
-#undef MULTIPLY
- break;
- }
-}
-
-
-static void to_yuv(const libcolour_colour_t* restrict from, libcolour_yuv_t* restrict to)
-{
- libcolour_colour_t tmp = *from;
- switch (from->model) {
- case LIBCOLOUR_YUV:
- *to = from->yuv;
- break;
- case LIBCOLOUR_YDBDR:
- to->Y = from->ydbdr.Y;
- to->U = from->ydbdr.Db / 3.069;
- to->V = from->ydbdr.Dr / -2.169;
- break;
- case LIBCOLOUR_SRGB:
- if (tmp.srgb.with_gamma) {
- tmp.srgb.with_gamma = 0;
- to_srgb(from, &tmp.srgb);
- }
-#define MULTIPLY(CR, CG, CB) ((CR) * tmp.srgb.R + (CG) * tmp.srgb.G + (CB) * tmp.srgb.B)
- to->Y = MULTIPLY(0.29899999999999998800959133404830936342477798461914, 0.58699999999999996624922005139524117112159729003906, 0.11400000000000000410782519111307919956743717193604);
- to->U = MULTIPLY(-0.14662756598240470062854967636667424812912940979004, -0.28771586836102963635752871596196200698614120483398, 0.43434343434343436474165400795754976570606231689453);
- to->V = MULTIPLY(0.61456892577224520035628074765554629266262054443359, -0.51452282157676354490405401520547457039356231689453, -0.10004610419548178035231700278018251992762088775635);
-#undef MULTIPLY
- break;
- default:
- tmp.model = LIBCOLOUR_CIEXYZ;
- to_ciexyz(from, &tmp.ciexyz);
- /* fall through */
- case LIBCOLOUR_CIEXYZ:
-#define MULTIPLY(CX, CY, CZ) ((CX) * tmp.ciexyz.X + (CY) * tmp.ciexyz.Y + (CZ) * tmp.ciexyz.Z)
- to->Y = MULTIPLY(0.40627729168038273499519164033699780702590942382812, 0.61835674212166968910509012857801280915737152099609, -0.00414330221353725880462093300593551248311996459961);
- to->U = MULTIPLY(-0.17209697328971895746718701047939248383045196533203, -0.40298951295605395239718404809536878019571304321289, 0.52034135430408912093014350830344483256340026855469);
- to->V = MULTIPLY(2.48462044709130047692724474472925066947937011718750, -1.88951420176453876997868519538315013051033020019531, -0.43353409663735725798616726933687459677457809448242);
-#undef MULTIPLY
- break;
- }
-}
-
-
-static void to_ypbpr(const libcolour_colour_t* restrict from, libcolour_ypbpr_t* restrict to)
-{
- libcolour_colour_t tmp = *from;
- switch (from->model) {
- case LIBCOLOUR_YPBPR:
- *to = from->ypbpr;
- break;
- case LIBCOLOUR_SRGB:
- if (tmp.srgb.with_gamma) {
- tmp.srgb.with_gamma = 0;
- to_srgb(from, &tmp.srgb);
- }
- to->Y = tmp.srgb.R * 0.2126 + tmp.srgb.G * 0.7152 + tmp.srgb.B * 0.0722;
- to->Pb = tmp.srgb.B - to->Y;
- to->Pr = tmp.srgb.R - to->Y;
- break;
- default:
- tmp.model = LIBCOLOUR_CIEXYZ;
- to_ciexyz(from, &tmp.ciexyz);
- /* fall through */
- case LIBCOLOUR_CIEXYZ:
-#define MULTIPLY(CX, CY, CZ) ((CX) * tmp.ciexyz.X + (CY) * tmp.ciexyz.Y + (CZ) * tmp.ciexyz.Z)
- to->Y = MULTIPLY(-0.00028314209073960778378920011277841695118695497513, 1.00019821310075673892470149439759552478790283203125, 0.00006512054470741990286342115723527967929840087891);
- to->Pb = MULTIPLY(0.05592664565509243568275365987574332393705844879150, -1.20422439283671711685030913940863683819770812988281, 1.05716144717799576113748116767965257167816162109375);
- to->Pr = MULTIPLY(3.24072939673847715269516811531502753496170043945312, -2.53733297492083753610359053709544241428375244140625, -0.49859531356743613805804216099204495549201965332031);
-#undef MULTIPLY
- break;
- }
-}
-
-
-static void to_ycgco(const libcolour_colour_t* restrict from, libcolour_ycgco_t* restrict to)
-{
- libcolour_colour_t tmp = *from;
- switch (from->model) {
- case LIBCOLOUR_YCGCO:
- *to = from->ycgco;
- break;
- case LIBCOLOUR_SRGB:
- if (tmp.srgb.with_gamma) {
- tmp.srgb.with_gamma = 0;
- to_srgb(from, &tmp.srgb);
- }
- to->Y = tmp.srgb.R / 4 + tmp.srgb.G / 2 + tmp.srgb.B / 4;
- to->Cg = -tmp.srgb.R / 4 + tmp.srgb.G / 2 - tmp.srgb.B / 4;
- to->Co = tmp.srgb.R / 2 - tmp.srgb.B / 2;
- break;
- default:
- tmp.model = LIBCOLOUR_CIEXYZ;
- to_ciexyz(from, &tmp.ciexyz);
- /* fall through */
- case LIBCOLOUR_CIEXYZ:
-#define MULTIPLY(CX, CY, CZ) ((CX) * tmp.ciexyz.X + (CY) * tmp.ciexyz.Y + (CZ) * tmp.ciexyz.Z)
- to->Y = MULTIPLY(0.33938913643068269188063368346774950623512268066406, 0.50271574450517486631895280879689380526542663574219, 0.16045211478220866574417868832824751734733581542969);
- to->Cg = MULTIPLY(-1.30865574267536244335019546269904822111129760742188, 1.37329621528319534284889869013568386435508728027344, -0.11889607256777862120955546743061859160661697387695);
- to->Co = MULTIPLY(1.59240137554169236544510113162687048316001892089844, -0.66655429104206020962664069884340278804302215576172, -0.77787838037271606062006412685150280594825744628906);
-#undef MULTIPLY
- break;
- }
-}
-
-
-static void to_cie1960ucs(const libcolour_colour_t* restrict from, libcolour_cie1960ucs_t* restrict to)
-{
- libcolour_colour_t tmp = *from;
- double u, v, w, y;
- switch (from->model) {
- case LIBCOLOUR_CIE1960UCS:
- *to = from->cie1960ucs;
- return;
- case LIBCOLOUR_CIEUVW:
- u = from->cieuvw.U, v = from->cieuvw.V, w = from->cieuvw.W;
- y = (w + 17) / 25;
- y *= y * y;
- w *= 13;
- to->u = u / w + from->cieuvw.u0;
- to->v = v / w + from->cieuvw.v0;
- to->Y = y;
- return;
- default:
- tmp.model = LIBCOLOUR_CIEXYZ;
- to_ciexyz(from, &tmp.ciexyz);
- /* fall through */
- case LIBCOLOUR_CIEXYZ:
- w = tmp.ciexyz.X + 15 * tmp.ciexyz.Y + 3 * tmp.ciexyz.Z;
- to->u = 4 * tmp.ciexyz.X / w;
- to->v = 6 * tmp.ciexyz.Y / w;
- to->Y = tmp.ciexyz.Y;
- return;
- }
-}
-
-
-static void to_cieuvw(const libcolour_colour_t* restrict from, libcolour_cieuvw_t* restrict to)
-{
- double U, V, W, w;
- libcolour_colour_t tmp = *from;
- switch (from->model) {
- case LIBCOLOUR_CIEUVW:
- U = from->cieuvw.U, V = from->cieuvw.V, W = from->cieuvw.W;
- w = W * 13;
- U += w * (from->cieuvw.u0 - to->u0);
- V += w * (from->cieuvw.v0 - to->v0);
- to->U = U, to->V = V, to->W = W;
- break;
- default:
- tmp.model = LIBCOLOUR_CIE1960UCS;
- to_cie1960ucs(from, &tmp.cie1960ucs);
- /* fall through */
- case LIBCOLOUR_CIE1960UCS:
- U = tmp.cie1960ucs.u, V = tmp.cie1960ucs.v, W = tmp.cie1960ucs.Y;
- W = 25 * cbrt(W) - 17;
- w = W * 13;
- to->U = w * (U - to->u0);
- to->V = w * (V - to->v0);
- to->W = W;
- break;
- }
-}
-
-
-
-int libcolour_convert(const libcolour_colour_t* restrict from, libcolour_colour_t* restrict to)
-{
-#define X(C, T) 1 +
- if (from->model < 0 || from->model > LIBCOLOUR_LIST_MODELS 0) {
-#undef X
- errno = EINVAL;
- return -1;
- }
- switch (to->model) {
- case LIBCOLOUR_RGB:
- to_rgb(from, &to->rgb);
- break;
- case LIBCOLOUR_SRGB:
- to_srgb(from, &to->srgb);
- break;
- case LIBCOLOUR_CIEXYY:
- to_ciexyy(from, &to->ciexyy);
- break;
- case LIBCOLOUR_CIEXYZ:
- to_ciexyz(from, &to->ciexyz);
- break;
- case LIBCOLOUR_CIELAB:
- to_cielab(from, &to->cielab);
- break;
- case LIBCOLOUR_CIELUV:
- to_cieluv(from, &to->cieluv);
- break;
- case LIBCOLOUR_CIELCHUV:
- to_cielchuv(from, &to->cielchuv);
- break;
- case LIBCOLOUR_YIQ:
- to_yiq(from, &to->yiq);
- break;
- case LIBCOLOUR_YDBDR:
- to_ydbdr(from, &to->ydbdr);
- break;
- case LIBCOLOUR_YUV:
- to_yuv(from, &to->yuv);
- break;
- case LIBCOLOUR_YPBPR:
- to_ypbpr(from, &to->ypbpr);
- break;
- case LIBCOLOUR_YCGCO:
- to_ycgco(from, &to->ycgco);
- break;
- case LIBCOLOUR_CIE1960UCS:
- to_cie1960ucs(from, &to->cie1960ucs);
- break;
- case LIBCOLOUR_CIEUVW:
- to_cieuvw(from, &to->cieuvw);
- break;
- default:
- errno = EINVAL;
- return -1;
- }
- return 0;
-}
-
diff --git a/src/libcolour.c b/src/libcolour.c
deleted file mode 100644
index 867e280..0000000
--- a/src/libcolour.c
+++ /dev/null
@@ -1,717 +0,0 @@
-/**
- * Copyright © 2016 Mattias Andrée <maandree@kth.se>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 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/>.
- */
-#include "libcolour.h"
-
-#include <alloca.h>
-#include <errno.h>
-#include <math.h>
-#include <string.h>
-
-
-#define MARSHAL_VERSION 0
-
-
-
-double libcolour_srgb_encode(double t)
-{
- double sign = 1;
- if (t < 0) {
- t = -t;
- sign = -1;
- }
- t = t <= 0.0031306684425217108 ? 12.92 * t : 1.055 * pow(t, 1 / 2.4) - 0.055;
- return t * sign;
-}
-
-double libcolour_srgb_decode(double t)
-{
- double sign = 1;
- if (t < 0) {
- t = -t;
- sign = -1;
- }
- t = t <= 0.0031306684425217108 * 12.92 ? t / 12.92 : pow((t + 0.055) / 1.055, 2.4);
- return t * sign;
-}
-
-
-int libcolour_delta_e(const libcolour_colour_t* a, const libcolour_colour_t* b, double* e)
-{
- libcolour_cielab_t u, v;
- u.model = v.model = LIBCOLOUR_CIELAB;
- if (libcolour_convert(a, (libcolour_colour_t*)&u))
- return -1;
- if (libcolour_convert(b, (libcolour_colour_t*)&v))
- return -1;
- u.L -= v.L, u.L *= u.L;
- u.a -= v.a, u.a *= u.a;
- u.b -= v.b, u.b *= u.b;
- *e = sqrt(u.L + u.a + u.b);
- return 0;
-}
-
-
-#define eliminate(M, n, m) eliminate_(n, m, &(M))
-static int eliminate_(size_t n, size_t m, double (*Mp)[n][m])
-{
-#define M (*Mp)
- size_t r1, r2, c;
- double d;
- double* R1;
- double* R2;
- for (r1 = 0; r1 < n; r1++) {
- R1 = M[r1];
- if (R1[r1] == 0) {
- for (r2 = r1 + 1; r2 < n; r2++)
- if (M[r2][r1] != 0)
- break;
- if (r2 == n) {
- errno = EDOM;
- return -1;
- }
- R2 = M[r2];
- for (c = 0; c < m; c++)
- d = R1[c], R1[c] = R2[c], R2[c] = d;
- }
- d = R1[r1];
- for (c = 0; c < m; c++)
- R1[c] /= d;
- for (r2 = r1 + 1; r2 < n; r2++) {
- R2 = M[r2];
- d = R2[r1];
- for (c = 0; c < m; c++)
- R2[c] -= R1[c] * d;
- }
- }
- for (r1 = n; --r1;) {
- R1 = M[r1];
- for (r2 = r1; r2--;) {
- R2 = M[r2];
- d = R2[r1];
- for (c = 0; c < m; c++)
- R2[c] -= R1[c] * d;
- }
- }
- return 0;
-#undef M
-}
-
-
-int libcolour_proper(libcolour_colour_t* colour)
-{
- libcolour_colour_t r, g, b, w;
- double m[3][4];
- switch (colour->model) {
- case LIBCOLOUR_CIELUV:
- colour->cieluv.white.model = LIBCOLOUR_CIEXYZ;
- break;
- case LIBCOLOUR_CIELCHUV:
- colour->cielchuv.white.model = LIBCOLOUR_CIEXYZ;
- if (colour->cielchuv.one_revolution == 0.)
- colour->cielchuv.one_revolution = 360.;
- break;
- case LIBCOLOUR_RGB:
- colour->rgb.red.model = LIBCOLOUR_CIEXYY;
- colour->rgb.green.model = LIBCOLOUR_CIEXYY;
- colour->rgb.blue.model = LIBCOLOUR_CIEXYY;
- colour->rgb.white.model = LIBCOLOUR_CIEXYY;
- colour->rgb.red.Y = 1;
- colour->rgb.green.Y = 1;
- colour->rgb.blue.Y = 1;
- r.model = g.model = b.model = w.model = LIBCOLOUR_CIEXYZ;
- libcolour_convert((const libcolour_colour_t*)&colour->rgb.red, &r);
- libcolour_convert((const libcolour_colour_t*)&colour->rgb.green, &g);
- libcolour_convert((const libcolour_colour_t*)&colour->rgb.blue, &b);
- libcolour_convert((const libcolour_colour_t*)&colour->rgb.white, &w);
- m[0][0] = r.ciexyz.X, m[0][1] = g.ciexyz.X, m[0][2] = b.ciexyz.X, m[0][3] = w.ciexyz.X;
- m[1][0] = r.ciexyz.Y, m[1][1] = g.ciexyz.Y, m[1][2] = b.ciexyz.Y, m[1][3] = w.ciexyz.Y;
- m[2][0] = r.ciexyz.Z, m[2][1] = g.ciexyz.Z, m[2][2] = b.ciexyz.Z, m[2][3] = w.ciexyz.Z;
- if (eliminate(m, 3, 4))
- return -1;
- colour->rgb.red.Y = m[0][3];
- colour->rgb.green.Y = m[1][3];
- colour->rgb.blue.Y = m[2][3];
- break;
- default:
- break;
- }
- return 0;
-}
-
-
-static int get_primaries(libcolour_rgb_t* cs)
-{
- libcolour_colour_t r, g, b, w;
- double Sr, Sg, Sb;
- double M[3][6];
-
- r.model = g.model = b.model = w.model = LIBCOLOUR_CIEXYZ;
- r.ciexyz.Y = 1;
- g.ciexyz.Y = 1;
- b.ciexyz.Y = 1;
-
- Sr = cs->M[1][0] * cs->white_r;
- Sg = cs->M[1][1] * cs->white_g;
- Sb = cs->M[1][2] * cs->white_b;
-
- r.ciexyz.X = cs->M[0][0] / Sr, r.ciexyz.Z = cs->M[2][0] / Sr;
- g.ciexyz.X = cs->M[0][1] / Sg, g.ciexyz.Z = cs->M[2][1] / Sg;
- b.ciexyz.X = cs->M[0][2] / Sb, b.ciexyz.Z = cs->M[2][2] / Sb;
-
- M[0][0] = r.ciexyz.X, M[0][1] = g.ciexyz.X, M[0][2] = b.ciexyz.X, M[0][3] = 1, M[0][4] = 0, M[0][5] = 0;
- M[1][0] = r.ciexyz.Y, M[1][1] = g.ciexyz.Y, M[1][2] = b.ciexyz.Y, M[1][3] = 0, M[1][4] = 1, M[1][5] = 0;
- M[2][0] = r.ciexyz.Z, M[2][1] = g.ciexyz.Z, M[2][2] = b.ciexyz.Z, M[2][3] = 0, M[2][4] = 0, M[2][5] = 1;
-
- if (eliminate(M, 3, 6))
- return -1;
-
- memcpy(M[0], M[0] + 3, 3 * sizeof(double)), M[0][3] = Sr;
- memcpy(M[1], M[1] + 3, 3 * sizeof(double)), M[1][3] = Sg;
- memcpy(M[2], M[2] + 3, 3 * sizeof(double)), M[2][3] = Sb;
-
- if (eliminate(M, 3, 4))
- return -1;
-
- w.ciexyz.X = M[0][3];
- w.ciexyz.Y = M[1][3];
- w.ciexyz.Z = M[2][3];
-
- cs->red.model = LIBCOLOUR_CIEXYY;
- cs->green.model = LIBCOLOUR_CIEXYY;
- cs->blue.model = LIBCOLOUR_CIEXYY;
- cs->white.model = LIBCOLOUR_CIEXYY;
-
- libcolour_convert(&r, (libcolour_colour_t*)&cs->red);
- libcolour_convert(&g, (libcolour_colour_t*)&cs->green);
- libcolour_convert(&b, (libcolour_colour_t*)&cs->blue);
- libcolour_convert(&w, (libcolour_colour_t*)&cs->white);
-
- return 0;
-}
-
-
-static int get_matrices(libcolour_rgb_t* cs)
-{
- libcolour_colour_t r, g, b, w;
- double M[3][6];
- double Sr, Sg, Sb;
-
- r.model = g.model = b.model = LIBCOLOUR_CIEXYZ;
- w.model = LIBCOLOUR_CIEXYY;
- libcolour_convert((const libcolour_colour_t*)&cs->red, &w), w.ciexyy.Y = 1, libcolour_convert(&w, &r);
- libcolour_convert((const libcolour_colour_t*)&cs->green, &w), w.ciexyy.Y = 1, libcolour_convert(&w, &g);
- libcolour_convert((const libcolour_colour_t*)&cs->blue, &w), w.ciexyy.Y = 1, libcolour_convert(&w, &b);
- w.model = LIBCOLOUR_CIEXYZ;
- libcolour_convert((const libcolour_colour_t*)&cs->white, &w);
-
- M[0][0] = r.ciexyz.X, M[0][1] = g.ciexyz.X, M[0][2] = b.ciexyz.X, M[0][3] = 1, M[0][4] = 0, M[0][5] = 0;
- M[1][0] = r.ciexyz.Y, M[1][1] = g.ciexyz.Y, M[1][2] = b.ciexyz.Y, M[1][3] = 0, M[1][4] = 1, M[1][5] = 0;
- M[2][0] = r.ciexyz.Z, M[2][1] = g.ciexyz.Z, M[2][2] = b.ciexyz.Z, M[2][3] = 0, M[2][4] = 0, M[2][5] = 1;
-
- if (eliminate(M, 3, 6))
- return -1;
-
- Sr = M[0][3] * w.ciexyz.X + M[0][4] * w.ciexyz.Y + M[0][5] * w.ciexyz.Z;
- Sg = M[1][3] * w.ciexyz.X + M[1][4] * w.ciexyz.Y + M[1][5] * w.ciexyz.Z;
- Sb = M[2][3] * w.ciexyz.X + M[2][4] * w.ciexyz.Y + M[2][5] * w.ciexyz.Z;
-
- Sr /= cs->white_r;
- Sg /= cs->white_g;
- Sb /= cs->white_b;
-
- cs->M[0][0] = Sr * r.ciexyz.X, cs->M[0][1] = Sg * g.ciexyz.X, cs->M[0][2] = Sb * b.ciexyz.X;
- cs->M[1][0] = Sr * r.ciexyz.Y, cs->M[1][1] = Sg * g.ciexyz.Y, cs->M[1][2] = Sb * b.ciexyz.Y;
- cs->M[2][0] = Sr * r.ciexyz.Z, cs->M[2][1] = Sg * g.ciexyz.Z, cs->M[2][2] = Sb * b.ciexyz.Z;
-
- memcpy(M[0], cs->M[0], 3 * sizeof(double)), M[0][3] = 1, M[0][4] = 0, M[0][5] = 0;
- memcpy(M[1], cs->M[1], 3 * sizeof(double)), M[1][3] = 0, M[1][4] = 1, M[1][5] = 0;
- memcpy(M[2], cs->M[2], 3 * sizeof(double)), M[2][3] = 0, M[2][4] = 0, M[2][5] = 1;
-
- if (eliminate(M, 3, 6))
- return -1;
-
- memcpy(cs->Minv[0], M[0] + 3, 3 * sizeof(double));
- memcpy(cs->Minv[1], M[1] + 3, 3 * sizeof(double));
- memcpy(cs->Minv[2], M[2] + 3, 3 * sizeof(double));
-
- return 0;
-}
-
-
-#define invert(Minv, M, n) invert_(n, &(Minv), &(M))
-static int invert_(size_t n, double (*Minvp)[n][n], double (*Mp)[n][n])
-{
-#define Minv (*Minvp)
-#define M (*Mp)
-#define J (*Jp)
- double J[n][2 * n] = alloca(sizeof(double[n][2 * n]));
- size_t i;
- for (i = 0; i < n; i++) {
- memcpy(J[i], M[i], n * sizeof(double));
- memset(J[i] + n, 0, n * sizeof(double));
- J[i][n + i] = 1;
- }
- if (eliminate(J, n, 2 * n))
- return -1;
- for (i = 0; i < n; i++)
- memcpy(Minv[i], J[i] + n, n * sizeof(double));
- return 0;
-#undef J
-#undef M
-#undef Minv
-}
-
-
-static double transfer_function_l_star(double t)
-{
- double sign = 1;
- if (t < 0) {
- t = -t;
- sign = -1;
- }
- t = t > 216. / 24389. ? 1.16 * cbrt(t) - 0.16 : t * 24389. / 2700.;
- return t * sign;
-}
-
-static double invtransfer_function_l_star(double t)
-{
- double sign = 1;
- if (t < 0) {
- t = -t;
- sign = -1;
- }
- t = t > 0.08 ? (((1000000. * t + 480000.) * t + 76800.) * t + 4096.) / 1560896.0 : t * 2700. / 24389.;
- return t * sign;
-}
-
-static double transfer_function_oetf_hlg(double t)
-{
- double sign = 1;
- if (t < 0) {
- t = -t;
- sign = -1;
- }
- t = 12 * t <= 1 ? sqrt(3 * t) : 0.17883277 * log(t - 0.02372241) + 1.004293468902569985701234145381;
- return t * sign;
-}
-
-static double invtransfer_function_oetf_hlg(double t)
-{
- double sign = 1;
- if (t < 0) {
- t = -t;
- sign = -1;
- }
- t = t <= 0.5 ? t * t / 3 : exp(t - 1.004293468902569985701234145381) / 0.17883277 + 0.02372241;
- return t * sign;
-}
-
-
-static void get_transfer_function(libcolour_colour_t* cs)
-{
- if (cs->model == LIBCOLOUR_RGB) {
- switch (cs->rgb.colour_space) {
- case LIBCOLOUR_RGB_COLOUR_SPACE_ECI_RGB_V2:
- cs->rgb.to_encoded_red = cs->rgb.to_encoded_green = cs->rgb.to_encoded_blue = transfer_function_l_star;
- cs->rgb.to_decoded_red = cs->rgb.to_decoded_green = cs->rgb.to_decoded_blue = invtransfer_function_l_star;
- break;
- case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_EOTF_PQ:
- case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OOTF_PQ:
- case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OETF_PQ:
- case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_EOTF_HLG:
- case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OOTF_HLG:
- /* TODO http://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.2100-0-201607-I!!PDF-E.pdf */
- break;
- case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OETF_HLG:
- cs->rgb.to_encoded_red = cs->rgb.to_encoded_green = cs->rgb.to_encoded_blue = transfer_function_oetf_hlg;
- cs->rgb.to_decoded_red = cs->rgb.to_decoded_green = cs->rgb.to_decoded_blue = invtransfer_function_oetf_hlg;
- break;
- default:
- break;
- }
- }
-}
-
-
-int libcolour_get_rgb_colour_space(libcolour_rgb_t* cs, libcolour_rgb_colour_space_t space)
-{
-#define XYY(XVALUE, YVALUE) (libcolour_ciexyy_t){ .model = LIBCOLOUR_CIEXYY, .x = XVALUE, .y = YVALUE, .Y = 1}
-
- switch (space) {
- case LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_MEASUREMENTS:
- if (get_matrices(cs))
- return -1;
- if (cs->encoding_type == LIBCOLOUR_ENCODING_TYPE_REGULAR)
- cs->transitioninv = cs->transition * cs->slope;
- return 0;
-
- case LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_MATRIX:
- if (invert(cs->Minv, cs->M, 3) || get_primaries(cs))
- return -1;
- if (cs->encoding_type == LIBCOLOUR_ENCODING_TYPE_REGULAR)
- cs->transitioninv = cs->transition * cs->slope;
- return 0;
-
- case LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_INV_MATRIX:
- if (invert(cs->M, cs->Minv, 3) || get_primaries(cs))
- return -1;
- if (cs->encoding_type == LIBCOLOUR_ENCODING_TYPE_REGULAR)
- cs->transitioninv = cs->transition * cs->slope;
- return 0;
-
- case LIBCOLOUR_RGB_COLOUR_SPACE_SRGB:
- cs->red = XYY(0.6400, 0.3300);
- cs->green = XYY(0.3000, 0.6000);
- cs->blue = XYY(0.1500, 0.0600);
- cs->white = LIBCOLOUR_ILLUMINANT_D65;
- cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_REGULAR;
- cs->offset = 0.055;
- cs->gamma = 2.4;
- cs->slope = 12.92;
- cs->transition = 0.0031306684425217108;
- break;
-
- case LIBCOLOUR_RGB_COLOUR_SPACE_ADOBE_RGB:
- cs->red = XYY(0.6400, 0.3300);
- cs->green = XYY(0.2100, 0.7100);
- cs->blue = XYY(0.1500, 0.0600);
- cs->white = LIBCOLOUR_ILLUMINANT_D65;
- cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
- cs->gamma = 2.2;
- break;
-
- case LIBCOLOUR_RGB_COLOUR_SPACE_APPLE_RGB:
- cs->red = XYY(0.6250, 0.3400);
- cs->green = XYY(0.2800, 0.5950);
- cs->blue = XYY(0.1550, 0.0700);
- cs->white = LIBCOLOUR_ILLUMINANT_D65;
- cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
- cs->gamma = 1.8;
- break;
-
- case LIBCOLOUR_RGB_COLOUR_SPACE_BEST_RGB:
- cs->red = XYY(0.7347, 0.2653);
- cs->green = XYY(0.2150, 0.7750);
- cs->blue = XYY(0.1300, 0.0350);
- cs->white = LIBCOLOUR_ILLUMINANT_D50;
- cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
- cs->gamma = 2.2;
- break;
-
- case LIBCOLOUR_RGB_COLOUR_SPACE_BETA_RGB:
- cs->red = XYY(0.6888, 0.3112);
- cs->green = XYY(0.1986, 0.7551);
- cs->blue = XYY(0.1265, 0.0352);
- cs->white = LIBCOLOUR_ILLUMINANT_D50;
- cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
- cs->gamma = 2.2;
- break;
-
- case LIBCOLOUR_RGB_COLOUR_SPACE_BRUCE_RGB:
- cs->red = XYY(0.6400, 0.3300);
- cs->green = XYY(0.2800, 0.6500);
- cs->blue = XYY(0.1500, 0.0600);
- cs->white = LIBCOLOUR_ILLUMINANT_D65;
- cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
- cs->gamma = 2.2;
- break;
-
- case LIBCOLOUR_RGB_COLOUR_SPACE_CIE_RGB:
- cs->red = XYY(0.7350, 0.2650);
- cs->green = XYY(0.2740, 0.7170);
- cs->blue = XYY(0.1670, 0.0090);
- cs->white = LIBCOLOUR_ILLUMINANT_E;
- cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
- cs->gamma = 2.2;
- break;
-
- case LIBCOLOUR_RGB_COLOUR_SPACE_COLORMATCH_RGB:
- cs->red = XYY(0.6300, 0.3400);
- cs->green = XYY(0.2950, 0.6050);
- cs->blue = XYY(0.1500, 0.0750);
- cs->white = LIBCOLOUR_ILLUMINANT_D50;
- cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
- cs->gamma = 1.8;
- break;
-
- case LIBCOLOUR_RGB_COLOUR_SPACE_DCI_P3_D65:
- cs->red = XYY(0.6380, 0.3200);
- cs->green = XYY(0.2650, 0.6900);
- cs->blue = XYY(0.1500, 0.0600);
- cs->white = LIBCOLOUR_ILLUMINANT_D65;
- cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
- cs->gamma = 2.6;
- break;
-
- case LIBCOLOUR_RGB_COLOUR_SPACE_DCI_P3_THEATER:
- cs->red = XYY(0.6380, 0.3200);
- cs->green = XYY(0.2650, 0.6900);
- cs->blue = XYY(0.1500, 0.0600);
- cs->white = XYY(0.314, 0.351);
- cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
- cs->gamma = 2.6;
- break;
-
- case LIBCOLOUR_RGB_COLOUR_SPACE_DON_RGB_4:
- cs->red = XYY(0.6960, 0.3000);
- cs->green = XYY(0.2150, 0.7650);
- cs->blue = XYY(0.1300, 0.0350);
- cs->white = LIBCOLOUR_ILLUMINANT_D50;
- cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
- cs->gamma = 2.2;
- break;
-
- case LIBCOLOUR_RGB_COLOUR_SPACE_ECI_RGB:
- cs->red = XYY(0.6700, 0.3300);
- cs->green = XYY(0.2100, 0.7100);
- cs->blue = XYY(0.1400, 0.0800);
- cs->white = LIBCOLOUR_ILLUMINANT_D50;
- cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
- cs->gamma = 1.8;
- break;
-
- case LIBCOLOUR_RGB_COLOUR_SPACE_ECI_RGB_V2:
- cs->red = XYY(0.6700, 0.3300);
- cs->green = XYY(0.2100, 0.7100);
- cs->blue = XYY(0.1400, 0.0800);
- cs->white = LIBCOLOUR_ILLUMINANT_D50;
- cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_CUSTOM;
- break;
-
- case LIBCOLOUR_RGB_COLOUR_SPACE_EKTA_SPACE_PS5:
- cs->red = XYY(0.6950, 0.3050);
- cs->green = XYY(0.2600, 0.7000);
- cs->blue = XYY(0.1100, 0.0050);
- cs->white = LIBCOLOUR_ILLUMINANT_D50;
- cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
- cs->gamma = 2.2;
- break;
-
- case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_601_625_LINE:
- cs->red = XYY(0.6400, 0.3300);
- cs->green = XYY(0.2900, 0.6000);
- cs->blue = XYY(0.1500, 0.0060);
- cs->white = LIBCOLOUR_ILLUMINANT_D65;
- cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_REGULAR;
- cs->gamma = 1 / 0.45;
- cs->offset = 0.09929682680944;
- cs->slope = 4.5;
- cs->transition = 0.018053968510807;
- break;
-
- case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_601_525_LINE:
- cs->red = XYY(0.6300, 0.3400);
- cs->green = XYY(0.3100, 0.5950);
- cs->blue = XYY(0.1550, 0.0700);
- cs->white = LIBCOLOUR_ILLUMINANT_D65;
- cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_REGULAR;
- cs->gamma = 1 / 0.45;
- cs->offset = 0.09929682680944;
- cs->slope = 4.5;
- cs->transition = 0.018053968510807;
- break;
-
- case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_709:
- cs->red = XYY(0.6300, 0.3300);
- cs->green = XYY(0.3000, 0.6000);
- cs->blue = XYY(0.1500, 0.0600);
- cs->white = LIBCOLOUR_ILLUMINANT_D65;
- cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_REGULAR;
- cs->gamma = 1 / 0.45;
- cs->offset = 0.09929682680944;
- cs->slope = 4.5;
- cs->transition = 0.018053968510807;
- break;
-
- case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2020:
- cs->red = XYY(0.7080, 0.2920);
- cs->green = XYY(0.1700, 0.7970);
- cs->blue = XYY(0.1310, 0.0460);
- cs->white = LIBCOLOUR_ILLUMINANT_D65;
- cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_REGULAR;
- cs->gamma = 1 / 0.45;
- cs->offset = 0.09929682680944;
- cs->slope = 4.5;
- cs->transition = 0.018053968510807;
- break;
-
- case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_EOTF_PQ:
- case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OOTF_PQ:
- case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OETF_PQ:
- case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_EOTF_HLG:
- case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OOTF_HLG:
- case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OETF_HLG:
- cs->red = XYY(0.7080, 0.2920);
- cs->green = XYY(0.1700, 0.7970);
- cs->blue = XYY(0.1310, 0.0460);
- cs->white = LIBCOLOUR_ILLUMINANT_D65;
- cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_CUSTOM;
- break;
-
- case LIBCOLOUR_RGB_COLOUR_SPACE_LIGHTROOM_RGB:
- cs->red = XYY(0.7347, 0.2653);
- cs->green = XYY(0.1596, 0.8404);
- cs->blue = XYY(0.0366, 0.0001);
- cs->white = LIBCOLOUR_ILLUMINANT_D50;
- cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_LINEAR;
- break;
-
- case LIBCOLOUR_RGB_COLOUR_SPACE_NTSC_RGB:
- cs->red = XYY(0.6700, 0.3300);
- cs->green = XYY(0.2100, 0.7100);
- cs->blue = XYY(0.1400, 0.0800);
- cs->white = LIBCOLOUR_ILLUMINANT_C;
- cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_REGULAR;
- cs->gamma = 1 / 0.45;
- cs->offset = 0.09929682680944;
- cs->slope = 4.5;
- cs->transition = 0.018053968510807;
- break;
-
- case LIBCOLOUR_RGB_COLOUR_SPACE_PAL_SECAM_RGB:
- cs->red = XYY(0.6400, 0.3300);
- cs->green = XYY(0.2900, 0.6000);
- cs->blue = XYY(0.1500, 0.0600);
- cs->white = LIBCOLOUR_ILLUMINANT_D65;
- cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_REGULAR;
- cs->gamma = 1 / 0.45;
- cs->offset = 0.09929682680944;
- cs->slope = 4.5;
- cs->transition = 0.018053968510807;
- break;
-
- case LIBCOLOUR_RGB_COLOUR_SPACE_PROPHOTO_RGB:
- cs->red = XYY(0.7347, 0.2653);
- cs->green = XYY(0.1596, 0.8404);
- cs->blue = XYY(0.0366, 0.0001);
- cs->white = LIBCOLOUR_ILLUMINANT_D50;
- cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
- cs->gamma = 1.8;
- break;
-
- case LIBCOLOUR_RGB_COLOUR_SPACE_SGI_RGB:
- cs->red = XYY(0.6250, 0.3400);
- cs->green = XYY(0.2800, 0.5950);
- cs->blue = XYY(0.1550, 0.0700);
- cs->white = LIBCOLOUR_ILLUMINANT_D50;
- cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
- cs->gamma = 1.47;
- break;
-
- case LIBCOLOUR_RGB_COLOUR_SPACE_SMPTE_240M_RGB:
- cs->red = XYY(0.6300, 0.3400);
- cs->green = XYY(0.3100, 0.5950);
- cs->blue = XYY(0.1550, 0.0700);
- cs->white = LIBCOLOUR_ILLUMINANT_D65;
- cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_REGULAR;
- cs->gamma = 1 / 0.45;
- cs->offset = 0.1115721957735072;
- cs->slope = 4.0;
- cs->transition = 0.022821585552393633;
- break;
-
- case LIBCOLOUR_RGB_COLOUR_SPACE_SMPTE_C_RGB:
- cs->red = XYY(0.6300, 0.3400);
- cs->green = XYY(0.3100, 0.5950);
- cs->blue = XYY(0.1550, 0.0700);
- cs->white = LIBCOLOUR_ILLUMINANT_D65;
- cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_REGULAR;
- cs->gamma = 1 / 0.45;
- cs->offset = 0.09929682680944;
- cs->slope = 4.5;
- cs->transition = 0.018053968510807;
- break;
-
- case LIBCOLOUR_RGB_COLOUR_SPACE_WIDE_GAMUT_RGB:
- cs->red = XYY(0.7350, 0.2650);
- cs->green = XYY(0.1150, 0.8260);
- cs->blue = XYY(0.1570, 0.0180);
- cs->white = LIBCOLOUR_ILLUMINANT_D50;
- cs->encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
- cs->gamma = 2.19921875;
- break;
-
- default:
- errno = EINVAL;
- return -1;
- }
- if (cs->encoding_type == LIBCOLOUR_ENCODING_TYPE_REGULAR)
- cs->transitioninv = cs->transition * cs->slope;
- cs->colour_space = space;
- cs->white_r = cs->white_g = cs->white_b = 1;
- if (get_matrices(cs) || libcolour_proper((libcolour_colour_t*)cs))
- return -1;
- get_transfer_function((libcolour_colour_t*)cs);
- return 0;
-
-#undef XYY
-}
-
-
-size_t libcolour_marshal(const libcolour_colour_t* colour, void* buf)
-{
- if (buf)
- *(int*)buf = MARSHAL_VERSION;
- switch (colour->model) {
-#define X(C, T)\
- case C:\
- if (buf)\
- memcpy((char*)buf + sizeof(int), colour, sizeof(T));\
- return sizeof(int) + sizeof(T);
- LIBCOLOUR_LIST_MODELS
-#undef X
- default:
- errno = EINVAL;
- return 0;
- }
-}
-
-
-size_t libcolour_unmarshal(libcolour_colour_t* colour, const void* buf)
-{
- enum libcolour_model model;
- size_t r;
- int ver;
- ver = *(int*)buf;
- if (ver != MARSHAL_VERSION) {
- errno = EINVAL;
- return 0;
- }
- model = *(enum libcolour_model*)((char*)buf + sizeof(int));
- switch (model) {
-#define X(C, T)\
- case C:\
- if (colour)\
- memcpy(colour, (char*)buf + sizeof(int), sizeof(T));\
- r = sizeof(int) + sizeof(T);\
- break;
- LIBCOLOUR_LIST_MODELS
-#undef X
- default:
- errno = EINVAL;
- return 0;
- }
- if (colour) {
- if (colour->model == LIBCOLOUR_RGB) {
- colour->rgb.to_encoded_red = colour->rgb.to_encoded_green = colour->rgb.to_encoded_blue = NULL;
- colour->rgb.to_decoded_red = colour->rgb.to_decoded_green = colour->rgb.to_decoded_blue = NULL;
- }
- get_transfer_function(colour);
- }
- return r;
-}
-
diff --git a/src/libcolour.h b/src/libcolour.h
deleted file mode 100644
index 6387151..0000000
--- a/src/libcolour.h
+++ /dev/null
@@ -1,301 +0,0 @@
-/**
- * Copyright © 2016 Mattias Andrée <maandree@kth.se>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 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/>.
- */
-#ifndef LIBCOLOUR_H
-#define LIBCOLOUR_H
-
-
-#include <stddef.h>
-
-
-
-#define LIBCOLOUR_ILLUMINANT__(x__, y__) (libcolour_ciexyy_t){.model = LIBCOLOUR_CIEXYY, .x = x__, .y = y__, .Y = 1}
-
-#define LIBCOLOUR_ILLUMINANT_A LIBCOLOUR_ILLUMINANT__(0.447573514098910552050369915378, 0.407439444306660847328060981454)
-#define LIBCOLOUR_ILLUMINANT_B LIBCOLOUR_ILLUMINANT__(0.348407693041403399014654951316, 0.351617234807268863594487129376)
-#define LIBCOLOUR_ILLUMINANT_C LIBCOLOUR_ILLUMINANT__(0.310058473730255412803558101587, 0.316149707523236456196968902077)
-#define LIBCOLOUR_ILLUMINANT_D50 LIBCOLOUR_ILLUMINANT__(0.345668037029273123028616510055, 0.358496838937619077825047497754)
-#define LIBCOLOUR_ILLUMINANT_D55 LIBCOLOUR_ILLUMINANT__(0.332424102468830251488896010414, 0.347428039087666229445261478759)
-#define LIBCOLOUR_ILLUMINANT_D65 LIBCOLOUR_ILLUMINANT__(0.312726871026564878786047074755, 0.329023206641284038376227272238)
-#define LIBCOLOUR_ILLUMINANT_D75 LIBCOLOUR_ILLUMINANT__(0.299022300412497055166483050925, 0.314852737888341893679466920730)
-#define LIBCOLOUR_ILLUMINANT_E LIBCOLOUR_ILLUMINANT__(1. / 3, 1. / 3)
-#define LIBCOLOUR_ILLUMINANT_F1 LIBCOLOUR_ILLUMINANT__(0.313062433035651010992950205036, 0.337106477918307445573731229160)
-#define LIBCOLOUR_ILLUMINANT_F2 LIBCOLOUR_ILLUMINANT__(0.372068154452825539113547392844, 0.375122558203110079144693145281)
-#define LIBCOLOUR_ILLUMINANT_F3 LIBCOLOUR_ILLUMINANT__(0.409090035308107391465171076561, 0.394117134255365986206243178458)
-#define LIBCOLOUR_ILLUMINANT_F4 LIBCOLOUR_ILLUMINANT__(0.440181095827666568620628595454, 0.403090691158138336724903183494)
-#define LIBCOLOUR_ILLUMINANT_F5 LIBCOLOUR_ILLUMINANT__(0.313756583095696484075887155996, 0.345160794752101929283583103825)
-#define LIBCOLOUR_ILLUMINANT_F6 LIBCOLOUR_ILLUMINANT__(0.377882361062687466279896852939, 0.388192885537868959122675960316)
-#define LIBCOLOUR_ILLUMINANT_F7 LIBCOLOUR_ILLUMINANT__(0.312852472915475354753311876266, 0.329174178033567632617462095368)
-#define LIBCOLOUR_ILLUMINANT_F8 LIBCOLOUR_ILLUMINANT__(0.345805753550315952971061506105, 0.358617583214377477762724311106)
-#define LIBCOLOUR_ILLUMINANT_F9 LIBCOLOUR_ILLUMINANT__(0.374105245592801061160770359493, 0.372672400924498159469067104510)
-#define LIBCOLOUR_ILLUMINANT_F10 LIBCOLOUR_ILLUMINANT__(0.346086913993929323751785886998, 0.358751605952200347537939251197)
-#define LIBCOLOUR_ILLUMINANT_F11 LIBCOLOUR_ILLUMINANT__(0.380537485483030235577928124258, 0.376915309293930078649026427229)
-#define LIBCOLOUR_ILLUMINANT_F12 LIBCOLOUR_ILLUMINANT__(0.437023901312296902954557253906, 0.404214327891585678553809657387)
-
-#define LIBCOLOUR_ILLUMINANT_A_10DEG_OBS LIBCOLOUR_ILLUMINANT__(0.451173939693730152722395132514, 0.405936604212625562482230634487)
-#define LIBCOLOUR_ILLUMINANT_B_10DEG_OBS LIBCOLOUR_ILLUMINANT__(0.349819801494100579564161535018, 0.352687989927865819250740742063)
-#define LIBCOLOUR_ILLUMINANT_C_10DEG_OBS LIBCOLOUR_ILLUMINANT__(0.310388663270034004248998371622, 0.319050711366790695766582075521)
-#define LIBCOLOUR_ILLUMINANT_D50_10DEG_OBS LIBCOLOUR_ILLUMINANT__(0.347729429961154856698613002663, 0.359522508516545380441442603114)
-#define LIBCOLOUR_ILLUMINANT_D55_10DEG_OBS LIBCOLOUR_ILLUMINANT__(0.334116336430253457745465084372, 0.348766090975953568786849245953)
-#define LIBCOLOUR_ILLUMINANT_D65_10DEG_OBS LIBCOLOUR_ILLUMINANT__(0.313823646938709621689866935412, 0.330998985489933561510156323493)
-#define LIBCOLOUR_ILLUMINANT_D75_10DEG_OBS LIBCOLOUR_ILLUMINANT__(0.299679971345752860223399238748, 0.317403239854836705102769656150)
-#define LIBCOLOUR_ILLUMINANT_E_10DEG_OBS LIBCOLOUR_ILLUMINANT__(1. / 3, 1. / 3)
-#define LIBCOLOUR_ILLUMINANT_F1_10DEG_OBS LIBCOLOUR_ILLUMINANT__(0.318098801070991199502202562144, 0.335489451474129951602520804954)
-#define LIBCOLOUR_ILLUMINANT_F2_10DEG_OBS LIBCOLOUR_ILLUMINANT__(0.379274832262508854174853922814, 0.367227934400669309145115448700)
-#define LIBCOLOUR_ILLUMINANT_F3_10DEG_OBS LIBCOLOUR_ILLUMINANT__(0.417644682102624287267644831445, 0.383124504918675723441623404142)
-#define LIBCOLOUR_ILLUMINANT_F4_10DEG_OBS LIBCOLOUR_ILLUMINANT__(0.449247699162001246087072559021, 0.390605475879083674506375700730)
-#define LIBCOLOUR_ILLUMINANT_F5_10DEG_OBS LIBCOLOUR_ILLUMINANT__(0.319739939104951298443069163113, 0.342367055369128092667807550242)
-#define LIBCOLOUR_ILLUMINANT_F6_10DEG_OBS LIBCOLOUR_ILLUMINANT__(0.386626908526034762658696308790, 0.378372201588893453116924092683)
-#define LIBCOLOUR_ILLUMINANT_F7_10DEG_OBS LIBCOLOUR_ILLUMINANT__(0.315645637312390425766039925293, 0.329508145132134222521358424274)
-#define LIBCOLOUR_ILLUMINANT_F8_10DEG_OBS LIBCOLOUR_ILLUMINANT__(0.348965563721531868424108324689, 0.359317299140994528272585739614)
-#define LIBCOLOUR_ILLUMINANT_F9_10DEG_OBS LIBCOLOUR_ILLUMINANT__(0.378258900384649654480284652891, 0.370371375730762564248976786985)
-#define LIBCOLOUR_ILLUMINANT_F10_10DEG_OBS LIBCOLOUR_ILLUMINANT__(0.350893389986753234666139178444, 0.354302210111646531665030579461)
-#define LIBCOLOUR_ILLUMINANT_F11_10DEG_OBS LIBCOLOUR_ILLUMINANT__(0.385435391037903751776383387551, 0.371094786781121399599214782938)
-#define LIBCOLOUR_ILLUMINANT_F12_10DEG_OBS LIBCOLOUR_ILLUMINANT__(0.442654456042513022584472537346, 0.397060737666593277506166259627)
-
-
-#define LIBCOLOUR_LIST_MODELS\
- X(LIBCOLOUR_RGB, libcolour_rgb_t)\
- X(LIBCOLOUR_SRGB, libcolour_srgb_t)\
- X(LIBCOLOUR_CIEXYY, libcolour_ciexyy_t)\
- X(LIBCOLOUR_CIEXYZ, libcolour_ciexyz_t)\
- X(LIBCOLOUR_CIELAB, libcolour_cielab_t)\
- X(LIBCOLOUR_CIELUV, libcolour_cieluv_t)\
- X(LIBCOLOUR_CIELCHUV, libcolour_cielchuv_t)\
- X(LIBCOLOUR_YIQ, libcolour_yiq_t)\
- X(LIBCOLOUR_YDBDR, libcolour_ydbdr_t)\
- X(LIBCOLOUR_YUV, libcolour_yuv_t)\
- X(LIBCOLOUR_YPBPR, libcolour_ypbpr_t)\
- X(LIBCOLOUR_YCGCO, libcolour_ycgco_t)\
- X(LIBCOLOUR_CIE1960UCS, libcolour_cie1960ucs_t)\
- X(LIBCOLOUR_CIEUVW, libcolour_cieuvw_t)
-
-
-typedef enum libcolour_model {
-#define X(C, T) C,
- LIBCOLOUR_LIST_MODELS
-#undef X
-} libcolour_model_t;
-
-
-typedef enum libcolour_encoding_type {
- LIBCOLOUR_ENCODING_TYPE_LINEAR,
- LIBCOLOUR_ENCODING_TYPE_SIMPLE,
- LIBCOLOUR_ENCODING_TYPE_REGULAR,
- LIBCOLOUR_ENCODING_TYPE_CUSTOM
-} libcolour_encoding_type;
-
-
-typedef enum libcolour_rgb_colour_space {
- LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_MEASUREMENTS,
- LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_MATRIX,
- LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_INV_MATRIX,
- LIBCOLOUR_RGB_COLOUR_SPACE_SRGB,
- LIBCOLOUR_RGB_COLOUR_SPACE_ADOBE_RGB,
- LIBCOLOUR_RGB_COLOUR_SPACE_APPLE_RGB,
- LIBCOLOUR_RGB_COLOUR_SPACE_BEST_RGB,
- LIBCOLOUR_RGB_COLOUR_SPACE_BETA_RGB,
- LIBCOLOUR_RGB_COLOUR_SPACE_BRUCE_RGB,
- LIBCOLOUR_RGB_COLOUR_SPACE_CIE_RGB,
- LIBCOLOUR_RGB_COLOUR_SPACE_COLORMATCH_RGB,
- LIBCOLOUR_RGB_COLOUR_SPACE_DCI_P3_D65,
- LIBCOLOUR_RGB_COLOUR_SPACE_DCI_P3_THEATER,
- LIBCOLOUR_RGB_COLOUR_SPACE_DON_RGB_4,
- LIBCOLOUR_RGB_COLOUR_SPACE_ECI_RGB,
- LIBCOLOUR_RGB_COLOUR_SPACE_ECI_RGB_V2,
- LIBCOLOUR_RGB_COLOUR_SPACE_EKTA_SPACE_PS5,
- LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_601_625_LINE,
- LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_601_525_LINE,
- LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_709,
- LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2020,
- LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_EOTF_PQ,
- LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OOTF_PQ,
- LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OETF_PQ,
- LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_EOTF_HLG,
- LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OOTF_HLG,
- LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OETF_HLG,
- LIBCOLOUR_RGB_COLOUR_SPACE_LIGHTROOM_RGB,
- LIBCOLOUR_RGB_COLOUR_SPACE_NTSC_RGB,
- LIBCOLOUR_RGB_COLOUR_SPACE_PAL_SECAM_RGB,
- LIBCOLOUR_RGB_COLOUR_SPACE_PROPHOTO_RGB,
- LIBCOLOUR_RGB_COLOUR_SPACE_SGI_RGB,
- LIBCOLOUR_RGB_COLOUR_SPACE_SMPTE_240M_RGB,
- LIBCOLOUR_RGB_COLOUR_SPACE_SMPTE_C_RGB,
- LIBCOLOUR_RGB_COLOUR_SPACE_WIDE_GAMUT_RGB
-} libcolour_rgb_colour_space_t;
-
-
-typedef struct libcolour_srgb {
- enum libcolour_model model;
- double R;
- double G;
- double B;
- int with_gamma;
-} libcolour_srgb_t;
-
-typedef struct libcolour_ciexyy {
- enum libcolour_model model;
- double x;
- double y;
- double Y;
-} libcolour_ciexyy_t;
-
-typedef struct libcolour_ciexyz {
- enum libcolour_model model;
- double X;
- double Y;
- double Z;
-} libcolour_ciexyz_t;
-
-typedef struct libcolour_cielab {
- enum libcolour_model model;
- double L;
- double a;
- double b;
-} libcolour_cielab_t;
-
-typedef struct libcolour_yiq {
- enum libcolour_model model;
- double Y;
- double I;
- double Q;
-} libcolour_yiq_t;
-
-typedef struct libcolour_ydbdr {
- enum libcolour_model model;
- double Y;
- double Db;
- double Dr;
-} libcolour_ydbdr_t;
-
-typedef struct libcolour_yuv {
- enum libcolour_model model;
- double Y;
- double U;
- double V;
-} libcolour_yuv_t;
-
-typedef struct libcolour_ypbpr {
- enum libcolour_model model;
- double Y;
- double Pb;
- double Pr;
-} libcolour_ypbpr_t;
-
-typedef struct libcolour_ycgco {
- enum libcolour_model model;
- double Y;
- double Cg;
- double Co;
-} libcolour_ycgco_t;
-
-typedef struct libcolour_cie1960ucs {
- enum libcolour_model model;
- double u;
- double v;
- double Y;
-} libcolour_cie1960ucs_t;
-
-typedef struct libcolour_cieuvw {
- enum libcolour_model model;
- double U;
- double V;
- double W;
- double u0;
- double v0;
-} libcolour_cieuvw_t;
-
-typedef struct libcolour_cieluv {
- enum libcolour_model model;
- double L;
- double u;
- double v;
- struct libcolour_ciexyz white;
-} libcolour_cieluv_t;
-
-typedef struct libcolour_cielchuv {
- enum libcolour_model model;
- double L;
- double C;
- double h;
- struct libcolour_ciexyz white;
- double one_revolution;
-} libcolour_cielchuv_t;
-
-typedef struct libcolour_rgb {
- enum libcolour_model model;
- double R;
- double G;
- double B;
- int with_gamma;
- enum libcolour_encoding_type encoding_type;
- double gamma;
- double offset;
- double slope;
- double transition;
- double transitioninv;
- double (*to_encoded_red)(double);
- double (*to_decoded_red)(double);
- double (*to_encoded_green)(double);
- double (*to_decoded_green)(double);
- double (*to_encoded_blue)(double);
- double (*to_decoded_blue)(double);
- struct libcolour_ciexyy red;
- struct libcolour_ciexyy green;
- struct libcolour_ciexyy blue;
- struct libcolour_ciexyy white;
- double white_r;
- double white_g;
- double white_b;
- double M[3][3];
- double Minv[3][3];
- enum libcolour_rgb_colour_space colour_space;
-} libcolour_rgb_t;
-
-
-typedef union libcolour_colour {
- enum libcolour_model model;
- struct libcolour_rgb rgb;
- struct libcolour_srgb srgb;
- struct libcolour_ciexyy ciexyy;
- struct libcolour_ciexyz ciexyz;
- struct libcolour_cielab cielab;
- struct libcolour_cieluv cieluv;
- struct libcolour_cielchuv cielchuv;
- struct libcolour_yiq yiq;
- struct libcolour_ydbdr ydbdr;
- struct libcolour_yuv yuv;
- struct libcolour_ypbpr ypbpr;
- struct libcolour_ycgco ycgco;
- struct libcolour_cie1960ucs cie1960ucs;
- struct libcolour_cieuvw cieuvw;
-} libcolour_colour_t;
-
-
-
-int libcolour_convert(const libcolour_colour_t* restrict from, libcolour_colour_t* restrict to);
-double libcolour_srgb_encode(double);
-double libcolour_srgb_decode(double);
-int libcolour_delta_e(const libcolour_colour_t*, const libcolour_colour_t*, double*);
-int libcolour_proper(libcolour_colour_t*);
-int libcolour_get_rgb_colour_space(libcolour_rgb_t*, libcolour_rgb_colour_space_t);
-size_t libcolour_marshal(const libcolour_colour_t*, void*);
-size_t libcolour_unmarshal(libcolour_colour_t*, const void*);
-
-
-
-#endif
-
diff --git a/src/test.c b/src/test.c
deleted file mode 100644
index ad7acfc..0000000
--- a/src/test.c
+++ /dev/null
@@ -1,657 +0,0 @@
-/**
- * Copyright © 2016 Mattias Andrée <maandree@kth.se>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 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/>.
- */
-#include "libcolour.h"
-
-#include <math.h>
-#include <stdio.h>
-#include <string.h>
-
-
-#ifndef SKIP_2CONVERT
-static int test_2convert(libcolour_colour_t* c1, libcolour_colour_t* c2, libcolour_colour_t* c3)
-{
- double ch1, ch2, ch3;
- if (libcolour_convert(c1, c2))
- return -1;
- if (libcolour_convert(c2, c3))
- return -1;
- if ((c1->model == LIBCOLOUR_CIELCHUV) &&
- !isnan(c1->cielchuv.h) && !isnan(c3->cielchuv.h) &&
- !isinf(c1->cielchuv.h) && !isinf(c3->cielchuv.h) &&
- (c3->cielchuv.h / c3->cielchuv.one_revolution > 0.99999))
- c3->cielchuv.h = 0;
- ch1 = c1->srgb.R - c3->srgb.R;
- ch2 = c1->srgb.G - c3->srgb.G;
- ch3 = c1->srgb.B - c3->srgb.B;
- ch1 *= ch1;
- ch2 *= ch2;
- ch3 *= ch3;
- switch (c1->model) {
- case LIBCOLOUR_CIEXYY:
- if (c1->ciexyy.Y == 0)
- ch1 = ch2 = 0;
- if (c1->ciexyy.y == 0)
- ch1 = ch2 = ch3 = 0;
- break;
- case LIBCOLOUR_CIEXYZ:
- if (c1->ciexyz.Y == 0)
- ch1 = ch3 = 0;
- break;
- case LIBCOLOUR_CIE1960UCS:
- if (c1->cie1960ucs.v == 0)
- ch1 = ch2 = ch3 = 0;
- if (c1->cie1960ucs.Y == 0)
- ch1 = ch2 = 0;
- break;
- case LIBCOLOUR_CIEUVW:
- if (c1->cieuvw.W == 0)
- ch1 = ch2 = 0;
- break;
- case LIBCOLOUR_CIELCHUV:
- if (c1->cielchuv.C == 0)
- ch1 = ch3 = 0;
- break;
- case LIBCOLOUR_CIELAB:
- if (c1->cielchuv.L == 0)
- ch2 = ch3 = 0;
- break;
- default:
- break;
- }
- if (ch1 > 0.000001 ||
- ch2 > 0.000001 ||
- ch3 > 0.000001)
- return 0;
- return 1;
-}
-
-
-static int test_2convert_11(libcolour_colour_t* c1, libcolour_model_t model)
-{
- libcolour_colour_t c2, c3;
- int r1, r2;
- c3 = *c1;
- c2.model = model;
- switch (model) {
- case LIBCOLOUR_RGB:
- c2.rgb.with_gamma = 0;
- if (libcolour_get_rgb_colour_space(&c2.rgb, LIBCOLOUR_RGB_COLOUR_SPACE_SRGB) < 0)
- return -1;
- return test_2convert(c1, &c2, &c3);
- case LIBCOLOUR_SRGB:
- c2.srgb.with_gamma = 0;
- if (r1 = test_2convert(c1, &c2, &c3), r1 < 0)
- return -1;
- c2.srgb.with_gamma = 1;
- if (r2 = test_2convert(c1, &c2, &c3), r2 < 0)
- return -1;
- return r1 & r2;
- case LIBCOLOUR_CIELCHUV:
- c2.cielchuv.one_revolution = 360.;
- /* fall though */
- case LIBCOLOUR_CIELUV:
- c2.cieluv.white.model = LIBCOLOUR_CIEXYZ;
- c2.cieluv.white.X = 1.0294;
- c2.cieluv.white.Y = 1;
- c2.cieluv.white.Z = 0.9118;
- return test_2convert(c1, &c2, &c3);
- case LIBCOLOUR_CIEUVW:
- c2.cieuvw.u0 = 0.37;
- c2.cieuvw.v0 = 0.30;
- return test_2convert(c1, &c2, &c3);
- default:
- return test_2convert(c1, &c2, &c3);
- }
-}
-
-
-static int test_2convert_1n(libcolour_model_t model, const char* model_name, double ch1, double ch2, double ch3)
-{
- libcolour_colour_t c1;
- int run, r, rc = 1;
-
- c1.model = model;
- switch (model) {
- case LIBCOLOUR_CIELAB:
- c1.cielab.L = ch1 * 100, c1.cielab.a = ch2 * 100, c1.cielab.b = ch3 * 100;
- break;
- case LIBCOLOUR_CIELCHUV:
- if (ch3 > 0.9999)
- return 1;
- /* fall though */
- default:
- c1.srgb.R = ch1, c1.srgb.G = ch2, c1.srgb.B = ch3;
- break;
- }
-
- for (run = 0;; run++) {
- switch (model) {
- case LIBCOLOUR_RGB:
- if (run == 2)
- return rc;
- c1.rgb.with_gamma = run;
- if (libcolour_get_rgb_colour_space(&c1.rgb, LIBCOLOUR_RGB_COLOUR_SPACE_SRGB) < 0)
- return -1;
- break;
- case LIBCOLOUR_SRGB:
- if (run == 2)
- return rc;
- c1.srgb.with_gamma = run;
- break;
- case LIBCOLOUR_CIELCHUV:
- c1.cielchuv.one_revolution = run < 2 ? 360. : 2 * 3.14159265358979323846;
- c1.cielchuv.h *= c1.cielchuv.one_revolution;
- /* fall through */
- case LIBCOLOUR_CIELUV:
- c1.cieluv.white.model = LIBCOLOUR_CIEXYZ;
- if (run == 0) {
- c1.cieluv.white.X = 1.0294;
- c1.cieluv.white.Y = 1;
- c1.cieluv.white.Z = 0.9118;
- } else if (run == 1) {
- c1.cieluv.white.X = 1.03;
- c1.cieluv.white.Y = 0.8;
- c1.cieluv.white.Z = 0.92;
- } else if (run == 2 && model == LIBCOLOUR_CIELCHUV) {
- c1.cieluv.white.X = 1.0294;
- c1.cieluv.white.Y = 1;
- c1.cieluv.white.Z = 0.9118;
- } else if (run == 3 && model == LIBCOLOUR_CIELCHUV) {
- c1.cieluv.white.X = 1.03;
- c1.cieluv.white.Y = 0.8;
- c1.cieluv.white.Z = 0.92;
- } else {
- return rc;
- }
- break;
- case LIBCOLOUR_CIEUVW:
- if (run == 0) {
- c1.cieuvw.u0 = 0.37;
- c1.cieuvw.v0 = 0.30;
- } else if (run == 1) {
- c1.cieuvw.u0 = 0.47;
- c1.cieuvw.v0 = 0.31;
- } else {
- return rc;
- }
- break;
- default:
- if (run == 1)
- return rc;
- break;
- }
-
-#define X(ENUM, TYPE)\
- r = test_2convert_11(&c1, ENUM);\
- if (r < 0)\
- return -1;\
- if (!r)\
- printf("%s -> %s -> %s failed at run %i with (%lf, %lf, %lf)\n",\
- model_name, #ENUM, model_name, run, ch1, ch2, ch3), rc = 0;
- LIBCOLOUR_LIST_MODELS;
-#undef X
- }
-}
-
-
-static int test_2convert_nm(double ch1, double ch2, double ch3)
-{
- int r, rc = 1;
-
-#define X(ENUM, TYPE)\
- r = test_2convert_1n(ENUM, #ENUM, ch1, ch2, ch3);\
- if (r < 0)\
- return -1;\
- if (!r)\
- rc = 0;
- LIBCOLOUR_LIST_MODELS;
-#undef X
-
- return rc;
-}
-
-
-static int test_2convert_nm_all(void)
-{
-#define N 11
- int r, rc = 1;
- double ch1, ch2, ch3;
- int i, j, k;
-
- for (i = 0; i < N; i++) {
- for (j = 0; j < N; j++) {
- for (k = 0; k < N; k++) {
- ch1 = ((i + N / 2) % N) / (N - 1);
- ch2 = ((j + N / 2) % N) / (N - 1);
- ch3 = ((k + N / 2) % N) / (N - 1);
-
- if (ch1 > 0.999) ch1 = 1;
- if (ch2 > 0.999) ch2 = 1;
- if (ch3 > 0.999) ch3 = 1;
-
- r = test_2convert_nm(ch1, ch2, ch3);
- if (r < 0)
- return -1;
- if (!r)
- rc = 0;
- }
- }
- }
-
- return rc;
-#undef N
-}
-#endif
-
-
-static inline int ftest(double a, double b, double l)
-{
- return a - l <= b && b <= a + l;
-}
-
-
-#define test_rgb(COLOUR_SPACE, ...) test_rgb_(COLOUR_SPACE, #COLOUR_SPACE, __VA_ARGS__)
-static int test_rgb_(enum libcolour_rgb_colour_space colour_space, const char* name,
- double r, double g, double b, double x, double y, double z,
- double xx, double yy, double zz)
-{
- libcolour_colour_t c1, c2;
-
- c1.model = LIBCOLOUR_RGB;
- c2.model = LIBCOLOUR_CIEXYZ;
- c1.rgb.with_gamma = 0;
- c1.rgb.R = r, c1.rgb.G = g, c1.rgb.B = b;
- if (libcolour_get_rgb_colour_space(&c1.rgb, colour_space) ||
- libcolour_convert(&c1, &c2)) {
- printf("%s failed without gamma\n", name);
- return 0;
- } else if (!ftest(c2.ciexyz.X, x, 0.0001) ||
- !ftest(c2.ciexyz.Y, y, 0.0001) ||
- !ftest(c2.ciexyz.Z, z, 0.0001)) {
- printf("%s failed without gamma\n", name);
- return 0;
- }
-
- c1.model = LIBCOLOUR_RGB;
- c2.model = LIBCOLOUR_CIEXYZ;
- c1.rgb.with_gamma = 1;
- c1.rgb.R = r, c1.rgb.G = g, c1.rgb.B = b;
- if (libcolour_get_rgb_colour_space(&c1.rgb, colour_space) ||
- libcolour_convert(&c1, &c2)) {
- printf("%s failed with gamma\n", name);
- return 0;
- } else if (!ftest(c2.ciexyz.X, xx, 0.0001) ||
- !ftest(c2.ciexyz.Y, yy, 0.0001) ||
- !ftest(c2.ciexyz.Z, zz, 0.0001)) {
- printf("%s failed with gamma\n", name);
- return 0;
- }
-
- if (libcolour_convert(&c2, &c1) ||
- !ftest(c1.rgb.R, r, 0.0000001) ||
- !ftest(c1.rgb.G, g, 0.0000001) ||
- !ftest(c1.rgb.B, b, 0.0000001)) {
- printf("%s failed, encode\n", name);
- return 0;
- }
-
- return 1;
-}
-
-
-static int test_1convert(libcolour_colour_t *c1, libcolour_model_t model, const char* name1,
- const char* name2, double ch1, double ch2, double ch3, double d1,
- double d2, double d3)
-{
- libcolour_colour_t c2, c3;
- int rc = 1;
- c3 = *c1;
- c2.model = model;
- switch (model) {
- case LIBCOLOUR_CIELCHUV:
- c2.cielchuv.one_revolution = 360;
- /* fall-through */
- case LIBCOLOUR_CIELUV:
- c2.cieluv.white.X = 0.9504705586542831;
- c2.cieluv.white.Y = 1;
- c2.cieluv.white.Z = 1.0888287363958837;
- break;
- default:
- break;
- }
- if (libcolour_convert(c1, &c2))
- return -1;
- if (!ftest(c2.srgb.R, ch1, d1) ||
- !ftest(c2.srgb.G, ch2, d2) ||
- !ftest(c2.srgb.B, ch3, d3)) {
- printf("%s -> %s failed\n", name1, name2), rc = 0;
- rc = 0;
- }
- if (libcolour_convert(&c2, &c3))
- return -1;
- if (!ftest(c3.srgb.R, c1->srgb.R, 0.00000001) ||
- !ftest(c3.srgb.G, c1->srgb.G, 0.00000001) ||
- !ftest(c3.srgb.B, c1->srgb.B, 0.00000001)) {
- printf("%s -> %s failed\n", name2, name1), rc = 0;
- rc = 0;
- }
- return rc;
-}
-
-
-/**
- * Test libcolour
- *
- * @return 0: All tests passed
- * 1: At least one test fail
- * 2: An error occurred
- */
-int main(int argc, char* argv[])
-{
- int r, rc = 0;
- libcolour_colour_t c1, c2, c3, c4;
- double t1, t2;
- size_t n;
- char buf[sizeof(int) + sizeof(libcolour_rgb_t)];
-
-#ifndef SKIP_2CONVERT
- r = test_2convert_nm_all();
- if (r < 0)
- goto fail;
- if (!r)
- rc = 1;
-#else
- (void) r;
-#endif
-
- c1.model = LIBCOLOUR_SRGB;
- c1.srgb.R = 0.02, c1.srgb.G = 0.5, c1.srgb.B = 0.9;
- c1.srgb.with_gamma = 0;
- c2.model = LIBCOLOUR_RGB;
- c2.rgb.with_gamma = 0;
- if (libcolour_get_rgb_colour_space(&c2.rgb, LIBCOLOUR_RGB_COLOUR_SPACE_SRGB)) {
- printf("LIBCOLOUR_RGB_COLOUR_SPACE_SRGB failed\n"), rc = 0;
- goto colour_spaces_done;
- }
- if (c2.rgb.white_r != 1 || c2.rgb.white_g != 1 || c2.rgb.white_b != 1 ||
- c2.rgb.red.model != LIBCOLOUR_CIEXYY || c2.rgb.green.model != LIBCOLOUR_CIEXYY ||
- c2.rgb.blue.model != LIBCOLOUR_CIEXYY || c2.rgb.white.model != LIBCOLOUR_CIEXYY ||
- c2.rgb.colour_space != LIBCOLOUR_RGB_COLOUR_SPACE_SRGB || c2.rgb.gamma != 2.4 ||
- c2.rgb.encoding_type != LIBCOLOUR_ENCODING_TYPE_REGULAR || c2.rgb.slope != 12.92
- || c2.rgb.offset != 0.055 || c2.rgb.transitioninv != c2.rgb.transition * c2.rgb.slope ||
- !ftest(c2.rgb.transition, 0.00313067, 0.00000001)) {
- printf("LIBCOLOUR_RGB_COLOUR_SPACE_SRGB failed\n"), rc = 0;
- goto colour_spaces_done;
- }
- t1 = c2.rgb.transition * c2.rgb.slope;
- t2 = (1 + c2.rgb.offset) * pow(c2.rgb.transition, 1 / c2.rgb.gamma) - c2.rgb.offset;
- if (!ftest(t1, t2, 0.0000001) || c2.rgb.white.Y != 1 ||
- c2.rgb.red.x != 0.64 || c2.rgb.red.y != 0.33 || !ftest(c2.rgb.red.Y, 0.21265, 0.00005) ||
- c2.rgb.green.x != 0.30 || c2.rgb.green.y != 0.60 || !ftest(c2.rgb.green.Y, 0.71515, 0.00005) ||
- c2.rgb.blue.x != 0.15 || c2.rgb.blue.y != 0.06 || !ftest(c2.rgb.blue.Y, 0.07215, 0.00005) ||
- !ftest(c2.rgb.white.x, 0.312727, 0.000001) || !ftest(c2.rgb.white.y, 0.329023, 0.000001) ||
- !ftest(c2.rgb.red.Y + c2.rgb.green.Y + c2.rgb.blue.Y, 1, 0.00000001)) {
- printf("LIBCOLOUR_RGB_COLOUR_SPACE_SRGB failed\n"), rc = 0;
- goto colour_spaces_done;
- }
- if (libcolour_convert(&c1, &c2) ||
- !ftest(c1.srgb.R, c2.rgb.R, 0.0000001) ||
- !ftest(c1.srgb.G, c2.rgb.G, 0.0000001) ||
- !ftest(c1.srgb.B, c2.rgb.B, 0.0000001)) {
- printf("LIBCOLOUR_RGB_COLOUR_SPACE_SRGB failed\n"), rc = 0;
- goto colour_spaces_done;
- }
- if (libcolour_convert(&c2, &c1) ||
- !ftest(c1.srgb.R, c2.rgb.R, 0.0000001) ||
- !ftest(c1.srgb.G, c2.rgb.G, 0.0000001) ||
- !ftest(c1.srgb.B, c2.rgb.B, 0.0000001)) {
- printf("LIBCOLOUR_RGB_COLOUR_SPACE_SRGB failed\n"), rc = 0;
- goto colour_spaces_done;
- }
-
- c1.model = c2.model = LIBCOLOUR_CIELAB;
- c1.cielab.L = 30, c2.cielab.L = 80;
- c1.cielab.a = 40, c2.cielab.a = -10;
- c1.cielab.b = -50, c2.cielab.b = -40;
- if (libcolour_delta_e(&c1, &c2, &t1) || !ftest(t1, 71.4142842854285, 0.0000001))
- printf("libcolour_delta_e failed\n"), rc = 0;
-
- rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_ADOBE_RGB, 0.3, 0.2, 0.9,
- 0.379497, 0.282430, 0.914245, 0.195429, 0.098925, 0.790020);
-
- rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_APPLE_RGB, 0.3, 0.2, 0.9,
- 0.364212, 0.282789, 0.866008, 0.221570, 0.134028, 0.773782);
-
- rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_BEST_RGB, 0.3, 0.2, 0.9,
- 0.345007, 0.246779, 0.736029, 0.151406, 0.064655, 0.647212);
-
- rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_BETA_RGB, 0.3, 0.2, 0.9,
- 0.342837, 0.253386, 0.714198, 0.146437, 0.066824, 0.623382);
-
- rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_BRUCE_RGB, 0.3, 0.2, 0.9,
- 0.368857, 0.276910, 0.915272, 0.191184, 0.096699, 0.791486);
-
- rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_CIE_RGB, 0.3, 0.2, 0.9,
- 0.389293, 0.225188, 0.892857, 0.202678, 0.044608, 0.785312);
-
- rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_COLORMATCH_RGB, 0.3, 0.2, 0.9,
- 0.337557, 0.274378, 0.651989, 0.186858, 0.123210, 0.581381);
-
- rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_DON_RGB_4, 0.3, 0.2, 0.9,
- 0.344990, 0.251411, 0.727872, 0.150504, 0.066348, 0.638058);
-
- rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_ECI_RGB, 0.3, 0.2, 0.9,
- 0.353021, 0.286400, 0.695202, 0.196733, 0.134157, 0.630279);
-
- rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_ECI_RGB_V2, 0.3, 0.2, 0.9,
- 0.353021, 0.286400, 0.695202, 0.149594, 0.097238, 0.579927);
-
- rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_EKTA_SPACE_PS5, 0.3, 0.2, 0.9,
- 0.320377, 0.229160, 0.713291, 0.127134, 0.043253, 0.622392);
-
- rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_NTSC_RGB, 0.3, 0.2, 0.9,
- 0.397081, 0.310031, 1.017821, 0.235650, 0.156675, 0.906707);
-
- rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_PAL_SECAM_RGB, 0.3, 0.2, 0.9,
- 0.357972, 0.272130, 0.877151, 0.208580, 0.120322, 0.769056);
-
- rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_PROPHOTO_RGB, 0.3, 0.2, 0.9,
- 0.294559, 0.228864, 0.742689, 0.124735, 0.072340, 0.682655);
-
- rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_SMPTE_C_RGB, 0.3, 0.2, 0.9,
- 0.363595, 0.281822, 0.890350, 0.216773, 0.131311, 0.783348);
-
- rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_WIDE_GAMUT_RGB, 0.3, 0.2, 0.9,
- 0.367485, 0.237631, 0.706442, 0.170318, 0.052665, 0.614915);
-
- rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_LIGHTROOM_RGB, 0.3, 0.2, 0.9,
- 0.294559, 0.228864, 0.742689, 0.294559, 0.228864, 0.742689);
-
- /*
- TODO test LIBCOLOUR_RGB_COLOUR_SPACE_DCI_P3_D65
- TODO test LIBCOLOUR_RGB_COLOUR_SPACE_DCI_P3_THEATER
- TODO test LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_601_625_LINE
- TODO test LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_601_525_LINE
- TODO test LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_709
- TODO test LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2020
- TODO test LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_EOTF_PQ
- TODO test LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OOTF_PQ
- TODO test LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OETF_PQ
- TODO test LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_EOTF_HLG
- TODO test LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OOTF_HLG
- TODO test LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OETF_HLG
- TODO test LIBCOLOUR_RGB_COLOUR_SPACE_SGI_RGB
- TODO test LIBCOLOUR_RGB_COLOUR_SPACE_SMPTE_240M_RGB
-
- TODO test LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_MEASUREMENTS
- TODO test LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_MATRIX
- TODO test LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_INV_MATRIX
- */
-
- /* TODO test transfer functions more rigorously */
-
- c1.model = c2.model = LIBCOLOUR_RGB;
- c3.model = c4.model = LIBCOLOUR_SRGB;
- c1.rgb.with_gamma = c3.srgb.with_gamma = 0;
- c2.rgb.with_gamma = c4.srgb.with_gamma = 1;
- if (libcolour_get_rgb_colour_space(&c1.rgb, LIBCOLOUR_RGB_COLOUR_SPACE_SRGB))
- goto fail;
- if (libcolour_get_rgb_colour_space(&c2.rgb, LIBCOLOUR_RGB_COLOUR_SPACE_SRGB))
- goto fail;
- for (t1 = 0; t1 <= 1; t1 += 0.001) {
- c1.rgb.R = c3.srgb.R = t1 - 1;
- c1.rgb.G = c3.srgb.G = t1;
- c1.rgb.B = c3.srgb.B = t1 + 1;
- if (libcolour_convert(&c1, &c2))
- goto fail;
- if (libcolour_convert(&c3, &c4))
- goto fail;
- if (!ftest(c2.rgb.R, c4.srgb.R, 0.00000000001) ||
- !ftest(c2.rgb.G, c4.srgb.G, 0.00000000001) ||
- !ftest(c2.rgb.B, c4.srgb.B, 0.00000000001) ||
- !ftest(libcolour_srgb_encode(c1.rgb.R), c2.srgb.R, 0.00000000001) ||
- !ftest(libcolour_srgb_encode(c1.rgb.G), c2.srgb.G, 0.00000000001) ||
- !ftest(libcolour_srgb_encode(c1.rgb.B), c2.srgb.B, 0.00000000001)) {
- printf("libcolour_srgb_encode failed\n"), rc = 0;
- goto colour_spaces_done;
- }
- if (libcolour_convert(&c2, &c1))
- goto fail;
- if (libcolour_convert(&c4, &c3))
- goto fail;
- if (!ftest(c1.rgb.R, c3.srgb.R, 0.00000000001) ||
- !ftest(c1.rgb.G, c3.srgb.G, 0.00000000001) ||
- !ftest(c1.rgb.B, c3.srgb.B, 0.00000000001) ||
- !ftest(libcolour_srgb_decode(c2.rgb.R), c1.srgb.R, 0.00000000001) ||
- !ftest(libcolour_srgb_decode(c2.rgb.G), c1.srgb.G, 0.00000000001) ||
- !ftest(libcolour_srgb_decode(c2.rgb.B), c1.srgb.B, 0.00000000001)) {
- printf("libcolour_srgb_decode failed\n"), rc = 0;
- goto colour_spaces_done;
- }
- }
-
- c1.rgb.encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
- c1.rgb.gamma = 2.2;
- c1.rgb.with_gamma = 0;
- c1.rgb.R = 0.25;
- c1.rgb.G = 0.5;
- c1.rgb.B = 0.75;
- c4 = c3 = c2 = c1;
- c2.rgb.with_gamma = c3.srgb.with_gamma = 1;
- c3.rgb.gamma = c4.rgb.gamma = 1.8;
- if (libcolour_convert(&c1, &c2))
- goto fail;
- if (libcolour_convert(&c2, &c3))
- goto fail;
- if (libcolour_convert(&c3, &c4))
- goto fail;
- if (!ftest(c1.rgb.R, c4.srgb.R, 0.0000001) ||
- !ftest(c1.rgb.G, c4.srgb.G, 0.0000001) ||
- !ftest(c1.rgb.B, c4.srgb.B, 0.0000001)) {
- printf("libcolour_convert failed to convert between two transfer functions\n"), rc = 0;
- goto colour_spaces_done;
- }
-
- if (libcolour_convert(&c1, &c4))
- goto fail;
- if (!ftest(c1.rgb.R, c4.srgb.R, 0.0000001) ||
- !ftest(c1.rgb.G, c4.srgb.G, 0.0000001) ||
- !ftest(c1.rgb.B, c4.srgb.B, 0.0000001)) {
- printf("libcolour_convert failed to convert when two different transfer functions are not applied\n"), rc = 0;
- goto colour_spaces_done;
- }
-
-#define TEST(TO, CH1, CH2, CH3, D1, D2, D3)\
- r = test_1convert(&c1, TO, "LIBCOLOUR_SRGB", #TO, CH1, CH2, CH3, D1, D2, D3);\
- if (r < 0)\
- goto fail;\
- if (!r)\
- rc = 1;
-
- c1.model = LIBCOLOUR_SRGB;
- c1.srgb.with_gamma = 0;
- c1.srgb.R = 0.3, c1.srgb.G = 0.2, c1.srgb.B = 0.7;
- TEST(LIBCOLOUR_CIEXYZ, 0.321558, 0.257355, 0.694851, 0.000001, 00000001, 0.000001);
- TEST(LIBCOLOUR_CIEXYY, 0.252447, 0.202043, 0.257355, 0.000001, 0.000001, 0.000001);
- TEST(LIBCOLOUR_CIELAB, 57.7851, 30.3599, -44.9740, 0.0001, 0.0001, 0.0001);
- TEST(LIBCOLOUR_CIELUV, 57.7851, 5.5723, -74.1571, 0.0001, 0.0001, 0.0001);
- TEST(LIBCOLOUR_CIELCHUV, 57.7851, 74.3662, 274.2972, 0.0001, 0.0001, 0.0001);
- /*
- * TODO convert test from sRGB to:
- * LChab 57.7851, 54.2622, 304.0215
- * YDbDr
- * YPbPr
- * YCgCo
- * CIE 1960 UCS
- * CIEUVW
- */
- c1.srgb.with_gamma = 0;
- c1.srgb.R = 32 / 255., c1.srgb.G = 65 / 255., c1.srgb.B = 32 / 255.;
- TEST(LIBCOLOUR_YIQ, 0.201, -0.035, -0.068, 0.001, 0.001, 0.001);
- TEST(LIBCOLOUR_YUV, 0.201, -0.037, -0.067, 0.001, 0.001, 0.001);
- /* XXX YCbCr(60, 118, 116) */
- /* XXX HSV(120, 0.508, 0.255) */
- /* XXX HSI(120, 0.256, 0.169) */
- /* XXX HSL(120, 0.340, 0.190) */
-
- if (rc)
- goto colour_spaces_done;
-
-#undef TEST
- colour_spaces_done:
-
- memset(&c1, 0, sizeof(c1));
- memset(&c2, 0, sizeof(c2));
- c1.model = LIBCOLOUR_RGB;
- if (libcolour_get_rgb_colour_space(&c1.rgb, LIBCOLOUR_RGB_COLOUR_SPACE_ECI_RGB_V2))
- goto fail;
- c3 = c1;
- c1.rgb.to_encoded_red = NULL;
- c1.rgb.to_encoded_green = NULL;
- c1.rgb.to_encoded_blue = NULL;
- c1.rgb.to_decoded_red = NULL;
- c1.rgb.to_decoded_green = NULL;
- c1.rgb.to_decoded_blue = NULL;
- if (libcolour_marshal(&c1, NULL) > sizeof(buf)) {
- printf("libcolour_marshal failed\n"), rc = 0;
- goto marshal_done;
- }
- n = libcolour_marshal(&c1, buf);
- if (n > sizeof(buf)) {
- printf("libcolour_marshal failed\n"), rc = 0;
- goto marshal_done;
- }
- if (libcolour_unmarshal(NULL, buf) != n) {
- printf("libcolour_unmarshal failed\n"), rc = 0;
- goto marshal_done;
- }
- if (libcolour_unmarshal(&c2, buf) != n) {
- printf("libcolour_unmarshal failed\n"), rc = 0;
- goto marshal_done;
- }
- if (memcmp(&c2, &c3, sizeof(c2))) {
- printf("libcolour_(un)marshal failed\n"), rc = 0;
- goto marshal_done;
- }
- marshal_done:
-
- return rc;
- fail:
- perror(*argv);
- return 2;
- (void) argc;
-}
diff --git a/test.c b/test.c
new file mode 100644
index 0000000..f6fb2e1
--- /dev/null
+++ b/test.c
@@ -0,0 +1,658 @@
+/* See LICENSE file for copyright and license details. */
+#include "libcolour.h"
+
+#include <math.h>
+#include <stdio.h>
+#include <string.h>
+
+
+#undef libcolour_unmarshal
+
+#define libcolour_colour_t libcolour_colour_lf_t
+#define libcolour_rgb_t libcolour_rgb_lf_t
+#define libcolour_unmarshal libcolour_unmarshal_lf
+
+
+#ifndef SKIP_2CONVERT
+static int
+test_2convert(libcolour_colour_t *c1, libcolour_colour_t *c2, libcolour_colour_t *c3)
+{
+ double ch1, ch2, ch3;
+ if (libcolour_convert(c1, c2))
+ return -1;
+ if (libcolour_convert(c2, c3))
+ return -1;
+ if ((c1->model == LIBCOLOUR_CIELCHUV) &&
+ !isnan(c1->cielchuv.h) && !isnan(c3->cielchuv.h) &&
+ !isinf(c1->cielchuv.h) && !isinf(c3->cielchuv.h) &&
+ (c3->cielchuv.h / c3->cielchuv.one_revolution > 0.99999))
+ c3->cielchuv.h = 0;
+ ch1 = c1->srgb.R - c3->srgb.R;
+ ch2 = c1->srgb.G - c3->srgb.G;
+ ch3 = c1->srgb.B - c3->srgb.B;
+ ch1 *= ch1;
+ ch2 *= ch2;
+ ch3 *= ch3;
+ switch (c1->model) {
+ case LIBCOLOUR_CIEXYY:
+ if (c1->ciexyy.Y == 0)
+ ch1 = ch2 = 0;
+ if (c1->ciexyy.y == 0)
+ ch1 = ch2 = ch3 = 0;
+ break;
+ case LIBCOLOUR_CIEXYZ:
+ if (c1->ciexyz.Y == 0)
+ ch1 = ch3 = 0;
+ break;
+ case LIBCOLOUR_CIE1960UCS:
+ if (c1->cie1960ucs.v == 0)
+ ch1 = ch2 = ch3 = 0;
+ if (c1->cie1960ucs.Y == 0)
+ ch1 = ch2 = 0;
+ break;
+ case LIBCOLOUR_CIEUVW:
+ if (c1->cieuvw.W == 0)
+ ch1 = ch2 = 0;
+ break;
+ case LIBCOLOUR_CIELCHUV:
+ if (c1->cielchuv.C == 0)
+ ch1 = ch3 = 0;
+ break;
+ case LIBCOLOUR_CIELAB:
+ if (c1->cielchuv.L == 0)
+ ch2 = ch3 = 0;
+ break;
+ default:
+ break;
+ }
+ if (ch1 > 0.000001 ||
+ ch2 > 0.000001 ||
+ ch3 > 0.000001)
+ return 0;
+ return 1;
+}
+
+
+static int
+test_2convert_11(libcolour_colour_t *c1, libcolour_model_t model)
+{
+ libcolour_colour_t c2, c3;
+ int r1, r2;
+ c3 = *c1;
+ c2.model = model;
+ switch (model) {
+ case LIBCOLOUR_RGB:
+ c2.rgb.with_transfer = 0;
+ if (libcolour_get_rgb_colour_space(&c2.rgb, LIBCOLOUR_RGB_COLOUR_SPACE_SRGB) < 0)
+ return -1;
+ return test_2convert(c1, &c2, &c3);
+ case LIBCOLOUR_SRGB:
+ c2.srgb.with_transfer = 0;
+ if (r1 = test_2convert(c1, &c2, &c3), r1 < 0)
+ return -1;
+ c2.srgb.with_transfer = 1;
+ if (r2 = test_2convert(c1, &c2, &c3), r2 < 0)
+ return -1;
+ return r1 & r2;
+ case LIBCOLOUR_CIELCHUV:
+ c2.cielchuv.one_revolution = 360.;
+ /* fall though */
+ case LIBCOLOUR_CIELUV:
+ c2.cieluv.white.model = LIBCOLOUR_CIEXYZ;
+ c2.cieluv.white.X = 1.0294;
+ c2.cieluv.white.Y = 1;
+ c2.cieluv.white.Z = 0.9118;
+ return test_2convert(c1, &c2, &c3);
+ case LIBCOLOUR_CIEUVW:
+ c2.cieuvw.u0 = 0.37;
+ c2.cieuvw.v0 = 0.30;
+ return test_2convert(c1, &c2, &c3);
+ default:
+ return test_2convert(c1, &c2, &c3);
+ }
+}
+
+
+static int
+test_2convert_1n(libcolour_model_t model, const char *model_name, double ch1, double ch2, double ch3)
+{
+ libcolour_colour_t c1;
+ int run, r, rc = 1;
+
+ c1.model = model;
+ switch (model) {
+ case LIBCOLOUR_CIELAB:
+ c1.cielab.L = ch1 * 100, c1.cielab.a = ch2 * 100, c1.cielab.b = ch3 * 100;
+ break;
+ case LIBCOLOUR_CIELCHUV:
+ if (ch3 > 0.9999)
+ return 1;
+ /* fall though */
+ default:
+ c1.srgb.R = ch1, c1.srgb.G = ch2, c1.srgb.B = ch3;
+ break;
+ }
+
+ for (run = 0;; run++) {
+ switch (model) {
+ case LIBCOLOUR_RGB:
+ if (run == 2)
+ return rc;
+ c1.rgb.with_transfer = run;
+ if (libcolour_get_rgb_colour_space(&c1.rgb, LIBCOLOUR_RGB_COLOUR_SPACE_SRGB) < 0)
+ return -1;
+ break;
+ case LIBCOLOUR_SRGB:
+ if (run == 2)
+ return rc;
+ c1.srgb.with_transfer = run;
+ break;
+ case LIBCOLOUR_CIELCHUV:
+ c1.cielchuv.one_revolution = run < 2 ? 360. : 2 * 3.14159265358979323846;
+ c1.cielchuv.h *= c1.cielchuv.one_revolution;
+ /* fall through */
+ case LIBCOLOUR_CIELUV:
+ c1.cieluv.white.model = LIBCOLOUR_CIEXYZ;
+ if (run == 0) {
+ c1.cieluv.white.X = 1.0294;
+ c1.cieluv.white.Y = 1;
+ c1.cieluv.white.Z = 0.9118;
+ } else if (run == 1) {
+ c1.cieluv.white.X = 1.03;
+ c1.cieluv.white.Y = 0.8;
+ c1.cieluv.white.Z = 0.92;
+ } else if (run == 2 && model == LIBCOLOUR_CIELCHUV) {
+ c1.cieluv.white.X = 1.0294;
+ c1.cieluv.white.Y = 1;
+ c1.cieluv.white.Z = 0.9118;
+ } else if (run == 3 && model == LIBCOLOUR_CIELCHUV) {
+ c1.cieluv.white.X = 1.03;
+ c1.cieluv.white.Y = 0.8;
+ c1.cieluv.white.Z = 0.92;
+ } else {
+ return rc;
+ }
+ break;
+ case LIBCOLOUR_CIEUVW:
+ if (run == 0) {
+ c1.cieuvw.u0 = 0.37;
+ c1.cieuvw.v0 = 0.30;
+ } else if (run == 1) {
+ c1.cieuvw.u0 = 0.47;
+ c1.cieuvw.v0 = 0.31;
+ } else {
+ return rc;
+ }
+ break;
+ default:
+ if (run == 1)
+ return rc;
+ break;
+ }
+
+#define X(ENUM, T, N)\
+ r = test_2convert_11(&c1, ENUM);\
+ if (r < 0)\
+ return -1;\
+ if (!r)\
+ printf("%s -> %s -> %s failed at run %i with (%lf, %lf, %lf)\n",\
+ model_name, #ENUM, model_name, run, ch1, ch2, ch3), rc = 0;
+ LIBCOLOUR_LIST_MODELS(X,);
+#undef X
+ }
+}
+
+
+static int
+test_2convert_nm(double ch1, double ch2, double ch3)
+{
+ int r, rc = 1;
+
+#define X(ENUM, T, N)\
+ r = test_2convert_1n(ENUM, #ENUM, ch1, ch2, ch3);\
+ if (r < 0)\
+ return -1;\
+ if (!r)\
+ rc = 0;
+ LIBCOLOUR_LIST_MODELS(X,);
+#undef X
+
+ return rc;
+}
+
+
+static int
+test_2convert_nm_all(void)
+{
+#define N 11
+ int r, rc = 1;
+ double ch1, ch2, ch3;
+ int i, j, k;
+
+ for (i = 0; i < N; i++) {
+ for (j = 0; j < N; j++) {
+ for (k = 0; k < N; k++) {
+ ch1 = ((i + N / 2) % N) / (N - 1);
+ ch2 = ((j + N / 2) % N) / (N - 1);
+ ch3 = ((k + N / 2) % N) / (N - 1);
+
+ if (ch1 > 0.999) ch1 = 1;
+ if (ch2 > 0.999) ch2 = 1;
+ if (ch3 > 0.999) ch3 = 1;
+
+ r = test_2convert_nm(ch1, ch2, ch3);
+ if (r < 0)
+ return -1;
+ if (!r)
+ rc = 0;
+ }
+ }
+ }
+
+ return rc;
+#undef N
+}
+#endif
+
+
+static inline int
+ftest(double a, double b, double l)
+{
+ return a - l <= b && b <= a + l;
+}
+
+
+#define test_rgb(COLOUR_SPACE, ...) test_rgb_(COLOUR_SPACE, #COLOUR_SPACE, __VA_ARGS__)
+static int
+test_rgb_(enum libcolour_rgb_colour_space colour_space, const char *name,
+ double r, double g, double b, double x, double y, double z,
+ double xx, double yy, double zz)
+{
+ libcolour_colour_t c1, c2;
+
+ c1.model = LIBCOLOUR_RGB;
+ c2.model = LIBCOLOUR_CIEXYZ;
+ c1.rgb.with_transfer = 0;
+ c1.rgb.R = r, c1.rgb.G = g, c1.rgb.B = b;
+ if (libcolour_get_rgb_colour_space(&c1.rgb, colour_space) ||
+ libcolour_convert(&c1, &c2)) {
+ printf("%s failed without gamma\n", name);
+ return 0;
+ } else if (!ftest(c2.ciexyz.X, x, 0.0001) ||
+ !ftest(c2.ciexyz.Y, y, 0.0001) ||
+ !ftest(c2.ciexyz.Z, z, 0.0001)) {
+ printf("%s failed without gamma\n", name);
+ return 0;
+ }
+
+ c1.model = LIBCOLOUR_RGB;
+ c2.model = LIBCOLOUR_CIEXYZ;
+ c1.rgb.with_transfer = 1;
+ c1.rgb.R = r, c1.rgb.G = g, c1.rgb.B = b;
+ if (libcolour_get_rgb_colour_space(&c1.rgb, colour_space) ||
+ libcolour_convert(&c1, &c2)) {
+ printf("%s failed with gamma\n", name);
+ return 0;
+ } else if (!ftest(c2.ciexyz.X, xx, 0.0001) ||
+ !ftest(c2.ciexyz.Y, yy, 0.0001) ||
+ !ftest(c2.ciexyz.Z, zz, 0.0001)) {
+ printf("%s failed with gamma\n", name);
+ return 0;
+ }
+
+ if (libcolour_convert(&c2, &c1) ||
+ !ftest(c1.rgb.R, r, 0.0000001) ||
+ !ftest(c1.rgb.G, g, 0.0000001) ||
+ !ftest(c1.rgb.B, b, 0.0000001)) {
+ printf("%s failed, encode\n", name);
+ return 0;
+ }
+
+ return 1;
+}
+
+
+static int
+test_1convert(libcolour_colour_t *c1, libcolour_model_t model, const char *name1,
+ const char *name2, double ch1, double ch2, double ch3, double d1,
+ double d2, double d3)
+{
+ libcolour_colour_t c2, c3;
+ int rc = 1;
+ c3 = *c1;
+ c2.model = model;
+ switch (model) {
+ case LIBCOLOUR_CIELCHUV:
+ c2.cielchuv.one_revolution = 360;
+ /* fall-through */
+ case LIBCOLOUR_CIELUV:
+ c2.cieluv.white.X = 0.9504705586542831;
+ c2.cieluv.white.Y = 1;
+ c2.cieluv.white.Z = 1.0888287363958837;
+ break;
+ default:
+ break;
+ }
+ if (libcolour_convert(c1, &c2))
+ return -1;
+ if (!ftest(c2.srgb.R, ch1, d1) ||
+ !ftest(c2.srgb.G, ch2, d2) ||
+ !ftest(c2.srgb.B, ch3, d3)) {
+ printf("%s -> %s failed\n", name1, name2), rc = 0;
+ rc = 0;
+ }
+ if (libcolour_convert(&c2, &c3))
+ return -1;
+ if (!ftest(c3.srgb.R, c1->srgb.R, 0.00000001) ||
+ !ftest(c3.srgb.G, c1->srgb.G, 0.00000001) ||
+ !ftest(c3.srgb.B, c1->srgb.B, 0.00000001)) {
+ printf("%s -> %s failed\n", name2, name1), rc = 0;
+ rc = 0;
+ }
+ return rc;
+}
+
+
+/**
+ * Test libcolour
+ *
+ * @return 0: All tests passed
+ * 1: At least one test fail
+ * 2: An error occurred
+ */
+int
+main(int argc, char *argv[])
+{
+ int r, rc = 0;
+ libcolour_colour_t c1, c2, c3, c4;
+ double t1, t2;
+ size_t n;
+ char buf[sizeof(int) + sizeof(libcolour_rgb_t)];
+
+#ifndef SKIP_2CONVERT
+ r = test_2convert_nm_all();
+ if (r < 0)
+ goto fail;
+ if (!r)
+ rc = 1;
+#else
+ (void) r;
+#endif
+
+ c1.model = LIBCOLOUR_SRGB;
+ c1.srgb.R = 0.02, c1.srgb.G = 0.5, c1.srgb.B = 0.9;
+ c1.srgb.with_transfer = 0;
+ c2.model = LIBCOLOUR_RGB;
+ c2.rgb.with_transfer = 0;
+ if (libcolour_get_rgb_colour_space(&c2.rgb, LIBCOLOUR_RGB_COLOUR_SPACE_SRGB)) {
+ printf("LIBCOLOUR_RGB_COLOUR_SPACE_SRGB failed\n"), rc = 0;
+ goto colour_spaces_done;
+ }
+ if (c2.rgb.white_r != 1 || c2.rgb.white_g != 1 || c2.rgb.white_b != 1 ||
+ c2.rgb.red.model != LIBCOLOUR_CIEXYY || c2.rgb.green.model != LIBCOLOUR_CIEXYY ||
+ c2.rgb.blue.model != LIBCOLOUR_CIEXYY || c2.rgb.white.model != LIBCOLOUR_CIEXYY ||
+ c2.rgb.colour_space != LIBCOLOUR_RGB_COLOUR_SPACE_SRGB || c2.rgb.gamma != 2.4 ||
+ c2.rgb.encoding_type != LIBCOLOUR_ENCODING_TYPE_REGULAR || c2.rgb.slope != 12.92
+ || c2.rgb.offset != 0.055 || c2.rgb.transitioninv != c2.rgb.transition * c2.rgb.slope ||
+ !ftest(c2.rgb.transition, 0.00313067, 0.00000001)) {
+ printf("LIBCOLOUR_RGB_COLOUR_SPACE_SRGB failed\n"), rc = 0;
+ goto colour_spaces_done;
+ }
+ t1 = c2.rgb.transition * c2.rgb.slope;
+ t2 = (1 + c2.rgb.offset) * pow(c2.rgb.transition, 1 / c2.rgb.gamma) - c2.rgb.offset;
+ if (!ftest(t1, t2, 0.0000001) || c2.rgb.white.Y != 1 ||
+ c2.rgb.red.x != 0.64 || c2.rgb.red.y != 0.33 || !ftest(c2.rgb.red.Y, 0.21265, 0.00005) ||
+ c2.rgb.green.x != 0.30 || c2.rgb.green.y != 0.60 || !ftest(c2.rgb.green.Y, 0.71515, 0.00005) ||
+ c2.rgb.blue.x != 0.15 || c2.rgb.blue.y != 0.06 || !ftest(c2.rgb.blue.Y, 0.07215, 0.00005) ||
+ !ftest(c2.rgb.white.x, 0.312727, 0.000001) || !ftest(c2.rgb.white.y, 0.329023, 0.000001) ||
+ !ftest(c2.rgb.red.Y + c2.rgb.green.Y + c2.rgb.blue.Y, 1, 0.00000001)) {
+ printf("LIBCOLOUR_RGB_COLOUR_SPACE_SRGB failed\n"), rc = 0;
+ goto colour_spaces_done;
+ }
+ if (libcolour_convert(&c1, &c2) ||
+ !ftest(c1.srgb.R, c2.rgb.R, 0.0000001) ||
+ !ftest(c1.srgb.G, c2.rgb.G, 0.0000001) ||
+ !ftest(c1.srgb.B, c2.rgb.B, 0.0000001)) {
+ printf("LIBCOLOUR_RGB_COLOUR_SPACE_SRGB failed\n"), rc = 0;
+ goto colour_spaces_done;
+ }
+ if (libcolour_convert(&c2, &c1) ||
+ !ftest(c1.srgb.R, c2.rgb.R, 0.0000001) ||
+ !ftest(c1.srgb.G, c2.rgb.G, 0.0000001) ||
+ !ftest(c1.srgb.B, c2.rgb.B, 0.0000001)) {
+ printf("LIBCOLOUR_RGB_COLOUR_SPACE_SRGB failed\n"), rc = 0;
+ goto colour_spaces_done;
+ }
+
+ c1.model = c2.model = LIBCOLOUR_CIELAB;
+ c1.cielab.L = 30, c2.cielab.L = 80;
+ c1.cielab.a = 40, c2.cielab.a = -10;
+ c1.cielab.b = -50, c2.cielab.b = -40;
+ if (libcolour_delta_e(&c1, &c2, &t1) || !ftest(t1, 71.4142842854285, 0.0000001))
+ printf("libcolour_delta_e failed\n"), rc = 0;
+
+ rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_ADOBE_RGB, 0.3, 0.2, 0.9,
+ 0.379497, 0.282430, 0.914245, 0.195429, 0.098925, 0.790020);
+
+ rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_APPLE_RGB, 0.3, 0.2, 0.9,
+ 0.364212, 0.282789, 0.866008, 0.221570, 0.134028, 0.773782);
+
+ rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_BEST_RGB, 0.3, 0.2, 0.9,
+ 0.345007, 0.246779, 0.736029, 0.151406, 0.064655, 0.647212);
+
+ rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_BETA_RGB, 0.3, 0.2, 0.9,
+ 0.342837, 0.253386, 0.714198, 0.146437, 0.066824, 0.623382);
+
+ rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_BRUCE_RGB, 0.3, 0.2, 0.9,
+ 0.368857, 0.276910, 0.915272, 0.191184, 0.096699, 0.791486);
+
+ rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_CIE_RGB, 0.3, 0.2, 0.9,
+ 0.389293, 0.225188, 0.892857, 0.202678, 0.044608, 0.785312);
+
+ rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_COLORMATCH_RGB, 0.3, 0.2, 0.9,
+ 0.337557, 0.274378, 0.651989, 0.186858, 0.123210, 0.581381);
+
+ rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_DON_RGB_4, 0.3, 0.2, 0.9,
+ 0.344990, 0.251411, 0.727872, 0.150504, 0.066348, 0.638058);
+
+ rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_ECI_RGB, 0.3, 0.2, 0.9,
+ 0.353021, 0.286400, 0.695202, 0.196733, 0.134157, 0.630279);
+
+ rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_ECI_RGB_V2, 0.3, 0.2, 0.9,
+ 0.353021, 0.286400, 0.695202, 0.149594, 0.097238, 0.579927);
+
+ rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_EKTA_SPACE_PS5, 0.3, 0.2, 0.9,
+ 0.320377, 0.229160, 0.713291, 0.127134, 0.043253, 0.622392);
+
+ rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_NTSC_RGB, 0.3, 0.2, 0.9,
+ 0.397081, 0.310031, 1.017821, 0.235650, 0.156675, 0.906707);
+
+ rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_PAL_SECAM_RGB, 0.3, 0.2, 0.9,
+ 0.357972, 0.272130, 0.877151, 0.208580, 0.120322, 0.769056);
+
+ rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_PROPHOTO_RGB, 0.3, 0.2, 0.9,
+ 0.294559, 0.228864, 0.742689, 0.124735, 0.072340, 0.682655);
+
+ rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_SMPTE_C_RGB, 0.3, 0.2, 0.9,
+ 0.363595, 0.281822, 0.890350, 0.216773, 0.131311, 0.783348);
+
+ rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_WIDE_GAMUT_RGB, 0.3, 0.2, 0.9,
+ 0.367485, 0.237631, 0.706442, 0.170318, 0.052665, 0.614915);
+
+ rc &= test_rgb(LIBCOLOUR_RGB_COLOUR_SPACE_LIGHTROOM_RGB, 0.3, 0.2, 0.9,
+ 0.294559, 0.228864, 0.742689, 0.294559, 0.228864, 0.742689);
+
+ /*
+ TODO test LIBCOLOUR_RGB_COLOUR_SPACE_DCI_P3_D65
+ TODO test LIBCOLOUR_RGB_COLOUR_SPACE_DCI_P3_THEATER
+ TODO test LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_601_625_LINE
+ TODO test LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_601_525_LINE
+ TODO test LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_709
+ TODO test LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2020
+ TODO test LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_EOTF_PQ
+ TODO test LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OOTF_PQ
+ TODO test LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OETF_PQ
+ TODO test LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_EOTF_HLG
+ TODO test LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OOTF_HLG
+ TODO test LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OETF_HLG
+ TODO test LIBCOLOUR_RGB_COLOUR_SPACE_SGI_RGB
+ TODO test LIBCOLOUR_RGB_COLOUR_SPACE_SMPTE_240M_RGB
+
+ TODO test LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_MEASUREMENTS
+ TODO test LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_MATRIX
+ TODO test LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_INV_MATRIX
+ */
+
+ /* TODO test transfer functions more rigorously */
+
+ c1.model = c2.model = LIBCOLOUR_RGB;
+ c3.model = c4.model = LIBCOLOUR_SRGB;
+ c1.rgb.with_transfer = c3.srgb.with_transfer = 0;
+ c2.rgb.with_transfer = c4.srgb.with_transfer = 1;
+ if (libcolour_get_rgb_colour_space(&c1.rgb, LIBCOLOUR_RGB_COLOUR_SPACE_SRGB))
+ goto fail;
+ if (libcolour_get_rgb_colour_space(&c2.rgb, LIBCOLOUR_RGB_COLOUR_SPACE_SRGB))
+ goto fail;
+ for (t1 = 0; t1 <= 1; t1 += 0.001) {
+ c1.rgb.R = c3.srgb.R = t1 - 1;
+ c1.rgb.G = c3.srgb.G = t1;
+ c1.rgb.B = c3.srgb.B = t1 + 1;
+ if (libcolour_convert(&c1, &c2))
+ goto fail;
+ if (libcolour_convert(&c3, &c4))
+ goto fail;
+ if (!ftest(c2.rgb.R, c4.srgb.R, 0.00000000001) ||
+ !ftest(c2.rgb.G, c4.srgb.G, 0.00000000001) ||
+ !ftest(c2.rgb.B, c4.srgb.B, 0.00000000001) ||
+ !ftest(libcolour_srgb_encode(c1.rgb.R), c2.srgb.R, 0.00000000001) ||
+ !ftest(libcolour_srgb_encode(c1.rgb.G), c2.srgb.G, 0.00000000001) ||
+ !ftest(libcolour_srgb_encode(c1.rgb.B), c2.srgb.B, 0.00000000001)) {
+ printf("libcolour_srgb_encode failed\n"), rc = 0;
+ goto colour_spaces_done;
+ }
+ if (libcolour_convert(&c2, &c1))
+ goto fail;
+ if (libcolour_convert(&c4, &c3))
+ goto fail;
+ if (!ftest(c1.rgb.R, c3.srgb.R, 0.00000000001) ||
+ !ftest(c1.rgb.G, c3.srgb.G, 0.00000000001) ||
+ !ftest(c1.rgb.B, c3.srgb.B, 0.00000000001) ||
+ !ftest(libcolour_srgb_decode(c2.rgb.R), c1.srgb.R, 0.00000000001) ||
+ !ftest(libcolour_srgb_decode(c2.rgb.G), c1.srgb.G, 0.00000000001) ||
+ !ftest(libcolour_srgb_decode(c2.rgb.B), c1.srgb.B, 0.00000000001)) {
+ printf("libcolour_srgb_decode failed\n"), rc = 0;
+ goto colour_spaces_done;
+ }
+ }
+
+ c1.rgb.encoding_type = LIBCOLOUR_ENCODING_TYPE_SIMPLE;
+ c1.rgb.gamma = 2.2;
+ c1.rgb.with_transfer = 0;
+ c1.rgb.R = 0.25;
+ c1.rgb.G = 0.5;
+ c1.rgb.B = 0.75;
+ c4 = c3 = c2 = c1;
+ c2.rgb.with_transfer = c3.srgb.with_transfer = 1;
+ c3.rgb.gamma = c4.rgb.gamma = 1.8;
+ if (libcolour_convert(&c1, &c2))
+ goto fail;
+ if (libcolour_convert(&c2, &c3))
+ goto fail;
+ if (libcolour_convert(&c3, &c4))
+ goto fail;
+ if (!ftest(c1.rgb.R, c4.srgb.R, 0.0000001) ||
+ !ftest(c1.rgb.G, c4.srgb.G, 0.0000001) ||
+ !ftest(c1.rgb.B, c4.srgb.B, 0.0000001)) {
+ printf("libcolour_convert failed to convert between two transfer functions\n"), rc = 0;
+ goto colour_spaces_done;
+ }
+
+ if (libcolour_convert(&c1, &c4))
+ goto fail;
+ if (!ftest(c1.rgb.R, c4.srgb.R, 0.0000001) ||
+ !ftest(c1.rgb.G, c4.srgb.G, 0.0000001) ||
+ !ftest(c1.rgb.B, c4.srgb.B, 0.0000001)) {
+ printf("libcolour_convert failed to convert when two different transfer functions are not applied\n"), rc = 0;
+ goto colour_spaces_done;
+ }
+
+#define TEST(TO, CH1, CH2, CH3, D1, D2, D3)\
+ r = test_1convert(&c1, TO, "LIBCOLOUR_SRGB", #TO, CH1, CH2, CH3, D1, D2, D3);\
+ if (r < 0)\
+ goto fail;\
+ if (!r)\
+ rc = 1;
+
+ c1.model = LIBCOLOUR_SRGB;
+ c1.srgb.with_transfer = 0;
+ c1.srgb.R = 0.3, c1.srgb.G = 0.2, c1.srgb.B = 0.7;
+ TEST(LIBCOLOUR_CIEXYZ, 0.321558, 0.257355, 0.694851, 0.000001, 0.000001, 0.000001);
+ TEST(LIBCOLOUR_CIEXYY, 0.252447, 0.202043, 0.257355, 0.000001, 0.000001, 0.000001);
+ TEST(LIBCOLOUR_CIELAB, 57.7851, 30.3599, -44.9740, 0.0001, 0.0001, 0.0001);
+ TEST(LIBCOLOUR_CIELUV, 57.7851, 5.5723, -74.1571, 0.0001, 0.0001, 0.0001);
+ TEST(LIBCOLOUR_CIELCHUV, 57.7851, 74.3662, 274.2972, 0.0001, 0.0001, 0.0001);
+ /*
+ * TODO convert test from sRGB to:
+ * LChab 57.7851, 54.2622, 304.0215
+ * YDbDr
+ * YPbPr
+ * YCgCo
+ * CIE 1960 UCS
+ * CIEUVW
+ */
+ c1.srgb.with_transfer = 0;
+ c1.srgb.R = 32 / 255., c1.srgb.G = 65 / 255., c1.srgb.B = 32 / 255.;
+ TEST(LIBCOLOUR_YIQ, 0.201, -0.035, -0.068, 0.001, 0.001, 0.001);
+ TEST(LIBCOLOUR_YUV, 0.201, -0.037, -0.067, 0.001, 0.001, 0.001);
+ /* XXX YCbCr(60, 118, 116) */
+ /* XXX HSV(120, 0.508, 0.255) */
+ /* XXX HSI(120, 0.256, 0.169) */
+ /* XXX HSL(120, 0.340, 0.190) */
+
+ if (rc)
+ goto colour_spaces_done;
+
+#undef TEST
+colour_spaces_done:
+
+ memset(&c1, 0, sizeof(c1));
+ memset(&c2, 0, sizeof(c2));
+ c1.model = LIBCOLOUR_RGB;
+ if (libcolour_get_rgb_colour_space(&c1.rgb, LIBCOLOUR_RGB_COLOUR_SPACE_ECI_RGB_V2))
+ goto fail;
+ c3 = c1;
+ c1.rgb.to_encoded_red = NULL;
+ c1.rgb.to_encoded_green = NULL;
+ c1.rgb.to_encoded_blue = NULL;
+ c1.rgb.to_decoded_red = NULL;
+ c1.rgb.to_decoded_green = NULL;
+ c1.rgb.to_decoded_blue = NULL;
+ if (libcolour_marshal(&c1, NULL) > sizeof(buf)) {
+ printf("libcolour_marshal failed\n"), rc = 0;
+ goto marshal_done;
+ }
+ n = libcolour_marshal(&c1, buf);
+ if (n > sizeof(buf)) {
+ printf("libcolour_marshal failed\n"), rc = 0;
+ goto marshal_done;
+ }
+ if (libcolour_unmarshal(NULL, buf) != n) {
+ printf("libcolour_unmarshal failed\n"), rc = 0;
+ goto marshal_done;
+ }
+ if (libcolour_unmarshal(&c2, buf) != n) {
+ printf("libcolour_unmarshal failed\n"), rc = 0;
+ goto marshal_done;
+ }
+ if (memcmp(&c2, &c3, sizeof(c2))) {
+ printf("libcolour_(un)marshal failed\n"), rc = 0;
+ goto marshal_done;
+ }
+ marshal_done:
+
+ return rc;
+ fail:
+ perror(*argv);
+ return 2;
+ (void) argc;
+}