static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, GetBitContext *gb)

{

    const HEVCSPS *sps = s->ps.sps;

    int max_poc_lsb    = 1 << sps->log2_max_poc_lsb;

    int prev_delta_msb = 0;

    unsigned int nb_sps = 0, nb_sh;

    int i;



    rps->nb_refs = 0;

    if (!sps->long_term_ref_pics_present_flag)

        return 0;



    if (sps->num_long_term_ref_pics_sps > 0)

        nb_sps = get_ue_golomb_long(gb);

    nb_sh = get_ue_golomb_long(gb);



    if (nb_sps > sps->num_long_term_ref_pics_sps)

        return AVERROR_INVALIDDATA;

    if (nb_sh + (uint64_t)nb_sps > FF_ARRAY_ELEMS(rps->poc))

        return AVERROR_INVALIDDATA;



    rps->nb_refs = nb_sh + nb_sps;



    for (i = 0; i < rps->nb_refs; i++) {

        uint8_t delta_poc_msb_present;



        if (i < nb_sps) {

            uint8_t lt_idx_sps = 0;



            if (sps->num_long_term_ref_pics_sps > 1)

                lt_idx_sps = get_bits(gb, av_ceil_log2(sps->num_long_term_ref_pics_sps));



            rps->poc[i]  = sps->lt_ref_pic_poc_lsb_sps[lt_idx_sps];

            rps->used[i] = sps->used_by_curr_pic_lt_sps_flag[lt_idx_sps];

        } else {

            rps->poc[i]  = get_bits(gb, sps->log2_max_poc_lsb);

            rps->used[i] = get_bits1(gb);

        }



        delta_poc_msb_present = get_bits1(gb);

        if (delta_poc_msb_present) {

            int delta = get_ue_golomb_long(gb);



            if (i && i != nb_sps)

                delta += prev_delta_msb;



            rps->poc[i] += s->poc - delta * max_poc_lsb - s->sh.pic_order_cnt_lsb;

            prev_delta_msb = delta;

        }

    }



    return 0;

}

static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, GetBitContext *gb)

{

    const HEVCSPS *sps = s->ps.sps;

    int max_poc_lsb    = 1 << sps->log2_max_poc_lsb;

    int prev_delta_msb = 0;

    unsigned int nb_sps = 0, nb_sh;

    int i;



    rps->nb_refs = 0;

    if (!sps->long_term_ref_pics_present_flag)

        return 0;



    if (sps->num_long_term_ref_pics_sps > 0)

        nb_sps = get_ue_golomb_long(gb);

    nb_sh = get_ue_golomb_long(gb);



    if (nb_sps > sps->num_long_term_ref_pics_sps)

        return AVERROR_INVALIDDATA;

    if (nb_sh + (uint64_t)nb_sps > FF_ARRAY_ELEMS(rps->poc))

        return AVERROR_INVALIDDATA;



    rps->nb_refs = nb_sh + nb_sps;



    for (i = 0; i < rps->nb_refs; i++) {

        uint8_t delta_poc_msb_present;



        if (i < nb_sps) {

            uint8_t lt_idx_sps = 0;



            if (sps->num_long_term_ref_pics_sps > 1)

                lt_idx_sps = get_bits(gb, av_ceil_log2(sps->num_long_term_ref_pics_sps));



            rps->poc[i]  = sps->lt_ref_pic_poc_lsb_sps[lt_idx_sps];

            rps->used[i] = sps->used_by_curr_pic_lt_sps_flag[lt_idx_sps];

        } else {

            rps->poc[i]  = get_bits(gb, sps->log2_max_poc_lsb);

            rps->used[i] = get_bits1(gb);

        }



        delta_poc_msb_present = get_bits1(gb);

        if (delta_poc_msb_present) {

            int delta = get_ue_golomb_long(gb);



            if (i && i != nb_sps)

                delta += prev_delta_msb;



            rps->poc[i] += s->poc - delta * max_poc_lsb - s->sh.pic_order_cnt_lsb;

            prev_delta_msb = delta;

        }

    }



    return 0;

}

            int delta = get_ue_golomb_long(gb);             rps->poc[i] += s->poc - delta * max_poc_lsb - s->sh.pic_order_cnt_lsb;
static int FUNC_0(HEVCContext *VAR_0, LongTermRPS *VAR_1, GetBitContext *VAR_2)

{

    const HEVCSPS *VAR_3 = VAR_0->ps.VAR_3;

    int VAR_4    = 1 << VAR_3->log2_max_poc_lsb;

    int VAR_5 = 0;

    unsigned int VAR_6 = 0, VAR_7;

    int VAR_8;



    VAR_1->nb_refs = 0;

    if (!VAR_3->long_term_ref_pics_present_flag)

        return 0;



    if (VAR_3->num_long_term_ref_pics_sps > 0)

        VAR_6 = get_ue_golomb_long(VAR_2);

    VAR_7 = get_ue_golomb_long(VAR_2);



    if (VAR_6 > VAR_3->num_long_term_ref_pics_sps)

        return AVERROR_INVALIDDATA;

    if (VAR_7 + (uint64_t)VAR_6 > FF_ARRAY_ELEMS(VAR_1->poc))

        return AVERROR_INVALIDDATA;



    VAR_1->nb_refs = VAR_7 + VAR_6;



    for (VAR_8 = 0; VAR_8 < VAR_1->nb_refs; VAR_8++) {

        uint8_t delta_poc_msb_present;



        if (VAR_8 < VAR_6) {

            uint8_t lt_idx_sps = 0;



            if (VAR_3->num_long_term_ref_pics_sps > 1)

                lt_idx_sps = get_bits(VAR_2, av_ceil_log2(VAR_3->num_long_term_ref_pics_sps));



            VAR_1->poc[VAR_8]  = VAR_3->lt_ref_pic_poc_lsb_sps[lt_idx_sps];

            VAR_1->used[VAR_8] = VAR_3->used_by_curr_pic_lt_sps_flag[lt_idx_sps];

        } else {

            VAR_1->poc[VAR_8]  = get_bits(VAR_2, VAR_3->log2_max_poc_lsb);

            VAR_1->used[VAR_8] = get_bits1(VAR_2);

        }



        delta_poc_msb_present = get_bits1(VAR_2);

        if (delta_poc_msb_present) {

            int delta = get_ue_golomb_long(VAR_2);



            if (VAR_8 && VAR_8 != VAR_6)

                delta += VAR_5;



            VAR_1->poc[VAR_8] += VAR_0->poc - delta * VAR_4 - VAR_0->sh.pic_order_cnt_lsb;

            VAR_5 = delta;

        }

    }



    return 0;

}

static int FUNC_0(HEVCContext *VAR_0, LongTermRPS *VAR_1, GetBitContext *VAR_2)
{ const HEVCSPS *VAR_3 = VAR_0->ps.VAR_3; int VAR_4    = 1 << VAR_3->log2_max_poc_lsb; int VAR_5 = 0; unsigned int VAR_6 = 0, VAR_7; int VAR_8; VAR_1->nb_refs = 0; if (!VAR_3->long_term_ref_pics_present_flag)
return 0; if (VAR_3->num_long_term_ref_pics_sps > 0)
VAR_6 = get_ue_golomb_long(VAR_2); VAR_7 = get_ue_golomb_long(VAR_2); if (VAR_6 > VAR_3->num_long_term_ref_pics_sps)
return AVERROR_INVALIDDATA; if (VAR_7 + (uint64_t)VAR_6 > FF_ARRAY_ELEMS(VAR_1->poc))
return AVERROR_INVALIDDATA; VAR_1->nb_refs = VAR_7 + VAR_6; for (VAR_8 = 0; VAR_8 < VAR_1->nb_refs; VAR_8++) { uint8_t delta_poc_msb_present; if (VAR_8 < VAR_6) { uint8_t lt_idx_sps = 0; if (VAR_3->num_long_term_ref_pics_sps > 1)
lt_idx_sps = get_bits(VAR_2, av_ceil_log2(VAR_3->num_long_term_ref_pics_sps)); VAR_1->poc[VAR_8]  = VAR_3->lt_ref_pic_poc_lsb_sps[lt_idx_sps]; VAR_1->used[VAR_8] = VAR_3->used_by_curr_pic_lt_sps_flag[lt_idx_sps]; } else { VAR_1->poc[VAR_8]  = get_bits(VAR_2, VAR_3->log2_max_poc_lsb); VAR_1->used[VAR_8] = get_bits1(VAR_2); } delta_poc_msb_present = get_bits1(VAR_2); if (delta_poc_msb_present) { int delta = get_ue_golomb_long(VAR_2); if (VAR_8 && VAR_8 != VAR_6)
delta += VAR_5; VAR_1->poc[VAR_8] += VAR_0->poc - delta * VAR_4 - VAR_0->sh.pic_order_cnt_lsb; VAR_5 = delta; } } return 0; }