Fixed multiple bugs in FindSample implementation of AVI and WAV file
handler.
This commit is contained in:
parent
12f7a36132
commit
edd8bc3a77
|
@ -840,15 +840,19 @@ static LONG WINAPI IAVIStream_fnFindSample(IAVIStream *iface, LONG pos,
|
|||
ULONG n;
|
||||
|
||||
for (n = 0; n < This->sInfo.dwFormatChangeCount; n++)
|
||||
if (This->idxFmtChanges[n].ckid >= pos)
|
||||
if (This->idxFmtChanges[n].ckid >= pos) {
|
||||
pos = This->idxFmtChanges[n].ckid;
|
||||
goto RETURN_FOUND;
|
||||
}
|
||||
} else {
|
||||
LONG n;
|
||||
|
||||
for (n = (LONG)This->sInfo.dwFormatChangeCount; n >= 0; n--) {
|
||||
if (This->idxFmtChanges[n].ckid <= pos)
|
||||
if (This->idxFmtChanges[n].ckid <= pos) {
|
||||
pos = This->idxFmtChanges[n].ckid;
|
||||
goto RETURN_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
if (pos > (LONG)This->sInfo.dwStart)
|
||||
return 0; /* format changes always for first frame */
|
||||
|
@ -858,32 +862,36 @@ static LONG WINAPI IAVIStream_fnFindSample(IAVIStream *iface, LONG pos,
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (flags & FIND_RET) {
|
||||
RETURN_FOUND:
|
||||
if (flags & FIND_LENGTH) {
|
||||
if (pos < (LONG)This->sInfo.dwStart)
|
||||
return -1;
|
||||
|
||||
switch (flags & FIND_RET) {
|
||||
case FIND_LENGTH:
|
||||
/* physical size */
|
||||
pos = This->idxFrames[pos].dwChunkLength;
|
||||
break;
|
||||
case FIND_OFFSET:
|
||||
/* physical position */
|
||||
pos = This->idxFrames[pos].dwChunkOffset + 2 * sizeof(DWORD)
|
||||
+ offset * This->sInfo.dwSampleSize;
|
||||
break;
|
||||
case FIND_SIZE:
|
||||
/* logical size */
|
||||
if (This->sInfo.dwSampleSize)
|
||||
pos = This->sInfo.dwSampleSize;
|
||||
else
|
||||
pos = 1;
|
||||
} else if (flags & FIND_OFFSET) {
|
||||
/* physical position */
|
||||
pos = This->idxFrames[pos].dwChunkOffset + offset * This->sInfo.dwSampleSize;
|
||||
} else if (flags & FIND_SIZE) {
|
||||
/* physical size */
|
||||
pos = This->idxFrames[pos].dwChunkLength;
|
||||
} else if (flags & FIND_INDEX) {
|
||||
FIXME(": FIND_INDEX flag is not supported!");
|
||||
|
||||
pos = This->paf->dwIdxChunkPos;
|
||||
} /* else logical position */
|
||||
break;
|
||||
case FIND_INDEX:
|
||||
FIXME(": FIND_INDEX flag is not supported!\n");
|
||||
/* This is an index in the index-table on disc. */
|
||||
break;
|
||||
}; /* else logical position */
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IAVIStream_fnReadFormat(IAVIStream *iface, LONG pos,
|
||||
LPVOID format, LONG *formatsize)
|
||||
{
|
||||
|
|
|
@ -757,9 +757,10 @@ static LONG WINAPI IAVIStream_fnFindSample(IAVIStream *iface, LONG pos,
|
|||
pos = 0;
|
||||
}
|
||||
|
||||
if (flags & (FIND_LENGTH|FIND_SIZE))
|
||||
if ((flags & FIND_RET) == FIND_LENGTH ||
|
||||
(flags & FIND_RET) == FIND_SIZE)
|
||||
return This->sInfo.dwSampleSize;
|
||||
if (flags & FIND_OFFSET)
|
||||
if ((flags & FIND_RET) == FIND_OFFSET)
|
||||
return This->ckData.dwDataOffset + pos * This->sInfo.dwSampleSize;
|
||||
|
||||
return pos;
|
||||
|
|
Loading…
Reference in New Issue