aboutsummaryrefslogtreecommitdiff
path: root/matroska/src
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-01-17 23:08:57 +0100
committermetamuffin <metamuffin@disroot.org>2023-01-17 23:08:57 +0100
commit5aa557e864bd2cf940e7164b7568e7e545817306 (patch)
tree6eec3a834c4217dbf1208dc9b34bb7debddb1d9c /matroska/src
parentcda5929b5176947490bcf0f661f61b4b9d5ea7c1 (diff)
downloadjellything-5aa557e864bd2cf940e7164b7568e7e545817306.tar
jellything-5aa557e864bd2cf940e7164b7568e7e545817306.tar.bz2
jellything-5aa557e864bd2cf940e7164b7568e7e545817306.tar.zst
wokrs
Diffstat (limited to 'matroska/src')
-rw-r--r--matroska/src/block.rs39
1 files changed, 26 insertions, 13 deletions
diff --git a/matroska/src/block.rs b/matroska/src/block.rs
index dd5b340..9e66353 100644
--- a/matroska/src/block.rs
+++ b/matroska/src/block.rs
@@ -3,13 +3,15 @@ use anyhow::Result;
use std::io::Cursor;
pub enum LacingType {
+ Xiph,
FixedSize,
Ebml,
- Xiph,
}
pub struct Block {
pub track: u64,
+ pub keyframe: bool,
+ pub discardable: bool,
pub timestamp_off: i16,
pub invisible: bool,
pub lacing: Option<LacingType>,
@@ -23,16 +25,20 @@ impl Block {
let flags = buf[c + 2];
let data = Vec::from(&buf[c + 3..]);
- let invisible = (flags & 0b10000) == 0b10000;
- let lacing = match flags & 0b1100 {
- 0b0000 => None,
- 0b0100 => Some(LacingType::Xiph),
- 0b1000 => Some(LacingType::Ebml),
- 0b1100 => Some(LacingType::FixedSize),
+ let invisible = (flags & 0b1000) == 0b1000;
+ let lacing = match flags & 0b110 {
+ 0b000 => None,
+ 0b010 => Some(LacingType::Xiph),
+ 0b100 => Some(LacingType::FixedSize),
+ 0b110 => Some(LacingType::Ebml),
_ => unreachable!(),
};
+ let keyframe = (flags & 0b10000000) == 0b10000000;
+ let discardable = (flags & 0b1) == 0b1;
Ok(Self {
+ keyframe,
+ discardable,
track,
data,
invisible,
@@ -45,16 +51,23 @@ impl Block {
write_vint(&mut out, self.track).unwrap();
out.extend(self.timestamp_off.to_be_bytes().into_iter());
out.push(
- match self.invisible {
- true => 0b10000,
- false => 0b00000,
+ match self.discardable {
+ true => 0b1,
+ false => 0b0,
+ } | match self.invisible {
+ true => 0b10000000,
+ false => 0b00000000,
+ } | match self.invisible {
+ true => 0b1000,
+ false => 0b0000,
} | match self.lacing {
- Some(LacingType::Xiph) => 0b0100,
- Some(LacingType::Ebml) => 0b1000,
- Some(LacingType::FixedSize) => 0b1100,
+ Some(LacingType::Xiph) => 0b010,
+ Some(LacingType::Ebml) => 0b100,
+ Some(LacingType::FixedSize) => 0b110,
None => 0b0000,
},
);
+ out.extend(self.data.iter());
out
}
}