forge
Explore
Log in

Don't you dare go Hollow

U21: ec-dvdsub ready queue holds Cue only (the unit pts was never read on take); 90 kHz base is a const

Browse files at this commit

3fe281a9f3e0297d3771be20ef2f3eeff65fbed1Ahmet Kaan GümüşParent: 1984e2f
crates/ec-dvdsub/src/lib.rsmodified+5 -5
@@ -29,6 +29,7 @@ use ec_core::{
2929 pub const MAX_DIMENSION: u32 = 4096;
3030 /// Ticks of the SPU delay unit: 1024 periods of the 90 kHz clock.
3131 pub const DELAY_UNIT_90K: i64 = 1024;
32+const CLOCK_90K: TimeBase = TimeBase::new(1, 90_000);
3233 /// Finished cues kept for [`DvdSubDecoder::take_cue`].
3334 pub const MAX_PENDING: usize = 64;
3435
@@ -475,7 +476,7 @@ pub struct DvdSubDecoder {
475476 params: CodecParameters,
476477 palette: Palette,
477478 canvas: (u32, u32),
478- ready: VecDeque<(Cue, Option<Timestamp>)>,
479+ ready: VecDeque<Cue>,
479480 }
480481
481482 impl DvdSubDecoder {
@@ -498,21 +499,20 @@ impl DvdSubDecoder {
498499 pub fn push_unit(&mut self, unit: &[u8], pts: Option<Timestamp>) -> Result<()> {
499500 let mut cue = decode_spu(unit, &self.palette, self.canvas)?;
500501 if let Some(p) = pts {
501- let base = TimeBase::try_new(1, 90_000).map_err(|_| Error::corrupt("dvdsub: time base"))?;
502- let delay = Timestamp::new(cue.start_90k, base)
502+ let delay = Timestamp::new(cue.start_90k, CLOCK_90K)
503503 .rescale(p.base, ec_core::Rounding::Nearest);
504504 cue.frame.pts = Some(Timestamp::new(p.ticks.saturating_add(delay.ticks), p.base));
505505 }
506506 if self.ready.len() >= MAX_PENDING {
507507 self.ready.pop_front();
508508 }
509- self.ready.push_back((cue, pts));
509+ self.ready.push_back(cue);
510510 Ok(())
511511 }
512512
513513 /// The next decoded cue with its timing, oldest first.
514514 pub fn take_cue(&mut self) -> Option<Cue> {
515- self.ready.pop_front().map(|(c, _)| c)
515+ self.ready.pop_front()
516516 }
517517 }
518518