static int asf_read_simple_index(AVFormatContext *s, const GUIDParseTable *g)

{

    ASFContext *asf = s->priv_data;

    AVIOContext *pb = s->pb;

    AVStream *st    = NULL;

    uint64_t interval; // index entry time interval in 100 ns units, usually it's 1s

    uint32_t pkt_num, nb_entries;

    int32_t prev_pkt_num = -1;

    int i, ret;

    uint64_t size = avio_rl64(pb);



    // simple index objects should be ordered by stream number, this loop tries to find

    // the first not indexed video stream

    for (i = 0; i < asf->nb_streams; i++) {

        if ((asf->asf_st[i]->type == AVMEDIA_TYPE_VIDEO) && !asf->asf_st[i]->indexed) {

            asf->asf_st[i]->indexed = 1;

            st = s->streams[asf->asf_st[i]->index];

            break;

        }

    }

    if (!st) {

        avio_skip(pb, size - 24); // if there's no video stream, skip index object

        return 0;

    }

    avio_skip(pb, 16); // skip File ID

    interval = avio_rl64(pb);

    avio_skip(pb, 4);

    nb_entries = avio_rl32(pb);

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

        pkt_num = avio_rl32(pb);

        ret = avio_skip(pb, 2);

        if (ret < 0) {

            av_log(s, AV_LOG_ERROR, "Skipping failed in asf_read_simple_index.\n");

            return ret;

        }

        if (prev_pkt_num != pkt_num) {

            av_add_index_entry(st, asf->first_packet_offset + asf->packet_size *

                               pkt_num, av_rescale(interval, i, 10000),

                               asf->packet_size, 0, AVINDEX_KEYFRAME);

            prev_pkt_num = pkt_num;

        }

    }

    asf->is_simple_index = 1;

    align_position(pb, asf->offset, size);



    return 0;

}

static int asf_read_simple_index(AVFormatContext *s, const GUIDParseTable *g)

{

    ASFContext *asf = s->priv_data;

    AVIOContext *pb = s->pb;

    AVStream *st    = NULL;

    uint64_t interval; 

    uint32_t pkt_num, nb_entries;

    int32_t prev_pkt_num = -1;

    int i, ret;

    uint64_t size = avio_rl64(pb);



    

    

    for (i = 0; i < asf->nb_streams; i++) {

        if ((asf->asf_st[i]->type == AVMEDIA_TYPE_VIDEO) && !asf->asf_st[i]->indexed) {

            asf->asf_st[i]->indexed = 1;

            st = s->streams[asf->asf_st[i]->index];

            break;

        }

    }

    if (!st) {

        avio_skip(pb, size - 24); 

        return 0;

    }

    avio_skip(pb, 16); 

    interval = avio_rl64(pb);

    avio_skip(pb, 4);

    nb_entries = avio_rl32(pb);

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

        pkt_num = avio_rl32(pb);

        ret = avio_skip(pb, 2);

        if (ret < 0) {

            av_log(s, AV_LOG_ERROR, "Skipping failed in asf_read_simple_index.\n");

            return ret;

        }

        if (prev_pkt_num != pkt_num) {

            av_add_index_entry(st, asf->first_packet_offset + asf->packet_size *

                               pkt_num, av_rescale(interval, i, 10000),

                               asf->packet_size, 0, AVINDEX_KEYFRAME);

            prev_pkt_num = pkt_num;

        }

    }

    asf->is_simple_index = 1;

    align_position(pb, asf->offset, size);



    return 0;

}

    int i, ret;         ret = avio_skip(pb, 2);         if (ret < 0) {             return ret;
static int FUNC_0(AVFormatContext *VAR_0, const GUIDParseTable *VAR_1)

{

    ASFContext *asf = VAR_0->priv_data;

    AVIOContext *pb = VAR_0->pb;

    AVStream *st    = NULL;

    uint64_t interval; 

    uint32_t pkt_num, nb_entries;

    int32_t prev_pkt_num = -1;

    int VAR_2, VAR_3;

    uint64_t size = avio_rl64(pb);



    

    

    for (VAR_2 = 0; VAR_2 < asf->nb_streams; VAR_2++) {

        if ((asf->asf_st[VAR_2]->type == AVMEDIA_TYPE_VIDEO) && !asf->asf_st[VAR_2]->indexed) {

            asf->asf_st[VAR_2]->indexed = 1;

            st = VAR_0->streams[asf->asf_st[VAR_2]->index];

            break;

        }

    }

    if (!st) {

        avio_skip(pb, size - 24); 

        return 0;

    }

    avio_skip(pb, 16); 

    interval = avio_rl64(pb);

    avio_skip(pb, 4);

    nb_entries = avio_rl32(pb);

    for (VAR_2 = 0; VAR_2 < nb_entries; VAR_2++) {

        pkt_num = avio_rl32(pb);

        VAR_3 = avio_skip(pb, 2);

        if (VAR_3 < 0) {

            av_log(VAR_0, AV_LOG_ERROR, "Skipping failed in FUNC_0.\n");

            return VAR_3;

        }

        if (prev_pkt_num != pkt_num) {

            av_add_index_entry(st, asf->first_packet_offset + asf->packet_size *

                               pkt_num, av_rescale(interval, VAR_2, 10000),

                               asf->packet_size, 0, AVINDEX_KEYFRAME);

            prev_pkt_num = pkt_num;

        }

    }

    asf->is_simple_index = 1;

    align_position(pb, asf->offset, size);



    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0, const GUIDParseTable *VAR_1)
{ ASFContext *asf = VAR_0->priv_data; AVIOContext *pb = VAR_0->pb; AVStream *st    = NULL; uint64_t interval; uint32_t pkt_num, nb_entries; int32_t prev_pkt_num = -1; int VAR_2, VAR_3; uint64_t size = avio_rl64(pb); for (VAR_2 = 0; VAR_2 < asf->nb_streams; VAR_2++) { if ((asf->asf_st[VAR_2]->type == AVMEDIA_TYPE_VIDEO) && !asf->asf_st[VAR_2]->indexed) { asf->asf_st[VAR_2]->indexed = 1; st = VAR_0->streams[asf->asf_st[VAR_2]->index]; break; } } if (!st) { avio_skip(pb, size - 24); return 0; } avio_skip(pb, 16); interval = avio_rl64(pb); avio_skip(pb, 4); nb_entries = avio_rl32(pb); for (VAR_2 = 0; VAR_2 < nb_entries; VAR_2++) { pkt_num = avio_rl32(pb); VAR_3 = avio_skip(pb, 2); if (VAR_3 < 0) { av_log(VAR_0, AV_LOG_ERROR, "Skipping failed in FUNC_0.\n"); return VAR_3; } if (prev_pkt_num != pkt_num) { av_add_index_entry(st, asf->first_packet_offset + asf->packet_size *
pkt_num, av_rescale(interval, VAR_2, 10000),
asf->packet_size, 0, AVINDEX_KEYFRAME); prev_pkt_num = pkt_num; } } asf->is_simple_index = 1; align_position(pb, asf->offset, size); return 0; }