Every parser now carries provenance, on the one shared buffer
dts, ac3 and truehd assembled access units across PES packets with three private implementations of the same bookkeeping, and none of them carried the source byte offset. They now hold a PesBuf, so a unit takes the timestamp AND the source of the packet covering its first byte, from the same mark, and no codec can answer that question its own way again. dts is the reference case: its pts_marks already implemented the rule correctly, and all 61 of its existing tests -- including the PTS attribution ones -- pass unchanged on the shared type. That is the evidence the type preserves the behaviour dts had right. ac3 kept a single carry-over timestamp and one anchor offset, so it could only attribute the first unit in a call; it now resolves each unit at its own offset. truehd had no attribution at all beyond a running clock. New tests cover the case that motivated this: a unit whose first bytes arrive in one packet and whose remainder arrives in the next keeps the FIRST packet's offset. At a clip seam those two packets belong to different clips, and taking the later one places the audio in the wrong one. Clippy on the pinned toolchain caught an empty `if` block left where dts used to clear stale marks -- restored as an explicit clear, with why it is still needed once drain keeps the covering mark.
This commit is contained in:
@@ -276,4 +276,15 @@ mod tests {
|
||||
let f = p.parse(&make_pes(vec![0xFF, 0xF1, 0x50], Some(0)));
|
||||
assert_eq!(f.len(), 1, "too short to validate → kept");
|
||||
}
|
||||
|
||||
/// One PES is one unit here, so the frame carries that packet's offset.
|
||||
#[test]
|
||||
fn a_frame_carries_its_packets_source() {
|
||||
let mut parser = AdtsParser::new();
|
||||
let mut p = make_pes(adts_frame(64), Some(90_000));
|
||||
p.source = Some(crate::pes::SourcePos::at_byte(4_242));
|
||||
let frames = parser.parse(&p);
|
||||
assert!(!frames.is_empty(), "a valid ADTS frame is emitted");
|
||||
assert_eq!(frames[0].source.map(|s| s.byte), Some(4_242));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user