diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-07-30 17:09:13 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-07-30 17:29:12 +0400 |
commit | d6686149e2d72655d57c45ac18dee3b820897a5c (patch) | |
tree | 23d88224dbdb4aed1227e0831bf99ab51e3798fc /libavformat/asfdec.c | |
parent | 66487d73c3a9244dd238f3b5d8ed9d55670e97ea (diff) |
asfdec: Skip to keyframe after seeking
Fixes Ticket1616
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/asfdec.c')
-rw-r--r-- | libavformat/asfdec.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index f34a14119d..d83460e663 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -1137,7 +1137,7 @@ static int asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt) if (asf->stream_index < 0 || s->streams[asf->stream_index]->discard >= AVDISCARD_ALL || (!asf->packet_key_frame && - s->streams[asf->stream_index]->discard >= AVDISCARD_NONKEY)) { + (s->streams[asf->stream_index]->discard >= AVDISCARD_NONKEY || asf->streams[s->streams[asf->stream_index]->id].skip_to_key))) { asf->packet_time_start = 0; /* unhandled packet (should not happen) */ avio_skip(pb, asf->packet_frag_size); @@ -1148,6 +1148,7 @@ static int asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt) continue; } asf->asf_st = &asf->streams[s->streams[asf->stream_index]->id]; + asf->asf_st->skip_to_key = 0; } asf_st = asf->asf_st; av_assert0(asf_st); @@ -1366,6 +1367,21 @@ static void asf_reset_header(AVFormatContext *s) asf->asf_st = NULL; } +static void skip_to_key(AVFormatContext *s) +{ + ASFContext *asf = s->priv_data; + int i; + + for (i = 0; i < 128; i++) { + int j = asf->asfid2avid[i]; + ASFStream *asf_st = &asf->streams[i]; + if (j < 0 || s->streams[j]->codec->codec_type != AVMEDIA_TYPE_VIDEO) + continue; + + asf_st->skip_to_key = 1; + } +} + static int asf_read_close(AVFormatContext *s) { asf_reset_header(s); @@ -1515,6 +1531,7 @@ static int asf_read_seek(AVFormatContext *s, int stream_index, if(avio_seek(s->pb, pos, SEEK_SET) < 0) return -1; asf_reset_header(s); + skip_to_key(s); return 0; } } @@ -1522,6 +1539,7 @@ static int asf_read_seek(AVFormatContext *s, int stream_index, if (ff_seek_frame_binary(s, stream_index, pts, flags) < 0) return -1; asf_reset_header(s); + skip_to_key(s); return 0; } |