lavf/utils: Support av_index_search_timestamp in case of AVIndexEntry with discarded...
authorSasi Inguva <isasi-at-google.com@ffmpeg.org>
Thu, 15 Sep 2016 20:36:18 +0000 (13:36 -0700)
committerMichael Niedermayer <michael@niedermayer.cc>
Mon, 19 Sep 2016 17:51:13 +0000 (19:51 +0200)
Signed-off-by: Sasi Inguva <isasi@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/utils.c

index d605a96..f043bae 100644 (file)
@@ -1937,6 +1937,16 @@ int ff_index_search_timestamp(const AVIndexEntry *entries, int nb_entries,
 
     while (b - a > 1) {
         m         = (a + b) >> 1;
+
+        // Search for the next non-discarded packet.
+        while ((entries[m].flags & AVINDEX_DISCARD_FRAME) && m < b) {
+            m++;
+            if (m == b && entries[m].timestamp >= wanted_timestamp) {
+                m = b - 1;
+                break;
+            }
+        }
+
         timestamp = entries[m].timestamp;
         if (timestamp >= wanted_timestamp)
             b = m;