Commit 9f67cfef authored by Michael Günnewig's avatar Michael Günnewig Committed by Alexandre Julliard

- Fixed some signed/unsigned mismatches.

- Fixed bugs in AVISaveOptions dialog handling. - Fixed bug in AVIFILE_LoadFile -- now check for more than MAX_AVISTREAMS streams in file. - Implemented AVIMakeFileFromStreams and AVISaveVA method. - Added IAVIEditStream interface. - Implemented EditStream* methods. - Added stubs for AVISaveVW, CreateEditableStream. - Added stubs for clipboard handling.
parent 5caccaf6
......@@ -20,6 +20,7 @@ C_SRCS = \
factory.c \
getframe.c \
icmstream.c \
tmpfile.c \
wavfile.c
RC_SRCS = \
......
......@@ -279,9 +279,9 @@ static HRESULT WINAPI ACMStream_fnInfo(IAVIStream *iface,LPAVISTREAMINFOW psi,
return hr;
}
memcpy(psi, &This->sInfo, min(size, sizeof(This->sInfo)));
memcpy(psi, &This->sInfo, min(size, (LONG)sizeof(This->sInfo)));
if (size < sizeof(This->sInfo))
if (size < (LONG)sizeof(This->sInfo))
return AVIERR_BUFFERTOOSMALL;
return AVIERR_OK;
}
......@@ -402,7 +402,7 @@ static HRESULT WINAPI ACMStream_fnRead(IAVIStream *iface, LONG start,
ICOM_THIS(IAVIStreamImpl,iface);
HRESULT hr;
LONG size;
DWORD size;
TRACE("(%p,%ld,%ld,%p,%ld,%p,%p)\n", iface, start, samples, buffer,
buffersize, bytesread, samplesread);
......@@ -618,11 +618,11 @@ static HRESULT WINAPI ACMStream_fnDelete(IAVIStream *iface, LONG start,
return AVIERR_BADPARAM;
/* Delete before start of stream? */
if (start + samples < This->sInfo.dwStart)
if ((DWORD)(start + samples) < This->sInfo.dwStart)
return AVIERR_OK;
/* Delete after end of stream? */
if (start > This->sInfo.dwLength)
if ((DWORD)start > This->sInfo.dwLength)
return AVIERR_OK;
/* For the rest we need write capability */
......@@ -722,7 +722,7 @@ static HRESULT AVIFILE_OpenCompressor(IAVIStreamImpl *This)
This->sInfo.dwSampleSize = This->lpOutFormat->nBlockAlign;
This->sInfo.dwScale = This->lpOutFormat->nBlockAlign;
This->sInfo.dwRate = This->lpOutFormat->nAvgBytesPerSec;
This->sInfo.dwQuality = ICQUALITY_DEFAULT;
This->sInfo.dwQuality = (DWORD)ICQUALITY_DEFAULT;
SetRectEmpty(&This->sInfo.rcFrame);
/* convert positions ansd sizes to output format */
......
@ stub AVIBuildFilter
@ stdcall AVIBuildFilterA(str long long)
@ stdcall AVIBuildFilterW(wstr long long)
@ stub AVIClearClipboard
@ stdcall AVIClearClipboard()
@ stdcall AVIFileAddRef(ptr)
@ stub AVIFileCreateStream
@ stdcall AVIFileCreateStreamA(ptr ptr ptr)
......@@ -19,18 +19,18 @@
@ stdcall AVIFileReadData(ptr long ptr ptr)
@ stdcall AVIFileRelease(ptr)
@ stdcall AVIFileWriteData(ptr long ptr long)
@ stub AVIGetFromClipboard
@ stdcall AVIGetFromClipboard(ptr)
@ stdcall AVIMakeCompressedStream(ptr ptr ptr ptr)
@ stub AVIMakeFileFromStreams
@ stdcall AVIMakeFileFromStreams(ptr long ptr)
@ stub AVIMakeStreamFromClipboard
@ stub AVIPutFileOnClipboard
@ stdcall AVIPutFileOnClipboard(ptr)
@ stub AVISave
@ stub AVISaveA
@ stdcall AVISaveOptions(long long long ptr ptr)
@ stdcall AVISaveOptionsFree(long ptr)
@ stub AVISaveV
@ stub AVISaveVA
@ stub AVISaveVW
@ stdcall AVISaveVA(str ptr ptr long ptr ptr)
@ stdcall AVISaveVW(wstr ptr ptr long ptr ptr)
@ stub AVISaveW
@ stdcall AVIStreamAddRef(ptr)
@ stub AVIStreamBeginStreaming
......@@ -58,19 +58,19 @@
@ stdcall AVIStreamWrite(ptr long long ptr long long ptr ptr)
@ stdcall AVIStreamWriteData(ptr long ptr long)
@ stub CLSID_AVISimpleUnMarshal
@ stub CreateEditableStream
@ stdcall CreateEditableStream(ptr ptr)
@ stdcall DllCanUnloadNow() AVIFILE_DllCanUnloadNow
@ stdcall DllGetClassObject(ptr ptr ptr) AVIFILE_DllGetClassObject
@ stub EditStreamClone
@ stub EditStreamCopy
@ stub EditStreamCut
@ stub EditStreamPaste
@ stdcall EditStreamClone(ptr ptr)
@ stdcall EditStreamCopy(ptr ptr ptr ptr)
@ stdcall EditStreamCut(ptr ptr ptr ptr)
@ stdcall EditStreamPaste(ptr ptr ptr ptr long long)
@ stub EditStreamSetInfo
@ stub EditStreamSetInfoA
@ stub EditStreamSetInfoW
@ stdcall EditStreamSetInfoA(ptr ptr long)
@ stdcall EditStreamSetInfoW(ptr ptr long)
@ stub EditStreamSetName
@ stub EditStreamSetNameA
@ stub EditStreamSetNameW
@ stdcall EditStreamSetNameA(ptr str)
@ stdcall EditStreamSetNameW(ptr wstr)
@ extern IID_IAVIEditStream
@ extern IID_IAVIFile
@ extern IID_IAVIStream
......
......@@ -344,9 +344,9 @@ static HRESULT WINAPI IAVIFile_fnInfo(IAVIFile *iface, LPAVIFILEINFOW afi,
AVIFILE_UpdateInfo(This);
memcpy(afi, &This->fInfo, min(size, sizeof(This->fInfo)));
memcpy(afi, &This->fInfo, min((DWORD)size, sizeof(This->fInfo)));
if (size < sizeof(This->fInfo))
if ((DWORD)size < sizeof(This->fInfo))
return AVIERR_BUFFERTOOSMALL;
return AVIERR_OK;
}
......@@ -735,9 +735,9 @@ static HRESULT WINAPI IAVIStream_fnInfo(IAVIStream *iface,LPAVISTREAMINFOW psi,
if (size < 0)
return AVIERR_BADSIZE;
memcpy(psi, &This->sInfo, min(size, sizeof(This->sInfo)));
memcpy(psi, &This->sInfo, min((DWORD)size, sizeof(This->sInfo)));
if (size < sizeof(This->sInfo))
if ((DWORD)size < sizeof(This->sInfo))
return AVIERR_BUFFERTOOSMALL;
return AVIERR_OK;
}
......@@ -786,19 +786,21 @@ static LONG WINAPI IAVIStream_fnFindSample(IAVIStream *iface, LONG pos,
};
} else if ((flags & FIND_FORMAT) && This->idxFmtChanges != NULL &&
This->sInfo.fccType == streamtypeVIDEO) {
UINT n;
if (flags & FIND_NEXT) {
ULONG n;
for (n = 0; n < This->sInfo.dwFormatChangeCount; n++)
if (This->idxFmtChanges[n].ckid >= pos)
goto RETURN_FOUND;
} else {
for (n = This->sInfo.dwFormatChangeCount; n >= 0; n--) {
LONG n;
for (n = (LONG)This->sInfo.dwFormatChangeCount; n >= 0; n--) {
if (This->idxFmtChanges[n].ckid <= pos)
goto RETURN_FOUND;
}
if (pos > This->sInfo.dwStart)
if (pos > (LONG)This->sInfo.dwStart)
return 0; /* format changes always for first frame */
}
}
......@@ -850,8 +852,8 @@ static HRESULT WINAPI IAVIStream_fnReadFormat(IAVIStream *iface, LONG pos,
}
/* copy initial format (only as much as will fit) */
memcpy(format, This->lpFormat, min(*formatsize, This->cbFormat));
if (*formatsize < This->cbFormat) {
memcpy(format, This->lpFormat, min(*(DWORD*)formatsize, This->cbFormat));
if (*(DWORD*)formatsize < This->cbFormat) {
*formatsize = This->cbFormat;
return AVIERR_BUFFERTOOSMALL;
}
......@@ -999,9 +1001,9 @@ static HRESULT WINAPI IAVIStream_fnRead(IAVIStream *iface, LONG start,
*samplesread = 0;
/* check parameters */
if (This->sInfo.dwStart > start)
if ((LONG)This->sInfo.dwStart > start)
return AVIERR_NODATA; /* couldn't read before start of stream */
if (This->sInfo.dwStart + This->sInfo.dwLength < start)
if (This->sInfo.dwStart + This->sInfo.dwLength < (DWORD)start)
return AVIERR_NODATA; /* start is past end of stream */
/* should we read as much as possible? */
......@@ -1017,7 +1019,7 @@ static HRESULT WINAPI IAVIStream_fnRead(IAVIStream *iface, LONG start,
}
/* limit to end of stream */
if (This->sInfo.dwLength < samples)
if ((LONG)This->sInfo.dwLength < samples)
samples = This->sInfo.dwLength;
if ((start - This->sInfo.dwStart) > (This->sInfo.dwLength - samples))
samples = This->sInfo.dwLength - (start - This->sInfo.dwStart);
......@@ -1392,11 +1394,11 @@ static DWORD AVIFILE_ComputeMoviStart(IAVIFileImpl *This)
/* strl,strh,strf => (3 + 2 * 2) * sizeof(DWORD) = 7 * sizeof(DWORD) */
dwPos += 7 * sizeof(DWORD) + sizeof(AVIStreamHeader);
dwPos += ((pStream->cbFormat + 1) & ~1);
dwPos += ((pStream->cbFormat + 1) & ~1U);
if (pStream->lpHandlerData != NULL && pStream->cbHandlerData > 0)
dwPos += 2 * sizeof(DWORD) + ((pStream->cbHandlerData + 1) & ~1);
dwPos += 2 * sizeof(DWORD) + ((pStream->cbHandlerData + 1) & ~1U);
if (lstrlenW(pStream->sInfo.szName) > 0)
dwPos += 2 * sizeof(DWORD) + ((lstrlenW(pStream->sInfo.szName) + 1) & ~1);
dwPos += 2 * sizeof(DWORD) + ((lstrlenW(pStream->sInfo.szName) + 1) & ~1U);
}
if (This->dwMoviChunkPos == 0) {
......@@ -1427,7 +1429,7 @@ static void AVIFILE_ConstructAVIStream(IAVIFileImpl *paf, DWORD nr, LPAVISTRE
pstream->ref = 0;
pstream->paf = paf;
pstream->nStream = nr;
pstream->dwCurrentFrame = -1;
pstream->dwCurrentFrame = (DWORD)-1;
pstream->lLastFrame = -1;
if (asi != NULL) {
......@@ -1465,7 +1467,7 @@ static void AVIFILE_DestructAVIStream(IAVIStreamImpl *This)
/* pre-conditions */
assert(This != NULL);
This->dwCurrentFrame = -1;
This->dwCurrentFrame = (DWORD)-1;
This->lLastFrame = -1;
This->paf = NULL;
if (This->idxFrames != NULL) {
......@@ -1542,6 +1544,12 @@ static HRESULT AVIFILE_LoadFile(IAVIFileImpl *This)
if (mmioRead(This->hmmio, (HPSTR)&MainAVIHdr, ck.cksize) != ck.cksize)
return AVIERR_FILEREAD;
/* check for MAX_AVISTREAMS limit */
if (MainAVIHdr.dwStreams > MAX_AVISTREAMS) {
WARN("file contains %lu streams, but only supports %d -- change MAX_AVISTREAMS!\n", MainAVIHdr.dwStreams, MAX_AVISTREAMS);
return AVIERR_UNSUPPORTED;
}
/* adjust permissions if copyrighted material in file */
if (MainAVIHdr.dwFlags & AVIFILEINFO_COPYRIGHTED) {
This->uMode &= ~MMIO_RWMODE;
......
......@@ -20,14 +20,14 @@
105 stub AVIMAKECOMPRESSEDSTREAM
106 stub AVIMAKEFILEFROMSTREAMS
107 stub AVIMAKESTREAMFROMCLIPBOARD
110 stub AVISTREAMGETFRAME
111 stub AVISTREAMGETFRAMECLOSE
112 stub AVISTREAMGETFRAMEOPEN
110 pascal AVIStreamGetFrame(long long) AVIStreamGetFrame
111 pascal AVIStreamGetFrameClose(long) AVIStreamGetFrameClose
112 pascal AVIStreamGetFrameOpen(long ptr) AVIStreamGetFrameOpen
120 stub _AVISAVE
121 stub AVISAVEV
122 stub AVISAVEOPTIONS
123 stub AVIBUILDFILTER
124 stub AVISAVEOPTIONSFREE
123 pascal AVIBuildFilter(str long word) AVIBuildFilterA
124 pascal AVISaveOptionsFree(word ptr) AVISaveOptionsFree
130 pascal AVIStreamStart(long) AVIStreamStart
131 pascal AVIStreamLength(long) AVIStreamLength
132 pascal AVIStreamTimeToSample(long long) AVIStreamTimeToSample
......@@ -36,20 +36,20 @@
141 pascal AVIFileRelease(long) AVIFileRelease
142 pascal AVIFileInfo(long ptr long) AVIFileInfoA
143 pascal AVIFileGetStream(long ptr long long) AVIFileGetStream
144 stub AVIFILECREATESTREAM
146 stub AVIFILEWRITEDATA
147 stub AVIFILEREADDATA
144 pascal AVIFileCreateStream(long ptr ptr) AVIFileCreateStreamA
146 pascal AVIFileWriteData(long long ptr long) AVIFileWriteData
147 pascal AVIFileReadData(long long ptr ptr) AVIFileReadData
148 pascal AVIFileEndRecord(long) AVIFileEndRecord
160 pascal AVIStreamAddRef(long) AVIStreamAddRef
161 pascal AVIStreamRelease(long) AVIStreamRelease
162 stub AVISTREAMINFO
163 stub AVISTREAMFINDSAMPLE
164 stub AVISTREAMREADFORMAT
165 stub AVISTREAMREADDATA
166 stub AVISTREAMWRITEDATA
167 stub AVISTREAMREAD
168 stub AVISTREAMWRITE
169 stub AVISTREAMSETFORMAT
162 pascal AVIStreamInfo(long ptr long) AVIStreamInfoA
163 pascal AVIStreamFindSample(long long long) AVIStreamFindSample
164 pascal AVIStreamReadFormat(long long ptr ptr) AVIStreamReadFormat
165 pascal AVIStreamReadData(long long ptr ptr) AVIStreamReadData
166 pascal AVIStreamWriteData(long long ptr long) AVIStreamWriteData
167 pascal AVIStreamRead(long long long ptr long ptr ptr) AVIStreamRead
168 pascal AVIStreamWrite(long long long ptr long long ptr ptr) AVIStreamWrite
169 pascal AVIStreamSetFormat(long long ptr long) AVIStreamSetFormat
180 stub EDITSTREAMCOPY
181 stub EDITSTREAMCUT
182 stub EDITSTREAMPASTE
......
......@@ -20,7 +20,7 @@
#define __AVIFILE_PRIVATE_H
#ifndef MAX_AVISTREAMS
#define MAX_AVISTREAMS 4
#define MAX_AVISTREAMS 8
#endif
#ifndef comptypeDIB
......@@ -65,6 +65,7 @@ extern HRESULT AVIFILE_CreateWAVFile(REFIID riid, LPVOID *ppobj);
extern HRESULT AVIFILE_CreateACMStream(REFIID riid, LPVOID *ppobj);
extern HRESULT AVIFILE_CreateICMStream(REFIID riid, LPVOID *ppobj);
extern PGETFRAME AVIFILE_CreateGetFrame(PAVISTREAM pstream);
extern PAVIFILE AVIFILE_CreateAVITempFile(int nStreams,PAVISTREAM *ppStreams);
extern LPCWSTR AVIFILE_BasenameW(LPCWSTR szFileName);
......
......@@ -33,7 +33,7 @@ HRESULT ReadExtraChunk(LPEXTRACHUNKS extra,FOURCC ckid,LPVOID lpData,
LPLONG size)
{
LPBYTE lp;
LONG cb;
DWORD cb;
/* pre-conditions */
assert(extra != NULL);
......@@ -47,9 +47,10 @@ HRESULT ReadExtraChunk(LPEXTRACHUNKS extra,FOURCC ckid,LPVOID lpData,
if (((FOURCC*)lp)[0] == ckid) {
/* found correct chunk */
if (lpData != NULL && *size > 0)
memcpy(lpData, lp + 2 * sizeof(DWORD), min(((LPDWORD)lp)[1],*size));
memcpy(lpData, lp + 2 * sizeof(DWORD),
min(((LPDWORD)lp)[1], *(LPDWORD)size));
*size = ((LPDWORD)lp)[1];
*(LPDWORD)size = ((LPDWORD)lp)[1];
return AVIERR_OK;
} else {
......@@ -103,7 +104,7 @@ HRESULT WriteExtraChunk(LPEXTRACHUNKS extra,FOURCC ckid,LPVOID lpData,
HRESULT ReadChunkIntoExtra(LPEXTRACHUNKS extra,HMMIO hmmio,MMCKINFO *lpck)
{
LPDWORD lp;
LONG cb;
DWORD cb;
/* pre-conditions */
assert(extra != NULL);
......@@ -132,7 +133,7 @@ HRESULT ReadChunkIntoExtra(LPEXTRACHUNKS extra,HMMIO hmmio,MMCKINFO *lpck)
if (lpck->cksize > 0) {
if (mmioSeek(hmmio, lpck->dwDataOffset, SEEK_SET) == -1)
return AVIERR_FILEREAD;
if (mmioRead(hmmio, (HPSTR)&lp[2], lpck->cksize) != lpck->cksize)
if (mmioRead(hmmio, (HPSTR)&lp[2], lpck->cksize) != (LONG)lpck->cksize)
return AVIERR_FILEREAD;
}
......
......@@ -71,9 +71,9 @@ typedef struct _IGetFrameImpl {
PAVISTREAM pStream;
LPVOID lpInBuffer;
DWORD cbInBuffer;
LONG cbInBuffer;
LPBITMAPINFOHEADER lpInFormat;
DWORD cbInFormat;
LONG cbInFormat;
LONG lCurrentFrame;
LPBITMAPINFOHEADER lpOutFormat;
......@@ -341,7 +341,7 @@ static HRESULT WINAPI IGetFrame_fnSetFormat(IGetFrame *iface,
if (This->lpInFormat == NULL) {
HRESULT hr;
This->cbInBuffer = sInfo.dwSuggestedBufferSize;
This->cbInBuffer = (LONG)sInfo.dwSuggestedBufferSize;
if (This->cbInBuffer == 0)
This->cbInBuffer = 1024;
......
......@@ -329,9 +329,9 @@ static HRESULT WINAPI ICMStream_fnInfo(IAVIStream *iface,LPAVISTREAMINFOW psi,
if (size < 0)
return AVIERR_BADSIZE;
memcpy(psi, &This->sInfo, min(size, sizeof(This->sInfo)));
memcpy(psi, &This->sInfo, min((DWORD)size, sizeof(This->sInfo)));
if (size < sizeof(This->sInfo))
if ((DWORD)size < sizeof(This->sInfo))
return AVIERR_BUFFERTOOSMALL;
return AVIERR_OK;
}
......@@ -885,7 +885,7 @@ static HRESULT AVIFILE_EncodeFrame(IAVIStreamImpl *This,
static HRESULT AVIFILE_OpenGetFrame(IAVIStreamImpl *This)
{
LPBITMAPINFOHEADER lpbi;
LONG size;
DWORD size;
/* pre-conditions */
assert(This != NULL);
......@@ -910,7 +910,7 @@ static HRESULT AVIFILE_OpenGetFrame(IAVIStreamImpl *This)
/* get memory for output format */
size = ICCompressGetFormatSize(This->hic, lpbi);
if (size < sizeof(BITMAPINFOHEADER))
if ((LONG)size < (LONG)sizeof(BITMAPINFOHEADER))
return AVIERR_COMPRESSOR;
This->lpbiOutput = (LPBITMAPINFOHEADER)GlobalAllocPtr(GHND, size);
if (This->lpbiOutput == NULL)
......
/*
* Copyright 2003 Michael Gnnewig
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define COM_NO_WINDOWS_H
#include <assert.h>
#include "winbase.h"
#include "winuser.h"
#include "winnls.h"
#include "winerror.h"
#include "windowsx.h"
#include "mmsystem.h"
#include "vfw.h"
#include "avifile_private.h"
#include "extrachunk.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(avifile);
/***********************************************************************/
static HRESULT WINAPI ITmpFile_fnQueryInterface(IAVIFile* iface,REFIID refiid,LPVOID *obj);
static ULONG WINAPI ITmpFile_fnAddRef(IAVIFile* iface);
static ULONG WINAPI ITmpFile_fnRelease(IAVIFile* iface);
static HRESULT WINAPI ITmpFile_fnInfo(IAVIFile*iface,AVIFILEINFOW*afi,LONG size);
static HRESULT WINAPI ITmpFile_fnGetStream(IAVIFile*iface,PAVISTREAM*avis,DWORD fccType,LONG lParam);
static HRESULT WINAPI ITmpFile_fnCreateStream(IAVIFile*iface,PAVISTREAM*avis,AVISTREAMINFOW*asi);
static HRESULT WINAPI ITmpFile_fnWriteData(IAVIFile*iface,DWORD ckid,LPVOID lpData,LONG size);
static HRESULT WINAPI ITmpFile_fnReadData(IAVIFile*iface,DWORD ckid,LPVOID lpData,LONG *size);
static HRESULT WINAPI ITmpFile_fnEndRecord(IAVIFile*iface);
static HRESULT WINAPI ITmpFile_fnDeleteStream(IAVIFile*iface,DWORD fccType,LONG lParam);
struct ICOM_VTABLE(IAVIFile) itmpft = {
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
ITmpFile_fnQueryInterface,
ITmpFile_fnAddRef,
ITmpFile_fnRelease,
ITmpFile_fnInfo,
ITmpFile_fnGetStream,
ITmpFile_fnCreateStream,
ITmpFile_fnWriteData,
ITmpFile_fnReadData,
ITmpFile_fnEndRecord,
ITmpFile_fnDeleteStream
};
typedef struct _ITmpFileImpl {
/* IUnknown stuff */
ICOM_VFIELD(IAVIFile);
DWORD ref;
/* IAVIFile stuff */
AVIFILEINFOW fInfo;
PAVISTREAM *ppStreams;
} ITmpFileImpl;
PAVIFILE AVIFILE_CreateAVITempFile(int nStreams, PAVISTREAM *ppStreams) {
ITmpFileImpl *tmpFile;
int i;
tmpFile = LocalAlloc(LPTR, sizeof(ITmpFileImpl));
if (tmpFile == NULL)
return NULL;
tmpFile->lpVtbl = &itmpft;
tmpFile->ref = 1;
memset(&tmpFile->fInfo, 0, sizeof(tmpFile->fInfo));
tmpFile->fInfo.dwStreams = nStreams;
tmpFile->ppStreams = LocalAlloc(LPTR, nStreams * sizeof(PAVISTREAM));
if (tmpFile->ppStreams == NULL) {
LocalFree((HLOCAL)tmpFile);
return NULL;
}
for (i = 0; i < nStreams; i++) {
AVISTREAMINFOW sInfo;
tmpFile->ppStreams[i] = ppStreams[i];
AVIStreamAddRef(ppStreams[i]);
AVIStreamInfoW(ppStreams[i], &sInfo, sizeof(sInfo));
if (i == 0) {
tmpFile->fInfo.dwScale = sInfo.dwScale;
tmpFile->fInfo.dwRate = sInfo.dwRate;
if (!sInfo.dwScale || !sInfo.dwRate) {
tmpFile->fInfo.dwScale = 1;
tmpFile->fInfo.dwRate = 100;
}
}
if (tmpFile->fInfo.dwSuggestedBufferSize < sInfo.dwSuggestedBufferSize)
tmpFile->fInfo.dwSuggestedBufferSize = sInfo.dwSuggestedBufferSize;
{
register DWORD tmp;
tmp = MulDiv(AVIStreamSampleToTime(ppStreams[i], sInfo.dwLength), \
tmpFile->fInfo.dwScale, tmpFile->fInfo.dwRate * 1000);
if (tmpFile->fInfo.dwLength < tmp)
tmpFile->fInfo.dwLength = tmp;
tmp = sInfo.rcFrame.right - sInfo.rcFrame.left;
if (tmpFile->fInfo.dwWidth < tmp)
tmpFile->fInfo.dwWidth = tmp;
tmp = sInfo.rcFrame.bottom - sInfo.rcFrame.top;
if (tmpFile->fInfo.dwHeight < tmp)
tmpFile->fInfo.dwHeight = tmp;
}
}
return (PAVIFILE)tmpFile;
}
static HRESULT WINAPI ITmpFile_fnQueryInterface(IAVIFile *iface, REFIID refiid,
LPVOID *obj)
{
ICOM_THIS(ITmpFileImpl,iface);
TRACE("(%p,%s,%p)\n", This, debugstr_guid(refiid), obj);
if (IsEqualGUID(&IID_IUnknown, refiid) ||
IsEqualGUID(&IID_IAVIFile, refiid)) {
*obj = iface;
IAVIFile_AddRef(iface);
return S_OK;
}
return OLE_E_ENUM_NOMORE;
}
static ULONG WINAPI ITmpFile_fnAddRef(IAVIFile *iface)
{
ICOM_THIS(ITmpFileImpl,iface);
TRACE("(%p) -> %ld\n", iface, This->ref + 1);
return ++(This->ref);
}
static ULONG WINAPI ITmpFile_fnRelease(IAVIFile *iface)
{
ICOM_THIS(ITmpFileImpl,iface);
TRACE("(%p) -> %ld\n", iface, This->ref - 1);
if (!--(This->ref)) {
int i;
for (i = 0; i < This->fInfo.dwStreams; i++) {
if (This->ppStreams[i] != NULL) {
AVIStreamRelease(This->ppStreams[i]);
This->ppStreams[i] = NULL;
}
}
LocalFree((HLOCAL)This);
return 0;
}
return This->ref;
}
static HRESULT WINAPI ITmpFile_fnInfo(IAVIFile *iface,
AVIFILEINFOW *afi, LONG size)
{
ICOM_THIS(ITmpFileImpl,iface);
TRACE("(%p,%p,%ld)\n",iface,afi,size);
if (afi == NULL)
return AVIERR_BADPARAM;
if (size < 0)
return AVIERR_BADSIZE;
memcpy(afi, &This->fInfo, min((DWORD)size, sizeof(This->fInfo)));
if ((DWORD)size < sizeof(This->fInfo))
return AVIERR_BUFFERTOOSMALL;
return AVIERR_OK;
}
static HRESULT WINAPI ITmpFile_fnGetStream(IAVIFile *iface, PAVISTREAM *avis,
DWORD fccType, LONG lParam)
{
ICOM_THIS(ITmpFileImpl,iface);
ULONG nStream = (ULONG)-1;
TRACE("(%p,%p,0x%08lX,%ld)\n", iface, avis, fccType, lParam);
if (avis == NULL || lParam < 0)
return AVIERR_BADPARAM;
if (fccType != streamtypeANY) {
/* search the number of the specified stream */
ULONG i;
for (i = 0; i < This->fInfo.dwStreams; i++) {
AVISTREAMINFOW sInfo;
HRESULT hr;
hr = AVIStreamInfoW(This->ppStreams[i], &sInfo, sizeof(sInfo));
if (FAILED(hr))
return hr;
if (sInfo.fccType == fccType) {
if (lParam == 0) {
nStream = i;
break;
} else
lParam--;
}
}
} else
nStream = lParam;
/* Does the requested stream exist ? */
if (nStream < This->fInfo.dwStreams && This->ppStreams[nStream] != NULL) {
*avis = This->ppStreams[nStream];
AVIStreamAddRef(*avis);
return AVIERR_OK;
}
/* Sorry, but the specified stream doesn't exist */
return AVIERR_NODATA;
}
static HRESULT WINAPI ITmpFile_fnCreateStream(IAVIFile *iface,PAVISTREAM *avis,
AVISTREAMINFOW *asi)
{
TRACE("(%p,%p,%p)\n",iface,avis,asi);
return AVIERR_UNSUPPORTED;
}
static HRESULT WINAPI ITmpFile_fnWriteData(IAVIFile *iface, DWORD ckid,
LPVOID lpData, LONG size)
{
TRACE("(%p,0x%08lX,%p,%ld)\n", iface, ckid, lpData, size);
return AVIERR_UNSUPPORTED;
}
static HRESULT WINAPI ITmpFile_fnReadData(IAVIFile *iface, DWORD ckid,
LPVOID lpData, LONG *size)
{
TRACE("(%p,0x%08lX,%p,%p)\n", iface, ckid, lpData, size);
return AVIERR_UNSUPPORTED;
}
static HRESULT WINAPI ITmpFile_fnEndRecord(IAVIFile *iface)
{
TRACE("(%p)\n",iface);
return AVIERR_OK;
}
static HRESULT WINAPI ITmpFile_fnDeleteStream(IAVIFile *iface, DWORD fccType,
LONG lParam)
{
TRACE("(%p,0x%08lX,%ld)\n", iface, fccType, lParam);
return AVIERR_UNSUPPORTED;
}
......@@ -298,9 +298,9 @@ static HRESULT WINAPI IAVIFile_fnInfo(IAVIFile *iface, LPAVIFILEINFOW afi,
MulDiv(This->sInfo.dwSampleSize,This->sInfo.dwRate,This->sInfo.dwScale);
}
memcpy(afi, &This->fInfo, min(size, sizeof(This->fInfo)));
memcpy(afi, &This->fInfo, min((DWORD)size, sizeof(This->fInfo)));
if (size < sizeof(This->fInfo))
if ((DWORD)size < sizeof(This->fInfo))
return AVIERR_BUFFERTOOSMALL;
return AVIERR_OK;
}
......@@ -667,9 +667,9 @@ static HRESULT WINAPI IAVIStream_fnInfo(IAVIStream *iface,LPAVISTREAMINFOW psi,
if (size < 0)
return AVIERR_BADSIZE;
memcpy(psi, &This->paf->sInfo, min(size, sizeof(This->paf->sInfo)));
memcpy(psi, &This->paf->sInfo, min((DWORD)size, sizeof(This->paf->sInfo)));
if (size < sizeof(This->paf->sInfo))
if ((DWORD)size < sizeof(This->paf->sInfo))
return AVIERR_BUFFERTOOSMALL;
return AVIERR_OK;
}
......@@ -810,7 +810,7 @@ static HRESULT WINAPI IAVIStream_fnRead(IAVIStream *iface, LONG start,
*samplesread = 0;
/* positions without data */
if (start < 0 || start > This->sInfo.dwLength)
if (start < 0 || (DWORD)start > This->sInfo.dwLength)
return AVIERR_OK;
/* check samples */
......@@ -818,13 +818,13 @@ static HRESULT WINAPI IAVIStream_fnRead(IAVIStream *iface, LONG start,
samples = 0;
if (buffersize > 0) {
if (samples > 0)
samples = min(samples, buffersize / This->sInfo.dwSampleSize);
samples = min((DWORD)samples, buffersize / This->sInfo.dwSampleSize);
else
samples = buffersize / This->sInfo.dwSampleSize;
}
/* limit to end of stream */
if (start + samples > This->sInfo.dwLength)
if ((DWORD)(start + samples) > This->sInfo.dwLength)
samples = This->sInfo.dwLength - start;
/* request only the sizes? */
......@@ -846,7 +846,7 @@ static HRESULT WINAPI IAVIStream_fnRead(IAVIStream *iface, LONG start,
return AVIERR_OK;
/* Can I atleast read one sample? */
if (buffersize < This->sInfo.dwSampleSize)
if ((DWORD)buffersize < This->sInfo.dwSampleSize)
return AVIERR_BUFFERTOOSMALL;
buffersize = samples * This->sInfo.dwSampleSize;
......@@ -909,7 +909,7 @@ static HRESULT WINAPI IAVIStream_fnWrite(IAVIStream *iface, LONG start,
if (mmioWrite(This->hmmio, (HPSTR)buffer, buffersize) != buffersize)
return AVIERR_FILEWRITE;
This->sInfo.dwLength = max(This->sInfo.dwLength, start + samples);
This->sInfo.dwLength = max(This->sInfo.dwLength, (DWORD)start + samples);
This->ckData.cksize = max(This->ckData.cksize,
start * This->sInfo.dwSampleSize + buffersize);
......@@ -935,23 +935,23 @@ static HRESULT WINAPI IAVIStream_fnDelete(IAVIStream *iface, LONG start,
return AVIERR_BADPARAM;
/* Delete before start of stream? */
if (start + samples < This->sInfo.dwStart)
if ((DWORD)(start + samples) < This->sInfo.dwStart)
return AVIERR_OK;
/* Delete after end of stream? */
if (start > This->sInfo.dwLength)
if ((DWORD)start > This->sInfo.dwLength)
return AVIERR_OK;
/* For the rest we need write permissions */
if ((This->uMode & MMIO_RWMODE) == 0)
return AVIERR_READONLY;
if (start + samples >= This->sInfo.dwLength) {
if ((DWORD)(start + samples) >= This->sInfo.dwLength) {
/* deletion at end */
samples = This->sInfo.dwLength - start;
This->sInfo.dwLength -= samples;
This->ckData.cksize -= samples * This->sInfo.dwSampleSize;
} else if (start <= This->sInfo.dwStart) {
} else if ((DWORD)start <= This->sInfo.dwStart) {
/* deletion at start */
samples = This->sInfo.dwStart - start;
start = This->sInfo.dwStart;
......
......@@ -42,6 +42,7 @@ LONG VFWAPI TermVFW(void);
typedef struct IAVIStream IAVIStream,*PAVISTREAM;
typedef struct IAVIFile IAVIFile,*PAVIFILE;
typedef struct IGetFrame IGetFrame,*PGETFRAME;
typedef struct IAVIEditStream IAVIEditStream, *PAVIEDITSTREAM;
/* Installable Compressor Manager */
......@@ -743,6 +744,7 @@ typedef WORD TWOCC;
#define ckidAVINEWINDEX mmioFOURCC('i', 'd', 'x', '1')
#define streamtypeANY 0UL
#define streamtypeVIDEO mmioFOURCC('v', 'i', 'd', 's')
#define streamtypeAUDIO mmioFOURCC('a', 'u', 'd', 's')
#define streamtypeMIDI mmioFOURCC('m', 'i', 'd', 's')
......@@ -1042,6 +1044,7 @@ LPVOID WINAPI AVIStreamGetFrame(PGETFRAME pg,LONG pos);
HRESULT WINAPI AVIStreamGetFrameClose(PGETFRAME pg);
HRESULT WINAPI AVIMakeCompressedStream(PAVISTREAM*ppsCompressed,PAVISTREAM ppsSource,AVICOMPRESSOPTIONS *lpOptions,CLSID*pclsidHandler);
HRESULT WINAPI AVIMakeFileFromStreams(PAVIFILE *ppfile, int nStreams, PAVISTREAM *ppStreams);
HRESULT WINAPI AVIStreamOpenFromFileA(PAVISTREAM *ppavi, LPCSTR szFile,
DWORD fccType, LONG lParam,
......@@ -1059,6 +1062,14 @@ BOOL WINAPI AVISaveOptions(HWND hWnd,UINT uFlags,INT nStream,
PAVISTREAM *ppavi,LPAVICOMPRESSOPTIONS *ppOptions);
HRESULT WINAPI AVISaveOptionsFree(INT nStreams,LPAVICOMPRESSOPTIONS*ppOptions);
HRESULT WINAPI AVISaveVA(LPCSTR szFile, CLSID *pclsidHandler,
AVISAVECALLBACK lpfnCallback, int nStream,
PAVISTREAM *ppavi, LPAVICOMPRESSOPTIONS *plpOptions);
HRESULT WINAPI AVISaveVW(LPCWSTR szFile, CLSID *pclsidHandler,
AVISAVECALLBACK lpfnCallback, int nStream,
PAVISTREAM *ppavi, LPAVICOMPRESSOPTIONS *plpOptions);
#define AVISaveV WINELIB_NAME_AW(AVISaveV)
LONG WINAPI AVIStreamStart(PAVISTREAM iface);
LONG WINAPI AVIStreamLength(PAVISTREAM iface);
LONG WINAPI AVIStreamSampleToTime(PAVISTREAM pstream, LONG lSample);
......@@ -1084,6 +1095,52 @@ LONG WINAPI AVIStreamTimeToSample(PAVISTREAM pstream, LONG lTime);
AVIStreamSampleToTime(pavi, AVIStreamStart(pavi))
/*****************************************************************************
* IAVIEditStream interface
*/
#define INTERFACE IAVIEditStream
#define IAVIEditStream_METHODS \
IUnknown_METHODS \
STDMETHOD(Cut)(IAVIEditStream*iface,LONG*plStart,LONG*plLength,PAVISTREAM*ppResult) PURE; \
STDMETHOD(Copy)(IAVIEditStream*iface,LONG*plStart,LONG*plLength,PAVISTREAM*ppResult) PURE; \
STDMETHOD(Paste)(IAVIEditStream*iface,LONG*plStart,LONG*plLength,PAVISTREAM pSource,LONG lStart,LONG lEnd) PURE; \
STDMETHOD(Clone)(IAVIEditStream*iface,PAVISTREAM*ppResult) PURE; \
STDMETHOD(SetInfo)(IAVIEditStream*iface,LPAVISTREAMINFOW asi, LONG size) PURE;
ICOM_DEFINE(IAVIEditStream,IUnknown)
#undef INTERFACE
#ifdef COBJMACROS
/*** IUnknown methods ***/
#define IAVIEditStream_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IAVIEditStream_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IAVIEditStream_Release(p) (p)->lpVtbl->Release(p)
/*** IAVIEditStream methods ***/
#define IAVIEditStream_Cut(p,a,b,c) (p)->lpVtbl->Cut(p,a,b,c)
#define IAVIEditStream_Copy(p,a,b,c) (p)->lpVtbl->Copy(p,a,b,c)
#define IAVIEditStream_Paste(p,a,b,c,d,e) (p)->lpVtbl->Paste(p,a,b,c,d,e)
#define IAVIEditStream_Clone(p,a) (p)->lpVtbl->Clone(p,a)
#define IAVIEditStream_SetInfo(p,a,b) (p)->lpVtbl->SetInfo(p,a,b)
#endif
HRESULT WINAPI CreateEditableStream(PAVISTREAM *ppEditable,PAVISTREAM pSource);
HRESULT WINAPI EditStreamClone(PAVISTREAM pStream, PAVISTREAM *ppResult);
HRESULT WINAPI EditStreamCopy(PAVISTREAM pStream, LONG *plStart,
LONG *plLength, PAVISTREAM *ppResult);
HRESULT WINAPI EditStreamCut(PAVISTREAM pStream, LONG *plStart,
LONG *plLength, PAVISTREAM *ppResult);
HRESULT WINAPI EditStreamPaste(PAVISTREAM pDest, LONG *plStart, LONG *plLength,
PAVISTREAM pSource, LONG lStart, LONG lEnd);
HRESULT WINAPI EditStreamSetInfoA(PAVISTREAM pstream, LPAVISTREAMINFOA asi,
LONG size);
HRESULT WINAPI EditStreamSetInfoW(PAVISTREAM pstream, LPAVISTREAMINFOW asi,
LONG size);
#define EditStreamSetInfo WINELIB_NAME_AW(EditStreamSetInfo)
HRESULT WINAPI EditStreamSetNameA(PAVISTREAM pstream, LPCSTR szName);
HRESULT WINAPI EditStreamSetNameW(PAVISTREAM pstream, LPCWSTR szName);
#define EditStreamSetName WINELIB_NAME_AW(EditStreamSetName)
/*****************************************************************************
* IAVIFile interface
*/
/* In Win32 this interface uses UNICODE only */
......@@ -1160,6 +1217,23 @@ ICOM_DEFINE(IGetFrame,IUnknown)
#define IGetFrame_SetFormat(p,a,b,c,d,e,f) (p)->lpVtbl->SetFormat(p,a,b,c,d,e,f)
#endif
HRESULT WINAPI AVIClearClipboard(void);
HRESULT WINAPI AVIGetFromClipboard(PAVIFILE *ppfile);
HRESULT WINAPI AVIPutFileOnClipboard(PAVIFILE pfile);
#ifdef _WIN32
#ifdef OFN_READONLY
BOOL WINAPI GetOpenFileNamePreviewA(LPOPENFILENAMEA lpofn);
BOOL WINAPI GetOpenFileNamePreviewW(LPOPENFILENAMEW lpofn);
#define GetOpenFileNamePreview WINELIB_NAME_AW(GetOpenFileNamePreview)
BOOL WINAPI GetSaveFileNamePreviewA(LPOPENFILENAMEA lpofn);
BOOL WINAPI GetSaveFileNamePreviewW(LPOPENFILENAMEW lpofn);
#define GetSaveFileNamePreview WINELIB_NAME_AW(GetSaveFileNamePreview)
#endif
#endif
#define AVIERR_OK 0
#define MAKE_AVIERR(error) MAKE_SCODE(SEVERITY_ERROR,FACILITY_ITF,0x4000+error)
......
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