[Mplayer-cvslog] CVS: main/libmpdemux demux_mpg.c,1.42,1.43

Arpi of Ize arpi at mplayerhq.hu
Wed Oct 9 00:57:42 CEST 2002


Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var/tmp.root/cvs-serv8446

Modified Files:
	demux_mpg.c 
Log Message:
fixed LPCM parsing


Index: demux_mpg.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mpg.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- demux_mpg.c	29 Sep 2002 19:26:40 -0000	1.42
+++ demux_mpg.c	8 Oct 2002 22:57:39 -0000	1.43
@@ -107,12 +107,12 @@
     len-=2;
     mp_dbg(MSGT_DEMUX,MSGL_DBG3,"  hdrlen=%d  (len=%d)",hdrlen,len);
     if(hdrlen>len){ mp_msg(MSGT_DEMUX,MSGL_V,"demux_mpg: invalid header length  \n"); return -1;}
-    if(pts_flags==2){
+    if(pts_flags==2 && hdrlen>=5){
       c=stream_read_char(demux->stream);
       pts=read_mpeg_timestamp(demux->stream,c);
       len-=5;hdrlen-=5;
     } else
-    if(pts_flags==3){
+    if(pts_flags==3 && hdrlen>=10){
       c=stream_read_char(demux->stream);
       pts=read_mpeg_timestamp(demux->stream,c);
       c=stream_read_char(demux->stream);
@@ -154,27 +154,37 @@
         if(demux->audio->id==-1) demux->audio->id=aid;
 
       if(demux->audio->id==aid){
-//        int type;
+        int type;
         ds=demux->audio;
         if(!ds->sh) ds->sh=demux->a_streams[aid];
         // READ Packet: Skip additional audio header data:
-        c=stream_read_char(demux->stream);//type=c;
-        c=stream_read_char(demux->stream);//type|=c<<8;
-        c=stream_read_char(demux->stream);//type|=c<<16;
-//        printf("[%06X]",type);
+        c=stream_read_char(demux->stream);//num of frames
+        type=stream_read_char(demux->stream);//startpos hi
+        type=(type<<8)|stream_read_char(demux->stream);//startpos lo
+//        printf("\r[%02X][%04X]",c,type);
         len-=3;
-        if((aid&0xE0)==0xA0 && len>=2){
-          // read PCM header
-          int head;
-          head=stream_read_char(demux->stream); head=c<<8;
-          c=stream_read_char(demux->stream);    head|=c;  len-=2;
-          while(len>0 && head!=0x180){
-            head=c<<8;
-            c=stream_read_char(demux->stream);
-            head|=c;--len;
-          }
-          if(!len) mp_msg(MSGT_DEMUX,MSGL_V,"End of packet while searching for PCM header\n");
+        if((aid&0xE0)==0xA0 && len>=3){
+	  unsigned char* hdr;
+	  // save audio header as codecdata!
+	  if(!((sh_audio_t*)(ds->sh))->codecdata_len){
+	      ((sh_audio_t*)(ds->sh))->codecdata=malloc(3);
+	      ((sh_audio_t*)(ds->sh))->codecdata_len=3;
+	  }
+	  hdr=((sh_audio_t*)(ds->sh))->codecdata;
+          // read LPCM header:
+	  // emphasis[1], mute[1], rvd[1], frame number[5]:
+          hdr[0]=stream_read_char(demux->stream);
+//          printf(" [%01X:%02d]",c>>5,c&31);
+	  // quantization[2],freq[2],rvd[1],channels[3]
+          hdr[1]=stream_read_char(demux->stream);
+//          printf("[%01X:%01X] ",c>>4,c&15);
+	  // dynamic range control (0x80=off):
+          hdr[2]=stream_read_char(demux->stream);
+//          printf("[%02X] ",c);
+          len-=3;
+          if(len<=0) mp_msg(MSGT_DEMUX,MSGL_V,"End of packet while searching for PCM header\n");
         }
+//        printf("  \n");
       } //  if(demux->audio->id==aid)
 
       } else mp_msg(MSGT_DEMUX,MSGL_V,"Unknown 0x1BD substream: 0x%02X  \n",aid);




More information about the MPlayer-cvslog mailing list