# HG changeset patch # User michael # Date 1229645139 0 # Node ID 64a0415da32fd4d5763fd79c06ff167abdf95536 # Parent ee23da1a0c743546a0a19a2e0e77e017e997d3c8 Optimize ctx calculation in decode_cabac_mb_mvd(), code by dark shikari. The case for 16x16 blocks becomes 10 cpu cycles faster on pentium dual, i could not find a speed difference in the case of subblocks though. diff -r ee23da1a0c74 -r 64a0415da32f h264.c --- a/h264.c Thu Dec 18 23:52:32 2008 +0000 +++ b/h264.c Fri Dec 19 00:05:39 2008 +0000 @@ -5039,14 +5039,8 @@ int amvd = abs( h->mvd_cache[list][scan8[n] - 1][l] ) + abs( h->mvd_cache[list][scan8[n] - 8][l] ); int ctxbase = (l == 0) ? 40 : 47; - int ctx, mvd; - - if( amvd < 3 ) - ctx = 0; - else if( amvd > 32 ) - ctx = 2; - else - ctx = 1; + int mvd; + int ctx = (amvd>2) + (amvd>32); if(!get_cabac(&h->cabac, &h->cabac_state[ctxbase+ctx])) return 0;