Skip to main content

ReferenceKernel

Struct ReferenceKernel 

Source
pub struct ReferenceKernel<N: FromPrimitive = f32> { /* private fields */ }
Expand description

A reference implementation of the Kernel trait, copied verbatim from the officially-endorsed implementation by darwinium-com.

Trait Implementations§

Source§

impl<N: Default + FromPrimitive> Default for ReferenceKernel<N>

Source§

fn default() -> ReferenceKernel<N>

Returns the “default value” for a type. Read more
Source§

impl Kernel for ReferenceKernel<f32>

Available on crate features std only.
Source§

type Buffer1WidthX = UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B1>, B1>, B1>, B1>, B1>

The width of the first stage (compression) buffer.
Source§

type Buffer1LengthY = UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B1>, B1>, B1>, B1>, B1>

The length of the first stage (compression) buffer.
Source§

type InternalFloat = f32

The internal floating point type used for intermediate calculations.
Source§

type InputDimension = UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>

The width and height of the input image.
Source§

type OutputDimension = UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>

The width and height of the output hash.
Source§

type RequiredHardwareFeature = Term

The hardware features required to run this kernel
Source§

type Ident = &'static str

Identification token.
Source§

fn ident(&self) -> Self::Ident

Return an identification of the kernel. For composite kernels that route to multiple kernels, report the kernel that would be executed.
Source§

fn adjust_quality(input: Self::InternalFloat) -> f32

Adjust the quality metric to be between 0 and 1.
Source§

fn dct2d( &mut self, buffer: &GenericArray<GenericArray<f32, Self::Buffer1WidthX>, Self::Buffer1LengthY>, tmp_row_buffer: &mut GenericArray<f32, Self::Buffer1WidthX>, output: &mut GenericArray<GenericArray<f32, U16>, U16>, )

Apply a 2D DCT-II transformation to the input buffer write the result to the output buffer.
Source§

fn sum_of_gradients( &mut self, input: &GenericArray<GenericArray<Self::InternalFloat, U16>, U16>, ) -> Self::InternalFloat

Compute the sum of gradients of the input buffer in both horizontal and vertical directions.
Source§

fn quantize( &mut self, input: &GenericArray<GenericArray<f32, U16>, U16>, threshold: &mut Self::InternalFloat, output: &mut GenericArray<GenericArray<u8, U2>, U16>, )

Convert input to binary by thresholding at median
Source§

fn jarosz_compress( &mut self, buffer: &GenericArray<GenericArray<f32, U512>, U512>, output: &mut GenericArray<GenericArray<f32, Self::Buffer1WidthX>, Self::Buffer1LengthY>, )

Apply a tent-filter average to every 8x8 sub-block of the input buffer and write the result of each sub-block to the output buffer.
Source§

fn cvt_rgb8_to_luma8f<const R_COEFF: u32, const G_COEFF: u32, const B_COEFF: u32>( &mut self, input: &GenericArray<GenericArray<u8, U3>, Self::InputDimension>, output: &mut GenericArray<f32, Self::InputDimension>, )
where Self::RequiredHardwareFeature: EvaluateHardwareFeature<EnabledStatic = B1>,

Convert one row of input from RGB8 to LUMA8 floating point. Read more
Source§

fn cvt_rgba8_to_luma8f<const R_COEFF: u32, const G_COEFF: u32, const B_COEFF: u32>( &mut self, input: &GenericArray<GenericArray<u8, U4>, Self::InputDimension>, output: &mut GenericArray<f32, Self::InputDimension>, )
where Self::RequiredHardwareFeature: EvaluateHardwareFeature<EnabledStatic = B1>,

Convert RGBA8 to LUMA8. Read more
Source§

fn pdqf_t( &mut self, input: &mut GenericArray<GenericArray<Self::InternalFloat, Self::OutputDimension>, Self::OutputDimension>, )
where Self::RequiredHardwareFeature: EvaluateHardwareFeature<EnabledStatic = B1>,

Transpose a PDQF matrix in place. Output is equivalent to PDQF(t(image)). Read more
Source§

fn pdqf_negate_alt_cols<const NEGATE: bool>( &mut self, input: &mut GenericArray<GenericArray<Self::InternalFloat, Self::OutputDimension>, Self::OutputDimension>, )
where Self::RequiredHardwareFeature: EvaluateHardwareFeature<EnabledStatic = B1>,

Negate alternative columns of PDQF matrix in place. Equivalent to PDQF(flop(image)). Read more
Source§

fn pdqf_negate_alt_rows<const NEGATE: bool>( &mut self, input: &mut GenericArray<GenericArray<Self::InternalFloat, Self::OutputDimension>, Self::OutputDimension>, )
where Self::RequiredHardwareFeature: EvaluateHardwareFeature<EnabledStatic = B1>,

Negate alternative rows of PDQF matrix in place. Equivalent to PDQF(flip(image)). Read more
Source§

fn pdqf_negate_off_diagonals( &mut self, input: &mut GenericArray<GenericArray<Self::InternalFloat, Self::OutputDimension>, Self::OutputDimension>, )

Negate off-diagonals of PDQF matrix in place. Equivalent to PDQF(rotate180(image)). Read more
Source§

fn required_hardware_features_met() -> bool

Shorthand to <<K as Kernel>::RequiredHardwareFeature as EvaluateHardwareFeature>::met_runtime() Read more
Source§

impl Kernel for ReferenceKernel<f64>

Available on crate features std only.
Source§

type Buffer1WidthX = UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B1>, B1>, B1>, B1>, B1>

The width of the first stage (compression) buffer.
Source§

type Buffer1LengthY = UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B1>, B1>, B1>, B1>, B1>

The length of the first stage (compression) buffer.
Source§

type InternalFloat = f64

The internal floating point type used for intermediate calculations.
Source§

type InputDimension = UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>

The width and height of the input image.
Source§

type OutputDimension = UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>

The width and height of the output hash.
Source§

type RequiredHardwareFeature = Term

The hardware features required to run this kernel
Source§

type Ident = &'static str

Identification token.
Source§

fn ident(&self) -> Self::Ident

Return an identification of the kernel. For composite kernels that route to multiple kernels, report the kernel that would be executed.
Source§

fn adjust_quality(input: Self::InternalFloat) -> f32

Adjust the quality metric to be between 0 and 1.
Source§

fn dct2d( &mut self, buffer: &GenericArray<GenericArray<f64, Self::Buffer1WidthX>, Self::Buffer1LengthY>, tmp_row_buffer: &mut GenericArray<f64, Self::Buffer1WidthX>, output: &mut GenericArray<GenericArray<f64, U16>, U16>, )

Apply a 2D DCT-II transformation to the input buffer write the result to the output buffer.
Source§

fn sum_of_gradients( &mut self, input: &GenericArray<GenericArray<Self::InternalFloat, U16>, U16>, ) -> Self::InternalFloat

Compute the sum of gradients of the input buffer in both horizontal and vertical directions.
Source§

fn quantize( &mut self, input: &GenericArray<GenericArray<f64, U16>, U16>, threshold: &mut Self::InternalFloat, output: &mut GenericArray<GenericArray<u8, U2>, U16>, )

Convert input to binary by thresholding at median
Source§

fn jarosz_compress( &mut self, buffer: &GenericArray<GenericArray<f32, U512>, U512>, output: &mut GenericArray<GenericArray<f64, Self::Buffer1WidthX>, Self::Buffer1LengthY>, )

Apply a tent-filter average to every 8x8 sub-block of the input buffer and write the result of each sub-block to the output buffer.
Source§

fn cvt_rgb8_to_luma8f<const R_COEFF: u32, const G_COEFF: u32, const B_COEFF: u32>( &mut self, input: &GenericArray<GenericArray<u8, U3>, Self::InputDimension>, output: &mut GenericArray<f32, Self::InputDimension>, )
where Self::RequiredHardwareFeature: EvaluateHardwareFeature<EnabledStatic = B1>,

Convert one row of input from RGB8 to LUMA8 floating point. Read more
Source§

fn cvt_rgba8_to_luma8f<const R_COEFF: u32, const G_COEFF: u32, const B_COEFF: u32>( &mut self, input: &GenericArray<GenericArray<u8, U4>, Self::InputDimension>, output: &mut GenericArray<f32, Self::InputDimension>, )
where Self::RequiredHardwareFeature: EvaluateHardwareFeature<EnabledStatic = B1>,

Convert RGBA8 to LUMA8. Read more
Source§

fn pdqf_t( &mut self, input: &mut GenericArray<GenericArray<Self::InternalFloat, Self::OutputDimension>, Self::OutputDimension>, )
where Self::RequiredHardwareFeature: EvaluateHardwareFeature<EnabledStatic = B1>,

Transpose a PDQF matrix in place. Output is equivalent to PDQF(t(image)). Read more
Source§

fn pdqf_negate_alt_cols<const NEGATE: bool>( &mut self, input: &mut GenericArray<GenericArray<Self::InternalFloat, Self::OutputDimension>, Self::OutputDimension>, )
where Self::RequiredHardwareFeature: EvaluateHardwareFeature<EnabledStatic = B1>,

Negate alternative columns of PDQF matrix in place. Equivalent to PDQF(flop(image)). Read more
Source§

fn pdqf_negate_alt_rows<const NEGATE: bool>( &mut self, input: &mut GenericArray<GenericArray<Self::InternalFloat, Self::OutputDimension>, Self::OutputDimension>, )
where Self::RequiredHardwareFeature: EvaluateHardwareFeature<EnabledStatic = B1>,

Negate alternative rows of PDQF matrix in place. Equivalent to PDQF(flip(image)). Read more
Source§

fn pdqf_negate_off_diagonals( &mut self, input: &mut GenericArray<GenericArray<Self::InternalFloat, Self::OutputDimension>, Self::OutputDimension>, )

Negate off-diagonals of PDQF matrix in place. Equivalent to PDQF(rotate180(image)). Read more
Source§

fn required_hardware_features_met() -> bool

Shorthand to <<K as Kernel>::RequiredHardwareFeature as EvaluateHardwareFeature>::met_runtime() Read more
Source§

impl PreciseKernel for ReferenceKernel<f32>

Available on crate features std only.
Source§

impl PreciseKernel for ReferenceKernel<f64>

Available on crate features std only.

Auto Trait Implementations§

§

impl<N> Freeze for ReferenceKernel<N>

§

impl<N> RefUnwindSafe for ReferenceKernel<N>
where N: RefUnwindSafe,

§

impl<N> Send for ReferenceKernel<N>
where N: Send,

§

impl<N> Sync for ReferenceKernel<N>
where N: Sync,

§

impl<N> Unpin for ReferenceKernel<N>
where N: Unpin,

§

impl<N> UnsafeUnpin for ReferenceKernel<N>

§

impl<N> UnwindSafe for ReferenceKernel<N>
where N: UnwindSafe,

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<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.