Mercurial > libavcodec.hg
diff golomb.h @ 1234:fc2a7eefa9cc libavcodec
svq3 decoder by anonymous
| author | michaelni |
|---|---|
| date | Fri, 09 May 2003 22:16:14 +0000 |
| parents | 4e891257d3e2 |
| children | fa181d095027 |
line wrap: on
line diff
--- a/golomb.h Thu May 08 02:01:17 2003 +0000 +++ b/golomb.h Fri May 09 22:16:14 2003 +0000 @@ -25,6 +25,8 @@ * @author Michael Niedermayer <michaelni@gmx.at> */ +#define INVALID_VLC 0x80000000 + extern const uint8_t ff_golomb_vlc_len[512]; extern const uint8_t ff_ue_golomb_vlc_code[512]; extern const int8_t ff_se_golomb_vlc_code[512]; @@ -59,6 +61,27 @@ } } +static inline int svq3_get_ue_golomb(GetBitContext *gb){ + unsigned int buf; + int log; + + OPEN_READER(re, gb); + UPDATE_CACHE(re, gb); + buf=GET_CACHE(re, gb)|1; + + if((buf & 0xAAAAAAAA) == 0) + return INVALID_VLC; + + for(log=31; (buf & 0x80000000) == 0; log--){ + buf = (buf << 2) - ((buf << log) >> (log - 1)) + (buf >> 30); + } + + LAST_SKIP_BITS(re, gb, 63 - 2*log); + CLOSE_READER(re, gb); + + return ((buf << log) >> log) - 1; +} + /** * read unsigned truncated exp golomb code. */ @@ -112,6 +135,27 @@ } } +static inline int svq3_get_se_golomb(GetBitContext *gb){ + unsigned int buf; + int log; + + OPEN_READER(re, gb); + UPDATE_CACHE(re, gb); + buf=GET_CACHE(re, gb)|1; + + if((buf & 0xAAAAAAAA) == 0) + return INVALID_VLC; + + for(log=31; (buf & 0x80000000) == 0; log--){ + buf = (buf << 2) - ((buf << log) >> (log - 1)) + (buf >> 30); + } + + LAST_SKIP_BITS(re, gb, 63 - 2*log); + CLOSE_READER(re, gb); + + return (signed) (((((buf << log) >> log) - 1) ^ -(buf & 0x1)) + 1) >> 1; +} + #ifdef TRACE static inline int get_ue(GetBitContext *s, char *file, char *func, int line){
