about summary refs log tree commit diff
path: root/prism/src/unpack.rs
diff options
context:
space:
mode:
authorgennyble <gen@nyble.dev>2024-03-09 21:50:32 -0600
committergennyble <gen@nyble.dev>2024-03-09 21:50:32 -0600
commit4b37607028967fd178745d0986f88b83f0d65e2f (patch)
tree3a411673a11e2326d19b602b37b44d73ca314423 /prism/src/unpack.rs
parente9531eefae80caeb0b32b8e0acd568c14f65b384 (diff)
downloadlri-rs-4b37607028967fd178745d0986f88b83f0d65e2f.tar.gz
lri-rs-4b37607028967fd178745d0986f88b83f0d65e2f.zip
dirty repo; this was here; wip
Diffstat (limited to 'prism/src/unpack.rs')
-rw-r--r--prism/src/unpack.rs61
1 files changed, 0 insertions, 61 deletions
diff --git a/prism/src/unpack.rs b/prism/src/unpack.rs
deleted file mode 100644
index bc761f3..0000000
--- a/prism/src/unpack.rs
+++ /dev/null
@@ -1,61 +0,0 @@
-const TEN_MASK: u64 = 1023; // ten bits
-
-pub fn tenbit(packd: &[u8], count: usize, upack: &mut [u16]) {
-	let required_len_packd = (count as f32 * (10.0 / 8.0)).ceil() as usize;
-
-	if count > upack.len() {
-		panic!(
-			"expected output buffer to be {count} bytes, got {} bytes",
-			upack.len()
-		)
-	}
-
-	if required_len_packd > packd.len() {
-		panic!(
-			"expected input to be at least {required_len_packd} bytes, it was {}",
-			packd.len()
-		)
-	}
-
-	let mut packd = packd[..required_len_packd].to_vec();
-	packd.reverse();
-	let chunker = packd.chunks_exact(5);
-	let remain = chunker.remainder();
-
-	for (idx, chnk) in chunker.enumerate() {
-		let long = u64::from_be_bytes([
-			0x00, 0x00, 0x00, chnk[0], chnk[1], chnk[2], chnk[3], chnk[4],
-		]);
-
-		let b4 = long & TEN_MASK;
-		let b3 = (long >> 10) & TEN_MASK;
-		let b2 = (long >> 20) & TEN_MASK;
-		let b1 = (long >> 30) & TEN_MASK;
-
-		let idx = idx * 4;
-		upack[idx] = b1 as u16;
-		upack[idx + 1] = b2 as u16;
-		upack[idx + 2] = b3 as u16;
-		upack[idx + 3] = b4 as u16;
-	}
-
-	if remain.len() > 0 {
-		let mut long_bytes = [0x00; 8];
-
-		for (idx, byte) in remain.iter().enumerate() {
-			long_bytes[idx] = *byte;
-		}
-
-		let long = u64::from_le_bytes(long_bytes);
-
-		let count_remain = count % 4;
-		let start = count - count_remain;
-		for idx in 0..count_remain {
-			upack[start + idx] = ((long >> (10 * idx)) & TEN_MASK) as u16;
-		}
-	}
-}
-
-//pub fn twelvebit(packed: &[u8]) {
-// 3 bytes per 2 12-bits
-//}