From 855d6e8644e2bb2b223a007d9ac5ad72dc4b0575 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Thu, 18 Aug 2016 09:55:39 +0000 Subject: [PATCH] [AVIFIL32] Sync with Wine Staging 1.9.16. CORE-11866 svn path=/trunk/; revision=72272 --- reactos/dll/win32/avifil32/api.c | 38 ------- reactos/dll/win32/avifil32/avifile_private.h | 1 - reactos/dll/win32/avifil32/editstream.c | 50 +++++++-- reactos/dll/win32/avifil32/factory.c | 111 ++++++++----------- reactos/dll/win32/avifil32/tmpfile.c | 2 +- reactos/media/doc/README.WINE | 2 +- 6 files changed, 94 insertions(+), 110 deletions(-) diff --git a/reactos/dll/win32/avifil32/api.c b/reactos/dll/win32/avifil32/api.c index 800793cfbc4..f3b474b5b6a 100644 --- a/reactos/dll/win32/avifil32/api.c +++ b/reactos/dll/win32/avifil32/api.c @@ -1959,44 +1959,6 @@ HRESULT WINAPI AVISaveVW(LPCWSTR szFile, CLSID *pclsidHandler, return hres; } -/*********************************************************************** - * CreateEditableStream (AVIFIL32.@) - */ -HRESULT WINAPI CreateEditableStream(PAVISTREAM *ppEditable, PAVISTREAM pSource) -{ - IAVIEditStream *pEdit = NULL; - HRESULT hr; - - TRACE("(%p,%p)\n", ppEditable, pSource); - - if (ppEditable == NULL) - return AVIERR_BADPARAM; - - *ppEditable = NULL; - - if (pSource != NULL) { - hr = IAVIStream_QueryInterface(pSource, &IID_IAVIEditStream, - (LPVOID*)&pEdit); - if (SUCCEEDED(hr) && pEdit != NULL) { - hr = IAVIEditStream_Clone(pEdit, ppEditable); - IAVIEditStream_Release(pEdit); - - return hr; - } - } - - /* need own implementation of IAVIEditStream */ - pEdit = AVIFILE_CreateEditStream(pSource); - if (pEdit == NULL) - return AVIERR_MEMORY; - - hr = IAVIEditStream_QueryInterface(pEdit, &IID_IAVIStream, - (LPVOID*)ppEditable); - IAVIEditStream_Release(pEdit); - - return hr; -} - /*********************************************************************** * EditStreamClone (AVIFIL32.@) */ diff --git a/reactos/dll/win32/avifil32/avifile_private.h b/reactos/dll/win32/avifil32/avifile_private.h index 95d350cb7f2..cf03c2572ef 100644 --- a/reactos/dll/win32/avifil32/avifile_private.h +++ b/reactos/dll/win32/avifil32/avifile_private.h @@ -65,7 +65,6 @@ extern HRESULT AVIFILE_CreateAVIFile(IUnknown *pUnkOuter, REFIID riid, LPVOID *p extern HRESULT AVIFILE_CreateWAVFile(IUnknown *outer_unk, REFIID riid, void **ret_iface) DECLSPEC_HIDDEN; extern HRESULT AVIFILE_CreateACMStream(REFIID riid, LPVOID *ppobj) DECLSPEC_HIDDEN; extern HRESULT AVIFILE_CreateICMStream(REFIID riid, LPVOID *ppobj) DECLSPEC_HIDDEN; -extern PAVIEDITSTREAM AVIFILE_CreateEditStream(PAVISTREAM pstream) DECLSPEC_HIDDEN; extern PGETFRAME AVIFILE_CreateGetFrame(PAVISTREAM pstream) DECLSPEC_HIDDEN; extern PAVIFILE AVIFILE_CreateAVITempFile(int nStreams, const PAVISTREAM *ppStreams) DECLSPEC_HIDDEN; diff --git a/reactos/dll/win32/avifil32/editstream.c b/reactos/dll/win32/avifil32/editstream.c index f53835d6fd1..f763179fae9 100644 --- a/reactos/dll/win32/avifil32/editstream.c +++ b/reactos/dll/win32/avifil32/editstream.c @@ -53,6 +53,8 @@ struct _IAVIEditStreamImpl { LPBITMAPINFOHEADER lpFrame; /* frame of pCurStream */ }; +static IAVIEditStreamImpl *AVIFILE_CreateEditStream(IAVIStream *stream); + static inline IAVIEditStreamImpl *impl_from_IAVIEditStream(IAVIEditStream *iface) { return CONTAINING_RECORD(iface, IAVIEditStreamImpl, IAVIEditStream_iface); @@ -381,15 +383,15 @@ static HRESULT WINAPI IAVIEditStream_fnCopy(IAVIEditStream*iface,LONG*plStart, *(LPDWORD)plLength = This->sInfo.dwStart + This->sInfo.dwLength - *(LPDWORD)plStart; - pEdit = (IAVIEditStreamImpl*)AVIFILE_CreateEditStream(NULL); + pEdit = AVIFILE_CreateEditStream(NULL); if (pEdit == NULL) return AVIERR_MEMORY; - hr = IAVIEditStream_Paste((PAVIEDITSTREAM)pEdit, &start, plLength, &This->IAVIStream_iface, + hr = IAVIEditStream_Paste(&pEdit->IAVIEditStream_iface, &start, plLength, &This->IAVIStream_iface, *plStart, *plStart + *plLength); *plStart = start; if (FAILED(hr)) - IAVIEditStream_Release((PAVIEDITSTREAM)pEdit); + IAVIEditStream_Release(&pEdit->IAVIEditStream_iface); else *ppResult = &This->IAVIStream_iface; @@ -597,7 +599,7 @@ static HRESULT WINAPI IAVIEditStream_fnClone(IAVIEditStream*iface, return AVIERR_BADPARAM; *ppResult = NULL; - pEdit = (IAVIEditStreamImpl*)AVIFILE_CreateEditStream(NULL); + pEdit = AVIFILE_CreateEditStream(NULL); if (pEdit == NULL) return AVIERR_MEMORY; if (This->nStreams > pEdit->nTableSize) { @@ -638,7 +640,7 @@ static HRESULT WINAPI IAVIEditStream_fnSetInfo(IAVIEditStream*iface, This->sInfo.dwRate = asi->dwRate; This->sInfo.dwScale = asi->dwScale; This->sInfo.dwQuality = asi->dwQuality; - CopyRect(&This->sInfo.rcFrame, &asi->rcFrame); + This->sInfo.rcFrame = asi->rcFrame; memcpy(This->sInfo.szName, asi->szName, sizeof(asi->szName)); This->sInfo.dwEditCount++; @@ -988,7 +990,7 @@ static const struct IAVIStreamVtbl ieditstast = { IEditAVIStream_fnSetInfo }; -PAVIEDITSTREAM AVIFILE_CreateEditStream(PAVISTREAM pstream) +static IAVIEditStreamImpl *AVIFILE_CreateEditStream(IAVIStream *pstream) { IAVIEditStreamImpl *pedit = NULL; @@ -1002,5 +1004,39 @@ PAVIEDITSTREAM AVIFILE_CreateEditStream(PAVISTREAM pstream) IAVIStream_Create(&pedit->IAVIStream_iface, (LPARAM)pstream, 0); - return (PAVIEDITSTREAM)pedit; + return pedit; +} + +/*********************************************************************** + * CreateEditableStream (AVIFIL32.@) + */ +HRESULT WINAPI CreateEditableStream(IAVIStream **editable, IAVIStream *src) +{ + IAVIEditStream *edit = NULL; + IAVIEditStreamImpl *editobj; + HRESULT hr; + + TRACE("(%p,%p)\n", editable, src); + + if (!editable) + return AVIERR_BADPARAM; + *editable = NULL; + + if (src) { + hr = IAVIStream_QueryInterface(src, &IID_IAVIEditStream, (void**)&edit); + if (SUCCEEDED(hr) && edit) { + hr = IAVIEditStream_Clone(edit, editable); + IAVIEditStream_Release(edit); + + return hr; + } + } + + /* Need own implementation of IAVIEditStream */ + editobj = AVIFILE_CreateEditStream(src); + if (!editobj) + return AVIERR_MEMORY; + *editable = &editobj->IAVIStream_iface; + + return S_OK; } diff --git a/reactos/dll/win32/avifil32/factory.c b/reactos/dll/win32/avifil32/factory.c index 5e939cf49e4..0ef0e338a98 100644 --- a/reactos/dll/win32/avifil32/factory.c +++ b/reactos/dll/win32/avifil32/factory.c @@ -25,27 +25,11 @@ HMODULE AVIFILE_hModule = NULL; static BOOL AVIFILE_bLocked; static UINT AVIFILE_uUseCount; -static HRESULT WINAPI IClassFactory_fnQueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj); -static ULONG WINAPI IClassFactory_fnAddRef(LPCLASSFACTORY iface); -static ULONG WINAPI IClassFactory_fnRelease(LPCLASSFACTORY iface); -static HRESULT WINAPI IClassFactory_fnCreateInstance(LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj); -static HRESULT WINAPI IClassFactory_fnLockServer(LPCLASSFACTORY iface,BOOL dolock); - -static const IClassFactoryVtbl iclassfact = { - IClassFactory_fnQueryInterface, - IClassFactory_fnAddRef, - IClassFactory_fnRelease, - IClassFactory_fnCreateInstance, - IClassFactory_fnLockServer -}; - typedef struct { - /* IUnknown fields */ IClassFactory IClassFactory_iface; - DWORD dwRef; - - CLSID clsid; + LONG ref; + CLSID clsid; } IClassFactoryImpl; static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface) @@ -53,35 +37,10 @@ static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface) return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface); } -static HRESULT AVIFILE_CreateClassFactory(const CLSID *pclsid, const IID *riid, - LPVOID *ppv) +static HRESULT WINAPI IClassFactory_fnQueryInterface(IClassFactory *iface, REFIID riid, + void **ppobj) { - IClassFactoryImpl *pClassFactory = NULL; - HRESULT hr; - - *ppv = NULL; - - pClassFactory = HeapAlloc(GetProcessHeap(), 0, sizeof(*pClassFactory)); - if (pClassFactory == NULL) - return E_OUTOFMEMORY; - - pClassFactory->IClassFactory_iface.lpVtbl = &iclassfact; - pClassFactory->dwRef = 0; - pClassFactory->clsid = *pclsid; - - hr = IClassFactory_QueryInterface(&pClassFactory->IClassFactory_iface, riid, ppv); - if (FAILED(hr)) { - HeapFree(GetProcessHeap(), 0, pClassFactory); - *ppv = NULL; - } - - return hr; -} - -static HRESULT WINAPI IClassFactory_fnQueryInterface(LPCLASSFACTORY iface, - REFIID riid,LPVOID *ppobj) -{ - TRACE("(%p,%p,%p)\n", iface, riid, ppobj); + TRACE("(%p,%s,%p)\n", iface, debugstr_guid(riid), ppobj); if ((IsEqualGUID(&IID_IUnknown, riid)) || (IsEqualGUID(&IID_IClassFactory, riid))) { @@ -93,31 +52,30 @@ static HRESULT WINAPI IClassFactory_fnQueryInterface(LPCLASSFACTORY iface, return E_NOINTERFACE; } -static ULONG WINAPI IClassFactory_fnAddRef(LPCLASSFACTORY iface) +static ULONG WINAPI IClassFactory_fnAddRef(IClassFactory *iface) { - IClassFactoryImpl *This = impl_from_IClassFactory(iface); + IClassFactoryImpl *This = impl_from_IClassFactory(iface); + ULONG ref = InterlockedIncrement(&This->ref); - TRACE("(%p)\n", iface); - - return ++(This->dwRef); + TRACE("(%p) ref = %u\n", This, ref); + return ref; } -static ULONG WINAPI IClassFactory_fnRelease(LPCLASSFACTORY iface) +static ULONG WINAPI IClassFactory_fnRelease(IClassFactory *iface) { - IClassFactoryImpl *This = impl_from_IClassFactory(iface); + IClassFactoryImpl *This = impl_from_IClassFactory(iface); + ULONG ref = InterlockedDecrement(&This->ref); - TRACE("(%p)\n", iface); - if ((--(This->dwRef)) > 0) - return This->dwRef; + TRACE("(%p) ref = %u\n", This, ref); - HeapFree(GetProcessHeap(), 0, This); + if(!ref) + HeapFree(GetProcessHeap(), 0, This); - return 0; + return ref; } -static HRESULT WINAPI IClassFactory_fnCreateInstance(LPCLASSFACTORY iface, - LPUNKNOWN pOuter, - REFIID riid,LPVOID *ppobj) +static HRESULT WINAPI IClassFactory_fnCreateInstance(IClassFactory *iface, IUnknown *pOuter, + REFIID riid, void **ppobj) { IClassFactoryImpl *This = impl_from_IClassFactory(iface); @@ -147,7 +105,7 @@ static HRESULT WINAPI IClassFactory_fnCreateInstance(LPCLASSFACTORY iface, return E_NOINTERFACE; } -static HRESULT WINAPI IClassFactory_fnLockServer(LPCLASSFACTORY iface,BOOL dolock) +static HRESULT WINAPI IClassFactory_fnLockServer(IClassFactory *iface, BOOL dolock) { TRACE("(%p,%d)\n",iface,dolock); @@ -156,6 +114,35 @@ static HRESULT WINAPI IClassFactory_fnLockServer(LPCLASSFACTORY iface,BOOL doloc return S_OK; } +static const IClassFactoryVtbl iclassfact = { + IClassFactory_fnQueryInterface, + IClassFactory_fnAddRef, + IClassFactory_fnRelease, + IClassFactory_fnCreateInstance, + IClassFactory_fnLockServer +}; + +static HRESULT AVIFILE_CreateClassFactory(const CLSID *clsid, const IID *riid, void **ppv) +{ + IClassFactoryImpl *cf; + HRESULT hr; + + *ppv = NULL; + + cf = HeapAlloc(GetProcessHeap(), 0, sizeof(*cf)); + if (!cf) + return E_OUTOFMEMORY; + + cf->IClassFactory_iface.lpVtbl = &iclassfact; + cf->ref = 1; + cf->clsid = *clsid; + + hr = IClassFactory_QueryInterface(&cf->IClassFactory_iface, riid, ppv); + IClassFactory_Release(&cf->IClassFactory_iface); + + return hr; +} + LPCWSTR AVIFILE_BasenameW(LPCWSTR szPath) { #define SLASH(w) ((w) == '/' || (w) == '\\') diff --git a/reactos/dll/win32/avifil32/tmpfile.c b/reactos/dll/win32/avifil32/tmpfile.c index c1ffdd66318..288d7a4a8bb 100644 --- a/reactos/dll/win32/avifil32/tmpfile.c +++ b/reactos/dll/win32/avifil32/tmpfile.c @@ -260,5 +260,5 @@ PAVIFILE AVIFILE_CreateAVITempFile(int nStreams, const PAVISTREAM *ppStreams) } } - return (PAVIFILE)tmpFile; + return &tmpFile->IAVIFile_iface; } diff --git a/reactos/media/doc/README.WINE b/reactos/media/doc/README.WINE index 0785a37046c..4bea8dd0d7f 100644 --- a/reactos/media/doc/README.WINE +++ b/reactos/media/doc/README.WINE @@ -48,7 +48,7 @@ reactos/dll/win32/advpack # Synced to WineStaging-1.9.11 reactos/dll/win32/atl # Synced to WineStaging-1.9.16 reactos/dll/win32/atl80 # Synced to WineStaging-1.9.11 reactos/dll/win32/atl100 # Synced to WineStaging-1.9.11 -reactos/dll/win32/avifil32 # Synced to WineStaging-1.9.11 +reactos/dll/win32/avifil32 # Synced to WineStaging-1.9.16 reactos/dll/win32/bcrypt # Synced to WineStaging-1.9.4 reactos/dll/win32/browseui # Out of sync reactos/dll/win32/cabinet # Synced to WineStaging-1.9.11