X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fwvdec.c;h=96a631fcf382008d627a9420f7df627e1535f373;hb=f5b26fbc2f564831b337f1de9faaaf6753a03871;hp=4e58512393c2988c5e7ebd947d3291fa8c4d7d69;hpb=037c9c25e6213852e33de5b6e00bbf9d26195938;p=ffmpeg diff --git a/libavformat/wvdec.c b/libavformat/wvdec.c index 4e58512393c..96a631fcf38 100644 --- a/libavformat/wvdec.c +++ b/libavformat/wvdec.c @@ -296,6 +296,7 @@ static int wv_read_packet(AVFormatContext *s, AVPacket *pkt) } } pkt->stream_index = 0; + pkt->pos = pos; wc->block_parsed = 1; pkt->pts = wc->header.block_idx; block_samples = wc->header.samples; @@ -305,41 +306,6 @@ static int wv_read_packet(AVFormatContext *s, AVPacket *pkt) else pkt->duration = block_samples; - av_add_index_entry(s->streams[0], pos, pkt->pts, 0, 0, AVINDEX_KEYFRAME); - return 0; -} - -static int wv_read_seek(AVFormatContext *s, int stream_index, - int64_t timestamp, int flags) -{ - AVStream *st = s->streams[stream_index]; - WVContext *wc = s->priv_data; - AVPacket pkt1, *pkt = &pkt1; - int ret; - int index = av_index_search_timestamp(st, timestamp, flags); - int64_t pos, pts; - - /* if found, seek there */ - if (index >= 0 && - timestamp <= st->index_entries[st->nb_index_entries - 1].timestamp) { - wc->block_parsed = 1; - avio_seek(s->pb, st->index_entries[index].pos, SEEK_SET); - return 0; - } - /* if timestamp is out of bounds, return error */ - if (timestamp < 0 || timestamp >= s->duration) - return AVERROR(EINVAL); - - pos = avio_tell(s->pb); - do { - ret = av_read_frame(s, pkt); - if (ret < 0) { - avio_seek(s->pb, pos, SEEK_SET); - return ret; - } - pts = pkt->pts; - av_free_packet(pkt); - } while(pts < timestamp); return 0; } @@ -350,5 +316,5 @@ AVInputFormat ff_wv_demuxer = { .read_probe = wv_probe, .read_header = wv_read_header, .read_packet = wv_read_packet, - .read_seek = wv_read_seek, + .flags = AVFMT_GENERIC_INDEX, };