Created
July 18, 2017 01:41
-
-
Save anonymous/680c80aa20a107a71f139a3b2a03055d to your computer and use it in GitHub Desktop.
Rust code shared from the playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unsafe fn exp_rotation_1(x :* mut celt_norm, off :usize, | |
len :usize, stride :usize, c :v16, s :v16) { | |
let ms = neg16!(s); | |
let off = off as isize; | |
let stride = stride as isize; | |
let len = len as isize; | |
let mut xptr = x.offset(off); | |
macro_rules! epmm { | |
($a:ident, $b:ident, $s:ident) => { | |
extract16!(pshr32!(mac16_16!(mult16_16!(c, $a), $s, $b), 15)) | |
}; | |
} | |
for _ in 0 .. len - stride { | |
let x1 = *xptr; | |
let x2 = *xptr.offset(stride); | |
*xptr.offset(stride) = epmm!(x2, x1, s); | |
*xptr = epmm!(x1, x2, ms); | |
xptr = xptr.offset(1); | |
} | |
// Sadly, we can't use Rust slices in this function yet | |
// because we are writing to negative indices of X here. | |
// We'd have to change it somewhere higher up in the chain. | |
// Maybe it would work if we changed it in celt/bands.c... | |
xptr = x.offset(off + len - 2 * stride - 1); | |
for _ in 0 .. len- 2 * stride { | |
let x1 = *xptr; | |
let x2 = *xptr.offset(stride); | |
*xptr.offset(stride) = epmm!(x2, x1, s); | |
*xptr = epmm!(x1, x2, ms); | |
xptr = xptr.offset(-1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment