Trait exr::block::samples::FromNativeSample

source ·
pub trait FromNativeSample:
    Sized
    + Copy
    + Default
    + 'static {
    // Required methods
    fn from_f16(value: f16) -> Self;
    fn from_f32(value: f32) -> Self;
    fn from_u32(value: u32) -> Self;

    // Provided methods
    fn from_f16s(from: &[f16], to: &mut [Self]) { ... }
    fn from_f32s(from: &[f32], to: &mut [Self]) { ... }
    fn from_u32s(from: &[u32], to: &mut [Self]) { ... }
}
Expand description

Create an arbitrary sample type from one of the defined sample types. Should be compiled to a no-op where the file contains the predicted sample type. The slice functions should be optimized into a memcpy where there is no conversion needed.

Required Methods§

source

fn from_f16(value: f16) -> Self

Create this sample from a f16, trying to represent the same numerical value

source

fn from_f32(value: f32) -> Self

Create this sample from a f32, trying to represent the same numerical value

source

fn from_u32(value: u32) -> Self

Create this sample from a u32, trying to represent the same numerical value

Provided Methods§

source

fn from_f16s(from: &[f16], to: &mut [Self])

Convert all values from the slice into this type. This function exists to allow the compiler to perform a vectorization optimization. Note that this default implementation will not be vectorized by the compiler automatically. For maximum performance you will need to override this function and implement it via an explicit batched conversion such as convert_to_f32_slice

source

fn from_f32s(from: &[f32], to: &mut [Self])

Convert all values from the slice into this type. This function exists to allow the compiler to perform a vectorization optimization. Note that this default implementation will be vectorized by the compiler automatically.

source

fn from_u32s(from: &[u32], to: &mut [Self])

Convert all values from the slice into this type. This function exists to allow the compiler to perform a vectorization optimization. Note that this default implementation will be vectorized by the compiler automatically, provided that the CPU supports the necessary conversion instructions. For example, x86_64 lacks the instructions to convert u32 to floats, so this will inevitably be slow on x86_64.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl FromNativeSample for f32

source§

fn from_f16(value: f16) -> Self

source§

fn from_f32(value: f32) -> Self

source§

fn from_u32(value: u32) -> Self

source§

fn from_f16s(from: &[f16], to: &mut [Self])

source§

impl FromNativeSample for u32

source§

fn from_f16(value: f16) -> Self

source§

fn from_f32(value: f32) -> Self

source§

fn from_u32(value: u32) -> Self

Implementors§