diff options
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | NOTES.md | 10 | ||||
-rw-r--r-- | src/main.rs | 37 |
3 files changed, 47 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore index e39cff4..ed84e91 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target -*.png \ No newline at end of file +*.png +*.lri_part \ No newline at end of file diff --git a/NOTES.md b/NOTES.md index 84e1da8..eadb745 100644 --- a/NOTES.md +++ b/NOTES.md @@ -60,3 +60,13 @@ So I looked through the file for the magic number LELR. It was found fifteen tim I assumed some would be false positives, it's only four bytes!, so I had a good idea for once! I looked at the 7 bytes that were offset 21 from the end of the magic number. In the header, these should be reserved: all null. It matched 10 times and failed 5! + +# Found some RAW data!!!! +## 2023-06-08 00:37 CST +tired, need sleep. +- no "lost data"; all data is held by a LightHeader +- it appears sometimes the length fields move around in `header_length` *(which is indeed sometimes set to the header length)* and the message length +- lak was able to use SourceExplorer to figure out that, yeah, the data really is right after the LightHeader. +- **thank you** +- it appears to be 14bpp packed *(for wall.lri at least)*. the `camera_module.proto` has this as one of the raw options. we should make it a priority to find and parse this. +- yay \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 28f557a..1fdb23e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -use std::{fs::File, path::Path}; +use std::{fs::File, io::Write, os::unix::prelude::FileExt, path::Path}; use lri_rs::Message; use png::{BitDepth, ColorType}; @@ -81,7 +81,40 @@ fn main() { } println!("\nDumping header info.."); - heads.iter().for_each(|h| h.header.nice_info()) + heads.iter().for_each(|h| h.header.print_info()); + + println!("\nWriting large ones to disk!"); + for (idx, head) in heads.iter().enumerate() { + if head.header.header_length > 1024 * 1024 { + // I guess we only care if it's at least a megabyte + let name = format!("{idx}.lri_part"); + let mut file = File::create(&name).unwrap(); + file.write_all(&data[head.start..head.end]).unwrap(); + println!( + "Wrote {:.2}MB to disk as {name}", + head.header.combined_length as f32 / (1024.0 * 1024.0) + ); + } + + if idx == 2 { + let data = &data[head.start + 32..head.end]; + + let mut first = vec![0; data.len() / 2]; + let mut second = vec![0; data.len() / 2]; + for (idx, chnk) in data.chunks(2).enumerate() { + first[idx] = chnk[0]; + second[idx] = chnk[0]; + } + + let name = format!("{idx}_first.lri_part"); + let mut file = File::create(&name).unwrap(); + file.write_all(&first).unwrap(); + + let name = format!("{idx}_second.lri_part"); + let mut file = File::create(&name).unwrap(); + file.write_all(&second).unwrap(); + } + } } fn make_png<P: AsRef<Path>>( |