[x264-devel] commit: Optimizations in predict_mv_direct (Jason Garrett-Glaser )

git version control git at videolan.org
Mon Dec 15 03:33:30 CET 2008


x264 | branch: master | Jason Garrett-Glaser <darkshikari at gmail.com> | Sun Dec 14 18:30:51 2008 -0800| [2b8d6a6f957be623186ea2a20bcb13c3637440b8] | committer: Jason Garrett-Glaser 

Optimizations in predict_mv_direct
Add some early terminations and minor optimizations
This change may also fix the extremely rare direct+threading MV bug.

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

 common/macroblock.c |   31 ++++++++++++++++---------------
 1 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/common/macroblock.c b/common/macroblock.c
index 25683f1..87dc185 100644
--- a/common/macroblock.c
+++ b/common/macroblock.c
@@ -273,29 +273,27 @@ static int x264_mb_predict_mv_direct16x16_spatial( x264_t *h )
 
     if( ref[0] < 0 && ref[1] < 0 )
     {
-        ref[0] =
-        ref[1] = 0;
-        *(uint64_t*)mv[0] = 0;
+        x264_macroblock_cache_ref( h, 0, 0, 4, 4, 0, 0 );
+        x264_macroblock_cache_ref( h, 0, 0, 4, 4, 1, 0 );
+        x264_macroblock_cache_mv( h, 0, 0, 4, 4, 0, 0 );
+        x264_macroblock_cache_mv( h, 0, 0, 4, 4, 1, 0 );
+        return 1;
     }
+
+    if( ref[0] >= 0 )
+        x264_mb_predict_mv_16x16( h, 0, ref[0], mv[0] );
     else
-    {
-        for( i_list=0; i_list<2; i_list++ )
-        {
-            if( ref[i_list] >= 0 )
-                x264_mb_predict_mv_16x16( h, i_list, ref[i_list], mv[i_list] );
-            else
-                *(uint32_t*)mv[i_list] = 0;
-        }
-    }
+        *(uint32_t*)mv[0] = 0;
+    if( ref[1] >= 0 )
+        x264_mb_predict_mv_16x16( h, 1, ref[1], mv[1] );
+    else
+        *(uint32_t*)mv[1] = 0;
 
     x264_macroblock_cache_ref( h, 0, 0, 4, 4, 0, ref[0] );
     x264_macroblock_cache_ref( h, 0, 0, 4, 4, 1, ref[1] );
     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( IS_INTRA( type_col ) )
-        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] ) )
@@ -308,6 +306,9 @@ static int x264_mb_predict_mv_direct16x16_spatial( x264_t *h )
         return 0;
     }
 
+    if( IS_INTRA( type_col ) || (ref[0]&&ref[1]) )
+        return 1;
+
     b8x8 = h->sps->b_direct8x8_inference ||
            (type_col != P_8x8 && type_col != B_SKIP && type_col != B_DIRECT && type_col != B_8x8);
 



More information about the x264-devel mailing list