Skip to content

Commit f05cd32

Browse files
authoredMar 19, 2024··
feat: extracted vpx structure (#21)
1 parent dbe8a82 commit f05cd32

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+9358
-2220
lines changed
 

‎Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@ byteorder = "1.5.0"
2020
bytes = "1.5.0"
2121
cfb = "0.9.0"
2222
encoding_rs = "0.8.33"
23+
fake = { version = "2.9.2", features = ["derive"] }
2324
md2 = "0.10.2"
2425
nom = "7.1.3"
2526
serde = { version = "1.0.188", features = ["derive"] }
2627
serde_json = { version = "1.0.107", features = ["preserve_order"] }
2728
utf16string = "0.2.0"
2829
quick-xml = { version = "0.31.0", features = ["serialize"] }
2930
serde_repr = "0.1.16"
31+
hex = "0.4.3"
32+
wavefront_rs = "2.0.0-beta.1"
33+
flate2 = "1.0.28"
3034

3135
[dev-dependencies]
3236
dirs = "5.0.1"

‎src/vpx/biff.rs

+18-10
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ impl<'a> BiffReader<'a> {
4747
reader
4848
}
4949

50+
pub fn with_remaining(data: &'a [u8], bytes_in_record_remaining: usize) -> Self {
51+
let reader: BiffReader<'a> = BiffReader {
52+
data,
53+
pos: 0,
54+
bytes_in_record_remaining,
55+
record_start: 0,
56+
tag: "".to_string(),
57+
warn_remaining: true,
58+
};
59+
reader
60+
}
61+
5062
/**
5163
* Useful if you just want to read a bunch of tags and don't care about the data
5264
*/
@@ -181,16 +193,8 @@ impl<'a> BiffReader<'a> {
181193
let data = &self.data[self.pos..self.pos + pos_0];
182194

183195
self.pos += count;
184-
match String::from_utf8(data.to_vec()) {
185-
Ok(s) => StringWithEncoding {
186-
encoding: StringEncoding::Utf8,
187-
string: s.to_string(),
188-
},
189-
Err(_e) => StringWithEncoding {
190-
encoding: StringEncoding::Latin1,
191-
string: decode_latin1(data).to_string(),
192-
},
193-
}
196+
let s: StringWithEncoding = data.into();
197+
s
194198
}
195199

196200
pub fn get_str_no_remaining_update(&mut self, count: usize) -> String {
@@ -386,6 +390,10 @@ impl<'a> BiffReader<'a> {
386390
d
387391
}
388392

393+
pub(crate) fn get_remaining(&self) -> &[u8] {
394+
&self.data[self.pos..]
395+
}
396+
389397
pub fn skip(&mut self, count: usize) {
390398
self.pos += count;
391399
self.bytes_in_record_remaining -= count;

0 commit comments

Comments
 (0)
Please sign in to comment.