Here are some bugfixes for avifile that Maarten mainly did during WineConf. The behaviour corresponds to what native avifil32 does. I will add tests to show this and submit the patches then. (Maybe avifil32 does a few more hacks like these, I'll add those too when I find them when creating tests.) If anyone has any comments on the patches as they are now already, please let me know. Thanks! Julius
From 2e9c13211c0343fd59faf835a1d954416ab46203 Mon Sep 17 00:00:00 2001 From: Julius Schwartzenberg <julius.schwartzenberg(a)gmail.com> Date: Sun, 8 Nov 2009 15:18:26 +0100 Subject: [PATCH 1/3] avifile: Fix header for audio stream
--- dlls/avifil32/avifile.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/dlls/avifil32/avifile.c b/dlls/avifil32/avifile.c index 49e141f..4ecc6f6 100644 --- a/dlls/avifil32/avifile.c +++ b/dlls/avifil32/avifile.c @@ -1816,7 +1816,15 @@ static HRESULT AVIFILE_LoadFile(IAVIFileImpl *This) if (FAILED(hr)) return hr; }; - + if (pStream->lpFormat != NULL && pStream->sInfo.fccType == streamtypeAUDIO) + { + WAVEFORMATEX *wfx = pStream->lpFormat; + wfx->nBlockAlign = wfx->nChannels * wfx->wBitsPerSample / 8; + pStream->sInfo.dwSampleSize = wfx->nBlockAlign; + TRACE("Block size reset to %u, chan=%u bpp=%u\n", wfx->nBlockAlign, wfx->nChannels, wfx->wBitsPerSample); + pStream->sInfo.dwScale = 1; + pStream->sInfo.dwRate = wfx->nSamplesPerSec; + } if (mmioAscend(This->hmmio, &ck, 0) != S_OK) return AVIERR_FILEREAD; } -- 1.6.3.3
From 969620de75ae75d13cf5f443842cee8bf28c4362 Mon Sep 17 00:00:00 2001 From: Julius Schwartzenberg <julius.schwartzenberg(a)gmail.com> Date: Sun, 8 Nov 2009 15:28:19 +0100 Subject: [PATCH 2/3] avifile: Fix header suggested buffersize
--- dlls/avifil32/avifile.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/dlls/avifil32/avifile.c b/dlls/avifil32/avifile.c index 4ecc6f6..c40cbd9 100644 --- a/dlls/avifil32/avifile.c +++ b/dlls/avifil32/avifile.c @@ -1652,7 +1652,7 @@ static HRESULT AVIFILE_LoadFile(IAVIFileImpl *This) This->fInfo.dwCaps = AVIFILECAPS_CANREAD|AVIFILECAPS_CANWRITE; This->fInfo.dwLength = MainAVIHdr.dwTotalFrames; This->fInfo.dwStreams = MainAVIHdr.dwStreams; - This->fInfo.dwSuggestedBufferSize = MainAVIHdr.dwSuggestedBufferSize; + This->fInfo.dwSuggestedBufferSize = 0; This->fInfo.dwWidth = MainAVIHdr.dwWidth; This->fInfo.dwHeight = MainAVIHdr.dwHeight; LoadStringW(AVIFILE_hModule, IDS_AVIFILETYPE, This->fInfo.szFileType, @@ -1754,8 +1754,7 @@ static HRESULT AVIFILE_LoadFile(IAVIFileImpl *This) pStream->sInfo.dwRate = streamHdr.dwRate; pStream->sInfo.dwStart = streamHdr.dwStart; pStream->sInfo.dwLength = streamHdr.dwLength; - pStream->sInfo.dwSuggestedBufferSize = - streamHdr.dwSuggestedBufferSize; + pStream->sInfo.dwSuggestedBufferSize = 0; pStream->sInfo.dwQuality = streamHdr.dwQuality; pStream->sInfo.dwSampleSize = streamHdr.dwSampleSize; pStream->sInfo.rcFrame.left = streamHdr.rcFrame.left; @@ -1905,6 +1904,13 @@ static HRESULT AVIFILE_LoadFile(IAVIFileImpl *This) } } + for (nStream = 0; nStream < This->fInfo.dwStreams; nStream++) + { + DWORD sugbuf = This->ppStreams[nStream]->sInfo.dwSuggestedBufferSize; + if (This->fInfo.dwSuggestedBufferSize < sugbuf) + This->fInfo.dwSuggestedBufferSize = sugbuf; + } + /* find other chunks */ FindChunkAndKeepExtras(&This->fileextra, This->hmmio, &ck, &ckRIFF, 0); -- 1.6.3.3
From 39d6ecab76989b93d35a0568e105fd306fa32706 Mon Sep 17 00:00:00 2001 From: Julius Schwartzenberg <julius.schwartzenberg(a)gmail.com> Date: Sun, 8 Nov 2009 15:32:33 +0100 Subject: [PATCH 3/3] avifile: Fix playback of fixed sample size audio stream
--- dlls/avifil32/avifile.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-) diff --git a/dlls/avifil32/avifile.c b/dlls/avifil32/avifile.c index c40cbd9..5fa45ae 100644 --- a/dlls/avifil32/avifile.c +++ b/dlls/avifil32/avifile.c @@ -1093,6 +1093,9 @@ static HRESULT WINAPI IAVIStream_fnRead(IAVIStream *iface, LONG start, /* convert samples to bytes */ samples *= This->sInfo.dwSampleSize; + if (!buffer) + buffersize = samples; + while (samples > 0 && buffersize > 0) { if (block != This->dwCurrentFrame) { hr = AVIFILE_ReadBlock(This, block, NULL, 0); @@ -1102,11 +1105,12 @@ static HRESULT WINAPI IAVIStream_fnRead(IAVIStream *iface, LONG start, size = min((DWORD)samples, (DWORD)buffersize); size = min(size, This->cbBuffer - offset); - memcpy(buffer, ((BYTE*)&This->lpBuffer[2]) + offset, size); - + if (buffer) + memcpy(buffer, ((BYTE*)&This->lpBuffer[2]) + offset, size); block++; offset = 0; - buffer = ((LPBYTE)buffer)+size; + if (buffer) + buffer = ((LPBYTE)buffer)+size; samples -= size; buffersize -= size; @@ -1117,7 +1121,9 @@ static HRESULT WINAPI IAVIStream_fnRead(IAVIStream *iface, LONG start, *samplesread += size / This->sInfo.dwSampleSize; } - if (samples == 0) + TRACE("Returning %d/%d\n", bytesread ? *bytesread : -1, samplesread ? *samplesread : -1); + + if (samples == 0 || !buffer) return AVIERR_OK; else return AVIERR_BUFFERTOOSMALL; -- 1.6.3.3
On Di, 2009-11-10 at 00:43 +0100, Julius Schwartzenberg wrote:
I will add tests to show this and submit the patches then.
I created a test for avifil32 in June 2008, but it was not comitted. ( http://www.winehq.org/pipermail/wine-patches/2008-June/056310.html ) The bug 14085 was created to document the required feature: http://bugs.winehq.org/show_bug.cgi?id=14085 an importlib for multiple dlls is not supported (avicap32 + avifil32 + msvfw32 => vfw32) You can and should create tests (crosscompile them to check the Windows results and to verify the implementation changes) and send them as a seperate patch, but the patche can't be comitted before bug 14085 is fixed. -- By by ... Detlef
Detlef Riekenberg wrote:
On Di, 2009-11-10 at 00:43 +0100, Julius Schwartzenberg wrote:
I will add tests to show this and submit the patches then.
I created a test for avifil32 in June 2008, but it was not comitted. ( http://www.winehq.org/pipermail/wine-patches/2008-June/056310.html )
Thanks for the pointer. I was already wondering why there were no tests in the avifil32 directory. I'll keep this in mind. There are some tests that use avifile in winmm though. Julius
participants (2)
-
Detlef Riekenberg -
Julius Schwartzenberg