static void apply_loop_filter(Vp3DecodeContext *s)

{

    int x, y, plane;

    int width, height;

    int fragment;

    int stride;

    unsigned char *plane_data;



    int bounding_values_array[256];

    int *bounding_values= bounding_values_array+127;

    int filter_limit;



    /* find the right loop limit value */

    for (x = 63; x >= 0; x--) {

        if (vp31_ac_scale_factor[x] >= s->quality_index)

            break;

    }

    filter_limit = vp31_filter_limit_values[s->quality_index];



    /* set up the bounding values */

    memset(bounding_values_array, 0, 256 * sizeof(int));

    for (x = 0; x < filter_limit; x++) {

        bounding_values[-x - filter_limit] = -filter_limit + x;

        bounding_values[-x] = -x;

        bounding_values[x] = x;

        bounding_values[x + filter_limit] = filter_limit - x;

    }



    for (plane = 0; plane < 3; plane++) {



        if (plane == 0) {

            /* Y plane parameters */

            fragment = 0;

            width = s->fragment_width;

            height = s->fragment_height;

            stride = s->current_frame.linesize[0];

            plane_data = s->current_frame.data[0];

        } else if (plane == 1) {

            /* U plane parameters */

            fragment = s->u_fragment_start;

            width = s->fragment_width / 2;

            height = s->fragment_height / 2;

            stride = s->current_frame.linesize[1];

            plane_data = s->current_frame.data[1];

        } else {

            /* V plane parameters */

            fragment = s->v_fragment_start;

            width = s->fragment_width / 2;

            height = s->fragment_height / 2;

            stride = s->current_frame.linesize[2];

            plane_data = s->current_frame.data[2];

        }



        for (y = 0; y < height; y++) {



            for (x = 0; x < width; x++) {

START_TIMER

                /* do not perform left edge filter for left columns frags */

                if ((x > 0) &&

                    (s->all_fragments[fragment].coding_method != MODE_COPY)) {

                    horizontal_filter(

                        plane_data + s->all_fragments[fragment].first_pixel - 7*stride, 

                        stride, bounding_values);

                }



                /* do not perform top edge filter for top row fragments */

                if ((y > 0) &&

                    (s->all_fragments[fragment].coding_method != MODE_COPY)) {

                    vertical_filter(

                        plane_data + s->all_fragments[fragment].first_pixel + stride, 

                        stride, bounding_values);

                }



                /* do not perform right edge filter for right column

                 * fragments or if right fragment neighbor is also coded

                 * in this frame (it will be filtered in next iteration) */

                if ((x < width - 1) &&

                    (s->all_fragments[fragment].coding_method != MODE_COPY) &&

                    (s->all_fragments[fragment + 1].coding_method == MODE_COPY)) {

                    horizontal_filter(

                        plane_data + s->all_fragments[fragment + 1].first_pixel - 7*stride, 

                        stride, bounding_values);

                }



                /* do not perform bottom edge filter for bottom row

                 * fragments or if bottom fragment neighbor is also coded

                 * in this frame (it will be filtered in the next row) */

                if ((y < height - 1) &&

                    (s->all_fragments[fragment].coding_method != MODE_COPY) &&

                    (s->all_fragments[fragment + width].coding_method == MODE_COPY)) {

                    vertical_filter(

                        plane_data + s->all_fragments[fragment + width].first_pixel + stride, 

                        stride, bounding_values);

                }



                fragment++;

STOP_TIMER("loop filter")

            }

        }

    }

}

static void apply_loop_filter(Vp3DecodeContext *s)

{

    int x, y, plane;

    int width, height;

    int fragment;

    int stride;

    unsigned char *plane_data;



    int bounding_values_array[256];

    int *bounding_values= bounding_values_array+127;

    int filter_limit;



    

    for (x = 63; x >= 0; x--) {

        if (vp31_ac_scale_factor[x] >= s->quality_index)

            break;

    }

    filter_limit = vp31_filter_limit_values[s->quality_index];



    

    memset(bounding_values_array, 0, 256 * sizeof(int));

    for (x = 0; x < filter_limit; x++) {

        bounding_values[-x - filter_limit] = -filter_limit + x;

        bounding_values[-x] = -x;

        bounding_values[x] = x;

        bounding_values[x + filter_limit] = filter_limit - x;

    }



    for (plane = 0; plane < 3; plane++) {



        if (plane == 0) {

            

            fragment = 0;

            width = s->fragment_width;

            height = s->fragment_height;

            stride = s->current_frame.linesize[0];

            plane_data = s->current_frame.data[0];

        } else if (plane == 1) {

            

            fragment = s->u_fragment_start;

            width = s->fragment_width / 2;

            height = s->fragment_height / 2;

            stride = s->current_frame.linesize[1];

            plane_data = s->current_frame.data[1];

        } else {

            

            fragment = s->v_fragment_start;

            width = s->fragment_width / 2;

            height = s->fragment_height / 2;

            stride = s->current_frame.linesize[2];

            plane_data = s->current_frame.data[2];

        }



        for (y = 0; y < height; y++) {



            for (x = 0; x < width; x++) {

START_TIMER

                

                if ((x > 0) &&

                    (s->all_fragments[fragment].coding_method != MODE_COPY)) {

                    horizontal_filter(

                        plane_data + s->all_fragments[fragment].first_pixel - 7*stride, 

                        stride, bounding_values);

                }



                

                if ((y > 0) &&

                    (s->all_fragments[fragment].coding_method != MODE_COPY)) {

                    vertical_filter(

                        plane_data + s->all_fragments[fragment].first_pixel + stride, 

                        stride, bounding_values);

                }



                





                if ((x < width - 1) &&

                    (s->all_fragments[fragment].coding_method != MODE_COPY) &&

                    (s->all_fragments[fragment + 1].coding_method == MODE_COPY)) {

                    horizontal_filter(

                        plane_data + s->all_fragments[fragment + 1].first_pixel - 7*stride, 

                        stride, bounding_values);

                }



                





                if ((y < height - 1) &&

                    (s->all_fragments[fragment].coding_method != MODE_COPY) &&

                    (s->all_fragments[fragment + width].coding_method == MODE_COPY)) {

                    vertical_filter(

                        plane_data + s->all_fragments[fragment + width].first_pixel + stride, 

                        stride, bounding_values);

                }



                fragment++;

STOP_TIMER("loop filter")

            }

        }

    }

}

static void FUNC_0(Vp3DecodeContext *VAR_0)

{

    int VAR_1, VAR_2, VAR_3;

    int VAR_4, VAR_5;

    int VAR_6;

    int VAR_7;

    unsigned char *VAR_8;



    int VAR_9[256];

    int *VAR_10= VAR_9+127;

    int VAR_11;



    

    for (VAR_1 = 63; VAR_1 >= 0; VAR_1--) {

        if (vp31_ac_scale_factor[VAR_1] >= VAR_0->quality_index)

            break;

    }

    VAR_11 = vp31_filter_limit_values[VAR_0->quality_index];



    

    memset(VAR_9, 0, 256 * sizeof(int));

    for (VAR_1 = 0; VAR_1 < VAR_11; VAR_1++) {

        VAR_10[-VAR_1 - VAR_11] = -VAR_11 + VAR_1;

        VAR_10[-VAR_1] = -VAR_1;

        VAR_10[VAR_1] = VAR_1;

        VAR_10[VAR_1 + VAR_11] = VAR_11 - VAR_1;

    }



    for (VAR_3 = 0; VAR_3 < 3; VAR_3++) {



        if (VAR_3 == 0) {

            

            VAR_6 = 0;

            VAR_4 = VAR_0->fragment_width;

            VAR_5 = VAR_0->fragment_height;

            VAR_7 = VAR_0->current_frame.linesize[0];

            VAR_8 = VAR_0->current_frame.data[0];

        } else if (VAR_3 == 1) {

            

            VAR_6 = VAR_0->u_fragment_start;

            VAR_4 = VAR_0->fragment_width / 2;

            VAR_5 = VAR_0->fragment_height / 2;

            VAR_7 = VAR_0->current_frame.linesize[1];

            VAR_8 = VAR_0->current_frame.data[1];

        } else {

            

            VAR_6 = VAR_0->v_fragment_start;

            VAR_4 = VAR_0->fragment_width / 2;

            VAR_5 = VAR_0->fragment_height / 2;

            VAR_7 = VAR_0->current_frame.linesize[2];

            VAR_8 = VAR_0->current_frame.data[2];

        }



        for (VAR_2 = 0; VAR_2 < VAR_5; VAR_2++) {



            for (VAR_1 = 0; VAR_1 < VAR_4; VAR_1++) {

START_TIMER

                

                if ((VAR_1 > 0) &&

                    (VAR_0->all_fragments[VAR_6].coding_method != MODE_COPY)) {

                    horizontal_filter(

                        VAR_8 + VAR_0->all_fragments[VAR_6].first_pixel - 7*VAR_7, 

                        VAR_7, VAR_10);

                }



                

                if ((VAR_2 > 0) &&

                    (VAR_0->all_fragments[VAR_6].coding_method != MODE_COPY)) {

                    vertical_filter(

                        VAR_8 + VAR_0->all_fragments[VAR_6].first_pixel + VAR_7, 

                        VAR_7, VAR_10);

                }



                





                if ((VAR_1 < VAR_4 - 1) &&

                    (VAR_0->all_fragments[VAR_6].coding_method != MODE_COPY) &&

                    (VAR_0->all_fragments[VAR_6 + 1].coding_method == MODE_COPY)) {

                    horizontal_filter(

                        VAR_8 + VAR_0->all_fragments[VAR_6 + 1].first_pixel - 7*VAR_7, 

                        VAR_7, VAR_10);

                }



                





                if ((VAR_2 < VAR_5 - 1) &&

                    (VAR_0->all_fragments[VAR_6].coding_method != MODE_COPY) &&

                    (VAR_0->all_fragments[VAR_6 + VAR_4].coding_method == MODE_COPY)) {

                    vertical_filter(

                        VAR_8 + VAR_0->all_fragments[VAR_6 + VAR_4].first_pixel + VAR_7, 

                        VAR_7, VAR_10);

                }



                VAR_6++;

STOP_TIMER("loop filter")

            }

        }

    }

}

static void FUNC_0(Vp3DecodeContext *VAR_0)
{ int VAR_1, VAR_2, VAR_3; int VAR_4, VAR_5; int VAR_6; int VAR_7; unsigned char *VAR_8; int VAR_9[256]; int *VAR_10= VAR_9+127; int VAR_11; for (VAR_1 = 63; VAR_1 >= 0; VAR_1--) { if (vp31_ac_scale_factor[VAR_1] >= VAR_0->quality_index)
break; } VAR_11 = vp31_filter_limit_values[VAR_0->quality_index]; memset(VAR_9, 0, 256 * sizeof(int)); for (VAR_1 = 0; VAR_1 < VAR_11; VAR_1++) { VAR_10[-VAR_1 - VAR_11] = -VAR_11 + VAR_1; VAR_10[-VAR_1] = -VAR_1; VAR_10[VAR_1] = VAR_1; VAR_10[VAR_1 + VAR_11] = VAR_11 - VAR_1; } for (VAR_3 = 0; VAR_3 < 3; VAR_3++) { if (VAR_3 == 0) { VAR_6 = 0; VAR_4 = VAR_0->fragment_width; VAR_5 = VAR_0->fragment_height; VAR_7 = VAR_0->current_frame.linesize[0]; VAR_8 = VAR_0->current_frame.data[0]; } else if (VAR_3 == 1) { VAR_6 = VAR_0->u_fragment_start; VAR_4 = VAR_0->fragment_width / 2; VAR_5 = VAR_0->fragment_height / 2; VAR_7 = VAR_0->current_frame.linesize[1]; VAR_8 = VAR_0->current_frame.data[1]; } else { VAR_6 = VAR_0->v_fragment_start; VAR_4 = VAR_0->fragment_width / 2; VAR_5 = VAR_0->fragment_height / 2; VAR_7 = VAR_0->current_frame.linesize[2]; VAR_8 = VAR_0->current_frame.data[2]; } for (VAR_2 = 0; VAR_2 < VAR_5; VAR_2++) { for (VAR_1 = 0; VAR_1 < VAR_4; VAR_1++) { START_TIMER
if ((VAR_1 > 0) &&
(VAR_0->all_fragments[VAR_6].coding_method != MODE_COPY)) { horizontal_filter(
VAR_8 + VAR_0->all_fragments[VAR_6].first_pixel - 7*VAR_7,
VAR_7, VAR_10); } if ((VAR_2 > 0) &&
(VAR_0->all_fragments[VAR_6].coding_method != MODE_COPY)) { vertical_filter(
VAR_8 + VAR_0->all_fragments[VAR_6].first_pixel + VAR_7,
VAR_7, VAR_10); } if ((VAR_1 < VAR_4 - 1) &&
(VAR_0->all_fragments[VAR_6].coding_method != MODE_COPY) &&
(VAR_0->all_fragments[VAR_6 + 1].coding_method == MODE_COPY)) { horizontal_filter(
VAR_8 + VAR_0->all_fragments[VAR_6 + 1].first_pixel - 7*VAR_7,
VAR_7, VAR_10); } if ((VAR_2 < VAR_5 - 1) &&
(VAR_0->all_fragments[VAR_6].coding_method != MODE_COPY) &&
(VAR_0->all_fragments[VAR_6 + VAR_4].coding_method == MODE_COPY)) { vertical_filter(
VAR_8 + VAR_0->all_fragments[VAR_6 + VAR_4].first_pixel + VAR_7,
VAR_7, VAR_10); } VAR_6++; STOP_TIMER("loop filter")
} } } }