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  /// Returns true if the extension corresponds to a format supported by FileTransform.
1074  /// The argument is case-insensitive, and a leading dot, if present, is ignored.
1075  /// Note that FileTransform will attempt all format readers on a given file until it is
1076  /// successful, even files that contain an unsupported extension or no extension.
1077  /// However, this function is useful for applications that want to know which files are likely
1078  /// to be LUT files, based on their extension.
1079  static bool IsFormatExtensionSupported(const char * extension);
1080 
1081  FileTransform & operator=(const FileTransform &) = delete;
1082  /// Do not use (needed only for pybind11).
1083  virtual ~FileTransform();
1084 
1085 private:
1086  FileTransform();
1087  FileTransform(const FileTransform &);
1088 
1089  static void deleter(FileTransform * t);
1090 
1091  class Impl;
1092  Impl * m_impl;
1093  Impl * getImpl() { return m_impl; }
1094  const Impl * getImpl() const { return m_impl; }
1095 };
1096 
1097 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const FileTransform &);
1098 
1099 
1100 /**
1101  * Provides a set of hard-coded algorithmic building blocks
1102  * that are needed to accurately implement various common color transformations.
1103  */
1104 class OCIOEXPORT FixedFunctionTransform : public Transform
1105 {
1106 public:
1107  static FixedFunctionTransformRcPtr Create(FixedFunctionStyle style);
1108  static FixedFunctionTransformRcPtr Create(FixedFunctionStyle style,
1109  const double * params,
1110  size_t num);
1111 
1112  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_FIXED_FUNCTION; }
1113 
1114  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1115  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1116 
1117  /// Checks if this exactly equals other.
1118  virtual bool equals(const FixedFunctionTransform & other) const noexcept = 0;
1119 
1120  virtual FixedFunctionStyle getStyle() const = 0;
1121  /// Select which algorithm to use.
1122  virtual void setStyle(FixedFunctionStyle style) = 0;
1123 
1124  virtual size_t getNumParams() const = 0;
1125  virtual void getParams(double * params) const = 0;
1126  /// Set the parameters (for functions that require them).
1127  virtual void setParams(const double * params, size_t num) = 0;
1128 
1130  FixedFunctionTransform & operator= (const FixedFunctionTransform &) = delete;
1131  /// Do not use (needed only for pybind11).
1132  virtual ~FixedFunctionTransform() = default;
1133 
1134 protected:
1135  FixedFunctionTransform() = default;
1136 };
1137 
1138 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const FixedFunctionTransform &);
1139 
1140 
1141 /**
1142  * Primary color correction controls.
1143  *
1144  * This transform is for making basic color correction adjustments to an image such as brightness,
1145  * contrast, or saturation.
1146  *
1147  * The controls are customized for linear, logarithmic, and video color encodings.
1148  * * Linear controls: Exposure, Contrast, Pivot, Offset, Saturation, Black Clip, White Clip.
1149  * * Log controls: Brightness, Contrast, Pivot, Log Gamma, Saturation, Black Clip, White Clip,
1150  * Black Pivot White Pivot.
1151  * * Video controls : Lift, Gamma, Gain, Offset, Saturation, Black Clip, White Clip,
1152  * Black Pivot White Pivot.
1153  *
1154  * The controls are dynamic, so they may be adjusted even after the Transform has been included
1155  * in a Processor.
1156  */
1158 {
1159 public:
1160  /// Creates an instance of GradingPrimaryTransform.
1161  static GradingPrimaryTransformRcPtr Create(GradingStyle style);
1162 
1163  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_GRADING_PRIMARY; }
1164 
1165  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1166  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1167 
1168  /// Checks if this equals other.
1169  virtual bool equals(const GradingPrimaryTransform & other) const noexcept = 0;
1170 
1171  /// Adjusts the behavior of the transform for log, linear, or video color space encodings.
1172  virtual GradingStyle getStyle() const noexcept = 0;
1173  /// Will reset value to style's defaults if style is not the current style.
1174  virtual void setStyle(GradingStyle style) noexcept = 0;
1175 
1176  virtual const GradingPrimary & getValue() const = 0;
1177  /// Throws if value is not valid.
1178  virtual void setValue(const GradingPrimary & values) = 0;
1179 
1180  /**
1181  * Parameters can be made dynamic so the values can be changed through the CPU or GPU processor,
1182  * but if there are several GradingPrimaryTransform only one can have dynamic parameters.
1183  */
1184  virtual bool isDynamic() const noexcept = 0;
1185  virtual void makeDynamic() noexcept = 0;
1186  virtual void makeNonDynamic() noexcept = 0;
1187 
1189  GradingPrimaryTransform & operator= (const GradingPrimaryTransform &) = delete;
1190  /// Do not use (needed only for pybind11).
1191  virtual ~GradingPrimaryTransform() = default;
1192 
1193 protected:
1194  GradingPrimaryTransform() = default;
1195 };
1196 
1197 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const GradingPrimaryTransform &) noexcept;
1198 
1199 
1200 /**
1201  * RGB curve color correction controls.
1202  *
1203  * This transform allows for modifying tone reproduction via B-spline curves.
1204  *
1205  * There is an R, G, and B curve along with a Master curve (that applies to R, G, and B). Each
1206  * curve is specified via the x and y coordinates of its control points. A monotonic spline is
1207  * fit to the control points. The x coordinates must be non-decreasing. When the grading style
1208  * is linear, the units for the control points are photographic stops relative to 0.18.
1209  *
1210  * The control points are dynamic, so they may be adjusted even after the Transform is included
1211  * in a Processor.
1212  */
1214 {
1215 public:
1216  /// Creates an instance of GradingPrimaryTransform.
1217  static GradingRGBCurveTransformRcPtr Create(GradingStyle style);
1218 
1220 
1221  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1222  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1223 
1224  /// Checks if this equals other.
1225  virtual bool equals(const GradingRGBCurveTransform & other) const noexcept = 0;
1226 
1227  /// Adjusts the behavior of the transform for log, linear, or video color space encodings.
1228  virtual GradingStyle getStyle() const noexcept = 0;
1229  /// Will reset value to style's defaults if style is not the current style.
1230  virtual void setStyle(GradingStyle style) noexcept = 0;
1231 
1232  virtual const ConstGradingRGBCurveRcPtr getValue() const = 0;
1233  /// Throws if value is not valid.
1234  virtual void setValue(const ConstGradingRGBCurveRcPtr & values) = 0;
1235 
1236  /**
1237  * It is possible to provide a desired slope value for each control point. The number of slopes is
1238  * always the same as the number of control points and so the control points must be set before
1239  * setting the slopes. The slopes are primarily intended for use by config authors looking to match
1240  * a specific shape with as few control points as possible, they are not intended to be exposed to
1241  * a user interface for direct manipulation. When a curve is being generated for creative purposes
1242  * it is better to let OCIO calculate the slopes automatically.
1243  */
1244  virtual float getSlope(RGBCurveType c, size_t index) const = 0;
1245  virtual void setSlope(RGBCurveType c, size_t index, float slope) = 0;
1246  virtual bool slopesAreDefault(RGBCurveType c) const = 0;
1247 
1248  /**
1249  * The scene-linear grading style applies a lin-to-log transform to the pixel
1250  * values before going through the curve. However, in some cases (e.g. drawing curves in a UI)
1251  * it may be useful to bypass the lin-to-log. Default value is false.
1252  */
1253  virtual bool getBypassLinToLog() const = 0;
1254  virtual void setBypassLinToLog(bool bypass) = 0;
1255 
1256  /**
1257  * Parameters can be made dynamic so the values can be changed through the CPU or GPU processor,
1258  * but if there are several GradingRGBCurveTransform only one can have dynamic parameters.
1259  */
1260  virtual bool isDynamic() const noexcept = 0;
1261  virtual void makeDynamic() noexcept = 0;
1262  virtual void makeNonDynamic() noexcept = 0;
1263 
1265  GradingRGBCurveTransform & operator= (const GradingRGBCurveTransform &) = delete;
1266  /// Do not use (needed only for pybind11).
1267  virtual ~GradingRGBCurveTransform() = default;
1268 
1269 protected:
1270  GradingRGBCurveTransform() = default;
1271 };
1272 
1273 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const GradingRGBCurveTransform &) noexcept;
1274 
1275 
1276 /**
1277  * Tonal color correction controls.
1278  *
1279  * This transform is for making fine adjustments to tone reproduction in specific tonal ranges.
1280  *
1281  * There are five tonal controls and each one has two parameters to control its range:
1282  * * Blacks (start, width)
1283  * * Shadows(start, pivot)
1284  * * Midtones(center, width)
1285  * * Highlights(start, pivot)
1286  * * Whites(start, width)
1287  *
1288  * The transform has three styles that adjust the response and default ranges for linear,
1289  * logarithimic, and video color encodings. The defaults vary based on the style. When the
1290  * style is linear, the units for start/width/etc. are photographic stops relative to 0.18.
1291  *
1292  * Each control allows R, G, B adjustments and a Master adjustment.
1293  *
1294  * There is also an S-contrast control for imparting an S-shape curve.
1295  *
1296  * The controls are dynamic, so they may be adjusted even after the Transform has been included
1297  * in a Processor.
1298  */
1300 {
1301 public:
1302  /// Creates an instance of GradingToneTransform.
1303  static GradingToneTransformRcPtr Create(GradingStyle style);
1304 
1305  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_GRADING_TONE; }
1306 
1307  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1308  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1309 
1310  virtual bool equals(const GradingToneTransform & other) const noexcept = 0;
1311 
1312  /// Adjusts the behavior of the transform for log, linear, or video color space encodings.
1313  virtual GradingStyle getStyle() const noexcept = 0;
1314  /// Will reset value to style's defaults if style is not the current style.
1315  virtual void setStyle(GradingStyle style) noexcept = 0;
1316 
1317  virtual const GradingTone & getValue() const = 0;
1318  virtual void setValue(const GradingTone & values) = 0;
1319 
1320  /**
1321  * Parameters can be made dynamic so the values can be changed through the CPU or GPU processor,
1322  * but if there are several GradingToneTransform only one can have dynamic parameters.
1323  */
1324  virtual bool isDynamic() const noexcept = 0;
1325  virtual void makeDynamic() noexcept = 0;
1326  virtual void makeNonDynamic() noexcept = 0;
1327 
1328  GradingToneTransform(const GradingToneTransform &) = delete;
1329  GradingToneTransform & operator= (const GradingToneTransform &) = delete;
1330  /// Do not use (needed only for pybind11).
1331  virtual ~GradingToneTransform() = default;
1332 
1333 protected:
1334  GradingToneTransform() = default;
1335 };
1336 
1337 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const GradingToneTransform &) noexcept;
1338 
1339 
1340 class OCIOEXPORT GroupTransform : public Transform
1341 {
1342 public:
1343  static GroupTransformRcPtr Create();
1344 
1345  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1346  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1347 
1348  /// Throws if index is not allowed.
1349  virtual ConstTransformRcPtr getTransform(int index) const = 0;
1350 
1351  /// Throws if index is not allowed.
1352  virtual TransformRcPtr & getTransform(int index) = 0;
1353 
1354  /// Return number of transforms.
1355  virtual int getNumTransforms() const noexcept = 0;
1356  /// Adds a transform to the end of the group.
1357  virtual void appendTransform(TransformRcPtr transform) noexcept = 0;
1358  /// Add a transform at the beginning of the group.
1359  virtual void prependTransform(TransformRcPtr transform) noexcept = 0;
1360 
1361  /**
1362  * \brief Write the transforms comprising the group to the stream.
1363  *
1364  * Writing (as opposed to Baking) is a lossless process. An exception is thrown if the
1365  * processor cannot be losslessly written to the specified file format. Transforms such as
1366  * FileTransform or ColorSpaceTransform are resolved into write-able simple transforms using
1367  * the config and context. Supported formats include CTF, CLF, and CDL. All available formats
1368  * can be listed with the following:
1369  * \code{.cpp}
1370  * // What are the allowed writing output formats?
1371  * std::ostringstream formats;
1372  * formats << "Formats to write to: ";
1373  * for (int i = 0; i < GroupTransform::GetNumWriteFormats(); ++i)
1374  * {
1375  * if (i != 0) formats << ", ";
1376  * formats << GroupTransform::GetFormatNameByIndex(i);
1377  * formats << " (." << GroupTransform::GetFormatExtensionByIndex(i) << ")";
1378  * }
1379  * \endcode
1380  */
1381  virtual void write(const ConstConfigRcPtr & config,
1382  const char * formatName,
1383  std::ostream & os) const = 0;
1384 
1385  /// Get the number of writers.
1386  static int GetNumWriteFormats() noexcept;
1387 
1388  /// Get the writer at index, return empty string if an invalid index is specified.
1389  static const char * GetFormatNameByIndex(int index) noexcept;
1390  static const char * GetFormatExtensionByIndex(int index) noexcept;
1391 
1392  GroupTransform(const GroupTransform &) = delete;
1393  GroupTransform & operator=(const GroupTransform &) = delete;
1394  /// Do not use (needed only for pybind11).
1395  virtual ~GroupTransform() = default;
1396 
1397 protected:
1398  GroupTransform() = default;
1399 };
1400 
1401 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const GroupTransform &);
1402 
1403 
1404 
1405 /**
1406  * Applies a logarithm with an affine transform before and after.
1407  * Represents the Cineon lin-to-log type transforms::
1408  *
1409  * logSideSlope * log( linSideSlope * color + linSideOffset, base) + logSideOffset
1410  *
1411  * * Default values are: 1. * log( 1. * color + 0., 2.) + 0.
1412  * * The alpha channel is not affected.
1413  */
1414 class OCIOEXPORT LogAffineTransform : public Transform
1415 {
1416 public:
1417  static LogAffineTransformRcPtr Create();
1418 
1419  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_LOG_AFFINE; }
1420 
1421  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1422  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1423 
1424  /// Checks if this exactly equals other.
1425  virtual bool equals(const LogAffineTransform & other) const noexcept = 0;
1426 
1427  virtual double getBase() const noexcept = 0;
1428  virtual void setBase(double base) noexcept = 0;
1429 
1430  // !rst:: **Get/Set values for the R, G, B components**
1431 
1432  virtual void getLogSideSlopeValue(double(&values)[3]) const noexcept = 0;
1433  virtual void setLogSideSlopeValue(const double(&values)[3]) noexcept = 0;
1434  virtual void getLogSideOffsetValue(double(&values)[3]) const noexcept = 0;
1435  virtual void setLogSideOffsetValue(const double(&values)[3]) noexcept = 0;
1436  virtual void getLinSideSlopeValue(double(&values)[3]) const noexcept = 0;
1437  virtual void setLinSideSlopeValue(const double(&values)[3]) noexcept = 0;
1438  virtual void getLinSideOffsetValue(double(&values)[3]) const noexcept = 0;
1439  virtual void setLinSideOffsetValue(const double(&values)[3]) noexcept = 0;
1440 
1441  LogAffineTransform(const LogAffineTransform &) = delete;
1442  LogAffineTransform & operator= (const LogAffineTransform &) = delete;
1443  /// Do not use (needed only for pybind11).
1444  virtual ~LogAffineTransform() = default;
1445 
1446 protected:
1447  LogAffineTransform() = default;
1448 };
1449 
1450 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const LogAffineTransform &);
1451 
1452 
1453 /**
1454  * Same as LogAffineTransform but with the addition of a linear segment near black. This formula
1455  * is used for many camera logs (e.g., LogC) as well as ACEScct.
1456  *
1457  * * The linSideBreak specifies the point on the linear axis where the log and linear
1458  * segments meet. It must be set (there is no default).
1459  * * The linearSlope specifies the slope of the linear segment of the forward (linToLog)
1460  * transform. By default it is set equal to the slope of the log curve at the break point.
1461  */
1463 {
1464 public:
1465  /// LinSideBreak must be set for the transform to be valid (there is no default).
1466  static LogCameraTransformRcPtr Create(const double(&linSideBreakValues)[3]);
1467 
1468  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_LOG_CAMERA; }
1469 
1470  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1471  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1472 
1473  /// Checks if this exactly equals other.
1474  virtual bool equals(const LogCameraTransform & other) const noexcept = 0;
1475 
1476  virtual double getBase() const noexcept = 0;
1477  virtual void setBase(double base) noexcept = 0;
1478 
1479  /// Get/Set values for the R, G, B components.
1480  virtual void getLogSideSlopeValue(double(&values)[3]) const noexcept = 0;
1481  virtual void setLogSideSlopeValue(const double(&values)[3]) noexcept = 0;
1482  virtual void getLogSideOffsetValue(double(&values)[3]) const noexcept = 0;
1483  virtual void setLogSideOffsetValue(const double(&values)[3]) noexcept = 0;
1484  virtual void getLinSideSlopeValue(double(&values)[3]) const noexcept = 0;
1485  virtual void setLinSideSlopeValue(const double(&values)[3]) noexcept = 0;
1486  virtual void getLinSideOffsetValue(double(&values)[3]) const noexcept = 0;
1487  virtual void setLinSideOffsetValue(const double(&values)[3]) noexcept = 0;
1488  virtual void getLinSideBreakValue(double(&values)[3]) const noexcept = 0;
1489  virtual void setLinSideBreakValue(const double(&values)[3]) noexcept = 0;
1490 
1491  /// Return true if LinearSlope values were set, false if they were not.
1492  virtual bool getLinearSlopeValue(double(&values)[3]) const = 0;
1493  /**
1494  * \brief Set LinearSlope value.
1495  *
1496  * \note
1497  * You must call setLinSideBreakValue before calling this.
1498  */
1499  virtual void setLinearSlopeValue(const double(&values)[3]) = 0;
1500  /// Remove LinearSlope values so that default values are used.
1501  virtual void unsetLinearSlopeValue() = 0;
1502 
1503  LogCameraTransform(const LogCameraTransform &) = delete;
1504  LogCameraTransform & operator= (const LogCameraTransform &) = delete;
1505  /// Do not use (needed only for pybind11).
1506  virtual ~LogCameraTransform() = default;
1507 
1508 protected:
1509  LogCameraTransform() = default;
1510 };
1511 
1512 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const LogCameraTransform &);
1513 
1514 
1515 /**
1516  * Represents log transform: log(color, base)
1517  *
1518  * * The input will be clamped for negative numbers.
1519  * * Default base is 2.0.
1520  * * The alpha channel is not affected.
1521  */
1522 class OCIOEXPORT LogTransform : public Transform
1523 {
1524 public:
1525  static LogTransformRcPtr Create();
1526 
1527  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_LOG; }
1528 
1529  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1530  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1531 
1532  /// Checks if this exactly equals other.
1533  virtual bool equals(const LogTransform & other) const noexcept = 0;
1534 
1535  virtual double getBase() const noexcept = 0;
1536  virtual void setBase(double val) noexcept = 0;
1537 
1538  LogTransform(const LogTransform &) = delete;
1539  LogTransform & operator= (const LogTransform &) = delete;
1540  /// Do not use (needed only for pybind11).
1541  virtual ~LogTransform() = default;
1542 
1543 protected:
1544  LogTransform() = default;
1545 };
1546 
1547 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const LogTransform &);
1548 
1549 
1550 class OCIOEXPORT LookTransform : public Transform
1551 {
1552 public:
1553  static LookTransformRcPtr Create();
1554 
1555  TransformRcPtr createEditableCopy() const override;
1556 
1557  TransformDirection getDirection() const noexcept override;
1558  void setDirection(TransformDirection dir) noexcept override;
1559 
1560  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_LOOK; }
1561 
1562  /// Will throw if data is not valid.
1563  void validate() const override;
1564 
1565  const char * getSrc() const;
1566  void setSrc(const char * src);
1567 
1568  const char * getDst() const;
1569  void setDst(const char * dst);
1570 
1571  const char * getLooks() const;
1572  /**
1573  * Specify looks to apply.
1574  * Looks is a potentially comma (or colon) delimited list of look names,
1575  * Where +/- prefixes are optionally allowed to denote forward/inverse
1576  * look specification. (And forward is assumed in the absence of either)
1577  */
1578  void setLooks(const char * looks);
1579 
1580  bool getSkipColorSpaceConversion() const;
1581  void setSkipColorSpaceConversion(bool skip);
1582 
1583  /**
1584  * Return the name of the color space after applying looks in the forward
1585  * direction but without converting to the destination color space. This is equivalent
1586  * to the process space of the last look in the look sequence (and takes into account that
1587  * a look fall-back may be used).
1588  */
1589  static const char * GetLooksResultColorSpace(const ConstConfigRcPtr & config,
1590  const ConstContextRcPtr & context,
1591  const char * looks);
1592 
1593  LookTransform & operator=(const LookTransform &) = delete;
1594  /// Do not use (needed only for pybind11).
1595  virtual ~LookTransform();
1596 
1597 private:
1598  LookTransform();
1599  LookTransform(const LookTransform &);
1600 
1601  static void deleter(LookTransform * t);
1602 
1603  class Impl;
1604  Impl * m_impl;
1605  Impl * getImpl() { return m_impl; }
1606  const Impl * getImpl() const { return m_impl; }
1607 };
1608 
1609 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const LookTransform &);
1610 
1611 
1612 /// Represents a 1D-LUT transform.
1613 class OCIOEXPORT Lut1DTransform : public Transform
1614 {
1615 public:
1616  /// Create an identity 1D-LUT of length two.
1617  static Lut1DTransformRcPtr Create();
1618 
1619  /**
1620  * Create an identity 1D-LUT with specific length and
1621  * half-domain setting. Will throw for lengths longer than 1024x1024.
1622  */
1623  static Lut1DTransformRcPtr Create(unsigned long length,
1624  bool isHalfDomain);
1625 
1626  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_LUT1D; }
1627 
1628  virtual BitDepth getFileOutputBitDepth() const noexcept = 0;
1629  /**
1630  * Get the bit-depth associated with the LUT values read
1631  * from a file or set the bit-depth of values to be written to a file
1632  * (for file formats such as CLF that support multiple bit-depths).
1633  * However, note that the values stored in the object are always
1634  * normalized.
1635  */
1636  virtual void setFileOutputBitDepth(BitDepth bitDepth) noexcept = 0;
1637 
1638  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1639  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1640 
1641  /// Checks if this exactly equals other.
1642  virtual bool equals(const Lut1DTransform & other) const noexcept = 0;
1643 
1644  virtual unsigned long getLength() const = 0;
1645  /**
1646  * Changing the length will reset the LUT to identity.
1647  * Will throw for lengths longer than 1024x1024.
1648  */
1649  virtual void setLength(unsigned long length) = 0;
1650 
1651  virtual void getValue(unsigned long index, float & r, float & g, float & b) const = 0;
1652  /**
1653  * Set the values of a LUT1D. Will throw if the index
1654  * is outside of the range from 0 to (length-1).
1655  *
1656  * The LUT values are always for the "forward" LUT, regardless of how
1657  * the transform direction is set.
1658  *
1659  * These values are normalized relative to what may be stored in any
1660  * given LUT files. For example in a CLF file using a "10i" output
1661  * depth, a value of 1023 in the file is normalized to 1.0. The
1662  * values here are unclamped and may extend outside [0,1].
1663  *
1664  * LUTs in various file formats may only provide values for one
1665  * channel where R, G, B are the same. Even in that case, you should
1666  * provide three equal values to the setter.
1667  */
1668  virtual void setValue(unsigned long index, float r, float g, float b) = 0;
1669 
1670  virtual bool getInputHalfDomain() const noexcept = 0;
1671  /**
1672  * In a half-domain LUT, the contents of the LUT specify
1673  * the desired value of the function for each half-float value.
1674  * Therefore, the length of the LUT must be 65536 entries or else
1675  * validate() will throw.
1676  */
1677  virtual void setInputHalfDomain(bool isHalfDomain) noexcept = 0;
1678 
1679  virtual bool getOutputRawHalfs() const noexcept = 0;
1680  /**
1681  * Set OutputRawHalfs to true if you want to output the
1682  * LUT contents as 16-bit floating point values expressed as unsigned
1683  * 16-bit integers representing the equivalent bit pattern.
1684  * For example, the value 1.0 would be written as the integer 15360
1685  * because it has the same bit-pattern. Note that this implies the
1686  * values will be quantized to a 16-bit float. Note that this setting
1687  * only controls the output formatting (where supported) and not the
1688  * values for getValue/setValue. The only file formats that currently
1689  * support this are CLF and CTF.
1690  */
1691  virtual void setOutputRawHalfs(bool isRawHalfs) noexcept = 0;
1692 
1693  virtual Lut1DHueAdjust getHueAdjust() const noexcept = 0;
1694  /**
1695  * The 1D-LUT transform optionally supports a hue adjustment
1696  * feature that was used in some versions of ACES. This adjusts the hue
1697  * of the result to approximately match the input.
1698  */
1699  virtual void setHueAdjust(Lut1DHueAdjust algo) = 0;
1700 
1701  virtual Interpolation getInterpolation() const = 0;
1702  virtual void setInterpolation(Interpolation algo) = 0;
1703 
1704  Lut1DTransform(const Lut1DTransform &) = delete;
1705  Lut1DTransform & operator= (const Lut1DTransform &) = delete;
1706  /// Do not use (needed only for pybind11).
1707  virtual ~Lut1DTransform() = default;
1708 
1709 protected:
1710  Lut1DTransform() = default;
1711 };
1712 
1713 extern OCIOEXPORT std::ostream& operator<< (std::ostream&, const Lut1DTransform&);
1714 
1715 
1716 /// Represents a 3D-LUT transform.
1717 class OCIOEXPORT Lut3DTransform : public Transform
1718 {
1719 public:
1720  /// Create an identity 3D-LUT of size 2x2x2.
1721  static Lut3DTransformRcPtr Create();
1722 
1723  /**
1724  * Create an identity 3D-LUT with specific grid size.
1725  * Will throw for grid size larger than 129.
1726  */
1727  static Lut3DTransformRcPtr Create(unsigned long gridSize);
1728 
1729  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_LUT3D; }
1730 
1731  virtual BitDepth getFileOutputBitDepth() const noexcept = 0;
1732  /**
1733  * Get the bit-depth associated with the LUT values read
1734  * from a file or set the bit-depth of values to be written to a file
1735  * (for file formats such as CLF that support multiple bit-depths).
1736  * However, note that the values stored in the object are always
1737  * normalized.
1738  */
1739  virtual void setFileOutputBitDepth(BitDepth bitDepth) noexcept = 0;
1740 
1741  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1742  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1743 
1744  /// Checks if this exactly equals other.
1745  virtual bool equals(const Lut3DTransform & other) const noexcept = 0;
1746 
1747  virtual unsigned long getGridSize() const = 0;
1748  /**
1749  * Changing the grid size will reset the LUT to identity.
1750  * Will throw for grid sizes larger than 129.
1751  */
1752  virtual void setGridSize(unsigned long gridSize) = 0;
1753 
1754  virtual void getValue(unsigned long indexR,
1755  unsigned long indexG,
1756  unsigned long indexB,
1757  float & r, float & g, float & b) const = 0;
1758  /**
1759  * Set the values of a 3D-LUT. Will throw if an index is
1760  * outside of the range from 0 to (gridSize-1).
1761  *
1762  * The LUT values are always for the "forward" LUT, regardless of how the
1763  * transform direction is set.
1764  *
1765  * These values are normalized relative to what may be stored in any
1766  * given LUT files. For example in a CLF file using a "10i" output
1767  * depth, a value of 1023 in the file is normalized to 1.0. The values
1768  * here are unclamped and may extend outside [0,1].
1769  */
1770  virtual void setValue(unsigned long indexR,
1771  unsigned long indexG,
1772  unsigned long indexB,
1773  float r, float g, float b) = 0;
1774 
1775  virtual Interpolation getInterpolation() const = 0;
1776  virtual void setInterpolation(Interpolation algo) = 0;
1777 
1778  Lut3DTransform(const Lut3DTransform &) = delete;
1779  Lut3DTransform & operator= (const Lut3DTransform &) = delete;
1780  /// Do not use (needed only for pybind11).
1781  virtual ~Lut3DTransform() = default;
1782 
1783 protected:
1784  Lut3DTransform() = default;
1785 };
1786 
1787 extern OCIOEXPORT std::ostream& operator<< (std::ostream&, const Lut3DTransform&);
1788 
1789 /**
1790  * Represents an MX+B Matrix transform.
1791  *
1792  * \note
1793  * For singular matrices, an inverse direction will throw an exception during finalization.
1794  */
1796 {
1797 public:
1798  static MatrixTransformRcPtr Create();
1799 
1800  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_MATRIX; }
1801 
1802  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1803  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1804 
1805  /// Checks if this exactly equals other.
1806  virtual bool equals(const MatrixTransform & other) const noexcept = 0;
1807 
1808  virtual void getMatrix(double * m44) const = 0;
1809  /**
1810  * Get or set the values of a Matrix. Expects 16 values,
1811  * where the first four are the coefficients to generate the R output
1812  * channel from R, G, B, A input channels.
1813  *
1814  * The Matrix values are always for the "forward" Matrix, regardless of
1815  * how the transform direction is set.
1816  *
1817  * These values are normalized relative to what may be stored in
1818  * file formats such as CLF. For example in a CLF file using a "32f"
1819  * input depth and "10i" output depth, a value of 1023 in the file
1820  * is normalized to 1.0. The values here are unclamped and may
1821  * extend outside [0,1].
1822  */
1823  virtual void setMatrix(const double * m44) = 0;
1824 
1825  virtual void getOffset(double * offset4) const = 0;
1826  /**
1827  * Get or set the R, G, B, A offsets to be applied
1828  * after the matrix.
1829  *
1830  * These values are normalized relative to what may be stored in
1831  * file formats such as CLF. For example, in a CLF file using a
1832  * "10i" output depth, a value of 1023 in the file is normalized
1833  * to 1.0. The values here are unclamped and may extend
1834  * outside [0,1].
1835  */
1836  virtual void setOffset(const double * offset4) = 0;
1837 
1838  /**
1839  * Get the bit-depths associated with the matrix values read from a
1840  * file or set the bit-depths of values to be written to a file
1841  * (for file formats such as CLF that support multiple bit-depths).
1842  *
1843  * In a format such as CLF, the matrix values are scaled to take
1844  * pixels at the specified inBitDepth to pixels at the specified
1845  * outBitDepth. This complicates the interpretation of the matrix
1846  * values and so this object always holds normalized values and
1847  * scaling is done on the way from or to file formats such as CLF.
1848  */
1849  virtual BitDepth getFileInputBitDepth() const noexcept = 0;
1850  virtual void setFileInputBitDepth(BitDepth bitDepth) noexcept = 0;
1851  virtual BitDepth getFileOutputBitDepth() const noexcept = 0;
1852  virtual void setFileOutputBitDepth(BitDepth bitDepth) noexcept = 0;
1853 
1854 
1855  /// **Convenience functions**
1856  ///
1857  /// Build the matrix and offset corresponding to higher-level concepts.
1858  ///
1859  /// \note
1860  /// These can throw an exception if for any component
1861  /// ``oldmin == oldmax. (divide by 0)``
1862  static void Fit(double * m44, double* offset4,
1863  const double * oldmin4, const double * oldmax4,
1864  const double * newmin4, const double * newmax4);
1865 
1866  static void Identity(double * m44, double * offset4);
1867 
1868  static void Sat(double * m44, double * offset4,
1869  double sat, const double * lumaCoef3);
1870 
1871  static void Scale(double * m44, double * offset4,
1872  const double * scale4);
1873 
1874  static void View(double * m44, double * offset4,
1875  int * channelHot4,
1876  const double * lumaCoef3);
1877 
1878  MatrixTransform(const MatrixTransform &) = delete;
1879  MatrixTransform & operator= (const MatrixTransform &) = delete;
1880  /// Do not use (needed only for pybind11).
1881  virtual ~MatrixTransform() = default;
1882 
1883 protected:
1884  MatrixTransform() = default;
1885 };
1886 
1887 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const MatrixTransform &) noexcept;
1888 
1889 
1890 /**
1891  * Represents a range transform
1892  *
1893  * The Range is used to apply an affine transform (scale & offset) and
1894  * clamps values to min/max bounds on all color components except the alpha.
1895  * The scale and offset values are computed from the input and output bounds.
1896  *
1897  * Refer to section 7.2.4 in specification S-2014-006 "A Common File Format
1898  * for Look-Up Tables" from the Academy of Motion Picture Arts and Sciences
1899  * and the American Society of Cinematographers.
1900  *
1901  * \note
1902  * The "noClamp" style described in the specification S-2014-006 becomes a
1903  * MatrixOp at the processor level.
1904  *
1905  * \note
1906  * Changing the transform direction does not modify the in/out values --
1907  * they are always specified with respect to the "forward" direction.
1908  */
1909 class OCIOEXPORT RangeTransform : public Transform
1910 {
1911 public:
1912  /// Creates an instance of RangeTransform.
1913  static RangeTransformRcPtr Create();
1914 
1915  TransformType getTransformType() const noexcept override { return TRANSFORM_TYPE_RANGE; }
1916 
1917  virtual RangeStyle getStyle() const noexcept = 0;
1918  /// Set the Range style to clamp or not input values.
1919  virtual void setStyle(RangeStyle style) noexcept = 0;
1920 
1921  virtual const FormatMetadata & getFormatMetadata() const noexcept = 0;
1922  virtual FormatMetadata & getFormatMetadata() noexcept = 0;
1923 
1924  /// Checks if this equals other.
1925  virtual bool equals(const RangeTransform & other) const noexcept = 0;
1926 
1927  /**
1928  * **File bit-depth**
1929  *
1930  * In a format such as CLF, the range values are scaled to take
1931  * pixels at the specified inBitDepth to pixels at the specified
1932  * outBitDepth. This complicates the interpretation of the range
1933  * values and so this object always holds normalized values and
1934  * scaling is done on the way from or to file formats such as CLF.
1935  */
1936 
1937  /// Get the bit-depths associated with the range values read from a file
1938  /// or set the bit-depths of values to be written to a file (for file
1939  /// formats such as CLF that support multiple bit-depths).
1940  virtual BitDepth getFileInputBitDepth() const noexcept = 0;
1941  virtual void setFileInputBitDepth(BitDepth bitDepth) noexcept = 0;
1942  virtual BitDepth getFileOutputBitDepth() const noexcept = 0;
1943  virtual void setFileOutputBitDepth(BitDepth bitDepth) noexcept = 0;
1944 
1945  /**
1946  * **Range values**
1947  *
1948  * These values are normalized relative to what may be stored in file
1949  * formats such as CLF. For example in a CLF file using a "10i" input
1950  * depth, a MaxInValue of 1023 in the file is normalized to 1.0.
1951  * Likewise, for an output depth of "12i", a MaxOutValue of 4095 in the
1952  * file is normalized to 1.0. The values here are unclamped and may
1953  * extend outside [0,1].
1954  */
1955 
1956  /// Get the minimum value for the input.
1957  virtual double getMinInValue() const noexcept = 0;
1958  /// Set the minimum value for the input.
1959  virtual void setMinInValue(double val) noexcept = 0;
1960  /// Is the minimum value for the input set?
1961  virtual bool hasMinInValue() const noexcept = 0;
1962  /// Unset the minimum value for the input
1963  virtual void unsetMinInValue() noexcept = 0;
1964 
1965  /// Set the maximum value for the input.
1966  virtual void setMaxInValue(double val) noexcept = 0;
1967  /// Get the maximum value for the input.
1968  virtual double getMaxInValue() const noexcept = 0;
1969  /// Is the maximum value for the input set?
1970  virtual bool hasMaxInValue() const noexcept = 0;
1971  /// Unset the maximum value for the input.
1972  virtual void unsetMaxInValue() noexcept = 0;
1973 
1974  /// Set the minimum value for the output.
1975  virtual void setMinOutValue(double val) noexcept = 0;
1976  /// Get the minimum value for the output.
1977  virtual double getMinOutValue() const noexcept = 0;
1978  /// Is the minimum value for the output set?
1979  virtual bool hasMinOutValue() const noexcept = 0;
1980  /// Unset the minimum value for the output.
1981  virtual void unsetMinOutValue() noexcept = 0;
1982 
1983  /// Set the maximum value for the output.
1984  virtual void setMaxOutValue(double val) noexcept = 0;
1985  /// Get the maximum value for the output.
1986  virtual double getMaxOutValue() const noexcept = 0;
1987  /// Is the maximum value for the output set?
1988  virtual bool hasMaxOutValue() const noexcept = 0;
1989  /// Unset the maximum value for the output.
1990  virtual void unsetMaxOutValue() noexcept = 0;
1991 
1992  RangeTransform(const RangeTransform &) = delete;
1993  RangeTransform & operator= (const RangeTransform &) = delete;
1994  /// Do not use (needed only for pybind11).
1995  virtual ~RangeTransform() = default;
1996 
1997 protected:
1998  RangeTransform() = default;
1999 };
2000 
2001 extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const RangeTransform &) noexcept;
2002 
2003 } // namespace OCIO_NAMESPACE
2004 
2005 #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:632
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
GLsizei const GLfloat * value
Definition: glcorearb.h:824
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 &)
FixedFunctionStyle
Enumeration of the :cpp:class:FixedFunctionTransform transform algorithms.
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
OIIO_UTIL_API std::string extension(string_view filepath, bool include_dot=true) noexcept
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