diff libmpdemux/demuxer.c @ 35392:092c40fbd33d

Try to improve seeking in files with only few video packets, in particular files with cover art. This might cause issues with badly interleaved files, particularly together with -audio-delay, even though I did not see issues in my very limited testing.
author reimar
date Mon, 26 Nov 2012 19:30:58 +0000
parents c93bf3f1540b
children d6305a78a11e
line wrap: on
line diff
--- a/libmpdemux/demuxer.c	Mon Nov 26 11:32:50 2012 +0000
+++ b/libmpdemux/demuxer.c	Mon Nov 26 19:30:58 2012 +0000
@@ -663,6 +663,7 @@
             demux_packet_t *p = ds->first;
             // obviously not yet EOF after all
             ds->eof = 0;
+            ds->fill_count = 0;
 #if 0
             if (demux->reference_clock != MP_NOPTS_VALUE) {
                 if (   p->pts != MP_NOPTS_VALUE
@@ -697,6 +698,11 @@
             --ds->packs;
             return 1;
         }
+        // avoid buffering too far ahead in e.g. badly interleaved files
+        // or when one stream is shorter, without breaking large audio
+        // delay with well interleaved files.
+        if (ds->fill_count++ > 20)
+            break;
         // avoid printing the "too many ..." message over and over
         if (ds->eof)
             break;