changeset 3770:4f1a99fb9d9a

mpeg VDR vs. BIN fixed?
author arpi
date Wed, 26 Dec 2001 16:34:06 +0000
parents 8398ffdc0a8e
children a14b3a600b81
files libmpdemux/demux_mpg.c libmpdemux/demuxer.c
diffstat 2 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_mpg.c	Wed Dec 26 15:55:24 2001 +0000
+++ b/libmpdemux/demux_mpg.c	Wed Dec 26 16:34:06 2001 +0000
@@ -278,8 +278,8 @@
   // sure: head=0x000001XX
   mp_dbg(MSGT_DEMUX,MSGL_DBG4,"*** head=0x%X\n",head);
   if(demux->synced==0){
-    if(head==0x1BA) demux->synced=1; else
-    if(head==0x1BD || (head>=0x1C0 && head<=0x1EF)) demux->synced=3; // PES?
+    if(head==0x1BA) demux->synced=1; //else
+//    if(head==0x1BD || (head>=0x1C0 && head<=0x1EF)) demux->synced=3; // PES?
   } else
   if(demux->synced==1){
     if(head==0x1BB || head==0x1BD || (head>=0x1C0 && head<=0x1EF)){
--- a/libmpdemux/demuxer.c	Wed Dec 26 15:55:24 2001 +0000
+++ b/libmpdemux/demuxer.c	Wed Dec 26 16:34:06 2001 +0000
@@ -441,9 +441,20 @@
 //=============== Try to open as MPEG-PS file: =================
 if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_MPEG_PS){
  int pes=1;
+ int tmp;
  while(pes>=0){
   demuxer=new_demuxer(stream,DEMUXER_TYPE_MPEG_PS,audio_id,video_id,dvdsub_id);
-  if(!pes) demuxer->synced=1; // hack!
+  
+  // try to pre-detect PES:
+  tmp=stream_read_dword(demuxer->stream);
+  if(tmp==0x1E0 || tmp==0x1C0){
+      tmp=stream_read_word(demuxer->stream);
+      if(tmp>1 && tmp<=2048) pes=0; // demuxer->synced=3; // PES...
+  }
+  stream_seek(demuxer->stream,0);
+  
+  if(!pes) demuxer->synced=3; // hack!
+
   num_elementary_packets100=0;
   num_elementary_packets101=0;
   num_elementary_packets1B6=0;