FA-49866 / PCM sample encoding / Open access
Pcm alaw code selection: negative magnitude rule · case 01
A-law negative input omits its complement offset at quantization boundaries.
ROOT CAUSE
A-law negative input omits its complement offset at quantization boundaries.
VERIFIED REPAIR
Use the stated conversion contract at negative magnitude rule.
Unsuccessful approach: Applying the offset to positive samples breaks positive low bins.
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 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, 84] | [213, 213, 85, 212, 85] | Failed |
| oracle 2 | [197, 69, 197, 69] | [197, 90, 197, 69] | Failed |
| 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, 93] | [213, 85, 210, 82] | Failed |
| oracle 7 | [245, 117, 133, 5] | [245, 117, 133, 5] | Passed |
| variant packet 1 | [213, 213, 85, 212, 84, 213, 213, 85, 212, 84] | [213, 213, 85, 212, 85, 213, 213, 85, 212, 85] | Failed |
SHA-256 / 595b66b88707c2a78b05b691f686c5b12128a60a51452e38dd2c97dca96cc736
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=(abs(sample)-1)>>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 | [218, 213, 85, 213, 85] | [213, 213, 85, 212, 85] | Failed |
| oracle 2 | [218, 90, 197, 69] | [197, 90, 197, 69] | Failed |
| oracle 3 | [170, 42, 170, 42] | [170, 42, 170, 42] | Passed |
| oracle 4 | [] | [] | Passed |
| oracle 5 | [250, 234, 138] | [229, 149, 181] | Failed |
| oracle 6 | [213, 85, 210, 82] | [213, 85, 210, 82] | Passed |
| oracle 7 | [202, 117, 154, 5] | [245, 117, 133, 5] | Failed |
| variant packet 1 | [218, 213, 85, 213, 85, 218, 213, 85, 213, 85] | [213, 213, 85, 212, 85, 213, 213, 85, 212, 85] | Failed |
SHA-256 / 9e13219722da37ecbfaa5ec83c0a1c5ba6e0f0d5236b95cc8f7f3a76cdcf6401
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:03.879506+00:00.
Case digest / c46a1788e822427e26fa5a645533b78f1bff68d9421a3b58105e3de25bf429b6