type= MB_TYPE_BIDIR;
type= CANDIDATE_MB_TYPE_BIDIR; } if(fimin<score){ score=fimin; type= CANDIDATE_MB_TYPE_FORWARD_I; } if(bimin<score){ score=bimin; type= CANDIDATE_MB_TYPE_BACKWARD_I;
void ff_estimate_b_frame_motion(MpegEncContext * s,                             int mb_x, int mb_y){    const int penalty_factor= s->me.mb_penalty_factor;    int fmin, bmin, dmin, fbmin;    int type=0;        s->me.skip=0;    if (s->codec_id == CODEC_ID_MPEG4)        dmin= direct_search(s, mb_x, mb_y);    else        dmin= INT_MAX;    s->me.skip=0;    fmin= ff_estimate_motion_b(s, mb_x, mb_y, s->b_forw_mv_table, &s->last_picture, s->f_code) + 3*penalty_factor;        s->me.skip=0;    bmin= ff_estimate_motion_b(s, mb_x, mb_y, s->b_back_mv_table, &s->next_picture, s->b_code) + 2*penalty_factor;//printf(" %d %d ", s->b_forw_mv_table[xy][0], s->b_forw_mv_table[xy][1]);    s->me.skip=0;    fbmin= bidir_refine(s, mb_x, mb_y) + penalty_factor;//printf("%d %d %d %d\n", dmin, fmin, bmin, fbmin);    {        int score= fmin;        type = MB_TYPE_FORWARD;                if (dmin <= score){            score = dmin;            type = MB_TYPE_DIRECT;        }        if(bmin<score){            score=bmin;            type= MB_TYPE_BACKWARD;         }        if(fbmin<score){            score=fbmin;            type= MB_TYPE_BIDIR;        }                score= ((unsigned)(score*score + 128*256))>>16;        s->current_picture.mc_mb_var_sum += score;        s->current_picture.mc_mb_var[mb_y*s->mb_stride + mb_x] = score; //FIXME use SSE    }    if(s->avctx->mb_decision > FF_MB_DECISION_SIMPLE){        type= MB_TYPE_FORWARD | MB_TYPE_BACKWARD | MB_TYPE_BIDIR | MB_TYPE_DIRECT; //FIXME something smarter        if(dmin>256*256*16) type&= ~MB_TYPE_DIRECT; //dont try direct mode if its invalid for this MB    }    s->mb_type[mb_y*s->mb_stride + mb_x]= type;}