changeset 28630:acadba04afaf

Be more robust against corrupted RM files that contain invalid packet length by seeking to a known good place when index table is available.
author zuxy
date Thu, 19 Feb 2009 11:42:05 +0000
parents b089d639e810
children 70a43ec47c61
files libmpdemux/demux_real.c
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_real.c	Thu Feb 19 10:07:46 2009 +0000
+++ b/libmpdemux/demux_real.c	Thu Feb 19 11:42:05 2009 +0000
@@ -624,7 +624,15 @@
     if (len < 12){
 	mp_msg(MSGT_DEMUX, MSGL_V,"%08X: packet v%d len=%d  \n",(int)demuxer->filepos,(int)version,(int)len);
 	mp_msg(MSGT_DEMUX, MSGL_WARN,"bad packet len (%d)\n", len);
-	stream_skip(demuxer->stream, len);
+	if ((unsigned)demuxer->video->id < MAX_STREAMS) {
+	    if (priv->current_vpacket + 1 < priv->index_table_size[demuxer->video->id]) {
+		stream_seek(demuxer->stream, priv->index_table[demuxer->video->id][++priv->current_vpacket].offset);
+	    }
+	} else if ((unsigned)demuxer->audio->id < MAX_STREAMS) {
+	    if (priv->current_apacket + 1 < priv->index_table_size[demuxer->audio->id]) {
+		stream_seek(demuxer->stream, priv->index_table[demuxer->audio->id][++priv->current_apacket].offset);
+	    }
+	}
 	continue; //goto loop;
     }