Commit 2a14c4e8 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

avifil32: Use ifaces instead of vtbl pointers in IAVIEditStreamImpl.

parent 6ad10335
...@@ -122,11 +122,10 @@ static const struct IAVIStreamVtbl ieditstast = { ...@@ -122,11 +122,10 @@ static const struct IAVIStreamVtbl ieditstast = {
typedef struct _IAVIEditStreamImpl IAVIEditStreamImpl; typedef struct _IAVIEditStreamImpl IAVIEditStreamImpl;
struct _IAVIEditStreamImpl { struct _IAVIEditStreamImpl {
/* IUnknown stuff */ IAVIEditStream IAVIEditStream_iface;
const IAVIEditStreamVtbl *lpVtbl; IAVIStream IAVIStream_iface;
const IAVIStreamVtbl *lpVtblAVIStream;
LONG ref; LONG ref;
AVISTREAMINFOW sInfo; AVISTREAMINFOW sInfo;
...@@ -140,14 +139,14 @@ struct _IAVIEditStreamImpl { ...@@ -140,14 +139,14 @@ struct _IAVIEditStreamImpl {
LPBITMAPINFOHEADER lpFrame; /* frame of pCurStream */ LPBITMAPINFOHEADER lpFrame; /* frame of pCurStream */
}; };
static inline IAVIEditStreamImpl *impl_from_IAVIStream( IAVIStream *iface ) static inline IAVIEditStreamImpl *impl_from_IAVIEditStream(IAVIEditStream *iface)
{ {
return (IAVIEditStreamImpl *)((char*)iface - FIELD_OFFSET(IAVIEditStreamImpl, lpVtblAVIStream)); return CONTAINING_RECORD(iface, IAVIEditStreamImpl, IAVIEditStream_iface);
} }
static inline IAVIStream *IAVIStream_from_impl( IAVIEditStreamImpl *impl ) static inline IAVIEditStreamImpl *impl_from_IAVIStream(IAVIStream *iface)
{ {
return (IAVIStream *)&impl->lpVtblAVIStream; return CONTAINING_RECORD(iface, IAVIEditStreamImpl, IAVIStream_iface);
} }
/***********************************************************************/ /***********************************************************************/
...@@ -160,11 +159,11 @@ PAVIEDITSTREAM AVIFILE_CreateEditStream(PAVISTREAM pstream) ...@@ -160,11 +159,11 @@ PAVIEDITSTREAM AVIFILE_CreateEditStream(PAVISTREAM pstream)
if (pedit == NULL) if (pedit == NULL)
return NULL; return NULL;
pedit->lpVtbl = &ieditstream; pedit->IAVIEditStream_iface.lpVtbl = &ieditstream;
pedit->lpVtblAVIStream = &ieditstast; pedit->IAVIStream_iface.lpVtbl = &ieditstast;
pedit->ref = 1; pedit->ref = 1;
IAVIStream_Create( IAVIStream_from_impl( pedit ),(LPARAM)pstream,0); IAVIStream_Create(&pedit->IAVIStream_iface, (LPARAM)pstream, 0);
return (PAVIEDITSTREAM)pedit; return (PAVIEDITSTREAM)pedit;
} }
...@@ -316,7 +315,7 @@ static BOOL AVIFILE_FormatsEqual(PAVISTREAM avi1, PAVISTREAM avi2) ...@@ -316,7 +315,7 @@ static BOOL AVIFILE_FormatsEqual(PAVISTREAM avi1, PAVISTREAM avi2)
static HRESULT WINAPI IAVIEditStream_fnQueryInterface(IAVIEditStream*iface,REFIID refiid,LPVOID *obj) static HRESULT WINAPI IAVIEditStream_fnQueryInterface(IAVIEditStream*iface,REFIID refiid,LPVOID *obj)
{ {
IAVIEditStreamImpl *This = (IAVIEditStreamImpl *)iface; IAVIEditStreamImpl *This = impl_from_IAVIEditStream(iface);
TRACE("(%p,%s,%p)\n", This, debugstr_guid(refiid), obj); TRACE("(%p,%s,%p)\n", This, debugstr_guid(refiid), obj);
...@@ -328,7 +327,7 @@ static HRESULT WINAPI IAVIEditStream_fnQueryInterface(IAVIEditStream*iface,REFII ...@@ -328,7 +327,7 @@ static HRESULT WINAPI IAVIEditStream_fnQueryInterface(IAVIEditStream*iface,REFII
return S_OK; return S_OK;
} else if (IsEqualGUID(&IID_IAVIStream, refiid)) { } else if (IsEqualGUID(&IID_IAVIStream, refiid)) {
*obj = IAVIStream_from_impl( This ); *obj = &This->IAVIStream_iface;
IAVIEditStream_AddRef(iface); IAVIEditStream_AddRef(iface);
return S_OK; return S_OK;
...@@ -339,7 +338,7 @@ static HRESULT WINAPI IAVIEditStream_fnQueryInterface(IAVIEditStream*iface,REFII ...@@ -339,7 +338,7 @@ static HRESULT WINAPI IAVIEditStream_fnQueryInterface(IAVIEditStream*iface,REFII
static ULONG WINAPI IAVIEditStream_fnAddRef(IAVIEditStream*iface) static ULONG WINAPI IAVIEditStream_fnAddRef(IAVIEditStream*iface)
{ {
IAVIEditStreamImpl *This = (IAVIEditStreamImpl *)iface; IAVIEditStreamImpl *This = impl_from_IAVIEditStream(iface);
ULONG ref = InterlockedIncrement(&This->ref); ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) -> %d\n", iface, ref); TRACE("(%p) -> %d\n", iface, ref);
...@@ -349,7 +348,7 @@ static ULONG WINAPI IAVIEditStream_fnAddRef(IAVIEditStream*iface) ...@@ -349,7 +348,7 @@ static ULONG WINAPI IAVIEditStream_fnAddRef(IAVIEditStream*iface)
static ULONG WINAPI IAVIEditStream_fnRelease(IAVIEditStream*iface) static ULONG WINAPI IAVIEditStream_fnRelease(IAVIEditStream*iface)
{ {
IAVIEditStreamImpl *This = (IAVIEditStreamImpl *)iface; IAVIEditStreamImpl *This = impl_from_IAVIEditStream(iface);
DWORD i; DWORD i;
ULONG ref = InterlockedDecrement(&This->ref); ULONG ref = InterlockedDecrement(&This->ref);
...@@ -376,7 +375,7 @@ static ULONG WINAPI IAVIEditStream_fnRelease(IAVIEditStream*iface) ...@@ -376,7 +375,7 @@ static ULONG WINAPI IAVIEditStream_fnRelease(IAVIEditStream*iface)
static HRESULT WINAPI IAVIEditStream_fnCut(IAVIEditStream*iface,LONG*plStart, static HRESULT WINAPI IAVIEditStream_fnCut(IAVIEditStream*iface,LONG*plStart,
LONG*plLength,PAVISTREAM*ppResult) LONG*plLength,PAVISTREAM*ppResult)
{ {
IAVIEditStreamImpl *This = (IAVIEditStreamImpl *)iface; IAVIEditStreamImpl *This = impl_from_IAVIEditStream(iface);
PAVISTREAM stream; PAVISTREAM stream;
DWORD start, len, streamPos, streamNr; DWORD start, len, streamPos, streamNr;
HRESULT hr; HRESULT hr;
...@@ -460,7 +459,7 @@ static HRESULT WINAPI IAVIEditStream_fnCut(IAVIEditStream*iface,LONG*plStart, ...@@ -460,7 +459,7 @@ static HRESULT WINAPI IAVIEditStream_fnCut(IAVIEditStream*iface,LONG*plStart,
static HRESULT WINAPI IAVIEditStream_fnCopy(IAVIEditStream*iface,LONG*plStart, static HRESULT WINAPI IAVIEditStream_fnCopy(IAVIEditStream*iface,LONG*plStart,
LONG*plLength,PAVISTREAM*ppResult) LONG*plLength,PAVISTREAM*ppResult)
{ {
IAVIEditStreamImpl *This = (IAVIEditStreamImpl *)iface; IAVIEditStreamImpl *This = impl_from_IAVIEditStream(iface);
IAVIEditStreamImpl* pEdit; IAVIEditStreamImpl* pEdit;
HRESULT hr; HRESULT hr;
LONG start = 0; LONG start = 0;
...@@ -490,14 +489,13 @@ static HRESULT WINAPI IAVIEditStream_fnCopy(IAVIEditStream*iface,LONG*plStart, ...@@ -490,14 +489,13 @@ static HRESULT WINAPI IAVIEditStream_fnCopy(IAVIEditStream*iface,LONG*plStart,
if (pEdit == NULL) if (pEdit == NULL)
return AVIERR_MEMORY; return AVIERR_MEMORY;
hr = IAVIEditStream_Paste((PAVIEDITSTREAM)pEdit,&start,plLength, hr = IAVIEditStream_Paste((PAVIEDITSTREAM)pEdit, &start, plLength, &This->IAVIStream_iface,
IAVIStream_from_impl( This ),*plStart, *plStart, *plStart + *plLength);
*plStart + *plLength);
*plStart = start; *plStart = start;
if (FAILED(hr)) if (FAILED(hr))
IAVIEditStream_Release((PAVIEDITSTREAM)pEdit); IAVIEditStream_Release((PAVIEDITSTREAM)pEdit);
else else
*ppResult = IAVIStream_from_impl( This ); *ppResult = &This->IAVIStream_iface;
return hr; return hr;
} }
...@@ -506,7 +504,7 @@ static HRESULT WINAPI IAVIEditStream_fnPaste(IAVIEditStream*iface,LONG*plStart, ...@@ -506,7 +504,7 @@ static HRESULT WINAPI IAVIEditStream_fnPaste(IAVIEditStream*iface,LONG*plStart,
LONG*plLength,PAVISTREAM pSource, LONG*plLength,PAVISTREAM pSource,
LONG lStart,LONG lLength) LONG lStart,LONG lLength)
{ {
IAVIEditStreamImpl *This = (IAVIEditStreamImpl *)iface; IAVIEditStreamImpl *This = impl_from_IAVIEditStream(iface);
AVISTREAMINFOW srcInfo; AVISTREAMINFOW srcInfo;
IAVIEditStreamImpl *pEdit = NULL; IAVIEditStreamImpl *pEdit = NULL;
PAVISTREAM pStream; PAVISTREAM pStream;
...@@ -552,7 +550,7 @@ static HRESULT WINAPI IAVIEditStream_fnPaste(IAVIEditStream*iface,LONG*plStart, ...@@ -552,7 +550,7 @@ static HRESULT WINAPI IAVIEditStream_fnPaste(IAVIEditStream*iface,LONG*plStart,
if (size != This->sInfo.rcFrame.bottom - This->sInfo.rcFrame.top) if (size != This->sInfo.rcFrame.bottom - This->sInfo.rcFrame.top)
return AVIERR_UNSUPPORTED; /* FIXME: Can't GetFrame convert it? */ return AVIERR_UNSUPPORTED; /* FIXME: Can't GetFrame convert it? */
} else if (srcInfo.fccType == streamtypeAUDIO) { } else if (srcInfo.fccType == streamtypeAUDIO) {
if (! AVIFILE_FormatsEqual(IAVIStream_from_impl( This ), pSource)) if (!AVIFILE_FormatsEqual(&This->IAVIStream_iface, pSource))
return AVIERR_UNSUPPORTED; return AVIERR_UNSUPPORTED;
} else { } else {
/* FIXME: streamtypeMIDI and streamtypeTEXT */ /* FIXME: streamtypeMIDI and streamtypeTEXT */
...@@ -561,7 +559,7 @@ static HRESULT WINAPI IAVIEditStream_fnPaste(IAVIEditStream*iface,LONG*plStart, ...@@ -561,7 +559,7 @@ static HRESULT WINAPI IAVIEditStream_fnPaste(IAVIEditStream*iface,LONG*plStart,
/* try to get an IEditStreamInternal interface */ /* try to get an IEditStreamInternal interface */
if (SUCCEEDED(IAVIStream_QueryInterface(pSource, &IID_IEditStreamInternal, (LPVOID*)&pEdit))) if (SUCCEEDED(IAVIStream_QueryInterface(pSource, &IID_IEditStreamInternal, (LPVOID*)&pEdit)))
IAVIEditStream_Release( (IAVIEditStream *)pEdit ); /* pSource holds a reference */ IAVIEditStream_Release(&pEdit->IAVIEditStream_iface); /* pSource holds a reference */
/* for video must check for change of format */ /* for video must check for change of format */
if (This->sInfo.fccType == streamtypeVIDEO) { if (This->sInfo.fccType == streamtypeVIDEO) {
...@@ -574,8 +572,8 @@ static HRESULT WINAPI IAVIEditStream_fnPaste(IAVIEditStream*iface,LONG*plStart, ...@@ -574,8 +572,8 @@ static HRESULT WINAPI IAVIEditStream_fnPaste(IAVIEditStream*iface,LONG*plStart,
*/ */
if ((pEdit != NULL && pEdit->bDecompress) || if ((pEdit != NULL && pEdit->bDecompress) ||
AVIStreamNearestKeyFrame(pSource, lStart) != lStart || AVIStreamNearestKeyFrame(pSource, lStart) != lStart ||
AVIStreamNearestKeyFrame(IAVIStream_from_impl( This ), *plStart) != *plStart || AVIStreamNearestKeyFrame(&This->IAVIStream_iface, *plStart) != *plStart ||
(This->nStreams > 0 && !AVIFILE_FormatsEqual(IAVIStream_from_impl( This ), pSource))) { (This->nStreams > 0 && !AVIFILE_FormatsEqual(&This->IAVIStream_iface, pSource))) {
/* Use first stream part to get format to convert everything to */ /* Use first stream part to get format to convert everything to */
AVIFILE_ReadFrame(This, This->pStreams[0].pStream, AVIFILE_ReadFrame(This, This->pStreams[0].pStream,
This->pStreams[0].dwStart); This->pStreams[0].dwStart);
...@@ -693,7 +691,7 @@ static HRESULT WINAPI IAVIEditStream_fnPaste(IAVIEditStream*iface,LONG*plStart, ...@@ -693,7 +691,7 @@ static HRESULT WINAPI IAVIEditStream_fnPaste(IAVIEditStream*iface,LONG*plStart,
static HRESULT WINAPI IAVIEditStream_fnClone(IAVIEditStream*iface, static HRESULT WINAPI IAVIEditStream_fnClone(IAVIEditStream*iface,
PAVISTREAM*ppResult) PAVISTREAM*ppResult)
{ {
IAVIEditStreamImpl *This = (IAVIEditStreamImpl *)iface; IAVIEditStreamImpl *This = impl_from_IAVIEditStream(iface);
IAVIEditStreamImpl* pEdit; IAVIEditStreamImpl* pEdit;
DWORD i; DWORD i;
...@@ -722,7 +720,7 @@ static HRESULT WINAPI IAVIEditStream_fnClone(IAVIEditStream*iface, ...@@ -722,7 +720,7 @@ static HRESULT WINAPI IAVIEditStream_fnClone(IAVIEditStream*iface,
IAVIStream_AddRef(pEdit->pStreams[i].pStream); IAVIStream_AddRef(pEdit->pStreams[i].pStream);
} }
*ppResult = IAVIStream_from_impl( This ); *ppResult = &This->IAVIStream_iface;
return AVIERR_OK; return AVIERR_OK;
} }
...@@ -730,7 +728,7 @@ static HRESULT WINAPI IAVIEditStream_fnClone(IAVIEditStream*iface, ...@@ -730,7 +728,7 @@ static HRESULT WINAPI IAVIEditStream_fnClone(IAVIEditStream*iface,
static HRESULT WINAPI IAVIEditStream_fnSetInfo(IAVIEditStream*iface, static HRESULT WINAPI IAVIEditStream_fnSetInfo(IAVIEditStream*iface,
LPAVISTREAMINFOW asi,LONG size) LPAVISTREAMINFOW asi,LONG size)
{ {
IAVIEditStreamImpl *This = (IAVIEditStreamImpl *)iface; IAVIEditStreamImpl *This = impl_from_IAVIEditStream(iface);
TRACE("(%p,%p,%d)\n",iface,asi,size); TRACE("(%p,%p,%d)\n",iface,asi,size);
...@@ -755,19 +753,19 @@ static HRESULT WINAPI IEditAVIStream_fnQueryInterface(IAVIStream*iface, ...@@ -755,19 +753,19 @@ static HRESULT WINAPI IEditAVIStream_fnQueryInterface(IAVIStream*iface,
REFIID refiid,LPVOID*obj) REFIID refiid,LPVOID*obj)
{ {
IAVIEditStreamImpl *This = impl_from_IAVIStream( iface ); IAVIEditStreamImpl *This = impl_from_IAVIStream( iface );
return IAVIEditStream_QueryInterface((IAVIEditStream *)This,refiid,obj); return IAVIEditStream_QueryInterface(&This->IAVIEditStream_iface,refiid,obj);
} }
static ULONG WINAPI IEditAVIStream_fnAddRef(IAVIStream*iface) static ULONG WINAPI IEditAVIStream_fnAddRef(IAVIStream*iface)
{ {
IAVIEditStreamImpl *This = impl_from_IAVIStream( iface ); IAVIEditStreamImpl *This = impl_from_IAVIStream( iface );
return IAVIEditStream_AddRef((IAVIEditStream*)This); return IAVIEditStream_AddRef(&This->IAVIEditStream_iface);
} }
static ULONG WINAPI IEditAVIStream_fnRelease(IAVIStream*iface) static ULONG WINAPI IEditAVIStream_fnRelease(IAVIStream*iface)
{ {
IAVIEditStreamImpl *This = impl_from_IAVIStream( iface ); IAVIEditStreamImpl *This = impl_from_IAVIStream( iface );
return IAVIEditStream_Release((IAVIEditStream*)This); return IAVIEditStream_Release(&This->IAVIEditStream_iface);
} }
static HRESULT WINAPI IEditAVIStream_fnCreate(IAVIStream*iface, static HRESULT WINAPI IEditAVIStream_fnCreate(IAVIStream*iface,
...@@ -1021,7 +1019,7 @@ static HRESULT WINAPI IEditAVIStream_fnDelete(IAVIStream*iface,LONG start, ...@@ -1021,7 +1019,7 @@ static HRESULT WINAPI IEditAVIStream_fnDelete(IAVIStream*iface,LONG start,
TRACE("(%p,%d,%d)\n",iface,start,samples); TRACE("(%p,%d,%d)\n",iface,start,samples);
return IAVIEditStream_Cut((IAVIEditStream*)This,&start,&samples,NULL); return IAVIEditStream_Cut(&This->IAVIEditStream_iface,&start,&samples,NULL);
} }
static HRESULT WINAPI IEditAVIStream_fnReadData(IAVIStream*iface,DWORD fcc, static HRESULT WINAPI IEditAVIStream_fnReadData(IAVIStream*iface,DWORD fcc,
...@@ -1063,5 +1061,5 @@ static HRESULT WINAPI IEditAVIStream_fnSetInfo(IAVIStream*iface, ...@@ -1063,5 +1061,5 @@ static HRESULT WINAPI IEditAVIStream_fnSetInfo(IAVIStream*iface,
TRACE("(%p,%p,%d)\n",iface,info,len); TRACE("(%p,%p,%d)\n",iface,info,len);
return IAVIEditStream_SetInfo((IAVIEditStream*)This,info,len); return IAVIEditStream_SetInfo(&This->IAVIEditStream_iface,info,len);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment