static void encode_refpass(Jpeg2000T1Context *t1, int width, int height, int *nmsedec, int bpno)

{

    int y0, x, y, mask = 1 << (bpno + NMSEDEC_FRACBITS);

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

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

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

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

                    int ctxno = ff_jpeg2000_getrefctxno(t1->flags[y+1][x+1]);

                    *nmsedec += getnmsedec_ref(t1->data[y][x], bpno + NMSEDEC_FRACBITS);

                    ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, t1->data[y][x] & mask ? 1:0);

                    t1->flags[y+1][x+1] |= JPEG2000_T1_REF;

                }

}

static void encode_refpass(Jpeg2000T1Context *t1, int width, int height, int *nmsedec, int bpno)

{

    int y0, x, y, mask = 1 << (bpno + NMSEDEC_FRACBITS);

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

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

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

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

                    int ctxno = ff_jpeg2000_getrefctxno(t1->flags[y+1][x+1]);

                    *nmsedec += getnmsedec_ref(t1->data[y][x], bpno + NMSEDEC_FRACBITS);

                    ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, t1->data[y][x] & mask ? 1:0);

                    t1->flags[y+1][x+1] |= JPEG2000_T1_REF;

                }

}

static void FUNC_0(Jpeg2000T1Context *VAR_0, int VAR_1, int VAR_2, int *VAR_3, int VAR_4)

{

    int VAR_5, VAR_6, VAR_7, VAR_8 = 1 << (VAR_4 + NMSEDEC_FRACBITS);

    for (VAR_5 = 0; VAR_5 < VAR_2; VAR_5 += 4)

        for (VAR_6 = 0; VAR_6 < VAR_1; VAR_6++)

            for (VAR_7 = VAR_5; VAR_7 < VAR_2 && VAR_7 < VAR_5+4; VAR_7++)

                if ((VAR_0->flags[VAR_7+1][VAR_6+1] & (JPEG2000_T1_SIG | JPEG2000_T1_VIS)) == JPEG2000_T1_SIG){

                    int VAR_9 = ff_jpeg2000_getrefctxno(VAR_0->flags[VAR_7+1][VAR_6+1]);

                    *VAR_3 += getnmsedec_ref(VAR_0->data[VAR_7][VAR_6], VAR_4 + NMSEDEC_FRACBITS);

                    ff_mqc_encode(&VAR_0->mqc, VAR_0->mqc.cx_states + VAR_9, VAR_0->data[VAR_7][VAR_6] & VAR_8 ? 1:0);

                    VAR_0->flags[VAR_7+1][VAR_6+1] |= JPEG2000_T1_REF;

                }

}

static void FUNC_0(Jpeg2000T1Context *VAR_0, int VAR_1, int VAR_2, int *VAR_3, int VAR_4)
{ int VAR_5, VAR_6, VAR_7, VAR_8 = 1 << (VAR_4 + NMSEDEC_FRACBITS); for (VAR_5 = 0; VAR_5 < VAR_2; VAR_5 += 4) for (VAR_6 = 0; VAR_6 < VAR_1; VAR_6++) for (VAR_7 = VAR_5; VAR_7 < VAR_2 && VAR_7 < VAR_5+4; VAR_7++) if ((VAR_0->flags[VAR_7+1][VAR_6+1] & (JPEG2000_T1_SIG | JPEG2000_T1_VIS)) == JPEG2000_T1_SIG){ int VAR_9 = ff_jpeg2000_getrefctxno(VAR_0->flags[VAR_7+1][VAR_6+1]); *VAR_3 += getnmsedec_ref(VAR_0->data[VAR_7][VAR_6], VAR_4 + NMSEDEC_FRACBITS); ff_mqc_encode(&VAR_0->mqc, VAR_0->mqc.cx_states + VAR_9, VAR_0->data[VAR_7][VAR_6] & VAR_8 ? 1:0); VAR_0->flags[VAR_7+1][VAR_6+1] |= JPEG2000_T1_REF; } }