aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xevc/scripts/bench_modes7
-rw-r--r--evc/src/bin/decode.rs5
-rw-r--r--evc/src/bin/encode.rs4
-rw-r--r--evc/src/codec/encode/advanced.rs4
-rw-r--r--evc/src/codec/encode/simple.rs4
-rw-r--r--evc/src/format/header.rs8
-rw-r--r--evc/src/format/ser.rs2
-rw-r--r--evc/src/helpers/vector.rs17
-rw-r--r--evc/src/refsampler.rs2
9 files changed, 37 insertions, 16 deletions
diff --git a/evc/scripts/bench_modes b/evc/scripts/bench_modes
index f6105db..7cc6abd 100755
--- a/evc/scripts/bench_modes
+++ b/evc/scripts/bench_modes
@@ -3,15 +3,18 @@ set w $argv[1]
set h $argv[2]
set t $argv[3]
-ffmpeg -hide_banner -i $argv[4] -to {$t} -vf scale={$w}x{$h},fps=30,format=rgb24 -f rawvideo pipe:1 > samples/raw
+ffmpeg -hide_banner -i $argv[4] -to {$t} -vf scale={$w}x{$h},fps=30,format=rgb24 -f rawvideo pipe:1 >samples/raw
+ffmpeg -hide_banner -y -i $argv[4] -to {$t} -vf scale={$w}x{$h},fps=30,format=rgb24 -c:v vp9 samples/reference.webm
+echo
echo "file: "$argv[4]
echo "resolution: "{$w}x{$h}
echo "frames: "(math $t \* 30)
+echo "reference (raw): "(du -h samples/raw | cut -f 1)
+echo "reference (vp8): "(du -h samples/reference.webm | cut -f 1)
for mode in trivial simple-exhaustive simple-fast advanced advanced-partial
echo -----------
echo "mode: $mode"
echo "time: $(command time -f %U ./target/release/encode -W {$w} -H {$h} --mode $mode $argv[5..] <samples/raw >samples/encoded-$mode 2>| tail -n 1)s"
echo "size: $(du -h samples/encoded-$mode | cut -f 1)"
end
-
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>,