diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2003-05-09 22:16:14 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2003-05-09 22:16:14 +0000 |
commit | 8b82a9567547f1ca7ab54f97982e180f42795664 (patch) | |
tree | 2c00a56ee1166a3421470397d759f0573303d4eb /libavcodec/golomb.h | |
parent | a466e345e41253aa2c8cf9d62ff32be8d2cde0fa (diff) | |
download | ffmpeg-8b82a9567547f1ca7ab54f97982e180f42795664.tar.gz |
svq3 decoder by anonymous
Originally committed as revision 1845 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/golomb.h')
-rw-r--r-- | libavcodec/golomb.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/libavcodec/golomb.h b/libavcodec/golomb.h index 91c699367c..510d913ae1 100644 --- a/libavcodec/golomb.h +++ b/libavcodec/golomb.h @@ -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 get_ue_golomb(GetBitContext *gb){ } } +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 get_se_golomb(GetBitContext *gb){ } } +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){ |