diff mbox

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

Message ID 1473971779-27524-5-git-send-email-isasi@google.com
State Accepted
Commit b518d809f16359945eded03c2504641a7f497532
Headers show

Commit Message

Sasi Inguva Sept. 15, 2016, 8:36 p.m. UTC
Signed-off-by: Sasi Inguva <isasi@google.com>
---
 libavformat/utils.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Michael Niedermayer Sept. 19, 2016, 5:57 p.m. UTC | #1
On Thu, Sep 15, 2016 at 01:36:18PM -0700, Sasi Inguva wrote:
> Signed-off-by: Sasi Inguva <isasi@google.com>
> ---
>  libavformat/utils.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)

applied

thx

[...]
diff mbox

Patch

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;