aboutsummaryrefslogtreecommitdiff
path: root/evc/src/block.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2022-12-06 17:45:26 +0100
committermetamuffin <metamuffin@disroot.org>2022-12-06 17:45:26 +0100
commite3c742ff04a665c70c029f266aa0fe72e12ac72c (patch)
treee6a262a223d151afd804359e243cc5d0301e732f /evc/src/block.rs
parent849c3769fbd38940c9bfa73bcea160848a38d9b6 (diff)
downloadvideo-codec-experiments-e3c742ff04a665c70c029f266aa0fe72e12ac72c.tar
video-codec-experiments-e3c742ff04a665c70c029f266aa0fe72e12ac72c.tar.bz2
video-codec-experiments-e3c742ff04a665c70c029f266aa0fe72e12ac72c.tar.zst
vec2 everywhere
Diffstat (limited to 'evc/src/block.rs')
-rw-r--r--evc/src/block.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/evc/src/block.rs b/evc/src/block.rs
index 8daba5c..d0dd4d5 100644
--- a/evc/src/block.rs
+++ b/evc/src/block.rs
@@ -3,13 +3,14 @@ use anyhow::bail;
use crate::{
pixel::Pixel,
ser::{Ser, Sink, Source},
+ vec2::Vec2,
};
#[derive(Clone, Debug)]
pub enum Block {
Literal(Vec<Pixel>),
Split(Box<[Block; 2]>),
- Reference { translation: (usize, usize) },
+ Reference { translation: Vec2 },
}
impl Block {
@@ -32,20 +33,20 @@ impl Block {
Ok(())
}
- pub fn read(source: &mut impl std::io::Read, size: (usize, usize)) -> anyhow::Result<Self> {
+ pub fn read(source: &mut impl std::io::Read, size: Vec2) -> anyhow::Result<Self> {
Ok(match source.get::<u8>()? {
0 => Block::Literal(source.get()?),
1 => Block::Split(Box::new({
- let vert = size.0 > size.1;
+ let vert = size.x > size.y;
let asize = if vert {
- (size.0 / 2, size.1)
+ (size.x / 2, size.y).into()
} else {
- (size.0, size.1 / 2)
+ (size.x, size.y / 2).into()
};
let bsize = if vert {
- (size.0 - size.0 / 2, size.1)
+ (size.x - size.x / 2, size.y).into()
} else {
- (size.0, size.1 - size.1 / 2)
+ (size.x, size.y - size.y / 2).into()
};
let a = Block::read(source, asize)?;
@@ -53,7 +54,7 @@ impl Block {
[a, b]
})),
2 => Block::Reference {
- translation: (0, 0), //source.get()?,
+ translation: Vec2::ZERO, //source.get()?,
},
x => bail!("corrupt block type ({})", x),
})