mirror of
https://github.com/freemkv/libfreemkv.git
synced 2026-10-07 18:13:10 +00:00
Round 7 enumerated the state space of SeamPlan::place and found three more holes in the mark heuristics — the third consecutive round to find a defect here, each time in the guard the previous round added: - a clip file opening ON its own IN mark, after a tail frame past the previous clip OUT had already advanced the cursor, read as another crossing and jumped a clip too far: 28 minutes of clip 6 dropped; - the last clip was unguarded entirely (`clip + 1 < len` skipped the check), so the 9->10 seam rewound 75.6s with dropped_total() at 0 — the exact round-5 signature, reachable without any corrupt input; - a glitch mid-clip satisfies "inside the current clip", so the round-6 stranding survived for the rest of that clip. Three patches to the same heuristic, three wrong in a new way. So stop patching it. Everything above the placement is still heuristics over marks, but the property they exist to serve is now checked DIRECTLY: a track output must not run backwards. A placement that would rewind by more than DISCONTINUITY_BACKSTEP_NS is refused; the scan then looks for a LATER clip containing the frame that does not rewind, which is exactly what a genuine overlap crossing looks like; and if none exists the frame is dropped and counted, because emitting it anywhere moves the track backwards. The tolerance is the backstep constant because B-frame reorder legitimately emits out of order by a fraction of a second, while a rewind that matters is orders of magnitude larger. The cursor moves ONLY when a later clip actually accepts the frame. My first version of this advanced on a failed search, which strands a track exactly as before — caught immediately by the round-6 regression test. All 29 previous timeline tests still pass, including continuity_preserves_forward_gap. The three round-7 scenarios now have a test each, with the real 00801.mpls numbers.