static int hls_slice_data_wpp(HEVCContext *s, const HEVCNAL *nal)

{

    const uint8_t *data = nal->data;

    int length          = nal->size;

    HEVCLocalContext *lc = s->HEVClc;

    int *ret = av_malloc_array(s->sh.num_entry_point_offsets + 1, sizeof(int));

    int *arg = av_malloc_array(s->sh.num_entry_point_offsets + 1, sizeof(int));

    int64_t offset;

    int startheader, cmpt = 0;

    int i, j, res = 0;



    if (!ret || !arg) {

        av_free(ret);

        av_free(arg);

        return AVERROR(ENOMEM);

    }





    if (!s->sList[1]) {

        ff_alloc_entries(s->avctx, s->sh.num_entry_point_offsets + 1);





        for (i = 1; i < s->threads_number; i++) {

            s->sList[i] = av_malloc(sizeof(HEVCContext));

            memcpy(s->sList[i], s, sizeof(HEVCContext));

            s->HEVClcList[i] = av_mallocz(sizeof(HEVCLocalContext));

            s->sList[i]->HEVClc = s->HEVClcList[i];

        }

    }



    offset = (lc->gb.index >> 3);



    for (j = 0, cmpt = 0, startheader = offset + s->sh.entry_point_offset[0]; j < nal->skipped_bytes; j++) {

        if (nal->skipped_bytes_pos[j] >= offset && nal->skipped_bytes_pos[j] < startheader) {

            startheader--;

            cmpt++;

        }

    }



    for (i = 1; i < s->sh.num_entry_point_offsets; i++) {

        offset += (s->sh.entry_point_offset[i - 1] - cmpt);

        for (j = 0, cmpt = 0, startheader = offset

             + s->sh.entry_point_offset[i]; j < nal->skipped_bytes; j++) {

            if (nal->skipped_bytes_pos[j] >= offset && nal->skipped_bytes_pos[j] < startheader) {

                startheader--;

                cmpt++;

            }

        }

        s->sh.size[i - 1] = s->sh.entry_point_offset[i] - cmpt;

        s->sh.offset[i - 1] = offset;



    }

    if (s->sh.num_entry_point_offsets != 0) {

        offset += s->sh.entry_point_offset[s->sh.num_entry_point_offsets - 1] - cmpt;

        if (length < offset) {

            av_log(s->avctx, AV_LOG_ERROR, "entry_point_offset table is corrupted\n");

            res = AVERROR_INVALIDDATA;

            goto error;

        }

        s->sh.size[s->sh.num_entry_point_offsets - 1] = length - offset;

        s->sh.offset[s->sh.num_entry_point_offsets - 1] = offset;



    }

    s->data = data;



    for (i = 1; i < s->threads_number; i++) {

        s->sList[i]->HEVClc->first_qp_group = 1;

        s->sList[i]->HEVClc->qp_y = s->sList[0]->HEVClc->qp_y;

        memcpy(s->sList[i], s, sizeof(HEVCContext));

        s->sList[i]->HEVClc = s->HEVClcList[i];

    }



    avpriv_atomic_int_set(&s->wpp_err, 0);

    ff_reset_entries(s->avctx);



    for (i = 0; i <= s->sh.num_entry_point_offsets; i++) {

        arg[i] = i;

        ret[i] = 0;

    }



    if (s->ps.pps->entropy_coding_sync_enabled_flag)

        s->avctx->execute2(s->avctx, hls_decode_entry_wpp, arg, ret, s->sh.num_entry_point_offsets + 1);



    for (i = 0; i <= s->sh.num_entry_point_offsets; i++)

        res += ret[i];

error:

    av_free(ret);

    av_free(arg);

    return res;

}

static int hls_slice_data_wpp(HEVCContext *s, const HEVCNAL *nal)

{

    const uint8_t *data = nal->data;

    int length          = nal->size;

    HEVCLocalContext *lc = s->HEVClc;

    int *ret = av_malloc_array(s->sh.num_entry_point_offsets + 1, sizeof(int));

    int *arg = av_malloc_array(s->sh.num_entry_point_offsets + 1, sizeof(int));

    int64_t offset;

    int startheader, cmpt = 0;

    int i, j, res = 0;



    if (!ret || !arg) {

        av_free(ret);

        av_free(arg);

        return AVERROR(ENOMEM);

    }





    if (!s->sList[1]) {

        ff_alloc_entries(s->avctx, s->sh.num_entry_point_offsets + 1);





        for (i = 1; i < s->threads_number; i++) {

            s->sList[i] = av_malloc(sizeof(HEVCContext));

            memcpy(s->sList[i], s, sizeof(HEVCContext));

            s->HEVClcList[i] = av_mallocz(sizeof(HEVCLocalContext));

            s->sList[i]->HEVClc = s->HEVClcList[i];

        }

    }



    offset = (lc->gb.index >> 3);



    for (j = 0, cmpt = 0, startheader = offset + s->sh.entry_point_offset[0]; j < nal->skipped_bytes; j++) {

        if (nal->skipped_bytes_pos[j] >= offset && nal->skipped_bytes_pos[j] < startheader) {

            startheader--;

            cmpt++;

        }

    }



    for (i = 1; i < s->sh.num_entry_point_offsets; i++) {

        offset += (s->sh.entry_point_offset[i - 1] - cmpt);

        for (j = 0, cmpt = 0, startheader = offset

             + s->sh.entry_point_offset[i]; j < nal->skipped_bytes; j++) {

            if (nal->skipped_bytes_pos[j] >= offset && nal->skipped_bytes_pos[j] < startheader) {

                startheader--;

                cmpt++;

            }

        }

        s->sh.size[i - 1] = s->sh.entry_point_offset[i] - cmpt;

        s->sh.offset[i - 1] = offset;



    }

    if (s->sh.num_entry_point_offsets != 0) {

        offset += s->sh.entry_point_offset[s->sh.num_entry_point_offsets - 1] - cmpt;

        if (length < offset) {

            av_log(s->avctx, AV_LOG_ERROR, "entry_point_offset table is corrupted\n");

            res = AVERROR_INVALIDDATA;

            goto error;

        }

        s->sh.size[s->sh.num_entry_point_offsets - 1] = length - offset;

        s->sh.offset[s->sh.num_entry_point_offsets - 1] = offset;



    }

    s->data = data;



    for (i = 1; i < s->threads_number; i++) {

        s->sList[i]->HEVClc->first_qp_group = 1;

        s->sList[i]->HEVClc->qp_y = s->sList[0]->HEVClc->qp_y;

        memcpy(s->sList[i], s, sizeof(HEVCContext));

        s->sList[i]->HEVClc = s->HEVClcList[i];

    }



    avpriv_atomic_int_set(&s->wpp_err, 0);

    ff_reset_entries(s->avctx);



    for (i = 0; i <= s->sh.num_entry_point_offsets; i++) {

        arg[i] = i;

        ret[i] = 0;

    }



    if (s->ps.pps->entropy_coding_sync_enabled_flag)

        s->avctx->execute2(s->avctx, hls_decode_entry_wpp, arg, ret, s->sh.num_entry_point_offsets + 1);



    for (i = 0; i <= s->sh.num_entry_point_offsets; i++)

        res += ret[i];

error:

    av_free(ret);

    av_free(arg);

    return res;

}

static int FUNC_0(HEVCContext *VAR_0, const HEVCNAL *VAR_1)

{

    const uint8_t *VAR_2 = VAR_1->VAR_2;

    int VAR_3          = VAR_1->size;

    HEVCLocalContext *lc = VAR_0->HEVClc;

    int *VAR_4 = av_malloc_array(VAR_0->sh.num_entry_point_offsets + 1, sizeof(int));

    int *VAR_5 = av_malloc_array(VAR_0->sh.num_entry_point_offsets + 1, sizeof(int));

    int64_t offset;

    int VAR_6, VAR_7 = 0;

    int VAR_8, VAR_9, VAR_10 = 0;



    if (!VAR_4 || !VAR_5) {

        av_free(VAR_4);

        av_free(VAR_5);

        return AVERROR(ENOMEM);

    }





    if (!VAR_0->sList[1]) {

        ff_alloc_entries(VAR_0->avctx, VAR_0->sh.num_entry_point_offsets + 1);





        for (VAR_8 = 1; VAR_8 < VAR_0->threads_number; VAR_8++) {

            VAR_0->sList[VAR_8] = av_malloc(sizeof(HEVCContext));

            memcpy(VAR_0->sList[VAR_8], VAR_0, sizeof(HEVCContext));

            VAR_0->HEVClcList[VAR_8] = av_mallocz(sizeof(HEVCLocalContext));

            VAR_0->sList[VAR_8]->HEVClc = VAR_0->HEVClcList[VAR_8];

        }

    }



    offset = (lc->gb.index >> 3);



    for (VAR_9 = 0, VAR_7 = 0, VAR_6 = offset + VAR_0->sh.entry_point_offset[0]; VAR_9 < VAR_1->skipped_bytes; VAR_9++) {

        if (VAR_1->skipped_bytes_pos[VAR_9] >= offset && VAR_1->skipped_bytes_pos[VAR_9] < VAR_6) {

            VAR_6--;

            VAR_7++;

        }

    }



    for (VAR_8 = 1; VAR_8 < VAR_0->sh.num_entry_point_offsets; VAR_8++) {

        offset += (VAR_0->sh.entry_point_offset[VAR_8 - 1] - VAR_7);

        for (VAR_9 = 0, VAR_7 = 0, VAR_6 = offset

             + VAR_0->sh.entry_point_offset[VAR_8]; VAR_9 < VAR_1->skipped_bytes; VAR_9++) {

            if (VAR_1->skipped_bytes_pos[VAR_9] >= offset && VAR_1->skipped_bytes_pos[VAR_9] < VAR_6) {

                VAR_6--;

                VAR_7++;

            }

        }

        VAR_0->sh.size[VAR_8 - 1] = VAR_0->sh.entry_point_offset[VAR_8] - VAR_7;

        VAR_0->sh.offset[VAR_8 - 1] = offset;



    }

    if (VAR_0->sh.num_entry_point_offsets != 0) {

        offset += VAR_0->sh.entry_point_offset[VAR_0->sh.num_entry_point_offsets - 1] - VAR_7;

        if (VAR_3 < offset) {

            av_log(VAR_0->avctx, AV_LOG_ERROR, "entry_point_offset table is corrupted\n");

            VAR_10 = AVERROR_INVALIDDATA;

            goto error;

        }

        VAR_0->sh.size[VAR_0->sh.num_entry_point_offsets - 1] = VAR_3 - offset;

        VAR_0->sh.offset[VAR_0->sh.num_entry_point_offsets - 1] = offset;



    }

    VAR_0->VAR_2 = VAR_2;



    for (VAR_8 = 1; VAR_8 < VAR_0->threads_number; VAR_8++) {

        VAR_0->sList[VAR_8]->HEVClc->first_qp_group = 1;

        VAR_0->sList[VAR_8]->HEVClc->qp_y = VAR_0->sList[0]->HEVClc->qp_y;

        memcpy(VAR_0->sList[VAR_8], VAR_0, sizeof(HEVCContext));

        VAR_0->sList[VAR_8]->HEVClc = VAR_0->HEVClcList[VAR_8];

    }



    avpriv_atomic_int_set(&VAR_0->wpp_err, 0);

    ff_reset_entries(VAR_0->avctx);



    for (VAR_8 = 0; VAR_8 <= VAR_0->sh.num_entry_point_offsets; VAR_8++) {

        VAR_5[VAR_8] = VAR_8;

        VAR_4[VAR_8] = 0;

    }



    if (VAR_0->ps.pps->entropy_coding_sync_enabled_flag)

        VAR_0->avctx->execute2(VAR_0->avctx, hls_decode_entry_wpp, VAR_5, VAR_4, VAR_0->sh.num_entry_point_offsets + 1);



    for (VAR_8 = 0; VAR_8 <= VAR_0->sh.num_entry_point_offsets; VAR_8++)

        VAR_10 += VAR_4[VAR_8];

error:

    av_free(VAR_4);

    av_free(VAR_5);

    return VAR_10;

}

static int FUNC_0(HEVCContext *VAR_0, const HEVCNAL *VAR_1)
{ const uint8_t *VAR_2 = VAR_1->VAR_2; int VAR_3          = VAR_1->size; HEVCLocalContext *lc = VAR_0->HEVClc; int *VAR_4 = av_malloc_array(VAR_0->sh.num_entry_point_offsets + 1, sizeof(int)); int *VAR_5 = av_malloc_array(VAR_0->sh.num_entry_point_offsets + 1, sizeof(int)); int64_t offset; int VAR_6, VAR_7 = 0; int VAR_8, VAR_9, VAR_10 = 0; if (!VAR_4 || !VAR_5) { av_free(VAR_4); av_free(VAR_5); return AVERROR(ENOMEM); } if (!VAR_0->sList[1]) { ff_alloc_entries(VAR_0->avctx, VAR_0->sh.num_entry_point_offsets + 1); for (VAR_8 = 1; VAR_8 < VAR_0->threads_number; VAR_8++) { VAR_0->sList[VAR_8] = av_malloc(sizeof(HEVCContext)); memcpy(VAR_0->sList[VAR_8], VAR_0, sizeof(HEVCContext)); VAR_0->HEVClcList[VAR_8] = av_mallocz(sizeof(HEVCLocalContext)); VAR_0->sList[VAR_8]->HEVClc = VAR_0->HEVClcList[VAR_8]; } } offset = (lc->gb.index >> 3); for (VAR_9 = 0, VAR_7 = 0, VAR_6 = offset + VAR_0->sh.entry_point_offset[0]; VAR_9 < VAR_1->skipped_bytes; VAR_9++) { if (VAR_1->skipped_bytes_pos[VAR_9] >= offset && VAR_1->skipped_bytes_pos[VAR_9] < VAR_6) { VAR_6--; VAR_7++; } } for (VAR_8 = 1; VAR_8 < VAR_0->sh.num_entry_point_offsets; VAR_8++) { offset += (VAR_0->sh.entry_point_offset[VAR_8 - 1] - VAR_7); for (VAR_9 = 0, VAR_7 = 0, VAR_6 = offset
+ VAR_0->sh.entry_point_offset[VAR_8]; VAR_9 < VAR_1->skipped_bytes; VAR_9++) { if (VAR_1->skipped_bytes_pos[VAR_9] >= offset && VAR_1->skipped_bytes_pos[VAR_9] < VAR_6) { VAR_6--; VAR_7++; } } VAR_0->sh.size[VAR_8 - 1] = VAR_0->sh.entry_point_offset[VAR_8] - VAR_7; VAR_0->sh.offset[VAR_8 - 1] = offset; } if (VAR_0->sh.num_entry_point_offsets != 0) { offset += VAR_0->sh.entry_point_offset[VAR_0->sh.num_entry_point_offsets - 1] - VAR_7; if (VAR_3 < offset) { av_log(VAR_0->avctx, AV_LOG_ERROR, "entry_point_offset table is corrupted\n"); VAR_10 = AVERROR_INVALIDDATA; goto error; } VAR_0->sh.size[VAR_0->sh.num_entry_point_offsets - 1] = VAR_3 - offset; VAR_0->sh.offset[VAR_0->sh.num_entry_point_offsets - 1] = offset; } VAR_0->VAR_2 = VAR_2; for (VAR_8 = 1; VAR_8 < VAR_0->threads_number; VAR_8++) { VAR_0->sList[VAR_8]->HEVClc->first_qp_group = 1; VAR_0->sList[VAR_8]->HEVClc->qp_y = VAR_0->sList[0]->HEVClc->qp_y; memcpy(VAR_0->sList[VAR_8], VAR_0, sizeof(HEVCContext)); VAR_0->sList[VAR_8]->HEVClc = VAR_0->HEVClcList[VAR_8]; } avpriv_atomic_int_set(&VAR_0->wpp_err, 0); ff_reset_entries(VAR_0->avctx); for (VAR_8 = 0; VAR_8 <= VAR_0->sh.num_entry_point_offsets; VAR_8++) { VAR_5[VAR_8] = VAR_8; VAR_4[VAR_8] = 0; } if (VAR_0->ps.pps->entropy_coding_sync_enabled_flag)
VAR_0->avctx->execute2(VAR_0->avctx, hls_decode_entry_wpp, VAR_5, VAR_4, VAR_0->sh.num_entry_point_offsets + 1); for (VAR_8 = 0; VAR_8 <= VAR_0->sh.num_entry_point_offsets; VAR_8++) VAR_10 += VAR_4[VAR_8]; error:
av_free(VAR_4); av_free(VAR_5); return VAR_10; }