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

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

                           int seg_symbols)

{

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



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

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

            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)))) {

                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++) {

                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],

                                                                   bandno));

                }

                if (dec) {

                    int xorbit;

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

                                                        &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 mask = 3 << (bpno - 1), y0, x, y, runlen, dec;



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

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

            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)))) {

                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++) {

                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],

                                                                   bandno));

                }

                if (dec) {

                    int xorbit;

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

                                                        &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 = 3 << (VAR_4 - 1), VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;



    for (VAR_8 = 0; VAR_8 < VAR_3; VAR_8 += 4)

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

            if (VAR_8 + 3 < VAR_3 &&

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

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

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

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

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

                    continue;

                VAR_11 = ff_mqc_decode(&VAR_1->mqc,

                                       VAR_1->mqc.cx_states + MQC_CX_UNI);

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

                                                       VAR_1->mqc.cx_states +

                                                       MQC_CX_UNI);

                VAR_12 = 1;

            } else {

                VAR_11 = 0;

                VAR_12    = 0;

            }



            for (VAR_10 = VAR_8 + VAR_11; VAR_10 < VAR_8 + 4 && VAR_10 < VAR_3; VAR_10++) {

                if (!VAR_12) {

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

                        VAR_12 = ff_mqc_decode(&VAR_1->mqc,

                                            VAR_1->mqc.cx_states +

                                            ff_jpeg2000_getsigctxno(VAR_1->flags[VAR_10 + 1][VAR_9 + 1],

                                                                   VAR_5));

                }

                if (VAR_12) {

                    int VAR_13;

                    int VAR_14 = ff_jpeg2000_getsgnctxno(VAR_1->flags[VAR_10 + 1][VAR_9 + 1],

                                                        &VAR_13);

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

                                                    VAR_1->mqc.cx_states + VAR_14) ^

                                      VAR_13)

                                     ? -VAR_7 : VAR_7;

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

                }

                VAR_12 = 0;

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

            }

        }

    if (VAR_6) {

        int VAR_15;

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

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

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

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

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