static int asf_read_seek(AVFormatContext *s, int stream_index,

                         int64_t pts, int flags)

{

    ASFContext *asf = s->priv_data;

    AVStream *st    = s->streams[stream_index];

    int64_t pos;

    int index;



    if (s->packet_size <= 0)

        return -1;



    /* Try using the protocol's read_seek if available */

    if (s->pb) {

        int ret = avio_seek_time(s->pb, stream_index, pts, flags);

        if (ret >= 0)

            asf_reset_header(s);

        if (ret != AVERROR(ENOSYS))

            return ret;

    }



    if (!asf->index_read)

        asf_build_simple_index(s, stream_index);



    if ((asf->index_read && st->index_entries)) {

        index = av_index_search_timestamp(st, pts, flags);

        if (index >= 0) {

            /* find the position */

            pos = st->index_entries[index].pos;



            /* do the seek */

            av_log(s, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", pos);

            avio_seek(s->pb, pos, SEEK_SET);

            asf_reset_header(s);

            return 0;

        }

    }

    /* no index or seeking by index failed */

    if (ff_seek_frame_binary(s, stream_index, pts, flags) < 0)

        return -1;

    asf_reset_header(s);

    return 0;

}

static int asf_read_seek(AVFormatContext *s, int stream_index,

                         int64_t pts, int flags)

{

    ASFContext *asf = s->priv_data;

    AVStream *st    = s->streams[stream_index];

    int64_t pos;

    int index;



    if (s->packet_size <= 0)

        return -1;



    

    if (s->pb) {

        int ret = avio_seek_time(s->pb, stream_index, pts, flags);

        if (ret >= 0)

            asf_reset_header(s);

        if (ret != AVERROR(ENOSYS))

            return ret;

    }



    if (!asf->index_read)

        asf_build_simple_index(s, stream_index);



    if ((asf->index_read && st->index_entries)) {

        index = av_index_search_timestamp(st, pts, flags);

        if (index >= 0) {

            

            pos = st->index_entries[index].pos;



            

            av_log(s, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", pos);

            avio_seek(s->pb, pos, SEEK_SET);

            asf_reset_header(s);

            return 0;

        }

    }

    

    if (ff_seek_frame_binary(s, stream_index, pts, flags) < 0)

        return -1;

    asf_reset_header(s);

    return 0;

}

    int index;         asf_build_simple_index(s, stream_index);     if ((asf->index_read && st->index_entries)) {
static int FUNC_0(AVFormatContext *VAR_0, int VAR_1,

                         int64_t VAR_2, int VAR_3)

{

    ASFContext *asf = VAR_0->priv_data;

    AVStream *st    = VAR_0->streams[VAR_1];

    int64_t pos;

    int VAR_4;



    if (VAR_0->packet_size <= 0)

        return -1;



    

    if (VAR_0->pb) {

        int VAR_5 = avio_seek_time(VAR_0->pb, VAR_1, VAR_2, VAR_3);

        if (VAR_5 >= 0)

            asf_reset_header(VAR_0);

        if (VAR_5 != AVERROR(ENOSYS))

            return VAR_5;

    }



    if (!asf->index_read)

        asf_build_simple_index(VAR_0, VAR_1);



    if ((asf->index_read && st->index_entries)) {

        VAR_4 = av_index_search_timestamp(st, VAR_2, VAR_3);

        if (VAR_4 >= 0) {

            

            pos = st->index_entries[VAR_4].pos;



            

            av_log(VAR_0, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", pos);

            avio_seek(VAR_0->pb, pos, SEEK_SET);

            asf_reset_header(VAR_0);

            return 0;

        }

    }

    

    if (ff_seek_frame_binary(VAR_0, VAR_1, VAR_2, VAR_3) < 0)

        return -1;

    asf_reset_header(VAR_0);

    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0, int VAR_1,
int64_t VAR_2, int VAR_3)
{ ASFContext *asf = VAR_0->priv_data; AVStream *st    = VAR_0->streams[VAR_1]; int64_t pos; int VAR_4; if (VAR_0->packet_size <= 0)
return -1; if (VAR_0->pb) { int VAR_5 = avio_seek_time(VAR_0->pb, VAR_1, VAR_2, VAR_3); if (VAR_5 >= 0)
asf_reset_header(VAR_0); if (VAR_5 != AVERROR(ENOSYS))
return VAR_5; } if (!asf->index_read)
asf_build_simple_index(VAR_0, VAR_1); if ((asf->index_read && st->index_entries)) { VAR_4 = av_index_search_timestamp(st, VAR_2, VAR_3); if (VAR_4 >= 0) { pos = st->index_entries[VAR_4].pos; av_log(VAR_0, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", pos); avio_seek(VAR_0->pb, pos, SEEK_SET); asf_reset_header(VAR_0); return 0; } } if (ff_seek_frame_binary(VAR_0, VAR_1, VAR_2, VAR_3) < 0)
return -1; asf_reset_header(VAR_0); return 0; }