From: Loren Merritt Date: Mon, 9 Oct 2006 23:31:45 +0000 (+0000) Subject: compute pskip_mv only once per macroblock, and store it X-Git-Url: http://www.zmx.ovh/git.videolan.org/?a=commitdiff_plain;h=9243c844dfc47d6dea825a0a92bd8a990d6c3cac;p=x264.git 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 --- diff --git a/common/common.h b/common/common.h index da003e35..8c0cf137 100644 --- a/common/common.h +++ b/common/common.h @@ -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; diff --git a/common/macroblock.c b/common/macroblock.c index 4a24ff2c..41b4adaf 100644 --- a/common/macroblock.c +++ b/common/macroblock.c @@ -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] = diff --git a/encoder/analyse.c b/encoder/analyse.c index 2093ed1f..39f1abfc 100644 --- a/encoder/analyse.c +++ b/encoder/analyse.c @@ -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; } diff --git a/encoder/macroblock.c b/encoder/macroblock.c index e63dd36b..3a60d2d0 100644 --- a/encoder/macroblock.c +++ b/encoder/macroblock.c @@ -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],