1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//! Collection of demosaicing algorithms.

use ::{BayerDepth,RasterDepth};

/// The demosaicing algorithm to use to fill in the missing data.
#[derive(Clone,Copy,Debug,Eq,PartialEq)]
pub enum Demosaic {
    None,
    NearestNeighbour,
    Linear,
    Cubic,
}

macro_rules! rotate {
    ($v0:ident <- $v1:ident) => {{
        let rot = $v0;
        $v0 = $v1;
        $v1 = rot;
    }};
    ($v0:ident <- $v1:ident <- $v2:ident) => {{
        let rot = $v0;
        $v0 = $v1;
        $v1 = $v2;
        $v2 = rot;
    }};
    ($v0:ident <- $v1:ident <- $v2:ident <- $v3:ident <- $v4:ident <- $v5:ident <- $v6:ident) => {{
        let rot = $v0;
        $v0 = $v1;
        $v1 = $v2;
        $v2 = $v3;
        $v3 = $v4;
        $v4 = $v5;
        $v5 = $v6;
        $v6 = rot;
    }};
}

pub mod cubic;
pub mod linear;
pub mod nearestneighbour;
pub mod none;

/// Check if the image depth and the raster depth are compatible.
fn check_depth(bayer: BayerDepth, raster: RasterDepth) -> bool {
    match raster {
        RasterDepth::Depth8 =>
            bayer == BayerDepth::Depth8,
        RasterDepth::Depth16 =>
            bayer == BayerDepth::Depth16BE || bayer == BayerDepth::Depth16LE,
    }
}