for(i = 0;; i++) { url_fseek(&s->pb, asf->data_offset + i * asf->packet_size, SEEK_SET); if (asf_get_packet(s) < 0) break; printf("timestamp=%0.3f\n",  asf->packet_timestamp / 1000.0);
pkt = &pkt1;   if (s->nb_streams > 1) return -1;   if (pts < 0) pts = 0;    if (stream_index == -1) st = s->streams[0]; else st = s->streams[stream_index];   block_align = asf->packet_size;  byte_rate = st->codec.bit_rate / 8; if (block_align <= 0 || byte_rate <= 0) return -1;  pos_min = 0; pts_min = asf_read_pts(s, s->data_offset); if (pts_min == AV_NOPTS_VALUE) return -1;  pos_max = url_filesize(url_fileno(&s->pb)) - 1; pts_max = pts_min + s->duration;  while (pos_min <= pos_max) {  if (pts <= pts_min) { pos = pos_min; goto found; } else if (pts >= pts_max) { pos = pos_max; goto found; } else {  pos = (int64_t)((double)(pos_max - pos_min) * (double)(pts - pts_min) / (double)(pts_max - pts_min)) + pos_min; }   cur_pts = asf_read_pts(s, pos);   if (pts == cur_pts) { goto found; } else if (cur_pts == AV_NOPTS_VALUE) { return -1; } else if (pts < cur_pts) { pos_max = pos; pts_max = asf_read_pts(s, pos_max); if (pts >= pts_max) { pos = pos_max; goto found; } } else { pos_min = pos + asf->packet_size; pts_min = asf_read_pts(s, pos_min); if (pts <= pts_min) { goto found; } }
static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t pts){#if 0    ASFContext *asf = s->priv_data;    int i;    for(i = 0;; i++) {        url_fseek(&s->pb, asf->data_offset + i * asf->packet_size, SEEK_SET);        if (asf_get_packet(s) < 0)            break;        printf("timestamp=%0.3f\n",  asf->packet_timestamp / 1000.0);    }#endif    return -1;}