From: Loren Merritt Date: Fri, 4 Feb 2005 01:20:55 +0000 (+0000) Subject: r114 didn't completely fix the problem, trying again. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2796ba0138a59efa32357f9dc708eefe01c55882;p=libx264 r114 didn't completely fix the problem, trying again. git-svn-id: svn://svn.videolan.org/x264/trunk@115 df754926-b1dd-0310-bc7b-ec298dee348c --- diff --git a/common/common.h b/common/common.h index 03b93259..c25af813 100644 --- a/common/common.h +++ b/common/common.h @@ -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; diff --git a/encoder/analyse.c b/encoder/analyse.c index 7bd8d4ec..2e5609cd 100644 --- a/encoder/analyse.c +++ b/encoder/analyse.c @@ -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; diff --git a/encoder/me.c b/encoder/me.c index 99703cdd..1b9a4489 100644 --- a/encoder/me.c +++ b/encoder/me.c @@ -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 ); }