static int64_t asf_read_pts(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit)
{
    ASFContext *asf = s->priv_data;
    AVPacket pkt1, *pkt = &pkt1;
    ASFStream *asf_st;
    int64_t pts;
    int64_t pos= *ppos;
    int i;
    int64_t start_pos[s->nb_streams];
    for(i=0; i<s->nb_streams; i++){
        start_pos[i]= pos;
    }
    pos= (pos+asf->packet_size-1-s->data_offset)/asf->packet_size*asf->packet_size+ s->data_offset;
    *ppos= pos;
    url_fseek(s->pb, pos, SEEK_SET);
    asf_reset_header(s);
    for(;;){
        if (av_read_frame(s, pkt) < 0){
            av_log(s, AV_LOG_INFO, "asf_read_pts failed\n");
            return AV_NOPTS_VALUE;
        }
        pts= pkt->pts;
        av_free_packet(pkt);
        if(pkt->flags&PKT_FLAG_KEY){
            i= pkt->stream_index;
            asf_st= s->streams[i]->priv_data;
            pos= asf_st->packet_pos;
            av_add_index_entry(s->streams[i], pos, pts, pkt->size, pos - start_pos[i] + 1, AVINDEX_KEYFRAME);
            start_pos[i]= asf_st->packet_pos + 1;
            if(pkt->stream_index == stream_index)
               break;
        }
    }
    *ppos= pos;
    return pts;
}
['static int64_t asf_read_pts(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit)\n{\n    ASFContext *asf = s->priv_data;\n    AVPacket pkt1, *pkt = &pkt1;\n    ASFStream *asf_st;\n    int64_t pts;\n    int64_t pos= *ppos;\n    int i;\n    int64_t start_pos[s->nb_streams];\n    for(i=0; i<s->nb_streams; i++){\n        start_pos[i]= pos;\n    }\n    pos= (pos+asf->packet_size-1-s->data_offset)/asf->packet_size*asf->packet_size+ s->data_offset;\n    *ppos= pos;\n    url_fseek(s->pb, pos, SEEK_SET);\n    asf_reset_header(s);\n    for(;;){\n        if (av_read_frame(s, pkt) < 0){\n            av_log(s, AV_LOG_INFO, "asf_read_pts failed\\n");\n            return AV_NOPTS_VALUE;\n        }\n        pts= pkt->pts;\n        av_free_packet(pkt);\n        if(pkt->flags&PKT_FLAG_KEY){\n            i= pkt->stream_index;\n            asf_st= s->streams[i]->priv_data;\n            pos= asf_st->packet_pos;\n            av_add_index_entry(s->streams[i], pos, pts, pkt->size, pos - start_pos[i] + 1, AVINDEX_KEYFRAME);\n            start_pos[i]= asf_st->packet_pos + 1;\n            if(pkt->stream_index == stream_index)\n               break;\n        }\n    }\n    *ppos= pos;\n    return pts;\n}']