s->mv[0][i][0] = s->field_mv_table[mb_index][i][0]*time_pb/time_pp + mx; s->mv[0][i][1] = s->field_mv_table[mb_index][i][1]*time_pb/time_pp + my; s->mv[1][i][0] = mx ? s->mv[0][i][0] - s->field_mv_table[mb_index][i][0] : s->field_mv_table[mb_index][i][0]*(time_pb - time_pp)/time_pp; s->mv[1][i][1] = my ? s->mv[0][i][1] - s->field_mv_table[mb_index][i][1] : s->field_mv_table[mb_index][i][1]*(time_pb - time_pp)/time_pp;
s->mv[0][i][0] = s->p_field_mv_table[i][0][mb_index][0]*time_pb/time_pp + mx; s->mv[0][i][1] = s->p_field_mv_table[i][0][mb_index][1]*time_pb/time_pp + my; s->mv[1][i][0] = mx ? s->mv[0][i][0] - s->p_field_mv_table[i][0][mb_index][0] : s->p_field_mv_table[i][0][mb_index][0]*(time_pb - time_pp)/time_pp; s->mv[1][i][1] = my ? s->mv[0][i][1] - s->p_field_mv_table[i][0][mb_index][1] : s->p_field_mv_table[i][0][mb_index][1]*(time_pb - time_pp)/time_pp;
int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my){    const int mb_index= s->mb_x + s->mb_y*s->mb_stride;    const int colocated_mb_type= s->next_picture.mb_type[mb_index]; //FIXME or next?    int xy= s->block_index[0];    uint16_t time_pp= s->pp_time;    uint16_t time_pb= s->pb_time;    int i;        //FIXME avoid divides        if(IS_8X8(colocated_mb_type)){        s->mv_type = MV_TYPE_8X8;        for(i=0; i<4; i++){            xy= s->block_index[i];            s->mv[0][i][0] = s->next_picture.motion_val[0][xy][0]*time_pb/time_pp + mx;            s->mv[0][i][1] = s->next_picture.motion_val[0][xy][1]*time_pb/time_pp + my;            s->mv[1][i][0] = mx ? s->mv[0][i][0] - s->next_picture.motion_val[0][xy][0]                                : s->next_picture.motion_val[0][xy][0]*(time_pb - time_pp)/time_pp;            s->mv[1][i][1] = my ? s->mv[0][i][1] - s->next_picture.motion_val[0][xy][1]                                 : s->next_picture.motion_val[0][xy][1]*(time_pb - time_pp)/time_pp;        }        return MB_TYPE_DIRECT2 | MB_TYPE_8x8 | MB_TYPE_L0L1;    } else if(IS_INTERLACED(colocated_mb_type)){        s->mv_type = MV_TYPE_FIELD;        for(i=0; i<2; i++){            if(s->top_field_first){                time_pp= s->pp_field_time - s->field_select_table[mb_index][i] + i;                time_pb= s->pb_field_time - s->field_select_table[mb_index][i] + i;            }else{                time_pp= s->pp_field_time + s->field_select_table[mb_index][i] - i;                time_pb= s->pb_field_time + s->field_select_table[mb_index][i] - i;            }            s->mv[0][i][0] = s->field_mv_table[mb_index][i][0]*time_pb/time_pp + mx;            s->mv[0][i][1] = s->field_mv_table[mb_index][i][1]*time_pb/time_pp + my;            s->mv[1][i][0] = mx ? s->mv[0][i][0] - s->field_mv_table[mb_index][i][0]                                : s->field_mv_table[mb_index][i][0]*(time_pb - time_pp)/time_pp;            s->mv[1][i][1] = my ? s->mv[0][i][1] - s->field_mv_table[mb_index][i][1]                                 : s->field_mv_table[mb_index][i][1]*(time_pb - time_pp)/time_pp;        }        return MB_TYPE_DIRECT2 | MB_TYPE_16x8 | MB_TYPE_L0L1 | MB_TYPE_INTERLACED;    }else{        s->mv[0][0][0] = s->mv[0][1][0] = s->mv[0][2][0] = s->mv[0][3][0] = s->next_picture.motion_val[0][xy][0]*time_pb/time_pp + mx;        s->mv[0][0][1] = s->mv[0][1][1] = s->mv[0][2][1] = s->mv[0][3][1] = s->next_picture.motion_val[0][xy][1]*time_pb/time_pp + my;        s->mv[1][0][0] = s->mv[1][1][0] = s->mv[1][2][0] = s->mv[1][3][0] = mx ? s->mv[0][0][0] - s->next_picture.motion_val[0][xy][0]                            : s->next_picture.motion_val[0][xy][0]*(time_pb - time_pp)/time_pp;        s->mv[1][0][1] = s->mv[1][1][1] = s->mv[1][2][1] = s->mv[1][3][1] = my ? s->mv[0][0][1] - s->next_picture.motion_val[0][xy][1]                             : s->next_picture.motion_val[0][xy][1]*(time_pb - time_pp)/time_pp;        if((s->avctx->workaround_bugs & FF_BUG_DIRECT_BLOCKSIZE) || !s->quarter_sample)            s->mv_type= MV_TYPE_16X16;        else            s->mv_type= MV_TYPE_8X8;        return MB_TYPE_DIRECT2 | MB_TYPE_16x16 | MB_TYPE_L0L1; //Note see prev line    }}