Coverage Report

Created: 2025-11-11 07:15

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/av-scenechange-0.14.1/src/data/hadamard.rs
Line
Count
Source
1
0
pub unsafe fn hadamard4x4(data: &mut [i32]) {
2
0
    hadamard2d::<{ 4 * 4 }, 4, 4>(&mut *(data.as_mut_ptr() as *mut [i32; 16]));
3
0
}
4
5
// SAFETY: The length of data must be 64.
6
0
pub unsafe fn hadamard8x8(data: &mut [i32]) {
7
0
    hadamard2d::<{ 8 * 8 }, 8, 8>(&mut *(data.as_mut_ptr() as *mut [i32; 64]));
8
0
}
9
10
0
fn hadamard2d<const LEN: usize, const W: usize, const H: usize>(data: &mut [i32; LEN]) {
11
    // Vertical transform.
12
0
    let vert_func = if H == 4 {
13
0
        hadamard4_1d::<LEN, W, 1, H>
14
0
    } else {
15
0
        hadamard8_1d::<LEN, W, 1, H>
16
0
    };
17
0
    vert_func(data);
18
19
    // Horizontal transform.
20
0
    let horz_func = if W == 4 {
21
0
        hadamard4_1d::<LEN, H, W, 1>
22
0
    } else {
23
0
        hadamard8_1d::<LEN, H, W, 1>
24
0
    };
25
0
    horz_func(data);
26
0
}
Unexecuted instantiation: av_scenechange::data::hadamard::hadamard2d::<16, 4, 4>
Unexecuted instantiation: av_scenechange::data::hadamard::hadamard2d::<64, 8, 8>
27
28
#[allow(clippy::erasing_op)]
29
#[allow(clippy::identity_op)]
30
0
fn hadamard4_1d<const LEN: usize, const N: usize, const STRIDE0: usize, const STRIDE1: usize>(
31
0
    data: &mut [i32; LEN],
32
0
) {
33
0
    for i in 0..N {
34
0
        let sub: &mut [i32] = &mut data[i * STRIDE0..];
35
0
        let (a0, a1) = butterfly(sub[0 * STRIDE1], sub[1 * STRIDE1]);
36
0
        let (a2, a3) = butterfly(sub[2 * STRIDE1], sub[3 * STRIDE1]);
37
0
        let (b0, b2) = butterfly(a0, a2);
38
0
        let (b1, b3) = butterfly(a1, a3);
39
0
        sub[0 * STRIDE1] = b0;
40
0
        sub[1 * STRIDE1] = b1;
41
0
        sub[2 * STRIDE1] = b2;
42
0
        sub[3 * STRIDE1] = b3;
43
0
    }
44
0
}
Unexecuted instantiation: av_scenechange::data::hadamard::hadamard4_1d::<16, 4, 4, 1>
Unexecuted instantiation: av_scenechange::data::hadamard::hadamard4_1d::<16, 4, 1, 4>
Unexecuted instantiation: av_scenechange::data::hadamard::hadamard4_1d::<64, 8, 8, 1>
Unexecuted instantiation: av_scenechange::data::hadamard::hadamard4_1d::<64, 8, 1, 8>
45
46
#[allow(clippy::erasing_op)]
47
#[allow(clippy::identity_op)]
48
0
fn hadamard8_1d<const LEN: usize, const N: usize, const STRIDE0: usize, const STRIDE1: usize>(
49
0
    data: &mut [i32; LEN],
50
0
) {
51
0
    for i in 0..N {
52
0
        let sub: &mut [i32] = &mut data[i * STRIDE0..];
53
0
54
0
        let (a0, a1) = butterfly(sub[0 * STRIDE1], sub[1 * STRIDE1]);
55
0
        let (a2, a3) = butterfly(sub[2 * STRIDE1], sub[3 * STRIDE1]);
56
0
        let (a4, a5) = butterfly(sub[4 * STRIDE1], sub[5 * STRIDE1]);
57
0
        let (a6, a7) = butterfly(sub[6 * STRIDE1], sub[7 * STRIDE1]);
58
0
59
0
        let (b0, b2) = butterfly(a0, a2);
60
0
        let (b1, b3) = butterfly(a1, a3);
61
0
        let (b4, b6) = butterfly(a4, a6);
62
0
        let (b5, b7) = butterfly(a5, a7);
63
0
64
0
        let (c0, c4) = butterfly(b0, b4);
65
0
        let (c1, c5) = butterfly(b1, b5);
66
0
        let (c2, c6) = butterfly(b2, b6);
67
0
        let (c3, c7) = butterfly(b3, b7);
68
0
69
0
        sub[0 * STRIDE1] = c0;
70
0
        sub[1 * STRIDE1] = c1;
71
0
        sub[2 * STRIDE1] = c2;
72
0
        sub[3 * STRIDE1] = c3;
73
0
        sub[4 * STRIDE1] = c4;
74
0
        sub[5 * STRIDE1] = c5;
75
0
        sub[6 * STRIDE1] = c6;
76
0
        sub[7 * STRIDE1] = c7;
77
0
    }
78
0
}
Unexecuted instantiation: av_scenechange::data::hadamard::hadamard8_1d::<16, 4, 4, 1>
Unexecuted instantiation: av_scenechange::data::hadamard::hadamard8_1d::<16, 4, 1, 4>
Unexecuted instantiation: av_scenechange::data::hadamard::hadamard8_1d::<64, 8, 8, 1>
Unexecuted instantiation: av_scenechange::data::hadamard::hadamard8_1d::<64, 8, 1, 8>
79
80
0
const fn butterfly(a: i32, b: i32) -> (i32, i32) {
81
0
    ((a + b), (a - b))
82
0
}