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
//! RGBA → luma conversion for the SSIM metrics.
/// MATLAB/Octave `rgb2gray` coefficients (the YIQ luminance row). The SSIM
/// references all run on `rgb2gray(imread(...))`, so the port has to use the
/// same weights rather than the YIQ constants blazediff's pixel diff uses.
const R_WEIGHT: f32 = 0.298936;
const G_WEIGHT: f32 = 0.587043;
const B_WEIGHT: f32 = 0.114021;
/// Convert an RGBA8 buffer to a plane of luma samples in `0..=255`.
///
/// Left as a straight loop rather than hand-vectorised: it is a single
/// multiply-accumulate over a byte stream, memory-bound, and under 2% of any
/// metric's runtime — the convolutions in `super::convolve` run 10 passes of
/// 11 taps over the same pixels. Deinterleaving RGBA into vector lanes would
/// cost more code than it saves time.
pub