if(s->co_located_type_table[mb_x + mb_y*s->mb_width]==CO_LOCATED_TYPE_4MV){
if(IS_8X8(s->next_picture.mb_type[mot_xy])){
static inline int direct_search(MpegEncContext * s,                                int mb_x, int mb_y){    int P[10][2];    const int mot_stride = s->mb_width + 2;    const int mot_xy = (mb_y + 1)*mot_stride + mb_x + 1;    const int shift= 1+s->quarter_sample;    int dmin, i;    const int time_pp= s->pp_time;    const int time_pb= s->pb_time;    int mx, my, xmin, xmax, ymin, ymax;    int16_t (*mv_table)[2]= s->b_direct_mv_table;    uint8_t * const mv_penalty= s->me.mv_penalty[1] + MAX_MV;        ymin= xmin=(-32)>>shift;    ymax= xmax=   31>>shift;    if(s->co_located_type_table[mb_x + mb_y*s->mb_width]==CO_LOCATED_TYPE_4MV){        s->mv_type= MV_TYPE_8X8;    }else{        s->mv_type= MV_TYPE_16X16;    }    for(i=0; i<4; i++){        int index= s->block_index[i];        int min, max;            s->me.co_located_mv[i][0]= s->motion_val[index][0];        s->me.co_located_mv[i][1]= s->motion_val[index][1];        s->me.direct_basis_mv[i][0]= s->me.co_located_mv[i][0]*time_pb/time_pp + ((i& 1)<<(shift+3));        s->me.direct_basis_mv[i][1]= s->me.co_located_mv[i][1]*time_pb/time_pp + ((i>>1)<<(shift+3));//        s->me.direct_basis_mv[1][i][0]= s->me.co_located_mv[i][0]*(time_pb - time_pp)/time_pp + ((i &1)<<(shift+3);//        s->me.direct_basis_mv[1][i][1]= s->me.co_located_mv[i][1]*(time_pb - time_pp)/time_pp + ((i>>1)<<(shift+3);        max= FFMAX(s->me.direct_basis_mv[i][0], s->me.direct_basis_mv[i][0] - s->me.co_located_mv[i][0])>>shift;        min= FFMIN(s->me.direct_basis_mv[i][0], s->me.direct_basis_mv[i][0] - s->me.co_located_mv[i][0])>>shift;        max+= (2*mb_x + (i& 1))*8 + 1; // +-1 is for the simpler rounding        min+= (2*mb_x + (i& 1))*8 - 1;        xmax= FFMIN(xmax, s->width - max);        xmin= FFMAX(xmin, - 16     - min);        max= FFMAX(s->me.direct_basis_mv[i][1], s->me.direct_basis_mv[i][1] - s->me.co_located_mv[i][1])>>shift;        min= FFMIN(s->me.direct_basis_mv[i][1], s->me.direct_basis_mv[i][1] - s->me.co_located_mv[i][1])>>shift;        max+= (2*mb_y + (i>>1))*8 + 1; // +-1 is for the simpler rounding        min+= (2*mb_y + (i>>1))*8 - 1;        ymax= FFMIN(ymax, s->height - max);        ymin= FFMAX(ymin, - 16      - min);                if(s->mv_type == MV_TYPE_16X16) break;    }        assert(xmax <= 15 && ymax <= 15 && xmin >= -16 && ymin >= -16);        if(xmax < 0 || xmin >0 || ymax < 0 || ymin > 0){        s->b_direct_mv_table[mot_xy][0]= 0;        s->b_direct_mv_table[mot_xy][1]= 0;        return 256*256*256*64;    }    P_LEFT[0]        = clip(mv_table[mot_xy - 1][0], xmin<<shift, xmax<<shift);    P_LEFT[1]        = clip(mv_table[mot_xy - 1][1], ymin<<shift, ymax<<shift);    /* special case for first line */    if (mb_y) {        P_TOP[0]      = clip(mv_table[mot_xy - mot_stride             ][0], xmin<<shift, xmax<<shift);        P_TOP[1]      = clip(mv_table[mot_xy - mot_stride             ][1], ymin<<shift, ymax<<shift);        P_TOPRIGHT[0] = clip(mv_table[mot_xy - mot_stride + 1         ][0], xmin<<shift, xmax<<shift);        P_TOPRIGHT[1] = clip(mv_table[mot_xy - mot_stride + 1         ][1], ymin<<shift, ymax<<shift);            P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]);        P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]);    }     //FIXME direct_search  ptr in context!!! (needed for chroma anyway or this will get messy)       if(s->flags&CODEC_FLAG_QPEL){        dmin = simple_direct_qpel_epzs_motion_search(s, 0, &mx, &my, P, 0, 0, xmin, ymin, xmax, ymax,                                                      &s->last_picture, mv_table, 1<<14, mv_penalty);        dmin = simple_direct_qpel_qpel_motion_search(s, &mx, &my, dmin, xmin, ymin, xmax, ymax,                                                0, 0, &s->last_picture, 0, 0, mv_penalty);                if(s->avctx->me_sub_cmp != s->avctx->mb_cmp && !s->me.skip)            dmin= simple_direct_qpel_qpel_get_mb_score(s, mx, my, 0, 0, &s->last_picture, mv_penalty);    }else{        dmin = simple_direct_hpel_epzs_motion_search(s, 0, &mx, &my, P, 0, 0, xmin, ymin, xmax, ymax,                                                      &s->last_picture, mv_table, 1<<15, mv_penalty);        dmin = simple_direct_hpel_hpel_motion_search(s, &mx, &my, dmin, xmin, ymin, xmax, ymax,                                                0, 0, &s->last_picture, 0, 0, mv_penalty);        if(s->avctx->me_sub_cmp != s->avctx->mb_cmp && !s->me.skip)            dmin= simple_direct_hpel_hpel_get_mb_score(s, mx, my, 0, 0, &s->last_picture, mv_penalty);    }    s->b_direct_mv_table[mot_xy][0]= mx;    s->b_direct_mv_table[mot_xy][1]= my;    return dmin;}