FAILURE MAP
← Case archive

FA-49011 / PCM sample encoding / Open access

Alaw expansion: polarity bit · case 01

A-law polarity uses the opposite convention from the decoder.

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

ROOT CAUSE

A-law polarity uses the opposite convention from the decoder.

VERIFIED REPAIR

Use the stated conversion contract at polarity bit.

Unsuccessful approach: Testing a wire mantissa bit makes polarity depend on magnitude.

Case contract

Decode eight-bit A-law codes into signed integer PCM using alternating-bit mask85, midpoint reconstruction and explicit segment rules.

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(codes):
    out=[]
    for raw in codes:
        code=raw^85
        segment=(code>>4)&7
        mantissa=code&15
        amplitude=(mantissa<<4)+8
        if segment:
            amplitude+=256
        if segment>1:
            amplitude<<=segment-1
        out.append(-amplitude if code&128 else amplitude)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([213, 85, 212, 84],)), [8, -8, 24, -24])
check('oracle 2', solve(*([197, 69, 245, 117],)), [264, -264, 528, -528])
check('oracle 3', solve(*([165, 37, 181, 53],)), [16896, -16896, 8448, -8448])
check('oracle 4', solve(*([0, 128, 255],)), [-5504, 5504, 848])
check('oracle 5', solve(*([],)), [])
check('oracle 6', solve(*([214, 86, 196, 68],)), [56, -56, 280, -280])
check('oracle 7', solve(*([149, 21, 133, 5],)), [2112, -2112, 4224, -4224])
if N == 1: check('variant packet 1', solve(*[[213, 85, 212, 84, 213, 85, 212, 84]]), [8, -8, 24, -24, 8, -8, 24, -24])
if N == 2: check('variant packet 2', solve(*[[213, 85, 212, 84, 213, 85, 212, 84, 213, 85, 212, 84]]), [8, -8, 24, -24, 8, -8, 24, -24, 8, -8, 24, -24])
if N == 3: check('variant packet 3', solve(*[[213, 85, 212, 84, 213, 85, 212, 84, 213, 85, 212, 84, 213, 85, 212, 84]]), [8, -8, 24, -24, 8, -8, 24, -24, 8, -8, 24, -24, 8, -8, 24, -24])
if N == 4: check('variant packet 4', solve(*[[213, 85, 212, 84, 213, 85, 212, 84, 213, 85, 212, 84, 213, 85, 212, 84, 213, 85, 212, 84]]), [8, -8, 24, -24, 8, -8, 24, -24, 8, -8, 24, -24, 8, -8, 24, -24, 8, -8, 24, -24])
if N == 5: check('variant packet 5', solve(*[[213, 85, 212, 84, 213, 85, 212, 84, 213, 85, 212, 84, 213, 85, 212, 84, 213, 85, 212, 84, 213, 85, 212, 84]]), [8, -8, 24, -24, 8, -8, 24, -24, 8, -8, 24, -24, 8, -8, 24, -24, 8, -8, 24, -24, 8, -8, 24, -24])
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[-8, 8, -24, 24][8, -8, 24, -24]Failed
oracle 2[-264, 264, -528, 528][264, -264, 528, -528]Failed
oracle 3[-16896, 16896, -8448, 8448][16896, -16896, 8448, -8448]Failed
oracle 4[5504, -5504, -848][-5504, 5504, 848]Failed
oracle 5[][]Passed
oracle 6[-56, 56, -280, 280][56, -56, 280, -280]Failed
oracle 7[-2112, 2112, -4224, 4224][2112, -2112, 4224, -4224]Failed
variant packet 1[-8, 8, -24, 24, -8, 8, -24, 24][8, -8, 24, -24, 8, -8, 24, -24]Failed

SHA-256 / f6d8cab891597a0a100498b1dfbaea43aae9384a5cc7f3bcf980347a60e37ae5

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(codes):
    out=[]
    for raw in codes:
        code=raw^85
        segment=(code>>4)&7
        mantissa=code&15
        amplitude=(mantissa<<4)+8
        if segment:
            amplitude+=256
        if segment>1:
            amplitude<<=segment-1
        out.append(amplitude if raw&1 else -amplitude)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([213, 85, 212, 84],)), [8, -8, 24, -24])
check('oracle 2', solve(*([197, 69, 245, 117],)), [264, -264, 528, -528])
check('oracle 3', solve(*([165, 37, 181, 53],)), [16896, -16896, 8448, -8448])
check('oracle 4', solve(*([0, 128, 255],)), [-5504, 5504, 848])
check('oracle 5', solve(*([],)), [])
check('oracle 6', solve(*([214, 86, 196, 68],)), [56, -56, 280, -280])
check('oracle 7', solve(*([149, 21, 133, 5],)), [2112, -2112, 4224, -4224])
if N == 1: check('variant packet 1', solve(*[[213, 85, 212, 84, 213, 85, 212, 84]]), [8, -8, 24, -24, 8, -8, 24, -24])
if N == 2: check('variant packet 2', solve(*[[213, 85, 212, 84, 213, 85, 212, 84, 213, 85, 212, 84]]), [8, -8, 24, -24, 8, -8, 24, -24, 8, -8, 24, -24])
if N == 3: check('variant packet 3', solve(*[[213, 85, 212, 84, 213, 85, 212, 84, 213, 85, 212, 84, 213, 85, 212, 84]]), [8, -8, 24, -24, 8, -8, 24, -24, 8, -8, 24, -24, 8, -8, 24, -24])
if N == 4: check('variant packet 4', solve(*[[213, 85, 212, 84, 213, 85, 212, 84, 213, 85, 212, 84, 213, 85, 212, 84, 213, 85, 212, 84]]), [8, -8, 24, -24, 8, -8, 24, -24, 8, -8, 24, -24, 8, -8, 24, -24, 8, -8, 24, -24])
if N == 5: check('variant packet 5', solve(*[[213, 85, 212, 84, 213, 85, 212, 84, 213, 85, 212, 84, 213, 85, 212, 84, 213, 85, 212, 84, 213, 85, 212, 84]]), [8, -8, 24, -24, 8, -8, 24, -24, 8, -8, 24, -24, 8, -8, 24, -24, 8, -8, 24, -24, 8, -8, 24, -24])
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[8, 8, -24, -24][8, -8, 24, -24]Failed
oracle 2[264, 264, 528, 528][264, -264, 528, -528]Failed
oracle 3[16896, 16896, 8448, 8448][16896, -16896, 8448, -8448]Failed
oracle 4[-5504, -5504, 848][-5504, 5504, 848]Failed
oracle 5[][]Passed
oracle 6[-56, -56, -280, -280][56, -56, 280, -280]Failed
oracle 7[2112, 2112, 4224, 4224][2112, -2112, 4224, -4224]Failed
variant packet 1[8, 8, -24, -24, 8, 8, -24, -24][8, -8, 24, -24, 8, -8, 24, -24]Failed

SHA-256 / f26fab8bc6d9254d7493de1ddf91e0f265cfd82149c6d30670032fb6488521af

3 / The verified repair

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

N = 1
observations = []
def solve(codes):
    out=[]
    for raw in codes:
        code=raw^85
        segment=(code>>4)&7
        mantissa=code&15
        amplitude=(mantissa<<4)+8
        if segment:
            amplitude+=256
        if segment>1:
            amplitude<<=segment-1
        out.append(amplitude if code&128 else -amplitude)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([213, 85, 212, 84],)), [8, -8, 24, -24])
check('oracle 2', solve(*([197, 69, 245, 117],)), [264, -264, 528, -528])
check('oracle 3', solve(*([165, 37, 181, 53],)), [16896, -16896, 8448, -8448])
check('oracle 4', solve(*([0, 128, 255],)), [-5504, 5504, 848])
check('oracle 5', solve(*([],)), [])
check('oracle 6', solve(*([214, 86, 196, 68],)), [56, -56, 280, -280])
check('oracle 7', solve(*([149, 21, 133, 5],)), [2112, -2112, 4224, -4224])
if N == 1: check('variant packet 1', solve(*[[213, 85, 212, 84, 213, 85, 212, 84]]), [8, -8, 24, -24, 8, -8, 24, -24])
if N == 2: check('variant packet 2', solve(*[[213, 85, 212, 84, 213, 85, 212, 84, 213, 85, 212, 84]]), [8, -8, 24, -24, 8, -8, 24, -24, 8, -8, 24, -24])
if N == 3: check('variant packet 3', solve(*[[213, 85, 212, 84, 213, 85, 212, 84, 213, 85, 212, 84, 213, 85, 212, 84]]), [8, -8, 24, -24, 8, -8, 24, -24, 8, -8, 24, -24, 8, -8, 24, -24])
if N == 4: check('variant packet 4', solve(*[[213, 85, 212, 84, 213, 85, 212, 84, 213, 85, 212, 84, 213, 85, 212, 84, 213, 85, 212, 84]]), [8, -8, 24, -24, 8, -8, 24, -24, 8, -8, 24, -24, 8, -8, 24, -24, 8, -8, 24, -24])
if N == 5: check('variant packet 5', solve(*[[213, 85, 212, 84, 213, 85, 212, 84, 213, 85, 212, 84, 213, 85, 212, 84, 213, 85, 212, 84, 213, 85, 212, 84]]), [8, -8, 24, -24, 8, -8, 24, -24, 8, -8, 24, -24, 8, -8, 24, -24, 8, -8, 24, -24, 8, -8, 24, -24])
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[8, -8, 24, -24][8, -8, 24, -24]Passed
oracle 2[264, -264, 528, -528][264, -264, 528, -528]Passed
oracle 3[16896, -16896, 8448, -8448][16896, -16896, 8448, -8448]Passed
oracle 4[-5504, 5504, 848][-5504, 5504, 848]Passed
oracle 5[][]Passed
oracle 6[56, -56, 280, -280][56, -56, 280, -280]Passed
oracle 7[2112, -2112, 4224, -4224][2112, -2112, 4224, -4224]Passed
variant packet 1[8, -8, 24, -24, 8, -8, 24, -24][8, -8, 24, -24, 8, -8, 24, -24]Passed

SHA-256 / 86375ee9ce48759ec2ddcfd7d48f2426685fdacd10c9765d2fc3ad0ce12d7296

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

Case digest / b991c1da01286cc6078f02e6d86a4ec809dd07f1bd0907dcb140f79aa352cb83