[x264-devel] commit: Eliminate edge cases for MV predictors (Jason Garrett-Glaser )

git at videolan.org git at videolan.org
Thu Jul 15 14:14:24 CEST 2010


x264 | branch: stable | Jason Garrett-Glaser <darkshikari at gmail.com> | Tue Jul  6 13:39:44 2010 -0700| [04e40ff9f61672bec01230ce6d70bc487f12bc2c] | committer: Jason Garrett-Glaser 

Eliminate edge cases for MV predictors
Saves a few clocks in mv pred.

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

 common/frame.c      |    7 +++++--
 common/macroblock.c |    9 +++++++--
 common/mvpred.c     |   17 ++++-------------
 encoder/analyse.c   |    4 ++--
 4 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/common/frame.c b/common/frame.c
index d862468..fa48f5a 100644
--- a/common/frame.c
+++ b/common/frame.c
@@ -103,7 +103,9 @@ x264_frame_t *x264_frame_new( x264_t *h, int b_fdec )
         CHECKED_MALLOC( frame->mb_type, i_mb_count * sizeof(int8_t));
         CHECKED_MALLOC( frame->mb_partition, i_mb_count * sizeof(uint8_t));
         CHECKED_MALLOC( frame->mv[0], 2*16 * i_mb_count * sizeof(int16_t) );
-        CHECKED_MALLOC( frame->mv16x16, 2*i_mb_count * sizeof(int16_t) );
+        CHECKED_MALLOC( frame->mv16x16, 2*(i_mb_count+1) * sizeof(int16_t) );
+        M32( frame->mv16x16[0] ) = 0;
+        frame->mv16x16++;
         CHECKED_MALLOC( frame->ref[0], 4 * i_mb_count * sizeof(int8_t) );
         if( h->param.i_bframe )
         {
@@ -205,7 +207,8 @@ void x264_frame_delete( x264_frame_t *frame )
         x264_free( frame->mb_partition );
         x264_free( frame->mv[0] );
         x264_free( frame->mv[1] );
-        x264_free( frame->mv16x16 );
+        if( frame->mv16x16 )
+            x264_free( frame->mv16x16-1 );
         x264_free( frame->ref[0] );
         x264_free( frame->ref[1] );
         x264_pthread_mutex_destroy( &frame->mutex );
diff --git a/common/macroblock.c b/common/macroblock.c
index ebff1c5..a7085aa 100644
--- a/common/macroblock.c
+++ b/common/macroblock.c
@@ -251,7 +251,11 @@ int x264_macroblock_cache_allocate( x264_t *h )
             i_refs = X264_MIN(16, i_refs + 1); //blind weights add one duplicate frame
 
         for( int j = !i; j < i_refs; j++ )
-            CHECKED_MALLOC( h->mb.mvr[i][j], 2 * i_mb_count * sizeof(int16_t) );
+        {
+            CHECKED_MALLOC( h->mb.mvr[i][j], 2 * (i_mb_count + 1) * sizeof(int16_t) );
+            M32( h->mb.mvr[i][j][0] ) = 0;
+            h->mb.mvr[i][j]++;
+        }
     }
 
     if( h->param.analyse.i_weighted_pred )
@@ -300,7 +304,8 @@ void x264_macroblock_cache_free( x264_t *h )
 {
     for( int i = 0; i < 2; i++ )
         for( int j = !i; j < 32; j++ )
-            x264_free( h->mb.mvr[i][j] );
+            if( h->mb.mvr[i][j] )
+                x264_free( h->mb.mvr[i][j]-1 );
     for( int i = 0; i < 16; i++ )
         x264_free( h->mb.p_weight_buf[i] );
 
diff --git a/common/mvpred.c b/common/mvpred.c
index 03dfe9f..38636e1 100644
--- a/common/mvpred.c
+++ b/common/mvpred.c
@@ -423,19 +423,10 @@ void x264_mb_predict_mv_ref16x16( x264_t *h, int i_list, int i_ref, int16_t mvc[
     }
 
     /* spatial predictors */
-    if( h->mb.i_neighbour_frame & MB_LEFT )
-    {
-        SET_MVP( mvr[h->mb.i_mb_left_xy] );
-    }
-    if( h->mb.i_neighbour_frame & MB_TOP )
-    {
-        SET_MVP( mvr[h->mb.i_mb_top_xy] );
-
-        if( h->mb.i_neighbour_frame & MB_TOPLEFT )
-            SET_MVP( mvr[h->mb.i_mb_topleft_xy] );
-        if( h->mb.i_neighbour_frame & MB_TOPRIGHT )
-            SET_MVP( mvr[h->mb.i_mb_topright_xy] );
-    }
+    SET_MVP( mvr[h->mb.i_mb_left_xy] );
+    SET_MVP( mvr[h->mb.i_mb_top_xy] );
+    SET_MVP( mvr[h->mb.i_mb_topleft_xy] );
+    SET_MVP( mvr[h->mb.i_mb_topright_xy] );
 #undef SET_MVP
 
     /* temporal predictors */
diff --git a/encoder/analyse.c b/encoder/analyse.c
index 93f7eed..2f19f99 100644
--- a/encoder/analyse.c
+++ b/encoder/analyse.c
@@ -1956,7 +1956,7 @@ static void x264_mb_analyse_inter_b8x8_mixed_ref( x264_t *h, x264_mb_analysis_t
             lX->me8x8[i].cost = INT_MAX;
             for( int i_ref = 0; i_ref <= i_maxref[l]; i_ref++ )
             {
-                m.i_ref_cost = REF_COST( l, i_ref );;
+                m.i_ref_cost = REF_COST( l, i_ref );
 
                 LOAD_HPELS( &m, h->mb.pic.p_fref[l][i_ref], l, i_ref, 8*x8, 8*y8 );
 
@@ -2104,7 +2104,7 @@ static void x264_mb_analyse_inter_b16x8( x264_t *h, x264_mb_analysis_t *a, int i
             for( int j = 0; j < i_ref8s; j++ )
             {
                 int i_ref = ref8[j];
-                m.i_ref_cost = REF_COST( l, i_ref );;
+                m.i_ref_cost = REF_COST( l, i_ref );
 
                 LOAD_HPELS( &m, h->mb.pic.p_fref[l][i_ref], l, i_ref, 0, 8*i );
 



More information about the x264-devel mailing list