X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=bitstream.h;h=46038842092121e8dc2c7be675f07d01408738e6;hp=d13ef4c2bd6946deff17e9104432052b1319b25e;hb=5a8158c86d30905b0684fdf4e74a9bb1d1ba767b;hpb=4163d3460d5dc61264636ebeb7b3fe8052b93568 diff --git a/bitstream.h b/bitstream.h index d13ef4c2..46038842 100644 --- a/bitstream.h +++ b/bitstream.h @@ -9,11 +9,6 @@ /** \file bitstream.h Bitstream structures and inline functions. */ -#define AV_RB32(x) ((((const uint8_t*)(x))[0] << 24) | \ - (((const uint8_t*)(x))[1] << 16) | \ - (((const uint8_t*)(x))[2] << 8) | \ - ((const uint8_t*)(x))[3]) - /** Structure for bistream I/O. */ struct getbit_context { /* Start of the internal buffer. */ @@ -35,8 +30,9 @@ struct vlc { static inline uint32_t show_bits(struct getbit_context *gbc, int num) { int idx = gbc->index; - uint32_t x = AV_RB32(gbc->buffer + (idx >> 3)) << (idx & 7); - return x >> (32 - num); + const uint8_t *p = gbc->buffer + (idx >> 3); + uint32_t x = ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]); + return (x << (idx & 7)) >> (32 - num); } static inline int get_bits_count(struct getbit_context *gbc) @@ -57,7 +53,7 @@ static inline unsigned int get_bits(struct getbit_context *gbc, int n) } /* This is rather hot, we can do better than get_bits(gbc, 1). */ -static inline unsigned int get_bits1(struct getbit_context *gbc) +static inline unsigned int get_bit(struct getbit_context *gbc) { int idx = gbc->index++; uint8_t tmp = gbc->buffer[idx >> 3], mask = (1 << (7 - (idx & 7))); @@ -83,40 +79,7 @@ static inline void init_get_bits(struct getbit_context *gbc, void init_vlc(struct vlc *vlc, int nb_bits, int nb_codes, const void *bits, const void *codes, int codes_size); - void free_vlc(struct vlc *vlc); +int get_vlc(struct getbit_context *gbc, VLC_TYPE(*table)[2], int bits, + int max_depth); -/** - * Parse a vlc code. - * - * \param bits The number of bits which will be read at once, must be - * identical to nb_bits in init_vlc() - * - * \param max_depth The number of times bits bits must be read to completely - * read the longest vlc code = (max_vlc_length + bits - 1) / bits. - */ -static inline int get_vlc(struct getbit_context *gbc, VLC_TYPE(*table)[2], - int bits, int max_depth) -{ - int n, idx, nb_bits, code; - - idx = show_bits(gbc, bits); - code = table[idx][0]; - n = table[idx][1]; - if (max_depth > 1 && n < 0) { - skip_bits(gbc, bits); - nb_bits = -n; - idx = show_bits(gbc, nb_bits) + code; - code = table[idx][0]; - n = table[idx][1]; - if (max_depth > 2 && n < 0) { - skip_bits(gbc, nb_bits); - nb_bits = -n; - idx = show_bits(gbc, nb_bits) + code; - code = table[idx][0]; - n = table[idx][1]; - } - } - skip_bits(gbc, n); - return code; -}