From 0a346b8372140b56bf65a6df1c00e2cd6c6cdf86 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sat, 17 Dec 2022 18:01:51 +0100 Subject: small optimizations and info binary --- evc/src/helpers/matrix.rs | 2 +- evc/src/helpers/pixel.rs | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'evc/src/helpers') diff --git a/evc/src/helpers/matrix.rs b/evc/src/helpers/matrix.rs index 87c0e7d..c3c120b 100644 --- a/evc/src/helpers/matrix.rs +++ b/evc/src/helpers/matrix.rs @@ -1,6 +1,6 @@ use crate::helpers::vector::Vec2; -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy, PartialEq)] pub struct Mat2 { pub a: T, pub b: T, diff --git a/evc/src/helpers/pixel.rs b/evc/src/helpers/pixel.rs index 816d7dc..39fe98c 100644 --- a/evc/src/helpers/pixel.rs +++ b/evc/src/helpers/pixel.rs @@ -1,6 +1,6 @@ use crate::format::ser::{Ser, Sink, Source}; -#[derive(Copy, Clone, Debug, Default)] +#[derive(Copy, Clone, Debug, Default, PartialEq)] pub struct Pixel { pub r: u8, pub g: u8, @@ -24,11 +24,12 @@ impl Pixel { pub fn distance(a: Pixel, b: Pixel) -> usize { let (rd, gd, bd) = ( a.r.abs_diff(b.r) as usize, - a.r.abs_diff(b.r) as usize, - a.r.abs_diff(b.r) as usize, + a.g.abs_diff(b.g) as usize, + a.b.abs_diff(b.b) as usize, ); // fast_sqrt(rd * rd + gd * gd + bd * bd) - SQRT[rd + gd + bd] + // SQRT[rd + gd + bd] + rd + gd + bd } #[inline] -- cgit v1.2.3-70-g09d2