static int get_bits(Jpeg2000DecoderContext *s, int n)

{

    int res = 0;

    if (s->buf_end - s->buf < ((n - s->bit_index) >> 8))

        return AVERROR_INVALIDDATA;

    while (--n >= 0) {

        res <<= 1;

        if (s->bit_index == 0) {

            s->bit_index = 7 + (*s->buf != 0xff);

            s->buf++;

        }

        s->bit_index--;

        res |= (*s->buf >> s->bit_index) & 1;

    }

    return res;

}

static int get_bits(Jpeg2000DecoderContext *s, int n)

{

    int res = 0;

    if (s->buf_end - s->buf < ((n - s->bit_index) >> 8))

        return AVERROR_INVALIDDATA;

    while (--n >= 0) {

        res <<= 1;

        if (s->bit_index == 0) {

            s->bit_index = 7 + (*s->buf != 0xff);

            s->buf++;

        }

        s->bit_index--;

        res |= (*s->buf >> s->bit_index) & 1;

    }

    return res;

}

    if (s->buf_end - s->buf < ((n - s->bit_index) >> 8))         return AVERROR_INVALIDDATA;             s->bit_index = 7 + (*s->buf != 0xff);             s->buf++;         res |= (*s->buf >> s->bit_index) & 1;
static int FUNC_0(Jpeg2000DecoderContext *VAR_0, int VAR_1)

{

    int VAR_2 = 0;

    if (VAR_0->buf_end - VAR_0->buf < ((VAR_1 - VAR_0->bit_index) >> 8))

        return AVERROR_INVALIDDATA;

    while (--VAR_1 >= 0) {

        VAR_2 <<= 1;

        if (VAR_0->bit_index == 0) {

            VAR_0->bit_index = 7 + (*VAR_0->buf != 0xff);

            VAR_0->buf++;

        }

        VAR_0->bit_index--;

        VAR_2 |= (*VAR_0->buf >> VAR_0->bit_index) & 1;

    }

    return VAR_2;

}

static int FUNC_0(Jpeg2000DecoderContext *VAR_0, int VAR_1)
{ int VAR_2 = 0; if (VAR_0->buf_end - VAR_0->buf < ((VAR_1 - VAR_0->bit_index) >> 8))
return AVERROR_INVALIDDATA; while (--VAR_1 >= 0) { VAR_2 <<= 1; if (VAR_0->bit_index == 0) { VAR_0->bit_index = 7 + (*VAR_0->buf != 0xff); VAR_0->buf++; } VAR_0->bit_index--; VAR_2 |= (*VAR_0->buf >> VAR_0->bit_index) & 1; } return VAR_2; }