Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion quest/m1/fuzz-findings/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ fixed the MKV block-header panic; its input is
## Required

- [moq-mux on a fixed mp4-atom](/quest/m1/fuzz-findings/mp4-atom-bump.md) - waiting on a 0.17.x release containing kixelated/mp4-atom#264, then moq-mux bumps to it and commits the `sgpd` and `iref` regressions
- [TS step scan stays ordered](/quest/m1/fuzz-findings/ts-step-scan.md) - the step detector's look-ahead never subtracts past its start
- [SPS fields cannot overflow](/quest/m1/fuzz-findings/sps-overflow.md) - hostile H.264 and H.265 SPS crop and size fields are refused instead of wrapping
- [mp4-atom iloc is bounded](/quest/m1/fuzz-findings/mp4-atom-iloc.md) - zero-size `iloc` extents cannot allocate megabytes from a few bytes
- [A catalog update reuses its encoder](/quest/m1/fuzz-findings/catalog-encoder.md) - republishing a compressed catalog or HLS group stops allocating a fresh DEFLATE encoder (about 200 KB) each time
19 changes: 0 additions & 19 deletions quest/m1/fuzz-findings/ts-step-scan.md

This file was deleted.

Binary file added rs/moq-mux/fuzz/regressions/ts/step-scan
Binary file not shown.
37 changes: 24 additions & 13 deletions rs/moq-mux/src/container/ts/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ struct Ahead {
back: Option<Duration>,
/// The first PCR read since, which times how long the silent streams are waited for.
since: Option<u64>,
/// The next input offset to read, and the framer's state there.
/// The next input offset to read, never before `at`, and the framer's state there.
scan: u64,
framer: Framer,
/// The step, once every clock confirmed it.
Expand All @@ -292,15 +292,14 @@ impl Steps {
self.clock = routes.pcr_pid.map(|pid| (pid, None));
}
let (mut cursor, mut framer) = demux.cursor();
let start = (cursor, framer);
let Some((at, pkt)) = demux.peek(&mut cursor, &mut framer) else {
return Verdict::Route;
};
let pid = (u16::from(pkt[1] & 0x1f) << 8) | u16::from(pkt[2]);
let marks = Marks::read(pkt, routes, &self.headers);

if self.ahead.is_none() && at >= self.cleared {
self.ahead = self.trigger(at, pid, &marks, routes, start);
self.ahead = self.trigger(at, pid, &marks, routes, framer);
}
let Some(ahead) = &mut self.ahead else {
self.observe(pid, marks, routes);
Expand Down Expand Up @@ -342,15 +341,9 @@ impl Steps {
}

/// Start judging a step at the packet at `at` if it shows one, with the clocks expected to
/// step with it.
fn trigger(
&self,
at: u64,
pid: u16,
marks: &Marks,
routes: &Routes,
(scan, framer): (u64, Framer),
) -> Option<Ahead> {
/// step with it. `framer` is locked onto that packet, so the scan reads it again from `at`
/// rather than from the junk a resync skipped before it.
fn trigger(&self, at: u64, pid: u16, marks: &Marks, routes: &Routes, framer: Framer) -> Option<Ahead> {
let last_pcr = self.clock.and_then(|(_, last)| last);
let stepped = if marks.flagged {
None
Expand Down Expand Up @@ -397,7 +390,7 @@ impl Steps {
headers: self.headers.clone(),
back: None,
since: None,
scan,
scan: at,
framer,
confirmed: None,
})
Expand Down Expand Up @@ -631,6 +624,24 @@ mod tests {
assert_eq!(judge(&mux.out, &[VIDEO]), None);
}

/// Junk before the switch, such as a torn packet at the splice, makes the framer resync onto
/// the packet that shows the step, past the cursor. The look-ahead reads on from that
/// packet, not from the junk, so the switch is still judged whole.
#[test]
fn a_resync_before_the_step_reads_on_from_it() {
let (mut mux, mut cc) = (Mux::default(), 0);
second(&mut mux, &mut cc, PCR_HZ, true);
mux.out.extend_from_slice(&[0x00; 5]);
second(&mut mux, &mut cc, PCR_WRAP + 2 * PCR_HZ - SWITCH, true);
let Some(Step::Rewind { by, flagged: false }) = judge(&mux.out, &[VIDEO]) else {
panic!("the switch was missed");
};
assert!(
by.abs_diff(Duration::from_millis(16_844_460)) < Duration::from_millis(100),
"{by:?}"
);
}

/// A PES header split across packets still times its stream, so the switch is seen.
#[test]
fn a_split_pes_header_steps_with_the_clock() {
Expand Down
Loading