Mercurial > libavcodec.hg
diff vp56.h @ 12253:112b3a0db187 libavcodec
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
author | conrad |
---|---|
date | Fri, 23 Jul 2010 21:46:17 +0000 |
parents | b8211cda076d |
children | 6e6c92d36c4b |
line wrap: on
line diff
--- a/vp56.h Fri Jul 23 21:46:14 2010 +0000 +++ b/vp56.h Fri Jul 23 21:46:17 2010 +0000 @@ -226,6 +226,24 @@ 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);