I'm working on fixing some things in avifil32. Several problems should
be gone when using the attached four patches and most AVI files play
back properly.
With one file however (GOODTIME.AVI from the win95 cd) I get this error
after about a second:
err:heap:HEAP_ValidateInUseArena Heap 0x110000: in-use arena 0x184420
next block has PREV_FREE flag
non enough memory
I have no idea where this comes from and why it happens. (It appears to
be unrelated to the memcpy call in avifile.c around line 1114.) With
+heap I also get this before the error:
HIGHPERF/GOODTIME.AVI: heap.c:403: HEAP_GetPtr: Controletest '0' faalt.
(the assert fails)
What could I try to figure out the cause of this problem? I can provide
both the file and my test program if necessary. Note that on MS Windows
XP it all works without problems.
From a5fdf2316923e9b4fd254e571b5f70cb5a5ee87f Mon Sep 17 00:00:00 2001
From: Julius Schwartzenberg julius.schwartzenberg@gmail.com
Date: Sun, 8 Nov 2009 15:18:26 +0100
Subject: 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 84a0ee0327569c91c74d99be3c124c09cfc45cb9 Mon Sep 17 00:00:00 2001
From: Julius Schwartzenberg
julius.schwartzenberg@gmail.com
Date: Sun, 8 Nov 2009 15:28:19 +0100
Subject: 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 c6437174e6c2241b95b0d9b30ae6d2cac8218cdc Mon Sep 17 00:00:00 2001
From: Julius Schwartzenberg
julius.schwartzenberg@gmail.com
Date: Sun, 8 Nov 2009 15:32:33 +0100
Subject: 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
From 9a429b3146f6718b3742816e2ff163e65e1ad748 Mon Sep 17 00:00:00 2001
From: Julius Schwartzenberg
julius.schwartzenberg@gmail.com
Date: Sun, 15 Nov 2009 17:07:52 +0100
Subject: Fix ticking problem which occured when reading through a block
---
dlls/avifil32/avifile.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/dlls/avifil32/avifile.c b/dlls/avifil32/avifile.c
index 5fa45ae..88bf2ab 100644
--- a/dlls/avifil32/avifile.c
+++ b/dlls/avifil32/avifile.c
@@ -1089,6 +1089,7 @@ static HRESULT WINAPI IAVIStream_fnRead(IAVIStream *iface, LONG start,
/* convert start sample to block,offset pair */
AVIFILE_SamplesToBlock(This, &block, &offset);
+ TRACE("block=%d, offset=%d\n", block, offset);
/* convert samples to bytes */
samples *= This->sInfo.dwSampleSize;
@@ -1097,6 +1098,7 @@ static HRESULT WINAPI IAVIStream_fnRead(IAVIStream *iface, LONG start,
buffersize = samples;
while (samples > 0 && buffersize > 0) {
+ LONG blocksize;
if (block != This->dwCurrentFrame) {
hr = AVIFILE_ReadBlock(This, block, NULL, 0);
if (FAILED(hr))
@@ -1104,7 +1106,10 @@ static HRESULT WINAPI IAVIStream_fnRead(IAVIStream *iface, LONG start,
}
size = min((DWORD)samples, (DWORD)buffersize);
- size = min(size, This->cbBuffer - offset);
+ blocksize = (BYTE*)This->lpBuffer[1];
+/* blocksize = This->cbBuffer; */
+ TRACE("blocksize = %u\n",blocksize);
+ size = min(size, blocksize - offset);
if (buffer)
memcpy(buffer, ((BYTE*)&This->lpBuffer[2]) + offset, size);
block++;
--
1.6.3.3