pub enum Sample {
F16(f16),
F32(f32),
U32(u32),
}
Expand description
A single red, green, blue, or alpha value.
Variants§
F16(f16)
A 16-bit float sample.
F32(f32)
A 32-bit float sample.
U32(u32)
An unsigned integer sample.
Implementations§
source§impl Sample
impl Sample
sourcepub fn to_f16(self) -> f16
pub fn to_f16(self) -> f16
Convert the sample to an f16 value. This has lower precision than f32.
Note: An f32 can only represent integers up to 1024
as precise as a u32 could.
sourcepub fn to_f32(self) -> f32
pub fn to_f32(self) -> f32
Convert the sample to an f32 value.
Note: An f32 can only represent integers up to 8388608
as precise as a u32 could.
Trait Implementations§
source§impl FromNativeSample for Sample
impl FromNativeSample for Sample
source§fn from_f16(value: f16) -> Self
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
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
fn from_u32(value: u32) -> Self
Create this sample from a u32, trying to represent the same numerical value
source§fn from_f16s(from: &[f16], to: &mut [Self])
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])
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])
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.source§impl IntoNativeSample for Sample
impl IntoNativeSample for Sample
source§impl PartialEq for Sample
impl PartialEq for Sample
source§impl ValidateResult for Sample
impl ValidateResult for Sample
source§fn validate_result(
&self,
other: &Self,
options: ValidationOptions,
location: impl Fn() -> String,
) -> ValidationResult
fn validate_result( &self, other: &Self, options: ValidationOptions, location: impl Fn() -> String, ) -> ValidationResult
Compare self with the other.
Exceptional behaviour: Read more
source§fn assert_equals_result(&self, result: &Self)
fn assert_equals_result(&self, result: &Self)
Compare self with the other. Panics if not equal. Read more
impl Copy for Sample
Auto Trait Implementations§
impl Freeze for Sample
impl RefUnwindSafe for Sample
impl Send for Sample
impl Sync for Sample
impl Unpin for Sample
impl UnwindSafe for Sample
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian()
.