Skip to content

Commit 0be62f9

Browse files
garyoclaude
andcommitted
Add kOfxParamPropColourManagement for colour-managed RGB/RGBA params (#158)
Implements the agreed spec change from #158: a string-enum property a plug-in sets on an RGB or RGBA parameter to declare the colourspace of the parameter's values (defaults, current value and keyframes): - kOfxParamColourManagementNone - legacy, unmanaged (default) - kOfxParamColourManagementManaged - ACES2065-1 (AP0), scene-linear, unclamped; for processing colours - kOfxParamColourManagementSRGB - sRGB, [0..1]; for display-referred UI colours such as Draw Suite overlays The encoding is fixed at parameter-definition time and needs no OCIO config, so both colour-managed and unmanaged hosts can support it. Defaults to None, so existing plug-ins are unaffected. - include/ofxParam.h: the property and its three values with full @propdef metadata (enum, dim 1), plus ParamsRGB / ParamsRGBA property sets (the colour param types were not previously modelled). - Documentation/sources/Reference/ofxParameter.rst: spec text with the musts/shoulds for hosts and plug-ins. - Examples/Rectangle/rectangle.cpp: declares its solid-fill colour param as Managed, demonstrating the mandatory set-status check. - release-notes.md: noted under 1.5.1. - openfx-cpp/include/openfx/*: regenerated metadata, property sets and typed accessors via scripts/gen-props.py. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Gary Oberbrunner <garyo@darkstarsystems.com>
1 parent 9943cdf commit 0be62f9

8 files changed

Lines changed: 1263 additions & 65 deletions

File tree

Documentation/sources/Reference/ofxParameter.rst

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,80 @@ These are typed by :c:macro:`kOfxParamTypeRGB` and :c:macro:`kOfxParamTypeRGBA`.
150150

151151
Colour parameters are 3 or 4 dimensional double precision floating point
152152
parameters. They are displayed using the host's appropriate interface
153-
for a colour. Values are always normalised in the range [0 .. 1], with 0
153+
for a colour. By default values are normalised in the range [0 .. 1], with 0
154154
being the nominal black point and 1 being the white point.
155155

156+
Colour-Managed Colour Parameters
157+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
158+
159+
The legacy behaviour above does not say which colourspace a colour parameter's
160+
values are in, so plug-ins and hosts have historically had to guess (usually
161+
assuming sRGB). A plug-in may instead declare the encoding explicitly by setting
162+
:c:macro:`kOfxParamPropColourManagement` on an RGB or RGBA parameter. This
163+
property governs the colourspace of *every* value exchanged for the parameter,
164+
including its default, its current value and any keyframes. It does not change
165+
the parameter's type, dimension or numeric API — values are still read and
166+
written as 3 or 4 doubles through the ordinary parameter suite.
167+
168+
The property must be one of:
169+
170+
- :c:macro:`kOfxParamColourManagementNone` — the parameter is not
171+
colour-managed; its values are interpreted as in legacy OpenFX. This is the
172+
default, so existing plug-ins are unaffected.
173+
- :c:macro:`kOfxParamColourManagementManaged` — the values are in the
174+
**ACES2065-1 (AP0)** reference colourspace. They are scene-linear and are not
175+
constrained to the [0 .. 1] range. Use this for colours that participate in
176+
image processing, such as a key colour or a solid-fill colour.
177+
- :c:macro:`kOfxParamColourManagementSRGB` — the values are in the **sRGB**
178+
colourspace ("web" RGB, with the sRGB transfer function), constrained to the
179+
[0 .. 1] range. Use this for display-referred user-interface colours, such as
180+
overlay and on-screen-control colours drawn with the
181+
:c:struct:`OfxDrawSuiteV1`. It is not intended for processing image pixels.
182+
183+
ACES2065-1 is the reference colourspace of the OpenFX native colour management
184+
config (see ``ofxColour.h``). It was chosen because it is a
185+
single, well-specified, scene-referred linear space wide enough to carry any
186+
colour without clamping. Restricting the managed encoding to this one space,
187+
rather than an arbitrary colourspace name, keeps both hosts and plug-ins simple
188+
and makes stored colours portable between applications. Plug-ins that need to
189+
convert managed values to or from another space can do so themselves; the
190+
conversions are standard and need no host involvement.
191+
192+
Rules for plug-ins:
193+
194+
- A plug-in **must** set this property, if at all, only when defining the
195+
parameter (during the describe stage), before the parameter instance exists.
196+
- A plug-in **must not** change the property on a parameter instance, and in
197+
particular **must not** change it during a render or other action to influence
198+
a subsequent read. Hosts may evaluate parameters concurrently; the encoding is
199+
a fixed property of the parameter, not a per-read mode.
200+
- A plug-in **must** check the status returned when setting the property. A host
201+
that does not support it will fail the set; the plug-in **must** then fall
202+
back to :c:macro:`kOfxParamColourManagementNone` behaviour.
203+
- A plug-in that declares a managed or sRGB encoding **must** supply every value
204+
it sets (defaults included) in the declared colourspace, and **must** interpret
205+
every value it reads as being in that colourspace.
206+
207+
Rules for hosts:
208+
209+
- A host that supports the property **must** accept all three values.
210+
- A host **should** convert the parameter's colour from its declared encoding
211+
into whatever space it needs — for example to draw an accurate swatch, to feed
212+
the value to the Draw Suite, or to hand a wide-gamut colour to the plug-in at
213+
render time.
214+
- A host **should** store managed values as ACES2065-1 and sRGB values as sRGB
215+
in its project files, so colour parameters are portable between applications
216+
and across versions.
217+
- When a host first loads a project saved before a parameter became
218+
colour-managed, it **should** convert the previously stored values into the
219+
parameter's declared colourspace, assuming the legacy values were sRGB if it
220+
has no better information.
221+
222+
Support for this property does **not** require the host to advertise any
223+
particular :c:macro:`kOfxImageEffectPropColourManagementStyle`: the managed and
224+
sRGB encodings are fully specified here and need no OCIO config. See
225+
``ofxColour.h`` for the native colour management properties and reference
226+
colourspaces.
156227

157228
Boolean Parameters
158229
------------------

Examples/Rectangle/rectangle.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,20 @@ describeInContext(OfxImageEffectHandle effect, OfxPropertySetHandle inArgs)
803803
gPropHost->propSetString(paramProps, kOfxParamPropHint, 0, "The colour of the rectangle");
804804
gPropHost->propSetString(paramProps, kOfxParamPropScriptName, 0, "colour");
805805
gPropHost->propSetString(paramProps, kOfxPropLabel, 0, "Colour");
806+
807+
// The rectangle is a solid fill, so its colour participates in image
808+
// processing. Declare the parameter colour-managed: its values (including
809+
// the default set below) are then in the ACES2065-1 reference colourspace.
810+
// A plugin must check the status -- a host that does not support this
811+
// property fails the set, in which case the colour is simply a legacy,
812+
// unmanaged value. This minimal example treats the value identically either
813+
// way; the default is opaque black, which is (0,0,0) in every RGB
814+
// colourspace.
815+
OfxStatus colourManagedStat =
816+
gPropHost->propSetString(paramProps, kOfxParamPropColourManagement, 0,
817+
kOfxParamColourManagementManaged);
818+
(void) colourManagedStat;
819+
806820
gPropHost->propSetDouble(paramProps, kOfxParamPropDefault, 0, 0);
807821
gPropHost->propSetDouble(paramProps, kOfxParamPropDefault, 1, 0);
808822
gPropHost->propSetDouble(paramProps, kOfxParamPropDefault, 2, 0);

include/ofxParam.h

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,97 @@ The exact type and dimension is dependent on the type of the parameter. These ar
421421
*/
422422
#define kOfxParamPropDefault "OfxParamPropDefault"
423423

424+
/** @brief Declares how an RGB or RGBA parameter's colour values are encoded,
425+
so that a host can interpret, convert and display them correctly.
426+
427+
This property applies only to parameters of type ::kOfxParamTypeRGB and
428+
::kOfxParamTypeRGBA. It governs the colourspace of *every* value exchanged for
429+
the parameter through the parameter suite, including its default
430+
(::kOfxParamPropDefault), its current value, and any keyframes. It does not
431+
change the parameter's type, dimension, or numeric API: values are still 3 or 4
432+
doubles passed through the ordinary ::OfxParameterSuiteV1 calls.
433+
434+
- Valid Values - This must be one of
435+
- ::kOfxParamColourManagementNone - the parameter is not colour-managed;
436+
its values are interpreted as they always have been (the legacy,
437+
unmanaged behaviour). This is the default.
438+
- ::kOfxParamColourManagementManaged - the parameter's values are in the
439+
ACES2065-1 (AP0) reference colourspace. The values are scene-linear and
440+
are not constrained to the [0..1] range.
441+
- ::kOfxParamColourManagementSRGB - the parameter's values are in the sRGB
442+
colourspace (IEC 61966-2-1, i.e. "web" RGB, with the sRGB transfer
443+
function), constrained to the [0..1] range. This is intended for
444+
display-referred user-interface colours such as overlay and on-screen
445+
control colours drawn with the Draw Suite, not for processing image
446+
pixels.
447+
448+
ACES2065-1 is the reference colourspace of the OFX native colour management
449+
config (see @ref ofxColour.h), chosen because it is a single, well-specified,
450+
scene-referred linear space wide enough to carry any colour the host or plug-in
451+
may need without clamping. Restricting the managed encoding to this one space
452+
(rather than an arbitrary colourspace name) keeps both hosts and plug-ins simple
453+
and makes stored colours portable between applications.
454+
455+
A plug-in MUST set this property, if at all, only during the describe-in-context
456+
/ parameter-definition stage, before the parameter instance exists. A plug-in
457+
MUST NOT change it on a parameter instance, and in particular MUST NOT change it
458+
during a render or other action in order to influence a subsequent read: hosts
459+
may evaluate parameters concurrently, and the encoding is a fixed property of
460+
the parameter, not a per-read mode.
461+
462+
A plug-in MUST check the status returned when setting this property. A host that
463+
does not implement it will fail the set; in that case the plug-in MUST fall back
464+
to ::kOfxParamColourManagementNone behaviour (old-style, unmanaged values). A
465+
plug-in that sets ::kOfxParamColourManagementManaged or
466+
::kOfxParamColourManagementSRGB MUST supply every value it sets (defaults
467+
included) in the declared colourspace, and MUST interpret every value it reads
468+
as being in that colourspace.
469+
470+
This property does not require the host to advertise any particular
471+
::kOfxImageEffectPropColourManagementStyle: the managed and sRGB encodings are
472+
fully specified by this spec and need no OCIO config. A host that supports this
473+
property MUST accept all three values; a host SHOULD convert the parameter's
474+
colour from its declared encoding into whatever space it needs (for example to
475+
draw an accurate swatch, to feed the value to the Draw Suite, or to hand a
476+
wide-gamut colour to the plug-in at render time).
477+
478+
A host SHOULD store ::kOfxParamColourManagementManaged values as ACES2065-1 and
479+
::kOfxParamColourManagementSRGB values as sRGB in its project files, so that
480+
colour params are portable between applications and across versions. When a host
481+
first loads a project saved before the parameter became colour-managed, it
482+
SHOULD convert the previously stored values into the parameter's declared
483+
colourspace (assuming the legacy values were sRGB if it has no better
484+
information).
485+
486+
The property is ignored on parameter types other than RGB and RGBA. It defaults
487+
to ::kOfxParamColourManagementNone, so existing plug-ins are unaffected.
488+
489+
@propdef
490+
type: enum
491+
dimension: 1
492+
introduced: "1.5.1"
493+
values:
494+
- OfxParamColourManagementNone
495+
- OfxParamColourManagementManaged
496+
- OfxParamColourManagementSRGB
497+
*/
498+
#define kOfxParamPropColourManagement "OfxParamPropColourManagement"
499+
500+
/** @brief Value for ::kOfxParamPropColourManagement: the colour parameter is
501+
not colour-managed; its values are interpreted as in legacy OpenFX. This is the
502+
default. */
503+
#define kOfxParamColourManagementNone "OfxParamColourManagementNone"
504+
505+
/** @brief Value for ::kOfxParamPropColourManagement: the colour parameter's
506+
values (defaults, current value and keyframes) are in the ACES2065-1 (AP0)
507+
reference colourspace, scene-linear and not constrained to [0..1]. */
508+
#define kOfxParamColourManagementManaged "OfxParamColourManagementManaged"
509+
510+
/** @brief Value for ::kOfxParamPropColourManagement: the colour parameter's
511+
values are in the sRGB colourspace, constrained to [0..1], intended for
512+
display-referred user-interface colours such as Draw Suite overlays. */
513+
#define kOfxParamColourManagementSRGB "OfxParamColourManagementSRGB"
514+
424515
/** @brief Describes how the double parameter should be interpreted by a host.
425516
426517
- Valid Values -This must be one of
@@ -1453,6 +1544,26 @@ changes a keyframe. The keyframe indices will not change within a single action
14531544
- ParamsNumeric_REF
14541545
*/
14551546

1547+
/** @propset ParamsRGB
1548+
write: plugin
1549+
props:
1550+
- OfxParamPropColourManagement
1551+
- ParamsCommon_REF
1552+
- ParamsAllButGroupPage_REF
1553+
- ParamsValue_REF
1554+
- ParamsNumeric_REF
1555+
*/
1556+
1557+
/** @propset ParamsRGBA
1558+
write: plugin
1559+
props:
1560+
- OfxParamPropColourManagement
1561+
- ParamsCommon_REF
1562+
- ParamsAllButGroupPage_REF
1563+
- ParamsValue_REF
1564+
- ParamsNumeric_REF
1565+
*/
1566+
14561567
/** @propset ParamsChoice
14571568
write: plugin
14581569
props:

0 commit comments

Comments
 (0)