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::{
29 pub const MAX_DIMENSION: u32 = 4096;29 pub const MAX_DIMENSION: u32 = 4096;
30 /// Ticks of the SPU delay unit: 1024 periods of the 90 kHz clock.30 /// Ticks of the SPU delay unit: 1024 periods of the 90 kHz clock.
31 pub const DELAY_UNIT_90K: i64 = 1024;31 pub const DELAY_UNIT_90K: i64 = 1024;
32+const CLOCK_90K: TimeBase = TimeBase::new(1, 90_000);
32 /// Finished cues kept for [`DvdSubDecoder::take_cue`].33 /// Finished cues kept for [`DvdSubDecoder::take_cue`].
33 pub const MAX_PENDING: usize = 64;34 pub const MAX_PENDING: usize = 64;
34 35
@@ -475,7 +476,7 @@ pub struct DvdSubDecoder {
475 params: CodecParameters,476 params: CodecParameters,
476 palette: Palette,477 palette: Palette,
477 canvas: (u32, u32),478 canvas: (u32, u32),
478- ready: VecDeque<(Cue, Option<Timestamp>)>,479+ ready: VecDeque<Cue>,
479 }480 }
480 481
481 impl DvdSubDecoder {482 impl DvdSubDecoder {
@@ -498,21 +499,20 @@ impl DvdSubDecoder {
498 pub fn push_unit(&mut self, unit: &[u8], pts: Option<Timestamp>) -> Result<()> {499 pub fn push_unit(&mut self, unit: &[u8], pts: Option<Timestamp>) -> Result<()> {
499 let mut cue = decode_spu(unit, &self.palette, self.canvas)?;500 let mut cue = decode_spu(unit, &self.palette, self.canvas)?;
500 if let Some(p) = pts {501 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, CLOCK_90K)
502- let delay = Timestamp::new(cue.start_90k, base)
503 .rescale(p.base, ec_core::Rounding::Nearest);503 .rescale(p.base, ec_core::Rounding::Nearest);
504 cue.frame.pts = Some(Timestamp::new(p.ticks.saturating_add(delay.ticks), p.base));504 cue.frame.pts = Some(Timestamp::new(p.ticks.saturating_add(delay.ticks), p.base));
505 }505 }
506 if self.ready.len() >= MAX_PENDING {506 if self.ready.len() >= MAX_PENDING {
507 self.ready.pop_front();507 self.ready.pop_front();
508 }508 }
509- self.ready.push_back((cue, pts));509+ self.ready.push_back(cue);
510 Ok(())510 Ok(())
511 }511 }
512 512
513 /// The next decoded cue with its timing, oldest first.513 /// The next decoded cue with its timing, oldest first.
514 pub fn take_cue(&mut self) -> Option<Cue> {514 pub fn take_cue(&mut self) -> Option<Cue> {
515- self.ready.pop_front().map(|(c, _)| c)515+ self.ready.pop_front()
516 }516 }
517 }517 }
518 518