diff options
author | metamuffin <metamuffin@disroot.org> | 2022-12-06 08:41:48 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2022-12-06 08:41:48 +0100 |
commit | cc1f02a71bd3ad5235ac92dec2d9c516c74f8b1c (patch) | |
tree | 0c418181610ada30f8a8291fc7fb4e906dccd982 /evc/src/block.rs | |
parent | 5002d0df81f74418665e4e99179ba56d8e78cbe1 (diff) | |
download | video-codec-experiments-cc1f02a71bd3ad5235ac92dec2d9c516c74f8b1c.tar video-codec-experiments-cc1f02a71bd3ad5235ac92dec2d9c516c74f8b1c.tar.bz2 video-codec-experiments-cc1f02a71bd3ad5235ac92dec2d9c516c74f8b1c.tar.zst |
decode somewhat works
Diffstat (limited to 'evc/src/block.rs')
-rw-r--r-- | evc/src/block.rs | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/evc/src/block.rs b/evc/src/block.rs index f58bcb3..98e3b54 100644 --- a/evc/src/block.rs +++ b/evc/src/block.rs @@ -1,3 +1,5 @@ +use anyhow::bail; + use crate::{ pixel::Pixel, ser::{Ser, Sink, Source}, @@ -28,8 +30,9 @@ impl Block { a.write(sink)?; b.write(sink)?; } - BlockInner::Reference { translation: _ } => { + BlockInner::Reference { translation } => { sink.put(2u8)?; + // sink.put(*translation)?; } } Ok(()) @@ -39,15 +42,20 @@ impl Block { let inner = match source.get::<u8>()? { 0 => BlockInner::Literal(source.get()?), 1 => BlockInner::Split(Box::new({ - let subsize = if size.0 > size.1 { + let subsize_left = if size.0 > size.1 { (size.0 / 2, size.1) } else { (size.0, size.1 / 2) }; - [Block::read(source, subsize)?, Block::read(source, subsize)?] + let subsize_right = (size.0 - subsize_left.0, size.1 - subsize_left.1); + let a = Block::read(source, subsize_left)?; + let b = Block::read(source, subsize_right)?; + [a, b] })), - 2 => todo!(), - _ => panic!("file corrupt"), + 2 => BlockInner::Reference { + translation: (0, 0), //source.get()?, + }, + x => bail!("corrupt block type ({})", x), }; Ok(Self { size, inner }) |