- First part of a new IAVIEditStream implementation.
- Fixed/Added some parameter checking. - Fixed bug in EditStreamSetInfoW. - Fixed bug in avifil32.spec (str instead of wstr). - Fixed cosmetic bug in IAVIStreamImpl_fnRelease. - Fixed typo.
This commit is contained in:
parent
4d375d1b8b
commit
53cfed70bb
|
@ -16,6 +16,7 @@ C_SRCS = \
|
|||
acmstream.c \
|
||||
api.c \
|
||||
avifile.c \
|
||||
editstream.c \
|
||||
extrachunk.c \
|
||||
factory.c \
|
||||
getframe.c \
|
||||
|
|
|
@ -395,6 +395,9 @@ HRESULT WINAPI AVIFileCreateStreamW(PAVIFILE pfile, PAVISTREAM *avis,
|
|||
{
|
||||
TRACE("(%p,%p,%p)\n", pfile, avis, asi);
|
||||
|
||||
if (pfile == NULL)
|
||||
return AVIERR_BADHANDLE;
|
||||
|
||||
return IAVIFile_CreateStream(pfile, avis, asi);
|
||||
}
|
||||
|
||||
|
@ -1006,7 +1009,7 @@ HRESULT WINAPI AVIBuildFilterA(LPSTR szFilter, LONG cbFilter, BOOL fSaving)
|
|||
szFilter[0] = 0;
|
||||
szFilter[1] = 0;
|
||||
|
||||
wszFilter = (LPWSTR)GlobalAllocPtr(GHND, cbFilter);
|
||||
wszFilter = (LPWSTR)GlobalAllocPtr(GHND, cbFilter * sizeof(WCHAR));
|
||||
if (wszFilter == NULL)
|
||||
return AVIERR_MEMORY;
|
||||
|
||||
|
@ -2030,7 +2033,7 @@ HRESULT WINAPI CreateEditableStream(PAVISTREAM *ppEditable, PAVISTREAM pSource)
|
|||
IAVIEditStream *pEdit = NULL;
|
||||
HRESULT hr;
|
||||
|
||||
FIXME("(%p,%p), semi stub!\n", ppEditable, pSource);
|
||||
TRACE("(%p,%p)\n", ppEditable, pSource);
|
||||
|
||||
if (ppEditable == NULL)
|
||||
return AVIERR_BADPARAM;
|
||||
|
@ -2040,18 +2043,25 @@ HRESULT WINAPI CreateEditableStream(PAVISTREAM *ppEditable, PAVISTREAM pSource)
|
|||
if (pSource != NULL) {
|
||||
hr = IAVIStream_QueryInterface(pSource, &IID_IAVIEditStream,
|
||||
(LPVOID*)&pEdit);
|
||||
if (FAILED(hr) || pEdit == NULL) {
|
||||
/* need own implementation of IAVIEditStream */
|
||||
|
||||
return AVIERR_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
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.@)
|
||||
|
@ -2121,13 +2131,13 @@ HRESULT WINAPI EditStreamCut(PAVISTREAM pStream, LONG *plStart,
|
|||
|
||||
TRACE("(%p,%p,%p,%p)\n", pStream, plStart, plLength, ppResult);
|
||||
|
||||
if (ppResult != NULL)
|
||||
*ppResult = NULL;
|
||||
if (pStream == NULL)
|
||||
return AVIERR_BADHANDLE;
|
||||
if (plStart == NULL || plLength == NULL || ppResult == NULL)
|
||||
if (plStart == NULL || plLength == NULL)
|
||||
return AVIERR_BADPARAM;
|
||||
|
||||
*ppResult = NULL;
|
||||
|
||||
hr = IAVIStream_QueryInterface(pStream, &IID_IAVIEditStream,(LPVOID*)&pEdit);
|
||||
if (SUCCEEDED(hr) && pEdit != NULL) {
|
||||
hr = IAVIEditStream_Cut(pEdit, plStart, plLength, ppResult);
|
||||
|
@ -2182,7 +2192,7 @@ HRESULT WINAPI EditStreamSetInfoA(PAVISTREAM pstream, LPAVISTREAMINFOA asi,
|
|||
if ((DWORD)size < sizeof(AVISTREAMINFOA))
|
||||
return AVIERR_BADSIZE;
|
||||
|
||||
memcpy(&asiw, asi, sizeof(asi) - sizeof(asi->szName));
|
||||
memcpy(&asiw, asi, sizeof(asiw) - sizeof(asiw.szName));
|
||||
MultiByteToWideChar(CP_ACP, 0, asi->szName, -1,
|
||||
asiw.szName, sizeof(asiw.szName));
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
@ stdcall AVIFileInit()
|
||||
@ stub AVIFileOpen
|
||||
@ stdcall AVIFileOpenA(ptr str long ptr)
|
||||
@ stdcall AVIFileOpenW(ptr str long ptr)
|
||||
@ stdcall AVIFileOpenW(ptr wstr long ptr)
|
||||
@ stdcall AVIFileReadData(ptr long ptr ptr)
|
||||
@ stdcall AVIFileRelease(ptr)
|
||||
@ stdcall AVIFileWriteData(ptr long ptr long)
|
||||
|
|
|
@ -305,8 +305,8 @@ static ULONG WINAPI IAVIFile_fnRelease(IAVIFile *iface)
|
|||
for (i = 0; i < This->fInfo.dwStreams; i++) {
|
||||
if (This->ppStreams[i] != NULL) {
|
||||
if (This->ppStreams[i]->ref != 0) {
|
||||
ERR(": someone has still a reference to stream %u (%p)!\n",
|
||||
i, This->ppStreams[i]);
|
||||
ERR(": someone has still %lu reference to stream %u (%p)!\n",
|
||||
This->ppStreams[i]->ref, i, This->ppStreams[i]);
|
||||
}
|
||||
AVIFILE_DestructAVIStream(This->ppStreams[i]);
|
||||
LocalFree((HLOCAL)This->ppStreams[i]);
|
||||
|
@ -529,7 +529,7 @@ static HRESULT WINAPI IAVIFile_fnDeleteStream(IAVIFile *iface, DWORD fccType,
|
|||
if (lParam < 0)
|
||||
return AVIERR_BADPARAM;
|
||||
|
||||
/* Habe user write permissions? */
|
||||
/* Have user write permissions? */
|
||||
if ((This->uMode & MMIO_RWMODE) == 0)
|
||||
return AVIERR_READONLY;
|
||||
|
||||
|
@ -756,10 +756,12 @@ static ULONG WINAPI IAVIStream_fnRelease(IAVIStream* iface)
|
|||
return 0;
|
||||
}
|
||||
|
||||
This->ref--;
|
||||
|
||||
if (This->paf != NULL)
|
||||
IAVIFile_Release((PAVIFILE)This->paf);
|
||||
|
||||
return --This->ref;
|
||||
return This->ref;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IAVIStream_fnCreate(IAVIStream *iface, LPARAM lParam1,
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
DEFINE_AVIGUID(CLSID_ICMStream, 0x00020001, 0, 0);
|
||||
DEFINE_AVIGUID(CLSID_WAVFile, 0x00020003, 0, 0);
|
||||
DEFINE_AVIGUID(CLSID_ACMStream, 0x0002000F, 0, 0);
|
||||
DEFINE_AVIGUID(IID_IEditStreamInternal, 0x0002000A,0,0);
|
||||
|
||||
extern HMODULE AVIFILE_hModule;
|
||||
|
||||
|
@ -64,6 +65,7 @@ extern HRESULT AVIFILE_CreateAVIFile(REFIID riid, LPVOID *ppobj);
|
|||
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 PAVIEDITSTREAM AVIFILE_CreateEditStream(PAVISTREAM pstream);
|
||||
extern PGETFRAME AVIFILE_CreateGetFrame(PAVISTREAM pstream);
|
||||
extern PAVIFILE AVIFILE_CreateAVITempFile(int nStreams,PAVISTREAM *ppStreams);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -171,7 +171,7 @@ static ULONG WINAPI IGetFrame_fnRelease(IGetFrame *iface)
|
|||
if (!--(This->ref)) {
|
||||
AVIFILE_CloseCompressor(This);
|
||||
if (This->pStream != NULL) {
|
||||
AVIStreamRelease(This->pStream);
|
||||
IAVIStream_Release(This->pStream);
|
||||
This->pStream = NULL;
|
||||
}
|
||||
|
||||
|
@ -191,6 +191,10 @@ static LPVOID WINAPI IGetFrame_fnGetFrame(IGetFrame *iface, LONG lPos)
|
|||
|
||||
TRACE("(%p,%ld)\n", iface, lPos);
|
||||
|
||||
/* We don't want negative start values! -- marks invalid buffer content */
|
||||
if (lPos < 0)
|
||||
return NULL;
|
||||
|
||||
/* check state */
|
||||
if (This->pStream == NULL)
|
||||
return NULL;
|
||||
|
@ -226,17 +230,18 @@ static LPVOID WINAPI IGetFrame_fnGetFrame(IGetFrame *iface, LONG lPos)
|
|||
}
|
||||
|
||||
if (lPos != This->lCurrentFrame) {
|
||||
LONG lNext = AVIStreamFindSample(This->pStream, lPos, FIND_KEY|FIND_PREV);
|
||||
LONG lNext = IAVIStream_FindSample(This->pStream,lPos,FIND_KEY|FIND_PREV);
|
||||
|
||||
if (lNext == -1)
|
||||
return NULL;
|
||||
return NULL; /* frame doesn't exist */
|
||||
if (lNext <= This->lCurrentFrame && This->lCurrentFrame < lPos)
|
||||
lNext = This->lCurrentFrame + 1;
|
||||
|
||||
for (; lNext <= lPos; lNext++) {
|
||||
/* new format for this frame? */
|
||||
if (This->bFormatChanges) {
|
||||
AVIStreamReadFormat(This->pStream, lNext, This->lpInFormat, &This->cbInFormat);
|
||||
IAVIStream_ReadFormat(This->pStream, lNext,
|
||||
This->lpInFormat, &This->cbInFormat);
|
||||
if (This->lpOutFormat != NULL) {
|
||||
if (This->lpOutFormat->biBitCount <= 8)
|
||||
ICDecompressGetPalette(This->hic, This->lpInFormat,
|
||||
|
@ -250,17 +255,26 @@ static LPVOID WINAPI IGetFrame_fnGetFrame(IGetFrame *iface, LONG lPos)
|
|||
/* not enough memory for input buffer? */
|
||||
readBytes = 0;
|
||||
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");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* IAVIStream::Read failed because of other reasons not buffersize? */
|
||||
if (This->cbInBuffer >= readBytes)
|
||||
break;
|
||||
This->lpInFormat = GlobalReAllocPtr(This->lpInFormat, This->cbInFormat + readBytes, 0);
|
||||
This->cbInBuffer = This->cbInFormat + readBytes;
|
||||
This->lpInFormat = GlobalReAllocPtr(This->lpInFormat, This->cbInBuffer, 0);
|
||||
if (This->lpInFormat == NULL)
|
||||
return NULL;
|
||||
return NULL; /* out of memory */
|
||||
This->lpInBuffer = (BYTE*)This->lpInFormat + This->cbInFormat;
|
||||
}
|
||||
|
||||
if (readSamples != 1)
|
||||
if (readSamples != 1) {
|
||||
ERR(": no frames read\n");
|
||||
return NULL;
|
||||
}
|
||||
if (readBytes != 0) {
|
||||
This->lpInFormat->biSizeImage = readBytes;
|
||||
|
||||
|
@ -349,7 +363,8 @@ static HRESULT WINAPI IGetFrame_fnSetFormat(IGetFrame *iface,
|
|||
if (This->cbInBuffer == 0)
|
||||
This->cbInBuffer = 1024;
|
||||
|
||||
AVIStreamFormatSize(This->pStream, sInfo.dwStart, &This->cbInFormat);
|
||||
IAVIStream_ReadFormat(This->pStream, sInfo.dwStart,
|
||||
NULL, &This->cbInFormat);
|
||||
|
||||
This->lpInFormat =
|
||||
(LPBITMAPINFOHEADER)GlobalAllocPtr(GHND, This->cbInFormat + This->cbInBuffer);
|
||||
|
@ -358,7 +373,7 @@ static HRESULT WINAPI IGetFrame_fnSetFormat(IGetFrame *iface,
|
|||
return AVIERR_MEMORY;
|
||||
}
|
||||
|
||||
hr = AVIStreamReadFormat(This->pStream, sInfo.dwStart, This->lpInFormat, &This->cbInFormat);
|
||||
hr = IAVIStream_ReadFormat(This->pStream, sInfo.dwStart, This->lpInFormat, &This->cbInFormat);
|
||||
if (FAILED(hr)) {
|
||||
AVIFILE_CloseCompressor(This);
|
||||
return hr;
|
||||
|
|
Loading…
Reference in New Issue