diff options
Diffstat (limited to 'src/plugins/common')
-rw-r--r-- | src/plugins/common/evr/evrcustompresenter.cpp | 93 | ||||
-rw-r--r-- | src/plugins/common/evr/evrcustompresenter.h | 65 | ||||
-rw-r--r-- | src/plugins/common/evr/evrd3dpresentengine.cpp | 12 | ||||
-rw-r--r-- | src/plugins/common/evr/evrd3dpresentengine.h | 2 | ||||
-rw-r--r-- | src/plugins/common/evr/evrhelpers.cpp | 8 | ||||
-rw-r--r-- | src/plugins/common/evr/evrhelpers.h | 4 | ||||
-rw-r--r-- | src/plugins/common/evr/evrvideowindowcontrol.h | 38 |
7 files changed, 112 insertions, 110 deletions
diff --git a/src/plugins/common/evr/evrcustompresenter.cpp b/src/plugins/common/evr/evrcustompresenter.cpp index b07dbe719..5ebde2dda 100644 --- a/src/plugins/common/evr/evrcustompresenter.cpp +++ b/src/plugins/common/evr/evrcustompresenter.cpp @@ -98,7 +98,7 @@ public: m_sample->AddRef(); } - ~PresentSampleEvent() + ~PresentSampleEvent() override { if (m_sample) m_sample->Release(); @@ -510,19 +510,16 @@ HRESULT SamplePool::initialize(QList<IMFSample*> &samples) if (m_initialized) return MF_E_INVALIDREQUEST; - IMFSample *sample = NULL; - // Move these samples into our allocated queue. - for (int i = 0; i < samples.size(); ++i) { - sample = samples.at(i); + for (auto sample : qAsConst(samples)) { sample->AddRef(); m_videoSampleQueue.append(sample); } m_initialized = true; - for (int i = 0; i < samples.size(); ++i) - samples[i]->Release(); + for (auto sample : qAsConst(samples)) + sample->Release(); samples.clear(); return S_OK; } @@ -531,8 +528,8 @@ HRESULT SamplePool::clear() { QMutexLocker locker(&m_mutex); - for (int i = 0; i < m_videoSampleQueue.size(); ++i) - m_videoSampleQueue[i]->Release(); + for (auto sample : qAsConst(m_videoSampleQueue)) + sample->Release(); m_videoSampleQueue.clear(); m_initialized = false; @@ -928,8 +925,8 @@ HRESULT EVRCustomPresenter::OnClockSetRate(MFTIME, float rate) // frame-step operation. if ((m_playbackRate == 0.0f) && (rate != 0.0f)) { cancelFrameStep(); - for (int i = 0; i < m_frameStep.samples.size(); ++i) - m_frameStep.samples[i]->Release(); + for (auto sample : qAsConst(m_frameStep.samples)) + sample->Release(); m_frameStep.samples.clear(); } @@ -1142,8 +1139,8 @@ HRESULT EVRCustomPresenter::flush() m_scheduler.flush(); // Flush the frame-step queue. - for (int i = 0; i < m_frameStep.samples.size(); ++i) - m_frameStep.samples[i]->Release(); + for (auto sample : qAsConst(m_frameStep.samples)) + sample->Release(); m_frameStep.samples.clear(); if (m_renderState == RenderStopped) { @@ -1365,18 +1362,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<UINT8*>(&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<UINT8*>(&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<UINT8*>(&displayArea), + sizeof(displayArea)); if (FAILED(hr)) goto done; @@ -1405,8 +1405,6 @@ HRESULT EVRCustomPresenter::setMediaType(IMFMediaType *mediaType) MFRatio fps = { 0, 0 }; QList<IMFSample*> sampleQueue; - IMFSample *sample = NULL; - // Cannot set the media type after shutdown. HRESULT hr = checkShutdown(); if (FAILED(hr)) @@ -1430,9 +1428,7 @@ HRESULT EVRCustomPresenter::setMediaType(IMFMediaType *mediaType) // Mark each sample with our token counter. If this batch of samples becomes // invalid, we increment the counter, so that we know they should be discarded. - for (int i = 0; i < sampleQueue.size(); ++i) { - sample = sampleQueue.at(i); - + for (auto sample : qAsConst(sampleQueue)) { hr = sample->SetUINT32(MFSamplePresenter_SampleCounter, m_tokenCounter); if (FAILED(hr)) goto done; @@ -1474,7 +1470,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<DWORD*>(&d3dFormat)); if (FAILED(hr)) return hr; @@ -1503,7 +1499,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<UINT32*>(&interlaceMode)); if (FAILED(hr)) return hr; @@ -1518,15 +1514,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<UINT8*>(&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<UINT8*>(&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<UINT8*>(&videoCropArea), + sizeof(videoCropArea), nullptr))) { hr = qt_evr_validateVideoArea(videoCropArea, width, height); - + } return hr; } @@ -1580,12 +1582,10 @@ HRESULT EVRCustomPresenter::processOutput() // Try to get a free sample from the video sample pool. hr = m_samplePool.getSample(&sample); - if (hr == MF_E_SAMPLEALLOCATOR_EMPTY) { - // No free samples. Try again when a sample is released. + if (hr == MF_E_SAMPLEALLOCATOR_EMPTY) // No free samples. Try again when a sample is released. return S_FALSE; - } else if (FAILED(hr)) { + if (FAILED(hr)) return hr; - } // From now on, we have a valid video sample pointer, where the mixer will // write the video data. @@ -1642,7 +1642,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<LONG_PTR>(&latencyTime), 0); } // Set up notification for when the sample is released. @@ -1734,7 +1734,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<DWORD_PTR>(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 +1807,7 @@ HRESULT EVRCustomPresenter::onSampleFree(IMFAsyncResult *result) if (FAILED(hr)) goto done; - if (m_frameStep.sampleNoRef == (DWORD_PTR)unk) { + if (m_frameStep.sampleNoRef == reinterpret_cast<DWORD_PTR>(unk)) { // Notify the EVR. hr = completeFrameStep(sample); if (FAILED(hr)) @@ -1997,7 +1997,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<const UINT8*>(&sourceRect), + sizeof(sourceRect)); attributes->Release(); } return hr; @@ -2017,23 +2018,23 @@ static QVideoFrame::PixelFormat pixelFormatFromMediaType(IMFMediaType *type) if (subtype == MFVideoFormat_RGB32) return QVideoFrame::Format_RGB32; - else if (subtype == MFVideoFormat_ARGB32) + if (subtype == MFVideoFormat_ARGB32) return QVideoFrame::Format_ARGB32; - else if (subtype == MFVideoFormat_RGB24) + if (subtype == MFVideoFormat_RGB24) return QVideoFrame::Format_RGB24; - else if (subtype == MFVideoFormat_RGB565) + if (subtype == MFVideoFormat_RGB565) return QVideoFrame::Format_RGB565; - else if (subtype == MFVideoFormat_RGB555) + if (subtype == MFVideoFormat_RGB555) return QVideoFrame::Format_RGB555; - else if (subtype == MFVideoFormat_AYUV) + if (subtype == MFVideoFormat_AYUV) return QVideoFrame::Format_AYUV444; - else if (subtype == MFVideoFormat_I420) + if (subtype == MFVideoFormat_I420) return QVideoFrame::Format_YUV420P; - else if (subtype == MFVideoFormat_UYVY) + if (subtype == MFVideoFormat_UYVY) return QVideoFrame::Format_UYVY; - else if (subtype == MFVideoFormat_YV12) + if (subtype == MFVideoFormat_YV12) return QVideoFrame::Format_YV12; - else if (subtype == MFVideoFormat_NV12) + if (subtype == MFVideoFormat_NV12) return QVideoFrame::Format_NV12; return QVideoFrame::Format_Invalid; diff --git a/src/plugins/common/evr/evrcustompresenter.h b/src/plugins/common/evr/evrcustompresenter.h index 199dee774..bd04bd952 100644 --- a/src/plugins/common/evr/evrcustompresenter.h +++ b/src/plugins/common/evr/evrcustompresenter.h @@ -58,6 +58,7 @@ class QAbstractVideoSurface; template<class T> class AsyncCallback : public IMFAsyncCallback { + Q_DISABLE_COPY(AsyncCallback) public: typedef HRESULT (T::*InvokeFn)(IMFAsyncResult *asyncResult); @@ -66,7 +67,7 @@ public: } // IUnknown - STDMETHODIMP QueryInterface(REFIID iid, void** ppv) + STDMETHODIMP QueryInterface(REFIID iid, void** ppv) override { if (!ppv) return E_POINTER; @@ -83,23 +84,23 @@ public: return S_OK; } - STDMETHODIMP_(ULONG) AddRef() { + STDMETHODIMP_(ULONG) AddRef() override { // Delegate to parent class. return m_parent->AddRef(); } - STDMETHODIMP_(ULONG) Release() { + STDMETHODIMP_(ULONG) Release() override { // Delegate to parent class. return m_parent->Release(); } // IMFAsyncCallback methods - STDMETHODIMP GetParameters(DWORD*, DWORD*) + STDMETHODIMP GetParameters(DWORD*, DWORD*) override { // Implementation of this method is optional. return E_NOTIMPL; } - STDMETHODIMP Invoke(IMFAsyncResult* asyncResult) + STDMETHODIMP Invoke(IMFAsyncResult* asyncResult) override { return (m_parent->*m_invokeFn)(asyncResult); } @@ -110,6 +111,7 @@ public: class Scheduler { + Q_DISABLE_COPY(Scheduler) public: enum ScheduleEvent { @@ -164,6 +166,7 @@ private: class SamplePool { + Q_DISABLE_COPY(SamplePool) public: SamplePool(); ~SamplePool(); @@ -188,6 +191,7 @@ class EVRCustomPresenter , public IMFGetService , public IMFTopologyServiceLookupClient { + Q_DISABLE_COPY(EVRCustomPresenter) public: // Defines the state of the presenter. enum RenderState @@ -216,40 +220,40 @@ public: }; EVRCustomPresenter(QAbstractVideoSurface *surface = 0); - ~EVRCustomPresenter(); + ~EVRCustomPresenter() override; bool isValid() const; // IUnknown methods - STDMETHODIMP QueryInterface(REFIID riid, void ** ppv); - STDMETHODIMP_(ULONG) AddRef(); - STDMETHODIMP_(ULONG) Release(); + STDMETHODIMP QueryInterface(REFIID riid, void ** ppv) override; + STDMETHODIMP_(ULONG) AddRef() override; + STDMETHODIMP_(ULONG) Release() override; // IMFGetService methods - STDMETHODIMP GetService(REFGUID guidService, REFIID riid, LPVOID *ppvObject); + STDMETHODIMP GetService(REFGUID guidService, REFIID riid, LPVOID *ppvObject) override; // IMFVideoPresenter methods - STDMETHODIMP ProcessMessage(MFVP_MESSAGE_TYPE message, ULONG_PTR param); - STDMETHODIMP GetCurrentMediaType(IMFVideoMediaType** mediaType); + STDMETHODIMP ProcessMessage(MFVP_MESSAGE_TYPE message, ULONG_PTR param) override; + STDMETHODIMP GetCurrentMediaType(IMFVideoMediaType** mediaType) override; // IMFClockStateSink methods - STDMETHODIMP OnClockStart(MFTIME systemTime, LONGLONG clockStartOffset); - STDMETHODIMP OnClockStop(MFTIME systemTime); - STDMETHODIMP OnClockPause(MFTIME systemTime); - STDMETHODIMP OnClockRestart(MFTIME systemTime); - STDMETHODIMP OnClockSetRate(MFTIME systemTime, float rate); + STDMETHODIMP OnClockStart(MFTIME systemTime, LONGLONG clockStartOffset) override; + STDMETHODIMP OnClockStop(MFTIME systemTime) override; + STDMETHODIMP OnClockPause(MFTIME systemTime) override; + STDMETHODIMP OnClockRestart(MFTIME systemTime) override; + STDMETHODIMP OnClockSetRate(MFTIME systemTime, float rate) override; // IMFRateSupport methods - STDMETHODIMP GetSlowestRate(MFRATE_DIRECTION direction, BOOL thin, float *rate); - STDMETHODIMP GetFastestRate(MFRATE_DIRECTION direction, BOOL thin, float *rate); - STDMETHODIMP IsRateSupported(BOOL thin, float rate, float *nearestSupportedRate); + STDMETHODIMP GetSlowestRate(MFRATE_DIRECTION direction, BOOL thin, float *rate) override; + STDMETHODIMP GetFastestRate(MFRATE_DIRECTION direction, BOOL thin, float *rate) override; + STDMETHODIMP IsRateSupported(BOOL thin, float rate, float *nearestSupportedRate) override; // IMFVideoDeviceID methods - STDMETHODIMP GetDeviceID(IID* deviceID); + STDMETHODIMP GetDeviceID(IID* deviceID) override; // IMFTopologyServiceLookupClient methods - STDMETHODIMP InitServicePointers(IMFTopologyServiceLookup *lookup); - STDMETHODIMP ReleaseServicePointers(); + STDMETHODIMP InitServicePointers(IMFTopologyServiceLookup *lookup) override; + STDMETHODIMP ReleaseServicePointers() override; void supportedFormatsChanged(); void setSurface(QAbstractVideoSurface *surface); @@ -258,7 +262,7 @@ public: void stopSurface(); void presentSample(IMFSample *sample); - bool event(QEvent *); + bool event(QEvent *) override; private: HRESULT checkShutdown() const @@ -324,17 +328,10 @@ private: // Holds information related to frame-stepping. struct FrameStep { - FrameStep() - : state(FrameStepNone) - , steps(0) - , sampleNoRef(0) - { - } - - FrameStepState state; + FrameStepState state = FrameStepNone; QList<IMFSample*> samples; - DWORD steps; - DWORD_PTR sampleNoRef; + DWORD steps = 0; + DWORD_PTR sampleNoRef = 0; }; long m_refCount; diff --git a/src/plugins/common/evr/evrd3dpresentengine.cpp b/src/plugins/common/evr/evrd3dpresentengine.cpp index 513fe66ca..ab694b795 100644 --- a/src/plugins/common/evr/evrd3dpresentengine.cpp +++ b/src/plugins/common/evr/evrd3dpresentengine.cpp @@ -202,7 +202,7 @@ private: unsigned int m_glTexture; QOpenGLContext *m_glContext; - ~OpenGLResources() + ~OpenGLResources() override { QScopedPointer<QOffscreenSurface> surface; if (m_glContext != QOpenGLContext::currentContext()) { @@ -251,7 +251,7 @@ public: } } - ~IMFSampleVideoBuffer() + ~IMFSampleVideoBuffer() override { if (m_surface) { if (m_mapMode != NotMapped) @@ -262,11 +262,11 @@ public: m_sample->Release(); } - QVariant handle() const; + QVariant handle() const override; - MapMode mapMode() const { return m_mapMode; } - uchar *map(MapMode, int*, int*); - void unmap(); + MapMode mapMode() const override { return m_mapMode; } + uchar *map(MapMode, int*, int*) override; + void unmap() override; private: mutable D3DPresentEngine *m_engine; diff --git a/src/plugins/common/evr/evrd3dpresentengine.h b/src/plugins/common/evr/evrd3dpresentengine.h index 258d8b548..8e2a444f3 100644 --- a/src/plugins/common/evr/evrd3dpresentengine.h +++ b/src/plugins/common/evr/evrd3dpresentengine.h @@ -72,6 +72,7 @@ class OpenGLResources; class EGLWrapper { + Q_DISABLE_COPY(EGLWrapper) public: EGLWrapper(); @@ -99,6 +100,7 @@ private: class D3DPresentEngine { + Q_DISABLE_COPY(D3DPresentEngine) public: enum Hint { diff --git a/src/plugins/common/evr/evrhelpers.cpp b/src/plugins/common/evr/evrhelpers.cpp index 96b61e2eb..a315f1a73 100644 --- a/src/plugins/common/evr/evrhelpers.cpp +++ b/src/plugins/common/evr/evrhelpers.cpp @@ -69,7 +69,7 @@ bool qt_evr_areMediaTypesEqual(IMFMediaType *type1, IMFMediaType *type2) { if (!type1 && !type2) return true; - else if (!type1 || !type2) + if (!type1 || !type2) return false; DWORD dwFlags = 0; @@ -84,10 +84,10 @@ HRESULT qt_evr_validateVideoArea(const MFVideoArea& area, UINT32 width, UINT32 h float fOffsetY = qt_evr_MFOffsetToFloat(area.OffsetY); if ( ((LONG)fOffsetX + area.Area.cx > (LONG)width) || - ((LONG)fOffsetY + area.Area.cy > (LONG)height) ) + ((LONG)fOffsetY + area.Area.cy > (LONG)height) ) { return MF_E_INVALIDMEDIATYPE; - else - return S_OK; + } + return S_OK; } bool qt_evr_isSampleTimePassed(IMFClock *clock, IMFSample *sample) 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<UINT32*>(&pRatio->Numerator), + reinterpret_cast<UINT32*>(&pRatio->Denominator)); } QVideoFrame::PixelFormat qt_evr_pixelFormatFromD3DFormat(DWORD format); diff --git a/src/plugins/common/evr/evrvideowindowcontrol.h b/src/plugins/common/evr/evrvideowindowcontrol.h index fcfe20958..ce3b7746f 100644 --- a/src/plugins/common/evr/evrvideowindowcontrol.h +++ b/src/plugins/common/evr/evrvideowindowcontrol.h @@ -51,37 +51,37 @@ class EvrVideoWindowControl : public QVideoWindowControl Q_OBJECT public: EvrVideoWindowControl(QObject *parent = 0); - ~EvrVideoWindowControl(); + ~EvrVideoWindowControl() override; bool setEvr(IUnknown *evr); - WId winId() const; - void setWinId(WId id); + WId winId() const override; + void setWinId(WId id) override; - QRect displayRect() const; - void setDisplayRect(const QRect &rect); + QRect displayRect() const override; + void setDisplayRect(const QRect &rect) override; - bool isFullScreen() const; - void setFullScreen(bool fullScreen); + bool isFullScreen() const override; + void setFullScreen(bool fullScreen) override; - void repaint(); + void repaint() override; - QSize nativeSize() const; + QSize nativeSize() const override; - Qt::AspectRatioMode aspectRatioMode() const; - void setAspectRatioMode(Qt::AspectRatioMode mode); + Qt::AspectRatioMode aspectRatioMode() const override; + void setAspectRatioMode(Qt::AspectRatioMode mode) override; - int brightness() const; - void setBrightness(int brightness); + int brightness() const override; + void setBrightness(int brightness) override; - int contrast() const; - void setContrast(int contrast); + int contrast() const override; + void setContrast(int contrast) override; - int hue() const; - void setHue(int hue); + int hue() const override; + void setHue(int hue) override; - int saturation() const; - void setSaturation(int saturation); + int saturation() const override; + void setSaturation(int saturation) override; void applyImageControls(); |