diff --git a/stb_vorbis.c b/stb_vorbis.c index 9d02e7c..1daf60d 100644 --- a/stb_vorbis.c +++ b/stb_vorbis.c @@ -1548,14 +1548,6 @@ static uint32 get_bits(vorb *f, int n) return z; } -static int32 get_bits_signed(vorb *f, int n) -{ - uint32 z = get_bits(f, n); - if (z & (1 << (n-1))) - z += ~((1 << n) - 1); - return (int32) z; -} - // @OPTIMIZE: primary accumulator for huffman // expand the buffer to as many bits as possible without reading off end of packet // it might be nice to allow f->valid_bits and f->acc to be stored in registers, @@ -1639,23 +1631,6 @@ static int codebook_decode_scalar_raw(vorb *f, Codebook *c) return -1; } -static int codebook_decode_scalar(vorb *f, Codebook *c) -{ - int i; - if (f->valid_bits < STB_VORBIS_FAST_HUFFMAN_LENGTH) - prep_huffman(f); - // fast huffman table lookup - i = f->acc & FAST_HUFFMAN_TABLE_MASK; - i = c->fast_huffman[i]; - if (i >= 0) { - f->acc >>= c->codeword_lengths[i]; - f->valid_bits -= c->codeword_lengths[i]; - if (f->valid_bits < 0) { f->valid_bits = 0; return -1; } - return i; - } - return codebook_decode_scalar_raw(f,c); -} - #ifndef STB_VORBIS_NO_INLINE_DECODE #define DECODE_RAW(var, f,c) \ @@ -1674,6 +1649,23 @@ static int codebook_decode_scalar(vorb *f, Codebook *c) #else +static int codebook_decode_scalar(vorb *f, Codebook *c) +{ + int i; + if (f->valid_bits < STB_VORBIS_FAST_HUFFMAN_LENGTH) + prep_huffman(f); + // fast huffman table lookup + i = f->acc & FAST_HUFFMAN_TABLE_MASK; + i = c->fast_huffman[i]; + if (i >= 0) { + f->acc >>= c->codeword_lengths[i]; + f->valid_bits -= c->codeword_lengths[i]; + if (f->valid_bits < 0) { f->valid_bits = 0; return -1; } + return i; + } + return codebook_decode_scalar_raw(f,c); +} + #define DECODE_RAW(var,f,c) var = codebook_decode_scalar(f,c); #endif