Skip to main content

StaticCPUProcessor

Struct StaticCPUProcessor 

Source
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

Source

pub fn into_inner(self) -> CPUProcessor

Returns the thread-confined CPU handle when the wrapper is owned.

Methods from Deref<Target = CPUProcessor>§

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub 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

§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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn apply_rgba(&self, rgba: &mut [f32; 4])

Apply the processor in place to one RGBA pixel.

Source

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.

Source

pub fn apply_rgb(&self, rgb: &mut [f32; 3])

Apply the processor in place to one RGB pixel.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn cache_id(&self) -> Option<String>

Return OCIO’s cache identifier for this CPU processor instance.

Source

pub fn try_cache_id(&self) -> Result<Option<String>>

Return OCIO’s cache identifier, preserving bridge errors.

Source

pub fn input_bit_depth(&self) -> i32

Return the declared input bit depth for this CPU path.

Source

pub fn try_input_bit_depth(&self) -> Result<i32>

Return the declared input bit depth, preserving bridge errors.

Source

pub fn output_bit_depth(&self) -> i32

Return the declared output bit depth for this CPU path.

Source

pub fn try_output_bit_depth(&self) -> Result<i32>

Return the declared output bit depth, preserving bridge errors.

Source

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.

Source

pub fn try_is_identity(&self) -> Result<bool>

Fallible variant of Self::is_identity.

Returns an error when the underlying OCIO query throws.

Source

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.

Source

pub fn has_dynamic_property_kind(&self, prop_type: DynamicPropertyType) -> bool

Return whether the CPU processor exposes a dynamic property of prop_type.

Source

pub fn try_has_dynamic_property_kind( &self, prop_type: DynamicPropertyType, ) -> Result<bool>

Fallible variant of Self::has_dynamic_property_kind.

Source

pub fn is_dynamic(&self) -> bool

Return whether this CPU processor contains any runtime-adjustable properties.

Source

pub fn try_is_dynamic(&self) -> Result<bool>

Fallible variant of Self::is_dynamic.

Trait Implementations§

Source§

impl Deref for StaticCPUProcessor

Source§

type Target = CPUProcessor

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Send for StaticCPUProcessor

Source§

impl Sync for StaticCPUProcessor

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.