diff options
Diffstat (limited to 'lvc/codec/src/decode.rs')
-rw-r--r-- | lvc/codec/src/decode.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lvc/codec/src/decode.rs b/lvc/codec/src/decode.rs new file mode 100644 index 0000000..771cba9 --- /dev/null +++ b/lvc/codec/src/decode.rs @@ -0,0 +1,25 @@ +use crate::{split::split, Block, Frame, View, P2}; +use rayon::join; + +pub fn decode(last_frame: &Frame, frame: &mut Frame, view: View, block: &Block) { + match block { + Block::Lit(pxs) => frame.import(view, &pxs), + Block::Split(a, b) => { + let [av, bv] = split(view); + let (frame1, frame2) = + unsafe { (&mut *(frame as *mut Frame), &mut *(frame as *mut Frame)) }; + join( + || decode(last_frame, frame1, av, &a), + || decode(last_frame, frame2, bv, &b), + ); + } + Block::Ref(r) => { + for y in view.a.y..view.b.y { + for x in view.a.x..view.b.x { + let p = P2 { x, y }; + frame[p] = last_frame[p + r.pos_off] + r.color_off + } + } + } + } +} |