[QUARTZ] Sync with Wine Staging 1.7.55. CORE-10536
[reactos.git] / reactos / dll / directx / wine / quartz / avisplit.c
index 2696890..fec1174 100644 (file)
@@ -186,7 +186,7 @@ static HRESULT AVISplitter_next_request(AVISplitterImpl *This, DWORD streamnumbe
                 ++stream->index_next;
             }
 
-            rtSampleStop = rtSampleStart + MEDIATIME_FROM_BYTES(entry->dwSize & ~(1 << 31));
+            rtSampleStop = rtSampleStart + MEDIATIME_FROM_BYTES(entry->dwSize & ~(1u << 31));
 
             TRACE("offset(%u) size(%u)\n", (DWORD)BYTES_FROM_MEDIATIME(rtSampleStart), (DWORD)BYTES_FROM_MEDIATIME(rtSampleStop - rtSampleStart));
         }
@@ -579,7 +579,7 @@ static HRESULT AVISplitter_ProcessIndex(AVISplitterImpl *This, AVISTDINDEX **ind
         BOOL keyframe = !(pIndex->aIndex[x].dwSize >> 31);
         DWORDLONG offset = pIndex->qwBaseOffset + pIndex->aIndex[x].dwOffset;
         TRACE("dwOffset: %x%08x\n", (DWORD)(offset >> 32), (DWORD)offset);
-        TRACE("dwSize: %u\n", (pIndex->aIndex[x].dwSize & ~(1<<31)));
+        TRACE("dwSize: %u\n", (pIndex->aIndex[x].dwSize & ~(1u << 31)));
         TRACE("Frame is a keyframe: %s\n", keyframe ? "yes" : "no");
     }
 
@@ -977,7 +977,7 @@ static HRESULT AVISplitter_InitializeStreams(AVISplitterImpl *This)
 
                     for (z = 0; z < stream->stdindex[y]->nEntriesInUse; ++z)
                     {
-                        UINT len = stream->stdindex[y]->aIndex[z].dwSize & ~(1 << 31);
+                        UINT len = stream->stdindex[y]->aIndex[z].dwSize & ~(1u << 31);
                         frames += len / stream->streamheader.dwSampleSize + !!(len % stream->streamheader.dwSampleSize);
                     }
                 }
@@ -1092,24 +1092,18 @@ static HRESULT AVISplitter_InputPin_PreConnect(IPin * iface, IPin * pConnectPin,
         return E_FAIL;
     }
 
-    pos += sizeof(RIFFCHUNK) + list.cb;
-    hr = IAsyncReader_SyncRead(This->pReader, pos, sizeof(list), (BYTE *)&list);
-
-    while (list.fcc == ckidAVIPADDING || (list.fcc == FOURCC_LIST && list.fccListType != listtypeAVIMOVIE))
+    /* Skip any chunks until we find the LIST chunk */
+    do
     {
         pos += sizeof(RIFFCHUNK) + list.cb;
-
         hr = IAsyncReader_SyncRead(This->pReader, pos, sizeof(list), (BYTE *)&list);
     }
+    while (hr == S_OK && (list.fcc != FOURCC_LIST ||
+           (list.fcc == FOURCC_LIST && list.fccListType != listtypeAVIMOVIE)));
 
-    if (list.fcc != FOURCC_LIST)
-    {
-        ERR("Expected LIST, but got %.04s\n", (LPSTR)&list.fcc);
-        return E_FAIL;
-    }
-    if (list.fccListType != listtypeAVIMOVIE)
+    if (hr != S_OK)
     {
-        ERR("Expected AVI movie list, but got %.04s\n", (LPSTR)&list.fccListType);
+        ERR("Failed to find LIST chunk from AVI file\n");
         return E_FAIL;
     }
 
@@ -1117,21 +1111,18 @@ static HRESULT AVISplitter_InputPin_PreConnect(IPin * iface, IPin * pConnectPin,
 
     /* FIXME: AVIX files are extended beyond the FOURCC chunk "AVI ", and thus won't be played here,
      * once I get one of the files I'll try to fix it */
-    if (hr == S_OK)
-    {
-        This->rtStart = pAviSplit->CurrentChunkOffset = MEDIATIME_FROM_BYTES(pos + sizeof(RIFFLIST));
-        pos += list.cb + sizeof(RIFFCHUNK);
-
-        pAviSplit->EndOfFile = This->rtStop = MEDIATIME_FROM_BYTES(pos);
-        if (pos > total)
-        {
-            ERR("File smaller (%x%08x) then EndOfFile (%x%08x)\n", (DWORD)(total >> 32), (DWORD)total, (DWORD)(pAviSplit->EndOfFile >> 32), (DWORD)pAviSplit->EndOfFile);
-            return E_FAIL;
-        }
+    This->rtStart = pAviSplit->CurrentChunkOffset = MEDIATIME_FROM_BYTES(pos + sizeof(RIFFLIST));
+    pos += list.cb + sizeof(RIFFCHUNK);
 
-        hr = IAsyncReader_SyncRead(This->pReader, BYTES_FROM_MEDIATIME(pAviSplit->CurrentChunkOffset), sizeof(pAviSplit->CurrentChunk), (BYTE *)&pAviSplit->CurrentChunk);
+    pAviSplit->EndOfFile = This->rtStop = MEDIATIME_FROM_BYTES(pos);
+    if (pos > total)
+    {
+        ERR("File smaller (%x%08x) then EndOfFile (%x%08x)\n", (DWORD)(total >> 32), (DWORD)total, (DWORD)(pAviSplit->EndOfFile >> 32), (DWORD)pAviSplit->EndOfFile);
+        return E_FAIL;
     }
 
+    hr = IAsyncReader_SyncRead(This->pReader, BYTES_FROM_MEDIATIME(pAviSplit->CurrentChunkOffset), sizeof(pAviSplit->CurrentChunk), (BYTE *)&pAviSplit->CurrentChunk);
+
     props->cbAlign = 1;
     props->cbPrefix = 0;
     /* Comrades, prevent shortage of buffers, or you will feel the consequences! DA! */
@@ -1325,7 +1316,7 @@ static HRESULT WINAPI AVISplitter_seek(IMediaSeeking *iface)
                 {
                     if (stream->streamheader.dwSampleSize)
                     {
-                        ULONG len = stream->stdindex[y]->aIndex[z].dwSize & ~(1 << 31);
+                        ULONG len = stream->stdindex[y]->aIndex[z].dwSize & ~(1u << 31);
                         ULONG size = stream->streamheader.dwSampleSize;
 
                         pin->dwSamplesProcessed += len / size;
@@ -1443,7 +1434,7 @@ HRESULT AVISplitter_create(IUnknown * pUnkOuter, LPVOID * ppv)
     if (FAILED(hr))
         return hr;
 
-    *ppv = This;
+    *ppv = &This->Parser.filter.IBaseFilter_iface;
 
     return hr;
 }