U255.mesa
u-255 law conversion
Takes 12 bit linear pcm and converts to u-255 8-bit and back.
L. Stewart, last updated: May 8, 1982 8:05 pm
L. Stewart, last updated: June 12, 1983 3:19 pm
U255:
DEFINITIONS =
BEGIN
Encode expects a left justified 12 bit two's complement integer and will return a right justified 8 bit u255 value;
Encode: PROCEDURE [INTEGER] RETURNS [INTEGER];
Decode expects a right justified 8 bit u255 value and will return a left justified 12 bit two's complement value;
Decode: PROCEDURE [INTEGER] RETURNS [INTEGER];
Other useful stuff
BitOp: TYPE = PROC [a, b: UNSPECIFIED] RETURNS [UNSPECIFIED];
And: BitOp;
Shift: BitOp;
Or: BitOp;
Swab: PROC [a: UNSPECIFIED] RETURNS [UNSPECIFIED];
Byte: TYPE = [0..377B];
BTab: TYPE = RECORD [d: PACKED SEQUENCE length: CARDINAL OF Byte];
WTab: TYPE = RECORD [d: SEQUENCE length: CARDINAL OF INTEGER];
Offset: CARDINAL = 2048;
convert an offset two's complement value (IN [0..4095]) to a left justified two's complement value ( IN [-2048*16..2047*16] )
OffToInt: PROC [i: CARDINAL] RETURNS [INTEGER];
Convert a left justified two's complement value to a right justified value arithmetic right shift by 4
IntToRJInt: PROC [i: INTEGER] RETURNS [INTEGER];
takes a file name and either a REF WTab or a REF BTab and writes the data to the file in binary. If byteSwap is TRUE, swaps bytes of word tables, byte tables are unaffected.
WriteBitsFile: PROC [name: Rope.ROPE, data: REF ANY, byteSwap: BOOL ← FALSE] RETURNS [BOOL];
takes a file name and either a REF WTab or a REF BTab and writes the data to the file in the form of a bcpl table. Since tables are written as word tables, swaps bytes for either byte or word tables.
WriteTableFile: PROC [name: Rope.ROPE, data: REF ANY, byteSwap: BOOL ← FALSE] RETURNS [BOOL];
END.
September 20, 1979 3:46 PM, Stewart, created
12-Jan-82 11:38:54, Stewart, Cedar