static int read_sl_header(PESContext *pes, SLConfigDescr *sl, const uint8_t *buf, int buf_size)

{

    GetBitContext gb;

    int au_start_flag = 0, au_end_flag = 0, ocr_flag = 0, idle_flag = 0;

    int padding_flag = 0, padding_bits = 0, inst_bitrate_flag = 0;

    int dts_flag = -1, cts_flag = -1;

    int64_t dts = AV_NOPTS_VALUE, cts = AV_NOPTS_VALUE;

    init_get_bits(&gb, buf, buf_size*8);



    if (sl->use_au_start)

        au_start_flag = get_bits1(&gb);

    if (sl->use_au_end)

        au_end_flag = get_bits1(&gb);

    if (!sl->use_au_start && !sl->use_au_end)

        au_start_flag = au_end_flag = 1;

    if (sl->ocr_len > 0)

        ocr_flag = get_bits1(&gb);

    if (sl->use_idle)

        idle_flag = get_bits1(&gb);

    if (sl->use_padding)

        padding_flag = get_bits1(&gb);

    if (padding_flag)

        padding_bits = get_bits(&gb, 3);



    if (!idle_flag && (!padding_flag || padding_bits != 0)) {

        if (sl->packet_seq_num_len)

            skip_bits_long(&gb, sl->packet_seq_num_len);

        if (sl->degr_prior_len)

            if (get_bits1(&gb))

                skip_bits(&gb, sl->degr_prior_len);

        if (ocr_flag)

            skip_bits_long(&gb, sl->ocr_len);

        if (au_start_flag) {

            if (sl->use_rand_acc_pt)

                get_bits1(&gb);

            if (sl->au_seq_num_len > 0)

                skip_bits_long(&gb, sl->au_seq_num_len);

            if (sl->use_timestamps) {

                dts_flag = get_bits1(&gb);

                cts_flag = get_bits1(&gb);

            }

        }

        if (sl->inst_bitrate_len)

            inst_bitrate_flag = get_bits1(&gb);

        if (dts_flag == 1)

            dts = get_bits64(&gb, sl->timestamp_len);

        if (cts_flag == 1)

            cts = get_bits64(&gb, sl->timestamp_len);

        if (sl->au_len > 0)

            skip_bits_long(&gb, sl->au_len);

        if (inst_bitrate_flag)

            skip_bits_long(&gb, sl->inst_bitrate_len);

    }



    if (dts != AV_NOPTS_VALUE)

        pes->dts = dts;

    if (cts != AV_NOPTS_VALUE)

        pes->pts = cts;



    avpriv_set_pts_info(pes->st, sl->timestamp_len, 1, sl->timestamp_res);



    return (get_bits_count(&gb) + 7) >> 3;

}

static int read_sl_header(PESContext *pes, SLConfigDescr *sl, const uint8_t *buf, int buf_size)

{

    GetBitContext gb;

    int au_start_flag = 0, au_end_flag = 0, ocr_flag = 0, idle_flag = 0;

    int padding_flag = 0, padding_bits = 0, inst_bitrate_flag = 0;

    int dts_flag = -1, cts_flag = -1;

    int64_t dts = AV_NOPTS_VALUE, cts = AV_NOPTS_VALUE;

    init_get_bits(&gb, buf, buf_size*8);



    if (sl->use_au_start)

        au_start_flag = get_bits1(&gb);

    if (sl->use_au_end)

        au_end_flag = get_bits1(&gb);

    if (!sl->use_au_start && !sl->use_au_end)

        au_start_flag = au_end_flag = 1;

    if (sl->ocr_len > 0)

        ocr_flag = get_bits1(&gb);

    if (sl->use_idle)

        idle_flag = get_bits1(&gb);

    if (sl->use_padding)

        padding_flag = get_bits1(&gb);

    if (padding_flag)

        padding_bits = get_bits(&gb, 3);



    if (!idle_flag && (!padding_flag || padding_bits != 0)) {

        if (sl->packet_seq_num_len)

            skip_bits_long(&gb, sl->packet_seq_num_len);

        if (sl->degr_prior_len)

            if (get_bits1(&gb))

                skip_bits(&gb, sl->degr_prior_len);

        if (ocr_flag)

            skip_bits_long(&gb, sl->ocr_len);

        if (au_start_flag) {

            if (sl->use_rand_acc_pt)

                get_bits1(&gb);

            if (sl->au_seq_num_len > 0)

                skip_bits_long(&gb, sl->au_seq_num_len);

            if (sl->use_timestamps) {

                dts_flag = get_bits1(&gb);

                cts_flag = get_bits1(&gb);

            }

        }

        if (sl->inst_bitrate_len)

            inst_bitrate_flag = get_bits1(&gb);

        if (dts_flag == 1)

            dts = get_bits64(&gb, sl->timestamp_len);

        if (cts_flag == 1)

            cts = get_bits64(&gb, sl->timestamp_len);

        if (sl->au_len > 0)

            skip_bits_long(&gb, sl->au_len);

        if (inst_bitrate_flag)

            skip_bits_long(&gb, sl->inst_bitrate_len);

    }



    if (dts != AV_NOPTS_VALUE)

        pes->dts = dts;

    if (cts != AV_NOPTS_VALUE)

        pes->pts = cts;



    avpriv_set_pts_info(pes->st, sl->timestamp_len, 1, sl->timestamp_res);



    return (get_bits_count(&gb) + 7) >> 3;

}

static int FUNC_0(PESContext *VAR_0, SLConfigDescr *VAR_1, const uint8_t *VAR_2, int VAR_3)

{

    GetBitContext gb;

    int VAR_4 = 0, VAR_5 = 0, VAR_6 = 0, VAR_7 = 0;

    int VAR_8 = 0, VAR_9 = 0, VAR_10 = 0;

    int VAR_11 = -1, VAR_12 = -1;

    int64_t dts = AV_NOPTS_VALUE, cts = AV_NOPTS_VALUE;

    init_get_bits(&gb, VAR_2, VAR_3*8);



    if (VAR_1->use_au_start)

        VAR_4 = get_bits1(&gb);

    if (VAR_1->use_au_end)

        VAR_5 = get_bits1(&gb);

    if (!VAR_1->use_au_start && !VAR_1->use_au_end)

        VAR_4 = VAR_5 = 1;

    if (VAR_1->ocr_len > 0)

        VAR_6 = get_bits1(&gb);

    if (VAR_1->use_idle)

        VAR_7 = get_bits1(&gb);

    if (VAR_1->use_padding)

        VAR_8 = get_bits1(&gb);

    if (VAR_8)

        VAR_9 = get_bits(&gb, 3);



    if (!VAR_7 && (!VAR_8 || VAR_9 != 0)) {

        if (VAR_1->packet_seq_num_len)

            skip_bits_long(&gb, VAR_1->packet_seq_num_len);

        if (VAR_1->degr_prior_len)

            if (get_bits1(&gb))

                skip_bits(&gb, VAR_1->degr_prior_len);

        if (VAR_6)

            skip_bits_long(&gb, VAR_1->ocr_len);

        if (VAR_4) {

            if (VAR_1->use_rand_acc_pt)

                get_bits1(&gb);

            if (VAR_1->au_seq_num_len > 0)

                skip_bits_long(&gb, VAR_1->au_seq_num_len);

            if (VAR_1->use_timestamps) {

                VAR_11 = get_bits1(&gb);

                VAR_12 = get_bits1(&gb);

            }

        }

        if (VAR_1->inst_bitrate_len)

            VAR_10 = get_bits1(&gb);

        if (VAR_11 == 1)

            dts = get_bits64(&gb, VAR_1->timestamp_len);

        if (VAR_12 == 1)

            cts = get_bits64(&gb, VAR_1->timestamp_len);

        if (VAR_1->au_len > 0)

            skip_bits_long(&gb, VAR_1->au_len);

        if (VAR_10)

            skip_bits_long(&gb, VAR_1->inst_bitrate_len);

    }



    if (dts != AV_NOPTS_VALUE)

        VAR_0->dts = dts;

    if (cts != AV_NOPTS_VALUE)

        VAR_0->pts = cts;



    avpriv_set_pts_info(VAR_0->st, VAR_1->timestamp_len, 1, VAR_1->timestamp_res);



    return (get_bits_count(&gb) + 7) >> 3;

}

static int FUNC_0(PESContext *VAR_0, SLConfigDescr *VAR_1, const uint8_t *VAR_2, int VAR_3)
{ GetBitContext gb; int VAR_4 = 0, VAR_5 = 0, VAR_6 = 0, VAR_7 = 0; int VAR_8 = 0, VAR_9 = 0, VAR_10 = 0; int VAR_11 = -1, VAR_12 = -1; int64_t dts = AV_NOPTS_VALUE, cts = AV_NOPTS_VALUE; init_get_bits(&gb, VAR_2, VAR_3*8); if (VAR_1->use_au_start)
VAR_4 = get_bits1(&gb); if (VAR_1->use_au_end)
VAR_5 = get_bits1(&gb); if (!VAR_1->use_au_start && !VAR_1->use_au_end)
VAR_4 = VAR_5 = 1; if (VAR_1->ocr_len > 0)
VAR_6 = get_bits1(&gb); if (VAR_1->use_idle)
VAR_7 = get_bits1(&gb); if (VAR_1->use_padding)
VAR_8 = get_bits1(&gb); if (VAR_8)
VAR_9 = get_bits(&gb, 3); if (!VAR_7 && (!VAR_8 || VAR_9 != 0)) { if (VAR_1->packet_seq_num_len)
skip_bits_long(&gb, VAR_1->packet_seq_num_len); if (VAR_1->degr_prior_len)
if (get_bits1(&gb))
skip_bits(&gb, VAR_1->degr_prior_len); if (VAR_6)
skip_bits_long(&gb, VAR_1->ocr_len); if (VAR_4) { if (VAR_1->use_rand_acc_pt)
get_bits1(&gb); if (VAR_1->au_seq_num_len > 0)
skip_bits_long(&gb, VAR_1->au_seq_num_len); if (VAR_1->use_timestamps) { VAR_11 = get_bits1(&gb); VAR_12 = get_bits1(&gb); } } if (VAR_1->inst_bitrate_len)
VAR_10 = get_bits1(&gb); if (VAR_11 == 1)
dts = get_bits64(&gb, VAR_1->timestamp_len); if (VAR_12 == 1)
cts = get_bits64(&gb, VAR_1->timestamp_len); if (VAR_1->au_len > 0)
skip_bits_long(&gb, VAR_1->au_len); if (VAR_10)
skip_bits_long(&gb, VAR_1->inst_bitrate_len); } if (dts != AV_NOPTS_VALUE)
VAR_0->dts = dts; if (cts != AV_NOPTS_VALUE)
VAR_0->pts = cts; avpriv_set_pts_info(VAR_0->st, VAR_1->timestamp_len, 1, VAR_1->timestamp_res); return (get_bits_count(&gb) + 7) >> 3; }