diff options
author | wm4 <nfxjfg@googlemail.com> | 2015-04-23 13:33:06 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-04-24 03:43:56 +0200 |
commit | 0f776df09e0ba3f45543f0bc9d32a1decb5e5fb2 (patch) | |
tree | 489bad154bc1ba923514ec43ef7421e584cf06c5 /libavformat/wvdec.c | |
parent | cd69c0e0181c2815ac239803b7edfa3f600e1c50 (diff) |
avformat/wvdec: fix seeking
While I'm not sure why exactly sure why the old code could end up in the
wrong position, using the generic index code is much simpler and is
known to work correctly.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/wvdec.c')
-rw-r--r-- | libavformat/wvdec.c | 38 |
1 files changed, 2 insertions, 36 deletions
diff --git a/libavformat/wvdec.c b/libavformat/wvdec.c index 4e58512393..96a631fcf3 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, }; |