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(aarch64_target_feature, arm_target_feature, raw_ref_op)
14 )]
15 
16 /// These values match the Rendering Intent values from the ICC spec
17 #[repr(u32)]
18 #[derive(Clone, Copy, Debug)]
19 pub enum Intent {
20     AbsoluteColorimetric = 3,
21     Saturation = 2,
22     RelativeColorimetric = 1,
23     Perceptual = 0,
24 }
25 
26 use Intent::*;
27 
28 impl Default for Intent {
default() -> Self29     fn default() -> Self {
30         /* Chris Murphy (CM consultant) suggests this as a default in the event that we
31          * cannot reproduce relative + Black Point Compensation.  BPC brings an
32          * unacceptable performance overhead, so we go with perceptual. */
33         Perceptual
34     }
35 }
36 
37 pub(crate) type s15Fixed16Number = i32;
38 
39 /* produces the nearest float to 'a' with a maximum error
40  * of 1/1024 which happens for large values like 0x40000040 */
41 #[inline]
s15Fixed16Number_to_float(a: s15Fixed16Number) -> f3242 fn s15Fixed16Number_to_float(a: s15Fixed16Number) -> f32 {
43     a as f32 / 65536.0
44 }
45 
46 #[inline]
double_to_s15Fixed16Number(v: f64) -> s15Fixed16Number47 fn double_to_s15Fixed16Number(v: f64) -> s15Fixed16Number {
48     (v * 65536f64) as i32
49 }
50 
51 #[cfg(feature = "c_bindings")]
52 extern crate libc;
53 #[cfg(feature = "c_bindings")]
54 pub mod c_bindings;
55 mod chain;
56 mod gtest;
57 mod iccread;
58 mod matrix;
59 mod transform;
60 pub use iccread::qcms_CIE_xyY as CIE_xyY;
61 pub use iccread::qcms_CIE_xyYTRIPLE as CIE_xyYTRIPLE;
62 pub use iccread::Profile;
63 pub use transform::DataType;
64 pub use transform::Transform;
65 #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
66 mod transform_avx;
67 #[cfg(all(any(target_arch = "aarch64", target_arch = "arm"), feature = "neon"))]
68 mod transform_neon;
69 #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
70 mod transform_sse2;
71 mod transform_util;
72