void ff_er_add_slice(ERContext *s, int startx, int starty,

                     int endx, int endy, int status)

{

    const int start_i  = av_clip(startx + starty * s->mb_width, 0, s->mb_num - 1);

    const int end_i    = av_clip(endx   + endy   * s->mb_width, 0, s->mb_num);

    const int start_xy = s->mb_index2xy[start_i];

    const int end_xy   = s->mb_index2xy[end_i];

    int mask           = -1;



    if (s->avctx->hwaccel && s->avctx->hwaccel->decode_slice)

        return;



    if (start_i > end_i || start_xy > end_xy) {

        av_log(s->avctx, AV_LOG_ERROR,

               "internal error, slice end before start\n");

        return;

    }



    if (!s->avctx->error_concealment)

        return;



    mask &= ~VP_START;

    if (status & (ER_AC_ERROR | ER_AC_END)) {

        mask           &= ~(ER_AC_ERROR | ER_AC_END);

        s->error_count -= end_i - start_i + 1;

    }

    if (status & (ER_DC_ERROR | ER_DC_END)) {

        mask           &= ~(ER_DC_ERROR | ER_DC_END);

        s->error_count -= end_i - start_i + 1;

    }

    if (status & (ER_MV_ERROR | ER_MV_END)) {

        mask           &= ~(ER_MV_ERROR | ER_MV_END);

        s->error_count -= end_i - start_i + 1;

    }



    if (status & ER_MB_ERROR) {

        s->error_occurred = 1;

        s->error_count    = INT_MAX;

    }



    if (mask == ~0x7F) {

        memset(&s->error_status_table[start_xy], 0,

               (end_xy - start_xy) * sizeof(uint8_t));

    } else {

        int i;

        for (i = start_xy; i < end_xy; i++)

            s->error_status_table[i] &= mask;

    }



    if (end_i == s->mb_num)

        s->error_count = INT_MAX;

    else {

        s->error_status_table[end_xy] &= mask;

        s->error_status_table[end_xy] |= status;

    }



    s->error_status_table[start_xy] |= VP_START;



    if (start_xy > 0 && !(s->avctx->active_thread_type & FF_THREAD_SLICE) &&

        er_supported(s) && s->avctx->skip_top * s->mb_width < start_i) {

        int prev_status = s->error_status_table[s->mb_index2xy[start_i - 1]];



        prev_status &= ~ VP_START;

        if (prev_status != (ER_MV_END | ER_DC_END | ER_AC_END)) {

            s->error_occurred = 1;

            s->error_count = INT_MAX;

        }

    }

}

void ff_er_add_slice(ERContext *s, int startx, int starty,

                     int endx, int endy, int status)

{

    const int start_i  = av_clip(startx + starty * s->mb_width, 0, s->mb_num - 1);

    const int end_i    = av_clip(endx   + endy   * s->mb_width, 0, s->mb_num);

    const int start_xy = s->mb_index2xy[start_i];

    const int end_xy   = s->mb_index2xy[end_i];

    int mask           = -1;



    if (s->avctx->hwaccel && s->avctx->hwaccel->decode_slice)

        return;



    if (start_i > end_i || start_xy > end_xy) {

        av_log(s->avctx, AV_LOG_ERROR,

               "internal error, slice end before start\n");

        return;

    }



    if (!s->avctx->error_concealment)

        return;



    mask &= ~VP_START;

    if (status & (ER_AC_ERROR | ER_AC_END)) {

        mask           &= ~(ER_AC_ERROR | ER_AC_END);

        s->error_count -= end_i - start_i + 1;

    }

    if (status & (ER_DC_ERROR | ER_DC_END)) {

        mask           &= ~(ER_DC_ERROR | ER_DC_END);

        s->error_count -= end_i - start_i + 1;

    }

    if (status & (ER_MV_ERROR | ER_MV_END)) {

        mask           &= ~(ER_MV_ERROR | ER_MV_END);

        s->error_count -= end_i - start_i + 1;

    }



    if (status & ER_MB_ERROR) {

        s->error_occurred = 1;

        s->error_count    = INT_MAX;

    }



    if (mask == ~0x7F) {

        memset(&s->error_status_table[start_xy], 0,

               (end_xy - start_xy) * sizeof(uint8_t));

    } else {

        int i;

        for (i = start_xy; i < end_xy; i++)

            s->error_status_table[i] &= mask;

    }



    if (end_i == s->mb_num)

        s->error_count = INT_MAX;

    else {

        s->error_status_table[end_xy] &= mask;

        s->error_status_table[end_xy] |= status;

    }



    s->error_status_table[start_xy] |= VP_START;



    if (start_xy > 0 && !(s->avctx->active_thread_type & FF_THREAD_SLICE) &&

        er_supported(s) && s->avctx->skip_top * s->mb_width < start_i) {

        int prev_status = s->error_status_table[s->mb_index2xy[start_i - 1]];



        prev_status &= ~ VP_START;

        if (prev_status != (ER_MV_END | ER_DC_END | ER_AC_END)) {

            s->error_occurred = 1;

            s->error_count = INT_MAX;

        }

    }

}

        s->error_count -= end_i - start_i + 1;         s->error_count -= end_i - start_i + 1;         s->error_count -= end_i - start_i + 1;         s->error_count    = INT_MAX;         s->error_count = INT_MAX;             s->error_count = INT_MAX;
void FUNC_0(ERContext *VAR_0, int VAR_1, int VAR_2,

                     int VAR_3, int VAR_4, int VAR_5)

{

    const int VAR_6  = av_clip(VAR_1 + VAR_2 * VAR_0->mb_width, 0, VAR_0->mb_num - 1);

    const int VAR_7    = av_clip(VAR_3   + VAR_4   * VAR_0->mb_width, 0, VAR_0->mb_num);

    const int VAR_8 = VAR_0->mb_index2xy[VAR_6];

    const int VAR_9   = VAR_0->mb_index2xy[VAR_7];

    int VAR_10           = -1;



    if (VAR_0->avctx->hwaccel && VAR_0->avctx->hwaccel->decode_slice)

        return;



    if (VAR_6 > VAR_7 || VAR_8 > VAR_9) {

        av_log(VAR_0->avctx, AV_LOG_ERROR,

               "internal error, slice end before start\n");

        return;

    }



    if (!VAR_0->avctx->error_concealment)

        return;



    VAR_10 &= ~VP_START;

    if (VAR_5 & (ER_AC_ERROR | ER_AC_END)) {

        VAR_10           &= ~(ER_AC_ERROR | ER_AC_END);

        VAR_0->error_count -= VAR_7 - VAR_6 + 1;

    }

    if (VAR_5 & (ER_DC_ERROR | ER_DC_END)) {

        VAR_10           &= ~(ER_DC_ERROR | ER_DC_END);

        VAR_0->error_count -= VAR_7 - VAR_6 + 1;

    }

    if (VAR_5 & (ER_MV_ERROR | ER_MV_END)) {

        VAR_10           &= ~(ER_MV_ERROR | ER_MV_END);

        VAR_0->error_count -= VAR_7 - VAR_6 + 1;

    }



    if (VAR_5 & ER_MB_ERROR) {

        VAR_0->error_occurred = 1;

        VAR_0->error_count    = INT_MAX;

    }



    if (VAR_10 == ~0x7F) {

        memset(&VAR_0->error_status_table[VAR_8], 0,

               (VAR_9 - VAR_8) * sizeof(uint8_t));

    } else {

        int VAR_11;

        for (VAR_11 = VAR_8; VAR_11 < VAR_9; VAR_11++)

            VAR_0->error_status_table[VAR_11] &= VAR_10;

    }



    if (VAR_7 == VAR_0->mb_num)

        VAR_0->error_count = INT_MAX;

    else {

        VAR_0->error_status_table[VAR_9] &= VAR_10;

        VAR_0->error_status_table[VAR_9] |= VAR_5;

    }



    VAR_0->error_status_table[VAR_8] |= VP_START;



    if (VAR_8 > 0 && !(VAR_0->avctx->active_thread_type & FF_THREAD_SLICE) &&

        er_supported(VAR_0) && VAR_0->avctx->skip_top * VAR_0->mb_width < VAR_6) {

        int VAR_12 = VAR_0->error_status_table[VAR_0->mb_index2xy[VAR_6 - 1]];



        VAR_12 &= ~ VP_START;

        if (VAR_12 != (ER_MV_END | ER_DC_END | ER_AC_END)) {

            VAR_0->error_occurred = 1;

            VAR_0->error_count = INT_MAX;

        }

    }

}

void FUNC_0(ERContext *VAR_0, int VAR_1, int VAR_2,
int VAR_3, int VAR_4, int VAR_5)
{ const int VAR_6  = av_clip(VAR_1 + VAR_2 * VAR_0->mb_width, 0, VAR_0->mb_num - 1); const int VAR_7    = av_clip(VAR_3   + VAR_4   * VAR_0->mb_width, 0, VAR_0->mb_num); const int VAR_8 = VAR_0->mb_index2xy[VAR_6]; const int VAR_9   = VAR_0->mb_index2xy[VAR_7]; int VAR_10           = -1; if (VAR_0->avctx->hwaccel && VAR_0->avctx->hwaccel->decode_slice)
return; if (VAR_6 > VAR_7 || VAR_8 > VAR_9) { av_log(VAR_0->avctx, AV_LOG_ERROR,
"internal error, slice end before start\n"); return; } if (!VAR_0->avctx->error_concealment)
return; VAR_10 &= ~VP_START; if (VAR_5 & (ER_AC_ERROR | ER_AC_END)) { VAR_10           &= ~(ER_AC_ERROR | ER_AC_END); VAR_0->error_count -= VAR_7 - VAR_6 + 1; } if (VAR_5 & (ER_DC_ERROR | ER_DC_END)) { VAR_10           &= ~(ER_DC_ERROR | ER_DC_END); VAR_0->error_count -= VAR_7 - VAR_6 + 1; } if (VAR_5 & (ER_MV_ERROR | ER_MV_END)) { VAR_10           &= ~(ER_MV_ERROR | ER_MV_END); VAR_0->error_count -= VAR_7 - VAR_6 + 1; } if (VAR_5 & ER_MB_ERROR) { VAR_0->error_occurred = 1; VAR_0->error_count    = INT_MAX; } if (VAR_10 == ~0x7F) { memset(&VAR_0->error_status_table[VAR_8], 0,
(VAR_9 - VAR_8) * sizeof(uint8_t)); } else { int VAR_11; for (VAR_11 = VAR_8; VAR_11 < VAR_9; VAR_11++) VAR_0->error_status_table[VAR_11] &= VAR_10; } if (VAR_7 == VAR_0->mb_num)
VAR_0->error_count = INT_MAX; else { VAR_0->error_status_table[VAR_9] &= VAR_10; VAR_0->error_status_table[VAR_9] |= VAR_5; } VAR_0->error_status_table[VAR_8] |= VP_START; if (VAR_8 > 0 && !(VAR_0->avctx->active_thread_type & FF_THREAD_SLICE) &&
er_supported(VAR_0) && VAR_0->avctx->skip_top * VAR_0->mb_width < VAR_6) { int VAR_12 = VAR_0->error_status_table[VAR_0->mb_index2xy[VAR_6 - 1]]; VAR_12 &= ~ VP_START; if (VAR_12 != (ER_MV_END | ER_DC_END | ER_AC_END)) { VAR_0->error_occurred = 1; VAR_0->error_count = INT_MAX; } } }