From: Jason Garrett-Glaser Date: Sat, 10 Apr 2010 01:13:22 +0000 (-0700) Subject: Add faster mv0 special case for macroblock-tree X-Git-Url: http://www.zmx.ovh/git.videolan.org/?a=commitdiff_plain;h=825e3a9c1d185328f426340d118cb7359d1aca4b;p=x264.git Add faster mv0 special case for macroblock-tree Improves performance on low-motion video. --- diff --git a/encoder/slicetype.c b/encoder/slicetype.c index 7377a6dc..120a38a9 100644 --- a/encoder/slicetype.c +++ b/encoder/slicetype.c @@ -686,12 +686,24 @@ static void x264_macroblock_tree_propagate( x264_t *h, x264_frame_t **frames, in for( int list = 0; list < 2; list++ ) if( (lists_used >> list)&1 ) { +#define CLIP_ADD(s,x) (s) = X264_MIN((s)+(x),(1<<16)-1) + int listamount = propagate_amount; + /* Apply bipred weighting. */ + if( lists_used == 3 ) + listamount = (listamount * bipred_weights[list] + 32) >> 6; + + /* Early termination for simple case of mv0. */ + if( !M32( mvs[list][mb_index] ) ) + { + CLIP_ADD( ref_costs[list][mb_index], listamount ); + continue; + } + int x = mvs[list][mb_index][0]; int y = mvs[list][mb_index][1]; - int listamount = propagate_amount; int mbx = (x>>5)+h->mb.i_mb_x; int mby = (y>>5)+h->mb.i_mb_y; - int idx0 = mbx + mby*h->mb.i_mb_stride; + int idx0 = mbx + mby * h->mb.i_mb_stride; int idx1 = idx0 + 1; int idx2 = idx0 + h->mb.i_mb_stride; int idx3 = idx0 + h->mb.i_mb_stride + 1; @@ -702,12 +714,6 @@ static void x264_macroblock_tree_propagate( x264_t *h, x264_frame_t **frames, in int idx2weight = y*(32-x); int idx3weight = y*x; - /* Apply bipred weighting. */ - if( lists_used == 3 ) - listamount = (listamount * bipred_weights[list] + 32) >> 6; - -#define CLIP_ADD(s,x) (s) = X264_MIN((s)+(x),(1<<16)-1) - /* We could just clip the MVs, but pixels that lie outside the frame probably shouldn't * be counted. */ if( mbx < h->sps->i_mb_width-1 && mby < h->sps->i_mb_height-1 && mbx >= 0 && mby >= 0 )