[MPlayer-dev-eng] More aggresive index rebuild for AVI files

Matan Ziv-Av matan at svgalib.org
Thu Jul 14 00:27:15 CEST 2011


Hello,

the attached patch adds an option -fixidx, which works better than 
-forceidx for some damaged AVI files.

This previous discussion is relevant:
http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2007-October/054571.html

Two main differences between Reimar Döffinger's patch and mine:

The decision not to skip a putative chunk is based on id, rather than size.

This patch introduces a new option, leaving the behaviour of forceidx unchanged.


-- 
Matan Ziv-Av.                         matan at svgalib.org
-------------- next part --------------
--- libmpdemux/aviheader.c.org	2011-07-13 16:33:59.000000000 +0300
+++ libmpdemux/aviheader.c	2011-07-14 01:15:20.000000000 +0300
@@ -74,7 +74,7 @@
   //
   if(stream_eof(demuxer->stream)) break;
   // Imply -forceidx if -saveidx is specified
-  if (index_file_save)
+  if (index_file_save && (index_mode<2))
     index_mode = 2;
   //
   if(id==mmioFOURCC('L','I','S','T')){
@@ -95,7 +95,7 @@
       demuxer->movi_end=stream_tell(demuxer->stream)+len;
       mp_msg(MSGT_HEADER,MSGL_V,MSGTR_MPDEMUX_AVIHDR_FoundMovieAt,(int)demuxer->movi_start,(int)demuxer->movi_end);
       if(demuxer->stream->end_pos>demuxer->movi_end) demuxer->movi_end=demuxer->stream->end_pos;
-      if(index_mode==-2 || index_mode==2 || index_mode==0)
+      if(index_mode==-2 || index_mode==2 || index_mode==0 || index_mode==3)
         break; // reading from non-seekable source (stdin) or forced index or no index forced
       if(list_end>0) stream_seek(demuxer->stream,list_end); // skip movi
       list_end=0;
@@ -704,6 +704,10 @@
 #endif
 skip_chunk:
     skip=(len+1)&(~1UL); // total bytes in this chunk
+    if(index_mode==3 &&
+       (((id&0xf0ffffff)!=0x30786469) && ((id&0xffff0000)!=0x62770000) && 
+        ((id&0xfffff0f0)!=0x63643030) && ((id&0xfffff0f0)!=0x78743030)))
+        skip=0;
     stream_seek(demuxer->stream,8+demuxer->filepos+skip);
   }
   priv->idx_size=idx_pos;
--- cfg-common.h.org	2011-07-14 01:12:59.000000000 +0300
+++ cfg-common.h	2011-07-14 01:12:36.000000000 +0300
@@ -424,6 +424,7 @@
     {"noidx", &index_mode, CONF_TYPE_FLAG, 0, -1, 0, NULL},
     {"idx", &index_mode, CONF_TYPE_FLAG, 0, -1, 1, NULL},
     {"forceidx", &index_mode, CONF_TYPE_FLAG, 0, -1, 2, NULL},
+    {"fixidx", &index_mode, CONF_TYPE_FLAG, 0, -1, 3, NULL},
     {"saveidx", &index_file_save, CONF_TYPE_STRING, 0, 0, 0, NULL},
     {"loadidx", &index_file_load, CONF_TYPE_STRING, 0, 0, 0, NULL},
 


More information about the MPlayer-dev-eng mailing list