if(emu){ ff_emulated_edge_mc(s, ptr, uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1); ptr= s->edge_emu_buffer;
if(s->flags&CODEC_FLAG_EMU_EDGE){ if(src_x<0 || src_y<0 || src_x + 9 >= s->h_edge_pos>>1 || src_y + 9 >= s->v_edge_pos>>1){ ff_emulated_edge_mc(s, ptr, uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1); ptr= s->edge_emu_buffer; emu=1; }
static inline void gmc1_motion(MpegEncContext *s,                               UINT8 *dest_y, UINT8 *dest_cb, UINT8 *dest_cr,                               int dest_offset,                               UINT8 **ref_picture, int src_offset){    UINT8 *ptr;    int offset, src_x, src_y, linesize, uvlinesize;    int motion_x, motion_y;    int emu=0;    motion_x= s->sprite_offset[0][0];    motion_y= s->sprite_offset[0][1];    src_x = s->mb_x * 16 + (motion_x >> (s->sprite_warping_accuracy+1));    src_y = s->mb_y * 16 + (motion_y >> (s->sprite_warping_accuracy+1));    motion_x<<=(3-s->sprite_warping_accuracy);    motion_y<<=(3-s->sprite_warping_accuracy);    src_x = clip(src_x, -16, s->width);    if (src_x == s->width)        motion_x =0;    src_y = clip(src_y, -16, s->height);    if (src_y == s->height)        motion_y =0;    linesize = s->linesize;    uvlinesize = s->uvlinesize;        ptr = ref_picture[0] + (src_y * linesize) + src_x + src_offset;    dest_y+=dest_offset;    if(s->flags&CODEC_FLAG_EMU_EDGE){        if(src_x<0 || src_y<0 || src_x + (motion_x&15) + 16 > s->h_edge_pos                              || src_y + (motion_y&15) + 16 > s->v_edge_pos){            ff_emulated_edge_mc(s, ptr, linesize, 17, 17, src_x, src_y, s->h_edge_pos, s->v_edge_pos);            ptr= s->edge_emu_buffer;            emu=1;        }    }        if((motion_x|motion_y)&7){        s->dsp.gmc1(dest_y  , ptr  , linesize, 16, motion_x&15, motion_y&15, 128 - s->no_rounding);        s->dsp.gmc1(dest_y+8, ptr+8, linesize, 16, motion_x&15, motion_y&15, 128 - s->no_rounding);    }else{        int dxy;                dxy= ((motion_x>>3)&1) | ((motion_y>>2)&2);        if (s->no_rounding){	    s->dsp.put_no_rnd_pixels_tab[0][dxy](dest_y, ptr, linesize, 16);        }else{            s->dsp.put_pixels_tab       [0][dxy](dest_y, ptr, linesize, 16);        }    }        if(s->flags&CODEC_FLAG_GRAY) return;    motion_x= s->sprite_offset[1][0];    motion_y= s->sprite_offset[1][1];    src_x = s->mb_x * 8 + (motion_x >> (s->sprite_warping_accuracy+1));    src_y = s->mb_y * 8 + (motion_y >> (s->sprite_warping_accuracy+1));    motion_x<<=(3-s->sprite_warping_accuracy);    motion_y<<=(3-s->sprite_warping_accuracy);    src_x = clip(src_x, -8, s->width>>1);    if (src_x == s->width>>1)        motion_x =0;    src_y = clip(src_y, -8, s->height>>1);    if (src_y == s->height>>1)        motion_y =0;    offset = (src_y * uvlinesize) + src_x + (src_offset>>1);    ptr = ref_picture[1] + offset;    if(emu){        ff_emulated_edge_mc(s, ptr, uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);        ptr= s->edge_emu_buffer;    }    s->dsp.gmc1(dest_cb + (dest_offset>>1), ptr, uvlinesize, 8, motion_x&15, motion_y&15, 128 - s->no_rounding);        ptr = ref_picture[2] + offset;    if(emu){        ff_emulated_edge_mc(s, ptr, uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);        ptr= s->edge_emu_buffer;    }    s->dsp.gmc1(dest_cr + (dest_offset>>1), ptr, uvlinesize, 8, motion_x&15, motion_y&15, 128 - s->no_rounding);        return;}