[MCIAVI32] Sync with Wine Staging 3.3. CORE-14434
[reactos.git] / dll / win32 / mciavi32 / mmoutput.c
index 3a2d4de..ee0481c 100644 (file)
@@ -20,6 +20,9 @@
  */
 
 #include "private_mciavi.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(mciavi);
 
 static BOOL MCIAVI_GetInfoAudio(WINE_MCIAVI* wma, const MMCKINFO* mmckList, MMCKINFO *mmckStream)
 {
@@ -137,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;
@@ -187,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:
@@ -223,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;
@@ -395,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;