HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OpenColorTransforms.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: BSD-3-Clause
2 // Copyright Contributors to the OpenColorIO Project.
3 
4 
5 #ifndef INCLUDED_OCIO_OPENCOLORTRANSFORMS_H
6 #define INCLUDED_OCIO_OPENCOLORTRANSFORMS_H
7 
8 #include <initializer_list>
9 #include <limits>
10 
11 #include "OpenColorTypes.h"
12 
13 #ifndef OCIO_NAMESPACE
14 #error This header cannot be used directly. Use <OpenColorIO/OpenColorIO.h> instead.
15 #endif
16 
17 /**
18  * C++ Transforms
19  * ==============
20  *
21  * Typically only needed when creating and/or manipulating configurations
22  */
23 
24 namespace OCIO_NAMESPACE
25 {
26 
27 
28 
29 /**
30  * The FormatMetadata class is intended to be a generic container to hold metadata from various
31  * file formats.
32  *
33  * This class provides a hierarchical metadata container. A metadata object is similar to an
34  * element in XML. The top level element is named "ROOT" and can't be renamed. Several transforms
35  * have a FormatMetadata.
36  * The root element and all of the sub-elements may contain:
37  * * A name string (e.g. "ROOT", "Description"...). Name can't be empty.
38  * * A value string (e.g. "updated viewing LUT"). Value can be empty.
39  * * A list of attributes (name, value) string pairs (e.g. "version", "1.5"). There are helper
40  * functions to get and set "id" and "name" attributes. Attribute names are unique.
41  * * And a list of child sub-elements, which are also objects implementing FormatMetadata. There
42  * can be several sub-elements with the same name.
43  */
45 {
46 public:
47  virtual const char * getElementName() const noexcept = 0;
48  /// Name has to be a non-empty string. Top-level element can't be renamed. 'ROOT' is reserved.
49  virtual void setElementName(const char *) = 0;
50 
51  virtual const char * getElementValue() const noexcept = 0;
52  virtual void setElementValue(const char *) = 0;
53 
54  virtual int getNumAttributes() const noexcept = 0;
55  /// Get the name of a attribute ("" if attribute does not exist).
56  virtual const char * getAttributeName(int i) const noexcept = 0;
57  /// Get the value of a attribute ("" if attribute does not exist).
58  virtual const char * getAttributeValue(int i) const noexcept = 0;
59  /// Get the value of a attribute of a given name ("" if attribute does not exist).
60  virtual const char * getAttributeValue(const char * name) const noexcept = 0;
61  /**
62  * Add an attribute with a given name and value. If an attribute with the same name already
63  * exists, its value is replaced. Throw if name is NULL or empty.
64  */
65  virtual void addAttribute(const char * name, const char * value) = 0;
66 
67  virtual int getNumChildrenElements() const noexcept = 0;
68  /**
69  * Access a child element.
70  *
71  * \note
72  * Adding siblings might cause a reallocation of the container and thus might make the
73  * reference unusable.
74  * Index i has to be positive and less than getNumChildrenElements() or the function will
75  * throw.
76  */
77  virtual const FormatMetadata & getChildElement(int i) const = 0;
78  virtual FormatMetadata & getChildElement(int i) = 0;
79 
80  /**
81  * Add a child element with a given name and value.
82  *
83  * Name has to be non-empty. Value may be empty, particularly if this element will have
84  * children. Element is added after all existing children. Use
85  * getChildElement(getNumChildrenElements()-1) to access the added element.
86  */
87  virtual void addChildElement(const char * name, const char * value) = 0;
88 
89  /// Remove all children, all attributes and the value.
90  virtual void clear() noexcept = 0;
91 
92  virtual FormatMetadata & operator=(const FormatMetadata & rhs) = 0;
93 
94  /**
95  * Convenience method to easily get/set the 'name' attribute. This corresponds to the
96  * ProcessNode name attribute from a CLF / CTF file or the name key of a transform in the
97  * config YAML.
98  */
99  virtual const char * getName() const noexcept = 0;
100  virtual void setName(const char * name) noexcept = 0;
101  /**
102  * Convenience method to easily get/set the 'id' attribute. This corresponds to the
103  * ProcessNode id attribute from a CLF/CTF file or the ColorCorrection id attribute from a
104  * CC/CCC/CDL file.
105  */
106  virtual const char * getID() const noexcept = 0;
107  virtual void setID(const char * id) noexcept = 0;
108 
109  FormatMetadata(const FormatMetadata & rhs) = delete;
110  /// Do not use (needed only for pybind11).
111  virtual ~FormatMetadata() = default;
112 
113 protected:
114  FormatMetadata() = default;
115 };
116 
117 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const FormatMetadata &);
118 
119 
120 /// Base class for all the transform classes
122 {
123 public:
124  virtual TransformRcPtr createEditableCopy() const = 0;
125 
126  virtual TransformDirection getDirection() const noexcept = 0;
127  /// Note that this only affects the evaluation and not the values stored in the object.
128  virtual void setDirection(TransformDirection dir) noexcept = 0;
129 
130  virtual TransformType getTransformType() const noexcept = 0;
131 
132  /// Will throw if data is not valid.
133  virtual void validate() const;
134 
135  Transform(const Transform &) = delete;
136  Transform & operator= (const Transform &) = delete;
137  /// Do not use (needed only for pybind11).
138  virtual ~Transform() = default;
139 
140 protected:
141  Transform() = default;
142 };
143 
144 extern OCIOEXPORT std::ostream& operator<< (std::ostream&, const Transform&);
145 
146 
147 
148 /**
149  * Forward direction wraps the 'expanded' range into the
150  * specified, often compressed, range.
151  */
153 {
154 public:
155  static AllocationTransformRcPtr Create();
156 
157  TransformRcPtr createEditableCopy() const override;
158 
159  TransformDirection getDirection() const noexcept override;
160  void setDirection(TransformDirection dir) noexcept override;
161 
163 
164  /// Will throw if data is not valid.
165  void validate() const override;
166 
167  Allocation getAllocation() const;
168  void setAllocation(Allocation allocation);
169 
170  int getNumVars() const;
171  void getVars(float * vars) const;
172  void setVars(int numvars, const float * vars);
173 
174  AllocationTransform & operator= (const AllocationTransform &) = delete;
175  /// Do not use (needed only for pybind11).
176  virtual ~AllocationTransform();
177 
178 private:
181 
182  static void deleter(AllocationTransform * t);
183 
184  class Impl;
185  Impl * m_impl;
186  Impl * getImpl() { return m_impl; }
187  const Impl * getImpl() const { return m_impl; }
188 };
189 
190 extern OCIOEXPORT std::ostream& operator<< (std::ostream&, const AllocationTransform&);
191 
192 
193 /**
194  * A built-in transform is similar to a FileTransform, but without the file.
195  * OCIO knows how to build a set of commonly used transforms on-demand, thus avoiding the need
196  * for external files and simplifying config authoring.
197  */
199 {
200 public:
201  static BuiltinTransformRcPtr Create();
202 
204 
205  virtual const char * getStyle() const noexcept = 0;
206  /**
207  * Select an existing built-in transform style from the list accessible
208  * through :cpp:class:`BuiltinTransformRegistry`. The style is the ID string that identifies
209  * which transform to apply.
210  */
211  virtual void setStyle(const char * style) = 0;
212 
213  virtual const char * getDescription() const noexcept = 0;
214 
215  /// Do not use (needed only for pybind11).
216  virtual ~BuiltinTransform() = default;
217 
218 protected:
219  BuiltinTransform() = default;
220 
221 private:
223  BuiltinTransform & operator= (const BuiltinTransform &) = delete;
224 };
225 
226 //
227 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const BuiltinTransform &) noexcept;
228 
229 
230 /**
231  * \brief
232  * An implementation of the ASC Color Decision List (CDL), based on the ASC v1.2
233  * specification.
234  *
235  * **ASC_SOP**
236  *
237  * Slope, offset, power::
238  * out = clamp( (in * slope) + offset ) ^ power
239  *
240  * \note​
241  * If the config version is 1, negative values are clamped if the power is not 1.0.
242  * For config version 2 and higher, the negative handling is controlled by the CDL style.
243  */
245 {
246 public:
247  static CDLTransformRcPtr Create();
248 
249  /**
250  * \brief Load the CDL from the src .cdl, .cc, or .ccc file.
251  *
252  * \note
253  * The cccid can be the ID of a CDL or the index of the CDL (as string). If cccid is NULL or
254  * empty the first CDL is returned. The cccid is case-sensitive. The src must be an
255  * absolute path reference, no relative directory or envvar resolution is performed. Throws
256  * if file does not contain any CDL or if the specified cccid is not found.
257  */
258  static CDLTransformRcPtr CreateFromFile(const char * src, const char * cccid);
259 
260  /**
261  * \brief Load all of the CDLs in a .cdl or .ccc file into a single GroupTransform.
262  *
263  * \note
264  * This may be useful as a quicker way for applications to check the contents of each of
265  * the CDLs. The src must be an absolute path reference, no relative directory or envvar
266  * resolution is performed.
267  */
268  static GroupTransformRcPtr CreateGroupFromFile(const char * src);
269 
270  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_CDL; }
271 
272  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
273  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
274 
275  virtual bool equals(const CDLTransform & other) const noexcept = 0;
276 
277  virtual CDLStyle getStyle() const = 0;
278  /**
279  * Use CDL_ASC to clamp values to [0,1] per the ASC spec. Use NO_CLAMP to
280  * never clamp values (regardless of whether power is 1.0). The NO_CLAMP option passes
281  * negatives through unchanged (like the NEGATIVE_PASS_THRU style of ExponentTransform).
282  * The default style is CDL_NO_CLAMP.
283  */
284  virtual void setStyle(CDLStyle style) = 0;
285 
286  virtual void getSlope(double * rgb) const = 0;
287  virtual void setSlope(const double * rgb) = 0;
288 
289  virtual void getOffset(double * rgb) const = 0;
290  virtual void setOffset(const double * rgb) = 0;
291 
292  virtual void getPower(double * rgb) const = 0;
293  virtual void setPower(const double * rgb) = 0;
294 
295  virtual void getSOP(double * vec9) const = 0;
296  virtual void setSOP(const double * vec9) = 0;
297 
298  virtual double getSat() const = 0;
299  virtual void setSat(double sat) = 0;
300 
301  /// These are hard-coded, by spec, to r709.
302  virtual void getSatLumaCoefs(double * rgb) const = 0;
303 
304  /**
305  * The get/setID methods are now deprecated. The preferred way of interacting with the ID is
306  * now via the transform's formatMetadata.
307  */
308  virtual const char * getID() const = 0;
309  virtual void setID(const char * id) = 0;
310 
311  /* Get/Set the first Description element under the SOPNode.
312  * Note: These emulate the get/setDescription methods from OCIO v1.
313  *
314  * Use the FormatMetadata interface for access to other Description elements in the CDL.
315  * The Description children of the SOPNode element in the CDL XML are named 'SOPDescription'
316  * in the FormatMetadata. NULL or empty string removes the first SOPDescription element.
317  */
318  virtual const char * getFirstSOPDescription() const = 0;
319  virtual void setFirstSOPDescription(const char * description) = 0;
320 
321  CDLTransform(const CDLTransform &) = delete;
322  CDLTransform & operator= (const CDLTransform &) = delete;
323  /// Do not use (needed only for pybind11).
324  virtual ~CDLTransform() = default;
325 
326 protected:
327  CDLTransform() = default;
328 };
329 
330 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const CDLTransform &);
331 
332 
334 {
335 public:
336  static ColorSpaceTransformRcPtr Create();
337 
338  TransformRcPtr createEditableCopy() const override;
339 
340  TransformDirection getDirection() const noexcept override;
341  void setDirection(TransformDirection dir) noexcept override;
342 
343  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_COLORSPACE; }
344 
345  void validate() const override;
346 
347  const char * getSrc() const;
348  void setSrc(const char * src);
349 
350  const char * getDst() const;
351  void setDst(const char * dst);
352 
353  /// Data color spaces do not get processed when true (which is the default).
354  bool getDataBypass() const noexcept;
355  void setDataBypass(bool enabled) noexcept;
356 
357  ColorSpaceTransform & operator=(const ColorSpaceTransform &) = delete;
358  /// Do not use (needed only for pybind11).
359  virtual ~ColorSpaceTransform();
360 
361 private:
362  ColorSpaceTransform();
363  ColorSpaceTransform(const ColorSpaceTransform &);
364 
365  static void deleter(ColorSpaceTransform * t);
366 
367  class Impl;
368  Impl * m_impl;
369  Impl * getImpl() { return m_impl; }
370  const Impl * getImpl() const { return m_impl; }
371 };
372 
373 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const ColorSpaceTransform &);
374 
375 
376 class OCIOEXPORT DisplayViewTransform : public Transform
377 {
378 public:
379  static DisplayViewTransformRcPtr Create();
380 
381  TransformRcPtr createEditableCopy() const override;
382 
383  TransformDirection getDirection() const noexcept override;
384  void setDirection(TransformDirection dir) noexcept override;
385 
387 
388  /// Will throw if data is not valid.
389  void validate() const override;
390 
391  const char * getSrc() const;
392  /// Specify the incoming color space.
393  void setSrc(const char * name);
394 
395  const char * getDisplay() const;
396  /// Specify which display to use.
397  void setDisplay(const char * display);
398 
399  const char * getView() const;
400  /// Specify which view transform to use.
401  void setView(const char * view);
402 
403  bool getLooksBypass() const;
404  /// Looks will be bypassed when true (the default is false).
405  void setLooksBypass(bool bypass);
406 
407  bool getDataBypass() const noexcept;
408  /// Data color spaces do not get processed when true (which is the default).
409  void setDataBypass(bool bypass) noexcept;
410 
411  /// Do not use (needed only for pybind11).
412  virtual ~DisplayViewTransform();
413 
414 private:
415  DisplayViewTransform();
416  DisplayViewTransform(const DisplayViewTransform &) = delete;
417  DisplayViewTransform & operator=(const DisplayViewTransform &) = delete;
418 
419  static void deleter(DisplayViewTransform * t);
420 
421  class Impl;
422  Impl * m_impl;
423  Impl * getImpl() { return m_impl; }
424  const Impl * getImpl() const { return m_impl; }
425 };
426 
427 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const DisplayViewTransform &);
428 
429 /**
430  * Used by the grading transforms to hold the red, green, blue, and master components
431  * of a single parameter. The master component affects all three channels (RGB).
432  */
434 {
435  GradingRGBM() = default;
436  GradingRGBM(double red, double green, double blue, double master)
437  : m_red(red)
438  , m_green(green)
439  , m_blue(blue)
440  , m_master(master)
441  {
442  }
443  GradingRGBM(const double(&rgbm)[4])
444  : m_red(rgbm[0])
445  , m_green(rgbm[1])
446  , m_blue(rgbm[2])
447  , m_master(rgbm[3])
448  {
449  }
450  double m_red{ 0. };
451  double m_green{ 0. };
452  double m_blue{ 0. };
453  double m_master{ 0. };
454 };
455 
456 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const GradingRGBM &);
457 
458 /// Grading primary values.
460 {
461  GradingPrimary() = delete;
462  explicit GradingPrimary(GradingStyle style)
463  : m_pivot(style == GRADING_LOG ? -0.2 : 0.18)
464  , m_clampBlack(NoClampBlack())
465  , m_clampWhite(NoClampWhite())
466  {
467  }
468 
469  GradingRGBM m_brightness{ 0.0, 0.0, 0.0, 0.0 };
470  GradingRGBM m_contrast { 1.0, 1.0, 1.0, 1.0 };
471  GradingRGBM m_gamma { 1.0, 1.0, 1.0, 1.0 };
472  GradingRGBM m_offset { 0.0, 0.0, 0.0, 0.0 };
473  GradingRGBM m_exposure { 0.0, 0.0, 0.0, 0.0 };
474  GradingRGBM m_lift { 0.0, 0.0, 0.0, 0.0 };
475  GradingRGBM m_gain { 1.0, 1.0, 1.0, 1.0 };
476 
477  double m_saturation{ 1.0 };
478  double m_pivot; // For LOG default is -0.2. LIN default is 0.18.
479  double m_pivotBlack{ 0.0 };
480  double m_pivotWhite{ 1.0 };
481  double m_clampBlack;
482  double m_clampWhite;
483 
484  /// The valid range for each parameter varies.
485  void validate(GradingStyle style) const;
486 
487  static double NoClampBlack();
488  static double NoClampWhite();
489 };
490 
491 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const GradingPrimary &);
492 
493 /// 2D control point used by \ref GradingBSplineCurve.
495 {
496  GradingControlPoint() = default;
497  GradingControlPoint(float x, float y) : m_x(x), m_y(y) {}
498  float m_x{ 0.f };
499  float m_y{ 0.f };
500 };
501 
502 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const GradingControlPoint &);
503 
504 /// A BSpline curve defined with \ref GradingControlPoint.
506 {
507 public:
508  /// Create a BSpline curve with a specified number of control points.
509  static GradingBSplineCurveRcPtr Create(size_t size);
510  /// Create a BSpline curve with a list of control points.
511  static GradingBSplineCurveRcPtr Create(std::initializer_list<GradingControlPoint> values);
512 
513  virtual GradingBSplineCurveRcPtr createEditableCopy() const = 0;
514  virtual size_t getNumControlPoints() const noexcept = 0;
515  virtual void setNumControlPoints(size_t size) = 0;
516  virtual const GradingControlPoint & getControlPoint(size_t index) const = 0;
517  virtual GradingControlPoint & getControlPoint(size_t index) = 0;
518  virtual float getSlope(size_t index) const = 0;
519  virtual void setSlope(size_t index, float slope) = 0;
520  virtual bool slopesAreDefault() const = 0;
521  virtual void validate() const = 0;
522 
523  GradingBSplineCurve(const GradingBSplineCurve &) = delete;
524  GradingBSplineCurve & operator= (const GradingBSplineCurve &) = delete;
525 
526  /// Do not use (needed only for pybind11).
527  virtual ~GradingBSplineCurve() = default;
528 
529 protected:
530  GradingBSplineCurve() = default;
531 };
532 
533 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const GradingBSplineCurve &);
534 
535 /**
536  * A set of red, green, blue and master curves. It is used by RGBCurveTransform and can be used as
537  * a dynamic property (see \ref DynamicPropertyGradingRGBCurve).
538  */
540 {
541 public:
542  static GradingRGBCurveRcPtr Create(GradingStyle style);
543  static GradingRGBCurveRcPtr Create(const ConstGradingRGBCurveRcPtr & rhs);
547  const ConstGradingBSplineCurveRcPtr & master);
548 
549  virtual GradingRGBCurveRcPtr createEditableCopy() const = 0;
550  virtual void validate() const = 0;
551  virtual bool isIdentity() const = 0;
552  virtual ConstGradingBSplineCurveRcPtr getCurve(RGBCurveType c) const = 0;
553  virtual GradingBSplineCurveRcPtr getCurve(RGBCurveType c) = 0;
554 
555  /// Do not use (needed only for pybind11).
556  virtual ~GradingRGBCurve() = default;
557 
558 protected:
559  GradingRGBCurve() = default;
560 };
561 
562 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const GradingRGBCurve &);
563 
564 /**
565  * Used by the grading tone transforms to hold the red, green, blue, master, start,
566  * and width components of a single parameter. The master component affects all three channels
567  * (RGB). The start and width components control the range of tones affected. Although this
568  * struct simply uses "start" and "width" for all the range values, the actual user-facing name
569  * changes based on the parameter.
570  */
572 {
573  GradingRGBMSW() = default;
574  GradingRGBMSW(double red, double green, double blue, double master, double start, double width)
575  : m_red (red)
576  , m_green (green)
577  , m_blue (blue)
578  , m_master(master)
579  , m_start (start)
580  , m_width (width)
581  {
582  }
583  GradingRGBMSW(const double(&rgbmsw)[6])
584  : m_red (rgbmsw[0])
585  , m_green (rgbmsw[1])
586  , m_blue (rgbmsw[2])
587  , m_master(rgbmsw[3])
588  , m_start (rgbmsw[4])
589  , m_width (rgbmsw[5])
590  {
591  }
592  GradingRGBMSW(double start, double width)
593  : m_start(start)
594  , m_width(width)
595  {
596  }
597  double m_red { 1. };
598  double m_green { 1. };
599  double m_blue { 1. };
600  double m_master{ 1. };
601  double m_start { 0. }; // Or center for midtones.
602  double m_width { 1. }; // Or pivot for shadows and highlights.
603 };
604 
605 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const GradingRGBMSW &);
606 
607 /// Grading tone values.
609 {
610  GradingTone() = delete;
611  explicit GradingTone(GradingStyle style)
612  : m_blacks(style == GRADING_LIN ? GradingRGBMSW(0., 4.) :
613  (style == GRADING_LOG ? GradingRGBMSW(0.4, 0.4) :
614  GradingRGBMSW(0.4, 0.4)))
615  , m_shadows(style == GRADING_LIN ? GradingRGBMSW(2., -7.) :
616  (style == GRADING_LOG ? GradingRGBMSW(0.5, 0.) :
617  GradingRGBMSW(0.6, 0.)))
618  , m_midtones(style == GRADING_LIN ? GradingRGBMSW(0., 8.) :
619  (style == GRADING_LOG ? GradingRGBMSW(0.4, 0.6) :
620  GradingRGBMSW(0.4, 0.7)))
621  , m_highlights(style == GRADING_LIN ? GradingRGBMSW(-2., 9.) :
622  (style == GRADING_LOG ? GradingRGBMSW(0.3, 1.) :
623  GradingRGBMSW(0.2, 1.)))
624  , m_whites(style == GRADING_LIN ? GradingRGBMSW(0., 8.) :
625  (style == GRADING_LOG ? GradingRGBMSW(0.4, 0.5) :
626  GradingRGBMSW(0.5, 0.5)))
627  {
628  }
629 
630  /**
631  * The valid range for each parameter varies. The client is expected to enforce
632  * these bounds in the UI.
633  */
634  void validate() const;
635 
641  double m_scontrast{ 1.0 };
642 };
643 
644 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const GradingTone &);
645 
646 /**
647  * Allows transform parameter values to be set on-the-fly (after finalization). For
648  * example, to modify the exposure in a viewport. Dynamic properties can be accessed from the
649  * `CPUProcessor` or `GpuShaderCreator` to change values between processing.
650  *
651  * \code{.cpp}
652  *
653  * OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
654  * OCIO::ConstProcessorRcPtr processor = config->getProcessor(colorSpace1, colorSpace2);
655  * OCIO::ConstCPUProcessorRcPtr cpuProcessor = processor->getDefaultCPUProcessor();
656  *
657  * if (cpuProcessor->hasDynamicProperty(OCIO::DYNAMIC_PROPERTY_EXPOSURE))
658  * {
659  * // Get the in-memory implementation of the dynamic property.
660  * OCIO::DynamicPropertyRcPtr dynProp =
661  * cpuProcessor->getDynamicProperty(OCIO::DYNAMIC_PROPERTY_EXPOSURE);
662  * // Get the interface used to change the double value.
663  * OCIO::DynamicPropertyDoubleRcPtr exposure =
664  * OCIO::DynamicPropertyValue::AsDouble(dynProp);
665  * // Update of the dynamic property instance with the new value.
666  * exposure->setValue(1.1f);
667  * }
668  * if (cpuProcessor->hasDynamicProperty(OCIO::DYNAMIC_PROPERTY_GRADING_PRIMARY))
669  * {
670  * OCIO::DynamicPropertyRcPtr dynProp =
671  * cpuProcessor->getDynamicProperty(OCIO::DYNAMIC_PROPERTY_GRADING_PRIMARY);
672  * OCIO::DynamicPropertyGradingPrimaryRcPtr primaryProp =
673  * OCIO::DynamicPropertyValue::AsGradingPrimary(dynProp);
674  * OCIO::GradingPrimary primary = primaryProp->getValue();
675  * primary.m_saturation += 0.1f;
676  * rgbCurveProp->setValue(primary);
677  * }
678  * if (cpuProcessor->hasDynamicProperty(OCIO::DYNAMIC_PROPERTY_GRADING_RGBCURVE))
679  * {
680  * OCIO::DynamicPropertyRcPtr dynProp =
681  * cpuProcessor->getDynamicProperty(OCIO::DYNAMIC_PROPERTY_GRADING_RGBCURVE);
682  * OCIO::DynamicPropertyGradingRGBCurveRcPtr rgbCurveProp =
683  * OCIO::DynamicPropertyValue::AsGradingRGBCurve(dynProp);
684  * OCIO::ConstGradingRGBCurveRcPtr rgbCurve = rgbCurveProp->getValue()->createEditableCopy();
685  * OCIO::GradingBSplineCurveRcPtr rCurve = rgbCurve->getCurve(OCIO::RGB_RED);
686  * rCurve->getControlPoint(1).m_y += 0.1f;
687  * rgbCurveProp->setValue(rgbCurve);
688  * }
689  * \endcode
690  */
692 {
693 public:
694  virtual DynamicPropertyType getType() const noexcept = 0;
695 
696  DynamicProperty & operator=(const DynamicProperty &) = delete;
697  DynamicProperty(const DynamicProperty &) = delete;
698 
699  /// Do not use (needed only for pybind11).
700  virtual ~DynamicProperty() = default;
701 
702 protected:
703  DynamicProperty() = default;
704 };
705 
706 namespace DynamicPropertyValue
707 {
708 /**
709  * Get the property as DynamicPropertyDoubleRcPtr to access the double value. Will throw if
710  * property type is not a type that holds a double such as DYNAMIC_PROPERTY_EXPOSURE.
711  */
713 /**
714  * Get the property as DynamicPropertyGradingPrimaryRcPtr to access the GradingPrimary value. Will
715  * throw if property type is not DYNAMIC_PROPERTY_GRADING_PRIMARY.
716  */
718 /**
719  * Get the property as DynamicPropertyGradingRGBCurveRcPtr to access the GradingRGBCurveRcPtr
720  * value. Will throw if property type is not DYNAMIC_PROPERTY_GRADING_RGBCURVE.
721  */
723 /**
724  * Get the property as DynamicPropertyGradingToneRcPtr to access the GradingTone value. Will throw
725  * if property type is not DYNAMIC_PROPERTY_GRADING_TONE.
726  */
728 }
729 
730 /// Interface used to access dynamic property double value.
732 {
733 public:
734  virtual double getValue() const = 0;
735  virtual void setValue(double value) = 0;
736 
738  DynamicPropertyDouble & operator=(const DynamicPropertyDouble &) = delete;
739  /// Do not use (needed only for pybind11).
740  virtual ~DynamicPropertyDouble() = default;
741 
742 protected:
743  DynamicPropertyDouble() = default;
744 };
745 
746 /// Interface used to access dynamic property GradingPrimary value.
748 {
749 public:
750  virtual const GradingPrimary & getValue() const = 0;
751  /// Will throw if value is not valid.
752  virtual void setValue(const GradingPrimary & value) = 0;
753 
755  DynamicPropertyGradingPrimary & operator=(const DynamicPropertyGradingPrimary &) = delete;
756  /// Do not use (needed only for pybind11).
757  virtual ~DynamicPropertyGradingPrimary() = default;
758 
759 protected:
760  DynamicPropertyGradingPrimary() = default;
761 };
762 
763 /// Interface used to access dynamic property ConstGradingRGBCurveRcPtr value.
765 {
766 public:
767  virtual const ConstGradingRGBCurveRcPtr & getValue() const = 0;
768  /// Will throw if value is not valid.
769  virtual void setValue(const ConstGradingRGBCurveRcPtr & value) = 0;
770 
773  /// Do not use (needed only for pybind11).
774  virtual ~DynamicPropertyGradingRGBCurve() = default;
775 
776 protected:
777  DynamicPropertyGradingRGBCurve() = default;
778 };
779 
780 /// Interface used to access dynamic property GradingTone value.
782 {
783 public:
784  virtual const GradingTone & getValue() const = 0;
785  /// Will throw if value is not valid.
786  virtual void setValue(const GradingTone & value) = 0;
787 
789  DynamicPropertyGradingTone & operator=(const DynamicPropertyGradingTone &) = delete;
790  /// Do not use (needed only for pybind11).
791  virtual ~DynamicPropertyGradingTone() = default;
792 
793 protected:
794  DynamicPropertyGradingTone() = default;
795 };
796 
797 
798 /**
799  * \brief Represents exponent transform: pow( clamp(color), value ).
800  *
801  * \note For configs with version == 1: Negative style is ignored and if the exponent is 1.0,
802  * this will not clamp. Otherwise, the input color will be clamped between [0.0, inf].
803  * For configs with version > 1: Negative value handling may be specified via setNegativeStyle.
804  */
805 class OCIOEXPORT ExponentTransform : public Transform
806 {
807 public:
808  static ExponentTransformRcPtr Create();
809 
811 
812  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
813  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
814 
815  /// Checks if this exactly equals other.
816  virtual bool equals(const ExponentTransform & other) const noexcept = 0;
817 
818  virtual void getValue(double(&vec4)[4]) const noexcept = 0;
819  virtual void setValue(const double(&vec4)[4]) noexcept = 0;
820 
821  /**
822  * Specifies how negative values are handled. Legal values:
823  *
824  * * NEGATIVE_CLAMP -- Clamp negative values (default).
825  * * NEGATIVE_MIRROR -- Positive curve is rotated 180 degrees around the origin to
826  * handle negatives.
827  * * NEGATIVE_PASS_THRU -- Negative values are passed through unchanged.
828  */
829  virtual NegativeStyle getNegativeStyle() const = 0;
830  virtual void setNegativeStyle(NegativeStyle style) = 0;
831 
832  ExponentTransform(const ExponentTransform &) = delete;
833  ExponentTransform & operator= (const ExponentTransform &) = delete;
834  /// Do not use (needed only for pybind11).
835  virtual ~ExponentTransform() = default;
836 
837 protected:
838  ExponentTransform() = default;
839 };
840 
841 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const ExponentTransform &);
842 
843 
844 /**
845  * Represents power functions with a linear section in the shadows
846  * such as sRGB and L*.
847  *
848  * The basic formula is::
849  *
850  * pow( (x + offset)/(1 + offset), gamma )
851  * with the breakpoint at offset/(gamma - 1).
852  *
853  * Negative values are never clamped.
854  */
856 {
857 public:
858  static ExponentWithLinearTransformRcPtr Create();
859 
861 
862  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
863  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
864 
865  /// Checks if this exactly equals other.
866  virtual bool equals(const ExponentWithLinearTransform & other) const noexcept = 0;
867 
868  virtual void getGamma(double(&values)[4]) const noexcept = 0;
869  /**
870  * Set the exponent value for the power function for R, G, B, A.
871  *
872  * \note
873  * The gamma values must be in the range of [1, 10]. Set the transform direction
874  * to inverse to obtain the effect of values less than 1.
875  */
876  virtual void setGamma(const double(&values)[4]) noexcept = 0;
877 
878  virtual void getOffset(double(&values)[4]) const noexcept = 0;
879  /**
880  * Set the offset value for the power function for R, G, B, A.
881  *
882  * \note
883  * The offset values must be in the range [0, 0.9].
884  */
885  virtual void setOffset(const double(&values)[4]) noexcept = 0;
886 
887  /**
888  * Specifies how negative values are handled. Legal values:
889  *
890  * * NEGATIVE_LINEAR -- Linear segment continues into negatives (default).
891  * * NEGATIVE_MIRROR -- Positive curve is rotated 180 degrees around the origin to
892  * handle negatives.
893  */
894  virtual NegativeStyle getNegativeStyle() const = 0;
895  virtual void setNegativeStyle(NegativeStyle style) = 0;
896 
898  ExponentWithLinearTransform & operator= (const ExponentWithLinearTransform &) = delete;
899  /// Do not use (needed only for pybind11).
900  virtual ~ExponentWithLinearTransform() = default;
901 
902 protected:
903  ExponentWithLinearTransform() = default;
904 };
905 
906 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const ExponentWithLinearTransform &);
907 
908 /**
909  * Applies exposure, gamma, and pivoted contrast adjustments.
910  * Adjusts the math to be appropriate for linear, logarithmic, or video
911  * color spaces.
912  */
914 {
915 public:
916  static ExposureContrastTransformRcPtr Create();
917 
919 
920  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
921  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
922 
923  /// Checks if this exactly equals other.
924  virtual bool equals(const ExposureContrastTransform & other) const noexcept = 0;
925 
926  virtual ExposureContrastStyle getStyle() const = 0;
927  /// Select the algorithm for linear, video or log color spaces.
928  virtual void setStyle(ExposureContrastStyle style) = 0;
929 
930  virtual double getExposure() const = 0;
931  /**
932  * Applies an exposure adjustment. The value is in units of stops (regardless of style), for
933  * example, a value of -1 would be equivalent to reducing the lighting by one half.
934  */
935  virtual void setExposure(double exposure) = 0;
936  /**
937  * Exposure can be made dynamic so the value can be changed through the CPU or GPU processor,
938  * but if there are several ExposureContrastTransform only one can have a dynamic exposure.
939  */
940  virtual bool isExposureDynamic() const = 0;
941  virtual void makeExposureDynamic() = 0;
942  virtual void makeExposureNonDynamic() = 0;
943 
944  virtual double getContrast() const = 0;
945  /**
946  * Applies a contrast/gamma adjustment around a pivot point. The contrast and gamma are
947  * mathematically the same, but two controls are provided to enable the use of separate
948  * dynamic parameters. Contrast is usually a scene-referred adjustment that pivots around
949  * gray whereas gamma is usually a display-referred adjustment that pivots around white.
950  */
951  virtual void setContrast(double contrast) = 0;
952  /**
953  * Contrast can be made dynamic so the value can be changed through the CPU or GPU processor,
954  * but if there are several ExposureContrastTransform only one can have a dynamic contrast.
955  */
956  virtual bool isContrastDynamic() const = 0;
957  virtual void makeContrastDynamic() = 0;
958  virtual void makeContrastNonDynamic() = 0;
959 
960  virtual double getGamma() const = 0;
961  virtual void setGamma(double gamma) = 0;
962  /**
963  * Gamma can be made dynamic so the value can be changed through the CPU or GPU processor,
964  * but if there are several ExposureContrastTransform only one can have a dynamic gamma.
965  */
966  virtual bool isGammaDynamic() const = 0;
967  virtual void makeGammaDynamic() = 0;
968  virtual void makeGammaNonDynamic() = 0;
969 
970  virtual double getPivot() const = 0;
971  /**
972  * Set the pivot point around which the contrast
973  * and gamma controls will work. Regardless of whether
974  * linear/video/log-style is being used, the pivot is always expressed
975  * in linear. In other words, a pivot of 0.18 is always mid-gray.
976  */
977  virtual void setPivot(double pivot) = 0;
978 
979  virtual double getLogExposureStep() const = 0;
980  /**
981  * Set the increment needed to move one stop for
982  * the log-style algorithm. For example, ACEScct is 0.057, LogC is
983  * roughly 0.074, and Cineon is roughly 90/1023 = 0.088.
984  * The default value is 0.088.
985  */
986  virtual void setLogExposureStep(double logExposureStep) = 0;
987 
988  virtual double getLogMidGray() const = 0;
989  /**
990  * Set the position of 18% gray for use by the
991  * log-style algorithm. For example, ACEScct is about 0.41, LogC is
992  * about 0.39, and ADX10 is 445/1023 = 0.435.
993  * The default value is 0.435.
994  */
995  virtual void setLogMidGray(double logMidGray) = 0;
996 
997  /// Do not use (needed only for pybind11).
998  virtual ~ExposureContrastTransform() = default;
999 
1000 protected:
1001  ExposureContrastTransform() = default;
1002 
1003 private:
1005  ExposureContrastTransform & operator= (const ExposureContrastTransform &) = delete;
1006 };
1007 
1008 extern OCIOEXPORT std::ostream & operator<<(std::ostream &,
1009  const ExposureContrastTransform &);
1010 
1011 
1012 class OCIOEXPORT FileTransform : public Transform
1013 {
1014 public:
1015  static FileTransformRcPtr Create();
1016 
1017  TransformRcPtr createEditableCopy() const override;
1018 
1019  TransformDirection getDirection() const noexcept override;
1020  void setDirection(TransformDirection dir) noexcept override;
1021 
1022  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_FILE; }
1023 
1024  /// Will throw if data is not valid.
1025  void validate() const override;
1026 
1027  const char * getSrc() const;
1028  void setSrc(const char * src);
1029 
1030  /**
1031  * The cccid can be the ID of a CDL or the index of the CDL (as string). If cccid is NULL or
1032  * empty the first CDL is returned. The cccid is case-sensitive.
1033  */
1034  const char * getCCCId() const;
1035  void setCCCId(const char * id);
1036 
1037  CDLStyle getCDLStyle() const;
1038  /**
1039  * Can be used with CDL, CC & CCC formats to specify the clamping behavior of
1040  * the CDLTransform. Default is CDL_NO_CLAMP.
1041  */
1042  void setCDLStyle(CDLStyle);
1043 
1044  /**
1045  * The file parsers that care about interpolation (LUTs) will try to make use of the requested
1046  * interpolation method when loading the file. In these cases, if the requested method could
1047  * not be used, a warning is logged. If no method is provided, or a method cannot be used,
1048  * INTERP_DEFAULT is used.
1049  */
1050  Interpolation getInterpolation() const;
1051  void setInterpolation(Interpolation interp);
1052 
1053  /// Get the number of LUT readers.
1054  static int GetNumFormats();
1055  /// Get the LUT readers at index, return empty string if an invalid index is specified.
1056  static const char * GetFormatNameByIndex(int index);
1057  /// Get the LUT reader extension at index, return empty string if an invalid index is specified.
1058  static const char * GetFormatExtensionByIndex(int index);
1059 
1060  FileTransform & operator=(const FileTransform &) = delete;
1061  /// Do not use (needed only for pybind11).
1062  virtual ~FileTransform();
1063 
1064 private:
1065  FileTransform();
1066  FileTransform(const FileTransform &);
1067 
1068  static void deleter(FileTransform * t);
1069 
1070  class Impl;
1071  Impl * m_impl;
1072  Impl * getImpl() { return m_impl; }
1073  const Impl * getImpl() const { return m_impl; }
1074 };
1075 
1076 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const FileTransform &);
1077 
1078 
1079 /**
1080  * Provides a set of hard-coded algorithmic building blocks
1081  * that are needed to accurately implement various common color transformations.
1082  */
1083 class OCIOEXPORT FixedFunctionTransform : public Transform
1084 {
1085 public:
1086  static FixedFunctionTransformRcPtr Create(FixedFunctionStyle style);
1087  static FixedFunctionTransformRcPtr Create(FixedFunctionStyle style,
1088  const double * params,
1089  size_t num);
1090 
1091  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_FIXED_FUNCTION; }
1092 
1093  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1094  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1095 
1096  /// Checks if this exactly equals other.
1097  virtual bool equals(const FixedFunctionTransform & other) const noexcept = 0;
1098 
1099  virtual FixedFunctionStyle getStyle() const = 0;
1100  /// Select which algorithm to use.
1101  virtual void setStyle(FixedFunctionStyle style) = 0;
1102 
1103  virtual size_t getNumParams() const = 0;
1104  virtual void getParams(double * params) const = 0;
1105  /// Set the parameters (for functions that require them).
1106  virtual void setParams(const double * params, size_t num) = 0;
1107 
1109  FixedFunctionTransform & operator= (const FixedFunctionTransform &) = delete;
1110  /// Do not use (needed only for pybind11).
1111  virtual ~FixedFunctionTransform() = default;
1112 
1113 protected:
1114  FixedFunctionTransform() = default;
1115 };
1116 
1117 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const FixedFunctionTransform &);
1118 
1119 
1120 /**
1121  * Primary color correction controls.
1122  *
1123  * This transform is for making basic color correction adjustments to an image such as brightness,
1124  * contrast, or saturation.
1125  *
1126  * The controls are customized for linear, logarithmic, and video color encodings.
1127  * * Linear controls: Exposure, Contrast, Pivot, Offset, Saturation, Black Clip, White Clip.
1128  * * Log controls: Brightness, Contrast, Pivot, Log Gamma, Saturation, Black Clip, White Clip,
1129  * Black Pivot White Pivot.
1130  * * Video controls : Lift, Gamma, Gain, Offset, Saturation, Black Clip, White Clip,
1131  * Black Pivot White Pivot.
1132  *
1133  * The controls are dynamic, so they may be adjusted even after the Transform has been included
1134  * in a Processor.
1135  */
1137 {
1138 public:
1139  /// Creates an instance of GradingPrimaryTransform.
1140  static GradingPrimaryTransformRcPtr Create(GradingStyle style);
1141 
1142  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_GRADING_PRIMARY; }
1143 
1144  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1145  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1146 
1147  /// Checks if this equals other.
1148  virtual bool equals(const GradingPrimaryTransform & other) const noexcept = 0;
1149 
1150  /// Adjusts the behavior of the transform for log, linear, or video color space encodings.
1151  virtual GradingStyle getStyle() const noexcept = 0;
1152  /// Will reset value to style's defaults if style is not the current style.
1153  virtual void setStyle(GradingStyle style) noexcept = 0;
1154 
1155  virtual const GradingPrimary & getValue() const = 0;
1156  /// Throws if value is not valid.
1157  virtual void setValue(const GradingPrimary & values) = 0;
1158 
1159  /**
1160  * Parameters can be made dynamic so the values can be changed through the CPU or GPU processor,
1161  * but if there are several GradingPrimaryTransform only one can have dynamic parameters.
1162  */
1163  virtual bool isDynamic() const noexcept = 0;
1164  virtual void makeDynamic() noexcept = 0;
1165  virtual void makeNonDynamic() noexcept = 0;
1166 
1168  GradingPrimaryTransform & operator= (const GradingPrimaryTransform &) = delete;
1169  /// Do not use (needed only for pybind11).
1170  virtual ~GradingPrimaryTransform() = default;
1171 
1172 protected:
1173  GradingPrimaryTransform() = default;
1174 };
1175 
1176 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const GradingPrimaryTransform &) noexcept;
1177 
1178 
1179 /**
1180  * RGB curve color correction controls.
1181  *
1182  * This transform allows for modifying tone reproduction via B-spline curves.
1183  *
1184  * There is an R, G, and B curve along with a Master curve (that applies to R, G, and B). Each
1185  * curve is specified via the x and y coordinates of its control points. A monotonic spline is
1186  * fit to the control points. The x coordinates must be non-decreasing. When the grading style
1187  * is linear, the units for the control points are photographic stops relative to 0.18.
1188  *
1189  * The control points are dynamic, so they may be adjusted even after the Transform is included
1190  * in a Processor.
1191  */
1193 {
1194 public:
1195  /// Creates an instance of GradingPrimaryTransform.
1196  static GradingRGBCurveTransformRcPtr Create(GradingStyle style);
1197 
1199 
1200  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1201  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1202 
1203  /// Checks if this equals other.
1204  virtual bool equals(const GradingRGBCurveTransform & other) const noexcept = 0;
1205 
1206  /// Adjusts the behavior of the transform for log, linear, or video color space encodings.
1207  virtual GradingStyle getStyle() const noexcept = 0;
1208  /// Will reset value to style's defaults if style is not the current style.
1209  virtual void setStyle(GradingStyle style) noexcept = 0;
1210 
1211  virtual const ConstGradingRGBCurveRcPtr getValue() const = 0;
1212  /// Throws if value is not valid.
1213  virtual void setValue(const ConstGradingRGBCurveRcPtr & values) = 0;
1214 
1215  /**
1216  * It is possible to provide a desired slope value for each control point. The number of slopes is
1217  * always the same as the number of control points and so the control points must be set before
1218  * setting the slopes. The slopes are primarily intended for use by config authors looking to match
1219  * a specific shape with as few control points as possible, they are not intended to be exposed to
1220  * a user interface for direct manipulation. When a curve is being generated for creative purposes
1221  * it is better to let OCIO calculate the slopes automatically.
1222  */
1223  virtual float getSlope(RGBCurveType c, size_t index) const = 0;
1224  virtual void setSlope(RGBCurveType c, size_t index, float slope) = 0;
1225  virtual bool slopesAreDefault(RGBCurveType c) const = 0;
1226 
1227  /**
1228  * The scene-linear grading style applies a lin-to-log transform to the pixel
1229  * values before going through the curve. However, in some cases (e.g. drawing curves in a UI)
1230  * it may be useful to bypass the lin-to-log. Default value is false.
1231  */
1232  virtual bool getBypassLinToLog() const = 0;
1233  virtual void setBypassLinToLog(bool bypass) = 0;
1234 
1235  /**
1236  * Parameters can be made dynamic so the values can be changed through the CPU or GPU processor,
1237  * but if there are several GradingRGBCurveTransform only one can have dynamic parameters.
1238  */
1239  virtual bool isDynamic() const noexcept = 0;
1240  virtual void makeDynamic() noexcept = 0;
1241  virtual void makeNonDynamic() noexcept = 0;
1242 
1244  GradingRGBCurveTransform & operator= (const GradingRGBCurveTransform &) = delete;
1245  /// Do not use (needed only for pybind11).
1246  virtual ~GradingRGBCurveTransform() = default;
1247 
1248 protected:
1249  GradingRGBCurveTransform() = default;
1250 };
1251 
1252 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const GradingRGBCurveTransform &) noexcept;
1253 
1254 
1255 /**
1256  * Tonal color correction controls.
1257  *
1258  * This transform is for making fine adjustments to tone reproduction in specific tonal ranges.
1259  *
1260  * There are five tonal controls and each one has two parameters to control its range:
1261  * * Blacks (start, width)
1262  * * Shadows(start, pivot)
1263  * * Midtones(center, width)
1264  * * Highlights(start, pivot)
1265  * * Whites(start, width)
1266  *
1267  * The transform has three styles that adjust the response and default ranges for linear,
1268  * logarithimic, and video color encodings. The defaults vary based on the style. When the
1269  * style is linear, the units for start/width/etc. are photographic stops relative to 0.18.
1270  *
1271  * Each control allows R, G, B adjustments and a Master adjustment.
1272  *
1273  * There is also an S-contrast control for imparting an S-shape curve.
1274  *
1275  * The controls are dynamic, so they may be adjusted even after the Transform has been included
1276  * in a Processor.
1277  */
1279 {
1280 public:
1281  /// Creates an instance of GradingToneTransform.
1282  static GradingToneTransformRcPtr Create(GradingStyle style);
1283 
1284  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_GRADING_TONE; }
1285 
1286  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1287  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1288 
1289  virtual bool equals(const GradingToneTransform & other) const noexcept = 0;
1290 
1291  /// Adjusts the behavior of the transform for log, linear, or video color space encodings.
1292  virtual GradingStyle getStyle() const noexcept = 0;
1293  /// Will reset value to style's defaults if style is not the current style.
1294  virtual void setStyle(GradingStyle style) noexcept = 0;
1295 
1296  virtual const GradingTone & getValue() const = 0;
1297  virtual void setValue(const GradingTone & values) = 0;
1298 
1299  /**
1300  * Parameters can be made dynamic so the values can be changed through the CPU or GPU processor,
1301  * but if there are several GradingToneTransform only one can have dynamic parameters.
1302  */
1303  virtual bool isDynamic() const noexcept = 0;
1304  virtual void makeDynamic() noexcept = 0;
1305  virtual void makeNonDynamic() noexcept = 0;
1306 
1307  GradingToneTransform(const GradingToneTransform &) = delete;
1308  GradingToneTransform & operator= (const GradingToneTransform &) = delete;
1309  /// Do not use (needed only for pybind11).
1310  virtual ~GradingToneTransform() = default;
1311 
1312 protected:
1313  GradingToneTransform() = default;
1314 };
1315 
1316 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const GradingToneTransform &) noexcept;
1317 
1318 
1319 class OCIOEXPORT GroupTransform : public Transform
1320 {
1321 public:
1322  static GroupTransformRcPtr Create();
1323 
1324  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1325  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1326 
1327  /// Throws if index is not allowed.
1328  virtual ConstTransformRcPtr getTransform(int index) const = 0;
1329 
1330  /// Throws if index is not allowed.
1331  virtual TransformRcPtr & getTransform(int index) = 0;
1332 
1333  /// Return number of transforms.
1334  virtual int getNumTransforms() const noexcept = 0;
1335  /// Adds a transform to the end of the group.
1336  virtual void appendTransform(TransformRcPtr transform) noexcept = 0;
1337  /// Add a transform at the beginning of the group.
1338  virtual void prependTransform(TransformRcPtr transform) noexcept = 0;
1339 
1340  /**
1341  * \brief Write the transforms comprising the group to the stream.
1342  *
1343  * Writing (as opposed to Baking) is a lossless process. An exception is thrown if the
1344  * processor cannot be losslessly written to the specified file format. Transforms such as
1345  * FileTransform or ColorSpaceTransform are resolved into write-able simple transforms using
1346  * the config and context. Supported formats include CTF, CLF, and CDL. All available formats
1347  * can be listed with the following:
1348  * \code{.cpp}
1349  * // What are the allowed writing output formats?
1350  * std::ostringstream formats;
1351  * formats << "Formats to write to: ";
1352  * for (int i = 0; i < GroupTransform::GetNumWriteFormats(); ++i)
1353  * {
1354  * if (i != 0) formats << ", ";
1355  * formats << GroupTransform::GetFormatNameByIndex(i);
1356  * formats << " (." << GroupTransform::GetFormatExtensionByIndex(i) << ")";
1357  * }
1358  * \endcode
1359  */
1360  virtual void write(const ConstConfigRcPtr & config,
1361  const char * formatName,
1362  std::ostream & os) const = 0;
1363 
1364  /// Get the number of writers.
1365  static int GetNumWriteFormats() noexcept;
1366 
1367  /// Get the writer at index, return empty string if an invalid index is specified.
1368  static const char * GetFormatNameByIndex(int index) noexcept;
1369  static const char * GetFormatExtensionByIndex(int index) noexcept;
1370 
1371  GroupTransform(const GroupTransform &) = delete;
1372  GroupTransform & operator=(const GroupTransform &) = delete;
1373  /// Do not use (needed only for pybind11).
1374  virtual ~GroupTransform() = default;
1375 
1376 protected:
1377  GroupTransform() = default;
1378 };
1379 
1380 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const GroupTransform &);
1381 
1382 
1383 
1384 /**
1385  * Applies a logarithm with an affine transform before and after.
1386  * Represents the Cineon lin-to-log type transforms::
1387  *
1388  * logSideSlope * log( linSideSlope * color + linSideOffset, base) + logSideOffset
1389  *
1390  * * Default values are: 1. * log( 1. * color + 0., 2.) + 0.
1391  * * The alpha channel is not affected.
1392  */
1393 class OCIOEXPORT LogAffineTransform : public Transform
1394 {
1395 public:
1396  static LogAffineTransformRcPtr Create();
1397 
1398  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_LOG_AFFINE; }
1399 
1400  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1401  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1402 
1403  /// Checks if this exactly equals other.
1404  virtual bool equals(const LogAffineTransform & other) const noexcept = 0;
1405 
1406  virtual double getBase() const noexcept = 0;
1407  virtual void setBase(double base) noexcept = 0;
1408 
1409  // !rst:: **Get/Set values for the R, G, B components**
1410 
1411  virtual void getLogSideSlopeValue(double(&values)[3]) const noexcept = 0;
1412  virtual void setLogSideSlopeValue(const double(&values)[3]) noexcept = 0;
1413  virtual void getLogSideOffsetValue(double(&values)[3]) const noexcept = 0;
1414  virtual void setLogSideOffsetValue(const double(&values)[3]) noexcept = 0;
1415  virtual void getLinSideSlopeValue(double(&values)[3]) const noexcept = 0;
1416  virtual void setLinSideSlopeValue(const double(&values)[3]) noexcept = 0;
1417  virtual void getLinSideOffsetValue(double(&values)[3]) const noexcept = 0;
1418  virtual void setLinSideOffsetValue(const double(&values)[3]) noexcept = 0;
1419 
1420  LogAffineTransform(const LogAffineTransform &) = delete;
1421  LogAffineTransform & operator= (const LogAffineTransform &) = delete;
1422  /// Do not use (needed only for pybind11).
1423  virtual ~LogAffineTransform() = default;
1424 
1425 protected:
1426  LogAffineTransform() = default;
1427 };
1428 
1429 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const LogAffineTransform &);
1430 
1431 
1432 /**
1433  * Same as LogAffineTransform but with the addition of a linear segment near black. This formula
1434  * is used for many camera logs (e.g., LogC) as well as ACEScct.
1435  *
1436  * * The linSideBreak specifies the point on the linear axis where the log and linear
1437  * segments meet. It must be set (there is no default).
1438  * * The linearSlope specifies the slope of the linear segment of the forward (linToLog)
1439  * transform. By default it is set equal to the slope of the log curve at the break point.
1440  */
1442 {
1443 public:
1444  /// LinSideBreak must be set for the transform to be valid (there is no default).
1445  static LogCameraTransformRcPtr Create(const double(&linSideBreakValues)[3]);
1446 
1447  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_LOG_CAMERA; }
1448 
1449  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1450  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1451 
1452  /// Checks if this exactly equals other.
1453  virtual bool equals(const LogCameraTransform & other) const noexcept = 0;
1454 
1455  virtual double getBase() const noexcept = 0;
1456  virtual void setBase(double base) noexcept = 0;
1457 
1458  /// Get/Set values for the R, G, B components.
1459  virtual void getLogSideSlopeValue(double(&values)[3]) const noexcept = 0;
1460  virtual void setLogSideSlopeValue(const double(&values)[3]) noexcept = 0;
1461  virtual void getLogSideOffsetValue(double(&values)[3]) const noexcept = 0;
1462  virtual void setLogSideOffsetValue(const double(&values)[3]) noexcept = 0;
1463  virtual void getLinSideSlopeValue(double(&values)[3]) const noexcept = 0;
1464  virtual void setLinSideSlopeValue(const double(&values)[3]) noexcept = 0;
1465  virtual void getLinSideOffsetValue(double(&values)[3]) const noexcept = 0;
1466  virtual void setLinSideOffsetValue(const double(&values)[3]) noexcept = 0;
1467  virtual void getLinSideBreakValue(double(&values)[3]) const noexcept = 0;
1468  virtual void setLinSideBreakValue(const double(&values)[3]) noexcept = 0;
1469 
1470  /// Return true if LinearSlope values were set, false if they were not.
1471  virtual bool getLinearSlopeValue(double(&values)[3]) const = 0;
1472  /**
1473  * \brief Set LinearSlope value.
1474  *
1475  * \note
1476  * You must call setLinSideBreakValue before calling this.
1477  */
1478  virtual void setLinearSlopeValue(const double(&values)[3]) = 0;
1479  /// Remove LinearSlope values so that default values are used.
1480  virtual void unsetLinearSlopeValue() = 0;
1481 
1482  LogCameraTransform(const LogCameraTransform &) = delete;
1483  LogCameraTransform & operator= (const LogCameraTransform &) = delete;
1484  /// Do not use (needed only for pybind11).
1485  virtual ~LogCameraTransform() = default;
1486 
1487 protected:
1488  LogCameraTransform() = default;
1489 };
1490 
1491 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const LogCameraTransform &);
1492 
1493 
1494 /**
1495  * Represents log transform: log(color, base)
1496  *
1497  * * The input will be clamped for negative numbers.
1498  * * Default base is 2.0.
1499  * * The alpha channel is not affected.
1500  */
1501 class OCIOEXPORT LogTransform : public Transform
1502 {
1503 public:
1504  static LogTransformRcPtr Create();
1505 
1506  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_LOG; }
1507 
1508  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1509  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1510 
1511  /// Checks if this exactly equals other.
1512  virtual bool equals(const LogTransform & other) const noexcept = 0;
1513 
1514  virtual double getBase() const noexcept = 0;
1515  virtual void setBase(double val) noexcept = 0;
1516 
1517  LogTransform(const LogTransform &) = delete;
1518  LogTransform & operator= (const LogTransform &) = delete;
1519  /// Do not use (needed only for pybind11).
1520  virtual ~LogTransform() = default;
1521 
1522 protected:
1523  LogTransform() = default;
1524 };
1525 
1526 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const LogTransform &);
1527 
1528 
1529 class OCIOEXPORT LookTransform : public Transform
1530 {
1531 public:
1532  static LookTransformRcPtr Create();
1533 
1534  TransformRcPtr createEditableCopy() const override;
1535 
1536  TransformDirection getDirection() const noexcept override;
1537  void setDirection(TransformDirection dir) noexcept override;
1538 
1539  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_LOOK; }
1540 
1541  /// Will throw if data is not valid.
1542  void validate() const override;
1543 
1544  const char * getSrc() const;
1545  void setSrc(const char * src);
1546 
1547  const char * getDst() const;
1548  void setDst(const char * dst);
1549 
1550  const char * getLooks() const;
1551  /**
1552  * Specify looks to apply.
1553  * Looks is a potentially comma (or colon) delimited list of look names,
1554  * Where +/- prefixes are optionally allowed to denote forward/inverse
1555  * look specification. (And forward is assumed in the absence of either)
1556  */
1557  void setLooks(const char * looks);
1558 
1559  bool getSkipColorSpaceConversion() const;
1560  void setSkipColorSpaceConversion(bool skip);
1561 
1562  /**
1563  * Return the name of the color space after applying looks in the forward
1564  * direction but without converting to the destination color space. This is equivalent
1565  * to the process space of the last look in the look sequence (and takes into account that
1566  * a look fall-back may be used).
1567  */
1568  static const char * GetLooksResultColorSpace(const ConstConfigRcPtr & config,
1569  const ConstContextRcPtr & context,
1570  const char * looks);
1571 
1572  LookTransform & operator=(const LookTransform &) = delete;
1573  /// Do not use (needed only for pybind11).
1574  virtual ~LookTransform();
1575 
1576 private:
1577  LookTransform();
1578  LookTransform(const LookTransform &);
1579 
1580  static void deleter(LookTransform * t);
1581 
1582  class Impl;
1583  Impl * m_impl;
1584  Impl * getImpl() { return m_impl; }
1585  const Impl * getImpl() const { return m_impl; }
1586 };
1587 
1588 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const LookTransform &);
1589 
1590 
1591 /// Represents a 1D-LUT transform.
1592 class OCIOEXPORT Lut1DTransform : public Transform
1593 {
1594 public:
1595  /// Create an identity 1D-LUT of length two.
1596  static Lut1DTransformRcPtr Create();
1597 
1598  /**
1599  * Create an identity 1D-LUT with specific length and
1600  * half-domain setting. Will throw for lengths longer than 1024x1024.
1601  */
1602  static Lut1DTransformRcPtr Create(unsigned long length,
1603  bool isHalfDomain);
1604 
1605  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_LUT1D; }
1606 
1607  virtual BitDepth getFileOutputBitDepth() const noexcept = 0;
1608  /**
1609  * Get the bit-depth associated with the LUT values read
1610  * from a file or set the bit-depth of values to be written to a file
1611  * (for file formats such as CLF that support multiple bit-depths).
1612  * However, note that the values stored in the object are always
1613  * normalized.
1614  */
1615  virtual void setFileOutputBitDepth(BitDepth bitDepth) noexcept = 0;
1616 
1617  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1618  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1619 
1620  /// Checks if this exactly equals other.
1621  virtual bool equals(const Lut1DTransform & other) const noexcept = 0;
1622 
1623  virtual unsigned long getLength() const = 0;
1624  /**
1625  * Changing the length will reset the LUT to identity.
1626  * Will throw for lengths longer than 1024x1024.
1627  */
1628  virtual void setLength(unsigned long length) = 0;
1629 
1630  virtual void getValue(unsigned long index, float & r, float & g, float & b) const = 0;
1631  /**
1632  * Set the values of a LUT1D. Will throw if the index
1633  * is outside of the range from 0 to (length-1).
1634  *
1635  * The LUT values are always for the "forward" LUT, regardless of how
1636  * the transform direction is set.
1637  *
1638  * These values are normalized relative to what may be stored in any
1639  * given LUT files. For example in a CLF file using a "10i" output
1640  * depth, a value of 1023 in the file is normalized to 1.0. The
1641  * values here are unclamped and may extend outside [0,1].
1642  *
1643  * LUTs in various file formats may only provide values for one
1644  * channel where R, G, B are the same. Even in that case, you should
1645  * provide three equal values to the setter.
1646  */
1647  virtual void setValue(unsigned long index, float r, float g, float b) = 0;
1648 
1649  virtual bool getInputHalfDomain() const noexcept = 0;
1650  /**
1651  * In a half-domain LUT, the contents of the LUT specify
1652  * the desired value of the function for each half-float value.
1653  * Therefore, the length of the LUT must be 65536 entries or else
1654  * validate() will throw.
1655  */
1656  virtual void setInputHalfDomain(bool isHalfDomain) noexcept = 0;
1657 
1658  virtual bool getOutputRawHalfs() const noexcept = 0;
1659  /**
1660  * Set OutputRawHalfs to true if you want to output the
1661  * LUT contents as 16-bit floating point values expressed as unsigned
1662  * 16-bit integers representing the equivalent bit pattern.
1663  * For example, the value 1.0 would be written as the integer 15360
1664  * because it has the same bit-pattern. Note that this implies the
1665  * values will be quantized to a 16-bit float. Note that this setting
1666  * only controls the output formatting (where supported) and not the
1667  * values for getValue/setValue. The only file formats that currently
1668  * support this are CLF and CTF.
1669  */
1670  virtual void setOutputRawHalfs(bool isRawHalfs) noexcept = 0;
1671 
1672  virtual Lut1DHueAdjust getHueAdjust() const noexcept = 0;
1673  /**
1674  * The 1D-LUT transform optionally supports a hue adjustment
1675  * feature that was used in some versions of ACES. This adjusts the hue
1676  * of the result to approximately match the input.
1677  */
1678  virtual void setHueAdjust(Lut1DHueAdjust algo) = 0;
1679 
1680  virtual Interpolation getInterpolation() const = 0;
1681  virtual void setInterpolation(Interpolation algo) = 0;
1682 
1683  Lut1DTransform(const Lut1DTransform &) = delete;
1684  Lut1DTransform & operator= (const Lut1DTransform &) = delete;
1685  /// Do not use (needed only for pybind11).
1686  virtual ~Lut1DTransform() = default;
1687 
1688 protected:
1689  Lut1DTransform() = default;
1690 };
1691 
1692 extern OCIOEXPORT std::ostream& operator<< (std::ostream&, const Lut1DTransform&);
1693 
1694 
1695 /// Represents a 3D-LUT transform.
1696 class OCIOEXPORT Lut3DTransform : public Transform
1697 {
1698 public:
1699  /// Create an identity 3D-LUT of size 2x2x2.
1700  static Lut3DTransformRcPtr Create();
1701 
1702  /**
1703  * Create an identity 3D-LUT with specific grid size.
1704  * Will throw for grid size larger than 129.
1705  */
1706  static Lut3DTransformRcPtr Create(unsigned long gridSize);
1707 
1708  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_LUT3D; }
1709 
1710  virtual BitDepth getFileOutputBitDepth() const noexcept = 0;
1711  /**
1712  * Get the bit-depth associated with the LUT values read
1713  * from a file or set the bit-depth of values to be written to a file
1714  * (for file formats such as CLF that support multiple bit-depths).
1715  * However, note that the values stored in the object are always
1716  * normalized.
1717  */
1718  virtual void setFileOutputBitDepth(BitDepth bitDepth) noexcept = 0;
1719 
1720  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1721  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1722 
1723  /// Checks if this exactly equals other.
1724  virtual bool equals(const Lut3DTransform & other) const noexcept = 0;
1725 
1726  virtual unsigned long getGridSize() const = 0;
1727  /**
1728  * Changing the grid size will reset the LUT to identity.
1729  * Will throw for grid sizes larger than 129.
1730  */
1731  virtual void setGridSize(unsigned long gridSize) = 0;
1732 
1733  virtual void getValue(unsigned long indexR,
1734  unsigned long indexG,
1735  unsigned long indexB,
1736  float & r, float & g, float & b) const = 0;
1737  /**
1738  * Set the values of a 3D-LUT. Will throw if an index is
1739  * outside of the range from 0 to (gridSize-1).
1740  *
1741  * The LUT values are always for the "forward" LUT, regardless of how the
1742  * transform direction is set.
1743  *
1744  * These values are normalized relative to what may be stored in any
1745  * given LUT files. For example in a CLF file using a "10i" output
1746  * depth, a value of 1023 in the file is normalized to 1.0. The values
1747  * here are unclamped and may extend outside [0,1].
1748  */
1749  virtual void setValue(unsigned long indexR,
1750  unsigned long indexG,
1751  unsigned long indexB,
1752  float r, float g, float b) = 0;
1753 
1754  virtual Interpolation getInterpolation() const = 0;
1755  virtual void setInterpolation(Interpolation algo) = 0;
1756 
1757  Lut3DTransform(const Lut3DTransform &) = delete;
1758  Lut3DTransform & operator= (const Lut3DTransform &) = delete;
1759  /// Do not use (needed only for pybind11).
1760  virtual ~Lut3DTransform() = default;
1761 
1762 protected:
1763  Lut3DTransform() = default;
1764 };
1765 
1766 extern OCIOEXPORT std::ostream& operator<< (std::ostream&, const Lut3DTransform&);
1767 
1768 /**
1769  * Represents an MX+B Matrix transform.
1770  *
1771  * \note
1772  * For singular matrices, an inverse direction will throw an exception during finalization.
1773  */
1775 {
1776 public:
1777  static MatrixTransformRcPtr Create();
1778 
1779  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_MATRIX; }
1780 
1781  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1782  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1783 
1784  /// Checks if this exactly equals other.
1785  virtual bool equals(const MatrixTransform & other) const noexcept = 0;
1786 
1787  virtual void getMatrix(double * m44) const = 0;
1788  /**
1789  * Get or set the values of a Matrix. Expects 16 values,
1790  * where the first four are the coefficients to generate the R output
1791  * channel from R, G, B, A input channels.
1792  *
1793  * The Matrix values are always for the "forward" Matrix, regardless of
1794  * how the transform direction is set.
1795  *
1796  * These values are normalized relative to what may be stored in
1797  * file formats such as CLF. For example in a CLF file using a "32f"
1798  * input depth and "10i" output depth, a value of 1023 in the file
1799  * is normalized to 1.0. The values here are unclamped and may
1800  * extend outside [0,1].
1801  */
1802  virtual void setMatrix(const double * m44) = 0;
1803 
1804  virtual void getOffset(double * offset4) const = 0;
1805  /**
1806  * Get or set the R, G, B, A offsets to be applied
1807  * after the matrix.
1808  *
1809  * These values are normalized relative to what may be stored in
1810  * file formats such as CLF. For example, in a CLF file using a
1811  * "10i" output depth, a value of 1023 in the file is normalized
1812  * to 1.0. The values here are unclamped and may extend
1813  * outside [0,1].
1814  */
1815  virtual void setOffset(const double * offset4) = 0;
1816 
1817  /**
1818  * Get the bit-depths associated with the matrix values read from a
1819  * file or set the bit-depths of values to be written to a file
1820  * (for file formats such as CLF that support multiple bit-depths).
1821  *
1822  * In a format such as CLF, the matrix values are scaled to take
1823  * pixels at the specified inBitDepth to pixels at the specified
1824  * outBitDepth. This complicates the interpretation of the matrix
1825  * values and so this object always holds normalized values and
1826  * scaling is done on the way from or to file formats such as CLF.
1827  */
1828  virtual BitDepth getFileInputBitDepth() const noexcept = 0;
1829  virtual void setFileInputBitDepth(BitDepth bitDepth) noexcept = 0;
1830  virtual BitDepth getFileOutputBitDepth() const noexcept = 0;
1831  virtual void setFileOutputBitDepth(BitDepth bitDepth) noexcept = 0;
1832 
1833 
1834  /// **Convenience functions**
1835  ///
1836  /// Build the matrix and offset corresponding to higher-level concepts.
1837  ///
1838  /// \note
1839  /// These can throw an exception if for any component
1840  /// ``oldmin == oldmax. (divide by 0)``
1841  static void Fit(double * m44, double* offset4,
1842  const double * oldmin4, const double * oldmax4,
1843  const double * newmin4, const double * newmax4);
1844 
1845  static void Identity(double * m44, double * offset4);
1846 
1847  static void Sat(double * m44, double * offset4,
1848  double sat, const double * lumaCoef3);
1849 
1850  static void Scale(double * m44, double * offset4,
1851  const double * scale4);
1852 
1853  static void View(double * m44, double * offset4,
1854  int * channelHot4,
1855  const double * lumaCoef3);
1856 
1857  MatrixTransform(const MatrixTransform &) = delete;
1858  MatrixTransform & operator= (const MatrixTransform &) = delete;
1859  /// Do not use (needed only for pybind11).
1860  virtual ~MatrixTransform() = default;
1861 
1862 protected:
1863  MatrixTransform() = default;
1864 };
1865 
1866 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const MatrixTransform &) noexcept;
1867 
1868 
1869 /**
1870  * Represents a range transform
1871  *
1872  * The Range is used to apply an affine transform (scale & offset) and
1873  * clamps values to min/max bounds on all color components except the alpha.
1874  * The scale and offset values are computed from the input and output bounds.
1875  *
1876  * Refer to section 7.2.4 in specification S-2014-006 "A Common File Format
1877  * for Look-Up Tables" from the Academy of Motion Picture Arts and Sciences
1878  * and the American Society of Cinematographers.
1879  *
1880  * \note
1881  * The "noClamp" style described in the specification S-2014-006 becomes a
1882  * MatrixOp at the processor level.
1883  *
1884  * \note
1885  * Changing the transform direction does not modify the in/out values --
1886  * they are always specified with respect to the "forward" direction.
1887  */
1888 class OCIOEXPORT RangeTransform : public Transform
1889 {
1890 public:
1891  /// Creates an instance of RangeTransform.
1892  static RangeTransformRcPtr Create();
1893 
1894  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_RANGE; }
1895 
1896  virtual RangeStyle getStyle() const noexcept = 0;
1897  /// Set the Range style to clamp or not input values.
1898  virtual void setStyle(RangeStyle style) noexcept = 0;
1899 
1900  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1901  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1902 
1903  /// Checks if this equals other.
1904  virtual bool equals(const RangeTransform & other) const noexcept = 0;
1905 
1906  /**
1907  * **File bit-depth**
1908  *
1909  * In a format such as CLF, the range values are scaled to take
1910  * pixels at the specified inBitDepth to pixels at the specified
1911  * outBitDepth. This complicates the interpretation of the range
1912  * values and so this object always holds normalized values and
1913  * scaling is done on the way from or to file formats such as CLF.
1914  */
1915 
1916  /// Get the bit-depths associated with the range values read from a file
1917  /// or set the bit-depths of values to be written to a file (for file
1918  /// formats such as CLF that support multiple bit-depths).
1919  virtual BitDepth getFileInputBitDepth() const noexcept = 0;
1920  virtual void setFileInputBitDepth(BitDepth bitDepth) noexcept = 0;
1921  virtual BitDepth getFileOutputBitDepth() const noexcept = 0;
1922  virtual void setFileOutputBitDepth(BitDepth bitDepth) noexcept = 0;
1923 
1924  /**
1925  * **Range values**
1926  *
1927  * These values are normalized relative to what may be stored in file
1928  * formats such as CLF. For example in a CLF file using a "10i" input
1929  * depth, a MaxInValue of 1023 in the file is normalized to 1.0.
1930  * Likewise, for an output depth of "12i", a MaxOutValue of 4095 in the
1931  * file is normalized to 1.0. The values here are unclamped and may
1932  * extend outside [0,1].
1933  */
1934 
1935  /// Get the minimum value for the input.
1936  virtual double getMinInValue() const noexcept = 0;
1937  /// Set the minimum value for the input.
1938  virtual void setMinInValue(double val) noexcept = 0;
1939  /// Is the minimum value for the input set?
1940  virtual bool hasMinInValue() const noexcept = 0;
1941  /// Unset the minimum value for the input
1942  virtual void unsetMinInValue() noexcept = 0;
1943 
1944  /// Set the maximum value for the input.
1945  virtual void setMaxInValue(double val) noexcept = 0;
1946  /// Get the maximum value for the input.
1947  virtual double getMaxInValue() const noexcept = 0;
1948  /// Is the maximum value for the input set?
1949  virtual bool hasMaxInValue() const noexcept = 0;
1950  /// Unset the maximum value for the input.
1951  virtual void unsetMaxInValue() noexcept = 0;
1952 
1953  /// Set the minimum value for the output.
1954  virtual void setMinOutValue(double val) noexcept = 0;
1955  /// Get the minimum value for the output.
1956  virtual double getMinOutValue() const noexcept = 0;
1957  /// Is the minimum value for the output set?
1958  virtual bool hasMinOutValue() const noexcept = 0;
1959  /// Unset the minimum value for the output.
1960  virtual void unsetMinOutValue() noexcept = 0;
1961 
1962  /// Set the maximum value for the output.
1963  virtual void setMaxOutValue(double val) noexcept = 0;
1964  /// Get the maximum value for the output.
1965  virtual double getMaxOutValue() const noexcept = 0;
1966  /// Is the maximum value for the output set?
1967  virtual bool hasMaxOutValue() const noexcept = 0;
1968  /// Unset the maximum value for the output.
1969  virtual void unsetMaxOutValue() noexcept = 0;
1970 
1971  RangeTransform(const RangeTransform &) = delete;
1972  RangeTransform & operator= (const RangeTransform &) = delete;
1973  /// Do not use (needed only for pybind11).
1974  virtual ~RangeTransform() = default;
1975 
1976 protected:
1977  RangeTransform() = default;
1978 };
1979 
1980 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const RangeTransform &) noexcept;
1981 
1982 } // namespace OCIO_NAMESPACE
1983 
1984 #endif
OCIO_SHARED_PTR< DisplayViewTransform > DisplayViewTransformRcPtr
2D control point used by GradingBSplineCurve.
Represents exponent transform: pow( clamp(color), value ).
TransformType getTransformType() const noexceptoverride
TransformType getTransformType() const noexceptoverride
PXL_API const char * getDescription(const ColorSpace *space)
Return the description of the color space.
TransformType getTransformType() const noexceptoverride
OCIO_SHARED_PTR< LookTransform > LookTransformRcPtr
*get result *(waiting if necessary)*A common idiom is to fire a bunch of sub tasks at the and then *wait for them to all complete We provide a helper class
Definition: thread.h:623
RangeStyle
A RangeTransform may be set to clamp the values, or not.
void skip(T &in, int n)
Definition: ImfXdr.h:711
Algorithms for Scene Linear color spaces.
Represents a 1D-LUT transform.
OCIO_SHARED_PTR< ExponentTransform > ExponentTransformRcPtr
GradingRGBMSW(const double(&rgbmsw)[6])
GLuint start
Definition: glcorearb.h:475
OCIO_SHARED_PTR< DynamicPropertyGradingTone > DynamicPropertyGradingToneRcPtr
TransformType getTransformType() const noexceptoverride
GLboolean GLboolean g
Definition: glcorearb.h:1222
Interface used to access dynamic property double value.
OCIO_SHARED_PTR< const Transform > ConstTransformRcPtr
OCIO_SHARED_PTR< AllocationTransform > AllocationTransformRcPtr
bool isIdentity(const MatType &m)
Determine if a matrix is an identity matrix.
Definition: Mat.h:860
GradingRGBM(const double(&rgbm)[4])
GLuint GLsizei GLsizei * length
Definition: glcorearb.h:795
OCIO_SHARED_PTR< Lut1DTransform > Lut1DTransformRcPtr
#define OCIO_NAMESPACE
Definition: OpenColorABI.h:8
GLint y
Definition: glcorearb.h:103
OCIO_SHARED_PTR< LogCameraTransform > LogCameraTransformRcPtr
DynamicPropertyType
Types for dynamic properties.
GradingRGBM(double red, double green, double blue, double master)
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: glcorearb.h:2539
Interface used to access dynamic property GradingTone value.
GradingRGBMSW(double start, double width)
class OCIOEXPORT DynamicProperty
TransformType getTransformType() const noexceptoverride
GLenum const GLfloat * params
Definition: glcorearb.h:105
OCIO_SHARED_PTR< FixedFunctionTransform > FixedFunctionTransformRcPtr
OCIOEXPORT DynamicPropertyGradingPrimaryRcPtr AsGradingPrimary(DynamicPropertyRcPtr &prop)
OCIO_SHARED_PTR< DynamicPropertyGradingRGBCurve > DynamicPropertyGradingRGBCurveRcPtr
OCIO_SHARED_PTR< ExponentWithLinearTransform > ExponentWithLinearTransformRcPtr
TransformType getTransformType() const noexceptoverride
TransformType getTransformType() const noexceptoverride
class OCIOEXPORT LookTransform
TransformType getTransformType() const noexceptoverride
OCIO_SHARED_PTR< ColorSpaceTransform > ColorSpaceTransformRcPtr
OCIO_SHARED_PTR< const Context > ConstContextRcPtr
TransformType getTransformType() const noexceptoverride
Interface used to access dynamic property ConstGradingRGBCurveRcPtr value.
Algorithms for Logarithmic color spaces.
OCIO_SHARED_PTR< DynamicPropertyDouble > DynamicPropertyDoubleRcPtr
TransformType getTransformType() const noexceptoverride
OCIO_SHARED_PTR< Lut3DTransform > Lut3DTransformRcPtr
OCIOEXPORT DynamicPropertyGradingRGBCurveRcPtr AsGradingRGBCurve(DynamicPropertyRcPtr &prop)
OCIO_SHARED_PTR< ExposureContrastTransform > ExposureContrastTransformRcPtr
TransformType getTransformType() const noexceptoverride
PXL_API const char * getName(const ColorSpace *space)
Return the name of the color space.
OCIO_SHARED_PTR< LogTransform > LogTransformRcPtr
class OCIOEXPORT GroupTransform
TransformType getTransformType() const noexceptoverride
class OCIOEXPORT GradingBSplineCurve
TransformType getTransformType() const noexceptoverride
GLfloat green
Definition: glcorearb.h:112
TransformType getTransformType() const noexceptoverride
#define OCIOEXPORT
Definition: OpenColorABI.h:67
class OCIOEXPORT Transform
OCIO_SHARED_PTR< GradingPrimaryTransform > GradingPrimaryTransformRcPtr
OCIO_SHARED_PTR< GradingBSplineCurve > GradingBSplineCurveRcPtr
TransformType getTransformType() const noexceptoverride
GLuint const GLchar * name
Definition: glcorearb.h:786
class OCIOEXPORT GradingRGBCurve
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
GA_API const UT_StringHolder transform
GLint GLenum GLint x
Definition: glcorearb.h:409
OCIO_SHARED_PTR< GradingRGBCurve > GradingRGBCurveRcPtr
An implementation of the ASC Color Decision List (CDL), based on the ASC v1.2 specification.
Base class for all the transform classes.
TransformType getTransformType() const noexceptoverride
OCIO_SHARED_PTR< MatrixTransform > MatrixTransformRcPtr
GLdouble t
Definition: glad.h:2397
OCIO_SHARED_PTR< Transform > TransformRcPtr
GradingStyle
Styles for grading transforms.
TransformType getTransformType() const noexceptoverride
class OCIOEXPORT DynamicPropertyGradingPrimary
GLsizeiptr size
Definition: glcorearb.h:664
OCIO_SHARED_PTR< const Config > ConstConfigRcPtr
GLenum GLenum dst
Definition: glcorearb.h:1793
OCIO_SHARED_PTR< RangeTransform > RangeTransformRcPtr
OCIO_SHARED_PTR< GradingToneTransform > GradingToneTransformRcPtr
OCIO_SHARED_PTR< DynamicPropertyGradingPrimary > DynamicPropertyGradingPrimaryRcPtr
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1602
TransformType getTransformType() const noexceptoverride
TransformType getTransformType() const noexceptoverride
Interface used to access dynamic property GradingPrimary value.
GLuint index
Definition: glcorearb.h:786
OCIO_SHARED_PTR< BuiltinTransform > BuiltinTransformRcPtr
OCIO_SHARED_PTR< FileTransform > FileTransformRcPtr
GLuint GLfloat * val
Definition: glcorearb.h:1608
GA_API const UT_StringHolder pivot
Lut1DHueAdjust
Used by :cpp:classLut1DTransform to control optional hue restoration algorithm.
OCIO_SHARED_PTR< const GradingBSplineCurve > ConstGradingBSplineCurveRcPtr
class OCIOEXPORT AllocationTransform
OCIO_SHARED_PTR< LogAffineTransform > LogAffineTransformRcPtr
GLint GLsizei width
Definition: glcorearb.h:103
OCIOEXPORT std::ostream & operator<<(std::ostream &, const ColorSpaceMenuParameters &)
Definition: core.h:982
FixedFunctionStyle
Enumeration of the :cpp:class:FixedFunctionTransform transform algorithms.
Definition: core.h:1131
OCIO_SHARED_PTR< GroupTransform > GroupTransformRcPtr
Represents a 3D-LUT transform.
OCIOEXPORT DynamicPropertyDoubleRcPtr AsDouble(DynamicPropertyRcPtr &prop)
class OCIOEXPORT FileTransform
PXL_API void getLooks(UT_StringArray &looks)
Returns a list of looks (color transforms)
GLboolean r
Definition: glcorearb.h:1222
#define const
Definition: zconf.h:214
GLfloat GLfloat blue
Definition: glcorearb.h:112
GradingRGBMSW(double red, double green, double blue, double master, double start, double width)
OCIO_SHARED_PTR< CDLTransform > CDLTransformRcPtr
class OCIOEXPORT DynamicPropertyGradingTone
void write(T &out, bool v)
Definition: ImfXdr.h:287
OCIO_SHARED_PTR< GradingRGBCurveTransform > GradingRGBCurveTransformRcPtr
A BSpline curve defined with GradingControlPoint.
TransformType getTransformType() const noexceptoverride
class OCIOEXPORT DisplayViewTransform
png_structrp int png_fixed_point red
Definition: png.h:1083
OCIO_SHARED_PTR< const GradingRGBCurve > ConstGradingRGBCurveRcPtr
RGBCurveType
Types for GradingRGBCurve.
class OCIOEXPORT DynamicPropertyDouble
TransformType getTransformType() const noexceptoverride
OCIOEXPORT DynamicPropertyGradingToneRcPtr AsGradingTone(DynamicPropertyRcPtr &prop)
ExposureContrastStyle
Enumeration of the :cpp:class:ExposureContrastTransform transform algorithms.
OCIO_SHARED_PTR< DynamicProperty > DynamicPropertyRcPtr
GLenum src
Definition: glcorearb.h:1793
class OCIOEXPORT DynamicPropertyGradingRGBCurve