diff options
author | Lars Knoll <lars.knoll@qt.io> | 2021-04-12 14:05:25 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2021-04-16 10:50:06 +0000 |
commit | a9a332e265528d12ad05c5b3be23118ab712cc3d (patch) | |
tree | b10e19d8b8ca07f9d5ca77ce66b039b3994843a8 /src/multimedia | |
parent | 301c0f6fd94e0459fd06cac70f25bbbaea1cc92e (diff) |
Clean up QVideoSink and it's platform implementation
* Normalize ranges of brightness and friends to [-1, 1] and use
floating point numbers.
* Remove getters for values from the platform API, rather store them
in the frontend. This simplifies the work that needs to be done on
the backend side.
Change-Id: I8d63dacaa6b2873b33e17fcd7831e41173109a7e
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Doris Verria <doris.verria@qt.io>
Diffstat (limited to 'src/multimedia')
14 files changed, 153 insertions, 529 deletions
diff --git a/src/multimedia/platform/darwin/avfvideosink.mm b/src/multimedia/platform/darwin/avfvideosink.mm index b0d727038..f28ff98c4 100644 --- a/src/multimedia/platform/darwin/avfvideosink.mm +++ b/src/multimedia/platform/darwin/avfvideosink.mm @@ -100,8 +100,8 @@ QRect AVFVideoSink::displayRect() const void AVFVideoSink::setDisplayRect(const QRect &rect) { - if (m_displayRect == rect) - return; + Q_ASSERT(m_displayRect != rect); + m_displayRect = rect; if (m_interface) m_interface->updateLayerBounds(); @@ -114,8 +114,8 @@ bool AVFVideoSink::isFullScreen() const void AVFVideoSink::setFullScreen(bool fullScreen) { - if (fullScreen == m_fullscreen) - return; + Q_ASSERT(fullScreen != m_fullscreen); + m_fullscreen = fullScreen; if (m_interface) m_interface->reconfigure(); @@ -142,49 +142,29 @@ Qt::AspectRatioMode AVFVideoSink::aspectRatioMode() const void AVFVideoSink::setAspectRatioMode(Qt::AspectRatioMode mode) { - if (m_aspectRatioMode == mode) - return; + Q_ASSERT(m_aspectRatioMode != mode); + m_aspectRatioMode = mode; if (m_interface) m_interface->updateAspectRatio(); } -int AVFVideoSink::brightness() const -{ - return m_brightness; -} - -void AVFVideoSink::setBrightness(int brightness) +void AVFVideoSink::setBrightness(float brightness) { m_brightness = brightness; } -int AVFVideoSink::contrast() const -{ - return m_contrast; -} - -void AVFVideoSink::setContrast(int contrast) +void AVFVideoSink::setContrast(float contrast) { m_contrast = contrast; } -int AVFVideoSink::hue() const -{ - return m_hue; -} - -void AVFVideoSink::setHue(int hue) +void AVFVideoSink::setHue(float hue) { m_hue = hue; } -int AVFVideoSink::saturation() const -{ - return m_saturation; -} - -void AVFVideoSink::setSaturation(int saturation) +void AVFVideoSink::setSaturation(float saturation) { m_saturation = saturation; } diff --git a/src/multimedia/platform/darwin/avfvideosink_p.h b/src/multimedia/platform/darwin/avfvideosink_p.h index a5b5ade35..c8228d3b6 100644 --- a/src/multimedia/platform/darwin/avfvideosink_p.h +++ b/src/multimedia/platform/darwin/avfvideosink_p.h @@ -81,34 +81,27 @@ public: QVideoSink::GraphicsType graphicsType() const override { return m_graphicsType; } bool setGraphicsType(QVideoSink::GraphicsType type) override; - WId winId() const override; + WId winId() const; void setWinId(WId id) override; void setRhi(QRhi *rhi) override; - QRect displayRect() const override; + QRect displayRect() const; void setDisplayRect(const QRect &rect) override; - bool isFullScreen() const override; + bool isFullScreen() const; void setFullScreen(bool fullScreen) override; QSize nativeSize() const override; void setNativeSize(QSize size); - Qt::AspectRatioMode aspectRatioMode() const override; + Qt::AspectRatioMode aspectRatioMode() const; void setAspectRatioMode(Qt::AspectRatioMode mode) override; - int brightness() const override; - void setBrightness(int brightness) override; - - int contrast() const override; - void setContrast(int contrast) override; - - int hue() const override; - void setHue(int hue) override; - - int saturation() const override; - void setSaturation(int saturation) override; + void setBrightness(float brightness) override; + void setContrast(float contrast) override; + void setHue(float hue) override; + void setSaturation(float saturation) override; void setLayer(CALayer *playerLayer); @@ -125,10 +118,10 @@ private: QSize m_nativeSize; QRect m_displayRect; bool m_fullscreen = false; - int m_brightness = 0; - int m_contrast = 0; - int m_hue = 0; - int m_saturation = 0; + float m_brightness = 0; + float m_contrast = 0; + float m_hue = 0; + float m_saturation = 0; Qt::AspectRatioMode m_aspectRatioMode = Qt::KeepAspectRatio; }; diff --git a/src/multimedia/platform/gstreamer/common/qgstreamervideooverlay.cpp b/src/multimedia/platform/gstreamer/common/qgstreamervideooverlay.cpp index 5db0497e9..7c017a108 100644 --- a/src/multimedia/platform/gstreamer/common/qgstreamervideooverlay.cpp +++ b/src/multimedia/platform/gstreamer/common/qgstreamervideooverlay.cpp @@ -74,15 +74,10 @@ public: virtual bool hasShowPrerollFrame() const = 0; virtual void reset() = 0; - virtual int brightness() const = 0; - virtual bool setBrightness(int brightness) = 0; - virtual int contrast() const = 0; - virtual bool setContrast(int contrast) = 0; - virtual int hue() const = 0; - virtual bool setHue(int hue) = 0; - virtual int saturation() const = 0; - virtual bool setSaturation(int saturation) = 0; - virtual Qt::AspectRatioMode aspectRatioMode() const = 0; + virtual bool setBrightness(float brightness) = 0; + virtual bool setContrast(float contrast) = 0; + virtual bool setHue(float hue) = 0; + virtual bool setSaturation(float saturation) = 0; virtual void setAspectRatioMode(Qt::AspectRatioMode mode) = 0; }; @@ -115,90 +110,42 @@ public: setSaturation(m_saturation); } - int brightness() const override - { - int brightness = 0; - if (m_hasBrightness) - brightness = m_videoSink.getInt("brightness"); - - return brightness / 10; - } - - bool setBrightness(int brightness) override + bool setBrightness(float brightness) override { m_brightness = brightness; if (m_hasBrightness) - m_videoSink.set("brightness", brightness * 10); + m_videoSink.set("brightness", brightness * 1000); return m_hasBrightness; } - int contrast() const override - { - int contrast = 0; - if (m_hasContrast) - contrast = m_videoSink.getInt("contrast"); - - return contrast / 10; - } - - bool setContrast(int contrast) override + bool setContrast(float contrast) override { m_contrast = contrast; if (m_hasContrast) - m_videoSink.set("contrast", contrast * 10); + m_videoSink.set("contrast", contrast * 1000); return m_hasContrast; } - int hue() const override - { - int hue = 0; - if (m_hasHue) - hue = m_videoSink.getInt("hue"); - - return hue / 10; - } - - bool setHue(int hue) override + bool setHue(float hue) override { m_hue = hue; if (m_hasHue) - m_videoSink.set("hue", hue * 10); + m_videoSink.set("hue", hue * 1000); return m_hasHue; } - int saturation() const override - { - int saturation = 0; - if (m_hasSaturation) - saturation = m_videoSink.getInt("saturation"); - - return saturation / 10; - } - - bool setSaturation(int saturation) override + bool setSaturation(float saturation) override { m_saturation = saturation; if (m_hasSaturation) - m_videoSink.set("saturation", saturation * 10); + m_videoSink.set("saturation", saturation * 1000); return m_hasSaturation; } - Qt::AspectRatioMode aspectRatioMode() const override - { - Qt::AspectRatioMode mode = Qt::KeepAspectRatio; - if (m_hasForceAspectRatio) { - gboolean forceAR = m_videoSink.getBool("force-aspect-ratio"); - if (!forceAR) - mode = Qt::IgnoreAspectRatio; - } - - return mode; - } - void setAspectRatioMode(Qt::AspectRatioMode mode) override { m_aspectRatioMode = mode; @@ -216,10 +163,10 @@ protected: bool m_hasSaturation = false; bool m_hasShowPrerollFrame = false; Qt::AspectRatioMode m_aspectRatioMode = Qt::KeepAspectRatio; - int m_brightness = 0; - int m_contrast = 0; - int m_hue = 0; - int m_saturation = 0; + float m_brightness = 0; + float m_contrast = 0; + float m_hue = 0; + float m_saturation = 0; }; class QVaapiSinkProperties : public QXVImageSinkProperties @@ -233,80 +180,44 @@ public: m_saturation = 1; } - int brightness() const override - { - gfloat brightness = 0; - if (m_hasBrightness) - brightness = m_videoSink.getFloat("brightness"); - - return brightness * 100; // [-1,1] -> [-100,100] - } - - bool setBrightness(int brightness) override + bool setBrightness(float brightness) override { m_brightness = brightness; if (m_hasBrightness) { - gfloat v = brightness / 100.0; // [-100,100] -> [-1,1] + gfloat v = brightness; m_videoSink.set("brightness", v); } return m_hasBrightness; } - int contrast() const override - { - gfloat contrast = 1; - if (m_hasContrast) - contrast = m_videoSink.getFloat("contrast"); - - return (contrast - 1) * 100; // [0,2] -> [-100,100] - } - - bool setContrast(int contrast) override + bool setContrast(float contrast) override { m_contrast = contrast; if (m_hasContrast) { - gfloat v = (contrast / 100.0) + 1; // [-100,100] -> [0,2] + gfloat v = contrast + 1; // [-1, 1] -> [0,2] m_videoSink.set("contrast", v); } return m_hasContrast; } - int hue() const override - { - gfloat hue = 0; - if (m_hasHue) - hue = m_videoSink.getFloat("hue"); - - return hue / 180 * 100; // [-180,180] -> [-100,100] - } - - bool setHue(int hue) override + bool setHue(float hue) override { m_hue = hue; if (m_hasHue) { - gfloat v = hue / 100.0 * 180; // [-100,100] -> [-180,180] + gfloat v = hue * 180; // [-1,1] -> [-180,180] m_videoSink.set("hue", v); } return m_hasHue; } - int saturation() const override - { - gfloat saturation = 1; - if (m_hasSaturation) - saturation = m_videoSink.getFloat("saturation"); - - return (saturation - 1) * 100; // [0,2] -> [-100,100] - } - - bool setSaturation(int saturation) override + bool setSaturation(float saturation) override { m_saturation = saturation; if (m_hasSaturation) { - gfloat v = (saturation / 100.0) + 1; // [-100,100] -> [0,2] + gfloat v = saturation + 1; // [-100,100] -> [0,2] m_videoSink.set("saturation", v); } @@ -519,52 +430,27 @@ void QGstreamerVideoOverlay::showPrerollFrameChanged(GObject *, GParamSpec *, QG overlay->updateIsActive(); } -Qt::AspectRatioMode QGstreamerVideoOverlay::aspectRatioMode() const -{ - return m_sinkProperties->aspectRatioMode(); -} - void QGstreamerVideoOverlay::setAspectRatioMode(Qt::AspectRatioMode mode) { m_sinkProperties->setAspectRatioMode(mode); } -int QGstreamerVideoOverlay::brightness() const -{ - return m_sinkProperties->brightness(); -} - -void QGstreamerVideoOverlay::setBrightness(int brightness) +void QGstreamerVideoOverlay::setBrightness(float brightness) { m_sinkProperties->setBrightness(brightness); } -int QGstreamerVideoOverlay::contrast() const -{ - return m_sinkProperties->contrast(); -} - -void QGstreamerVideoOverlay::setContrast(int contrast) +void QGstreamerVideoOverlay::setContrast(float contrast) { m_sinkProperties->setContrast(contrast); } -int QGstreamerVideoOverlay::hue() const -{ - return m_sinkProperties->hue(); -} - -void QGstreamerVideoOverlay::setHue(int hue) +void QGstreamerVideoOverlay::setHue(float hue) { m_sinkProperties->setHue(hue); } -int QGstreamerVideoOverlay::saturation() const -{ - return m_sinkProperties->saturation(); -} - -void QGstreamerVideoOverlay::setSaturation(int saturation) +void QGstreamerVideoOverlay::setSaturation(float saturation) { m_sinkProperties->setSaturation(saturation); } diff --git a/src/multimedia/platform/gstreamer/common/qgstreamervideooverlay_p.h b/src/multimedia/platform/gstreamer/common/qgstreamervideooverlay_p.h index 48571d926..c1ce528c8 100644 --- a/src/multimedia/platform/gstreamer/common/qgstreamervideooverlay_p.h +++ b/src/multimedia/platform/gstreamer/common/qgstreamervideooverlay_p.h @@ -82,17 +82,10 @@ public: Qt::AspectRatioMode aspectRatioMode() const; void setAspectRatioMode(Qt::AspectRatioMode mode); - int brightness() const; - void setBrightness(int brightness); - - int contrast() const; - void setContrast(int contrast); - - int hue() const; - void setHue(int hue); - - int saturation() const; - void setSaturation(int saturation); + void setBrightness(float brightness); + void setContrast(float contrast); + void setHue(float hue); + void setSaturation(float saturation); bool processSyncMessage(const QGstreamerMessage &message) override; bool processBusMessage(const QGstreamerMessage &message) override; diff --git a/src/multimedia/platform/gstreamer/common/qgstreamervideosink.cpp b/src/multimedia/platform/gstreamer/common/qgstreamervideosink.cpp index d3d1647da..c56363f72 100644 --- a/src/multimedia/platform/gstreamer/common/qgstreamervideosink.cpp +++ b/src/multimedia/platform/gstreamer/common/qgstreamervideosink.cpp @@ -86,11 +86,6 @@ QGstElement QGstreamerVideoSink::gstSink() return m_videoRenderer->gstVideoSink(); } -WId QGstreamerVideoSink::winId() const -{ - return m_windowId; -} - void QGstreamerVideoSink::setWinId(WId id) { if (m_windowId == id) @@ -120,71 +115,36 @@ bool QGstreamerVideoSink::processBusMessage(const QGstreamerMessage &message) return m_videoOverlay->processBusMessage(message); } -QRect QGstreamerVideoSink::displayRect() const -{ - return m_displayRect; -} - void QGstreamerVideoSink::setDisplayRect(const QRect &rect) { m_videoOverlay->setRenderRectangle(m_displayRect = rect); } -Qt::AspectRatioMode QGstreamerVideoSink::aspectRatioMode() const -{ - return m_videoOverlay->aspectRatioMode(); -} - void QGstreamerVideoSink::setAspectRatioMode(Qt::AspectRatioMode mode) { m_videoOverlay->setAspectRatioMode(mode); } -int QGstreamerVideoSink::brightness() const -{ - return m_videoOverlay->brightness(); -} - -void QGstreamerVideoSink::setBrightness(int brightness) +void QGstreamerVideoSink::setBrightness(float brightness) { m_videoOverlay->setBrightness(brightness); } -int QGstreamerVideoSink::contrast() const -{ - return m_videoOverlay->contrast(); -} - -void QGstreamerVideoSink::setContrast(int contrast) +void QGstreamerVideoSink::setContrast(float contrast) { m_videoOverlay->setContrast(contrast); } -int QGstreamerVideoSink::hue() const -{ - return m_videoOverlay->hue(); -} - -void QGstreamerVideoSink::setHue(int hue) +void QGstreamerVideoSink::setHue(float hue) { m_videoOverlay->setHue(hue); } -int QGstreamerVideoSink::saturation() const -{ - return m_videoOverlay->saturation(); -} - -void QGstreamerVideoSink::setSaturation(int saturation) +void QGstreamerVideoSink::setSaturation(float saturation) { m_videoOverlay->setSaturation(saturation); } -bool QGstreamerVideoSink::isFullScreen() const -{ - return m_fullScreen; -} - void QGstreamerVideoSink::setFullScreen(bool fullScreen) { if (fullScreen == m_fullScreen) diff --git a/src/multimedia/platform/gstreamer/common/qgstreamervideosink_p.h b/src/multimedia/platform/gstreamer/common/qgstreamervideosink_p.h index d75dc25b0..9293a6c6b 100644 --- a/src/multimedia/platform/gstreamer/common/qgstreamervideosink_p.h +++ b/src/multimedia/platform/gstreamer/common/qgstreamervideosink_p.h @@ -75,34 +75,22 @@ public: QVideoSink::GraphicsType graphicsType() const override; bool setGraphicsType(QVideoSink::GraphicsType type) override; - WId winId() const override; void setWinId(WId id) override; - QRhi *rhi() const { return m_rhi; } void setRhi(QRhi *rhi) override; - QRect displayRect() const override; void setDisplayRect(const QRect &rect) override; - bool isFullScreen() const override; void setFullScreen(bool fullScreen) override; QSize nativeSize() const override; - Qt::AspectRatioMode aspectRatioMode() const override; void setAspectRatioMode(Qt::AspectRatioMode mode) override; - int brightness() const override; - void setBrightness(int brightness) override; - - int contrast() const override; - void setContrast(int contrast) override; - - int hue() const override; - void setHue(int hue) override; - - int saturation() const override; - void setSaturation(int saturation) override; + void setBrightness(float brightness) override; + void setContrast(float contrast) override; + void setHue(float hue) override; + void setSaturation(float saturation) override; QGstElement gstSink(); diff --git a/src/multimedia/platform/qnx/mediaplayer/mmrenderervideowindowcontrol.cpp b/src/multimedia/platform/qnx/mediaplayer/mmrenderervideowindowcontrol.cpp index fe0f6f874..902835a2f 100644 --- a/src/multimedia/platform/qnx/mediaplayer/mmrenderervideowindowcontrol.cpp +++ b/src/multimedia/platform/qnx/mediaplayer/mmrenderervideowindowcontrol.cpp @@ -78,11 +78,6 @@ void MmRendererVideoWindowControl::setWinId(WId id) m_winId = id; } -QRect MmRendererVideoWindowControl::displayRect() const -{ - return m_displayRect ; -} - void MmRendererVideoWindowControl::setDisplayRect(const QRect &rect) { if (m_displayRect != rect) { @@ -91,11 +86,6 @@ void MmRendererVideoWindowControl::setDisplayRect(const QRect &rect) } } -bool MmRendererVideoWindowControl::isFullScreen() const -{ - return m_fullscreen; -} - void MmRendererVideoWindowControl::setFullScreen(bool fullScreen) { if (m_fullscreen != fullScreen) { @@ -125,12 +115,7 @@ void MmRendererVideoWindowControl::setAspectRatioMode(Qt::AspectRatioMode mode) m_aspectRatioMode = mode; } -int MmRendererVideoWindowControl::brightness() const -{ - return m_brightness; -} - -void MmRendererVideoWindowControl::setBrightness(int brightness) +void MmRendererVideoWindowControl::setBrightness(float brightness) { if (m_brightness != brightness) { m_brightness = brightness; @@ -139,12 +124,7 @@ void MmRendererVideoWindowControl::setBrightness(int brightness) } } -int MmRendererVideoWindowControl::contrast() const -{ - return m_contrast; -} - -void MmRendererVideoWindowControl::setContrast(int contrast) +void MmRendererVideoWindowControl::setContrast(float contrast) { if (m_contrast != contrast) { m_contrast = contrast; @@ -153,12 +133,7 @@ void MmRendererVideoWindowControl::setContrast(int contrast) } } -int MmRendererVideoWindowControl::hue() const -{ - return m_hue; -} - -void MmRendererVideoWindowControl::setHue(int hue) +void MmRendererVideoWindowControl::setHue(float hue) { if (m_hue != hue) { m_hue = hue; @@ -167,12 +142,7 @@ void MmRendererVideoWindowControl::setHue(int hue) } } -int MmRendererVideoWindowControl::saturation() const -{ - return m_saturation; -} - -void MmRendererVideoWindowControl::setSaturation(int saturation) +void MmRendererVideoWindowControl::setSaturation(float saturation) { if (m_saturation != saturation) { m_saturation = saturation; @@ -307,7 +277,7 @@ void MmRendererVideoWindowControl::updateVideoPosition() void MmRendererVideoWindowControl::updateBrightness() { if (m_window != 0) { - const int backendValue = m_brightness * 2.55f; + const int backendValue = m_brightness * 255f; if (screen_set_window_property_iv(m_window, SCREEN_PROPERTY_BRIGHTNESS, &backendValue) != 0) perror("Setting brightness failed"); } @@ -316,7 +286,7 @@ void MmRendererVideoWindowControl::updateBrightness() void MmRendererVideoWindowControl::updateContrast() { if (m_window != 0) { - const int backendValue = m_contrast * 1.27f; + const int backendValue = m_contrast * 127f; if (screen_set_window_property_iv(m_window, SCREEN_PROPERTY_CONTRAST, &backendValue) != 0) perror("Setting contrast failed"); } @@ -325,7 +295,7 @@ void MmRendererVideoWindowControl::updateContrast() void MmRendererVideoWindowControl::updateHue() { if (m_window != 0) { - const int backendValue = m_hue * 1.27f; + const int backendValue = m_hue * 127f; if (screen_set_window_property_iv(m_window, SCREEN_PROPERTY_HUE, &backendValue) != 0) perror("Setting hue failed"); } @@ -334,7 +304,7 @@ void MmRendererVideoWindowControl::updateHue() void MmRendererVideoWindowControl::updateSaturation() { if (m_window != 0) { - const int backendValue = m_saturation * 1.27f; + const int backendValue = m_saturation * 127f; if (screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SATURATION, &backendValue) != 0) perror("Setting saturation failed"); } diff --git a/src/multimedia/platform/qnx/mediaplayer/mmrenderervideowindowcontrol_p.h b/src/multimedia/platform/qnx/mediaplayer/mmrenderervideowindowcontrol_p.h index 518eb8099..315a75077 100644 --- a/src/multimedia/platform/qnx/mediaplayer/mmrenderervideowindowcontrol_p.h +++ b/src/multimedia/platform/qnx/mediaplayer/mmrenderervideowindowcontrol_p.h @@ -68,10 +68,8 @@ public: WId winId() const override; void setWinId(WId id) override; - QRect displayRect() const override; void setDisplayRect(const QRect &rect) override; - bool isFullScreen() const override; void setFullScreen(bool fullScreen) override; void repaint() override; @@ -81,17 +79,10 @@ public: Qt::AspectRatioMode aspectRatioMode() const override; void setAspectRatioMode(Qt::AspectRatioMode mode) override; - int brightness() const override; - void setBrightness(int brightness) override; - - int contrast() const override; - void setContrast(int contrast) override; - - int hue() const override; - void setHue(int hue) override; - - int saturation() const override; - void setSaturation(int saturation) override; + void setBrightness(float brightness) override; + void setContrast(float contrast) override; + void setHue(float hue) override; + void setSaturation(float saturation) override; // // Called by media control @@ -118,10 +109,10 @@ private: Qt::AspectRatioMode m_aspectRatioMode; QString m_windowName; screen_window_t m_window; - int m_hue; - int m_brightness; - int m_contrast; - int m_saturation; + float m_hue; + float m_brightness; + float m_contrast; + float m_saturation; }; QT_END_NAMESPACE diff --git a/src/multimedia/platform/qplatformvideosink.cpp b/src/multimedia/platform/qplatformvideosink.cpp index f1ec3dcbc..2912b32e4 100644 --- a/src/multimedia/platform/qplatformvideosink.cpp +++ b/src/multimedia/platform/qplatformvideosink.cpp @@ -143,15 +143,7 @@ QPlatformVideoSink::QPlatformVideoSink(QVideoSink *parent) */ /*! - \fn QPlatformVideoSink::brightness() const - - Returns the brightness adjustment applied to a video overlay. - - Valid brightness values range between -100 and 100, the default is 0. -*/ - -/*! - \fn QPlatformVideoSink::setBrightness(int brightness) + \fn QPlatformVideoSink::setBrightness(float brightness) Sets a \a brightness adjustment for a video overlay. @@ -159,21 +151,7 @@ QPlatformVideoSink::QPlatformVideoSink(QVideoSink *parent) */ /*! - \fn QPlatformVideoSink::brightnessChanged(int brightness) - - Signals that a video overlay's \a brightness adjustment has changed. -*/ - -/*! - \fn QPlatformVideoSink::contrast() const - - Returns the contrast adjustment applied to a video overlay. - - Valid contrast values range between -100 and 100, the default is 0. -*/ - -/*! - \fn QPlatformVideoSink::setContrast(int contrast) + \fn QPlatformVideoSink::setContrast(float contrast) Sets the \a contrast adjustment for a video overlay. @@ -181,21 +159,7 @@ QPlatformVideoSink::QPlatformVideoSink(QVideoSink *parent) */ /*! - \fn QPlatformVideoSink::contrastChanged(int contrast) - - Signals that a video overlay's \a contrast adjustment has changed. -*/ - -/*! - \fn QPlatformVideoSink::hue() const - - Returns the hue adjustment applied to a video overlay. - - Value hue values range between -100 and 100, the default is 0. -*/ - -/*! - \fn QPlatformVideoSink::setHue(int hue) + \fn QPlatformVideoSink::setHue(float hue) Sets a \a hue adjustment for a video overlay. @@ -203,32 +167,12 @@ QPlatformVideoSink::QPlatformVideoSink(QVideoSink *parent) */ /*! - \fn QPlatformVideoSink::hueChanged(int hue) - - Signals that a video overlay's \a hue adjustment has changed. -*/ - -/*! - \fn QPlatformVideoSink::saturation() const - - Returns the saturation adjustment applied to a video overlay. - - Value saturation values range between -100 and 100, the default is 0. -*/ - -/*! - \fn QPlatformVideoSink::setSaturation(int saturation) + \fn QPlatformVideoSink::setSaturation(float saturation) Sets a \a saturation adjustment for a video overlay. Valid saturation values range between -100 and 100, the default is 0. */ -/*! - \fn QPlatformVideoSink::saturationChanged(int saturation) - - Signals that a video overlay's \a saturation adjustment has changed. -*/ - QT_END_NAMESPACE #include "moc_qplatformvideosink_p.cpp" diff --git a/src/multimedia/platform/qplatformvideosink_p.h b/src/multimedia/platform/qplatformvideosink_p.h index 61f0a678d..2e43e0f71 100644 --- a/src/multimedia/platform/qplatformvideosink_p.h +++ b/src/multimedia/platform/qplatformvideosink_p.h @@ -61,33 +61,22 @@ public: virtual QVideoSink::GraphicsType graphicsType() const { return QVideoSink::NativeWindow; } virtual bool setGraphicsType(QVideoSink::GraphicsType /*type*/) { return false; } - virtual WId winId() const = 0; virtual void setWinId(WId id) = 0; virtual void setRhi(QRhi */*rhi*/) {} - virtual QRect displayRect() const = 0; virtual void setDisplayRect(const QRect &rect) = 0; - virtual bool isFullScreen() const = 0; virtual void setFullScreen(bool fullScreen) = 0; virtual QSize nativeSize() const = 0; - virtual Qt::AspectRatioMode aspectRatioMode() const = 0; virtual void setAspectRatioMode(Qt::AspectRatioMode mode) = 0; - virtual int brightness() const = 0; - virtual void setBrightness(int brightness) = 0; - - virtual int contrast() const = 0; - virtual void setContrast(int contrast) = 0; - - virtual int hue() const = 0; - virtual void setHue(int hue) = 0; - - virtual int saturation() const = 0; - virtual void setSaturation(int saturation) = 0; + virtual void setBrightness(float brightness) = 0; + virtual void setContrast(float contrast) = 0; + virtual void setHue(float hue) = 0; + virtual void setSaturation(float saturation) = 0; QVideoSink *videoSink() { return sink; } diff --git a/src/multimedia/platform/windows/evr/evrvideowindowcontrol.cpp b/src/multimedia/platform/windows/evr/evrvideowindowcontrol.cpp index 00f29793a..4b8e6dc0f 100644 --- a/src/multimedia/platform/windows/evr/evrvideowindowcontrol.cpp +++ b/src/multimedia/platform/windows/evr/evrvideowindowcontrol.cpp @@ -98,11 +98,6 @@ void EvrVideoWindowControl::clear() m_processor = NULL; } -WId EvrVideoWindowControl::winId() const -{ - return m_windowId; -} - void EvrVideoWindowControl::setWinId(WId id) { m_windowId = id; @@ -111,11 +106,6 @@ void EvrVideoWindowControl::setWinId(WId id) m_displayControl->SetVideoWindow(HWND(m_windowId)); } -QRect EvrVideoWindowControl::displayRect() const -{ - return m_displayRect; -} - void EvrVideoWindowControl::setDisplayRect(const QRect &rect) { m_displayRect = rect; @@ -152,46 +142,12 @@ void EvrVideoWindowControl::setDisplayRect(const QRect &rect) } } -bool EvrVideoWindowControl::isFullScreen() const -{ - return m_fullScreen; -} - void EvrVideoWindowControl::setFullScreen(bool fullScreen) { if (m_fullScreen == fullScreen) return; } -void EvrVideoWindowControl::repaint() -{ - QSize size = nativeSize(); - if (size.width() > 0 && size.height() > 0 - && m_displayControl - && SUCCEEDED(m_displayControl->RepaintVideo())) { - return; - } - - PAINTSTRUCT paint; - if (HDC dc = ::BeginPaint(HWND(m_windowId), &paint)) { - HPEN pen = ::CreatePen(PS_SOLID, 1, m_windowColor); - HBRUSH brush = ::CreateSolidBrush(m_windowColor); - ::SelectObject(dc, pen); - ::SelectObject(dc, brush); - - ::Rectangle( - dc, - m_displayRect.left(), - m_displayRect.top(), - m_displayRect.right() + 1, - m_displayRect.bottom() + 1); - - ::DeleteObject(pen); - ::DeleteObject(brush); - ::EndPaint(HWND(m_windowId), &paint); - } -} - QSize EvrVideoWindowControl::nativeSize() const { QSize size; @@ -203,11 +159,6 @@ QSize EvrVideoWindowControl::nativeSize() const return size; } -Qt::AspectRatioMode EvrVideoWindowControl::aspectRatioMode() const -{ - return m_aspectRatioMode; -} - void EvrVideoWindowControl::setAspectRatioMode(Qt::AspectRatioMode mode) { m_aspectRatioMode = mode; @@ -233,12 +184,7 @@ void EvrVideoWindowControl::setAspectRatioMode(Qt::AspectRatioMode mode) } } -int EvrVideoWindowControl::brightness() const -{ - return m_brightness; -} - -void EvrVideoWindowControl::setBrightness(int brightness) +void EvrVideoWindowControl::setBrightness(float brightness) { if (m_brightness == brightness) return; @@ -250,12 +196,7 @@ void EvrVideoWindowControl::setBrightness(int brightness) applyImageControls(); } -int EvrVideoWindowControl::contrast() const -{ - return m_contrast; -} - -void EvrVideoWindowControl::setContrast(int contrast) +void EvrVideoWindowControl::setContrast(float contrast) { if (m_contrast == contrast) return; @@ -267,12 +208,7 @@ void EvrVideoWindowControl::setContrast(int contrast) applyImageControls(); } -int EvrVideoWindowControl::hue() const -{ - return m_hue; -} - -void EvrVideoWindowControl::setHue(int hue) +void EvrVideoWindowControl::setHue(float hue) { if (m_hue == hue) return; @@ -284,12 +220,7 @@ void EvrVideoWindowControl::setHue(int hue) applyImageControls(); } -int EvrVideoWindowControl::saturation() const -{ - return m_saturation; -} - -void EvrVideoWindowControl::setSaturation(int saturation) +void EvrVideoWindowControl::setSaturation(float saturation) { if (m_saturation == saturation) return; @@ -324,7 +255,7 @@ void EvrVideoWindowControl::applyImageControls() } } -DXVA2_Fixed32 EvrVideoWindowControl::scaleProcAmpValue(DWORD prop, int value) const +DXVA2_Fixed32 EvrVideoWindowControl::scaleProcAmpValue(DWORD prop, float value) const { float scaledValue = 0.0; @@ -332,9 +263,9 @@ DXVA2_Fixed32 EvrVideoWindowControl::scaleProcAmpValue(DWORD prop, int value) co if (SUCCEEDED(m_processor->GetProcAmpRange(prop, &range))) { scaledValue = DXVA2FixedToFloat(range.DefaultValue); if (value > 0) - scaledValue += float(value) * (DXVA2FixedToFloat(range.MaxValue) - DXVA2FixedToFloat(range.DefaultValue)) / 100; + scaledValue += float(value) * (DXVA2FixedToFloat(range.MaxValue) - DXVA2FixedToFloat(range.DefaultValue)); else if (value < 0) - scaledValue -= float(value) * (DXVA2FixedToFloat(range.MinValue) - DXVA2FixedToFloat(range.DefaultValue)) / 100; + scaledValue -= float(value) * (DXVA2FixedToFloat(range.MinValue) - DXVA2FixedToFloat(range.DefaultValue)); } return DXVA2FloatToFixed(scaledValue); diff --git a/src/multimedia/platform/windows/evr/evrvideowindowcontrol_p.h b/src/multimedia/platform/windows/evr/evrvideowindowcontrol_p.h index 0d829398f..b9fbc271c 100644 --- a/src/multimedia/platform/windows/evr/evrvideowindowcontrol_p.h +++ b/src/multimedia/platform/windows/evr/evrvideowindowcontrol_p.h @@ -66,49 +66,36 @@ public: bool setEvr(IUnknown *evr); - WId winId() const override; void setWinId(WId id) override; - QRect displayRect() const override; void setDisplayRect(const QRect &rect) override; - bool isFullScreen() const override; void setFullScreen(bool fullScreen) override; - void repaint() override; - QSize nativeSize() const override; - Qt::AspectRatioMode aspectRatioMode() const override; void setAspectRatioMode(Qt::AspectRatioMode mode) override; - int brightness() const override; - void setBrightness(int brightness) override; - - int contrast() const override; - void setContrast(int contrast) override; - - int hue() const override; - void setHue(int hue) override; - - int saturation() const override; - void setSaturation(int saturation) override; + void setBrightness(float brightness) override; + void setContrast(float contrast) override; + void setHue(float hue) override; + void setSaturation(float saturation) override; void applyImageControls(); private: void clear(); - DXVA2_Fixed32 scaleProcAmpValue(DWORD prop, int value) const; + DXVA2_Fixed32 scaleProcAmpValue(DWORD prop, float value) const; WId m_windowId; COLORREF m_windowColor; DWORD m_dirtyValues; Qt::AspectRatioMode m_aspectRatioMode; QRect m_displayRect; - int m_brightness; - int m_contrast; - int m_hue; - int m_saturation; + float m_brightness; + float m_contrast; + float m_hue; + float m_saturation; bool m_fullScreen; IMFVideoDisplayControl *m_displayControl; diff --git a/src/multimedia/video/qvideosink.cpp b/src/multimedia/video/qvideosink.cpp index 93308112e..7cd786651 100644 --- a/src/multimedia/video/qvideosink.cpp +++ b/src/multimedia/video/qvideosink.cpp @@ -65,17 +65,15 @@ public: QVideoSink *q_ptr = nullptr; QPlatformVideoSink *videoSink = nullptr; QVideoSink::GraphicsType type = QVideoSink::Memory; - QVideoFrameFormat surfaceFormat; - QSize nativeResolution; - bool active = false; + bool fullScreen = false; WId window = 0; QRhi *rhi = nullptr; Qt::AspectRatioMode aspectRatioMode = Qt::KeepAspectRatio; QRectF targetRect; - int brightness = 0; - int contrast = 0; - int saturation = 0; - int hue = 0; + float brightness = 0; + float contrast = 0; + float saturation = 0; + float hue = 0; Qt::BGMode backgroundMode = Qt::OpaqueMode; }; @@ -133,18 +131,12 @@ void QVideoSink::setGraphicsType(QVideoSink::GraphicsType type) d->videoSink->setGraphicsType(type); } -bool QVideoSink::isGraphicsTypeSupported(QVideoSink::GraphicsType type) -{ - // #### - return type == NativeWindow; -} - /*! Returns the native window id that the sink is currently rendering to. */ WId QVideoSink::nativeWindowId() const { - return d->videoSink->winId(); + return d->window; } /*! @@ -157,6 +149,9 @@ WId QVideoSink::nativeWindowId() const */ void QVideoSink::setNativeWindowId(WId id) { + if (d->window == id) + return; + d->window = id; d->videoSink->setWinId(id); } @@ -189,6 +184,9 @@ void QVideoSink::setRhi(QRhi *rhi) */ void QVideoSink::setFullScreen(bool fullscreen) { + if (d->fullScreen == fullscreen) + return; + d->fullScreen = fullscreen; d->videoSink->setFullScreen(fullscreen); } @@ -197,16 +195,18 @@ void QVideoSink::setFullScreen(bool fullscreen) */ bool QVideoSink::isFullscreen() const { - return d->videoSink->isFullScreen(); + return d->fullScreen; } Qt::AspectRatioMode QVideoSink::aspectRatioMode() const { - return d->videoSink->aspectRatioMode(); + return d->aspectRatioMode; } void QVideoSink::setAspectRatioMode(Qt::AspectRatioMode mode) { + if (d->aspectRatioMode == mode) + return; d->videoSink->setAspectRatioMode(mode); } @@ -217,47 +217,61 @@ QRectF QVideoSink::targetRect() const void QVideoSink::setTargetRect(const QRectF &rect) { - d->videoSink->setDisplayRect(rect.toRect()); + if (d->targetRect == rect) + return; d->targetRect = rect; + d->videoSink->setDisplayRect(rect.toRect()); } -int QVideoSink::brightness() const +float QVideoSink::brightness() const { - return d->videoSink->brightness(); + return d->brightness; } -void QVideoSink::setBrightness(int brightness) +void QVideoSink::setBrightness(float brightness) { + if (d->brightness == brightness) + return; + d->brightness = brightness; d->videoSink->setBrightness(brightness); } -int QVideoSink::contrast() const +float QVideoSink::contrast() const { - return d->videoSink->contrast(); + return d->contrast; } -void QVideoSink::setContrast(int contrast) +void QVideoSink::setContrast(float contrast) { + if (d->contrast == contrast) + return; + d->contrast = contrast; d->videoSink->setContrast(contrast); } -int QVideoSink::hue() const +float QVideoSink::hue() const { - return d->videoSink->hue(); + return d->hue; } -void QVideoSink::setHue(int hue) +void QVideoSink::setHue(float hue) { + if (d->hue == hue) + return; + d->hue = hue; d->videoSink->setHue(hue); } -int QVideoSink::saturation() const +float QVideoSink::saturation() const { - return d->videoSink->saturation(); + return d->saturation; } -void QVideoSink::setSaturation(int saturation) +void QVideoSink::setSaturation(float saturation) { + if (d->saturation == saturation) + return; + d->saturation = saturation; d->videoSink->setSaturation(saturation); } diff --git a/src/multimedia/video/qvideosink.h b/src/multimedia/video/qvideosink.h index e88a288c5..34b2f7bf9 100644 --- a/src/multimedia/video/qvideosink.h +++ b/src/multimedia/video/qvideosink.h @@ -71,8 +71,6 @@ public: GraphicsType graphicsType() const; void setGraphicsType(GraphicsType type); - static bool isGraphicsTypeSupported(GraphicsType type); - // setter sets graphics type to NativeWindow WId nativeWindowId() const; void setNativeWindowId(WId id); @@ -89,17 +87,17 @@ public: QRectF targetRect() const; void setTargetRect(const QRectF &rect); - int brightness() const; - void setBrightness(int brightness); + float brightness() const; + void setBrightness(float brightness); - int contrast() const; - void setContrast(int contrast); + float contrast() const; + void setContrast(float contrast); - int hue() const; - void setHue(int hue); + float hue() const; + void setHue(float hue); - int saturation() const; - void setSaturation(int saturation); + float saturation() const; + void setSaturation(float saturation); Qt::BGMode backgroundMode() const; void setBackgroundMode(Qt::BGMode mode); |