changeset 8326:4849a0cfc2aa

DMO audio support (including 6ch support too)
author arpi
date Sun, 01 Dec 2002 16:40:05 +0000
parents 5d5d1b3ec737
children e7b199b406bb
files libmpcodecs/Makefile libmpcodecs/ad.c libmpcodecs/ad_dmo.c
diffstat 3 files changed, 106 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/Makefile	Sun Dec 01 16:38:56 2002 +0000
+++ b/libmpcodecs/Makefile	Sun Dec 01 16:40:05 2002 +0000
@@ -6,7 +6,7 @@
 
 AUDIO_SRCS_LIB=ad_liba52.c ad_hwac3.c ad_mp3lib.c
 AUDIO_SRCS_NAT=ad_alaw.c ad_dk3adpcm.c ad_pcm.c ad_dvdpcm.c ad_imaadpcm.c ad_msadpcm.c ad_msgsm.c ad_roqaudio.c
-AUDIO_SRCS_OPT=ad_acm.c ad_dshow.c ad_qtaudio.c ad_ffmpeg.c ad_faad.c ad_libvorbis.c ad_libmad.c ad_realaud.c ad_libdv.c
+AUDIO_SRCS_OPT=ad_acm.c ad_dshow.c ad_dmo.c ad_qtaudio.c ad_ffmpeg.c ad_faad.c ad_libvorbis.c ad_libmad.c ad_realaud.c ad_libdv.c
 AUDIO_SRCS=dec_audio.c ad.c $(AUDIO_SRCS_LIB) $(AUDIO_SRCS_NAT) $(AUDIO_SRCS_OPT)
 
 VIDEO_SRCS_LIB=vd_libmpeg2.c vd_nuv.c vd_lzo.c
--- a/libmpcodecs/ad.c	Sun Dec 01 16:38:56 2002 +0000
+++ b/libmpcodecs/ad.c	Sun Dec 01 16:40:05 2002 +0000
@@ -29,6 +29,7 @@
 extern ad_functions_t mpcodecs_ad_dk4adpcm;
 extern ad_functions_t mpcodecs_ad_roqaudio;
 extern ad_functions_t mpcodecs_ad_dshow;
+extern ad_functions_t mpcodecs_ad_dmo;
 extern ad_functions_t mpcodecs_ad_acm;
 extern ad_functions_t mpcodecs_ad_msgsm;
 extern ad_functions_t mpcodecs_ad_faad;
@@ -62,6 +63,7 @@
 #ifdef USE_WIN32DLL
 #ifdef USE_DIRECTSHOW
   &mpcodecs_ad_dshow,
+  &mpcodecs_ad_dmo,
 #endif
   &mpcodecs_ad_acm,
 #endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libmpcodecs/ad_dmo.c	Sun Dec 01 16:40:05 2002 +0000
@@ -0,0 +1,103 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "config.h"
+#include "mp_msg.h"
+#include "help_mp.h"
+
+#ifdef USE_DIRECTSHOW
+
+#include "ad_internal.h"
+
+static ad_info_t info = 
+{
+	"Win32/DirectShow decoders",
+	"dmo",
+	"A'rpi",
+	"avifile.sf.net",
+	""
+};
+
+LIBAD_EXTERN(dmo)
+
+#include "dmo/DMO_AudioDecoder.h"
+
+static int init(sh_audio_t *sh)
+{
+  return 1;
+}
+
+extern int audio_output_channels;
+
+static int preinit(sh_audio_t *sh_audio)
+{
+  DMO_AudioDecoder* ds_adec;
+  int chans=(audio_output_channels==sh_audio->wf->nChannels) ?
+      audio_output_channels : (sh_audio->wf->nChannels>=2 ? 2 : 1);
+  if(!(ds_adec=DMO_AudioDecoder_Open(sh_audio->codec->dll,&sh_audio->codec->guid,sh_audio->wf,chans)))
+  {
+    mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_MissingDLLcodec,sh_audio->codec->dll);
+    return 0;
+  }
+    sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec;
+    sh_audio->channels=chans;
+    sh_audio->samplerate=sh_audio->wf->nSamplesPerSec;
+    sh_audio->audio_in_minsize=4*sh_audio->wf->nBlockAlign;
+    if(sh_audio->audio_in_minsize<8192) sh_audio->audio_in_minsize=8192;
+    sh_audio->audio_out_minsize=4*16384;
+    sh_audio->context = ds_adec;
+  mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32/DMO audio codec init OK!\n");
+  return 1;
+}
+
+static void uninit(sh_audio_t *sh)
+{
+    DMO_AudioDecoder* ds_adec = sh->context;
+    DMO_AudioDecoder_Destroy(ds_adec);
+}
+
+static int control(sh_audio_t *sh_audio,int cmd,void* arg, ...)
+{
+  int skip;
+    switch(cmd)
+    {
+      case ADCTRL_SKIP_FRAME:
+		    skip=sh_audio->wf->nBlockAlign;
+		    if(skip<16){
+		      skip=(sh_audio->wf->nAvgBytesPerSec/16)&(~7);
+		      if(skip<16) skip=16;
+		    }
+		    demux_read_data(sh_audio->ds,NULL,skip);
+	  return CONTROL_TRUE;
+    }
+  return CONTROL_UNKNOWN;
+}
+
+static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
+{
+	DMO_AudioDecoder* ds_adec = sh_audio->context;
+//	int len=-1;
+        int size_in=0;
+        int size_out=0;
+        int srcsize=DMO_AudioDecoder_GetSrcSize(ds_adec, maxlen);
+        mp_msg(MSGT_DECAUDIO,MSGL_DBG3,"DMO says: srcsize=%d  (buffsize=%d)  out_size=%d\n",srcsize,sh_audio->a_in_buffer_size,maxlen);
+        if(srcsize>sh_audio->a_in_buffer_size) srcsize=sh_audio->a_in_buffer_size; // !!!!!!
+        if(sh_audio->a_in_buffer_len<srcsize){
+          sh_audio->a_in_buffer_len+=
+            demux_read_data(sh_audio->ds,&sh_audio->a_in_buffer[sh_audio->a_in_buffer_len],
+            srcsize-sh_audio->a_in_buffer_len);
+        }
+        DMO_AudioDecoder_Convert(ds_adec, sh_audio->a_in_buffer,sh_audio->a_in_buffer_len,
+            buf,maxlen, &size_in,&size_out);
+        mp_dbg(MSGT_DECAUDIO,MSGL_DBG2,"DMO: audio %d -> %d converted  (in_buf_len=%d of %d)  %d\n",size_in,size_out,sh_audio->a_in_buffer_len,sh_audio->a_in_buffer_size,ds_tell_pts(sh_audio->ds));
+        if(size_in>=sh_audio->a_in_buffer_len){
+          sh_audio->a_in_buffer_len=0;
+        } else {
+          sh_audio->a_in_buffer_len-=size_in;
+          memcpy(sh_audio->a_in_buffer,&sh_audio->a_in_buffer[size_in],sh_audio->a_in_buffer_len);
+        }
+//        len=size_out;
+  return size_out;
+}
+#endif