FAILURE MAP
← Case archive

FA-78826 / Broadcast timecode arithmetic / Open access

90 kHz presentation timestamp to frame label: elapsed wrap · case 01

Frames after a PTS rollover get negative frame numbers.

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

ROOT CAUSE

The elapsed ticks are not wrapped.

VERIFIED REPAIR

Reduce elapsed ticks modulo 2^33.

Unsuccessful approach: The absolute difference mirrors wrapped timestamps to the start.

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 -90000<raw<0:
        return None
    d=raw
    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: elapsed wrap', [100, 8589931092, [25, 1]], [1, '00:00:00:01']), ('regression variant: elapsed wrap', [877, 8589933592, [50, 1]], [1, '00:00:00:01']), ('partial repair probe: elapsed wrap', [7775999000, 8589933592, [50, 1]], [4320000, '00:00:00:00']), ('partial repair variant: elapsed wrap', [8586244592, 8589844592, [25, 1]], [2385093, '02:30:03:18']), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('boundary control', [0, 45000, [25, 1]], None), ('normal control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('normal control', [127800, 126000, [25, 1]], [1, '00:00:00:01']), ('normal control', [1801, 0, [50, 1]], [1, '00:00:00:01'])], [('regression: elapsed wrap', [0, 90000, [25, 1]], [2386068, '02:30:42:18']), ('regression variant: elapsed wrap', [35999, 126000, [24000, 1001]], [2288337, '02:29:07:09']), ('partial repair probe: elapsed wrap', [7775910000, 8589844592, [24000, 1001]], [2071528, '23:58:33:16']), ('partial repair variant: elapsed wrap', [7775910000, 8589844592, [25, 1]], [2160000, '00:00:00:00']), ('boundary control', [0, 45000, [25, 1]], None), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('normal control', [7776000000, 0, [50, 1]], [4320000, '00:00:00:00']), ('normal control', [3754, 0, [24000, 1001]], [1, '00:00:00:01']), ('normal control', [1877, 0, [50, 1]], [1, '00:00:00:01'])], [('regression: elapsed wrap', [7775999000, 8589933592, [50, 1]], [4320000, '00:00:00:00']), ('regression variant: elapsed wrap', [877, 8589933592, [24000, 1001]], [1, '00:00:00:01']), ('partial repair probe: elapsed wrap', [8586333592, 8589933592, [30000, 1001]], [2859252, '02:28:28:12']), ('partial repair variant: elapsed wrap', [810000, 900000, [30000, 1001]], [2860421, '02:29:07:11']), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('normal control', [127800, 126000, [50, 1]], [1, '00:00:00:01']), ('normal control', [3753, 0, [50, 1]], [2, '00:00:00:02']), ('normal control', [129754, 126000, [25, 1]], [1, '00:00:00:01'])], [('regression: elapsed wrap', [7775910000, 8589844592, [24000, 1001]], [2071528, '23:58:33:16']), ('regression variant: elapsed wrap', [36000, 126000, [24000, 1001]], [2288337, '02:29:07:09']), ('partial repair probe: elapsed wrap', [877, 8589933592, [50, 1]], [1, '00:00:00:01']), ('partial repair variant: elapsed wrap', [809999, 900000, [25, 1]], [2386068, '02:30:42:18']), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('boundary control', [0, 45000, [25, 1]], None), ('normal control', [7776000000, 0, [24000, 1001]], [2071528, '23:58:33:16']), ('normal control', [8586460592, 126000, [30000, 1001]], [2859252, '02:28:28:12']), ('normal control', [810001, 900000, [24000, 1001]], None)], [('regression: elapsed wrap', [8586333592, 8589933592, [30000, 1001]], [2859252, '02:28:28:12']), ('regression variant: elapsed wrap', [8586244592, 8589844592, [25, 1]], [2385093, '02:30:03:18']), ('partial repair probe: elapsed wrap', [35999, 126000, [24000, 1001]], [2288337, '02:29:07:09']), ('partial repair variant: elapsed wrap', [8589754591, 8589844592, [24000, 1001]], [2288337, '02:29:07:09']), ('boundary control', [0, 45000, [25, 1]], None), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('normal control', [127502, 126000, [24000, 1001]], [0, '00:00:00:00']), ('normal control', [901502, 900000, [25, 1]], [0, '00:00:00:00']), ('normal control', [127502, 126000, [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: elapsed wrap[-2386092, '21:29:16:08'][1, '00:00:00:01']Failed
regression variant: elapsed wrap[-4772185, '21:29:16:15'][1, '00:00:00:01']Failed
partial repair probe: elapsed wrap[-452186, '21:29:16:14'][4320000, '00:00:00:00']Failed
partial repair variant: elapsed wrap[-1000, '23:59:20:00'][2385093, '02:30:03:18']Failed
boundary control[1, '00:00:00:01'][1, '00:00:00:01']Passed
boundary controlNoneNonePassed
normal 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[1, '00:00:00:01'][1, '00:00:00:01']Passed

SHA-256 / 95611c5672ad1c5dc5622e4261c936ce4de094621d7d875441798e08f11cbec0

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 -90000<raw<0:
        return None
    d=abs(raw)
    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: elapsed wrap', [100, 8589931092, [25, 1]], [1, '00:00:00:01']), ('regression variant: elapsed wrap', [877, 8589933592, [50, 1]], [1, '00:00:00:01']), ('partial repair probe: elapsed wrap', [7775999000, 8589933592, [50, 1]], [4320000, '00:00:00:00']), ('partial repair variant: elapsed wrap', [8586244592, 8589844592, [25, 1]], [2385093, '02:30:03:18']), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('boundary control', [0, 45000, [25, 1]], None), ('normal control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('normal control', [127800, 126000, [25, 1]], [1, '00:00:00:01']), ('normal control', [1801, 0, [50, 1]], [1, '00:00:00:01'])], [('regression: elapsed wrap', [0, 90000, [25, 1]], [2386068, '02:30:42:18']), ('regression variant: elapsed wrap', [35999, 126000, [24000, 1001]], [2288337, '02:29:07:09']), ('partial repair probe: elapsed wrap', [7775910000, 8589844592, [24000, 1001]], [2071528, '23:58:33:16']), ('partial repair variant: elapsed wrap', [7775910000, 8589844592, [25, 1]], [2160000, '00:00:00:00']), ('boundary control', [0, 45000, [25, 1]], None), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('normal control', [7776000000, 0, [50, 1]], [4320000, '00:00:00:00']), ('normal control', [3754, 0, [24000, 1001]], [1, '00:00:00:01']), ('normal control', [1877, 0, [50, 1]], [1, '00:00:00:01'])], [('regression: elapsed wrap', [7775999000, 8589933592, [50, 1]], [4320000, '00:00:00:00']), ('regression variant: elapsed wrap', [877, 8589933592, [24000, 1001]], [1, '00:00:00:01']), ('partial repair probe: elapsed wrap', [8586333592, 8589933592, [30000, 1001]], [2859252, '02:28:28:12']), ('partial repair variant: elapsed wrap', [810000, 900000, [30000, 1001]], [2860421, '02:29:07:11']), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('normal control', [127800, 126000, [50, 1]], [1, '00:00:00:01']), ('normal control', [3753, 0, [50, 1]], [2, '00:00:00:02']), ('normal control', [129754, 126000, [25, 1]], [1, '00:00:00:01'])], [('regression: elapsed wrap', [7775910000, 8589844592, [24000, 1001]], [2071528, '23:58:33:16']), ('regression variant: elapsed wrap', [36000, 126000, [24000, 1001]], [2288337, '02:29:07:09']), ('partial repair probe: elapsed wrap', [877, 8589933592, [50, 1]], [1, '00:00:00:01']), ('partial repair variant: elapsed wrap', [809999, 900000, [25, 1]], [2386068, '02:30:42:18']), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('boundary control', [0, 45000, [25, 1]], None), ('normal control', [7776000000, 0, [24000, 1001]], [2071528, '23:58:33:16']), ('normal control', [8586460592, 126000, [30000, 1001]], [2859252, '02:28:28:12']), ('normal control', [810001, 900000, [24000, 1001]], None)], [('regression: elapsed wrap', [8586333592, 8589933592, [30000, 1001]], [2859252, '02:28:28:12']), ('regression variant: elapsed wrap', [8586244592, 8589844592, [25, 1]], [2385093, '02:30:03:18']), ('partial repair probe: elapsed wrap', [35999, 126000, [24000, 1001]], [2288337, '02:29:07:09']), ('partial repair variant: elapsed wrap', [8589754591, 8589844592, [24000, 1001]], [2288337, '02:29:07:09']), ('boundary control', [0, 45000, [25, 1]], None), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('normal control', [127502, 126000, [24000, 1001]], [0, '00:00:00:00']), ('normal control', [901502, 900000, [25, 1]], [0, '00:00:00:00']), ('normal control', [127502, 126000, [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: elapsed wrap[2386092, '02:30:43:17'][1, '00:00:00:01']Failed
regression variant: elapsed wrap[4772185, '02:30:43:35'][1, '00:00:00:01']Failed
partial repair probe: elapsed wrap[452186, '02:30:43:36'][4320000, '00:00:00:00']Failed
partial repair variant: elapsed wrap[1000, '00:00:40:00'][2385093, '02:30:03:18']Failed
boundary control[1, '00:00:00:01'][1, '00:00:00:01']Passed
boundary controlNoneNonePassed
normal 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[1, '00:00:00:01'][1, '00:00:00:01']Passed

SHA-256 / 9c3eadf75989303436055e925fb80ac757e165a5f039e09715bad993bcb5d1b8

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: elapsed wrap', [100, 8589931092, [25, 1]], [1, '00:00:00:01']), ('regression variant: elapsed wrap', [877, 8589933592, [50, 1]], [1, '00:00:00:01']), ('partial repair probe: elapsed wrap', [7775999000, 8589933592, [50, 1]], [4320000, '00:00:00:00']), ('partial repair variant: elapsed wrap', [8586244592, 8589844592, [25, 1]], [2385093, '02:30:03:18']), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('boundary control', [0, 45000, [25, 1]], None), ('normal control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('normal control', [127800, 126000, [25, 1]], [1, '00:00:00:01']), ('normal control', [1801, 0, [50, 1]], [1, '00:00:00:01'])], [('regression: elapsed wrap', [0, 90000, [25, 1]], [2386068, '02:30:42:18']), ('regression variant: elapsed wrap', [35999, 126000, [24000, 1001]], [2288337, '02:29:07:09']), ('partial repair probe: elapsed wrap', [7775910000, 8589844592, [24000, 1001]], [2071528, '23:58:33:16']), ('partial repair variant: elapsed wrap', [7775910000, 8589844592, [25, 1]], [2160000, '00:00:00:00']), ('boundary control', [0, 45000, [25, 1]], None), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('normal control', [7776000000, 0, [50, 1]], [4320000, '00:00:00:00']), ('normal control', [3754, 0, [24000, 1001]], [1, '00:00:00:01']), ('normal control', [1877, 0, [50, 1]], [1, '00:00:00:01'])], [('regression: elapsed wrap', [7775999000, 8589933592, [50, 1]], [4320000, '00:00:00:00']), ('regression variant: elapsed wrap', [877, 8589933592, [24000, 1001]], [1, '00:00:00:01']), ('partial repair probe: elapsed wrap', [8586333592, 8589933592, [30000, 1001]], [2859252, '02:28:28:12']), ('partial repair variant: elapsed wrap', [810000, 900000, [30000, 1001]], [2860421, '02:29:07:11']), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('normal control', [127800, 126000, [50, 1]], [1, '00:00:00:01']), ('normal control', [3753, 0, [50, 1]], [2, '00:00:00:02']), ('normal control', [129754, 126000, [25, 1]], [1, '00:00:00:01'])], [('regression: elapsed wrap', [7775910000, 8589844592, [24000, 1001]], [2071528, '23:58:33:16']), ('regression variant: elapsed wrap', [36000, 126000, [24000, 1001]], [2288337, '02:29:07:09']), ('partial repair probe: elapsed wrap', [877, 8589933592, [50, 1]], [1, '00:00:00:01']), ('partial repair variant: elapsed wrap', [809999, 900000, [25, 1]], [2386068, '02:30:42:18']), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('boundary control', [0, 45000, [25, 1]], None), ('normal control', [7776000000, 0, [24000, 1001]], [2071528, '23:58:33:16']), ('normal control', [8586460592, 126000, [30000, 1001]], [2859252, '02:28:28:12']), ('normal control', [810001, 900000, [24000, 1001]], None)], [('regression: elapsed wrap', [8586333592, 8589933592, [30000, 1001]], [2859252, '02:28:28:12']), ('regression variant: elapsed wrap', [8586244592, 8589844592, [25, 1]], [2385093, '02:30:03:18']), ('partial repair probe: elapsed wrap', [35999, 126000, [24000, 1001]], [2288337, '02:29:07:09']), ('partial repair variant: elapsed wrap', [8589754591, 8589844592, [24000, 1001]], [2288337, '02:29:07:09']), ('boundary control', [0, 45000, [25, 1]], None), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('normal control', [127502, 126000, [24000, 1001]], [0, '00:00:00:00']), ('normal control', [901502, 900000, [25, 1]], [0, '00:00:00:00']), ('normal control', [127502, 126000, [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: elapsed wrap[1, '00:00:00:01'][1, '00:00:00:01']Passed
regression variant: elapsed wrap[1, '00:00:00:01'][1, '00:00:00:01']Passed
partial repair probe: elapsed wrap[4320000, '00:00:00:00'][4320000, '00:00:00:00']Passed
partial repair variant: elapsed wrap[2385093, '02:30:03:18'][2385093, '02:30:03:18']Passed
boundary control[1, '00:00:00:01'][1, '00:00:00:01']Passed
boundary controlNoneNonePassed
normal 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[1, '00:00:00:01'][1, '00:00:00:01']Passed

SHA-256 / 00039b71d074744d22825d551c8258ec1aa6617f8122da1c689e64e367b7813b

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.955874+00:00.

Case digest / 41b9d423e746eaf9dac651583eb24569d5d09dd4367d2a42473b7f650278dcee