Signed-off-by: Paul B Mahol <onemda@gmail.com>
Paul B Mahol authored on 2015/10/30 20:07:13... | ... |
@@ -239,6 +239,11 @@ static int film_read_header(AVFormatContext *s) |
239 | 239 |
film->sample_table[i].stream = film->video_stream_index; |
240 | 240 |
film->sample_table[i].pts = AV_RB32(&scratch[8]) & 0x7FFFFFFF; |
241 | 241 |
film->sample_table[i].keyframe = (scratch[8] & 0x80) ? 0 : 1; |
242 |
+ av_add_index_entry(s->streams[film->video_stream_index], |
|
243 |
+ film->sample_table[i].sample_offset, |
|
244 |
+ film->sample_table[i].pts, |
|
245 |
+ film->sample_table[i].sample_size, 0, |
|
246 |
+ film->sample_table[i].keyframe); |
|
242 | 247 |
} |
243 | 248 |
} |
244 | 249 |
|
... | ... |
@@ -279,6 +284,21 @@ static int film_read_packet(AVFormatContext *s, |
279 | 279 |
return ret; |
280 | 280 |
} |
281 | 281 |
|
282 |
+static int film_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) |
|
283 |
+{ |
|
284 |
+ FilmDemuxContext *film = s->priv_data; |
|
285 |
+ AVStream *st = s->streams[stream_index]; |
|
286 |
+ int index = av_index_search_timestamp(st, timestamp, flags); |
|
287 |
+ if (index < 0) |
|
288 |
+ return -1; |
|
289 |
+ if (avio_seek(s->pb, st->index_entries[index].pos, SEEK_SET) < 0) |
|
290 |
+ return -1; |
|
291 |
+ |
|
292 |
+ film->current_sample = index; |
|
293 |
+ |
|
294 |
+ return 0; |
|
295 |
+} |
|
296 |
+ |
|
282 | 297 |
AVInputFormat ff_segafilm_demuxer = { |
283 | 298 |
.name = "film_cpk", |
284 | 299 |
.long_name = NULL_IF_CONFIG_SMALL("Sega FILM / CPK"), |
... | ... |
@@ -287,4 +307,5 @@ AVInputFormat ff_segafilm_demuxer = { |
287 | 287 |
.read_header = film_read_header, |
288 | 288 |
.read_packet = film_read_packet, |
289 | 289 |
.read_close = film_read_close, |
290 |
+ .read_seek = film_read_seek, |
|
290 | 291 |
}; |