FAILURE MAP
← Case archive

FA-78821 / Broadcast timecode arithmetic / Open access

90 kHz presentation timestamp to frame label: pre-roll window · case 01

Timestamps that legitimately wrapped past 2^33 are discarded.

Verified by executionVariant 1 · 9 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Every negative difference is treated as pre-roll.

VERIFIED REPAIR

Only differences within one second before first_pts are pre-roll.

Unsuccessful approach: A half-second window wraps late reordered frames into huge offsets.

Case contract

PTS values are 33-bit 90 kHz ticks. The elapsed ticks since first_pts wrap modulo 2^33, except that a PTS less than 90000 ticks before first_pts (reordering pre-roll) returns None. The frame is the nearest frame at rate [N,D] (halves up); the label uses nominal rate ceil(N/D) and wraps at 24 hours.

Why this case matters

Timecode arithmetic errors misplace edits, commercial breaks and captions against the broadcast clock.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(pts, first_pts, fps):
    WRAP=1<<33
    raw=pts-first_pts
    if raw<0:
        return None
    d=raw%WRAP
    num,den=fps
    n=(2*d*num+90000*den)//(180000*den)
    nominal=-(-num//den)
    return [n,'%02d:%02d:%02d:%02d'%(n//(3600*nominal)%24,n//(60*nominal)%60,n//nominal%60,n%nominal)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: pre-roll window', [100, 8589931092, [25, 1]], [1, '00:00:00:01']), ('regression variant: pre-roll window', [877, 8589933592, [50, 1]], [1, '00:00:00:01']), ('partial repair probe: pre-roll window', [36001, 126000, [30000, 1001]], None), ('partial repair variant: pre-roll window', [8589843593, 8589933592, [25, 1]], None), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('normal control', [127800, 126000, [25, 1]], [1, '00:00:00:01']), ('normal control', [901502, 900000, [24000, 1001]], [0, '00:00:00:00']), ('normal control', [900001, 900000, [50, 1]], [0, '00:00:00:00'])], [('regression: pre-roll window', [0, 90000, [25, 1]], [2386068, '02:30:42:18']), ('regression variant: pre-roll window', [35999, 126000, [24000, 1001]], [2288337, '02:29:07:09']), ('partial repair probe: pre-roll window', [8589843593, 8589933592, [24000, 1001]], None), ('partial repair variant: pre-roll window', [8589754593, 8589844592, [25, 1]], None), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('normal control', [1, 0, [25, 1]], [0, '00:00:00:00']), ('normal control', [324126000, 126000, [24000, 1001]], [86314, '00:59:56:10']), ('normal control', [126000, 126000, [25, 1]], [0, '00:00:00:00'])], [('regression: pre-roll window', [7775999000, 8589933592, [50, 1]], [4320000, '00:00:00:00']), ('regression variant: pre-roll window', [877, 8589933592, [24000, 1001]], [1, '00:00:00:01']), ('partial repair probe: pre-roll window', [36001, 126000, [25, 1]], None), ('partial repair variant: pre-roll window', [8589754593, 8589844592, [50, 1]], None), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('normal control', [0, 0, [50, 1]], [0, '00:00:00:00']), ('normal control', [3753, 0, [25, 1]], [1, '00:00:00:01']), ('normal control', [129600, 126000, [25, 1]], [1, '00:00:00:01'])], [('regression: pre-roll window', [7775910000, 8589844592, [24000, 1001]], [2071528, '23:58:33:16']), ('regression variant: pre-roll window', [36000, 126000, [24000, 1001]], [2288337, '02:29:07:09']), ('partial repair probe: pre-roll window', [810001, 900000, [50, 1]], None), ('partial repair variant: pre-roll window', [8589754593, 8589844592, [30000, 1001]], None), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('normal control', [324900000, 900000, [24000, 1001]], [86314, '00:59:56:10']), ('normal control', [127800, 126000, [30000, 1001]], [1, '00:00:00:01']), ('normal control', [127502, 126000, [24000, 1001]], [0, '00:00:00:00'])], [('regression: pre-roll window', [8586333592, 8589933592, [30000, 1001]], [2859252, '02:28:28:12']), ('regression variant: pre-roll window', [8586244592, 8589844592, [25, 1]], [2385093, '02:30:03:18']), ('partial repair probe: pre-roll window', [36001, 126000, [50, 1]], None), ('partial repair variant: pre-roll window', [8589754593, 8589844592, [24000, 1001]], None), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('normal control', [3754, 0, [25, 1]], [1, '00:00:00:01']), ('normal control', [127502, 126000, [25, 1]], [0, '00:00:00:00']), ('normal control', [1501, 0, [25, 1]], [0, '00:00:00:00'])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: pre-roll windowNone[1, '00:00:00:01']Failed
regression variant: pre-roll windowNone[1, '00:00:00:01']Failed
partial repair probe: pre-roll windowNoneNonePassed
partial repair variant: pre-roll windowNoneNonePassed
boundary control[1, '00:00:00:01'][1, '00:00:00:01']Passed
boundary control[1, '00:00:00:01'][1, '00:00:00:01']Passed
normal control[1, '00:00:00:01'][1, '00:00:00:01']Passed
normal control[0, '00:00:00:00'][0, '00:00:00:00']Passed
normal control[0, '00:00:00:00'][0, '00:00:00:00']Passed

SHA-256 / 813855b0af0116f91ce320067c5ee4eebe9a0f4b931e458ae33910de194c0cef

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(pts, first_pts, fps):
    WRAP=1<<33
    raw=pts-first_pts
    if -45000<raw<0:
        return None
    d=raw%WRAP
    num,den=fps
    n=(2*d*num+90000*den)//(180000*den)
    nominal=-(-num//den)
    return [n,'%02d:%02d:%02d:%02d'%(n//(3600*nominal)%24,n//(60*nominal)%60,n//nominal%60,n%nominal)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: pre-roll window', [100, 8589931092, [25, 1]], [1, '00:00:00:01']), ('regression variant: pre-roll window', [877, 8589933592, [50, 1]], [1, '00:00:00:01']), ('partial repair probe: pre-roll window', [36001, 126000, [30000, 1001]], None), ('partial repair variant: pre-roll window', [8589843593, 8589933592, [25, 1]], None), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('normal control', [127800, 126000, [25, 1]], [1, '00:00:00:01']), ('normal control', [901502, 900000, [24000, 1001]], [0, '00:00:00:00']), ('normal control', [900001, 900000, [50, 1]], [0, '00:00:00:00'])], [('regression: pre-roll window', [0, 90000, [25, 1]], [2386068, '02:30:42:18']), ('regression variant: pre-roll window', [35999, 126000, [24000, 1001]], [2288337, '02:29:07:09']), ('partial repair probe: pre-roll window', [8589843593, 8589933592, [24000, 1001]], None), ('partial repair variant: pre-roll window', [8589754593, 8589844592, [25, 1]], None), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('normal control', [1, 0, [25, 1]], [0, '00:00:00:00']), ('normal control', [324126000, 126000, [24000, 1001]], [86314, '00:59:56:10']), ('normal control', [126000, 126000, [25, 1]], [0, '00:00:00:00'])], [('regression: pre-roll window', [7775999000, 8589933592, [50, 1]], [4320000, '00:00:00:00']), ('regression variant: pre-roll window', [877, 8589933592, [24000, 1001]], [1, '00:00:00:01']), ('partial repair probe: pre-roll window', [36001, 126000, [25, 1]], None), ('partial repair variant: pre-roll window', [8589754593, 8589844592, [50, 1]], None), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('normal control', [0, 0, [50, 1]], [0, '00:00:00:00']), ('normal control', [3753, 0, [25, 1]], [1, '00:00:00:01']), ('normal control', [129600, 126000, [25, 1]], [1, '00:00:00:01'])], [('regression: pre-roll window', [7775910000, 8589844592, [24000, 1001]], [2071528, '23:58:33:16']), ('regression variant: pre-roll window', [36000, 126000, [24000, 1001]], [2288337, '02:29:07:09']), ('partial repair probe: pre-roll window', [810001, 900000, [50, 1]], None), ('partial repair variant: pre-roll window', [8589754593, 8589844592, [30000, 1001]], None), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('normal control', [324900000, 900000, [24000, 1001]], [86314, '00:59:56:10']), ('normal control', [127800, 126000, [30000, 1001]], [1, '00:00:00:01']), ('normal control', [127502, 126000, [24000, 1001]], [0, '00:00:00:00'])], [('regression: pre-roll window', [8586333592, 8589933592, [30000, 1001]], [2859252, '02:28:28:12']), ('regression variant: pre-roll window', [8586244592, 8589844592, [25, 1]], [2385093, '02:30:03:18']), ('partial repair probe: pre-roll window', [36001, 126000, [50, 1]], None), ('partial repair variant: pre-roll window', [8589754593, 8589844592, [24000, 1001]], None), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('normal control', [3754, 0, [25, 1]], [1, '00:00:00:01']), ('normal control', [127502, 126000, [25, 1]], [0, '00:00:00:00']), ('normal control', [1501, 0, [25, 1]], [0, '00:00:00:00'])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: pre-roll window[1, '00:00:00:01'][1, '00:00:00:01']Passed
regression variant: pre-roll window[1, '00:00:00:01'][1, '00:00:00:01']Passed
partial repair probe: pre-roll window[2860421, '02:29:07:11']NoneFailed
partial repair variant: pre-roll window[2386068, '02:30:42:18']NoneFailed
boundary control[1, '00:00:00:01'][1, '00:00:00:01']Passed
boundary control[1, '00:00:00:01'][1, '00:00:00:01']Passed
normal control[1, '00:00:00:01'][1, '00:00:00:01']Passed
normal control[0, '00:00:00:00'][0, '00:00:00:00']Passed
normal control[0, '00:00:00:00'][0, '00:00:00:00']Passed

SHA-256 / f9ddeb1f7a21f99e82ef897ba7e2f930f466fb221e3c1be2df76bc304cf2b1b1

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(pts, first_pts, fps):
    WRAP=1<<33
    raw=pts-first_pts
    if -90000<raw<0:
        return None
    d=raw%WRAP
    num,den=fps
    n=(2*d*num+90000*den)//(180000*den)
    nominal=-(-num//den)
    return [n,'%02d:%02d:%02d:%02d'%(n//(3600*nominal)%24,n//(60*nominal)%60,n//nominal%60,n%nominal)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: pre-roll window', [100, 8589931092, [25, 1]], [1, '00:00:00:01']), ('regression variant: pre-roll window', [877, 8589933592, [50, 1]], [1, '00:00:00:01']), ('partial repair probe: pre-roll window', [36001, 126000, [30000, 1001]], None), ('partial repair variant: pre-roll window', [8589843593, 8589933592, [25, 1]], None), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('normal control', [127800, 126000, [25, 1]], [1, '00:00:00:01']), ('normal control', [901502, 900000, [24000, 1001]], [0, '00:00:00:00']), ('normal control', [900001, 900000, [50, 1]], [0, '00:00:00:00'])], [('regression: pre-roll window', [0, 90000, [25, 1]], [2386068, '02:30:42:18']), ('regression variant: pre-roll window', [35999, 126000, [24000, 1001]], [2288337, '02:29:07:09']), ('partial repair probe: pre-roll window', [8589843593, 8589933592, [24000, 1001]], None), ('partial repair variant: pre-roll window', [8589754593, 8589844592, [25, 1]], None), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('normal control', [1, 0, [25, 1]], [0, '00:00:00:00']), ('normal control', [324126000, 126000, [24000, 1001]], [86314, '00:59:56:10']), ('normal control', [126000, 126000, [25, 1]], [0, '00:00:00:00'])], [('regression: pre-roll window', [7775999000, 8589933592, [50, 1]], [4320000, '00:00:00:00']), ('regression variant: pre-roll window', [877, 8589933592, [24000, 1001]], [1, '00:00:00:01']), ('partial repair probe: pre-roll window', [36001, 126000, [25, 1]], None), ('partial repair variant: pre-roll window', [8589754593, 8589844592, [50, 1]], None), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('normal control', [0, 0, [50, 1]], [0, '00:00:00:00']), ('normal control', [3753, 0, [25, 1]], [1, '00:00:00:01']), ('normal control', [129600, 126000, [25, 1]], [1, '00:00:00:01'])], [('regression: pre-roll window', [7775910000, 8589844592, [24000, 1001]], [2071528, '23:58:33:16']), ('regression variant: pre-roll window', [36000, 126000, [24000, 1001]], [2288337, '02:29:07:09']), ('partial repair probe: pre-roll window', [810001, 900000, [50, 1]], None), ('partial repair variant: pre-roll window', [8589754593, 8589844592, [30000, 1001]], None), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('normal control', [324900000, 900000, [24000, 1001]], [86314, '00:59:56:10']), ('normal control', [127800, 126000, [30000, 1001]], [1, '00:00:00:01']), ('normal control', [127502, 126000, [24000, 1001]], [0, '00:00:00:00'])], [('regression: pre-roll window', [8586333592, 8589933592, [30000, 1001]], [2859252, '02:28:28:12']), ('regression variant: pre-roll window', [8586244592, 8589844592, [25, 1]], [2385093, '02:30:03:18']), ('partial repair probe: pre-roll window', [36001, 126000, [50, 1]], None), ('partial repair variant: pre-roll window', [8589754593, 8589844592, [24000, 1001]], None), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('normal control', [3754, 0, [25, 1]], [1, '00:00:00:01']), ('normal control', [127502, 126000, [25, 1]], [0, '00:00:00:00']), ('normal control', [1501, 0, [25, 1]], [0, '00:00:00:00'])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: pre-roll window[1, '00:00:00:01'][1, '00:00:00:01']Passed
regression variant: pre-roll window[1, '00:00:00:01'][1, '00:00:00:01']Passed
partial repair probe: pre-roll windowNoneNonePassed
partial repair variant: pre-roll windowNoneNonePassed
boundary control[1, '00:00:00:01'][1, '00:00:00:01']Passed
boundary control[1, '00:00:00:01'][1, '00:00:00:01']Passed
normal control[1, '00:00:00:01'][1, '00:00:00:01']Passed
normal control[0, '00:00:00:00'][0, '00:00:00:00']Passed
normal control[0, '00:00:00:00'][0, '00:00:00:00']Passed

SHA-256 / 4885b4bd3c83b33bfc1d61e030c3e01125a9ee9bc6f3803fe1b5a07ea5ea070c

Verification & scope

A deterministic bounded teaching model with a stipulated toy contract; it does not claim conformance to SMPTE or any broadcast standard. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:49:38.690699+00:00.

Case digest / 6c3c370720ec3074dc24d99795b3339e5db346619e3a9e0e6923e24c7a816b38