[Ffmpeg-cvslog] r6607 - in trunk/libavcodec: cabac.c cabac.h

michael subversion
Mon Oct 9 22:44:11 CEST 2006


Author: michael
Date: Mon Oct  9 22:44:11 2006
New Revision: 6607

Modified:
   trunk/libavcodec/cabac.c
   trunk/libavcodec/cabac.h

Log:
optimize branchless C CABAC decoder


Modified: trunk/libavcodec/cabac.c
==============================================================================
--- trunk/libavcodec/cabac.c	(original)
+++ trunk/libavcodec/cabac.c	Mon Oct  9 22:44:11 2006
@@ -133,11 +133,19 @@
         c->mps_state[2*i+3]= 2*mps_state[i]+3;
 
         if( i ){
+#ifdef BRANCHLESS_CABAD
+            c->mps_state[-2*i-3]= 2*lps_state[i]+2; //FIXME yes this is not valid C but iam lazy, cleanup welcome
+            c->mps_state[-2*i-4]= 2*lps_state[i]+3;
+        }else{
+            c->mps_state[-2*i-3]= 3;
+            c->mps_state[-2*i-4]= 2;
+#else
             c->lps_state[2*i+2]= 2*lps_state[i]+2;
             c->lps_state[2*i+3]= 2*lps_state[i]+3;
         }else{
             c->lps_state[2*i+2]= 3;
             c->lps_state[2*i+3]= 2;
+#endif
         }
     }
 }

Modified: trunk/libavcodec/cabac.h
==============================================================================
--- trunk/libavcodec/cabac.h	(original)
+++ trunk/libavcodec/cabac.h	Mon Oct  9 22:44:11 2006
@@ -452,7 +452,7 @@
     int bit, lps_mask attribute_unused;
 
     c->range -= RangeLPS;
-#if 1
+#ifndef BRANCHLESS_CABAD
     if(c->low < c->range){
         bit= s&1;
         *state= c->mps_state[s];
@@ -475,8 +475,9 @@
     c->low -= c->range & lps_mask;
     c->range += (RangeLPS - c->range) & lps_mask;
 
-    bit= (s^lps_mask)&1;
-    *state= c->mps_state[s - (130&lps_mask)];
+    s^=lps_mask;
+    *state= c->mps_state[s];
+    bit= s&1;
 
     lps_mask= ff_h264_norm_shift[c->range>>(CABAC_BITS+3)];
     c->range<<= lps_mask;




More information about the ffmpeg-cvslog mailing list