[x264-devel] commit: Faster signed golomb coding (Jason Garrett-Glaser )

git version control git at videolan.org
Tue May 19 04:41:41 CEST 2009


x264 | branch: master | Jason Garrett-Glaser <darkshikari at gmail.com> | Fri May 15 20:07:59 2009 -0700| [0e050663d16cd5b095723bd00136873aa461d5cd] | committer: Jason Garrett-Glaser 

Faster signed golomb coding
3% faster CAVLC RDO and bitstream writing.

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=0e050663d16cd5b095723bd00136873aa461d5cd
---

 common/bs.h |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/common/bs.h b/common/bs.h
index e36549e..eafa8f8 100644
--- a/common/bs.h
+++ b/common/bs.h
@@ -219,7 +219,12 @@ static inline void bs_write_ue( bs_t *s, int val )
 static inline void bs_write_se( bs_t *s, int val )
 {
     int size = 0;
-    int tmp = val = val <= 0 ? -val*2+1 : val*2;
+    /* Faster than (val <= 0 ? -val*2+1 : val*2) */
+    /* 4 instructions on x86, 3 on ARM */
+    int tmp = 1 - val*2;
+    if( tmp < 0 ) tmp = val*2;
+    val = tmp;
+
     if( tmp >= 0x100 )
     {
         size = 16;
@@ -258,7 +263,12 @@ static inline int bs_size_ue_big( unsigned int val )
 
 static inline int bs_size_se( int val )
 {
-    return bs_size_ue_big( val <= 0 ? -val*2 : val*2-1 );
+    int tmp = 1 - val*2;
+    if( tmp < 0 ) tmp = val*2;
+    if( tmp < 256 )
+        return x264_ue_size_tab[tmp];
+    else
+        return x264_ue_size_tab[tmp>>8]+16;
 }
 
 static inline int bs_size_te( int x, int val )



More information about the x264-devel mailing list