FA-78556 / Broadcast timecode arithmetic / Open access
2:3 pulldown film frame placement: field count lookup · case 01
Field counts are wrong whenever the cadence phase is not zero.
ROOT CAUSE
The count is looked up from the film index without the phase.
VERIFIED REPAIR
Look up the count at the phased cadence position.
Unsuccessful approach: The inverted count table swaps two- and three-field frames.
Case contract
Film frames follow the A2 B3 C2 D3 field cadence (10 fields per 4 film frames). phase is the cadence position (0=A..3=D) of film frame 0, which starts at video field 0. Negative n returns None. For film frame n return [video frame of its first field, "upper" for an even field index else "lower", number of fields].
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(n, phase):
if n<0:
return None
def sf(a):
return 10*(a//4)+[0,2,5,7][a%4]
a=n+phase
start=sf(a)-sf(phase)
count=[2,3,2,3][n%4]
return [start//2,'upper' if start%2==0 else 'lower',count]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: field count lookup', [0, 1], [0, 'upper', 3]), ('regression variant: field count lookup', [10, 1], [12, 'lower', 3]), ('partial repair probe: field count lookup', [3, 0], [3, 'lower', 3]), ('partial repair variant: field count lookup', [34, 2], [42, 'lower', 2]), ('normal control', [-3, 2], None), ('normal control', [-2, 3], None), ('normal control', [-2, 1], None)], [('regression: field count lookup', [2, 3], [2, 'lower', 3]), ('regression variant: field count lookup', [36, 1], [45, 'upper', 3]), ('partial repair probe: field count lookup', [4, 0], [5, 'upper', 2]), ('partial repair variant: field count lookup', [9, 3], [11, 'lower', 2]), ('normal control', [-5, 1], None), ('normal control', [-1, 1], None), ('normal control', [-4, 1], None)], [('regression: field count lookup', [9, 1], [11, 'lower', 2]), ('regression variant: field count lookup', [38, 3], [47, 'lower', 3]), ('partial repair probe: field count lookup', [0, 1], [0, 'upper', 3]), ('partial repair variant: field count lookup', [10, 1], [12, 'lower', 3]), ('normal control', [-2, 2], None), ('normal control', [-1, 0], None), ('normal control', [-2, 0], None)], [('regression: field count lookup', [35, 1], [44, 'upper', 2]), ('regression variant: field count lookup', [1, 3], [1, 'lower', 2]), ('partial repair probe: field count lookup', [2, 3], [2, 'lower', 3]), ('partial repair variant: field count lookup', [22, 2], [27, 'lower', 2]), ('normal control', [-1, 2], None), ('normal control', [-4, 2], None), ('normal control', [-2, 3], None)], [('regression: field count lookup', [9, 3], [11, 'lower', 2]), ('regression variant: field count lookup', [30, 3], [37, 'lower', 3]), ('partial repair probe: field count lookup', [8, 0], [10, 'upper', 2]), ('partial repair variant: field count lookup', [26, 2], [32, 'lower', 2]), ('normal control', [-2, 1], None), ('normal control', [-3, 0], None), ('normal control', [-1, 1], None)]]
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: field count lookup | [0, 'upper', 2] | [0, 'upper', 3] | Failed |
| regression variant: field count lookup | [12, 'lower', 2] | [12, 'lower', 3] | Failed |
| partial repair probe: field count lookup | [3, 'lower', 3] | [3, 'lower', 3] | Passed |
| partial repair variant: field count lookup | [42, 'lower', 2] | [42, 'lower', 2] | Passed |
| normal control | None | None | Passed |
| normal control | None | None | Passed |
| normal control | None | None | Passed |
SHA-256 / ad5cc010f830d75f047ecbae9bc60163cbafd67b20a6802907e83ce0d463f699
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(n, phase):
if n<0:
return None
def sf(a):
return 10*(a//4)+[0,2,5,7][a%4]
a=n+phase
start=sf(a)-sf(phase)
count=[3,2,3,2][a%4]
return [start//2,'upper' if start%2==0 else 'lower',count]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: field count lookup', [0, 1], [0, 'upper', 3]), ('regression variant: field count lookup', [10, 1], [12, 'lower', 3]), ('partial repair probe: field count lookup', [3, 0], [3, 'lower', 3]), ('partial repair variant: field count lookup', [34, 2], [42, 'lower', 2]), ('normal control', [-3, 2], None), ('normal control', [-2, 3], None), ('normal control', [-2, 1], None)], [('regression: field count lookup', [2, 3], [2, 'lower', 3]), ('regression variant: field count lookup', [36, 1], [45, 'upper', 3]), ('partial repair probe: field count lookup', [4, 0], [5, 'upper', 2]), ('partial repair variant: field count lookup', [9, 3], [11, 'lower', 2]), ('normal control', [-5, 1], None), ('normal control', [-1, 1], None), ('normal control', [-4, 1], None)], [('regression: field count lookup', [9, 1], [11, 'lower', 2]), ('regression variant: field count lookup', [38, 3], [47, 'lower', 3]), ('partial repair probe: field count lookup', [0, 1], [0, 'upper', 3]), ('partial repair variant: field count lookup', [10, 1], [12, 'lower', 3]), ('normal control', [-2, 2], None), ('normal control', [-1, 0], None), ('normal control', [-2, 0], None)], [('regression: field count lookup', [35, 1], [44, 'upper', 2]), ('regression variant: field count lookup', [1, 3], [1, 'lower', 2]), ('partial repair probe: field count lookup', [2, 3], [2, 'lower', 3]), ('partial repair variant: field count lookup', [22, 2], [27, 'lower', 2]), ('normal control', [-1, 2], None), ('normal control', [-4, 2], None), ('normal control', [-2, 3], None)], [('regression: field count lookup', [9, 3], [11, 'lower', 2]), ('regression variant: field count lookup', [30, 3], [37, 'lower', 3]), ('partial repair probe: field count lookup', [8, 0], [10, 'upper', 2]), ('partial repair variant: field count lookup', [26, 2], [32, 'lower', 2]), ('normal control', [-2, 1], None), ('normal control', [-3, 0], None), ('normal control', [-1, 1], None)]]
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: field count lookup | [0, 'upper', 2] | [0, 'upper', 3] | Failed |
| regression variant: field count lookup | [12, 'lower', 2] | [12, 'lower', 3] | Failed |
| partial repair probe: field count lookup | [3, 'lower', 2] | [3, 'lower', 3] | Failed |
| partial repair variant: field count lookup | [42, 'lower', 3] | [42, 'lower', 2] | Failed |
| normal control | None | None | Passed |
| normal control | None | None | Passed |
| normal control | None | None | Passed |
SHA-256 / fcfc7592ae4cf9ad53d83533d39988e7d35b5717eed7305922cfb9197f934dc2
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(n, phase):
if n<0:
return None
def sf(a):
return 10*(a//4)+[0,2,5,7][a%4]
a=n+phase
start=sf(a)-sf(phase)
count=[2,3,2,3][a%4]
return [start//2,'upper' if start%2==0 else 'lower',count]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: field count lookup', [0, 1], [0, 'upper', 3]), ('regression variant: field count lookup', [10, 1], [12, 'lower', 3]), ('partial repair probe: field count lookup', [3, 0], [3, 'lower', 3]), ('partial repair variant: field count lookup', [34, 2], [42, 'lower', 2]), ('normal control', [-3, 2], None), ('normal control', [-2, 3], None), ('normal control', [-2, 1], None)], [('regression: field count lookup', [2, 3], [2, 'lower', 3]), ('regression variant: field count lookup', [36, 1], [45, 'upper', 3]), ('partial repair probe: field count lookup', [4, 0], [5, 'upper', 2]), ('partial repair variant: field count lookup', [9, 3], [11, 'lower', 2]), ('normal control', [-5, 1], None), ('normal control', [-1, 1], None), ('normal control', [-4, 1], None)], [('regression: field count lookup', [9, 1], [11, 'lower', 2]), ('regression variant: field count lookup', [38, 3], [47, 'lower', 3]), ('partial repair probe: field count lookup', [0, 1], [0, 'upper', 3]), ('partial repair variant: field count lookup', [10, 1], [12, 'lower', 3]), ('normal control', [-2, 2], None), ('normal control', [-1, 0], None), ('normal control', [-2, 0], None)], [('regression: field count lookup', [35, 1], [44, 'upper', 2]), ('regression variant: field count lookup', [1, 3], [1, 'lower', 2]), ('partial repair probe: field count lookup', [2, 3], [2, 'lower', 3]), ('partial repair variant: field count lookup', [22, 2], [27, 'lower', 2]), ('normal control', [-1, 2], None), ('normal control', [-4, 2], None), ('normal control', [-2, 3], None)], [('regression: field count lookup', [9, 3], [11, 'lower', 2]), ('regression variant: field count lookup', [30, 3], [37, 'lower', 3]), ('partial repair probe: field count lookup', [8, 0], [10, 'upper', 2]), ('partial repair variant: field count lookup', [26, 2], [32, 'lower', 2]), ('normal control', [-2, 1], None), ('normal control', [-3, 0], None), ('normal control', [-1, 1], None)]]
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: field count lookup | [0, 'upper', 3] | [0, 'upper', 3] | Passed |
| regression variant: field count lookup | [12, 'lower', 3] | [12, 'lower', 3] | Passed |
| partial repair probe: field count lookup | [3, 'lower', 3] | [3, 'lower', 3] | Passed |
| partial repair variant: field count lookup | [42, 'lower', 2] | [42, 'lower', 2] | Passed |
| normal control | None | None | Passed |
| normal control | None | None | Passed |
| normal control | None | None | Passed |
SHA-256 / fc430c535bbbf7bafc122a35fb4fd7e9b1c96773334c5c4ad695fc298557d320
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:36.593849+00:00.
Case digest / 504e97ba28ea904cfebcc767c78f20b21bf43863ec828b091e1ff2cb2271f7c3