changeset 190:a8552ad553e0

DirectShow audio support
author arpi_esp
date Thu, 22 Mar 2001 01:57:58 +0000
parents 45778577e6aa
children aa52cdb712d8
files codecs.c mplayer.c
diffstat 2 files changed, 61 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/codecs.c	Thu Mar 22 01:55:53 2001 +0000
+++ b/codecs.c	Thu Mar 22 01:57:58 2001 +0000
@@ -1,8 +1,23 @@
 //#define ANGELPOTION
 //#define USE_DIRECTSHOW
 
-static GUID CLSID_DivxDecompressorCF={0x82CCd3E0, 0xF71A, 0x11D0,
+static    GUID wmv1_clsid={0x4facbba1, 0xffd8, 0x4cd7,
+    {0x82, 0x28, 0x61, 0xe2, 0xf6, 0x5c, 0xb1, 0xae}};
+static    GUID wmv2_clsid={0x521fb373, 0x7654, 0x49f2, 
+    {0xbd, 0xb1, 0x0c, 0x6e, 0x66, 0x60, 0x71, 0x4f}};    
+static    GUID CLSID_MorganMjpeg={0x6988b440, 0x8352, 0x11d3, 
+    {0x9b, 0xda, 0xca, 0x86, 0x73, 0x7c, 0x71, 0x68}};
+static    GUID CLSID_Acelp={0x4009f700, 0xaeba, 0x11d1,
+    {0x83, 0x44, 0x00, 0xc0, 0x4f, 0xb9, 0x2e, 0xb7}};
+static    GUID CLSID_Voxware={0x73f7a062, 0x8829, 0x11d1,
+    {0xb5, 0x50, 0x00, 0x60, 0x97, 0x24, 0x2d, 0x8d}};
+static    GUID CLSID_DivxDecompressorCF={0x82CCd3E0, 0xF71A, 0x11D0,
     { 0x9f, 0xe5, 0x00, 0x60, 0x97, 0x78, 0xaa, 0xaa}};
+static    GUID CLSID_IV50_Decoder={0x30355649, 0x0000, 0x0010,
+    {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
+static    GUID dvsd_clsid={0xB1B77C00, 0xC3E4, 0x11CF,
+    {0xAF, 0x79, 0x00, 0xAA, 0x00, 0xB6, 0x7A, 0x42}};
+
 
 char* get_vids_codec_name(){
 //  unsigned long fccHandler=avi_header.video.fccHandler;
@@ -134,6 +149,14 @@
           return "mcmjpg32.dll";
 //          return "m3jpeg32.dll";
 //          return "libavi_mjpeg.so";
+
+	case mmioFOURCC('W', 'M', 'V', '1'):
+	  printf("Video in Windows Media Video 1 format\n");
+          avi_header.yuv_supported=1;
+          avi_header.vids_guid=&wmv1_clsid;
+          return "wmvds32.ax";
+
+
   }
   printf("UNKNOWN video codec: %.4s (0x%0X)\n",&fccHandler,fccHandler);
   printf("If you know this video format and codec, you can edit codecs.c in the source!\n");
@@ -162,7 +185,8 @@
 	case 0x32://MS GSM
             return "msgsm32.acm";   // segfault :( - not req. has internal now!
         case 0x75://VoxWare
-            return "voxmsdec.ax";   // directshow, not yet supported just a try
+            avi_header.auds_guid=&CLSID_Voxware;
+            return "voxmsdec.ax";
 //	case 0x06://???
 //            return "lhacm.acm";
 //            return "msg711.acm";
--- a/mplayer.c	Thu Mar 22 01:55:53 2001 +0000
+++ b/mplayer.c	Thu Mar 22 01:57:58 2001 +0000
@@ -58,6 +58,7 @@
 
 #ifdef USE_DIRECTSHOW
 #include "DirectShow/DS_VideoDec.h"
+#include "DirectShow/DS_AudioDec.h"
 #endif
 
 #include "opendivx/decore.h"
@@ -367,8 +368,8 @@
 int stream_type;
 stream_t* stream=NULL;
 int file_format=DEMUXER_TYPE_UNKNOWN;
-int has_audio=1; // audio format 0=no 1=mpeg 2=pcm 3=ac3 4=win32 5=alaw 6=msgsm
-int has_video=0; // video format 0=no 1=mpeg 2=win32/VfW 3=OpenDivX 4=w32/DShow
+int has_audio=1; // audio  0=no 1=mpeg 2=pcm 3=ac3 4=ACM 5=alaw 6=msgsm 7=DShow
+int has_video=0; // video  0=no 1=mpeg 2=win32/VfW 3=OpenDivX 4=w32/DShow
 //
 int audio_format=0; // override
 #ifdef ALSA_TIMER
@@ -676,6 +677,7 @@
   if(verbose) printf("detected AVI audio format: %d\n",has_audio);
   if(has_audio==4){
     if(!avi_header.audio_codec) avi_header.audio_codec=get_auds_codec_name();
+    if(avi_header.auds_guid) has_audio=7; // force DShow
     if(!avi_header.audio_codec) has_audio=0; // unknown win32 codec
     if(verbose) printf("win32 audio codec: '%s'\n",avi_header.audio_codec);
   }
@@ -743,6 +745,7 @@
   if(verbose) printf("detected ASF audio format: %d\n",has_audio);
   if(has_audio==4){
     if(!avi_header.audio_codec) avi_header.audio_codec=get_auds_codec_name();
+    if(avi_header.auds_guid) has_audio=7; // force DShow
     if(!avi_header.audio_codec) has_audio=0; // unknown win32 codec
     if(verbose) printf("win32 audio codec: '%s'\n",avi_header.audio_codec);
   }
@@ -1166,6 +1169,36 @@
   }
 }
 
+if(has_audio==7){
+#ifndef USE_DIRECTSHOW
+  printf("Compiled without DirectShow support -> force nosound :(\n");
+  has_audio=0;
+#else
+  // Win32 DShow audio codec:
+    WAVEFORMATEX *in_fmt=(WAVEFORMATEX*)&avi_header.wf_ext;
+    avi_header.wf.nChannels=in_fmt->nChannels;
+    avi_header.wf.nSamplesPerSec=in_fmt->nSamplesPerSec;
+    avi_header.wf.nAvgBytesPerSec=2*avi_header.wf.nSamplesPerSec*avi_header.wf.nChannels;
+    avi_header.wf.wFormatTag=WAVE_FORMAT_PCM;
+    avi_header.wf.nBlockAlign=2*in_fmt->nChannels;
+    avi_header.wf.wBitsPerSample=16;
+    avi_header.wf.cbSize=0;
+
+  if(!DS_AudioDecoder_Open(avi_header.audio_codec,avi_header.auds_guid,in_fmt)){
+    MP3_channels=avi_header.wf.nChannels;
+    MP3_samplerate=avi_header.wf.nSamplesPerSec;
+  } else {
+    printf("Could not load/initialize Win32/DirctShow AUDIO codec (missing .AX file?)\n");
+    if((in_fmt->wFormatTag)==0x55){
+      printf("Audio format is MP3 -> fallback to internal mp3lib/mpg123\n");
+      has_audio=1;  // fallback to mp3lib
+    } else
+      has_audio=0;  // nosound
+  }
+#endif
+}
+
+
 // allocate audio out buffer:
 a_buffer=malloc(a_buffer_size);
 memset(a_buffer,0,a_buffer_size);