# HG changeset patch # User michael # Date 1166714402 0 # Node ID 5a2ee0bc27392d628524c89e0f256be20731f195 # Parent fabb67829f3fd3f0d30e978406dbd9525cd9b35f skip motion estimation and encoding of non direct-0,0 MBs if the next MB is skiped (mpeg4 doesnt allow such MBs and in the past we did ME and encoding until at the end we droped them, so this should be faster though i didnt benchmark it, benchmark welcome) diff -r fabb67829f3f -r 5a2ee0bc2739 motion_est.c --- a/motion_est.c Thu Dec 21 14:24:23 2006 +0000 +++ b/motion_est.c Thu Dec 21 15:20:02 2006 +0000 @@ -1843,6 +1843,18 @@ get_limits(s, 16*mb_x, 16*mb_y); c->skip=0; + + if(s->codec_id == CODEC_ID_MPEG4 && s->next_picture.mbskip_table[xy]){ + int score= direct_search(s, mb_x, mb_y); //FIXME just check 0,0 + + score= ((unsigned)(score*score + 128*256))>>16; + c->mc_mb_var_sum_temp += score; + s->current_picture.mc_mb_var[mb_y*s->mb_stride + mb_x] = score; //FIXME use SSE + s->mb_type[mb_y*s->mb_stride + mb_x]= CANDIDATE_MB_TYPE_DIRECT0; + + return; + } + if(c->avctx->me_threshold){ int vard= check_input_motion(s, mb_x, mb_y, 0); diff -r fabb67829f3f -r 5a2ee0bc2739 mpegvideo.c --- a/mpegvideo.c Thu Dec 21 14:24:23 2006 +0000 +++ b/mpegvideo.c Thu Dec 21 15:20:02 2006 +0000 @@ -5226,8 +5226,8 @@ } } - if(s->flags & CODEC_FLAG_QP_RD){ - if(best_s.mv_type==MV_TYPE_16X16 && !(best_s.mv_dir&MV_DIRECT)){ + if((s->flags & CODEC_FLAG_QP_RD) && dmin < INT_MAX){ + if(best_s.mv_type==MV_TYPE_16X16){ //FIXME move 4mv after QPRD const int last_qp= backup_s.qscale; int qpi, qp, dc[6]; DCTELEM ac[6][16]; @@ -5283,6 +5283,14 @@ encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb, &dmin, &next_block, mx, my); } + if(mb_type&CANDIDATE_MB_TYPE_DIRECT0){ + backup_s.dquant = 0; + s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT; + s->mb_intra= 0; + ff_mpeg4_set_direct_mv(s, 0, 0); + encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb, + &dmin, &next_block, 0, 0); + } s->current_picture.qscale_table[xy]= best_s.qscale; copy_context_after_encode(s, &best_s, -1); diff -r fabb67829f3f -r 5a2ee0bc2739 mpegvideo.h --- a/mpegvideo.h Thu Dec 21 14:24:23 2006 +0000 +++ b/mpegvideo.h Thu Dec 21 15:20:02 2006 +0000 @@ -402,6 +402,8 @@ #define CANDIDATE_MB_TYPE_BACKWARD_I 0x400 #define CANDIDATE_MB_TYPE_BIDIR_I 0x800 +#define CANDIDATE_MB_TYPE_DIRECT0 0x1000 + int block_index[6]; ///< index to current MB in block based arrays with edges int block_wrap[6]; uint8_t *dest[3];