static int decode_slice_thread(AVCodecContext *avctx, void *arg, int jobnr, int threadnr)

{

    ProresContext *ctx = avctx->priv_data;

    SliceContext *slice = &ctx->slices[jobnr];

    const uint8_t *buf = slice->data;

    AVFrame *pic = ctx->frame;

    int i, hdr_size, qscale, log2_chroma_blocks_per_mb;

    int luma_stride, chroma_stride;

    int y_data_size, u_data_size, v_data_size, a_data_size;

    uint8_t *dest_y, *dest_u, *dest_v, *dest_a;

    int16_t qmat_luma_scaled[64];

    int16_t qmat_chroma_scaled[64];

    int mb_x_shift;



    slice->ret = -1;

    //av_log(avctx, AV_LOG_INFO, "slice %d mb width %d mb x %d y %d\n",

    //       jobnr, slice->mb_count, slice->mb_x, slice->mb_y);



    // slice header

    hdr_size = buf[0] >> 3;

    qscale = av_clip(buf[1], 1, 224);

    qscale = qscale > 128 ? qscale - 96 << 2: qscale;

    y_data_size = AV_RB16(buf + 2);

    u_data_size = AV_RB16(buf + 4);

    v_data_size = slice->data_size - y_data_size - u_data_size - hdr_size;

    if (hdr_size > 7) v_data_size = AV_RB16(buf + 6);

    a_data_size = slice->data_size - y_data_size - u_data_size -

                  v_data_size - hdr_size;



    if (y_data_size < 0 || u_data_size < 0 || v_data_size < 0

        || hdr_size+y_data_size+u_data_size+v_data_size > slice->data_size){

        av_log(avctx, AV_LOG_ERROR, "invalid plane data size\n");

        return -1;

    }



    buf += hdr_size;



    for (i = 0; i < 64; i++) {

        qmat_luma_scaled  [i] = ctx->qmat_luma  [i] * qscale;

        qmat_chroma_scaled[i] = ctx->qmat_chroma[i] * qscale;

    }



    if (ctx->frame_type == 0) {

        luma_stride   = pic->linesize[0];

        chroma_stride = pic->linesize[1];

    } else {

        luma_stride   = pic->linesize[0] << 1;

        chroma_stride = pic->linesize[1] << 1;

    }



    if (avctx->pix_fmt == AV_PIX_FMT_YUV444P10 || avctx->pix_fmt == AV_PIX_FMT_YUVA444P10) {

        mb_x_shift = 5;

        log2_chroma_blocks_per_mb = 2;

    } else {

        mb_x_shift = 4;

        log2_chroma_blocks_per_mb = 1;

    }



    dest_y = pic->data[0] + (slice->mb_y << 4) * luma_stride + (slice->mb_x << 5);

    dest_u = pic->data[1] + (slice->mb_y << 4) * chroma_stride + (slice->mb_x << mb_x_shift);

    dest_v = pic->data[2] + (slice->mb_y << 4) * chroma_stride + (slice->mb_x << mb_x_shift);

    dest_a = pic->data[3] + (slice->mb_y << 4) * luma_stride + (slice->mb_x << 5);



    if (ctx->frame_type && ctx->first_field ^ ctx->frame->top_field_first) {

        dest_y += pic->linesize[0];

        dest_u += pic->linesize[1];

        dest_v += pic->linesize[2];

        dest_a += pic->linesize[3];

    }



    decode_slice_luma(avctx, slice, (uint16_t*)dest_y, luma_stride,

                      buf, y_data_size, qmat_luma_scaled);



    if (!(avctx->flags & CODEC_FLAG_GRAY)) {

        decode_slice_chroma(avctx, slice, (uint16_t*)dest_u, chroma_stride,

                            buf + y_data_size, u_data_size,

                            qmat_chroma_scaled, log2_chroma_blocks_per_mb);

        decode_slice_chroma(avctx, slice, (uint16_t*)dest_v, chroma_stride,

                            buf + y_data_size + u_data_size, v_data_size,

                            qmat_chroma_scaled, log2_chroma_blocks_per_mb);

    }

    /* decode alpha plane if available */

    if (ctx->alpha_info && dest_a && a_data_size)

        decode_slice_alpha(ctx, (uint16_t*)dest_a, luma_stride,

                           buf + y_data_size + u_data_size + v_data_size,

                           a_data_size, slice->mb_count);



    slice->ret = 0;

    return 0;

}

static int decode_slice_thread(AVCodecContext *avctx, void *arg, int jobnr, int threadnr)

{

    ProresContext *ctx = avctx->priv_data;

    SliceContext *slice = &ctx->slices[jobnr];

    const uint8_t *buf = slice->data;

    AVFrame *pic = ctx->frame;

    int i, hdr_size, qscale, log2_chroma_blocks_per_mb;

    int luma_stride, chroma_stride;

    int y_data_size, u_data_size, v_data_size, a_data_size;

    uint8_t *dest_y, *dest_u, *dest_v, *dest_a;

    int16_t qmat_luma_scaled[64];

    int16_t qmat_chroma_scaled[64];

    int mb_x_shift;



    slice->ret = -1;

    

    



    

    hdr_size = buf[0] >> 3;

    qscale = av_clip(buf[1], 1, 224);

    qscale = qscale > 128 ? qscale - 96 << 2: qscale;

    y_data_size = AV_RB16(buf + 2);

    u_data_size = AV_RB16(buf + 4);

    v_data_size = slice->data_size - y_data_size - u_data_size - hdr_size;

    if (hdr_size > 7) v_data_size = AV_RB16(buf + 6);

    a_data_size = slice->data_size - y_data_size - u_data_size -

                  v_data_size - hdr_size;



    if (y_data_size < 0 || u_data_size < 0 || v_data_size < 0

        || hdr_size+y_data_size+u_data_size+v_data_size > slice->data_size){

        av_log(avctx, AV_LOG_ERROR, "invalid plane data size\n");

        return -1;

    }



    buf += hdr_size;



    for (i = 0; i < 64; i++) {

        qmat_luma_scaled  [i] = ctx->qmat_luma  [i] * qscale;

        qmat_chroma_scaled[i] = ctx->qmat_chroma[i] * qscale;

    }



    if (ctx->frame_type == 0) {

        luma_stride   = pic->linesize[0];

        chroma_stride = pic->linesize[1];

    } else {

        luma_stride   = pic->linesize[0] << 1;

        chroma_stride = pic->linesize[1] << 1;

    }



    if (avctx->pix_fmt == AV_PIX_FMT_YUV444P10 || avctx->pix_fmt == AV_PIX_FMT_YUVA444P10) {

        mb_x_shift = 5;

        log2_chroma_blocks_per_mb = 2;

    } else {

        mb_x_shift = 4;

        log2_chroma_blocks_per_mb = 1;

    }



    dest_y = pic->data[0] + (slice->mb_y << 4) * luma_stride + (slice->mb_x << 5);

    dest_u = pic->data[1] + (slice->mb_y << 4) * chroma_stride + (slice->mb_x << mb_x_shift);

    dest_v = pic->data[2] + (slice->mb_y << 4) * chroma_stride + (slice->mb_x << mb_x_shift);

    dest_a = pic->data[3] + (slice->mb_y << 4) * luma_stride + (slice->mb_x << 5);



    if (ctx->frame_type && ctx->first_field ^ ctx->frame->top_field_first) {

        dest_y += pic->linesize[0];

        dest_u += pic->linesize[1];

        dest_v += pic->linesize[2];

        dest_a += pic->linesize[3];

    }



    decode_slice_luma(avctx, slice, (uint16_t*)dest_y, luma_stride,

                      buf, y_data_size, qmat_luma_scaled);



    if (!(avctx->flags & CODEC_FLAG_GRAY)) {

        decode_slice_chroma(avctx, slice, (uint16_t*)dest_u, chroma_stride,

                            buf + y_data_size, u_data_size,

                            qmat_chroma_scaled, log2_chroma_blocks_per_mb);

        decode_slice_chroma(avctx, slice, (uint16_t*)dest_v, chroma_stride,

                            buf + y_data_size + u_data_size, v_data_size,

                            qmat_chroma_scaled, log2_chroma_blocks_per_mb);

    }

    

    if (ctx->alpha_info && dest_a && a_data_size)

        decode_slice_alpha(ctx, (uint16_t*)dest_a, luma_stride,

                           buf + y_data_size + u_data_size + v_data_size,

                           a_data_size, slice->mb_count);



    slice->ret = 0;

    return 0;

}

    if (ctx->alpha_info && dest_a && a_data_size)
static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int VAR_2, int VAR_3)

{

    ProresContext *ctx = VAR_0->priv_data;

    SliceContext *slice = &ctx->slices[VAR_2];

    const uint8_t *VAR_4 = slice->data;

    AVFrame *pic = ctx->frame;

    int VAR_5, VAR_6, VAR_7, VAR_8;

    int VAR_9, VAR_10;

    int VAR_11, VAR_12, VAR_13, VAR_14;

    uint8_t *dest_y, *dest_u, *dest_v, *dest_a;

    int16_t qmat_luma_scaled[64];

    int16_t qmat_chroma_scaled[64];

    int VAR_15;



    slice->ret = -1;

    

    



    

    VAR_6 = VAR_4[0] >> 3;

    VAR_7 = av_clip(VAR_4[1], 1, 224);

    VAR_7 = VAR_7 > 128 ? VAR_7 - 96 << 2: VAR_7;

    VAR_11 = AV_RB16(VAR_4 + 2);

    VAR_12 = AV_RB16(VAR_4 + 4);

    VAR_13 = slice->data_size - VAR_11 - VAR_12 - VAR_6;

    if (VAR_6 > 7) VAR_13 = AV_RB16(VAR_4 + 6);

    VAR_14 = slice->data_size - VAR_11 - VAR_12 -

                  VAR_13 - VAR_6;



    if (VAR_11 < 0 || VAR_12 < 0 || VAR_13 < 0

        || VAR_6+VAR_11+VAR_12+VAR_13 > slice->data_size){

        av_log(VAR_0, AV_LOG_ERROR, "invalid plane data size\n");

        return -1;

    }



    VAR_4 += VAR_6;



    for (VAR_5 = 0; VAR_5 < 64; VAR_5++) {

        qmat_luma_scaled  [VAR_5] = ctx->qmat_luma  [VAR_5] * VAR_7;

        qmat_chroma_scaled[VAR_5] = ctx->qmat_chroma[VAR_5] * VAR_7;

    }



    if (ctx->frame_type == 0) {

        VAR_9   = pic->linesize[0];

        VAR_10 = pic->linesize[1];

    } else {

        VAR_9   = pic->linesize[0] << 1;

        VAR_10 = pic->linesize[1] << 1;

    }



    if (VAR_0->pix_fmt == AV_PIX_FMT_YUV444P10 || VAR_0->pix_fmt == AV_PIX_FMT_YUVA444P10) {

        VAR_15 = 5;

        VAR_8 = 2;

    } else {

        VAR_15 = 4;

        VAR_8 = 1;

    }



    dest_y = pic->data[0] + (slice->mb_y << 4) * VAR_9 + (slice->mb_x << 5);

    dest_u = pic->data[1] + (slice->mb_y << 4) * VAR_10 + (slice->mb_x << VAR_15);

    dest_v = pic->data[2] + (slice->mb_y << 4) * VAR_10 + (slice->mb_x << VAR_15);

    dest_a = pic->data[3] + (slice->mb_y << 4) * VAR_9 + (slice->mb_x << 5);



    if (ctx->frame_type && ctx->first_field ^ ctx->frame->top_field_first) {

        dest_y += pic->linesize[0];

        dest_u += pic->linesize[1];

        dest_v += pic->linesize[2];

        dest_a += pic->linesize[3];

    }



    decode_slice_luma(VAR_0, slice, (uint16_t*)dest_y, VAR_9,

                      VAR_4, VAR_11, qmat_luma_scaled);



    if (!(VAR_0->flags & CODEC_FLAG_GRAY)) {

        decode_slice_chroma(VAR_0, slice, (uint16_t*)dest_u, VAR_10,

                            VAR_4 + VAR_11, VAR_12,

                            qmat_chroma_scaled, VAR_8);

        decode_slice_chroma(VAR_0, slice, (uint16_t*)dest_v, VAR_10,

                            VAR_4 + VAR_11 + VAR_12, VAR_13,

                            qmat_chroma_scaled, VAR_8);

    }

    

    if (ctx->alpha_info && dest_a && VAR_14)

        decode_slice_alpha(ctx, (uint16_t*)dest_a, VAR_9,

                           VAR_4 + VAR_11 + VAR_12 + VAR_13,

                           VAR_14, slice->mb_count);



    slice->ret = 0;

    return 0;

}

static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int VAR_2, int VAR_3)
{ ProresContext *ctx = VAR_0->priv_data; SliceContext *slice = &ctx->slices[VAR_2]; const uint8_t *VAR_4 = slice->data; AVFrame *pic = ctx->frame; int VAR_5, VAR_6, VAR_7, VAR_8; int VAR_9, VAR_10; int VAR_11, VAR_12, VAR_13, VAR_14; uint8_t *dest_y, *dest_u, *dest_v, *dest_a; int16_t qmat_luma_scaled[64]; int16_t qmat_chroma_scaled[64]; int VAR_15; slice->ret = -1; VAR_6 = VAR_4[0] >> 3; VAR_7 = av_clip(VAR_4[1], 1, 224); VAR_7 = VAR_7 > 128 ? VAR_7 - 96 << 2: VAR_7; VAR_11 = AV_RB16(VAR_4 + 2); VAR_12 = AV_RB16(VAR_4 + 4); VAR_13 = slice->data_size - VAR_11 - VAR_12 - VAR_6; if (VAR_6 > 7) VAR_13 = AV_RB16(VAR_4 + 6); VAR_14 = slice->data_size - VAR_11 - VAR_12 -
VAR_13 - VAR_6; if (VAR_11 < 0 || VAR_12 < 0 || VAR_13 < 0
|| VAR_6+VAR_11+VAR_12+VAR_13 > slice->data_size){ av_log(VAR_0, AV_LOG_ERROR, "invalid plane data size\n"); return -1; } VAR_4 += VAR_6; for (VAR_5 = 0; VAR_5 < 64; VAR_5++) { qmat_luma_scaled  [VAR_5] = ctx->qmat_luma  [VAR_5] * VAR_7; qmat_chroma_scaled[VAR_5] = ctx->qmat_chroma[VAR_5] * VAR_7; } if (ctx->frame_type == 0) { VAR_9   = pic->linesize[0]; VAR_10 = pic->linesize[1]; } else { VAR_9   = pic->linesize[0] << 1; VAR_10 = pic->linesize[1] << 1; } if (VAR_0->pix_fmt == AV_PIX_FMT_YUV444P10 || VAR_0->pix_fmt == AV_PIX_FMT_YUVA444P10) { VAR_15 = 5; VAR_8 = 2; } else { VAR_15 = 4; VAR_8 = 1; } dest_y = pic->data[0] + (slice->mb_y << 4) * VAR_9 + (slice->mb_x << 5); dest_u = pic->data[1] + (slice->mb_y << 4) * VAR_10 + (slice->mb_x << VAR_15); dest_v = pic->data[2] + (slice->mb_y << 4) * VAR_10 + (slice->mb_x << VAR_15); dest_a = pic->data[3] + (slice->mb_y << 4) * VAR_9 + (slice->mb_x << 5); if (ctx->frame_type && ctx->first_field ^ ctx->frame->top_field_first) { dest_y += pic->linesize[0]; dest_u += pic->linesize[1]; dest_v += pic->linesize[2]; dest_a += pic->linesize[3]; } decode_slice_luma(VAR_0, slice, (uint16_t*)dest_y, VAR_9,
VAR_4, VAR_11, qmat_luma_scaled); if (!(VAR_0->flags & CODEC_FLAG_GRAY)) { decode_slice_chroma(VAR_0, slice, (uint16_t*)dest_u, VAR_10,
VAR_4 + VAR_11, VAR_12,
qmat_chroma_scaled, VAR_8); decode_slice_chroma(VAR_0, slice, (uint16_t*)dest_v, VAR_10,
VAR_4 + VAR_11 + VAR_12, VAR_13,
qmat_chroma_scaled, VAR_8); } if (ctx->alpha_info && dest_a && VAR_14)
decode_slice_alpha(ctx, (uint16_t*)dest_a, VAR_9,
VAR_4 + VAR_11 + VAR_12 + VAR_13,
VAR_14, slice->mb_count); slice->ret = 0; return 0; }