From 2167abcf72d978b4ac2f08fa7cbbddaada01f165 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Tue, 7 Mar 2023 08:00:00 +0100 Subject: a --- evc/src/codec/compress.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'evc/src/codec/compress.rs') 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 { 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::>(); norm_idct_channel(w, h, &mut ch); for y in 0..h { -- cgit v1.2.3-70-g09d2