static int decode_buffering_period(H264Context *h)

{

    unsigned int sps_id;

    int sched_sel_idx;

    SPS *sps;



    sps_id = get_ue_golomb_31(&h->gb);

    if (sps_id > 31 || !h->sps_buffers[sps_id]) {

        av_log(h->avctx, AV_LOG_ERROR,

               "non-existing SPS %d referenced in buffering period\n", sps_id);

        return AVERROR_INVALIDDATA;

    }

    sps = h->sps_buffers[sps_id];



    // NOTE: This is really so duplicated in the standard... See H.264, D.1.1

    if (sps->nal_hrd_parameters_present_flag) {

        for (sched_sel_idx = 0; sched_sel_idx < sps->cpb_cnt; sched_sel_idx++) {

            h->initial_cpb_removal_delay[sched_sel_idx] =

                get_bits(&h->gb, sps->initial_cpb_removal_delay_length);

            // initial_cpb_removal_delay_offset

            skip_bits(&h->gb, sps->initial_cpb_removal_delay_length);

        }

    }

    if (sps->vcl_hrd_parameters_present_flag) {

        for (sched_sel_idx = 0; sched_sel_idx < sps->cpb_cnt; sched_sel_idx++) {

            h->initial_cpb_removal_delay[sched_sel_idx] =

                get_bits(&h->gb, sps->initial_cpb_removal_delay_length);

            // initial_cpb_removal_delay_offset

            skip_bits(&h->gb, sps->initial_cpb_removal_delay_length);

        }

    }



    h->sei_buffering_period_present = 1;

    return 0;

}

static int decode_buffering_period(H264Context *h)

{

    unsigned int sps_id;

    int sched_sel_idx;

    SPS *sps;



    sps_id = get_ue_golomb_31(&h->gb);

    if (sps_id > 31 || !h->sps_buffers[sps_id]) {

        av_log(h->avctx, AV_LOG_ERROR,

               "non-existing SPS %d referenced in buffering period\n", sps_id);

        return AVERROR_INVALIDDATA;

    }

    sps = h->sps_buffers[sps_id];



    

    if (sps->nal_hrd_parameters_present_flag) {

        for (sched_sel_idx = 0; sched_sel_idx < sps->cpb_cnt; sched_sel_idx++) {

            h->initial_cpb_removal_delay[sched_sel_idx] =

                get_bits(&h->gb, sps->initial_cpb_removal_delay_length);

            

            skip_bits(&h->gb, sps->initial_cpb_removal_delay_length);

        }

    }

    if (sps->vcl_hrd_parameters_present_flag) {

        for (sched_sel_idx = 0; sched_sel_idx < sps->cpb_cnt; sched_sel_idx++) {

            h->initial_cpb_removal_delay[sched_sel_idx] =

                get_bits(&h->gb, sps->initial_cpb_removal_delay_length);

            

            skip_bits(&h->gb, sps->initial_cpb_removal_delay_length);

        }

    }



    h->sei_buffering_period_present = 1;

    return 0;

}

static int FUNC_0(H264Context *VAR_0)

{

    unsigned int VAR_1;

    int VAR_2;

    SPS *sps;



    VAR_1 = get_ue_golomb_31(&VAR_0->gb);

    if (VAR_1 > 31 || !VAR_0->sps_buffers[VAR_1]) {

        av_log(VAR_0->avctx, AV_LOG_ERROR,

               "non-existing SPS %d referenced in buffering period\n", VAR_1);

        return AVERROR_INVALIDDATA;

    }

    sps = VAR_0->sps_buffers[VAR_1];



    

    if (sps->nal_hrd_parameters_present_flag) {

        for (VAR_2 = 0; VAR_2 < sps->cpb_cnt; VAR_2++) {

            VAR_0->initial_cpb_removal_delay[VAR_2] =

                get_bits(&VAR_0->gb, sps->initial_cpb_removal_delay_length);

            

            skip_bits(&VAR_0->gb, sps->initial_cpb_removal_delay_length);

        }

    }

    if (sps->vcl_hrd_parameters_present_flag) {

        for (VAR_2 = 0; VAR_2 < sps->cpb_cnt; VAR_2++) {

            VAR_0->initial_cpb_removal_delay[VAR_2] =

                get_bits(&VAR_0->gb, sps->initial_cpb_removal_delay_length);

            

            skip_bits(&VAR_0->gb, sps->initial_cpb_removal_delay_length);

        }

    }



    VAR_0->sei_buffering_period_present = 1;

    return 0;

}

static int FUNC_0(H264Context *VAR_0)
{ unsigned int VAR_1; int VAR_2; SPS *sps; VAR_1 = get_ue_golomb_31(&VAR_0->gb); if (VAR_1 > 31 || !VAR_0->sps_buffers[VAR_1]) { av_log(VAR_0->avctx, AV_LOG_ERROR,
"non-existing SPS %d referenced in buffering period\n", VAR_1); return AVERROR_INVALIDDATA; } sps = VAR_0->sps_buffers[VAR_1]; if (sps->nal_hrd_parameters_present_flag) { for (VAR_2 = 0; VAR_2 < sps->cpb_cnt; VAR_2++) { VAR_0->initial_cpb_removal_delay[VAR_2] =
get_bits(&VAR_0->gb, sps->initial_cpb_removal_delay_length); skip_bits(&VAR_0->gb, sps->initial_cpb_removal_delay_length); } } if (sps->vcl_hrd_parameters_present_flag) { for (VAR_2 = 0; VAR_2 < sps->cpb_cnt; VAR_2++) { VAR_0->initial_cpb_removal_delay[VAR_2] =
get_bits(&VAR_0->gb, sps->initial_cpb_removal_delay_length); skip_bits(&VAR_0->gb, sps->initial_cpb_removal_delay_length); } } VAR_0->sei_buffering_period_present = 1; return 0; }