static int loco_decode_plane(LOCOContext *l, uint8_t *data, int width, int height,

                             int stride, const uint8_t *buf, int buf_size, int step)

{

    RICEContext rc;

    int val;

    int i, j;



    if(buf_size<=0)

        return -1;



    init_get_bits8(&rc.gb, buf, buf_size);

    rc.save  = 0;

    rc.run   = 0;

    rc.run2  = 0;

    rc.lossy = l->lossy;



    rc.sum   = 8;

    rc.count = 1;



    /* restore top left pixel */

    val     = loco_get_rice(&rc);

    data[0] = 128 + val;

    /* restore top line */

    for (i = 1; i < width; i++) {

        val = loco_get_rice(&rc);

        data[i * step] = data[i * step - step] + val;

    }

    data += stride;

    for (j = 1; j < height; j++) {

        /* restore left column */

        val = loco_get_rice(&rc);

        data[0] = data[-stride] + val;

        /* restore all other pixels */

        for (i = 1; i < width; i++) {

            val = loco_get_rice(&rc);

            data[i * step] = loco_predict(&data[i * step], stride, step) + val;

        }

        data += stride;

    }



    return (get_bits_count(&rc.gb) + 7) >> 3;

}

static int loco_decode_plane(LOCOContext *l, uint8_t *data, int width, int height,

                             int stride, const uint8_t *buf, int buf_size, int step)

{

    RICEContext rc;

    int val;

    int i, j;



    if(buf_size<=0)

        return -1;



    init_get_bits8(&rc.gb, buf, buf_size);

    rc.save  = 0;

    rc.run   = 0;

    rc.run2  = 0;

    rc.lossy = l->lossy;



    rc.sum   = 8;

    rc.count = 1;



    

    val     = loco_get_rice(&rc);

    data[0] = 128 + val;

    

    for (i = 1; i < width; i++) {

        val = loco_get_rice(&rc);

        data[i * step] = data[i * step - step] + val;

    }

    data += stride;

    for (j = 1; j < height; j++) {

        

        val = loco_get_rice(&rc);

        data[0] = data[-stride] + val;

        

        for (i = 1; i < width; i++) {

            val = loco_get_rice(&rc);

            data[i * step] = loco_predict(&data[i * step], stride, step) + val;

        }

        data += stride;

    }



    return (get_bits_count(&rc.gb) + 7) >> 3;

}

static int FUNC_0(LOCOContext *VAR_0, uint8_t *VAR_1, int VAR_2, int VAR_3,

                             int VAR_4, const uint8_t *VAR_5, int VAR_6, int VAR_7)

{

    RICEContext rc;

    int VAR_8;

    int VAR_9, VAR_10;



    if(VAR_6<=0)

        return -1;



    init_get_bits8(&rc.gb, VAR_5, VAR_6);

    rc.save  = 0;

    rc.run   = 0;

    rc.run2  = 0;

    rc.lossy = VAR_0->lossy;



    rc.sum   = 8;

    rc.count = 1;



    

    VAR_8     = loco_get_rice(&rc);

    VAR_1[0] = 128 + VAR_8;

    

    for (VAR_9 = 1; VAR_9 < VAR_2; VAR_9++) {

        VAR_8 = loco_get_rice(&rc);

        VAR_1[VAR_9 * VAR_7] = VAR_1[VAR_9 * VAR_7 - VAR_7] + VAR_8;

    }

    VAR_1 += VAR_4;

    for (VAR_10 = 1; VAR_10 < VAR_3; VAR_10++) {

        

        VAR_8 = loco_get_rice(&rc);

        VAR_1[0] = VAR_1[-VAR_4] + VAR_8;

        

        for (VAR_9 = 1; VAR_9 < VAR_2; VAR_9++) {

            VAR_8 = loco_get_rice(&rc);

            VAR_1[VAR_9 * VAR_7] = loco_predict(&VAR_1[VAR_9 * VAR_7], VAR_4, VAR_7) + VAR_8;

        }

        VAR_1 += VAR_4;

    }



    return (get_bits_count(&rc.gb) + 7) >> 3;

}

static int FUNC_0(LOCOContext *VAR_0, uint8_t *VAR_1, int VAR_2, int VAR_3,
int VAR_4, const uint8_t *VAR_5, int VAR_6, int VAR_7)
{ RICEContext rc; int VAR_8; int VAR_9, VAR_10; if(VAR_6<=0)
return -1; init_get_bits8(&rc.gb, VAR_5, VAR_6); rc.save  = 0; rc.run   = 0; rc.run2  = 0; rc.lossy = VAR_0->lossy; rc.sum   = 8; rc.count = 1; VAR_8     = loco_get_rice(&rc); VAR_1[0] = 128 + VAR_8; for (VAR_9 = 1; VAR_9 < VAR_2; VAR_9++) { VAR_8 = loco_get_rice(&rc); VAR_1[VAR_9 * VAR_7] = VAR_1[VAR_9 * VAR_7 - VAR_7] + VAR_8; } VAR_1 += VAR_4; for (VAR_10 = 1; VAR_10 < VAR_3; VAR_10++) { VAR_8 = loco_get_rice(&rc); VAR_1[0] = VAR_1[-VAR_4] + VAR_8; for (VAR_9 = 1; VAR_9 < VAR_2; VAR_9++) { VAR_8 = loco_get_rice(&rc); VAR_1[VAR_9 * VAR_7] = loco_predict(&VAR_1[VAR_9 * VAR_7], VAR_4, VAR_7) + VAR_8; } VAR_1 += VAR_4; } return (get_bits_count(&rc.gb) + 7) >> 3; }