summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-10-21 20:45:00 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-10-21 20:45:00 +0200
commit27f7589ab1ad0f6d2694d713e176dfa234662e60 (patch)
tree19b3d253d6f9a856a6ba5edb75985127b530e53b /libavformat
parent7846280d1da5e4929bb8fb5adcc4b0c017535bea (diff)
seek: Fix av_gen_search() so that seeks outside max/min do not successfully seek to random
points but rather seek to the min/max. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/utils.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index a788eefc34..b931f77bb5 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1621,6 +1621,11 @@ int64_t av_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, i
return -1;
}
+ if(ts_min >= target_ts){
+ *ts_ret= ts_min;
+ return pos_min;
+ }
+
if(ts_max == AV_NOPTS_VALUE){
int step= 1024;
filesize = avio_size(s->pb);
@@ -1646,6 +1651,11 @@ int64_t av_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, i
pos_limit= pos_max;
}
+ if(ts_max <= target_ts){
+ *ts_ret= ts_max;
+ return pos_max;
+ }
+
if(ts_min > ts_max){
return -1;
}else if(ts_min == ts_max){