From 8421bdc381c3c64b3733dda5aec9d422282989d4 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 5 Sep 2018 09:28:39 +0200 Subject: DirectShow: Fix clang-tidy warnings about C-style casts Replace by reinterpret_cast<>. Change-Id: Iebcac7858d875e2d6f53db21489d86beb19ba947 Reviewed-by: Oliver Wolff --- src/plugins/common/evr/evrcustompresenter.cpp | 40 ++++++++++++++-------- src/plugins/common/evr/evrhelpers.h | 4 ++- src/plugins/directshow/camera/dscamerasession.cpp | 34 ++++++++++-------- .../directshow/camera/dsvideodevicecontrol.cpp | 3 +- src/plugins/directshow/common/directshowpin.cpp | 3 +- 5 files changed, 51 insertions(+), 33 deletions(-) diff --git a/src/plugins/common/evr/evrcustompresenter.cpp b/src/plugins/common/evr/evrcustompresenter.cpp index d5d9df14f..fd3054b0b 100644 --- a/src/plugins/common/evr/evrcustompresenter.cpp +++ b/src/plugins/common/evr/evrcustompresenter.cpp @@ -1365,18 +1365,21 @@ HRESULT EVRCustomPresenter::createOptimalVideoType(IMFMediaType *proposedType, I if (FAILED(hr)) goto done; - hr = mtOptimal->SetBlob(MF_MT_GEOMETRIC_APERTURE, (UINT8*)&displayArea, sizeof(displayArea)); + hr = mtOptimal->SetBlob(MF_MT_GEOMETRIC_APERTURE, reinterpret_cast(&displayArea), + sizeof(displayArea)); if (FAILED(hr)) goto done; // Set the pan/scan aperture and the minimum display aperture. We don't care // about them per se, but the mixer will reject the type if these exceed the // frame dimentions. - hr = mtOptimal->SetBlob(MF_MT_PAN_SCAN_APERTURE, (UINT8*)&displayArea, sizeof(displayArea)); + hr = mtOptimal->SetBlob(MF_MT_PAN_SCAN_APERTURE, reinterpret_cast(&displayArea), + sizeof(displayArea)); if (FAILED(hr)) goto done; - hr = mtOptimal->SetBlob(MF_MT_MINIMUM_DISPLAY_APERTURE, (UINT8*)&displayArea, sizeof(displayArea)); + hr = mtOptimal->SetBlob(MF_MT_MINIMUM_DISPLAY_APERTURE, reinterpret_cast(&displayArea), + sizeof(displayArea)); if (FAILED(hr)) goto done; @@ -1474,7 +1477,7 @@ HRESULT EVRCustomPresenter::isMediaTypeSupported(IMFMediaType *proposed) UINT32 width = 0, height = 0; // Validate the format. - HRESULT hr = qt_evr_getFourCC(proposed, (DWORD*)&d3dFormat); + HRESULT hr = qt_evr_getFourCC(proposed, reinterpret_cast(&d3dFormat)); if (FAILED(hr)) return hr; @@ -1503,7 +1506,7 @@ HRESULT EVRCustomPresenter::isMediaTypeSupported(IMFMediaType *proposed) return hr; // Reject interlaced formats. - hr = proposed->GetUINT32(MF_MT_INTERLACE_MODE, (UINT32*)&interlaceMode); + hr = proposed->GetUINT32(MF_MT_INTERLACE_MODE, reinterpret_cast(&interlaceMode)); if (FAILED(hr)) return hr; @@ -1518,15 +1521,21 @@ HRESULT EVRCustomPresenter::isMediaTypeSupported(IMFMediaType *proposed) // Any of these apertures may be unspecified in the media type, in which case // we ignore it. We just want to reject invalid apertures. - if (SUCCEEDED(proposed->GetBlob(MF_MT_PAN_SCAN_APERTURE, (UINT8*)&videoCropArea, sizeof(videoCropArea), NULL))) + if (SUCCEEDED(proposed->GetBlob(MF_MT_PAN_SCAN_APERTURE, + reinterpret_cast(&videoCropArea), + sizeof(videoCropArea), nullptr))) { hr = qt_evr_validateVideoArea(videoCropArea, width, height); - - if (SUCCEEDED(proposed->GetBlob(MF_MT_GEOMETRIC_APERTURE, (UINT8*)&videoCropArea, sizeof(videoCropArea), NULL))) + } + if (SUCCEEDED(proposed->GetBlob(MF_MT_GEOMETRIC_APERTURE, + reinterpret_cast(&videoCropArea), + sizeof(videoCropArea), nullptr))) { hr = qt_evr_validateVideoArea(videoCropArea, width, height); - - if (SUCCEEDED(proposed->GetBlob(MF_MT_MINIMUM_DISPLAY_APERTURE, (UINT8*)&videoCropArea, sizeof(videoCropArea), NULL))) + } + if (SUCCEEDED(proposed->GetBlob(MF_MT_MINIMUM_DISPLAY_APERTURE, + reinterpret_cast(&videoCropArea), + sizeof(videoCropArea), nullptr))) { hr = qt_evr_validateVideoArea(videoCropArea, width, height); - + } return hr; } @@ -1642,7 +1651,7 @@ HRESULT EVRCustomPresenter::processOutput() m_clock->GetCorrelatedTime(0, &mixerEndTime, &systemTime); LONGLONG latencyTime = mixerEndTime - mixerStartTime; - notifyEvent(EC_PROCESSING_LATENCY, (LONG_PTR)&latencyTime, 0); + notifyEvent(EC_PROCESSING_LATENCY, reinterpret_cast(&latencyTime), 0); } // Set up notification for when the sample is released. @@ -1734,7 +1743,7 @@ HRESULT EVRCustomPresenter::deliverFrameStepSample(IMFSample *sample) if (FAILED(hr)) goto done; - m_frameStep.sampleNoRef = (DWORD_PTR)unk; // No add-ref. + m_frameStep.sampleNoRef = reinterpret_cast(unk); // No add-ref. // NOTE: We do not AddRef the IUnknown pointer, because that would prevent the // sample from invoking the OnSampleFree callback after the sample is presented. @@ -1807,7 +1816,7 @@ HRESULT EVRCustomPresenter::onSampleFree(IMFAsyncResult *result) if (FAILED(hr)) goto done; - if (m_frameStep.sampleNoRef == (DWORD_PTR)unk) { + if (m_frameStep.sampleNoRef == reinterpret_cast(unk)) { // Notify the EVR. hr = completeFrameStep(sample); if (FAILED(hr)) @@ -1997,7 +2006,8 @@ HRESULT setMixerSourceRect(IMFTransform *mixer, const MFVideoNormalizedRect &sou HRESULT hr = mixer->GetAttributes(&attributes); if (SUCCEEDED(hr)) { - hr = attributes->SetBlob(video_ZOOM_RECT, (const UINT8*)&sourceRect, sizeof(sourceRect)); + hr = attributes->SetBlob(video_ZOOM_RECT, reinterpret_cast(&sourceRect), + sizeof(sourceRect)); attributes->Release(); } return hr; diff --git a/src/plugins/common/evr/evrhelpers.h b/src/plugins/common/evr/evrhelpers.h index 527612c45..b5bdf5ead 100644 --- a/src/plugins/common/evr/evrhelpers.h +++ b/src/plugins/common/evr/evrhelpers.h @@ -87,7 +87,9 @@ inline MFVideoArea qt_evr_makeMFArea(float x, float y, DWORD width, DWORD height inline HRESULT qt_evr_getFrameRate(IMFMediaType *pType, MFRatio *pRatio) { - return MFGetAttributeRatio(pType, MF_MT_FRAME_RATE, (UINT32*)&pRatio->Numerator, (UINT32*)&pRatio->Denominator); + return MFGetAttributeRatio(pType, MF_MT_FRAME_RATE, + reinterpret_cast(&pRatio->Numerator), + reinterpret_cast(&pRatio->Denominator)); } QVideoFrame::PixelFormat qt_evr_pixelFormatFromD3DFormat(DWORD format); diff --git a/src/plugins/directshow/camera/dscamerasession.cpp b/src/plugins/directshow/camera/dscamerasession.cpp index c309359ed..6b3662290 100644 --- a/src/plugins/directshow/camera/dscamerasession.cpp +++ b/src/plugins/directshow/camera/dscamerasession.cpp @@ -482,7 +482,7 @@ bool DSCameraSession::startPreview() if (m_surface) m_surface->start(m_previewSurfaceFormat); - hr = m_filterGraph->QueryInterface(IID_IMediaControl, (void**)&pControl); + hr = m_filterGraph->QueryInterface(IID_IMediaControl, reinterpret_cast(&pControl)); if (FAILED(hr)) { errorString = tr("Failed to get stream control"); goto failed; @@ -520,7 +520,8 @@ bool DSCameraSession::stopPreview() QString errorString; IMediaControl* pControl = 0; - HRESULT hr = m_filterGraph->QueryInterface(IID_IMediaControl, (void**)&pControl); + HRESULT hr = m_filterGraph->QueryInterface(IID_IMediaControl, + reinterpret_cast(&pControl)); if (FAILED(hr)) { errorString = tr("Failed to get stream control"); goto failed; @@ -714,7 +715,7 @@ bool DSCameraSession::createFilterGraph() // Create the filter graph hr = CoCreateInstance(CLSID_FilterGraph,NULL,CLSCTX_INPROC, - IID_IGraphBuilder, (void**)&m_filterGraph); + IID_IGraphBuilder, reinterpret_cast(*&m_filterGraph)); if (FAILED(hr)) { errorString = tr("Failed to create filter graph"); goto failed; @@ -722,7 +723,8 @@ bool DSCameraSession::createFilterGraph() // Create the capture graph builder hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC, - IID_ICaptureGraphBuilder2, (void**)&m_graphBuilder); + IID_ICaptureGraphBuilder2, + reinterpret_cast(&m_graphBuilder)); if (FAILED(hr)) { errorString = tr("Failed to create graph builder"); goto failed; @@ -756,7 +758,8 @@ bool DSCameraSession::createFilterGraph() QString output = QString::fromWCharArray(strName); mallocInterface->Free(strName); if (m_sourceDeviceName.contains(output)) { - hr = pMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**)&m_sourceFilter); + hr = pMoniker->BindToObject(nullptr, nullptr, IID_IBaseFilter, + reinterpret_cast(&m_sourceFilter)); if (SUCCEEDED(hr)) { pMoniker->Release(); break; @@ -775,7 +778,8 @@ bool DSCameraSession::createFilterGraph() while (pEnum->Next(1, &pMoniker, NULL) == S_OK) { IPropertyBag *pPropBag = 0; - hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)(&pPropBag)); + hr = pMoniker->BindToStorage(nullptr, nullptr, IID_IPropertyBag, + reinterpret_cast(&pPropBag)); if (FAILED(hr)) { pMoniker->Release(); continue; // Don't panic yet @@ -783,7 +787,8 @@ bool DSCameraSession::createFilterGraph() // No need to get the description, just grab it - hr = pMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**)&m_sourceFilter); + hr = pMoniker->BindToObject(0, 0, IID_IBaseFilter, + reinterpret_cast(&m_sourceFilter)); pPropBag->Release(); pMoniker->Release(); if (SUCCEEDED(hr)) { @@ -887,10 +892,9 @@ bool DSCameraSession::configurePreviewFormat() HRESULT hr; IAMStreamConfig* pConfig = 0; - hr = m_graphBuilder->FindInterface(&PIN_CATEGORY_CAPTURE, - &MEDIATYPE_Video, - m_sourceFilter, - IID_IAMStreamConfig, (void**)&pConfig); + hr = m_graphBuilder->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, + m_sourceFilter, IID_IAMStreamConfig, + reinterpret_cast(&pConfig)); if (FAILED(hr)) { qWarning() << "Failed to get config for capture device"; return false; @@ -1064,8 +1068,8 @@ void DSCameraSession::updateSourceCapabilities() IAMVideoControl *pVideoControl = 0; hr = m_graphBuilder->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, - m_sourceFilter, - IID_IAMVideoControl, (void**)&pVideoControl); + m_sourceFilter, IID_IAMVideoControl, + reinterpret_cast(&pVideoControl)); if (FAILED(hr)) { qWarning() << "Failed to get the video control"; } else { @@ -1091,8 +1095,8 @@ void DSCameraSession::updateSourceCapabilities() } hr = m_graphBuilder->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, - m_sourceFilter, - IID_IAMStreamConfig, (void**)&pConfig); + m_sourceFilter, IID_IAMStreamConfig, + reinterpret_cast(&pConfig)); if (FAILED(hr)) { qWarning() << "failed to get config on capture device"; return; diff --git a/src/plugins/directshow/camera/dsvideodevicecontrol.cpp b/src/plugins/directshow/camera/dsvideodevicecontrol.cpp index 26410fc3a..2c1fab764 100644 --- a/src/plugins/directshow/camera/dsvideodevicecontrol.cpp +++ b/src/plugins/directshow/camera/dsvideodevicecontrol.cpp @@ -156,7 +156,8 @@ void DSVideoDeviceControl::updateDevices() devInfo.first = output.toUtf8(); IPropertyBag *pPropBag; - hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)(&pPropBag)); + hr = pMoniker->BindToStorage(nullptr, nullptr, IID_IPropertyBag, + reinterpret_cast(&pPropBag)); if (SUCCEEDED(hr)) { // Find the description VARIANT varName; diff --git a/src/plugins/directshow/common/directshowpin.cpp b/src/plugins/directshow/common/directshowpin.cpp index 99304bcf1..0dae72d0a 100644 --- a/src/plugins/directshow/common/directshowpin.cpp +++ b/src/plugins/directshow/common/directshowpin.cpp @@ -622,7 +622,8 @@ HRESULT DirectShowInputPin::Receive(IMediaSample *pSample) IMediaSample2 *sample2; if (SUCCEEDED(pSample->QueryInterface(IID_PPV_ARGS(&sample2)))) { - hr = sample2->GetProperties(sizeof(m_sampleProperties), (PBYTE)&m_sampleProperties); + hr = sample2->GetProperties(sizeof(m_sampleProperties), + reinterpret_cast(&m_sampleProperties)); sample2->Release(); if (FAILED(hr)) return hr; -- cgit v1.2.3