The scaling factor decoding was fairly straight forward, but the huffman tables gave me fits. I had an error in one of the lookup tables and it was causing the decoder to be off by a couple bits. Argh. I think it is all worked out now. The code is up on bitbucket (the first post). The bit reservoir is still not implemented yet.

The bit reservoir is a cool concept to put more bits where they are needed in the bit stream. This is different from Variable Bitrate. Basically, if a frame completed encoding its data and there is space left over, it can be donated to future frames. The reservoir is only used for the main data section.

The main data is split between scaling factors and coefficients. The coefficients are in the frequency domain and are split into regions ( big value region, one’s region, and zeros) Different coding schemes are used for each region. When a sound signal is converted to the frequency domain, it tends to have most of its energy in the lower bands. Since the values are larger towards the bottom, more bits are used to encode them. After the big value region, most of the values are -1, 0, or 1. That region is called the one’s region and can be represented with few bits. After that, all of the coefficients are 0.

### Like this:

Like Loading...