aboutsummaryrefslogtreecommitdiff
path: root/evc/src/codec/decode.rs
blob: b7ab8c71db1473f5e2a7abceb46500438f481aba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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)),
    }
}