changeset 3056:213b35f84cf3

C++ -> C (import from avifile cvs)
author arpi
date Wed, 21 Nov 2001 19:12:39 +0000
parents 38df49b91824
children a78b90991320
files loader/dshow/DS_Filter.c loader/dshow/DS_Filter.h loader/dshow/allocator.c loader/dshow/allocator.h loader/dshow/cmediasample.c loader/dshow/cmediasample.h loader/dshow/guids.c loader/dshow/guids.h loader/dshow/inputpin.c loader/dshow/inputpin.h loader/dshow/interfaces.h loader/dshow/iunk.h loader/dshow/outputpin.c loader/dshow/outputpin.h
diffstat 14 files changed, 1528 insertions(+), 1333 deletions(-) [+]
line wrap: on
line diff
--- a/loader/dshow/DS_Filter.c	Wed Nov 21 18:40:59 2001 +0000
+++ b/loader/dshow/DS_Filter.c	Wed Nov 21 19:12:39 2001 +0000
@@ -1,223 +1,251 @@
 #include "DS_Filter.h"
-//#include "../loader/loader.h"
-#include "libwin32.h"
-//#include <string>
+#include "driver.h"
+#include "com.h"
 #include <stdio.h>
 #include <string.h>
 
-#define __MODULE__ "DirectShow generic filter"
-
-using namespace std;
-
-extern "C" int STDCALL expLoadLibraryA(const char*);
-
 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()
+static void DS_Filter_Start(DS_Filter* This)
 {
-    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;
+    HRESULT hr;
+
+    if (This->m_iState != 1)
+	return;
+
+    //Debug printf("DS_Filter_Start(%p)\n", This);
+    hr = This->m_pFilter->vt->Run(This->m_pFilter, 0);
+    if (hr != 0)
+    {
+	Debug printf("WARNING: m_Filter->Run() failed, error code %x\n", (int)hr);
+    }
+    hr = This->m_pImp->vt->GetAllocator(This->m_pImp, &This->m_pAll);
+
+    if (hr || !This->m_pAll)
+    {
+	Debug printf("WARNING: error getting IMemAllocator interface %x\n", (int)hr);
+	This->m_pImp->vt->Release((IUnknown*)This->m_pImp);
+        return;
+    }
+    This->m_pImp->vt->NotifyAllocator(This->m_pImp, This->m_pAll, 0);
+    This->m_iState = 2;
 }
 
-DS_Filter::~DS_Filter()
+static void DS_Filter_Stop(DS_Filter* This)
 {
-    //cout << "Destruction of DS_FILTER" << endl;
-    Stop();
-    destroy();
-    //cout << "Destruction of DS_FILTER done" << endl;
+    if (This->m_iState == 2)
+    {
+	This->m_iState = 1;
+	//Debug	printf("DS_Filter_Stop(%p)\n", This);
+	if (This->m_pFilter)
+	{
+	    //printf("vt: %p\n", m_pFilter->vt);
+	    //printf("vtstop %p\n", m_pFilter->vt->Stop);
+	    This->m_pFilter->vt->Stop(This->m_pFilter); // causes weird crash ??? FIXME
+	}
+	else
+	    printf("WARNING: DS_Filter::Stop() m_pFilter is NULL!\n");
+	This->m_pAll->vt->Release((IUnknown*)This->m_pAll);
+	This->m_pAll = 0;
+    }
 }
 
-void DS_Filter::destroy()
+void DS_Filter_Destroy(DS_Filter* This)
 {
-    if (m_iState == 0)
-	return;
-    m_iState = 0;
+    This->Stop(This);
+
+    This->m_iState = 0;
 
-    if (m_pOurInput)
-	m_pOurInput->vt->Release((IUnknown*)m_pOurInput);
-    if (m_pInputPin)
-	m_pInputPin->vt->Disconnect(m_pInputPin);
-    if (m_pOutputPin)
-	m_pOutputPin->vt->Disconnect(m_pOutputPin);
-    if (m_pFilter)
-	m_pFilter->vt->Release((IUnknown*)m_pFilter);
-    if (m_pOutputPin)
-	m_pOutputPin->vt->Release((IUnknown*)m_pOutputPin);
-    if (m_pInputPin)
-	m_pInputPin->vt->Release((IUnknown*)m_pInputPin);
-    if (m_pImp)
-	m_pImp->vt->Release((IUnknown*)m_pImp);
+    if (This->m_pOurInput)
+	This->m_pOurInput->vt->Release((IUnknown*)This->m_pOurInput);
+    if (This->m_pInputPin)
+	This->m_pInputPin->vt->Disconnect(This->m_pInputPin);
+    if (This->m_pOutputPin)
+	This->m_pOutputPin->vt->Disconnect(This->m_pOutputPin);
+    if (This->m_pFilter)
+	This->m_pFilter->vt->Release((IUnknown*)This->m_pFilter);
+    if (This->m_pOutputPin)
+	This->m_pOutputPin->vt->Release((IUnknown*)This->m_pOutputPin);
+    if (This->m_pInputPin)
+	This->m_pInputPin->vt->Release((IUnknown*)This->m_pInputPin);
+    if (This->m_pImp)
+	This->m_pImp->vt->Release((IUnknown*)This->m_pImp);
 
-    delete m_pOurOutput;
-    delete m_pParentFilter;
-    delete m_pSrcFilter;
+    if (This->m_pOurOutput)
+	This->m_pOurOutput->vt->Release((IUnknown*)This->m_pOurOutput);
+    if (This->m_pParentFilter)
+	This->m_pSrcFilter->vt->Release((IUnknown*)This->m_pParentFilter);
+    if (This->m_pSrcFilter)
+	This->m_pSrcFilter->vt->Release((IUnknown*)This->m_pSrcFilter);
 
     // FIXME - we are still leaving few things allocated!
-    if (m_iHandle)
-	FreeLibrary(m_iHandle);
+    if (This->m_iHandle)
+	FreeLibrary(This->m_iHandle);
+
+    free(This);
+
+    CodecRelease();
 }
 
-void DS_Filter::Create(const char* dllname, const GUID* id,
-		       AM_MEDIA_TYPE* in_fmt,
-		       AM_MEDIA_TYPE* out_fmt)
+DS_Filter* DS_FilterCreate(const char* dllname, const GUID* id,
+			   AM_MEDIA_TYPE* in_fmt,
+			   AM_MEDIA_TYPE* out_fmt)
 {
-    try
+    DS_Filter* This = (DS_Filter*) malloc(sizeof(DS_Filter));
+    if (!This)
+	return NULL;
+
+    CodecAlloc();
+
+    This->m_pFilter = NULL;
+    This->m_pInputPin = NULL;
+    This->m_pOutputPin = NULL;
+    This->m_pSrcFilter = NULL;
+    This->m_pParentFilter = NULL;
+    This->m_pOurInput = NULL;
+    This->m_pOurOutput = NULL;
+    This->m_pAll = NULL;
+    This->m_pImp = NULL;
+    This->m_iState = 0;
+
+    This->Start = DS_Filter_Start;
+    This->Stop = DS_Filter_Stop;
+
+    for (;;)
     {
-	m_iHandle = expLoadLibraryA(dllname);
-	if (!m_iHandle)
+	HRESULT result;
+	GETCLASS func;
+	struct IClassFactory* factory = NULL;
+	struct IUnknown* object = NULL;
+	IEnumPins* enum_pins = 0;
+	IPin* array[256];
+	ULONG fetched;
+        unsigned int i;
+
+	This->m_iHandle = LoadLibraryA(dllname);
+	if (!This->m_iHandle)
 	{
-	    char e[256];
-	    snprintf((char *)&e[0], 256, "Could not open DirectShow DLL: %.200s", dllname);
-	    throw FATAL(e);
+	    printf("Could not open DirectShow DLL: %.200s\n", dllname);
+	    break;
 	}
-        GETCLASS func = (GETCLASS)GetProcAddress(m_iHandle, "DllGetClassObject");
+	func = (GETCLASS)GetProcAddress(This->m_iHandle, "DllGetClassObject");
 	if (!func)
 	{
-	    char e[256];
-	    snprintf((char *)&e[0], 256, "Illegal or corrupt DirectShow DLL: %.200s", dllname);
-	    throw FATAL(e);
+	    printf("Illegal or corrupt DirectShow DLL: %.200s\n", dllname);
+	    break;
 	}
-
-	HRESULT result;
-	IClassFactory* factory = 0;
 	result = func(id, &IID_IClassFactory, (void**)&factory);
 	if (result || !factory)
-	    throw FATAL("No such class object");;
-
-	IUnknown* object = 0;
+	{
+	    printf("No such class object\n");
+	    break;
+	}
 	result = factory->vt->CreateInstance(factory, 0, &IID_IUnknown, (void**)&object);
 	factory->vt->Release((IUnknown*)factory);
 	if (result || !object)
-	    throw FATAL("Class factory failure");
-
-	result = object->vt->QueryInterface(object, &IID_IBaseFilter, (void**)&m_pFilter);
+	{
+	    printf("Class factory failure\n");
+	    break;
+	}
+	result = object->vt->QueryInterface(object, &IID_IBaseFilter, (void**)&This->m_pFilter);
 	object->vt->Release((IUnknown*)object);
-	if (result || !m_pFilter)
-	    throw FATAL("Object does not have IBaseFilter interface");
+	if (result || !This->m_pFilter)
+	{
+	    printf("Object does not have IBaseFilter interface\n");
+            break;
+	}
+	// enumerate pins
+	result = This->m_pFilter->vt->EnumPins(This->m_pFilter, &enum_pins);
+	if (result || !enum_pins)
+	{
+	    printf("Could not enumerate pins\n");
+            break;
+	}
 
-	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);
 	Debug printf("Pins enumeration returned %ld pins, error is %x\n", fetched, (int)result);
 
-	for (unsigned i = 0; i < fetched; i++)
+	for (i = 0; i < fetched; i++)
 	{
 	    int direction = -1;
 	    array[i]->vt->QueryDirection(array[i], (PIN_DIRECTION*)&direction);
-	    if (!m_pInputPin && direction == 0)
+	    if (!This->m_pInputPin && direction == 0)
 	    {
-		m_pInputPin = array[i];
-		m_pInputPin->vt->AddRef((IUnknown*)m_pInputPin);
+		This->m_pInputPin = array[i];
+		This->m_pInputPin->vt->AddRef((IUnknown*)This->m_pInputPin);
 	    }
-	    if (!m_pOutputPin && direction == 1)
+	    if (!This->m_pOutputPin && direction == 1)
 	    {
-		m_pOutputPin = array[i];
-		m_pOutputPin->vt->AddRef((IUnknown*)m_pOutputPin);
+		This->m_pOutputPin = array[i];
+		This->m_pOutputPin->vt->AddRef((IUnknown*)This->m_pOutputPin);
 	    }
 	    array[i]->vt->Release((IUnknown*)(array[i]));
 	}
-	if (!m_pInputPin)
-	    throw FATAL("Input pin not found");
-	if (!m_pOutputPin)
-	    throw FATAL("Output pin not found");
-
-	result = m_pInputPin->vt->QueryInterface((IUnknown*)m_pInputPin,
-						 &IID_IMemInputPin,
-						 (void**)&m_pImp);
-        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);
+	if (!This->m_pInputPin)
+	{
+	    printf("Input pin not found\n");
+            break;
+	}
+	if (!This->m_pOutputPin)
+	{
+	    printf("Output pin not found\n");
+            break;
+	}
+	result = This->m_pInputPin->vt->QueryInterface((IUnknown*)This->m_pInputPin,
+						       &IID_IMemInputPin,
+						       (void**)&This->m_pImp);
 	if (result)
-	    throw FATAL("Source format is not accepted");
+	{
+	    printf("Error getting IMemInputPin interface\n");
+	    break;
+	}
 
-	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);
+	This->m_pOurType = in_fmt;
+	This->m_pDestType = out_fmt;
+        result = This->m_pInputPin->vt->QueryAccept(This->m_pInputPin, This->m_pOurType);
 	if (result)
-	    throw FATAL("Error connecting to input pin");
-
-	m_pOurOutput = new COutputPin(*m_pDestType);
+	{
+	    printf("Source format is not accepted\n");
+            break;
+	}
+	This->m_pParentFilter = CBaseFilter2Create();
+	This->m_pSrcFilter = CBaseFilterCreate(This->m_pOurType, This->m_pParentFilter);
+	This->m_pOurInput = This->m_pSrcFilter->GetPin(This->m_pSrcFilter);
+	This->m_pOurInput->vt->AddRef((IUnknown*)This->m_pOurInput);
 
-	//extern void trapbug();
-	//trapbug();
-	result = m_pOutputPin->vt->ReceiveConnection(m_pOutputPin,
-						     m_pOurOutput,
-						     m_pDestType);
+	result = This->m_pInputPin->vt->ReceiveConnection(This->m_pInputPin,
+							  This->m_pOurInput,
+							  This->m_pOurType);
+	if (result)
+	{
+	    printf("Error connecting to input pin\n");
+            break;
+	}
+
+	This->m_pOurOutput = COutputPinCreate(This->m_pDestType);
+
+	result = This->m_pOutputPin->vt->ReceiveConnection(This->m_pOutputPin,
+							   (IPin*) This->m_pOurOutput,
+							   This->m_pDestType);
 	if (result)
 	{
 	    //printf("Tracking ACELP %d  0%x\n", result);
-	    throw FATAL("Error connecting to output pin");
+	    printf("Error connecting to output pin\n");
+            break;
 	}
 
 	printf("Using DirectShow codec: %s\n", dllname);
-	m_iState = 1;
-    }
-    catch (FatalError e)
-    {
-	//e.PrintAll();
-	destroy();
-	throw;
-    }
-}
-
-void DS_Filter::Start()
-{
-    if (m_iState != 1)
-	return;
-
-    HRESULT hr=m_pFilter->vt->Run(m_pFilter, 0);
-    if (hr != 0)
-    {
-	Debug printf("WARNING: m_Filter->Run() failed, error code %x\n", (int)hr);
+	This->m_iState = 1;
+        break;
     }
-    hr = m_pImp->vt->GetAllocator(m_pImp, &m_pAll);
-    if (hr)
+
+    if (This->m_iState != 1)
     {
-	Debug printf("Error getting IMemAllocator interface %x\n", (int)hr);
-        m_pImp->vt->Release((IUnknown*)m_pImp);
-        return;
+	DS_Filter_Destroy(This);
+        This = 0;
     }
-    m_pImp->vt->NotifyAllocator(m_pImp, m_pAll,	0);
-    m_iState = 2;
+    return This;
 }
-
-void DS_Filter::Stop()
-{
-    if (m_iState == 2)
-    {
-	m_pAll->vt->Release((IUnknown*)m_pAll);
-        if (m_pFilter)
-	    m_pFilter->vt->Stop(m_pFilter); // causes weird crash ??? FIXME
-	else
-	    printf("m_pFilter is NULL!\n");
-	m_pAll = 0;
-	m_iState = 1;
-    }
-}
--- a/loader/dshow/DS_Filter.h	Wed Nov 21 18:40:59 2001 +0000
+++ b/loader/dshow/DS_Filter.h	Wed Nov 21 19:12:39 2001 +0000
@@ -1,41 +1,46 @@
 #ifndef DS_FILTER_H
 #define DS_FILTER_H
 
-#include "interfaces.h"
 #include "inputpin.h"
 #include "outputpin.h"
 
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
 /**
    User will allocate and fill format structures, call Create(),
    and then set up m_pAll.
  **/
 
-struct DS_Filter
+typedef struct _DS_Filter DS_Filter;
+struct _DS_Filter
 {
-    DS_Filter();
-    virtual ~DS_Filter();
-    void Start();
-    void Stop();
-
     int m_iHandle;
     IBaseFilter* m_pFilter;
     IPin* m_pInputPin;
     IPin* m_pOutputPin;
-    
+
     CBaseFilter* m_pSrcFilter;
     CBaseFilter2* m_pParentFilter;
     IPin* m_pOurInput;
     COutputPin* m_pOurOutput;
-    
+
     AM_MEDIA_TYPE *m_pOurType, *m_pDestType;
     IMemAllocator* m_pAll;
     IMemInputPin* m_pImp;
     int m_iState;
 
-    void Create(const char* dllname, const GUID* id, AM_MEDIA_TYPE* in_fmt, AM_MEDIA_TYPE* out_fmt);
-    void SetPointer(char* pointer);
-
-    void destroy();
+    void ( *Start )(DS_Filter*);
+    void ( *Stop )(DS_Filter*);
 };
 
+DS_Filter* DS_FilterCreate(const char* dllname, const GUID* id,
+			   AM_MEDIA_TYPE* in_fmt, AM_MEDIA_TYPE* out_fmt);
+void DS_Filter_Destroy(DS_Filter* This);
+
+#if defined(__cplusplus)
+}
+#endif
+
 #endif /* DS_FILTER_H */
--- a/loader/dshow/allocator.c	Wed Nov 21 18:40:59 2001 +0000
+++ b/loader/dshow/allocator.c	Wed Nov 21 19:12:39 2001 +0000
@@ -3,62 +3,136 @@
 #include "wine/winerror.h"
 #include <stdio.h>
 
-//#undef Debug
-//#define Debug
+static int AllocatorKeeper = 0;
 
-using namespace std;
+static inline int avm_list_size(avm_list_t* head)
+{
+    avm_list_t* it = head;
+    int i = 0;
+    if (it)
+    {
+	for (;;)
+	{
+            i++;
+	    it = it->next;
+	    if (it == head)
+                break;
+	}
+    }
+    return i;
+}
 
-class AllocatorKeeper
+static inline int avm_list_print(avm_list_t* head)
 {
-public:
-    AllocatorKeeper()
+    avm_list_t* it = head;
+    int i = 0;
+    printf("Head: %p\n", head);
+    if (it)
     {
-	RegisterComClass(&CLSID_MemoryAllocator, MemAllocator::CreateAllocator);
+	for (;;)
+	{
+	    i++;
+	    printf("%d:  member: %p    next: %p  prev: %p\n",
+		   i, it->member, it->next, it->prev);
+	    it = it->next;
+	    if (it == head)
+                break;
+	}
     }
-    ~AllocatorKeeper()
+    return i;
+}
+
+static inline avm_list_t* avm_list_add_head(avm_list_t* head, void* member)
+{
+    avm_list_t* n = (avm_list_t*) malloc(sizeof(avm_list_t));
+    n->member = member;
+
+    if (!head)
     {
-	UnregisterComClass(&CLSID_MemoryAllocator, MemAllocator::CreateAllocator);
+	head = n;
+        head->prev = head;
     }
-};
-static AllocatorKeeper keeper;
+
+    n->prev = head->prev;
+    head->prev = n;
+    n->next = head;
+
+    return n;
+}
 
+static inline avm_list_t* avm_list_add_tail(avm_list_t* head, void* member)
+{
+    avm_list_t* n = avm_list_add_head(head, member);
+    return (!head) ? n : head;
+}
 
-GUID MemAllocator::interfaces[]=
+static inline avm_list_t* avm_list_del_head(avm_list_t* head)
 {
-    IID_IUnknown,
-    IID_IMemAllocator,
-};
+    avm_list_t* n = 0;
+    if (head)
+    {
+	if (head->next != head)
+	{
+	    n = head->next;
+	    head->prev->next = head->next;
+	    head->next->prev = head->prev;
+	}
 
-IMPLEMENT_IUNKNOWN(MemAllocator)
+	free(head);
+    }
+
+    return n;
+}
 
-long MemAllocator::CreateAllocator(GUID* clsid, GUID* iid, void** ppv)
+static inline avm_list_t* avm_list_find(avm_list_t* head, void* member)
 {
-    if(!ppv)return -1;
-    *ppv=0;
-    if(memcmp(clsid, &CLSID_MemoryAllocator, sizeof(GUID)))
+    avm_list_t* it = head;
+    if (it)
+    {
+	for (;;)
+	{
+	    if (it->member == member)
+		return it;
+	    it = it->next;
+	    if (it == head)
+                break;
+	}
+    }
+    return NULL;
+}
+
+static long MemAllocator_CreateAllocator(GUID* clsid, GUID* iid, void** ppv)
+{
+    IMemAllocator* p;
+    int result;
+    if (!ppv)
+	return -1;
+    *ppv = 0;
+    if (memcmp(clsid, &CLSID_MemoryAllocator, sizeof(GUID)))
 	return -1;
 
-    IMemAllocator* p=new MemAllocator;
-    int result=p->vt->QueryInterface((IUnknown*)p, iid, ppv);
+    p = (IMemAllocator*) MemAllocatorCreate();
+    result = p->vt->QueryInterface((IUnknown*)p, iid, ppv);
     p->vt->Release((IUnknown*)p);
+
     return result;
 }
 
-
 static HRESULT STDCALL MemAllocator_SetProperties(IMemAllocator * This,
 						  /* [in] */ ALLOCATOR_PROPERTIES *pRequest,
 						  /* [out] */ ALLOCATOR_PROPERTIES *pActual)
 {
-    Debug printf("MemAllocator_SetProperties() called\n");
+    MemAllocator* me = (MemAllocator*)This;
+    Debug printf("MemAllocator_SetProperties(%p) called\n", This);
     if (!pRequest || !pActual)
 	return E_INVALIDARG;
     if (pRequest->cBuffers<=0 || pRequest->cbBuffer<=0)
 	return E_FAIL;
-    MemAllocator* me = (MemAllocator*)This;
-    if (me->used_list.size() || me->free_list.size())
+    if (me->used_list != 0 || me->free_list != 0)
 	return E_FAIL;
     me->props = *pRequest;
     *pActual = *pRequest;
+
     return 0;
 }
 
@@ -71,34 +145,56 @@
     if (((MemAllocator*)This)->props.cbBuffer<0)
 	return E_FAIL;
     *pProps=((MemAllocator*)This)->props;
+
     return 0;
 }
 
 static HRESULT STDCALL MemAllocator_Commit(IMemAllocator * This)
 {
+    MemAllocator* me = (MemAllocator*)This;
+    int i;
     Debug printf("MemAllocator_Commit(%p) called\n", This);
-    MemAllocator* me=(MemAllocator*)This;
     if (((MemAllocator*)This)->props.cbBuffer < 0)
 	return E_FAIL;
-    if (me->used_list.size() || me->free_list.size())
+    if (me->used_list || me->free_list)
 	return E_INVALIDARG;
-    for(int i = 0; i<me->props.cBuffers; i++)
-	me->free_list.push_back(new CMediaSample(me, me->props.cbBuffer));
+    for (i = 0; i < me->props.cBuffers; i++)
+    {
+	CMediaSample* sample = CMediaSampleCreate((IMemAllocator*)me,
+						  me->props.cbBuffer);
+	//printf("FREEEEEEEEEEEE ADDED %p\n", sample);
 
+	me->free_list = avm_list_add_tail(me->free_list, sample);
+	//avm_list_print(me->free_list);
+    }
+
+    //printf("Added mem %p: lsz: %d  %d  size: %d\n", me, avm_list_size(me->free_list), me->props.cBuffers, me->props.cbBuffer);
     return 0;
 }
 
 static HRESULT STDCALL MemAllocator_Decommit(IMemAllocator * This)
 {
+    MemAllocator* me=(MemAllocator*)This;
     Debug printf("MemAllocator_Decommit(%p) called\n", This);
-    MemAllocator* me=(MemAllocator*)This;
-    list<CMediaSample*>::iterator it;
-    for(it=me->free_list.begin(); it!=me->free_list.end(); it++)
-	delete *it;
-    for(it=me->used_list.begin(); it!=me->used_list.end(); it++)
-	delete *it;
-    me->free_list.clear();
-    me->used_list.clear();
+    //printf("Deleted mem %p: %d  %d\n", me, me->free_list.size(), me->used_list.size());
+    while (me->used_list)
+    {
+        CMediaSample* sample = (CMediaSample*) me->used_list->member;
+	//printf("****************** Decommiting USED %p\n", sample);
+	//sample->vt->Release((IUnknown*)sample);
+	CMediaSample_Destroy((CMediaSample*)sample);
+	me->used_list = avm_list_del_head(me->used_list);
+    }
+
+    while (me->free_list)
+    {
+        CMediaSample* sample = (CMediaSample*) me->free_list->member;
+	//printf("****************** Decommiting FREE %p\n", sample);
+	//sample->vt->Release((IUnknown*)sample);
+	CMediaSample_Destroy((CMediaSample*)sample);
+        me->free_list = avm_list_del_head(me->free_list);
+    }
+
     return 0;
 }
 
@@ -108,71 +204,121 @@
 					      /* [in] */ REFERENCE_TIME *pEndTime,
 					      /* [in] */ DWORD dwFlags)
 {
-    Debug printf("MemAllocator_GetBuffer(%p) called\n", This);
     MemAllocator* me = (MemAllocator*)This;
-    if (me->free_list.size() == 0)
+    CMediaSample* sample;
+    Debug printf("MemAllocator_GetBuffer(%p) called  %d  %d\n", This,
+		 avm_list_size(me->used_list), avm_list_size(me->free_list));
+    if (!me->free_list)
     {
 	Debug printf("No samples available\n");
 	return E_FAIL;//should block here if no samples are available
     }
-    list<CMediaSample*>::iterator it = me->free_list.begin();
-    me->used_list.push_back(*it);
-    *ppBuffer = *it;
-    (*ppBuffer)->vt->AddRef((IUnknown*)*ppBuffer);
+
+    sample = (CMediaSample*) me->free_list->member;
+    me->free_list = avm_list_del_head(me->free_list);
+    me->used_list = avm_list_add_tail(me->used_list, sample);
+
+    //printf("MemAllocator getbuffer: %p  %d  %d\n", sample, avm_list_size(me->used_list), avm_list_size(me->free_list));
+
+    *ppBuffer = (IMediaSample*) sample;
+    sample->vt->AddRef((IUnknown*) sample);
     if (me->new_pointer)
     {
-	if(me->modified_sample)
-	    me->modified_sample->ResetPointer();
-	(*it)->SetPointer(me->new_pointer);
-	me->modified_sample=*it;
+	if (me->modified_sample)
+	    me->modified_sample->ResetPointer(me->modified_sample);
+	sample->SetPointer(sample, me->new_pointer);
+	me->modified_sample = sample;
 	me->new_pointer = 0;
     }
-    me->free_list.remove(*it);
     return 0;
 }
 
-static HRESULT STDCALL MemAllocator_ReleaseBuffer(IMemAllocator * This,
-						  /* [in] */ IMediaSample *pBuffer)
+static HRESULT STDCALL MemAllocator_ReleaseBuffer(IMemAllocator* This,
+						  /* [in] */ IMediaSample* pBuffer)
 {
-    Debug printf("MemAllocator_ReleaseBuffer(%p) called\n", This);
     MemAllocator* me = (MemAllocator*)This;
-    list<CMediaSample*>::iterator it;
-    for (it = me->used_list.begin(); it != me->used_list.end(); it++)
-	if (*it == pBuffer)
+    Debug printf("MemAllocator_ReleaseBuffer(%p) called   %d  %d\n", This,
+		 avm_list_size(me->used_list), avm_list_size(me->free_list));
+
+    for (;;)
+    {
+	avm_list_t* l = avm_list_find(me->used_list, pBuffer);
+	if (l)
 	{
-	    me->used_list.erase(it);
-	    me->free_list.push_back((CMediaSample*)pBuffer);
-	    return 0;
+	    CMediaSample* sample = (CMediaSample*) l->member;
+	    me->used_list = avm_list_del_head(me->used_list);
+	    me->free_list = avm_list_add_head(me->free_list, sample);
+	    //printf("****************** RELEASED OK %p  %p\n", me->used_list, me->free_list);
+
+            return 0;
 	}
-    Debug printf("Releasing unknown buffer\n");
+	else
+            break;
+    }
+    Debug printf("MemAllocator_ReleaseBuffer(%p) releasing unknown buffer!!!! %p\n", This, pBuffer);
     return E_FAIL;
 }
 
-MemAllocator::MemAllocator()
+
+static void MemAllocator_SetPointer(MemAllocator* This, char* pointer)
+{
+    This->new_pointer = pointer;
+}
+
+static void MemAllocator_ResetPointer(MemAllocator* This)
 {
-    Debug printf("MemAllocator::MemAllocator() called\n");
-    vt = new IMemAllocator_vt;
-    vt->QueryInterface = QueryInterface;
-    vt->AddRef = AddRef;
-    vt->Release = Release;
-    vt->SetProperties = MemAllocator_SetProperties;
-    vt->GetProperties = MemAllocator_GetProperties;
-    vt->Commit = MemAllocator_Commit;
-    vt->Decommit = MemAllocator_Decommit;
-    vt->GetBuffer = MemAllocator_GetBuffer;
-    vt->ReleaseBuffer = MemAllocator_ReleaseBuffer;
+    if (This->modified_sample)
+    {
+	This->modified_sample->ResetPointer(This->modified_sample);
+	This->modified_sample = 0;
+    }
+}
 
-    refcount = 1;
-    props.cBuffers = 1;
-    props.cbBuffer = 65536; /* :/ */
-    props.cbAlign = props.cbPrefix = 0;
-
-    new_pointer=0;
-    modified_sample=0;
+void MemAllocator_Destroy(MemAllocator* This)
+{
+    Debug printf("MemAllocator_Destroy(%p) called  (%d, %d)\n", This, This->refcount, AllocatorKeeper);
+    if (--AllocatorKeeper == 0)
+	UnregisterComClass(&CLSID_MemoryAllocator, MemAllocator_CreateAllocator);
+    free(This->vt);
+    free(This);
 }
 
-MemAllocator::~MemAllocator()
+IMPLEMENT_IUNKNOWN(MemAllocator)
+
+MemAllocator* MemAllocatorCreate()
 {
-    Debug printf("MemAllocator::~MemAllocator() called\n");
-    delete vt;
+    MemAllocator* This = (MemAllocator*) malloc(sizeof(MemAllocator));
+    Debug printf("MemAllocatorCreate() called -> %p\n", This);
+
+    This->refcount = 1;
+    This->props.cBuffers = 1;
+    This->props.cbBuffer = 65536; /* :/ */
+    This->props.cbAlign = This->props.cbPrefix = 0;
+
+    This->vt = (IMemAllocator_vt*) malloc(sizeof(IMemAllocator_vt));
+    This->vt->QueryInterface = MemAllocator_QueryInterface;
+    This->vt->AddRef = MemAllocator_AddRef;
+    This->vt->Release = MemAllocator_Release;
+    This->vt->SetProperties = MemAllocator_SetProperties;
+    This->vt->GetProperties = MemAllocator_GetProperties;
+    This->vt->Commit = MemAllocator_Commit;
+    This->vt->Decommit = MemAllocator_Decommit;
+    This->vt->GetBuffer = MemAllocator_GetBuffer;
+    This->vt->ReleaseBuffer = MemAllocator_ReleaseBuffer;
+
+    This->SetPointer = MemAllocator_SetPointer;
+    This->ResetPointer = MemAllocator_ResetPointer;
+
+    This->new_pointer = 0;
+    This->modified_sample = 0;
+    This->used_list = 0;
+    This->free_list = 0;
+
+    This->interfaces[0]=IID_IUnknown;
+    This->interfaces[1]=IID_IMemAllocator;
+
+    if (AllocatorKeeper++ == 0)
+	RegisterComClass(&CLSID_MemoryAllocator, MemAllocator_CreateAllocator);
+
+    return This;
 }
--- a/loader/dshow/allocator.h	Wed Nov 21 18:40:59 2001 +0000
+++ b/loader/dshow/allocator.h	Wed Nov 21 19:12:39 2001 +0000
@@ -3,33 +3,30 @@
 
 #include "interfaces.h"
 #include "cmediasample.h"
-#include "iunk.h"
 
-#include <list>
+typedef struct avm_list_t
+{
+    struct avm_list_t* next;
+    struct avm_list_t* prev;
+    void* member;
+} avm_list_t;
 
-struct MemAllocator: public IMemAllocator
+typedef struct _MemAllocator MemAllocator;
+struct _MemAllocator
 {
+    IMemAllocator_vt* vt;
     ALLOCATOR_PROPERTIES props;
-    std::list<CMediaSample*> used_list;
-    std::list<CMediaSample*> free_list;
+    avm_list_t* used_list;
+    avm_list_t* free_list;
     char* new_pointer;
     CMediaSample* modified_sample;
-    static GUID interfaces[];
-    DECLARE_IUNKNOWN(MemAllocator)
+    GUID interfaces[2];
+    DECLARE_IUNKNOWN();
 
-    MemAllocator();
-    ~MemAllocator();
-    void SetPointer(char* pointer) { new_pointer=pointer; }
-    void ResetPointer() 
-    { 
-	if (modified_sample)
-	{
-	    modified_sample->ResetPointer(); 
-	    modified_sample=0;
-	}
-    }
-
-    static long CreateAllocator(GUID* clsid, GUID* iid, void** ppv);
+    void ( *SetPointer )(MemAllocator* This, char* pointer);
+    void ( *ResetPointer )(MemAllocator* This);
 };
 
+MemAllocator* MemAllocatorCreate();
+
 #endif /* DS_ALLOCATOR_H */
--- a/loader/dshow/cmediasample.c	Wed Nov 21 18:40:59 2001 +0000
+++ b/loader/dshow/cmediasample.c	Wed Nov 21 19:12:39 2001 +0000
@@ -3,23 +3,23 @@
 #include <stdio.h>
 #include <string.h>
 
-static long STDCALL CMediaSample_QueryInterface(IUnknown * This,
+static long STDCALL CMediaSample_QueryInterface(IUnknown* This,
 						/* [in] */ IID* iid,
 						/* [iid_is][out] */ void **ppv)
 {
-    Debug printf("CMediaSample_QueryInterface() called\n");
+    Debug printf("CMediaSample_QueryInterface(%p) called\n", This);
     if (!ppv)
 	return E_INVALIDARG;
-    if (!memcmp(iid, &IID_IUnknown, 16))
+    if (memcmp(iid, &IID_IUnknown, sizeof(*iid)) == 0)
     {
-	*ppv=(void*)This;
-	This->vt->AddRef(This);
+	*ppv = (void*)This;
+	((IMediaSample*) This)->vt->AddRef(This);
 	return 0;
     }
-    if (!memcmp(iid, &IID_IMediaSample, 16))
+    if (memcmp(iid, &IID_IMediaSample, sizeof(*iid)) == 0)
     {
-	*ppv=(void*)This;
-	This->vt->AddRef(This);
+	*ppv = (void*)This;
+	((IMediaSample*) This)->vt->AddRef(This);
 	return 0;
     }
     return E_NOINTERFACE;
@@ -27,26 +27,39 @@
 
 static long STDCALL CMediaSample_AddRef(IUnknown* This)
 {
-    Debug printf("CMediaSample_AddRef() called\n");
+    Debug printf("CMediaSample_AddRef(%p) called\n", This);
     ((CMediaSample*)This)->refcount++;
     return 0;
 }
 
+void CMediaSample_Destroy(CMediaSample* This)
+{
+
+    Debug printf("CMediaSample_Destroy(%p) called (ref:%d)\n", This, This->refcount);
+    free(This->vt);
+    free(This->own_block);
+    if (This->media_type.pbFormat)
+	CoTaskMemFree(This->media_type.pbFormat);
+    free(This);
+}
+
 static long STDCALL CMediaSample_Release(IUnknown* This)
 {
-    Debug printf("%p: CMediaSample_Release() called, new refcount %d\n",
+    CMediaSample* parent=(CMediaSample*)This;
+    Debug printf("CMediaSample_Release(%p) called  (new ref:%d)\n",
 		 This, ((CMediaSample*)This)->refcount-1);
-    CMediaSample* parent=(CMediaSample*)This;
-    if (--((CMediaSample*)This)->refcount==0)
+    if (--((CMediaSample*)This)->refcount == 0)
+    {
 	parent->all->vt->ReleaseBuffer((IMemAllocator*)(parent->all),
 				       (IMediaSample*)This);
+    }
     return 0;
 }
 
 static HRESULT STDCALL CMediaSample_GetPointer(IMediaSample * This,
 					       /* [out] */ BYTE **ppBuffer)
 {
-    Debug printf("%p: CMediaSample_GetPointer() called\n", This);
+    Debug printf("CMediaSample_GetPointer(%p) called\n", This);
     if (!ppBuffer)
 	return E_INVALIDARG;
     *ppBuffer=(BYTE *)((CMediaSample*)This)->block;
@@ -55,7 +68,7 @@
 
 static long STDCALL CMediaSample_GetSize(IMediaSample * This)
 {
-    Debug printf("%p: CMediaSample_GetSize() called -> %d\n",
+    Debug printf("CMediaSample_GetSize(%p) called -> %d\n",
 		 This, ((CMediaSample*)This)->size);
     return ((CMediaSample*)This)->size;
 }
@@ -64,7 +77,7 @@
 					    /* [out] */ REFERENCE_TIME *pTimeStart,
 					    /* [out] */ REFERENCE_TIME *pTimeEnd)
 {
-    Debug printf("%p: CMediaSample_GetTime() called\n", This);
+    Debug printf("CMediaSample_GetTime(%p) called\n", This);
     return E_NOTIMPL;
 }
 
@@ -72,13 +85,13 @@
 					    /* [in] */ REFERENCE_TIME *pTimeStart,
 					    /* [in] */ REFERENCE_TIME *pTimeEnd)
 {
-    Debug printf("%p: CMediaSample_SetTime() called\n", This);
+    Debug printf("CMediaSample_SetTime(%p) called\n", This);
     return E_NOTIMPL;
 }
 
 static HRESULT STDCALL CMediaSample_IsSyncPoint(IMediaSample * This)
 {
-    Debug printf("%p: CMediaSample_IsSyncPoint() called\n", This);
+    Debug printf("CMediaSample_IsSyncPoint(%p) called\n", This);
     if (((CMediaSample*)This)->isSyncPoint)
 	return 0;
     return 1;
@@ -87,14 +100,14 @@
 static HRESULT STDCALL CMediaSample_SetSyncPoint(IMediaSample * This,
 						 long bIsSyncPoint)
 {
-    Debug printf("%p: CMediaSample_SetSyncPoint() called\n", This);
+    Debug printf("CMediaSample_SetSyncPoint(%p) called\n", This);
     ((CMediaSample*)This)->isSyncPoint=bIsSyncPoint;
     return 0;
 }
 
 static HRESULT STDCALL CMediaSample_IsPreroll(IMediaSample * This)
 {
-    Debug printf("%p: CMediaSample_IsPreroll() called\n", This);
+    Debug printf("CMediaSample_IsPreroll(%p) called\n", This);
 
     if (((CMediaSample*)This)->isPreroll)
 	return 0;//S_OK
@@ -105,33 +118,34 @@
 static HRESULT STDCALL CMediaSample_SetPreroll(IMediaSample * This,
 					       long bIsPreroll)
 {
-    Debug printf("%p: CMediaSample_SetPreroll() called\n", This);
+    Debug printf("CMediaSample_SetPreroll(%p) called\n", This);
     ((CMediaSample*)This)->isPreroll=bIsPreroll;
     return 0;
 }
 
-static long STDCALL CMediaSample_GetActualDataLength(IMediaSample * This)
+static long STDCALL CMediaSample_GetActualDataLength(IMediaSample* This)
 {
-    Debug printf("%p: CMediaSample_GetActualDataLength() called -> %d\n", This, ((CMediaSample*)This)->actual_size);
+    Debug printf("CMediaSample_GetActualDataLength(%p) called -> %d\n", This, ((CMediaSample*)This)->actual_size);
     return ((CMediaSample*)This)->actual_size;
 }
 
-static HRESULT STDCALL CMediaSample_SetActualDataLength(IMediaSample * This,
+static HRESULT STDCALL CMediaSample_SetActualDataLength(IMediaSample* This,
 							long __MIDL_0010)
 {
-    Debug printf("%p: CMediaSample_SetActualDataLength(%ld) called\n", This, __MIDL_0010);
+    Debug printf("CMediaSample_SetActualDataLength(%p, %ld) called\n", This, __MIDL_0010);
     if (__MIDL_0010 > ((CMediaSample*)This)->size)
     {
 	printf("%p: ERROR: CMediaSample buffer overflow\n", This);
     }
-    ((CMediaSample*)This)->actual_size=__MIDL_0010;
+    ((CMediaSample*)This)->actual_size = __MIDL_0010;
     return 0;
 }
 
-static HRESULT STDCALL CMediaSample_GetMediaType(IMediaSample * This,
-						 AM_MEDIA_TYPE **ppMediaType)
+static HRESULT STDCALL CMediaSample_GetMediaType(IMediaSample* This,
+						 AM_MEDIA_TYPE** ppMediaType)
 {
-    Debug printf("%p: CMediaSample_GetMediaType() called\n", This);
+    AM_MEDIA_TYPE* t;
+    Debug printf("CMediaSample_GetMediaType(%p) called\n", This);
     if(!ppMediaType)
 	return E_INVALIDARG;
     if(!((CMediaSample*)This)->type_valid)
@@ -139,28 +153,30 @@
 	*ppMediaType=0;
 	return 1;
     }
-    AM_MEDIA_TYPE& t=((CMediaSample*)This)->media_type;
-//    if(t.pbFormat)CoTaskMemFree(t.pbFormat);
-    (*ppMediaType)=(AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
-    memcpy(*ppMediaType, &t, sizeof(AM_MEDIA_TYPE));
-    (*ppMediaType)->pbFormat=(char*)CoTaskMemAlloc(t.cbFormat);
-    memcpy((*ppMediaType)->pbFormat, t.pbFormat, t.cbFormat);
-//    *ppMediaType=0; //media type was not changed
+
+    t = &((CMediaSample*)This)->media_type;
+    //    if(t.pbFormat)CoTaskMemFree(t.pbFormat);
+    (*ppMediaType) = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
+    **ppMediaType = *t;
+    (*ppMediaType)->pbFormat = (char*)CoTaskMemAlloc(t->cbFormat);
+    memcpy((*ppMediaType)->pbFormat, t->pbFormat, t->cbFormat);
+    //    *ppMediaType=0; //media type was not changed
     return 0;
 }
 
 static HRESULT STDCALL CMediaSample_SetMediaType(IMediaSample * This,
 						 AM_MEDIA_TYPE *pMediaType)
 {
-    Debug printf("%p: CMediaSample_SetMediaType() called\n", This);
+    AM_MEDIA_TYPE* t;
+    Debug printf("CMediaSample_SetMediaType(%p) called\n", This);
     if (!pMediaType)
 	return E_INVALIDARG;
-    AM_MEDIA_TYPE& t = ((CMediaSample*)This)->media_type;
-    if (t.pbFormat)
-	CoTaskMemFree(t.pbFormat);
-    t = *pMediaType;
-    t.pbFormat = (char*)CoTaskMemAlloc(t.cbFormat);
-    memcpy(t.pbFormat, pMediaType->pbFormat, t.cbFormat);
+    t = &((CMediaSample*)This)->media_type;
+    if (t->pbFormat)
+	CoTaskMemFree(t->pbFormat);
+    t = pMediaType;
+    t->pbFormat = (char*)CoTaskMemAlloc(t->cbFormat);
+    memcpy(t->pbFormat, pMediaType->pbFormat, t->cbFormat);
     ((CMediaSample*)This)->type_valid=1;
 
     return 0;
@@ -168,14 +184,14 @@
 
 static HRESULT STDCALL CMediaSample_IsDiscontinuity(IMediaSample * This)
 {
-    Debug printf("%p: CMediaSample_IsDiscontinuity() called\n", This);
+    Debug printf("CMediaSample_IsDiscontinuity(%p) called\n", This);
     return 1;
 }
 
 static HRESULT STDCALL CMediaSample_SetDiscontinuity(IMediaSample * This,
 						     long bDiscontinuity)
 {
-    Debug printf("%p: CMediaSample_SetDiscontinuity() called\n", This);
+    Debug printf("CMediaSample_SetDiscontinuity(%p) called\n", This);
     return E_NOTIMPL;
 }
 
@@ -183,7 +199,7 @@
 						 /* [out] */ LONGLONG *pTimeStart,
 						 /* [out] */ LONGLONG *pTimeEnd)
 {
-    Debug printf("%p: CMediaSample_GetMediaTime() called\n", This);
+    Debug printf("CMediaSample_GetMediaTime(%p) called\n", This);
     return E_NOTIMPL;
 }
 
@@ -191,54 +207,65 @@
 						 /* [in] */ LONGLONG *pTimeStart,
 						 /* [in] */ LONGLONG *pTimeEnd)
 {
-    Debug printf("%p: CMediaSample_SetMediaTime() called\n", This);
+    Debug printf("CMediaSample_SetMediaTime(%p) called\n", This);
     return E_NOTIMPL;
 }
 
-CMediaSample::CMediaSample(IMemAllocator* allocator, long _size)
+static void CMediaSample_SetPointer(CMediaSample* This, char* pointer)
 {
-    vt = new IMediaSample_vt;
+    Debug printf("CMediaSample_SetPointer(%p) called  -> %p\n", This, pointer);
+    if (pointer)
+	This->block = pointer;
+    else
+	This->block = This->own_block;
+}
 
-    vt->QueryInterface = CMediaSample_QueryInterface;
-    vt->AddRef = CMediaSample_AddRef;
-    vt->Release = CMediaSample_Release;
-    vt->GetPointer = CMediaSample_GetPointer;
-    vt->GetSize = CMediaSample_GetSize;
-    vt->GetTime = CMediaSample_GetTime;
-    vt->SetTime = CMediaSample_SetTime;
-    vt->IsSyncPoint = CMediaSample_IsSyncPoint;
-    vt->SetSyncPoint = CMediaSample_SetSyncPoint;
-    vt->IsPreroll = CMediaSample_IsPreroll;
-    vt->SetPreroll = CMediaSample_SetPreroll;
-    vt->GetActualDataLength = CMediaSample_GetActualDataLength;
-    vt->SetActualDataLength = CMediaSample_SetActualDataLength;
-    vt->GetMediaType = CMediaSample_GetMediaType;
-    vt->SetMediaType = CMediaSample_SetMediaType;
-    vt->IsDiscontinuity = CMediaSample_IsDiscontinuity;
-    vt->SetDiscontinuity = CMediaSample_SetDiscontinuity;
-    vt->GetMediaTime = CMediaSample_GetMediaTime;
-    vt->SetMediaTime = CMediaSample_SetMediaTime;
-
-    all = allocator;
-    size = _size;
-    refcount = 0;
-    actual_size = 0;
-    media_type.pbFormat = 0;
-    isPreroll = 0;
-    type_valid = 0;
-    own_block = new char[size];
-    block = own_block;
-    Debug printf("%p: Creating media sample with size %ld, buffer %p\n",
-		 this, _size, block);
+static void CMediaSample_ResetPointer(CMediaSample* This)
+{
+    Debug printf("CMediaSample_ResetPointer(%p) called\n", This);
+    This->block = This->own_block;
 }
 
-CMediaSample::~CMediaSample()
+CMediaSample* CMediaSampleCreate(IMemAllocator* allocator, int _size)
 {
-    Debug printf("%p: CMediaSample::~CMediaSample() called\n", this);
-    if (!vt)
-        printf("Second delete of CMediaSample()!!|\n");
-    delete vt;
-    delete own_block;
-    if (media_type.pbFormat)
-	CoTaskMemFree(media_type.pbFormat);
+    CMediaSample* This = (CMediaSample*) malloc(sizeof( CMediaSample ));
+    This->vt = (IMediaSample_vt*) malloc(sizeof(IMediaSample_vt));
+
+    This->vt->QueryInterface = CMediaSample_QueryInterface;
+    This->vt->AddRef = CMediaSample_AddRef;
+    This->vt->Release = CMediaSample_Release;
+    This->vt->GetPointer = CMediaSample_GetPointer;
+    This->vt->GetSize = CMediaSample_GetSize;
+    This->vt->GetTime = CMediaSample_GetTime;
+    This->vt->SetTime = CMediaSample_SetTime;
+    This->vt->IsSyncPoint = CMediaSample_IsSyncPoint;
+    This->vt->SetSyncPoint = CMediaSample_SetSyncPoint;
+    This->vt->IsPreroll = CMediaSample_IsPreroll;
+    This->vt->SetPreroll = CMediaSample_SetPreroll;
+    This->vt->GetActualDataLength = CMediaSample_GetActualDataLength;
+    This->vt->SetActualDataLength = CMediaSample_SetActualDataLength;
+    This->vt->GetMediaType = CMediaSample_GetMediaType;
+    This->vt->SetMediaType = CMediaSample_SetMediaType;
+    This->vt->IsDiscontinuity = CMediaSample_IsDiscontinuity;
+    This->vt->SetDiscontinuity = CMediaSample_SetDiscontinuity;
+    This->vt->GetMediaTime = CMediaSample_GetMediaTime;
+    This->vt->SetMediaTime = CMediaSample_SetMediaTime;
+
+    This->all = allocator;
+    This->size = _size;
+    This->refcount = 0; // increased by MemAllocator
+    This->actual_size = 0;
+    This->media_type.pbFormat = 0;
+    This->isPreroll = 0;
+    This->type_valid = 0;
+    This->own_block = (char*) malloc(This->size);
+    This->block = This->own_block;
+
+    This->SetPointer = CMediaSample_SetPointer;
+    This->ResetPointer = CMediaSample_ResetPointer;
+
+    Debug printf("CMediaSample_Create(%p) called - sample size %d, buffer %p\n",
+		 This, This->size, This->block);
+
+    return This;
 }
--- a/loader/dshow/cmediasample.h	Wed Nov 21 18:40:59 2001 +0000
+++ b/loader/dshow/cmediasample.h	Wed Nov 21 19:12:39 2001 +0000
@@ -4,8 +4,10 @@
 #include "interfaces.h"
 #include "guids.h"
 
-struct CMediaSample: public IMediaSample
+typedef struct _CMediaSample CMediaSample;
+struct _CMediaSample
 {
+    IMediaSample_vt* vt;
     IMemAllocator* all;
     int size;
     int actual_size;
@@ -16,10 +18,12 @@
     int isSyncPoint;
     AM_MEDIA_TYPE media_type;
     int type_valid;
-    CMediaSample(IMemAllocator* allocator, long _size);
-    ~CMediaSample();
-    void SetPointer(char* pointer) { block = pointer; }
-    void ResetPointer() { block = own_block; }
+    void ( *SetPointer) (CMediaSample* This,char* pointer);
+    void ( *ResetPointer) (CMediaSample* This); // FIXME replace with Set & 0
 };
 
+CMediaSample* CMediaSampleCreate(IMemAllocator* allocator, int _size);
+// called from allocator
+void CMediaSample_Destroy(CMediaSample* This);
+
 #endif /* DS_CMEDIASAMPLE_H */
--- a/loader/dshow/guids.c	Wed Nov 21 18:40:59 2001 +0000
+++ b/loader/dshow/guids.c	Wed Nov 21 19:12:39 2001 +0000
@@ -3,6 +3,9 @@
 
 GUID CLSID_DivxDecompressorCF={0x82CCd3E0, 0xF71A, 0x11D0,
     { 0x9f, 0xe5, 0x00, 0x60, 0x97, 0x78, 0xaa, 0xaa}};
+GUID IID_IDivxFilterInterface={0xd132ee97, 0x3e38, 0x4030,
+    {0x8b, 0x17, 0x59, 0x16, 0x3b, 0x30, 0xa1, 0xf5}};
+
 GUID CLSID_IV50_Decoder={0x30355649, 0x0000, 0x0010,
     {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
 GUID IID_IBaseFilter={0x56a86895, 0x0ad4, 0x11ce,
@@ -18,15 +21,15 @@
 GUID IID_IMediaSample={0x56a8689a, 0x0ad4, 0x11ce,
     {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
 
-GUID MEDIATYPE_Video={0x73646976, 0x0000, 0x0010, 
+GUID MEDIATYPE_Video={0x73646976, 0x0000, 0x0010,
     {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
-GUID GUID_NULL={0x0, 0x0, 0x0, 
+GUID GUID_NULL={0x0, 0x0, 0x0,
     {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}};
 GUID FORMAT_VideoInfo={0x05589f80, 0xc356, 0x11ce,
     {0xbf, 0x01, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a}};
 GUID MEDIASUBTYPE_RGB565={0xe436eb7b, 0x524f, 0x11ce,
     {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
-GUID MEDIASUBTYPE_RGB555={0xe436eb7c, 0x524f, 0x11ce, 
+GUID MEDIASUBTYPE_RGB555={0xe436eb7c, 0x524f, 0x11ce,
     {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
 GUID MEDIASUBTYPE_RGB24={0xe436eb7d, 0x524f, 0x11ce,
     {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
@@ -58,3 +61,4 @@
     {0xa1, 0xc1, 0x00, 0x60, 0x97, 0x78, 0xaa, 0xaa}};
 GUID IID_Iv50Hidden={0x665a4442, 0xd905, 0x11d0,
     {0xa3, 0x0e, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}};
+
--- a/loader/dshow/guids.h	Wed Nov 21 18:40:59 2001 +0000
+++ b/loader/dshow/guids.h	Wed Nov 21 19:12:39 2001 +0000
@@ -3,25 +3,22 @@
 
 #include "com.h"
 #include "wine/winbase.h"
-#include "wine/windef.h"
-#include "wine/winuser.h"
 #include "wine/vfw.h"
 
 extern int DSHOW_DEBUG;
 #define Debug if(DSHOW_DEBUG)
 
-struct IUnknown;
 typedef struct  _MediaType
 {
-    GUID      majortype;		//0x0
-    GUID      subtype;			//0x10
-    int      bFixedSizeSamples;		//0x20
-    int      bTemporalCompression;	//0x24
-    unsigned long     lSampleSize;	//0x28
-    GUID      formattype;		//0x2c
-    IUnknown  *pUnk;			//0x3c
-    unsigned long     cbFormat;		//0x40
-    char *pbFormat;			//0x44
+    GUID	majortype;		//0x0
+    GUID	subtype;		//0x10
+    int		bFixedSizeSamples;	//0x20
+    int		bTemporalCompression;	//0x24
+    unsigned long lSampleSize;		//0x28
+    GUID	formattype;		//0x2c
+    IUnknown*	pUnk;			//0x3c
+    unsigned long cbFormat;		//0x40
+    char	*pbFormat;		//0x44
 } AM_MEDIA_TYPE;
 
 typedef enum
@@ -32,10 +29,10 @@
 
 typedef long long REFERENCE_TIME;
 
-struct RECT32
+typedef struct RECT32
 {
     int left, top, right, bottom;
-};
+} RECT32;
 
 typedef struct tagVIDEOINFOHEADER {
 
@@ -55,15 +52,15 @@
     long cbPrefix;
 } ALLOCATOR_PROPERTIES;
 
-struct IBaseFilter;
-
+typedef struct _IBaseFilter IBaseFilter;
 typedef struct _PinInfo
 {
-    IBaseFilter *pFilter;
+    IBaseFilter* pFilter;
     PIN_DIRECTION dir;
     unsigned short achName[128];
 } PIN_INFO;
 
+
 extern GUID IID_IBaseFilter;
 extern GUID IID_IEnumPins;
 extern GUID IID_IEnumMediaTypes;
@@ -73,6 +70,7 @@
 extern GUID IID_DivxHidden;
 extern GUID IID_Iv50Hidden;
 extern GUID CLSID_DivxDecompressorCF;
+extern GUID IID_IDivxFilterInterface;
 extern GUID CLSID_IV50_Decoder;
 extern GUID CLSID_MemoryAllocator;
 extern GUID MEDIATYPE_Video;
--- a/loader/dshow/inputpin.c	Wed Nov 21 18:40:59 2001 +0000
+++ b/loader/dshow/inputpin.c	Wed Nov 21 19:12:39 2001 +0000
@@ -4,98 +4,46 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-GUID CInputPin::interfaces[]=
-{
-    IID_IUnknown,
-};
-IMPLEMENT_IUNKNOWN(CInputPin)
-
-GUID CRemotePin::interfaces[]=
+static int unimplemented(const char* s, void* p)
 {
-    IID_IUnknown,
-};
-IMPLEMENT_IUNKNOWN(CRemotePin)
-
-GUID CRemotePin2::interfaces[]=
-{
-    IID_IUnknown,
-};
-IMPLEMENT_IUNKNOWN(CRemotePin2)
+    Debug printf("%s(%p) called (UNIMPLEMENTED)", s, p);
+    return E_NOTIMPL;
+}
 
-GUID CBaseFilter::interfaces[]=
-{
-    IID_IUnknown,
-    IID_IBaseFilter,
-};
-IMPLEMENT_IUNKNOWN(CBaseFilter)
+/***********
+ * EnumPins
+ ***********/
 
-GUID CBaseFilter2::interfaces[]=
+typedef struct
 {
-    IID_IUnknown,
-    IID_IBaseFilter,
-    {0x76c61a30, 0xebe1, 0x11cf, {0x89, 0xf9, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xcb}},
-    {0xaae7e4e2, 0x6388, 0x11d1, {0x8d, 0x93, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2}},
-    {0x02ef04dd, 0x7580, 0x11d1, {0xbe, 0xce, 0x00, 0xc0, 0x4f, 0xb6, 0xe9, 0x37}},
-};
-IMPLEMENT_IUNKNOWN(CBaseFilter2)
-
-class CEnumPins: public IEnumPins
-{
+    IEnumPins_vt* vt;
     IPin* pin1;
     IPin* pin2;
     int counter;
-    static GUID interfaces[];
-    DECLARE_IUNKNOWN(CEnumPins)
-public:
-    CEnumPins(IPin*, IPin* =0);
-    ~CEnumPins(){delete vt;}
-    static long STDCALL Next (IEnumPins * This,
-			      /* [in] */ unsigned long cMediaTypes,
-			      /* [size_is][out] */ IPin **ppMediaTypes,
-			      /* [out] */ unsigned long *pcFetched);
-    static long STDCALL Skip (IEnumPins * This,
-			      /* [in] */ unsigned long cMediaTypes);
-    static long STDCALL Reset (IEnumPins * This);
-    static long STDCALL Clone (IEnumPins * This,
-			       /* [out] */ IEnumPins **ppEnum);
-};
+    GUID interfaces[2];
+    DECLARE_IUNKNOWN();
+} CEnumPins;
 
-GUID CEnumPins::interfaces[]=
+static long STDCALL CEnumPins_Next(IEnumPins* This,
+				   /* [in] */ unsigned long cMediaTypes,
+				   /* [size_is][out] */ IPin **ppMediaTypes,
+				   /* [out] */ unsigned long *pcFetched)
 {
-    IID_IUnknown,
-    IID_IEnumPins,
-};
-IMPLEMENT_IUNKNOWN(CEnumPins)
+    CEnumPins* pin = (CEnumPins*)This;
 
-CEnumPins::CEnumPins(IPin* p, IPin* pp): pin1(p), pin2(pp), counter(0), refcount(1)
-{
-    vt=new IEnumPins_vt;
-    vt->QueryInterface = QueryInterface;
-    vt->AddRef = AddRef;
-    vt->Release = Release;
-    vt->Next = Next;
-    vt->Skip = Skip;
-    vt->Reset = Reset;
-    vt->Clone = Clone;
-}
-
-long STDCALL CEnumPins::Next(IEnumPins * This,
-			     /* [in] */ unsigned long cMediaTypes,
-			     /* [size_is][out] */ IPin **ppMediaTypes,
-			     /* [out] */ unsigned long *pcFetched)
-{
-    Debug printf("CEnumPins::Next() called\n");
+    Debug printf("CEnumPins_Next(%p) called\n", This);
     if (!ppMediaTypes)
 	return E_INVALIDARG;
     if (!pcFetched && (cMediaTypes!=1))
 	return E_INVALIDARG;
     if (cMediaTypes<=0)
 	return 0;
-    int& lcounter=((CEnumPins*)This)->counter;
 
-    IPin* lpin1=((CEnumPins*)This)->pin1;
-    IPin* lpin2=((CEnumPins*)This)->pin2;
-    if (((lcounter == 2) && lpin2) || ((lcounter == 1) && !lpin2))
+    //lcounter = ((CEnumPins*)This)->counter;
+    //lpin1 = ((CEnumPins*)This)->pin1;
+    //lpin2 = ((CEnumPins*)This)->pin2;
+    if (((pin->counter == 2) && pin->pin2)
+	|| ((pin->counter == 1) && !pin->pin2))
     {
 	if (pcFetched)
 	    *pcFetched=0;
@@ -104,105 +52,118 @@
 
     if (pcFetched)
 	*pcFetched=1;
-    if (lcounter==0)
+    if (pin->counter==0)
     {
-	*ppMediaTypes = lpin1;
-	lpin1->vt->AddRef((IUnknown*)lpin1);
+	*ppMediaTypes = pin->pin1;
+	pin->pin1->vt->AddRef((IUnknown*)pin->pin1);
     }
     else
     {
-	*ppMediaTypes = lpin2;
-	lpin2->vt->AddRef((IUnknown*)lpin2);
+	*ppMediaTypes = pin->pin2;
+	pin->pin2->vt->AddRef((IUnknown*)pin->pin2);
     }
-    lcounter++;
+    pin->counter++;
     if (cMediaTypes == 1)
 	return 0;
     return 1;
 }
 
-long STDCALL CEnumPins::Skip(IEnumPins * This,
-			     /* [in] */ unsigned long cMediaTypes)
+static long STDCALL CEnumPins_Skip(IEnumPins* This,
+				   /* [in] */ unsigned long cMediaTypes)
 {
-    Debug printf("CEnumPins::Skip() called\n");
+    Debug unimplemented("CEnumPins_Skip", This);
     return E_NOTIMPL;
 }
 
-long STDCALL CEnumPins::Reset(IEnumPins * This)
+static long STDCALL CEnumPins_Reset(IEnumPins* This)
 {
-    Debug printf("CEnumPins::Reset() called\n");
-    ((CEnumPins*)This)->counter=0;
+    Debug printf("CEnumPins_Reset(%p) called\n", This);
+    ((CEnumPins*)This)->counter = 0;
     return 0;
 }
 
-long STDCALL CEnumPins::Clone(IEnumPins * This,
-			      /* [out] */ IEnumPins **ppEnum)
+static long STDCALL CEnumPins_Clone(IEnumPins* This,
+				    /* [out] */ IEnumPins** ppEnum)
 {
-    Debug printf("CEnumPins::Clone() called\n");
+    Debug unimplemented("CEnumPins_Clone", This);
     return E_NOTIMPL;
 }
 
-CInputPin::CInputPin(CBaseFilter* p, const AM_MEDIA_TYPE& vh)
-     : type(vh)
+static void CEnumPins_Destroy(CEnumPins* This)
 {
-    refcount = 1;
-    parent = p;
-    vt=new IPin_vt;
-    vt->QueryInterface = QueryInterface;
-    vt->AddRef = AddRef;
-    vt->Release = Release;
-    vt->Connect = Connect;
-    vt->ReceiveConnection = ReceiveConnection;
-    vt->Disconnect=Disconnect;
-    vt->ConnectedTo = ConnectedTo;
-    vt->ConnectionMediaType = ConnectionMediaType;
-    vt->QueryPinInfo = QueryPinInfo;
-    vt->QueryDirection = QueryDirection;
-    vt->QueryId = QueryId;
-    vt->QueryAccept = QueryAccept;
-    vt->EnumMediaTypes = EnumMediaTypes;
-    vt->QueryInternalConnections = QueryInternalConnections;
-    vt->EndOfStream = EndOfStream;
-    vt->BeginFlush = BeginFlush;
-    vt->EndFlush = EndFlush;
-    vt->NewSegment = NewSegment;
+    free(This->vt);
+    free(This);
 }
 
-long STDCALL CInputPin::Connect (
-    IPin * This,
-    /* [in] */ IPin *pReceivePin,
-    /* [in] */ AM_MEDIA_TYPE *pmt)
+IMPLEMENT_IUNKNOWN(CEnumPins)
+
+static CEnumPins* CEnumPinsCreate(IPin* p, IPin* pp)
 {
-    Debug printf("CInputPin::Connect() called\n");
+    CEnumPins* This = (CEnumPins*) malloc(sizeof(CEnumPins));
+
+    This->pin1 = p;
+    This->pin2 = pp;
+    This->counter = 0;
+    This->refcount = 1;
+
+    This->vt = (IEnumPins_vt*) malloc(sizeof(IEnumPins_vt));
+    This->vt->QueryInterface = CEnumPins_QueryInterface;
+    This->vt->AddRef = CEnumPins_AddRef;
+    This->vt->Release = CEnumPins_Release;
+    This->vt->Next = CEnumPins_Next;
+    This->vt->Skip = CEnumPins_Skip;
+    This->vt->Reset = CEnumPins_Reset;
+    This->vt->Clone = CEnumPins_Clone;
+
+    This->interfaces[0] = IID_IUnknown;
+    This->interfaces[1] = IID_IEnumPins;
+
+    return This;
+}
+
+
+
+/***********
+ * InputPin
+ ***********/
+
+static long STDCALL CInputPin_Connect(IPin * This,
+				      /* [in] */ IPin *pReceivePin,
+				      /* [in] */ AM_MEDIA_TYPE *pmt)
+{
+    Debug unimplemented("CInputPin_Connect", This);
     return E_NOTIMPL;
 }
 
-long STDCALL CInputPin::ReceiveConnection(IPin * This,
-					  /* [in] */ IPin *pConnector,
-					  /* [in] */ const AM_MEDIA_TYPE *pmt)
+static long STDCALL CInputPin_ReceiveConnection(IPin* This,
+						/* [in] */ IPin* pConnector,
+						/* [in] */ const AM_MEDIA_TYPE *pmt)
 {
-    Debug printf("CInputPin::ReceiveConnection() called\n");
+    Debug unimplemented("CInputPin_ReceiveConnection", This);
     return E_NOTIMPL;
 }
 
-long STDCALL CInputPin::Disconnect(IPin * This)
+static long STDCALL CInputPin_Disconnect(IPin* This)
 {
-    Debug printf("CInputPin::Disconnect() called\n");
+    Debug unimplemented("CInputPin_Disconnect", This);
     return E_NOTIMPL;
 }
 
-long STDCALL CInputPin::ConnectedTo(IPin * This, /* [out] */ IPin **pPin)
+static long STDCALL CInputPin_ConnectedTo(IPin* This,
+					  /* [out] */ IPin** pPin)
 {
-    Debug printf("CInputPin::ConnectedTo() called\n");
+    Debug unimplemented("CInputPin_ConnectedTo", This);
     return E_NOTIMPL;
 }
 
-long STDCALL CInputPin::ConnectionMediaType(IPin * This,
-					    /* [out] */ AM_MEDIA_TYPE *pmt)
+static long STDCALL CInputPin_ConnectionMediaType(IPin* This,
+						  /* [out] */ AM_MEDIA_TYPE *pmt)
 {
-    Debug printf("CInputPin::ConnectionMediaType() called\n");
-    if(!pmt)return E_INVALIDARG;
+    Debug printf("CInputPin_ConnectionMediaType(%p) called\n", This);
+    if (!pmt)
+	return E_INVALIDARG;
     *pmt=((CInputPin*)This)->type;
-    if(pmt->cbFormat>0)
+    if (pmt->cbFormat > 0)
     {
 	pmt->pbFormat=(char *)CoTaskMemAlloc(pmt->cbFormat);
 	memcpy(pmt->pbFormat, ((CInputPin*)This)->type.pbFormat, pmt->cbFormat);
@@ -210,352 +171,445 @@
     return 0;
 }
 
-long STDCALL CInputPin::QueryPinInfo(IPin * This, /* [out] */ PIN_INFO *pInfo)
+static long STDCALL CInputPin_QueryPinInfo(IPin* This,
+					   /* [out] */ PIN_INFO *pInfo)
 {
-    Debug printf("CInputPin::QueryPinInfo() called\n");
-    pInfo->dir=PINDIR_OUTPUT;
     CBaseFilter* lparent=((CInputPin*)This)->parent;
-    pInfo->pFilter = lparent;
+    Debug printf("CInputPin_QueryPinInfo(%p) called\n", This);
+    pInfo->dir = PINDIR_OUTPUT;
+    pInfo->pFilter = (IBaseFilter*) lparent;
     lparent->vt->AddRef((IUnknown*)lparent);
-    pInfo->achName[0]=0;
+    pInfo->achName[0] = 0;
+    return 0;
+}
+
+static long STDCALL CInputPin_QueryDirection(IPin* This,
+					      /* [out] */ PIN_DIRECTION *pPinDir)
+{
+    *pPinDir = PINDIR_OUTPUT;
+    Debug printf("CInputPin_QueryDirection(%p) called\n", This);
     return 0;
 }
 
-long STDCALL CInputPin::QueryDirection(IPin * This,
-				       /* [out] */ PIN_DIRECTION *pPinDir)
+static long STDCALL CInputPin_QueryId(IPin* This,
+				       /* [out] */ unsigned short* *Id)
 {
-    *pPinDir=PINDIR_OUTPUT;
-    Debug printf("CInputPin::QueryDirection() called\n");
-    return 0;
+    Debug unimplemented("CInputPin_QueryId", This);
+    return E_NOTIMPL;
 }
 
-long STDCALL CInputPin::QueryId(IPin * This, /* [out] */ unsigned short* *Id)
+static long STDCALL CInputPin_QueryAccept(IPin* This,
+					  /* [in] */ const AM_MEDIA_TYPE *pmt)
 {
-    Debug printf("CInputPin::QueryId() called\n");
+    Debug unimplemented("CInputPin_QueryAccept", This);
     return E_NOTIMPL;
 }
 
-long STDCALL CInputPin::QueryAccept(IPin * This,
-				    /* [in] */ const AM_MEDIA_TYPE *pmt)
+static long STDCALL CInputPin_EnumMediaTypes(IPin* This,
+					     /* [out] */ IEnumMediaTypes **ppEnum)
 {
-    Debug printf("CInputPin::QueryAccept() called\n");
+    Debug unimplemented("CInputPin_EnumMediaTypes", This);
+    return E_NOTIMPL;
+}
+
+static long STDCALL CInputPin_QueryInternalConnections(IPin* This,
+						       /* [out] */ IPin **apPin,
+						       /* [out][in] */ unsigned long *nPin)
+{
+    Debug unimplemented("CInputPin_QueryInternalConnections", This);
+    return E_NOTIMPL;
+}
+
+static long STDCALL CInputPin_EndOfStream(IPin * This)
+{
+    Debug unimplemented("CInputPin_EndOfStream", This);
     return E_NOTIMPL;
 }
 
 
-long STDCALL CInputPin::EnumMediaTypes (
-    IPin * This,
-    /* [out] */ IEnumMediaTypes **ppEnum)
-{
-    Debug printf("CInputPin::EnumMediaTypes() called\n");
-    return E_NOTIMPL;
-}
-
-
-long STDCALL CInputPin::QueryInternalConnections(IPin * This,
-						 /* [out] */ IPin **apPin,
-						 /* [out][in] */ unsigned long *nPin)
+static long STDCALL CInputPin_BeginFlush(IPin * This)
 {
-    Debug printf("CInputPin::QueryInternalConnections() called\n");
-    return E_NOTIMPL;
-}
-
-long STDCALL CInputPin::EndOfStream (IPin * This)
-{
-    Debug printf("CInputPin::EndOfStream() called\n");
-    return E_NOTIMPL;
-}
-
-
-long STDCALL CInputPin::BeginFlush(IPin * This)
-{
-    Debug printf("CInputPin::BeginFlush() called\n");
+    Debug unimplemented("CInputPin_BeginFlush", This);
     return E_NOTIMPL;
 }
 
 
-long STDCALL CInputPin::EndFlush(IPin * This)
+static long STDCALL CInputPin_EndFlush(IPin * This)
 {
-    Debug printf("CInputPin::EndFlush() called\n");
-    return E_NOTIMPL;
-}
-
-long STDCALL CInputPin::NewSegment(IPin * This,
-				   /* [in] */ REFERENCE_TIME tStart,
-				   /* [in] */ REFERENCE_TIME tStop,
-				   /* [in] */ double dRate)
-{
-    Debug printf("CInputPin::NewSegment() called\n");
+    Debug unimplemented("CInputPin_EndFlush", This);
     return E_NOTIMPL;
 }
 
-CBaseFilter::CBaseFilter(const AM_MEDIA_TYPE& type, CBaseFilter2* parent)
+static long STDCALL CInputPin_NewSegment(IPin * This,
+					  /* [in] */ REFERENCE_TIME tStart,
+					  /* [in] */ REFERENCE_TIME tStop,
+					  /* [in] */ double dRate)
 {
-    refcount = 1;
-    pin=new CInputPin(this, type);
-    unused_pin=new CRemotePin(this, parent->GetPin());
-    vt=new IBaseFilter_vt;
-    vt->QueryInterface = QueryInterface;
-    vt->AddRef = AddRef;
-    vt->Release = Release;
-    vt->GetClassID = GetClassID;
-    vt->Stop = Stop;
-    vt->Pause = Pause;
-    vt->Run = Run;
-    vt->GetState = GetState;
-    vt->SetSyncSource = SetSyncSource;
-    vt->GetSyncSource = GetSyncSource;
-    vt->EnumPins = EnumPins;
-    vt->FindPin = FindPin;
-    vt->QueryFilterInfo = QueryFilterInfo;
-    vt->JoinFilterGraph = JoinFilterGraph;
-    vt->QueryVendorInfo = QueryVendorInfo;
-}
-
-long STDCALL CBaseFilter::GetClassID(IBaseFilter * This,
-				      /* [out] */ CLSID *pClassID)
-{
-    Debug printf("CBaseFilter::GetClassID() called\n");
-    return E_NOTIMPL;
-}
-
-long STDCALL CBaseFilter::Stop(IBaseFilter * This)
-{
-    Debug printf("CBaseFilter::Stop() called\n");
+    Debug unimplemented("CInputPin_NewSegment", This);
     return E_NOTIMPL;
 }
 
-long STDCALL CBaseFilter::Pause(IBaseFilter * This)
+static void CInputPin_Destroy(CInputPin* This)
 {
-    Debug printf("CBaseFilter::Pause() called\n");
-    return E_NOTIMPL;
+    free(This->vt);
+    free(This);
 }
 
-long STDCALL CBaseFilter::Run(IBaseFilter * This,
-			      REFERENCE_TIME tStart)
+IMPLEMENT_IUNKNOWN(CInputPin)
+
+CInputPin* CInputPinCreate(CBaseFilter* p, const AM_MEDIA_TYPE* amt)
 {
-    Debug printf("CBaseFilter::Run() called\n");
-    return E_NOTIMPL;
+    CInputPin* This = (CInputPin*) malloc(sizeof(CInputPin));
+
+    This->parent = p;
+    This->refcount = 1;
+    This->type = *amt;
+
+    This->vt= (IPin_vt*) malloc(sizeof(IPin_vt));
+    This->vt->QueryInterface = CInputPin_QueryInterface;
+    This->vt->AddRef = CInputPin_AddRef;
+    This->vt->Release = CInputPin_Release;
+    This->vt->Connect = CInputPin_Connect;
+    This->vt->ReceiveConnection = CInputPin_ReceiveConnection;
+    This->vt->Disconnect = CInputPin_Disconnect;
+    This->vt->ConnectedTo = CInputPin_ConnectedTo;
+    This->vt->ConnectionMediaType = CInputPin_ConnectionMediaType;
+    This->vt->QueryPinInfo = CInputPin_QueryPinInfo;
+    This->vt->QueryDirection = CInputPin_QueryDirection;
+    This->vt->QueryId = CInputPin_QueryId;
+    This->vt->QueryAccept = CInputPin_QueryAccept;
+    This->vt->EnumMediaTypes = CInputPin_EnumMediaTypes;
+    This->vt->QueryInternalConnections = CInputPin_QueryInternalConnections;
+    This->vt->EndOfStream = CInputPin_EndOfStream;
+    This->vt->BeginFlush = CInputPin_BeginFlush;
+    This->vt->EndFlush = CInputPin_EndFlush;
+    This->vt->NewSegment = CInputPin_NewSegment;
+
+    This->interfaces[0]=IID_IUnknown;
+
+    return This;
 }
 
-long STDCALL CBaseFilter::GetState(IBaseFilter * This,
-				   /* [in] */ unsigned long dwMilliSecsTimeout,
-				   // /* [out] */ FILTER_STATE *State)
-				   void* State)
+
+/*************
+ * BaseFilter
+ *************/
+
+static long STDCALL CBaseFilter_GetClassID(IBaseFilter * This,
+					   /* [out] */ CLSID *pClassID)
 {
-    Debug printf("CBaseFilter::GetState() called\n");
+    Debug unimplemented("CBaseFilter_GetClassID", This);
     return E_NOTIMPL;
 }
 
-long STDCALL CBaseFilter::SetSyncSource(IBaseFilter * This,
-					/* [in] */ IReferenceClock *pClock)
+static long STDCALL CBaseFilter_Stop(IBaseFilter* This)
 {
-    Debug printf("CBaseFilter::SetSyncSource() called\n");
+    Debug unimplemented("CBaseFilter_Stop", This);
     return E_NOTIMPL;
 }
 
-long STDCALL CBaseFilter::GetSyncSource (
-        IBaseFilter * This,
-        /* [out] */ IReferenceClock **pClock)
+static long STDCALL CBaseFilter_Pause(IBaseFilter* This)
 {
-    Debug printf("CBaseFilter::GetSyncSource() called\n");
+    Debug unimplemented("CBaseFilter_Pause", This);
+    return E_NOTIMPL;
+}
+
+static long STDCALL CBaseFilter_Run(IBaseFilter* This, REFERENCE_TIME tStart)
+{
+    Debug unimplemented("CBaseFilter_Run", This);
     return E_NOTIMPL;
 }
 
-
-long STDCALL CBaseFilter::EnumPins (
-        IBaseFilter * This,
-        /* [out] */ IEnumPins **ppEnum)
+static long STDCALL CBaseFilter_GetState(IBaseFilter* This,
+					 /* [in] */ unsigned long dwMilliSecsTimeout,
+					 // /* [out] */ FILTER_STATE *State)
+					 void* State)
 {
-    Debug printf("CBaseFilter::EnumPins() called\n");
-    *ppEnum=new CEnumPins(((CBaseFilter*)This)->pin, ((CBaseFilter*)This)->unused_pin);
-    return 0;
+    Debug unimplemented("CBaseFilter_GetState", This);
+    return E_NOTIMPL;
 }
 
+static long STDCALL CBaseFilter_SetSyncSource(IBaseFilter* This,
+					      /* [in] */ IReferenceClock *pClock)
+{
+    Debug unimplemented("CBaseFilter_SetSyncSource", This);
+    return E_NOTIMPL;
+}
 
-long STDCALL CBaseFilter::FindPin (
-        IBaseFilter * This,
-        /* [string][in] */ const unsigned short* Id,
-        /* [out] */ IPin **ppPin)
+static long STDCALL CBaseFilter_GetSyncSource(IBaseFilter* This,
+					      /* [out] */ IReferenceClock **pClock)
 {
-    Debug printf("CBaseFilter::FindPin() called\n");
+    Debug unimplemented("CBaseFilter_GetSyncSource", This);
     return E_NOTIMPL;
 }
 
 
-long STDCALL CBaseFilter::QueryFilterInfo (
-        IBaseFilter * This,
-//        /* [out] */ FILTER_INFO *pInfo)
-	void* pInfo)
+static long STDCALL CBaseFilter_EnumPins(IBaseFilter* This,
+					 /* [out] */ IEnumPins **ppEnum)
+{
+    Debug printf("CBaseFilter_EnumPins(%p) called\n", This);
+    *ppEnum = (IEnumPins*) CEnumPinsCreate(((CBaseFilter*)This)->pin, ((CBaseFilter*)This)->unused_pin);
+    return 0;
+}
+
+static long STDCALL CBaseFilter_FindPin(IBaseFilter* This,
+					/* [string][in] */ const unsigned short* Id,
+					/* [out] */ IPin **ppPin)
 {
-    Debug printf("CBaseFilter::QueryFilterInfo() called\n");
+    Debug unimplemented("CBaseFilter_FindPin\n", This);
+    return E_NOTIMPL;
+}
+
+static long STDCALL CBaseFilter_QueryFilterInfo(IBaseFilter * This,
+						// /* [out] */ FILTER_INFO *pInfo)
+						void* pInfo)
+{
+    Debug unimplemented("CBaseFilter_QueryFilterInfo", This);
+    return E_NOTIMPL;
+}
+
+static long STDCALL CBaseFilter_JoinFilterGraph(IBaseFilter * This,
+						/* [in] */ IFilterGraph *pGraph,
+						/* [string][in] */ const unsigned short* pName)
+{
+    Debug unimplemented("CBaseFilter_JoinFilterGraph", This);
+    return E_NOTIMPL;
+}
+
+static long STDCALL CBaseFilter_QueryVendorInfo(IBaseFilter * This,
+						/* [string][out] */ unsigned short* *pVendorInfo)
+{
+    Debug unimplemented("CBaseFilter_QueryVendorInfo", This);
     return E_NOTIMPL;
 }
 
+static IPin* CBaseFilter_GetPin(CBaseFilter* This)
+{
+    return This->pin;
+}
 
-long STDCALL CBaseFilter::JoinFilterGraph (
-        IBaseFilter * This,
-        /* [in] */ IFilterGraph *pGraph,
-        /* [string][in] */ const unsigned short* pName)
+static IPin* CBaseFilter_GetUnusedPin(CBaseFilter* This)
 {
-    Debug printf("CBaseFilter::JoinFilterGraph() called\n");
-    return E_NOTIMPL;
+    return This->unused_pin;
+}
+
+static void CBaseFilter_Destroy(CBaseFilter* This)
+{
+    free(This->vt);
+    This->pin->vt->Release((IUnknown*)This->pin);
+    This->unused_pin->vt->Release((IUnknown*)This->unused_pin);
+    free(This);
 }
 
+IMPLEMENT_IUNKNOWN(CBaseFilter)
 
-long STDCALL CBaseFilter::QueryVendorInfo (
-        IBaseFilter * This,
-        /* [string][out] */ unsigned short* *pVendorInfo)
+CBaseFilter* CBaseFilterCreate(const AM_MEDIA_TYPE* type, CBaseFilter2* parent)
 {
-    Debug printf("CBaseFilter::QueryVendorInfo() called\n");
-    return E_NOTIMPL;
+    CBaseFilter* This = (CBaseFilter*) malloc(sizeof(CBaseFilter));
+    This->refcount = 1;
+
+    This->pin = (IPin*) CInputPinCreate(This, type);
+    This->unused_pin = (IPin*) CRemotePinCreate(This, parent->GetPin(parent));
+
+    This->vt = (IBaseFilter_vt*) malloc(sizeof(IBaseFilter_vt));
+    This->vt->QueryInterface = CBaseFilter_QueryInterface;
+    This->vt->AddRef = CBaseFilter_AddRef;
+    This->vt->Release = CBaseFilter_Release;
+    This->vt->GetClassID = CBaseFilter_GetClassID;
+    This->vt->Stop = CBaseFilter_Stop;
+    This->vt->Pause = CBaseFilter_Pause;
+    This->vt->Run = CBaseFilter_Run;
+    This->vt->GetState = CBaseFilter_GetState;
+    This->vt->SetSyncSource = CBaseFilter_SetSyncSource;
+    This->vt->GetSyncSource = CBaseFilter_GetSyncSource;
+    This->vt->EnumPins = CBaseFilter_EnumPins;
+    This->vt->FindPin = CBaseFilter_FindPin;
+    This->vt->QueryFilterInfo = CBaseFilter_QueryFilterInfo;
+    This->vt->JoinFilterGraph = CBaseFilter_JoinFilterGraph;
+    This->vt->QueryVendorInfo = CBaseFilter_QueryVendorInfo;
+
+    This->interfaces[0] = IID_IUnknown;
+    This->interfaces[1] = IID_IBaseFilter;
+
+    This->GetPin = CBaseFilter_GetPin;
+    This->GetUnusedPin = CBaseFilter_GetUnusedPin;
+
+    return This;
 }
 
 
-CBaseFilter2::CBaseFilter2() : refcount(1)
-{
-    pin=new CRemotePin2(this);
-    vt=new IBaseFilter_vt;
-    memset(vt, 0, sizeof (IBaseFilter_vt));
-    vt->QueryInterface = QueryInterface;
-    vt->AddRef = AddRef;
-    vt->Release = Release;
-    vt->GetClassID = GetClassID;
-    vt->Stop = Stop;
-    vt->Pause = Pause;
-    vt->Run = Run;
-    vt->GetState = GetState;
-    vt->SetSyncSource = SetSyncSource;
-    vt->GetSyncSource = GetSyncSource;
-    vt->EnumPins = EnumPins;
-    vt->FindPin = FindPin;
-    vt->QueryFilterInfo = QueryFilterInfo;
-    vt->JoinFilterGraph = JoinFilterGraph;
-    vt->QueryVendorInfo = QueryVendorInfo;
-}
+/**************
+ * BaseFilter2
+ **************/
 
 
-
-
-long STDCALL CBaseFilter2::GetClassID (
-        IBaseFilter * This,
-        /* [out] */ CLSID *pClassID)
+static long STDCALL CBaseFilter2_GetClassID(IBaseFilter * This,
+					     /* [out] */ CLSID *pClassID)
 {
-    Debug printf("CBaseFilter2::GetClassID() called\n");
+    Debug unimplemented("CBaseFilter2_GetClassID", This);
     return E_NOTIMPL;
 }
 
-long STDCALL CBaseFilter2::Stop (
-        IBaseFilter * This)
+static long STDCALL CBaseFilter2_Stop(IBaseFilter * This)
 {
-    Debug printf("CBaseFilter2::Stop() called\n");
+    Debug unimplemented("CBaseFilter2_Stop", This);
     return E_NOTIMPL;
 }
 
-
-long STDCALL CBaseFilter2::Pause (IBaseFilter * This)
+static long STDCALL CBaseFilter2_Pause(IBaseFilter * This)
 {
-    Debug printf("CBaseFilter2::Pause() called\n");
+    Debug unimplemented("CBaseFilter2_Pause", This);
     return E_NOTIMPL;
 }
 
-long STDCALL CBaseFilter2::Run (IBaseFilter * This, REFERENCE_TIME tStart)
+static long STDCALL CBaseFilter2_Run(IBaseFilter * This, REFERENCE_TIME tStart)
 {
-    Debug printf("CBaseFilter2::Run() called\n");
+    Debug unimplemented("CBaseFilter2_Run", This);
     return E_NOTIMPL;
 }
 
 
-long STDCALL CBaseFilter2::GetState (
-        IBaseFilter * This,
-        /* [in] */ unsigned long dwMilliSecsTimeout,
-//        /* [out] */ FILTER_STATE *State)
-    	void* State)
+static long STDCALL CBaseFilter2_GetState(IBaseFilter* This,
+					  /* [in] */ unsigned long dwMilliSecsTimeout,
+					  // /* [out] */ FILTER_STATE *State)
+					  void* State)
+{
+    Debug unimplemented("CBaseFilter2_GetState", This);
+    return E_NOTIMPL;
+}
+
+static long STDCALL CBaseFilter2_SetSyncSource(IBaseFilter* This,
+					       /* [in] */ IReferenceClock* pClock)
+{
+    Debug unimplemented("CBaseFilter2_SetSyncSource", This);
+    return E_NOTIMPL;
+}
+
+static long STDCALL CBaseFilter2_GetSyncSource(IBaseFilter* This,
+					       /* [out] */ IReferenceClock** pClock)
+{
+    Debug unimplemented("CBaseFilter2_GetSyncSource", This);
+    return E_NOTIMPL;
+}
+
+static long STDCALL CBaseFilter2_EnumPins(IBaseFilter* This,
+					  /* [out] */ IEnumPins** ppEnum)
 {
-    Debug printf("CBaseFilter2::GetState() called\n");
+    Debug printf("CBaseFilter2_EnumPins(%p) called\n", This);
+    *ppEnum = (IEnumPins*) CEnumPinsCreate(((CBaseFilter2*)This)->pin, 0);
+    return 0;
+}
+
+static long STDCALL CBaseFilter2_FindPin(IBaseFilter* This,
+					 /* [string][in] */ const unsigned short* Id,
+					 /* [out] */ IPin** ppPin)
+{
+    Debug unimplemented("CBaseFilter2_FindPin", This);
+    return E_NOTIMPL;
+}
+
+static long STDCALL CBaseFilter2_QueryFilterInfo(IBaseFilter* This,
+						 // /* [out] */ FILTER_INFO *pInfo)
+						 void* pInfo)
+{
+    Debug unimplemented("CBaseFilter2_QueryFilterInfo", This);
+    return E_NOTIMPL;
+}
+
+static long STDCALL CBaseFilter2_JoinFilterGraph(IBaseFilter* This,
+						 /* [in] */ IFilterGraph* pGraph,
+						 /* [string][in] */
+						  const unsigned short* pName)
+{
+    Debug unimplemented("CBaseFilter2_JoinFilterGraph", This);
     return E_NOTIMPL;
 }
 
-
-long STDCALL CBaseFilter2::SetSyncSource (
-        IBaseFilter * This,
-        /* [in] */ IReferenceClock *pClock)
+static long STDCALL CBaseFilter2_QueryVendorInfo(IBaseFilter* This,
+						 /* [string][out] */
+						 unsigned short** pVendorInfo)
 {
-    Debug printf("CBaseFilter2::SetSyncSource() called\n");
+    Debug unimplemented("CBaseFilter2_QueryVendorInfo", This);
     return E_NOTIMPL;
 }
 
+static IPin* CBaseFilter2_GetPin(CBaseFilter2* This)
+{
+    return This->pin;
+}
 
-long STDCALL CBaseFilter2::GetSyncSource (
-        IBaseFilter * This,
-        /* [out] */ IReferenceClock **pClock)
+static void CBaseFilter2_Destroy(CBaseFilter2* This)
 {
-    Debug printf("CBaseFilter2::GetSyncSource() called\n");
-    return E_NOTIMPL;
+    This->pin->vt->Release((IUnknown*) This->pin);
+    free(This->vt);
+    free(This);
 }
 
+IMPLEMENT_IUNKNOWN(CBaseFilter2)
 
-long STDCALL CBaseFilter2::EnumPins (
-        IBaseFilter * This,
-        /* [out] */ IEnumPins **ppEnum)
+static GUID CBaseFilter2_interf1 =
+{0x76c61a30, 0xebe1, 0x11cf, {0x89, 0xf9, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xcb}};
+static GUID CBaseFilter2_interf2 =
+{0xaae7e4e2, 0x6388, 0x11d1, {0x8d, 0x93, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2}};
+static GUID CBaseFilter2_interf3 =
+{0x02ef04dd, 0x7580, 0x11d1, {0xbe, 0xce, 0x00, 0xc0, 0x4f, 0xb6, 0xe9, 0x37}};
+
+CBaseFilter2* CBaseFilter2Create()
 {
-    Debug printf("CBaseFilter2::EnumPins() called\n");
-    *ppEnum=new CEnumPins(((CBaseFilter2*)This)->pin);
-    return 0;
+    CBaseFilter2* This = (CBaseFilter2*) malloc(sizeof(CBaseFilter2));
+
+    This->refcount = 1;
+    This->pin = (IPin*) CRemotePin2Create(This);
+
+    This->vt = (IBaseFilter_vt*) malloc(sizeof(IBaseFilter_vt));
+    memset(This->vt, 0, sizeof(IBaseFilter_vt));
+    This->vt->QueryInterface = CBaseFilter2_QueryInterface;
+    This->vt->AddRef = CBaseFilter2_AddRef;
+    This->vt->Release = CBaseFilter2_Release;
+    This->vt->GetClassID = CBaseFilter2_GetClassID;
+    This->vt->Stop = CBaseFilter2_Stop;
+    This->vt->Pause = CBaseFilter2_Pause;
+    This->vt->Run = CBaseFilter2_Run;
+    This->vt->GetState = CBaseFilter2_GetState;
+    This->vt->SetSyncSource = CBaseFilter2_SetSyncSource;
+    This->vt->GetSyncSource = CBaseFilter2_GetSyncSource;
+    This->vt->EnumPins = CBaseFilter2_EnumPins;
+    This->vt->FindPin = CBaseFilter2_FindPin;
+    This->vt->QueryFilterInfo = CBaseFilter2_QueryFilterInfo;
+    This->vt->JoinFilterGraph = CBaseFilter2_JoinFilterGraph;
+    This->vt->QueryVendorInfo = CBaseFilter2_QueryVendorInfo;
+
+    This->GetPin = CBaseFilter2_GetPin;
+
+    This->interfaces[0] = IID_IUnknown;
+    This->interfaces[1] = IID_IBaseFilter;
+    This->interfaces[2] = CBaseFilter2_interf1;
+    This->interfaces[3] = CBaseFilter2_interf2;
+    This->interfaces[4] = CBaseFilter2_interf3;
+
+    return This;
 }
 
 
-long STDCALL CBaseFilter2::FindPin (
-        IBaseFilter * This,
-        /* [string][in] */ const unsigned short* Id,
-        /* [out] */ IPin **ppPin)
-{
-    Debug printf("CBaseFilter2::FindPin() called\n");
-    return E_NOTIMPL;
-}
-
-
-long STDCALL CBaseFilter2::QueryFilterInfo (
-        IBaseFilter * This,
-//        /* [out] */ FILTER_INFO *pInfo)
-	void* pInfo)
-{
-    Debug printf("CBaseFilter2::QueryFilterInfo() called\n");
-    return E_NOTIMPL;
-}
+/*************
+ * CRemotePin
+ *************/
 
 
-long STDCALL CBaseFilter2::JoinFilterGraph(IBaseFilter * This,
-					   /* [in] */ IFilterGraph *pGraph,
-					   /* [string][in] */
-					   const unsigned short* pName)
+static long STDCALL CRemotePin_ConnectedTo(IPin* This, /* [out] */ IPin** pPin)
 {
-    Debug printf("CBaseFilter2::JoinFilterGraph() called\n");
-    return E_NOTIMPL;
-}
-
-long STDCALL CBaseFilter2::QueryVendorInfo(IBaseFilter * This,
-					   /* [string][out] */
-					   unsigned short* *pVendorInfo)
-{
-    Debug printf("CBaseFilter2::QueryVendorInfo() called\n");
-    return E_NOTIMPL;
-}
-
-static long STDCALL CRemotePin_ConnectedTo(IPin * This, /* [out] */ IPin **pPin)
-{
-    Debug printf("CRemotePin::ConnectedTo called\n");
+    Debug printf("CRemotePin_ConnectedTo(%p) called\n", This);
     if (!pPin)
 	return E_INVALIDARG;
-    *pPin=((CRemotePin*)This)->remote_pin;
+    *pPin = ((CRemotePin*)This)->remote_pin;
     (*pPin)->vt->AddRef((IUnknown*)(*pPin));
     return 0;
 }
 
-static long STDCALL CRemotePin_QueryDirection(IPin * This,
+static long STDCALL CRemotePin_QueryDirection(IPin* This,
 					      /* [out] */ PIN_DIRECTION *pPinDir)
 {
-    Debug printf("CRemotePin::QueryDirection called\n");
+    Debug printf("CRemotePin_QueryDirection(%p) called\n", This);
     if (!pPinDir)
 	return E_INVALIDARG;
     *pPinDir=PINDIR_INPUT;
@@ -564,27 +618,65 @@
 
 static long STDCALL CRemotePin_ConnectionMediaType(IPin* This, /* [out] */ AM_MEDIA_TYPE* pmt)
 {
-    Debug printf("CRemotePin::ConnectionMediaType() called\n");
+    Debug unimplemented("CRemotePin_ConnectionMediaType", This);
     return E_NOTIMPL;
 }
 
 static long STDCALL CRemotePin_QueryPinInfo(IPin* This, /* [out] */ PIN_INFO* pInfo)
 {
-    Debug printf("CRemotePin::QueryPinInfo() called\n");
-    pInfo->dir=PINDIR_INPUT;
     CBaseFilter* lparent = ((CRemotePin*)This)->parent;
-    pInfo->pFilter = lparent;
+    Debug printf("CRemotePin_QueryPinInfo(%p) called\n", This);
+    pInfo->dir= PINDIR_INPUT;
+    pInfo->pFilter = (IBaseFilter*) lparent;
     lparent->vt->AddRef((IUnknown*)lparent);
     pInfo->achName[0]=0;
     return 0;
 }
 
+static void CRemotePin_Destroy(CRemotePin* This)
+{
+    Debug printf("CRemotePin_Destroy(%p) called\n", This);
+    free(This->vt);
+    free(This);
+}
+
+IMPLEMENT_IUNKNOWN(CRemotePin)
+
+CRemotePin* CRemotePinCreate(CBaseFilter* pt, IPin* rpin)
+{
+    CRemotePin* This = (CRemotePin*) malloc(sizeof(CRemotePin));
+    Debug printf("CRemotePinCreate() called -> %p\n", This);
+
+    This->parent = pt;
+    This->remote_pin = rpin;
+    This->refcount = 1;
+
+    This->vt = (IPin_vt*) malloc(sizeof(IPin_vt));
+    memset(This->vt, 0, sizeof(IPin_vt));
+    This->vt->QueryInterface = CRemotePin_QueryInterface;
+    This->vt->AddRef = CRemotePin_AddRef;
+    This->vt->Release = CRemotePin_Release;
+    This->vt->QueryDirection = CRemotePin_QueryDirection;
+    This->vt->ConnectedTo = CRemotePin_ConnectedTo;
+    This->vt->ConnectionMediaType = CRemotePin_ConnectionMediaType;
+    This->vt->QueryPinInfo = CRemotePin_QueryPinInfo;
+
+    This->interfaces[0] = IID_IUnknown;
+
+    return This;
+}
+
+
+/*************
+ * CRemotePin
+ *************/
+
 
 static long STDCALL CRemotePin2_QueryPinInfo(IPin * This,
 				       /* [out] */ PIN_INFO *pInfo)
 {
-    Debug printf("CRemotePin2::QueryPinInfo called\n");
     CBaseFilter2* lparent=((CRemotePin2*)This)->parent;
+    Debug printf("CRemotePin2_QueryPinInfo(%p) called\n", This);
     pInfo->pFilter=(IBaseFilter*)lparent;
     lparent->vt->AddRef((IUnknown*)lparent);
     pInfo->dir=PINDIR_OUTPUT;
@@ -592,27 +684,31 @@
     return 0;
 }
 
-CRemotePin::CRemotePin(CBaseFilter* pt, IPin* rpin): parent(pt), remote_pin(rpin),
-    refcount(1)
+static void CRemotePin2_Destroy(CRemotePin2* This)
 {
-    vt = new IPin_vt;
-    memset(vt, 0, sizeof(IPin_vt));
-    vt->QueryInterface = QueryInterface;
-    vt->AddRef = AddRef;
-    vt->Release = Release;
-    vt->QueryDirection = CRemotePin_QueryDirection;
-    vt->ConnectedTo = CRemotePin_ConnectedTo;
-    vt->ConnectionMediaType = CRemotePin_ConnectionMediaType;
-    vt->QueryPinInfo = CRemotePin_QueryPinInfo;
+    Debug printf("CRemotePin2_Destroy(%p) called\n", This);
+    free(This->vt);
+    free(This);
 }
 
-CRemotePin2::CRemotePin2(CBaseFilter2* p):parent(p),
-    refcount(1)
+IMPLEMENT_IUNKNOWN(CRemotePin2)
+
+CRemotePin2* CRemotePin2Create(CBaseFilter2* p)
 {
-    vt = new IPin_vt;
-    memset(vt, 0, sizeof(IPin_vt));
-    vt->QueryInterface = QueryInterface;
-    vt->AddRef = AddRef;
-    vt->Release = Release;
-    vt->QueryPinInfo = CRemotePin2_QueryPinInfo;
+    CRemotePin2* This = (CRemotePin2*) malloc(sizeof(CRemotePin2));
+    Debug printf("CRemotePin2Create() called -> %p\n", This);
+
+    This->parent = p;
+    This->refcount = 1;
+
+    This->vt = (IPin_vt*) malloc(sizeof(IPin_vt));
+    memset(This->vt, 0, sizeof(IPin_vt));
+    This->vt->QueryInterface = CRemotePin2_QueryInterface;
+    This->vt->AddRef = CRemotePin2_AddRef;
+    This->vt->Release = CRemotePin2_Release;
+    This->vt->QueryPinInfo = CRemotePin2_QueryPinInfo;
+
+    This->interfaces[0] = IID_IUnknown;
+
+    return This;
 }
--- a/loader/dshow/inputpin.h	Wed Nov 21 18:40:59 2001 +0000
+++ b/loader/dshow/inputpin.h	Wed Nov 21 19:12:39 2001 +0000
@@ -2,215 +2,70 @@
 #define DS_INPUTPIN_H
 
 #include "interfaces.h"
-#include "guids.h"
-#include "iunk.h"
+
+typedef struct _CBaseFilter2 CBaseFilter2;
+struct _CBaseFilter2
+{
+    IBaseFilter_vt* vt;
+    IPin* pin;
+    GUID interfaces[5];
+    DECLARE_IUNKNOWN();
 
-class CBaseFilter2;
-class CBaseFilter: public IBaseFilter
+    IPin* ( *GetPin )(CBaseFilter2* This);
+};
+
+CBaseFilter2* CBaseFilter2Create();
+
+
+typedef struct _CBaseFilter CBaseFilter;
+struct _CBaseFilter
 {
+    IBaseFilter_vt* vt;
     IPin* pin;
     IPin* unused_pin;
-    static GUID interfaces[];
-    DECLARE_IUNKNOWN(CBaseFilter)
-public:
-    CBaseFilter(const AM_MEDIA_TYPE& vhdr, CBaseFilter2* parent);
-    ~CBaseFilter(){delete vt;pin->vt->Release((IUnknown*)pin);unused_pin->vt->Release((IUnknown*)unused_pin);}
-    
-    IPin* GetPin() {return pin;}
-    IPin* GetUnusedPin() {return unused_pin;}
-
-    static long STDCALL GetClassID (IBaseFilter * This,
-				    /* [out] */ CLSID *pClassID);
-    
-    static long STDCALL Stop (IBaseFilter * This);
-    static long STDCALL Pause (IBaseFilter * This);
-    static long STDCALL Run (IBaseFilter * This, REFERENCE_TIME tStart);
-    static long STDCALL GetState (IBaseFilter * This,
-				  /* [in] */ unsigned long dwMilliSecsTimeout,
-				  // /* [out] */ FILTER_STATE *State);
-				  void* State);
+    GUID interfaces[2];
+    DECLARE_IUNKNOWN();
 
-    static long STDCALL SetSyncSource (IBaseFilter * This,
-				       /* [in] */ IReferenceClock *pClock);
-    static long STDCALL GetSyncSource (IBaseFilter * This,
-				       /* [out] */ IReferenceClock **pClock);
-    static long STDCALL EnumPins (IBaseFilter * This,
-				  /* [out] */ IEnumPins **ppEnum);
-    static long STDCALL FindPin (IBaseFilter * This,
-				 /* [string][in] */ const unsigned short* Id,
-				 /* [out] */ IPin **ppPin);
-    static long STDCALL QueryFilterInfo (IBaseFilter * This,
-					 ///* [out] */ FILTER_INFO *pInfo);
-					 void* pInfo);
-    static long STDCALL JoinFilterGraph (IBaseFilter * This,
-					 /* [in] */ IFilterGraph *pGraph,
-					 /* [string][in] */
-					 const unsigned short* pName);
-    static long STDCALL QueryVendorInfo (IBaseFilter * This,
-					 /* [string][out] */
-					 unsigned short* *pVendorInfo);
+    IPin* ( *GetPin )(CBaseFilter* This);
+    IPin* ( *GetUnusedPin )(CBaseFilter* This);
 };
 
-class CInputPin: public IPin
+CBaseFilter* CBaseFilterCreate(const AM_MEDIA_TYPE* vhdr, CBaseFilter2* parent);
+
+
+typedef struct _CInputPin CInputPin;
+struct _CInputPin
 {
+    IPin_vt* vt;
     AM_MEDIA_TYPE type;
     CBaseFilter* parent;
-    static GUID interfaces[];
-    DECLARE_IUNKNOWN(CInputPin)
-public:
-    CInputPin(CBaseFilter* parent, const AM_MEDIA_TYPE& vhdr);
-    ~CInputPin(){delete vt;}
-//    IPin* GetPin();
-
-//    static long STDCALL QueryInterface(IUnknown* This, GUID* iid, void** ppv);
-//    static long STDCALL AddRef(IUnknown* This);
-//    static long STDCALL Release(IUnknown* This);
-
-    static long STDCALL Connect ( 
-	IPin * This,
-        /* [in] */ IPin *pReceivePin,
-        /* [in] */ AM_MEDIA_TYPE *pmt);
-        
-    static long STDCALL ReceiveConnection ( 
-        IPin * This,
-        /* [in] */ IPin *pConnector,
-        /* [in] */ const AM_MEDIA_TYPE *pmt);
-    
-    static long STDCALL Disconnect ( 
-        IPin * This);
-    
-    static long STDCALL ConnectedTo ( 
-        IPin * This,
-        /* [out] */ IPin **pPin);
-    
-    static long STDCALL ConnectionMediaType ( 
-        IPin * This,
-        /* [out] */ AM_MEDIA_TYPE *pmt);
-    
-    static long STDCALL QueryPinInfo ( 
-        IPin * This,
-        /* [out] */ PIN_INFO *pInfo);
-    
-    static long STDCALL QueryDirection ( 
-        IPin * This,
-        /* [out] */ PIN_DIRECTION *pPinDir);
-    
-    static long STDCALL QueryId ( 
-        IPin * This,
-        /* [out] */ unsigned short* *Id);
-    
-    static long STDCALL QueryAccept ( 
-        IPin * This,
-        /* [in] */ const AM_MEDIA_TYPE *pmt);
-    
-    static long STDCALL EnumMediaTypes ( 
-        IPin * This,
-        /* [out] */ IEnumMediaTypes **ppEnum);
-    
-    static long STDCALL QueryInternalConnections ( 
-        IPin * This,
-        /* [out] */ IPin **apPin,
-        /* [out][in] */ unsigned long *nPin);
-    
-    static long STDCALL EndOfStream ( 
-        IPin * This);
-    
-    static long STDCALL BeginFlush ( 
-        IPin * This);
-    
-    static long STDCALL EndFlush ( 
-        IPin * This);
-    
-    static long STDCALL NewSegment ( 
-        IPin * This,
-        /* [in] */ REFERENCE_TIME tStart,
-        /* [in] */ REFERENCE_TIME tStop,
-        /* [in] */ double dRate);
+    GUID interfaces[1];
+    DECLARE_IUNKNOWN();
 };
 
-class CBaseFilter2: public IBaseFilter
-{
-    IPin* pin;
-    static GUID interfaces[];
-    DECLARE_IUNKNOWN(CBaseFilter2)
-public:
-    CBaseFilter2();
-    ~CBaseFilter2(){delete vt;pin->vt->Release((IUnknown*)pin);}
-    IPin* GetPin() {return pin;}
-    
-//    static long STDCALL QueryInterface(IUnknown* This, GUID* iid, void** ppv);
-//    static long STDCALL AddRef(IUnknown* This);
-//    static long STDCALL Release(IUnknown* This);
-    static long STDCALL GetClassID ( 
-        IBaseFilter * This,
-        /* [out] */ CLSID *pClassID);
-    
-    static long STDCALL Stop ( 
-        IBaseFilter * This);
-    
-    static long STDCALL Pause ( 
-        IBaseFilter * This);
-    
-    static long STDCALL Run ( 
-        IBaseFilter * This,
-        REFERENCE_TIME tStart);
-    
-    static long STDCALL GetState ( 
-        IBaseFilter * This,
-        /* [in] */ unsigned long dwMilliSecsTimeout,
-//        /* [out] */ FILTER_STATE *State);
-    	void* State);
-    
-    static long STDCALL SetSyncSource ( 
-        IBaseFilter * This,
-        /* [in] */ IReferenceClock *pClock);
-    
-    static long STDCALL GetSyncSource ( 
-        IBaseFilter * This,
-        /* [out] */ IReferenceClock **pClock);
-    
-    static long STDCALL EnumPins ( 
-        IBaseFilter * This,
-        /* [out] */ IEnumPins **ppEnum);
-    
-    static long STDCALL FindPin ( 
-        IBaseFilter * This,
-        /* [string][in] */ const unsigned short* Id,
-        /* [out] */ IPin **ppPin);
-    
-    static long STDCALL QueryFilterInfo ( 
-        IBaseFilter * This,
-//        /* [out] */ FILTER_INFO *pInfo);
-	void* pInfo);
-    
-    static long STDCALL JoinFilterGraph ( 
-        IBaseFilter * This,
-        /* [in] */ IFilterGraph *pGraph,
-        /* [string][in] */ const unsigned short* pName);
-    
-    static long STDCALL QueryVendorInfo ( 
-        IBaseFilter * This,
-        /* [string][out] */ unsigned short* *pVendorInfo);
-};
+CInputPin* CInputPinCreate(CBaseFilter* parent, const AM_MEDIA_TYPE* vhdr);
 
 
-struct CRemotePin: public IPin
+typedef struct CRemotePin
 {
+    IPin_vt* vt;
     CBaseFilter* parent;
     IPin* remote_pin;
-    static GUID interfaces[];
-    DECLARE_IUNKNOWN(CRemotePin)
-    CRemotePin(CBaseFilter* pt, IPin* rpin);
-    ~CRemotePin(){delete vt;}
-};
+    GUID interfaces[1];
+    DECLARE_IUNKNOWN();
+} CRemotePin;
+
+CRemotePin* CRemotePinCreate(CBaseFilter* pt, IPin* rpin);
+
 
-struct CRemotePin2: public IPin
+typedef struct CRemotePin2
 {
+    IPin_vt* vt;
     CBaseFilter2* parent;
-    static GUID interfaces[];
-    DECLARE_IUNKNOWN(CRemotePin2)
-    CRemotePin2(CBaseFilter2* parent);
-    ~CRemotePin2(){delete vt;}
-};
+    GUID interfaces[1];
+    DECLARE_IUNKNOWN();
+} CRemotePin2;
+
+CRemotePin2* CRemotePin2Create(CBaseFilter2* parent);
 
 #endif /* DS_INPUTPIN_H */
--- a/loader/dshow/interfaces.h	Wed Nov 21 18:40:59 2001 +0000
+++ b/loader/dshow/interfaces.h	Wed Nov 21 19:12:39 2001 +0000
@@ -9,100 +9,44 @@
 
 */
 
+#include "iunk.h"
 #include "com.h"
-#include "guids.h"
 
-#ifndef STDCALL
-#define STDCALL __attribute__((__stdcall__))
-#endif
-
-typedef GUID& REFIID;
+//typedef GUID& REFIID;
 typedef GUID CLSID;
 typedef GUID IID;
 
 /*    Sh*t. MSVC++ and g++ use different methods of storing vtables.    */
 
-struct IBaseFilter;
-struct IReferenceClock;
-struct IEnumPins;
-struct IEnumMediaTypes;
-struct IPin;
-struct IFilterGraph;
-struct IMemInputPin;
-struct IMemAllocator;
-struct IMediaSample;
-struct IHidden;
-struct IHidden2;
+typedef struct _IReferenceClock IReferenceClock;
+typedef struct _IFilterGraph IFilterGraph;
 
 enum PIN_DIRECTION;
 
-class IClassFactory2
-{
-public:
-    virtual long STDCALL QueryInterface(GUID* iid, void** ppv) =0;
-    virtual long STDCALL AddRef() =0;
-    virtual long STDCALL Release() =0;
-    virtual long STDCALL CreateInstance(IUnknown* pUnkOuter, GUID* riid, void** ppvObject) =0;
-};
-
-struct IBaseFilter_vt: IUnknown_vt
+typedef struct _IEnumMediaTypes IEnumMediaTypes;
+typedef struct IEnumMediaTypes_vt
 {
-    HRESULT STDCALL ( *GetClassID )(IBaseFilter * This,
-				    /* [out] */ CLSID *pClassID);
-    HRESULT STDCALL ( *Stop )(IBaseFilter * This);
-    HRESULT STDCALL ( *Pause )(IBaseFilter * This);
-    HRESULT STDCALL ( *Run )(IBaseFilter * This,
-			     REFERENCE_TIME tStart);
-    HRESULT STDCALL ( *GetState )(IBaseFilter * This,
-				  /* [in] */ unsigned long dwMilliSecsTimeout,
-				  ///* [out] */ FILTER_STATE *State);
-				  void* State);
-    HRESULT STDCALL ( *SetSyncSource )(IBaseFilter * This,
-				       /* [in] */ IReferenceClock *pClock);
-    HRESULT STDCALL ( *GetSyncSource )(IBaseFilter * This,
-				       /* [out] */ IReferenceClock **pClock);
-    HRESULT STDCALL ( *EnumPins )(IBaseFilter * This,
-				  /* [out] */ IEnumPins **ppEnum);
-    HRESULT STDCALL ( *FindPin )(IBaseFilter * This,
-				 /* [string][in] */ const unsigned short* Id,
-				 /* [out] */ IPin **ppPin);
-    HRESULT STDCALL ( *QueryFilterInfo )(IBaseFilter * This,
-					 // /* [out] */ FILTER_INFO *pInfo);
-					 void* pInfo);
-    HRESULT STDCALL ( *JoinFilterGraph )(IBaseFilter * This,
-					 /* [in] */ IFilterGraph *pGraph,
-					 /* [string][in] */ const unsigned short* pName);
-    HRESULT STDCALL ( *QueryVendorInfo )(IBaseFilter * This,
-					 /* [string][out] */ unsigned short* *pVendorInfo);
-};
+    INHERIT_IUNKNOWN();
 
-struct IBaseFilter
-{
-    struct IBaseFilter_vt *vt;
-};
+    HRESULT STDCALL ( *Next )(IEnumMediaTypes* This,
+			      /* [in] */ unsigned long cMediaTypes,
+			      /* [size_is][out] */ AM_MEDIA_TYPE** ppMediaTypes,
+			      /* [out] */ unsigned long* pcFetched);
+    HRESULT STDCALL ( *Skip )(IEnumMediaTypes* This,
+			      /* [in] */ unsigned long cMediaTypes);
+    HRESULT STDCALL ( *Reset )(IEnumMediaTypes* This);
+    HRESULT STDCALL ( *Clone )(IEnumMediaTypes* This,
+			       /* [out] */ IEnumMediaTypes** ppEnum);
+} IEnumMediaTypes_vt;
+struct _IEnumMediaTypes { IEnumMediaTypes_vt* vt; };
 
 
-struct IEnumPins_vt: IUnknown_vt
+
+typedef struct _IPin IPin;
+typedef struct IPin_vt
 {
-    HRESULT STDCALL ( *Next )(IEnumPins * This,
-			      /* [in] */ unsigned long cPins,
-			      /* [size_is][out] */ IPin **ppPins,
-			      /* [out] */ unsigned long *pcFetched);
-    HRESULT STDCALL ( *Skip )(IEnumPins * This,
-			      /* [in] */ unsigned long cPins);
-    HRESULT STDCALL ( *Reset )(IEnumPins * This);
-    HRESULT STDCALL ( *Clone )(IEnumPins * This,
-			       /* [out] */ IEnumPins **ppEnum);
-};
+    INHERIT_IUNKNOWN();
 
-struct IEnumPins
-{
-    struct IEnumPins_vt *vt;
-};
-
-
-struct IPin_vt: IUnknown_vt
-{
     HRESULT STDCALL ( *Connect )(IPin * This,
 				 /* [in] */ IPin *pReceivePin,
 				 /* [in] */ /*const*/ AM_MEDIA_TYPE *pmt);
@@ -131,35 +75,135 @@
 				    /* [in] */ REFERENCE_TIME tStart,
 				    /* [in] */ REFERENCE_TIME tStop,
 				    /* [in] */ double dRate);
-};
+} IPin_vt;
+struct _IPin { IPin_vt *vt; };
+
+
+typedef struct _IEnumPins IEnumPins;
+typedef struct IEnumPins_vt
+{
+    INHERIT_IUNKNOWN();
+
+    HRESULT STDCALL ( *Next )(IEnumPins* This,
+			      /* [in] */ unsigned long cPins,
+			      /* [size_is][out] */ IPin** ppPins,
+			      /* [out] */ unsigned long* pcFetched);
+    HRESULT STDCALL ( *Skip )(IEnumPins* This,
+			      /* [in] */ unsigned long cPins);
+    HRESULT STDCALL ( *Reset )(IEnumPins* This);
+    HRESULT STDCALL ( *Clone )(IEnumPins* This,
+			       /* [out] */ IEnumPins** ppEnum);
+} IEnumPins_vt;
+struct _IEnumPins { struct IEnumPins_vt* vt; };
+
+
+typedef struct _IMediaSample IMediaSample;
+typedef struct IMediaSample_vt
+{
+    INHERIT_IUNKNOWN();
 
-struct IPin
-{
-    IPin_vt *vt;
-};
+    HRESULT STDCALL ( *GetPointer )(IMediaSample* This,
+				    /* [out] */ unsigned char** ppBuffer);
+    LONG    STDCALL ( *GetSize )(IMediaSample* This);
+    HRESULT STDCALL ( *GetTime )(IMediaSample* This,
+				 /* [out] */ REFERENCE_TIME* pTimeStart,
+				 /* [out] */ REFERENCE_TIME* pTimeEnd);
+    HRESULT STDCALL ( *SetTime )(IMediaSample* This,
+				 /* [in] */ REFERENCE_TIME* pTimeStart,
+				 /* [in] */ REFERENCE_TIME* pTimeEnd);
+    HRESULT STDCALL ( *IsSyncPoint )(IMediaSample* This);
+    HRESULT STDCALL ( *SetSyncPoint )(IMediaSample* This,
+				      long bIsSyncPoint);
+    HRESULT STDCALL ( *IsPreroll )(IMediaSample* This);
+    HRESULT STDCALL ( *SetPreroll )(IMediaSample* This,
+				    long bIsPreroll);
+    LONG    STDCALL ( *GetActualDataLength )(IMediaSample* This);
+    HRESULT STDCALL ( *SetActualDataLength )(IMediaSample* This,
+					     long __MIDL_0010);
+    HRESULT STDCALL ( *GetMediaType )(IMediaSample* This,
+				      AM_MEDIA_TYPE** ppMediaType);
+    HRESULT STDCALL ( *SetMediaType )(IMediaSample* This,
+				      AM_MEDIA_TYPE* pMediaType);
+    HRESULT STDCALL ( *IsDiscontinuity )(IMediaSample* This);
+    HRESULT STDCALL ( *SetDiscontinuity )(IMediaSample* This,
+					  long bDiscontinuity);
+    HRESULT STDCALL ( *GetMediaTime )(IMediaSample* This,
+				      /* [out] */ long long* pTimeStart,
+				      /* [out] */ long long* pTimeEnd);
+    HRESULT STDCALL ( *SetMediaTime )(IMediaSample* This,
+				      /* [in] */ long long* pTimeStart,
+				      /* [in] */ long long* pTimeEnd);
+} IMediaSample_vt;
+struct _IMediaSample { struct IMediaSample_vt* vt; };
+
 
 
-struct IEnumMediaTypes_vt: IUnknown_vt
+//typedef struct _IBaseFilter IBaseFilter;
+typedef struct IBaseFilter_vt
 {
-    HRESULT STDCALL ( *Next )(IEnumMediaTypes * This,
-			      /* [in] */ unsigned long cMediaTypes,
-			      /* [size_is][out] */ AM_MEDIA_TYPE **ppMediaTypes,
-			      /* [out] */ unsigned long *pcFetched);
-    HRESULT STDCALL ( *Skip )(IEnumMediaTypes * This,
-			      /* [in] */ unsigned long cMediaTypes);
-    HRESULT STDCALL ( *Reset )(IEnumMediaTypes * This);
-    HRESULT STDCALL ( *Clone )(IEnumMediaTypes * This,
-			       /* [out] */ IEnumMediaTypes **ppEnum);
-};
+    INHERIT_IUNKNOWN();
 
-struct IEnumMediaTypes
-{
-    IEnumMediaTypes_vt *vt;
-};
+    HRESULT STDCALL ( *GetClassID )(IBaseFilter * This,
+				    /* [out] */ CLSID *pClassID);
+    HRESULT STDCALL ( *Stop )(IBaseFilter * This);
+    HRESULT STDCALL ( *Pause )(IBaseFilter * This);
+    HRESULT STDCALL ( *Run )(IBaseFilter * This,
+			     REFERENCE_TIME tStart);
+    HRESULT STDCALL ( *GetState )(IBaseFilter * This,
+				  /* [in] */ unsigned long dwMilliSecsTimeout,
+				  ///* [out] */ FILTER_STATE *State);
+				  void* State);
+    HRESULT STDCALL ( *SetSyncSource )(IBaseFilter* This,
+				       /* [in] */ IReferenceClock *pClock);
+    HRESULT STDCALL ( *GetSyncSource )(IBaseFilter* This,
+				       /* [out] */ IReferenceClock **pClock);
+    HRESULT STDCALL ( *EnumPins )(IBaseFilter* This,
+				  /* [out] */ IEnumPins **ppEnum);
+    HRESULT STDCALL ( *FindPin )(IBaseFilter* This,
+				 /* [string][in] */ const unsigned short* Id,
+				 /* [out] */ IPin** ppPin);
+    HRESULT STDCALL ( *QueryFilterInfo )(IBaseFilter* This,
+					 // /* [out] */ FILTER_INFO *pInfo);
+					 void* pInfo);
+    HRESULT STDCALL ( *JoinFilterGraph )(IBaseFilter* This,
+					 /* [in] */ IFilterGraph* pGraph,
+					 /* [string][in] */ const unsigned short* pName);
+    HRESULT STDCALL ( *QueryVendorInfo )(IBaseFilter* This,
+					 /* [string][out] */ unsigned short** pVendorInfo);
+} IBaseFilter_vt;
+struct _IBaseFilter { struct IBaseFilter_vt* vt; };
 
 
-struct IMemInputPin_vt: IUnknown_vt
+
+typedef struct _IMemAllocator IMemAllocator;
+typedef struct IMemAllocator_vt
 {
+    INHERIT_IUNKNOWN();
+
+    HRESULT STDCALL ( *SetProperties )(IMemAllocator* This,
+				       /* [in] */ ALLOCATOR_PROPERTIES *pRequest,
+				       /* [out] */ ALLOCATOR_PROPERTIES *pActual);
+    HRESULT STDCALL ( *GetProperties )(IMemAllocator* This,
+				       /* [out] */ ALLOCATOR_PROPERTIES *pProps);
+    HRESULT STDCALL ( *Commit )(IMemAllocator* This);
+    HRESULT STDCALL ( *Decommit )(IMemAllocator* This);
+    HRESULT STDCALL ( *GetBuffer )(IMemAllocator* This,
+				   /* [out] */ IMediaSample** ppBuffer,
+				   /* [in] */ REFERENCE_TIME* pStartTime,
+				   /* [in] */ REFERENCE_TIME* pEndTime,
+				   /* [in] */ unsigned long dwFlags);
+    HRESULT STDCALL ( *ReleaseBuffer )(IMemAllocator* This,
+				       /* [in] */ IMediaSample* pBuffer);
+} IMemAllocator_vt;
+struct _IMemAllocator { IMemAllocator_vt* vt; };
+
+
+
+typedef struct _IMemInputPin IMemInputPin;
+typedef struct IMemInputPin_vt
+{
+    INHERIT_IUNKNOWN();
+
     HRESULT STDCALL ( *GetAllocator )(IMemInputPin * This,
 				      /* [out] */ IMemAllocator **ppAllocator);
     HRESULT STDCALL ( *NotifyAllocator )(IMemInputPin * This,
@@ -174,114 +218,69 @@
 					 /* [in] */ long nSamples,
 					 /* [out] */ long *nSamplesProcessed);
     HRESULT STDCALL ( *ReceiveCanBlock )(IMemInputPin * This);
-};
-
-struct IMemInputPin
-{
-    IMemInputPin_vt *vt;
-};
+} IMemInputPin_vt;
+struct _IMemInputPin { IMemInputPin_vt* vt; };
 
 
-struct IMemAllocator_vt: IUnknown_vt
+typedef struct _IHidden IHidden;
+typedef struct IHidden_vt
 {
-    HRESULT STDCALL ( *SetProperties )(IMemAllocator * This,
-				       /* [in] */ ALLOCATOR_PROPERTIES *pRequest,
-				       /* [out] */ ALLOCATOR_PROPERTIES *pActual);
-    HRESULT STDCALL ( *GetProperties )(IMemAllocator * This,
-				       /* [out] */ ALLOCATOR_PROPERTIES *pProps);
-    HRESULT STDCALL ( *Commit )(IMemAllocator * This);
-    HRESULT STDCALL ( *Decommit )(IMemAllocator * This);
-    HRESULT STDCALL ( *GetBuffer )(IMemAllocator * This,
-				   /* [out] */ IMediaSample **ppBuffer,
-				   /* [in] */ REFERENCE_TIME *pStartTime,
-				   /* [in] */ REFERENCE_TIME *pEndTime,
-				   /* [in] */ unsigned long dwFlags);
-    HRESULT STDCALL ( *ReleaseBuffer )(IMemAllocator * This,
-				       /* [in] */ IMediaSample *pBuffer);
-};
+    INHERIT_IUNKNOWN();
 
-struct IMemAllocator
-{
-    IMemAllocator_vt *vt;
-};
+    HRESULT STDCALL ( *GetSmth )(IHidden* This, int* pv);
+    HRESULT STDCALL ( *SetSmth )(IHidden* This, int v1, int v2);
+    HRESULT STDCALL ( *GetSmth2 )(IHidden* This, int* pv);
+    HRESULT STDCALL ( *SetSmth2 )(IHidden* This, int v1, int v2);
+    HRESULT STDCALL ( *GetSmth3 )(IHidden* This, int* pv);
+    HRESULT STDCALL ( *SetSmth3 )(IHidden* This, int v1, int v2);
+    HRESULT STDCALL ( *GetSmth4 )(IHidden* This, int* pv);
+    HRESULT STDCALL ( *SetSmth4 )(IHidden* This, int v1, int v2);
+    HRESULT STDCALL ( *GetSmth5 )(IHidden* This, int* pv);
+    HRESULT STDCALL ( *SetSmth5 )(IHidden* This, int v1, int v2);
+    HRESULT STDCALL ( *GetSmth6 )(IHidden* This, int* pv);
+} IHidden_vt;
+struct _IHidden { struct IHidden_vt* vt; };
 
 
-struct IMediaSample_vt: IUnknown_vt
+typedef struct _IHidden2 IHidden2;
+typedef struct IHidden2_vt
 {
-    HRESULT STDCALL ( *GetPointer )(IMediaSample * This,
-				    /* [out] */ unsigned char **ppBuffer);
-    long STDCALL ( *GetSize )(IMediaSample * This);
-    HRESULT STDCALL ( *GetTime )(IMediaSample * This,
-				 /* [out] */ REFERENCE_TIME *pTimeStart,
-				 /* [out] */ REFERENCE_TIME *pTimeEnd);
-    HRESULT STDCALL ( *SetTime )(IMediaSample * This,
-				 /* [in] */ REFERENCE_TIME *pTimeStart,
-				 /* [in] */ REFERENCE_TIME *pTimeEnd);
-    HRESULT STDCALL ( *IsSyncPoint )(IMediaSample * This);
-    HRESULT STDCALL ( *SetSyncPoint )(IMediaSample * This,
-				      long bIsSyncPoint);
-    HRESULT STDCALL ( *IsPreroll )(IMediaSample * This);
-    HRESULT STDCALL ( *SetPreroll )(IMediaSample * This,
-				    long bIsPreroll);
-    long STDCALL ( *GetActualDataLength )(IMediaSample * This);
-    HRESULT STDCALL ( *SetActualDataLength )(IMediaSample * This,
-					     long __MIDL_0010);
-    HRESULT STDCALL ( *GetMediaType )(IMediaSample * This,
-				      AM_MEDIA_TYPE **ppMediaType);
-    HRESULT STDCALL ( *SetMediaType )(IMediaSample * This,
-				      AM_MEDIA_TYPE *pMediaType);
-    HRESULT STDCALL ( *IsDiscontinuity )(IMediaSample * This);
-    HRESULT STDCALL ( *SetDiscontinuity )(IMediaSample * This,
-					  long bDiscontinuity);
-    HRESULT STDCALL ( *GetMediaTime )(IMediaSample * This,
-				      /* [out] */ long long *pTimeStart,
-				      /* [out] */ long long *pTimeEnd);
-    HRESULT STDCALL ( *SetMediaTime )(IMediaSample * This,
-				      /* [in] */ long long *pTimeStart,
-				      /* [in] */ long long *pTimeEnd);
-};
+    INHERIT_IUNKNOWN();
 
-struct IMediaSample
-{
-    struct IMediaSample_vt *vt;
-};
+    HRESULT STDCALL ( *unk1 )(void);
+    HRESULT STDCALL ( *unk2 )(void);
+    HRESULT STDCALL ( *unk3 )(void);
+    HRESULT STDCALL ( *DecodeGet )(IHidden2* This, int* region);
+    HRESULT STDCALL ( *unk5 )(void);
+    HRESULT STDCALL ( *DecodeSet )(IHidden2* This, int* region);
+    HRESULT STDCALL ( *unk7 )(void);
+    HRESULT STDCALL ( *unk8 )(void);
+} IHidden2_vt;
+struct _IHidden2 { struct IHidden2_vt* vt; };
 
 
-struct IHidden_vt: IUnknown_vt
-{
-    HRESULT STDCALL ( *GetSmth )(IHidden * This, int* pv);
-    HRESULT STDCALL ( *SetSmth )(IHidden * This, int v1, int v2);
-    HRESULT STDCALL ( *GetSmth2 )(IHidden * This, int* pv);
-    HRESULT STDCALL ( *SetSmth2 )(IHidden * This, int v1, int v2);
-    HRESULT STDCALL ( *GetSmth3 )(IHidden * This, int* pv);
-    HRESULT STDCALL ( *SetSmth3 )(IHidden * This, int v1, int v2);
-    HRESULT STDCALL ( *GetSmth4 )(IHidden * This, int* pv);
-    HRESULT STDCALL ( *SetSmth4 )(IHidden * This, int v1, int v2);
-    HRESULT STDCALL ( *GetSmth5 )(IHidden * This, int* pv);
-    HRESULT STDCALL ( *SetSmth5 )(IHidden * This, int v1, int v2);
-    HRESULT STDCALL ( *GetSmth6 )(IHidden * This, int* pv);
-};
+// fixme
+typedef struct IDivxFilterInterface {
+    struct IDivxFilterInterface_vt* vt;
+} IDivxFilterInterface;
 
-struct IHidden
+struct IDivxFilterInterface_vt
 {
-    struct IHidden_vt *vt;
-};
+    INHERIT_IUNKNOWN();
 
-struct IHidden2_vt: IUnknown_vt
-{
-    HRESULT STDCALL (*unk1) ();
-    HRESULT STDCALL (*unk2) ();
-    HRESULT STDCALL (*unk3) ();
-    HRESULT STDCALL (*DecodeGet) (IHidden2* This, int* region);
-    HRESULT STDCALL (*unk5) ();
-    HRESULT STDCALL (*DecodeSet) (IHidden2* This, int* region);
-    HRESULT STDCALL (*unk7) ();
-    HRESULT STDCALL (*unk8) ();
-};
-
-struct IHidden2
-{
-    struct IHidden2_vt *vt;
+    HRESULT STDCALL ( *get_PPLevel )(IDivxFilterInterface* This, int* PPLevel); // current postprocessing level
+    HRESULT STDCALL ( *put_PPLevel )(IDivxFilterInterface* This, int PPLevel); // new postprocessing level
+    HRESULT STDCALL ( *put_DefaultPPLevel )(IDivxFilterInterface* This);
+    HRESULT STDCALL ( *put_MaxDelayAllowed )(IDivxFilterInterface* This, int maxdelayallowed);
+    HRESULT STDCALL ( *put_Brightness )(IDivxFilterInterface* This,  int brightness);
+    HRESULT STDCALL ( *put_Contrast )(IDivxFilterInterface* This,  int contrast);
+    HRESULT STDCALL ( *put_Saturation )(IDivxFilterInterface* This, int saturation);
+    HRESULT STDCALL ( *get_MaxDelayAllowed )(IDivxFilterInterface* This,  int* maxdelayallowed);
+    HRESULT STDCALL ( *get_Brightness)(IDivxFilterInterface* This, int* brightness);
+    HRESULT STDCALL ( *get_Contrast)(IDivxFilterInterface* This, int* contrast);
+    HRESULT STDCALL ( *get_Saturation )(IDivxFilterInterface* This, int* saturation);
+    HRESULT STDCALL ( *put_AspectRatio )(IDivxFilterInterface* This, int x, IDivxFilterInterface* Thisit, int y);
+    HRESULT STDCALL ( *get_AspectRatio )(IDivxFilterInterface* This, int* x, IDivxFilterInterface* Thisit, int* y);
 };
 
 #endif  /* DS_INTERFACES_H */
--- a/loader/dshow/iunk.h	Wed Nov 21 18:40:59 2001 +0000
+++ b/loader/dshow/iunk.h	Wed Nov 21 19:12:39 2001 +0000
@@ -1,48 +1,49 @@
 #ifndef DS_IUNK_H
 #define DS_IUNK_H
 
-#include "interfaces.h"
 #include "guids.h"
+#include <stdlib.h>
 
-#define DECLARE_IUNKNOWN(CLASSNAME) \
-    int refcount; \
-    static long STDCALL QueryInterface(IUnknown * This, GUID* riid, void **ppvObject); \
-    static long STDCALL AddRef (IUnknown * This); \
-    static long STDCALL Release (IUnknown * This); 
-    
+#define INHERIT_IUNKNOWN() \
+    long STDCALL ( *QueryInterface )(IUnknown * This, GUID* riid, void **ppvObject); \
+    long STDCALL ( *AddRef )(IUnknown * This); \
+    long STDCALL ( *Release )(IUnknown * This);
+
+#define DECLARE_IUNKNOWN() \
+    int refcount;
+
 #define IMPLEMENT_IUNKNOWN(CLASSNAME) 		\
-long STDCALL CLASSNAME ::QueryInterface(IUnknown * This, GUID* riid, void **ppvObject) \
+static long STDCALL CLASSNAME ## _QueryInterface(IUnknown * This, \
+					  GUID* riid, void **ppvObject) \
 { \
-    Debug printf(#CLASSNAME "::QueryInterface() called\n");\
-    if (!ppvObject) return 0x80004003; 		\
     CLASSNAME * me = (CLASSNAME *)This;		\
-    unsigned int i = 0;				\
-    for(const GUID* r=me->interfaces; i<sizeof(CLASSNAME ::interfaces)/sizeof(CLASSNAME ::interfaces[0]); r++, i++) \
-	if(!memcmp(r, riid, 16)) 		\
+    GUID* r; unsigned int i = 0;		\
+    Debug printf(#CLASSNAME "_QueryInterface(%p) called\n", This);\
+    if (!ppvObject) return 0x80004003; 		\
+    for(r=me->interfaces; i<sizeof(me->interfaces)/sizeof(me->interfaces[0]); r++, i++) \
+	if(!memcmp(r, riid, sizeof(*r)))	\
 	{ 					\
-	    This->vt->AddRef((IUnknown*)This); 	\
+	    me->vt->AddRef((IUnknown*)This); 	\
 	    *ppvObject=This; 			\
 	    return 0; 				\
 	} 					\
-    Debug printf("Failed\n");			\
+    Debug printf("Query failed!\n");		\
     return E_NOINTERFACE;			\
 } 						\
 						\
-long STDCALL CLASSNAME ::AddRef ( 		\
-    IUnknown * This) 				\
+static long STDCALL CLASSNAME ## _AddRef(IUnknown * This) \
 {						\
-    Debug printf(#CLASSNAME "::AddRef() called\n"); \
     CLASSNAME * me=( CLASSNAME *)This;		\
+    Debug printf(#CLASSNAME "_AddRef(%p) called (ref:%d)\n", This, me->refcount); \
     return ++(me->refcount); 			\
 }     						\
 						\
-long STDCALL CLASSNAME ::Release ( 		\
-    IUnknown * This) 				\
+static long STDCALL CLASSNAME ## _Release(IUnknown * This) \
 { 						\
-    Debug printf(#CLASSNAME "::Release() called\n"); \
     CLASSNAME* me=( CLASSNAME *)This;	 	\
-    if(--(me->refcount) ==0)			\
-		delete ( CLASSNAME *) This; 	\
+    Debug printf(#CLASSNAME "_Release(%p) called (new ref:%d)\n", This, me->refcount - 1); \
+    if(--(me->refcount) == 0)			\
+		CLASSNAME ## _Destroy(me); 	\
     return 0; 					\
 }
 
--- a/loader/dshow/outputpin.c	Wed Nov 21 18:40:59 2001 +0000
+++ b/loader/dshow/outputpin.c	Wed Nov 21 19:12:39 2001 +0000
@@ -1,39 +1,22 @@
-#include "outputpin.h"
-#include "allocator.h"
-#include "iunk.h"
+
 #include "wine/winerror.h"
-
-#include "stdio.h"
-//#include "string.h"
-
-//#include <cstdio>
-//#include <cstring>
+#include "wine/windef.h"
+#include "outputpin.h"
+#include <stdio.h>
+#include <string.h>
 
 /*
     An object beyond interface IEnumMediaTypes.
     Returned by COutputPin through call IPin::EnumMediaTypes().
 */
 
-using namespace std;
-
-class CEnumMediaTypes: public IEnumMediaTypes
+typedef struct CEnumMediaTypes
 {
-public:
+    IEnumMediaTypes_vt* vt;
     AM_MEDIA_TYPE type;
-    static GUID interfaces[];
-    DECLARE_IUNKNOWN(CEnumMediaTypes)
-    CEnumMediaTypes(const AM_MEDIA_TYPE&);
-    ~CEnumMediaTypes() {delete vt;}
-};
-
-GUID CEnumMediaTypes::interfaces[]=
-{
-    IID_IUnknown,
-    IID_IEnumMediaTypes,
-};
-
-// IPin->IUnknown methods
-IMPLEMENT_IUNKNOWN(CEnumMediaTypes)
+    GUID interfaces[2];
+    DECLARE_IUNKNOWN();
+} CEnumMediaTypes;
 
 
 static HRESULT STDCALL CEnumMediaTypes_Next(IEnumMediaTypes * This,
@@ -41,7 +24,7 @@
 					    /* [size_is][out] */ AM_MEDIA_TYPE **ppMediaTypes,
 					    /* [out] */ ULONG *pcFetched)
 {
-    AM_MEDIA_TYPE& type=((CEnumMediaTypes*)This)->type;
+    AM_MEDIA_TYPE* type = &((CEnumMediaTypes*)This)->type;
     Debug printf("CEnumMediaTypes::Next() called\n");
     if (!ppMediaTypes)
 	return E_INVALIDARG;
@@ -53,11 +36,12 @@
     if (pcFetched)
 	*pcFetched=1;
     ppMediaTypes[0] = (AM_MEDIA_TYPE *)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
-    memcpy(*ppMediaTypes, &type, sizeof(AM_MEDIA_TYPE));
+    // copy structures - C can handle this...
+    **ppMediaTypes = *type;
     if (ppMediaTypes[0]->pbFormat)
     {
 	ppMediaTypes[0]->pbFormat=(char *)CoTaskMemAlloc(ppMediaTypes[0]->cbFormat);
-	memcpy(ppMediaTypes[0]->pbFormat, type.pbFormat, ppMediaTypes[0]->cbFormat);
+	memcpy(ppMediaTypes[0]->pbFormat, type->pbFormat, ppMediaTypes[0]->cbFormat);
     }
     if (cMediaTypes == 1)
 	return 0;
@@ -85,72 +69,50 @@
     return E_NOTIMPL;
 }
 
-
-CEnumMediaTypes::CEnumMediaTypes(const AM_MEDIA_TYPE& amtype)
+void CEnumMediaTypes_Destroy(CEnumMediaTypes* This)
 {
-    refcount = 1;
-    type = amtype;
+    free(This->vt);
+    free(This);
+}
+
+// IPin->IUnknown methods
+IMPLEMENT_IUNKNOWN(CEnumMediaTypes)
 
-    vt = new IEnumMediaTypes_vt;
-    vt->QueryInterface = QueryInterface;
-    vt->AddRef = AddRef;
-    vt->Release = Release;
-    vt->Next = CEnumMediaTypes_Next;
-    vt->Skip = CEnumMediaTypes_Skip;
-    vt->Reset = CEnumMediaTypes_Reset;
-    vt->Clone = CEnumMediaTypes_Clone;
+CEnumMediaTypes* CEnumMediaTypesCreate(const AM_MEDIA_TYPE* amt)
+{
+    CEnumMediaTypes *This = (CEnumMediaTypes*) malloc(sizeof(CEnumMediaTypes)) ;
+    This->refcount = 1;
+    This->type = *amt;
+
+    This->vt = (IEnumMediaTypes_vt*) malloc(sizeof(IEnumMediaTypes_vt));
+    This->vt->QueryInterface = CEnumMediaTypes_QueryInterface;
+    This->vt->AddRef = CEnumMediaTypes_AddRef;
+    This->vt->Release = CEnumMediaTypes_Release;
+    This->vt->Next = CEnumMediaTypes_Next;
+    This->vt->Skip = CEnumMediaTypes_Skip;
+    This->vt->Reset = CEnumMediaTypes_Reset;
+    This->vt->Clone = CEnumMediaTypes_Clone;
+
+    This->interfaces[0] = IID_IUnknown;
+    This->interfaces[1] = IID_IEnumMediaTypes;
+
+    return This;
 }
 
 
-static HRESULT STDCALL COutputPin_AddRef(IUnknown* This)
-{
-    Debug printf("COutputPin_AddRef(%p) called (%d)\n",
-		 This, ((COutputPin*)This)->refcount);
-    ((COutputPin*)This)->refcount++;
-    return 0;
-}
-
-static HRESULT STDCALL COutputPin_Release(IUnknown* This)
-{
-    Debug printf("COutputPin_Release(%p) called (%d)\n",
-		 This, ((COutputPin*)This)->refcount);
-    if (--((COutputPin*)This)->refcount<=0)
-	delete (COutputPin*)This;
-
-    return 0;
-}
-
-static HRESULT STDCALL COutputPin_M_AddRef(IUnknown* This)
-{
-    COutputMemPin* p = (COutputMemPin*) This;
-    Debug printf("COutputPin_MAddRef(%p) called (%p,   %d)\n",
-		 p, p->parent, p->parent->refcount);
-    p->parent->refcount++;
-    return 0;
-}
-
-static HRESULT STDCALL COutputPin_M_Release(IUnknown* This)
-{
-    COutputMemPin* p = (COutputMemPin*) This;
-    Debug printf("COutputPin_MRelease(%p) called (%p,   %d)\n",
-		 p, p->parent, p->parent->refcount);
-    if (--p->parent->refcount <= 0)
-	delete p->parent;
-    return 0;
-}
-
-/* Implementation of output pin object. */
-// Constructor
+/*************
+ * COutputPin
+ *************/
 
 
 static HRESULT STDCALL COutputPin_QueryInterface(IUnknown* This, GUID* iid, void** ppv)
 {
+    COutputPin* p = (COutputPin*) This;
+
     Debug printf("COutputPin_QueryInterface(%p) called\n", This);
     if (!ppv)
 	return E_INVALIDARG;
 
-    COutputPin* p = (COutputPin*) This;
-
     if (memcmp(iid, &IID_IUnknown, 16) == 0)
     {
 	*ppv = p;
@@ -186,7 +148,7 @@
     {
 	pmt->pbFormat=CoTaskMemAlloc(pmt->cbFormat);
 	memcpy(pmt->pbFormat, ((COutputPin*)This)->type.pbFormat, pmt->cbFormat);
-    }	
+    }
 */
     //return E_NOTIMPL;
     return 0;// XXXXXXXXXXXXX CHECKME XXXXXXXXXXXXXXX
@@ -270,7 +232,7 @@
     Debug printf("COutputPin_EnumMediaTypes() called\n");
     if (!ppEnum)
 	return E_INVALIDARG;
-    *ppEnum=new CEnumMediaTypes(((COutputPin*)This)->type);
+    *ppEnum = (IEnumMediaTypes*) CEnumMediaTypesCreate(&((COutputPin*)This)->type);
     return 0;
 }
 
@@ -305,7 +267,7 @@
 				       /* [in] */ REFERENCE_TIME tStop,
 				       /* [in] */ double dRate)
 {
-    Debug printf("COutputPin_NewSegment(%ld,%ld,%f) called\n",
+    Debug printf("COutputPin_NewSegment(%Ld,%Ld,%f) called\n",
 		 tStart, tStop, dRate);
     return 0;
 }
@@ -316,11 +278,12 @@
 
 static HRESULT STDCALL COutputPin_M_QueryInterface(IUnknown* This, GUID* iid, void** ppv)
 {
-    Debug printf("COutputPin_M_QueryInterface() called\n");
+    COutputPin* p = (COutputPin*)This;
+
+    Debug printf("COutputPin_M_QueryInterface(%p) called\n", This);
     if (!ppv)
 	return E_INVALIDARG;
 
-    COutputPin* p = (COutputPin*)This;
     if(!memcmp(iid, &IID_IUnknown, 16))
     {
 	*ppv=p;
@@ -352,16 +315,16 @@
 
 // IMemInputPin methods
 
-static HRESULT STDCALL COutputPin_GetAllocator(IMemInputPin * This,
-					 /* [out] */ IMemAllocator **ppAllocator)
+static HRESULT STDCALL COutputPin_GetAllocator(IMemInputPin* This,
+					 /* [out] */ IMemAllocator** ppAllocator)
 {
     Debug printf("COutputPin_GetAllocator(%p, %p) called\n", This->vt, ppAllocator);
-    *ppAllocator=new MemAllocator;
+    *ppAllocator = (IMemAllocator*) MemAllocatorCreate();
     return 0;
 }
-    
-static HRESULT STDCALL COutputPin_NotifyAllocator(IMemInputPin * This,
-						  /* [in] */ IMemAllocator *pAllocator,
+
+static HRESULT STDCALL COutputPin_NotifyAllocator(IMemInputPin* This,
+						  /* [in] */ IMemAllocator* pAllocator,
 						  /* [in] */ int bReadOnly)
 {
     Debug printf("COutputPin_NotifyAllocator(%p, %p) called\n", This, pAllocator);
@@ -369,28 +332,30 @@
     return 0;
 }
 
-static HRESULT STDCALL COutputPin_GetAllocatorRequirements(IMemInputPin * This,
-							   /* [out] */ ALLOCATOR_PROPERTIES *pProps)
+static HRESULT STDCALL COutputPin_GetAllocatorRequirements(IMemInputPin* This,
+							   /* [out] */ ALLOCATOR_PROPERTIES* pProps)
 {
     Debug printf("COutputPin_GetAllocatorRequirements() called\n");
     return E_NOTIMPL;
 }
 
-static HRESULT STDCALL COutputPin_Receive(IMemInputPin * This,
-				    /* [in] */ IMediaSample *pSample)
+static HRESULT STDCALL COutputPin_Receive(IMemInputPin* This,
+					  /* [in] */ IMediaSample* pSample)
 {
+    COutputMemPin* mp = (COutputMemPin*)This;
+    char* pointer;
+    int len;
+
     Debug printf("COutputPin_Receive(%p) called\n", This);
     if (!pSample)
 	return E_INVALIDARG;
-    char* pointer;
-    if (pSample->vt->GetPointer(pSample, (BYTE **)&pointer))
+    if (pSample->vt->GetPointer(pSample, (BYTE**) &pointer))
 	return -1;
-    int len = pSample->vt->GetActualDataLength(pSample);
+    len = pSample->vt->GetActualDataLength(pSample);
     if (len == 0)
 	len = pSample->vt->GetSize(pSample);//for iv50
     //if(me.frame_pointer)memcpy(me.frame_pointer, pointer, len);
 
-    COutputMemPin* mp= (COutputMemPin*)This;
     if (mp->frame_pointer)
 	*(mp->frame_pointer) = pointer;
     if (mp->frame_size_pointer)
@@ -403,8 +368,9 @@
     fwrite(&((VIDEOINFOHEADER*)me.type.pbFormat)->bmiHeader, sizeof(BITMAPINFOHEADER), 1, file);
     fwrite(pointer, len, 1, file);
     fclose(file);
-*/    
+*/
 //    pSample->vt->Release((IUnknown*)pSample);
+
     return 0;
 }
 
@@ -423,49 +389,120 @@
     return E_NOTIMPL;
 }
 
-COutputPin::COutputPin(const AM_MEDIA_TYPE& vh)
-    :refcount(1), type(vh), remote(0)
+static void COutputPin_SetFramePointer(COutputPin* This, char** z)
+{
+    This->mempin->frame_pointer = z;
+}
+
+static void COutputPin_SetPointer2(COutputPin* This, char* p)
+{
+    if (This->mempin->pAllocator)
+        // fixme
+	This->mempin->pAllocator->SetPointer(This->mempin->pAllocator, p);
+}
+
+static void COutputPin_SetFrameSizePointer(COutputPin* This, long* z)
+{
+    This->mempin->frame_size_pointer = z;
+}
+
+static void COutputPin_SetNewFormat(COutputPin* This, const AM_MEDIA_TYPE* amt)
+{
+    This->type = *amt;
+}
+
+static void COutputPin_Destroy(COutputPin* This)
 {
-    vt = new IPin_vt;
-    vt->QueryInterface = COutputPin_QueryInterface;
-    vt->AddRef = COutputPin_AddRef;
-    vt->Release = COutputPin_Release;
-    vt->Connect = COutputPin_Connect;
-    vt->ReceiveConnection = COutputPin_ReceiveConnection;
-    vt->Disconnect = COutputPin_Disconnect;
-    vt->ConnectedTo = COutputPin_ConnectedTo;
-    vt->ConnectionMediaType = COutputPin_ConnectionMediaType;
-    vt->QueryPinInfo = COutputPin_QueryPinInfo;
-    vt->QueryDirection = COutputPin_QueryDirection;
-    vt->QueryId = COutputPin_QueryId;
-    vt->QueryAccept = COutputPin_QueryAccept;
-    vt->EnumMediaTypes = COutputPin_EnumMediaTypes;
-    vt->QueryInternalConnections = COutputPin_QueryInternalConnections;
-    vt->EndOfStream = COutputPin_EndOfStream;
-    vt->BeginFlush = COutputPin_BeginFlush;
-    vt->EndFlush = COutputPin_EndFlush;
-    vt->NewSegment = COutputPin_NewSegment;
+    free(This->vt);
+    free(This->mempin->vt);
+    free(This->mempin);
+    free(This);
+}
+
+static HRESULT STDCALL COutputPin_AddRef(IUnknown* This)
+{
+    Debug printf("COutputPin_AddRef(%p) called (%d)\n",
+		 This, ((COutputPin*)This)->refcount);
+    ((COutputPin*)This)->refcount++;
+    return 0;
+}
 
-    mempin = new COutputMemPin;
-    mempin->vt = new IMemInputPin_vt;
-    mempin->vt->QueryInterface = COutputPin_M_QueryInterface;
-    mempin->vt->AddRef = COutputPin_M_AddRef;
-    mempin->vt->Release = COutputPin_M_Release;
-    mempin->vt->GetAllocator = COutputPin_GetAllocator;
-    mempin->vt->NotifyAllocator = COutputPin_NotifyAllocator;
-    mempin->vt->GetAllocatorRequirements = COutputPin_GetAllocatorRequirements;
-    mempin->vt->Receive = COutputPin_Receive;
-    mempin->vt->ReceiveMultiple = COutputPin_ReceiveMultiple;
-    mempin->vt->ReceiveCanBlock = COutputPin_ReceiveCanBlock;
+static HRESULT STDCALL COutputPin_Release(IUnknown* This)
+{
+    Debug printf("COutputPin_Release(%p) called (%d)\n",
+		 This, ((COutputPin*)This)->refcount);
+    if (--((COutputPin*)This)->refcount<=0)
+	COutputPin_Destroy((COutputPin*)This);
 
-    mempin->frame_size_pointer = 0;
-    mempin->frame_pointer = 0;
-    mempin->pAllocator = 0;
-    mempin->parent = this;
+    return 0;
+}
+
+static HRESULT STDCALL COutputPin_M_AddRef(IUnknown* This)
+{
+    COutputMemPin* p = (COutputMemPin*) This;
+    Debug printf("COutputPin_MAddRef(%p) called (%p,   %d)\n",
+		 p, p->parent, p->parent->refcount);
+    p->parent->refcount++;
+    return 0;
 }
 
-COutputPin::~COutputPin()
+static HRESULT STDCALL COutputPin_M_Release(IUnknown* This)
+{
+    COutputMemPin* p = (COutputMemPin*) This;
+    Debug printf("COutputPin_MRelease(%p) called (%p,   %d)\n",
+		 p, p->parent, p->parent->refcount);
+    if (--p->parent->refcount <= 0)
+	COutputPin_Destroy(p->parent);
+    return 0;
+}
+
+COutputPin* COutputPinCreate(const AM_MEDIA_TYPE* amt)
 {
-    delete vt;
-    delete mempin->vt;
+    COutputPin* This = (COutputPin*) malloc(sizeof(COutputPin));
+    This->refcount = 1;
+    This->remote = 0;
+    This->type = *amt;
+    This->vt = (IPin_vt*) malloc(sizeof(IPin_vt));
+    This->vt->QueryInterface = COutputPin_QueryInterface;
+    This->vt->AddRef = COutputPin_AddRef;
+    This->vt->Release = COutputPin_Release;
+    This->vt->Connect = COutputPin_Connect;
+    This->vt->ReceiveConnection = COutputPin_ReceiveConnection;
+    This->vt->Disconnect = COutputPin_Disconnect;
+    This->vt->ConnectedTo = COutputPin_ConnectedTo;
+    This->vt->ConnectionMediaType = COutputPin_ConnectionMediaType;
+    This->vt->QueryPinInfo = COutputPin_QueryPinInfo;
+    This->vt->QueryDirection = COutputPin_QueryDirection;
+    This->vt->QueryId = COutputPin_QueryId;
+    This->vt->QueryAccept = COutputPin_QueryAccept;
+    This->vt->EnumMediaTypes = COutputPin_EnumMediaTypes;
+    This->vt->QueryInternalConnections = COutputPin_QueryInternalConnections;
+    This->vt->EndOfStream = COutputPin_EndOfStream;
+    This->vt->BeginFlush = COutputPin_BeginFlush;
+    This->vt->EndFlush = COutputPin_EndFlush;
+    This->vt->NewSegment = COutputPin_NewSegment;
+
+    This->mempin = (COutputMemPin*) malloc(sizeof(COutputMemPin));
+    This->mempin->vt = (IMemInputPin_vt*) malloc(sizeof(IMemInputPin_vt));
+    This->mempin->vt->QueryInterface = COutputPin_M_QueryInterface;
+    This->mempin->vt->AddRef = COutputPin_M_AddRef;
+    This->mempin->vt->Release = COutputPin_M_Release;
+    This->mempin->vt->GetAllocator = COutputPin_GetAllocator;
+    This->mempin->vt->NotifyAllocator = COutputPin_NotifyAllocator;
+    This->mempin->vt->GetAllocatorRequirements = COutputPin_GetAllocatorRequirements;
+    This->mempin->vt->Receive = COutputPin_Receive;
+    This->mempin->vt->ReceiveMultiple = COutputPin_ReceiveMultiple;
+    This->mempin->vt->ReceiveCanBlock = COutputPin_ReceiveCanBlock;
+
+    This->mempin->frame_size_pointer = 0;
+    This->mempin->frame_pointer = 0;
+    This->mempin->pAllocator = 0;
+    This->mempin->parent = This;
+
+    This->SetPointer2 = COutputPin_SetPointer2;
+    This->SetFramePointer = COutputPin_SetFramePointer;
+    This->SetFrameSizePointer = COutputPin_SetFrameSizePointer;
+    This->SetNewFormat = COutputPin_SetNewFormat;
+
+    return This;
 }
--- a/loader/dshow/outputpin.h	Wed Nov 21 18:40:59 2001 +0000
+++ b/loader/dshow/outputpin.h	Wed Nov 21 19:12:39 2001 +0000
@@ -3,35 +3,33 @@
 
 /* "output pin" - the one that connects to output of filter. */
 
-#include "interfaces.h"
-#include "guids.h"
 #include "allocator.h"
 
-struct COutputPin;
+typedef struct _COutputPin COutputPin;
 
-struct COutputMemPin : public IMemInputPin
+typedef struct _COutputMemPin COutputMemPin;
+struct _COutputMemPin
 {
+    IMemInputPin_vt* vt;
     char** frame_pointer;
     long* frame_size_pointer;
     MemAllocator* pAllocator;
     COutputPin* parent;
 };
 
-struct COutputPin : public IPin
+struct _COutputPin
 {
+    IPin_vt* vt;
     COutputMemPin* mempin;
     int refcount;
     AM_MEDIA_TYPE type;
     IPin* remote;
-    COutputPin(const AM_MEDIA_TYPE& vhdr);
-    ~COutputPin();
-    void SetFramePointer(char** z) { mempin->frame_pointer = z; }
-    void SetPointer2(char* p) {
-	if (mempin->pAllocator)
-	    mempin->pAllocator->SetPointer(p);
-    }
-    void SetFrameSizePointer(long* z) { mempin->frame_size_pointer = z; }
-    void SetNewFormat(const AM_MEDIA_TYPE& a) { type = a; }
+    void ( *SetFramePointer )(COutputPin*, char** z);
+    void ( *SetPointer2 )(COutputPin*, char* p);
+    void ( *SetFrameSizePointer )(COutputPin*, long* z);
+    void ( *SetNewFormat )(COutputPin*, const AM_MEDIA_TYPE* a);
 };
 
+COutputPin* COutputPinCreate(const AM_MEDIA_TYPE* vhdr);
+
 #endif /* DS_OUTPUTPIN_H */