static int svq1_motion_inter_4v_block(MpegEncContext *s, GetBitContext *bitbuf,

                                      uint8_t *current, uint8_t *previous,

                                      int pitch, svq1_pmv *motion, int x, int y)

{

    uint8_t *src;

    uint8_t *dst;

    svq1_pmv mv;

    svq1_pmv *pmv[4];

    int i, result;



    /* predict and decode motion vector (0) */

    pmv[0] = &motion[0];

    if (y == 0) {

        pmv[1] =

        pmv[2] = pmv[0];

    } else {

        pmv[1] = &motion[(x / 8) + 2];

        pmv[2] = &motion[(x / 8) + 4];

    }



    result = svq1_decode_motion_vector(bitbuf, &mv, pmv);



    if (result != 0)

        return result;



    /* predict and decode motion vector (1) */

    pmv[0] = &mv;

    if (y == 0) {

        pmv[1] =

        pmv[2] = pmv[0];

    } else {

        pmv[1] = &motion[(x / 8) + 3];

    }

    result = svq1_decode_motion_vector(bitbuf, &motion[0], pmv);



    if (result != 0)

        return result;



    /* predict and decode motion vector (2) */

    pmv[1] = &motion[0];

    pmv[2] = &motion[(x / 8) + 1];



    result = svq1_decode_motion_vector(bitbuf, &motion[(x / 8) + 2], pmv);



    if (result != 0)

        return result;



    /* predict and decode motion vector (3) */

    pmv[2] = &motion[(x / 8) + 2];

    pmv[3] = &motion[(x / 8) + 3];



    result = svq1_decode_motion_vector(bitbuf, pmv[3], pmv);



    if (result != 0)

        return result;



    /* form predictions */

    for (i = 0; i < 4; i++) {

        int mvx = pmv[i]->x + (i  & 1) * 16;

        int mvy = pmv[i]->y + (i >> 1) * 16;



        // FIXME: clipping or padding?

        if (y + (mvy >> 1) < 0)

            mvy = 0;

        if (x + (mvx >> 1) < 0)

            mvx = 0;



        src = &previous[(x + (mvx >> 1)) + (y + (mvy >> 1)) * pitch];

        dst = current;



        s->dsp.put_pixels_tab[1][((mvy & 1) << 1) | (mvx & 1)](dst, src, pitch, 8);



        /* select next block */

        if (i & 1)

            current += 8 * (pitch - 1);

        else

            current += 8;

    }



    return 0;

}

static int svq1_motion_inter_4v_block(MpegEncContext *s, GetBitContext *bitbuf,

                                      uint8_t *current, uint8_t *previous,

                                      int pitch, svq1_pmv *motion, int x, int y)

{

    uint8_t *src;

    uint8_t *dst;

    svq1_pmv mv;

    svq1_pmv *pmv[4];

    int i, result;



    

    pmv[0] = &motion[0];

    if (y == 0) {

        pmv[1] =

        pmv[2] = pmv[0];

    } else {

        pmv[1] = &motion[(x / 8) + 2];

        pmv[2] = &motion[(x / 8) + 4];

    }



    result = svq1_decode_motion_vector(bitbuf, &mv, pmv);



    if (result != 0)

        return result;



    

    pmv[0] = &mv;

    if (y == 0) {

        pmv[1] =

        pmv[2] = pmv[0];

    } else {

        pmv[1] = &motion[(x / 8) + 3];

    }

    result = svq1_decode_motion_vector(bitbuf, &motion[0], pmv);



    if (result != 0)

        return result;



    

    pmv[1] = &motion[0];

    pmv[2] = &motion[(x / 8) + 1];



    result = svq1_decode_motion_vector(bitbuf, &motion[(x / 8) + 2], pmv);



    if (result != 0)

        return result;



    

    pmv[2] = &motion[(x / 8) + 2];

    pmv[3] = &motion[(x / 8) + 3];



    result = svq1_decode_motion_vector(bitbuf, pmv[3], pmv);



    if (result != 0)

        return result;



    

    for (i = 0; i < 4; i++) {

        int mvx = pmv[i]->x + (i  & 1) * 16;

        int mvy = pmv[i]->y + (i >> 1) * 16;



        

        if (y + (mvy >> 1) < 0)

            mvy = 0;

        if (x + (mvx >> 1) < 0)

            mvx = 0;



        src = &previous[(x + (mvx >> 1)) + (y + (mvy >> 1)) * pitch];

        dst = current;



        s->dsp.put_pixels_tab[1][((mvy & 1) << 1) | (mvx & 1)](dst, src, pitch, 8);



        

        if (i & 1)

            current += 8 * (pitch - 1);

        else

            current += 8;

    }



    return 0;

}

static int FUNC_0(MpegEncContext *VAR_0, GetBitContext *VAR_1,

                                      uint8_t *VAR_2, uint8_t *VAR_3,

                                      int VAR_4, svq1_pmv *VAR_5, int VAR_6, int VAR_7)

{

    uint8_t *src;

    uint8_t *dst;

    svq1_pmv mv;

    svq1_pmv *pmv[4];

    int VAR_8, VAR_9;



    

    pmv[0] = &VAR_5[0];

    if (VAR_7 == 0) {

        pmv[1] =

        pmv[2] = pmv[0];

    } else {

        pmv[1] = &VAR_5[(VAR_6 / 8) + 2];

        pmv[2] = &VAR_5[(VAR_6 / 8) + 4];

    }



    VAR_9 = svq1_decode_motion_vector(VAR_1, &mv, pmv);



    if (VAR_9 != 0)

        return VAR_9;



    

    pmv[0] = &mv;

    if (VAR_7 == 0) {

        pmv[1] =

        pmv[2] = pmv[0];

    } else {

        pmv[1] = &VAR_5[(VAR_6 / 8) + 3];

    }

    VAR_9 = svq1_decode_motion_vector(VAR_1, &VAR_5[0], pmv);



    if (VAR_9 != 0)

        return VAR_9;



    

    pmv[1] = &VAR_5[0];

    pmv[2] = &VAR_5[(VAR_6 / 8) + 1];



    VAR_9 = svq1_decode_motion_vector(VAR_1, &VAR_5[(VAR_6 / 8) + 2], pmv);



    if (VAR_9 != 0)

        return VAR_9;



    

    pmv[2] = &VAR_5[(VAR_6 / 8) + 2];

    pmv[3] = &VAR_5[(VAR_6 / 8) + 3];



    VAR_9 = svq1_decode_motion_vector(VAR_1, pmv[3], pmv);



    if (VAR_9 != 0)

        return VAR_9;



    

    for (VAR_8 = 0; VAR_8 < 4; VAR_8++) {

        int VAR_10 = pmv[VAR_8]->VAR_6 + (VAR_8  & 1) * 16;

        int VAR_11 = pmv[VAR_8]->VAR_7 + (VAR_8 >> 1) * 16;



        

        if (VAR_7 + (VAR_11 >> 1) < 0)

            VAR_11 = 0;

        if (VAR_6 + (VAR_10 >> 1) < 0)

            VAR_10 = 0;



        src = &VAR_3[(VAR_6 + (VAR_10 >> 1)) + (VAR_7 + (VAR_11 >> 1)) * VAR_4];

        dst = VAR_2;



        VAR_0->dsp.put_pixels_tab[1][((VAR_11 & 1) << 1) | (VAR_10 & 1)](dst, src, VAR_4, 8);



        

        if (VAR_8 & 1)

            VAR_2 += 8 * (VAR_4 - 1);

        else

            VAR_2 += 8;

    }



    return 0;

}

static int FUNC_0(MpegEncContext *VAR_0, GetBitContext *VAR_1,
uint8_t *VAR_2, uint8_t *VAR_3,
int VAR_4, svq1_pmv *VAR_5, int VAR_6, int VAR_7)
{ uint8_t *src; uint8_t *dst; svq1_pmv mv; svq1_pmv *pmv[4]; int VAR_8, VAR_9; pmv[0] = &VAR_5[0]; if (VAR_7 == 0) { pmv[1] =
pmv[2] = pmv[0]; } else { pmv[1] = &VAR_5[(VAR_6 / 8) + 2]; pmv[2] = &VAR_5[(VAR_6 / 8) + 4]; } VAR_9 = svq1_decode_motion_vector(VAR_1, &mv, pmv); if (VAR_9 != 0)
return VAR_9; pmv[0] = &mv; if (VAR_7 == 0) { pmv[1] =
pmv[2] = pmv[0]; } else { pmv[1] = &VAR_5[(VAR_6 / 8) + 3]; } VAR_9 = svq1_decode_motion_vector(VAR_1, &VAR_5[0], pmv); if (VAR_9 != 0)
return VAR_9; pmv[1] = &VAR_5[0]; pmv[2] = &VAR_5[(VAR_6 / 8) + 1]; VAR_9 = svq1_decode_motion_vector(VAR_1, &VAR_5[(VAR_6 / 8) + 2], pmv); if (VAR_9 != 0)
return VAR_9; pmv[2] = &VAR_5[(VAR_6 / 8) + 2]; pmv[3] = &VAR_5[(VAR_6 / 8) + 3]; VAR_9 = svq1_decode_motion_vector(VAR_1, pmv[3], pmv); if (VAR_9 != 0)
return VAR_9; for (VAR_8 = 0; VAR_8 < 4; VAR_8++) { int VAR_10 = pmv[VAR_8]->VAR_6 + (VAR_8  & 1) * 16; int VAR_11 = pmv[VAR_8]->VAR_7 + (VAR_8 >> 1) * 16; if (VAR_7 + (VAR_11 >> 1) < 0)
VAR_11 = 0; if (VAR_6 + (VAR_10 >> 1) < 0)
VAR_10 = 0; src = &VAR_3[(VAR_6 + (VAR_10 >> 1)) + (VAR_7 + (VAR_11 >> 1)) * VAR_4]; dst = VAR_2; VAR_0->dsp.put_pixels_tab[1][((VAR_11 & 1) << 1) | (VAR_10 & 1)](dst, src, VAR_4, 8); if (VAR_8 & 1)
VAR_2 += 8 * (VAR_4 - 1); else
VAR_2 += 8; } return 0; }