aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2015-11-28 00:13:52 +0100
committerMarton Balint <cus@passwd.hu>2015-12-08 02:14:44 +0100
commit97795ba6c3a58fe1b72fedcf9c65c99fb0725b9c (patch)
treeecf151d0d2bae0d7d27abb48fdbf1632fbf8b3e4 /libavformat
parentdd1d9b80c99eab2790f6e9c80aa1131c6e9a311d (diff)
downloadffmpeg-97795ba6c3a58fe1b72fedcf9c65c99fb0725b9c.tar.gz
lavf/mxfdec: fix seeking before the first keyframe
Regression since 53f2ef2c4afb1d49a679dea9163cb0e4671f3117. Fixes ticket #5017. Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/mxfdec.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 0e055fd297..f4222fcab5 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -3193,6 +3193,16 @@ static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_ti
sample_time = FFMAX(sample_time, 0);
if (t->fake_index) {
+ /* The first frames may not be keyframes in presentation order, so
+ * we have to advance the target to be able to find the first
+ * keyframe backwards... */
+ if (!(flags & AVSEEK_FLAG_ANY) &&
+ (flags & AVSEEK_FLAG_BACKWARD) &&
+ t->ptses[0] != AV_NOPTS_VALUE &&
+ sample_time < t->ptses[0] &&
+ (t->fake_index[t->ptses[0]].flags & AVINDEX_KEYFRAME))
+ sample_time = t->ptses[0];
+
/* behave as if we have a proper index */
if ((sample_time = ff_index_search_timestamp(t->fake_index, t->nb_ptses, sample_time, flags)) < 0)
return sample_time;