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