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 
162  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_ALLOCATION; }
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 
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 
203  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_BUILTIN; }
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:
222  BuiltinTransform(const BuiltinTransform &) = delete;
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 
386  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_DISPLAY_VIEW; }
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 bool operator==(const GradingRGBM & lhs, const GradingRGBM & rhs);
457 extern OCIOEXPORT bool operator!=(const GradingRGBM & lhs, const GradingRGBM & rhs);
458 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const GradingRGBM &);
459 
460 /// Grading primary values.
462 {
463  GradingPrimary() = delete;
464  explicit GradingPrimary(GradingStyle style)
465  : m_pivot(style == GRADING_LOG ? -0.2 : 0.18)
466  , m_clampBlack(NoClampBlack())
467  , m_clampWhite(NoClampWhite())
468  {
469  }
470 
471  GradingRGBM m_brightness{ 0.0, 0.0, 0.0, 0.0 };
472  GradingRGBM m_contrast { 1.0, 1.0, 1.0, 1.0 };
473  GradingRGBM m_gamma { 1.0, 1.0, 1.0, 1.0 };
474  GradingRGBM m_offset { 0.0, 0.0, 0.0, 0.0 };
475  GradingRGBM m_exposure { 0.0, 0.0, 0.0, 0.0 };
476  GradingRGBM m_lift { 0.0, 0.0, 0.0, 0.0 };
477  GradingRGBM m_gain { 1.0, 1.0, 1.0, 1.0 };
478 
479  double m_saturation{ 1.0 };
480  double m_pivot; // For LOG default is -0.2. LIN default is 0.18.
481  double m_pivotBlack{ 0.0 };
482  double m_pivotWhite{ 1.0 };
483  double m_clampBlack;
484  double m_clampWhite;
485 
486  /// The valid range for each parameter varies.
487  void validate(GradingStyle style) const;
488 
489  static double NoClampBlack();
490  static double NoClampWhite();
491 };
492 
493 extern OCIOEXPORT bool operator==(const GradingPrimary & lhs, const GradingPrimary & rhs);
494 extern OCIOEXPORT bool operator!=(const GradingPrimary & lhs, const GradingPrimary & rhs);
495 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const GradingPrimary &);
496 
497 /// 2D control point used by \ref GradingBSplineCurve.
499 {
500  GradingControlPoint() = default;
501  GradingControlPoint(float x, float y) : m_x(x), m_y(y) {}
502  float m_x{ 0.f };
503  float m_y{ 0.f };
504 };
505 
506 extern OCIOEXPORT bool operator==(const GradingControlPoint & lhs, const GradingControlPoint & rhs);
507 extern OCIOEXPORT bool operator!=(const GradingControlPoint & lhs, const GradingControlPoint & rhs);
508 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const GradingControlPoint &);
509 
510 /// A BSpline curve defined with \ref GradingControlPoint.
512 {
513 public:
514  /// Create a BSpline curve with a specified number of control points.
515  static GradingBSplineCurveRcPtr Create(size_t size);
516  /// Create a BSpline curve with a list of control points.
517  static GradingBSplineCurveRcPtr Create(std::initializer_list<GradingControlPoint> values);
518 
519  virtual GradingBSplineCurveRcPtr createEditableCopy() const = 0;
520  virtual size_t getNumControlPoints() const noexcept = 0;
521  virtual void setNumControlPoints(size_t size) = 0;
522  virtual const GradingControlPoint & getControlPoint(size_t index) const = 0;
523  virtual GradingControlPoint & getControlPoint(size_t index) = 0;
524  virtual float getSlope(size_t index) const = 0;
525  virtual void setSlope(size_t index, float slope) = 0;
526  virtual bool slopesAreDefault() const = 0;
527  virtual void validate() const = 0;
528 
529  GradingBSplineCurve(const GradingBSplineCurve &) = delete;
531 
532  /// Do not use (needed only for pybind11).
533  virtual ~GradingBSplineCurve() = default;
534 
535 protected:
536  GradingBSplineCurve() = default;
537 };
538 
539 extern OCIOEXPORT bool operator==(const GradingBSplineCurve & lhs, const GradingBSplineCurve & rhs);
540 extern OCIOEXPORT bool operator!=(const GradingBSplineCurve & lhs, const GradingBSplineCurve & rhs);
541 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const GradingBSplineCurve &);
542 
543 /**
544  * A set of red, green, blue and master curves. It is used by RGBCurveTransform and can be used as
545  * a dynamic property (see \ref DynamicPropertyGradingRGBCurve).
546  */
548 {
549 public:
550  static GradingRGBCurveRcPtr Create(GradingStyle style);
551  static GradingRGBCurveRcPtr Create(const ConstGradingRGBCurveRcPtr & rhs);
555  const ConstGradingBSplineCurveRcPtr & master);
556 
557  virtual GradingRGBCurveRcPtr createEditableCopy() const = 0;
558  virtual void validate() const = 0;
559  virtual bool isIdentity() const = 0;
560  virtual ConstGradingBSplineCurveRcPtr getCurve(RGBCurveType c) const = 0;
561  virtual GradingBSplineCurveRcPtr getCurve(RGBCurveType c) = 0;
562 
563  /// Do not use (needed only for pybind11).
564  virtual ~GradingRGBCurve() = default;
565 
566 protected:
567  GradingRGBCurve() = default;
568 };
569 
570 extern OCIOEXPORT bool operator==(const GradingRGBCurve & lhs, const GradingRGBCurve & rhs);
571 extern OCIOEXPORT bool operator!=(const GradingRGBCurve & lhs, const GradingRGBCurve & rhs);
572 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const GradingRGBCurve &);
573 
574 /**
575  * Used by the grading tone transforms to hold the red, green, blue, master, start,
576  * and width components of a single parameter. The master component affects all three channels
577  * (RGB). The start and width components control the range of tones affected. Although this
578  * struct simply uses "start" and "width" for all the range values, the actual user-facing name
579  * changes based on the parameter.
580  */
582 {
583  GradingRGBMSW() = default;
584  GradingRGBMSW(double red, double green, double blue, double master, double start, double width)
585  : m_red (red)
586  , m_green (green)
587  , m_blue (blue)
588  , m_master(master)
589  , m_start (start)
590  , m_width (width)
591  {
592  }
593  GradingRGBMSW(const double(&rgbmsw)[6])
594  : m_red (rgbmsw[0])
595  , m_green (rgbmsw[1])
596  , m_blue (rgbmsw[2])
597  , m_master(rgbmsw[3])
598  , m_start (rgbmsw[4])
599  , m_width (rgbmsw[5])
600  {
601  }
602  GradingRGBMSW(double start, double width)
603  : m_start(start)
604  , m_width(width)
605  {
606  }
607  double m_red { 1. };
608  double m_green { 1. };
609  double m_blue { 1. };
610  double m_master{ 1. };
611  double m_start { 0. }; // Or center for midtones.
612  double m_width { 1. }; // Or pivot for shadows and highlights.
613 };
614 
615 extern OCIOEXPORT bool operator==(const GradingRGBMSW & lhs, const GradingRGBMSW & rhs);
616 extern OCIOEXPORT bool operator!=(const GradingRGBMSW & lhs, const GradingRGBMSW & rhs);
617 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const GradingRGBMSW &);
618 
619 /// Grading tone values.
621 {
622  GradingTone() = delete;
623  explicit GradingTone(GradingStyle style)
624  : m_blacks(style == GRADING_LIN ? GradingRGBMSW(0., 4.) :
625  (style == GRADING_LOG ? GradingRGBMSW(0.4, 0.4) :
626  GradingRGBMSW(0.4, 0.4)))
627  , m_shadows(style == GRADING_LIN ? GradingRGBMSW(2., -7.) :
628  (style == GRADING_LOG ? GradingRGBMSW(0.5, 0.) :
629  GradingRGBMSW(0.6, 0.)))
630  , m_midtones(style == GRADING_LIN ? GradingRGBMSW(0., 8.) :
631  (style == GRADING_LOG ? GradingRGBMSW(0.4, 0.6) :
632  GradingRGBMSW(0.4, 0.7)))
633  , m_highlights(style == GRADING_LIN ? GradingRGBMSW(-2., 9.) :
634  (style == GRADING_LOG ? GradingRGBMSW(0.3, 1.) :
635  GradingRGBMSW(0.2, 1.)))
636  , m_whites(style == GRADING_LIN ? GradingRGBMSW(0., 8.) :
637  (style == GRADING_LOG ? GradingRGBMSW(0.4, 0.5) :
638  GradingRGBMSW(0.5, 0.5)))
639  {
640  }
641 
642  /**
643  * The valid range for each parameter varies. The client is expected to enforce
644  * these bounds in the UI.
645  */
646  void validate() const;
647 
653  double m_scontrast{ 1.0 };
654 };
655 
656 extern OCIOEXPORT bool operator==(const GradingTone & lhs, const GradingTone & rhs);
657 extern OCIOEXPORT bool operator!=(const GradingTone & lhs, const GradingTone & rhs);
658 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const GradingTone &);
659 
660 /**
661  * Allows transform parameter values to be set on-the-fly (after finalization). For
662  * example, to modify the exposure in a viewport. Dynamic properties can be accessed from the
663  * `CPUProcessor` or `GpuShaderCreator` to change values between processing.
664  *
665  * \code{.cpp}
666  *
667  * OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
668  * OCIO::ConstProcessorRcPtr processor = config->getProcessor(colorSpace1, colorSpace2);
669  * OCIO::ConstCPUProcessorRcPtr cpuProcessor = processor->getDefaultCPUProcessor();
670  *
671  * if (cpuProcessor->hasDynamicProperty(OCIO::DYNAMIC_PROPERTY_EXPOSURE))
672  * {
673  * // Get the in-memory implementation of the dynamic property.
674  * OCIO::DynamicPropertyRcPtr dynProp =
675  * cpuProcessor->getDynamicProperty(OCIO::DYNAMIC_PROPERTY_EXPOSURE);
676  * // Get the interface used to change the double value.
677  * OCIO::DynamicPropertyDoubleRcPtr exposure =
678  * OCIO::DynamicPropertyValue::AsDouble(dynProp);
679  * // Update of the dynamic property instance with the new value.
680  * exposure->setValue(1.1f);
681  * }
682  * if (cpuProcessor->hasDynamicProperty(OCIO::DYNAMIC_PROPERTY_GRADING_PRIMARY))
683  * {
684  * OCIO::DynamicPropertyRcPtr dynProp =
685  * cpuProcessor->getDynamicProperty(OCIO::DYNAMIC_PROPERTY_GRADING_PRIMARY);
686  * OCIO::DynamicPropertyGradingPrimaryRcPtr primaryProp =
687  * OCIO::DynamicPropertyValue::AsGradingPrimary(dynProp);
688  * OCIO::GradingPrimary primary = primaryProp->getValue();
689  * primary.m_saturation += 0.1f;
690  * primaryProp->setValue(primary);
691  * }
692  * if (cpuProcessor->hasDynamicProperty(OCIO::DYNAMIC_PROPERTY_GRADING_RGBCURVE))
693  * {
694  * OCIO::DynamicPropertyRcPtr dynProp =
695  * cpuProcessor->getDynamicProperty(OCIO::DYNAMIC_PROPERTY_GRADING_RGBCURVE);
696  * OCIO::DynamicPropertyGradingRGBCurveRcPtr rgbCurveProp =
697  * OCIO::DynamicPropertyValue::AsGradingRGBCurve(dynProp);
698  * OCIO::ConstGradingRGBCurveRcPtr rgbCurve = rgbCurveProp->getValue()->createEditableCopy();
699  * OCIO::GradingBSplineCurveRcPtr rCurve = rgbCurve->getCurve(OCIO::RGB_RED);
700  * rCurve->getControlPoint(1).m_y += 0.1f;
701  * rgbCurveProp->setValue(rgbCurve);
702  * }
703  * \endcode
704  */
706 {
707 public:
708  virtual DynamicPropertyType getType() const noexcept = 0;
709 
710  DynamicProperty & operator=(const DynamicProperty &) = delete;
711  DynamicProperty(const DynamicProperty &) = delete;
712 
713  /// Do not use (needed only for pybind11).
714  virtual ~DynamicProperty() = default;
715 
716 protected:
717  DynamicProperty() = default;
718 };
719 
720 namespace DynamicPropertyValue
721 {
722 /**
723  * Get the property as DynamicPropertyDoubleRcPtr to access the double value. Will throw if
724  * property type is not a type that holds a double such as DYNAMIC_PROPERTY_EXPOSURE.
725  */
727 /**
728  * Get the property as DynamicPropertyGradingPrimaryRcPtr to access the GradingPrimary value. Will
729  * throw if property type is not DYNAMIC_PROPERTY_GRADING_PRIMARY.
730  */
732 /**
733  * Get the property as DynamicPropertyGradingRGBCurveRcPtr to access the GradingRGBCurveRcPtr
734  * value. Will throw if property type is not DYNAMIC_PROPERTY_GRADING_RGBCURVE.
735  */
737 /**
738  * Get the property as DynamicPropertyGradingToneRcPtr to access the GradingTone value. Will throw
739  * if property type is not DYNAMIC_PROPERTY_GRADING_TONE.
740  */
742 }
743 
744 /// Interface used to access dynamic property double value.
746 {
747 public:
748  virtual double getValue() const = 0;
749  virtual void setValue(double value) = 0;
750 
753  /// Do not use (needed only for pybind11).
754  virtual ~DynamicPropertyDouble() = default;
755 
756 protected:
757  DynamicPropertyDouble() = default;
758 };
759 
760 /// Interface used to access dynamic property GradingPrimary value.
762 {
763 public:
764  virtual const GradingPrimary & getValue() const = 0;
765  /// Will throw if value is not valid.
766  virtual void setValue(const GradingPrimary & value) = 0;
767 
770  /// Do not use (needed only for pybind11).
771  virtual ~DynamicPropertyGradingPrimary() = default;
772 
773 protected:
774  DynamicPropertyGradingPrimary() = default;
775 };
776 
777 /// Interface used to access dynamic property ConstGradingRGBCurveRcPtr value.
779 {
780 public:
781  virtual const ConstGradingRGBCurveRcPtr & getValue() const = 0;
782  /// Will throw if value is not valid.
783  virtual void setValue(const ConstGradingRGBCurveRcPtr & value) = 0;
784 
787  /// Do not use (needed only for pybind11).
788  virtual ~DynamicPropertyGradingRGBCurve() = default;
789 
790 protected:
791  DynamicPropertyGradingRGBCurve() = default;
792 };
793 
794 /// Interface used to access dynamic property GradingTone value.
796 {
797 public:
798  virtual const GradingTone & getValue() const = 0;
799  /// Will throw if value is not valid.
800  virtual void setValue(const GradingTone & value) = 0;
801 
804  /// Do not use (needed only for pybind11).
805  virtual ~DynamicPropertyGradingTone() = default;
806 
807 protected:
808  DynamicPropertyGradingTone() = default;
809 };
810 
811 
812 /**
813  * \brief Represents exponent transform: pow( clamp(color), value ).
814  *
815  * \note For configs with version == 1: Negative style is ignored and if the exponent is 1.0,
816  * this will not clamp. Otherwise, the input color will be clamped between [0.0, inf].
817  * For configs with version > 1: Negative value handling may be specified via setNegativeStyle.
818  */
819 class OCIOEXPORT ExponentTransform : public Transform
820 {
821 public:
822  static ExponentTransformRcPtr Create();
823 
824  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_EXPONENT; }
825 
826  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
827  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
828 
829  /// Checks if this exactly equals other.
830  virtual bool equals(const ExponentTransform & other) const noexcept = 0;
831 
832  virtual void getValue(double(&vec4)[4]) const noexcept = 0;
833  virtual void setValue(const double(&vec4)[4]) noexcept = 0;
834 
835  /**
836  * Specifies how negative values are handled. Legal values:
837  *
838  * * NEGATIVE_CLAMP -- Clamp negative values (default).
839  * * NEGATIVE_MIRROR -- Positive curve is rotated 180 degrees around the origin to
840  * handle negatives.
841  * * NEGATIVE_PASS_THRU -- Negative values are passed through unchanged.
842  */
843  virtual NegativeStyle getNegativeStyle() const = 0;
844  virtual void setNegativeStyle(NegativeStyle style) = 0;
845 
846  ExponentTransform(const ExponentTransform &) = delete;
847  ExponentTransform & operator= (const ExponentTransform &) = delete;
848  /// Do not use (needed only for pybind11).
849  virtual ~ExponentTransform() = default;
850 
851 protected:
852  ExponentTransform() = default;
853 };
854 
855 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const ExponentTransform &);
856 
857 
858 /**
859  * Represents power functions with a linear section in the shadows
860  * such as sRGB and L*.
861  *
862  * The basic formula is::
863  *
864  * pow( (x + offset)/(1 + offset), gamma )
865  * with the breakpoint at offset/(gamma - 1).
866  *
867  * Negative values are never clamped.
868  */
870 {
871 public:
872  static ExponentWithLinearTransformRcPtr Create();
873 
875 
876  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
877  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
878 
879  /// Checks if this exactly equals other.
880  virtual bool equals(const ExponentWithLinearTransform & other) const noexcept = 0;
881 
882  virtual void getGamma(double(&values)[4]) const noexcept = 0;
883  /**
884  * Set the exponent value for the power function for R, G, B, A.
885  *
886  * \note
887  * The gamma values must be in the range of [1, 10]. Set the transform direction
888  * to inverse to obtain the effect of values less than 1.
889  */
890  virtual void setGamma(const double(&values)[4]) noexcept = 0;
891 
892  virtual void getOffset(double(&values)[4]) const noexcept = 0;
893  /**
894  * Set the offset value for the power function for R, G, B, A.
895  *
896  * \note
897  * The offset values must be in the range [0, 0.9].
898  */
899  virtual void setOffset(const double(&values)[4]) noexcept = 0;
900 
901  /**
902  * Specifies how negative values are handled. Legal values:
903  *
904  * * NEGATIVE_LINEAR -- Linear segment continues into negatives (default).
905  * * NEGATIVE_MIRROR -- Positive curve is rotated 180 degrees around the origin to
906  * handle negatives.
907  */
908  virtual NegativeStyle getNegativeStyle() const = 0;
909  virtual void setNegativeStyle(NegativeStyle style) = 0;
910 
912  ExponentWithLinearTransform & operator= (const ExponentWithLinearTransform &) = delete;
913  /// Do not use (needed only for pybind11).
914  virtual ~ExponentWithLinearTransform() = default;
915 
916 protected:
917  ExponentWithLinearTransform() = default;
918 };
919 
920 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const ExponentWithLinearTransform &);
921 
922 /**
923  * Applies exposure, gamma, and pivoted contrast adjustments.
924  * Adjusts the math to be appropriate for linear, logarithmic, or video
925  * color spaces.
926  */
928 {
929 public:
930  static ExposureContrastTransformRcPtr Create();
931 
933 
934  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
935  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
936 
937  /// Checks if this exactly equals other.
938  virtual bool equals(const ExposureContrastTransform & other) const noexcept = 0;
939 
940  virtual ExposureContrastStyle getStyle() const = 0;
941  /// Select the algorithm for linear, video or log color spaces.
942  virtual void setStyle(ExposureContrastStyle style) = 0;
943 
944  virtual double getExposure() const = 0;
945  /**
946  * Applies an exposure adjustment. The value is in units of stops (regardless of style), for
947  * example, a value of -1 would be equivalent to reducing the lighting by one half.
948  */
949  virtual void setExposure(double exposure) = 0;
950  /**
951  * Exposure can be made dynamic so the value can be changed through the CPU or GPU processor,
952  * but if there are several ExposureContrastTransform only one can have a dynamic exposure.
953  */
954  virtual bool isExposureDynamic() const = 0;
955  virtual void makeExposureDynamic() = 0;
956  virtual void makeExposureNonDynamic() = 0;
957 
958  virtual double getContrast() const = 0;
959  /**
960  * Applies a contrast/gamma adjustment around a pivot point. The contrast and gamma are
961  * mathematically the same, but two controls are provided to enable the use of separate
962  * dynamic parameters. Contrast is usually a scene-referred adjustment that pivots around
963  * gray whereas gamma is usually a display-referred adjustment that pivots around white.
964  */
965  virtual void setContrast(double contrast) = 0;
966  /**
967  * Contrast can be made dynamic so the value can be changed through the CPU or GPU processor,
968  * but if there are several ExposureContrastTransform only one can have a dynamic contrast.
969  */
970  virtual bool isContrastDynamic() const = 0;
971  virtual void makeContrastDynamic() = 0;
972  virtual void makeContrastNonDynamic() = 0;
973 
974  virtual double getGamma() const = 0;
975  virtual void setGamma(double gamma) = 0;
976  /**
977  * Gamma can be made dynamic so the value can be changed through the CPU or GPU processor,
978  * but if there are several ExposureContrastTransform only one can have a dynamic gamma.
979  */
980  virtual bool isGammaDynamic() const = 0;
981  virtual void makeGammaDynamic() = 0;
982  virtual void makeGammaNonDynamic() = 0;
983 
984  virtual double getPivot() const = 0;
985  /**
986  * Set the pivot point around which the contrast
987  * and gamma controls will work. Regardless of whether
988  * linear/video/log-style is being used, the pivot is always expressed
989  * in linear. In other words, a pivot of 0.18 is always mid-gray.
990  */
991  virtual void setPivot(double pivot) = 0;
992 
993  virtual double getLogExposureStep() const = 0;
994  /**
995  * Set the increment needed to move one stop for
996  * the log-style algorithm. For example, ACEScct is 0.057, LogC is
997  * roughly 0.074, and Cineon is roughly 90/1023 = 0.088.
998  * The default value is 0.088.
999  */
1000  virtual void setLogExposureStep(double logExposureStep) = 0;
1001 
1002  virtual double getLogMidGray() const = 0;
1003  /**
1004  * Set the position of 18% gray for use by the
1005  * log-style algorithm. For example, ACEScct is about 0.41, LogC is
1006  * about 0.39, and ADX10 is 445/1023 = 0.435.
1007  * The default value is 0.435.
1008  */
1009  virtual void setLogMidGray(double logMidGray) = 0;
1010 
1011  /// Do not use (needed only for pybind11).
1012  virtual ~ExposureContrastTransform() = default;
1013 
1014 protected:
1015  ExposureContrastTransform() = default;
1016 
1017 private:
1019  ExposureContrastTransform & operator= (const ExposureContrastTransform &) = delete;
1020 };
1021 
1022 extern OCIOEXPORT std::ostream & operator<<(std::ostream &,
1023  const ExposureContrastTransform &);
1024 
1025 
1026 class OCIOEXPORT FileTransform : public Transform
1027 {
1028 public:
1029  static FileTransformRcPtr Create();
1030 
1031  TransformRcPtr createEditableCopy() const override;
1032 
1033  TransformDirection getDirection() const noexcept override;
1034  void setDirection(TransformDirection dir) noexcept override;
1035 
1036  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_FILE; }
1037 
1038  /// Will throw if data is not valid.
1039  void validate() const override;
1040 
1041  const char * getSrc() const;
1042  void setSrc(const char * src);
1043 
1044  /**
1045  * The cccid can be the ID of a CDL or the index of the CDL (as string). If cccid is NULL or
1046  * empty the first CDL is returned. The cccid is case-sensitive.
1047  */
1048  const char * getCCCId() const;
1049  void setCCCId(const char * id);
1050 
1051  CDLStyle getCDLStyle() const;
1052  /**
1053  * Can be used with CDL, CC & CCC formats to specify the clamping behavior of
1054  * the CDLTransform. Default is CDL_NO_CLAMP.
1055  */
1056  void setCDLStyle(CDLStyle);
1057 
1058  /**
1059  * The file parsers that care about interpolation (LUTs) will try to make use of the requested
1060  * interpolation method when loading the file. In these cases, if the requested method could
1061  * not be used, a warning is logged. If no method is provided, or a method cannot be used,
1062  * INTERP_DEFAULT is used.
1063  */
1064  Interpolation getInterpolation() const;
1065  void setInterpolation(Interpolation interp);
1066 
1067  /// Get the number of LUT readers.
1068  static int GetNumFormats();
1069  /// Get the LUT readers at index, return empty string if an invalid index is specified.
1070  static const char * GetFormatNameByIndex(int index);
1071  /// Get the LUT reader extension at index, return empty string if an invalid index is specified.
1072  static const char * GetFormatExtensionByIndex(int index);
1073 
1074  FileTransform & operator=(const FileTransform &) = delete;
1075  /// Do not use (needed only for pybind11).
1076  virtual ~FileTransform();
1077 
1078 private:
1079  FileTransform();
1080  FileTransform(const FileTransform &);
1081 
1082  static void deleter(FileTransform * t);
1083 
1084  class Impl;
1085  Impl * m_impl;
1086  Impl * getImpl() { return m_impl; }
1087  const Impl * getImpl() const { return m_impl; }
1088 };
1089 
1090 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const FileTransform &);
1091 
1092 
1093 /**
1094  * Provides a set of hard-coded algorithmic building blocks
1095  * that are needed to accurately implement various common color transformations.
1096  */
1097 class OCIOEXPORT FixedFunctionTransform : public Transform
1098 {
1099 public:
1100  static FixedFunctionTransformRcPtr Create(FixedFunctionStyle style);
1101  static FixedFunctionTransformRcPtr Create(FixedFunctionStyle style,
1102  const double * params,
1103  size_t num);
1104 
1105  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_FIXED_FUNCTION; }
1106 
1107  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1108  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1109 
1110  /// Checks if this exactly equals other.
1111  virtual bool equals(const FixedFunctionTransform & other) const noexcept = 0;
1112 
1113  virtual FixedFunctionStyle getStyle() const = 0;
1114  /// Select which algorithm to use.
1115  virtual void setStyle(FixedFunctionStyle style) = 0;
1116 
1117  virtual size_t getNumParams() const = 0;
1118  virtual void getParams(double * params) const = 0;
1119  /// Set the parameters (for functions that require them).
1120  virtual void setParams(const double * params, size_t num) = 0;
1121 
1123  FixedFunctionTransform & operator= (const FixedFunctionTransform &) = delete;
1124  /// Do not use (needed only for pybind11).
1125  virtual ~FixedFunctionTransform() = default;
1126 
1127 protected:
1128  FixedFunctionTransform() = default;
1129 };
1130 
1131 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const FixedFunctionTransform &);
1132 
1133 
1134 /**
1135  * Primary color correction controls.
1136  *
1137  * This transform is for making basic color correction adjustments to an image such as brightness,
1138  * contrast, or saturation.
1139  *
1140  * The controls are customized for linear, logarithmic, and video color encodings.
1141  * * Linear controls: Exposure, Contrast, Pivot, Offset, Saturation, Black Clip, White Clip.
1142  * * Log controls: Brightness, Contrast, Pivot, Log Gamma, Saturation, Black Clip, White Clip,
1143  * Black Pivot White Pivot.
1144  * * Video controls : Lift, Gamma, Gain, Offset, Saturation, Black Clip, White Clip,
1145  * Black Pivot White Pivot.
1146  *
1147  * The controls are dynamic, so they may be adjusted even after the Transform has been included
1148  * in a Processor.
1149  */
1151 {
1152 public:
1153  /// Creates an instance of GradingPrimaryTransform.
1154  static GradingPrimaryTransformRcPtr Create(GradingStyle style);
1155 
1156  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_GRADING_PRIMARY; }
1157 
1158  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1159  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1160 
1161  /// Checks if this equals other.
1162  virtual bool equals(const GradingPrimaryTransform & other) const noexcept = 0;
1163 
1164  /// Adjusts the behavior of the transform for log, linear, or video color space encodings.
1165  virtual GradingStyle getStyle() const noexcept = 0;
1166  /// Will reset value to style's defaults if style is not the current style.
1167  virtual void setStyle(GradingStyle style) noexcept = 0;
1168 
1169  virtual const GradingPrimary & getValue() const = 0;
1170  /// Throws if value is not valid.
1171  virtual void setValue(const GradingPrimary & values) = 0;
1172 
1173  /**
1174  * Parameters can be made dynamic so the values can be changed through the CPU or GPU processor,
1175  * but if there are several GradingPrimaryTransform only one can have dynamic parameters.
1176  */
1177  virtual bool isDynamic() const noexcept = 0;
1178  virtual void makeDynamic() noexcept = 0;
1179  virtual void makeNonDynamic() noexcept = 0;
1180 
1182  GradingPrimaryTransform & operator= (const GradingPrimaryTransform &) = delete;
1183  /// Do not use (needed only for pybind11).
1184  virtual ~GradingPrimaryTransform() = default;
1185 
1186 protected:
1187  GradingPrimaryTransform() = default;
1188 };
1189 
1190 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const GradingPrimaryTransform &) noexcept;
1191 
1192 
1193 /**
1194  * RGB curve color correction controls.
1195  *
1196  * This transform allows for modifying tone reproduction via B-spline curves.
1197  *
1198  * There is an R, G, and B curve along with a Master curve (that applies to R, G, and B). Each
1199  * curve is specified via the x and y coordinates of its control points. A monotonic spline is
1200  * fit to the control points. The x coordinates must be non-decreasing. When the grading style
1201  * is linear, the units for the control points are photographic stops relative to 0.18.
1202  *
1203  * The control points are dynamic, so they may be adjusted even after the Transform is included
1204  * in a Processor.
1205  */
1207 {
1208 public:
1209  /// Creates an instance of GradingPrimaryTransform.
1210  static GradingRGBCurveTransformRcPtr Create(GradingStyle style);
1211 
1213 
1214  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1215  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1216 
1217  /// Checks if this equals other.
1218  virtual bool equals(const GradingRGBCurveTransform & other) const noexcept = 0;
1219 
1220  /// Adjusts the behavior of the transform for log, linear, or video color space encodings.
1221  virtual GradingStyle getStyle() const noexcept = 0;
1222  /// Will reset value to style's defaults if style is not the current style.
1223  virtual void setStyle(GradingStyle style) noexcept = 0;
1224 
1225  virtual const ConstGradingRGBCurveRcPtr getValue() const = 0;
1226  /// Throws if value is not valid.
1227  virtual void setValue(const ConstGradingRGBCurveRcPtr & values) = 0;
1228 
1229  /**
1230  * It is possible to provide a desired slope value for each control point. The number of slopes is
1231  * always the same as the number of control points and so the control points must be set before
1232  * setting the slopes. The slopes are primarily intended for use by config authors looking to match
1233  * a specific shape with as few control points as possible, they are not intended to be exposed to
1234  * a user interface for direct manipulation. When a curve is being generated for creative purposes
1235  * it is better to let OCIO calculate the slopes automatically.
1236  */
1237  virtual float getSlope(RGBCurveType c, size_t index) const = 0;
1238  virtual void setSlope(RGBCurveType c, size_t index, float slope) = 0;
1239  virtual bool slopesAreDefault(RGBCurveType c) const = 0;
1240 
1241  /**
1242  * The scene-linear grading style applies a lin-to-log transform to the pixel
1243  * values before going through the curve. However, in some cases (e.g. drawing curves in a UI)
1244  * it may be useful to bypass the lin-to-log. Default value is false.
1245  */
1246  virtual bool getBypassLinToLog() const = 0;
1247  virtual void setBypassLinToLog(bool bypass) = 0;
1248 
1249  /**
1250  * Parameters can be made dynamic so the values can be changed through the CPU or GPU processor,
1251  * but if there are several GradingRGBCurveTransform only one can have dynamic parameters.
1252  */
1253  virtual bool isDynamic() const noexcept = 0;
1254  virtual void makeDynamic() noexcept = 0;
1255  virtual void makeNonDynamic() noexcept = 0;
1256 
1258  GradingRGBCurveTransform & operator= (const GradingRGBCurveTransform &) = delete;
1259  /// Do not use (needed only for pybind11).
1260  virtual ~GradingRGBCurveTransform() = default;
1261 
1262 protected:
1263  GradingRGBCurveTransform() = default;
1264 };
1265 
1266 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const GradingRGBCurveTransform &) noexcept;
1267 
1268 
1269 /**
1270  * Tonal color correction controls.
1271  *
1272  * This transform is for making fine adjustments to tone reproduction in specific tonal ranges.
1273  *
1274  * There are five tonal controls and each one has two parameters to control its range:
1275  * * Blacks (start, width)
1276  * * Shadows(start, pivot)
1277  * * Midtones(center, width)
1278  * * Highlights(start, pivot)
1279  * * Whites(start, width)
1280  *
1281  * The transform has three styles that adjust the response and default ranges for linear,
1282  * logarithimic, and video color encodings. The defaults vary based on the style. When the
1283  * style is linear, the units for start/width/etc. are photographic stops relative to 0.18.
1284  *
1285  * Each control allows R, G, B adjustments and a Master adjustment.
1286  *
1287  * There is also an S-contrast control for imparting an S-shape curve.
1288  *
1289  * The controls are dynamic, so they may be adjusted even after the Transform has been included
1290  * in a Processor.
1291  */
1293 {
1294 public:
1295  /// Creates an instance of GradingToneTransform.
1296  static GradingToneTransformRcPtr Create(GradingStyle style);
1297 
1298  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_GRADING_TONE; }
1299 
1300  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1301  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1302 
1303  virtual bool equals(const GradingToneTransform & other) const noexcept = 0;
1304 
1305  /// Adjusts the behavior of the transform for log, linear, or video color space encodings.
1306  virtual GradingStyle getStyle() const noexcept = 0;
1307  /// Will reset value to style's defaults if style is not the current style.
1308  virtual void setStyle(GradingStyle style) noexcept = 0;
1309 
1310  virtual const GradingTone & getValue() const = 0;
1311  virtual void setValue(const GradingTone & values) = 0;
1312 
1313  /**
1314  * Parameters can be made dynamic so the values can be changed through the CPU or GPU processor,
1315  * but if there are several GradingToneTransform only one can have dynamic parameters.
1316  */
1317  virtual bool isDynamic() const noexcept = 0;
1318  virtual void makeDynamic() noexcept = 0;
1319  virtual void makeNonDynamic() noexcept = 0;
1320 
1321  GradingToneTransform(const GradingToneTransform &) = delete;
1322  GradingToneTransform & operator= (const GradingToneTransform &) = delete;
1323  /// Do not use (needed only for pybind11).
1324  virtual ~GradingToneTransform() = default;
1325 
1326 protected:
1327  GradingToneTransform() = default;
1328 };
1329 
1330 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const GradingToneTransform &) noexcept;
1331 
1332 
1333 class OCIOEXPORT GroupTransform : public Transform
1334 {
1335 public:
1336  static GroupTransformRcPtr Create();
1337 
1338  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1339  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1340 
1341  /// Throws if index is not allowed.
1342  virtual ConstTransformRcPtr getTransform(int index) const = 0;
1343 
1344  /// Throws if index is not allowed.
1345  virtual TransformRcPtr & getTransform(int index) = 0;
1346 
1347  /// Return number of transforms.
1348  virtual int getNumTransforms() const noexcept = 0;
1349  /// Adds a transform to the end of the group.
1350  virtual void appendTransform(TransformRcPtr transform) noexcept = 0;
1351  /// Add a transform at the beginning of the group.
1352  virtual void prependTransform(TransformRcPtr transform) noexcept = 0;
1353 
1354  /**
1355  * \brief Write the transforms comprising the group to the stream.
1356  *
1357  * Writing (as opposed to Baking) is a lossless process. An exception is thrown if the
1358  * processor cannot be losslessly written to the specified file format. Transforms such as
1359  * FileTransform or ColorSpaceTransform are resolved into write-able simple transforms using
1360  * the config and context. Supported formats include CTF, CLF, and CDL. All available formats
1361  * can be listed with the following:
1362  * \code{.cpp}
1363  * // What are the allowed writing output formats?
1364  * std::ostringstream formats;
1365  * formats << "Formats to write to: ";
1366  * for (int i = 0; i < GroupTransform::GetNumWriteFormats(); ++i)
1367  * {
1368  * if (i != 0) formats << ", ";
1369  * formats << GroupTransform::GetFormatNameByIndex(i);
1370  * formats << " (." << GroupTransform::GetFormatExtensionByIndex(i) << ")";
1371  * }
1372  * \endcode
1373  */
1374  virtual void write(const ConstConfigRcPtr & config,
1375  const char * formatName,
1376  std::ostream & os) const = 0;
1377 
1378  /// Get the number of writers.
1379  static int GetNumWriteFormats() noexcept;
1380 
1381  /// Get the writer at index, return empty string if an invalid index is specified.
1382  static const char * GetFormatNameByIndex(int index) noexcept;
1383  static const char * GetFormatExtensionByIndex(int index) noexcept;
1384 
1385  GroupTransform(const GroupTransform &) = delete;
1386  GroupTransform & operator=(const GroupTransform &) = delete;
1387  /// Do not use (needed only for pybind11).
1388  virtual ~GroupTransform() = default;
1389 
1390 protected:
1391  GroupTransform() = default;
1392 };
1393 
1394 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const GroupTransform &);
1395 
1396 
1397 
1398 /**
1399  * Applies a logarithm with an affine transform before and after.
1400  * Represents the Cineon lin-to-log type transforms::
1401  *
1402  * logSideSlope * log( linSideSlope * color + linSideOffset, base) + logSideOffset
1403  *
1404  * * Default values are: 1. * log( 1. * color + 0., 2.) + 0.
1405  * * The alpha channel is not affected.
1406  */
1407 class OCIOEXPORT LogAffineTransform : public Transform
1408 {
1409 public:
1410  static LogAffineTransformRcPtr Create();
1411 
1412  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_LOG_AFFINE; }
1413 
1414  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1415  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1416 
1417  /// Checks if this exactly equals other.
1418  virtual bool equals(const LogAffineTransform & other) const noexcept = 0;
1419 
1420  virtual double getBase() const noexcept = 0;
1421  virtual void setBase(double base) noexcept = 0;
1422 
1423  // !rst:: **Get/Set values for the R, G, B components**
1424 
1425  virtual void getLogSideSlopeValue(double(&values)[3]) const noexcept = 0;
1426  virtual void setLogSideSlopeValue(const double(&values)[3]) noexcept = 0;
1427  virtual void getLogSideOffsetValue(double(&values)[3]) const noexcept = 0;
1428  virtual void setLogSideOffsetValue(const double(&values)[3]) noexcept = 0;
1429  virtual void getLinSideSlopeValue(double(&values)[3]) const noexcept = 0;
1430  virtual void setLinSideSlopeValue(const double(&values)[3]) noexcept = 0;
1431  virtual void getLinSideOffsetValue(double(&values)[3]) const noexcept = 0;
1432  virtual void setLinSideOffsetValue(const double(&values)[3]) noexcept = 0;
1433 
1434  LogAffineTransform(const LogAffineTransform &) = delete;
1435  LogAffineTransform & operator= (const LogAffineTransform &) = delete;
1436  /// Do not use (needed only for pybind11).
1437  virtual ~LogAffineTransform() = default;
1438 
1439 protected:
1440  LogAffineTransform() = default;
1441 };
1442 
1443 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const LogAffineTransform &);
1444 
1445 
1446 /**
1447  * Same as LogAffineTransform but with the addition of a linear segment near black. This formula
1448  * is used for many camera logs (e.g., LogC) as well as ACEScct.
1449  *
1450  * * The linSideBreak specifies the point on the linear axis where the log and linear
1451  * segments meet. It must be set (there is no default).
1452  * * The linearSlope specifies the slope of the linear segment of the forward (linToLog)
1453  * transform. By default it is set equal to the slope of the log curve at the break point.
1454  */
1456 {
1457 public:
1458  /// LinSideBreak must be set for the transform to be valid (there is no default).
1459  static LogCameraTransformRcPtr Create(const double(&linSideBreakValues)[3]);
1460 
1461  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_LOG_CAMERA; }
1462 
1463  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1464  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1465 
1466  /// Checks if this exactly equals other.
1467  virtual bool equals(const LogCameraTransform & other) const noexcept = 0;
1468 
1469  virtual double getBase() const noexcept = 0;
1470  virtual void setBase(double base) noexcept = 0;
1471 
1472  /// Get/Set values for the R, G, B components.
1473  virtual void getLogSideSlopeValue(double(&values)[3]) const noexcept = 0;
1474  virtual void setLogSideSlopeValue(const double(&values)[3]) noexcept = 0;
1475  virtual void getLogSideOffsetValue(double(&values)[3]) const noexcept = 0;
1476  virtual void setLogSideOffsetValue(const double(&values)[3]) noexcept = 0;
1477  virtual void getLinSideSlopeValue(double(&values)[3]) const noexcept = 0;
1478  virtual void setLinSideSlopeValue(const double(&values)[3]) noexcept = 0;
1479  virtual void getLinSideOffsetValue(double(&values)[3]) const noexcept = 0;
1480  virtual void setLinSideOffsetValue(const double(&values)[3]) noexcept = 0;
1481  virtual void getLinSideBreakValue(double(&values)[3]) const noexcept = 0;
1482  virtual void setLinSideBreakValue(const double(&values)[3]) noexcept = 0;
1483 
1484  /// Return true if LinearSlope values were set, false if they were not.
1485  virtual bool getLinearSlopeValue(double(&values)[3]) const = 0;
1486  /**
1487  * \brief Set LinearSlope value.
1488  *
1489  * \note
1490  * You must call setLinSideBreakValue before calling this.
1491  */
1492  virtual void setLinearSlopeValue(const double(&values)[3]) = 0;
1493  /// Remove LinearSlope values so that default values are used.
1494  virtual void unsetLinearSlopeValue() = 0;
1495 
1496  LogCameraTransform(const LogCameraTransform &) = delete;
1497  LogCameraTransform & operator= (const LogCameraTransform &) = delete;
1498  /// Do not use (needed only for pybind11).
1499  virtual ~LogCameraTransform() = default;
1500 
1501 protected:
1502  LogCameraTransform() = default;
1503 };
1504 
1505 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const LogCameraTransform &);
1506 
1507 
1508 /**
1509  * Represents log transform: log(color, base)
1510  *
1511  * * The input will be clamped for negative numbers.
1512  * * Default base is 2.0.
1513  * * The alpha channel is not affected.
1514  */
1515 class OCIOEXPORT LogTransform : public Transform
1516 {
1517 public:
1518  static LogTransformRcPtr Create();
1519 
1520  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_LOG; }
1521 
1522  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1523  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1524 
1525  /// Checks if this exactly equals other.
1526  virtual bool equals(const LogTransform & other) const noexcept = 0;
1527 
1528  virtual double getBase() const noexcept = 0;
1529  virtual void setBase(double val) noexcept = 0;
1530 
1531  LogTransform(const LogTransform &) = delete;
1532  LogTransform & operator= (const LogTransform &) = delete;
1533  /// Do not use (needed only for pybind11).
1534  virtual ~LogTransform() = default;
1535 
1536 protected:
1537  LogTransform() = default;
1538 };
1539 
1540 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const LogTransform &);
1541 
1542 
1543 class OCIOEXPORT LookTransform : public Transform
1544 {
1545 public:
1546  static LookTransformRcPtr Create();
1547 
1548  TransformRcPtr createEditableCopy() const override;
1549 
1550  TransformDirection getDirection() const noexcept override;
1551  void setDirection(TransformDirection dir) noexcept override;
1552 
1553  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_LOOK; }
1554 
1555  /// Will throw if data is not valid.
1556  void validate() const override;
1557 
1558  const char * getSrc() const;
1559  void setSrc(const char * src);
1560 
1561  const char * getDst() const;
1562  void setDst(const char * dst);
1563 
1564  const char * getLooks() const;
1565  /**
1566  * Specify looks to apply.
1567  * Looks is a potentially comma (or colon) delimited list of look names,
1568  * Where +/- prefixes are optionally allowed to denote forward/inverse
1569  * look specification. (And forward is assumed in the absence of either)
1570  */
1571  void setLooks(const char * looks);
1572 
1573  bool getSkipColorSpaceConversion() const;
1574  void setSkipColorSpaceConversion(bool skip);
1575 
1576  /**
1577  * Return the name of the color space after applying looks in the forward
1578  * direction but without converting to the destination color space. This is equivalent
1579  * to the process space of the last look in the look sequence (and takes into account that
1580  * a look fall-back may be used).
1581  */
1582  static const char * GetLooksResultColorSpace(const ConstConfigRcPtr & config,
1583  const ConstContextRcPtr & context,
1584  const char * looks);
1585 
1586  LookTransform & operator=(const LookTransform &) = delete;
1587  /// Do not use (needed only for pybind11).
1588  virtual ~LookTransform();
1589 
1590 private:
1591  LookTransform();
1592  LookTransform(const LookTransform &);
1593 
1594  static void deleter(LookTransform * t);
1595 
1596  class Impl;
1597  Impl * m_impl;
1598  Impl * getImpl() { return m_impl; }
1599  const Impl * getImpl() const { return m_impl; }
1600 };
1601 
1602 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const LookTransform &);
1603 
1604 
1605 /// Represents a 1D-LUT transform.
1606 class OCIOEXPORT Lut1DTransform : public Transform
1607 {
1608 public:
1609  /// Create an identity 1D-LUT of length two.
1610  static Lut1DTransformRcPtr Create();
1611 
1612  /**
1613  * Create an identity 1D-LUT with specific length and
1614  * half-domain setting. Will throw for lengths longer than 1024x1024.
1615  */
1616  static Lut1DTransformRcPtr Create(unsigned long length,
1617  bool isHalfDomain);
1618 
1619  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_LUT1D; }
1620 
1621  virtual BitDepth getFileOutputBitDepth() const noexcept = 0;
1622  /**
1623  * Get the bit-depth associated with the LUT values read
1624  * from a file or set the bit-depth of values to be written to a file
1625  * (for file formats such as CLF that support multiple bit-depths).
1626  * However, note that the values stored in the object are always
1627  * normalized.
1628  */
1629  virtual void setFileOutputBitDepth(BitDepth bitDepth) noexcept = 0;
1630 
1631  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1632  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1633 
1634  /// Checks if this exactly equals other.
1635  virtual bool equals(const Lut1DTransform & other) const noexcept = 0;
1636 
1637  virtual unsigned long getLength() const = 0;
1638  /**
1639  * Changing the length will reset the LUT to identity.
1640  * Will throw for lengths longer than 1024x1024.
1641  */
1642  virtual void setLength(unsigned long length) = 0;
1643 
1644  virtual void getValue(unsigned long index, float & r, float & g, float & b) const = 0;
1645  /**
1646  * Set the values of a LUT1D. Will throw if the index
1647  * is outside of the range from 0 to (length-1).
1648  *
1649  * The LUT values are always for the "forward" LUT, regardless of how
1650  * the transform direction is set.
1651  *
1652  * These values are normalized relative to what may be stored in any
1653  * given LUT files. For example in a CLF file using a "10i" output
1654  * depth, a value of 1023 in the file is normalized to 1.0. The
1655  * values here are unclamped and may extend outside [0,1].
1656  *
1657  * LUTs in various file formats may only provide values for one
1658  * channel where R, G, B are the same. Even in that case, you should
1659  * provide three equal values to the setter.
1660  */
1661  virtual void setValue(unsigned long index, float r, float g, float b) = 0;
1662 
1663  virtual bool getInputHalfDomain() const noexcept = 0;
1664  /**
1665  * In a half-domain LUT, the contents of the LUT specify
1666  * the desired value of the function for each half-float value.
1667  * Therefore, the length of the LUT must be 65536 entries or else
1668  * validate() will throw.
1669  */
1670  virtual void setInputHalfDomain(bool isHalfDomain) noexcept = 0;
1671 
1672  virtual bool getOutputRawHalfs() const noexcept = 0;
1673  /**
1674  * Set OutputRawHalfs to true if you want to output the
1675  * LUT contents as 16-bit floating point values expressed as unsigned
1676  * 16-bit integers representing the equivalent bit pattern.
1677  * For example, the value 1.0 would be written as the integer 15360
1678  * because it has the same bit-pattern. Note that this implies the
1679  * values will be quantized to a 16-bit float. Note that this setting
1680  * only controls the output formatting (where supported) and not the
1681  * values for getValue/setValue. The only file formats that currently
1682  * support this are CLF and CTF.
1683  */
1684  virtual void setOutputRawHalfs(bool isRawHalfs) noexcept = 0;
1685 
1686  virtual Lut1DHueAdjust getHueAdjust() const noexcept = 0;
1687  /**
1688  * The 1D-LUT transform optionally supports a hue adjustment
1689  * feature that was used in some versions of ACES. This adjusts the hue
1690  * of the result to approximately match the input.
1691  */
1692  virtual void setHueAdjust(Lut1DHueAdjust algo) = 0;
1693 
1694  virtual Interpolation getInterpolation() const = 0;
1695  virtual void setInterpolation(Interpolation algo) = 0;
1696 
1697  Lut1DTransform(const Lut1DTransform &) = delete;
1698  Lut1DTransform & operator= (const Lut1DTransform &) = delete;
1699  /// Do not use (needed only for pybind11).
1700  virtual ~Lut1DTransform() = default;
1701 
1702 protected:
1703  Lut1DTransform() = default;
1704 };
1705 
1706 extern OCIOEXPORT std::ostream& operator<< (std::ostream&, const Lut1DTransform&);
1707 
1708 
1709 /// Represents a 3D-LUT transform.
1710 class OCIOEXPORT Lut3DTransform : public Transform
1711 {
1712 public:
1713  /// Create an identity 3D-LUT of size 2x2x2.
1714  static Lut3DTransformRcPtr Create();
1715 
1716  /**
1717  * Create an identity 3D-LUT with specific grid size.
1718  * Will throw for grid size larger than 129.
1719  */
1720  static Lut3DTransformRcPtr Create(unsigned long gridSize);
1721 
1722  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_LUT3D; }
1723 
1724  virtual BitDepth getFileOutputBitDepth() const noexcept = 0;
1725  /**
1726  * Get the bit-depth associated with the LUT values read
1727  * from a file or set the bit-depth of values to be written to a file
1728  * (for file formats such as CLF that support multiple bit-depths).
1729  * However, note that the values stored in the object are always
1730  * normalized.
1731  */
1732  virtual void setFileOutputBitDepth(BitDepth bitDepth) noexcept = 0;
1733 
1734  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1735  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1736 
1737  /// Checks if this exactly equals other.
1738  virtual bool equals(const Lut3DTransform & other) const noexcept = 0;
1739 
1740  virtual unsigned long getGridSize() const = 0;
1741  /**
1742  * Changing the grid size will reset the LUT to identity.
1743  * Will throw for grid sizes larger than 129.
1744  */
1745  virtual void setGridSize(unsigned long gridSize) = 0;
1746 
1747  virtual void getValue(unsigned long indexR,
1748  unsigned long indexG,
1749  unsigned long indexB,
1750  float & r, float & g, float & b) const = 0;
1751  /**
1752  * Set the values of a 3D-LUT. Will throw if an index is
1753  * outside of the range from 0 to (gridSize-1).
1754  *
1755  * The LUT values are always for the "forward" LUT, regardless of how the
1756  * transform direction is set.
1757  *
1758  * These values are normalized relative to what may be stored in any
1759  * given LUT files. For example in a CLF file using a "10i" output
1760  * depth, a value of 1023 in the file is normalized to 1.0. The values
1761  * here are unclamped and may extend outside [0,1].
1762  */
1763  virtual void setValue(unsigned long indexR,
1764  unsigned long indexG,
1765  unsigned long indexB,
1766  float r, float g, float b) = 0;
1767 
1768  virtual Interpolation getInterpolation() const = 0;
1769  virtual void setInterpolation(Interpolation algo) = 0;
1770 
1771  Lut3DTransform(const Lut3DTransform &) = delete;
1772  Lut3DTransform & operator= (const Lut3DTransform &) = delete;
1773  /// Do not use (needed only for pybind11).
1774  virtual ~Lut3DTransform() = default;
1775 
1776 protected:
1777  Lut3DTransform() = default;
1778 };
1779 
1780 extern OCIOEXPORT std::ostream& operator<< (std::ostream&, const Lut3DTransform&);
1781 
1782 /**
1783  * Represents an MX+B Matrix transform.
1784  *
1785  * \note
1786  * For singular matrices, an inverse direction will throw an exception during finalization.
1787  */
1789 {
1790 public:
1791  static MatrixTransformRcPtr Create();
1792 
1793  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_MATRIX; }
1794 
1795  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1796  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1797 
1798  /// Checks if this exactly equals other.
1799  virtual bool equals(const MatrixTransform & other) const noexcept = 0;
1800 
1801  virtual void getMatrix(double * m44) const = 0;
1802  /**
1803  * Get or set the values of a Matrix. Expects 16 values,
1804  * where the first four are the coefficients to generate the R output
1805  * channel from R, G, B, A input channels.
1806  *
1807  * The Matrix values are always for the "forward" Matrix, regardless of
1808  * how the transform direction is set.
1809  *
1810  * These values are normalized relative to what may be stored in
1811  * file formats such as CLF. For example in a CLF file using a "32f"
1812  * input depth and "10i" output depth, a value of 1023 in the file
1813  * is normalized to 1.0. The values here are unclamped and may
1814  * extend outside [0,1].
1815  */
1816  virtual void setMatrix(const double * m44) = 0;
1817 
1818  virtual void getOffset(double * offset4) const = 0;
1819  /**
1820  * Get or set the R, G, B, A offsets to be applied
1821  * after the matrix.
1822  *
1823  * These values are normalized relative to what may be stored in
1824  * file formats such as CLF. For example, in a CLF file using a
1825  * "10i" output depth, a value of 1023 in the file is normalized
1826  * to 1.0. The values here are unclamped and may extend
1827  * outside [0,1].
1828  */
1829  virtual void setOffset(const double * offset4) = 0;
1830 
1831  /**
1832  * Get the bit-depths associated with the matrix values read from a
1833  * file or set the bit-depths of values to be written to a file
1834  * (for file formats such as CLF that support multiple bit-depths).
1835  *
1836  * In a format such as CLF, the matrix values are scaled to take
1837  * pixels at the specified inBitDepth to pixels at the specified
1838  * outBitDepth. This complicates the interpretation of the matrix
1839  * values and so this object always holds normalized values and
1840  * scaling is done on the way from or to file formats such as CLF.
1841  */
1842  virtual BitDepth getFileInputBitDepth() const noexcept = 0;
1843  virtual void setFileInputBitDepth(BitDepth bitDepth) noexcept = 0;
1844  virtual BitDepth getFileOutputBitDepth() const noexcept = 0;
1845  virtual void setFileOutputBitDepth(BitDepth bitDepth) noexcept = 0;
1846 
1847 
1848  /// **Convenience functions**
1849  ///
1850  /// Build the matrix and offset corresponding to higher-level concepts.
1851  ///
1852  /// \note
1853  /// These can throw an exception if for any component
1854  /// ``oldmin == oldmax. (divide by 0)``
1855  static void Fit(double * m44, double* offset4,
1856  const double * oldmin4, const double * oldmax4,
1857  const double * newmin4, const double * newmax4);
1858 
1859  static void Identity(double * m44, double * offset4);
1860 
1861  static void Sat(double * m44, double * offset4,
1862  double sat, const double * lumaCoef3);
1863 
1864  static void Scale(double * m44, double * offset4,
1865  const double * scale4);
1866 
1867  static void View(double * m44, double * offset4,
1868  int * channelHot4,
1869  const double * lumaCoef3);
1870 
1871  MatrixTransform(const MatrixTransform &) = delete;
1872  MatrixTransform & operator= (const MatrixTransform &) = delete;
1873  /// Do not use (needed only for pybind11).
1874  virtual ~MatrixTransform() = default;
1875 
1876 protected:
1877  MatrixTransform() = default;
1878 };
1879 
1880 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const MatrixTransform &) noexcept;
1881 
1882 
1883 /**
1884  * Represents a range transform
1885  *
1886  * The Range is used to apply an affine transform (scale & offset) and
1887  * clamps values to min/max bounds on all color components except the alpha.
1888  * The scale and offset values are computed from the input and output bounds.
1889  *
1890  * Refer to section 7.2.4 in specification S-2014-006 "A Common File Format
1891  * for Look-Up Tables" from the Academy of Motion Picture Arts and Sciences
1892  * and the American Society of Cinematographers.
1893  *
1894  * \note
1895  * The "noClamp" style described in the specification S-2014-006 becomes a
1896  * MatrixOp at the processor level.
1897  *
1898  * \note
1899  * Changing the transform direction does not modify the in/out values --
1900  * they are always specified with respect to the "forward" direction.
1901  */
1902 class OCIOEXPORT RangeTransform : public Transform
1903 {
1904 public:
1905  /// Creates an instance of RangeTransform.
1906  static RangeTransformRcPtr Create();
1907 
1908  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_RANGE; }
1909 
1910  virtual RangeStyle getStyle() const noexcept = 0;
1911  /// Set the Range style to clamp or not input values.
1912  virtual void setStyle(RangeStyle style) noexcept = 0;
1913 
1914  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1915  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1916 
1917  /// Checks if this equals other.
1918  virtual bool equals(const RangeTransform & other) const noexcept = 0;
1919 
1920  /**
1921  * **File bit-depth**
1922  *
1923  * In a format such as CLF, the range values are scaled to take
1924  * pixels at the specified inBitDepth to pixels at the specified
1925  * outBitDepth. This complicates the interpretation of the range
1926  * values and so this object always holds normalized values and
1927  * scaling is done on the way from or to file formats such as CLF.
1928  */
1929 
1930  /// Get the bit-depths associated with the range values read from a file
1931  /// or set the bit-depths of values to be written to a file (for file
1932  /// formats such as CLF that support multiple bit-depths).
1933  virtual BitDepth getFileInputBitDepth() const noexcept = 0;
1934  virtual void setFileInputBitDepth(BitDepth bitDepth) noexcept = 0;
1935  virtual BitDepth getFileOutputBitDepth() const noexcept = 0;
1936  virtual void setFileOutputBitDepth(BitDepth bitDepth) noexcept = 0;
1937 
1938  /**
1939  * **Range values**
1940  *
1941  * These values are normalized relative to what may be stored in file
1942  * formats such as CLF. For example in a CLF file using a "10i" input
1943  * depth, a MaxInValue of 1023 in the file is normalized to 1.0.
1944  * Likewise, for an output depth of "12i", a MaxOutValue of 4095 in the
1945  * file is normalized to 1.0. The values here are unclamped and may
1946  * extend outside [0,1].
1947  */
1948 
1949  /// Get the minimum value for the input.
1950  virtual double getMinInValue() const noexcept = 0;
1951  /// Set the minimum value for the input.
1952  virtual void setMinInValue(double val) noexcept = 0;
1953  /// Is the minimum value for the input set?
1954  virtual bool hasMinInValue() const noexcept = 0;
1955  /// Unset the minimum value for the input
1956  virtual void unsetMinInValue() noexcept = 0;
1957 
1958  /// Set the maximum value for the input.
1959  virtual void setMaxInValue(double val) noexcept = 0;
1960  /// Get the maximum value for the input.
1961  virtual double getMaxInValue() const noexcept = 0;
1962  /// Is the maximum value for the input set?
1963  virtual bool hasMaxInValue() const noexcept = 0;
1964  /// Unset the maximum value for the input.
1965  virtual void unsetMaxInValue() noexcept = 0;
1966 
1967  /// Set the minimum value for the output.
1968  virtual void setMinOutValue(double val) noexcept = 0;
1969  /// Get the minimum value for the output.
1970  virtual double getMinOutValue() const noexcept = 0;
1971  /// Is the minimum value for the output set?
1972  virtual bool hasMinOutValue() const noexcept = 0;
1973  /// Unset the minimum value for the output.
1974  virtual void unsetMinOutValue() noexcept = 0;
1975 
1976  /// Set the maximum value for the output.
1977  virtual void setMaxOutValue(double val) noexcept = 0;
1978  /// Get the maximum value for the output.
1979  virtual double getMaxOutValue() const noexcept = 0;
1980  /// Is the maximum value for the output set?
1981  virtual bool hasMaxOutValue() const noexcept = 0;
1982  /// Unset the maximum value for the output.
1983  virtual void unsetMaxOutValue() noexcept = 0;
1984 
1985  RangeTransform(const RangeTransform &) = delete;
1986  RangeTransform & operator= (const RangeTransform &) = delete;
1987  /// Do not use (needed only for pybind11).
1988  virtual ~RangeTransform() = default;
1989 
1990 protected:
1991  RangeTransform() = default;
1992 };
1993 
1994 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const RangeTransform &) noexcept;
1995 
1996 } // namespace OCIO_NAMESPACE
1997 
1998 #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:613
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
OCIOEXPORT bool operator!=(const GradingRGBM &lhs, const GradingRGBM &rhs)
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
__hostdev__ void setValue(uint32_t offset, bool v)
Definition: NanoVDB.h:5750
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)
__hostdev__ float getValue(uint32_t i) const
Definition: NanoVDB.h:5578
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
OCIOEXPORT bool operator==(const GradingRGBM &lhs, const GradingRGBM &rhs)
TransformType getTransformType() const noexceptoverride
TransformType getTransformType() const noexceptoverride
Interface used to access dynamic property GradingPrimary value.
LeafData & operator=(const LeafData &)=delete
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
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
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