diff options
author | metamuffin <metamuffin@disroot.org> | 2024-06-10 15:28:36 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-06-10 15:28:36 +0200 |
commit | 05d11426a8e60fa060733eb8ae7843bc2ae9725c (patch) | |
tree | 57cfad9cedf1eb50de193f1657b42234745c044e /remuxer/src/seek_index.rs | |
parent | c0365c8c64f403fd9ee75c0db1a9ed6134633e8f (diff) | |
download | jellything-05d11426a8e60fa060733eb8ae7843bc2ae9725c.tar jellything-05d11426a8e60fa060733eb8ae7843bc2ae9725c.tar.bz2 jellything-05d11426a8e60fa060733eb8ae7843bc2ae9725c.tar.zst |
apply many clippy issue
Diffstat (limited to 'remuxer/src/seek_index.rs')
-rw-r--r-- | remuxer/src/seek_index.rs | 81 |
1 files changed, 35 insertions, 46 deletions
diff --git a/remuxer/src/seek_index.rs b/remuxer/src/seek_index.rs index 5bec6e6..7008696 100644 --- a/remuxer/src/seek_index.rs +++ b/remuxer/src/seek_index.rs @@ -18,7 +18,7 @@ use std::{collections::BTreeMap, fs::File, io::BufReader, path::Path, sync::Arc} pub fn get_seek_index(path: &Path) -> anyhow::Result<Arc<BTreeMap<u64, Arc<SeekIndex>>>> { cache_memory(&["seekindex", path.to_str().unwrap()], move || { info!("generating seek index for {path:?}"); - let input = File::open(&path).context("opening source file")?; + let input = File::open(path).context("opening source file")?; let mut input = EbmlReader::new(BufReader::new(input)); let index = import_seek_index(&mut input)?; info!("done"); @@ -67,52 +67,43 @@ fn import_seek_index_segment( MatroskaTag::Cluster(_) => { let mut children = children.unwrap(); let mut pts = 0; - loop { - if let Some(Ok(Unflat { - children, - item, - position, - })) = children.n() - { - match item { - MatroskaTag::Timestamp(ts) => pts = ts, - MatroskaTag::BlockGroup(_) => { - trace!("group"); - let mut children = children.unwrap(); - while let Some(Ok(Unflat { - children: _, item, .. - })) = children.n() - { - match item { - MatroskaTag::Block(ref block) => { - debug!( - "block: track={} tso={}", - block.track, block.timestamp_off - ); - seek_index_add( - seek_index, - &block, - position.unwrap(), - pts, - ); - } - _ => trace!("{item:?}"), + while let Some(Ok(Unflat { + children, + item, + position, + })) = children.n() + { + match item { + MatroskaTag::Timestamp(ts) => pts = ts, + MatroskaTag::BlockGroup(_) => { + trace!("group"); + let mut children = children.unwrap(); + while let Some(Ok(Unflat { + children: _, item, .. + })) = children.n() + { + match item { + MatroskaTag::Block(ref block) => { + debug!( + "block: track={} tso={}", + block.track, block.timestamp_off + ); + seek_index_add(seek_index, block, position.unwrap(), pts); } + _ => trace!("{item:?}"), } } - MatroskaTag::SimpleBlock(block) => { - trace!( - "simple block: track={} tso={}", - block.track, - block.timestamp_off - ); - trace!("{pts} {}", block.timestamp_off); - seek_index_add(seek_index, &block, position.unwrap(), pts); - } - _ => trace!("(rsc) tag ignored: {item:?}"), } - } else { - break; + MatroskaTag::SimpleBlock(block) => { + trace!( + "simple block: track={} tso={}", + block.track, + block.timestamp_off + ); + trace!("{pts} {}", block.timestamp_off); + seek_index_add(seek_index, &block, position.unwrap(), pts); + } + _ => trace!("(rsc) tag ignored: {item:?}"), } } } @@ -142,9 +133,7 @@ fn seek_index_add( // } // } - let trs = seek_index - .entry(block.track) - .or_insert(SeekIndex::default()); + let trs = seek_index.entry(block.track).or_default(); if block.keyframe { trs.keyframes.push(trs.blocks.len()); |