[Mplayer-cvslog] CVS: main demux_mpg.c,1.23,1.24 mplayer.c,1.183,1.184

Arpi of Ize arpi at mplayer.dev.hu
Mon Jul 16 22:21:29 CEST 2001


Update of /cvsroot/mplayer/main
In directory mplayer:/var/tmp.root/cvs-serv24508

Modified Files:
	demux_mpg.c mplayer.c 
Log Message:
mpeg PES steram support (only 1E0 & 1C0 packets, no 1BA/1BB headers)

Index: demux_mpg.c
===================================================================
RCS file: /cvsroot/mplayer/main/demux_mpg.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- demux_mpg.c	16 Jul 2001 15:36:20 -0000	1.23
+++ demux_mpg.c	16 Jul 2001 20:21:26 -0000	1.24
@@ -237,6 +237,7 @@
 int num_elementary_packets100=0;
 int num_elementary_packets101=0;
 int num_elementary_packets1B6=0;
+int num_elementary_packetsPES=0;
 
 int demux_mpg_es_fill_buffer(demuxer_t *demux){
   // Elementary video stream
@@ -278,6 +279,14 @@
   if(verbose>=4) printf("*** head=0x%X\n",head);
   if(demux->synced==0){
     if(head==0x1BA) demux->synced=1;
+#if 0
+    else if(head>=0x1C0 && head<=0x1EF){
+      demux->synced=2;
+      if(verbose) printf("Mpeg PES stream synced at 0x%X (%d)!\n",demux->filepos,demux->filepos);
+      num_elementary_packets100=0; // requires for re-sync!
+      num_elementary_packets101=0; // requires for re-sync!
+    }
+#endif
   } else
   if(demux->synced==1){
     if(head==0x1BB || head==0x1BD || (head>=0x1C0 && head<=0x1EF)){
@@ -301,11 +310,15 @@
       if(head==0x101) ++num_elementary_packets101;
       if(verbose>=3) printf("Opps... elementary video packet found: %03X\n",head);
     } else
+    if(head>=0x1C0 && head<0x1F0){
+      ++num_elementary_packetsPES;
+      if(verbose>=3) printf("Opps... PES packet found: %03X\n",head);
+    } else
       if(head==0x1B6) ++num_elementary_packets1B6;
 #if 1
-    if(num_elementary_packets100>50 && num_elementary_packets101>50
-       && skipped>4000000){
-        if(verbose) printf("sync_mpeg_ps: seems to be ES stream...\n");
+    if( ( (num_elementary_packets100>50 && num_elementary_packets101>50) ||
+          (num_elementary_packetsPES>50) ) && skipped>4000000){
+        if(verbose) printf("sync_mpeg_ps: seems to be ES/PES stream...\n");
         demux->stream->eof=1;
         break;
     }

Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.183
retrieving revision 1.184
diff -u -r1.183 -r1.184
--- mplayer.c	16 Jul 2001 17:07:13 -0000	1.183
+++ mplayer.c	16 Jul 2001 20:21:26 -0000	1.184
@@ -187,6 +187,7 @@
 
 extern int num_elementary_packets100; // for MPEG-ES fileformat detection
 extern int num_elementary_packets101;
+extern int num_elementary_packetsPES;
 
 extern picture_t *picture;	// exported from libmpeg2/decode.c
 
@@ -707,16 +708,25 @@
 }
 //=============== Try to open as MPEG-PS file: =================
 if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_MPEG_PS){
+ int pes=1;
+ while(pes>=0){
   stream_reset(stream);
   demuxer=new_demuxer(stream,DEMUXER_TYPE_MPEG_PS,audio_id,video_id,dvdsub_id);
   stream_seek(demuxer->stream,seek_to_byte);
+  if(!pes) demuxer->synced=1; // hack!
   if(ds_fill_buffer(demuxer->video)){
-    printf("Detected MPEG-PS file format!\n");
+    if(!pes)
+      printf("Detected MPEG-PES file format!\n");
+    else
+      printf("Detected MPEG-PS file format!\n");
     file_format=DEMUXER_TYPE_MPEG_PS;
   } else {
     // some hack to get meaningfull error messages to our unhappy users:
     if(num_elementary_packets100>=2 && num_elementary_packets101>=2 &&
        abs(num_elementary_packets101-num_elementary_packets100)<8){
+      if(num_elementary_packetsPES>=4 && num_elementary_packetsPES>=num_elementary_packets100-4){
+        --pes;continue; // tricky...
+      }
       file_format=DEMUXER_TYPE_MPEG_ES; //  <-- hack is here :)
     } else {
       if(demuxer->synced==2)
@@ -725,6 +735,8 @@
         printf("Not MPEG System Stream format... (maybe Transport Stream?)\n");
     }
   }
+  break;
+ }
 }
 //=============== Try to open as MPEG-ES file: =================
 if(file_format==DEMUXER_TYPE_MPEG_ES){ // little hack, see above!




More information about the MPlayer-cvslog mailing list