FAILURE MAP
← Case archive

FA-49846 / PCM sample encoding / Open access

Pcm mulaw code selection: segment boundary · case 01

An exact companding segment boundary stays in the lower segment.

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

ROOT CAUSE

An exact companding segment boundary stays in the lower segment.

VERIFIED REPAIR

Use the stated conversion contract at segment boundary.

Unsuccessful approach: Starting at half the threshold advances every segment too early.

Case contract

Bounded mu-law-style selection model: clamp magnitude32635, add bias132, select segment and mantissa then complement the full eight-bit code.

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
        amplitude=min(32635,abs(sample))+132
        exponent=0
        while exponent<7 and amplitude>(256<<exponent):
            exponent+=1
        mantissa=(amplitude>>(exponent+3))&15
        code=(128 if negative else 0)|(exponent<<4)|mantissa
        out.append((~code)&255)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([0, 1, -1, 100, -100],)), [255, 255, 127, 242, 114])
check('oracle 2', solve(*([124, 125, -124],)), [239, 239, 111])
check('oracle 3', solve(*([32635, 40000, -40000],)), [128, 128, 0])
check('oracle 4', solve(*([],)), [])
check('oracle 5', solve(*([1000, 4000, 16000],)), [206, 175, 144])
check('oracle 6', solve(*([380, 892, 1916],)), [223, 207, 191])
check('oracle 7', solve(*([-1000, -4000, -16000],)), [78, 47, 16])
if N == 1: check('variant packet 1', solve(*[[0, 1, -1, 100, -100, 0, 1, -1, 100, -100]]), [255, 255, 127, 242, 114, 255, 255, 127, 242, 114])
if N == 2: check('variant packet 2', solve(*[[0, 1, -1, 100, -100, 0, 1, -1, 100, -100, 0, 1, -1, 100, -100]]), [255, 255, 127, 242, 114, 255, 255, 127, 242, 114, 255, 255, 127, 242, 114])
if N == 3: check('variant packet 3', solve(*[[0, 1, -1, 100, -100, 0, 1, -1, 100, -100, 0, 1, -1, 100, -100, 0, 1, -1, 100, -100]]), [255, 255, 127, 242, 114, 255, 255, 127, 242, 114, 255, 255, 127, 242, 114, 255, 255, 127, 242, 114])
if N == 4: check('variant packet 4', solve(*[[0, 1, -1, 100, -100, 0, 1, -1, 100, -100, 0, 1, -1, 100, -100, 0, 1, -1, 100, -100, 0, 1, -1, 100, -100]]), [255, 255, 127, 242, 114, 255, 255, 127, 242, 114, 255, 255, 127, 242, 114, 255, 255, 127, 242, 114, 255, 255, 127, 242, 114])
if N == 5: check('variant packet 5', solve(*[[0, 1, -1, 100, -100, 0, 1, -1, 100, -100, 0, 1, -1, 100, -100, 0, 1, -1, 100, -100, 0, 1, -1, 100, -100, 0, 1, -1, 100, -100]]), [255, 255, 127, 242, 114, 255, 255, 127, 242, 114, 255, 255, 127, 242, 114, 255, 255, 127, 242, 114, 255, 255, 127, 242, 114, 255, 255, 127, 242, 114])
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
oracle 1[255, 255, 127, 242, 114][255, 255, 127, 242, 114]Passed
oracle 2[255, 239, 127][239, 239, 111]Failed
oracle 3[128, 128, 0][128, 128, 0]Passed
oracle 4[][]Passed
oracle 5[206, 175, 144][206, 175, 144]Passed
oracle 6[239, 223, 207][223, 207, 191]Failed
oracle 7[78, 47, 16][78, 47, 16]Passed
variant packet 1[255, 255, 127, 242, 114, 255, 255, 127, 242, 114][255, 255, 127, 242, 114, 255, 255, 127, 242, 114]Passed

SHA-256 / 67a71579de58a826c701213669f2aba7aacc18adb75be67e3beb8ed24a21466d

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
        amplitude=min(32635,abs(sample))+132
        exponent=0
        while exponent<7 and amplitude>=(128<<exponent):
            exponent+=1
        mantissa=(amplitude>>(exponent+3))&15
        code=(128 if negative else 0)|(exponent<<4)|mantissa
        out.append((~code)&255)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([0, 1, -1, 100, -100],)), [255, 255, 127, 242, 114])
check('oracle 2', solve(*([124, 125, -124],)), [239, 239, 111])
check('oracle 3', solve(*([32635, 40000, -40000],)), [128, 128, 0])
check('oracle 4', solve(*([],)), [])
check('oracle 5', solve(*([1000, 4000, 16000],)), [206, 175, 144])
check('oracle 6', solve(*([380, 892, 1916],)), [223, 207, 191])
check('oracle 7', solve(*([-1000, -4000, -16000],)), [78, 47, 16])
if N == 1: check('variant packet 1', solve(*[[0, 1, -1, 100, -100, 0, 1, -1, 100, -100]]), [255, 255, 127, 242, 114, 255, 255, 127, 242, 114])
if N == 2: check('variant packet 2', solve(*[[0, 1, -1, 100, -100, 0, 1, -1, 100, -100, 0, 1, -1, 100, -100]]), [255, 255, 127, 242, 114, 255, 255, 127, 242, 114, 255, 255, 127, 242, 114])
if N == 3: check('variant packet 3', solve(*[[0, 1, -1, 100, -100, 0, 1, -1, 100, -100, 0, 1, -1, 100, -100, 0, 1, -1, 100, -100]]), [255, 255, 127, 242, 114, 255, 255, 127, 242, 114, 255, 255, 127, 242, 114, 255, 255, 127, 242, 114])
if N == 4: check('variant packet 4', solve(*[[0, 1, -1, 100, -100, 0, 1, -1, 100, -100, 0, 1, -1, 100, -100, 0, 1, -1, 100, -100, 0, 1, -1, 100, -100]]), [255, 255, 127, 242, 114, 255, 255, 127, 242, 114, 255, 255, 127, 242, 114, 255, 255, 127, 242, 114, 255, 255, 127, 242, 114])
if N == 5: check('variant packet 5', solve(*[[0, 1, -1, 100, -100, 0, 1, -1, 100, -100, 0, 1, -1, 100, -100, 0, 1, -1, 100, -100, 0, 1, -1, 100, -100, 0, 1, -1, 100, -100]]), [255, 255, 127, 242, 114, 255, 255, 127, 242, 114, 255, 255, 127, 242, 114, 255, 255, 127, 242, 114, 255, 255, 127, 242, 114, 255, 255, 127, 242, 114])
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
oracle 1[231, 231, 103, 225, 97][255, 255, 127, 242, 114]Failed
oracle 2[215, 215, 87][239, 239, 111]Failed
oracle 3[128, 128, 0][128, 128, 0]Passed
oracle 4[][]Passed
oracle 5[183, 151, 128][206, 175, 144]Failed
oracle 6[199, 183, 167][223, 207, 191]Failed
oracle 7[55, 23, 0][78, 47, 16]Failed
variant packet 1[231, 231, 103, 225, 97, 231, 231, 103, 225, 97][255, 255, 127, 242, 114, 255, 255, 127, 242, 114]Failed

SHA-256 / 004620e991cf416a56f376766f70ebd6987276061c694e6fa315ba01436a1deb

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
        amplitude=min(32635,abs(sample))+132
        exponent=0
        while exponent<7 and amplitude>=(256<<exponent):
            exponent+=1
        mantissa=(amplitude>>(exponent+3))&15
        code=(128 if negative else 0)|(exponent<<4)|mantissa
        out.append((~code)&255)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([0, 1, -1, 100, -100],)), [255, 255, 127, 242, 114])
check('oracle 2', solve(*([124, 125, -124],)), [239, 239, 111])
check('oracle 3', solve(*([32635, 40000, -40000],)), [128, 128, 0])
check('oracle 4', solve(*([],)), [])
check('oracle 5', solve(*([1000, 4000, 16000],)), [206, 175, 144])
check('oracle 6', solve(*([380, 892, 1916],)), [223, 207, 191])
check('oracle 7', solve(*([-1000, -4000, -16000],)), [78, 47, 16])
if N == 1: check('variant packet 1', solve(*[[0, 1, -1, 100, -100, 0, 1, -1, 100, -100]]), [255, 255, 127, 242, 114, 255, 255, 127, 242, 114])
if N == 2: check('variant packet 2', solve(*[[0, 1, -1, 100, -100, 0, 1, -1, 100, -100, 0, 1, -1, 100, -100]]), [255, 255, 127, 242, 114, 255, 255, 127, 242, 114, 255, 255, 127, 242, 114])
if N == 3: check('variant packet 3', solve(*[[0, 1, -1, 100, -100, 0, 1, -1, 100, -100, 0, 1, -1, 100, -100, 0, 1, -1, 100, -100]]), [255, 255, 127, 242, 114, 255, 255, 127, 242, 114, 255, 255, 127, 242, 114, 255, 255, 127, 242, 114])
if N == 4: check('variant packet 4', solve(*[[0, 1, -1, 100, -100, 0, 1, -1, 100, -100, 0, 1, -1, 100, -100, 0, 1, -1, 100, -100, 0, 1, -1, 100, -100]]), [255, 255, 127, 242, 114, 255, 255, 127, 242, 114, 255, 255, 127, 242, 114, 255, 255, 127, 242, 114, 255, 255, 127, 242, 114])
if N == 5: check('variant packet 5', solve(*[[0, 1, -1, 100, -100, 0, 1, -1, 100, -100, 0, 1, -1, 100, -100, 0, 1, -1, 100, -100, 0, 1, -1, 100, -100, 0, 1, -1, 100, -100]]), [255, 255, 127, 242, 114, 255, 255, 127, 242, 114, 255, 255, 127, 242, 114, 255, 255, 127, 242, 114, 255, 255, 127, 242, 114, 255, 255, 127, 242, 114])
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
oracle 1[255, 255, 127, 242, 114][255, 255, 127, 242, 114]Passed
oracle 2[239, 239, 111][239, 239, 111]Passed
oracle 3[128, 128, 0][128, 128, 0]Passed
oracle 4[][]Passed
oracle 5[206, 175, 144][206, 175, 144]Passed
oracle 6[223, 207, 191][223, 207, 191]Passed
oracle 7[78, 47, 16][78, 47, 16]Passed
variant packet 1[255, 255, 127, 242, 114, 255, 255, 127, 242, 114][255, 255, 127, 242, 114, 255, 255, 127, 242, 114]Passed

SHA-256 / 9a61544a71b8062ad93686f3ed544e53c854273e6558ea0c346d7822c4809892

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

Case digest / 6d586ff395e39c90ff66c814cd5a8dc703386dbf4cdf84e77c27d9b7f361c25f