]> granicus.if.org Git - libx264/commitdiff
r114 didn't completely fix the problem, trying again.
authorLoren Merritt <pengvado@videolan.org>
Fri, 4 Feb 2005 01:20:55 +0000 (01:20 +0000)
committerLoren Merritt <pengvado@videolan.org>
Fri, 4 Feb 2005 01:20:55 +0000 (01:20 +0000)
git-svn-id: svn://svn.videolan.org/x264/trunk@115 df754926-b1dd-0310-bc7b-ec298dee348c

common/common.h
encoder/analyse.c
encoder/me.c

index 03b93259301f2cf218ca60172840fa85cf2e20b2..c25af813a6ca3ee7d90b60b1e5860611007c7ac5 100644 (file)
@@ -263,9 +263,12 @@ struct x264_t
         int     i_b8_xy;
         int     i_b4_xy;
 
-        /* Allowed MV range to stay within the picture + emulated edge pixels */
+        /* Allowed qpel MV range to stay within the picture + emulated edge pixels */
         int     mv_min[2];
         int     mv_max[2];
+        /* Fullpel MV range for motion search */
+        int     mv_min_fpel[2];
+        int     mv_max_fpel[2];
 
         unsigned int i_neighbour;
 
index 7bd8d4ec9d6ad6304a7bb3acc4d526f94408a170..2e5609cde332a6e0db528f3d95761a5e789a077e 100644 (file)
@@ -154,12 +154,16 @@ static void x264_mb_analyse_init( x264_t *h, x264_mb_analysis_t *a, int i_qp )
         int i;
 
         /* Calculate max allowed MV range */
-        h->mb.mv_min[0] = 4*( -16*h->mb.i_mb_x - 24 );
-        h->mb.mv_max[0] = 4*( 16*( h->sps->i_mb_width - h->mb.i_mb_x ) + 8 );
+        h->mb.mv_min_fpel[0] = -16*h->mb.i_mb_x - 8;
+        h->mb.mv_max_fpel[0] = 16*( h->sps->i_mb_width - h->mb.i_mb_x ) - 8;
+        h->mb.mv_min[0] = 4*( h->mb.mv_min_fpel[0] - 16 );
+        h->mb.mv_max[0] = 4*( h->mb.mv_max_fpel[0] + 16 );
         if( h->mb.i_mb_x == 0)
         {
-            h->mb.mv_min[1] = 4*( -16*h->mb.i_mb_y - 24 );
-            h->mb.mv_max[1] = 4*( 16*( h->sps->i_mb_height - h->mb.i_mb_y ) + 8 );
+            h->mb.mv_min_fpel[1] = -16*h->mb.i_mb_y - 8;
+            h->mb.mv_max_fpel[1] = 16*( h->sps->i_mb_height - h->mb.i_mb_y ) - 8;
+            h->mb.mv_min[1] = 4*( h->mb.mv_min_fpel[1] - 16 );
+            h->mb.mv_max[1] = 4*( h->mb.mv_max_fpel[1] + 16 );
         }
 
         a->l0.me16x16.cost = -1;
index 99703cdd4482928b7a7cfae074d36eaa9bfe1523..1b9a448980a56b2cb803bbd786162b4463750136 100644 (file)
@@ -65,10 +65,10 @@ void x264_me_search_ref( x264_t *h, x264_me_t *m, int (*mvc)[2], int i_mvc, int
     uint8_t *p_fref = m->p_fref;
     int i_iter;
 
-    const int mv_x_min = h->mb.mv_min[0] + 16;
-    const int mv_y_min = h->mb.mv_min[1] + 16;
-    const int mv_x_max = h->mb.mv_max[0] - 16;
-    const int mv_y_max = h->mb.mv_max[1] - 16;
+    const int mv_x_min = h->mb.mv_min_fpel[0];
+    const int mv_y_min = h->mb.mv_min_fpel[1];
+    const int mv_x_max = h->mb.mv_max_fpel[0];
+    const int mv_y_max = h->mb.mv_max_fpel[1];
 
     /* init with mvp */
     /* XXX: We don't need to clamp because the way diamond work, we will
@@ -76,8 +76,8 @@ void x264_me_search_ref( x264_t *h, x264_me_t *m, int (*mvc)[2], int i_mvc, int
      * with componant magnitude greater.
      * XXX: if some vector can go outside, (accelerator, ....) you need to clip
      * them yourself */
-    bmx = ( x264_clip3( m->mvp[0], mv_x_min, mv_x_max ) + 2 ) >> 2;
-    bmy = ( x264_clip3( m->mvp[1], mv_y_min, mv_y_max ) + 2 ) >> 2;
+    bmx = x264_clip3( ( m->mvp[0] + 2 ) >> 2, mv_x_min, mv_x_max );
+    bmy = x264_clip3( ( m->mvp[1] + 2 ) >> 2, mv_y_min, mv_y_max );
 
     bcost = h->pixf.sad[i_pixel]( m->p_fenc, m->i_stride,
                 &p_fref[bmy * m->i_stride + bmx], m->i_stride );
@@ -85,8 +85,8 @@ void x264_me_search_ref( x264_t *h, x264_me_t *m, int (*mvc)[2], int i_mvc, int
     /* try extra predictors if provided */
     for( i_iter = 0; i_iter < i_mvc; i_iter++ )
     {
-        const int mx = ( x264_clip3( mvc[i_iter][0], mv_x_min, mv_x_max ) + 2 ) >> 2;
-        const int my = ( x264_clip3( mvc[i_iter][1], mv_y_min, mv_y_max ) + 2 ) >> 2;
+        const int mx = x264_clip3( ( mvc[i_iter][0] + 2 ) >> 2, mv_x_min, mv_x_max );
+        const int my = x264_clip3( ( mvc[i_iter][1] + 2 ) >> 2, mv_y_min, mv_y_max );
         if( mx != bmx || my != bmy )
             COST_MV( mx, my );
     }