void ff_mpeg4_pred_ac(MpegEncContext *s, int16_t *block, int n, int dir)

{

    int i;

    int16_t *ac_val, *ac_val1;

    int8_t *const qscale_table = s->current_picture.qscale_table;



    /* find prediction */

    ac_val  = s->ac_val[0][0] + s->block_index[n] * 16;

    ac_val1 = ac_val;

    if (s->ac_pred) {

        if (dir == 0) {

            const int xy = s->mb_x - 1 + s->mb_y * s->mb_stride;

            /* left prediction */

            ac_val -= 16;



            if (s->mb_x == 0 || s->qscale == qscale_table[xy] ||

                n == 1 || n == 3) {

                /* same qscale */

                for (i = 1; i < 8; i++)

                    block[s->idsp.idct_permutation[i << 3]] += ac_val[i];

            } else {

                /* different qscale, we must rescale */

                for (i = 1; i < 8; i++)

                    block[s->idsp.idct_permutation[i << 3]] += ROUNDED_DIV(ac_val[i] * qscale_table[xy], s->qscale);

            }

        } else {

            const int xy = s->mb_x + s->mb_y * s->mb_stride - s->mb_stride;

            /* top prediction */

            ac_val -= 16 * s->block_wrap[n];



            if (s->mb_y == 0 || s->qscale == qscale_table[xy] ||

                n == 2 || n == 3) {

                /* same qscale */

                for (i = 1; i < 8; i++)

                    block[s->idsp.idct_permutation[i]] += ac_val[i + 8];

            } else {

                /* different qscale, we must rescale */

                for (i = 1; i < 8; i++)

                    block[s->idsp.idct_permutation[i]] += ROUNDED_DIV(ac_val[i + 8] * qscale_table[xy], s->qscale);

            }

        }

    }

    /* left copy */

    for (i = 1; i < 8; i++)

        ac_val1[i] = block[s->idsp.idct_permutation[i << 3]];



    /* top copy */

    for (i = 1; i < 8; i++)

        ac_val1[8 + i] = block[s->idsp.idct_permutation[i]];

}

void ff_mpeg4_pred_ac(MpegEncContext *s, int16_t *block, int n, int dir)

{

    int i;

    int16_t *ac_val, *ac_val1;

    int8_t *const qscale_table = s->current_picture.qscale_table;



    

    ac_val  = s->ac_val[0][0] + s->block_index[n] * 16;

    ac_val1 = ac_val;

    if (s->ac_pred) {

        if (dir == 0) {

            const int xy = s->mb_x - 1 + s->mb_y * s->mb_stride;

            

            ac_val -= 16;



            if (s->mb_x == 0 || s->qscale == qscale_table[xy] ||

                n == 1 || n == 3) {

                

                for (i = 1; i < 8; i++)

                    block[s->idsp.idct_permutation[i << 3]] += ac_val[i];

            } else {

                

                for (i = 1; i < 8; i++)

                    block[s->idsp.idct_permutation[i << 3]] += ROUNDED_DIV(ac_val[i] * qscale_table[xy], s->qscale);

            }

        } else {

            const int xy = s->mb_x + s->mb_y * s->mb_stride - s->mb_stride;

            

            ac_val -= 16 * s->block_wrap[n];



            if (s->mb_y == 0 || s->qscale == qscale_table[xy] ||

                n == 2 || n == 3) {

                

                for (i = 1; i < 8; i++)

                    block[s->idsp.idct_permutation[i]] += ac_val[i + 8];

            } else {

                

                for (i = 1; i < 8; i++)

                    block[s->idsp.idct_permutation[i]] += ROUNDED_DIV(ac_val[i + 8] * qscale_table[xy], s->qscale);

            }

        }

    }

    

    for (i = 1; i < 8; i++)

        ac_val1[i] = block[s->idsp.idct_permutation[i << 3]];



    

    for (i = 1; i < 8; i++)

        ac_val1[8 + i] = block[s->idsp.idct_permutation[i]];

}

    ac_val  = s->ac_val[0][0] + s->block_index[n] * 16;
void FUNC_0(MpegEncContext *VAR_0, int16_t *VAR_1, int VAR_2, int VAR_3)

{

    int VAR_4;

    int16_t *ac_val, *ac_val1;

    int8_t *const qscale_table = VAR_0->current_picture.qscale_table;



    

    ac_val  = VAR_0->ac_val[0][0] + VAR_0->block_index[VAR_2] * 16;

    ac_val1 = ac_val;

    if (VAR_0->ac_pred) {

        if (VAR_3 == 0) {

            const int VAR_6 = VAR_0->mb_x - 1 + VAR_0->mb_y * VAR_0->mb_stride;

            

            ac_val -= 16;



            if (VAR_0->mb_x == 0 || VAR_0->qscale == qscale_table[VAR_6] ||

                VAR_2 == 1 || VAR_2 == 3) {

                

                for (VAR_4 = 1; VAR_4 < 8; VAR_4++)

                    VAR_1[VAR_0->idsp.idct_permutation[VAR_4 << 3]] += ac_val[VAR_4];

            } else {

                

                for (VAR_4 = 1; VAR_4 < 8; VAR_4++)

                    VAR_1[VAR_0->idsp.idct_permutation[VAR_4 << 3]] += ROUNDED_DIV(ac_val[VAR_4] * qscale_table[VAR_6], VAR_0->qscale);

            }

        } else {

            const int VAR_6 = VAR_0->mb_x + VAR_0->mb_y * VAR_0->mb_stride - VAR_0->mb_stride;

            

            ac_val -= 16 * VAR_0->block_wrap[VAR_2];



            if (VAR_0->mb_y == 0 || VAR_0->qscale == qscale_table[VAR_6] ||

                VAR_2 == 2 || VAR_2 == 3) {

                

                for (VAR_4 = 1; VAR_4 < 8; VAR_4++)

                    VAR_1[VAR_0->idsp.idct_permutation[VAR_4]] += ac_val[VAR_4 + 8];

            } else {

                

                for (VAR_4 = 1; VAR_4 < 8; VAR_4++)

                    VAR_1[VAR_0->idsp.idct_permutation[VAR_4]] += ROUNDED_DIV(ac_val[VAR_4 + 8] * qscale_table[VAR_6], VAR_0->qscale);

            }

        }

    }

    

    for (VAR_4 = 1; VAR_4 < 8; VAR_4++)

        ac_val1[VAR_4] = VAR_1[VAR_0->idsp.idct_permutation[VAR_4 << 3]];



    

    for (VAR_4 = 1; VAR_4 < 8; VAR_4++)

        ac_val1[8 + VAR_4] = VAR_1[VAR_0->idsp.idct_permutation[VAR_4]];

}

void FUNC_0(MpegEncContext *VAR_0, int16_t *VAR_1, int VAR_2, int VAR_3)
{ int VAR_4; int16_t *ac_val, *ac_val1; int8_t *const qscale_table = VAR_0->current_picture.qscale_table; ac_val  = VAR_0->ac_val[0][0] + VAR_0->block_index[VAR_2] * 16; ac_val1 = ac_val; if (VAR_0->ac_pred) { if (VAR_3 == 0) { const int VAR_6 = VAR_0->mb_x - 1 + VAR_0->mb_y * VAR_0->mb_stride; ac_val -= 16; if (VAR_0->mb_x == 0 || VAR_0->qscale == qscale_table[VAR_6] ||
VAR_2 == 1 || VAR_2 == 3) { for (VAR_4 = 1; VAR_4 < 8; VAR_4++) VAR_1[VAR_0->idsp.idct_permutation[VAR_4 << 3]] += ac_val[VAR_4]; } else { for (VAR_4 = 1; VAR_4 < 8; VAR_4++) VAR_1[VAR_0->idsp.idct_permutation[VAR_4 << 3]] += ROUNDED_DIV(ac_val[VAR_4] * qscale_table[VAR_6], VAR_0->qscale); } } else { const int VAR_6 = VAR_0->mb_x + VAR_0->mb_y * VAR_0->mb_stride - VAR_0->mb_stride; ac_val -= 16 * VAR_0->block_wrap[VAR_2]; if (VAR_0->mb_y == 0 || VAR_0->qscale == qscale_table[VAR_6] ||
VAR_2 == 2 || VAR_2 == 3) { for (VAR_4 = 1; VAR_4 < 8; VAR_4++) VAR_1[VAR_0->idsp.idct_permutation[VAR_4]] += ac_val[VAR_4 + 8]; } else { for (VAR_4 = 1; VAR_4 < 8; VAR_4++) VAR_1[VAR_0->idsp.idct_permutation[VAR_4]] += ROUNDED_DIV(ac_val[VAR_4 + 8] * qscale_table[VAR_6], VAR_0->qscale); } } } for (VAR_4 = 1; VAR_4 < 8; VAR_4++) ac_val1[VAR_4] = VAR_1[VAR_0->idsp.idct_permutation[VAR_4 << 3]]; for (VAR_4 = 1; VAR_4 < 8; VAR_4++) ac_val1[8 + VAR_4] = VAR_1[VAR_0->idsp.idct_permutation[VAR_4]]; }