about summary refs log tree commit diff
path: root/unpacker
diff options
context:
space:
mode:
authorgennyble <gen@nyble.dev>2023-09-10 02:44:01 -0500
committergennyble <gen@nyble.dev>2023-09-10 02:44:01 -0500
commita962ba9c853a797e9a41b2830ec0181b167d8cd9 (patch)
tree7de53dfcaf87c5d4b43f2e8b38161eb193c136ad /unpacker
parent70187683361d97a8b5a251567323c323c90302f2 (diff)
downloadlri-rs-a962ba9c853a797e9a41b2830ec0181b167d8cd9.tar.gz
lri-rs-a962ba9c853a797e9a41b2830ec0181b167d8cd9.zip
reorg
Diffstat (limited to 'unpacker')
-rw-r--r--unpacker/Cargo.lock7
-rw-r--r--unpacker/Cargo.toml8
-rw-r--r--unpacker/src/lib.rs44
-rw-r--r--unpacker/src/main.rs31
4 files changed, 0 insertions, 90 deletions
diff --git a/unpacker/Cargo.lock b/unpacker/Cargo.lock
deleted file mode 100644
index 44d0a0f..0000000
--- a/unpacker/Cargo.lock
+++ /dev/null
@@ -1,7 +0,0 @@
-# This file is automatically @generated by Cargo.
-# It is not intended for manual editing.
-version = 3
-
-[[package]]
-name = "unpacker"
-version = "0.1.0"
diff --git a/unpacker/Cargo.toml b/unpacker/Cargo.toml
deleted file mode 100644
index 147529a..0000000
--- a/unpacker/Cargo.toml
+++ /dev/null
@@ -1,8 +0,0 @@
-[package]
-name = "unpacker"
-version = "0.1.0"
-edition = "2021"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
diff --git a/unpacker/src/lib.rs b/unpacker/src/lib.rs
deleted file mode 100644
index f649581..0000000
--- a/unpacker/src/lib.rs
+++ /dev/null
@@ -1,44 +0,0 @@
-#[derive(Debug)]
-pub struct Unpacker {
-	pub out: Vec<u8>,
-	pub work: u16,
-	pub work_idx: usize,
-}
-
-impl Unpacker {
-	pub fn new() -> Self {
-		Self {
-			out: vec![],
-			work: 0,
-			work_idx: 0,
-		}
-	}
-
-	pub fn push(&mut self, byte: u8) {
-		self.work = self.work << 8;
-		self.work |= byte as u16;
-		self.work_idx += 8;
-
-		//println!("[{work_idx}]");
-
-		if self.work_idx >= 10 {
-			let to_front = self.work_idx - 10;
-			let fronted = self.work >> to_front;
-			let masked = fronted & 0b000_000_111_11_111_11;
-
-			let fixwork = fronted << to_front;
-
-			self.out.extend(masked.to_le_bytes());
-			self.work_idx -= 10;
-			self.work ^= fixwork;
-		}
-	}
-
-	pub fn finish(&mut self) {
-		if self.work_idx > 0 {
-			let remain = 10 - self.work_idx;
-			let out = self.work << remain;
-			self.out.extend(out.to_le_bytes())
-		}
-	}
-}
diff --git a/unpacker/src/main.rs b/unpacker/src/main.rs
deleted file mode 100644
index 36d8131..0000000
--- a/unpacker/src/main.rs
+++ /dev/null
@@ -1,31 +0,0 @@
-use unpacker::Unpacker;
-
-fn main() {
-	// Four bits padding at the end.
-	let testdata = vec![
-		0b10000000, 0b00010000, 0b00000010, 0b00000000, 0b01000000, 0b00001000, 0b00000001,
-		0b00000000, 0b00100000, 0b00000100, 0b00000000, 0b10000000, 0b00010000,
-	];
-
-	let mut up = Unpacker {
-		out: vec![],
-		work: 0,
-		work_idx: 0,
-	};
-
-	let count = (10.0 as f32 * (10.0 / 8.0)).ceil() as usize;
-	for byte in testdata {
-		up.push(byte);
-
-		if count == up.out.len() {
-			break;
-		}
-	}
-	if count > up.out.len() {
-		up.finish();
-	}
-
-	for chnk in up.out.chunks(2) {
-		println!("{:02b} {:08b}", chnk[1], chnk[0]);
-	}
-}