FA-78811 / Broadcast timecode arithmetic / Open access
Chase-lock offset with subframes: day length in subframes · case 01
Offsets across midnight are wrapped at a fraction of the day.
ROOT CAUSE
The day length omits the subframe scale.
VERIFIED REPAIR
The day is 86400*fps*100 subframes.
Unsuccessful approach: Omitting the frame rate wraps at 1/fps of a day.
Case contract
Labels HH:MM:SS:FF.s where s is one or two digits of hundredths of a frame (".5" means 50). Return the offset from a to b as [frames, subframes] along the shorter way round 24 hours (exactly 12 hours is positive), with both components carrying the sign and 0 <= |subframes| < 100.
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(a, b, fps):
def parse(t):
main,sub=t.split('.')
h,m,s,f=map(int,main.split(':'))
return (((h*60+m)*60+s)*fps+f)*100+int(sub.ljust(2,'0'))
day=86400*fps
d=(parse(b)-parse(a))%day
if d>day//2:
d-=day
sign=-1 if d<0 else 1
q,r=divmod(abs(d),100)
return [sign*q,sign*r]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: day length in subframes', ['00:00:00:00.0', '12:00:00:00.0', 25], [1080000, 0]), ('regression variant: day length in subframes', ['23:00:00:00.99', '00:00:59:01.99', 30], [109771, 0]), ('partial repair probe: day length in subframes', ['12:30:30:01.00', '23:30:00:24.05', 25], [989273, 5]), ('partial repair variant: day length in subframes', ['01:00:30:00.99', '23:30:00:29.50', 30], [-162871, -49]), ('boundary control', ['00:00:00:00.00', '00:00:00:01.50', 25], [1, 50]), ('boundary control', ['00:00:00:01.50', '00:00:00:00.00', 25], [-1, -50]), ('normal control', ['23:59:59:24.5', '00:00:00:00.0', 25], [0, 50]), ('normal control', ['23:00:00:24.50', '23:00:30:01.99', 25], [727, 49]), ('normal control', ['23:59:30:01.50', '23:59:00:01.0', 30], [-900, -50])], [('regression: day length in subframes', ['00:59:59:00.5', '01:59:00:29.50', 30], [106259, 0]), ('regression variant: day length in subframes', ['01:00:59:01.5', '01:59:30:01.5', 25], [87775, 0]), ('partial repair probe: day length in subframes', ['00:30:59:00.0', '12:30:59:00.0', 30], [1296000, 0]), ('partial repair variant: day length in subframes', ['01:00:59:24.00', '01:59:00:24.99', 25], [87025, 99]), ('boundary control', ['00:00:00:01.50', '00:00:00:00.00', 25], [-1, -50]), ('boundary control', ['23:59:59:24.5', '00:00:00:00.0', 25], [0, 50]), ('normal control', ['01:00:00:29.5', '01:00:00:00.5', 30], [-29, 0]), ('normal control', ['23:00:00:29.50', '23:00:59:00.5', 30], [1741, 0]), ('normal control', ['00:00:59:29.0', '00:00:59:00.0', 30], [-29, 0])], [('regression: day length in subframes', ['12:30:30:01.00', '23:30:00:24.05', 25], [989273, 5]), ('regression variant: day length in subframes', ['23:59:00:24.5', '00:30:59:01.0', 25], [47951, 50]), ('partial repair probe: day length in subframes', ['01:30:59:29.05', '13:30:59:29.05', 30], [1296000, 0]), ('partial repair variant: day length in subframes', ['01:59:30:29.50', '01:30:30:29.0', 30], [-52200, -50]), ('boundary control', ['23:59:59:24.5', '00:00:00:00.0', 25], [0, 50]), ('boundary control', ['00:00:00:00.00', '00:00:00:01.50', 25], [1, 50]), ('normal control', ['23:00:30:00.50', '23:00:30:01.0', 25], [0, 50]), ('normal control', ['23:59:59:01.50', '23:59:59:01.05', 30], [0, -45]), ('normal control', ['00:59:30:00.99', '00:59:30:01.50', 30], [0, 51])], [('regression: day length in subframes', ['00:30:59:00.0', '12:30:59:00.0', 30], [1296000, 0]), ('regression variant: day length in subframes', ['01:00:59:29.50', '00:30:30:29.99', 30], [-54869, -51]), ('partial repair probe: day length in subframes', ['23:00:00:00.99', '00:00:59:01.99', 30], [109771, 0]), ('partial repair variant: day length in subframes', ['23:30:59:00.5', '23:59:30:01.00', 30], [51330, 50]), ('boundary control', ['00:00:00:00.00', '00:00:00:01.50', 25], [1, 50]), ('boundary control', ['00:00:00:01.50', '00:00:00:00.00', 25], [-1, -50]), ('normal control', ['00:00:00:01.05', '23:59:30:01.00', 25], [-750, -5]), ('normal control', ['23:00:59:24.0', '23:00:59:00.0', 25], [-24, 0]), ('normal control', ['00:00:00:00.5', '00:00:00:00.0', 25], [0, -50])], [('regression: day length in subframes', ['01:30:59:29.05', '13:30:59:29.05', 30], [1296000, 0]), ('regression variant: day length in subframes', ['01:00:30:00.99', '23:30:00:29.50', 30], [-162871, -49]), ('partial repair probe: day length in subframes', ['01:00:59:01.5', '01:59:30:01.5', 25], [87775, 0]), ('partial repair variant: day length in subframes', ['12:59:30:01.50', '00:59:59:00.05', 30], [-1295131, -45]), ('boundary control', ['00:00:00:01.50', '00:00:00:00.00', 25], [-1, -50]), ('boundary control', ['23:59:59:24.5', '00:00:00:00.0', 25], [0, 50]), ('normal control', ['23:30:30:29.50', '23:30:00:00.5', 30], [-929, 0]), ('normal control', ['00:00:59:00.05', '23:59:30:00.50', 25], [-2224, -55]), ('normal control', ['00:00:00:01.99', '23:59:59:29.5', 30], [-2, -49])]]
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: day length in subframes | [0, 0] | [1080000, 0] | Failed |
| regression variant: day length in subframes | [6091, 0] | [109771, 0] | Failed |
| partial repair probe: day length in subframes | [-4326, -95] | [989273, 5] | Failed |
| partial repair variant: day length in subframes | [-7351, -49] | [-162871, -49] | Failed |
| boundary control | [1, 50] | [1, 50] | Passed |
| boundary control | [-1, -50] | [-1, -50] | Passed |
| normal control | [0, 50] | [0, 50] | Passed |
| normal control | [727, 49] | [727, 49] | Passed |
| normal control | [-900, -50] | [-900, -50] | Passed |
SHA-256 / 8fed5e7818c562f2076d7675dc263c0d8280eaee0b813187c5356f48a690cd7d
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(a, b, fps):
def parse(t):
main,sub=t.split('.')
h,m,s,f=map(int,main.split(':'))
return (((h*60+m)*60+s)*fps+f)*100+int(sub.ljust(2,'0'))
day=86400*100
d=(parse(b)-parse(a))%day
if d>day//2:
d-=day
sign=-1 if d<0 else 1
q,r=divmod(abs(d),100)
return [sign*q,sign*r]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: day length in subframes', ['00:00:00:00.0', '12:00:00:00.0', 25], [1080000, 0]), ('regression variant: day length in subframes', ['23:00:00:00.99', '00:00:59:01.99', 30], [109771, 0]), ('partial repair probe: day length in subframes', ['12:30:30:01.00', '23:30:00:24.05', 25], [989273, 5]), ('partial repair variant: day length in subframes', ['01:00:30:00.99', '23:30:00:29.50', 30], [-162871, -49]), ('boundary control', ['00:00:00:00.00', '00:00:00:01.50', 25], [1, 50]), ('boundary control', ['00:00:00:01.50', '00:00:00:00.00', 25], [-1, -50]), ('normal control', ['23:59:59:24.5', '00:00:00:00.0', 25], [0, 50]), ('normal control', ['23:00:00:24.50', '23:00:30:01.99', 25], [727, 49]), ('normal control', ['23:59:30:01.50', '23:59:00:01.0', 30], [-900, -50])], [('regression: day length in subframes', ['00:59:59:00.5', '01:59:00:29.50', 30], [106259, 0]), ('regression variant: day length in subframes', ['01:00:59:01.5', '01:59:30:01.5', 25], [87775, 0]), ('partial repair probe: day length in subframes', ['00:30:59:00.0', '12:30:59:00.0', 30], [1296000, 0]), ('partial repair variant: day length in subframes', ['01:00:59:24.00', '01:59:00:24.99', 25], [87025, 99]), ('boundary control', ['00:00:00:01.50', '00:00:00:00.00', 25], [-1, -50]), ('boundary control', ['23:59:59:24.5', '00:00:00:00.0', 25], [0, 50]), ('normal control', ['01:00:00:29.5', '01:00:00:00.5', 30], [-29, 0]), ('normal control', ['23:00:00:29.50', '23:00:59:00.5', 30], [1741, 0]), ('normal control', ['00:00:59:29.0', '00:00:59:00.0', 30], [-29, 0])], [('regression: day length in subframes', ['12:30:30:01.00', '23:30:00:24.05', 25], [989273, 5]), ('regression variant: day length in subframes', ['23:59:00:24.5', '00:30:59:01.0', 25], [47951, 50]), ('partial repair probe: day length in subframes', ['01:30:59:29.05', '13:30:59:29.05', 30], [1296000, 0]), ('partial repair variant: day length in subframes', ['01:59:30:29.50', '01:30:30:29.0', 30], [-52200, -50]), ('boundary control', ['23:59:59:24.5', '00:00:00:00.0', 25], [0, 50]), ('boundary control', ['00:00:00:00.00', '00:00:00:01.50', 25], [1, 50]), ('normal control', ['23:00:30:00.50', '23:00:30:01.0', 25], [0, 50]), ('normal control', ['23:59:59:01.50', '23:59:59:01.05', 30], [0, -45]), ('normal control', ['00:59:30:00.99', '00:59:30:01.50', 30], [0, 51])], [('regression: day length in subframes', ['00:30:59:00.0', '12:30:59:00.0', 30], [1296000, 0]), ('regression variant: day length in subframes', ['01:00:59:29.50', '00:30:30:29.99', 30], [-54869, -51]), ('partial repair probe: day length in subframes', ['23:00:00:00.99', '00:00:59:01.99', 30], [109771, 0]), ('partial repair variant: day length in subframes', ['23:30:59:00.5', '23:59:30:01.00', 30], [51330, 50]), ('boundary control', ['00:00:00:00.00', '00:00:00:01.50', 25], [1, 50]), ('boundary control', ['00:00:00:01.50', '00:00:00:00.00', 25], [-1, -50]), ('normal control', ['00:00:00:01.05', '23:59:30:01.00', 25], [-750, -5]), ('normal control', ['23:00:59:24.0', '23:00:59:00.0', 25], [-24, 0]), ('normal control', ['00:00:00:00.5', '00:00:00:00.0', 25], [0, -50])], [('regression: day length in subframes', ['01:30:59:29.05', '13:30:59:29.05', 30], [1296000, 0]), ('regression variant: day length in subframes', ['01:00:30:00.99', '23:30:00:29.50', 30], [-162871, -49]), ('partial repair probe: day length in subframes', ['01:00:59:01.5', '01:59:30:01.5', 25], [87775, 0]), ('partial repair variant: day length in subframes', ['12:59:30:01.50', '00:59:59:00.05', 30], [-1295131, -45]), ('boundary control', ['00:00:00:01.50', '00:00:00:00.00', 25], [-1, -50]), ('boundary control', ['23:59:59:24.5', '00:00:00:00.0', 25], [0, 50]), ('normal control', ['23:30:30:29.50', '23:30:00:00.5', 30], [-929, 0]), ('normal control', ['00:00:59:00.05', '23:59:30:00.50', 25], [-2224, -55]), ('normal control', ['00:00:00:01.99', '23:59:59:29.5', 30], [-2, -49])]]
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: day length in subframes | [43200, 0] | [1080000, 0] | Failed |
| regression variant: day length in subframes | [23371, 0] | [109771, 0] | Failed |
| partial repair probe: day length in subframes | [38873, 5] | [989273, 5] | Failed |
| partial repair variant: day length in subframes | [9928, 51] | [-162871, -49] | Failed |
| boundary control | [1, 50] | [1, 50] | Passed |
| boundary control | [-1, -50] | [-1, -50] | Passed |
| normal control | [0, 50] | [0, 50] | Passed |
| normal control | [727, 49] | [727, 49] | Passed |
| normal control | [-900, -50] | [-900, -50] | Passed |
SHA-256 / 2024bc7c0c32e7f2c3d99a617a8326eb01a99a72e3e2a5cd26ceb97353211230
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(a, b, fps):
def parse(t):
main,sub=t.split('.')
h,m,s,f=map(int,main.split(':'))
return (((h*60+m)*60+s)*fps+f)*100+int(sub.ljust(2,'0'))
day=86400*fps*100
d=(parse(b)-parse(a))%day
if d>day//2:
d-=day
sign=-1 if d<0 else 1
q,r=divmod(abs(d),100)
return [sign*q,sign*r]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: day length in subframes', ['00:00:00:00.0', '12:00:00:00.0', 25], [1080000, 0]), ('regression variant: day length in subframes', ['23:00:00:00.99', '00:00:59:01.99', 30], [109771, 0]), ('partial repair probe: day length in subframes', ['12:30:30:01.00', '23:30:00:24.05', 25], [989273, 5]), ('partial repair variant: day length in subframes', ['01:00:30:00.99', '23:30:00:29.50', 30], [-162871, -49]), ('boundary control', ['00:00:00:00.00', '00:00:00:01.50', 25], [1, 50]), ('boundary control', ['00:00:00:01.50', '00:00:00:00.00', 25], [-1, -50]), ('normal control', ['23:59:59:24.5', '00:00:00:00.0', 25], [0, 50]), ('normal control', ['23:00:00:24.50', '23:00:30:01.99', 25], [727, 49]), ('normal control', ['23:59:30:01.50', '23:59:00:01.0', 30], [-900, -50])], [('regression: day length in subframes', ['00:59:59:00.5', '01:59:00:29.50', 30], [106259, 0]), ('regression variant: day length in subframes', ['01:00:59:01.5', '01:59:30:01.5', 25], [87775, 0]), ('partial repair probe: day length in subframes', ['00:30:59:00.0', '12:30:59:00.0', 30], [1296000, 0]), ('partial repair variant: day length in subframes', ['01:00:59:24.00', '01:59:00:24.99', 25], [87025, 99]), ('boundary control', ['00:00:00:01.50', '00:00:00:00.00', 25], [-1, -50]), ('boundary control', ['23:59:59:24.5', '00:00:00:00.0', 25], [0, 50]), ('normal control', ['01:00:00:29.5', '01:00:00:00.5', 30], [-29, 0]), ('normal control', ['23:00:00:29.50', '23:00:59:00.5', 30], [1741, 0]), ('normal control', ['00:00:59:29.0', '00:00:59:00.0', 30], [-29, 0])], [('regression: day length in subframes', ['12:30:30:01.00', '23:30:00:24.05', 25], [989273, 5]), ('regression variant: day length in subframes', ['23:59:00:24.5', '00:30:59:01.0', 25], [47951, 50]), ('partial repair probe: day length in subframes', ['01:30:59:29.05', '13:30:59:29.05', 30], [1296000, 0]), ('partial repair variant: day length in subframes', ['01:59:30:29.50', '01:30:30:29.0', 30], [-52200, -50]), ('boundary control', ['23:59:59:24.5', '00:00:00:00.0', 25], [0, 50]), ('boundary control', ['00:00:00:00.00', '00:00:00:01.50', 25], [1, 50]), ('normal control', ['23:00:30:00.50', '23:00:30:01.0', 25], [0, 50]), ('normal control', ['23:59:59:01.50', '23:59:59:01.05', 30], [0, -45]), ('normal control', ['00:59:30:00.99', '00:59:30:01.50', 30], [0, 51])], [('regression: day length in subframes', ['00:30:59:00.0', '12:30:59:00.0', 30], [1296000, 0]), ('regression variant: day length in subframes', ['01:00:59:29.50', '00:30:30:29.99', 30], [-54869, -51]), ('partial repair probe: day length in subframes', ['23:00:00:00.99', '00:00:59:01.99', 30], [109771, 0]), ('partial repair variant: day length in subframes', ['23:30:59:00.5', '23:59:30:01.00', 30], [51330, 50]), ('boundary control', ['00:00:00:00.00', '00:00:00:01.50', 25], [1, 50]), ('boundary control', ['00:00:00:01.50', '00:00:00:00.00', 25], [-1, -50]), ('normal control', ['00:00:00:01.05', '23:59:30:01.00', 25], [-750, -5]), ('normal control', ['23:00:59:24.0', '23:00:59:00.0', 25], [-24, 0]), ('normal control', ['00:00:00:00.5', '00:00:00:00.0', 25], [0, -50])], [('regression: day length in subframes', ['01:30:59:29.05', '13:30:59:29.05', 30], [1296000, 0]), ('regression variant: day length in subframes', ['01:00:30:00.99', '23:30:00:29.50', 30], [-162871, -49]), ('partial repair probe: day length in subframes', ['01:00:59:01.5', '01:59:30:01.5', 25], [87775, 0]), ('partial repair variant: day length in subframes', ['12:59:30:01.50', '00:59:59:00.05', 30], [-1295131, -45]), ('boundary control', ['00:00:00:01.50', '00:00:00:00.00', 25], [-1, -50]), ('boundary control', ['23:59:59:24.5', '00:00:00:00.0', 25], [0, 50]), ('normal control', ['23:30:30:29.50', '23:30:00:00.5', 30], [-929, 0]), ('normal control', ['00:00:59:00.05', '23:59:30:00.50', 25], [-2224, -55]), ('normal control', ['00:00:00:01.99', '23:59:59:29.5', 30], [-2, -49])]]
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: day length in subframes | [1080000, 0] | [1080000, 0] | Passed |
| regression variant: day length in subframes | [109771, 0] | [109771, 0] | Passed |
| partial repair probe: day length in subframes | [989273, 5] | [989273, 5] | Passed |
| partial repair variant: day length in subframes | [-162871, -49] | [-162871, -49] | Passed |
| boundary control | [1, 50] | [1, 50] | Passed |
| boundary control | [-1, -50] | [-1, -50] | Passed |
| normal control | [0, 50] | [0, 50] | Passed |
| normal control | [727, 49] | [727, 49] | Passed |
| normal control | [-900, -50] | [-900, -50] | Passed |
SHA-256 / 1b23a78563bb8834dda647977287706b34842c0245f0616c96c922ffc56ee98c
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.653025+00:00.
Case digest / 4f5d7eea29c6fe0e198af590add781ee285d5989c85c65c700f6a2efd069c8c8