comparison 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
comparison
equal deleted inserted replaced
12252:b8211cda076d 12253:112b3a0db187
224 c->code_word = bit ? code_word - low_shift : code_word; 224 c->code_word = bit ? code_word - low_shift : code_word;
225 225
226 return bit; 226 return bit;
227 } 227 }
228 228
229 // branchy variant, to be used where there's a branch based on the bit decoded
230 static av_always_inline int vp56_rac_get_prob_branchy(VP56RangeCoder *c, int prob)
231 {
232 unsigned long code_word = vp56_rac_renorm(c);
233 unsigned low = 1 + (((c->high - 1) * prob) >> 8);
234 unsigned low_shift = low << 8;
235
236 if (code_word >= low_shift) {
237 c->high -= low;
238 c->code_word = code_word - low_shift;
239 return 1;
240 }
241
242 c->high = low;
243 c->code_word = code_word;
244 return 0;
245 }
246
229 static inline int vp56_rac_get(VP56RangeCoder *c) 247 static inline int vp56_rac_get(VP56RangeCoder *c)
230 { 248 {
231 unsigned int code_word = vp56_rac_renorm(c); 249 unsigned int code_word = vp56_rac_renorm(c);
232 /* equiprobable */ 250 /* equiprobable */
233 int low = (c->high + 1) >> 1; 251 int low = (c->high + 1) >> 1;