static void correlate_slice_buffered(SnowContext *s, slice_buffer * sb, SubBand *b, DWTELEM *src, int stride, int inverse, int use_median, int start_y, int end_y){

    const int w= b->width;

    int x,y;



//    START_TIMER



    DWTELEM * line;

    DWTELEM * prev;



    if (start_y != 0)

        line = slice_buffer_get_line(sb, ((start_y - 1) * b->stride_line) + b->buf_y_offset) + b->buf_x_offset;



    for(y=start_y; y<end_y; y++){

        prev = line;

//        line = slice_buffer_get_line_from_address(sb, src + (y * stride));

        line = slice_buffer_get_line(sb, (y * b->stride_line) + b->buf_y_offset) + b->buf_x_offset;

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

            if(x){

                if(use_median){

                    if(y && x+1<w) line[x] += mid_pred(line[x - 1], prev[x], prev[x + 1]);

                    else  line[x] += line[x - 1];

                }else{

                    if(y) line[x] += mid_pred(line[x - 1], prev[x], line[x - 1] + prev[x] - prev[x - 1]);

                    else  line[x] += line[x - 1];

                }

            }else{

                if(y) line[x] += prev[x];

            }

        }

    }



//    STOP_TIMER("correlate")

}

static void correlate_slice_buffered(SnowContext *s, slice_buffer * sb, SubBand *b, DWTELEM *src, int stride, int inverse, int use_median, int start_y, int end_y){

    const int w= b->width;

    int x,y;







    DWTELEM * line;

    DWTELEM * prev;



    if (start_y != 0)

        line = slice_buffer_get_line(sb, ((start_y - 1) * b->stride_line) + b->buf_y_offset) + b->buf_x_offset;



    for(y=start_y; y<end_y; y++){

        prev = line;



        line = slice_buffer_get_line(sb, (y * b->stride_line) + b->buf_y_offset) + b->buf_x_offset;

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

            if(x){

                if(use_median){

                    if(y && x+1<w) line[x] += mid_pred(line[x - 1], prev[x], prev[x + 1]);

                    else  line[x] += line[x - 1];

                }else{

                    if(y) line[x] += mid_pred(line[x - 1], prev[x], line[x - 1] + prev[x] - prev[x - 1]);

                    else  line[x] += line[x - 1];

                }

            }else{

                if(y) line[x] += prev[x];

            }

        }

    }





}

static void FUNC_0(SnowContext *VAR_0, slice_buffer * VAR_1, SubBand *VAR_2, DWTELEM *VAR_3, int VAR_4, int VAR_5, int VAR_6, int VAR_7, int VAR_8){

    const int VAR_9= VAR_2->width;

    int VAR_10,VAR_11;







    DWTELEM * line;

    DWTELEM * prev;



    if (VAR_7 != 0)

        line = slice_buffer_get_line(VAR_1, ((VAR_7 - 1) * VAR_2->stride_line) + VAR_2->buf_y_offset) + VAR_2->buf_x_offset;



    for(VAR_11=VAR_7; VAR_11<VAR_8; VAR_11++){

        prev = line;



        line = slice_buffer_get_line(VAR_1, (VAR_11 * VAR_2->stride_line) + VAR_2->buf_y_offset) + VAR_2->buf_x_offset;

        for(VAR_10=0; VAR_10<VAR_9; VAR_10++){

            if(VAR_10){

                if(VAR_6){

                    if(VAR_11 && VAR_10+1<VAR_9) line[VAR_10] += mid_pred(line[VAR_10 - 1], prev[VAR_10], prev[VAR_10 + 1]);

                    else  line[VAR_10] += line[VAR_10 - 1];

                }else{

                    if(VAR_11) line[VAR_10] += mid_pred(line[VAR_10 - 1], prev[VAR_10], line[VAR_10 - 1] + prev[VAR_10] - prev[VAR_10 - 1]);

                    else  line[VAR_10] += line[VAR_10 - 1];

                }

            }else{

                if(VAR_11) line[VAR_10] += prev[VAR_10];

            }

        }

    }





}

static void FUNC_0(SnowContext *VAR_0, slice_buffer * VAR_1, SubBand *VAR_2, DWTELEM *VAR_3, int VAR_4, int VAR_5, int VAR_6, int VAR_7, int VAR_8){ const int VAR_9= VAR_2->width; int VAR_10,VAR_11; DWTELEM * line; DWTELEM * prev; if (VAR_7 != 0)
line = slice_buffer_get_line(VAR_1, ((VAR_7 - 1) * VAR_2->stride_line) + VAR_2->buf_y_offset) + VAR_2->buf_x_offset; for(VAR_11=VAR_7; VAR_11<VAR_8; VAR_11++){ prev = line; line = slice_buffer_get_line(VAR_1, (VAR_11 * VAR_2->stride_line) + VAR_2->buf_y_offset) + VAR_2->buf_x_offset; for(VAR_10=0; VAR_10<VAR_9; VAR_10++){ if(VAR_10){ if(VAR_6){ if(VAR_11 && VAR_10+1<VAR_9) line[VAR_10] += mid_pred(line[VAR_10 - 1], prev[VAR_10], prev[VAR_10 + 1]); else  line[VAR_10] += line[VAR_10 - 1]; }else{ if(VAR_11) line[VAR_10] += mid_pred(line[VAR_10 - 1], prev[VAR_10], line[VAR_10 - 1] + prev[VAR_10] - prev[VAR_10 - 1]); else  line[VAR_10] += line[VAR_10 - 1]; } }else{ if(VAR_11) line[VAR_10] += prev[VAR_10]; } } } }