aboutsummaryrefslogtreecommitdiff
path: root/evc/src/codec/compress.rs
diff options
context:
space:
mode:
Diffstat (limited to 'evc/src/codec/compress.rs')
-rw-r--r--evc/src/codec/compress.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/evc/src/codec/compress.rs b/evc/src/codec/compress.rs
index 688f04b..09d1f29 100644
--- a/evc/src/codec/compress.rs
+++ b/evc/src/codec/compress.rs
@@ -65,17 +65,20 @@ pub fn lit_compress(w: usize, h: usize, pixels: &[Pixel]) -> Vec<u8> {
norm_dct_channel(w, h, &mut ch);
for i in 0..w * h {
- out.push(unsafe { std::mem::transmute(ch[i] as i8) });
+ out.extend(unsafe { std::mem::transmute::<_, [u8; 4]>(ch[i]) });
}
}
out
}
+
pub fn lit_decompress(compressed: &[u8], mut target: View<&mut Frame>) {
let (w, h) = (target.size.x as usize, target.size.y as usize);
for ci in 0..3 {
let mut ch = compressed[ci * w * h..(ci + 1) * w * h]
- .iter()
- .map(|v| unsafe { std::mem::transmute::<_, i8>(*v) } as f32)
+ .chunks_exact(4)
+ .map(|v| unsafe {
+ std::mem::transmute::<_, f32>(TryInto::<[u8; 4]>::try_into(v).unwrap())
+ })
.collect::<Vec<_>>();
norm_idct_channel(w, h, &mut ch);
for y in 0..h {