* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include <stdarg.h>
-
-#include "windef.h"
-#include "winbase.h"
-#include "wingdi.h"
-#include "winuser.h"
-#include "vfw.h"
-
#include "avifile_private.h"
-#include "wine/debug.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(avifile);
-
#ifndef DIBPTR
#define DIBPTR(lp) ((LPBYTE)(lp) + (lp)->biSize + \
(lp)->biClrUsed * sizeof(RGBQUAD))
/***********************************************************************/
-static HRESULT WINAPI IGetFrame_fnQueryInterface(IGetFrame *iface,
- REFIID refiid, LPVOID *obj);
-static ULONG WINAPI IGetFrame_fnAddRef(IGetFrame *iface);
-static ULONG WINAPI IGetFrame_fnRelease(IGetFrame *iface);
-static LPVOID WINAPI IGetFrame_fnGetFrame(IGetFrame *iface, LONG lPos);
-static HRESULT WINAPI IGetFrame_fnBegin(IGetFrame *iface, LONG lStart,
- LONG lEnd, LONG lRate);
-static HRESULT WINAPI IGetFrame_fnEnd(IGetFrame *iface);
-static HRESULT WINAPI IGetFrame_fnSetFormat(IGetFrame *iface,
- LPBITMAPINFOHEADER lpbi,
- LPVOID lpBits, INT x, INT y,
- INT dx, INT dy);
-
-static const struct IGetFrameVtbl igetframeVtbl = {
- IGetFrame_fnQueryInterface,
- IGetFrame_fnAddRef,
- IGetFrame_fnRelease,
- IGetFrame_fnGetFrame,
- IGetFrame_fnBegin,
- IGetFrame_fnEnd,
- IGetFrame_fnSetFormat
-};
-
typedef struct _IGetFrameImpl {
/* IUnknown stuff */
- const IGetFrameVtbl *lpVtbl;
+ IGetFrame IGetFrame_iface;
LONG ref;
/* IGetFrame stuff */
/***********************************************************************/
+static inline IGetFrameImpl *impl_from_IGetFrame(IGetFrame *iface)
+{
+ return CONTAINING_RECORD(iface, IGetFrameImpl, IGetFrame_iface);
+}
+
static void AVIFILE_CloseCompressor(IGetFrameImpl *This)
{
if (This->lpInFormat != This->lpOutFormat) {
}
}
-PGETFRAME AVIFILE_CreateGetFrame(PAVISTREAM pStream)
-{
- IGetFrameImpl *pg;
-
- /* check parameter */
- if (pStream == NULL)
- return NULL;
-
- pg = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IGetFrameImpl));
- if (pg != NULL) {
- pg->lpVtbl = &igetframeVtbl;
- pg->ref = 1;
- pg->lCurrentFrame = -1;
- pg->pStream = pStream;
- IAVIStream_AddRef(pStream);
- }
-
- return (PGETFRAME)pg;
-}
-
static HRESULT WINAPI IGetFrame_fnQueryInterface(IGetFrame *iface,
REFIID refiid, LPVOID *obj)
{
- IGetFrameImpl *This = (IGetFrameImpl *)iface;
+ IGetFrameImpl *This = impl_from_IGetFrame(iface);
TRACE("(%p,%s,%p)\n", This, debugstr_guid(refiid), obj);
static ULONG WINAPI IGetFrame_fnAddRef(IGetFrame *iface)
{
- IGetFrameImpl *This = (IGetFrameImpl *)iface;
+ IGetFrameImpl *This = impl_from_IGetFrame(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p)\n", iface);
static ULONG WINAPI IGetFrame_fnRelease(IGetFrame *iface)
{
- IGetFrameImpl *This = (IGetFrameImpl *)iface;
+ IGetFrameImpl *This = impl_from_IGetFrame(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p)\n", iface);
static LPVOID WINAPI IGetFrame_fnGetFrame(IGetFrame *iface, LONG lPos)
{
- IGetFrameImpl *This = (IGetFrameImpl *)iface;
+ IGetFrameImpl *This = impl_from_IGetFrame(iface);
LONG readBytes;
LONG readSamples;
if (FAILED(AVIStreamSampleSize(This->pStream, lNext, &readBytes)))
return NULL; /* bad thing, but bad things will happen */
if (readBytes <= 0) {
- ERR(": IAVIStream::REad doesn't return needed bytes!\n");
+ ERR(": IAVIStream::Read doesn't return needed bytes!\n");
return NULL;
}
static HRESULT WINAPI IGetFrame_fnBegin(IGetFrame *iface, LONG lStart,
LONG lEnd, LONG lRate)
{
- IGetFrameImpl *This = (IGetFrameImpl *)iface;
+ IGetFrameImpl *This = impl_from_IGetFrame(iface);
TRACE("(%p,%d,%d,%d)\n", iface, lStart, lEnd, lRate);
static HRESULT WINAPI IGetFrame_fnEnd(IGetFrame *iface)
{
- IGetFrameImpl *This = (IGetFrameImpl *)iface;
+ IGetFrameImpl *This = impl_from_IGetFrame(iface);
TRACE("(%p)\n", iface);
LPVOID lpBits, INT x, INT y,
INT dx, INT dy)
{
- IGetFrameImpl *This = (IGetFrameImpl *)iface;
+ IGetFrameImpl *This = impl_from_IGetFrame(iface);
AVISTREAMINFOW sInfo;
LPBITMAPINFOHEADER lpbi = lpbiWanted;
if (sInfo.fccType != streamtypeVIDEO)
return AVIERR_UNSUPPORTED;
- This->bFormatChanges =
- (sInfo.dwFlags & AVISTREAMINFO_FORMATCHANGES ? TRUE : FALSE );
+ This->bFormatChanges = (sInfo.dwFlags & AVISTREAMINFO_FORMATCHANGES) != 0;
This->dwFormatChangeCount = sInfo.dwFormatChangeCount;
This->dwEditCount = sInfo.dwEditCount;
This->lCurrentFrame = -1;
}
if (lpBits == NULL) {
- register DWORD size = This->lpOutFormat->biClrUsed * sizeof(RGBQUAD);
+ DWORD size = This->lpOutFormat->biClrUsed * sizeof(RGBQUAD);
size += This->lpOutFormat->biSize + This->lpOutFormat->biSizeImage;
This->lpOutFormat = HeapReAlloc(GetProcessHeap(), 0, This->lpOutFormat, size);
}
}
+static const struct IGetFrameVtbl igetframeVtbl = {
+ IGetFrame_fnQueryInterface,
+ IGetFrame_fnAddRef,
+ IGetFrame_fnRelease,
+ IGetFrame_fnGetFrame,
+ IGetFrame_fnBegin,
+ IGetFrame_fnEnd,
+ IGetFrame_fnSetFormat
+};
+
+PGETFRAME AVIFILE_CreateGetFrame(PAVISTREAM pStream)
+{
+ IGetFrameImpl *pg;
+
+ /* check parameter */
+ if (pStream == NULL)
+ return NULL;
+
+ pg = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IGetFrameImpl));
+ if (pg != NULL) {
+ pg->IGetFrame_iface.lpVtbl = &igetframeVtbl;
+ pg->ref = 1;
+ pg->lCurrentFrame = -1;
+ pg->pStream = pStream;
+ IAVIStream_AddRef(pStream);
+ }
+
+ return (PGETFRAME)pg;
+}
+
/***********************************************************************/