dxy = ((motion_by & 1) << 1) | (motion_bx & 1); src_x = mb_x * 16 + (motion_bx >> 1); src_y = mb_y * 16 + (motion_by >> 1); src_x = clip(src_x, -16, s->width); if (src_x == s->width) dxy&= 2; src_y = clip(src_y, -16, s->height); if (src_y == s->height) dxy&= 1;
dxy = ((motion_by & 1) << 1) | (motion_bx & 1); src_x = mb_x * 16 + (motion_bx >> 1); src_y = mb_y * 16 + (motion_by >> 1); assert(src_x >=-16 && src_x<=s->width); assert(src_y >=-16 && src_y<=s->height);  ptr = s->next_picture.data[0] + (src_y * s->linesize) + src_x; s->dsp.avg_pixels_tab[0][dxy](dest_y    , ptr    , s->linesize, 16); }
static inline int check_bidir_mv(MpegEncContext * s,                   int mb_x, int mb_y,                   int motion_fx, int motion_fy,                   int motion_bx, int motion_by,                   int pred_fx, int pred_fy,                   int pred_bx, int pred_by){    //FIXME optimize?    //FIXME direct mode penalty    UINT16 *mv_penalty= s->mv_penalty[s->f_code] + MAX_MV; // f_code of the prev frame    uint8_t *dest_y = s->me_scratchpad;    uint8_t *ptr;    int dxy;    int src_x, src_y;    int fbmin;    fbmin = (mv_penalty[motion_fx-pred_fx] + mv_penalty[motion_fy-pred_fy])*s->qscale;    dxy = ((motion_fy & 1) << 1) | (motion_fx & 1);    src_x = mb_x * 16 + (motion_fx >> 1);    src_y = mb_y * 16 + (motion_fy >> 1);    src_x = clip(src_x, -16, s->width);    if (src_x == s->width)        dxy&= 2;    src_y = clip(src_y, -16, s->height);    if (src_y == s->height)        dxy&= 1;    ptr = s->last_picture.data[0] + (src_y * s->linesize) + src_x;    s->dsp.put_pixels_tab[0][dxy](dest_y    , ptr    , s->linesize, 16);    fbmin += (mv_penalty[motion_bx-pred_bx] + mv_penalty[motion_by-pred_by])*s->qscale;    dxy = ((motion_by & 1) << 1) | (motion_bx & 1);    src_x = mb_x * 16 + (motion_bx >> 1);    src_y = mb_y * 16 + (motion_by >> 1);    src_x = clip(src_x, -16, s->width);    if (src_x == s->width)        dxy&= 2;    src_y = clip(src_y, -16, s->height);    if (src_y == s->height)        dxy&= 1;    ptr = s->next_picture.data[0] + (src_y * s->linesize) + src_x;    s->dsp.avg_pixels_tab[0][dxy](dest_y    , ptr    , s->linesize, 16);    fbmin += s->dsp.pix_abs16x16(s->new_picture.data[0] + mb_x*16 + mb_y*16*s->linesize, dest_y, s->linesize);    return fbmin;}