diff options
Diffstat (limited to 'evc/src')
-rw-r--r-- | evc/src/bin/decode.rs | 5 | ||||
-rw-r--r-- | evc/src/bin/encode.rs | 4 | ||||
-rw-r--r-- | evc/src/codec/encode/advanced.rs | 4 | ||||
-rw-r--r-- | evc/src/codec/encode/simple.rs | 4 | ||||
-rw-r--r-- | evc/src/format/header.rs | 8 | ||||
-rw-r--r-- | evc/src/format/ser.rs | 2 | ||||
-rw-r--r-- | evc/src/helpers/vector.rs | 17 | ||||
-rw-r--r-- | evc/src/refsampler.rs | 2 |
8 files changed, 32 insertions, 14 deletions
diff --git a/evc/src/bin/decode.rs b/evc/src/bin/decode.rs index c2b3b4d..bb76231 100644 --- a/evc/src/bin/decode.rs +++ b/evc/src/bin/decode.rs @@ -8,7 +8,7 @@ use evc::{ format::{header::Header, ser::Source}, frame::Frame, }; -use log::info; +use log::{info, warn}; use std::io::{BufReader, BufWriter}; #[derive(Parser)] @@ -30,6 +30,9 @@ fn main() -> anyhow::Result<()> { let header = input.get::<Header>().context("reading header")?; info!("{header:?}"); + if header.resolution.x * header.resolution.y > 100_000_000 { + warn!("resolution is quite big. video is likely corrupt."); + } let size = header.resolution; let config = DecodeConfig { diff --git a/evc/src/bin/encode.rs b/evc/src/bin/encode.rs index c313fd0..c9d8792 100644 --- a/evc/src/bin/encode.rs +++ b/evc/src/bin/encode.rs @@ -65,9 +65,7 @@ fn main() -> anyhow::Result<()> { let mut prev_frame = Frame::new(size); for i in 0.. { info!("encode frame {i}"); - let mut frame = Frame::read(&mut input, size) - .context("reading raw frame") - .unwrap(); + let mut frame = Frame::read(&mut input, size).context("reading raw frame")?; let v1 = frame.view(); let v2 = prev_frame.view(); diff --git a/evc/src/codec/encode/advanced.rs b/evc/src/codec/encode/advanced.rs index e86a1b8..e15d8f2 100644 --- a/evc/src/codec/encode/advanced.rs +++ b/evc/src/codec/encode/advanced.rs @@ -80,6 +80,10 @@ pub fn partial( pk(&view, &prev, &mut d, &mut p, &pm, |p| p.translation.x -= 1); pk(&view, &prev, &mut d, &mut p, &pm, |p| p.translation.y += 1); pk(&view, &prev, &mut d, &mut p, &pm, |p| p.translation.y -= 1); + + pk(&view, &prev, &mut d, &mut p, &pm, |p| p.value_scale += 1); + pk(&view, &prev, &mut d, &mut p, &pm, |p| p.value_scale -= 1); + if d >= diff { break (diff, Block::AdvancedReference(pm)); } diff --git a/evc/src/codec/encode/simple.rs b/evc/src/codec/encode/simple.rs index 8ae1abb..cabbc15 100644 --- a/evc/src/codec/encode/simple.rs +++ b/evc/src/codec/encode/simple.rs @@ -45,10 +45,6 @@ pub fn fast( } }; - probe(offset + Vec2 { x: 2, y: 0 }); - probe(offset + Vec2 { x: -2, y: 0 }); - probe(offset + Vec2 { x: 0, y: 2 }); - probe(offset + Vec2 { x: 0, y: -2 }); probe(offset + Vec2 { x: 1, y: 0 }); probe(offset + Vec2 { x: -1, y: 0 }); probe(offset + Vec2 { x: 0, y: 1 }); diff --git a/evc/src/format/header.rs b/evc/src/format/header.rs index 371b4ba..ecbae89 100644 --- a/evc/src/format/header.rs +++ b/evc/src/format/header.rs @@ -1,6 +1,6 @@ use crate::{ - helpers::vector::Vec2, format::ser::{Ser, Sink, Source}, + helpers::vector::Vec2, }; #[derive(Debug, Clone, PartialEq, Copy)] @@ -14,15 +14,15 @@ pub const MAGIC: [u8; 4] = [0x5eu8, 0xb1u8, 0xc3u8, 0x08u8]; impl Ser for Header { fn write(&self, sink: &mut impl std::io::Write) -> anyhow::Result<()> { sink.put(MAGIC)?; - sink.put((self.resolution, self.frame_count))?; + sink.put((Into::<Vec2<u16>>::into(self.resolution), self.frame_count))?; Ok(()) } fn read(source: &mut impl std::io::Read) -> anyhow::Result<Self> { assert_eq!(source.get::<[u8; 4]>()?, MAGIC); - let (resolution, frame_count) = source.get()?; + let (resolution, frame_count): (Vec2<u16>, usize) = source.get()?; Ok(Self { - resolution, + resolution: resolution.into(), frame_count, }) } diff --git a/evc/src/format/ser.rs b/evc/src/format/ser.rs index 995ca75..f063377 100644 --- a/evc/src/format/ser.rs +++ b/evc/src/format/ser.rs @@ -151,7 +151,7 @@ impl Ser for u16 { fn write(&self, sink: &mut impl Write) -> anyhow::Result<()> { Ok(sink .write_all(&unsafe { std::mem::transmute_copy::<_, [u8; 2]>(self) }) - .context("write 16")?) + .context("write u16")?) } fn read(source: &mut impl Read) -> anyhow::Result<Self> { let mut buf = [0u8; 2]; diff --git a/evc/src/helpers/vector.rs b/evc/src/helpers/vector.rs index 7cb180a..0209c58 100644 --- a/evc/src/helpers/vector.rs +++ b/evc/src/helpers/vector.rs @@ -4,6 +4,23 @@ pub struct Vec2<T> { pub y: T, } +impl From<Vec2<isize>> for Vec2<u16> { + fn from(value: Vec2<isize>) -> Self { + Self { + x: value.x as u16, + y: value.y as u16, + } + } +} +impl From<Vec2<u16>> for Vec2<isize> { + fn from(value: Vec2<u16>) -> Self { + Self { + x: value.x as isize, + y: value.y as isize, + } + } +} + impl Vec2<isize> { pub const ZERO: Vec2<isize> = Vec2 { x: 0, y: 0 }; pub const UP: Vec2<isize> = Vec2 { x: 0, y: -1 }; diff --git a/evc/src/refsampler.rs b/evc/src/refsampler.rs index a9a6d29..d6f2bb1 100644 --- a/evc/src/refsampler.rs +++ b/evc/src/refsampler.rs @@ -22,7 +22,7 @@ impl<'a> Sampler<'a> { pub fn sample(&self, p: Vec2<f32>) -> Pixel { self.view .sample(self.translation + self.transform.transform(p + self.halfsize) - self.halfsize) - // .scale(self.value_scale) + .scale(self.value_scale) } pub fn from_refblock( view: View<&'a Frame>, |