summaryrefslogtreecommitdiff
path: root/libavformat/segafilm.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2015-10-30 12:07:13 +0100
committerPaul B Mahol <onemda@gmail.com>2015-11-02 10:53:05 +0100
commite6cccf9daa64e36ccdd575fdfd36b7fdb2661840 (patch)
treed010edba9be3b88873f27daeda173e96d008a337 /libavformat/segafilm.c
parent55abb94b7d9a4dc93bece7ed7bc77daf4cc4a91d (diff)
downloadffmpeg-e6cccf9daa64e36ccdd575fdfd36b7fdb2661840.tar.gz
avformat/segafilm: implement seeking
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavformat/segafilm.c')
-rw-r--r--libavformat/segafilm.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/libavformat/segafilm.c b/libavformat/segafilm.c
index 44fa683a71..b4f9b3d825 100644
--- a/libavformat/segafilm.c
+++ b/libavformat/segafilm.c
@@ -239,6 +239,11 @@ static int film_read_header(AVFormatContext *s)
film->sample_table[i].stream = film->video_stream_index;
film->sample_table[i].pts = AV_RB32(&scratch[8]) & 0x7FFFFFFF;
film->sample_table[i].keyframe = (scratch[8] & 0x80) ? 0 : 1;
+ av_add_index_entry(s->streams[film->video_stream_index],
+ film->sample_table[i].sample_offset,
+ film->sample_table[i].pts,
+ film->sample_table[i].sample_size, 0,
+ film->sample_table[i].keyframe);
}
}
@@ -279,6 +284,21 @@ static int film_read_packet(AVFormatContext *s,
return ret;
}
+static int film_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
+{
+ FilmDemuxContext *film = s->priv_data;
+ AVStream *st = s->streams[stream_index];
+ int index = av_index_search_timestamp(st, timestamp, flags);
+ if (index < 0)
+ return -1;
+ if (avio_seek(s->pb, st->index_entries[index].pos, SEEK_SET) < 0)
+ return -1;
+
+ film->current_sample = index;
+
+ return 0;
+}
+
AVInputFormat ff_segafilm_demuxer = {
.name = "film_cpk",
.long_name = NULL_IF_CONFIG_SMALL("Sega FILM / CPK"),
@@ -287,4 +307,5 @@ AVInputFormat ff_segafilm_demuxer = {
.read_header = film_read_header,
.read_packet = film_read_packet,
.read_close = film_read_close,
+ .read_seek = film_read_seek,
};