From e8ecd538d4812f5c9972b65c8ef76bd027db3446 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Sat, 16 Sep 2017 20:45:04 +0000 Subject: [PATCH] [QUARTZ] Sync with Wine Staging 2.16. CORE-13762 84f5761 quartz: Use standard wine_dbgstr_longlong. e994c62 quartz: Use nAvgBytesPerSec to calculate length. e1d14d2 quartz: Restore a comment explaining mediatime. bf9eaac quartz: Small readability fix. svn path=/trunk/; revision=75858 --- reactos/dll/directx/wine/quartz/avisplit.c | 12 ++++++------ reactos/dll/directx/wine/quartz/dsoundrender.c | 6 +++--- reactos/dll/directx/wine/quartz/filesource.c | 2 +- .../dll/directx/wine/quartz/quartz_private.h | 1 + reactos/dll/directx/wine/quartz/vmr9.c | 2 +- reactos/dll/directx/wine/quartz/waveparser.c | 18 +++++++----------- 6 files changed, 19 insertions(+), 22 deletions(-) diff --git a/reactos/dll/directx/wine/quartz/avisplit.c b/reactos/dll/directx/wine/quartz/avisplit.c index b70383c5713..fbdd01a3a84 100644 --- a/reactos/dll/directx/wine/quartz/avisplit.c +++ b/reactos/dll/directx/wine/quartz/avisplit.c @@ -558,7 +558,7 @@ static HRESULT AVISplitter_ProcessIndex(AVISplitterImpl *This, AVISTDINDEX **ind TRACE("bIndexType: %u\n", pIndex->bIndexType); TRACE("nEntriesInUse: %u\n", pIndex->nEntriesInUse); TRACE("dwChunkId: %.4s\n", (char *)&pIndex->dwChunkId); - TRACE("qwBaseOffset: %x%08x\n", (DWORD)(pIndex->qwBaseOffset >> 32), (DWORD)pIndex->qwBaseOffset); + TRACE("qwBaseOffset: %s\n", wine_dbgstr_longlong(pIndex->qwBaseOffset)); TRACE("dwReserved_3: %u\n", pIndex->dwReserved_3); if (pIndex->bIndexType != AVI_INDEX_OF_CHUNKS @@ -578,7 +578,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("dwOffset: %s\n", wine_dbgstr_longlong(offset)); TRACE("dwSize: %u\n", (pIndex->aIndex[x].dwSize & ~(1u << 31))); TRACE("Frame is a keyframe: %s\n", keyframe ? "yes" : "no"); } @@ -629,9 +629,9 @@ static HRESULT AVISplitter_ProcessOldIndex(AVISplitterImpl *This) } else if (temp2 != chunkid) { - ERR("Faulty index or bug in handling: Wanted FCC: %s, Abs FCC: %s (@ %x), Rel FCC: %s (@ %.0x%08x)\n", + ERR("Faulty index or bug in handling: Wanted FCC: %s, Abs FCC: %s (@ %x), Rel FCC: %s (@ %s)\n", debugstr_an((char *)&chunkid, 4), debugstr_an((char *)&temp, 4), offset, - debugstr_an((char *)&temp2, 4), (DWORD)((mov_pos + offset) >> 32), (DWORD)(mov_pos + offset)); + debugstr_an((char *)&temp2, 4), wine_dbgstr_longlong(mov_pos + offset)); relative = -1; } else @@ -828,7 +828,7 @@ static HRESULT AVISplitter_ProcessStreamList(AVISplitterImpl * This, const BYTE stream->stdindex = CoTaskMemRealloc(stream->stdindex, sizeof(*stream->stdindex) * stream->entries); for (x = 0; x < pIndex->nEntriesInUse; ++x) { - TRACE("qwOffset: %x%08x\n", (DWORD)(pIndex->aIndex[x].qwOffset >> 32), (DWORD)pIndex->aIndex[x].qwOffset); + TRACE("qwOffset: %s\n", wine_dbgstr_longlong(pIndex->aIndex[x].qwOffset)); TRACE("dwSize: %u\n", pIndex->aIndex[x].dwSize); TRACE("dwDuration: %u (unreliable)\n", pIndex->aIndex[x].dwDuration); @@ -1117,7 +1117,7 @@ static HRESULT AVISplitter_InputPin_PreConnect(IPin * iface, IPin * pConnectPin, 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); + ERR("File smaller (%s) then EndOfFile (%s)\n", wine_dbgstr_longlong(total), wine_dbgstr_longlong(pAviSplit->EndOfFile)); return E_FAIL; } diff --git a/reactos/dll/directx/wine/quartz/dsoundrender.c b/reactos/dll/directx/wine/quartz/dsoundrender.c index 3d1ffb48add..35daaefa79d 100644 --- a/reactos/dll/directx/wine/quartz/dsoundrender.c +++ b/reactos/dll/directx/wine/quartz/dsoundrender.c @@ -97,9 +97,9 @@ static REFERENCE_TIME time_from_pos(DSoundRenderImpl *This, DWORD pos) { static DWORD pos_from_time(DSoundRenderImpl *This, REFERENCE_TIME time) { WAVEFORMATEX *wfx = (WAVEFORMATEX*)This->renderer.pInputPin->pin.mtCurrent.pbFormat; REFERENCE_TIME ret = time; - ret *= wfx->nSamplesPerSec; + ret *= wfx->nAvgBytesPerSec; ret /= 10000000; - ret *= wfx->nBlockAlign; + ret -= ret % wfx->nBlockAlign; return ret; } @@ -406,7 +406,7 @@ static HRESULT WINAPI DSoundRender_CheckMediaType(BaseRenderer *iface, const AM_ TRACE("Format = %p\n", format); TRACE("wFormatTag = %x %x\n", format->wFormatTag, WAVE_FORMAT_PCM); TRACE("nChannels = %d\n", format->nChannels); - TRACE("nSamplesPerSec = %d\n", format->nAvgBytesPerSec); + TRACE("nSamplesPerSec = %d\n", format->nSamplesPerSec); TRACE("nAvgBytesPerSec = %d\n", format->nAvgBytesPerSec); TRACE("nBlockAlign = %d\n", format->nBlockAlign); TRACE("wBitsPerSample = %d\n", format->wBitsPerSample); diff --git a/reactos/dll/directx/wine/quartz/filesource.c b/reactos/dll/directx/wine/quartz/filesource.c index 3e7a473d35c..16a0419327c 100644 --- a/reactos/dll/directx/wine/quartz/filesource.c +++ b/reactos/dll/directx/wine/quartz/filesource.c @@ -1320,7 +1320,7 @@ static HRESULT WINAPI FileAsyncReader_SyncRead(IAsyncReader * iface, LONGLONG ll HRESULT hr = S_OK; FileAsyncReader *This = impl_from_IAsyncReader(iface); - TRACE("(%x%08x, %d, %p)\n", (ULONG)(llPosition >> 32), (ULONG)llPosition, lLength, pBuffer); + TRACE("(%s, %d, %p)\n", wine_dbgstr_longlong(llPosition), lLength, pBuffer); ZeroMemory(&ovl, sizeof(ovl)); diff --git a/reactos/dll/directx/wine/quartz/quartz_private.h b/reactos/dll/directx/wine/quartz/quartz_private.h index c85a03326db..45565939a19 100644 --- a/reactos/dll/directx/wine/quartz/quartz_private.h +++ b/reactos/dll/directx/wine/quartz/quartz_private.h @@ -52,6 +52,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(quartz); #include "pin.h" #include "parser.h" +/* see IAsyncReader::Request on MSDN for the explanation of this */ #define MEDIATIME_FROM_BYTES(x) ((LONGLONG)(x) * 10000000) #define SEC_FROM_MEDIATIME(time) ((time) / 10000000) #define BYTES_FROM_MEDIATIME(time) SEC_FROM_MEDIATIME(time) diff --git a/reactos/dll/directx/wine/quartz/vmr9.c b/reactos/dll/directx/wine/quartz/vmr9.c index ab2a975e6aa..6e06cf43b02 100644 --- a/reactos/dll/directx/wine/quartz/vmr9.c +++ b/reactos/dll/directx/wine/quartz/vmr9.c @@ -365,7 +365,7 @@ static HRESULT WINAPI VMR9_CheckMediaType(BaseRenderer *iface, const AM_MEDIA_TY ERR("Format type %s not supported\n", debugstr_guid(&pmt->formattype)); return S_FALSE; } - if (This->bmiheader.biCompression) + if (This->bmiheader.biCompression != BI_RGB) return S_FALSE; return S_OK; } diff --git a/reactos/dll/directx/wine/quartz/waveparser.c b/reactos/dll/directx/wine/quartz/waveparser.c index 31ec627da17..27006be5687 100644 --- a/reactos/dll/directx/wine/quartz/waveparser.c +++ b/reactos/dll/directx/wine/quartz/waveparser.c @@ -27,9 +27,8 @@ typedef struct WAVEParserImpl ParserImpl Parser; LONGLONG StartOfFile; /* in media time */ LONGLONG EndOfFile; - DWORD dwSampleSize; - DWORD nSamplesPerSec; - DWORD dwLength; + DWORD nAvgBytesPerSec; + DWORD nBlockAlign; } WAVEParserImpl; static inline WAVEParserImpl *impl_from_IMediaSeeking( IMediaSeeking *iface ) @@ -46,7 +45,7 @@ static LONGLONG bytepos_to_duration(WAVEParserImpl *This, LONGLONG bytepos) { LONGLONG duration = BYTES_FROM_MEDIATIME(bytepos - This->StartOfFile); duration *= 10000000; - duration /= (This->dwSampleSize * This->nSamplesPerSec); + duration /= This->nAvgBytesPerSec; return duration; } @@ -55,11 +54,11 @@ static LONGLONG duration_to_bytepos(WAVEParserImpl *This, LONGLONG duration) { LONGLONG bytepos; - bytepos = (This->dwSampleSize * This->nSamplesPerSec); + bytepos = This->nAvgBytesPerSec; bytepos *= duration; bytepos /= 10000000; + bytepos -= bytepos % This->nBlockAlign; bytepos += BYTES_FROM_MEDIATIME(This->StartOfFile); - bytepos -= bytepos % This->dwSampleSize; return MEDIATIME_FROM_BYTES(bytepos); } @@ -236,7 +235,6 @@ static HRESULT WAVEParser_InputPin_PreConnect(IPin * iface, IPin * pConnectPin, PIN_INFO piOutput; AM_MEDIA_TYPE amt; WAVEParserImpl * pWAVEParser = impl_from_IBaseFilter(This->pin.pinInfo.pFilter); - LONGLONG length, avail; piOutput.dir = PINDIR_OUTPUT; piOutput.pFilter = &pWAVEParser->Parser.filter.IBaseFilter_iface; @@ -305,10 +303,8 @@ static HRESULT WAVEParser_InputPin_PreConnect(IPin * iface, IPin * pConnectPin, props->cbPrefix = 0; props->cbBuffer = 4096; props->cBuffers = 3; - pWAVEParser->dwSampleSize = ((WAVEFORMATEX*)amt.pbFormat)->nBlockAlign; - IAsyncReader_Length(This->pReader, &length, &avail); - pWAVEParser->dwLength = length / (ULONGLONG)pWAVEParser->dwSampleSize; - pWAVEParser->nSamplesPerSec = ((WAVEFORMATEX*)amt.pbFormat)->nSamplesPerSec; + pWAVEParser->nBlockAlign = ((WAVEFORMATEX*)amt.pbFormat)->nBlockAlign; + pWAVEParser->nAvgBytesPerSec = ((WAVEFORMATEX*)amt.pbFormat)->nAvgBytesPerSec; hr = Parser_AddPin(&(pWAVEParser->Parser), &piOutput, props, &amt); CoTaskMemFree(amt.pbFormat);