FA-49881 / PCM sample encoding / Open access
Pcm alaw code selection: segment transition · case 01
Exact segment thresholds select the previous code segment.
ROOT CAUSE
Exact segment thresholds select the previous code segment.
VERIFIED REPAIR
Use the stated conversion contract at segment transition.
Unsuccessful approach: Using a half threshold prematurely changes the segment.
Case contract
Stipulated bounded A-law-style PCM encoder with negative complement offset, thirteen-bit working magnitude, segment-specific shifts and alternating wire mask.
Why this case matters
Offline PCM interchange uses these exact bounded packet and sample representation decisions.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(samples):
out=[]
for sample in samples:
negative=sample<0
magnitude=(-sample-1 if negative else sample)>>3
magnitude=min(magnitude,4095)
segment=0
while segment<7 and magnitude>(32<<segment):
segment+=1
shift=1 if segment<2 else segment
mantissa=(magnitude>>shift)&15
code=(0 if negative else 128)|(segment<<4)|mantissa
out.append(code^85)
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([0, 8, -8, 16, -16],)), [213, 213, 85, 212, 85])
check('oracle 2', solve(*([256, -256, 264, -264],)), [197, 90, 197, 69])
check('oracle 3', solve(*([32767, -32768, 40000, -40000],)), [170, 42, 170, 42])
check('oracle 4', solve(*([],)), [])
check('oracle 5', solve(*([1024, 2048, 8192],)), [229, 149, 181])
check('oracle 6', solve(*([1, -1, 127, -128],)), [213, 85, 210, 82])
check('oracle 7', solve(*([512, -513, 4096, -4097],)), [245, 117, 133, 5])
if N == 1: check('variant packet 1', solve(*[[0, 8, -8, 16, -16, 0, 8, -8, 16, -16]]), [213, 213, 85, 212, 85, 213, 213, 85, 212, 85])
if N == 2: check('variant packet 2', solve(*[[0, 8, -8, 16, -16, 0, 8, -8, 16, -16, 0, 8, -8, 16, -16]]), [213, 213, 85, 212, 85, 213, 213, 85, 212, 85, 213, 213, 85, 212, 85])
if N == 3: check('variant packet 3', solve(*[[0, 8, -8, 16, -16, 0, 8, -8, 16, -16, 0, 8, -8, 16, -16, 0, 8, -8, 16, -16]]), [213, 213, 85, 212, 85, 213, 213, 85, 212, 85, 213, 213, 85, 212, 85, 213, 213, 85, 212, 85])
if N == 4: check('variant packet 4', solve(*[[0, 8, -8, 16, -16, 0, 8, -8, 16, -16, 0, 8, -8, 16, -16, 0, 8, -8, 16, -16, 0, 8, -8, 16, -16]]), [213, 213, 85, 212, 85, 213, 213, 85, 212, 85, 213, 213, 85, 212, 85, 213, 213, 85, 212, 85, 213, 213, 85, 212, 85])
if N == 5: check('variant packet 5', solve(*[[0, 8, -8, 16, -16, 0, 8, -8, 16, -16, 0, 8, -8, 16, -16, 0, 8, -8, 16, -16, 0, 8, -8, 16, -16, 0, 8, -8, 16, -16]]), [213, 213, 85, 212, 85, 213, 213, 85, 212, 85, 213, 213, 85, 212, 85, 213, 213, 85, 212, 85, 213, 213, 85, 212, 85, 213, 213, 85, 212, 85])
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 |
|---|---|---|---|
| oracle 1 | [213, 213, 85, 212, 85] | [213, 213, 85, 212, 85] | Passed |
| oracle 2 | [213, 90, 197, 85] | [197, 90, 197, 69] | Failed |
| oracle 3 | [170, 42, 170, 42] | [170, 42, 170, 42] | Passed |
| oracle 4 | [] | [] | Passed |
| oracle 5 | [245, 229, 133] | [229, 149, 181] | Failed |
| oracle 6 | [213, 85, 210, 82] | [213, 85, 210, 82] | Passed |
| oracle 7 | [197, 69, 149, 21] | [245, 117, 133, 5] | Failed |
| variant packet 1 | [213, 213, 85, 212, 85, 213, 213, 85, 212, 85] | [213, 213, 85, 212, 85, 213, 213, 85, 212, 85] | Passed |
SHA-256 / 3f406484ecd0dbc12aac694cf0a30b0ff3ea54ed698517afea82c040a4f83d13
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(samples):
out=[]
for sample in samples:
negative=sample<0
magnitude=(-sample-1 if negative else sample)>>3
magnitude=min(magnitude,4095)
segment=0
while segment<7 and magnitude>=(16<<segment):
segment+=1
shift=1 if segment<2 else segment
mantissa=(magnitude>>shift)&15
code=(0 if negative else 128)|(segment<<4)|mantissa
out.append(code^85)
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([0, 8, -8, 16, -16],)), [213, 213, 85, 212, 85])
check('oracle 2', solve(*([256, -256, 264, -264],)), [197, 90, 197, 69])
check('oracle 3', solve(*([32767, -32768, 40000, -40000],)), [170, 42, 170, 42])
check('oracle 4', solve(*([],)), [])
check('oracle 5', solve(*([1024, 2048, 8192],)), [229, 149, 181])
check('oracle 6', solve(*([1, -1, 127, -128],)), [213, 85, 210, 82])
check('oracle 7', solve(*([512, -513, 4096, -4097],)), [245, 117, 133, 5])
if N == 1: check('variant packet 1', solve(*[[0, 8, -8, 16, -16, 0, 8, -8, 16, -16]]), [213, 213, 85, 212, 85, 213, 213, 85, 212, 85])
if N == 2: check('variant packet 2', solve(*[[0, 8, -8, 16, -16, 0, 8, -8, 16, -16, 0, 8, -8, 16, -16]]), [213, 213, 85, 212, 85, 213, 213, 85, 212, 85, 213, 213, 85, 212, 85])
if N == 3: check('variant packet 3', solve(*[[0, 8, -8, 16, -16, 0, 8, -8, 16, -16, 0, 8, -8, 16, -16, 0, 8, -8, 16, -16]]), [213, 213, 85, 212, 85, 213, 213, 85, 212, 85, 213, 213, 85, 212, 85, 213, 213, 85, 212, 85])
if N == 4: check('variant packet 4', solve(*[[0, 8, -8, 16, -16, 0, 8, -8, 16, -16, 0, 8, -8, 16, -16, 0, 8, -8, 16, -16, 0, 8, -8, 16, -16]]), [213, 213, 85, 212, 85, 213, 213, 85, 212, 85, 213, 213, 85, 212, 85, 213, 213, 85, 212, 85, 213, 213, 85, 212, 85])
if N == 5: check('variant packet 5', solve(*[[0, 8, -8, 16, -16, 0, 8, -8, 16, -16, 0, 8, -8, 16, -16, 0, 8, -8, 16, -16, 0, 8, -8, 16, -16, 0, 8, -8, 16, -16]]), [213, 213, 85, 212, 85, 213, 213, 85, 212, 85, 213, 213, 85, 212, 85, 213, 213, 85, 212, 85, 213, 213, 85, 212, 85, 213, 213, 85, 212, 85])
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 |
|---|---|---|---|
| oracle 1 | [213, 213, 85, 212, 85] | [213, 213, 85, 212, 85] | Passed |
| oracle 2 | [253, 74, 253, 125] | [197, 90, 197, 69] | Failed |
| oracle 3 | [170, 42, 170, 42] | [170, 42, 170, 42] | Passed |
| oracle 4 | [] | [] | Passed |
| oracle 5 | [157, 141, 173] | [229, 149, 181] | Failed |
| oracle 6 | [213, 85, 210, 82] | [213, 85, 210, 82] | Passed |
| oracle 7 | [237, 109, 189, 61] | [245, 117, 133, 5] | Failed |
| variant packet 1 | [213, 213, 85, 212, 85, 213, 213, 85, 212, 85] | [213, 213, 85, 212, 85, 213, 213, 85, 212, 85] | Passed |
SHA-256 / 66bcffaf4c42e70c5dcdfd925622336ae207e7d37220e9206a97df598fe96680
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(samples):
out=[]
for sample in samples:
negative=sample<0
magnitude=(-sample-1 if negative else sample)>>3
magnitude=min(magnitude,4095)
segment=0
while segment<7 and magnitude>=(32<<segment):
segment+=1
shift=1 if segment<2 else segment
mantissa=(magnitude>>shift)&15
code=(0 if negative else 128)|(segment<<4)|mantissa
out.append(code^85)
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([0, 8, -8, 16, -16],)), [213, 213, 85, 212, 85])
check('oracle 2', solve(*([256, -256, 264, -264],)), [197, 90, 197, 69])
check('oracle 3', solve(*([32767, -32768, 40000, -40000],)), [170, 42, 170, 42])
check('oracle 4', solve(*([],)), [])
check('oracle 5', solve(*([1024, 2048, 8192],)), [229, 149, 181])
check('oracle 6', solve(*([1, -1, 127, -128],)), [213, 85, 210, 82])
check('oracle 7', solve(*([512, -513, 4096, -4097],)), [245, 117, 133, 5])
if N == 1: check('variant packet 1', solve(*[[0, 8, -8, 16, -16, 0, 8, -8, 16, -16]]), [213, 213, 85, 212, 85, 213, 213, 85, 212, 85])
if N == 2: check('variant packet 2', solve(*[[0, 8, -8, 16, -16, 0, 8, -8, 16, -16, 0, 8, -8, 16, -16]]), [213, 213, 85, 212, 85, 213, 213, 85, 212, 85, 213, 213, 85, 212, 85])
if N == 3: check('variant packet 3', solve(*[[0, 8, -8, 16, -16, 0, 8, -8, 16, -16, 0, 8, -8, 16, -16, 0, 8, -8, 16, -16]]), [213, 213, 85, 212, 85, 213, 213, 85, 212, 85, 213, 213, 85, 212, 85, 213, 213, 85, 212, 85])
if N == 4: check('variant packet 4', solve(*[[0, 8, -8, 16, -16, 0, 8, -8, 16, -16, 0, 8, -8, 16, -16, 0, 8, -8, 16, -16, 0, 8, -8, 16, -16]]), [213, 213, 85, 212, 85, 213, 213, 85, 212, 85, 213, 213, 85, 212, 85, 213, 213, 85, 212, 85, 213, 213, 85, 212, 85])
if N == 5: check('variant packet 5', solve(*[[0, 8, -8, 16, -16, 0, 8, -8, 16, -16, 0, 8, -8, 16, -16, 0, 8, -8, 16, -16, 0, 8, -8, 16, -16, 0, 8, -8, 16, -16]]), [213, 213, 85, 212, 85, 213, 213, 85, 212, 85, 213, 213, 85, 212, 85, 213, 213, 85, 212, 85, 213, 213, 85, 212, 85, 213, 213, 85, 212, 85])
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 |
|---|---|---|---|
| oracle 1 | [213, 213, 85, 212, 85] | [213, 213, 85, 212, 85] | Passed |
| oracle 2 | [197, 90, 197, 69] | [197, 90, 197, 69] | Passed |
| oracle 3 | [170, 42, 170, 42] | [170, 42, 170, 42] | Passed |
| oracle 4 | [] | [] | Passed |
| oracle 5 | [229, 149, 181] | [229, 149, 181] | Passed |
| oracle 6 | [213, 85, 210, 82] | [213, 85, 210, 82] | Passed |
| oracle 7 | [245, 117, 133, 5] | [245, 117, 133, 5] | Passed |
| variant packet 1 | [213, 213, 85, 212, 85, 213, 213, 85, 212, 85] | [213, 213, 85, 212, 85, 213, 213, 85, 212, 85] | Passed |
SHA-256 / df99ba847feb88c82ec2203b6e947d4ae1167b17d32ccde326bc8d136c175a7b
Verification & scope
Stipulated finite model; no claim of hardware timing or full file-format conformance. 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:45:04.084219+00:00.
Case digest / 1532f8608f80e04df1102a5bae60e19334b9dee058aeed24e4b23463ebda8a2e