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

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Fri Aug 26 14:19:48 CEST 2005


Hi,
On Fri, Aug 26, 2005 at 12:15:56AM +0200, Nico Sabbi wrote:
> it's demux_mpg_probe().
> If you set demux_mpg_pes_probe() as probing function you should
> get what you need.

Won't work. synced is never 3 at that place, also the num_* variables
aren't counted when detection is started with synced==3.
This is too much effort. Attached patch just does extension based
detection. Also removed the seeking function since it currently can't
work.

Greetings,
Reimar Döffinger
-------------- next part --------------
diff -u libmpdemux/demux_mpg.c libmpdemux/demux_mpg.c
--- libmpdemux/demux_mpg.c	2005-08-06 15:32:05.000000000 +0200
+++ libmpdemux/demux_mpg.c	2005-08-26 13:38:30.000000000 +0200
@@ -506,6 +506,36 @@
   return 1;
 }
 
+static int demux_mpg_gxf_fill_buffer(demuxer_t *demux, demux_stream_t *ds) {
+  demux_packet_t *pack;
+  uint32_t state = (uint32_t)demux->priv;
+  int pos = 0;
+  int discard = 0;
+  unsigned char *buf;
+  if (demux->stream->eof)
+    return 0;
+  demux->filepos = stream_tell(demux->stream);
+  pack = new_demux_packet(STREAM_BUFFER_SIZE);
+  buf = pack->buffer;
+  while (pos < STREAM_BUFFER_SIZE) {
+    register int c = stream_read_char(demux->stream);
+    if (c < 0) { // EOF
+      resize_demux_packet(pack, pos);
+      break;
+    }
+    state = state << 8 | c;
+    if (state == 0x1bc || state == 0x1bf)
+      discard = 1;
+    else if (state == 0x100)
+      discard = 0;
+    if (!discard)
+      buf[pos++] = c;
+  }
+  ds_add_packet(ds, pack);
+  demux->priv = (void *)state;
+  return 1;
+}
+
 int demux_mpg_fill_buffer(demuxer_t *demux, demux_stream_t *ds){
 unsigned int head=0;
 int skipped=0;
@@ -789,6 +819,13 @@
     return demuxer;
 }
 
+static demuxer_t *demux_mpg_gxf_open(demuxer_t *demuxer) {
+  demuxer->audio->sh = NULL;
+  demuxer->video->sh = new_sh_video(demuxer,0);
+  ((sh_video_t *)demuxer->video->sh)->ds = demuxer->video;
+  demuxer->priv = (void *) 0xffffffff;
+  return demuxer;
+}
 
 static demuxer_t* demux_mpg_ps_open(demuxer_t* demuxer)
 {
@@ -844,6 +881,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_gxf_fill_buffer,
+  demux_mpg_gxf_open,
+  NULL,
+  NULL,
+  NULL
+};
+
 demuxer_desc_t demuxer_desc_mpeg_es = {
   "MPEG ES demuxer",
   "mpeges",
diff -u libmpdemux/demuxer.c libmpdemux/demuxer.c
--- libmpdemux/demuxer.c	2005-08-23 10:00:55.000000000 +0200
+++ libmpdemux/demuxer.c	2005-08-25 12:10:10.000000000 +0200
@@ -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
diff -u libmpdemux/demuxer.h libmpdemux/demuxer.h
--- libmpdemux/demuxer.h	2005-08-06 15:32:07.000000000 +0200
+++ libmpdemux/demuxer.h	2005-08-25 12:09:01.000000000 +0200
@@ -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
diff -u libmpdemux/extension.c libmpdemux/extension.c
--- libmpdemux/extension.c	2005-04-18 22:40:40.000000000 +0200
+++ libmpdemux/extension.c	2005-08-26 13:38:44.000000000 +0200
@@ -20,6 +20,7 @@
 //        { "mpe", DEMUXER_TYPE_MPEG_PS },
         { "vob", DEMUXER_TYPE_MPEG_PS },
         { "m2v", DEMUXER_TYPE_MPEG_PS },
+        { "gxf", DEMUXER_TYPE_MPEG_GXF },
         { "avi", DEMUXER_TYPE_AVI },
         { "mp4", DEMUXER_TYPE_MOV },
         { "mov", DEMUXER_TYPE_MOV },
diff -u libmpdemux/video.c libmpdemux/video.c
--- libmpdemux/video.c	2005-08-14 22:01:10.000000000 +0200
+++ libmpdemux/video.c	2005-08-26 13:14:21.000000000 +0200
@@ -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)))


More information about the MPlayer-dev-eng mailing list