diff options
Diffstat (limited to 'evc/src/codec')
-rw-r--r-- | evc/src/codec/encode.rs | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/evc/src/codec/encode.rs b/evc/src/codec/encode.rs index dbefdb4..ce5d71b 100644 --- a/evc/src/codec/encode.rs +++ b/evc/src/codec/encode.rs @@ -1,5 +1,6 @@ use crate::{ - block::Block, frame::Frame, pixel::Pixel, threading::both_par, vec2::Vec2, view::View, + block::Block, frame::Frame, helpers::threading::both_par, helpers::vector::Vec2, pixel::Pixel, + view::View, }; #[derive(Debug, Clone)] @@ -17,15 +18,15 @@ pub fn encode_block(view: View<&Frame>, prev: View<&Frame>, config: &EncodeConfi // let importance = importance(&view); let (diff, translation) = if view.area() > config.max_diff_size { - (f64::INFINITY, Vec2::ZERO) + (f64::INFINITY, Vec2::<isize>::ZERO) } else if config.translate { let mut best_diff = f64::INFINITY; - let mut best_translation = Vec2::ZERO; + let mut best_translation = Vec2::<isize>::ZERO; const OFFSETS: &[isize] = &[-64, -32, -16, -8, -4, -2, -1, 0, 1, 2, 4, 8, 16, 32, 64]; for x in OFFSETS { for y in OFFSETS { let translation = Vec2 { x: *x, y: *y }; - let diff = View::diff(&view, &prev.offset(translation)) / view.area() as f64; + let diff = View::diff(&view, &prev.offset(translation)); // / view.area() as f64; if diff < best_diff { best_translation = translation; best_diff = diff; @@ -34,7 +35,10 @@ pub fn encode_block(view: View<&Frame>, prev: View<&Frame>, config: &EncodeConfi } (best_diff, best_translation) } else { - (View::diff(&view, &prev) / view.area() as f64, Vec2::ZERO) + ( + View::diff(&view, &prev) / view.area() as f64, + Vec2::<isize>::ZERO, + ) }; // config.importance_k) // / (config.importance_k + importance * config.importance_scale) @@ -76,10 +80,10 @@ pub fn importance(view: &View<&Frame>) -> f64 { for y in 0..view.size.y { let p = Vec2 { x, y }; if x > 0 { - acc += Pixel::distance(view[p], view[p + Vec2::LEFT]); + acc += Pixel::distance(view[p], view[p + Vec2::<isize>::LEFT]); } if y > 0 { - acc += Pixel::distance(view[p], view[p + Vec2::UP]); + acc += Pixel::distance(view[p], view[p + Vec2::<isize>::UP]); } } } |