static int lag_decode_arith_plane(LagarithContext *l, uint8_t *dst,

                                  int width, int height, int stride,

                                  const uint8_t *src, int src_size)

{

    int i = 0;

    int read = 0;

    uint32_t length;

    uint32_t offset = 1;

    int esc_count = src[0];

    GetBitContext gb;

    lag_rac rac;



    rac.avctx = l->avctx;

    l->zeros = 0;



    if (esc_count < 4) {

        length = width * height;

        if (esc_count && AV_RL32(src + 1) < length) {

            length = AV_RL32(src + 1);

            offset += 4;

        }



        init_get_bits(&gb, src + offset, src_size * 8);



        if (lag_read_prob_header(&rac, &gb) < 0)

            return -1;



        ff_lag_rac_init(&rac, &gb, length - stride);



        for (i = 0; i < height; i++)

            read += lag_decode_line(l, &rac, dst + (i * stride), width,

                                    stride, esc_count);



        if (read > length)

            av_log(l->avctx, AV_LOG_WARNING,

                   "Output more bytes than length (%d of %d)\n", read,

                   length);

    } else if (esc_count < 8) {

        esc_count -= 4;

        if (esc_count > 0) {

            /* Zero run coding only, no range coding. */

            for (i = 0; i < height; i++)

                src += lag_decode_zero_run_line(l, dst + (i * stride), src,

                                                width, esc_count);

        } else {

            /* Plane is stored uncompressed */

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

                memcpy(dst + (i * stride), src, width);

                src += width;

            }

        }

    } else if (esc_count == 0xff) {

        /* Plane is a solid run of given value */

        for (i = 0; i < height; i++)

            memset(dst + i * stride, src[1], width);

        /* Do not apply prediction.

           Note: memset to 0 above, setting first value to src[1]

           and applying prediction gives the same result. */

        return 0;

    } else {

        av_log(l->avctx, AV_LOG_ERROR,

               "Invalid zero run escape code! (%#x)\n", esc_count);

        return -1;

    }



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

        lag_pred_line(l, dst, width, stride, i);

        dst += stride;

    }



    return 0;

}

static int lag_decode_arith_plane(LagarithContext *l, uint8_t *dst,

                                  int width, int height, int stride,

                                  const uint8_t *src, int src_size)

{

    int i = 0;

    int read = 0;

    uint32_t length;

    uint32_t offset = 1;

    int esc_count = src[0];

    GetBitContext gb;

    lag_rac rac;



    rac.avctx = l->avctx;

    l->zeros = 0;



    if (esc_count < 4) {

        length = width * height;

        if (esc_count && AV_RL32(src + 1) < length) {

            length = AV_RL32(src + 1);

            offset += 4;

        }



        init_get_bits(&gb, src + offset, src_size * 8);



        if (lag_read_prob_header(&rac, &gb) < 0)

            return -1;



        ff_lag_rac_init(&rac, &gb, length - stride);



        for (i = 0; i < height; i++)

            read += lag_decode_line(l, &rac, dst + (i * stride), width,

                                    stride, esc_count);



        if (read > length)

            av_log(l->avctx, AV_LOG_WARNING,

                   "Output more bytes than length (%d of %d)\n", read,

                   length);

    } else if (esc_count < 8) {

        esc_count -= 4;

        if (esc_count > 0) {

            

            for (i = 0; i < height; i++)

                src += lag_decode_zero_run_line(l, dst + (i * stride), src,

                                                width, esc_count);

        } else {

            

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

                memcpy(dst + (i * stride), src, width);

                src += width;

            }

        }

    } else if (esc_count == 0xff) {

        

        for (i = 0; i < height; i++)

            memset(dst + i * stride, src[1], width);

        





        return 0;

    } else {

        av_log(l->avctx, AV_LOG_ERROR,

               "Invalid zero run escape code! (%#x)\n", esc_count);

        return -1;

    }



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

        lag_pred_line(l, dst, width, stride, i);

        dst += stride;

    }



    return 0;

}

            for (i = 0; i < height; i++)                 src += lag_decode_zero_run_line(l, dst + (i * stride), src,                                                 width, esc_count);
static int FUNC_0(LagarithContext *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 = 0;

    int VAR_8 = 0;

    uint32_t length;

    uint32_t offset = 1;

    int VAR_9 = VAR_5[0];

    GetBitContext gb;

    lag_rac rac;



    rac.avctx = VAR_0->avctx;

    VAR_0->zeros = 0;



    if (VAR_9 < 4) {

        length = VAR_2 * VAR_3;

        if (VAR_9 && AV_RL32(VAR_5 + 1) < length) {

            length = AV_RL32(VAR_5 + 1);

            offset += 4;

        }



        init_get_bits(&gb, VAR_5 + offset, VAR_6 * 8);



        if (lag_read_prob_header(&rac, &gb) < 0)

            return -1;



        ff_lag_rac_init(&rac, &gb, length - VAR_4);



        for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++)

            VAR_8 += lag_decode_line(VAR_0, &rac, VAR_1 + (VAR_7 * VAR_4), VAR_2,

                                    VAR_4, VAR_9);



        if (VAR_8 > length)

            av_log(VAR_0->avctx, AV_LOG_WARNING,

                   "Output more bytes than length (%d of %d)\n", VAR_8,

                   length);

    } else if (VAR_9 < 8) {

        VAR_9 -= 4;

        if (VAR_9 > 0) {

            

            for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++)

                VAR_5 += lag_decode_zero_run_line(VAR_0, VAR_1 + (VAR_7 * VAR_4), VAR_5,

                                                VAR_2, VAR_9);

        } else {

            

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

                memcpy(VAR_1 + (VAR_7 * VAR_4), VAR_5, VAR_2);

                VAR_5 += VAR_2;

            }

        }

    } else if (VAR_9 == 0xff) {

        

        for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++)

            memset(VAR_1 + VAR_7 * VAR_4, VAR_5[1], VAR_2);

        





        return 0;

    } else {

        av_log(VAR_0->avctx, AV_LOG_ERROR,

               "Invalid zero run escape code! (%#x)\n", VAR_9);

        return -1;

    }



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

        lag_pred_line(VAR_0, VAR_1, VAR_2, VAR_4, VAR_7);

        VAR_1 += VAR_4;

    }



    return 0;

}

static int FUNC_0(LagarithContext *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 = 0; int VAR_8 = 0; uint32_t length; uint32_t offset = 1; int VAR_9 = VAR_5[0]; GetBitContext gb; lag_rac rac; rac.avctx = VAR_0->avctx; VAR_0->zeros = 0; if (VAR_9 < 4) { length = VAR_2 * VAR_3; if (VAR_9 && AV_RL32(VAR_5 + 1) < length) { length = AV_RL32(VAR_5 + 1); offset += 4; } init_get_bits(&gb, VAR_5 + offset, VAR_6 * 8); if (lag_read_prob_header(&rac, &gb) < 0)
return -1; ff_lag_rac_init(&rac, &gb, length - VAR_4); for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) VAR_8 += lag_decode_line(VAR_0, &rac, VAR_1 + (VAR_7 * VAR_4), VAR_2,
VAR_4, VAR_9); if (VAR_8 > length)
av_log(VAR_0->avctx, AV_LOG_WARNING,
"Output more bytes than length (%d of %d)\n", VAR_8,
length); } else if (VAR_9 < 8) { VAR_9 -= 4; if (VAR_9 > 0) { for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) VAR_5 += lag_decode_zero_run_line(VAR_0, VAR_1 + (VAR_7 * VAR_4), VAR_5,
VAR_2, VAR_9); } else { for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) { memcpy(VAR_1 + (VAR_7 * VAR_4), VAR_5, VAR_2); VAR_5 += VAR_2; } } } else if (VAR_9 == 0xff) { for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) memset(VAR_1 + VAR_7 * VAR_4, VAR_5[1], VAR_2); return 0; } else { av_log(VAR_0->avctx, AV_LOG_ERROR,
"Invalid zero run escape code! (%#x)\n", VAR_9); return -1; } for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) { lag_pred_line(VAR_0, VAR_1, VAR_2, VAR_4, VAR_7); VAR_1 += VAR_4; } return 0; }