FA-78801 / Broadcast timecode arithmetic / Open access
Chase-lock offset with subframes: subframe sign · case 01
Negative offsets carry a positive subframe part.
ROOT CAUSE
The sign is not applied to the subframe component.
VERIFIED REPAIR
Apply the sign to both components.
Unsuccessful approach: Signing the subframes only when there are no whole frames still mixes signs.
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*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,r]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: subframe sign', ['00:00:00:01.50', '00:00:00:00.00', 25], [-1, -50]), ('regression variant: subframe sign', ['01:30:00:00.5', '01:00:59:00.05', 30], [-52230, -45]), ('partial repair probe: subframe sign', ['01:00:30:00.99', '23:30:00:29.50', 30], [-162871, -49]), ('partial repair variant: subframe sign', ['00:59:30:00.99', '23:30:30:00.50', 30], [-160200, -49]), ('boundary control', ['00:00:00:00.00', '00:00:00:01.50', 25], [1, 50]), ('boundary control', ['00:00:00:00.0', '12:00:00:00.0', 25], [1080000, 0]), ('normal control', ['23:59:59:24.5', '00:00:00:00.0', 25], [0, 50]), ('normal control', ['00:59:59:00.5', '01:59:00:29.50', 30], [106259, 0]), ('normal control', ['00:30:59:00.0', '12:30:59:00.0', 30], [1296000, 0])], [('regression: subframe sign', ['01:00:59:29.50', '00:30:30:29.99', 30], [-54869, -51]), ('regression variant: subframe sign', ['00:59:00:29.00', '00:00:00:01.05', 30], [-106227, -95]), ('partial repair probe: subframe sign', ['01:59:30:29.50', '01:30:30:29.0', 30], [-52200, -50]), ('partial repair variant: subframe sign', ['23:59:30:01.50', '23:59:00:01.0', 30], [-900, -50]), ('boundary control', ['00:00:00:00.0', '12:00:00:00.0', 25], [1080000, 0]), ('boundary control', ['23:59:59:24.5', '00:00:00:00.0', 25], [0, 50]), ('normal control', ['01:30:59:29.05', '13:30:59:29.05', 30], [1296000, 0]), ('normal control', ['23:59:00:24.5', '00:30:59:01.0', 25], [47951, 50]), ('normal control', ['23:30:59:00.5', '23:59:30:01.00', 30], [51330, 50])], [('regression: subframe sign', ['01:00:30:00.99', '23:30:00:29.50', 30], [-162871, -49]), ('regression variant: subframe sign', ['12:00:59:01.50', '01:00:00:01.05', 25], [-991475, -45]), ('partial repair probe: subframe sign', ['12:59:30:01.50', '00:59:59:00.05', 30], [-1295131, -45]), ('partial repair variant: subframe sign', ['01:30:59:00.50', '23:30:30:29.0', 30], [-216841, -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', ['00:00:00:01.05', '23:00:00:01.05', 25], [-90000, 0]), ('normal control', ['00:00:00:29.05', '12:00:00:29.05', 30], [1296000, 0]), ('normal control', ['00:59:30:01.5', '23:00:00:29.50', 30], [-215072, 0])], [('regression: subframe sign', ['01:59:30:29.50', '01:30:30:29.0', 30], [-52200, -50]), ('regression variant: subframe sign', ['01:30:00:00.0', '01:00:59:24.99', 25], [-43500, -1]), ('partial repair probe: subframe sign', ['01:30:00:00.5', '01:00:59:00.05', 30], [-52230, -45]), ('partial repair variant: subframe sign', ['00:59:30:01.50', '00:59:00:01.00', 30], [-900, -50]), ('boundary control', ['00:00:00:00.00', '00:00:00:01.50', 25], [1, 50]), ('boundary control', ['00:00:00:00.0', '12:00:00:00.0', 25], [1080000, 0]), ('normal control', ['23:00:00:00.05', '23:30:00:01.0', 30], [54000, 95]), ('normal control', ['00:30:00:01.0', '01:00:00:01.0', 30], [54000, 0]), ('normal control', ['00:00:59:00.00', '23:00:00:01.0', 30], [-109769, 0])], [('regression: subframe sign', ['12:59:30:01.50', '00:59:59:00.05', 30], [-1295131, -45]), ('regression variant: subframe sign', ['00:59:30:00.99', '23:30:30:00.50', 30], [-160200, -49]), ('partial repair probe: subframe sign', ['00:59:00:29.00', '00:00:00:01.05', 30], [-106227, -95]), ('partial repair variant: subframe sign', ['12:30:59:00.5', '12:00:59:01.99', 25], [-44998, -51]), ('boundary control', ['00:00:00:00.0', '12:00:00:00.0', 25], [1080000, 0]), ('boundary control', ['23:59:59:24.5', '00:00:00:00.0', 25], [0, 50]), ('normal control', ['01:30:00:24.50', '12:59:00:01.5', 25], [1033477, 0]), ('normal control', ['23:00:59:01.5', '01:30:00:00.0', 30], [268228, 50]), ('normal control', ['00:59:30:01.0', '12:59:30:01.0', 30], [1296000, 0])]]
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: subframe sign | [-1, 50] | [-1, -50] | Failed |
| regression variant: subframe sign | [-52230, 45] | [-52230, -45] | Failed |
| partial repair probe: subframe sign | [-162871, 49] | [-162871, -49] | Failed |
| partial repair variant: subframe sign | [-160200, 49] | [-160200, -49] | Failed |
| boundary control | [1, 50] | [1, 50] | Passed |
| boundary control | [1080000, 0] | [1080000, 0] | Passed |
| normal control | [0, 50] | [0, 50] | Passed |
| normal control | [106259, 0] | [106259, 0] | Passed |
| normal control | [1296000, 0] | [1296000, 0] | Passed |
SHA-256 / be06220384be1117d9615863014bd594261b6e18a9762ade8fa744783ecb88b0
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*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 if q==0 else r]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: subframe sign', ['00:00:00:01.50', '00:00:00:00.00', 25], [-1, -50]), ('regression variant: subframe sign', ['01:30:00:00.5', '01:00:59:00.05', 30], [-52230, -45]), ('partial repair probe: subframe sign', ['01:00:30:00.99', '23:30:00:29.50', 30], [-162871, -49]), ('partial repair variant: subframe sign', ['00:59:30:00.99', '23:30:30:00.50', 30], [-160200, -49]), ('boundary control', ['00:00:00:00.00', '00:00:00:01.50', 25], [1, 50]), ('boundary control', ['00:00:00:00.0', '12:00:00:00.0', 25], [1080000, 0]), ('normal control', ['23:59:59:24.5', '00:00:00:00.0', 25], [0, 50]), ('normal control', ['00:59:59:00.5', '01:59:00:29.50', 30], [106259, 0]), ('normal control', ['00:30:59:00.0', '12:30:59:00.0', 30], [1296000, 0])], [('regression: subframe sign', ['01:00:59:29.50', '00:30:30:29.99', 30], [-54869, -51]), ('regression variant: subframe sign', ['00:59:00:29.00', '00:00:00:01.05', 30], [-106227, -95]), ('partial repair probe: subframe sign', ['01:59:30:29.50', '01:30:30:29.0', 30], [-52200, -50]), ('partial repair variant: subframe sign', ['23:59:30:01.50', '23:59:00:01.0', 30], [-900, -50]), ('boundary control', ['00:00:00:00.0', '12:00:00:00.0', 25], [1080000, 0]), ('boundary control', ['23:59:59:24.5', '00:00:00:00.0', 25], [0, 50]), ('normal control', ['01:30:59:29.05', '13:30:59:29.05', 30], [1296000, 0]), ('normal control', ['23:59:00:24.5', '00:30:59:01.0', 25], [47951, 50]), ('normal control', ['23:30:59:00.5', '23:59:30:01.00', 30], [51330, 50])], [('regression: subframe sign', ['01:00:30:00.99', '23:30:00:29.50', 30], [-162871, -49]), ('regression variant: subframe sign', ['12:00:59:01.50', '01:00:00:01.05', 25], [-991475, -45]), ('partial repair probe: subframe sign', ['12:59:30:01.50', '00:59:59:00.05', 30], [-1295131, -45]), ('partial repair variant: subframe sign', ['01:30:59:00.50', '23:30:30:29.0', 30], [-216841, -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', ['00:00:00:01.05', '23:00:00:01.05', 25], [-90000, 0]), ('normal control', ['00:00:00:29.05', '12:00:00:29.05', 30], [1296000, 0]), ('normal control', ['00:59:30:01.5', '23:00:00:29.50', 30], [-215072, 0])], [('regression: subframe sign', ['01:59:30:29.50', '01:30:30:29.0', 30], [-52200, -50]), ('regression variant: subframe sign', ['01:30:00:00.0', '01:00:59:24.99', 25], [-43500, -1]), ('partial repair probe: subframe sign', ['01:30:00:00.5', '01:00:59:00.05', 30], [-52230, -45]), ('partial repair variant: subframe sign', ['00:59:30:01.50', '00:59:00:01.00', 30], [-900, -50]), ('boundary control', ['00:00:00:00.00', '00:00:00:01.50', 25], [1, 50]), ('boundary control', ['00:00:00:00.0', '12:00:00:00.0', 25], [1080000, 0]), ('normal control', ['23:00:00:00.05', '23:30:00:01.0', 30], [54000, 95]), ('normal control', ['00:30:00:01.0', '01:00:00:01.0', 30], [54000, 0]), ('normal control', ['00:00:59:00.00', '23:00:00:01.0', 30], [-109769, 0])], [('regression: subframe sign', ['12:59:30:01.50', '00:59:59:00.05', 30], [-1295131, -45]), ('regression variant: subframe sign', ['00:59:30:00.99', '23:30:30:00.50', 30], [-160200, -49]), ('partial repair probe: subframe sign', ['00:59:00:29.00', '00:00:00:01.05', 30], [-106227, -95]), ('partial repair variant: subframe sign', ['12:30:59:00.5', '12:00:59:01.99', 25], [-44998, -51]), ('boundary control', ['00:00:00:00.0', '12:00:00:00.0', 25], [1080000, 0]), ('boundary control', ['23:59:59:24.5', '00:00:00:00.0', 25], [0, 50]), ('normal control', ['01:30:00:24.50', '12:59:00:01.5', 25], [1033477, 0]), ('normal control', ['23:00:59:01.5', '01:30:00:00.0', 30], [268228, 50]), ('normal control', ['00:59:30:01.0', '12:59:30:01.0', 30], [1296000, 0])]]
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: subframe sign | [-1, 50] | [-1, -50] | Failed |
| regression variant: subframe sign | [-52230, 45] | [-52230, -45] | Failed |
| partial repair probe: subframe sign | [-162871, 49] | [-162871, -49] | Failed |
| partial repair variant: subframe sign | [-160200, 49] | [-160200, -49] | Failed |
| boundary control | [1, 50] | [1, 50] | Passed |
| boundary control | [1080000, 0] | [1080000, 0] | Passed |
| normal control | [0, 50] | [0, 50] | Passed |
| normal control | [106259, 0] | [106259, 0] | Passed |
| normal control | [1296000, 0] | [1296000, 0] | Passed |
SHA-256 / 2c439c3b352a698a58daeb457b13e774520b44f899c1dc127e04edde14a605d2
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: subframe sign', ['00:00:00:01.50', '00:00:00:00.00', 25], [-1, -50]), ('regression variant: subframe sign', ['01:30:00:00.5', '01:00:59:00.05', 30], [-52230, -45]), ('partial repair probe: subframe sign', ['01:00:30:00.99', '23:30:00:29.50', 30], [-162871, -49]), ('partial repair variant: subframe sign', ['00:59:30:00.99', '23:30:30:00.50', 30], [-160200, -49]), ('boundary control', ['00:00:00:00.00', '00:00:00:01.50', 25], [1, 50]), ('boundary control', ['00:00:00:00.0', '12:00:00:00.0', 25], [1080000, 0]), ('normal control', ['23:59:59:24.5', '00:00:00:00.0', 25], [0, 50]), ('normal control', ['00:59:59:00.5', '01:59:00:29.50', 30], [106259, 0]), ('normal control', ['00:30:59:00.0', '12:30:59:00.0', 30], [1296000, 0])], [('regression: subframe sign', ['01:00:59:29.50', '00:30:30:29.99', 30], [-54869, -51]), ('regression variant: subframe sign', ['00:59:00:29.00', '00:00:00:01.05', 30], [-106227, -95]), ('partial repair probe: subframe sign', ['01:59:30:29.50', '01:30:30:29.0', 30], [-52200, -50]), ('partial repair variant: subframe sign', ['23:59:30:01.50', '23:59:00:01.0', 30], [-900, -50]), ('boundary control', ['00:00:00:00.0', '12:00:00:00.0', 25], [1080000, 0]), ('boundary control', ['23:59:59:24.5', '00:00:00:00.0', 25], [0, 50]), ('normal control', ['01:30:59:29.05', '13:30:59:29.05', 30], [1296000, 0]), ('normal control', ['23:59:00:24.5', '00:30:59:01.0', 25], [47951, 50]), ('normal control', ['23:30:59:00.5', '23:59:30:01.00', 30], [51330, 50])], [('regression: subframe sign', ['01:00:30:00.99', '23:30:00:29.50', 30], [-162871, -49]), ('regression variant: subframe sign', ['12:00:59:01.50', '01:00:00:01.05', 25], [-991475, -45]), ('partial repair probe: subframe sign', ['12:59:30:01.50', '00:59:59:00.05', 30], [-1295131, -45]), ('partial repair variant: subframe sign', ['01:30:59:00.50', '23:30:30:29.0', 30], [-216841, -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', ['00:00:00:01.05', '23:00:00:01.05', 25], [-90000, 0]), ('normal control', ['00:00:00:29.05', '12:00:00:29.05', 30], [1296000, 0]), ('normal control', ['00:59:30:01.5', '23:00:00:29.50', 30], [-215072, 0])], [('regression: subframe sign', ['01:59:30:29.50', '01:30:30:29.0', 30], [-52200, -50]), ('regression variant: subframe sign', ['01:30:00:00.0', '01:00:59:24.99', 25], [-43500, -1]), ('partial repair probe: subframe sign', ['01:30:00:00.5', '01:00:59:00.05', 30], [-52230, -45]), ('partial repair variant: subframe sign', ['00:59:30:01.50', '00:59:00:01.00', 30], [-900, -50]), ('boundary control', ['00:00:00:00.00', '00:00:00:01.50', 25], [1, 50]), ('boundary control', ['00:00:00:00.0', '12:00:00:00.0', 25], [1080000, 0]), ('normal control', ['23:00:00:00.05', '23:30:00:01.0', 30], [54000, 95]), ('normal control', ['00:30:00:01.0', '01:00:00:01.0', 30], [54000, 0]), ('normal control', ['00:00:59:00.00', '23:00:00:01.0', 30], [-109769, 0])], [('regression: subframe sign', ['12:59:30:01.50', '00:59:59:00.05', 30], [-1295131, -45]), ('regression variant: subframe sign', ['00:59:30:00.99', '23:30:30:00.50', 30], [-160200, -49]), ('partial repair probe: subframe sign', ['00:59:00:29.00', '00:00:00:01.05', 30], [-106227, -95]), ('partial repair variant: subframe sign', ['12:30:59:00.5', '12:00:59:01.99', 25], [-44998, -51]), ('boundary control', ['00:00:00:00.0', '12:00:00:00.0', 25], [1080000, 0]), ('boundary control', ['23:59:59:24.5', '00:00:00:00.0', 25], [0, 50]), ('normal control', ['01:30:00:24.50', '12:59:00:01.5', 25], [1033477, 0]), ('normal control', ['23:00:59:01.5', '01:30:00:00.0', 30], [268228, 50]), ('normal control', ['00:59:30:01.0', '12:59:30:01.0', 30], [1296000, 0])]]
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: subframe sign | [-1, -50] | [-1, -50] | Passed |
| regression variant: subframe sign | [-52230, -45] | [-52230, -45] | Passed |
| partial repair probe: subframe sign | [-162871, -49] | [-162871, -49] | Passed |
| partial repair variant: subframe sign | [-160200, -49] | [-160200, -49] | Passed |
| boundary control | [1, 50] | [1, 50] | Passed |
| boundary control | [1080000, 0] | [1080000, 0] | Passed |
| normal control | [0, 50] | [0, 50] | Passed |
| normal control | [106259, 0] | [106259, 0] | Passed |
| normal control | [1296000, 0] | [1296000, 0] | Passed |
SHA-256 / 30272c3f1e380a3dd2e22181cfeaf805e99fe91ddf5a207479c01a55844a4441
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.607026+00:00.
Case digest / 3dc75ba8a04d3d0668565d289356eeca2506cac111182d0360c1f35ec522150a