summaryrefslogtreecommitdiff
path: root/libavformat/utils.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-10-05 18:23:47 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-10-05 18:23:47 +0200
commitf9bd9794763004852e4410f23d3f155a478357f1 (patch)
treedf9362206373ba2804c9da1c2d5cc2fb3dd6ff58 /libavformat/utils.c
parentec1ffae0cdbcb84e0d3474b41a51fe36b93e1a76 (diff)
generic seeking: fail if there are 1000 non keyframes found with no keyframe.
This avoids scanning through a whole file just to fail. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r--libavformat/utils.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 7fe2a954a8..d8b62f3083 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1749,6 +1749,7 @@ static int seek_frame_generic(AVFormatContext *s,
if(index < 0 || index==st->nb_index_entries-1){
AVPacket pkt;
+ int nonkey=0;
if(st->nb_index_entries){
assert(st->index_entries);
@@ -1768,9 +1769,13 @@ static int seek_frame_generic(AVFormatContext *s,
if (read_status < 0)
break;
av_free_packet(&pkt);
- if(stream_index == pkt.stream_index){
- if((pkt.flags & AV_PKT_FLAG_KEY) && pkt.dts > timestamp)
+ if(stream_index == pkt.stream_index && pkt.dts > timestamp){
+ if(pkt.flags & AV_PKT_FLAG_KEY)
break;
+ if(nonkey++ > 1000){
+ av_log(s, AV_LOG_ERROR,"seek_frame_generic failed as this stream seems to contain no keyframes after the target timestamp, %d non keyframes found\n", nonkey);
+ break;
+ }
}
}
index = av_index_search_timestamp(st, timestamp, flags);