pub struct StaticCPUProcessor(/* private fields */);Expand description
A CPU processor proven to contain no dynamic properties.
This wrapper can be shared across threads to process independent image buffers. Its one-time dynamic-property validation adds no lock to pixel processing. Single-pixel calls still check the processor’s cached bit-depth compatibility. OCIO native interop must not mutate or replace its underlying processor concurrently.
let cpu = std::sync::Arc::new(cpu.try_into_static()?);
std::thread::scope(|scope| {
let cpu = cpu.clone();
scope.spawn(move || {
let mut rgba = [0.1, 0.2, 0.3, 1.0];
cpu.try_apply_rgba(&mut rgba).unwrap();
});
});Implementations§
Source§impl StaticCPUProcessor
impl StaticCPUProcessor
Sourcepub fn into_inner(self) -> CPUProcessor
pub fn into_inner(self) -> CPUProcessor
Returns the thread-confined CPU handle when the wrapper is owned.
Methods from Deref<Target = CPUProcessor>§
Sourcepub fn try_apply_packed_image(
&self,
data: &mut [u8],
layout: PackedImageLayout,
) -> Result<()>
pub fn try_apply_packed_image( &self, data: &mut [u8], layout: PackedImageLayout, ) -> Result<()>
Process an exclusively borrowed packed image in place. Unpadded generic layouts may use a small temporary buffer for the final pixel; earlier regions may already be modified if a later native call fails.
Sourcepub fn try_convert_packed_image(
&self,
source: &[u8],
source_layout: PackedImageLayout,
destination: &mut [u8],
destination_layout: PackedImageLayout,
) -> Result<()>
pub fn try_convert_packed_image( &self, source: &[u8], source_layout: PackedImageLayout, destination: &mut [u8], destination_layout: PackedImageLayout, ) -> Result<()>
Convert independently laid-out packed images. Dimensions must match; bit depths and channel ordering may differ. Unpadded tails may use small temporary buffers and multiple calls; later failure may leave earlier destination regions modified.
Sourcepub fn try_convert_packed_to_planar(
&self,
source: &[u8],
source_layout: PackedImageLayout,
destination: SignedPlanarBytesMut<'_>,
) -> Result<()>
pub fn try_convert_packed_to_planar( &self, source: &[u8], source_layout: PackedImageLayout, destination: SignedPlanarBytesMut<'_>, ) -> Result<()>
Convert a packed source into separate signed-stride destination planes.
The images must have matching dimensions and processor-compatible bit depths. Alpha may be present independently on either side. OCIO fills missing input alpha with zero in 2.4/2.5 and one in 2.6; it discards alpha if the output lacks it. Unpadded tails may use small temporary buffers and multiple native calls; a later error may leave earlier output regions modified.
Sourcepub fn try_convert_planar_to_packed(
&self,
source: SignedPlanarBytes<'_>,
destination: &mut [u8],
destination_layout: PackedImageLayout,
) -> Result<()>
pub fn try_convert_planar_to_packed( &self, source: SignedPlanarBytes<'_>, destination: &mut [u8], destination_layout: PackedImageLayout, ) -> Result<()>
Convert signed-stride source planes into a packed destination.
See Self::try_convert_packed_to_planar for dimensions, alpha,
bit-depth and borrowed-buffer requirements.
Sourcepub fn try_apply_planar_signed(
&self,
image: SignedPlanarBytesMut<'_>,
) -> Result<()>
pub fn try_apply_planar_signed( &self, image: SignedPlanarBytesMut<'_>, ) -> Result<()>
Process a planar image in place with signed byte strides without copying.
Unpadded planes are split into up to three native regions so OCIO’s final pointer step remains within each slice. Earlier regions may be modified if a later region reports an error.
Sourcepub fn try_apply_planar_signed_convert(
&self,
source: SignedPlanarBytes<'_>,
destination: SignedPlanarBytesMut<'_>,
) -> Result<()>
pub fn try_apply_planar_signed_convert( &self, source: SignedPlanarBytes<'_>, destination: SignedPlanarBytesMut<'_>, ) -> Result<()>
Convert separate signed-stride planar images without copying pixel data.
Source and destination must have equal dimensions. Alpha may be present
independently on either side. Missing input alpha follows the native
version’s behavior, described by Self::try_convert_packed_to_planar.
Their layouts and bit depths may differ. Unpadded planes may require
multiple native calls; a later failure can leave earlier output modified.
Sourcepub fn try_apply_planar_convert(
&self,
source: PlanarBytes<'_>,
destination: PlanarBytesMut<'_>,
) -> Result<()>
pub fn try_apply_planar_convert( &self, source: PlanarBytes<'_>, destination: PlanarBytesMut<'_>, ) -> Result<()>
Convert separate planar buffers using the processor’s input and output depths.
Layouts may have different strides and bit depths, but must have identical
dimensions. Alpha may be present independently on either side; see
Self::try_convert_packed_to_planar for missing-alpha behavior. Buffers are borrowed
directly without copying; strides are in bytes and must be positive and aligned.
Unpadded tails may require multiple native calls; a later error may leave
earlier destination regions modified.
Sourcepub fn try_apply_packed_convert(
&self,
input: &[u8],
output: &mut [u8],
layout: PackedConversionLayout,
) -> Result<()>
pub fn try_apply_packed_convert( &self, input: &[u8], output: &mut [u8], layout: PackedConversionLayout, ) -> Result<()>
Convert separate packed buffers with the processor’s input/output depths.
RGB and RGBA are supported. Strides are measured in samples. Input and output slices are checked independently and must meet native alignment. Unpadded tails may require an additional native call; an error in that call can leave the earlier destination pixels modified.
Sourcepub fn try_apply_planar_bytes(
&self,
red: &mut [u8],
green: &mut [u8],
blue: &mut [u8],
alpha: Option<&mut [u8]>,
layout: PlanarByteLayout,
) -> Result<()>
pub fn try_apply_planar_bytes( &self, red: &mut [u8], green: &mut [u8], blue: &mut [u8], alpha: Option<&mut [u8]>, layout: PlanarByteLayout, ) -> Result<()>
Process planar byte buffers in place at the processor’s native bit depth.
All pointers and strides must be aligned for the selected storage type. The binding validates the layout and passes the original buffers to OCIO. Unpadded final samples are handled in up to three native regions, with no pixel copy. A later error may leave earlier regions modified.
Sourcepub fn try_apply_planar_strided_f32(
&self,
red: &mut [f32],
green: &mut [f32],
blue: &mut [f32],
alpha: Option<&mut [f32]>,
layout: PlanarF32Layout,
) -> Result<()>
pub fn try_apply_planar_strided_f32( &self, red: &mut [f32], green: &mut [f32], blue: &mut [f32], alpha: Option<&mut [f32]>, layout: PlanarF32Layout, ) -> Result<()>
Process strided planar F32 channels in place without copying pixels.
Strides are measured in F32 elements and must be positive. As required by OCIO, the row stride must be at least the pixel stride times the width, even for a single row. Alpha may be omitted. If a plane ends immediately after its last sample, the image is processed in up to three regions to keep OCIO’s pointer increments within the slices. If a later region fails, earlier regions may already be modified.
Sourcepub fn try_apply_planar_f32(
&self,
red: &mut [f32],
green: &mut [f32],
blue: &mut [f32],
alpha: Option<&mut [f32]>,
width: usize,
height: usize,
) -> Result<()>
pub fn try_apply_planar_f32( &self, red: &mut [f32], green: &mut [f32], blue: &mut [f32], alpha: Option<&mut [f32]>, width: usize, height: usize, ) -> Result<()>
Process contiguous row-major planar float channels in place.
Each channel must contain exactly width * height samples. Alpha is
optional. The native descriptor borrows these slices for this call and
no pixel buffer is allocated or copied by the binding.
Sourcepub unsafe fn apply(&self, img_desc: *mut c_void)
👎Deprecated since 0.2.0: raw OCIO image-descriptor entry point; prefer apply_rgb/apply_rgba/apply_*_pixels for Rust callers
pub unsafe fn apply(&self, img_desc: *mut c_void)
raw OCIO image-descriptor entry point; prefer apply_rgb/apply_rgba/apply_*_pixels for Rust callers
§Safety
img_desc must point to a valid OCIO image descriptor for the active
ABI. The pixel buffers referenced by the descriptor must remain
allocated, writable, and correctly strided for the full call. The
descriptor is borrowed only; this method does not take ownership.
Sourcepub fn try_apply_image_desc(
&self,
image: &mut NativeImageDesc<'_>,
) -> Result<()>
pub fn try_apply_image_desc( &self, image: &mut NativeImageDesc<'_>, ) -> Result<()>
Apply in place to a Rust-owned native descriptor.
OCIO rejects a descriptor whose bit depth does not match both processor bit depths. The descriptor and its backing buffers are reused.
Sourcepub fn try_convert_image_desc(
&self,
source: &mut NativeImageDesc<'_>,
destination: &mut NativeImageDesc<'_>,
) -> Result<()>
pub fn try_convert_image_desc( &self, source: &mut NativeImageDesc<'_>, destination: &mut NativeImageDesc<'_>, ) -> Result<()>
Convert between Rust-owned native descriptors of equal size.
OCIO checks the dimensions and input/output bit depths before processing.
Sourcepub unsafe fn try_apply_raw(&self, img_desc: *mut c_void) -> Result<()>
pub unsafe fn try_apply_raw(&self, img_desc: *mut c_void) -> Result<()>
Apply a native OCIO image descriptor in place without taking ownership.
Prefer the slice-based methods for Rust buffers. This entry point is for interop with C++ code that already owns a descriptor.
§Safety
img_desc must point to a valid OCIO image descriptor for the active
ABI (pass a pointer to its ImageDesc base). The pixel buffers must
remain exclusively accessible, writable, correctly aligned and strided
for the processor’s bit depths. This bypasses Rust’s layout checks and
tail handling: the buffers must accommodate native pointer stepping.
Sourcepub unsafe fn try_apply_raw_v2(
&self,
src_img_desc: *mut c_void,
dst_img_desc: *mut c_void,
) -> Result<()>
pub unsafe fn try_apply_raw_v2( &self, src_img_desc: *mut c_void, dst_img_desc: *mut c_void, ) -> Result<()>
Apply between separate native OCIO image descriptors without taking ownership.
§Safety
Both pointers must address valid ImageDesc bases for the active ABI.
Source storage must be readable and destination storage exclusively
writable, with no overlap. Both must satisfy the native alignment,
bit-depth, stride and pointer-stepping requirements described in
Self::try_apply_raw.
Sourcepub fn apply_rgba(&self, rgba: &mut [f32; 4])
pub fn apply_rgba(&self, rgba: &mut [f32; 4])
Apply the processor in place to one RGBA pixel.
Sourcepub fn try_apply_rgba(&self, rgba: &mut [f32; 4]) -> Result<()>
pub fn try_apply_rgba(&self, rgba: &mut [f32; 4]) -> Result<()>
Apply the processor in place to one RGBA pixel.
Both processor bit depths must be F32, as required by OCIO’s
single-pixel API. A mismatch returns an error without changing rgba.
Sourcepub fn try_apply_rgb(&self, rgb: &mut [f32; 3]) -> Result<()>
pub fn try_apply_rgb(&self, rgb: &mut [f32; 3]) -> Result<()>
Apply the processor in place to one RGB pixel.
Both processor bit depths must be F32, as required by OCIO’s
single-pixel API. A mismatch returns an error without changing rgb.
Sourcepub fn apply_rgba_pixels(&self, rgba: &mut [f32], num_pixels: i64, stride: i64)
pub fn apply_rgba_pixels(&self, rgba: &mut [f32], num_pixels: i64, stride: i64)
Apply the processor to an RGBA float buffer with an explicit scalar stride.
stride is measured in f32 elements, not bytes.
Sourcepub fn try_apply_rgba_pixels(
&self,
rgba: &mut [f32],
num_pixels: i64,
stride: i64,
) -> Result<()>
pub fn try_apply_rgba_pixels( &self, rgba: &mut [f32], num_pixels: i64, stride: i64, ) -> Result<()>
Apply the processor to an RGBA float buffer with an explicit scalar stride.
stride is measured in f32 elements, not bytes.
Sourcepub fn apply_rgb_pixels(&self, rgb: &mut [f32], num_pixels: i64, stride: i64)
pub fn apply_rgb_pixels(&self, rgb: &mut [f32], num_pixels: i64, stride: i64)
Apply the processor to an RGB float buffer with an explicit scalar stride.
stride is measured in f32 elements, not bytes.
Sourcepub fn try_apply_rgb_pixels(
&self,
rgb: &mut [f32],
num_pixels: i64,
stride: i64,
) -> Result<()>
pub fn try_apply_rgb_pixels( &self, rgb: &mut [f32], num_pixels: i64, stride: i64, ) -> Result<()>
Apply the processor to an RGB float buffer with an explicit scalar stride.
stride is measured in f32 elements, not bytes.
Sourcepub fn apply_rgba_packed_bit_depth(
&self,
rgba: &mut [u8],
bit_depth: BitDepth,
num_pixels: i64,
stride: i64,
)
pub fn apply_rgba_packed_bit_depth( &self, rgba: &mut [u8], bit_depth: BitDepth, num_pixels: i64, stride: i64, )
Apply the processor to packed RGBA bytes using an explicit OCIO bit depth.
bit_depth must match the CPU processor’s finalized bit-depth contract.
In particular, a default CPU processor commonly expects BitDepth::F32.
Sourcepub fn try_apply_rgba_packed_bit_depth(
&self,
rgba: &mut [u8],
bit_depth: BitDepth,
num_pixels: i64,
stride: i64,
) -> Result<()>
pub fn try_apply_rgba_packed_bit_depth( &self, rgba: &mut [u8], bit_depth: BitDepth, num_pixels: i64, stride: i64, ) -> Result<()>
Apply the processor to packed RGBA bytes using an explicit OCIO bit depth.
bit_depth must match the CPU processor’s finalized bit-depth contract.
In particular, a default CPU processor commonly expects BitDepth::F32.
Sourcepub fn apply_rgb_packed_bit_depth(
&self,
rgb: &mut [u8],
bit_depth: BitDepth,
num_pixels: i64,
stride: i64,
)
pub fn apply_rgb_packed_bit_depth( &self, rgb: &mut [u8], bit_depth: BitDepth, num_pixels: i64, stride: i64, )
Apply the processor to packed RGB bytes using an explicit OCIO bit depth.
bit_depth must match the CPU processor’s finalized bit-depth contract.
In particular, a default CPU processor commonly expects BitDepth::F32.
Sourcepub fn try_apply_rgb_packed_bit_depth(
&self,
rgb: &mut [u8],
bit_depth: BitDepth,
num_pixels: i64,
stride: i64,
) -> Result<()>
pub fn try_apply_rgb_packed_bit_depth( &self, rgb: &mut [u8], bit_depth: BitDepth, num_pixels: i64, stride: i64, ) -> Result<()>
Apply the processor to packed RGB bytes using an explicit OCIO bit depth.
bit_depth must match the CPU processor’s finalized bit-depth contract.
In particular, a default CPU processor commonly expects BitDepth::F32.
Sourcepub fn is_no_op(&self) -> bool
pub fn is_no_op(&self) -> bool
Return whether the CPU path is an identity/no-op transform.
Returns false if OCIO reports an error. Use Self::try_is_no_op to
distinguish that case from a non-identity processor.
Sourcepub fn try_is_no_op(&self) -> Result<bool>
pub fn try_is_no_op(&self) -> Result<bool>
Fallible variant of Self::is_no_op.
Returns an error when the underlying OCIO query throws.
Sourcepub fn has_channel_crosstalk(&self) -> bool
pub fn has_channel_crosstalk(&self) -> bool
Return whether the CPU path mixes color channels.
Returns false if OCIO reports an error. Use
Self::try_has_channel_crosstalk to distinguish that case from a
lane-wise processor.
Sourcepub fn try_has_channel_crosstalk(&self) -> Result<bool>
pub fn try_has_channel_crosstalk(&self) -> Result<bool>
Fallible variant of Self::has_channel_crosstalk.
Returns an error when the underlying OCIO query throws.
Sourcepub fn cache_id(&self) -> Option<String>
pub fn cache_id(&self) -> Option<String>
Return OCIO’s cache identifier for this CPU processor instance.
Sourcepub fn try_cache_id(&self) -> Result<Option<String>>
pub fn try_cache_id(&self) -> Result<Option<String>>
Return OCIO’s cache identifier, preserving bridge errors.
Sourcepub fn input_bit_depth(&self) -> i32
pub fn input_bit_depth(&self) -> i32
Return the declared input bit depth for this CPU path.
Sourcepub fn try_input_bit_depth(&self) -> Result<i32>
pub fn try_input_bit_depth(&self) -> Result<i32>
Return the declared input bit depth, preserving bridge errors.
Sourcepub fn output_bit_depth(&self) -> i32
pub fn output_bit_depth(&self) -> i32
Return the declared output bit depth for this CPU path.
Sourcepub fn try_output_bit_depth(&self) -> Result<i32>
pub fn try_output_bit_depth(&self) -> Result<i32>
Return the declared output bit depth, preserving bridge errors.
Sourcepub fn is_identity(&self) -> bool
pub fn is_identity(&self) -> bool
Return whether this CPU path is functionally identity.
Returns false if OCIO reports an error. Use Self::try_is_identity
to distinguish that case from a non-identity processor.
Sourcepub fn try_is_identity(&self) -> Result<bool>
pub fn try_is_identity(&self) -> Result<bool>
Fallible variant of Self::is_identity.
Returns an error when the underlying OCIO query throws.
Sourcepub fn dynamic_property(
&self,
prop_type: DynamicPropertyType,
) -> Result<DynamicProperty>
pub fn dynamic_property( &self, prop_type: DynamicPropertyType, ) -> Result<DynamicProperty>
Borrow a runtime-adjustable dynamic property from the CPU processor.
Returns the OCIO error when the requested property is not available.
Sourcepub fn has_dynamic_property_kind(&self, prop_type: DynamicPropertyType) -> bool
pub fn has_dynamic_property_kind(&self, prop_type: DynamicPropertyType) -> bool
Return whether the CPU processor exposes a dynamic property of prop_type.
Sourcepub fn try_has_dynamic_property_kind(
&self,
prop_type: DynamicPropertyType,
) -> Result<bool>
pub fn try_has_dynamic_property_kind( &self, prop_type: DynamicPropertyType, ) -> Result<bool>
Fallible variant of Self::has_dynamic_property_kind.
Sourcepub fn is_dynamic(&self) -> bool
pub fn is_dynamic(&self) -> bool
Return whether this CPU processor contains any runtime-adjustable properties.
Sourcepub fn try_is_dynamic(&self) -> Result<bool>
pub fn try_is_dynamic(&self) -> Result<bool>
Fallible variant of Self::is_dynamic.