static inline int vc1_pred_dc(MpegEncContext *s, int overlap, int pq, int n,

                              int a_avail, int c_avail,

                              int16_t **dc_val_ptr, int *dir_ptr)

{

    int a, b, c, wrap, pred;

    int16_t *dc_val;

    int mb_pos = s->mb_x + s->mb_y * s->mb_stride;

    int q1, q2 = 0;



    wrap = s->block_wrap[n];

    dc_val = s->dc_val[0] + s->block_index[n];



    /* B A

     * C X

     */

    c = dc_val[ - 1];

    b = dc_val[ - 1 - wrap];

    a = dc_val[ - wrap];

    /* scale predictors if needed */

    q1 = s->current_picture.f.qscale_table[mb_pos];

    if (c_avail && (n != 1 && n != 3)) {

        q2 = s->current_picture.f.qscale_table[mb_pos - 1];

        if (q2 && q2 != q1)

            c = (c * s->y_dc_scale_table[q2] * ff_vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18;

    }

    if (a_avail && (n != 2 && n != 3)) {

        q2 = s->current_picture.f.qscale_table[mb_pos - s->mb_stride];

        if (q2 && q2 != q1)

            a = (a * s->y_dc_scale_table[q2] * ff_vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18;

    }

    if (a_avail && c_avail && (n != 3)) {

        int off = mb_pos;

        if (n != 1)

            off--;

        if (n != 2)

            off -= s->mb_stride;

        q2 = s->current_picture.f.qscale_table[off];

        if (q2 && q2 != q1)

            b = (b * s->y_dc_scale_table[q2] * ff_vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18;

    }



    if (a_avail && c_avail) {

        if (abs(a - b) <= abs(b - c)) {

            pred     = c;

            *dir_ptr = 1; // left

        } else {

            pred     = a;

            *dir_ptr = 0; // top

        }

    } else if (a_avail) {

        pred     = a;

        *dir_ptr = 0; // top

    } else if (c_avail) {

        pred     = c;

        *dir_ptr = 1; // left

    } else {

        pred     = 0;

        *dir_ptr = 1; // left

    }



    /* update predictor */

    *dc_val_ptr = &dc_val[0];

    return pred;

}

static inline int vc1_pred_dc(MpegEncContext *s, int overlap, int pq, int n,

                              int a_avail, int c_avail,

                              int16_t **dc_val_ptr, int *dir_ptr)

{

    int a, b, c, wrap, pred;

    int16_t *dc_val;

    int mb_pos = s->mb_x + s->mb_y * s->mb_stride;

    int q1, q2 = 0;



    wrap = s->block_wrap[n];

    dc_val = s->dc_val[0] + s->block_index[n];



    





    c = dc_val[ - 1];

    b = dc_val[ - 1 - wrap];

    a = dc_val[ - wrap];

    

    q1 = s->current_picture.f.qscale_table[mb_pos];

    if (c_avail && (n != 1 && n != 3)) {

        q2 = s->current_picture.f.qscale_table[mb_pos - 1];

        if (q2 && q2 != q1)

            c = (c * s->y_dc_scale_table[q2] * ff_vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18;

    }

    if (a_avail && (n != 2 && n != 3)) {

        q2 = s->current_picture.f.qscale_table[mb_pos - s->mb_stride];

        if (q2 && q2 != q1)

            a = (a * s->y_dc_scale_table[q2] * ff_vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18;

    }

    if (a_avail && c_avail && (n != 3)) {

        int off = mb_pos;

        if (n != 1)

            off--;

        if (n != 2)

            off -= s->mb_stride;

        q2 = s->current_picture.f.qscale_table[off];

        if (q2 && q2 != q1)

            b = (b * s->y_dc_scale_table[q2] * ff_vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18;

    }



    if (a_avail && c_avail) {

        if (abs(a - b) <= abs(b - c)) {

            pred     = c;

            *dir_ptr = 1; 

        } else {

            pred     = a;

            *dir_ptr = 0; 

        }

    } else if (a_avail) {

        pred     = a;

        *dir_ptr = 0; 

    } else if (c_avail) {

        pred     = c;

        *dir_ptr = 1; 

    } else {

        pred     = 0;

        *dir_ptr = 1; 

    }



    

    *dc_val_ptr = &dc_val[0];

    return pred;

}

static inline int FUNC_0(MpegEncContext *VAR_0, int VAR_1, int VAR_2, int VAR_3,

                              int VAR_4, int VAR_5,

                              int16_t **VAR_6, int *VAR_7)

{

    int VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;

    int16_t *dc_val;

    int VAR_13 = VAR_0->mb_x + VAR_0->mb_y * VAR_0->mb_stride;

    int VAR_14, VAR_15 = 0;



    VAR_11 = VAR_0->block_wrap[VAR_3];

    dc_val = VAR_0->dc_val[0] + VAR_0->block_index[VAR_3];



    





    VAR_10 = dc_val[ - 1];

    VAR_9 = dc_val[ - 1 - VAR_11];

    VAR_8 = dc_val[ - VAR_11];

    

    VAR_14 = VAR_0->current_picture.f.qscale_table[VAR_13];

    if (VAR_5 && (VAR_3 != 1 && VAR_3 != 3)) {

        VAR_15 = VAR_0->current_picture.f.qscale_table[VAR_13 - 1];

        if (VAR_15 && VAR_15 != VAR_14)

            VAR_10 = (VAR_10 * VAR_0->y_dc_scale_table[VAR_15] * ff_vc1_dqscale[VAR_0->y_dc_scale_table[VAR_14] - 1] + 0x20000) >> 18;

    }

    if (VAR_4 && (VAR_3 != 2 && VAR_3 != 3)) {

        VAR_15 = VAR_0->current_picture.f.qscale_table[VAR_13 - VAR_0->mb_stride];

        if (VAR_15 && VAR_15 != VAR_14)

            VAR_8 = (VAR_8 * VAR_0->y_dc_scale_table[VAR_15] * ff_vc1_dqscale[VAR_0->y_dc_scale_table[VAR_14] - 1] + 0x20000) >> 18;

    }

    if (VAR_4 && VAR_5 && (VAR_3 != 3)) {

        int VAR_16 = VAR_13;

        if (VAR_3 != 1)

            VAR_16--;

        if (VAR_3 != 2)

            VAR_16 -= VAR_0->mb_stride;

        VAR_15 = VAR_0->current_picture.f.qscale_table[VAR_16];

        if (VAR_15 && VAR_15 != VAR_14)

            VAR_9 = (VAR_9 * VAR_0->y_dc_scale_table[VAR_15] * ff_vc1_dqscale[VAR_0->y_dc_scale_table[VAR_14] - 1] + 0x20000) >> 18;

    }



    if (VAR_4 && VAR_5) {

        if (abs(VAR_8 - VAR_9) <= abs(VAR_9 - VAR_10)) {

            VAR_12     = VAR_10;

            *VAR_7 = 1; 

        } else {

            VAR_12     = VAR_8;

            *VAR_7 = 0; 

        }

    } else if (VAR_4) {

        VAR_12     = VAR_8;

        *VAR_7 = 0; 

    } else if (VAR_5) {

        VAR_12     = VAR_10;

        *VAR_7 = 1; 

    } else {

        VAR_12     = 0;

        *VAR_7 = 1; 

    }



    

    *VAR_6 = &dc_val[0];

    return VAR_12;

}

static inline int FUNC_0(MpegEncContext *VAR_0, int VAR_1, int VAR_2, int VAR_3,
int VAR_4, int VAR_5,
int16_t **VAR_6, int *VAR_7)
{ int VAR_8, VAR_9, VAR_10, VAR_11, VAR_12; int16_t *dc_val; int VAR_13 = VAR_0->mb_x + VAR_0->mb_y * VAR_0->mb_stride; int VAR_14, VAR_15 = 0; VAR_11 = VAR_0->block_wrap[VAR_3]; dc_val = VAR_0->dc_val[0] + VAR_0->block_index[VAR_3]; VAR_10 = dc_val[ - 1]; VAR_9 = dc_val[ - 1 - VAR_11]; VAR_8 = dc_val[ - VAR_11]; VAR_14 = VAR_0->current_picture.f.qscale_table[VAR_13]; if (VAR_5 && (VAR_3 != 1 && VAR_3 != 3)) { VAR_15 = VAR_0->current_picture.f.qscale_table[VAR_13 - 1]; if (VAR_15 && VAR_15 != VAR_14)
VAR_10 = (VAR_10 * VAR_0->y_dc_scale_table[VAR_15] * ff_vc1_dqscale[VAR_0->y_dc_scale_table[VAR_14] - 1] + 0x20000) >> 18; } if (VAR_4 && (VAR_3 != 2 && VAR_3 != 3)) { VAR_15 = VAR_0->current_picture.f.qscale_table[VAR_13 - VAR_0->mb_stride]; if (VAR_15 && VAR_15 != VAR_14)
VAR_8 = (VAR_8 * VAR_0->y_dc_scale_table[VAR_15] * ff_vc1_dqscale[VAR_0->y_dc_scale_table[VAR_14] - 1] + 0x20000) >> 18; } if (VAR_4 && VAR_5 && (VAR_3 != 3)) { int VAR_16 = VAR_13; if (VAR_3 != 1)
VAR_16--; if (VAR_3 != 2)
VAR_16 -= VAR_0->mb_stride; VAR_15 = VAR_0->current_picture.f.qscale_table[VAR_16]; if (VAR_15 && VAR_15 != VAR_14)
VAR_9 = (VAR_9 * VAR_0->y_dc_scale_table[VAR_15] * ff_vc1_dqscale[VAR_0->y_dc_scale_table[VAR_14] - 1] + 0x20000) >> 18; } if (VAR_4 && VAR_5) { if (abs(VAR_8 - VAR_9) <= abs(VAR_9 - VAR_10)) { VAR_12     = VAR_10; *VAR_7 = 1; } else { VAR_12     = VAR_8; *VAR_7 = 0; } } else if (VAR_4) { VAR_12     = VAR_8; *VAR_7 = 0; } else if (VAR_5) { VAR_12     = VAR_10; *VAR_7 = 1; } else { VAR_12     = 0; *VAR_7 = 1; } *VAR_6 = &dc_val[0]; return VAR_12; }