use crate::{block::Block, frame::Frame, refsampler::Sampler, view::View}; pub fn decode_block(block: &Block, mut target: View<&mut Frame>, prev: View<&Frame>) { match &block { Block::Literal(pixels) => target.set_pixels(pixels), Block::Split(box [a, b]) => { let [at, bt] = target.split_mut_unsafe(); let [ap, bp] = prev.split(); decode_block(a, at, ap); decode_block(b, bt, bp); } Block::Reference { translation } => target.copy_from(&prev.offset(*translation)), Block::AdvancedReference(r) => target.copy_from_sampler(&Sampler::from_refblock(prev, r)), } }