diff options
author | Sasi Inguva <isasi-at-google.com@ffmpeg.org> | 2016-09-15 13:36:18 -0700 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2016-09-19 19:51:13 +0200 |
commit | b518d809f16359945eded03c2504641a7f497532 (patch) | |
tree | 02ef2393ca406b6d59958acf7be65b9398e42c5a | |
parent | 2dbedc20ce2f92e8c76e4284441d881906fabe5d (diff) | |
download | ffmpeg-b518d809f16359945eded03c2504641a7f497532.tar.gz |
lavf/utils: Support av_index_search_timestamp in case of AVIndexEntry with discarded packets.
Signed-off-by: Sasi Inguva <isasi@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavformat/utils.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index d605a969a9..f043baec4d 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; |