qcms/
lib.rs

1/*! A pure Rust color management library.
2*/
3
4#![allow(dead_code)]
5#![allow(non_camel_case_types)]
6#![allow(non_snake_case)]
7#![allow(non_upper_case_globals)]
8// These are needed for the neon SIMD code and can be removed once the MSRV supports the
9// instrinsics we use
10#![cfg_attr(feature = "neon", feature(stdsimd))]
11#![cfg_attr(
12    feature = "neon",
13    feature(arm_target_feature, raw_ref_op)
14
15)]
16
17/// These values match the Rendering Intent values from the ICC spec
18#[repr(C)]
19#[derive(Clone, Copy, Debug)]
20pub enum Intent {
21    AbsoluteColorimetric = 3,
22    Saturation = 2,
23    RelativeColorimetric = 1,
24    Perceptual = 0,
25}
26
27use Intent::*;
28
29impl Default for Intent {
30    fn default() -> Self {
31        /* Chris Murphy (CM consultant) suggests this as a default in the event that we
32         * cannot reproduce relative + Black Point Compensation.  BPC brings an
33         * unacceptable performance overhead, so we go with perceptual. */
34        Perceptual
35    }
36}
37
38pub(crate) type s15Fixed16Number = i32;
39
40/* produces the nearest float to 'a' with a maximum error
41 * of 1/1024 which happens for large values like 0x40000040 */
42#[inline]
43fn s15Fixed16Number_to_float(a: s15Fixed16Number) -> f32 {
44    a as f32 / 65536.0
45}
46
47#[inline]
48fn double_to_s15Fixed16Number(v: f64) -> s15Fixed16Number {
49    (v * 65536f64) as i32
50}
51
52#[cfg(feature = "c_bindings")]
53extern crate libc;
54#[cfg(feature = "c_bindings")]
55pub mod c_bindings;
56mod chain;
57mod gtest;
58mod iccread;
59mod matrix;
60mod transform;
61pub use iccread::qcms_CIE_xyY as CIE_xyY;
62pub use iccread::qcms_CIE_xyYTRIPLE as CIE_xyYTRIPLE;
63pub use iccread::Profile;
64pub use transform::DataType;
65pub use transform::Transform;
66#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
67mod transform_avx;
68#[cfg(all(any(target_arch = "aarch64", target_arch = "arm"), feature = "neon"))]
69mod transform_neon;
70#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
71mod transform_sse2;
72mod transform_util;