[x264-devel] commit: omit P/B-skip mc from macroblock_encode if the pixels haven' t been overwritten since probe_skip (Jason Garrett-Glaser )

git version control git at videolan.org
Sun Apr 27 11:16:38 CEST 2008


x264 | branch: master | Jason Garrett-Glaser <darkshikari at gmail.com> | Thu Apr 24 18:55:30 2008 -0600| [2b3d65e7c2389fc4201dafb69422550e15ef0d85]

omit P/B-skip mc from macroblock_encode if the pixels haven't been overwritten since probe_skip

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

 common/common.h      |    3 +++
 encoder/analyse.c    |    3 +++
 encoder/macroblock.c |   30 +++++++++++++++++-------------
 3 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/common/common.h b/common/common.h
index 5adcefc..628c000 100644
--- a/common/common.h
+++ b/common/common.h
@@ -424,6 +424,9 @@ struct x264_t
          * 1 (non-RD only) = the DCT is still in h->dct, restore fdec and skip reconstruction.
          * 2 (RD only) = the DCT has since been overwritten by RD; restore that too. */
         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;
 
         struct
         {
diff --git a/encoder/analyse.c b/encoder/analyse.c
index de3cf57..9da9a5c 100644
--- a/encoder/analyse.c
+++ b/encoder/analyse.c
@@ -340,6 +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;
     }
 }
 
@@ -2388,6 +2389,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;
                     return;
                 }
             }
@@ -2404,6 +2406,7 @@ 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;
 
             x264_mb_analyse_load_costs( h, &analysis );
 
diff --git a/encoder/macroblock.c b/encoder/macroblock.c
index 0eafd58..20bc52a 100644
--- a/encoder/macroblock.c
+++ b/encoder/macroblock.c
@@ -293,19 +293,21 @@ void x264_macroblock_encode_pskip( x264_t *h )
     const int mvy = x264_clip3( h->mb.cache.mv[0][x264_scan8[0]][1],
                                 h->mb.mv_min[1], h->mb.mv_max[1] );
 
-    /* Motion compensation XXX probably unneeded */
-    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],
-                   mvx, mvy, 16, 16 );
+    /* don't do pskip motion compensation if it was already done in macroblock_analyse */
+    if( !h->mb.b_skip_pbskip_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],
+                       mvx, mvy, 16, 16 );
 
-    /* Chroma MC */
-    h->mc.mc_chroma( h->mb.pic.p_fdec[1],       FDEC_STRIDE,
-                     h->mb.pic.p_fref[0][0][4], h->mb.pic.i_stride[1],
-                     mvx, mvy, 8, 8 );
+        h->mc.mc_chroma( h->mb.pic.p_fdec[1],       FDEC_STRIDE,
+                         h->mb.pic.p_fref[0][0][4], h->mb.pic.i_stride[1],
+                         mvx, mvy, 8, 8 );
 
-    h->mc.mc_chroma( h->mb.pic.p_fdec[2],       FDEC_STRIDE,
-                     h->mb.pic.p_fref[0][0][5], h->mb.pic.i_stride[2],
-                     mvx, mvy, 8, 8 );
+        h->mc.mc_chroma( h->mb.pic.p_fdec[2],       FDEC_STRIDE,
+                         h->mb.pic.p_fref[0][0][5], h->mb.pic.i_stride[2],
+                         mvx, mvy, 8, 8 );
+    }
 
     x264_macroblock_encode_skip( h );
 }
@@ -346,8 +348,9 @@ void x264_macroblock_encode( x264_t *h )
     }
     if( h->mb.i_type == B_SKIP )
     {
-        /* XXX motion compensation is probably unneeded */
-        x264_mb_mc( h );
+        /* don't do bskip motion compensation if it was already done in macroblock_analyse */
+        if( !h->mb.b_skip_pbskip_mc )
+            x264_mb_mc( h );
         x264_macroblock_encode_skip( h );
         return;
     }
@@ -705,6 +708,7 @@ int x264_macroblock_probe_skip( x264_t *h, const int b_bidir )
         }
     }
 
+    h->mb.b_skip_pbskip_mc = 1;
     return 1;
 }
 



More information about the x264-devel mailing list