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>
This commit is contained in:
Sasi Inguva 2016-09-15 13:36:18 -07:00 committed by Michael Niedermayer
parent 2dbedc20ce
commit b518d809f1
1 changed files with 10 additions and 0 deletions

View 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;