/* could be faster, but isn't called many times */
/* factor of 4 from qpel, 2 from sign, and 2 because mv can be opposite from mvp */
int i;
- p_cost_mv[a->i_qp] = x264_malloc( (4*4*h->param.analyse.i_mv_range + 1) * sizeof(int16_t) );
- p_cost_mv[a->i_qp] += 2*4*h->param.analyse.i_mv_range;
- for( i = 0; i <= 2*4*h->param.analyse.i_mv_range; i++ )
+ p_cost_mv[a->i_qp] = x264_malloc( (4*4*2048 + 1) * sizeof(int16_t) );
+ p_cost_mv[a->i_qp] += 2*4*2048;
+ for( i = 0; i <= 2*4*2048; i++ )
{
p_cost_mv[a->i_qp][-i] =
p_cost_mv[a->i_qp][i] = a->i_lambda * bs_size_se( i );
/* Calculate max allowed MV range */
#define CLIP_FMV(mv) x264_clip3( mv, -i_fmv_range, i_fmv_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 - 1 ) + 24 );
h->mb.mv_min_fpel[0] = CLIP_FMV( -16*h->mb.i_mb_x - 8 );
- h->mb.mv_max_fpel[0] = CLIP_FMV( 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 );
+ h->mb.mv_max_fpel[0] = CLIP_FMV( 16*( h->sps->i_mb_width - h->mb.i_mb_x - 1 ) + 8 );
+ h->mb.mv_min_spel[0] = 4*( h->mb.mv_min_fpel[0] - 16 );
+ h->mb.mv_max_spel[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 - 1 ) + 24 );
h->mb.mv_min_fpel[1] = CLIP_FMV( -16*h->mb.i_mb_y - 8 );
- h->mb.mv_max_fpel[1] = CLIP_FMV( 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 );
+ h->mb.mv_max_fpel[1] = CLIP_FMV( 16*( h->sps->i_mb_height - h->mb.i_mb_y - 1 ) + 8 );
+ h->mb.mv_min_spel[1] = 4*( h->mb.mv_min_fpel[1] - 16 );
+ h->mb.mv_max_spel[1] = 4*( h->mb.mv_max_fpel[1] + 16 );
}
#undef CLIP_FMV
if( h->mb.i_me_method == X264_ME_UMH )
{
/* clamp mvp to inside frame+padding, so that we don't have to check it each iteration */
- p_cost_mvx = m->p_cost_mv - x264_clip3( m->mvp[0], h->mb.mv_min[0], h->mb.mv_max[0] );
- p_cost_mvy = m->p_cost_mv - x264_clip3( m->mvp[1], h->mb.mv_min[1], h->mb.mv_max[1] );
+ p_cost_mvx = m->p_cost_mv - x264_clip3( m->mvp[0], h->mb.mv_min_spel[0], h->mb.mv_max_spel[0] );
+ p_cost_mvy = m->p_cost_mv - x264_clip3( m->mvp[1], h->mb.mv_min_spel[1], h->mb.mv_max_spel[1] );
}
bmx = pmx = x264_clip3( ( m->mvp[0] + 2 ) >> 2, mv_x_min, mv_x_max );
/* try the subpel component of the predicted mv */
if( hpel_iters )
{
- 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 mx = x264_clip3( m->mvp[0], h->mb.mv_min_spel[0], h->mb.mv_max_spel[0] );
+ int my = x264_clip3( m->mvp[1], h->mb.mv_min_spel[1], h->mb.mv_max_spel[1] );
if( mx != bmx || my != bmy )
COST_MV_SAD( mx, my, -1 );
}
const int bw = x264_pixel_size[i_pixel].w;
const int bh = x264_pixel_size[i_pixel].h;
const int bs = bw*bh;
- const int16_t *p_cost_m0x = m0->p_cost_mv - x264_clip3( m0->mvp[0], h->mb.mv_min[0], h->mb.mv_max[0] );
- const int16_t *p_cost_m0y = m0->p_cost_mv - x264_clip3( m0->mvp[1], h->mb.mv_min[0], h->mb.mv_max[0] );
- const int16_t *p_cost_m1x = m1->p_cost_mv - x264_clip3( m1->mvp[0], h->mb.mv_min[0], h->mb.mv_max[0] );
- const int16_t *p_cost_m1y = m1->p_cost_mv - x264_clip3( m1->mvp[1], h->mb.mv_min[0], h->mb.mv_max[0] );
+ const int16_t *p_cost_m0x = m0->p_cost_mv - x264_clip3( m0->mvp[0], h->mb.mv_min_spel[0], h->mb.mv_max_spel[0] );
+ const int16_t *p_cost_m0y = m0->p_cost_mv - x264_clip3( m0->mvp[1], h->mb.mv_min_spel[0], h->mb.mv_max_spel[0] );
+ const int16_t *p_cost_m1x = m1->p_cost_mv - x264_clip3( m1->mvp[0], h->mb.mv_min_spel[0], h->mb.mv_max_spel[0] );
+ const int16_t *p_cost_m1y = m1->p_cost_mv - x264_clip3( m1->mvp[1], h->mb.mv_min_spel[0], h->mb.mv_max_spel[0] );
DECLARE_ALIGNED( uint8_t, pix0[9][16*16], 16 );
DECLARE_ALIGNED( uint8_t, pix1[9][16*16], 16 );
DECLARE_ALIGNED( uint8_t, pix[16*16], 16 );