diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2003-05-13 00:46:42 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2003-05-13 00:46:42 +0000 |
commit | 4704097a2b557fa9e58def0956dbdef7842a3fd3 (patch) | |
tree | c1ad308caf530a66679e417e5bf834ce7c23ca75 /libavcodec/golomb.h | |
parent | f138f88364f88cdc1ecd99f55b38c73cd5c7919e (diff) | |
download | ffmpeg-4704097a2b557fa9e58def0956dbdef7842a3fd3.tar.gz |
optimizations
Originally committed as revision 1867 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/golomb.h')
-rw-r--r-- | libavcodec/golomb.h | 62 |
1 files changed, 42 insertions, 20 deletions
diff --git a/libavcodec/golomb.h b/libavcodec/golomb.h index 510d913ae1..f1e6d6d987 100644 --- a/libavcodec/golomb.h +++ b/libavcodec/golomb.h @@ -32,6 +32,10 @@ extern const uint8_t ff_ue_golomb_vlc_code[512]; extern const int8_t ff_se_golomb_vlc_code[512]; extern const uint8_t ff_ue_golomb_len[256]; +extern const uint8_t ff_interleaved_golomb_vlc_len[256]; +extern const uint8_t ff_interleaved_ue_golomb_vlc_code[256]; +extern const int8_t ff_interleaved_se_golomb_vlc_code[256]; + /** * read unsigned exp golomb code. @@ -62,24 +66,33 @@ static inline int get_ue_golomb(GetBitContext *gb){ } static inline int svq3_get_ue_golomb(GetBitContext *gb){ - unsigned int buf; + uint32_t buf; int log; OPEN_READER(re, gb); UPDATE_CACHE(re, gb); - buf=GET_CACHE(re, gb)|1; - - if((buf & 0xAAAAAAAA) == 0) - return INVALID_VLC; + buf=GET_CACHE(re, gb); + + if(buf&0xAA800000){ + buf >>= 32 - 8; + LAST_SKIP_BITS(re, gb, ff_interleaved_golomb_vlc_len[buf]); + CLOSE_READER(re, gb); + + return ff_interleaved_ue_golomb_vlc_code[buf]; + }else{ + buf|=1; + if((buf & 0xAAAAAAAA) == 0) + return INVALID_VLC; - for(log=31; (buf & 0x80000000) == 0; log--){ - buf = (buf << 2) - ((buf << log) >> (log - 1)) + (buf >> 30); - } + 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); + LAST_SKIP_BITS(re, gb, 63 - 2*log); + CLOSE_READER(re, gb); - return ((buf << log) >> log) - 1; + return ((buf << log) >> log) - 1; + } } /** @@ -141,19 +154,28 @@ static inline int svq3_get_se_golomb(GetBitContext *gb){ OPEN_READER(re, gb); UPDATE_CACHE(re, gb); - buf=GET_CACHE(re, gb)|1; + buf=GET_CACHE(re, gb); - if((buf & 0xAAAAAAAA) == 0) - return INVALID_VLC; + if(buf&0xAA800000){ + buf >>= 32 - 8; + LAST_SKIP_BITS(re, gb, ff_interleaved_golomb_vlc_len[buf]); + CLOSE_READER(re, gb); + + return ff_interleaved_se_golomb_vlc_code[buf]; + }else{ + buf |=1; + if((buf & 0xAAAAAAAA) == 0) + return INVALID_VLC; - for(log=31; (buf & 0x80000000) == 0; log--){ - buf = (buf << 2) - ((buf << log) >> (log - 1)) + (buf >> 30); - } + 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); + LAST_SKIP_BITS(re, gb, 63 - 2*log); + CLOSE_READER(re, gb); - return (signed) (((((buf << log) >> log) - 1) ^ -(buf & 0x1)) + 1) >> 1; + return (signed) (((((buf << log) >> log) - 1) ^ -(buf & 0x1)) + 1) >> 1; + } } #ifdef TRACE |