]> granicus.if.org Git - libx264/commitdiff
omit redundant mc after non-rdo dct size decision, and in b-direct rdo
authorFiona Glaser <fiona@x264.com>
Sat, 24 May 2008 03:22:29 +0000 (21:22 -0600)
committerLoren Merritt <pengvado@akuvian.org>
Tue, 3 Jun 2008 22:21:23 +0000 (16:21 -0600)
common/common.h
common/macroblock.c
encoder/analyse.c
encoder/macroblock.c
encoder/me.c

index 425fc8fa73a49c54f48ab8156a80c96e6bac098d..bb72957b9aad1e6c2504c21bdddfe078a8d655f7 100644 (file)
@@ -429,7 +429,7 @@ struct x264_t
         int i_skip_intra;
         /* skip flag for P/B-skip motion compensation */
         /* if we've already done skip MC, we don't need to do it again */
-        int b_skip_pbskip_mc;
+        int b_skip_mc;
 
         struct
         {
index 7c8b939fb937f6815d532e90ce9869c8a2eae1b5..d6406644d8a5fd4f082eec05d7ba4f92fca6af71 100644 (file)
@@ -308,7 +308,7 @@ static int x264_mb_predict_mv_direct16x16_temporal( x264_t *h )
 static int x264_mb_predict_mv_direct16x16_spatial( x264_t *h )
 {
     int ref[2];
-    DECLARE_ALIGNED_4( int16_t mv[2][2] );
+    DECLARE_ALIGNED_8( int16_t mv[2][2] );
     int i_list;
     int i8, i4;
     int b8x8;
index c0c44b39a0ff53824ad72c9871bf048da3f228f4..24d594a974f6501397df1446b57d52a1ec5d9903 100644 (file)
@@ -340,7 +340,7 @@ static void x264_mb_analyse_init( x264_t *h, x264_mb_analysis_t *a, int i_qp )
                 a->b_fast_intra = 1;
             }
         }
-        h->mb.b_skip_pbskip_mc = 0;
+        h->mb.b_skip_mc = 0;
     }
 }
 
@@ -1916,8 +1916,12 @@ static void x264_mb_analyse_b_rd( x264_t *h, x264_mb_analysis_t *a, int i_satd_i
     if( a->b_direct_available && a->i_rd16x16direct == COST_MAX )
     {
         h->mb.i_type = B_DIRECT;
+        /* Assumes direct/skip MC is still in fdec */
+        /* Requires b-rdo to be done before intra analysis */
+        h->mb.b_skip_mc = 1;
         x264_analyse_update_cache( h, a );
         a->i_rd16x16direct = x264_rd_cost_mb( h, a->i_lambda2 );
+        h->mb.b_skip_mc = 0;
     }
 
     //FIXME not all the update_cache calls are needed
@@ -2009,7 +2013,7 @@ static inline void x264_mb_analyse_transform( x264_t *h )
     if( x264_mb_transform_8x8_allowed( h ) && h->param.analyse.b_transform_8x8 )
     {
         int i_cost4, i_cost8;
-        /* FIXME only luma mc is needed */
+        /* Only luma MC is really needed, but the full MC is re-used in macroblock_encode. */
         x264_mb_mc( h );
 
         i_cost8 = h->pixf.sa8d[PIXEL_16x16]( h->mb.pic.p_fenc[0], FENC_STRIDE,
@@ -2018,6 +2022,7 @@ static inline void x264_mb_analyse_transform( x264_t *h )
                                              h->mb.pic.p_fdec[0], FDEC_STRIDE );
 
         h->mb.b_transform_8x8 = i_cost8 < i_cost4;
+        h->mb.b_skip_mc = 1;
     }
 }
 
@@ -2387,7 +2392,7 @@ void x264_macroblock_analyse( x264_t *h )
                 {
                     h->mb.i_type = B_SKIP;
                     x264_analyse_update_cache( h, &analysis );
-                    h->mb.b_skip_pbskip_mc = 1;
+                    h->mb.b_skip_mc = 1;
                     return;
                 }
             }
@@ -2404,7 +2409,8 @@ void x264_macroblock_analyse( x264_t *h )
             const unsigned int flags = h->param.analyse.inter;
             int i_type;
             int i_partition;
-            h->mb.b_skip_pbskip_mc = 0;
+            int i_satd_inter = 0; // shut up uninitialized warning
+            h->mb.b_skip_mc = 0;
 
             x264_mb_analyse_load_costs( h, &analysis );
 
@@ -2547,11 +2553,9 @@ void x264_macroblock_analyse( x264_t *h )
                 }
             }
 
-            x264_mb_analyse_intra( h, &analysis, i_cost );
-
             if( analysis.b_mbrd )
             {
-                int i_satd_inter = i_cost;
+                i_satd_inter = i_cost;
                 x264_mb_analyse_b_rd( h, &analysis, i_satd_inter );
                 i_type = B_SKIP;
                 i_cost = i_bskip_cost;
@@ -2566,6 +2570,12 @@ void x264_macroblock_analyse( x264_t *h )
 
                 h->mb.i_type = i_type;
                 h->mb.i_partition = i_partition;
+            }
+            
+            x264_mb_analyse_intra( h, &analysis, i_satd_inter );
+
+            if( analysis.b_mbrd )
+            {
                 x264_mb_analyse_transform_rd( h, &analysis, &i_satd_inter, &i_cost );
                 x264_intra_rd( h, &analysis, i_satd_inter * 17/16 );
             }
index 74c9413055890a52c8bb6e0b147c93270d443fc7..7ac93b11902cb5161597c5b3b877318d7252bd14 100644 (file)
@@ -292,7 +292,7 @@ void x264_macroblock_encode_pskip( x264_t *h )
                                 h->mb.mv_min[1], h->mb.mv_max[1] );
 
     /* don't do pskip motion compensation if it was already done in macroblock_analyse */
-    if( !h->mb.b_skip_pbskip_mc )
+    if( !h->mb.b_skip_mc )
     {
         h->mc.mc_luma( h->mb.pic.p_fdec[0],    FDEC_STRIDE,
                        h->mb.pic.p_fref[0][0], h->mb.pic.i_stride[0],
@@ -348,7 +348,7 @@ void x264_macroblock_encode( x264_t *h )
     if( h->mb.i_type == B_SKIP )
     {
         /* don't do bskip motion compensation if it was already done in macroblock_analyse */
-        if( !h->mb.b_skip_pbskip_mc )
+        if( !h->mb.b_skip_mc )
             x264_mb_mc( h );
         x264_macroblock_encode_skip( h );
         return;
@@ -417,8 +417,9 @@ void x264_macroblock_encode( x264_t *h )
         int i8x8, i4x4;
         int i_decimate_mb = 0;
 
-        /* Motion compensation */
-        x264_mb_mc( h );
+        /* Don't repeat motion compensation if it was already done in non-RD transform analysis */
+        if( !h->mb.b_skip_mc )
+            x264_mb_mc( h );
 
         if( h->mb.b_lossless )
         {
@@ -690,7 +691,7 @@ int x264_macroblock_probe_skip( x264_t *h, const int b_bidir )
         }
     }
 
-    h->mb.b_skip_pbskip_mc = 1;
+    h->mb.b_skip_mc = 1;
     return 1;
 }
 
index 7598b76f9014ea17a5c209ccc6d60c2d62ccdd7b..0dd63782bfae1098aabf6b1609ccc4b06556a5fb 100644 (file)
@@ -786,7 +786,7 @@ if( pass == 0 || !visited[(m0x)&7][(m0y)&7][(m1x)&7][(m1y)&7] ) \
     int i0 = 4 + 3*(m0x-om0x) + (m0y-om0y); \
     int i1 = 4 + 3*(m1x-om1x) + (m1y-om1y); \
     visited[(m0x)&7][(m0y)&7][(m1x)&7][(m1y)&7] = 1; \
-    memcpy( pix, pix0[i0], bs ); \
+    h->mc.memcpy_aligned( pix, pix0[i0], bs ); \
     if( i_weight == 32 ) \
         h->mc.avg[i_pixel]( pix, bw, pix1[i1], bw ); \
     else \