Commit 9243c844 authored by Loren Merritt's avatar Loren Merritt

compute pskip_mv only once per macroblock, and store it


git-svn-id: svn://svn.videolan.org/x264/trunk@587 df754926-b1dd-0310-bc7b-ec298dee348c
parent 0a453377
......@@ -496,6 +496,7 @@ struct x264_t
int16_t direct_mv[2][X264_SCAN8_SIZE][2];
int8_t direct_ref[2][X264_SCAN8_SIZE];
int pskip_mv[2];
/* number of neighbors (top and left) that used 8x8 dct */
int i_neighbour_transform_size;
......
......@@ -1306,6 +1306,9 @@ void x264_macroblock_cache_load( x264_t *h, int i_mb_x, int i_mb_y )
h->mb.cache.skip[x264_scan8[4] - 8] = h->mb.skipbp[i_top_xy] & 0x8;
}
}
if( h->sh.i_type == SLICE_TYPE_P )
x264_mb_predict_mv_pskip( h, h->mb.cache.pskip_mv );
}
h->mb.i_neighbour4[0] =
......
......@@ -893,17 +893,16 @@ static void x264_mb_analyse_inter_p16x16( x264_t *h, x264_mb_analysis_t *a )
/* early termination
* SSD threshold would probably be better than SATD */
if( i_ref == 0 && a->b_try_pskip && m.cost-m.cost_mv < 300*a->i_lambda )
if( i_ref == 0
&& a->b_try_pskip
&& m.cost-m.cost_mv < 300*a->i_lambda
&& abs(m.mv[0]-h->mb.cache.pskip_mv[0])
+ abs(m.mv[1]-h->mb.cache.pskip_mv[1]) <= 1
&& x264_macroblock_probe_pskip( h ) )
{
int mvskip[2];
x264_mb_predict_mv_pskip( h, mvskip );
if( abs(m.mv[0]-mvskip[0]) + abs(m.mv[1]-mvskip[1]) <= 1
&& x264_macroblock_probe_pskip( h ) )
{
h->mb.i_type = P_SKIP;
x264_analyse_update_cache( h, a );
return;
}
h->mb.i_type = P_SKIP;
x264_analyse_update_cache( h, a );
return;
}
m.cost += i_ref_cost;
......@@ -922,16 +921,13 @@ static void x264_mb_analyse_inter_p16x16( x264_t *h, x264_mb_analysis_t *a )
x264_macroblock_cache_ref( h, 0, 0, 4, 4, 0, a->l0.me16x16.i_ref );
h->mb.i_type = P_L0;
if( a->b_mbrd && a->l0.i_ref == 0 )
if( a->b_mbrd && a->l0.i_ref == 0
&& a->l0.me16x16.mv[0] == h->mb.cache.pskip_mv[0]
&& a->l0.me16x16.mv[1] == h->mb.cache.pskip_mv[1] )
{
int mvskip[2];
x264_mb_predict_mv_pskip( h, mvskip );
if( a->l0.me16x16.mv[0] == mvskip[0] && a->l0.me16x16.mv[1] == mvskip[1] )
{
h->mb.i_partition = D_16x16;
x264_macroblock_cache_mv( h, 0, 0, 4, 4, 0, a->l0.me16x16.mv[0], a->l0.me16x16.mv[1] );
a->l0.i_rd16x16 = x264_rd_cost_mb( h, a->i_lambda2 );
}
h->mb.i_partition = D_16x16;
x264_macroblock_cache_mv( h, 0, 0, 4, 4, 0, a->l0.me16x16.mv[0], a->l0.me16x16.mv[1] );
a->l0.i_rd16x16 = x264_rd_cost_mb( h, a->i_lambda2 );
}
}
......@@ -2552,12 +2548,10 @@ static void x264_analyse_update_cache( x264_t *h, x264_mb_analysis_t *a )
case P_SKIP:
{
int mvp[2];
x264_mb_predict_mv_pskip( h, mvp );
/* */
h->mb.i_partition = D_16x16;
x264_macroblock_cache_ref( h, 0, 0, 4, 4, 0, 0 );
x264_macroblock_cache_mv ( h, 0, 0, 4, 4, 0, mvp[0], mvp[1] );
x264_macroblock_cache_mv ( h, 0, 0, 4, 4, 0, h->mb.cache.pskip_mv[0],
h->mb.cache.pskip_mv[1] );
break;
}
......
......@@ -638,17 +638,12 @@ void x264_macroblock_encode( x264_t *h )
if( !b_force_no_skip )
{
if( h->mb.i_type == P_L0 && h->mb.i_partition == D_16x16 &&
h->mb.i_cbp_luma == 0x00 && h->mb.i_cbp_chroma== 0x00 &&
h->mb.i_cbp_luma == 0x00 && h->mb.i_cbp_chroma == 0x00 &&
h->mb.cache.mv[0][x264_scan8[0]][0] == h->mb.cache.pskip_mv[0] &&
h->mb.cache.mv[0][x264_scan8[0]][1] == h->mb.cache.pskip_mv[1] &&
h->mb.cache.ref[0][x264_scan8[0]] == 0 )
{
int mvp[2];
x264_mb_predict_mv_pskip( h, mvp );
if( h->mb.cache.mv[0][x264_scan8[0]][0] == mvp[0] &&
h->mb.cache.mv[0][x264_scan8[0]][1] == mvp[1] )
{
h->mb.i_type = P_SKIP;
}
h->mb.i_type = P_SKIP;
}
/* Check for B_SKIP */
......@@ -681,9 +676,8 @@ int x264_macroblock_probe_skip( x264_t *h, int b_bidir )
if( !b_bidir )
{
/* Get the MV */
x264_mb_predict_mv_pskip( h, mvp );
mvp[0] = x264_clip3( mvp[0], h->mb.mv_min[0], h->mb.mv_max[0] );
mvp[1] = x264_clip3( mvp[1], h->mb.mv_min[1], h->mb.mv_max[1] );
mvp[0] = x264_clip3( h->mb.cache.pskip_mv[0], h->mb.mv_min[0], h->mb.mv_max[0] );
mvp[1] = x264_clip3( h->mb.cache.pskip_mv[1], h->mb.mv_min[1], h->mb.mv_max[1] );
/* Motion compensation */
h->mc.mc_luma( h->mb.pic.p_fref[0][0], h->mb.pic.i_stride[0],
......
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