changeset 554:d8b3c80604e3

dvd sub parser move dto mplayer.c
author arpi_esp
date Fri, 20 Apr 2001 23:00:11 +0000
parents 576d0157aa42
children 5bfbe42747e5
files demux_mpg.c demuxer.c mplayer.c
diffstat 3 files changed, 31 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/demux_mpg.c	Fri Apr 20 22:43:22 2001 +0000
+++ b/demux_mpg.c	Fri Apr 20 23:00:11 2001 +0000
@@ -3,9 +3,9 @@
 //#define MAX_PS_PACKETSIZE 2048
 #define MAX_PS_PACKETSIZE (224*1024)
 
-static void parse_dvdsub(unsigned char *buf,int len){
-    printf("\rDVDsub packet: %d  \n",len);
-}
+//static void parse_dvdsub(unsigned char *buf,int len){
+//    printf("\rDVDsub packet: %d  \n",len);
+//}
 
 static int mpeg_pts_error=0;
 
@@ -226,7 +226,7 @@
     }
 #endif
     ds_read_packet(ds,demux->stream,len,pts/90000.0f,0);
-    if(ds==demux->sub) parse_dvdsub(ds->last->buffer,ds->last->len);
+//    if(ds==demux->sub) parse_dvdsub(ds->last->buffer,ds->last->len);
     return 1;
   }
   if(verbose>=2) printf("DEMUX_MPG: Skipping %d data bytes from packet %04X\n",len,id);
@@ -289,14 +289,12 @@
   } // else
   if(demux->synced==2){
       ret=demux_mpg_read_packet(demux,head);
-/*
       if(!ret)
         if(--max_packs==0){
           demux->stream->eof=1;
           printf("demux: file doesn't contain the selected audio or video stream\n");
           return 0;
         }
-*/
   } else {
     if(head>=0x100 && head<0x1B0){
       if(head==0x100)
--- a/demuxer.c	Fri Apr 20 22:43:22 2001 +0000
+++ b/demuxer.c	Fri Apr 20 23:00:11 2001 +0000
@@ -289,3 +289,19 @@
         return len;
     }
 }
+
+int ds_get_packet_sub(demux_stream_t *ds,char **start){
+    while(1){
+        int len;
+        if(ds->buffer_pos>=ds->buffer_size){
+          *start = NULL;
+          if(!ds->packs) return -1; // no sub
+          if(!ds_fill_buffer(ds)) return -1; // EOF
+        }
+        len=ds->buffer_size-ds->buffer_pos;
+        *start = &ds->buffer[ds->buffer_pos];
+        ds->buffer_pos+=len;
+        return len;
+    }
+}
+
--- a/mplayer.c	Fri Apr 20 22:43:22 2001 +0000
+++ b/mplayer.c	Fri Apr 20 23:00:11 2001 +0000
@@ -289,6 +289,7 @@
 demuxer_t *demuxer=NULL;
 demux_stream_t *d_audio=NULL;
 demux_stream_t *d_video=NULL;
+demux_stream_t *d_dvdsub=NULL;
 
 sh_audio_t *sh_audio=NULL;//&sh_audio_i;
 sh_video_t *sh_video=NULL;//&sh_video_i;
@@ -708,6 +709,7 @@
 //====== File format recognized, set up these for compatibility: =========
 d_audio=demuxer->audio;
 d_video=demuxer->video;
+d_dvdsub=demuxer->sub;
 //d_audio->sh=sh_audio; 
 //d_video->sh=sh_video; 
 //sh_audio=d_audio->sh;sh_audio->ds=d_audio;
@@ -2039,6 +2041,15 @@
       find_sub(sub_uses_time?(100*(v_pts+sub_delay)):((v_pts+sub_delay)*sub_fps)); // FIXME! frame counter...
       current_module=NULL;
   }
+  
+  // DVD sub:
+  { unsigned char* buf=NULL;
+    int len=ds_get_packet_sub(d_dvdsub,&buf);
+    if(len>0){
+       printf("\rDVD sub: %d   \n",len);
+    }
+  }
+  
 }
 
 } // while(!eof)