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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//! RAW (Bayer) source kernels.
//!
//! `colconv` ingests Bayer-mosaic frames produced by upstream
//! camera-RAW pipelines (RED REDline / R3D, Blackmagic RAW / BRAW,
//! Nikon NRAW SDK, FFmpeg's `bayer_*` decoders) and runs demosaic +
//! white balance + 3x3 color-correction in a single per-row kernel.
//!
//! # Scope
//!
//! `colconv` covers **demosaic onwards**. Decoding the camera's
//! compressed bitstream into a Bayer plane is the vendor SDK's job
//! (RED SDK / BRAW SDK / Nikon Decoder); `colconv` consumes the
//! resulting [`crate::frame::BayerFrame`] /
//! [`crate::frame::BayerFrame16`] and produces RGB rows.
//!
//! # Parameters
//!
//! Three caller-supplied values shape the output (none of them
//! belong on the source frame itself, since the same Bayer plane can
//! legitimately render with different choices):
//!
//! - [`BayerPattern`] — which sensor color sits at the top-left of
//! the repeating 2x2 tile.
//! - [`WhiteBalance`] — per-channel R / G / B gains.
//! - [`ColorCorrectionMatrix`] — 3x3 RGB→RGB transform from sensor
//! primaries into the working space.
//!
//! The walker fuses [`WhiteBalance`] and [`ColorCorrectionMatrix`]
//! into a single 3x3 transform (`M = CCM · diag(wb)`) once at
//! `*_to` entry, so the per-pixel arithmetic is one 3x3 matmul.
//!
//! # Demosaic algorithm
//!
//! Selected via [`BayerDemosaic`]. Currently only
//! [`BayerDemosaic::Bilinear`] (3x3 row window, 4-tap horizontal /
//! vertical average for the missing channels) is wired up. The enum
//! is `#[non_exhaustive]` so future variants (e.g. Malvar-He-Cutler)
//! can land without a breaking change.
//!
//! # Memory model
//!
//! The walker performs **zero per-row and zero per-frame
//! allocation**. For row `r` it slices `above`, `mid`, `below`
//! references into the source plane (clamping at row 0 and
//! row `height − 1`) and hands them to the sink as a
//! `BayerRow{,16}` borrow. The sink owns the RGB output buffer for
//! the lifetime of the run; the kernel writes into it in place.
pub use ;
pub use *;
pub use *;
pub use *;