Ignore:
Timestamp:
04/23/07 16:47:30 (17 years ago)
Author:
r2d
Message:

improved decoder speed using LUT for huffman decoding. profiling/bench needed (see LUT_DEPTH parameter in huffman.h)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libmpc/branches/r2d/libmpcdec/mpc_bits_reader.h

    r288 r290  
    6161}
    6262
    63 // FIXME : this must be implemented with a lookup table
    6463// basic huffman decoding routine
    6564// works with maximum lengths up to 16
     
    6867        mpc_uint16_t code;
    6968        code = ((r->buff[0] << 16) | (r->buff[1] << 8) | r->buff[2]) >> r->count;
     69
     70        while (code < Table->Code) Table++;
     71
     72        r->buff -= (int)(r->count - Table->Length) >> 3;
     73        r->count = (r->count - Table->Length) & 0x07;
     74
     75        return Table->Value;
     76}
     77
     78// LUT-based huffman decoding routine
     79// works with maximum lengths up to 16
     80static mpc_inline mpc_int32_t mpc_bits_huff_lut(mpc_bits_reader * r, const mpc_lut_data *lut)
     81{
     82        mpc_uint16_t code;
     83        mpc_huff_lut tmp;
     84        const mpc_huffman * Table;
     85        code = ((r->buff[0] << 16) | (r->buff[1] << 8) | r->buff[2]) >> r->count;
     86
     87        tmp = lut->lut[code >> (16 - LUT_DEPTH)];
     88        if (tmp.Length != 0) {
     89                r->buff -= (int)(r->count - tmp.Length) >> 3;
     90                r->count = (r->count - tmp.Length) & 0x07;
     91                return tmp.Value;
     92        }
     93
     94        Table = lut->table + (unsigned char)tmp.Value;
    7095
    7196        while (code < Table->Code) Table++;
Note: See TracChangeset for help on using the changeset viewer.