static void decode_clnpass(Jpeg2000DecoderContext *s, Jpeg2000T1Context *t1,

                           int width, int height, int bpno, int bandno,

                           int seg_symbols, int vert_causal_ctx_csty_symbol)

{

    int mask = 3 << (bpno - 1), y0, x, y, runlen, dec;



    for (y0 = 0; y0 < height; y0 += 4) {

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

            int flags_mask = -1;

            if (vert_causal_ctx_csty_symbol)

                flags_mask &= ~(JPEG2000_T1_SIG_S | JPEG2000_T1_SIG_SW | JPEG2000_T1_SIG_SE | JPEG2000_T1_SGN_S);

            if (y0 + 3 < height &&

                !((t1->flags[y0 + 1][x + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)) ||

                  (t1->flags[y0 + 2][x + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)) ||

                  (t1->flags[y0 + 3][x + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)) ||

                  (t1->flags[y0 + 4][x + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG) & flags_mask))) {

                if (!ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_RL))

                    continue;

                runlen = ff_mqc_decode(&t1->mqc,

                                       t1->mqc.cx_states + MQC_CX_UNI);

                runlen = (runlen << 1) | ff_mqc_decode(&t1->mqc,

                                                       t1->mqc.cx_states +

                                                       MQC_CX_UNI);

                dec = 1;

            } else {

                runlen = 0;

                dec    = 0;

            }



            for (y = y0 + runlen; y < y0 + 4 && y < height; y++) {

                int flags_mask = -1;

                if (vert_causal_ctx_csty_symbol && y == y0 + 3)

                    flags_mask &= ~(JPEG2000_T1_SIG_S | JPEG2000_T1_SIG_SW | JPEG2000_T1_SIG_SE | JPEG2000_T1_SGN_S);

                if (!dec) {

                    if (!(t1->flags[y+1][x+1] & (JPEG2000_T1_SIG | JPEG2000_T1_VIS))) {

                        dec = ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ff_jpeg2000_getsigctxno(t1->flags[y+1][x+1] & flags_mask,

                                                                                             bandno));

                    }

                }

                if (dec) {

                    int xorbit;

                    int ctxno = ff_jpeg2000_getsgnctxno(t1->flags[y + 1][x + 1] & flags_mask,

                                                        &xorbit);

                    t1->data[y][x] = (ff_mqc_decode(&t1->mqc,

                                                    t1->mqc.cx_states + ctxno) ^

                                      xorbit)

                                     ? -mask : mask;

                    ff_jpeg2000_set_significance(t1, x, y, t1->data[y][x] < 0);

                }

                dec = 0;

                t1->flags[y + 1][x + 1] &= ~JPEG2000_T1_VIS;

            }

        }

    }

    if (seg_symbols) {

        int val;

        val = ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI);

        val = (val << 1) + ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI);

        val = (val << 1) + ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI);

        val = (val << 1) + ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI);

        if (val != 0xa)

            av_log(s->avctx, AV_LOG_ERROR,

                   "Segmentation symbol value incorrect\n");

    }

}

static void decode_clnpass(Jpeg2000DecoderContext *s, Jpeg2000T1Context *t1,

                           int width, int height, int bpno, int bandno,

                           int seg_symbols, int vert_causal_ctx_csty_symbol)

{

    int mask = 3 << (bpno - 1), y0, x, y, runlen, dec;



    for (y0 = 0; y0 < height; y0 += 4) {

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

            int flags_mask = -1;

            if (vert_causal_ctx_csty_symbol)

                flags_mask &= ~(JPEG2000_T1_SIG_S | JPEG2000_T1_SIG_SW | JPEG2000_T1_SIG_SE | JPEG2000_T1_SGN_S);

            if (y0 + 3 < height &&

                !((t1->flags[y0 + 1][x + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)) ||

                  (t1->flags[y0 + 2][x + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)) ||

                  (t1->flags[y0 + 3][x + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)) ||

                  (t1->flags[y0 + 4][x + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG) & flags_mask))) {

                if (!ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_RL))

                    continue;

                runlen = ff_mqc_decode(&t1->mqc,

                                       t1->mqc.cx_states + MQC_CX_UNI);

                runlen = (runlen << 1) | ff_mqc_decode(&t1->mqc,

                                                       t1->mqc.cx_states +

                                                       MQC_CX_UNI);

                dec = 1;

            } else {

                runlen = 0;

                dec    = 0;

            }



            for (y = y0 + runlen; y < y0 + 4 && y < height; y++) {

                int flags_mask = -1;

                if (vert_causal_ctx_csty_symbol && y == y0 + 3)

                    flags_mask &= ~(JPEG2000_T1_SIG_S | JPEG2000_T1_SIG_SW | JPEG2000_T1_SIG_SE | JPEG2000_T1_SGN_S);

                if (!dec) {

                    if (!(t1->flags[y+1][x+1] & (JPEG2000_T1_SIG | JPEG2000_T1_VIS))) {

                        dec = ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ff_jpeg2000_getsigctxno(t1->flags[y+1][x+1] & flags_mask,

                                                                                             bandno));

                    }

                }

                if (dec) {

                    int xorbit;

                    int ctxno = ff_jpeg2000_getsgnctxno(t1->flags[y + 1][x + 1] & flags_mask,

                                                        &xorbit);

                    t1->data[y][x] = (ff_mqc_decode(&t1->mqc,

                                                    t1->mqc.cx_states + ctxno) ^

                                      xorbit)

                                     ? -mask : mask;

                    ff_jpeg2000_set_significance(t1, x, y, t1->data[y][x] < 0);

                }

                dec = 0;

                t1->flags[y + 1][x + 1] &= ~JPEG2000_T1_VIS;

            }

        }

    }

    if (seg_symbols) {

        int val;

        val = ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI);

        val = (val << 1) + ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI);

        val = (val << 1) + ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI);

        val = (val << 1) + ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI);

        if (val != 0xa)

            av_log(s->avctx, AV_LOG_ERROR,

                   "Segmentation symbol value incorrect\n");

    }

}

static void FUNC_0(Jpeg2000DecoderContext *VAR_0, Jpeg2000T1Context *VAR_1,

                           int VAR_2, int VAR_3, int VAR_4, int VAR_5,

                           int VAR_6, int VAR_7)

{

    int VAR_8 = 3 << (VAR_4 - 1), VAR_9, VAR_10, VAR_11, VAR_12, VAR_13;



    for (VAR_9 = 0; VAR_9 < VAR_3; VAR_9 += 4) {

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

            int VAR_15 = -1;

            if (VAR_7)

                VAR_15 &= ~(JPEG2000_T1_SIG_S | JPEG2000_T1_SIG_SW | JPEG2000_T1_SIG_SE | JPEG2000_T1_SGN_S);

            if (VAR_9 + 3 < VAR_3 &&

                !((VAR_1->flags[VAR_9 + 1][VAR_10 + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)) ||

                  (VAR_1->flags[VAR_9 + 2][VAR_10 + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)) ||

                  (VAR_1->flags[VAR_9 + 3][VAR_10 + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)) ||

                  (VAR_1->flags[VAR_9 + 4][VAR_10 + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG) & VAR_15))) {

                if (!ff_mqc_decode(&VAR_1->mqc, VAR_1->mqc.cx_states + MQC_CX_RL))

                    continue;

                VAR_12 = ff_mqc_decode(&VAR_1->mqc,

                                       VAR_1->mqc.cx_states + MQC_CX_UNI);

                VAR_12 = (VAR_12 << 1) | ff_mqc_decode(&VAR_1->mqc,

                                                       VAR_1->mqc.cx_states +

                                                       MQC_CX_UNI);

                VAR_13 = 1;

            } else {

                VAR_12 = 0;

                VAR_13    = 0;

            }



            for (VAR_11 = VAR_9 + VAR_12; VAR_11 < VAR_9 + 4 && VAR_11 < VAR_3; VAR_11++) {

                int VAR_15 = -1;

                if (VAR_7 && VAR_11 == VAR_9 + 3)

                    VAR_15 &= ~(JPEG2000_T1_SIG_S | JPEG2000_T1_SIG_SW | JPEG2000_T1_SIG_SE | JPEG2000_T1_SGN_S);

                if (!VAR_13) {

                    if (!(VAR_1->flags[VAR_11+1][VAR_10+1] & (JPEG2000_T1_SIG | JPEG2000_T1_VIS))) {

                        VAR_13 = ff_mqc_decode(&VAR_1->mqc, VAR_1->mqc.cx_states + ff_jpeg2000_getsigctxno(VAR_1->flags[VAR_11+1][VAR_10+1] & VAR_15,

                                                                                             VAR_5));

                    }

                }

                if (VAR_13) {

                    int VAR_15;

                    int VAR_16 = ff_jpeg2000_getsgnctxno(VAR_1->flags[VAR_11 + 1][VAR_10 + 1] & VAR_15,

                                                        &VAR_15);

                    VAR_1->data[VAR_11][VAR_10] = (ff_mqc_decode(&VAR_1->mqc,

                                                    VAR_1->mqc.cx_states + VAR_16) ^

                                      VAR_15)

                                     ? -VAR_8 : VAR_8;

                    ff_jpeg2000_set_significance(VAR_1, VAR_10, VAR_11, VAR_1->data[VAR_11][VAR_10] < 0);

                }

                VAR_13 = 0;

                VAR_1->flags[VAR_11 + 1][VAR_10 + 1] &= ~JPEG2000_T1_VIS;

            }

        }

    }

    if (VAR_6) {

        int VAR_17;

        VAR_17 = ff_mqc_decode(&VAR_1->mqc, VAR_1->mqc.cx_states + MQC_CX_UNI);

        VAR_17 = (VAR_17 << 1) + ff_mqc_decode(&VAR_1->mqc, VAR_1->mqc.cx_states + MQC_CX_UNI);

        VAR_17 = (VAR_17 << 1) + ff_mqc_decode(&VAR_1->mqc, VAR_1->mqc.cx_states + MQC_CX_UNI);

        VAR_17 = (VAR_17 << 1) + ff_mqc_decode(&VAR_1->mqc, VAR_1->mqc.cx_states + MQC_CX_UNI);

        if (VAR_17 != 0xa)

            av_log(VAR_0->avctx, AV_LOG_ERROR,

                   "Segmentation symbol value incorrect\n");

    }

}

static void FUNC_0(Jpeg2000DecoderContext *VAR_0, Jpeg2000T1Context *VAR_1,
int VAR_2, int VAR_3, int VAR_4, int VAR_5,
int VAR_6, int VAR_7)
{ int VAR_8 = 3 << (VAR_4 - 1), VAR_9, VAR_10, VAR_11, VAR_12, VAR_13; for (VAR_9 = 0; VAR_9 < VAR_3; VAR_9 += 4) { for (VAR_10 = 0; VAR_10 < VAR_2; VAR_10++) { int VAR_15 = -1; if (VAR_7)
VAR_15 &= ~(JPEG2000_T1_SIG_S | JPEG2000_T1_SIG_SW | JPEG2000_T1_SIG_SE | JPEG2000_T1_SGN_S); if (VAR_9 + 3 < VAR_3 &&
!((VAR_1->flags[VAR_9 + 1][VAR_10 + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)) ||
(VAR_1->flags[VAR_9 + 2][VAR_10 + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)) ||
(VAR_1->flags[VAR_9 + 3][VAR_10 + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG)) ||
(VAR_1->flags[VAR_9 + 4][VAR_10 + 1] & (JPEG2000_T1_SIG_NB | JPEG2000_T1_VIS | JPEG2000_T1_SIG) & VAR_15))) { if (!ff_mqc_decode(&VAR_1->mqc, VAR_1->mqc.cx_states + MQC_CX_RL))
continue; VAR_12 = ff_mqc_decode(&VAR_1->mqc,
VAR_1->mqc.cx_states + MQC_CX_UNI); VAR_12 = (VAR_12 << 1) | ff_mqc_decode(&VAR_1->mqc,
VAR_1->mqc.cx_states +
MQC_CX_UNI); VAR_13 = 1; } else { VAR_12 = 0; VAR_13    = 0; } for (VAR_11 = VAR_9 + VAR_12; VAR_11 < VAR_9 + 4 && VAR_11 < VAR_3; VAR_11++) { int VAR_15 = -1; if (VAR_7 && VAR_11 == VAR_9 + 3)
VAR_15 &= ~(JPEG2000_T1_SIG_S | JPEG2000_T1_SIG_SW | JPEG2000_T1_SIG_SE | JPEG2000_T1_SGN_S); if (!VAR_13) { if (!(VAR_1->flags[VAR_11+1][VAR_10+1] & (JPEG2000_T1_SIG | JPEG2000_T1_VIS))) { VAR_13 = ff_mqc_decode(&VAR_1->mqc, VAR_1->mqc.cx_states + ff_jpeg2000_getsigctxno(VAR_1->flags[VAR_11+1][VAR_10+1] & VAR_15,
VAR_5)); } } if (VAR_13) { int VAR_15; int VAR_16 = ff_jpeg2000_getsgnctxno(VAR_1->flags[VAR_11 + 1][VAR_10 + 1] & VAR_15,
&VAR_15); VAR_1->data[VAR_11][VAR_10] = (ff_mqc_decode(&VAR_1->mqc,
VAR_1->mqc.cx_states + VAR_16) ^
VAR_15)
? -VAR_8 : VAR_8; ff_jpeg2000_set_significance(VAR_1, VAR_10, VAR_11, VAR_1->data[VAR_11][VAR_10] < 0); } VAR_13 = 0; VAR_1->flags[VAR_11 + 1][VAR_10 + 1] &= ~JPEG2000_T1_VIS; } } } if (VAR_6) { int VAR_17; VAR_17 = ff_mqc_decode(&VAR_1->mqc, VAR_1->mqc.cx_states + MQC_CX_UNI); VAR_17 = (VAR_17 << 1) + ff_mqc_decode(&VAR_1->mqc, VAR_1->mqc.cx_states + MQC_CX_UNI); VAR_17 = (VAR_17 << 1) + ff_mqc_decode(&VAR_1->mqc, VAR_1->mqc.cx_states + MQC_CX_UNI); VAR_17 = (VAR_17 << 1) + ff_mqc_decode(&VAR_1->mqc, VAR_1->mqc.cx_states + MQC_CX_UNI); if (VAR_17 != 0xa)
av_log(VAR_0->avctx, AV_LOG_ERROR,
"Segmentation symbol value incorrect\n"); } }