static void gmc1_motion(MpegEncContext *s,

                        uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,

                        uint8_t **ref_picture)

{

    uint8_t *ptr;

    int src_x, src_y, motion_x, motion_y;

    ptrdiff_t offset, linesize, uvlinesize;

    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      = av_clip(src_x, -16, s->width);

    if (src_x == s->width)

        motion_x = 0;

    src_y = av_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;



    if ((unsigned)src_x >= FFMAX(s->h_edge_pos - 17, 0) ||

        (unsigned)src_y >= FFMAX(s->v_edge_pos - 17, 0)) {

        s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr,

                                 linesize, linesize,

                                 17, 17,

                                 src_x, src_y,

                                 s->h_edge_pos, s->v_edge_pos);

        ptr = s->sc.edge_emu_buffer;

    }



    if ((motion_x | motion_y) & 7) {

        s->mdsp.gmc1(dest_y, ptr, linesize, 16,

                     motion_x & 15, motion_y & 15, 128 - s->no_rounding);

        s->mdsp.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->hdsp.put_no_rnd_pixels_tab[0][dxy](dest_y, ptr, linesize, 16);

        } else {

            s->hdsp.put_pixels_tab[0][dxy](dest_y, ptr, linesize, 16);

        }

    }



    if (CONFIG_GRAY && s->avctx->flags & AV_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      = av_clip(src_x, -8, s->width >> 1);

    if (src_x == s->width >> 1)

        motion_x = 0;

    src_y = av_clip(src_y, -8, s->height >> 1);

    if (src_y == s->height >> 1)

        motion_y = 0;



    offset = (src_y * uvlinesize) + src_x;

    ptr    = ref_picture[1] + offset;

    if ((unsigned)src_x >= FFMAX((s->h_edge_pos >> 1) - 9, 0) ||

        (unsigned)src_y >= FFMAX((s->v_edge_pos >> 1) - 9, 0)) {

        s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr,

                                 uvlinesize, uvlinesize,

                                 9, 9,

                                 src_x, src_y,

                                 s->h_edge_pos >> 1, s->v_edge_pos >> 1);

        ptr = s->sc.edge_emu_buffer;

        emu = 1;

    }

    s->mdsp.gmc1(dest_cb, ptr, uvlinesize, 8,

                 motion_x & 15, motion_y & 15, 128 - s->no_rounding);



    ptr = ref_picture[2] + offset;

    if (emu) {

        s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr,

                                 uvlinesize, uvlinesize,

                                 9, 9,

                                 src_x, src_y,

                                 s->h_edge_pos >> 1, s->v_edge_pos >> 1);

        ptr = s->sc.edge_emu_buffer;

    }

    s->mdsp.gmc1(dest_cr, ptr, uvlinesize, 8,

                 motion_x & 15, motion_y & 15, 128 - s->no_rounding);

}

static void gmc1_motion(MpegEncContext *s,

                        uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,

                        uint8_t **ref_picture)

{

    uint8_t *ptr;

    int src_x, src_y, motion_x, motion_y;

    ptrdiff_t offset, linesize, uvlinesize;

    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      = av_clip(src_x, -16, s->width);

    if (src_x == s->width)

        motion_x = 0;

    src_y = av_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;



    if ((unsigned)src_x >= FFMAX(s->h_edge_pos - 17, 0) ||

        (unsigned)src_y >= FFMAX(s->v_edge_pos - 17, 0)) {

        s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr,

                                 linesize, linesize,

                                 17, 17,

                                 src_x, src_y,

                                 s->h_edge_pos, s->v_edge_pos);

        ptr = s->sc.edge_emu_buffer;

    }



    if ((motion_x | motion_y) & 7) {

        s->mdsp.gmc1(dest_y, ptr, linesize, 16,

                     motion_x & 15, motion_y & 15, 128 - s->no_rounding);

        s->mdsp.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->hdsp.put_no_rnd_pixels_tab[0][dxy](dest_y, ptr, linesize, 16);

        } else {

            s->hdsp.put_pixels_tab[0][dxy](dest_y, ptr, linesize, 16);

        }

    }



    if (CONFIG_GRAY && s->avctx->flags & AV_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      = av_clip(src_x, -8, s->width >> 1);

    if (src_x == s->width >> 1)

        motion_x = 0;

    src_y = av_clip(src_y, -8, s->height >> 1);

    if (src_y == s->height >> 1)

        motion_y = 0;



    offset = (src_y * uvlinesize) + src_x;

    ptr    = ref_picture[1] + offset;

    if ((unsigned)src_x >= FFMAX((s->h_edge_pos >> 1) - 9, 0) ||

        (unsigned)src_y >= FFMAX((s->v_edge_pos >> 1) - 9, 0)) {

        s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr,

                                 uvlinesize, uvlinesize,

                                 9, 9,

                                 src_x, src_y,

                                 s->h_edge_pos >> 1, s->v_edge_pos >> 1);

        ptr = s->sc.edge_emu_buffer;

        emu = 1;

    }

    s->mdsp.gmc1(dest_cb, ptr, uvlinesize, 8,

                 motion_x & 15, motion_y & 15, 128 - s->no_rounding);



    ptr = ref_picture[2] + offset;

    if (emu) {

        s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr,

                                 uvlinesize, uvlinesize,

                                 9, 9,

                                 src_x, src_y,

                                 s->h_edge_pos >> 1, s->v_edge_pos >> 1);

        ptr = s->sc.edge_emu_buffer;

    }

    s->mdsp.gmc1(dest_cr, ptr, uvlinesize, 8,

                 motion_x & 15, motion_y & 15, 128 - s->no_rounding);

}

    motion_x <<= (3 - s->sprite_warping_accuracy);     motion_y <<= (3 - s->sprite_warping_accuracy);     motion_x <<= (3 - s->sprite_warping_accuracy);     motion_y <<= (3 - s->sprite_warping_accuracy);
static void FUNC_0(MpegEncContext *VAR_0,

                        uint8_t *VAR_1, uint8_t *VAR_2, uint8_t *VAR_3,

                        uint8_t **VAR_4)

{

    uint8_t *ptr;

    int VAR_5, VAR_6, VAR_7, VAR_8;

    ptrdiff_t offset, linesize, uvlinesize;

    int VAR_9 = 0;



    VAR_7   = VAR_0->sprite_offset[0][0];

    VAR_8   = VAR_0->sprite_offset[0][1];

    VAR_5      = VAR_0->mb_x * 16 + (VAR_7 >> (VAR_0->sprite_warping_accuracy + 1));

    VAR_6      = VAR_0->mb_y * 16 + (VAR_8 >> (VAR_0->sprite_warping_accuracy + 1));

    VAR_7 <<= (3 - VAR_0->sprite_warping_accuracy);

    VAR_8 <<= (3 - VAR_0->sprite_warping_accuracy);

    VAR_5      = av_clip(VAR_5, -16, VAR_0->width);

    if (VAR_5 == VAR_0->width)

        VAR_7 = 0;

    VAR_6 = av_clip(VAR_6, -16, VAR_0->height);

    if (VAR_6 == VAR_0->height)

        VAR_8 = 0;



    linesize   = VAR_0->linesize;

    uvlinesize = VAR_0->uvlinesize;



    ptr = VAR_4[0] + VAR_6 * linesize + VAR_5;



    if ((unsigned)VAR_5 >= FFMAX(VAR_0->h_edge_pos - 17, 0) ||

        (unsigned)VAR_6 >= FFMAX(VAR_0->v_edge_pos - 17, 0)) {

        VAR_0->vdsp.emulated_edge_mc(VAR_0->sc.edge_emu_buffer, ptr,

                                 linesize, linesize,

                                 17, 17,

                                 VAR_5, VAR_6,

                                 VAR_0->h_edge_pos, VAR_0->v_edge_pos);

        ptr = VAR_0->sc.edge_emu_buffer;

    }



    if ((VAR_7 | VAR_8) & 7) {

        VAR_0->mdsp.gmc1(VAR_1, ptr, linesize, 16,

                     VAR_7 & 15, VAR_8 & 15, 128 - VAR_0->no_rounding);

        VAR_0->mdsp.gmc1(VAR_1 + 8, ptr + 8, linesize, 16,

                     VAR_7 & 15, VAR_8 & 15, 128 - VAR_0->no_rounding);

    } else {

        int VAR_10;



        VAR_10 = ((VAR_7 >> 3) & 1) | ((VAR_8 >> 2) & 2);

        if (VAR_0->no_rounding) {

            VAR_0->hdsp.put_no_rnd_pixels_tab[0][VAR_10](VAR_1, ptr, linesize, 16);

        } else {

            VAR_0->hdsp.put_pixels_tab[0][VAR_10](VAR_1, ptr, linesize, 16);

        }

    }



    if (CONFIG_GRAY && VAR_0->avctx->flags & AV_CODEC_FLAG_GRAY)

        return;



    VAR_7   = VAR_0->sprite_offset[1][0];

    VAR_8   = VAR_0->sprite_offset[1][1];

    VAR_5      = VAR_0->mb_x * 8 + (VAR_7 >> (VAR_0->sprite_warping_accuracy + 1));

    VAR_6      = VAR_0->mb_y * 8 + (VAR_8 >> (VAR_0->sprite_warping_accuracy + 1));

    VAR_7 <<= (3 - VAR_0->sprite_warping_accuracy);

    VAR_8 <<= (3 - VAR_0->sprite_warping_accuracy);

    VAR_5      = av_clip(VAR_5, -8, VAR_0->width >> 1);

    if (VAR_5 == VAR_0->width >> 1)

        VAR_7 = 0;

    VAR_6 = av_clip(VAR_6, -8, VAR_0->height >> 1);

    if (VAR_6 == VAR_0->height >> 1)

        VAR_8 = 0;



    offset = (VAR_6 * uvlinesize) + VAR_5;

    ptr    = VAR_4[1] + offset;

    if ((unsigned)VAR_5 >= FFMAX((VAR_0->h_edge_pos >> 1) - 9, 0) ||

        (unsigned)VAR_6 >= FFMAX((VAR_0->v_edge_pos >> 1) - 9, 0)) {

        VAR_0->vdsp.emulated_edge_mc(VAR_0->sc.edge_emu_buffer, ptr,

                                 uvlinesize, uvlinesize,

                                 9, 9,

                                 VAR_5, VAR_6,

                                 VAR_0->h_edge_pos >> 1, VAR_0->v_edge_pos >> 1);

        ptr = VAR_0->sc.edge_emu_buffer;

        VAR_9 = 1;

    }

    VAR_0->mdsp.gmc1(VAR_2, ptr, uvlinesize, 8,

                 VAR_7 & 15, VAR_8 & 15, 128 - VAR_0->no_rounding);



    ptr = VAR_4[2] + offset;

    if (VAR_9) {

        VAR_0->vdsp.emulated_edge_mc(VAR_0->sc.edge_emu_buffer, ptr,

                                 uvlinesize, uvlinesize,

                                 9, 9,

                                 VAR_5, VAR_6,

                                 VAR_0->h_edge_pos >> 1, VAR_0->v_edge_pos >> 1);

        ptr = VAR_0->sc.edge_emu_buffer;

    }

    VAR_0->mdsp.gmc1(VAR_3, ptr, uvlinesize, 8,

                 VAR_7 & 15, VAR_8 & 15, 128 - VAR_0->no_rounding);

}

static void FUNC_0(MpegEncContext *VAR_0,
uint8_t *VAR_1, uint8_t *VAR_2, uint8_t *VAR_3,
uint8_t **VAR_4)
{ uint8_t *ptr; int VAR_5, VAR_6, VAR_7, VAR_8; ptrdiff_t offset, linesize, uvlinesize; int VAR_9 = 0; VAR_7   = VAR_0->sprite_offset[0][0]; VAR_8   = VAR_0->sprite_offset[0][1]; VAR_5      = VAR_0->mb_x * 16 + (VAR_7 >> (VAR_0->sprite_warping_accuracy + 1)); VAR_6      = VAR_0->mb_y * 16 + (VAR_8 >> (VAR_0->sprite_warping_accuracy + 1)); VAR_7 <<= (3 - VAR_0->sprite_warping_accuracy); VAR_8 <<= (3 - VAR_0->sprite_warping_accuracy); VAR_5      = av_clip(VAR_5, -16, VAR_0->width); if (VAR_5 == VAR_0->width)
VAR_7 = 0; VAR_6 = av_clip(VAR_6, -16, VAR_0->height); if (VAR_6 == VAR_0->height)
VAR_8 = 0; linesize   = VAR_0->linesize; uvlinesize = VAR_0->uvlinesize; ptr = VAR_4[0] + VAR_6 * linesize + VAR_5; if ((unsigned)VAR_5 >= FFMAX(VAR_0->h_edge_pos - 17, 0) ||
(unsigned)VAR_6 >= FFMAX(VAR_0->v_edge_pos - 17, 0)) { VAR_0->vdsp.emulated_edge_mc(VAR_0->sc.edge_emu_buffer, ptr,
linesize, linesize,
17, 17,
VAR_5, VAR_6,
VAR_0->h_edge_pos, VAR_0->v_edge_pos); ptr = VAR_0->sc.edge_emu_buffer; } if ((VAR_7 | VAR_8) & 7) { VAR_0->mdsp.gmc1(VAR_1, ptr, linesize, 16,
VAR_7 & 15, VAR_8 & 15, 128 - VAR_0->no_rounding); VAR_0->mdsp.gmc1(VAR_1 + 8, ptr + 8, linesize, 16,
VAR_7 & 15, VAR_8 & 15, 128 - VAR_0->no_rounding); } else { int VAR_10; VAR_10 = ((VAR_7 >> 3) & 1) | ((VAR_8 >> 2) & 2); if (VAR_0->no_rounding) { VAR_0->hdsp.put_no_rnd_pixels_tab[0][VAR_10](VAR_1, ptr, linesize, 16); } else { VAR_0->hdsp.put_pixels_tab[0][VAR_10](VAR_1, ptr, linesize, 16); } } if (CONFIG_GRAY && VAR_0->avctx->flags & AV_CODEC_FLAG_GRAY)
return; VAR_7   = VAR_0->sprite_offset[1][0]; VAR_8   = VAR_0->sprite_offset[1][1]; VAR_5      = VAR_0->mb_x * 8 + (VAR_7 >> (VAR_0->sprite_warping_accuracy + 1)); VAR_6      = VAR_0->mb_y * 8 + (VAR_8 >> (VAR_0->sprite_warping_accuracy + 1)); VAR_7 <<= (3 - VAR_0->sprite_warping_accuracy); VAR_8 <<= (3 - VAR_0->sprite_warping_accuracy); VAR_5      = av_clip(VAR_5, -8, VAR_0->width >> 1); if (VAR_5 == VAR_0->width >> 1)
VAR_7 = 0; VAR_6 = av_clip(VAR_6, -8, VAR_0->height >> 1); if (VAR_6 == VAR_0->height >> 1)
VAR_8 = 0; offset = (VAR_6 * uvlinesize) + VAR_5; ptr    = VAR_4[1] + offset; if ((unsigned)VAR_5 >= FFMAX((VAR_0->h_edge_pos >> 1) - 9, 0) ||
(unsigned)VAR_6 >= FFMAX((VAR_0->v_edge_pos >> 1) - 9, 0)) { VAR_0->vdsp.emulated_edge_mc(VAR_0->sc.edge_emu_buffer, ptr,
uvlinesize, uvlinesize,
9, 9,
VAR_5, VAR_6,
VAR_0->h_edge_pos >> 1, VAR_0->v_edge_pos >> 1); ptr = VAR_0->sc.edge_emu_buffer; VAR_9 = 1; } VAR_0->mdsp.gmc1(VAR_2, ptr, uvlinesize, 8,
VAR_7 & 15, VAR_8 & 15, 128 - VAR_0->no_rounding); ptr = VAR_4[2] + offset; if (VAR_9) { VAR_0->vdsp.emulated_edge_mc(VAR_0->sc.edge_emu_buffer, ptr,
uvlinesize, uvlinesize,
9, 9,
VAR_5, VAR_6,
VAR_0->h_edge_pos >> 1, VAR_0->v_edge_pos >> 1); ptr = VAR_0->sc.edge_emu_buffer; } VAR_0->mdsp.gmc1(VAR_3, ptr, uvlinesize, 8,
VAR_7 & 15, VAR_8 & 15, 128 - VAR_0->no_rounding); }