aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--matroska/src/write.rs13
-rw-r--r--remuxer/src/import/mod.rs2
-rw-r--r--remuxer/src/lib.rs6
-rw-r--r--server/src/routes/ui/account/admin.rs2
4 files changed, 17 insertions, 6 deletions
diff --git a/matroska/src/write.rs b/matroska/src/write.rs
index 8fc17c3..63cec2b 100644
--- a/matroska/src/write.rs
+++ b/matroska/src/write.rs
@@ -90,13 +90,15 @@ impl MatroskaTag {
pub fn write_full(&self, w: &mut Vec<u8>) -> Result<()> {
let mut buf = vec![];
buf.extend(self.id().to_be_bytes().iter().skip_while(|&v| *v == 0u8));
- // note: it is relevant here, to pass the buffer with the id, such that closing tags, can clear it
+ //* note: it is relevant here, to pass the buffer with the id, such that closing tags, can clear it
self.write(&mut buf)?;
w.extend_from_slice(&buf);
Ok(())
}
}
+/// this routine works only, if the varint is as small as it can possibly be.
+/// thats not always what we do though - see below
pub fn vint_length(v: u64) -> usize {
let mut len = 1;
while len <= 8 {
@@ -107,8 +109,17 @@ pub fn vint_length(v: u64) -> usize {
}
len
}
+pub fn bad_vint_length(v: u64) -> usize {
+ match 64 - v.leading_zeros() {
+ x if x <= 8 => 1,
+ x if x <= 16 => 2,
+ x if x <= 32 => 4,
+ _ => 8,
+ }
+}
pub trait WriteValue {
+ /// writes the contents of a tag, including the size but excluding the id.
fn write_to(&self, w: &mut Vec<u8>) -> Result<()>;
}
diff --git a/remuxer/src/import/mod.rs b/remuxer/src/import/mod.rs
index 2dc2e5a..b57db15 100644
--- a/remuxer/src/import/mod.rs
+++ b/remuxer/src/import/mod.rs
@@ -182,7 +182,7 @@ fn import_read_segment(
MatroskaTag::BlockGroup(_) => {
debug!("group");
let mut children = children.unwrap();
- let mut position = children.position();
+ let position = children.position(); //? TODO where should this point to? cluster or block?
while let Some(Ok(Unflat { children: _, item })) = children.n() {
match item {
MatroskaTag::Block(ref buf) => {
diff --git a/remuxer/src/lib.rs b/remuxer/src/lib.rs
index 8aaee15..c0a4c69 100644
--- a/remuxer/src/lib.rs
+++ b/remuxer/src/lib.rs
@@ -13,7 +13,7 @@ use jellycommon::{BlockIndex, ItemInfo, SeekIndex, SourceTrack, SourceTrackKind}
use jellymatroska::{
block::Block,
read::EbmlReader,
- write::{vint_length, EbmlWriter},
+ write::{bad_vint_length, vint_length, EbmlWriter},
Master, MatroskaTag,
};
use log::{debug, info, trace, warn};
@@ -164,9 +164,9 @@ impl RemuxerContext {
};
inputs[track].layouting_progress_index += 1;
source_offsets[track].get_or_insert(block.source_off);
- if block.pts > cluster_pts + 2_000 {
+ if block.pts > cluster_pts + 1_000 {
let cluster_content_size = 1 + 1 // timestamp {tag, size}
- + vint_length(cluster_pts) // timestamp tag value
+ + bad_vint_length(cluster_pts) // timestamp tag value
+ p;
let cluster_size = 4 // tag length
+ vint_length(cluster_content_size as u64) // size varint
diff --git a/server/src/routes/ui/account/admin.rs b/server/src/routes/ui/account/admin.rs
index ce388d4..9d0a674 100644
--- a/server/src/routes/ui/account/admin.rs
+++ b/server/src/routes/ui/account/admin.rs
@@ -25,7 +25,7 @@ pub fn r_account_admin_dashboard(
Err(anyhow!("you not admin"))?
}
- // TODO this doesnt scale
+ // TODO this doesnt scale, pagination!
let users = database.users.iter().collect::<Result<Vec<_>, _>>()?;
let invites = database.invites.iter().collect::<Result<Vec<_>, _>>()?;