X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=nihav-core%2Fsrc%2Fscale%2Fpalette%2Fneuquant.rs;h=09745000150c19c2c2a20e65cbdd365040f9e7f8;hb=b53512389ece2e9e496ae2e99a1b2f2072931f1a;hp=7b19eb5fdd52283180fe6ed6a67e45122a64a800;hpb=4b459d0b9b76cb51c1029e6d1ffb17cf5f2d44d9;p=nihav.git diff --git a/nihav-core/src/scale/palette/neuquant.rs b/nihav-core/src/scale/palette/neuquant.rs index 7b19eb5..0974500 100644 --- a/nihav-core/src/scale/palette/neuquant.rs +++ b/nihav-core/src/scale/palette/neuquant.rs @@ -39,7 +39,7 @@ impl NeuQuantQuantiser { let mut range = 0; let sqradius = (radius * radius) as f64; while (idx0 < high) || (idx1 > low) { - let sqrng = (range * range) as f64; + let sqrng = f64::from(range * range); let a = alpha * (sqradius - sqrng) / sqradius; range += 1; if idx0 < high { @@ -52,6 +52,7 @@ impl NeuQuantQuantiser { } } } + #[allow(clippy::float_cmp)] fn find_node(&mut self, clr: &[f64; 3]) -> usize { for i in 0..SPECIAL_NODES { if &self.weights[i] == clr { @@ -85,7 +86,7 @@ impl NeuQuantQuantiser { pub fn learn(&mut self, src: &[Pixel]) { let mut bias_radius = (256 / 8) << 6; let alphadec = (30 + (self.factor - 1) / 3) as f64; - let initial_alpha = (1 << 10) as f64; + let initial_alpha = f64::from(1 << 10); let npixels = src.len(); @@ -105,7 +106,7 @@ impl NeuQuantQuantiser { } for i in 0..samples { - let clr = [src[pos].r as f64, src[pos].g as f64, src[pos].b as f64]; + let clr = [f64::from(src[pos].r), f64::from(src[pos].g), f64::from(src[pos].b)]; let idx = self.find_node(&clr); if idx >= SPECIAL_NODES { let new_alpha = alphadec / initial_alpha;