nutdec: Flip the direction for seeking with an index in the failure case.
authorMichael Niedermayer <michaelni@gmx.at>
Sun, 19 Aug 2012 21:30:27 +0000 (23:30 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sun, 26 Aug 2012 20:15:18 +0000 (22:15 +0200)
This is closer to how seeking works without an index

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/nutdec.c

index ba3eb85..3389c79 100644 (file)
@@ -951,6 +951,8 @@ static int read_seek(AVFormatContext *s, int stream_index,
     if (st->index_entries) {
         int index = av_index_search_timestamp(st, pts, flags);
         if (index < 0)
+            index = av_index_search_timestamp(st, pts, flags ^ AVSEEK_FLAG_BACKWARD);
+        if (index < 0)
             return -1;
 
         pos2 = st->index_entries[index].pos;