static void apply_motion_4x4(RoqContext *ri, int x, int y, unsigned char mv,

    signed char mean_x, signed char mean_y)

{

    int i, hw, mx, my;

    unsigned char *pa, *pb;



    mx = x + 8 - (mv >> 4) - mean_x;

    my = y + 8 - (mv & 0xf) - mean_y;



    pa = ri->current_frame.data[0] + (y * ri->y_stride) + x;

    pb = ri->last_frame.data[0] + (my * ri->y_stride) + mx;

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

        pa[0] = pb[0];

        pa[1] = pb[1];

        pa[2] = pb[2];

        pa[3] = pb[3];

        pa += ri->y_stride;

        pb += ri->y_stride;

    }



#if 0

    pa = ri->current_frame.data[1] + (y/2) * (ri->c_stride) + x/2;

    pb = ri->last_frame.data[1] + (my/2) * (ri->c_stride) + (mx + 1)/2;

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

        pa[0] = pb[0];

        pa[1] = pb[1];

        pa += ri->c_stride;

        pb += ri->c_stride;

    }



    pa = ri->current_frame.data[2] + (y/2) * (ri->c_stride) + x/2;

    pb = ri->last_frame.data[2] + (my/2) * (ri->c_stride) + (mx + 1)/2;

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

        pa[0] = pb[0];

        pa[1] = pb[1];

        pa += ri->c_stride;

        pb += ri->c_stride;

    }

#else

    hw = ri->y_stride/2;

    pa = ri->current_frame.data[1] + (y * ri->y_stride)/4 + x/2;

    pb = ri->last_frame.data[1] + (my/2) * (ri->y_stride/2) + (mx + 1)/2;



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

        switch(((my & 0x01) << 1) | (mx & 0x01)) {



        case 0:

            pa[0] = pb[0];

            pa[1] = pb[1];

            pa[hw] = pb[hw];

            pa[hw+1] = pb[hw+1];

            break;



        case 1:

            pa[0] = avg2(pb[0], pb[1]);

            pa[1] = avg2(pb[1], pb[2]);

            pa[hw] = avg2(pb[hw], pb[hw+1]);

            pa[hw+1] = avg2(pb[hw+1], pb[hw+2]);

            break;



        case 2:

            pa[0] = avg2(pb[0], pb[hw]);

            pa[1] = avg2(pb[1], pb[hw+1]);

            pa[hw] = avg2(pb[hw], pb[hw*2]);

            pa[hw+1] = avg2(pb[hw+1], pb[(hw*2)+1]);

            break;



        case 3:

            pa[0] = avg4(pb[0], pb[1], pb[hw], pb[hw+1]);

            pa[1] = avg4(pb[1], pb[2], pb[hw+1], pb[hw+2]);

            pa[hw] = avg4(pb[hw], pb[hw+1], pb[hw*2], pb[(hw*2)+1]);

            pa[hw+1] = avg4(pb[hw+1], pb[hw+2], pb[(hw*2)+1], pb[(hw*2)+1]);

            break;

        }



        pa = ri->current_frame.data[2] + (y * ri->y_stride)/4 + x/2;

        pb = ri->last_frame.data[2] + (my/2) * (ri->y_stride/2) + (mx + 1)/2;

    }

#endif

}

static void apply_motion_4x4(RoqContext *ri, int x, int y, unsigned char mv,

    signed char mean_x, signed char mean_y)

{

    int i, hw, mx, my;

    unsigned char *pa, *pb;



    mx = x + 8 - (mv >> 4) - mean_x;

    my = y + 8 - (mv & 0xf) - mean_y;



    pa = ri->current_frame.data[0] + (y * ri->y_stride) + x;

    pb = ri->last_frame.data[0] + (my * ri->y_stride) + mx;

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

        pa[0] = pb[0];

        pa[1] = pb[1];

        pa[2] = pb[2];

        pa[3] = pb[3];

        pa += ri->y_stride;

        pb += ri->y_stride;

    }



#if 0

    pa = ri->current_frame.data[1] + (y/2) * (ri->c_stride) + x/2;

    pb = ri->last_frame.data[1] + (my/2) * (ri->c_stride) + (mx + 1)/2;

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

        pa[0] = pb[0];

        pa[1] = pb[1];

        pa += ri->c_stride;

        pb += ri->c_stride;

    }



    pa = ri->current_frame.data[2] + (y/2) * (ri->c_stride) + x/2;

    pb = ri->last_frame.data[2] + (my/2) * (ri->c_stride) + (mx + 1)/2;

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

        pa[0] = pb[0];

        pa[1] = pb[1];

        pa += ri->c_stride;

        pb += ri->c_stride;

    }

#else

    hw = ri->y_stride/2;

    pa = ri->current_frame.data[1] + (y * ri->y_stride)/4 + x/2;

    pb = ri->last_frame.data[1] + (my/2) * (ri->y_stride/2) + (mx + 1)/2;



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

        switch(((my & 0x01) << 1) | (mx & 0x01)) {



        case 0:

            pa[0] = pb[0];

            pa[1] = pb[1];

            pa[hw] = pb[hw];

            pa[hw+1] = pb[hw+1];

            break;



        case 1:

            pa[0] = avg2(pb[0], pb[1]);

            pa[1] = avg2(pb[1], pb[2]);

            pa[hw] = avg2(pb[hw], pb[hw+1]);

            pa[hw+1] = avg2(pb[hw+1], pb[hw+2]);

            break;



        case 2:

            pa[0] = avg2(pb[0], pb[hw]);

            pa[1] = avg2(pb[1], pb[hw+1]);

            pa[hw] = avg2(pb[hw], pb[hw*2]);

            pa[hw+1] = avg2(pb[hw+1], pb[(hw*2)+1]);

            break;



        case 3:

            pa[0] = avg4(pb[0], pb[1], pb[hw], pb[hw+1]);

            pa[1] = avg4(pb[1], pb[2], pb[hw+1], pb[hw+2]);

            pa[hw] = avg4(pb[hw], pb[hw+1], pb[hw*2], pb[(hw*2)+1]);

            pa[hw+1] = avg4(pb[hw+1], pb[hw+2], pb[(hw*2)+1], pb[(hw*2)+1]);

            break;

        }



        pa = ri->current_frame.data[2] + (y * ri->y_stride)/4 + x/2;

        pb = ri->last_frame.data[2] + (my/2) * (ri->y_stride/2) + (mx + 1)/2;

    }

#endif

}

static void FUNC_0(RoqContext *VAR_0, int VAR_1, int VAR_2, unsigned char VAR_3,

    signed char VAR_4, signed char VAR_5)

{

    int VAR_6, VAR_7, VAR_8, VAR_9;

    unsigned char *VAR_10, *VAR_11;



    VAR_8 = VAR_1 + 8 - (VAR_3 >> 4) - VAR_4;

    VAR_9 = VAR_2 + 8 - (VAR_3 & 0xf) - VAR_5;



    VAR_10 = VAR_0->current_frame.data[0] + (VAR_2 * VAR_0->y_stride) + VAR_1;

    VAR_11 = VAR_0->last_frame.data[0] + (VAR_9 * VAR_0->y_stride) + VAR_8;

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

        VAR_10[0] = VAR_11[0];

        VAR_10[1] = VAR_11[1];

        VAR_10[2] = VAR_11[2];

        VAR_10[3] = VAR_11[3];

        VAR_10 += VAR_0->y_stride;

        VAR_11 += VAR_0->y_stride;

    }



#if 0

    VAR_10 = VAR_0->current_frame.data[1] + (VAR_2/2) * (VAR_0->c_stride) + VAR_1/2;

    VAR_11 = VAR_0->last_frame.data[1] + (VAR_9/2) * (VAR_0->c_stride) + (VAR_8 + 1)/2;

    for(VAR_6 = 0; VAR_6 < 2; VAR_6++) {

        VAR_10[0] = VAR_11[0];

        VAR_10[1] = VAR_11[1];

        VAR_10 += VAR_0->c_stride;

        VAR_11 += VAR_0->c_stride;

    }



    VAR_10 = VAR_0->current_frame.data[2] + (VAR_2/2) * (VAR_0->c_stride) + VAR_1/2;

    VAR_11 = VAR_0->last_frame.data[2] + (VAR_9/2) * (VAR_0->c_stride) + (VAR_8 + 1)/2;

    for(VAR_6 = 0; VAR_6 < 2; VAR_6++) {

        VAR_10[0] = VAR_11[0];

        VAR_10[1] = VAR_11[1];

        VAR_10 += VAR_0->c_stride;

        VAR_11 += VAR_0->c_stride;

    }

#else

    VAR_7 = VAR_0->y_stride/2;

    VAR_10 = VAR_0->current_frame.data[1] + (VAR_2 * VAR_0->y_stride)/4 + VAR_1/2;

    VAR_11 = VAR_0->last_frame.data[1] + (VAR_9/2) * (VAR_0->y_stride/2) + (VAR_8 + 1)/2;



    for(VAR_6 = 0; VAR_6 < 2; VAR_6++) {

        switch(((VAR_9 & 0x01) << 1) | (VAR_8 & 0x01)) {



        case 0:

            VAR_10[0] = VAR_11[0];

            VAR_10[1] = VAR_11[1];

            VAR_10[VAR_7] = VAR_11[VAR_7];

            VAR_10[VAR_7+1] = VAR_11[VAR_7+1];

            break;



        case 1:

            VAR_10[0] = avg2(VAR_11[0], VAR_11[1]);

            VAR_10[1] = avg2(VAR_11[1], VAR_11[2]);

            VAR_10[VAR_7] = avg2(VAR_11[VAR_7], VAR_11[VAR_7+1]);

            VAR_10[VAR_7+1] = avg2(VAR_11[VAR_7+1], VAR_11[VAR_7+2]);

            break;



        case 2:

            VAR_10[0] = avg2(VAR_11[0], VAR_11[VAR_7]);

            VAR_10[1] = avg2(VAR_11[1], VAR_11[VAR_7+1]);

            VAR_10[VAR_7] = avg2(VAR_11[VAR_7], VAR_11[VAR_7*2]);

            VAR_10[VAR_7+1] = avg2(VAR_11[VAR_7+1], VAR_11[(VAR_7*2)+1]);

            break;



        case 3:

            VAR_10[0] = avg4(VAR_11[0], VAR_11[1], VAR_11[VAR_7], VAR_11[VAR_7+1]);

            VAR_10[1] = avg4(VAR_11[1], VAR_11[2], VAR_11[VAR_7+1], VAR_11[VAR_7+2]);

            VAR_10[VAR_7] = avg4(VAR_11[VAR_7], VAR_11[VAR_7+1], VAR_11[VAR_7*2], VAR_11[(VAR_7*2)+1]);

            VAR_10[VAR_7+1] = avg4(VAR_11[VAR_7+1], VAR_11[VAR_7+2], VAR_11[(VAR_7*2)+1], VAR_11[(VAR_7*2)+1]);

            break;

        }



        VAR_10 = VAR_0->current_frame.data[2] + (VAR_2 * VAR_0->y_stride)/4 + VAR_1/2;

        VAR_11 = VAR_0->last_frame.data[2] + (VAR_9/2) * (VAR_0->y_stride/2) + (VAR_8 + 1)/2;

    }

#endif

}

static void FUNC_0(RoqContext *VAR_0, int VAR_1, int VAR_2, unsigned char VAR_3,
signed char VAR_4, signed char VAR_5)
{ int VAR_6, VAR_7, VAR_8, VAR_9; unsigned char *VAR_10, *VAR_11; VAR_8 = VAR_1 + 8 - (VAR_3 >> 4) - VAR_4; VAR_9 = VAR_2 + 8 - (VAR_3 & 0xf) - VAR_5; VAR_10 = VAR_0->current_frame.data[0] + (VAR_2 * VAR_0->y_stride) + VAR_1; VAR_11 = VAR_0->last_frame.data[0] + (VAR_9 * VAR_0->y_stride) + VAR_8; for(VAR_6 = 0; VAR_6 < 4; VAR_6++) { VAR_10[0] = VAR_11[0]; VAR_10[1] = VAR_11[1]; VAR_10[2] = VAR_11[2]; VAR_10[3] = VAR_11[3]; VAR_10 += VAR_0->y_stride; VAR_11 += VAR_0->y_stride; } #if 0
VAR_10 = VAR_0->current_frame.data[1] + (VAR_2/2) * (VAR_0->c_stride) + VAR_1/2; VAR_11 = VAR_0->last_frame.data[1] + (VAR_9/2) * (VAR_0->c_stride) + (VAR_8 + 1)/2; for(VAR_6 = 0; VAR_6 < 2; VAR_6++) { VAR_10[0] = VAR_11[0]; VAR_10[1] = VAR_11[1]; VAR_10 += VAR_0->c_stride; VAR_11 += VAR_0->c_stride; } VAR_10 = VAR_0->current_frame.data[2] + (VAR_2/2) * (VAR_0->c_stride) + VAR_1/2; VAR_11 = VAR_0->last_frame.data[2] + (VAR_9/2) * (VAR_0->c_stride) + (VAR_8 + 1)/2; for(VAR_6 = 0; VAR_6 < 2; VAR_6++) { VAR_10[0] = VAR_11[0]; VAR_10[1] = VAR_11[1]; VAR_10 += VAR_0->c_stride; VAR_11 += VAR_0->c_stride; } #else
VAR_7 = VAR_0->y_stride/2; VAR_10 = VAR_0->current_frame.data[1] + (VAR_2 * VAR_0->y_stride)/4 + VAR_1/2; VAR_11 = VAR_0->last_frame.data[1] + (VAR_9/2) * (VAR_0->y_stride/2) + (VAR_8 + 1)/2; for(VAR_6 = 0; VAR_6 < 2; VAR_6++) { switch(((VAR_9 & 0x01) << 1) | (VAR_8 & 0x01)) { case 0:
VAR_10[0] = VAR_11[0]; VAR_10[1] = VAR_11[1]; VAR_10[VAR_7] = VAR_11[VAR_7]; VAR_10[VAR_7+1] = VAR_11[VAR_7+1]; break; case 1:
VAR_10[0] = avg2(VAR_11[0], VAR_11[1]); VAR_10[1] = avg2(VAR_11[1], VAR_11[2]); VAR_10[VAR_7] = avg2(VAR_11[VAR_7], VAR_11[VAR_7+1]); VAR_10[VAR_7+1] = avg2(VAR_11[VAR_7+1], VAR_11[VAR_7+2]); break; case 2:
VAR_10[0] = avg2(VAR_11[0], VAR_11[VAR_7]); VAR_10[1] = avg2(VAR_11[1], VAR_11[VAR_7+1]); VAR_10[VAR_7] = avg2(VAR_11[VAR_7], VAR_11[VAR_7*2]); VAR_10[VAR_7+1] = avg2(VAR_11[VAR_7+1], VAR_11[(VAR_7*2)+1]); break; case 3:
VAR_10[0] = avg4(VAR_11[0], VAR_11[1], VAR_11[VAR_7], VAR_11[VAR_7+1]); VAR_10[1] = avg4(VAR_11[1], VAR_11[2], VAR_11[VAR_7+1], VAR_11[VAR_7+2]); VAR_10[VAR_7] = avg4(VAR_11[VAR_7], VAR_11[VAR_7+1], VAR_11[VAR_7*2], VAR_11[(VAR_7*2)+1]); VAR_10[VAR_7+1] = avg4(VAR_11[VAR_7+1], VAR_11[VAR_7+2], VAR_11[(VAR_7*2)+1], VAR_11[(VAR_7*2)+1]); break; } VAR_10 = VAR_0->current_frame.data[2] + (VAR_2 * VAR_0->y_stride)/4 + VAR_1/2; VAR_11 = VAR_0->last_frame.data[2] + (VAR_9/2) * (VAR_0->y_stride/2) + (VAR_8 + 1)/2; } #endif
}