aboutsummaryrefslogtreecommitdiff
path: root/test2/src/decode.rs
diff options
context:
space:
mode:
Diffstat (limited to 'test2/src/decode.rs')
-rw-r--r--test2/src/decode.rs31
1 files changed, 27 insertions, 4 deletions
diff --git a/test2/src/decode.rs b/test2/src/decode.rs
index 974c6d9..da0538b 100644
--- a/test2/src/decode.rs
+++ b/test2/src/decode.rs
@@ -1,20 +1,43 @@
+use crate::{BLOCK_SIZE, Frame};
use framework::BitstreamFilter;
-use glam::{I16Vec2, i16vec2};
+use glam::{IVec2, ivec2};
pub struct Dec {
- res: I16Vec2,
+ res: IVec2,
+ last: Frame,
}
impl BitstreamFilter for Dec {
const INPUT_CODEC_ID: &str = "V_VCETEST2";
const OUTPUT_CODEC_ID: &str = "V_UNCOMPRESSED";
fn new(width: u32, height: u32) -> Self {
+ let res = ivec2(width as i32, height as i32);
Self {
- res: i16vec2(width as i16, height as i16),
+ res,
+ last: Frame::new(res),
}
}
fn process_block(&mut self, a: Vec<u8>) -> Vec<u8> {
- a
+ let mut buf = a.as_slice();
+ let mut frame = Frame::new(self.res);
+ for by in 0..frame.res.y / BLOCK_SIZE {
+ for bx in 0..frame.res.x / BLOCK_SIZE {
+ let boff = ivec2(bx * BLOCK_SIZE, by * BLOCK_SIZE);
+
+ let reloff = ivec2(buf[0] as i32 - 127, buf[1] as i32 - 127);
+ buf = &buf[2..];
+
+ let roff = reloff + boff;
+
+ Frame::copy_block(&self.last, &mut frame, roff, boff);
+
+ let size = frame.import_block_diff(boff, buf);
+ buf = &buf[size..];
+ }
+ }
+
+ self.last = frame.clone();
+ frame.data
}
}