[FFmpeg-devel] [PATCH 5/6] lavf/utils: Support av_index_search_timestamp in case of AVIndexEntry with discarded packets.

Sasi Inguva isasi at google.com
Thu Sep 15 23:36:18 EEST 2016


Signed-off-by: Sasi Inguva <isasi at google.com>
---
 libavformat/utils.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index d605a96..f043bae 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -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;
-- 
2.8.0.rc3.226.g39d4020



More information about the ffmpeg-devel mailing list