diff options
author | metamuffin <metamuffin@disroot.org> | 2022-12-07 20:38:00 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2022-12-07 20:38:00 +0100 |
commit | 9d7986bbfd44b69a623fa29528b5d13000b91c77 (patch) | |
tree | 8da95f328243a96acec6c3ea6ebddc71bb63f05c /evc/src/format/ser.rs | |
parent | 7be0d5039db7e8660bced13698178bf1d6758109 (diff) | |
download | video-codec-experiments-9d7986bbfd44b69a623fa29528b5d13000b91c77.tar video-codec-experiments-9d7986bbfd44b69a623fa29528b5d13000b91c77.tar.bz2 video-codec-experiments-9d7986bbfd44b69a623fa29528b5d13000b91c77.tar.zst |
advanced translate
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}; |