Faster CAVLC decoding of trailing_ones. Based on a patch by dark shikari.
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 18 Dec 2008 16:11:19 +0000 (16:11 +0000)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 18 Dec 2008 16:11:19 +0000 (16:11 +0000)
decode_residual is about 3.3% faster.

Originally committed as revision 16219 to svn://svn.ffmpeg.org/ffmpeg/trunk

libavcodec/h264.c

index d3a8e56..6f68095 100644 (file)
@@ -4087,9 +4087,11 @@ static int decode_residual(H264Context *h, GetBitContext *gb, DCTELEM *block, in
     tprintf(h->s.avctx, "trailing:%d, total:%d\n", trailing_ones, total_coeff);
     assert(total_coeff<=16);
 
-    for(i=0; i<trailing_ones; i++){
-        level[i]= 1 - 2*get_bits1(gb);
-    }
+    i = show_bits(gb, 3);
+    skip_bits(gb, trailing_ones);
+    level[0] = 1-((i&4)>>1);
+    level[1] = 1-((i&2)   );
+    level[2] = 1-((i&1)<<1);
 
     if(trailing_ones<total_coeff) {
         int level_code, mask;