diff options
author | metamuffin <metamuffin@disroot.org> | 2023-01-26 21:45:29 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-01-26 21:45:29 +0100 |
commit | 04e3ebfdda613be0e58290a49536116cc57ad147 (patch) | |
tree | f694064c74e35ddb49fd900a83885e5874a78448 /matroska/src | |
parent | c715d411f465ef742ba76866dfb177f71598b69c (diff) | |
download | jellything-04e3ebfdda613be0e58290a49536116cc57ad147.tar jellything-04e3ebfdda613be0e58290a49536116cc57ad147.tar.bz2 jellything-04e3ebfdda613be0e58290a49536116cc57ad147.tar.zst |
mhh
Diffstat (limited to 'matroska/src')
-rw-r--r-- | matroska/src/bin/mkvdump.rs | 6 | ||||
-rw-r--r-- | matroska/src/write.rs | 11 |
2 files changed, 12 insertions, 5 deletions
diff --git a/matroska/src/bin/mkvdump.rs b/matroska/src/bin/mkvdump.rs index 10c697a..ba05c19 100644 --- a/matroska/src/bin/mkvdump.rs +++ b/matroska/src/bin/mkvdump.rs @@ -14,9 +14,9 @@ fn main() -> anyhow::Result<()> { while let Some(tag) = r.next() { let tag = tag?; match tag { - MatroskaTag::SimpleBlock(_) => (), - MatroskaTag::Block(_) => (), - _ => eprintln!("{} {tag:?}", r.position), + MatroskaTag::SimpleBlock(_) => (), // println!("{} SimpleBlock", r.position), + MatroskaTag::Block(_) => (), // println!("{} Block", r.position), + _ => println!("{} {tag:?}", r.position), } } Ok(()) diff --git a/matroska/src/write.rs b/matroska/src/write.rs index ee1c44c..8c1e7bb 100644 --- a/matroska/src/write.rs +++ b/matroska/src/write.rs @@ -26,6 +26,10 @@ impl EbmlWriter { Ok(()) } + pub fn position(&self) -> usize { + self.position + } + pub fn write_padding(&mut self, position: usize) -> Result<()> { let mut size = position - self.position; match size { @@ -62,14 +66,17 @@ impl EbmlWriter { if i > (1 << 56) - 1 { bail!("vint does not fit"); } + self.write_vint_len(i, Self::vint_length(i)) + } + pub fn vint_length(v: u64) -> usize { let mut len = 1; while len <= 8 { - if i < (1 << ((7 * len) - 1)) { + if v < (1 << ((7 * len) - 1)) { break; } len += 1; } - self.write_vint_len(i, len) + len } pub fn write_vint_len(&mut self, i: u64, len: usize) -> Result<()> { let mut bytes = i.to_be_bytes(); |