2001-02-14 21:49:22 +00:00
|
|
|
/*
|
|
|
|
* Digital video MCI Wine Driver
|
|
|
|
*
|
|
|
|
* Copyright 1999, 2000 Eric POUECH
|
2004-01-01 00:48:01 +00:00
|
|
|
* Copyright 2003 Dmitry Timoshkov
|
2002-03-09 23:29:33 +00:00
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2001-02-14 21:49:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "private_mciavi.h"
|
2002-03-09 23:29:33 +00:00
|
|
|
#include "wine/debug.h"
|
2001-02-14 21:49:22 +00:00
|
|
|
|
2002-03-09 23:29:33 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(mciavi);
|
2001-02-14 21:49:22 +00:00
|
|
|
|
2004-01-01 00:48:01 +00:00
|
|
|
static BOOL MCIAVI_GetInfoAudio(WINE_MCIAVI* wma, const MMCKINFO* mmckList, MMCKINFO *mmckStream)
|
2001-02-14 21:49:22 +00:00
|
|
|
{
|
|
|
|
MMCKINFO mmckInfo;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
|
|
|
TRACE("ash.fccType='%c%c%c%c'\n", LOBYTE(LOWORD(wma->ash_audio.fccType)),
|
|
|
|
HIBYTE(LOWORD(wma->ash_audio.fccType)),
|
|
|
|
LOBYTE(HIWORD(wma->ash_audio.fccType)),
|
2001-02-14 21:49:22 +00:00
|
|
|
HIBYTE(HIWORD(wma->ash_audio.fccType)));
|
2004-08-09 18:47:37 +00:00
|
|
|
if (wma->ash_audio.fccHandler) /* not all streams specify a handler */
|
|
|
|
TRACE("ash.fccHandler='%c%c%c%c'\n", LOBYTE(LOWORD(wma->ash_audio.fccHandler)),
|
2002-05-31 23:06:46 +00:00
|
|
|
HIBYTE(LOWORD(wma->ash_audio.fccHandler)),
|
|
|
|
LOBYTE(HIWORD(wma->ash_audio.fccHandler)),
|
2001-02-14 21:49:22 +00:00
|
|
|
HIBYTE(HIWORD(wma->ash_audio.fccHandler)));
|
2004-08-09 18:47:37 +00:00
|
|
|
else
|
|
|
|
TRACE("ash.fccHandler=0, no handler specified\n");
|
2006-10-12 19:34:57 +00:00
|
|
|
TRACE("ash.dwFlags=%d\n", wma->ash_audio.dwFlags);
|
2001-02-14 21:49:22 +00:00
|
|
|
TRACE("ash.wPriority=%d\n", wma->ash_audio.wPriority);
|
|
|
|
TRACE("ash.wLanguage=%d\n", wma->ash_audio.wLanguage);
|
2006-10-12 19:34:57 +00:00
|
|
|
TRACE("ash.dwInitialFrames=%d\n", wma->ash_audio.dwInitialFrames);
|
|
|
|
TRACE("ash.dwScale=%d\n", wma->ash_audio.dwScale);
|
|
|
|
TRACE("ash.dwRate=%d\n", wma->ash_audio.dwRate);
|
|
|
|
TRACE("ash.dwStart=%d\n", wma->ash_audio.dwStart);
|
|
|
|
TRACE("ash.dwLength=%d\n", wma->ash_audio.dwLength);
|
|
|
|
TRACE("ash.dwSuggestedBufferSize=%d\n", wma->ash_audio.dwSuggestedBufferSize);
|
|
|
|
TRACE("ash.dwQuality=%d\n", wma->ash_audio.dwQuality);
|
|
|
|
TRACE("ash.dwSampleSize=%d\n", wma->ash_audio.dwSampleSize);
|
2002-05-31 23:06:46 +00:00
|
|
|
TRACE("ash.rcFrame=(%d,%d,%d,%d)\n", wma->ash_audio.rcFrame.top, wma->ash_audio.rcFrame.left,
|
2001-02-14 21:49:22 +00:00
|
|
|
wma->ash_audio.rcFrame.bottom, wma->ash_audio.rcFrame.right);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2004-01-01 00:48:01 +00:00
|
|
|
/* rewind to the start of the stream */
|
|
|
|
mmioAscend(wma->hFile, mmckStream, 0);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
mmckInfo.ckid = ckidSTREAMFORMAT;
|
|
|
|
if (mmioDescend(wma->hFile, &mmckInfo, mmckList, MMIO_FINDCHUNK) != 0) {
|
2004-01-01 00:48:01 +00:00
|
|
|
WARN("Can't find 'strf' chunk\n");
|
2001-02-14 21:49:22 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (mmckInfo.cksize < sizeof(WAVEFORMAT)) {
|
2006-10-12 19:34:57 +00:00
|
|
|
WARN("Size of strf chunk (%d) < audio format struct\n", mmckInfo.cksize);
|
2001-02-14 21:49:22 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
wma->lpWaveFormat = HeapAlloc(GetProcessHeap(), 0, mmckInfo.cksize);
|
|
|
|
if (!wma->lpWaveFormat) {
|
|
|
|
WARN("Can't alloc WaveFormat\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
mmioRead(wma->hFile, (LPSTR)wma->lpWaveFormat, mmckInfo.cksize);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
TRACE("waveFormat.wFormatTag=%d\n", wma->lpWaveFormat->wFormatTag);
|
|
|
|
TRACE("waveFormat.nChannels=%d\n", wma->lpWaveFormat->nChannels);
|
2006-10-12 19:34:57 +00:00
|
|
|
TRACE("waveFormat.nSamplesPerSec=%d\n", wma->lpWaveFormat->nSamplesPerSec);
|
|
|
|
TRACE("waveFormat.nAvgBytesPerSec=%d\n", wma->lpWaveFormat->nAvgBytesPerSec);
|
2001-02-14 21:49:22 +00:00
|
|
|
TRACE("waveFormat.nBlockAlign=%d\n", wma->lpWaveFormat->nBlockAlign);
|
|
|
|
TRACE("waveFormat.wBitsPerSample=%d\n", wma->lpWaveFormat->wBitsPerSample);
|
|
|
|
if (mmckInfo.cksize >= sizeof(WAVEFORMATEX))
|
|
|
|
TRACE("waveFormat.cbSize=%d\n", wma->lpWaveFormat->cbSize);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-01-01 00:48:01 +00:00
|
|
|
static BOOL MCIAVI_GetInfoVideo(WINE_MCIAVI* wma, const MMCKINFO* mmckList, MMCKINFO* mmckStream)
|
2001-02-14 21:49:22 +00:00
|
|
|
{
|
|
|
|
MMCKINFO mmckInfo;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
|
|
|
TRACE("ash.fccType='%c%c%c%c'\n", LOBYTE(LOWORD(wma->ash_video.fccType)),
|
|
|
|
HIBYTE(LOWORD(wma->ash_video.fccType)),
|
|
|
|
LOBYTE(HIWORD(wma->ash_video.fccType)),
|
2001-02-14 21:49:22 +00:00
|
|
|
HIBYTE(HIWORD(wma->ash_video.fccType)));
|
2002-05-31 23:06:46 +00:00
|
|
|
TRACE("ash.fccHandler='%c%c%c%c'\n", LOBYTE(LOWORD(wma->ash_video.fccHandler)),
|
|
|
|
HIBYTE(LOWORD(wma->ash_video.fccHandler)),
|
|
|
|
LOBYTE(HIWORD(wma->ash_video.fccHandler)),
|
2001-02-14 21:49:22 +00:00
|
|
|
HIBYTE(HIWORD(wma->ash_video.fccHandler)));
|
2006-10-12 19:34:57 +00:00
|
|
|
TRACE("ash.dwFlags=%d\n", wma->ash_video.dwFlags);
|
2001-02-14 21:49:22 +00:00
|
|
|
TRACE("ash.wPriority=%d\n", wma->ash_video.wPriority);
|
|
|
|
TRACE("ash.wLanguage=%d\n", wma->ash_video.wLanguage);
|
2006-10-12 19:34:57 +00:00
|
|
|
TRACE("ash.dwInitialFrames=%d\n", wma->ash_video.dwInitialFrames);
|
|
|
|
TRACE("ash.dwScale=%d\n", wma->ash_video.dwScale);
|
|
|
|
TRACE("ash.dwRate=%d\n", wma->ash_video.dwRate);
|
|
|
|
TRACE("ash.dwStart=%d\n", wma->ash_video.dwStart);
|
|
|
|
TRACE("ash.dwLength=%d\n", wma->ash_video.dwLength);
|
|
|
|
TRACE("ash.dwSuggestedBufferSize=%d\n", wma->ash_video.dwSuggestedBufferSize);
|
|
|
|
TRACE("ash.dwQuality=%d\n", wma->ash_video.dwQuality);
|
|
|
|
TRACE("ash.dwSampleSize=%d\n", wma->ash_video.dwSampleSize);
|
2002-05-31 23:06:46 +00:00
|
|
|
TRACE("ash.rcFrame=(%d,%d,%d,%d)\n", wma->ash_video.rcFrame.top, wma->ash_video.rcFrame.left,
|
2001-02-14 21:49:22 +00:00
|
|
|
wma->ash_video.rcFrame.bottom, wma->ash_video.rcFrame.right);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2004-01-01 00:48:01 +00:00
|
|
|
/* rewind to the start of the stream */
|
|
|
|
mmioAscend(wma->hFile, mmckStream, 0);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
mmckInfo.ckid = ckidSTREAMFORMAT;
|
|
|
|
if (mmioDescend(wma->hFile, &mmckInfo, mmckList, MMIO_FINDCHUNK) != 0) {
|
2004-01-01 00:48:01 +00:00
|
|
|
WARN("Can't find 'strf' chunk\n");
|
2001-02-14 21:49:22 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
wma->inbih = HeapAlloc(GetProcessHeap(), 0, mmckInfo.cksize);
|
|
|
|
if (!wma->inbih) {
|
|
|
|
WARN("Can't alloc input BIH\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
mmioRead(wma->hFile, (LPSTR)wma->inbih, mmckInfo.cksize);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2006-10-12 19:34:57 +00:00
|
|
|
TRACE("bih.biSize=%d\n", wma->inbih->biSize);
|
|
|
|
TRACE("bih.biWidth=%d\n", wma->inbih->biWidth);
|
|
|
|
TRACE("bih.biHeight=%d\n", wma->inbih->biHeight);
|
2001-02-14 21:49:22 +00:00
|
|
|
TRACE("bih.biPlanes=%d\n", wma->inbih->biPlanes);
|
|
|
|
TRACE("bih.biBitCount=%d\n", wma->inbih->biBitCount);
|
2006-10-12 19:34:57 +00:00
|
|
|
TRACE("bih.biCompression=%x\n", wma->inbih->biCompression);
|
|
|
|
TRACE("bih.biSizeImage=%d\n", wma->inbih->biSizeImage);
|
|
|
|
TRACE("bih.biXPelsPerMeter=%d\n", wma->inbih->biXPelsPerMeter);
|
|
|
|
TRACE("bih.biYPelsPerMeter=%d\n", wma->inbih->biYPelsPerMeter);
|
|
|
|
TRACE("bih.biClrUsed=%d\n", wma->inbih->biClrUsed);
|
|
|
|
TRACE("bih.biClrImportant=%d\n", wma->inbih->biClrImportant);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2004-01-01 00:48:01 +00:00
|
|
|
wma->source.left = 0;
|
|
|
|
wma->source.top = 0;
|
|
|
|
wma->source.right = wma->inbih->biWidth;
|
|
|
|
wma->source.bottom = wma->inbih->biHeight;
|
|
|
|
|
|
|
|
wma->dest = wma->source;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct AviListBuild {
|
|
|
|
DWORD numVideoFrames;
|
|
|
|
DWORD numAudioAllocated;
|
|
|
|
DWORD numAudioBlocks;
|
|
|
|
DWORD inVideoSize;
|
|
|
|
DWORD inAudioSize;
|
|
|
|
};
|
|
|
|
|
2002-05-31 23:06:46 +00:00
|
|
|
static BOOL MCIAVI_AddFrame(WINE_MCIAVI* wma, LPMMCKINFO mmck,
|
2001-02-14 21:49:22 +00:00
|
|
|
struct AviListBuild* alb)
|
|
|
|
{
|
2004-01-05 21:13:58 +00:00
|
|
|
const BYTE *p;
|
|
|
|
DWORD stream_n;
|
2004-03-16 01:14:39 +00:00
|
|
|
DWORD twocc;
|
2004-01-05 21:13:58 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
if (mmck->ckid == ckidAVIPADDING) return TRUE;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2004-01-05 21:13:58 +00:00
|
|
|
p = (const BYTE *)&mmck->ckid;
|
|
|
|
|
|
|
|
if (!isxdigit(p[0]) || !isxdigit(p[1]))
|
|
|
|
{
|
|
|
|
WARN("wrongly encoded stream #\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
stream_n = (p[0] <= '9') ? (p[0] - '0') : (tolower(p[0]) - 'a' + 10);
|
|
|
|
stream_n <<= 4;
|
|
|
|
stream_n |= (p[1] <= '9') ? (p[1] - '0') : (tolower(p[1]) - 'a' + 10);
|
|
|
|
|
2006-10-12 19:34:57 +00:00
|
|
|
TRACE("ckid %4.4s (stream #%d)\n", (LPSTR)&mmck->ckid, stream_n);
|
2004-01-05 21:13:58 +00:00
|
|
|
|
2004-03-16 01:14:39 +00:00
|
|
|
/* Some (rare?) AVI files have video streams name XXYY where XX = stream number and YY = TWOCC
|
|
|
|
* of the last 2 characters of the biCompression member of the BITMAPINFOHEADER structure.
|
|
|
|
* Ex: fccHandler = IV32 & biCompression = IV32 => stream name = XX32
|
|
|
|
* fccHandler = MSVC & biCompression = CRAM => stream name = XXAM
|
|
|
|
* Another possibility is that these TWOCC are simply ignored.
|
|
|
|
* Default to cktypeDIBcompressed when this case happens.
|
|
|
|
*/
|
|
|
|
twocc = TWOCCFromFOURCC(mmck->ckid);
|
|
|
|
if (twocc == TWOCCFromFOURCC(wma->inbih->biCompression))
|
|
|
|
twocc = cktypeDIBcompressed;
|
|
|
|
|
|
|
|
switch (twocc) {
|
2001-02-14 21:49:22 +00:00
|
|
|
case cktypeDIBbits:
|
|
|
|
case cktypeDIBcompressed:
|
|
|
|
case cktypePALchange:
|
2004-01-05 21:13:58 +00:00
|
|
|
if (stream_n != wma->video_stream_n)
|
|
|
|
{
|
2006-10-12 19:34:57 +00:00
|
|
|
TRACE("data belongs to another video stream #%d\n", stream_n);
|
2004-01-05 21:13:58 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-10-12 19:34:57 +00:00
|
|
|
TRACE("Adding video frame[%d]: %d bytes\n",
|
2001-02-14 21:49:22 +00:00
|
|
|
alb->numVideoFrames, mmck->cksize);
|
2004-01-01 00:48:01 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
if (alb->numVideoFrames < wma->dwPlayableVideoFrames) {
|
|
|
|
wma->lpVideoIndex[alb->numVideoFrames].dwOffset = mmck->dwDataOffset;
|
|
|
|
wma->lpVideoIndex[alb->numVideoFrames].dwSize = mmck->cksize;
|
|
|
|
if (alb->inVideoSize < mmck->cksize)
|
|
|
|
alb->inVideoSize = mmck->cksize;
|
|
|
|
alb->numVideoFrames++;
|
|
|
|
} else {
|
|
|
|
WARN("Too many video frames\n");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case cktypeWAVEbytes:
|
2004-01-05 21:13:58 +00:00
|
|
|
if (stream_n != wma->audio_stream_n)
|
|
|
|
{
|
2006-10-12 19:34:57 +00:00
|
|
|
TRACE("data belongs to another audio stream #%d\n", stream_n);
|
2004-01-05 21:13:58 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-10-12 19:34:57 +00:00
|
|
|
TRACE("Adding audio frame[%d]: %d bytes\n",
|
2001-02-14 21:49:22 +00:00
|
|
|
alb->numAudioBlocks, mmck->cksize);
|
|
|
|
if (wma->lpWaveFormat) {
|
|
|
|
if (alb->numAudioBlocks >= alb->numAudioAllocated) {
|
|
|
|
alb->numAudioAllocated += 32;
|
2003-11-21 23:54:04 +00:00
|
|
|
if (!wma->lpAudioIndex)
|
|
|
|
wma->lpAudioIndex = HeapAlloc(GetProcessHeap(), 0,
|
|
|
|
alb->numAudioAllocated * sizeof(struct MMIOPos));
|
|
|
|
else
|
|
|
|
wma->lpAudioIndex = HeapReAlloc(GetProcessHeap(), 0, wma->lpAudioIndex,
|
|
|
|
alb->numAudioAllocated * sizeof(struct MMIOPos));
|
2001-02-14 21:49:22 +00:00
|
|
|
if (!wma->lpAudioIndex) return FALSE;
|
|
|
|
}
|
|
|
|
wma->lpAudioIndex[alb->numAudioBlocks].dwOffset = mmck->dwDataOffset;
|
|
|
|
wma->lpAudioIndex[alb->numAudioBlocks].dwSize = mmck->cksize;
|
|
|
|
if (alb->inAudioSize < mmck->cksize)
|
|
|
|
alb->inAudioSize = mmck->cksize;
|
|
|
|
alb->numAudioBlocks++;
|
|
|
|
} else {
|
|
|
|
WARN("Wave chunk without wave format... discarding\n");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2004-01-05 21:13:58 +00:00
|
|
|
WARN("Unknown frame type %4.4s\n", (LPSTR)&mmck->ckid);
|
2001-02-14 21:49:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL MCIAVI_GetInfo(WINE_MCIAVI* wma)
|
|
|
|
{
|
|
|
|
MMCKINFO ckMainRIFF;
|
|
|
|
MMCKINFO mmckHead;
|
|
|
|
MMCKINFO mmckList;
|
|
|
|
MMCKINFO mmckInfo;
|
2008-06-25 12:27:37 +00:00
|
|
|
AVIStreamHeader strh;
|
2001-02-14 21:49:22 +00:00
|
|
|
struct AviListBuild alb;
|
2004-01-05 21:13:58 +00:00
|
|
|
DWORD stream_n;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
if (mmioDescend(wma->hFile, &ckMainRIFF, NULL, 0) != 0) {
|
|
|
|
WARN("Can't find 'RIFF' chunk\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
if ((ckMainRIFF.ckid != FOURCC_RIFF) || (ckMainRIFF.fccType != formtypeAVI)) {
|
|
|
|
WARN("Can't find 'AVI ' chunk\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
mmckHead.fccType = listtypeAVIHEADER;
|
|
|
|
if (mmioDescend(wma->hFile, &mmckHead, &ckMainRIFF, MMIO_FINDLIST) != 0) {
|
|
|
|
WARN("Can't find 'hdrl' list\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
mmckInfo.ckid = ckidAVIMAINHDR;
|
|
|
|
if (mmioDescend(wma->hFile, &mmckInfo, &mmckHead, MMIO_FINDCHUNK) != 0) {
|
|
|
|
WARN("Can't find 'avih' chunk\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
mmioRead(wma->hFile, (LPSTR)&wma->mah, sizeof(wma->mah));
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2006-10-12 19:34:57 +00:00
|
|
|
TRACE("mah.dwMicroSecPerFrame=%d\n", wma->mah.dwMicroSecPerFrame);
|
|
|
|
TRACE("mah.dwMaxBytesPerSec=%d\n", wma->mah.dwMaxBytesPerSec);
|
|
|
|
TRACE("mah.dwPaddingGranularity=%d\n", wma->mah.dwPaddingGranularity);
|
|
|
|
TRACE("mah.dwFlags=%d\n", wma->mah.dwFlags);
|
|
|
|
TRACE("mah.dwTotalFrames=%d\n", wma->mah.dwTotalFrames);
|
|
|
|
TRACE("mah.dwInitialFrames=%d\n", wma->mah.dwInitialFrames);
|
|
|
|
TRACE("mah.dwStreams=%d\n", wma->mah.dwStreams);
|
|
|
|
TRACE("mah.dwSuggestedBufferSize=%d\n", wma->mah.dwSuggestedBufferSize);
|
|
|
|
TRACE("mah.dwWidth=%d\n", wma->mah.dwWidth);
|
|
|
|
TRACE("mah.dwHeight=%d\n", wma->mah.dwHeight);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
mmioAscend(wma->hFile, &mmckInfo, 0);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2004-01-01 00:48:01 +00:00
|
|
|
TRACE("Start of streams\n");
|
2004-01-05 21:13:58 +00:00
|
|
|
wma->video_stream_n = 0;
|
|
|
|
wma->audio_stream_n = 0;
|
|
|
|
|
|
|
|
for (stream_n = 0; stream_n < wma->mah.dwStreams; stream_n++)
|
2004-01-01 00:48:01 +00:00
|
|
|
{
|
|
|
|
MMCKINFO mmckStream;
|
|
|
|
|
|
|
|
mmckList.fccType = listtypeSTREAMHEADER;
|
|
|
|
if (mmioDescend(wma->hFile, &mmckList, &mmckHead, MMIO_FINDLIST) != 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
mmckStream.ckid = ckidSTREAMHEADER;
|
|
|
|
if (mmioDescend(wma->hFile, &mmckStream, &mmckList, MMIO_FINDCHUNK) != 0)
|
|
|
|
{
|
|
|
|
WARN("Can't find 'strh' chunk\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2008-06-25 12:27:37 +00:00
|
|
|
mmioRead(wma->hFile, (LPSTR)&strh, sizeof(strh));
|
|
|
|
|
|
|
|
TRACE("Stream #%d fccType %4.4s\n", stream_n, (LPSTR)&strh.fccType);
|
2004-01-01 00:48:01 +00:00
|
|
|
|
2008-06-25 12:27:37 +00:00
|
|
|
if (strh.fccType == streamtypeVIDEO)
|
2004-01-01 00:48:01 +00:00
|
|
|
{
|
|
|
|
TRACE("found video stream\n");
|
2004-01-05 21:13:58 +00:00
|
|
|
if (wma->inbih)
|
|
|
|
WARN("ignoring another video stream\n");
|
|
|
|
else
|
|
|
|
{
|
2009-03-13 23:18:10 +00:00
|
|
|
wma->ash_video = strh;
|
2008-06-25 12:27:37 +00:00
|
|
|
|
2004-01-05 21:13:58 +00:00
|
|
|
if (!MCIAVI_GetInfoVideo(wma, &mmckList, &mmckStream))
|
|
|
|
return FALSE;
|
|
|
|
wma->video_stream_n = stream_n;
|
2009-12-15 17:44:19 +00:00
|
|
|
wma->dwSet |= 4;
|
2004-01-05 21:13:58 +00:00
|
|
|
}
|
2004-01-01 00:48:01 +00:00
|
|
|
}
|
2008-06-25 12:27:37 +00:00
|
|
|
else if (strh.fccType == streamtypeAUDIO)
|
2004-01-01 00:48:01 +00:00
|
|
|
{
|
|
|
|
TRACE("found audio stream\n");
|
2004-01-05 21:13:58 +00:00
|
|
|
if (wma->lpWaveFormat)
|
|
|
|
WARN("ignoring another audio stream\n");
|
|
|
|
else
|
|
|
|
{
|
2009-03-13 23:18:10 +00:00
|
|
|
wma->ash_audio = strh;
|
2008-06-25 12:27:37 +00:00
|
|
|
|
2004-01-05 21:13:58 +00:00
|
|
|
if (!MCIAVI_GetInfoAudio(wma, &mmckList, &mmckStream))
|
|
|
|
return FALSE;
|
|
|
|
wma->audio_stream_n = stream_n;
|
2009-12-15 17:44:19 +00:00
|
|
|
wma->dwSet |= 3;
|
2004-01-05 21:13:58 +00:00
|
|
|
}
|
2004-01-01 00:48:01 +00:00
|
|
|
}
|
|
|
|
else
|
2008-06-25 12:27:37 +00:00
|
|
|
TRACE("Unsupported stream type %4.4s\n", (LPSTR)&strh.fccType);
|
2004-01-01 00:48:01 +00:00
|
|
|
|
|
|
|
mmioAscend(wma->hFile, &mmckList, 0);
|
2004-01-05 21:13:58 +00:00
|
|
|
}
|
2004-01-01 00:48:01 +00:00
|
|
|
|
|
|
|
TRACE("End of streams\n");
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
mmioAscend(wma->hFile, &mmckHead, 0);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
/* no need to read optional JUNK chunk */
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
mmckList.fccType = listtypeAVIMOVIE;
|
|
|
|
if (mmioDescend(wma->hFile, &mmckList, &ckMainRIFF, MMIO_FINDLIST) != 0) {
|
|
|
|
WARN("Can't find 'movi' list\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
wma->dwPlayableVideoFrames = wma->mah.dwTotalFrames;
|
2002-05-31 23:06:46 +00:00
|
|
|
wma->lpVideoIndex = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
2001-02-14 21:49:22 +00:00
|
|
|
wma->dwPlayableVideoFrames * sizeof(struct MMIOPos));
|
|
|
|
if (!wma->lpVideoIndex) {
|
|
|
|
WARN("Can't alloc video index array\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
wma->dwPlayableAudioBlocks = 0;
|
2003-11-21 23:54:04 +00:00
|
|
|
wma->lpAudioIndex = NULL;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
alb.numAudioBlocks = alb.numVideoFrames = 0;
|
|
|
|
alb.inVideoSize = alb.inAudioSize = 0;
|
|
|
|
alb.numAudioAllocated = 0;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
while (mmioDescend(wma->hFile, &mmckInfo, &mmckList, 0) == 0) {
|
2002-05-31 23:06:46 +00:00
|
|
|
if (mmckInfo.fccType == listtypeAVIRECORD) {
|
2001-02-14 21:49:22 +00:00
|
|
|
MMCKINFO tmp;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
while (mmioDescend(wma->hFile, &tmp, &mmckInfo, 0) == 0) {
|
|
|
|
MCIAVI_AddFrame(wma, &tmp, &alb);
|
|
|
|
mmioAscend(wma->hFile, &tmp, 0);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
MCIAVI_AddFrame(wma, &mmckInfo, &alb);
|
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
mmioAscend(wma->hFile, &mmckInfo, 0);
|
|
|
|
}
|
|
|
|
if (alb.numVideoFrames != wma->dwPlayableVideoFrames) {
|
2006-10-12 19:34:57 +00:00
|
|
|
WARN("Found %d video frames (/%d), reducing playable frames\n",
|
2001-02-14 21:49:22 +00:00
|
|
|
alb.numVideoFrames, wma->dwPlayableVideoFrames);
|
|
|
|
wma->dwPlayableVideoFrames = alb.numVideoFrames;
|
|
|
|
}
|
|
|
|
wma->dwPlayableAudioBlocks = alb.numAudioBlocks;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
if (alb.inVideoSize > wma->ash_video.dwSuggestedBufferSize) {
|
2006-10-12 19:34:57 +00:00
|
|
|
WARN("inVideoSize=%d suggestedSize=%d\n", alb.inVideoSize, wma->ash_video.dwSuggestedBufferSize);
|
2001-02-14 21:49:22 +00:00
|
|
|
wma->ash_video.dwSuggestedBufferSize = alb.inVideoSize;
|
|
|
|
}
|
|
|
|
if (alb.inAudioSize > wma->ash_audio.dwSuggestedBufferSize) {
|
2006-10-12 19:34:57 +00:00
|
|
|
WARN("inAudioSize=%d suggestedSize=%d\n", alb.inAudioSize, wma->ash_audio.dwSuggestedBufferSize);
|
2001-02-14 21:49:22 +00:00
|
|
|
wma->ash_audio.dwSuggestedBufferSize = alb.inAudioSize;
|
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
wma->indata = HeapAlloc(GetProcessHeap(), 0, wma->ash_video.dwSuggestedBufferSize);
|
|
|
|
if (!wma->indata) {
|
|
|
|
WARN("Can't alloc input buffer\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL MCIAVI_OpenVideo(WINE_MCIAVI* wma)
|
|
|
|
{
|
2004-03-01 23:38:25 +00:00
|
|
|
HDC hDC;
|
2001-02-14 21:49:22 +00:00
|
|
|
DWORD outSize;
|
|
|
|
FOURCC fcc = wma->ash_video.fccHandler;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2004-01-01 00:48:01 +00:00
|
|
|
TRACE("fcc %4.4s\n", (LPSTR)&fcc);
|
|
|
|
|
2004-03-01 23:38:25 +00:00
|
|
|
wma->dwCachedFrame = -1;
|
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
/* get the right handle */
|
|
|
|
if (fcc == mmioFOURCC('C','R','A','M')) fcc = mmioFOURCC('M','S','V','C');
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
/* try to get a decompressor for that type */
|
|
|
|
wma->hic = ICLocate(ICTYPE_VIDEO, fcc, wma->inbih, NULL, ICMODE_DECOMPRESS);
|
|
|
|
if (!wma->hic) {
|
2004-04-05 20:19:09 +00:00
|
|
|
/* check for builtin DIB compressions */
|
|
|
|
fcc = wma->inbih->biCompression;
|
|
|
|
if ((fcc == mmioFOURCC('D','I','B',' ')) ||
|
|
|
|
(fcc == mmioFOURCC('R','L','E',' ')) ||
|
|
|
|
(fcc == BI_RGB) || (fcc == BI_RLE8) ||
|
|
|
|
(fcc == BI_RLE4) || (fcc == BI_BITFIELDS))
|
|
|
|
goto paint_frame;
|
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
WARN("Can't locate codec for the file\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
outSize = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
wma->outbih = HeapAlloc(GetProcessHeap(), 0, outSize);
|
|
|
|
if (!wma->outbih) {
|
|
|
|
WARN("Can't alloc output BIH\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!ICGetDisplayFormat(wma->hic, wma->inbih, wma->outbih, 0, 0, 0)) {
|
|
|
|
WARN("Can't open decompressor\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2006-10-12 19:34:57 +00:00
|
|
|
TRACE("bih.biSize=%d\n", wma->outbih->biSize);
|
|
|
|
TRACE("bih.biWidth=%d\n", wma->outbih->biWidth);
|
|
|
|
TRACE("bih.biHeight=%d\n", wma->outbih->biHeight);
|
2001-02-14 21:49:22 +00:00
|
|
|
TRACE("bih.biPlanes=%d\n", wma->outbih->biPlanes);
|
|
|
|
TRACE("bih.biBitCount=%d\n", wma->outbih->biBitCount);
|
2006-10-12 19:34:57 +00:00
|
|
|
TRACE("bih.biCompression=%x\n", wma->outbih->biCompression);
|
|
|
|
TRACE("bih.biSizeImage=%d\n", wma->outbih->biSizeImage);
|
|
|
|
TRACE("bih.biXPelsPerMeter=%d\n", wma->outbih->biXPelsPerMeter);
|
|
|
|
TRACE("bih.biYPelsPerMeter=%d\n", wma->outbih->biYPelsPerMeter);
|
|
|
|
TRACE("bih.biClrUsed=%d\n", wma->outbih->biClrUsed);
|
|
|
|
TRACE("bih.biClrImportant=%d\n", wma->outbih->biClrImportant);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
wma->outdata = HeapAlloc(GetProcessHeap(), 0, wma->outbih->biSizeImage);
|
|
|
|
if (!wma->outdata) {
|
|
|
|
WARN("Can't alloc output buffer\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
|
|
|
if (ICSendMessage(wma->hic, ICM_DECOMPRESS_BEGIN,
|
2007-05-31 14:00:52 +00:00
|
|
|
(DWORD_PTR)wma->inbih, (DWORD_PTR)wma->outbih) != ICERR_OK) {
|
2001-02-14 21:49:22 +00:00
|
|
|
WARN("Can't begin decompression\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2004-03-01 23:38:25 +00:00
|
|
|
paint_frame:
|
|
|
|
hDC = wma->hWndPaint ? GetDC(wma->hWndPaint) : 0;
|
|
|
|
if (hDC)
|
|
|
|
{
|
|
|
|
MCIAVI_PaintFrame(wma, hDC);
|
|
|
|
ReleaseDC(wma->hWndPaint, hDC);
|
|
|
|
}
|
2001-02-14 21:49:22 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-01-01 00:48:01 +00:00
|
|
|
static void CALLBACK MCIAVI_waveCallback(HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance,
|
|
|
|
DWORD_PTR dwParam1, DWORD_PTR dwParam2)
|
2001-02-14 21:49:22 +00:00
|
|
|
{
|
2007-12-20 22:45:34 +00:00
|
|
|
WINE_MCIAVI *wma = MCIAVI_mciGetOpenDev(dwInstance);
|
2004-01-01 00:48:01 +00:00
|
|
|
|
|
|
|
if (!wma) return;
|
|
|
|
|
|
|
|
EnterCriticalSection(&wma->cs);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
switch (uMsg) {
|
|
|
|
case WOM_OPEN:
|
|
|
|
case WOM_CLOSE:
|
|
|
|
break;
|
|
|
|
case WOM_DONE:
|
|
|
|
InterlockedIncrement(&wma->dwEventCount);
|
|
|
|
TRACE("Returning waveHdr=%lx\n", dwParam1);
|
|
|
|
SetEvent(wma->hEvent);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("Unknown uMsg=%d\n", uMsg);
|
|
|
|
}
|
2004-01-01 00:48:01 +00:00
|
|
|
|
|
|
|
LeaveCriticalSection(&wma->cs);
|
2001-02-14 21:49:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DWORD MCIAVI_OpenAudio(WINE_MCIAVI* wma, unsigned* nHdr, LPWAVEHDR* pWaveHdr)
|
|
|
|
{
|
|
|
|
DWORD dwRet;
|
|
|
|
LPWAVEHDR waveHdr;
|
|
|
|
unsigned i;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2002-10-19 17:20:02 +00:00
|
|
|
dwRet = waveOutOpen((HWAVEOUT *)&wma->hWave, WAVE_MAPPER, wma->lpWaveFormat,
|
2004-01-01 00:48:01 +00:00
|
|
|
(DWORD_PTR)MCIAVI_waveCallback, wma->wDevID, CALLBACK_FUNCTION);
|
2001-02-14 21:49:22 +00:00
|
|
|
if (dwRet != 0) {
|
2006-10-12 19:34:57 +00:00
|
|
|
TRACE("Can't open low level audio device %d\n", dwRet);
|
2001-02-14 21:49:22 +00:00
|
|
|
dwRet = MCIERR_DEVICE_OPEN;
|
|
|
|
wma->hWave = 0;
|
|
|
|
goto cleanUp;
|
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
/* FIXME: should set up a heuristic to compute the number of wave headers
|
|
|
|
* to be used...
|
|
|
|
*/
|
|
|
|
*nHdr = 7;
|
2002-05-31 23:06:46 +00:00
|
|
|
waveHdr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
2001-02-14 21:49:22 +00:00
|
|
|
*nHdr * (sizeof(WAVEHDR) + wma->ash_audio.dwSuggestedBufferSize));
|
|
|
|
if (!waveHdr) {
|
|
|
|
TRACE("Can't alloc wave headers\n");
|
|
|
|
dwRet = MCIERR_DEVICE_OPEN;
|
|
|
|
goto cleanUp;
|
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
for (i = 0; i < *nHdr; i++) {
|
|
|
|
/* other fields are zero:ed on allocation */
|
2002-05-31 23:06:46 +00:00
|
|
|
waveHdr[i].lpData = (char*)waveHdr +
|
2001-02-14 21:49:22 +00:00
|
|
|
*nHdr * sizeof(WAVEHDR) + i * wma->ash_audio.dwSuggestedBufferSize;
|
|
|
|
waveHdr[i].dwBufferLength = wma->ash_audio.dwSuggestedBufferSize;
|
|
|
|
if (waveOutPrepareHeader(wma->hWave, &waveHdr[i], sizeof(WAVEHDR))) {
|
|
|
|
dwRet = MCIERR_INTERNAL;
|
|
|
|
goto cleanUp;
|
|
|
|
}
|
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
if (wma->dwCurrVideoFrame != 0 && wma->lpWaveFormat) {
|
2001-05-09 17:31:31 +00:00
|
|
|
FIXME("Should recompute dwCurrAudioBlock, except unsynchronized sound & video\n");
|
2001-02-14 21:49:22 +00:00
|
|
|
}
|
|
|
|
wma->dwCurrAudioBlock = 0;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2005-01-07 15:40:09 +00:00
|
|
|
wma->hEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
|
2001-02-14 21:49:22 +00:00
|
|
|
wma->dwEventCount = *nHdr - 1;
|
|
|
|
*pWaveHdr = waveHdr;
|
|
|
|
cleanUp:
|
|
|
|
return dwRet;
|
2002-05-31 23:06:46 +00:00
|
|
|
}
|
2001-02-14 21:49:22 +00:00
|
|
|
|
|
|
|
void MCIAVI_PlayAudioBlocks(WINE_MCIAVI* wma, unsigned nHdr, LPWAVEHDR waveHdr)
|
|
|
|
{
|
2003-11-21 23:54:04 +00:00
|
|
|
if (!wma->lpAudioIndex)
|
|
|
|
return;
|
2006-10-12 19:34:57 +00:00
|
|
|
TRACE("%d (ec=%u)\n", wma->lpAudioIndex[wma->dwCurrAudioBlock].dwOffset, wma->dwEventCount);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
/* push as many blocks as possible => audio gets priority */
|
2002-05-31 23:06:46 +00:00
|
|
|
while (wma->dwStatus != MCI_MODE_STOP && wma->dwStatus != MCI_MODE_NOT_READY &&
|
2001-02-14 21:49:22 +00:00
|
|
|
wma->dwCurrAudioBlock < wma->dwPlayableAudioBlocks) {
|
|
|
|
unsigned whidx = wma->dwCurrAudioBlock % nHdr;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
ResetEvent(wma->hEvent);
|
|
|
|
if (InterlockedDecrement(&wma->dwEventCount) < 0 ||
|
|
|
|
!wma->lpAudioIndex[wma->dwCurrAudioBlock].dwOffset)
|
2004-01-28 20:05:20 +00:00
|
|
|
{
|
|
|
|
InterlockedIncrement(&wma->dwEventCount);
|
2001-02-14 21:49:22 +00:00
|
|
|
break;
|
2004-01-28 20:05:20 +00:00
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
mmioSeek(wma->hFile, wma->lpAudioIndex[wma->dwCurrAudioBlock].dwOffset, SEEK_SET);
|
|
|
|
mmioRead(wma->hFile, waveHdr[whidx].lpData, wma->lpAudioIndex[wma->dwCurrAudioBlock].dwSize);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
waveHdr[whidx].dwFlags &= ~WHDR_DONE;
|
|
|
|
waveHdr[whidx].dwBufferLength = wma->lpAudioIndex[wma->dwCurrAudioBlock].dwSize;
|
|
|
|
waveOutWrite(wma->hWave, &waveHdr[whidx], sizeof(WAVEHDR));
|
|
|
|
wma->dwCurrAudioBlock++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT MCIAVI_PaintFrame(WINE_MCIAVI* wma, HDC hDC)
|
|
|
|
{
|
2005-09-19 14:31:32 +00:00
|
|
|
void* pBitmapData;
|
|
|
|
LPBITMAPINFO pBitmapInfo;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
if (!hDC || !wma->inbih)
|
|
|
|
return TRUE;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2006-10-12 19:34:57 +00:00
|
|
|
TRACE("Painting frame %u (cached %u)\n", wma->dwCurrVideoFrame, wma->dwCachedFrame);
|
2004-03-01 23:38:25 +00:00
|
|
|
|
|
|
|
if (wma->dwCurrVideoFrame != wma->dwCachedFrame)
|
|
|
|
{
|
|
|
|
if (!wma->lpVideoIndex[wma->dwCurrVideoFrame].dwOffset)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (wma->lpVideoIndex[wma->dwCurrVideoFrame].dwSize)
|
|
|
|
{
|
|
|
|
mmioSeek(wma->hFile, wma->lpVideoIndex[wma->dwCurrVideoFrame].dwOffset, SEEK_SET);
|
|
|
|
mmioRead(wma->hFile, wma->indata, wma->lpVideoIndex[wma->dwCurrVideoFrame].dwSize);
|
|
|
|
|
|
|
|
wma->inbih->biSizeImage = wma->lpVideoIndex[wma->dwCurrVideoFrame].dwSize;
|
|
|
|
|
|
|
|
if (wma->hic && ICDecompress(wma->hic, 0, wma->inbih, wma->indata,
|
|
|
|
wma->outbih, wma->outdata) != ICERR_OK)
|
|
|
|
{
|
|
|
|
WARN("Decompression error\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wma->dwCachedFrame = wma->dwCurrVideoFrame;
|
|
|
|
}
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
if (wma->hic) {
|
|
|
|
pBitmapData = wma->outdata;
|
|
|
|
pBitmapInfo = (LPBITMAPINFO)wma->outbih;
|
2002-05-31 23:06:46 +00:00
|
|
|
} else {
|
2001-02-14 21:49:22 +00:00
|
|
|
pBitmapData = wma->indata;
|
|
|
|
pBitmapInfo = (LPBITMAPINFO)wma->inbih;
|
2002-05-31 23:06:46 +00:00
|
|
|
}
|
|
|
|
|
2005-09-19 14:31:32 +00:00
|
|
|
StretchDIBits(hDC,
|
|
|
|
wma->dest.left, wma->dest.top,
|
|
|
|
wma->dest.right - wma->dest.left, wma->dest.bottom - wma->dest.top,
|
|
|
|
wma->source.left, wma->source.top,
|
|
|
|
wma->source.right - wma->source.left, wma->source.bottom - wma->source.top,
|
|
|
|
pBitmapData, pBitmapInfo, DIB_RGB_COLORS, SRCCOPY);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2001-02-14 21:49:22 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|