[MPlayer-dev-eng] [PATCH] try to actually open demuxer in test

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Sat Oct 14 23:42:33 CEST 2006


Hello,
the attached patch makes the demuxer open function actually try to open
the file with a demuxer it detected and continue with others if it
fails.
This makes the dv-in-avi samples (at least
http://samples.mplayerhq.hu/avi/DV-hdr/foo001.avi) work out of the box
by falling back to libavformat demuxing.
Please test and check for stupid errors, that code somehow made my head
spin.

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libmpdemux/demuxer.c
===================================================================
--- libmpdemux/demuxer.c	(revision 20214)
+++ libmpdemux/demuxer.c	(working copy)
@@ -668,36 +668,41 @@
         fformat = demuxer_desc->type;
       if (fformat != 0) {
         if (fformat == demuxer_desc->type) {
+          demuxer_t *demux2 = demuxer;
           // Move messages to demuxer detection code?
           mp_msg(MSGT_DEMUXER, MSGL_INFO, MSGTR_Detected_XXX_FileFormat, demuxer_desc->shortdesc);
           file_format = demuxer_desc->type = fformat;
+          if (!demuxer->desc->open || (demux2 = demuxer->desc->open(demuxer))) {
+            demuxer = demux2;
+            goto dmx_open;
+          }
         } else {
           // Format changed after check, recurse
           free_demuxer(demuxer);
           return demux_open_stream(stream, fformat, force,
                    audio_id, video_id, dvdsub_id, filename);
         }
-      } else {
+      }
         // Check failed for forced demuxer, quit
         free_demuxer(demuxer);
         return NULL;
-      }
     }
   }
 }
 
-if (demuxer)
-  goto dmx_open;
-
 // Test demuxers with safe file checks
 for (i = 0; (demuxer_desc = demuxer_list[i]); i++) {
   if (demuxer_desc->safe_check) {
     demuxer = new_demuxer(stream,demuxer_desc->type,audio_id,video_id,dvdsub_id,filename);
     if ((fformat = demuxer_desc->check_file(demuxer)) != 0) {
       if (fformat == demuxer_desc->type) {
+        demuxer_t *demux2 = demuxer;
         mp_msg(MSGT_DEMUXER, MSGL_INFO, MSGTR_Detected_XXX_FileFormat, demuxer_desc->shortdesc);
         file_format = fformat;
-        break;
+        if (!demuxer->desc->open || (demux2 = demuxer->desc->open(demuxer))) {
+          demuxer = demux2;
+          goto dmx_open;
+        }
       } else {
         if (fformat == DEMUXER_TYPE_PLAYLIST)
           return demuxer; // handled in mplayer.c
@@ -708,16 +713,12 @@
         if(demuxer) return demuxer; // done!
         file_format = DEMUXER_TYPE_UNKNOWN;
       }
-    } else {
+    }
       free_demuxer(demuxer);
       demuxer = NULL;
-    }
   }
 }
 
-if (demuxer)
-  goto dmx_open;
-
 // If no forced demuxer perform file extension based detection
 // Ok. We're over the stable detectable fileformats, the next ones are a bit
 // fuzzy. So by default (extension_parsing==1) try extension-based detection
@@ -740,9 +741,13 @@
     demuxer = new_demuxer(stream,demuxer_desc->type,audio_id,video_id,dvdsub_id,filename);
     if ((fformat = demuxer_desc->check_file(demuxer)) != 0) {
       if (fformat == demuxer_desc->type) {
+        demuxer_t *demux2 = demuxer;
         mp_msg(MSGT_DEMUXER, MSGL_INFO, MSGTR_Detected_XXX_FileFormat, demuxer_desc->shortdesc);
         file_format = fformat;
-        break;
+        if (!demuxer->desc->open || (demux2 = demuxer->desc->open(demuxer))) {
+          demuxer = demux2;
+          goto dmx_open;
+        }
       } else {
         if (fformat == DEMUXER_TYPE_PLAYLIST)
           return demuxer; // handled in mplayer.c
@@ -753,27 +758,18 @@
         if(demuxer) return demuxer; // done!
         file_format = DEMUXER_TYPE_UNKNOWN;
       }
-    } else {
+    }
       free_demuxer(demuxer);
       demuxer = NULL;
-    }
   }
 }
 
-//=============== Unknown, exiting... ===========================
-if(file_format==DEMUXER_TYPE_UNKNOWN || demuxer == NULL){
-  //mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_FormatNotRecognized); // will be done by mplayer.c after fallback to playlist-parsing
   return NULL;
-}
 //====== File format recognized, set up these for compatibility: =========
 dmx_open:
 
 demuxer->file_format=file_format;
 
-if (demuxer->desc->open)
-  if (!(demuxer = demuxer->desc->open(demuxer)))
-    return NULL;
-
 if ((sh_video=demuxer->video->sh) && sh_video->bih){
 int biComp=le2me_32(sh_video->bih->biCompression);
   mp_msg(MSGT_DEMUX,MSGL_INFO,"VIDEO:  [%.4s]  %dx%d  %dbpp  %5.3f fps  %5.1f kbps (%4.1f kbyte/s)\n",


More information about the MPlayer-dev-eng mailing list