From aebfbbf2bdda8e18beef90c16da97bd335f7d3b0 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 12 Aug 2012 15:30:21 +0200 Subject: Remove win32/qt/xanim/real binary codecs loading Remove the win32 loader - the win32 emulation layer, as well as the code for using DirectShow/DMO/VFW codecs. Remove loading of xanim, QuickTime, and RealMedia codecs. The win32 emulation layer is based on a very old version of wine. Apparently, wine code was copied and hacked until it was somehow able to load a limited collection of binary codecs. It poked around in the code segment of some known binary codecs to disable unsupported win32 API calls to make them work. Example from module.c: for (i=0;i<5;i++) RVA(0x19e842)[i]=0x90; // make_new_region ? for (i=0;i<28;i++) RVA(0x19e86d)[i]=0x90; // call__call_CreateCompatibleDC ? for (i=0;i<5;i++) RVA(0x19e898)[i]=0x90; // jmp_to_call_loadbitmap ? for (i=0;i<9;i++) RVA(0x19e8ac)[i]=0x90; // call__calls_OLE_shit ? for (i=0;i<106;i++) RVA(0x261b10)[i]=0x90; // disable threads Just to show how utterly insane this code is. You wouldn't want even your worst enemy to have to maintain this. In fact, it seems nobody made major changes to this code ever since it was committed. Most formats can be decoded by libavcodecs these days, and the loader couldn't be used on 64 bit platforms anyway. The same is (probably) true for the other binary codecs. General note about how support for win32 codecs could be added back: It's not possible to replace the win32 loader code by using wine as library, because modern wine can not be linked with native Linux programs for certain reasons. It would be possible to to move DirectShow video decoding into a separate process linked with wine, like the CoreAVC-for-Linux patches do. There is also the mplayer-ww fork, which uses the dshownative library to use DirectShow codecs on Windows. --- Makefile | 57 - cfg-mplayer.h | 1 - configure | 183 +- libmpcodecs/ad.c | 19 - libmpcodecs/ad_acm.c | 259 -- libmpcodecs/ad_dmo.c | 126 - libmpcodecs/ad_dshow.c | 114 - libmpcodecs/ad_qtaudio.c | 353 --- libmpcodecs/ad_realaud.c | 463 ---- libmpcodecs/vd.c | 20 - libmpcodecs/vd_dmo.c | 134 - libmpcodecs/vd_dshow.c | 133 - libmpcodecs/vd_qtvideo.c | 321 --- libmpcodecs/vd_realvid.c | 453 ---- libmpcodecs/vd_vfw.c | 355 --- libmpcodecs/vd_vfwex.c | 4 - libmpcodecs/vd_xanim.c | 854 ------ libmpdemux/demux_avs.c | 476 ---- libmpdemux/demux_avs.h | 173 -- libmpdemux/demux_mkv.c | 33 +- loader/afl.c | 763 ------ loader/com.h | 82 - loader/debug.h | 12 - loader/dmo/DMO_AudioDecoder.c | 171 -- loader/dmo/DMO_AudioDecoder.h | 20 - loader/dmo/DMO_Filter.h | 39 - loader/dmo/DMO_VideoDecoder.c | 555 ---- loader/dmo/DMO_VideoDecoder.h | 29 - loader/dmo/buffer.c | 119 - loader/dmo/dmo.c | 166 -- loader/dmo/dmo.h | 81 - loader/dmo/dmo_guids.c | 41 - loader/dmo/dmo_guids.h | 35 - loader/dmo/dmo_interfaces.h | 194 -- loader/drv.c | 176 -- loader/drv.h | 18 - loader/dshow/DS_AudioDecoder.c | 192 -- loader/dshow/DS_AudioDecoder.h | 20 - loader/dshow/DS_Filter.c | 318 --- loader/dshow/DS_Filter.h | 42 - loader/dshow/DS_VideoDecoder.c | 916 ------- loader/dshow/DS_VideoDecoder.h | 32 - loader/dshow/allocator.c | 363 --- loader/dshow/allocator.h | 27 - loader/dshow/cmediasample.c | 576 ---- loader/dshow/cmediasample.h | 32 - loader/dshow/graph.c | 165 -- loader/dshow/graph.h | 57 - loader/dshow/guids.c | 83 - loader/dshow/guids.h | 89 - loader/dshow/inputpin.c | 1492 ----------- loader/dshow/inputpin.h | 70 - loader/dshow/interfaces.h | 360 --- loader/dshow/iunk.h | 54 - loader/dshow/libwin32.h | 256 -- loader/dshow/mediatype.c | 161 -- loader/dshow/mediatype.h | 96 - loader/dshow/outputpin.c | 957 ------- loader/dshow/outputpin.h | 32 - loader/elfdll.c | 292 -- loader/ext.c | 593 ----- loader/ext.h | 19 - loader/ldt_keeper.c | 275 -- loader/ldt_keeper.h | 15 - loader/loader.h | 36 - loader/module.c | 1075 -------- loader/pe_image.c | 949 ------- loader/pe_resource.c | 396 --- loader/qt_comp_template.c | 27 - loader/qt_fv.h | 1593 ----------- loader/qtx/qtxsdk/components.h | 757 ------ loader/qtx/qtxsdk/select.h | 72 - loader/registry.c | 531 ---- loader/registry.h | 40 - loader/resource.c | 487 ---- loader/vfl.c | 228 -- loader/win32.c | 5779 ---------------------------------------- loader/win32.h | 34 - loader/wine/avifmt.h | 240 -- loader/wine/basetsd.h | 152 -- loader/wine/debugtools.h | 71 - loader/wine/driver.h | 110 - loader/wine/elfdll.h | 13 - loader/wine/heap.h | 56 - loader/wine/ldt.h | 92 - loader/wine/mmreg.h | 249 -- loader/wine/module.h | 149 -- loader/wine/msacm.h | 935 ------- loader/wine/msacmdrv.h | 203 -- loader/wine/ntdef.h | 93 - loader/wine/objbase.h | 22 - loader/wine/pe_image.h | 81 - loader/wine/poppack.h | 15 - loader/wine/pshpack1.h | 12 - loader/wine/pshpack2.h | 12 - loader/wine/pshpack4.h | 14 - loader/wine/pshpack8.h | 12 - loader/wine/vfw.h | 669 ----- loader/wine/winbase.h | 1777 ------------ loader/wine/windef.h | 628 ----- loader/wine/windows.h | 30 - loader/wine/winerror.h | 1658 ------------ loader/wine/winestring.h | 13 - loader/wine/winnt.h | 2663 ------------------ loader/wine/winreg.h | 49 - loader/wine/winuser.h | 2922 -------------------- loader/wineacm.h | 62 - loader/wrapper.S | 88 - loader/wrapper.h | 19 - mplayer.c | 17 - path.c | 23 - path.h | 4 - stream/tvi_dshow.c | 3514 ------------------------ stream/tvi_dshow.h | 728 ----- 114 files changed, 2 insertions(+), 44013 deletions(-) delete mode 100644 libmpcodecs/ad_acm.c delete mode 100644 libmpcodecs/ad_dmo.c delete mode 100644 libmpcodecs/ad_dshow.c delete mode 100644 libmpcodecs/ad_qtaudio.c delete mode 100644 libmpcodecs/ad_realaud.c delete mode 100644 libmpcodecs/vd_dmo.c delete mode 100644 libmpcodecs/vd_dshow.c delete mode 100644 libmpcodecs/vd_qtvideo.c delete mode 100644 libmpcodecs/vd_realvid.c delete mode 100644 libmpcodecs/vd_vfw.c delete mode 100644 libmpcodecs/vd_vfwex.c delete mode 100644 libmpcodecs/vd_xanim.c delete mode 100644 libmpdemux/demux_avs.c delete mode 100644 libmpdemux/demux_avs.h delete mode 100644 loader/afl.c delete mode 100644 loader/com.h delete mode 100644 loader/debug.h delete mode 100644 loader/dmo/DMO_AudioDecoder.c delete mode 100644 loader/dmo/DMO_AudioDecoder.h delete mode 100644 loader/dmo/DMO_Filter.h delete mode 100644 loader/dmo/DMO_VideoDecoder.c delete mode 100644 loader/dmo/DMO_VideoDecoder.h delete mode 100644 loader/dmo/buffer.c delete mode 100644 loader/dmo/dmo.c delete mode 100644 loader/dmo/dmo.h delete mode 100644 loader/dmo/dmo_guids.c delete mode 100644 loader/dmo/dmo_guids.h delete mode 100644 loader/dmo/dmo_interfaces.h delete mode 100644 loader/drv.c delete mode 100644 loader/drv.h delete mode 100644 loader/dshow/DS_AudioDecoder.c delete mode 100644 loader/dshow/DS_AudioDecoder.h delete mode 100644 loader/dshow/DS_Filter.c delete mode 100644 loader/dshow/DS_Filter.h delete mode 100644 loader/dshow/DS_VideoDecoder.c delete mode 100644 loader/dshow/DS_VideoDecoder.h delete mode 100644 loader/dshow/allocator.c delete mode 100644 loader/dshow/allocator.h delete mode 100644 loader/dshow/cmediasample.c delete mode 100644 loader/dshow/cmediasample.h delete mode 100644 loader/dshow/graph.c delete mode 100644 loader/dshow/graph.h delete mode 100644 loader/dshow/guids.c delete mode 100644 loader/dshow/guids.h delete mode 100644 loader/dshow/inputpin.c delete mode 100644 loader/dshow/inputpin.h delete mode 100644 loader/dshow/interfaces.h delete mode 100644 loader/dshow/iunk.h delete mode 100644 loader/dshow/libwin32.h delete mode 100644 loader/dshow/mediatype.c delete mode 100644 loader/dshow/mediatype.h delete mode 100644 loader/dshow/outputpin.c delete mode 100644 loader/dshow/outputpin.h delete mode 100644 loader/elfdll.c delete mode 100644 loader/ext.c delete mode 100644 loader/ext.h delete mode 100644 loader/ldt_keeper.c delete mode 100644 loader/ldt_keeper.h delete mode 100644 loader/loader.h delete mode 100644 loader/module.c delete mode 100644 loader/pe_image.c delete mode 100644 loader/pe_resource.c delete mode 100644 loader/qt_comp_template.c delete mode 100644 loader/qt_fv.h delete mode 100644 loader/qtx/qtxsdk/components.h delete mode 100644 loader/qtx/qtxsdk/select.h delete mode 100644 loader/registry.c delete mode 100644 loader/registry.h delete mode 100644 loader/resource.c delete mode 100644 loader/vfl.c delete mode 100644 loader/win32.c delete mode 100644 loader/win32.h delete mode 100644 loader/wine/avifmt.h delete mode 100644 loader/wine/basetsd.h delete mode 100644 loader/wine/debugtools.h delete mode 100644 loader/wine/driver.h delete mode 100644 loader/wine/elfdll.h delete mode 100644 loader/wine/heap.h delete mode 100644 loader/wine/ldt.h delete mode 100644 loader/wine/mmreg.h delete mode 100644 loader/wine/module.h delete mode 100644 loader/wine/msacm.h delete mode 100644 loader/wine/msacmdrv.h delete mode 100644 loader/wine/ntdef.h delete mode 100644 loader/wine/objbase.h delete mode 100644 loader/wine/pe_image.h delete mode 100644 loader/wine/poppack.h delete mode 100644 loader/wine/pshpack1.h delete mode 100644 loader/wine/pshpack2.h delete mode 100644 loader/wine/pshpack4.h delete mode 100644 loader/wine/pshpack8.h delete mode 100644 loader/wine/vfw.h delete mode 100644 loader/wine/winbase.h delete mode 100644 loader/wine/windef.h delete mode 100644 loader/wine/windows.h delete mode 100644 loader/wine/winerror.h delete mode 100644 loader/wine/winestring.h delete mode 100644 loader/wine/winnt.h delete mode 100644 loader/wine/winreg.h delete mode 100644 loader/wine/winuser.h delete mode 100644 loader/wineacm.h delete mode 100644 loader/wrapper.S delete mode 100644 loader/wrapper.h delete mode 100644 stream/tvi_dshow.c delete mode 100644 stream/tvi_dshow.h diff --git a/Makefile b/Makefile index 81bf045dc0..a679e8e7ca 100644 --- a/Makefile +++ b/Makefile @@ -120,66 +120,17 @@ SRCS_COMMON-$(NETWORKING) += stream/stream_netstream.c \ SRCS_COMMON-$(PNG) += libmpcodecs/vd_mpng.c SRCS_COMMON-$(PRIORITY) += osdep/priority.c SRCS_COMMON-$(PVR) += stream/stream_pvr.c -SRCS_COMMON-$(QTX_CODECS) += libmpcodecs/ad_qtaudio.c \ - libmpcodecs/vd_qtvideo.c SRCS_COMMON-$(RADIO) += stream/stream_radio.c SRCS_COMMON-$(RADIO_CAPTURE) += stream/audio_in.c -SRCS_COMMON-$(REAL_CODECS) += libmpcodecs/ad_realaud.c \ - libmpcodecs/vd_realvid.c SRCS_COMMON-$(STREAM_CACHE) += stream/cache2.c SRCS_COMMON-$(TV) += stream/stream_tv.c stream/tv.c \ stream/frequencies.c stream/tvi_dummy.c SRCS_COMMON-$(TV_BSDBT848) += stream/tvi_bsdbt848.c -SRCS_COMMON-$(TV_DSHOW) += stream/tvi_dshow.c \ - loader/dshow/guids.c \ - loader/dshow/mediatype.c \ SRCS_COMMON-$(TV_V4L2) += stream/tvi_v4l2.c stream/audio_in.c SRCS_COMMON-$(VCD) += stream/stream_vcd.c SRCS_COMMON-$(VSTREAM) += stream/stream_vstream.c -SRCS_QTX_EMULATION += loader/wrapper.S -SRCS_COMMON-$(QTX_EMULATION) += $(SRCS_QTX_EMULATION) -SRCS_WIN32_EMULATION += loader/elfdll.c \ - loader/ext.c \ - loader/ldt_keeper.c \ - loader/module.c \ - loader/pe_image.c \ - loader/pe_resource.c \ - loader/registry.c \ - loader/resource.c \ - loader/win32.c \ - -SRCS_COMMON-$(WIN32_EMULATION) += $(SRCS_WIN32_EMULATION) - -SRCS_COMMON-$(WIN32DLL) += libmpcodecs/ad_acm.c \ - libmpcodecs/ad_dmo.c \ - libmpcodecs/ad_dshow.c \ - libmpcodecs/vd_dmo.c \ - libmpcodecs/vd_dshow.c \ - libmpcodecs/vd_vfw.c \ - libmpcodecs/vd_vfwex.c \ - libmpdemux/demux_avs.c \ - loader/afl.c \ - loader/drv.c \ - loader/vfl.c \ - loader/dshow/DS_AudioDecoder.c \ - loader/dshow/DS_Filter.c \ - loader/dshow/DS_VideoDecoder.c \ - loader/dshow/allocator.c \ - loader/dshow/cmediasample.c \ - loader/dshow/graph.c \ - loader/dshow/guids.c \ - loader/dshow/inputpin.c \ - loader/dshow/mediatype.c \ - loader/dshow/outputpin.c \ - loader/dmo/DMO_AudioDecoder.c \ - loader/dmo/DMO_VideoDecoder.c \ - loader/dmo/buffer.c \ - loader/dmo/dmo.c \ - loader/dmo/dmo_guids.c \ - -SRCS_COMMON-$(XANIM_CODECS) += libmpcodecs/vd_xanim.c SRCS_COMMON-$(DUMMY_OSD) += sub/osd_dummy.c SRCS_COMMON-$(LIBASS_OSD) += sub/osd_libass.c @@ -455,10 +406,6 @@ DIRS = . \ libmpcodecs/native \ libmpdemux \ libvo \ - loader \ - loader/dshow \ - loader/dmo \ - loader/wine \ osdep \ stream \ sub \ @@ -575,10 +522,6 @@ libdvdcss/%: CFLAGS := -Ilibdvdcss -D_GNU_SOURCE -DVERSION=\"1.2.10\" $(CFLAGS libdvdnav/%: CFLAGS := -Ilibdvdnav -D_GNU_SOURCE -DHAVE_CONFIG_H -DVERSION=\"MPlayer-custom\" $(CFLAGS) libdvdread4/%: CFLAGS := -Ilibdvdread4 -D_GNU_SOURCE $(CFLAGS_LIBDVDCSS_DVDREAD) $(CFLAGS) -loader/%: CFLAGS += -fno-omit-frame-pointer $(CFLAGS_NO_OMIT_LEAF_FRAME_POINTER) -#loader/%: CFLAGS += -Ddbg_printf=__vprintf -DTRACE=__vprintf -DDETAILED_OUT -loader/win32%: CFLAGS += $(CFLAGS_STACKREALIGN) - stream/stream_dvdnav%: CFLAGS := $(CFLAGS_LIBDVDNAV) $(CFLAGS) diff --git a/cfg-mplayer.h b/cfg-mplayer.h index 83fe9e3589..da39b06c65 100644 --- a/cfg-mplayer.h +++ b/cfg-mplayer.h @@ -363,7 +363,6 @@ const m_option_t common_opts[] = { #ifdef CONFIG_PRIORITY {"priority", &proc_priority, CONF_TYPE_STRING, 0, 0, 0, NULL}, #endif - {"codecpath", &codec_path, CONF_TYPE_STRING, 0, 0, 0, NULL}, OPT_CHOICE("noconfig", noconfig, CONF_GLOBAL | CONF_NOCFG | CONF_PRE_PARSE, ({"off", 0}, {"user", 1}, {"system", 2}, {"all", 3})), diff --git a/configure b/configure index 2e6187ad37..ce7c4488e7 100755 --- a/configure +++ b/configure @@ -340,7 +340,6 @@ Optional features: --disable-ftp disable FTP support [enabled] --disable-vstream disable TiVo vstream client support [autodetect] --disable-pthreads disable Posix threads support [autodetect] - --disable-w32threads disable Win32 threads support [autodetect] --disable-libass disable subtitle rendering with libass [autodetect] --disable-libass-osd disable OSD rendering with libass [autodetect] --enable-rpath enable runtime linker path for extra libs [disabled] @@ -352,10 +351,6 @@ Codecs: --enable-mng enable MNG input support [autodetect] --enable-jpeg enable JPEG input/output support [autodetect] --enable-libcdio enable libcdio support [autodetect] - --disable-win32dll disable Win32 DLL support [disabled] - --disable-qtx disable QuickTime codecs support [enabled] - --disable-xanim disable XAnim codecs support [enabled] - --disable-real disable RealPlayer codecs support [enabled] --enable-libav skip Libav autodetection [autodetect] --enable-faad enable FAAD2 (AAC) [autodetect] --disable-ladspa disable LADSPA plugin support [autodetect] @@ -493,8 +488,6 @@ _dvdreadconfig=dvdread-config _dvdread=auto _dvdread_internal=auto _libdvdcss_internal=auto -_xanim=auto -_real=auto _live=no _nemesi=auto _lcms2=auto @@ -502,7 +495,6 @@ _xinerama=auto _vm=auto _xf86keysym=auto _alsa=auto -_win32dll=no _select=yes _radio=no _radio_capture=no @@ -511,7 +503,6 @@ _radio_bsdbt848=auto _tv=yes _tv_v4l2=auto _tv_bsdbt848=auto -_tv_dshow=auto _pvr=auto networking=yes _winsock2_h=auto @@ -531,11 +522,9 @@ _translation=no _libdv=auto _cdda=auto _cddb=auto -_qtx=auto _coreaudio=auto _corevideo=auto _cocoa=auto -quicktime=auto _macosx_finder=no _macosx_bundle=auto _sortsub=yes @@ -545,7 +534,6 @@ _gethostbyname2=auto _ftp=auto _vstream=auto _pthreads=auto -_w32threads=auto _ass=auto _libass_osd=auto _rpath=no @@ -736,10 +724,6 @@ for ac_option do --disable-libdvdcss-internal) _libdvdcss_internal=no ;; --enable-dvdnav) _dvdnav=yes ;; --disable-dvdnav) _dvdnav=no ;; - --enable-xanim) _xanim=yes ;; - --disable-xanim) _xanim=no ;; - --enable-real) _real=yes ;; - --disable-real) _real=no ;; --enable-live) _live=yes ;; --disable-live) _live=no ;; --enable-nemesi) _nemesi=yes ;; @@ -760,8 +744,6 @@ for ac_option do --disable-tv-bsdbt848) _tv_bsdbt848=no ;; --enable-tv-v4l2) _tv_v4l2=yes ;; --disable-tv-v4l2) _tv_v4l2=no ;; - --enable-tv-dshow) _tv_dshow=yes ;; - --disable-tv-dshow) _tv_dshow=no ;; --enable-radio) _radio=yes ;; --enable-radio-capture) _radio_capture=yes ;; --disable-radio-capture) _radio_capture=no ;; @@ -812,8 +794,6 @@ for ac_option do --disable-vstream) _vstream=no ;; --enable-pthreads) _pthreads=yes ;; --disable-pthreads) _pthreads=no ;; - --enable-w32threads) _w32threads=yes ;; - --disable-w32threads) _w32threads=no ;; --enable-libass) _ass=yes ;; --disable-libass) _ass=no ;; --enable-libass-osd) _libass_osd=yes ;; @@ -832,9 +812,6 @@ for ac_option do --enable-gethostbyname2) _gethostbyname2=yes ;; --disable-gethostbyname2) _gethostbyname2=no ;; - --enable-qtx) _qtx=yes ;; - --disable-qtx) _qtx=no ;; - --enable-coreaudio) _coreaudio=yes ;; --disable-coreaudio) _coreaudio=no ;; --enable-corevideo) _corevideo=yes ;; @@ -849,9 +826,6 @@ for ac_option do --enable-sortsub) _sortsub=yes ;; --disable-sortsub) _sortsub=no ;; - --enable-win32dll) _win32dll=yes ;; - --disable-win32dll) _win32dll=no ;; - *) echo "Unknown parameter: $ac_option" >&2 exit 1 @@ -1261,7 +1235,6 @@ else CFLAGS="-D_ISOC99_SOURCE -D_BSD_SOURCE $CFLAGS" fi -cflag_check -mno-omit-leaf-frame-pointer && cflags_no_omit_leaf_frame_pointer="-mno-omit-leaf-frame-pointer" cflag_check -MD -MP && DEPFLAGS="-MD -MP" @@ -1661,7 +1634,6 @@ else res_comment="v4l2, ao_nas, win32 loader disabled" def_pthreads='#undef HAVE_PTHREADS' _nas=no ; _tv_v4l2=no - mingw32 || _win32dll=no fi echores "$_pthreads" @@ -1674,18 +1646,6 @@ if cygwin ; then fi fi -echocheck "w32threads" -if test "$_pthreads" = yes ; then - res_comment="using pthread instead" - _w32threads=no -fi -if test "$_w32threads" = auto ; then - _w32threads=no - mingw32 && _w32threads=yes -fi -test "$_w32threads" = yes && def_threads='#define HAVE_THREADS 1' -echores "$_w32threads" - echocheck "rpath" if test "$_rpath" = yes ; then for I in $(echo $extra_ldflags | sed 's/-L//g') ; do @@ -2084,19 +2044,6 @@ echores "$_directfb" if darwin; then -echocheck "QuickTime" -if test "$quicktime" = auto ; then - quicktime=no - statement_check QuickTime/QuickTime.h 'ImageDescription *desc; EnterMovies(); ExitMovies()' -framework QuickTime && quicktime=yes -fi -if test "$quicktime" = yes ; then - extra_ldflags="$extra_ldflags -framework QuickTime" - def_quicktime='#define CONFIG_QUICKTIME 1' -else - def_quicktime='#undef CONFIG_QUICKTIME' -fi -echores $quicktime - echocheck "Cocoa" if test "$_cocoa" = auto ; then cat > $TMPC < -#include -#include - -#include "config.h" -#include "mp_msg.h" -#include "libmpdemux/aviprint.h" -#include "loader/wineacm.h" - -#include "ad_internal.h" -#include "osdep/timer.h" - -static const ad_info_t info = -{ - "Win32/ACM decoders", - "acm", - "A'rpi", - "A'rpi & Alex", - "" -}; - -LIBAD_EXTERN(acm) - -typedef struct { - WAVEFORMATEX *o_wf; - HACMSTREAM handle; -} acm_context_t; - -static int init(sh_audio_t *sh_audio) -{ - int ret=decode_audio(sh_audio,sh_audio->a_buffer,4096,sh_audio->a_buffer_size); - if(ret<0){ - mp_msg(MSGT_DECAUDIO,MSGL_INFO,"ACM decoding error: %d\n",ret); - return 0; - } - sh_audio->a_buffer_len=ret; - return 1; -} - -static int preinit(sh_audio_t *sh_audio) -{ - HRESULT ret; - WAVEFORMATEX *in_fmt = sh_audio->wf; - DWORD srcsize = 0; - acm_context_t *priv; - - priv = malloc(sizeof(acm_context_t)); - if (!priv) - return 0; - sh_audio->context = priv; - - mp_msg(MSGT_WIN32, MSGL_V, "======= Win32 (ACM) AUDIO Codec init =======\n"); - -// priv->handle = NULL; - - priv->o_wf = malloc(sizeof(*priv->o_wf)); - if (!priv->o_wf) - { - mp_tmsg(MSGT_DECAUDIO,MSGL_ERR,"Could not load/initialize Win32/ACM audio codec (missing DLL file?).\n"); - return 0; - } - - priv->o_wf->nChannels = in_fmt->nChannels; - priv->o_wf->nSamplesPerSec = in_fmt->nSamplesPerSec; - priv->o_wf->nAvgBytesPerSec = 2*in_fmt->nSamplesPerSec*in_fmt->nChannels; - priv->o_wf->wFormatTag = WAVE_FORMAT_PCM; - priv->o_wf->nBlockAlign = 2*in_fmt->nChannels; - priv->o_wf->wBitsPerSample = 16; -// priv->o_wf->wBitsPerSample = inf_fmt->wBitsPerSample; - priv->o_wf->cbSize = 0; - - if ( mp_msg_test(MSGT_DECAUDIO,MSGL_V) ) - { - mp_msg(MSGT_DECAUDIO, MSGL_V, "Input format:\n"); - print_wave_header(in_fmt, MSGL_V); - mp_msg(MSGT_DECAUDIO, MSGL_V, "Output format:\n"); - print_wave_header(priv->o_wf, MSGL_V); - } - - MSACM_RegisterDriver((const char *)sh_audio->codec->dll, in_fmt->wFormatTag, 0); - ret = acmStreamOpen(&priv->handle, (HACMDRIVER)NULL, in_fmt, - priv->o_wf, NULL, 0, 0, 0); - if (ret) - { - if (ret == ACMERR_NOTPOSSIBLE) - mp_msg(MSGT_WIN32, MSGL_ERR, "ACM_Decoder: Unappropriate audio format\n"); - else - mp_msg(MSGT_WIN32, MSGL_ERR, "ACM_Decoder: acmStreamOpen error: %d\n", - (int)ret); - mp_tmsg(MSGT_DECAUDIO,MSGL_ERR,"Could not load/initialize Win32/ACM audio codec (missing DLL file?).\n"); - return 0; - } - mp_msg(MSGT_WIN32, MSGL_V, "Audio codec opened OK! ;-)\n"); - - acmStreamSize(priv->handle, in_fmt->nBlockAlign, &srcsize, ACM_STREAMSIZEF_SOURCE); - //if ( mp_msg_test(MSGT_DECAUDIO,MSGL_V) ) printf("Audio ACM output buffer min. size: %ld (reported by codec)\n", srcsize); - srcsize *= 2; - //if (srcsize < MAX_OUTBURST) srcsize = MAX_OUTBURST; - if (!srcsize) - { - mp_msg(MSGT_WIN32, MSGL_WARN, "Warning! ACM codec reports srcsize=0\n"); - srcsize = 16384; - } - // limit srcsize to 4-16kb - //while(srcsize && srcsize<4096) srcsize*=2; - //while(srcsize>16384) srcsize/=2; - sh_audio->audio_out_minsize=srcsize; // audio output min. size - mp_msg(MSGT_WIN32,MSGL_V,"Audio ACM output buffer min. size: %ld\n",srcsize); - - acmStreamSize(priv->handle, srcsize, &srcsize, ACM_STREAMSIZEF_DESTINATION); -// if(srcsizenBlockAlign) srcsize=in_fmt->nBlockAlign; - - if (!srcsize) - { - mp_msg(MSGT_WIN32, MSGL_WARN, "Warning! ACM codec reports srcsize=0\n"); - srcsize = 2*in_fmt->nBlockAlign; - } - - mp_msg(MSGT_WIN32,MSGL_V,"Audio ACM input buffer min. size: %ld\n",srcsize); - - sh_audio->audio_in_minsize=2*srcsize; // audio input min. size - - sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec; - sh_audio->channels=priv->o_wf->nChannels; - sh_audio->samplerate=priv->o_wf->nSamplesPerSec; - sh_audio->samplesize=2; - - mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32/ACM audio codec init OK!\n"); - return 1; -} - -static void uninit(sh_audio_t *sh) -{ - HRESULT ret; - acm_context_t *priv = sh->context; - -retry: - ret = acmStreamClose(priv->handle, 0); - - if (ret) - switch(ret) - { - case ACMERR_BUSY: - case ACMERR_CANCELED: - mp_msg(MSGT_WIN32, MSGL_DBG2, "ACM_Decoder: stream busy, waiting..\n"); - usec_sleep(100000000); - goto retry; - case ACMERR_UNPREPARED: - case ACMERR_NOTPOSSIBLE: - return; - default: - mp_msg(MSGT_WIN32, MSGL_WARN, "ACM_Decoder: unknown error occurred: %ld\n", ret); - return; - } - - MSACM_UnregisterAllDrivers(); - - free(priv->o_wf); - free(priv); -} - -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) -{ - ACMSTREAMHEADER ash; - HRESULT hr; - DWORD srcsize=0; - DWORD len=minlen; - acm_context_t *priv = sh_audio->context; - - acmStreamSize(priv->handle, len, &srcsize, ACM_STREAMSIZEF_DESTINATION); - mp_msg(MSGT_WIN32,MSGL_DBG3,"acm says: srcsize=%ld (buffsize=%d) out_size=%ld\n",srcsize,sh_audio->a_in_buffer_size,len); - - if(srcsizewf->nBlockAlign){ - srcsize=sh_audio->wf->nBlockAlign; - acmStreamSize(priv->handle, srcsize, &len, ACM_STREAMSIZEF_SOURCE); - if(len>maxlen) len=maxlen; - } - -// if(srcsize==0) srcsize=((WAVEFORMATEX *)&sh_audio->o_wf_ext)->nBlockAlign; - if(srcsize>sh_audio->a_in_buffer_size) srcsize=sh_audio->a_in_buffer_size; // !!!!!! - if(sh_audio->a_in_buffer_lena_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); - } - mp_msg(MSGT_WIN32,MSGL_DBG3,"acm convert %d -> %ld bytes\n",sh_audio->a_in_buffer_len,len); - memset(&ash, 0, sizeof(ash)); - ash.cbStruct=sizeof(ash); - ash.fdwStatus=0; - ash.dwUser=0; - ash.pbSrc=sh_audio->a_in_buffer; - ash.cbSrcLength=sh_audio->a_in_buffer_len; - ash.pbDst=buf; - ash.cbDstLength=len; - hr=acmStreamPrepareHeader(priv->handle,&ash,0); - if(hr){ - mp_msg(MSGT_WIN32,MSGL_V,"ACM_Decoder: acmStreamPrepareHeader error %d\n",(int)hr); - return -1; - } - hr=acmStreamConvert(priv->handle,&ash,0); - if(hr){ - mp_msg(MSGT_WIN32,MSGL_DBG2,"ACM_Decoder: acmStreamConvert error %d\n",(int)hr); - switch(hr) - { - case ACMERR_NOTPOSSIBLE: - case ACMERR_UNPREPARED: - mp_msg(MSGT_WIN32, MSGL_DBG2, "ACM_Decoder: acmStreamConvert error: probarly not initialized!\n"); - } -// return -1; - } - mp_msg(MSGT_WIN32,MSGL_DBG2,"acm converted %ld -> %ld\n",ash.cbSrcLengthUsed,ash.cbDstLengthUsed); - if(ash.cbSrcLengthUsed>=sh_audio->a_in_buffer_len){ - sh_audio->a_in_buffer_len=0; - } else { - sh_audio->a_in_buffer_len-=ash.cbSrcLengthUsed; - memcpy(sh_audio->a_in_buffer,&sh_audio->a_in_buffer[ash.cbSrcLengthUsed],sh_audio->a_in_buffer_len); - } - len=ash.cbDstLengthUsed; - hr=acmStreamUnprepareHeader(priv->handle,&ash,0); - if(hr){ - mp_msg(MSGT_WIN32,MSGL_V,"ACM_Decoder: acmStreamUnprepareHeader error %d\n",(int)hr); - } - return len; -} diff --git a/libmpcodecs/ad_dmo.c b/libmpcodecs/ad_dmo.c deleted file mode 100644 index 714651a7e4..0000000000 --- a/libmpcodecs/ad_dmo.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include -#include - -#include "config.h" -#include "options.h" -#include "mp_msg.h" - -#include "ad_internal.h" -#include "libaf/reorder_ch.h" - -static const ad_info_t info = -{ - "Win32/DMO decoders", - "dmo", - "A'rpi", - "avifile.sf.net", - "" -}; - -LIBAD_EXTERN(dmo) - -#include "loader/dmo/DMO_AudioDecoder.h" - -static int init(sh_audio_t *sh) -{ - return 1; -} - -static int preinit(sh_audio_t *sh_audio) -{ - struct MPOpts *opts = sh_audio->opts; - DMO_AudioDecoder* ds_adec; - int chans=(opts->audio_output_channels==sh_audio->wf->nChannels) ? - opts->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_tmsg(MSGT_DECAUDIO,MSGL_ERR,"ERROR: Could not open required DirectShow codec %s.\n",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->samplesize=2; - 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_lena_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; - memmove(sh_audio->a_in_buffer,&sh_audio->a_in_buffer[size_in],sh_audio->a_in_buffer_len); - } - if (size_out > 0 && sh_audio->channels >= 5) { - reorder_channel_nch(buf, AF_CHANNEL_LAYOUT_WAVEEX_DEFAULT, - AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT, - sh_audio->channels, - size_out / sh_audio->samplesize, - sh_audio->samplesize); - } -// len=size_out; - return size_out; -} diff --git a/libmpcodecs/ad_dshow.c b/libmpcodecs/ad_dshow.c deleted file mode 100644 index 8fb94660a4..0000000000 --- a/libmpcodecs/ad_dshow.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include -#include - -#include "config.h" -#include "mp_msg.h" - -#include "ad_internal.h" - -static const ad_info_t info = -{ - "Win32/DirectShow decoders", - "dshow", - "Nick Kurshev", - "avifile.sf.net", - "" -}; - -LIBAD_EXTERN(dshow) - -#include "loader/dshow/DS_AudioDecoder.h" - -static int init(sh_audio_t *sh) -{ - return 1; -} - -static int preinit(sh_audio_t *sh_audio) -{ - DS_AudioDecoder* ds_adec; - if(!(ds_adec=DS_AudioDecoder_Open(sh_audio->codec->dll,&sh_audio->codec->guid,sh_audio->wf))) - { - mp_tmsg(MSGT_DECAUDIO,MSGL_ERR,"ERROR: Could not open required DirectShow codec %s.\n",sh_audio->codec->dll); - return 0; - } - sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec; - sh_audio->channels=sh_audio->wf->nChannels; - sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; - sh_audio->samplesize=2; - sh_audio->audio_in_minsize=2*sh_audio->wf->nBlockAlign; - if(sh_audio->audio_in_minsize<8192) sh_audio->audio_in_minsize=8192; - sh_audio->audio_out_minsize=16384; - sh_audio->context = ds_adec; - mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32/DShow audio codec init OK!\n"); - return 1; -} - -static void uninit(sh_audio_t *sh) -{ - DS_AudioDecoder* ds_adec = sh->context; - DS_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) -{ - DS_AudioDecoder* ds_adec = sh_audio->context; -// int len=-1; - int size_in=0; - int size_out=0; - int srcsize=DS_AudioDecoder_GetSrcSize(ds_adec, maxlen); - mp_msg(MSGT_DECAUDIO,MSGL_DBG3,"DShow 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_lena_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); - } - DS_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,"DShow: 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; -} diff --git a/libmpcodecs/ad_qtaudio.c b/libmpcodecs/ad_qtaudio.c deleted file mode 100644 index 1edd87cd17..0000000000 --- a/libmpcodecs/ad_qtaudio.c +++ /dev/null @@ -1,353 +0,0 @@ -/* - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include -#include -#include - -#include "config.h" -#include "mp_msg.h" -#include "mpbswap.h" -#include "ad_internal.h" - -#ifdef CONFIG_QUICKTIME -#include -#else -#include "loader/ldt_keeper.h" -#include "loader/wine/winbase.h" -#include "loader/wine/windef.h" -#endif - -static const ad_info_t info = { - "QuickTime Audio Decoder", - "qtaudio", - "A'rpi", - "Sascha Sommer", - "uses win32 quicktime DLLs" -}; - -LIBAD_EXTERN(qtaudio) - -#ifndef CONFIG_QUICKTIME -typedef struct OpaqueSoundConverter* SoundConverter; -typedef unsigned long OSType; -typedef unsigned long UnsignedFixed; -typedef uint8_t Byte; -typedef struct SoundComponentData { - long flags; - OSType format; - short numChannels; - short sampleSize; - UnsignedFixed sampleRate; - long sampleCount; - Byte * buffer; - long reserved; -}SoundComponentData; - -typedef int (__cdecl* LPFUNC1)(long flag); -typedef int (__cdecl* LPFUNC2)(const SoundComponentData *, const SoundComponentData *,SoundConverter *); -typedef int (__cdecl* LPFUNC3)(SoundConverter sc); -typedef int (__cdecl* LPFUNC4)(void); -typedef int (__cdecl* LPFUNC5)(SoundConverter sc, OSType selector,void * infoPtr); -typedef int (__cdecl* LPFUNC6)(SoundConverter sc, - unsigned long inputBytesTarget, - unsigned long *inputFrames, - unsigned long *inputBytes, - unsigned long *outputBytes ); -typedef int (__cdecl* LPFUNC7)(SoundConverter sc, - const void *inputPtr, - unsigned long inputFrames, - void *outputPtr, - unsigned long *outputFrames, - unsigned long *outputBytes ); -typedef int (__cdecl* LPFUNC8)(SoundConverter sc, - void *outputPtr, - unsigned long *outputFrames, - unsigned long *outputBytes); -typedef int (__cdecl* LPFUNC9)(SoundConverter sc) ; - -static HINSTANCE qtime_qts; // handle to the preloaded quicktime.qts -static HINSTANCE qtml_dll; -static LPFUNC1 InitializeQTML; -static LPFUNC2 SoundConverterOpen; -static LPFUNC3 SoundConverterClose; -static LPFUNC4 TerminateQTML; -static LPFUNC5 SoundConverterSetInfo; -static LPFUNC6 SoundConverterGetBufferSizes; -static LPFUNC7 SoundConverterConvertBuffer; -static LPFUNC8 SoundConverterEndConversion; -static LPFUNC9 SoundConverterBeginConversion; - -#define siDecompressionParams 2002876005 // siDecompressionParams = FOUR_CHAR_CODE('wave') - -static int loader_init(void) -{ - -#ifdef WIN32_LOADER - Setup_LDT_Keeper(); -#endif - //preload quicktime.qts to avoid the problems caused by the hardcoded path inside the dll - qtime_qts = LoadLibraryA("QuickTime.qts"); - if( qtime_qts == (HMODULE)NULL ) - { - mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed loading QuickTime.qts\n" ); - return 1; - } - qtml_dll = LoadLibraryA("qtmlClient.dll"); - if( qtml_dll == (HMODULE)NULL ) - { - mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed loading qtmlClient.dll\n" ); - return 1; - } - InitializeQTML = (LPFUNC1)GetProcAddress(qtml_dll,"InitializeQTML"); - if ( InitializeQTML == NULL ) - { - mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed geting proc address InitializeQTML\n"); - return 1; - } - SoundConverterOpen = (LPFUNC2)GetProcAddress(qtml_dll,"SoundConverterOpen"); - if ( SoundConverterOpen == NULL ) - { - mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed getting proc address SoundConverterOpen\n"); - return 1; - } - SoundConverterClose = (LPFUNC3)GetProcAddress(qtml_dll,"SoundConverterClose"); - if ( SoundConverterClose == NULL ) - { - mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed getting proc address SoundConverterClose\n"); - return 1; - } - TerminateQTML = (LPFUNC4)GetProcAddress(qtml_dll,"TerminateQTML"); - if ( TerminateQTML == NULL ) - { - mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed getting proc address TerminateQTML\n"); - return 1; - } - SoundConverterSetInfo = (LPFUNC5)GetProcAddress(qtml_dll,"SoundConverterSetInfo"); - if ( SoundConverterSetInfo == NULL ) - { - mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed getting proc address SoundConverterSetInfo\n"); - return 1; - } - SoundConverterGetBufferSizes = (LPFUNC6)GetProcAddress(qtml_dll,"SoundConverterGetBufferSizes"); - if ( SoundConverterGetBufferSizes == NULL ) - { - mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed getting proc address SoundConverterGetBufferSizes\n"); - return 1; - } - SoundConverterConvertBuffer = (LPFUNC7)GetProcAddress(qtml_dll,"SoundConverterConvertBuffer"); - if ( SoundConverterConvertBuffer == NULL ) - { - mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed getting proc address SoundConverterConvertBuffer1\n"); - return 1; - } - SoundConverterEndConversion = (LPFUNC8)GetProcAddress(qtml_dll,"SoundConverterEndConversion"); - if ( SoundConverterEndConversion == NULL ) - { - mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed getting proc address SoundConverterEndConversion\n"); - return 1; - } - SoundConverterBeginConversion = (LPFUNC9)GetProcAddress(qtml_dll,"SoundConverterBeginConversion"); - if ( SoundConverterBeginConversion == NULL ) - { - mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed getting proc address SoundConverterBeginConversion\n"); - return 1; - } - mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"loader_init DONE???\n"); - return 0; -} -#endif /* #ifndef CONFIG_QUICKTIME */ - -static SoundConverter myConverter = NULL; -static SoundComponentData InputFormatInfo,OutputFormatInfo; - -static int InFrameSize; -static int OutFrameSize; - -static int preinit(sh_audio_t *sh){ - int error; - unsigned long FramesToGet=0; //how many frames the demuxer has to get - unsigned long InputBufferSize=0; //size of the input buffer - unsigned long OutputBufferSize=0; //size of the output buffer - unsigned long WantedBufferSize=0; //the size you want your buffers to be - void* codecdata = sh->codecdata; - - if (!sh->codecdata_len && sh->wf && sh->wf->cbSize){ - codecdata = sh->wf + 1; - } - -#ifdef CONFIG_QUICKTIME - EnterMovies(); -#else - if(loader_init()) return 0; // failed to load DLL - - mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"loader_init DONE!\n"); - - error = InitializeQTML(6+16); - if(error){ - mp_msg(MSGT_DECAUDIO,MSGL_ERR,"InitializeQTML:%i\n",error); - return 0; - } -#endif - - OutputFormatInfo.flags = InputFormatInfo.flags = 0; - OutputFormatInfo.sampleCount = InputFormatInfo.sampleCount = 0; - OutputFormatInfo.buffer = InputFormatInfo.buffer = NULL; - OutputFormatInfo.reserved = InputFormatInfo.reserved = 0; - OutputFormatInfo.numChannels = InputFormatInfo.numChannels = sh->wf->nChannels; - InputFormatInfo.sampleSize = sh->wf->wBitsPerSample; - OutputFormatInfo.sampleSize = 16; - OutputFormatInfo.sampleRate = InputFormatInfo.sampleRate = sh->wf->nSamplesPerSec; - InputFormatInfo.format = bswap_32(sh->format); //1363430706;///*1768775988;//*/1902406962;//qdm2//1768775988;//FOUR_CHAR_CODE('ima4'); - OutputFormatInfo.format = 1313820229;// FOUR_CHAR_CODE('NONE'); - - error = SoundConverterOpen(&InputFormatInfo, &OutputFormatInfo, &myConverter); - mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"SoundConverterOpen:%i\n",error); - if(error) return 0; - - if(codecdata){ - error = SoundConverterSetInfo(myConverter,siDecompressionParams,codecdata); - mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"SoundConverterSetInfo:%i\n",error); -// if(error) return 0; - } - - WantedBufferSize=OutputFormatInfo.numChannels*OutputFormatInfo.sampleRate*2; - error = SoundConverterGetBufferSizes(myConverter, - WantedBufferSize,&FramesToGet,&InputBufferSize,&OutputBufferSize); - mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"SoundConverterGetBufferSizes:%i\n",error); - mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"WantedBufferSize = %li\n",WantedBufferSize); - mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"InputBufferSize = %li\n",InputBufferSize); - mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"OutputBufferSize = %li\n",OutputBufferSize); - mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"FramesToGet = %li\n",FramesToGet); - - InFrameSize=(InputBufferSize+FramesToGet-1)/FramesToGet; - OutFrameSize=OutputBufferSize/FramesToGet; - - mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"FrameSize: %i -> %i\n",InFrameSize,OutFrameSize); - - error = SoundConverterBeginConversion(myConverter); - mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"SoundConverterBeginConversion:%i\n",error); - if(error) return 0; - - sh->audio_out_minsize=OutputBufferSize; - sh->audio_in_minsize=InputBufferSize; - - sh->channels=sh->wf->nChannels; - sh->samplerate=sh->wf->nSamplesPerSec; - sh->samplesize=2; //(sh->wf->wBitsPerSample+7)/8; - - sh->i_bps=sh->wf->nAvgBytesPerSec; -//InputBufferSize*WantedBufferSize/OutputBufferSize; - - if(sh->format==0x3343414D){ - // MACE 3:1 - sh->ds->ss_div = 2*3; // 1 samples/packet - sh->ds->ss_mul = sh->channels*2*1; // 1 bytes/packet - } else - if(sh->format==0x3643414D){ - // MACE 6:1 - sh->ds->ss_div = 2*6; // 1 samples/packet - sh->ds->ss_mul = sh->channels*2*1; // 1 bytes/packet - } - - return 1; // return values: 1=OK 0=ERROR -} - -static int init(sh_audio_t *sh_audio){ - - return 1; // return values: 1=OK 0=ERROR -} - -static void uninit(sh_audio_t *sh){ - int error; - unsigned long ConvertedFrames=0; - unsigned long ConvertedBytes=0; - -#if defined(WIN32_LOADER) && !defined(CONFIG_QUICKTIME) - Setup_FS_Segment(); -#endif - - error=SoundConverterEndConversion(myConverter,NULL,&ConvertedFrames,&ConvertedBytes); - mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"SoundConverterEndConversion:%i\n",error); - error = SoundConverterClose(myConverter); - mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"SoundConverterClose:%i\n",error); -// error = TerminateQTML(); -// printf("TerminateQTML:%i\n",error); -// FreeLibrary( qtml_dll ); -// qtml_dll = NULL; -// FreeLibrary( qtime_qts ); -// qtime_qts = NULL; -// printf("qt dll loader uninit done\n"); -#ifdef CONFIG_QUICKTIME - ExitMovies(); -#endif -} - -static int decode_audio(sh_audio_t *sh,unsigned char *buf,int minlen,int maxlen){ - unsigned long FramesToGet=0; //how many frames the demuxer has to get - unsigned long InputBufferSize=0; //size of the input buffer - unsigned long ConvertedFrames=0; - unsigned long ConvertedBytes=0; - -#if defined(WIN32_LOADER) && !defined(CONFIG_QUICKTIME) - Setup_FS_Segment(); -#endif - - FramesToGet=minlen/OutFrameSize; - if(FramesToGet*OutFrameSizesh->a_in_buffer_size) - FramesToGet=sh->a_in_buffer_size/InFrameSize; - - InputBufferSize=FramesToGet*InFrameSize; - -// printf("FramesToGet = %li (%li -> %li bytes)\n",FramesToGet, -// InputBufferSize, FramesToGet*OutFrameSize); - - if(InputBufferSize>sh->a_in_buffer_len){ - int x=demux_read_data(sh->ds,&sh->a_in_buffer[sh->a_in_buffer_len], - InputBufferSize-sh->a_in_buffer_len); - if(x>0) sh->a_in_buffer_len+=x; - if(InputBufferSize>sh->a_in_buffer_len) - FramesToGet=sh->a_in_buffer_len/InFrameSize; // not enough data! - } - -// printf("\nSoundConverterConvertBuffer(myConv=%p,inbuf=%p,frames=%d,outbuf=%p,&convframes=%p,&convbytes=%p)\n", -// myConverter,sh->a_in_buffer,FramesToGet,buf,&ConvertedFrames,&ConvertedBytes); - SoundConverterConvertBuffer(myConverter,sh->a_in_buffer, - FramesToGet,buf,&ConvertedFrames,&ConvertedBytes); -// printf("SoundConverterConvertBuffer:%i\n",error); -// printf("ConvertedFrames = %li\n",ConvertedFrames); -// printf("ConvertedBytes = %li\n",ConvertedBytes); - -// InputBufferSize=(ConvertedBytes/OutFrameSize)*InFrameSize; // FIXME!! - InputBufferSize=FramesToGet*InFrameSize; - sh->a_in_buffer_len-=InputBufferSize; - if(sh->a_in_buffer_len<0) sh->a_in_buffer_len=0; // should not happen... - else if(sh->a_in_buffer_len>0){ - memcpy(sh->a_in_buffer,&sh->a_in_buffer[InputBufferSize],sh->a_in_buffer_len); - } - - return ConvertedBytes; -} - -static int control(sh_audio_t *sh,int cmd,void* arg, ...){ - // various optional functions you MAY implement: - return CONTROL_UNKNOWN; -} diff --git a/libmpcodecs/ad_realaud.c b/libmpcodecs/ad_realaud.c deleted file mode 100644 index 3f221c61ef..0000000000 --- a/libmpcodecs/ad_realaud.c +++ /dev/null @@ -1,463 +0,0 @@ -/* - * This file is part of MPlayer. - * - * MPlayer is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * MPlayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with MPlayer; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include -#include -#include - -#include "config.h" - -//#include -#ifdef HAVE_LIBDL -#include -#endif -#include "path.h" -#include "libavutil/attributes.h" -#include "ad_internal.h" -#include "loader/wine/windef.h" - -static const ad_info_t info = { - "RealAudio decoder", - "realaud", - "Alex Beregszaszi", - "Florian Schneider, Arpad Gereoffy, Alex Beregszaszi, Donnie Smith", - "binary real audio codecs" -}; - -LIBAD_EXTERN(realaud) - -void *__builtin_new(unsigned long size); -void __builtin_delete(void *ize); - -void *__builtin_new(unsigned long size) { - return malloc(size); -} - -// required for cook's uninit: -void __builtin_delete(void* ize) { - free(ize); -} - -#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) -void *__ctype_b=NULL; -#endif - -static unsigned long (*raCloseCodec)(void*); -static unsigned long (*raDecode)(void*, char*,unsigned long,char*,unsigned int*,long); -static unsigned long (*raFreeDecoder)(void*); -//static unsigned long (*raGetNumberOfFlavors2)(void); -static unsigned long (*raInitDecoder)(void*, void*); -static unsigned long (*raOpenCodec)(void*); -static unsigned long (*raOpenCodec2)(void*, void*); -static unsigned long (*raSetFlavor)(void*,unsigned long); -static void (*raSetDLLAccessPath)(char*); -static void (*raSetPwd)(char*,char*); -#ifdef CONFIG_WIN32DLL -static unsigned long WINAPI (*wraCloseCodec)(void*); -static unsigned long WINAPI (*wraDecode)(void*, char*,unsigned long,char*,unsigned int*,long); -static unsigned long WINAPI (*wraFreeDecoder)(void*); -static unsigned long WINAPI (*wraInitDecoder)(void*, void*); -static unsigned long WINAPI (*wraOpenCodec)(void*); -static unsigned long WINAPI (*wraOpenCodec2)(void*, void*); -static unsigned long WINAPI (*wraSetFlavor)(void*,unsigned long); -static void WINAPI (*wraSetDLLAccessPath)(char*); -static void WINAPI (*wraSetPwd)(char*,char*); - -static int dll_type = 0; /* 0 = unix dlopen, 1 = win32 dll */ -#endif - -static void *rv_handle = NULL; - -#if 0 -typedef struct { - int samplerate; - short bits; - short channels; - int unk1; - int unk2; - int packetsize; - int unk3; - void* unk4; -} ra_init_t ; -#else - -/* - Probably the linux .so-s were compiled with old GCC without setting - packing, so it adds 2 bytes padding after the quality field. - In windows it seems that there's no padding in it. - - -- alex -*/ - -/* linux dlls doesn't need packing */ -typedef struct /*__attribute__((__packed__))*/ { - int samplerate; - short bits; - short channels; - short quality; - /* 2bytes padding here, by gcc */ - int bits_per_frame; - int packetsize; - int extradata_len; - void* extradata; -} ra_init_t; - -/* windows dlls need packed structs (no padding) */ -typedef struct __attribute__((__packed__)) { - int samplerate; - short bits; - short channels; - short quality; - int bits_per_frame; - int packetsize; - int extradata_len; - void* extradata; -} wra_init_t; -#endif - -#ifdef HAVE_LIBDL -static int load_syms_linux(char *path) -{ - void *handle; - - mp_msg(MSGT_DECVIDEO, MSGL_V, "opening shared obj '%s'\n", path); - handle = dlopen(path, RTLD_LAZY); - if (!handle) - { - mp_msg(MSGT_DECVIDEO, MSGL_WARN, "Error: %s\n", dlerror()); - return 0; - } - - raCloseCodec = dlsym(handle, "RACloseCodec"); - raDecode = dlsym(handle, "RADecode"); - raFreeDecoder = dlsym(handle, "RAFreeDecoder"); - raOpenCodec = dlsym(handle, "RAOpenCodec"); - raOpenCodec2 = dlsym(handle, "RAOpenCodec2"); - raInitDecoder = dlsym(handle, "RAInitDecoder"); - raSetFlavor = dlsym(handle, "RASetFlavor"); - raSetDLLAccessPath = dlsym(handle, "SetDLLAccessPath"); - raSetPwd = dlsym(handle, "RASetPwd"); // optional, used by SIPR - - if (raCloseCodec && raDecode && raFreeDecoder && - (raOpenCodec||raOpenCodec2) && raSetFlavor && - /*raSetDLLAccessPath &&*/ raInitDecoder) - { - rv_handle = handle; - return 1; - } - - mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Cannot resolve symbols - incompatible dll: %s\n",path); - dlclose(handle); - return 0; -} -#endif - -#ifdef CONFIG_WIN32DLL - -#ifdef WIN32_LOADER -#include "loader/ldt_keeper.h" -#endif -void* WINAPI LoadLibraryA(char* name); -void* WINAPI GetProcAddress(void* handle,char *func); -int WINAPI FreeLibrary(void *handle); - -static int load_syms_windows(char *path) -{ - void *handle; - - mp_msg(MSGT_DECVIDEO, MSGL_V, "opening win32 dll '%s'\n", path); -#ifdef WIN32_LOADER - Setup_LDT_Keeper(); -#endif - handle = LoadLibraryA(path); - if (!handle) - { - mp_msg(MSGT_DECVIDEO, MSGL_WARN, "Error loading dll\n"); - return 0; - } - - wraCloseCodec = GetProcAddress(handle, "RACloseCodec"); - wraDecode = GetProcAddress(handle, "RADecode");