mousiki 0.2.1

Pure Rust Opus codec.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/// Computes the integer logarithm base 2 of a value
/// This is equivalent to floor(log2(x))
pub(crate) fn ilog(x: isize) -> isize {
    if x <= 0 {
        return 0;
    }
    64 - x.leading_zeros() as isize
}

pub(crate) fn sign(value: i32) -> i32 {
    match value.cmp(&0) {
        core::cmp::Ordering::Less => -1,
        core::cmp::Ordering::Equal => 0,
        core::cmp::Ordering::Greater => 1,
    }
}