diff options
author | David Conrad <lessen42@gmail.com> | 2010-07-23 21:46:17 +0000 |
---|---|---|
committer | David Conrad <lessen42@gmail.com> | 2010-07-23 21:46:17 +0000 |
commit | fe1b5d974acf7736151e2e13f2498f4fbd6af765 (patch) | |
tree | a5135bb741533094e8824b8b9ff63659aa43a811 /libavcodec/vp56.h | |
parent | 5474ec2ac8a4964c4d6a0b51cd00a0ec2e7bb9a6 (diff) | |
download | ffmpeg-fe1b5d974acf7736151e2e13f2498f4fbd6af765.tar.gz |
Decode DCT tokens by branching to a different code path for each branch
on the huffman tree, instead of traversing the tree in a while loop.
Based on the similar optimization in libvpx's detokenize.c
10% faster at normal bitrates, and 30% faster for high-bitrate intra-only
Originally committed as revision 24468 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/vp56.h')
-rw-r--r-- | libavcodec/vp56.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/libavcodec/vp56.h b/libavcodec/vp56.h index b7c1887596..ad07a49e9b 100644 --- a/libavcodec/vp56.h +++ b/libavcodec/vp56.h @@ -226,6 +226,24 @@ static inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob) return bit; } +// branchy variant, to be used where there's a branch based on the bit decoded +static av_always_inline int vp56_rac_get_prob_branchy(VP56RangeCoder *c, int prob) +{ + unsigned long code_word = vp56_rac_renorm(c); + unsigned low = 1 + (((c->high - 1) * prob) >> 8); + unsigned low_shift = low << 8; + + if (code_word >= low_shift) { + c->high -= low; + c->code_word = code_word - low_shift; + return 1; + } + + c->high = low; + c->code_word = code_word; + return 0; +} + static inline int vp56_rac_get(VP56RangeCoder *c) { unsigned int code_word = vp56_rac_renorm(c); |