summaryrefslogtreecommitdiffstats
path: root/loader
diff options
context:
space:
mode:
authorarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-08-16 00:50:02 +0000
committerarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-08-16 00:50:02 +0000
commitbda27f2adc68d6065d7a7df1e6558c062efe41f1 (patch)
tree4077a416a09134894f71166eef48f9f39782fc9d /loader
parentfda7100c9d34a2c5dccddfd25e87193abe55a152 (diff)
downloadmpv-bda27f2adc68d6065d7a7df1e6558c062efe41f1.tar.bz2
mpv-bda27f2adc68d6065d7a7df1e6558c062efe41f1.tar.xz
big avifile sync - from now we have common code
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@1546 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'loader')
-rw-r--r--loader/dshow/DS_AudioDec.c199
-rw-r--r--loader/dshow/DS_AudioDecoder.c156
-rw-r--r--loader/dshow/DS_AudioDecoder.h21
-rw-r--r--loader/dshow/DS_Filter.c160
-rw-r--r--loader/dshow/DS_Filter.h24
-rw-r--r--loader/dshow/DS_VideoDec.c408
-rw-r--r--loader/dshow/DS_VideoDecoder.c625
-rw-r--r--loader/dshow/DS_VideoDecoder.h37
-rw-r--r--loader/dshow/Makefile6
-rw-r--r--loader/dshow/allocator.c183
-rw-r--r--loader/dshow/allocator.h46
-rw-r--r--loader/dshow/cmediasample.c288
-rw-r--r--loader/dshow/cmediasample.h92
-rw-r--r--loader/dshow/guids.h28
-rw-r--r--loader/dshow/inputpin.c518
-rw-r--r--loader/dshow/inputpin.h125
-rw-r--r--loader/dshow/interfaces.h458
-rw-r--r--loader/dshow/iunk.h20
-rw-r--r--loader/dshow/libwin32.h306
-rw-r--r--loader/dshow/outputpin.c556
-rw-r--r--loader/dshow/outputpin.h139
21 files changed, 2328 insertions, 2067 deletions
diff --git a/loader/dshow/DS_AudioDec.c b/loader/dshow/DS_AudioDec.c
index f3207f023a..9b462f631f 100644
--- a/loader/dshow/DS_AudioDec.c
+++ b/loader/dshow/DS_AudioDec.c
@@ -1,188 +1,63 @@
-/********************************************************
- DirectShow Audio decoder implementation
- Copyright 2000 Eugene Kuznetsov (divx@euro.ru)
- Converted C++ --> C :) by A'rpi/ESP-team
-
-*********************************************************/
-
-//#include <config.h>
+#include "guids.h"
+#include "interfaces.h"
-//#include "DS_AudioDecoder.h"
-//#include <string.h>
-using namespace std;
-#include <stdlib.h>
-#include <except.h>
-#define __MODULE__ "DirectShow_AudioDecoder"
+#include "DS_AudioDecoder.h"
+#include <wine/winerror.h>
+#include <libwin32.h>
+//#include <cpuinfo.h>
-#include <errno.h>
-#ifdef HAVE_MALLOC_H
-#include <malloc.h>
-#endif
-//#include <loader.h>
-//#include <wine/winbase.h>
-#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
-#include <strstream>
-#include <dlfcn.h>
+#include <errno.h>
#include <sys/types.h>
#include <sys/mman.h>
+#include <cstdio>
+#include <iostream>
+#include <strstream>
-#include <registry.h>
-#include <wine/winreg.h>
+#include "DS_AudioDec.h"
-#include "guids.h"
-#include "interfaces.h"
-#include "DS_Filter.h"
+// DS_Decoder(const CodecInfo& info, const WAVEFORMATEX*);
+// virtual ~DS_Decoder();
+// virtual int Convert(const void*, size_t, void*, size_t, size_t*, size_t*);
+// virtual int GetSrcSize(int);
-#include "BitmapInfo.h"
+static void* _handle;
-#include <string>
-#include <default.h>
+extern "C" void Setup_LDT_Keeper();
+extern "C" void setup_FS_Segment();
-#include "DS_AudioDec.h"
+extern "C" int DS_AudioDecoder_Open(char* dllname, GUID* guid, WAVEFORMATEX* wf){
-const GUID FORMAT_WaveFormatEx={
-0x05589f81, 0xc356, 0x11ce, 0xbf, 0x01, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a};
-const GUID MEDIATYPE_Audio={
-0x73647561, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71};
-const GUID MEDIASUBTYPE_PCM={
-0x00000001, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71};
-
-
-extern "C" char* def_path;
-
- static DS_Filter* dsf=0;
-
- static AM_MEDIA_TYPE m_sOurType, m_sDestType;
-// static void* m_pCust;
- static char* m_sVhdr;
- static char* m_sVhdr2;
-
- static WAVEFORMATEX in_fmt;
-
-// int m_iState=0;
-
-extern "C" int DS_AudioDecoder_Open(char* dllname, GUID* guid, WAVEFORMATEX* wf)
-{
-
- m_sVhdr=new char[18+wf->cbSize];
- memcpy(m_sVhdr, wf, 18+wf->cbSize);
- m_sVhdr2=new char[18];
- memcpy(m_sVhdr2, m_sVhdr, 18);
- WAVEFORMATEX* pWF=(WAVEFORMATEX*)m_sVhdr2;
- pWF->wFormatTag=1;
- pWF->wBitsPerSample=16;
- pWF->nBlockAlign=2*pWF->nChannels;
- pWF->cbSize=0;
- in_fmt=*wf;
-
- memset(&m_sOurType, 0, sizeof m_sOurType);
- m_sOurType.majortype=MEDIATYPE_Audio;
- m_sOurType.subtype=MEDIASUBTYPE_PCM;
- m_sOurType.subtype.f1=wf->wFormatTag;
- m_sOurType.formattype=FORMAT_WaveFormatEx;
- m_sOurType.lSampleSize=wf->nBlockAlign;
- m_sOurType.bFixedSizeSamples=true;
- m_sOurType.bTemporalCompression=false;
- m_sOurType.pUnk=0;
- m_sOurType.cbFormat=18+wf->cbSize;
- m_sOurType.pbFormat=m_sVhdr;
-
- memset(&m_sDestType, 0, sizeof m_sDestType);
- m_sDestType.majortype=MEDIATYPE_Audio;
- m_sDestType.subtype=MEDIASUBTYPE_PCM;
- m_sDestType.formattype=FORMAT_WaveFormatEx;
- m_sDestType.bFixedSizeSamples=true;
- m_sDestType.bTemporalCompression=false;
- m_sDestType.lSampleSize=2*wf->nChannels;
- m_sDestType.pUnk=0;
- m_sDestType.cbFormat=18;
- m_sDestType.pbFormat=m_sVhdr2;
-
- try
- {
-
- dsf=new DS_Filter();
- dsf->Create(dllname, guid, &m_sOurType, &m_sDestType);
- dsf->Start();
-
- ALLOCATOR_PROPERTIES props, props1;
- props.cBuffers=1;
- props.cbBuffer=m_sOurType.lSampleSize;
- props.cbAlign=props.cbPrefix=0;
- dsf->m_pAll->vt->SetProperties(dsf->m_pAll, &props, &props1);
- dsf->m_pAll->vt->Commit(dsf->m_pAll);
- }
- catch(FatalError e)
- {
- e.PrintAll();
- delete[] m_sVhdr;
- delete[] m_sVhdr2;
- return 1;
- }
+ Setup_LDT_Keeper();
+ setup_FS_Segment();
+
+ CodecInfo ci;
+ ci.dll=dllname;
+ ci.guid=*guid;
+
+ DS_AudioDecoder* dec=new DS_AudioDecoder(ci, wf);
+ _handle=(void*)dec;
return 0;
}
extern "C" void DS_AudioDecoder_Close(){
- delete[] m_sVhdr;
- delete[] m_sVhdr2;
}
-extern "C" int DS_AudioDecoder_GetSrcSize(int dest_size)
-{
- double efficiency=in_fmt.nAvgBytesPerSec/double(in_fmt.nSamplesPerSec*in_fmt.nBlockAlign);
- int frames=(int)(dest_size*efficiency);
- if(frames<1)frames=1;
- return frames*in_fmt.nBlockAlign;
+extern "C" int DS_AudioDecoder_GetSrcSize(int dest_size){
+ DS_AudioDecoder* dec=(DS_AudioDecoder*)_handle;
+ return dec->GetSrcSize(dest_size);
}
-
extern "C" int DS_AudioDecoder_Convert(unsigned char* in_data, unsigned in_size,
unsigned char* out_data, unsigned out_size,
- unsigned* size_read, unsigned* size_written)
-{
- if(in_data==0)return -1;
- if(out_data==0)return -1;
- int written=0;
- int read=0;
- in_size-=in_size%in_fmt.nBlockAlign;
- while(in_size>0)
- {
- long frame_size=0;
- char* frame_pointer;
-// m_pOurOutput->SetFramePointer(out_data+written);
- dsf->m_pOurOutput->SetFramePointer(&frame_pointer);
- dsf->m_pOurOutput->SetFrameSizePointer(&frame_size);
- IMediaSample* sample=0;
- dsf->m_pAll->vt->GetBuffer(dsf->m_pAll, &sample, 0, 0, 0);
- if(!sample)
- {
- cerr<<"ERROR: null sample"<<endl;
- break;
- }
- char* ptr;
- sample->vt->GetPointer(sample, (BYTE **)&ptr);
- memcpy(ptr, in_data+read, in_fmt.nBlockAlign);
- sample->vt->SetActualDataLength(sample, in_fmt.nBlockAlign);
- sample->vt->SetSyncPoint(sample, true);
- sample->vt->SetPreroll(sample, 0);
- int result=dsf->m_pImp->vt->Receive(dsf->m_pImp, sample);
- if(result) printf("Error putting data into input pin %x\n", result);
- if(written+frame_size>out_size)
- {
- sample->vt->Release((IUnknown*)sample);
- break;
- }
- memcpy(out_data+written, frame_pointer, frame_size);
- sample->vt->Release((IUnknown*)sample);
- read+=in_fmt.nBlockAlign;
- written+=frame_size;
- }
- if(size_read) *size_read=read;
- if(size_written) *size_written=written;
- return 0;
+ unsigned* size_read, unsigned* size_written){
+ DS_AudioDecoder* dec=(DS_AudioDecoder*)_handle;
+ setup_FS_Segment();
+ return dec->Convert( (void*)in_data,(size_t)in_size,
+ (void*)out_data,(size_t)out_size,
+ (size_t*)size_read, (size_t*)size_written );
}
diff --git a/loader/dshow/DS_AudioDecoder.c b/loader/dshow/DS_AudioDecoder.c
new file mode 100644
index 0000000000..cb6cb47d9e
--- /dev/null
+++ b/loader/dshow/DS_AudioDecoder.c
@@ -0,0 +1,156 @@
+/********************************************************
+
+ DirectShow audio decoder
+ Copyright 2001 Eugene Kuznetsov (divx@euro.ru)
+
+*********************************************************/
+#include "DS_AudioDecoder.h"
+
+#include <cstdio>
+#include <cstring>
+#include <string>
+#include <iostream>
+#define __MODULE__ "DirectShow audio decoder"
+const GUID FORMAT_WaveFormatEx = {
+ 0x05589f81, 0xc356, 0x11CE,
+ { 0xBF, 0x01, 0x00, 0xAA, 0x00, 0x55, 0x59, 0x5A }
+};
+const GUID MEDIATYPE_Audio = {
+ 0x73647561, 0x0000, 0x0010,
+ { 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 }
+};
+const GUID MEDIASUBTYPE_PCM = {
+ 0x00000001, 0x0000, 0x0010,
+ { 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 }
+};
+
+using namespace std;
+
+typedef long STDCALL (*GETCLASS) (GUID*, GUID*, void**);
+
+DS_AudioDecoder::DS_AudioDecoder(const CodecInfo& info, const WAVEFORMATEX* wf)
+ : IAudioDecoder(info, wf), m_pDS_Filter(0), m_sVhdr(0), m_sVhdr2(0)
+{
+ m_sVhdr=new char[18 + wf->cbSize];
+ memcpy(m_sVhdr, wf, 18 + wf->cbSize);
+ m_sVhdr2=new char[18 + wf->cbSize];
+ memcpy(m_sVhdr2, m_sVhdr, 18 + wf->cbSize);
+ WAVEFORMATEX* pWF=(WAVEFORMATEX*)m_sVhdr2;
+ pWF->wFormatTag=1;
+ pWF->wBitsPerSample=16;
+ pWF->nBlockAlign=2*pWF->nChannels;
+ pWF->cbSize=0;
+ in_fmt=*wf;
+
+ memset(&m_sOurType, 0, sizeof(m_sOurType));
+ m_sOurType.majortype=MEDIATYPE_Audio;
+ m_sOurType.subtype=MEDIASUBTYPE_PCM;
+ m_sOurType.subtype.f1=wf->wFormatTag;
+ m_sOurType.formattype=FORMAT_WaveFormatEx;
+ m_sOurType.lSampleSize=wf->nBlockAlign;
+ m_sOurType.bFixedSizeSamples=true;
+ m_sOurType.bTemporalCompression=false;
+ m_sOurType.pUnk=0;
+ m_sOurType.cbFormat=18+wf->cbSize;
+ m_sOurType.pbFormat=m_sVhdr;
+
+ memset(&m_sDestType, 0, sizeof(m_sDestType));
+ m_sDestType.majortype=MEDIATYPE_Audio;
+ m_sDestType.subtype=MEDIASUBTYPE_PCM;
+ m_sDestType.formattype=FORMAT_WaveFormatEx;
+ m_sDestType.bFixedSizeSamples=true;
+ m_sDestType.bTemporalCompression=false;
+ m_sDestType.lSampleSize=2*wf->nChannels;
+ m_sDestType.pUnk=0;
+ m_sDestType.cbFormat=18;
+ m_sDestType.pbFormat=m_sVhdr2;
+
+ try
+ {
+ m_pDS_Filter = new DS_Filter();
+ m_pDS_Filter->Create(info.dll.c_str(), &info.guid, &m_sOurType, &m_sDestType);
+ m_pDS_Filter->Start();
+
+ ALLOCATOR_PROPERTIES props, props1;
+ props.cBuffers=1;
+ props.cbBuffer=m_sOurType.lSampleSize;
+ props.cbAlign=props.cbPrefix=0;
+ m_pDS_Filter->m_pAll->vt->SetProperties(m_pDS_Filter->m_pAll, &props, &props1);
+ m_pDS_Filter->m_pAll->vt->Commit(m_pDS_Filter->m_pAll);
+ }
+ catch (FatalError e)
+ {
+ e.PrintAll();
+ delete[] m_sVhdr;
+ delete[] m_sVhdr2;
+ delete m_pDS_Filter;
+ throw;
+ }
+}
+
+DS_AudioDecoder::~DS_AudioDecoder()
+{
+ delete[] m_sVhdr;
+ delete[] m_sVhdr2;
+ delete m_pDS_Filter;
+}
+
+int DS_AudioDecoder::Convert(const void* in_data, size_t in_size,
+ void* out_data, size_t out_size,
+ size_t* size_read, size_t* size_written)
+{
+ if (!in_data || !out_data)
+ return -1;
+
+ size_t written = 0;
+ size_t read = 0;
+ in_size -= in_size%in_fmt.nBlockAlign;
+ while (in_size>0)
+ {
+ size_t frame_size=0;
+ char* frame_pointer;
+// m_pOurOutput->SetFramePointer(out_data+written);
+ m_pDS_Filter->m_pOurOutput->SetFramePointer(&frame_pointer);
+ m_pDS_Filter->m_pOurOutput->SetFrameSizePointer((long*)&frame_size);
+ IMediaSample* sample=0;
+ m_pDS_Filter->m_pAll->vt->GetBuffer(m_pDS_Filter->m_pAll, &sample, 0, 0, 0);
+ if(!sample)
+ {
+ Debug cerr<<"DS_AudioDecoder::Convert() Error: null sample"<<endl;
+ break;
+ }
+ char* ptr;
+ sample->vt->GetPointer(sample, (BYTE **)&ptr);
+ memcpy(ptr, (const uint8_t*)in_data + read, in_fmt.nBlockAlign);
+ sample->vt->SetActualDataLength(sample, in_fmt.nBlockAlign);
+ sample->vt->SetSyncPoint(sample, true);
+ sample->vt->SetPreroll(sample, 0);
+ int result = m_pDS_Filter->m_pImp->vt->Receive(m_pDS_Filter->m_pImp, sample);
+ if (result)
+ Debug printf("DS_AudioDecoder::Convert() Error: putting data into input pin %x\n", result);
+ if ((written + frame_size) > out_size)
+ {
+ sample->vt->Release((IUnknown*)sample);
+ break;
+ }
+ memcpy((uint8_t*)out_data + written, frame_pointer, frame_size);
+ sample->vt->Release((IUnknown*)sample);
+ read+=in_fmt.nBlockAlign;
+ written+=frame_size;
+ }
+ if (size_read)
+ *size_read = read;
+ if (size_written)
+ *size_written = written;
+ return 0;
+}
+
+int DS_AudioDecoder::GetSrcSize(int dest_size)
+{
+ double efficiency = (double) in_fmt.nAvgBytesPerSec
+ / (in_fmt.nSamplesPerSec*in_fmt.nBlockAlign);
+ int frames = int(dest_size*efficiency);
+ if (frames < 1)
+ frames = 1;
+ return frames * in_fmt.nBlockAlign;
+}
diff --git a/loader/dshow/DS_AudioDecoder.h b/loader/dshow/DS_AudioDecoder.h
new file mode 100644
index 0000000000..5b3eb548bf
--- /dev/null
+++ b/loader/dshow/DS_AudioDecoder.h
@@ -0,0 +1,21 @@
+#ifndef AVIFILE_DSHOW_H
+#define AVIFILE_DSHOW_H
+
+#include <libwin32.h>
+#include "DS_Filter.h"
+
+class DS_AudioDecoder : public IAudioDecoder
+{
+public:
+ DS_AudioDecoder(const CodecInfo& info, const WAVEFORMATEX*);
+ virtual ~DS_AudioDecoder();
+ virtual int Convert(const void*, size_t, void*, size_t, size_t*, size_t*);
+ virtual int GetSrcSize(int);
+protected:
+ AM_MEDIA_TYPE m_sOurType, m_sDestType;
+ DS_Filter* m_pDS_Filter;
+ char* m_sVhdr;
+ char* m_sVhdr2;
+};
+
+#endif
diff --git a/loader/dshow/DS_Filter.c b/loader/dshow/DS_Filter.c
index e2eeb1301a..a057dd2cec 100644
--- a/loader/dshow/DS_Filter.c
+++ b/loader/dshow/DS_Filter.c
@@ -1,34 +1,49 @@
-#include <stdio.h>
-#include <string.h>
#include "DS_Filter.h"
-#include <except.h>
//#include "../loader/loader.h"
+#include <libwin32.h>
#include <string>
-#include <iostream>
+#include <stdio.h>
+#include <string.h>
+
#define __MODULE__ "DirectShow generic filter"
using namespace std;
-typedef long STDCALL (*GETCLASS) (const GUID*, const GUID*, void**);
-extern "C" char* def_path;
-
extern "C" int STDCALL expLoadLibraryA(const char*);
-extern "C" STDCALL void* GetProcAddress(int, const char*);
-extern "C" int STDCALL FreeLibrary(int);
-extern "C" void Setup_LDT_Keeper();
-extern "C" void setup_FS_Segment();
+typedef long STDCALL (*GETCLASS) (const GUID*, const GUID*, void**);
+
+//extern "C" int STDCALL LoadLibraryA(const char*);
+//extern "C" STDCALL void* GetProcAddress(int, const char*); // STDCALL has to be first NetBSD
+//extern "C" int STDCALL FreeLibrary(int);
DS_Filter::DS_Filter()
- :m_iHandle(0), m_pFilter(0), m_pInputPin(0),
- m_pOutputPin(0), m_pSrcFilter(0), m_pParentFilter(0),
- m_pOurInput(0), m_pOurOutput(0), m_pAll(0), m_pImp(0),
- m_iState(0)
{
+ m_iHandle = 0;
+ m_pFilter = 0;
+ m_pInputPin = 0;
+ m_pOutputPin = 0;
+ m_pSrcFilter = 0;
+ m_pParentFilter = 0;
+ m_pOurInput = 0;
+ m_pOurOutput = 0;
+ m_pAll = 0;
+ m_pImp = 0;
+ m_iState = 0;
}
-void DS_Filter::clean()
+DS_Filter::~DS_Filter()
{
+ //cout << "Destruction of DS_FILTER" << endl;
+ Stop();
+ destroy();
+ //cout << "Destruction of DS_FILTER done" << endl;
+}
+
+void DS_Filter::destroy()
+{
+ if (m_iState == 0)
+ return;
m_iState = 0;
if (m_pOurInput)
@@ -53,67 +68,56 @@ void DS_Filter::clean()
// FIXME - we are still leaving few things allocated!
if (m_iHandle)
FreeLibrary(m_iHandle);
-
}
-DS_Filter::~DS_Filter()
+void DS_Filter::Create(const char* dllname, const GUID* id,
+ AM_MEDIA_TYPE* in_fmt,
+ AM_MEDIA_TYPE* out_fmt)
{
- //cout << "Destruction of DS_FILTER" << endl;
- Stop();
- if (m_iState == 1)
- clean();
- //cout << "Destruction of DS_FILTER done" << endl;
-}
-
-void DS_Filter::Create(char* dllname, const GUID* id, AM_MEDIA_TYPE* in_fmt, AM_MEDIA_TYPE* out_fmt)
-{
-
- Setup_LDT_Keeper();
-
try
{
-// string _fullname=def_path;
-// _fullname+="/";
-// _fullname+=dllname;
- m_iHandle= expLoadLibraryA(dllname);
+ m_iHandle = expLoadLibraryA(dllname);
if (!m_iHandle)
{
- char e[1024];
- snprintf(e, 1024, "Could not open DirectShow DLL: %s", dllname);
+ char e[256];
+ printf("Could not open DirectShow DLL: %.200s", dllname);
throw FATAL(e);
}
- GETCLASS func=(GETCLASS)GetProcAddress(m_iHandle, "DllGetClassObject");
+ GETCLASS func = (GETCLASS)GetProcAddress(m_iHandle, "DllGetClassObject");
if (!func)
{
- char e[1024];
- snprintf(e, 1024, "Illegal or corrupt DirectShow DLL: %s", dllname);
+ char e[256];
+ printf("Illegal or corrupt DirectShow DLL: %.200s", dllname);
throw FATAL(e);
}
HRESULT result;
- IClassFactory* factory=0;
- result=func(id, &IID_IClassFactory, (void**)&factory);
- if(result || (!factory)) throw FATAL("No such class object");;
-
- setup_FS_Segment();
+ IClassFactory* factory = 0;
+ result = func(id, &IID_IClassFactory, (void**)&factory);
+ if (result || !factory)
+ throw FATAL("No such class object");;
- IUnknown* object=0;
- result=factory->vt->CreateInstance(factory, 0, &IID_IUnknown, (void**)&object);
+ IUnknown* object = 0;
+ result = factory->vt->CreateInstance(factory, 0, &IID_IUnknown, (void**)&object);
factory->vt->Release((IUnknown*)factory);
- if(result || (!object)) throw FATAL("Class factory failure");
+ if (result || !object)
+ throw FATAL("Class factory failure");
- result=object->vt->QueryInterface(object, &IID_IBaseFilter, (void**)&m_pFilter);
+ result = object->vt->QueryInterface(object, &IID_IBaseFilter, (void**)&m_pFilter);
object->vt->Release((IUnknown*)object);
- if(result || (!m_pFilter)) throw FATAL("Object does not have IBaseFilter interface");
+ if (result || !m_pFilter)
+ throw FATAL("Object does not have IBaseFilter interface");
+
+ IEnumPins* enum_pins = 0;
+ // enumerate pins
+ result = m_pFilter->vt->EnumPins(m_pFilter, &enum_pins);
+ if (result || !enum_pins)
+ throw FATAL("Could not enumerate pins");
- IEnumPins* enum_pins=0;
- // enumerate pins
- result=m_pFilter->vt->EnumPins(m_pFilter, &enum_pins);
- if(result || (!enum_pins)) throw FATAL("Could not enumerate pins");
IPin* array[256];
ULONG fetched;
enum_pins->vt->Reset(enum_pins);
- result=enum_pins->vt->Next(enum_pins, (ULONG)256, (IPin**)array, &fetched);
+ result = enum_pins->vt->Next(enum_pins, (ULONG)256, (IPin**)array, &fetched);
Debug printf("Pins enumeration returned %ld pins, error is %x\n", fetched, (int)result);
for (unsigned i = 0; i < fetched; i++)
@@ -140,38 +144,45 @@ void DS_Filter::Create(char* dllname, const GUID* id, AM_MEDIA_TYPE* in_fmt, AM
result = m_pInputPin->vt->QueryInterface((IUnknown*)m_pInputPin,
&IID_IMemInputPin,
(void**)&m_pImp);
- if(result)
+ if (result)
throw FATAL("Error getting IMemInputPin interface");
- m_pOurType=in_fmt;
- m_pDestType=out_fmt;
- result=m_pInputPin->vt->QueryAccept(m_pInputPin, m_pOurType);
+ m_pOurType = in_fmt;
+ m_pDestType = out_fmt;
+ result = m_pInputPin->vt->QueryAccept(m_pInputPin, m_pOurType);
if (result)
throw FATAL("Source format is not accepted");
- m_pParentFilter=new CBaseFilter2;
- m_pSrcFilter=new CBaseFilter(*m_pOurType, m_pParentFilter);
- m_pOurInput=m_pSrcFilter->GetPin();
+ m_pParentFilter = new CBaseFilter2;
+ m_pSrcFilter = new CBaseFilter(*m_pOurType, m_pParentFilter);
+ m_pOurInput = m_pSrcFilter->GetPin();
m_pOurInput->vt->AddRef((IUnknown*)m_pOurInput);
- result=m_pInputPin->vt->ReceiveConnection(m_pInputPin, m_pOurInput,
- m_pOurType);
+ result = m_pInputPin->vt->ReceiveConnection(m_pInputPin,
+ m_pOurInput,
+ m_pOurType);
if (result)
throw FATAL("Error connecting to input pin");
m_pOurOutput = new COutputPin(*m_pDestType);
+ //extern void trapbug();
+ //trapbug();
result = m_pOutputPin->vt->ReceiveConnection(m_pOutputPin,
m_pOurOutput,
m_pDestType);
if (result)
+ {
+ //printf("Tracking ACELP %d 0%x\n", result);
throw FATAL("Error connecting to output pin");
- cout << "Using DirectShow codec: " << dllname << endl;
+ }
+
+ printf("Using DirectShow codec: %s\n", dllname);
m_iState = 1;
}
- catch(FatalError e)
+ catch (FatalError e)
{
- e.PrintAll();
- clean();
+ //e.PrintAll();
+ destroy();
throw;
}
}
@@ -181,22 +192,19 @@ void DS_Filter::Start()
if (m_iState != 1)
return;
- m_pFilter->vt->Pause(m_pFilter);
-
HRESULT hr=m_pFilter->vt->Run(m_pFilter, 0);
if (hr != 0)
{
- Debug cerr<<"WARNING: m_Filter->Run() failed, error code "<<hex<<hr<<dec<<endl;
+ Debug printf("WARNING: m_Filter->Run() failed, error code %x\n", (int)hr);
}
- hr=m_pImp->vt->GetAllocator(m_pImp, &m_pAll);
+ hr = m_pImp->vt->GetAllocator(m_pImp, &m_pAll);
if (hr)
{
- Debug cerr<<"Error getting IMemAllocator interface "<<hex<<hr<<dec<<endl;
+ Debug printf("Error getting IMemAllocator interface %x\n", (int)hr);
m_pImp->vt->Release((IUnknown*)m_pImp);
return;
}
m_pImp->vt->NotifyAllocator(m_pImp, m_pAll, 0);
-
m_iState = 2;
}
@@ -205,8 +213,8 @@ void DS_Filter::Stop()
if (m_iState == 2)
{
m_pAll->vt->Release((IUnknown*)m_pAll);
- m_pAll=0;
- m_pFilter->vt->Stop(m_pFilter);
- m_iState=1;
+ m_pFilter->vt->Stop(m_pFilter); // causes weird crash ??? FIXME
+ m_pAll = 0;
+ m_iState = 1;
}
}
diff --git a/loader/dshow/DS_Filter.h b/loader/dshow/DS_Filter.h
index 61ddb938fe..2f10849e2b 100644
--- a/loader/dshow/DS_Filter.h
+++ b/loader/dshow/DS_Filter.h
@@ -1,22 +1,22 @@
-#ifndef DS_Filter_H
-#define DS_Filter_H
+#ifndef DS_FILTER_H
+#define DS_FILTER_H
#include "interfaces.h"
#include "inputpin.h"
#include "outputpin.h"
-#include <string>
/**
- User will allocate and fill format structures, call Create(),
- and then set up m_pAll.
-**/
-class DS_Filter
+ User will allocate and fill format structures, call Create(),
+ and then set up m_pAll.
+ **/
+
+struct DS_Filter
{
-public:
DS_Filter();
virtual ~DS_Filter();
void Start();
void Stop();
+
int m_iHandle;
IBaseFilter* m_pFilter;
IPin* m_pInputPin;
@@ -32,10 +32,10 @@ public:
IMemInputPin* m_pImp;
int m_iState;
- void Create(char* dllname, const GUID* id, AM_MEDIA_TYPE* in_fmt, AM_MEDIA_TYPE* out_fmt);
+ void Create(const char* dllname, const GUID* id, AM_MEDIA_TYPE* in_fmt, AM_MEDIA_TYPE* out_fmt);
void SetPointer(char* pointer);
-private:
- void clean();
+
+ void destroy();
};
-#endif
+#endif /* DS_FILTER_H */
diff --git a/loader/dshow/DS_VideoDec.c b/loader/dshow/DS_VideoDec.c
index 48509602d3..71ca289cda 100644
--- a/loader/dshow/DS_VideoDec.c
+++ b/loader/dshow/DS_VideoDec.c
@@ -1,414 +1,78 @@
-/********************************************************
-
- DirectShow Video decoder implementation
- Copyright 2000 Eugene Kuznetsov (divx@euro.ru)
- Converted C++ --> C :) by A'rpi/ESP-team
-
-*********************************************************/
-
-//#include <config.h>
-
-//#include "DS_VideoDecoder.h"
-//#include <string.h>
-using namespace std;
-#include <stdlib.h>
-#include <except.h>
-#define __MODULE__ "DirectShow_VideoDecoder"
+#include "guids.h"
+#include "interfaces.h"
+#include "DS_VideoDecoder.h"
+#include <wine/winerror.h>
+#include <libwin32.h>
+//#include <cpuinfo.h>
-#include <errno.h>
-#ifdef HAVE_MALLOC_H
-#include <malloc.h>
-#endif
-//#include <loader.h>
-//#include <wine/winbase.h>
-#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
-#include <strstream>
-#include <dlfcn.h>
+#include <errno.h>
#include <sys/types.h>
#include <sys/mman.h>
+#include <cstdio>
+#include <iostream>
+#include <strstream>
#include <registry.h>
-#include <wine/winreg.h>
-
-#include "guids.h"
-#include "interfaces.h"
-#include "DS_Filter.h"
-
-#include "BitmapInfo.h"
-
-#include <string>
-#include <default.h>
+//#include <wine/winreg.h>
#include "DS_VideoDec.h"
+static void* _handle; // will be parameter later...
+static char** _d_ptr; // will be parameter later...
-extern "C" char* def_path;
-
- static char** m_destptr=0;
-
- static DS_Filter* dsf=0;
-
- static AM_MEDIA_TYPE m_sOurType, m_sDestType;
- static VIDEOINFOHEADER *m_sVhdr;
- static VIDEOINFOHEADER *m_sVhdr2;
- static void* m_pCust;
-
- static BITMAPINFOHEADER *m_bh;//format of input data
- static BitmapInfo m_decoder;//format of decoder output
- static BitmapInfo m_obh; //format of returned frames
-// CImage* m_outFrame;
+extern "C" void Setup_LDT_Keeper();
+extern "C" void setup_FS_Segment();
-// int m_iState=0;
+extern "C" int DS_VideoDecoder_Open(char* dllname, GUID* guid, BITMAPINFOHEADER* format, int flip,char** d_ptr){
-extern "C" int DS_VideoDecoder_Open(char* dllname, GUID* guid, BITMAPINFOHEADER* format, int flip,char** d_ptr)
-// :IVideoDecoder(info), m_sVhdr2(0)
-{
+ Setup_LDT_Keeper();
- m_destptr=d_ptr;
+ CodecInfo ci;
+ ci.dll=dllname;
+ ci.guid=*guid;
- //m_outFrame=0;
- //decpos = 0;
- //playpos = 0;
- //realtime = 0;
-
- try
- {
- m_bh=format;
- memset(&m_obh, 0, sizeof(m_obh));
- m_obh.biSize=sizeof(m_obh);
-
-#if 0
- memset(&m_sVhdr, 0, sizeof(m_sVhdr));
- m_sVhdr.bmiHeader=m_bh;
- m_sVhdr.rcSource.left=m_sVhdr.rcSource.top=0;
- m_sVhdr.rcSource.right=m_sVhdr.bmiHeader.biWidth;
- m_sVhdr.rcSource.bottom=m_sVhdr.bmiHeader.biHeight;
- m_sVhdr.rcTarget=m_sVhdr.rcSource;
-#else
- unsigned bihs = (format->biSize < (int) sizeof(BITMAPINFOHEADER)) ?
- sizeof(BITMAPINFOHEADER) : format->biSize;
- bihs = sizeof(VIDEOINFOHEADER) - sizeof(BITMAPINFOHEADER) + bihs;
-
- m_sVhdr = (VIDEOINFOHEADER*) new char[bihs];
- memset(m_sVhdr, 0, bihs);
- memcpy(&m_sVhdr->bmiHeader, m_bh, m_bh->biSize);
-
- m_sVhdr->rcSource.left = m_sVhdr->rcSource.top = 0;
- m_sVhdr->rcSource.right = m_sVhdr->bmiHeader.biWidth;
- m_sVhdr->rcSource.bottom = m_sVhdr->bmiHeader.biHeight;
- m_sVhdr->rcTarget = m_sVhdr->rcSource;
-#endif
- m_sOurType.majortype=MEDIATYPE_Video;
- m_sOurType.subtype=MEDIATYPE_Video;
- m_sOurType.subtype.f1=m_sVhdr->bmiHeader.biCompression;
- m_sOurType.formattype=FORMAT_VideoInfo;
- m_sOurType.bFixedSizeSamples=false;
- m_sOurType.bTemporalCompression=true;
- m_sOurType.pUnk=0;
-// m_sOurType.cbFormat=sizeof(m_sVhdr);
-// m_sOurType.pbFormat=(char*)&m_sVhdr;
- m_sOurType.cbFormat = bihs;
- m_sOurType.pbFormat = (char*)m_sVhdr;
-
- m_sVhdr2=(VIDEOINFOHEADER*)(new char[sizeof(VIDEOINFOHEADER)+12]);
-// *m_sVhdr2=m_sVhdr;
- memcpy(m_sVhdr2, m_sVhdr, sizeof(VIDEOINFOHEADER)+12);
- m_sVhdr2->bmiHeader.biCompression=0;
- m_sVhdr2->bmiHeader.biBitCount=24;
-
- memset(&m_sDestType, 0, sizeof(m_sDestType));
- m_sDestType.majortype=MEDIATYPE_Video;
- m_sDestType.subtype=MEDIASUBTYPE_RGB24;
- m_sDestType.formattype=FORMAT_VideoInfo;
- m_sDestType.bFixedSizeSamples=true;
- m_sDestType.bTemporalCompression=false;
- m_sDestType.lSampleSize=abs(m_sVhdr2->bmiHeader.biWidth*m_sVhdr2->bmiHeader.biHeight*
- ((m_sVhdr2->bmiHeader.biBitCount+7)/8));
- m_sVhdr2->bmiHeader.biSizeImage=m_sDestType.lSampleSize;
- m_sDestType.pUnk=0;
- m_sDestType.cbFormat=sizeof(VIDEOINFOHEADER);
- m_sDestType.pbFormat=(char*)m_sVhdr2;
- m_obh = *m_bh;
- m_obh.setBits(24);
-
- HRESULT result;
-
- dsf=new DS_Filter();
- dsf->Create(dllname, guid, &m_sOurType, &m_sDestType);
-
- if(!flip)
- {
- m_sVhdr2->bmiHeader.biHeight*=-1;
- m_obh.biHeight*=