Ignore:
Timestamp:
04/24/07 15:07:19 (17 years ago)
Author:
r2d
Message:

Improved sv8 huffman decoding using canonical property of the huffman tables. It reduces memory usage for the tables and improves speed (mainly with small LUT size).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libmpc/trunk/libmpcdec/mpc_bits_reader.h

    r290 r296  
    7676}
    7777
     78static mpc_inline mpc_int32_t mpc_bits_can_dec(mpc_bits_reader * r, const mpc_can_data *can)
     79{
     80        mpc_uint16_t code;
     81        mpc_huff_lut tmp;
     82        const mpc_huffman * Table;
     83        code = ((r->buff[0] << 16) | (r->buff[1] << 8) | r->buff[2]) >> r->count;
     84
     85        tmp = can->lut[code >> (16 - LUT_DEPTH)];
     86        if (tmp.Length != 0) {
     87                r->buff -= (int)(r->count - tmp.Length) >> 3;
     88                r->count = (r->count - tmp.Length) & 0x07;
     89                return tmp.Value;
     90        }
     91
     92        Table = can->table + (unsigned char)tmp.Value;
     93        while (code < Table->Code) Table++;
     94
     95        r->buff -= (int)(r->count - Table->Length) >> 3;
     96        r->count = (r->count - Table->Length) & 0x07;
     97
     98        return can->sym[(Table->Value - (code >> (16 - Table->Length))) & 0xFF] ;
     99}
     100
    78101// LUT-based huffman decoding routine
    79102// works with maximum lengths up to 16
     
    93116
    94117        Table = lut->table + (unsigned char)tmp.Value;
    95 
    96118        while (code < Table->Code) Table++;
    97119
Note: See TracChangeset for help on using the changeset viewer.