static int decode_cblk(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty,

                       Jpeg2000T1Context *t1, Jpeg2000Cblk *cblk,

                       int width, int height, int bandpos)

{

    int passno = cblk->npasses, pass_t = 2, bpno = cblk->nonzerobits - 1, y, clnpass_cnt = 0;

    int bpass_csty_symbol = JPEG2000_CBLK_BYPASS & codsty->cblk_style;

    int vert_causal_ctx_csty_symbol = JPEG2000_CBLK_VSC & codsty->cblk_style;



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

        memset(t1->data[y], 0, width * sizeof(**t1->data));



    /* If code-block contains no compressed data: nothing to do. */

    if (!cblk->length)

        return 0;



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

        memset(t1->flags[y], 0, (width + 2)*sizeof(**t1->flags));



    cblk->data[cblk->length] = 0xff;

    cblk->data[cblk->length+1] = 0xff;

    ff_mqc_initdec(&t1->mqc, cblk->data);



    while (passno--) {

        if (bpno < 0) {

            av_log(s->avctx, AV_LOG_ERROR, "bpno invalid\n");

            return AVERROR(EINVAL);

        }

        switch(pass_t) {

        case 0:

            decode_sigpass(t1, width, height, bpno + 1, bandpos,

                           bpass_csty_symbol && (clnpass_cnt >= 4), vert_causal_ctx_csty_symbol);

            break;

        case 1:

            decode_refpass(t1, width, height, bpno + 1);

            if (bpass_csty_symbol && clnpass_cnt >= 4)

                ff_mqc_initdec(&t1->mqc, cblk->data);

            break;

        case 2:

            decode_clnpass(s, t1, width, height, bpno + 1, bandpos,

                           codsty->cblk_style & JPEG2000_CBLK_SEGSYM, vert_causal_ctx_csty_symbol);

            clnpass_cnt = clnpass_cnt + 1;

            if (bpass_csty_symbol && clnpass_cnt >= 4)

                ff_mqc_initdec(&t1->mqc, cblk->data);

            break;

        }



        pass_t++;

        if (pass_t == 3) {

            bpno--;

            pass_t = 0;

        }

    }

    return 0;

}

static int decode_cblk(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty,

                       Jpeg2000T1Context *t1, Jpeg2000Cblk *cblk,

                       int width, int height, int bandpos)

{

    int passno = cblk->npasses, pass_t = 2, bpno = cblk->nonzerobits - 1, y, clnpass_cnt = 0;

    int bpass_csty_symbol = JPEG2000_CBLK_BYPASS & codsty->cblk_style;

    int vert_causal_ctx_csty_symbol = JPEG2000_CBLK_VSC & codsty->cblk_style;



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

        memset(t1->data[y], 0, width * sizeof(**t1->data));



    

    if (!cblk->length)

        return 0;



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

        memset(t1->flags[y], 0, (width + 2)*sizeof(**t1->flags));



    cblk->data[cblk->length] = 0xff;

    cblk->data[cblk->length+1] = 0xff;

    ff_mqc_initdec(&t1->mqc, cblk->data);



    while (passno--) {

        if (bpno < 0) {

            av_log(s->avctx, AV_LOG_ERROR, "bpno invalid\n");

            return AVERROR(EINVAL);

        }

        switch(pass_t) {

        case 0:

            decode_sigpass(t1, width, height, bpno + 1, bandpos,

                           bpass_csty_symbol && (clnpass_cnt >= 4), vert_causal_ctx_csty_symbol);

            break;

        case 1:

            decode_refpass(t1, width, height, bpno + 1);

            if (bpass_csty_symbol && clnpass_cnt >= 4)

                ff_mqc_initdec(&t1->mqc, cblk->data);

            break;

        case 2:

            decode_clnpass(s, t1, width, height, bpno + 1, bandpos,

                           codsty->cblk_style & JPEG2000_CBLK_SEGSYM, vert_causal_ctx_csty_symbol);

            clnpass_cnt = clnpass_cnt + 1;

            if (bpass_csty_symbol && clnpass_cnt >= 4)

                ff_mqc_initdec(&t1->mqc, cblk->data);

            break;

        }



        pass_t++;

        if (pass_t == 3) {

            bpno--;

            pass_t = 0;

        }

    }

    return 0;

}

        if (bpno < 0) {             av_log(s->avctx, AV_LOG_ERROR, "bpno invalid\n");             return AVERROR(EINVAL);
static int FUNC_0(Jpeg2000DecoderContext *VAR_0, Jpeg2000CodingStyle *VAR_1,

                       Jpeg2000T1Context *VAR_2, Jpeg2000Cblk *VAR_3,

                       int VAR_4, int VAR_5, int VAR_6)

{

    int VAR_7 = VAR_3->npasses, VAR_8 = 2, VAR_9 = VAR_3->nonzerobits - 1, VAR_10, VAR_11 = 0;

    int VAR_12 = JPEG2000_CBLK_BYPASS & VAR_1->cblk_style;

    int VAR_13 = JPEG2000_CBLK_VSC & VAR_1->cblk_style;



    for (VAR_10 = 0; VAR_10 < VAR_5; VAR_10++)

        memset(VAR_2->data[VAR_10], 0, VAR_4 * sizeof(**VAR_2->data));



    

    if (!VAR_3->length)

        return 0;



    for (VAR_10 = 0; VAR_10 < VAR_5+2; VAR_10++)

        memset(VAR_2->flags[VAR_10], 0, (VAR_4 + 2)*sizeof(**VAR_2->flags));



    VAR_3->data[VAR_3->length] = 0xff;

    VAR_3->data[VAR_3->length+1] = 0xff;

    ff_mqc_initdec(&VAR_2->mqc, VAR_3->data);



    while (VAR_7--) {

        if (VAR_9 < 0) {

            av_log(VAR_0->avctx, AV_LOG_ERROR, "VAR_9 invalid\n");

            return AVERROR(EINVAL);

        }

        switch(VAR_8) {

        case 0:

            decode_sigpass(VAR_2, VAR_4, VAR_5, VAR_9 + 1, VAR_6,

                           VAR_12 && (VAR_11 >= 4), VAR_13);

            break;

        case 1:

            decode_refpass(VAR_2, VAR_4, VAR_5, VAR_9 + 1);

            if (VAR_12 && VAR_11 >= 4)

                ff_mqc_initdec(&VAR_2->mqc, VAR_3->data);

            break;

        case 2:

            decode_clnpass(VAR_0, VAR_2, VAR_4, VAR_5, VAR_9 + 1, VAR_6,

                           VAR_1->cblk_style & JPEG2000_CBLK_SEGSYM, VAR_13);

            VAR_11 = VAR_11 + 1;

            if (VAR_12 && VAR_11 >= 4)

                ff_mqc_initdec(&VAR_2->mqc, VAR_3->data);

            break;

        }



        VAR_8++;

        if (VAR_8 == 3) {

            VAR_9--;

            VAR_8 = 0;

        }

    }

    return 0;

}

static int FUNC_0(Jpeg2000DecoderContext *VAR_0, Jpeg2000CodingStyle *VAR_1,
Jpeg2000T1Context *VAR_2, Jpeg2000Cblk *VAR_3,
int VAR_4, int VAR_5, int VAR_6)
{ int VAR_7 = VAR_3->npasses, VAR_8 = 2, VAR_9 = VAR_3->nonzerobits - 1, VAR_10, VAR_11 = 0; int VAR_12 = JPEG2000_CBLK_BYPASS & VAR_1->cblk_style; int VAR_13 = JPEG2000_CBLK_VSC & VAR_1->cblk_style; for (VAR_10 = 0; VAR_10 < VAR_5; VAR_10++) memset(VAR_2->data[VAR_10], 0, VAR_4 * sizeof(**VAR_2->data)); if (!VAR_3->length)
return 0; for (VAR_10 = 0; VAR_10 < VAR_5+2; VAR_10++) memset(VAR_2->flags[VAR_10], 0, (VAR_4 + 2)*sizeof(**VAR_2->flags)); VAR_3->data[VAR_3->length] = 0xff; VAR_3->data[VAR_3->length+1] = 0xff; ff_mqc_initdec(&VAR_2->mqc, VAR_3->data); while (VAR_7--) { if (VAR_9 < 0) { av_log(VAR_0->avctx, AV_LOG_ERROR, "VAR_9 invalid\n"); return AVERROR(EINVAL); } switch(VAR_8) { case 0:
decode_sigpass(VAR_2, VAR_4, VAR_5, VAR_9 + 1, VAR_6,
VAR_12 && (VAR_11 >= 4), VAR_13); break; case 1:
decode_refpass(VAR_2, VAR_4, VAR_5, VAR_9 + 1); if (VAR_12 && VAR_11 >= 4)
ff_mqc_initdec(&VAR_2->mqc, VAR_3->data); break; case 2:
decode_clnpass(VAR_0, VAR_2, VAR_4, VAR_5, VAR_9 + 1, VAR_6,
VAR_1->cblk_style & JPEG2000_CBLK_SEGSYM, VAR_13); VAR_11 = VAR_11 + 1; if (VAR_12 && VAR_11 >= 4)
ff_mqc_initdec(&VAR_2->mqc, VAR_3->data); break; } VAR_8++; if (VAR_8 == 3) { VAR_9--; VAR_8 = 0; } } return 0; }