[vlc-commits] demux: avi: fix skipping junk with non seekable streams

Francois Cartegnie git at videolan.org
Mon Jan 11 21:17:27 CET 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Jan 11 01:13:11 2016 +0100| [af927e5e04498e95297490108c47d15e7b97ad16] | committer: Francois Cartegnie

demux: avi: fix skipping junk with non seekable streams

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

 modules/demux/avi/libavi.c |   16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/modules/demux/avi/libavi.c b/modules/demux/avi/libavi.c
index ec25a72..d12ed9f 100644
--- a/modules/demux/avi/libavi.c
+++ b/modules/demux/avi/libavi.c
@@ -98,8 +98,20 @@ static int AVI_NextChunk( stream_t *s, avi_chunk_t *p_chk )
             return VLC_EGENERIC;
         }
     }
-    return stream_Seek( s, p_chk->common.i_chunk_pos +
-                                 __EVEN( p_chk->common.i_chunk_size ) + 8 );
+
+    bool b_seekable = false;
+    uint64_t i_offset = p_chk->common.i_chunk_pos +
+                        __EVEN( p_chk->common.i_chunk_size ) + 8;
+    if ( !stream_Control(s, STREAM_CAN_SEEK, &b_seekable) && b_seekable )
+    {
+        return stream_Seek( s, i_offset );
+    }
+    else
+    {
+        ssize_t i_read = i_offset - stream_Tell( s );
+        return (i_read >=0 && stream_Read( s, NULL, i_read ) == i_read) ?
+                    VLC_SUCCESS : VLC_EGENERIC;
+    }
 }
 
 /****************************************************************************



More information about the vlc-commits mailing list