diff options
Diffstat (limited to 'evc/src/format/ser.rs')
-rw-r--r-- | evc/src/format/ser.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/evc/src/format/ser.rs b/evc/src/format/ser.rs index 731a7a3..817cafe 100644 --- a/evc/src/format/ser.rs +++ b/evc/src/format/ser.rs @@ -246,6 +246,29 @@ impl Ser for Small<Vec2<isize>> { } } +pub fn map_scalar8(v: i8) -> f32 { + match v { + 0 => 0.0, + x if x > 0 => 2f32.powf((x as f32).abs() / 2.0 - 2.0), + x => -2f32.powf((-x as f32).abs() / 2.0 - 2.0), + } +} +// const SCALAR8: [f32; 256] = gen_scalar8_lookup(); +// const fn gen_scalar8_lookup() -> [f32; 256] { +// let mut a = [0.0; 256]; +// let mut i = 0usize; +// while i < 256 { +// a[i as usize] = if i == 0 { +// 0.0 +// } else { +// let x = i as i8 as f32; +// x.signum() * 2f32.powf(x.abs() / 2.0 - 2.0) +// }; +// i += 1; +// } +// a +// } + #[cfg(test)] mod test { use super::{Ser, Sink}; |