{
int i, j;
int i_fmv_range = 4 * h->param.analyse.i_mv_range;
- int i_fpel_border = 5; // 3 for hex search, 2 for subpel, ignores subme7 & bime
+ // limit motion search to a slightly smaller range than the theoretical limit,
+ // since the search may go a few iterations past its given range
+ int i_fpel_border = 5; // umh unconditional radius
+ int i_spel_border = 8; // 1.5 for subpel_satd, 1.5 for subpel_rd, 2 for bime, round up
/* Calculate max allowed MV range */
#define CLIP_FMV(mv) x264_clip3( mv, -i_fmv_range, i_fmv_range )
h->mb.mv_min[1] = 4*( -16*mb_y - 24 );
h->mb.mv_max[1] = 4*( 16*( mb_height - mb_y - 1 ) + 24 );
- h->mb.mv_min_spel[1] = CLIP_FMV( h->mb.mv_min[1] );
+ h->mb.mv_min_spel[1] = x264_clip3( h->mb.mv_min[1], X264_MAX(4*(-512+i_spel_border), -i_fmv_range), i_fmv_range );
h->mb.mv_max_spel[1] = CLIP_FMV( h->mb.mv_max[1] );
h->mb.mv_max_spel[1] = X264_MIN( h->mb.mv_max_spel[1], thread_mvy_range*4 );
h->mb.mv_min_fpel[1] = (h->mb.mv_min_spel[1]>>2) + i_fpel_border;
if( h->param.analyse.i_mv_range <= 0 )
h->param.analyse.i_mv_range = l->mv_range;
else
- h->param.analyse.i_mv_range = x264_clip3(h->param.analyse.i_mv_range, 32, 2048);
+ h->param.analyse.i_mv_range = x264_clip3(h->param.analyse.i_mv_range, 32, 512);
if( h->param.analyse.i_direct_8x8_inference < 0 )
h->param.analyse.i_direct_8x8_inference = l->direct8x8;
}