MPEG-4 Audio Lossless Coding (ALS)

From MultimediaWiki
Jump to navigation Jump to search

ALS is MPEG-4's pure lossless audio codec. It is based on the older LPAC (Lossless Predictive Audio Coding) codec from NUe.

Format

All integers are big-endian unless specified otherwise

File Header

 4 bytes - 'ALS\0'
 32 bits - sample rate
 32 bits - samples
 16 bits - channels-1
  8 bits - flags:
           3 bits - file type (RAW, WAV, AIFF)
           3 bits - (bpp - 1)/8
           1 bit  - floating point
           1 bit  - samples are big-endian
 16 bits - frame length-1
  8 bits - seek info in each n-th frame
 32 bits - flags:
           2 bits - seek location
           1  bit - adaptive order
           2 bits - coding table
           1  bit - pitch
           10 bits - pred order
           2 bits - block switching depth - 2
           1  bit - BGMC or Rice
           1  bit - subblock partition
           1  bit - joint stereo
           1  bit - multi-channel coding
           1  bit - channel config
           1  bit - channel sort      
           1  bit - CRC
           1  bit - RLSLMS
           5 bits - reserved
           1  bit - AUX data present
 if(channel config bit is set)
   16 bits - configuration
 if(channel sort bit is set)
   log2(channels-1)*channels/8+1 bytes
 32 bits - header size
 32 bits - trailer size
 <HEADER>
 <TRAILER>
 <CRC>
 Random access table
 <AUX>

AUX block

This block contains data not used by decoder (like cuesheet or image?) First 32 bits specify data size.

Data block

 if(some seek condition)
   32 bits - seek size
 if(multichannel && joint)
   8  bits - mcc flag
 if(subblocks flag is set)
 8-32 bits - flags
           1   bit - coupling off
           1   bit - block size is N
           2  bits - subblocks size is N/2
           4  bits - subblocks size is N/4
      if subblock depth > 3
           8  bits - subblocks size is N/8
      if subblock depth > 4
           16 bits - subblocks size is N/16

Block data:

 2 bits - block type (0 - zero block, 1 - constant, else - normal block)
 if(constant block)
   6 bits - padding
   8-32 bits - sample to fill this block (for 16-bit sample is stored in little-endian)