[Mplayer-cvslog] CVS: main/libmpdemux demux_mpg.c,1.46,1.47 demuxer.c,1.132,1.133 demuxer.h,1.54,1.55 video.c,1.31,1.32

Arpi of Ize arpi at mplayerhq.hu
Thu Jan 23 03:12:18 CET 2003


Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var/tmp.root/cvs-serv24453/libmpdemux

Modified Files:
	demux_mpg.c demuxer.c demuxer.h video.c 
Log Message:
raw mpeg4-es support (you need to set -fps manually!)


Index: demux_mpg.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mpg.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- demux_mpg.c	23 Nov 2002 10:58:08 -0000	1.46
+++ demux_mpg.c	23 Jan 2003 02:12:15 -0000	1.47
@@ -247,6 +247,7 @@
 
 int num_elementary_packets100=0;
 int num_elementary_packets101=0;
+int num_elementary_packets12x=0;
 int num_elementary_packets1B6=0;
 int num_elementary_packetsPES=0;
 int num_mp3audio_packets=0;
@@ -314,7 +315,8 @@
   } else {
     if(head>=0x100 && head<0x1B0){
       if(head==0x100) ++num_elementary_packets100; else
-      if(head==0x101) ++num_elementary_packets101;
+      if(head==0x101) ++num_elementary_packets101; else
+      if(head>=0x120 && head<=0x12F) ++num_elementary_packets12x;
       mp_msg(MSGT_DEMUX,MSGL_DBG3,"Opps... elementary video packet found: %03X\n",head);
     } else
     if((head>=0x1C0 && head<0x1F0) || head==0x1BD){

Index: demuxer.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.c,v
retrieving revision 1.132
retrieving revision 1.133
diff -u -r1.132 -r1.133
--- demuxer.c	22 Jan 2003 23:51:04 -0000	1.132
+++ demuxer.c	23 Jan 2003 02:12:15 -0000	1.133
@@ -292,6 +292,7 @@
     case DEMUXER_TYPE_FILM: return demux_film_fill_buffer(demux);
     case DEMUXER_TYPE_BMP: return demux_bmp_fill_buffer(demux);
     case DEMUXER_TYPE_FLI: return demux_fli_fill_buffer(demux);
+    case DEMUXER_TYPE_MPEG4_ES:
     case DEMUXER_TYPE_MPEG_ES: return demux_mpg_es_fill_buffer(demux);
     case DEMUXER_TYPE_MPEG_PS: return demux_mpg_fill_buffer(demux);
     case DEMUXER_TYPE_AVI: return demux_avi_fill_buffer(demux);
@@ -502,6 +503,7 @@
 extern int num_elementary_packets101;
 extern int num_elementary_packetsPES;
 extern int num_elementary_packets1B6;
+extern int num_elementary_packets12x;
 extern int num_mp3audio_packets;
 
 // commandline options, flags:
@@ -813,6 +815,7 @@
   num_elementary_packets100=0;
   num_elementary_packets101=0;
   num_elementary_packets1B6=0;
+  num_elementary_packets12x=0;
   num_elementary_packetsPES=0;
   num_mp3audio_packets=0;
 
@@ -823,8 +826,10 @@
       mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"MPEG-PS");
     file_format=DEMUXER_TYPE_MPEG_PS;
   } else {
-    mp_msg(MSGT_DEMUX,MSGL_V,"MPEG packet stats: p100: %d  p101: %d  PES: %d  MP3: %d \n",
-	num_elementary_packets100,num_elementary_packets101,num_elementary_packetsPES,num_mp3audio_packets);
+    mp_msg(MSGT_DEMUX,MSGL_V,"MPEG packet stats: p100: %d  p101: %d p1B6: %d p12x: %d PES: %d  MP3: %d \n",
+	num_elementary_packets100,num_elementary_packets101,
+	num_elementary_packets1B6,num_elementary_packets12x,
+	num_elementary_packetsPES,num_mp3audio_packets);
 //MPEG packet stats: p100: 458  p101: 458  PES: 0  MP3: 1103  (.m2v)
     if(num_mp3audio_packets>50 && num_mp3audio_packets>2*num_elementary_packets100
 	&& abs(num_elementary_packets100-num_elementary_packets101)>2)
@@ -836,7 +841,16 @@
         --pes;continue; // tricky...
       }
       file_format=DEMUXER_TYPE_MPEG_ES; //  <-- hack is here :)
-    } else {
+    } else 
+#if 0
+    // fuzzy mpeg4-es detection. do NOT enable without heavy testing of mpeg formats detection!
+    if(num_elementary_packets1B6>3 && num_elementary_packets12x>=1 &&
+       num_elementary_packetsPES==0 && num_elementary_packets100<=num_elementary_packets12x &&
+       demuxer->synced<2){
+      file_format=DEMUXER_TYPE_MPEG4_ES;
+    } else
+#endif
+    {
       if(demuxer->synced==2)
         mp_msg(MSGT_DEMUXER,MSGL_ERR,"MPEG: " MSGTR_MissingVideoStreamBug);
       else
@@ -849,15 +863,15 @@
  }
 }
 //=============== Try to open as MPEG-ES file: =================
-if(file_format==DEMUXER_TYPE_MPEG_ES){ // little hack, see above!
-  demuxer=new_demuxer(stream,DEMUXER_TYPE_MPEG_ES,audio_id,video_id,dvdsub_id);
+if(file_format==DEMUXER_TYPE_MPEG_ES || file_format==DEMUXER_TYPE_MPEG4_ES){ // little hack, see above!
+  demuxer=new_demuxer(stream,file_format,audio_id,video_id,dvdsub_id);
   if(!ds_fill_buffer(demuxer->video)){
     mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_InvalidMPEGES);
     file_format=DEMUXER_TYPE_UNKNOWN;
     free_demuxer(demuxer);
     demuxer = NULL;
   } else {
-    mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"MPEG-ES");
+    mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,(file_format==DEMUXER_TYPE_MPEG_ES)?"MPEG-ES":"MPEG4-ES");
   }
 }
 #ifdef HAVE_LIBDV095
@@ -1044,6 +1058,7 @@
   }
   break;
  }
+ case DEMUXER_TYPE_MPEG4_ES:
  case DEMUXER_TYPE_MPEG_ES: {
    sh_audio=NULL;   // ES streams has no audio channel
    d_video->sh=new_sh_video(demuxer,0); // create dummy video stream header, id=0
@@ -1207,6 +1222,7 @@
   case DEMUXER_TYPE_ASF:
       demux_seek_asf(demuxer,rel_seek_secs,flags);  break;
   
+  case DEMUXER_TYPE_MPEG4_ES:
   case DEMUXER_TYPE_MPEG_ES:
   case DEMUXER_TYPE_MPEG_PS:
       demux_seek_mpg(demuxer,rel_seek_secs,flags);  break;
@@ -1312,6 +1328,7 @@
 
 int demux_control(demuxer_t *demuxer, int cmd, void *arg) {
     switch(demuxer->type) {
+	case DEMUXER_TYPE_MPEG4_ES:
 	case DEMUXER_TYPE_MPEG_ES:
 	case DEMUXER_TYPE_MPEG_PS:
 	    return demux_mpg_control(demuxer,cmd,arg);

Index: demuxer.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.h,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- demuxer.h	22 Jan 2003 23:51:04 -0000	1.54
+++ demuxer.h	23 Jan 2003 02:12:15 -0000	1.55
@@ -35,11 +35,12 @@
 #define DEMUXER_TYPE_SMJPEG 24
 #define DEMUXER_TYPE_XMMS 25
 #define DEMUXER_TYPE_RAWVIDEO 26
+#define DEMUXER_TYPE_MPEG4_ES 27
 
 // This should always match the higest demuxer type number.
 // Unless you want to disallow users to force the demuxer to some types
 #define DEMUXER_TYPE_MIN 0
-#define DEMUXER_TYPE_MAX 26
+#define DEMUXER_TYPE_MAX 27
 
 #define DEMUXER_TYPE_DEMUXERS (1<<16)
 // A virtual demuxer type for the network code

Index: video.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/video.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- video.c	16 Jan 2003 23:40:31 -0000	1.31
+++ video.c	23 Jan 2003 02:12:15 -0000	1.32
@@ -89,6 +89,46 @@
    if (!demux_is_mpeg_rtp_stream(d_video->demuxer)) break;
    // otherwise fall through to...
 #endif
+ case DEMUXER_TYPE_MPEG4_ES: {
+   videobuf_len=0; videobuf_code_len=0;
+   mp_msg(MSGT_DECVIDEO,MSGL_V,"Searching for Video Object Start code... ");fflush(stdout);
+   while(1){
+      int i=sync_video_packet(d_video);
+      if(i<=0x11F) break; // found it!
+      if(!i || !skip_video_packet(d_video)){
+        mp_msg(MSGT_DECVIDEO,MSGL_V,"NONE :(\n");
+	return 0;
+      }
+   }
+   mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\n");
+   if(!videobuffer) videobuffer=(char*)memalign(8,VIDEOBUFFER_SIZE);
+   if(!videobuffer){ 
+     mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_ShMemAllocFail);
+     return 0;
+   }
+   mp_msg(MSGT_DECVIDEO,MSGL_V,"Searching for Video Object Layer Start code... ");fflush(stdout);
+   while(1){
+      int i=sync_video_packet(d_video);
+      printf("0x%X\n",i);
+      if(i>=0x120 && i<=0x12F) break; // found it!
+      if(!i || !read_video_packet(d_video)){
+        mp_msg(MSGT_DECVIDEO,MSGL_V,"NONE :(\n");
+	return 0;
+      }
+   }
+   mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\nSearching for Video Object Plane Start code... ");fflush(stdout);
+   while(1){
+      int i=sync_video_packet(d_video);
+      if(i==0x1B6) break; // found it!
+      if(!i || !read_video_packet(d_video)){
+        mp_msg(MSGT_DECVIDEO,MSGL_V,"NONE :(\n");
+	return 0;
+      }
+   }
+   mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\n");
+   sh_video->format=0x10000004;
+   break;
+ }
  case DEMUXER_TYPE_PVA:
  case DEMUXER_TYPE_MPEG_ES:
  case DEMUXER_TYPE_MPEG_PS: {
@@ -315,6 +355,16 @@
 	    mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_EnterTelecineMode,sh_video->fps);
 	    telecine=1;
 	}
+
+  } else if(demuxer->file_format==DEMUXER_TYPE_MPEG4_ES){
+      //
+        while(videobuf_len<VIDEOBUFFER_SIZE-MAX_VIDEO_PACKET_SIZE){
+          int i=sync_video_packet(d_video);
+          if(!read_video_packet(d_video)) return -1; // EOF
+	  if(i==0x1B6) break;
+        }
+	*start=videobuffer; in_size=videobuf_len;
+	videobuf_len=0;
 
   } else {
       // frame-based file formats: (AVI,ASF,MOV)



More information about the MPlayer-cvslog mailing list