[Cin] opencolorio c++ examples

Andrew Randrianasulu randrianasulu at gmail.com
Thu Jul 18 09:12:12 CEST 2024


I looked at

https://opencolorio.readthedocs.io/en/latest/guides/developing/usage_examples.html

and well, few calls for basic colorspace transform in c++ is not very bad,
but of course even with this easy way I still not quite understand where we
(cinelerra's) should put this call? At (ffmpeg) decode/encode step? At
display step?

=====

Applying a basic ColorSpace transform, using the CPU

This describes what code is used to convert from a specified source
ColorSpace to a specified destination ColorSpace. If you are using the OCIO
Nuke plugins, the OCIOColorSpace node performs these steps internally.

    Get the Config. This represents the entirety of the current color
“universe”. It can either be initialized by your app at startup or created
explicitly. In common usage, you can just query GetCurrentConfig(), which
will auto initialize on first use using the OCIO environment variable.

    Get Processor from the Config. A processor corresponds to a ‘baked’
color transformation. You specify two arguments when querying a processor:
the colorspace_section you are coming from, and the colorspace_section you
are going to. cfgcolorspaces_section ColorSpaces can be either explicitly
named strings (defined by the current configuration) or can be
cfgroles_section (essentially colorspace_section aliases) which are
consistent across configurations. Constructing a Processor object is likely
a blocking operation (thread-wise) so care should be taken to do this as
infrequently as is sensible. Once per render ‘setup’ would be appropriate,
once per scanline would be inappropriate.

    Get a CPU or GPU Processor. Building the processor assembles the
operators needed to perform the requested transformation, however it is not
ready to process pixels. The next step is to create a CPU or GPU processor.
This optimizes and finalizes the operators to produce something that may be
executed efficiently on the target platform.

    Convert your image, using the Processor. Once you have a CPU or GPU
processor, you can apply the color transformation using the “apply”
function. In C++, you may apply the processing in-place, by first wrapping
your image in an ImageDesc class. This approach is intended to be used in
high performance applications, and can be used on multiple threads (per
scanline, per tile, etc). In Python you call “applyRGB” / “applyRGBA” on
your sequence of pixels. Note that in both languages, it is far more
efficient to call “apply” on batches of pixels at a time.

=====
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cinelerra-gg.org/pipermail/cin/attachments/20240718/d3f171f2/attachment.htm>


More information about the Cin mailing list