[MPlayer-dev-eng] [PATCH] MPEG-ES in GXF demuxer

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Thu Aug 25 12:22:33 CEST 2005


Hi,
would this small patch be acceptable? It would allow playing gxf files
that contain MPEG2 video directly with MPlayer.
Since samples are rare, maybe somebody could copy those from
Address: ftp://www.ropa-net.de
Username: web49f4
Password: 123456

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libmpdemux/demux_mpg.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mpg.c,v
retrieving revision 1.60
diff -u -r1.60 demux_mpg.c
--- libmpdemux/demux_mpg.c	5 Aug 2005 19:57:46 -0000	1.60
+++ libmpdemux/demux_mpg.c	25 Aug 2005 10:17:43 -0000
@@ -408,6 +408,7 @@
 static int num_elementary_packets12x=0;
 static int num_elementary_packets1B6=0;
 static int num_elementary_packetsPES=0;
+static int num_gxf_packets=0;
 static int num_h264_slice=0; //combined slice
 static int num_h264_dpa=0; //DPA Slice
 static int num_h264_dpb=0; //DPB Slice
@@ -437,6 +438,7 @@
   num_elementary_packets1B6=0;
   num_elementary_packets12x=0;
   num_elementary_packetsPES=0;
+  num_gxf_packets=0;
   num_h264_slice=0; //combined slice
   num_h264_dpa=0; //DPA Slice
   num_h264_dpb=0; //DPB Slice
@@ -449,13 +451,14 @@
   if(demux_mpg_open(demuxer))
     file_format=DEMUXER_TYPE_MPEG_PS;
   else {
-    mp_msg(MSGT_DEMUX,MSGL_V,"MPEG packet stats: p100: %d  p101: %d p1B6: %d p12x: %d sli: %d a: %d b: %d c: %d idr: %d sps: %d pps: %d PES: %d  MP3: %d, synced: %d\n",
+    mp_msg(MSGT_DEMUX,MSGL_V,"MPEG packet stats: p100: %d  p101: %d p1B6: %d p12x: %d sli: %d a: %d b: %d c: %d idr: %d sps: %d pps: %d GXF: %d PES: %d  MP3: %d, synced: %d\n",
      num_elementary_packets100,num_elementary_packets101,
      num_elementary_packets1B6,num_elementary_packets12x,
      num_h264_slice, num_h264_dpa,
      num_h264_dpb, num_h264_dpc=0,
      num_h264_idr, num_h264_sps=0,
      num_h264_pps,
+     num_gxf_packets,
      num_elementary_packetsPES,num_mp3audio_packets, demuxer->synced);
 
      //MPEG packet stats: p100: 458  p101: 458  PES: 0  MP3: 1103  (.m2v)
@@ -464,6 +467,10 @@
        return file_format;
 
       // some hack to get meaningfull error messages to our unhappy users:
+      if (num_elementary_packets100>=2 && num_elementary_packets101>=2 &&
+          num_gxf_packets>=2)
+         file_format=DEMUXER_TYPE_MPEG_GXF;
+      else
       if(num_elementary_packets100>=2 && num_elementary_packets101>=2 &&
          abs(num_elementary_packets101+8-num_elementary_packets100)<16) {
          if(num_elementary_packetsPES>=4 && num_elementary_packetsPES>=num_elementary_packets100-4) {
@@ -579,6 +586,7 @@
       mp_msg(MSGT_DEMUX,MSGL_DBG3,"Opps... PES packet found: %03X\n",head);
     } else
       if(head==0x1B6) ++num_elementary_packets1B6;
+    else if (head == 0x1BC || head == 0x1BF) ++num_gxf_packets;
 #if 1
     if( ( (num_elementary_packets100>50 && num_elementary_packets101>50) ||
           (num_elementary_packetsPES>50) ) && skipped>4000000){
@@ -844,6 +852,22 @@
 };
 
 
+demuxer_desc_t demuxer_desc_mpeg_gxf = {
+  "MPEG ES in GXF demuxer",
+  "mpeggxf",
+  "MPEG-ES in GXF",
+  "Reimar Döffinger",
+  "Mpeg",
+  DEMUXER_TYPE_MPEG_GXF,
+  0, // hack autodetection
+  NULL,
+  demux_mpg_es_fill_buffer,
+  demux_mpg_es_open,
+  demux_close_mpg,
+  demux_seek_mpg,
+  NULL
+};
+
 demuxer_desc_t demuxer_desc_mpeg_es = {
   "MPEG ES demuxer",
   "mpeges",
Index: libmpdemux/demuxer.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.c,v
retrieving revision 1.198
diff -u -r1.198 demuxer.c
--- libmpdemux/demuxer.c	23 Aug 2005 08:03:26 -0000	1.198
+++ libmpdemux/demuxer.c	25 Aug 2005 10:17:53 -0000
@@ -51,6 +51,7 @@
 extern demuxer_desc_t demuxer_desc_mpeg_ps;
 extern demuxer_desc_t demuxer_desc_mpeg_pes;
 extern demuxer_desc_t demuxer_desc_mpeg_es;
+extern demuxer_desc_t demuxer_desc_mpeg_gxf;
 extern demuxer_desc_t demuxer_desc_mpeg4_es;
 extern demuxer_desc_t demuxer_desc_h264_es;
 extern demuxer_desc_t demuxer_desc_rawdv;
@@ -100,6 +101,7 @@
   &demuxer_desc_mpeg_ps,
   &demuxer_desc_mpeg_pes,
   &demuxer_desc_mpeg_es,
+  &demuxer_desc_mpeg_gxf,
   &demuxer_desc_mpeg4_es,
   &demuxer_desc_h264_es,
 #ifdef HAVE_LIBDV095
Index: libmpdemux/demuxer.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.h,v
retrieving revision 1.79
diff -u -r1.79 demuxer.h
--- libmpdemux/demuxer.h	5 Aug 2005 19:57:47 -0000	1.79
+++ libmpdemux/demuxer.h	25 Aug 2005 10:17:54 -0000
@@ -49,11 +49,12 @@
 #define DEMUXER_TYPE_AAC 39
 #define DEMUXER_TYPE_MPC 40
 #define DEMUXER_TYPE_MPEG_PES 41
+#define DEMUXER_TYPE_MPEG_GXF 42
 
 // 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 41
+#define DEMUXER_TYPE_MAX 42
 
 #define DEMUXER_TYPE_DEMUXERS (1<<16)
 // A virtual demuxer type for the network code
Index: libmpdemux/video.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/video.c,v
retrieving revision 1.51
diff -u -r1.51 video.c
--- libmpdemux/video.c	6 Aug 2005 16:15:07 -0000	1.51
+++ libmpdemux/video.c	25 Aug 2005 10:18:02 -0000
@@ -46,6 +46,7 @@
 
 if((d_video->demuxer->file_format == DEMUXER_TYPE_PVA) ||
    (d_video->demuxer->file_format == DEMUXER_TYPE_MPEG_ES) ||
+   (d_video->demuxer->file_format == DEMUXER_TYPE_MPEG_GXF) ||
    (d_video->demuxer->file_format == DEMUXER_TYPE_MPEG_PS && ((! sh_video->format) || (sh_video->format==0x10000001) || (sh_video->format==0x10000002))) ||
    (d_video->demuxer->file_format == DEMUXER_TYPE_MPEG_TY) ||
    (d_video->demuxer->file_format == DEMUXER_TYPE_MPEG_TS && ((sh_video->format==0x10000001) || (sh_video->format==0x10000002)))
@@ -403,6 +405,7 @@
     *start=NULL;
 
   if(demuxer->file_format==DEMUXER_TYPE_MPEG_ES || 
+     demuxer->file_format==DEMUXER_TYPE_MPEG_GXF ||
   	(demuxer->file_format==DEMUXER_TYPE_MPEG_PS && ((! sh_video->format) || (sh_video->format==0x10000001) || (sh_video->format==0x10000002)))
 		  || demuxer->file_format==DEMUXER_TYPE_PVA || 
 		  ((demuxer->file_format==DEMUXER_TYPE_MPEG_TS) && ((sh_video->format==0x10000001) || (sh_video->format==0x10000002)))
@@ -418,6 +421,14 @@
           int i=sync_video_packet(d_video);
 	  //void* buffer=&videobuffer[videobuf_len+4];
 	  int start=videobuf_len+4;
+          if (demuxer->file_format==DEMUXER_TYPE_MPEG_GXF) {
+            int discard = (i == 0x1BC || i == 0x1BF);
+            while (discard) {
+              skip_video_packet(d_video);
+              i = sync_video_packet(d_video);
+              discard = (i != 0x100);
+            }
+          }
           if(in_frame){
             if(i<0x101 || i>=0x1B0){  // not slice code -> end of frame
 #if 0


More information about the MPlayer-dev-eng mailing list