FA-78831 / Broadcast timecode arithmetic / Open access
90 kHz presentation timestamp to frame label: nearest frame · case 01
Timestamps a few ticks before a frame boundary map to the previous frame.
ROOT CAUSE
The frame index is floored.
VERIFIED REPAIR
Round to the nearest frame with halves up.
Unsuccessful approach: Float half-to-even rounding still misplaces exact half-frame ticks.
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%WRAP
num,den=fps
n=d*num//(90000*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: nearest frame', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('regression variant: nearest frame', [877, 8589933592, [24000, 1001]], [1, '00:00:00:01']), ('partial repair probe: nearest frame', [8589846392, 8589844592, [25, 1]], [1, '00:00:00:01']), ('partial repair variant: nearest frame', [800, 8589933592, [25, 1]], [1, '00:00:00:01']), ('boundary control', [100, 8589931092, [25, 1]], [1, '00:00:00:01']), ('boundary control', [0, 45000, [25, 1]], None), ('normal control', [901502, 900000, [24000, 1001]], [0, '00:00:00:00']), ('normal control', [7775999000, 8589933592, [50, 1]], [4320000, '00:00:00:00']), ('normal control', [1801, 0, [50, 1]], [1, '00:00:00:01'])], [('regression: nearest frame', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('regression variant: nearest frame', [36000, 126000, [24000, 1001]], [2288337, '02:29:07:09']), ('partial repair probe: nearest frame', [901800, 900000, [25, 1]], [1, '00:00:00:01']), ('partial repair variant: nearest frame', [1800, 0, [25, 1]], [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', [900001, 900000, [50, 1]], [0, '00:00:00:00']), ('normal control', [8589846093, 8589844592, [25, 1]], [0, '00:00:00:00']), ('normal control', [3754, 0, [24000, 1001]], [1, '00:00:00:01'])], [('regression: nearest frame', [0, 90000, [25, 1]], [2386068, '02:30:42:18']), ('regression variant: nearest frame', [324126000, 126000, [24000, 1001]], [86314, '00:59:56:10']), ('partial repair probe: nearest frame', [800, 8589933592, [25, 1]], [1, '00:00:00:01']), ('partial repair variant: nearest frame', [127800, 126000, [25, 1]], [1, '00:00:00:01']), ('boundary control', [100, 8589931092, [25, 1]], [1, '00:00:00:01']), ('boundary control', [0, 45000, [25, 1]], None), ('normal control', [126000, 126000, [25, 1]], [0, '00:00:00:00']), ('normal control', [0, 0, [50, 1]], [0, '00:00:00:00']), ('normal control', [3753, 0, [50, 1]], [2, '00:00:00:02'])], [('regression: nearest frame', [127800, 126000, [25, 1]], [1, '00:00:00:01']), ('regression variant: nearest frame', [8586244592, 8589844592, [25, 1]], [2385093, '02:30:03:18']), ('partial repair probe: nearest frame', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('partial repair variant: nearest frame', [8589846392, 8589844592, [25, 1]], [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', [129754, 126000, [25, 1]], [1, '00:00:00:01']), ('normal control', [7776000000, 0, [24000, 1001]], [2071528, '23:58:33:16']), ('normal control', [8586460592, 126000, [30000, 1001]], [2859252, '02:28:28:12'])], [('regression: nearest frame', [35999, 126000, [24000, 1001]], [2288337, '02:29:07:09']), ('regression variant: nearest frame', [809999, 900000, [25, 1]], [2386068, '02:30:42:18']), ('partial repair probe: nearest frame', [127800, 126000, [25, 1]], [1, '00:00:00:01']), ('partial repair variant: nearest frame', [901800, 900000, [25, 1]], [1, '00:00:00:01']), ('boundary control', [100, 8589931092, [25, 1]], [1, '00:00:00:01']), ('boundary control', [0, 45000, [25, 1]], None), ('normal control', [810001, 900000, [24000, 1001]], None), ('normal control', [4294966296, 8589933592, [24000, 1001]], [1144180, '13:14:34:04']), ('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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: nearest frame | [0, '00:00:00:00'] | [1, '00:00:00:01'] | Failed |
| regression variant: nearest frame | [0, '00:00:00:00'] | [1, '00:00:00:01'] | Failed |
| partial repair probe: nearest frame | [0, '00:00:00:00'] | [1, '00:00:00:01'] | Failed |
| partial repair variant: nearest frame | [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 | None | None | Passed |
| normal control | [0, '00:00:00:00'] | [0, '00:00:00:00'] | Passed |
| normal control | [4320000, '00:00:00:00'] | [4320000, '00:00:00:00'] | Passed |
| normal control | [1, '00:00:00:01'] | [1, '00:00:00:01'] | Passed |
SHA-256 / 924be05df8a75d9889ee235f7e13789d3e717b8335692f85e481ebd8f8fd710d
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=raw%WRAP
num,den=fps
n=round(d*num/(90000*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: nearest frame', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('regression variant: nearest frame', [877, 8589933592, [24000, 1001]], [1, '00:00:00:01']), ('partial repair probe: nearest frame', [8589846392, 8589844592, [25, 1]], [1, '00:00:00:01']), ('partial repair variant: nearest frame', [800, 8589933592, [25, 1]], [1, '00:00:00:01']), ('boundary control', [100, 8589931092, [25, 1]], [1, '00:00:00:01']), ('boundary control', [0, 45000, [25, 1]], None), ('normal control', [901502, 900000, [24000, 1001]], [0, '00:00:00:00']), ('normal control', [7775999000, 8589933592, [50, 1]], [4320000, '00:00:00:00']), ('normal control', [1801, 0, [50, 1]], [1, '00:00:00:01'])], [('regression: nearest frame', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('regression variant: nearest frame', [36000, 126000, [24000, 1001]], [2288337, '02:29:07:09']), ('partial repair probe: nearest frame', [901800, 900000, [25, 1]], [1, '00:00:00:01']), ('partial repair variant: nearest frame', [1800, 0, [25, 1]], [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', [900001, 900000, [50, 1]], [0, '00:00:00:00']), ('normal control', [8589846093, 8589844592, [25, 1]], [0, '00:00:00:00']), ('normal control', [3754, 0, [24000, 1001]], [1, '00:00:00:01'])], [('regression: nearest frame', [0, 90000, [25, 1]], [2386068, '02:30:42:18']), ('regression variant: nearest frame', [324126000, 126000, [24000, 1001]], [86314, '00:59:56:10']), ('partial repair probe: nearest frame', [800, 8589933592, [25, 1]], [1, '00:00:00:01']), ('partial repair variant: nearest frame', [127800, 126000, [25, 1]], [1, '00:00:00:01']), ('boundary control', [100, 8589931092, [25, 1]], [1, '00:00:00:01']), ('boundary control', [0, 45000, [25, 1]], None), ('normal control', [126000, 126000, [25, 1]], [0, '00:00:00:00']), ('normal control', [0, 0, [50, 1]], [0, '00:00:00:00']), ('normal control', [3753, 0, [50, 1]], [2, '00:00:00:02'])], [('regression: nearest frame', [127800, 126000, [25, 1]], [1, '00:00:00:01']), ('regression variant: nearest frame', [8586244592, 8589844592, [25, 1]], [2385093, '02:30:03:18']), ('partial repair probe: nearest frame', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('partial repair variant: nearest frame', [8589846392, 8589844592, [25, 1]], [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', [129754, 126000, [25, 1]], [1, '00:00:00:01']), ('normal control', [7776000000, 0, [24000, 1001]], [2071528, '23:58:33:16']), ('normal control', [8586460592, 126000, [30000, 1001]], [2859252, '02:28:28:12'])], [('regression: nearest frame', [35999, 126000, [24000, 1001]], [2288337, '02:29:07:09']), ('regression variant: nearest frame', [809999, 900000, [25, 1]], [2386068, '02:30:42:18']), ('partial repair probe: nearest frame', [127800, 126000, [25, 1]], [1, '00:00:00:01']), ('partial repair variant: nearest frame', [901800, 900000, [25, 1]], [1, '00:00:00:01']), ('boundary control', [100, 8589931092, [25, 1]], [1, '00:00:00:01']), ('boundary control', [0, 45000, [25, 1]], None), ('normal control', [810001, 900000, [24000, 1001]], None), ('normal control', [4294966296, 8589933592, [24000, 1001]], [1144180, '13:14:34:04']), ('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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: nearest frame | [0, '00:00:00:00'] | [1, '00:00:00:01'] | Failed |
| regression variant: nearest frame | [1, '00:00:00:01'] | [1, '00:00:00:01'] | Passed |
| partial repair probe: nearest frame | [0, '00:00:00:00'] | [1, '00:00:00:01'] | Failed |
| partial repair variant: nearest frame | [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 | None | None | Passed |
| normal control | [0, '00:00:00:00'] | [0, '00:00:00:00'] | Passed |
| normal control | [4320000, '00:00:00:00'] | [4320000, '00:00:00:00'] | Passed |
| normal control | [1, '00:00:00:01'] | [1, '00:00:00:01'] | Passed |
SHA-256 / 51302013c58ca53ab8d70ed24e54c6ab66281e70ed8e4782f1c8c07b0cf6c30c
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: nearest frame', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('regression variant: nearest frame', [877, 8589933592, [24000, 1001]], [1, '00:00:00:01']), ('partial repair probe: nearest frame', [8589846392, 8589844592, [25, 1]], [1, '00:00:00:01']), ('partial repair variant: nearest frame', [800, 8589933592, [25, 1]], [1, '00:00:00:01']), ('boundary control', [100, 8589931092, [25, 1]], [1, '00:00:00:01']), ('boundary control', [0, 45000, [25, 1]], None), ('normal control', [901502, 900000, [24000, 1001]], [0, '00:00:00:00']), ('normal control', [7775999000, 8589933592, [50, 1]], [4320000, '00:00:00:00']), ('normal control', [1801, 0, [50, 1]], [1, '00:00:00:01'])], [('regression: nearest frame', [1502, 0, [30000, 1001]], [1, '00:00:00:01']), ('regression variant: nearest frame', [36000, 126000, [24000, 1001]], [2288337, '02:29:07:09']), ('partial repair probe: nearest frame', [901800, 900000, [25, 1]], [1, '00:00:00:01']), ('partial repair variant: nearest frame', [1800, 0, [25, 1]], [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', [900001, 900000, [50, 1]], [0, '00:00:00:00']), ('normal control', [8589846093, 8589844592, [25, 1]], [0, '00:00:00:00']), ('normal control', [3754, 0, [24000, 1001]], [1, '00:00:00:01'])], [('regression: nearest frame', [0, 90000, [25, 1]], [2386068, '02:30:42:18']), ('regression variant: nearest frame', [324126000, 126000, [24000, 1001]], [86314, '00:59:56:10']), ('partial repair probe: nearest frame', [800, 8589933592, [25, 1]], [1, '00:00:00:01']), ('partial repair variant: nearest frame', [127800, 126000, [25, 1]], [1, '00:00:00:01']), ('boundary control', [100, 8589931092, [25, 1]], [1, '00:00:00:01']), ('boundary control', [0, 45000, [25, 1]], None), ('normal control', [126000, 126000, [25, 1]], [0, '00:00:00:00']), ('normal control', [0, 0, [50, 1]], [0, '00:00:00:00']), ('normal control', [3753, 0, [50, 1]], [2, '00:00:00:02'])], [('regression: nearest frame', [127800, 126000, [25, 1]], [1, '00:00:00:01']), ('regression variant: nearest frame', [8586244592, 8589844592, [25, 1]], [2385093, '02:30:03:18']), ('partial repair probe: nearest frame', [1800, 0, [25, 1]], [1, '00:00:00:01']), ('partial repair variant: nearest frame', [8589846392, 8589844592, [25, 1]], [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', [129754, 126000, [25, 1]], [1, '00:00:00:01']), ('normal control', [7776000000, 0, [24000, 1001]], [2071528, '23:58:33:16']), ('normal control', [8586460592, 126000, [30000, 1001]], [2859252, '02:28:28:12'])], [('regression: nearest frame', [35999, 126000, [24000, 1001]], [2288337, '02:29:07:09']), ('regression variant: nearest frame', [809999, 900000, [25, 1]], [2386068, '02:30:42:18']), ('partial repair probe: nearest frame', [127800, 126000, [25, 1]], [1, '00:00:00:01']), ('partial repair variant: nearest frame', [901800, 900000, [25, 1]], [1, '00:00:00:01']), ('boundary control', [100, 8589931092, [25, 1]], [1, '00:00:00:01']), ('boundary control', [0, 45000, [25, 1]], None), ('normal control', [810001, 900000, [24000, 1001]], None), ('normal control', [4294966296, 8589933592, [24000, 1001]], [1144180, '13:14:34:04']), ('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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: nearest frame | [1, '00:00:00:01'] | [1, '00:00:00:01'] | Passed |
| regression variant: nearest frame | [1, '00:00:00:01'] | [1, '00:00:00:01'] | Passed |
| partial repair probe: nearest frame | [1, '00:00:00:01'] | [1, '00:00:00:01'] | Passed |
| partial repair variant: nearest frame | [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 | None | None | Passed |
| normal control | [0, '00:00:00:00'] | [0, '00:00:00:00'] | Passed |
| normal control | [4320000, '00:00:00:00'] | [4320000, '00:00:00:00'] | Passed |
| normal control | [1, '00:00:00:01'] | [1, '00:00:00:01'] | Passed |
SHA-256 / 1973c456628a182fb374ef78592625edb07e5c31f5425a2a407bf119ffd1e92d
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:39.007854+00:00.
Case digest / 5ee417ace61fbf72ff782da6b8c473b54beaaf495e5c93484fa9cd8c35fe6092