]> git.videolan.org Git - x264.git/commitdiff
compute pskip_mv only once per macroblock, and store it
authorLoren Merritt <pengvado@videolan.org>
Mon, 9 Oct 2006 23:31:45 +0000 (23:31 +0000)
committerLoren Merritt <pengvado@videolan.org>
Mon, 9 Oct 2006 23:31:45 +0000 (23:31 +0000)
git-svn-id: svn://svn.videolan.org/x264/trunk@587 df754926-b1dd-0310-bc7b-ec298dee348c

common/common.h
common/macroblock.c
encoder/analyse.c
encoder/macroblock.c

index da003e355c6d130a7871b118ecc44a7dc3f33d8d..8c0cf1379b4f482dc32ac6d2e9e354d7af3e5483 100644 (file)
@@ -496,6 +496,7 @@ struct x264_t
 
             int16_t direct_mv[2][X264_SCAN8_SIZE][2];
             int8_t  direct_ref[2][X264_SCAN8_SIZE];
+            int     pskip_mv[2];
 
             /* number of neighbors (top and left) that used 8x8 dct */
             int     i_neighbour_transform_size;
index 4a24ff2cd41ac53e2b6a2878c222074f70eeeccf..41b4adaf0de3f630d56a301d37820f8be1d9ee8e 100644 (file)
@@ -1306,6 +1306,9 @@ void x264_macroblock_cache_load( x264_t *h, int i_mb_x, int i_mb_y )
                 h->mb.cache.skip[x264_scan8[4] - 8] = h->mb.skipbp[i_top_xy] & 0x8;
             }
         }
+
+        if( h->sh.i_type == SLICE_TYPE_P )
+            x264_mb_predict_mv_pskip( h, h->mb.cache.pskip_mv );
     }
 
     h->mb.i_neighbour4[0] =
index 2093ed1fe5748f4bd55f886cff05358f0132071d..39f1abfca619cd58a23151679d683ff62b886e56 100644 (file)
@@ -893,17 +893,16 @@ static void x264_mb_analyse_inter_p16x16( x264_t *h, x264_mb_analysis_t *a )
 
         /* early termination
          * SSD threshold would probably be better than SATD */
-        if( i_ref == 0 && a->b_try_pskip && m.cost-m.cost_mv < 300*a->i_lambda )
+        if( i_ref == 0
+            && a->b_try_pskip
+            && m.cost-m.cost_mv < 300*a->i_lambda
+            &&  abs(m.mv[0]-h->mb.cache.pskip_mv[0])
+              + abs(m.mv[1]-h->mb.cache.pskip_mv[1]) <= 1
+            && x264_macroblock_probe_pskip( h ) )
         {
-            int mvskip[2];
-            x264_mb_predict_mv_pskip( h, mvskip );
-            if( abs(m.mv[0]-mvskip[0]) + abs(m.mv[1]-mvskip[1]) <= 1
-                && x264_macroblock_probe_pskip( h ) )
-            {
-                h->mb.i_type = P_SKIP;
-                x264_analyse_update_cache( h, a );
-                return;
-            }
+            h->mb.i_type = P_SKIP;
+            x264_analyse_update_cache( h, a );
+            return;
         }
 
         m.cost += i_ref_cost;
@@ -922,16 +921,13 @@ static void x264_mb_analyse_inter_p16x16( x264_t *h, x264_mb_analysis_t *a )
     x264_macroblock_cache_ref( h, 0, 0, 4, 4, 0, a->l0.me16x16.i_ref );
 
     h->mb.i_type = P_L0;
-    if( a->b_mbrd && a->l0.i_ref == 0 )
+    if( a->b_mbrd && a->l0.i_ref == 0
+        && a->l0.me16x16.mv[0] == h->mb.cache.pskip_mv[0]
+        && a->l0.me16x16.mv[1] == h->mb.cache.pskip_mv[1] )
     {
-        int mvskip[2];
-        x264_mb_predict_mv_pskip( h, mvskip );
-        if( a->l0.me16x16.mv[0] == mvskip[0] && a->l0.me16x16.mv[1] == mvskip[1] )
-        {
-            h->mb.i_partition = D_16x16;
-            x264_macroblock_cache_mv( h, 0, 0, 4, 4, 0, a->l0.me16x16.mv[0], a->l0.me16x16.mv[1] );
-            a->l0.i_rd16x16 = x264_rd_cost_mb( h, a->i_lambda2 );
-        }
+        h->mb.i_partition = D_16x16;
+        x264_macroblock_cache_mv( h, 0, 0, 4, 4, 0, a->l0.me16x16.mv[0], a->l0.me16x16.mv[1] );
+        a->l0.i_rd16x16 = x264_rd_cost_mb( h, a->i_lambda2 );
     }
 }
 
@@ -2552,12 +2548,10 @@ static void x264_analyse_update_cache( x264_t *h, x264_mb_analysis_t *a  )
 
         case P_SKIP:
         {
-            int mvp[2];
-            x264_mb_predict_mv_pskip( h, mvp );
-            /* */
             h->mb.i_partition = D_16x16;
             x264_macroblock_cache_ref( h, 0, 0, 4, 4, 0, 0 );
-            x264_macroblock_cache_mv ( h, 0, 0, 4, 4, 0, mvp[0], mvp[1] );
+            x264_macroblock_cache_mv ( h, 0, 0, 4, 4, 0, h->mb.cache.pskip_mv[0],
+                                                         h->mb.cache.pskip_mv[1] );
             break;
         }
 
index e63dd36b406096d8caeb93ac42356a9ac98db20f..3a60d2d057bde6d9bec5d047619025ac74e05058 100644 (file)
@@ -638,17 +638,12 @@ void x264_macroblock_encode( x264_t *h )
     if( !b_force_no_skip )
     {
         if( h->mb.i_type == P_L0 && h->mb.i_partition == D_16x16 &&
-            h->mb.i_cbp_luma == 0x00 && h->mb.i_cbp_chroma== 0x00 &&
+            h->mb.i_cbp_luma == 0x00 && h->mb.i_cbp_chroma == 0x00 &&
+            h->mb.cache.mv[0][x264_scan8[0]][0] == h->mb.cache.pskip_mv[0] &&
+            h->mb.cache.mv[0][x264_scan8[0]][1] == h->mb.cache.pskip_mv[1] &&
             h->mb.cache.ref[0][x264_scan8[0]] == 0 )
         {
-            int mvp[2];
-
-            x264_mb_predict_mv_pskip( h, mvp );
-            if( h->mb.cache.mv[0][x264_scan8[0]][0] == mvp[0] &&
-                h->mb.cache.mv[0][x264_scan8[0]][1] == mvp[1] )
-            {
-                h->mb.i_type = P_SKIP;
-            }
+            h->mb.i_type = P_SKIP;
         }
 
         /* Check for B_SKIP */
@@ -681,9 +676,8 @@ int x264_macroblock_probe_skip( x264_t *h, int b_bidir )
     if( !b_bidir )
     {
         /* Get the MV */
-        x264_mb_predict_mv_pskip( h, mvp );
-        mvp[0] = x264_clip3( mvp[0], h->mb.mv_min[0], h->mb.mv_max[0] );
-        mvp[1] = x264_clip3( mvp[1], h->mb.mv_min[1], h->mb.mv_max[1] );
+        mvp[0] = x264_clip3( h->mb.cache.pskip_mv[0], h->mb.mv_min[0], h->mb.mv_max[0] );
+        mvp[1] = x264_clip3( h->mb.cache.pskip_mv[1], h->mb.mv_min[1], h->mb.mv_max[1] );
 
         /* Motion compensation */
         h->mc.mc_luma( h->mb.pic.p_fref[0][0], h->mb.pic.i_stride[0],