static void restore_median_il(uint8_t *src, int step, int stride,

                              int width, int height, int slices, int rmode)

{

    int i, j, slice;

    int A, B, C;

    uint8_t *bsrc;

    int slice_start, slice_height;

    const int cmask   = ~(rmode ? 3 : 1);

    const int stride2 = stride << 1;



    for (slice = 0; slice < slices; slice++) {

        slice_start    = ((slice * height) / slices) & cmask;

        slice_height   = ((((slice + 1) * height) / slices) & cmask) -

                         slice_start;

        slice_height >>= 1;





        bsrc = src + slice_start * stride;



        // first line - left neighbour prediction

        bsrc[0] += 0x80;

        A        = bsrc[0];

        for (i = step; i < width * step; i += step) {

            bsrc[i] += A;

            A        = bsrc[i];

        }

        for (i = 0; i < width * step; i += step) {

            bsrc[stride + i] += A;

            A                 = bsrc[stride + i];

        }

        bsrc += stride2;

        if (slice_height == 1)


        // second line - first element has top prediction, the rest uses median

        C        = bsrc[-stride2];

        bsrc[0] += C;

        A        = bsrc[0];

        for (i = step; i < width * step; i += step) {

            B        = bsrc[i - stride2];

            bsrc[i] += mid_pred(A, B, (uint8_t)(A + B - C));

            C        = B;

            A        = bsrc[i];

        }

        for (i = 0; i < width * step; i += step) {

            B                 = bsrc[i - stride];

            bsrc[stride + i] += mid_pred(A, B, (uint8_t)(A + B - C));

            C                 = B;

            A                 = bsrc[stride + i];

        }

        bsrc += stride2;

        // the rest of lines use continuous median prediction

        for (j = 2; j < slice_height; j++) {

            for (i = 0; i < width * step; i += step) {

                B        = bsrc[i - stride2];

                bsrc[i] += mid_pred(A, B, (uint8_t)(A + B - C));

                C        = B;

                A        = bsrc[i];

            }

            for (i = 0; i < width * step; i += step) {

                B                 = bsrc[i - stride];

                bsrc[i + stride] += mid_pred(A, B, (uint8_t)(A + B - C));

                C                 = B;

                A                 = bsrc[i + stride];

            }

            bsrc += stride2;

        }

    }

}
static void restore_median_il(uint8_t *src, int step, int stride,

                              int width, int height, int slices, int rmode)

{

    int i, j, slice;

    int A, B, C;

    uint8_t *bsrc;

    int slice_start, slice_height;

    const int cmask   = ~(rmode ? 3 : 1);

    const int stride2 = stride << 1;



    for (slice = 0; slice < slices; slice++) {

        slice_start    = ((slice * height) / slices) & cmask;

        slice_height   = ((((slice + 1) * height) / slices) & cmask) -

                         slice_start;

        slice_height >>= 1;





        bsrc = src + slice_start * stride;



        

        bsrc[0] += 0x80;

        A        = bsrc[0];

        for (i = step; i < width * step; i += step) {

            bsrc[i] += A;

            A        = bsrc[i];

        }

        for (i = 0; i < width * step; i += step) {

            bsrc[stride + i] += A;

            A                 = bsrc[stride + i];

        }

        bsrc += stride2;

        if (slice_height == 1)


        

        C        = bsrc[-stride2];

        bsrc[0] += C;

        A        = bsrc[0];

        for (i = step; i < width * step; i += step) {

            B        = bsrc[i - stride2];

            bsrc[i] += mid_pred(A, B, (uint8_t)(A + B - C));

            C        = B;

            A        = bsrc[i];

        }

        for (i = 0; i < width * step; i += step) {

            B                 = bsrc[i - stride];

            bsrc[stride + i] += mid_pred(A, B, (uint8_t)(A + B - C));

            C                 = B;

            A                 = bsrc[stride + i];

        }

        bsrc += stride2;

        

        for (j = 2; j < slice_height; j++) {

            for (i = 0; i < width * step; i += step) {

                B        = bsrc[i - stride2];

                bsrc[i] += mid_pred(A, B, (uint8_t)(A + B - C));

                C        = B;

                A        = bsrc[i];

            }

            for (i = 0; i < width * step; i += step) {

                B                 = bsrc[i - stride];

                bsrc[i + stride] += mid_pred(A, B, (uint8_t)(A + B - C));

                C                 = B;

                A                 = bsrc[i + stride];

            }

            bsrc += stride2;

        }

    }

}
static void FUNC_0(uint8_t *VAR_0, int VAR_1, int VAR_2,

                              int VAR_3, int VAR_4, int VAR_5, int VAR_6)

{

    int VAR_7, VAR_8, VAR_9;

    int VAR_10, VAR_11, VAR_12;

    uint8_t *bsrc;

    int VAR_13, VAR_14;

    const int VAR_15   = ~(VAR_6 ? 3 : 1);

    const int VAR_16 = VAR_2 << 1;



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

        VAR_13    = ((VAR_9 * VAR_4) / VAR_5) & VAR_15;

        VAR_14   = ((((VAR_9 + 1) * VAR_4) / VAR_5) & VAR_15) -

                         VAR_13;

        VAR_14 >>= 1;





        bsrc = VAR_0 + VAR_13 * VAR_2;



        

        bsrc[0] += 0x80;

        VAR_10        = bsrc[0];

        for (VAR_7 = VAR_1; VAR_7 < VAR_3 * VAR_1; VAR_7 += VAR_1) {

            bsrc[VAR_7] += VAR_10;

            VAR_10        = bsrc[VAR_7];

        }

        for (VAR_7 = 0; VAR_7 < VAR_3 * VAR_1; VAR_7 += VAR_1) {

            bsrc[VAR_2 + VAR_7] += VAR_10;

            VAR_10                 = bsrc[VAR_2 + VAR_7];

        }

        bsrc += VAR_16;

        if (VAR_14 == 1)


        

        VAR_12        = bsrc[-VAR_16];

        bsrc[0] += VAR_12;

        VAR_10        = bsrc[0];

        for (VAR_7 = VAR_1; VAR_7 < VAR_3 * VAR_1; VAR_7 += VAR_1) {

            VAR_11        = bsrc[VAR_7 - VAR_16];

            bsrc[VAR_7] += mid_pred(VAR_10, VAR_11, (uint8_t)(VAR_10 + VAR_11 - VAR_12));

            VAR_12        = VAR_11;

            VAR_10        = bsrc[VAR_7];

        }

        for (VAR_7 = 0; VAR_7 < VAR_3 * VAR_1; VAR_7 += VAR_1) {

            VAR_11                 = bsrc[VAR_7 - VAR_2];

            bsrc[VAR_2 + VAR_7] += mid_pred(VAR_10, VAR_11, (uint8_t)(VAR_10 + VAR_11 - VAR_12));

            VAR_12                 = VAR_11;

            VAR_10                 = bsrc[VAR_2 + VAR_7];

        }

        bsrc += VAR_16;

        

        for (VAR_8 = 2; VAR_8 < VAR_14; VAR_8++) {

            for (VAR_7 = 0; VAR_7 < VAR_3 * VAR_1; VAR_7 += VAR_1) {

                VAR_11        = bsrc[VAR_7 - VAR_16];

                bsrc[VAR_7] += mid_pred(VAR_10, VAR_11, (uint8_t)(VAR_10 + VAR_11 - VAR_12));

                VAR_12        = VAR_11;

                VAR_10        = bsrc[VAR_7];

            }

            for (VAR_7 = 0; VAR_7 < VAR_3 * VAR_1; VAR_7 += VAR_1) {

                VAR_11                 = bsrc[VAR_7 - VAR_2];

                bsrc[VAR_7 + VAR_2] += mid_pred(VAR_10, VAR_11, (uint8_t)(VAR_10 + VAR_11 - VAR_12));

                VAR_12                 = VAR_11;

                VAR_10                 = bsrc[VAR_7 + VAR_2];

            }

            bsrc += VAR_16;

        }

    }

}
static void FUNC_0(uint8_t *VAR_0, int VAR_1, int VAR_2,
int VAR_3, int VAR_4, int VAR_5, int VAR_6)
{ int VAR_7, VAR_8, VAR_9; int VAR_10, VAR_11, VAR_12; uint8_t *bsrc; int VAR_13, VAR_14; const int VAR_15   = ~(VAR_6 ? 3 : 1); const int VAR_16 = VAR_2 << 1; for (VAR_9 = 0; VAR_9 < VAR_5; VAR_9++) { VAR_13    = ((VAR_9 * VAR_4) / VAR_5) & VAR_15; VAR_14   = ((((VAR_9 + 1) * VAR_4) / VAR_5) & VAR_15) -
VAR_13; VAR_14 >>= 1; bsrc = VAR_0 + VAR_13 * VAR_2; bsrc[0] += 0x80; VAR_10        = bsrc[0]; for (VAR_7 = VAR_1; VAR_7 < VAR_3 * VAR_1; VAR_7 += VAR_1) { bsrc[VAR_7] += VAR_10; VAR_10        = bsrc[VAR_7]; } for (VAR_7 = 0; VAR_7 < VAR_3 * VAR_1; VAR_7 += VAR_1) { bsrc[VAR_2 + VAR_7] += VAR_10; VAR_10                 = bsrc[VAR_2 + VAR_7]; } bsrc += VAR_16; if (VAR_14 == 1)
VAR_12        = bsrc[-VAR_16]; bsrc[0] += VAR_12; VAR_10        = bsrc[0]; for (VAR_7 = VAR_1; VAR_7 < VAR_3 * VAR_1; VAR_7 += VAR_1) { VAR_11        = bsrc[VAR_7 - VAR_16]; bsrc[VAR_7] += mid_pred(VAR_10, VAR_11, (uint8_t)(VAR_10 + VAR_11 - VAR_12)); VAR_12        = VAR_11; VAR_10        = bsrc[VAR_7]; } for (VAR_7 = 0; VAR_7 < VAR_3 * VAR_1; VAR_7 += VAR_1) { VAR_11                 = bsrc[VAR_7 - VAR_2]; bsrc[VAR_2 + VAR_7] += mid_pred(VAR_10, VAR_11, (uint8_t)(VAR_10 + VAR_11 - VAR_12)); VAR_12                 = VAR_11; VAR_10                 = bsrc[VAR_2 + VAR_7]; } bsrc += VAR_16; for (VAR_8 = 2; VAR_8 < VAR_14; VAR_8++) { for (VAR_7 = 0; VAR_7 < VAR_3 * VAR_1; VAR_7 += VAR_1) { VAR_11        = bsrc[VAR_7 - VAR_16]; bsrc[VAR_7] += mid_pred(VAR_10, VAR_11, (uint8_t)(VAR_10 + VAR_11 - VAR_12)); VAR_12        = VAR_11; VAR_10        = bsrc[VAR_7]; } for (VAR_7 = 0; VAR_7 < VAR_3 * VAR_1; VAR_7 += VAR_1) { VAR_11                 = bsrc[VAR_7 - VAR_2]; bsrc[VAR_7 + VAR_2] += mid_pred(VAR_10, VAR_11, (uint8_t)(VAR_10 + VAR_11 - VAR_12)); VAR_12                 = VAR_11; VAR_10                 = bsrc[VAR_7 + VAR_2]; } bsrc += VAR_16; } } }