Commit 8443f260 authored by Loren Merritt's avatar Loren Merritt
Browse files

faster subpel motion search.

patch by Alex Wright.



git-svn-id: svn://svn.videolan.org/x264/trunk@381 df754926-b1dd-0310-bc7b-ec298dee348c
parent 8f0d66cc
...@@ -40,7 +40,7 @@ static const int subpel_iterations[][4] = ...@@ -40,7 +40,7 @@ static const int subpel_iterations[][4] =
{0,2,1,0}, {0,2,1,0},
{0,2,1,1}, {0,2,1,1},
{0,2,1,2}, {0,2,1,2},
{0,0,2,3}}; {0,0,2,2}};
static void refine_subpel( x264_t *h, x264_me_t *m, int hpel_iters, int qpel_iters, int *p_halfpel_thresh, int b_refine_qpel ); static void refine_subpel( x264_t *h, x264_me_t *m, int hpel_iters, int qpel_iters, int *p_halfpel_thresh, int b_refine_qpel );
...@@ -303,7 +303,8 @@ void x264_me_refine_qpel( x264_t *h, x264_me_t *m ) ...@@ -303,7 +303,8 @@ void x264_me_refine_qpel( x264_t *h, x264_me_t *m )
refine_subpel( h, m, hpel, qpel, NULL, 1 ); refine_subpel( h, m, hpel, qpel, NULL, 1 );
} }
#define COST_MV_SAD( mx, my ) \ #define COST_MV_SAD( mx, my, dir ) \
if( b_refine_qpel || (dir^1) != odir ) \
{ \ { \
int stride = 16; \ int stride = 16; \
uint8_t *src = h->mc.get_ref( m->p_fref, m->i_stride[0], pix, &stride, mx, my, bw, bh ); \ uint8_t *src = h->mc.get_ref( m->p_fref, m->i_stride[0], pix, &stride, mx, my, bw, bh ); \
...@@ -314,6 +315,7 @@ void x264_me_refine_qpel( x264_t *h, x264_me_t *m ) ...@@ -314,6 +315,7 @@ void x264_me_refine_qpel( x264_t *h, x264_me_t *m )
bcost = cost; \ bcost = cost; \
bmx = mx; \ bmx = mx; \
bmy = my; \ bmy = my; \
bdir = dir; \
} \ } \
} }
...@@ -362,25 +364,26 @@ static void refine_subpel( x264_t *h, x264_me_t *m, int hpel_iters, int qpel_ite ...@@ -362,25 +364,26 @@ static void refine_subpel( x264_t *h, x264_me_t *m, int hpel_iters, int qpel_ite
int odir = -1, bdir; int odir = -1, bdir;
/* try the subpel component of the predicted mv if it's close to /* try the subpel component of the predicted mv */
* the result of the fullpel search */
if( hpel_iters ) if( hpel_iters )
{ {
int mx = x264_clip3( m->mvp[0], h->mb.mv_min[0], h->mb.mv_max[0] ); int mx = x264_clip3( m->mvp[0], h->mb.mv_min[0], h->mb.mv_max[0] );
int my = x264_clip3( m->mvp[1], h->mb.mv_min[1], h->mb.mv_max[1] ); int my = x264_clip3( m->mvp[1], h->mb.mv_min[1], h->mb.mv_max[1] );
if( mx != bmx || my != bmy ) if( mx != bmx || my != bmy )
COST_MV_SAD( mx, my ); COST_MV_SAD( mx, my, -1 );
} }
/* hpel search */ /* hpel search */
bdir = -1;
for( i = hpel_iters; i > 0; i-- ) for( i = hpel_iters; i > 0; i-- )
{ {
odir = bdir;
omx = bmx; omx = bmx;
omy = bmy; omy = bmy;
COST_MV_SAD( omx, omy - 2 ); COST_MV_SAD( omx, omy - 2, 0 );
COST_MV_SAD( omx, omy + 2 ); COST_MV_SAD( omx, omy + 2, 1 );
COST_MV_SAD( omx - 2, omy ); COST_MV_SAD( omx - 2, omy, 2 );
COST_MV_SAD( omx + 2, omy ); COST_MV_SAD( omx + 2, omy, 3 );
if( bmx == omx && bmy == omy ) if( bmx == omx && bmy == omy )
break; break;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment