changeset 1331:b4457de47804

ds->type removed - using id-based audio format detection in mplayer.c
author arpi
date Mon, 16 Jul 2001 15:36:20 +0000
parents 8940480b3856
children cba6d263bf85
files demux_mpg.c demuxer.c demuxer.h mplayer.c
diffstat 4 files changed, 5 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/demux_mpg.c	Mon Jul 16 15:09:34 2001 +0000
+++ b/demux_mpg.c	Mon Jul 16 15:36:20 2001 +0000
@@ -13,10 +13,6 @@
 //#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 int mpeg_pts_error=0;
 
 static unsigned int read_mpeg_timestamp(stream_t *s,int c){
@@ -33,7 +29,6 @@
   return pts;
 }
 
-//static char dvdaudio_table[256];
 //static unsigned int packet_start_pos=0;
 
 extern void *new_sh_audio(demuxer_t *demux,int id);
@@ -65,7 +60,6 @@
   len=stream_read_word(demux->stream);
   if(verbose>=3)  printf("PACKET len=%d",len);
 //  if(len==62480){ demux->synced=0;return -1;} /* :) */
-//  if(len==0 || len>MAX_PS_PACKETSIZE) return -2;  // invalid packet !!!!!!
   if(len==0 || len>MAX_PS_PACKETSIZE){
     if(verbose>=2) printf("Invalid PS packet len: %d\n",len);
     return -2;  // invalid packet !!!!!!
@@ -144,10 +138,8 @@
         if(!demux->s_streams[aid]){
             printf("==> Found subtitle: %d\n",aid);
             demux->s_streams[aid]=1;
-            // new_sh_audio(aid);
         }
 
-        //if(demux->audio->id==-1) demux->audio->id=aid; // autodetect :)
         if(demux->sub->id==aid){
             ds=demux->sub;
         }
@@ -170,11 +162,7 @@
         c=stream_read_char(demux->stream);//type|=c<<16;
 //        printf("[%06X]",type);
         len-=3;
-        if(ds->type==-1){
-          // autodetect type
-          ds->type=((aid&0xE0)==0xA0)?2:3;
-        }
-        if(ds->type==2 && len>=2){
+        if((aid&0xE0)==0xA0 && len>=2){
           // read PCM header
           int head;
           head=stream_read_char(demux->stream); head=c<<8;
@@ -215,7 +203,6 @@
     if(demux->audio->id==aid){
       ds=demux->audio;
       if(!ds->sh) ds->sh=demux->a_streams[aid];
-      if(ds->type==-1) ds->type=1;
     }
   } else
   if(id>=0x1E0 && id<=0x1EF){
@@ -252,7 +239,6 @@
 int num_elementary_packets1B6=0;
 
 int demux_mpg_es_fill_buffer(demuxer_t *demux){
-//if(demux->type==DEMUXER_TYPE_MPEG_ES)
   // Elementary video stream
   if(demux->stream->eof) return 0;
   demux->filepos=stream_tell(demux->stream);
--- a/demuxer.c	Mon Jul 16 15:09:34 2001 +0000
+++ b/demuxer.c	Mon Jul 16 15:36:20 2001 +0000
@@ -23,7 +23,6 @@
   ds->bytes=0;
   ds->first=ds->last=NULL;
   ds->id=id;
-  ds->type=-1;
   ds->demuxer=demuxer;
 //----------------
   ds->asf_seq=-1;
--- a/demuxer.h	Mon Jul 16 15:09:34 2001 +0000
+++ b/demuxer.h	Mon Jul 16 15:36:20 2001 +0000
@@ -44,7 +44,6 @@
   demux_packet_t *first;  // read to current buffer from here
   demux_packet_t *last;   // append new packets from input stream to here
   int id;                 // stream ID  (for multiple audio/video streams)
-  int type;               // stream type (currently used only for mpg-PS audio)
   struct demuxer_st *demuxer; // parent demuxer structure (stream handler)
 // ---- asf -----
   demux_packet_t *asf_packet;  // read asf fragments here
--- a/mplayer.c	Mon Jul 16 15:09:34 2001 +0000
+++ b/mplayer.c	Mon Jul 16 15:36:20 2001 +0000
@@ -911,11 +911,10 @@
     has_audio=0;sh_audio=NULL;
   } else {
     sh_audio=d_audio->sh;sh_audio->ds=d_audio;
-    if(verbose) printf("detected MPG-PS audio format: %d\n",d_audio->type);
-    switch(d_audio->type){
-      case 1: sh_audio->format=0x50;break; // mpeg
-      case 2: sh_audio->format=0x10001;break;  // dvd pcm
-      case 3: sh_audio->format=0x2000;break; // ac3
+    switch(d_audio->id & 0xE0){  // 1110 0000 b  (high 3 bit: type  low 5: id)
+      case 0x00: sh_audio->format=0x50;break; // mpeg
+      case 0xA0: sh_audio->format=0x10001;break;  // dvd pcm
+      case 0x80: sh_audio->format=0x2000;break; // ac3
       default: has_audio=0;sh_audio=NULL; // unknown type
     }
   }