static int get_cox(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c)

{

    uint8_t byte;



    if (s->buf_end - s->buf < 5)

        return AVERROR(EINVAL);

    c->nreslevels = bytestream_get_byte(&s->buf) + 1; // num of resolution levels - 1



    /* compute number of resolution levels to decode */

    if (c->nreslevels < s->reduction_factor)

        c->nreslevels2decode = 1;

    else

        c->nreslevels2decode = c->nreslevels - s->reduction_factor;



    c->log2_cblk_width  = bytestream_get_byte(&s->buf) + 2; // cblk width

    c->log2_cblk_height = bytestream_get_byte(&s->buf) + 2; // cblk height



    c->cblk_style = bytestream_get_byte(&s->buf);

    if (c->cblk_style != 0) { // cblk style

        av_log(s->avctx, AV_LOG_ERROR, "no extra cblk styles supported\n");

        return -1;

    }

    c->transform = bytestream_get_byte(&s->buf); // DWT transformation type

    /* set integer 9/7 DWT in case of BITEXACT flag */

    if ((s->avctx->flags & CODEC_FLAG_BITEXACT) && (c->transform == FF_DWT97))

        c->transform = FF_DWT97_INT;



    if (c->csty & JPEG2000_CSTY_PREC) {

        int i;

        for (i = 0; i < c->nreslevels; i++) {

            byte = bytestream_get_byte(&s->buf);

            c->log2_prec_widths[i]  =  byte       & 0x0F;    // precinct PPx

            c->log2_prec_heights[i] = (byte >> 4) & 0x0F;    // precinct PPy

        }

    }

    return 0;

}

static int get_cox(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c)

{

    uint8_t byte;



    if (s->buf_end - s->buf < 5)

        return AVERROR(EINVAL);

    c->nreslevels = bytestream_get_byte(&s->buf) + 1; 



    

    if (c->nreslevels < s->reduction_factor)

        c->nreslevels2decode = 1;

    else

        c->nreslevels2decode = c->nreslevels - s->reduction_factor;



    c->log2_cblk_width  = bytestream_get_byte(&s->buf) + 2; 

    c->log2_cblk_height = bytestream_get_byte(&s->buf) + 2; 



    c->cblk_style = bytestream_get_byte(&s->buf);

    if (c->cblk_style != 0) { 

        av_log(s->avctx, AV_LOG_ERROR, "no extra cblk styles supported\n");

        return -1;

    }

    c->transform = bytestream_get_byte(&s->buf); 

    

    if ((s->avctx->flags & CODEC_FLAG_BITEXACT) && (c->transform == FF_DWT97))

        c->transform = FF_DWT97_INT;



    if (c->csty & JPEG2000_CSTY_PREC) {

        int i;

        for (i = 0; i < c->nreslevels; i++) {

            byte = bytestream_get_byte(&s->buf);

            c->log2_prec_widths[i]  =  byte       & 0x0F;    

            c->log2_prec_heights[i] = (byte >> 4) & 0x0F;    

        }

    }

    return 0;

}

static int FUNC_0(Jpeg2000DecoderContext *VAR_0, Jpeg2000CodingStyle *VAR_1)

{

    uint8_t byte;



    if (VAR_0->buf_end - VAR_0->buf < 5)

        return AVERROR(EINVAL);

    VAR_1->nreslevels = bytestream_get_byte(&VAR_0->buf) + 1; 



    

    if (VAR_1->nreslevels < VAR_0->reduction_factor)

        VAR_1->nreslevels2decode = 1;

    else

        VAR_1->nreslevels2decode = VAR_1->nreslevels - VAR_0->reduction_factor;



    VAR_1->log2_cblk_width  = bytestream_get_byte(&VAR_0->buf) + 2; 

    VAR_1->log2_cblk_height = bytestream_get_byte(&VAR_0->buf) + 2; 



    VAR_1->cblk_style = bytestream_get_byte(&VAR_0->buf);

    if (VAR_1->cblk_style != 0) { 

        av_log(VAR_0->avctx, AV_LOG_ERROR, "no extra cblk styles supported\n");

        return -1;

    }

    VAR_1->transform = bytestream_get_byte(&VAR_0->buf); 

    

    if ((VAR_0->avctx->flags & CODEC_FLAG_BITEXACT) && (VAR_1->transform == FF_DWT97))

        VAR_1->transform = FF_DWT97_INT;



    if (VAR_1->csty & JPEG2000_CSTY_PREC) {

        int VAR_2;

        for (VAR_2 = 0; VAR_2 < VAR_1->nreslevels; VAR_2++) {

            byte = bytestream_get_byte(&VAR_0->buf);

            VAR_1->log2_prec_widths[VAR_2]  =  byte       & 0x0F;    

            VAR_1->log2_prec_heights[VAR_2] = (byte >> 4) & 0x0F;    

        }

    }

    return 0;

}

static int FUNC_0(Jpeg2000DecoderContext *VAR_0, Jpeg2000CodingStyle *VAR_1)
{ uint8_t byte; if (VAR_0->buf_end - VAR_0->buf < 5)
return AVERROR(EINVAL); VAR_1->nreslevels = bytestream_get_byte(&VAR_0->buf) + 1; if (VAR_1->nreslevels < VAR_0->reduction_factor)
VAR_1->nreslevels2decode = 1; else
VAR_1->nreslevels2decode = VAR_1->nreslevels - VAR_0->reduction_factor; VAR_1->log2_cblk_width  = bytestream_get_byte(&VAR_0->buf) + 2; VAR_1->log2_cblk_height = bytestream_get_byte(&VAR_0->buf) + 2; VAR_1->cblk_style = bytestream_get_byte(&VAR_0->buf); if (VAR_1->cblk_style != 0) { av_log(VAR_0->avctx, AV_LOG_ERROR, "no extra cblk styles supported\n"); return -1; } VAR_1->transform = bytestream_get_byte(&VAR_0->buf); if ((VAR_0->avctx->flags & CODEC_FLAG_BITEXACT) && (VAR_1->transform == FF_DWT97))
VAR_1->transform = FF_DWT97_INT; if (VAR_1->csty & JPEG2000_CSTY_PREC) { int VAR_2; for (VAR_2 = 0; VAR_2 < VAR_1->nreslevels; VAR_2++) { byte = bytestream_get_byte(&VAR_0->buf); VAR_1->log2_prec_widths[VAR_2]  =  byte       & 0x0F; VAR_1->log2_prec_heights[VAR_2] = (byte >> 4) & 0x0F; } } return 0; }