]> granicus.if.org Git - libx264/commitdiff
Faster spatial direct MV prediction
authorFiona Glaser <fiona@x264.com>
Thu, 14 May 2009 11:11:15 +0000 (04:11 -0700)
committerFiona Glaser <fiona@x264.com>
Thu, 14 May 2009 11:11:15 +0000 (04:11 -0700)
unroll/tweak col_zero_flag

common/macroblock.c

index 54bc09c97f69a69b4ee6688e37379c581d3ea82e..1d5abe1ee95d06ca77317009e0bd4f4558a914d6 100644 (file)
@@ -293,16 +293,21 @@ static int x264_mb_predict_mv_direct16x16_spatial( x264_t *h )
         const int x8 = i8%2;
         const int y8 = i8/2;
         const int o8 = x8 + y8 * h->mb.i_b8_stride;
-        if( l1ref0[o8] == 0 || ( l1ref0[o8] < 0 && l1ref1[o8] == 0 ) )
+        const int o4 = 3*(x8 + y8 * h->mb.i_b4_stride);
+        if( l1ref0[o8] == 0 )
         {
-            const int16_t (*l1mv)[2] = (l1ref0[o8] == 0) ? l1mv0 : l1mv1;
-            const int16_t *mvcol = l1mv[3*x8 + 3*y8 * h->mb.i_b4_stride];
-            if( abs( mvcol[0] ) <= 1 && abs( mvcol[1] ) <= 1 )
+            if( abs( l1mv0[o4][0] ) <= 1 && abs( l1mv0[o4][1] ) <= 1 )
             {
-                if( ref[0] == 0 )
-                    x264_macroblock_cache_mv( h, 2*x8, 2*y8, 2, 2, 0, 0 );
-                if( ref[1] == 0 )
-                    x264_macroblock_cache_mv( h, 2*x8, 2*y8, 2, 2, 1, 0 );
+                if( ref[0] == 0 ) x264_macroblock_cache_mv( h, 2*x8, 2*y8, 2, 2, 0, 0 );
+                if( ref[1] == 0 ) x264_macroblock_cache_mv( h, 2*x8, 2*y8, 2, 2, 1, 0 );
+            }
+        }
+        else if( l1ref0[o8] < 0 && l1ref1[o8] == 0 )
+        {
+            if( abs( l1mv1[o4][0] ) <= 1 && abs( l1mv1[o4][1] ) <= 1 )
+            {
+                if( ref[0] == 0 ) x264_macroblock_cache_mv( h, 2*x8, 2*y8, 2, 2, 0, 0 );
+                if( ref[1] == 0 ) x264_macroblock_cache_mv( h, 2*x8, 2*y8, 2, 2, 1, 0 );
             }
         }
     }