mirror of
https://github.com/G2-Games/lbee-utils.git
synced 2025-04-19 07:12:55 -05:00
Compare commits
2 commits
9bb24a73f4
...
d9bd35f075
Author | SHA1 | Date | |
---|---|---|---|
d9bd35f075 | |||
871340d2bb |
2 changed files with 8 additions and 8 deletions
|
@ -1,4 +1,4 @@
|
||||||
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
|
use byteorder::{ReadBytesExt, WriteBytesExt, LE};
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
io::{Read, Seek, Write},
|
io::{Read, Seek, Write},
|
||||||
|
@ -41,11 +41,11 @@ impl CompressionInfo {
|
||||||
&self,
|
&self,
|
||||||
output: &mut T,
|
output: &mut T,
|
||||||
) -> Result<(), std::io::Error> {
|
) -> Result<(), std::io::Error> {
|
||||||
output.write_u32::<LittleEndian>(self.chunk_count as u32)?;
|
output.write_u32::<LE>(self.chunk_count as u32)?;
|
||||||
|
|
||||||
for chunk in &self.chunks {
|
for chunk in &self.chunks {
|
||||||
output.write_u32::<LittleEndian>(chunk.size_compressed as u32)?;
|
output.write_u32::<LE>(chunk.size_compressed as u32)?;
|
||||||
output.write_u32::<LittleEndian>(chunk.size_raw as u32)?;
|
output.write_u32::<LE>(chunk.size_raw as u32)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -59,7 +59,7 @@ impl CompressionInfo {
|
||||||
pub fn get_chunk_info<T: Seek + ReadBytesExt + Read>(
|
pub fn get_chunk_info<T: Seek + ReadBytesExt + Read>(
|
||||||
bytes: &mut T,
|
bytes: &mut T,
|
||||||
) -> Result<CompressionInfo, CzError> {
|
) -> Result<CompressionInfo, CzError> {
|
||||||
let parts_count = bytes.read_u32::<LittleEndian>()?;
|
let parts_count = bytes.read_u32::<LE>()?;
|
||||||
|
|
||||||
let mut part_sizes = vec![];
|
let mut part_sizes = vec![];
|
||||||
let mut total_size = 0;
|
let mut total_size = 0;
|
||||||
|
@ -67,10 +67,10 @@ pub fn get_chunk_info<T: Seek + ReadBytesExt + Read>(
|
||||||
|
|
||||||
// Loop over the compressed bytes
|
// Loop over the compressed bytes
|
||||||
for _ in 0..parts_count {
|
for _ in 0..parts_count {
|
||||||
let compressed_size = bytes.read_u32::<LittleEndian>()?;
|
let compressed_size = bytes.read_u32::<LE>()?;
|
||||||
total_size = i32::wrapping_add(total_size, compressed_size as i32);
|
total_size = i32::wrapping_add(total_size, compressed_size as i32);
|
||||||
|
|
||||||
let raw_size = bytes.read_u32::<LittleEndian>()?;
|
let raw_size = bytes.read_u32::<LE>()?;
|
||||||
total_size_raw = u32::wrapping_add(total_size_raw, raw_size);
|
total_size_raw = u32::wrapping_add(total_size_raw, raw_size);
|
||||||
|
|
||||||
part_sizes.push(ChunkInfo {
|
part_sizes.push(ChunkInfo {
|
||||||
|
@ -99,7 +99,7 @@ pub fn decompress<T: Seek + ReadBytesExt + Read>(
|
||||||
let mut buffer = vec![0u16; block.size_compressed];
|
let mut buffer = vec![0u16; block.size_compressed];
|
||||||
|
|
||||||
for word in buffer.iter_mut() {
|
for word in buffer.iter_mut() {
|
||||||
*word = input.read_u16::<LittleEndian>().unwrap();
|
*word = input.read_u16::<LE>().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
let raw_buf = decompress_lzw(&buffer, block.size_raw);
|
let raw_buf = decompress_lzw(&buffer, block.size_raw);
|
||||||
|
|
BIN
documents/cz_format_spec.odt
Normal file
BIN
documents/cz_format_spec.odt
Normal file
Binary file not shown.
Loading…
Reference in a new issue