OpenColorIO (C++)
The Academy Software Foundation's colour-management library for film and VFX: a declarative config of named colour spaces, roles, displays, views, looks and file rules is compiled, per conversion, into an optimised op list that runs either as a scanline CPU processor or as shader text generated for the caller's GPU API.
| Field | Value |
|---|---|
| Language | C++17; Python and Java bindings (src/bindings) |
| License | BSD-3-Clause (LICENSE); docs CC-BY-4.0 |
| Repository | AcademySoftwareFoundation/OpenColorIO |
| Revision read | 22dd9c4faa0d1b7cfb3d64d1a6e9cb454acc6cfd (September 30, 2026, "Update notes for 2.6 release"; CMakeLists.txt 2.7.0 dev) |
| Documentation | opencolorio.readthedocs.io; the public header OpenColorIO.h carries most of the API contract |
| Category | Colour: config-driven colour management, CPU and generated-GPU processing |
| Tier | B |
| Last reviewed | November 7, 2026 |
NOTE
Claims marked demonstrated come from small C++ programs in /tmp/ocio-demo built against OpenColorIO 2.4.2 from nixpkgs (nix-shell -p opencolorio), not the pinned 2.7.0 development tree. The 2.4.2 library embeds the older built-in config cg-config-v2.2.0_aces-v1.3_ocio-v2.4; the pinned tree adds the ACES 2.x configs and stricter LUT-size checks, as noted where they differ.
Overview
What it solves
A production renders, composites and grades in several applications, each of which must agree on what a pixel value means and how it is shown. OCIO moves that knowledge out of the applications into one shared file, the config, which an application loads (usually from $OCIO) and queries by name. The README.md says:
"OpenColorIO (OCIO) is a complete color management solution geared towards motion picture production with an emphasis on visual effects and computer animation. […] OCIO is compatible with the Academy Color Encoding Specification (ACES) and is LUT-format agnostic, supporting many popular formats."
Design philosophy
The application never sees colour mathematics. The internal-architecture page states the split (internal_architecture.rst):
"Configs and ColorSpaces are just a bookkeeping device used to get and ordered lists of Transforms corresponding to image color transformation. Transforms are visible to the person AUTHORING the OCIO config, but are NOT visible to the client applications. Client apps need only concern themselves with Configs and Processors."
and the same page adds that colour-space names "should NEVER be hard-coded into client software, but should be dynamically queried at runtime from the library" (internal_architecture.rst). The project mission lists "provide lossless color processing wherever possible" (README.md). The optimiser honours that through a named OPTIMIZATION_LOSSLESS preset, but the default preset is VERY_GOOD, which already adds 1D-LUT composition and fast approximations (OpenColorTypes.h); only GOOD and DRAFT compose 3D LUTs.
How it works
The config
A config is YAML (.ocio, or a zipped .ocioz archive). Its top-level keys in the built-in CG config include roles, file_rules, viewing_rules, shared_views, displays, looks, view_transforms, display_colorspaces, colorspaces and named_transforms (cg-config-v5.0.0; abridged):
roles:
aces_interchange: ACES2065-1
scene_linear: ACEScg
texture_paint: sRGB Encoded Rec.709 (sRGB)
file_rules:
- !<Rule> { name: EXR, colorspace: ACES2065-1, pattern: '*', extension: exr }
- !<Rule> { name: Default, colorspace: sRGB - Display }- A colour space defines its relation to one of two reference spaces (
REFERENCE_SPACE_SCENEorREFERENCE_SPACE_DISPLAY,OpenColorTypes.h) throughfrom_scene_reference/to_scene_referencetransform chains. It also carriesaliases,family,categories,encoding(sdr-video,log,scene-linear, …),isdata, and since 2.5 aninterop_id(cg-configsRGB entry). - A role is an indirection (
scene_linear,compositing_log,data,color_picking, …) that lets an application ask for "the working space" without knowing its name (OpenColorTypes.h). - A display lists views; a view pairs a
view_transform(scene-referred to display-referred, for example an ACES output transform) with a display colour space.viewing_rulesfilter which views apply to a source by itsencoding. - A look is a named creative grade applied in a process space.
- File rules map a path to a colour space by glob, extension or regex, consulted by
Config::getColorSpaceFromFilepath(OpenColorIO.h).
Config::CreateFromEnv reads $OCIO; CreateFromBuiltinConfig and the ocio:// URI load configs compiled into the library (OpenColorIO.h). The pinned tree embeds five CG and five studio ACES configs, from ocio-v2.1 to ocio-v2.6 (builtinconfigs/configs).
Transforms and builtin transforms
The transform vocabulary is a closed set of classes in OpenColorTransforms.h: MatrixTransform, ExponentWithLinearTransform, LogCameraTransform, FileTransform (24 registered formats from 19 readers in fileformats/, ICC matrix/TRC display profiles among them), FixedFunctionTransform (ACES algorithms in code), the Grading* transforms, GroupTransform, and the indirections ColorSpaceTransform, DisplayViewTransform and LookTransform.
OCIO v2 added BuiltinTransform: a string style resolved against a registry of op-building functors, so a config can name a standard conversion without shipping a LUT. Registration is per family (ACES, six camera vendors, displays, BuiltinTransformRegistry.cpp):
registry.addBuiltin("DISPLAY - CIE-XYZ-D65_to_sRGB",
"Convert CIE XYZ (D65 white) to sRGB (piecewise EOTF)",
CIE_XYZ_D65_to_SRGB_MONCURVE);(Displays.cpp). Each functor appends matrix and curve ops computed from primaries and the adaptation method, so the builtin is analytic.
Processors
Config::getProcessor takes two colour-space names, a display and view, a named transform, or an arbitrary transform tree, and returns a Processor: the transform tree flattened into an OpRcPtrVec (OpenColorIO.h). The Processor is a description; execution needs one of its derivatives (OpenColorIO.h):
ConstGPUProcessorRcPtr getDefaultGPUProcessor() const;
ConstCPUProcessorRcPtr getDefaultCPUProcessor() const;
ConstCPUProcessorRcPtr getOptimizedCPUProcessor(BitDepth inBitDepth,
BitDepth outBitDepth,
OptimizationFlags oFlags) const;Deriving an optimised processor runs finalize, optimize(oFlags) and, for the CPU, optimizeForBitdepth on a copy of the op list (Processor.cpp).
The optimiser
OptimizationFlags is a bit set of named rewrites (OpenColorTypes.h): remove identities, remove adjacent inverse pairs per op type (PAIR_IDENTITY_LUT3D, …), compose adjacent pairs (COMP_MATRIX, COMP_LUT1D, COMP_LUT3D, …), replace separable prefixes by one 1D LUT for integer and half inputs (COMP_SEPARABLE_PREFIX), and fast approximations (LUT_INV_FAST, FAST_LOG_EXP_POW). Presets group them: OPTIMIZATION_LOSSLESS, VERY_GOOD (the default: lossless plus COMP_LUT1D, LUT_INV_FAST, FAST_LOG_EXP_POW and COMP_SEPARABLE_PREFIX), GOOD (adds 3D LUT composition) and DRAFT (everything). OpRcPtrVec::optimize iterates RemoveNoOps, ReplaceOps, ReplaceIdentityOps, RemoveInverseOps and CombineOps until no pass makes progress, capped at MAX_OPTIMIZATION_PASSES = 80 (OpOptimizers.cpp).
Demonstrated with the 2.4.2 built-in CG config: srgb_tx to ACEScg has three unoptimised ops and two after OPTIMIZATION_DEFAULT; a GroupTransform of ACEScg to srgb_tx and back has six ops, isNoOp() returns false, and the OPTIMIZATION_LOSSLESS processor has zero ops. isNoOp reports on the unoptimised list, so a caller that wants to skip identity work must ask the optimised processor.
CPU processing
The CPU path takes a non-owning ImageDesc (OpenColorIO.h):
"This is a light-weight wrapper around an image, that provides a context for pixel access. This does NOT claim ownership of the pixels or copy image data."
PackedImageDesc accepts 3 or 4 channels, a ChannelOrdering (RGBA, BGRA, ABGR, RGB, BGR), a BitDepth (UINT8 to UINT16, F16, F32) and byte strides for channel, x and y; PlanarImageDesc takes four plane pointers (OpenColorIO.h, OpenColorTypes.h). CPUProcessor::apply walks the image one row at a time through a ScanlineHelper: the row is unpacked to packed RGBA float, every op runs over it in place, and the row is packed back (CPUProcessor.cpp):
while(true)
{
scanlineBuilder->prepRGBAScanline(&rgbaBuffer, numPixels);
if(numPixels == 0) break;
const size_t numOps = m_cpuOps.size();
for(size_t i = 0; i<numOps; ++i)
{
m_cpuOps[i]->apply(rgbaBuffer, rgbaBuffer, numPixels);
}
scanlineBuilder->finishRGBAScanline();
}When the destination is already packed RGBA F32 the destination row is the working buffer; otherwise init allocates three 4 * width scratch vectors per call, with the comment "TODO: Re-use memory from thread-safe memory pool" (ScanlineHelper.cpp). The first and last ops absorb the bit-depth conversion (inBitDepthOp, outBitDepthOp), often as a 1D LUT indexed by the integer input.
GPU processing: generated shader text
The GPU path does not run anything. GPUProcessor::extractGpuShaderInfo writes into a GpuShaderDesc: a shader function as text in the requested GpuLanguage (Cg, GLSL 1.2 to 4.0, GLSL_VK_4_6, GLSL ES, HLSL SM 5.0, OSL, MSL 2.0, OpenColorTypes.h), a list of 1D/2D and 3D LUT textures with their float values, and uniforms for dynamic properties (OpenColorIO.h). The caller allocates the textures, splices the function into its own fragment shader and binds everything. setFunctionName and setResourcePrefix keep two OCIO functions in one program from clashing; setDescriptorSetIndex and getUniformBufferSize serve Vulkan, where uniforms live in a block and binding 0 is reserved for it (OpenColorIO.h, GpuShaderDesc). Analytic ops (matrices, curves, ACES fixed functions) become inline code; only LUT ops need textures. A separate getOptimizedLegacyGPUProcessor(oFlags, edgelen) reproduces the v1 approach of baking into one 3D LUT, documented as "less accurate" (OpenColorIO.h).
Demonstrated (2.4.2, GPU_LANGUAGE_GLSL_4_0): the ACEScg to sRGB - Display / ACES 1.0 - SDR Video processor optimises to 15 ops (matrices, ranges, logs, two GradingRGBCurves, three FixedFunctions, one ExponentWithLinear) and generates a 277-line, 12,279-byte GLSL function with zero textures and zero uniforms; the B-spline knots are emitted as const float arrays.
Caching
Caches sit at two levels, each a mutex-guarded std::map (GenericCache, Caching.h). The config caches Processors under a hash of the used context variables, the transform's printed form and the direction (Config.cpp); the comment notes the key includes "just the arguments of the FileTransforms for LUTs", so edited LUT files need clearProcessorCache(). When a new processor's op-list getCacheID matches an existing entry, the existing one is reused so its derived processors come along. Each Processor caches its optimised, CPU and GPU derivatives keyed by bit depths and flags (Processor.cpp). ProcessorCacheFlags and the environment variables OCIO_DISABLE_ALL_CACHES and OCIO_DISABLE_PROCESSOR_CACHES turn this off; by default processors with dynamic properties are shared, and the caller "must then always set the dynamic property values prior to any color processing call" (OpenColorTypes.h).
Demonstrated: getProcessor("srgb_tx", "ACEScg") and getProcessor("sRGB Encoded Rec.709 (sRGB)", "scene_linear") (an alias and a role naming the same pair) return the same Processor instance, and two getDefaultCPUProcessor() calls return the same CPUProcessor.
Consumers: OpenImageIO and Blender
OpenImageIO wraps OCIO in ColorConfig; its ColorProcessor_OCIO holds getOptimizedCPUProcessor(ocio_optimization) and applies it to a PackedImageDesc built from OIIO's own strides (color_ocio.cpp). OIIO adds what OCIO leaves out: an own processor cache keyed by colour-space names and context (color_ocio.cpp), unpremultiplication and threading through parallel_image over regions (color_ocio.cpp). It also masks out OPTIMIZATION_COMP_GAMMA before OCIO 2.5.0 because "OCIO 2.3 and 2.4 compose back-to-back gamma/exponent ops in the wrong direction" (color_ocio.cpp).
Blender (read at 049750f9fa83) ships its own config, the AgX views among its displays (config.ocio), and an embedded fallback config that "uses only built-in transforms, so that loading it depends on no file" (libocio_fallback_config.cc). Its viewport chains two OCIO GPU functions, OCIO_to_scene_linear and OCIO_to_display, both generated as GPU_LANGUAGE_GLSL_1_3 with distinct resource prefixes and compiled by Blender's own GPU module, which uploads 1D LUTs as 2D textures and every LUT, 3D ones included, in half-float formats (libocio_gpu_shader_binder.cc, texture setup). OIIO's ColorProcessor_OCIO::isNoOp forwards to the unoptimised Processor::isNoOp (color_ocio.cpp).
Analysis
1. Pixel and memory model
OCIO has no image type. ImageDesc is a borrowed view of RGB(A) with byte strides per channel, x and y, packed or planar (see stride and interleaved, planar and semi-planar); channels beyond the fourth are ignored, and there is no notion of YCbCr, chroma subsampling or more than one row-major 2D region. Internally every op sees one representation: a row of packed RGBA float. The design trades generality of storage for a single kernel signature, apply(const void * in, void * out, long numPixels).
2. Genericity mechanism
Runtime polymorphism throughout: ImageDesc and GpuShaderCreator are abstract classes, ops are OpCPU objects behind shared_ptr, and ScanlineHelper is the one place templates appear (GenericScanlineHelper<InType, OutType>, instantiated per bit-depth pair, CPUProcessor.cpp). The genericity that matters is data: a config is a program written in transforms, and the optimiser is a peephole rewriter over that program.
3. Colour and metadata
This is the subject's whole domain. Colour identity is a name in a config, not a tagged value: a pixel buffer carries no colour state, and the application tracks which colour space each image is in. Two reference spaces separate scene-referred from display-referred data, and the display/view pair names the rendering intent that an ICC profile would otherwise carry. OCIO reads only matrix/TRC display ICC profiles: "Other types of ICC profiles are not currently supported in this reader" (FileFormatICC.cpp). It does not read CICP codes; the bridge to file metadata is the Color Interop Forum interop_id, "intended to identify color spaces in a way that is portable across different configs, making it suitable for use in various file formats" (OpenColorIO.h). Since 2.6, Config::findColorSpaceForID resolves an ID with the Color Interop Forum's fallback rules and Config::LocateBuiltinColorSpace finds the built-in equivalent of a colour space by fingerprinting (OpenColorIO.h). OpenImageIO maps those IDs to CICP on its side (deep-dive). Alpha is passed through untouched; premultiplication is the caller's concern.
4. I/O and codec architecture
OCIO reads no images. Its I/O is configs and LUT files, through a ConfigIOProxy hook that can supply them from memory or an archive instead of the file system (OpenColorIO.h); getColorSpaceFromFilepath is the only point where an image file meets the library, and it looks only at the path.
5. Hostile input and safety
Configs and LUTs are trusted-by-convention studio data, but LUT parsers do bound sizes: Max1DLUTLength = 300000 and Max3DLUTLength = 129 (LutLimits.h), and at the pinned revision the .cube reader rejects a LUT_3D_SIZE outside that range before it reserves storage (FileFormatIridasCube.cpp). Demonstrated against 2.4.2, which lacks that check in the .cube reader: a 23-byte file declaring LUT_3D_SIZE 1000 reached vector::reserve and surfaced as a std::length_error wrapped in an OCIO Exception (message vector::reserve); LUT_3D_SIZE 200 was accepted up to the entry count ("Found 1, expected 8000000"); a cube with a nan entry loaded and produced 0 for that channel. Errors are C++ exceptions; every registered format is tried in turn, and the exception lists one error per reader registered for the file's extension (iridas_cube and resolve_cube for .cube). No fuzz harness exists at this revision (no path matches fuzz). See hostile input.
6. Allocation and ownership
OCIO never owns pixels: ImageDesc borrows the caller's buffer and apply works in place or into a second caller buffer. What OCIO does own (configs, processors, transforms) it hands out as shared_ptr handles (ConstConfigRcPtr, ConstProcessorRcPtr, …), shared across threads and caches. The only per-image allocation is the ScanlineHelper's three 4 * width float vectors, made on each apply unless the destination is packed RGBA F32 (ScanlineHelper.cpp).
7. CPU parallelism and SIMD
OCIO starts no threads (src/OpenColorIO has no std::thread beyond a debug lock); CPUProcessor is shared and the caller splits the image, as OIIO does with parallel_image. SIMD is runtime-dispatched per op: the 1D and 3D LUT renderers have SSE2, AVX, AVX2 and AVX-512 variants chosen through CPUInfo, which also skips AVX on CPUs flagged AVXSlow and AVX2 gathers on AVX2SlowGather (Lut3DOpCPU.cpp, CPUInfo.h). OPTIMIZATION_FAST_LOG_EXP_POW swaps in SSE approximations of log, exp and pow. Demonstrated: the default (VERY_GOOD) processor maps sRGB 0.5 to 0.214037 in ACEScg, beside 0.214041 from the exact sRGB EOTF; the same default flags with OPTIMIZATION_FAST_LOG_EXP_POW cleared give 0.214041, so the residue is that approximation.
8. GPU offload and interop
The decisive design choice: OCIO owns the colour mathematics and none of the GPU plumbing. It emits source text and LUT arrays; the host compiles, allocates, uploads and binds. That is why one library serves OpenGL, Vulkan, Metal and DirectX hosts, and why Blender can force 2D textures for 1D LUTs and half-float storage on its side. The cost is that the host must accept shader source at run time (or bake it per config), and that CPU and GPU agree only within a tolerance, which the GPU tests check by rendering the same values on both and comparing (GPUUnitTest.cpp).
9. Temporal, animation and containers
Not applicable: OCIO processes one image at a time and knows no sequences or containers. The nearest feature is dynamic properties (exposure, contrast, gamma and the grading transforms, OpenColorTypes.h), which let a host change a parameter per frame on an existing processor without rebuilding it.
10. Testing and conformance
The tree carries CPU unit tests per op and format (tests/cpu), a GPU suite that validates each op family against the CPU result (tests/gpu, 17 files), Python and Java binding tests, and an OSL target (tests/osl). The built-in configs double as regression fixtures for config parsing. The CPU path is the oracle for the GPU path.
Lessons for Sparkles
- Q5 A minimum colour model can separate identity (a name or interop ID with a reference space and an encoding class) from mathematics (the op list). OCIO shows the encoding classes (
scene-linear,log,sdr-video,hdr-video,data) are enough to pick views automatically; Sparkles would still need to decide whether that identity rides on the pixel view (the baseline gap G4) or beside it, which OCIO leaves to applications. - Q5 Interop IDs, CICP and ICC are three keys to the same identity. OCIO accepts only the first natively; a D layer that reads PNG
cICPandiCCPmust map them itself, as OpenImageIO does. Matrix/TRC ICC is the subset OCIO found worth parsing. - Q3 A transform chain as data plus a peephole optimiser (remove inverse pairs, compose matrices, fold separable prefixes into a 1D LUT for integer input) is directly expressible in D, and could run at compile time when the chain is static, which OCIO cannot do; the runtime-config case still needs the runtime optimiser.
- Q3 Named precision levels are a usable contract:
LOSSLESSkeeps every op exact, the defaultVERY_GOODalready trades exactness for speed (1D-LUT composition, fastlog/exp/pow), andGOODandDRAFTbake into 3D LUTs. A Sparkles layer has to choose whether its default is the exact level. OIIO's workaround for a composition bug shows each rewrite needs its own differential test. - Q7 One kernel signature over a row of packed RGBA
floatmakes every op SIMD-able and every op GPU-emittable; the same op list producing both a CPU loop and shader code is the shape a D design could get from one source withsparkles:shadersand D-to-SPIR-V instead of text GLSL. OCIO's text output does not fit a pipeline that compiles shaders at build time without a runtime GLSL compiler. - Q6 The GPU interface (shader function, textures, uniform block size, descriptor set index) is small enough to map onto the Vulkan baseline;
GLSL_VK_4_6already reserves binding 0 for the uniform block. - Q4 Processor caching keyed by a canonical transform description, with reuse across contexts by op-list hash, avoids re-optimising on every frame; the stale-LUT hazard (keys omit LUT contents) is a reason to key on content hashes instead.
- Q8 OCIO's CPU processor is a ready oracle for a Sparkles colour layer: the differential test is "same input, same config, compare within tolerance", the same pattern OCIO uses between its own CPU and GPU paths.
- Q9 OCIO is a separate library from any image I/O, and both of its large consumers keep it behind their own wrapper; evidence for colour management as its own package that image-core depends on, not the reverse. Binding OCIO itself from D would bring C++ exceptions,
shared_ptrhandles and YAML parsing, none@nogc.
Strengths
- One config drives every application in a pipeline; applications ask by role or name.
- Analytic builtin transforms remove LUT files from standard conversions.
- The optimiser composes and cancels ops under explicit, documented precision levels.
- GPU output is API-neutral source text plus LUT data, tested against the CPU path.
- Borrowed, strided
ImageDesclets callers keep their own buffers. - Built-in ACES configs and the
ocio://URI give a working default with no files.
Weaknesses
- Pixels carry no colour state; every consumer re-invents the tagging.
- No CICP, and ICC limited to matrix/TRC display profiles.
- No internal threading; per-call scratch allocation in
ScanlineHelper. - Processor cache keys omit LUT contents; edited LUTs need a manual cache clear.
isNoOpon an unoptimised processor misses identities that the optimiser removes.- LUT readers are not fuzzed; size limits were missing from some readers in released versions (2.4.2
.cube). - Run-time shader text does not suit a build-time SPIR-V pipeline.
- C++ exceptions and reference-counted handles throughout the API.
Key design decisions and trade-offs
| Decision | Rationale | Trade-off |
|---|---|---|
| Colour identity lives in a config, not in pixels | One file governs every application in a pipeline | Every consumer tracks which space each buffer is in |
| Transforms compile to an optimised op list | Inverse pairs cancel and matrices compose before any pixel | Default VERY_GOOD is not exact; isNoOp reports on the unoptimised list |
| GPU output is shader text plus LUT arrays | One library serves OpenGL, Vulkan, Metal and DirectX hosts | Hosts must compile shader source at run time |
Borrowed, strided ImageDesc, one row at a time | Callers keep their buffers; one kernel signature per op | Scratch rows allocated per call; no threading inside the library |
| Processor cache keyed by transform text | Repeated getProcessor calls cost a hash lookup | Edited LUT files are not noticed without clearProcessorCache() |
Sources
- Source at the pinned revision:
OpenColorIO.h,OpenColorTypes.h,Config.cpp,Processor.cpp,CPUProcessor.cpp,ScanlineHelper.cpp,OpOptimizers.cpp,Caching.h,LutLimits.h,FileFormatIridasCube.cpp,FileFormatICC.cpp,Lut3DOpCPU.cpp,BuiltinTransformRegistry.cpp,Displays.cpp,cg-config-v5.0.0_aces-v2.1_ocio-v2.6.ocio,GPUUnitTest.cpp. - Documentation:
README.md,internal_architecture.rst,compatible_software.rst, opencolorio.readthedocs.io. - Consumers: OpenImageIO
color_ocio.cppate7eb5d1091142cb6(deep-dive); Blenderlibocio_gpu_shader_binder.cc,libocio_fallback_config.cc,config.ocioat049750f9fa83416e8bf9ae24e44b869f5ff46584. - Catalog: concepts, baseline: existing code, colour and resampling papers.