[x264-devel] commit: Backport various speed tweak ideas from ffmpeg ( Jason Garrett-Glaser )

git version control git at videolan.org
Mon Feb 15 10:20:25 CET 2010


x264 | branch: master | Jason Garrett-Glaser <darkshikari at gmail.com> | Fri Feb 12 21:15:12 2010 -0800| [41db4e8355e2390c430071c6f5ed9a2c8851e0a6] | committer: Jason Garrett-Glaser 

Backport various speed tweak ideas from ffmpeg
Add mv0 early termination to spatial direct calculation
Up to twice as fast direct mv calculation on near-motionless video.

Branchless CAVLC level code adjustment based on trailing ones.
A few clocks faster.

Check tc value before clipping in C version of deblock functions.
Much faster, but nobody uses those anyways.

Thanks to Michael Niedermayer for the ideas.

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

 common/frame.c      |    6 ++++--
 common/macroblock.c |    3 +++
 encoder/cavlc.c     |    7 +++----
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/common/frame.c b/common/frame.c
index 40cc78f..d89f5ab 100644
--- a/common/frame.c
+++ b/common/frame.c
@@ -472,12 +472,14 @@ static inline void deblock_luma_c( uint8_t *pix, int xstride, int ystride, int a
                 int delta;
                 if( abs( p2 - p0 ) < beta )
                 {
-                    pix[-2*xstride] = p1 + x264_clip3( (( p2 + ((p0 + q0 + 1) >> 1)) >> 1) - p1, -tc0[i], tc0[i] );
+                    if( tc0[i] )
+                        pix[-2*xstride] = p1 + x264_clip3( (( p2 + ((p0 + q0 + 1) >> 1)) >> 1) - p1, -tc0[i], tc0[i] );
                     tc++;
                 }
                 if( abs( q2 - q0 ) < beta )
                 {
-                    pix[ 1*xstride] = q1 + x264_clip3( (( q2 + ((p0 + q0 + 1) >> 1)) >> 1) - q1, -tc0[i], tc0[i] );
+                    if( tc0[i] )
+                        pix[ 1*xstride] = q1 + x264_clip3( (( q2 + ((p0 + q0 + 1) >> 1)) >> 1) - q1, -tc0[i], tc0[i] );
                     tc++;
                 }
 
diff --git a/common/macroblock.c b/common/macroblock.c
index cc9a3fd..278659c 100644
--- a/common/macroblock.c
+++ b/common/macroblock.c
@@ -272,6 +272,9 @@ static int x264_mb_predict_mv_direct16x16_spatial( x264_t *h )
     x264_macroblock_cache_mv_ptr( h, 0, 0, 4, 4, 0, mv[0] );
     x264_macroblock_cache_mv_ptr( h, 0, 0, 4, 4, 1, mv[1] );
 
+    if( !M64( mv ) )
+        return 1;
+
     if( h->param.i_threads > 1
         && ( mv[0][1] > h->mb.mv_max_spel[1]
           || mv[1][1] > h->mb.mv_max_spel[1] ) )
diff --git a/encoder/cavlc.c b/encoder/cavlc.c
index c65c9bd..85d2dde 100644
--- a/encoder/cavlc.c
+++ b/encoder/cavlc.c
@@ -147,10 +147,9 @@ static int block_residual_write_cavlc( x264_t *h, int i_ctxBlockCat, int16_t *l,
 
     if( i_trailing < i_total )
     {
-        int16_t val = runlevel.level[i_trailing];
-        int16_t val_original = runlevel.level[i_trailing]+LEVEL_TABLE_SIZE/2;
-        if( i_trailing < 3 )
-            val -= (val>>15)|1; /* as runlevel.level[i] can't be 1 for the first one if i_trailing < 3 */
+        int val = runlevel.level[i_trailing];
+        int val_original = runlevel.level[i_trailing]+LEVEL_TABLE_SIZE/2;
+        val -= ((val>>31)|1) & -(i_trailing < 3); /* as runlevel.level[i] can't be 1 for the first one if i_trailing < 3 */
         val += LEVEL_TABLE_SIZE/2;
 
         if( (unsigned)val_original < LEVEL_TABLE_SIZE )



More information about the x264-devel mailing list