FAILURE MAP
← Case archive

FA-78676 / Broadcast timecode arithmetic / Open access

Audio sample to frame cadence at 48 kHz: frame length · case 01

Every NTSC frame is reported as 1601 samples, breaking the five-frame cadence.

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

ROOT CAUSE

The frame length is a single truncated constant.

VERIFIED REPAIR

Compute the length from consecutive frame start samples.

Unsuccessful approach: A rounded-up constant reports 1602 samples for every frame.

Case contract

At 48000 samples per second and rate N/D, the frame containing sample s is floor(s*N/(48000*D)); frame k starts at sample ceil(k*48000*D/N). Return [frame, offset of s inside its frame, number of samples in that frame].

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(sample, rate):
    num,den={'23.976':(24000,1001),'24':(24,1),'25':(25,1),'29.97':(30000,1001),'30':(30,1)}[rate]
    frame=sample*num//(48000*den)
    start=-(-frame*48000*den//num)
    return [frame,sample-start,48000*den//num]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: frame length', [1602, '29.97'], [1, 0, 1602]), ('regression variant: frame length', [2002, '29.97'], [1, 400, 1602]), ('partial repair probe: frame length', [3070390, '29.97'], [1917, 122, 1601]), ('partial repair variant: frame length', [6050108, '29.97'], [3777, 864, 1601]), ('boundary control', [1920, '25'], [1, 0, 1920]), ('boundary control', [2002, '23.976'], [1, 0, 2002]), ('normal control', [1602, '24'], [0, 1602, 2000]), ('normal control', [1920, '30'], [1, 320, 1600]), ('normal control', [3204, '30'], [2, 4, 1600])], [('regression: frame length', [1601, '29.97'], [0, 1601, 1602]), ('regression variant: frame length', [1920, '29.97'], [1, 318, 1602]), ('partial repair probe: frame length', [6050108, '29.97'], [3777, 864, 1601]), ('partial repair variant: frame length', [8247925, '29.97'], [5149, 1286, 1601]), ('boundary control', [2002, '23.976'], [1, 0, 2002]), ('boundary control', [1920, '25'], [1, 0, 1920]), ('normal control', [9138728, '24'], [4569, 728, 2000]), ('normal control', [3203, '25'], [1, 1283, 1920]), ('normal control', [2001, '25'], [1, 81, 1920])], [('regression: frame length', [1919, '29.97'], [1, 317, 1602]), ('regression variant: frame length', [1, '29.97'], [0, 1, 1602]), ('partial repair probe: frame length', [8247925, '29.97'], [5149, 1286, 1601]), ('partial repair variant: frame length', [8735595, '29.97'], [5454, 468, 1601]), ('boundary control', [1920, '25'], [1, 0, 1920]), ('boundary control', [2002, '23.976'], [1, 0, 2002]), ('normal control', [1920, '23.976'], [0, 1920, 2002]), ('normal control', [1, '23.976'], [0, 1, 2002]), ('normal control', [1601, '24'], [0, 1601, 2000])], [('regression: frame length', [9580501, '29.97'], [5981, 1331, 1602]), ('regression variant: frame length', [1600, '29.97'], [0, 1600, 1602]), ('partial repair probe: frame length', [8735595, '29.97'], [5454, 468, 1601]), ('partial repair variant: frame length', [7203996, '29.97'], [4497, 1600, 1601]), ('boundary control', [2002, '23.976'], [1, 0, 2002]), ('boundary control', [1920, '25'], [1, 0, 1920]), ('normal control', [0, '24'], [0, 0, 2000]), ('normal control', [1920, '24'], [0, 1920, 2000]), ('normal control', [2001, '24'], [1, 1, 2000])], [('regression: frame length', [8008, '29.97'], [5, 0, 1602]), ('regression variant: frame length', [2001, '29.97'], [1, 399, 1602]), ('partial repair probe: frame length', [7203996, '29.97'], [4497, 1600, 1601]), ('partial repair variant: frame length', [3204, '29.97'], [2, 0, 1601]), ('boundary control', [1920, '25'], [1, 0, 1920]), ('boundary control', [2002, '23.976'], [1, 0, 2002]), ('normal control', [2839374, '30'], [1774, 974, 1600]), ('normal control', [1601, '23.976'], [0, 1601, 2002]), ('normal control', [1603, '25'], [0, 1603, 1920])]]
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: frame length[1, 0, 1601][1, 0, 1602]Failed
regression variant: frame length[1, 400, 1601][1, 400, 1602]Failed
partial repair probe: frame length[1917, 122, 1601][1917, 122, 1601]Passed
partial repair variant: frame length[3777, 864, 1601][3777, 864, 1601]Passed
boundary control[1, 0, 1920][1, 0, 1920]Passed
boundary control[1, 0, 2002][1, 0, 2002]Passed
normal control[0, 1602, 2000][0, 1602, 2000]Passed
normal control[1, 320, 1600][1, 320, 1600]Passed
normal control[2, 4, 1600][2, 4, 1600]Passed

SHA-256 / ce2e96563b9ca0c1b8c4c492f43b7ec54aad0a78fa12f4f2a3eec9e7d4d27ca7

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(sample, rate):
    num,den={'23.976':(24000,1001),'24':(24,1),'25':(25,1),'29.97':(30000,1001),'30':(30,1)}[rate]
    frame=sample*num//(48000*den)
    start=-(-frame*48000*den//num)
    return [frame,sample-start,-(-48000*den//num)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: frame length', [1602, '29.97'], [1, 0, 1602]), ('regression variant: frame length', [2002, '29.97'], [1, 400, 1602]), ('partial repair probe: frame length', [3070390, '29.97'], [1917, 122, 1601]), ('partial repair variant: frame length', [6050108, '29.97'], [3777, 864, 1601]), ('boundary control', [1920, '25'], [1, 0, 1920]), ('boundary control', [2002, '23.976'], [1, 0, 2002]), ('normal control', [1602, '24'], [0, 1602, 2000]), ('normal control', [1920, '30'], [1, 320, 1600]), ('normal control', [3204, '30'], [2, 4, 1600])], [('regression: frame length', [1601, '29.97'], [0, 1601, 1602]), ('regression variant: frame length', [1920, '29.97'], [1, 318, 1602]), ('partial repair probe: frame length', [6050108, '29.97'], [3777, 864, 1601]), ('partial repair variant: frame length', [8247925, '29.97'], [5149, 1286, 1601]), ('boundary control', [2002, '23.976'], [1, 0, 2002]), ('boundary control', [1920, '25'], [1, 0, 1920]), ('normal control', [9138728, '24'], [4569, 728, 2000]), ('normal control', [3203, '25'], [1, 1283, 1920]), ('normal control', [2001, '25'], [1, 81, 1920])], [('regression: frame length', [1919, '29.97'], [1, 317, 1602]), ('regression variant: frame length', [1, '29.97'], [0, 1, 1602]), ('partial repair probe: frame length', [8247925, '29.97'], [5149, 1286, 1601]), ('partial repair variant: frame length', [8735595, '29.97'], [5454, 468, 1601]), ('boundary control', [1920, '25'], [1, 0, 1920]), ('boundary control', [2002, '23.976'], [1, 0, 2002]), ('normal control', [1920, '23.976'], [0, 1920, 2002]), ('normal control', [1, '23.976'], [0, 1, 2002]), ('normal control', [1601, '24'], [0, 1601, 2000])], [('regression: frame length', [9580501, '29.97'], [5981, 1331, 1602]), ('regression variant: frame length', [1600, '29.97'], [0, 1600, 1602]), ('partial repair probe: frame length', [8735595, '29.97'], [5454, 468, 1601]), ('partial repair variant: frame length', [7203996, '29.97'], [4497, 1600, 1601]), ('boundary control', [2002, '23.976'], [1, 0, 2002]), ('boundary control', [1920, '25'], [1, 0, 1920]), ('normal control', [0, '24'], [0, 0, 2000]), ('normal control', [1920, '24'], [0, 1920, 2000]), ('normal control', [2001, '24'], [1, 1, 2000])], [('regression: frame length', [8008, '29.97'], [5, 0, 1602]), ('regression variant: frame length', [2001, '29.97'], [1, 399, 1602]), ('partial repair probe: frame length', [7203996, '29.97'], [4497, 1600, 1601]), ('partial repair variant: frame length', [3204, '29.97'], [2, 0, 1601]), ('boundary control', [1920, '25'], [1, 0, 1920]), ('boundary control', [2002, '23.976'], [1, 0, 2002]), ('normal control', [2839374, '30'], [1774, 974, 1600]), ('normal control', [1601, '23.976'], [0, 1601, 2002]), ('normal control', [1603, '25'], [0, 1603, 1920])]]
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: frame length[1, 0, 1602][1, 0, 1602]Passed
regression variant: frame length[1, 400, 1602][1, 400, 1602]Passed
partial repair probe: frame length[1917, 122, 1602][1917, 122, 1601]Failed
partial repair variant: frame length[3777, 864, 1602][3777, 864, 1601]Failed
boundary control[1, 0, 1920][1, 0, 1920]Passed
boundary control[1, 0, 2002][1, 0, 2002]Passed
normal control[0, 1602, 2000][0, 1602, 2000]Passed
normal control[1, 320, 1600][1, 320, 1600]Passed
normal control[2, 4, 1600][2, 4, 1600]Passed

SHA-256 / 1a160c1db2b1041ad73503c7772fde290d697719655d1655e6e18e6bd0dda83d

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(sample, rate):
    num,den={'23.976':(24000,1001),'24':(24,1),'25':(25,1),'29.97':(30000,1001),'30':(30,1)}[rate]
    frame=sample*num//(48000*den)
    start=-(-frame*48000*den//num)
    return [frame,sample-start,-(-(frame+1)*48000*den//num)-start]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: frame length', [1602, '29.97'], [1, 0, 1602]), ('regression variant: frame length', [2002, '29.97'], [1, 400, 1602]), ('partial repair probe: frame length', [3070390, '29.97'], [1917, 122, 1601]), ('partial repair variant: frame length', [6050108, '29.97'], [3777, 864, 1601]), ('boundary control', [1920, '25'], [1, 0, 1920]), ('boundary control', [2002, '23.976'], [1, 0, 2002]), ('normal control', [1602, '24'], [0, 1602, 2000]), ('normal control', [1920, '30'], [1, 320, 1600]), ('normal control', [3204, '30'], [2, 4, 1600])], [('regression: frame length', [1601, '29.97'], [0, 1601, 1602]), ('regression variant: frame length', [1920, '29.97'], [1, 318, 1602]), ('partial repair probe: frame length', [6050108, '29.97'], [3777, 864, 1601]), ('partial repair variant: frame length', [8247925, '29.97'], [5149, 1286, 1601]), ('boundary control', [2002, '23.976'], [1, 0, 2002]), ('boundary control', [1920, '25'], [1, 0, 1920]), ('normal control', [9138728, '24'], [4569, 728, 2000]), ('normal control', [3203, '25'], [1, 1283, 1920]), ('normal control', [2001, '25'], [1, 81, 1920])], [('regression: frame length', [1919, '29.97'], [1, 317, 1602]), ('regression variant: frame length', [1, '29.97'], [0, 1, 1602]), ('partial repair probe: frame length', [8247925, '29.97'], [5149, 1286, 1601]), ('partial repair variant: frame length', [8735595, '29.97'], [5454, 468, 1601]), ('boundary control', [1920, '25'], [1, 0, 1920]), ('boundary control', [2002, '23.976'], [1, 0, 2002]), ('normal control', [1920, '23.976'], [0, 1920, 2002]), ('normal control', [1, '23.976'], [0, 1, 2002]), ('normal control', [1601, '24'], [0, 1601, 2000])], [('regression: frame length', [9580501, '29.97'], [5981, 1331, 1602]), ('regression variant: frame length', [1600, '29.97'], [0, 1600, 1602]), ('partial repair probe: frame length', [8735595, '29.97'], [5454, 468, 1601]), ('partial repair variant: frame length', [7203996, '29.97'], [4497, 1600, 1601]), ('boundary control', [2002, '23.976'], [1, 0, 2002]), ('boundary control', [1920, '25'], [1, 0, 1920]), ('normal control', [0, '24'], [0, 0, 2000]), ('normal control', [1920, '24'], [0, 1920, 2000]), ('normal control', [2001, '24'], [1, 1, 2000])], [('regression: frame length', [8008, '29.97'], [5, 0, 1602]), ('regression variant: frame length', [2001, '29.97'], [1, 399, 1602]), ('partial repair probe: frame length', [7203996, '29.97'], [4497, 1600, 1601]), ('partial repair variant: frame length', [3204, '29.97'], [2, 0, 1601]), ('boundary control', [1920, '25'], [1, 0, 1920]), ('boundary control', [2002, '23.976'], [1, 0, 2002]), ('normal control', [2839374, '30'], [1774, 974, 1600]), ('normal control', [1601, '23.976'], [0, 1601, 2002]), ('normal control', [1603, '25'], [0, 1603, 1920])]]
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: frame length[1, 0, 1602][1, 0, 1602]Passed
regression variant: frame length[1, 400, 1602][1, 400, 1602]Passed
partial repair probe: frame length[1917, 122, 1601][1917, 122, 1601]Passed
partial repair variant: frame length[3777, 864, 1601][3777, 864, 1601]Passed
boundary control[1, 0, 1920][1, 0, 1920]Passed
boundary control[1, 0, 2002][1, 0, 2002]Passed
normal control[0, 1602, 2000][0, 1602, 2000]Passed
normal control[1, 320, 1600][1, 320, 1600]Passed
normal control[2, 4, 1600][2, 4, 1600]Passed

SHA-256 / 8da93c8614ab6c8e2d0a222e24554e87fded6128bb14c3d504545a593368a494

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

Case digest / 17dbf953f7357c9d48ced8ac1150d1ec27c2a0aefb382b05ebb03f2318376180