diff options
author | Aurelien Jacobs <aurel@gnuage.org> | 2007-04-09 16:48:28 +0000 |
---|---|---|
committer | Aurelien Jacobs <aurel@gnuage.org> | 2007-04-09 16:48:28 +0000 |
commit | cca9b6cdb3ad2bf4533295cf0de0131b03a5f75d (patch) | |
tree | 37ad31d0df0c245e2c5dd7e4e310a72f29708590 /libavformat | |
parent | df06539a251d75c2358603c91b32d38d3e23458b (diff) | |
download | ffmpeg-cca9b6cdb3ad2bf4533295cf0de0131b03a5f75d.tar.gz |
add support for seeking in matroska files
Originally committed as revision 8696 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/matroska.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/libavformat/matroska.c b/libavformat/matroska.c index f6b4c66a96..84516bec3e 100644 --- a/libavformat/matroska.c +++ b/libavformat/matroska.c @@ -2366,6 +2366,18 @@ matroska_read_header (AVFormatContext *s, res = 0; } + if (matroska->index_parsed) { + int i, track, stream; + for (i=0; i<matroska->num_indexes; i++) { + MatroskaDemuxIndex *idx = &matroska->index[i]; + track = matroska_find_track_by_num(matroska, idx->track); + stream = matroska->tracks[track]->stream_index; + av_add_index_entry(matroska->ctx->streams[stream], + idx->pos, idx->time/matroska->time_scale, + 0, 0, AVINDEX_KEYFRAME); + } + } + return res; } @@ -2754,6 +2766,26 @@ matroska_read_packet (AVFormatContext *s, } static int +matroska_read_seek (AVFormatContext *s, int stream_index, int64_t timestamp, + int flags) +{ + MatroskaDemuxContext *matroska = s->priv_data; + AVStream *st = s->streams[stream_index]; + int index; + + /* find index entry */ + index = av_index_search_timestamp(st, timestamp, flags); + if (index < 0) + return 0; + + /* do the seek */ + url_fseek(&s->pb, st->index_entries[index].pos, SEEK_SET); + matroska->num_packets = 0; + matroska->peek_id = 0; + return 0; +} + +static int matroska_read_close (AVFormatContext *s) { MatroskaDemuxContext *matroska = s->priv_data; @@ -2793,4 +2825,5 @@ AVInputFormat matroska_demuxer = { matroska_read_header, matroska_read_packet, matroska_read_close, + matroska_read_seek, }; |