[MCIAVI32] Sync with Wine Staging 3.3. CORE-14434
[reactos.git] / dll / win32 / mciavi32 / mmoutput.c
index 2cd3339..ee0481c 100644 (file)
@@ -140,11 +140,7 @@ static BOOL MCIAVI_GetInfoVideo(WINE_MCIAVI* wma, const MMCKINFO* mmckList, MMCK
     TRACE("bih.biClrUsed=%d\n",        wma->inbih->biClrUsed);
     TRACE("bih.biClrImportant=%d\n",   wma->inbih->biClrImportant);
 
-    wma->source.left = 0;
-    wma->source.top = 0;
-    wma->source.right = wma->inbih->biWidth;
-    wma->source.bottom = wma->inbih->biHeight;
-
+    SetRect(&wma->source, 0, 0, wma->inbih->biWidth, wma->inbih->biHeight);
     wma->dest = wma->source;
 
     return TRUE;
@@ -190,8 +186,11 @@ static BOOL        MCIAVI_AddFrame(WINE_MCIAVI* wma, LPMMCKINFO mmck,
      */
     twocc = TWOCCFromFOURCC(mmck->ckid);
     if (twocc == TWOCCFromFOURCC(wma->inbih->biCompression))
-       twocc = cktypeDIBcompressed;
-    
+        twocc = cktypeDIBcompressed;
+    /* Also detect some chunks that seem to be used by Indeo videos where the chunk is named
+     * after the codec. */
+    else if (twocc == LOWORD(wma->ash_video.fccHandler))
+        twocc = cktypeDIBcompressed;
     switch (twocc) {
     case cktypeDIBbits:
     case cktypeDIBcompressed:
@@ -226,14 +225,16 @@ static BOOL       MCIAVI_AddFrame(WINE_MCIAVI* wma, LPMMCKINFO mmck,
              alb->numAudioBlocks, mmck->cksize);
        if (wma->lpWaveFormat) {
            if (alb->numAudioBlocks >= alb->numAudioAllocated) {
-               alb->numAudioAllocated += 32;
-               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));
-               if (!wma->lpAudioIndex) return FALSE;
+                DWORD newsize = alb->numAudioAllocated + 32;
+                struct MMIOPos* newindex;
+
+                if (!wma->lpAudioIndex)
+                    newindex = HeapAlloc(GetProcessHeap(), 0, newsize * sizeof(struct MMIOPos));
+                else
+                    newindex = HeapReAlloc(GetProcessHeap(), 0, wma->lpAudioIndex, newsize * sizeof(struct MMIOPos));
+                if (!newindex) return FALSE;
+                alb->numAudioAllocated = newsize;
+                wma->lpAudioIndex = newindex;
            }
            wma->lpAudioIndex[alb->numAudioBlocks].dwOffset = mmck->dwDataOffset;
            wma->lpAudioIndex[alb->numAudioBlocks].dwSize = mmck->cksize;
@@ -398,8 +399,8 @@ BOOL MCIAVI_GetInfo(WINE_MCIAVI* wma)
        mmioAscend(wma->hFile, &mmckInfo, 0);
     }
     if (alb.numVideoFrames != wma->dwPlayableVideoFrames) {
-       WARN("Found %d video frames (/%d), reducing playable frames\n",
-            alb.numVideoFrames, wma->dwPlayableVideoFrames);
+       WARN("AVI header says %d frames, we found %d video frames, reducing playable frames\n",
+            wma->dwPlayableVideoFrames, alb.numVideoFrames);
        wma->dwPlayableVideoFrames = alb.numVideoFrames;
     }
     wma->dwPlayableAudioBlocks = alb.numAudioBlocks;
@@ -600,20 +601,20 @@ void MCIAVI_PlayAudioBlocks(WINE_MCIAVI* wma, unsigned nHdr, LPWAVEHDR waveHdr)
     }
 }
 
-LRESULT MCIAVI_PaintFrame(WINE_MCIAVI* wma, HDC hDC)
+double MCIAVI_PaintFrame(WINE_MCIAVI* wma, HDC hDC)
 {
     void*              pBitmapData;
     LPBITMAPINFO       pBitmapInfo;
 
     if (!hDC || !wma->inbih)
-       return TRUE;
+       return 0;
 
     TRACE("Painting frame %u (cached %u)\n", wma->dwCurrVideoFrame, wma->dwCachedFrame);
 
     if (wma->dwCurrVideoFrame != wma->dwCachedFrame)
     {
         if (!wma->lpVideoIndex[wma->dwCurrVideoFrame].dwOffset)
-           return FALSE;
+           return 0;
 
         if (wma->lpVideoIndex[wma->dwCurrVideoFrame].dwSize)
         {
@@ -626,7 +627,7 @@ LRESULT MCIAVI_PaintFrame(WINE_MCIAVI* wma, HDC hDC)
                                          wma->outbih, wma->outdata) != ICERR_OK)
             {
                 WARN("Decompression error\n");
-                return FALSE;
+                return 0;
             }
         }
 
@@ -648,5 +649,5 @@ LRESULT MCIAVI_PaintFrame(WINE_MCIAVI* wma, HDC hDC)
                   wma->source.right - wma->source.left, wma->source.bottom - wma->source.top,
                   pBitmapData, pBitmapInfo, DIB_RGB_COLORS, SRCCOPY);
 
-    return TRUE;
+    return (wma->ash_video.dwScale / (double)wma->ash_video.dwRate) * 1000000;
 }