Skip to main content

ocio_rs/
types.rs

1use std::fmt;
2
3/// Direction in which an OCIO transform or processor is evaluated.
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5#[repr(i32)]
6pub enum TransformDirection {
7    Forward = 0,
8    Inverse = 1,
9}
10
11impl fmt::Display for TransformDirection {
12    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
13        match self {
14            TransformDirection::Forward => write!(f, "forward"),
15            TransformDirection::Inverse => write!(f, "inverse"),
16        }
17    }
18}
19
20/// Reference space domain used by a color space or view transform.
21#[derive(Debug, Clone, Copy, PartialEq, Eq)]
22#[repr(i32)]
23pub enum ReferenceSpaceType {
24    Scene = 0,
25    Display = 1,
26}
27
28/// Domain filter used when searching for a color space.
29#[derive(Debug, Clone, Copy, PartialEq, Eq)]
30#[repr(i32)]
31pub enum SearchReferenceSpaceType {
32    Scene = 0,
33    Display = 1,
34    All = 2,
35}
36
37/// Visibility filter for color-space enumeration.
38#[derive(Debug, Clone, Copy, PartialEq, Eq)]
39#[repr(i32)]
40pub enum ColorSpaceVisibility {
41    Active = 0,
42    Inactive = 1,
43    All = 2,
44}
45
46/// Runtime OCIO transform subtype represented by a generic transform handle.
47#[derive(Debug, Clone, Copy, PartialEq, Eq)]
48#[repr(i32)]
49pub enum TransformType {
50    Allocation = 0,
51    Builtin = 1,
52    Cdl = 2,
53    ColorSpace = 3,
54    DisplayView = 4,
55    Exponent = 5,
56    ExponentWithLinear = 6,
57    ExposureContrast = 7,
58    File = 8,
59    FixedFunction = 9,
60    #[cfg(feature = "v2_5")]
61    GradingHueCurve = 10,
62    GradingPrimary = 11,
63    GradingRgbCurve = 12,
64    GradingTone = 13,
65    Group = 14,
66    LogAffine = 15,
67    LogCamera = 16,
68    Log = 17,
69    Look = 18,
70    Lut1D = 19,
71    Lut3D = 20,
72    Matrix = 21,
73    Range = 22,
74}
75
76impl fmt::Display for TransformType {
77    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
78        fmt::Debug::fmt(self, f)
79    }
80}
81
82/// Interpolation algorithm used by LUT and related transforms.
83#[derive(Debug, Clone, Copy, PartialEq, Eq)]
84#[repr(i32)]
85pub enum Interpolation {
86    Unknown = 0,
87    Nearest = 1,
88    Linear = 2,
89    Tetrahedral = 3,
90    Cubic = 4,
91    // OCIO deliberately numbers the "meta" modes apart from the real ones.
92    Default = 254,
93    Best = 255,
94}
95
96/// Pixel sample bit depth understood by OCIO processors.
97#[derive(Debug, Clone, Copy, PartialEq, Eq)]
98#[repr(i32)]
99pub enum BitDepth {
100    Unknown = 0,
101    Uint8 = 1,
102    Uint10 = 2,
103    Uint12 = 3,
104    Uint14 = 4,
105    Uint16 = 5,
106    Uint32 = 6,
107    F16 = 7,
108    F32 = 8,
109}
110
111/// Allocation domain used to map image values for processing.
112#[derive(Debug, Clone, Copy, PartialEq, Eq)]
113#[repr(i32)]
114pub enum Allocation {
115    Unknown = 0,
116    Uniform = 1,
117    Lg2 = 2,
118}
119
120/// Target shading language for OCIO GPU shader extraction.
121#[derive(Debug, Clone, Copy, PartialEq, Eq)]
122#[repr(i32)]
123pub enum GpuLanguage {
124    Cg = 0,
125    Glsl1_2 = 1,
126    Glsl1_3 = 2,
127    Glsl4_0 = 3,
128    #[cfg(feature = "v2_5")]
129    GlslVk4_6 = 4,
130    HlslSm5_0 = 5,
131    Osl1 = 6,
132    GlslEs1_0 = 7,
133    GlslEs3_0 = 8,
134    Msl2_0 = 9,
135}
136
137/// Policy used to populate OCIO context variables from the environment.
138#[derive(Debug, Clone, Copy, PartialEq, Eq)]
139#[repr(i32)]
140pub enum EnvironmentMode {
141    /// No recognized environment-loading policy.
142    Unknown = 0,
143    /// Load only variables declared in the configuration.
144    LoadPredefined = 1,
145    /// Load all variables from the process environment.
146    LoadAll = 2,
147}
148
149/// Whether a range transform clamps values at its domain boundaries.
150#[derive(Debug, Clone, Copy, PartialEq, Eq)]
151#[repr(i32)]
152pub enum RangeStyle {
153    NoClamp = 0,
154    Clamp = 1,
155}
156
157/// Built-in OCIO fixed-function transform style.
158#[derive(Debug, Clone, Copy, PartialEq, Eq)]
159#[repr(i32)]
160pub enum FixedFunctionStyle {
161    AcesRedMod03 = 0,
162    AcesRedMod10 = 1,
163    AcesGlow03 = 2,
164    AcesGlow10 = 3,
165    AcesDarkToDim10 = 4,
166    Rec2100Surround = 5,
167    RgbToHsv = 6,
168    XyzToxyY = 7,
169    XyzTouvY = 8,
170    XyzToLuv = 9,
171    AcesGamutMap02 = 10,
172    AcesGamutMap07 = 11,
173    AcesGamutCompress13 = 12,
174    LinToPq = 13,
175    LinToGammaLog = 14,
176    LinToDoubleLog = 15,
177    AcesOutputTransform20 = 16,
178    AcesRgbToJmh20 = 17,
179    AcesTonescaleCompress20 = 18,
180    AcesGamutCompress20 = 19,
181    #[cfg(feature = "v2_5")]
182    RgbToHsyLin = 20,
183    #[cfg(feature = "v2_5")]
184    RgbToHsyLog = 21,
185    #[cfg(feature = "v2_5")]
186    RgbToHsyVid = 22,
187    #[cfg(feature = "v2_6")]
188    AcesRgbToHmj20 = 23,
189}
190
191/// Domain in which exposure/contrast parameters are applied.
192#[derive(Debug, Clone, Copy, PartialEq, Eq)]
193#[repr(i32)]
194pub enum ExposureContrastStyle {
195    Linear = 0,
196    Video = 1,
197    Logarithmic = 2,
198}
199
200/// ASC CDL clamping behavior.
201#[derive(Debug, Clone, Copy, PartialEq, Eq)]
202#[repr(i32)]
203pub enum CDLStyle {
204    Asc = 0,
205    NoClamp = 1,
206}
207
208/// Treatment of negative values for transforms that require a policy.
209#[derive(Debug, Clone, Copy, PartialEq, Eq)]
210#[repr(i32)]
211pub enum NegativeStyle {
212    Clamp = 0,
213    Mirror = 1,
214    PassThru = 2,
215    Linear = 3,
216}
217
218/// One of the RGB or master curves in a grading RGB curve transform.
219#[derive(Debug, Clone, Copy, PartialEq, Eq)]
220#[repr(i32)]
221pub enum RGBCurveType {
222    Red = 0,
223    Green = 1,
224    Blue = 2,
225    Master = 3,
226}
227
228/// One of OCIO's hue-dependent grading curve families.
229#[cfg(feature = "v2_5")]
230#[cfg_attr(docsrs, doc(cfg(feature = "v2_5")))]
231#[derive(Debug, Clone, Copy, PartialEq, Eq)]
232#[repr(i32)]
233pub enum HueCurveType {
234    HueHue = 0,
235    HueSat = 1,
236    HueLum = 2,
237    LumSat = 3,
238    SatSat = 4,
239    LumLum = 5,
240    SatLum = 6,
241    HueFx = 7,
242}
243
244/// HSY conversion style used by hue-curve operations.
245#[cfg(feature = "v2_5")]
246#[cfg_attr(docsrs, doc(cfg(feature = "v2_5")))]
247#[derive(Debug, Clone, Copy, PartialEq, Eq)]
248#[repr(i32)]
249pub enum HSYTransformStyle {
250    None = 0,
251    Default = 1,
252}
253
254/// Grading domain used by OCIO grading transforms and values.
255#[derive(Debug, Clone, Copy, PartialEq, Eq)]
256#[repr(i32)]
257pub enum GradingStyle {
258    Log = 0,
259    Lin = 1,
260    Video = 2,
261}
262
263/// Bit flags selecting processor optimization passes.
264#[derive(Debug, Clone, Copy, PartialEq, Eq)]
265pub struct OptimizationFlags(pub u32);
266
267impl OptimizationFlags {
268    pub const NONE: Self = Self(0x00000000);
269    pub const IDENTITY: Self = Self(0x00000001);
270    pub const IDENTITY_GAMMA: Self = Self(0x00000002);
271    pub const PAIR_IDENTITY_CDL: Self = Self(0x00000040);
272    pub const PAIR_IDENTITY_EXPOSURE_CONTRAST: Self = Self(0x00000080);
273    pub const PAIR_IDENTITY_FIXED_FUNCTION: Self = Self(0x00000100);
274    pub const PAIR_IDENTITY_GAMMA: Self = Self(0x00000200);
275    pub const PAIR_IDENTITY_LUT1D: Self = Self(0x00000400);
276    pub const PAIR_IDENTITY_LUT3D: Self = Self(0x00000800);
277    pub const PAIR_IDENTITY_LOG: Self = Self(0x00001000);
278    pub const PAIR_IDENTITY_GRADING: Self = Self(0x00002000);
279    pub const COMP_EXPONENT: Self = Self(0x00040000);
280    pub const COMP_GAMMA: Self = Self(0x00080000);
281    pub const COMP_MATRIX: Self = Self(0x00100000);
282    pub const COMP_LUT1D: Self = Self(0x00200000);
283    pub const COMP_LUT3D: Self = Self(0x00400000);
284    pub const COMP_RANGE: Self = Self(0x00800000);
285    pub const COMP_SEPARABLE_PREFIX: Self = Self(0x01000000);
286    pub const LUT_INV_FAST: Self = Self(0x02000000);
287    pub const FAST_LOG_EXP_POW: Self = Self(0x04000000);
288    pub const SIMPLIFY_OPS: Self = Self(0x08000000);
289    pub const NO_DYNAMIC_PROPERTIES: Self = Self(0x10000000);
290    pub const LOSSLESS: Self = Self(
291        Self::IDENTITY.0
292            | Self::IDENTITY_GAMMA.0
293            | Self::PAIR_IDENTITY_CDL.0
294            | Self::PAIR_IDENTITY_EXPOSURE_CONTRAST.0
295            | Self::PAIR_IDENTITY_FIXED_FUNCTION.0
296            | Self::PAIR_IDENTITY_GAMMA.0
297            | Self::PAIR_IDENTITY_GRADING.0
298            | Self::PAIR_IDENTITY_LOG.0
299            | Self::PAIR_IDENTITY_LUT1D.0
300            | Self::PAIR_IDENTITY_LUT3D.0
301            | Self::COMP_EXPONENT.0
302            | Self::COMP_GAMMA.0
303            | Self::COMP_MATRIX.0
304            | Self::COMP_RANGE.0
305            | Self::SIMPLIFY_OPS.0,
306    );
307    pub const VERY_GOOD: Self = Self(
308        Self::LOSSLESS.0
309            | Self::COMP_LUT1D.0
310            | Self::LUT_INV_FAST.0
311            | Self::FAST_LOG_EXP_POW.0
312            | Self::COMP_SEPARABLE_PREFIX.0,
313    );
314    pub const GOOD: Self = Self(Self::VERY_GOOD.0 | Self::COMP_LUT3D.0);
315    pub const ALL: Self = Self(0xFFFFFFFF);
316    pub const DRAFT: Self = Self::ALL;
317    pub const DEFAULT: Self = Self::VERY_GOOD;
318}
319
320impl std::ops::BitOr for OptimizationFlags {
321    type Output = Self;
322    fn bitor(self, rhs: Self) -> Self::Output {
323        Self(self.0 | rhs.0)
324    }
325}
326
327/// Verbosity level for OCIO's process-global diagnostic logging.
328#[derive(Debug, Clone, Copy, PartialEq, Eq)]
329#[repr(i32)]
330pub enum LoggingLevel {
331    None = 0,
332    Warning = 1,
333    Info = 2,
334    Debug = 3,
335    /// OCIO has no trace level. Retained for source compatibility; logging
336    /// operations reject this value instead of passing it to the native API.
337    #[deprecated(note = "OpenColorIO does not define a trace logging level")]
338    Trace = 4,
339    /// OCIO's sentinel for an unrecognized level.
340    Unknown = 255,
341}
342
343/// Bit flags controlling config-level processor-cache behavior.
344#[derive(Debug, Clone, Copy, PartialEq, Eq)]
345pub struct ProcessorCacheFlags(pub u32);
346
347impl ProcessorCacheFlags {
348    pub const OFF: Self = Self(0x00000000);
349    pub const ENABLED: Self = Self(0x00000001);
350    pub const SHARE_DYN_PROPERTIES: Self = Self(0x00000002);
351    /// Native default: cache processors and share dynamic properties.
352    ///
353    /// A cached processor's dynamic property values may have been changed by
354    /// another user of that processor; set the desired values before processing.
355    pub const DEFAULT: Self = Self(Self::ENABLED.0 | Self::SHARE_DYN_PROPERTIES.0);
356}
357
358impl std::ops::BitOr for ProcessorCacheFlags {
359    type Output = Self;
360    fn bitor(self, rhs: Self) -> Self::Output {
361        Self(self.0 | rhs.0)
362    }
363}
364
365/// Origin of a display/view entry in a config.
366#[derive(Debug, Clone, Copy, PartialEq, Eq)]
367#[repr(i32)]
368pub enum ViewType {
369    Shared = 0,
370    DisplayDefined = 1,
371}
372
373/// Direction between a color space and its reference space.
374#[derive(Debug, Clone, Copy, PartialEq, Eq)]
375#[repr(i32)]
376pub enum ColorSpaceDirection {
377    ToReference = 0,
378    FromReference = 1,
379}
380
381/// Direction between a view transform and its reference space.
382#[derive(Debug, Clone, Copy, PartialEq, Eq)]
383#[repr(i32)]
384pub enum ViewTransformDirection {
385    ToReference = 0,
386    FromReference = 1,
387}
388
389/// Visibility filter for named-transform enumeration.
390#[derive(Debug, Clone, Copy, PartialEq, Eq)]
391#[repr(i32)]
392pub enum NamedTransformVisibility {
393    Active = 0,
394    Inactive = 1,
395    All = 2,
396}
397
398/// Runtime-adjustable OCIO processor property kind.
399#[derive(Debug, Clone, Copy, PartialEq, Eq)]
400#[repr(i32)]
401pub enum DynamicPropertyType {
402    Exposure = 0,
403    Contrast = 1,
404    Gamma = 2,
405    GradingPrimary = 3,
406    GradingRgbCurve = 4,
407    GradingTone = 5,
408    #[cfg(feature = "v2_5")]
409    GradingHueCurve = 6,
410}
411
412/// Hue adjustment mode for one-dimensional LUT transforms.
413#[derive(Debug, Clone, Copy, PartialEq, Eq)]
414#[repr(i32)]
415pub enum Lut1DHueAdjust {
416    None_ = 0,
417    Dw3 = 1,
418    Wypn = 2,
419}
420
421/// Channel memory ordering for OCIO packed image descriptors.
422#[derive(Debug, Clone, Copy, PartialEq, Eq)]
423#[repr(i32)]
424pub enum ChannelOrdering {
425    Rgba = 0,
426    Bgra = 1,
427    Abgr = 2,
428    Rgb = 3,
429    Bgr = 4,
430}