FAILURE MAP
← Case archive

FA-78816 / Broadcast timecode arithmetic / Open access

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

Streams that pass the PTS rollover jump backwards by more than 13 hours.

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

ROOT CAUSE

The wrap uses a 32-bit modulus.

VERIFIED REPAIR

Wrap at 2^33 ticks.

Unsuccessful approach: A modulus one tick short misplaces every wrapped timestamp by a tick.

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<<32
    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: wrap modulus', [0, 90000, [25, 1]], [2386068, '02:30:42:18']), ('regression variant: wrap modulus', [35999, 126000, [24000, 1001]], [2288337, '02:29:07:09']), ('partial repair probe: wrap modulus', [8589934591, 0, [24000, 1001]], [2288361, '02:29:08:09']), ('partial repair variant: wrap modulus', [800, 8589933592, [25, 1]], [1, '00:00:00:01']), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('normal control', [100, 8589931092, [25, 1]], [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'])], [('regression: wrap modulus', [7775999000, 8589933592, [50, 1]], [4320000, '00:00:00:00']), ('regression variant: wrap modulus', [36000, 126000, [24000, 1001]], [2288337, '02:29:07:09']), ('partial repair probe: wrap modulus', [800, 8589933592, [25, 1]], [1, '00:00:00:01']), ('partial repair variant: wrap modulus', [8589934591, 0, [30000, 1001]], [2860451, '02:29:08:11']), ('boundary control', [100, 8589931092, [25, 1]], [1, '00:00:00:01']), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('normal control', [900001, 900000, [50, 1]], [0, '00:00:00:00']), ('normal control', [877, 8589933592, [50, 1]], [1, '00:00:00:01']), ('normal control', [324126000, 126000, [24000, 1001]], [86314, '00:59:56:10'])], [('regression: wrap modulus', [7775910000, 8589844592, [24000, 1001]], [2071528, '23:58:33:16']), ('regression variant: wrap modulus', [8586244592, 8589844592, [25, 1]], [2385093, '02:30:03:18']), ('partial repair probe: wrap modulus', [8589934591, 0, [30000, 1001]], [2860451, '02:29:08:11']), ('partial repair variant: wrap modulus', [502, 8589933592, [30000, 1001]], [1, '00:00:00:01']), ('boundary control', [0, 45000, [25, 1]], None), ('boundary control', [100, 8589931092, [25, 1]], [1, '00:00:00:01']), ('normal control', [126000, 126000, [25, 1]], [0, '00:00:00:00']), ('normal control', [324126000, 126000, [50, 1]], [180000, '01:00:00:00']), ('normal control', [3753, 0, [25, 1]], [1, '00:00:00:01'])], [('regression: wrap modulus', [8586333592, 8589933592, [30000, 1001]], [2859252, '02:28:28:12']), ('regression variant: wrap modulus', [7775910000, 8589844592, [25, 1]], [2160000, '00:00:00:00']), ('partial repair probe: wrap modulus', [502, 8589933592, [30000, 1001]], [1, '00:00:00:01']), ('partial repair variant: wrap modulus', [877, 8589933592, [24000, 1001]], [1, '00:00:00:01']), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('boundary control', [0, 45000, [25, 1]], None), ('normal control', [129600, 126000, [25, 1]], [1, '00:00:00:01']), ('normal control', [801, 8589933592, [30000, 1001]], [1, '00:00:00:01']), ('normal control', [323999000, 8589933592, [25, 1]], [90000, '01:00:00:00'])], [('regression: wrap modulus', [7776000000, 0, [50, 1]], [4320000, '00:00:00:00']), ('regression variant: wrap modulus', [810000, 900000, [30000, 1001]], [2860421, '02:29:07:11']), ('partial repair probe: wrap modulus', [877, 8589933592, [24000, 1001]], [1, '00:00:00:01']), ('partial repair variant: wrap modulus', [8589934591, 0, [25, 1]], [2386093, '02:30:43:18']), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('normal control', [810001, 900000, [24000, 1001]], None), ('normal control', [3754, 0, [25, 1]], [1, '00:00:00:01']), ('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: wrap modulus[1193021, '13:15:20:21'][2386068, '02:30:42:18']Failed
regression variant: wrap modulus[1144156, '13:14:33:04'][2288337, '02:29:07:09']Failed
partial repair probe: wrap modulus[1144180, '13:14:34:04'][2288361, '02:29:08:09']Failed
partial repair variant: wrap modulus[1, '00:00:00:01'][1, '00:00:00:01']Passed
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[1, '00:00:00:01'][1, '00:00:00:01']Passed
normal control[0, '00:00:00:00'][0, '00:00:00:00']Passed

SHA-256 / 72cf517f73bef704c26d88ab172ffda391bd8b90ca66d2c56efde8a40b118a64

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)-1
    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: wrap modulus', [0, 90000, [25, 1]], [2386068, '02:30:42:18']), ('regression variant: wrap modulus', [35999, 126000, [24000, 1001]], [2288337, '02:29:07:09']), ('partial repair probe: wrap modulus', [8589934591, 0, [24000, 1001]], [2288361, '02:29:08:09']), ('partial repair variant: wrap modulus', [800, 8589933592, [25, 1]], [1, '00:00:00:01']), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('normal control', [100, 8589931092, [25, 1]], [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'])], [('regression: wrap modulus', [7775999000, 8589933592, [50, 1]], [4320000, '00:00:00:00']), ('regression variant: wrap modulus', [36000, 126000, [24000, 1001]], [2288337, '02:29:07:09']), ('partial repair probe: wrap modulus', [800, 8589933592, [25, 1]], [1, '00:00:00:01']), ('partial repair variant: wrap modulus', [8589934591, 0, [30000, 1001]], [2860451, '02:29:08:11']), ('boundary control', [100, 8589931092, [25, 1]], [1, '00:00:00:01']), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('normal control', [900001, 900000, [50, 1]], [0, '00:00:00:00']), ('normal control', [877, 8589933592, [50, 1]], [1, '00:00:00:01']), ('normal control', [324126000, 126000, [24000, 1001]], [86314, '00:59:56:10'])], [('regression: wrap modulus', [7775910000, 8589844592, [24000, 1001]], [2071528, '23:58:33:16']), ('regression variant: wrap modulus', [8586244592, 8589844592, [25, 1]], [2385093, '02:30:03:18']), ('partial repair probe: wrap modulus', [8589934591, 0, [30000, 1001]], [2860451, '02:29:08:11']), ('partial repair variant: wrap modulus', [502, 8589933592, [30000, 1001]], [1, '00:00:00:01']), ('boundary control', [0, 45000, [25, 1]], None), ('boundary control', [100, 8589931092, [25, 1]], [1, '00:00:00:01']), ('normal control', [126000, 126000, [25, 1]], [0, '00:00:00:00']), ('normal control', [324126000, 126000, [50, 1]], [180000, '01:00:00:00']), ('normal control', [3753, 0, [25, 1]], [1, '00:00:00:01'])], [('regression: wrap modulus', [8586333592, 8589933592, [30000, 1001]], [2859252, '02:28:28:12']), ('regression variant: wrap modulus', [7775910000, 8589844592, [25, 1]], [2160000, '00:00:00:00']), ('partial repair probe: wrap modulus', [502, 8589933592, [30000, 1001]], [1, '00:00:00:01']), ('partial repair variant: wrap modulus', [877, 8589933592, [24000, 1001]], [1, '00:00:00:01']), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('boundary control', [0, 45000, [25, 1]], None), ('normal control', [129600, 126000, [25, 1]], [1, '00:00:00:01']), ('normal control', [801, 8589933592, [30000, 1001]], [1, '00:00:00:01']), ('normal control', [323999000, 8589933592, [25, 1]], [90000, '01:00:00:00'])], [('regression: wrap modulus', [7776000000, 0, [50, 1]], [4320000, '00:00:00:00']), ('regression variant: wrap modulus', [810000, 900000, [30000, 1001]], [2860421, '02:29:07:11']), ('partial repair probe: wrap modulus', [877, 8589933592, [24000, 1001]], [1, '00:00:00:01']), ('partial repair variant: wrap modulus', [8589934591, 0, [25, 1]], [2386093, '02:30:43:18']), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('normal control', [810001, 900000, [24000, 1001]], None), ('normal control', [3754, 0, [25, 1]], [1, '00:00:00:01']), ('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: wrap modulus[2386068, '02:30:42:18'][2386068, '02:30:42:18']Passed
regression variant: wrap modulus[2288337, '02:29:07:09'][2288337, '02:29:07:09']Passed
partial repair probe: wrap modulus[0, '00:00:00:00'][2288361, '02:29:08:09']Failed
partial repair variant: wrap modulus[0, '00:00:00:00'][1, '00:00:00:01']Failed
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[1, '00:00:00:01'][1, '00:00:00:01']Passed
normal control[0, '00:00:00:00'][0, '00:00:00:00']Passed

SHA-256 / 8bdd36f14b86d965629ca20d141b9ebf07f6937cf08c1009342ea768b3485446

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: wrap modulus', [0, 90000, [25, 1]], [2386068, '02:30:42:18']), ('regression variant: wrap modulus', [35999, 126000, [24000, 1001]], [2288337, '02:29:07:09']), ('partial repair probe: wrap modulus', [8589934591, 0, [24000, 1001]], [2288361, '02:29:08:09']), ('partial repair variant: wrap modulus', [800, 8589933592, [25, 1]], [1, '00:00:00:01']), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('normal control', [100, 8589931092, [25, 1]], [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'])], [('regression: wrap modulus', [7775999000, 8589933592, [50, 1]], [4320000, '00:00:00:00']), ('regression variant: wrap modulus', [36000, 126000, [24000, 1001]], [2288337, '02:29:07:09']), ('partial repair probe: wrap modulus', [800, 8589933592, [25, 1]], [1, '00:00:00:01']), ('partial repair variant: wrap modulus', [8589934591, 0, [30000, 1001]], [2860451, '02:29:08:11']), ('boundary control', [100, 8589931092, [25, 1]], [1, '00:00:00:01']), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('normal control', [900001, 900000, [50, 1]], [0, '00:00:00:00']), ('normal control', [877, 8589933592, [50, 1]], [1, '00:00:00:01']), ('normal control', [324126000, 126000, [24000, 1001]], [86314, '00:59:56:10'])], [('regression: wrap modulus', [7775910000, 8589844592, [24000, 1001]], [2071528, '23:58:33:16']), ('regression variant: wrap modulus', [8586244592, 8589844592, [25, 1]], [2385093, '02:30:03:18']), ('partial repair probe: wrap modulus', [8589934591, 0, [30000, 1001]], [2860451, '02:29:08:11']), ('partial repair variant: wrap modulus', [502, 8589933592, [30000, 1001]], [1, '00:00:00:01']), ('boundary control', [0, 45000, [25, 1]], None), ('boundary control', [100, 8589931092, [25, 1]], [1, '00:00:00:01']), ('normal control', [126000, 126000, [25, 1]], [0, '00:00:00:00']), ('normal control', [324126000, 126000, [50, 1]], [180000, '01:00:00:00']), ('normal control', [3753, 0, [25, 1]], [1, '00:00:00:01'])], [('regression: wrap modulus', [8586333592, 8589933592, [30000, 1001]], [2859252, '02:28:28:12']), ('regression variant: wrap modulus', [7775910000, 8589844592, [25, 1]], [2160000, '00:00:00:00']), ('partial repair probe: wrap modulus', [502, 8589933592, [30000, 1001]], [1, '00:00:00:01']), ('partial repair variant: wrap modulus', [877, 8589933592, [24000, 1001]], [1, '00:00:00:01']), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('boundary control', [0, 45000, [25, 1]], None), ('normal control', [129600, 126000, [25, 1]], [1, '00:00:00:01']), ('normal control', [801, 8589933592, [30000, 1001]], [1, '00:00:00:01']), ('normal control', [323999000, 8589933592, [25, 1]], [90000, '01:00:00:00'])], [('regression: wrap modulus', [7776000000, 0, [50, 1]], [4320000, '00:00:00:00']), ('regression variant: wrap modulus', [810000, 900000, [30000, 1001]], [2860421, '02:29:07:11']), ('partial repair probe: wrap modulus', [877, 8589933592, [24000, 1001]], [1, '00:00:00:01']), ('partial repair variant: wrap modulus', [8589934591, 0, [25, 1]], [2386093, '02:30:43:18']), ('boundary control', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('boundary control', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('normal control', [810001, 900000, [24000, 1001]], None), ('normal control', [3754, 0, [25, 1]], [1, '00:00:00:01']), ('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: wrap modulus[2386068, '02:30:42:18'][2386068, '02:30:42:18']Passed
regression variant: wrap modulus[2288337, '02:29:07:09'][2288337, '02:29:07:09']Passed
partial repair probe: wrap modulus[2288361, '02:29:08:09'][2288361, '02:29:08:09']Passed
partial repair variant: wrap modulus[1, '00:00:00:01'][1, '00:00:00:01']Passed
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[1, '00:00:00:01'][1, '00:00:00:01']Passed
normal control[0, '00:00:00:00'][0, '00:00:00:00']Passed

SHA-256 / 8f61e8b7a85923b7c9dd853971d88862095ffdb055edc4984286d6f1b45b8c7c

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

Case digest / 2baa51fd01e228abd2b009cec1f961aedd1c970347374d26e19f22df2ec9a5ef