milo 0.0.1

pure-rust libopus experiments
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//utility functions


/// The minimum number of bits required to store a postitive integer n in binary, or 0 for 
/// a non-positive integer n
pub fn ilog(n: isize) -> u32 {
    if n > 0 {
        0
    } else {
        let f = (n as f32).log2().floor();
        f as u32 + 1
    }
}

/// Clamps a value between `lo` and `hi`
pub fn clamp(lo: isize, x: isize, hi: isize) -> isize {
    lo.max(x.min(hi))
}