[vlc-devel] commit: Fixed (common) broken dts in wav (close #2494) (Laurent Aimar )

git version control git at videolan.org
Mon Feb 9 21:09:08 CET 2009


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sun Feb  8 16:33:15 2009 +0100| [9e09dba85d718dce3cb5e48e28f1d7b19a4d05d3] | committer: Laurent Aimar 

Fixed (common) broken dts in wav (close #2494)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9e09dba85d718dce3cb5e48e28f1d7b19a4d05d3
---

 modules/demux/mpeg/es.c |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/modules/demux/mpeg/es.c b/modules/demux/mpeg/es.c
index 7c12cc8..2fdbcd1 100644
--- a/modules/demux/mpeg/es.c
+++ b/modules/demux/mpeg/es.c
@@ -671,17 +671,28 @@ static int GenericProbe( demux_t *p_demux, int64_t *pi_offset,
         if( !b_forced_demux )
             return VLC_EGENERIC;
     }
+    const bool b_wav = i_skip > 0;
 
-    /* peek the begining */
-    if( stream_Peek( p_demux->s, &p_peek, i_skip + i_check_size ) < i_skip + i_check_size )
+    /* peek the begining
+     * It is common that wav files have some sort of garbage at the begining */
+    const int i_probe = i_skip + i_check_size + ( b_wav ? 16000 : 0);
+    const int i_peek = stream_Peek( p_demux->s, &p_peek, i_probe );
+    if( i_peek < i_skip + i_check_size )
     {
         msg_Err( p_demux, "cannot peek" );
         return VLC_EGENERIC;
     }
-    if( !pf_check( &p_peek[i_skip] ) )
+    for( ;; )
     {
-        if( !b_forced_demux )
-            return VLC_EGENERIC;
+        if( i_skip + i_check_size > i_peek )
+        {
+            if( !b_forced_demux )
+                return VLC_EGENERIC;
+            break;
+        }
+        if( pf_check( &p_peek[i_skip] ) )
+            break;
+        i_skip++;
     }
 
     *pi_offset = i_offset + i_skip;




More information about the vlc-devel mailing list