summaryrefslogtreecommitdiffstats
path: root/loader/dshow/DS_AudioDecoder.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-08-12 15:30:21 +0200
committerwm4 <wm4@nowhere>2012-08-16 17:16:33 +0200
commitaebfbbf2bdda8e18beef90c16da97bd335f7d3b0 (patch)
treea7362bf3ef6f2d80a47b2e539a2ea4efe5e2e079 /loader/dshow/DS_AudioDecoder.c
parentc6b03ffef6250096373c4a81a489dae9fbff9087 (diff)
downloadmpv-aebfbbf2bdda8e18beef90c16da97bd335f7d3b0.tar.bz2
mpv-aebfbbf2bdda8e18beef90c16da97bd335f7d3b0.tar.xz
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.
Diffstat (limited to 'loader/dshow/DS_AudioDecoder.c')
-rw-r--r--loader/dshow/DS_AudioDecoder.c192
1 files changed, 0 insertions, 192 deletions
diff --git a/loader/dshow/DS_AudioDecoder.c b/loader/dshow/DS_AudioDecoder.c
deleted file mode 100644
index cfa2fcb5a2..0000000000
--- a/loader/dshow/DS_AudioDecoder.c
+++ /dev/null
@@ -1,192 +0,0 @@
-/********************************************************
-
- DirectShow audio decoder
- Copyright 2001 Eugene Kuznetsov (divx@euro.ru)
-
-*********************************************************/
-#include "config.h"
-
-#include "libwin32.h"
-
-#include "DS_Filter.h"
-
-struct DS_AudioDecoder
-{
- WAVEFORMATEX in_fmt;
- AM_MEDIA_TYPE m_sOurType, m_sDestType;
- DS_Filter* m_pDS_Filter;
- char* m_sVhdr;
- char* m_sVhdr2;
-};
-
-#include "DS_AudioDecoder.h"
-#ifdef WIN32_LOADER
-#include "loader/ldt_keeper.h"
-#endif
-
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-typedef long STDCALL (*GETCLASS) (GUID*, GUID*, void**);
-
-static SampleProcUserData sampleProcData;
-
-
-DS_AudioDecoder * DS_AudioDecoder_Open(char* dllname, GUID* guid, WAVEFORMATEX* wf)
-//DS_AudioDecoder * DS_AudioDecoder_Create(const CodecInfo * info, const WAVEFORMATEX* wf)
-{
- DS_AudioDecoder *this;
- int sz;
- WAVEFORMATEX* pWF;
-
-#ifdef WIN32_LOADER
- Setup_LDT_Keeper();
- Setup_FS_Segment();
-#endif
-
- this = malloc(sizeof(DS_AudioDecoder));
-
- sz = 18 + wf->cbSize;
- this->m_sVhdr = malloc(sz);
- memcpy(this->m_sVhdr, wf, sz);
- this->m_sVhdr2 = malloc(18);
- memcpy(this->m_sVhdr2, this->m_sVhdr, 18);
-
- pWF = (WAVEFORMATEX*)this->m_sVhdr2;
- pWF->wFormatTag = 1;
- pWF->wBitsPerSample = 16;
- pWF->nBlockAlign = pWF->nChannels * (pWF->wBitsPerSample + 7) / 8;
- pWF->cbSize = 0;
- pWF->nAvgBytesPerSec = pWF->nBlockAlign * pWF->nSamplesPerSec;
-
- memcpy(&this->in_fmt,wf,sizeof(WAVEFORMATEX));
-
- memset(&this->m_sOurType, 0, sizeof(this->m_sOurType));
- this->m_sOurType.majortype=MEDIATYPE_Audio;
- this->m_sOurType.subtype=MEDIASUBTYPE_PCM;
- this->m_sOurType.subtype.f1=wf->wFormatTag;
- this->m_sOurType.formattype=FORMAT_WaveFormatEx;
- this->m_sOurType.lSampleSize=wf->nBlockAlign;
- this->m_sOurType.bFixedSizeSamples=1;
- this->m_sOurType.bTemporalCompression=0;
- this->m_sOurType.pUnk=0;
- this->m_sOurType.cbFormat=sz;
- this->m_sOurType.pbFormat=this->m_sVhdr;
-
- memset(&this->m_sDestType, 0, sizeof(this->m_sDestType));
- this->m_sDestType.majortype=MEDIATYPE_Audio;
- this->m_sDestType.subtype=MEDIASUBTYPE_PCM;
-// this->m_sDestType.subtype.f1=pWF->wFormatTag;
- this->m_sDestType.formattype=FORMAT_WaveFormatEx;
- this->m_sDestType.bFixedSizeSamples=1;
- this->m_sDestType.bTemporalCompression=0;
- this->m_sDestType.lSampleSize=pWF->nBlockAlign;
- if (wf->wFormatTag == 0x130)
- // ACEL hack to prevent memory corruption
- // obviosly we are missing something here
- this->m_sDestType.lSampleSize *= 288;
- this->m_sDestType.pUnk=0;
- this->m_sDestType.cbFormat=18; //pWF->cbSize;
- this->m_sDestType.pbFormat=this->m_sVhdr2;
-
-//print_wave_header(this->m_sVhdr, MSGL_V);
-//print_wave_header(this->m_sVhdr2, MSGL_V);
-
- /*try*/
- {
- this->m_pDS_Filter = DS_FilterCreate(dllname, guid, &this->m_sOurType, &this->m_sDestType,&sampleProcData);
- if( !this->m_pDS_Filter ) {
- free(this);
- return NULL;
- }
-
- //Commit should be done before binary codec start
- this->m_pDS_Filter->m_pAll->vt->Commit(this->m_pDS_Filter->m_pAll);
-
- this->m_pDS_Filter->Start(this->m_pDS_Filter);
-
- }
- /*
- catch (FatalError& e)
- {
- e.PrintAll();
- delete[] m_sVhdr;
- delete[] m_sVhdr2;
- delete m_pDS_Filter;
- throw;
- }
- */
- return this;
-}
-
-void DS_AudioDecoder_Destroy(DS_AudioDecoder *this)
-{
- free(this->m_sVhdr);
- free(this->m_sVhdr2);
- DS_Filter_Destroy(this->m_pDS_Filter);
- free(this);
-}
-
-int DS_AudioDecoder_Convert(DS_AudioDecoder *this, const void* in_data, unsigned int in_size,
- void* out_data, unsigned int out_size,
- unsigned int* size_read, unsigned int* size_written)
-{
- unsigned int written = 0;
- unsigned int read = 0;
-
- if (!in_data || !out_data)
- return -1;
-
-#ifdef WIN32_LOADER
- Setup_FS_Segment();
-#endif
-
- in_size -= in_size%this->in_fmt.nBlockAlign;
- while (in_size>0)
- {
- IMediaSample* sample=0;
- char* ptr;
- int result;
- this->m_pDS_Filter->m_pAll->vt->GetBuffer(this->m_pDS_Filter->m_pAll, &sample, 0, 0, 0);
- if (!sample)
- {
- Debug printf("DS_AudioDecoder::Convert() Error: null sample\n");
- break;
- }
- sample->vt->SetActualDataLength(sample, this->in_fmt.nBlockAlign);
- sample->vt->GetPointer(sample, (BYTE **)&ptr);
- memcpy(ptr, (const uint8_t*)in_data + read, this->in_fmt.nBlockAlign);
- sample->vt->SetSyncPoint(sample, 1);
- sample->vt->SetPreroll(sample, 0);
- result = this->m_pDS_Filter->m_pImp->vt->Receive(this->m_pDS_Filter->m_pImp, sample);
- if (result)
- Debug printf("DS_AudioDecoder::Convert() Error: putting data into input pin %x\n", result);
- if ((written + sampleProcData.frame_size) > out_size)
- {
- sample->vt->Release((IUnknown*)sample);
- break;
- }
- memcpy((uint8_t*)out_data + written, sampleProcData.frame_pointer, sampleProcData.frame_size);
- sample->vt->Release((IUnknown*)sample);
- read+=this->in_fmt.nBlockAlign;
- written+=sampleProcData.frame_size;
- break;
- }
- if (size_read)
- *size_read = read;
- if (size_written)
- *size_written = written;
- return 0;
-}
-
-int DS_AudioDecoder_GetSrcSize(DS_AudioDecoder *this, int dest_size)
-{
- double efficiency =(double) this->in_fmt.nAvgBytesPerSec
- / (this->in_fmt.nSamplesPerSec*this->in_fmt.nBlockAlign);
- int frames = (int)(dest_size*efficiency);
-
- if (frames < 1)
- frames = 1;
- return frames * this->in_fmt.nBlockAlign;
-}