From 3e94b7ce2d8166767ec47425d2cefbc77cb5fde2 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 8 Jan 2015 14:32:41 +0100 Subject: Add video filtering support to VideoOutput Add the QAbstractVideoFilter base class and integrate it with VideoOutput. This can be used to perform arbitrary filtering or image processing on the frames of a video stream of a VideoOutput element right before the OpenGL texture is provided to the scenegraph by the video node. This opens up the possibility to integrate computer vision frameworks or accelerated image processing with Qt Quick applications that display video streams using Qt Multimedia. Conceptually it is somewhat similar to QVideoProbe, this approach however allows modifying the frame, in real time with tight integration to the scenegraph node, and targets Qt Quick meaning setting up the filter and processing the results of the computations happen completely in QML. [ChangeLog] Added QAbstractVideoFilter that serves as a base class for QML video filtering elements that integrate compute, vision, and image processing frameworks with VideoOutput. Change-Id: Ice1483f8c2daec5a43536978627a7bbb64549480 Reviewed-by: Yoann Lopes --- .../qdeclarativevideooutput_render_p.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/qtmultimediaquicktools/qdeclarativevideooutput_render_p.h') diff --git a/src/qtmultimediaquicktools/qdeclarativevideooutput_render_p.h b/src/qtmultimediaquicktools/qdeclarativevideooutput_render_p.h index dd8449fa8..a0fed3d00 100644 --- a/src/qtmultimediaquicktools/qdeclarativevideooutput_render_p.h +++ b/src/qtmultimediaquicktools/qdeclarativevideooutput_render_p.h @@ -48,6 +48,8 @@ QT_BEGIN_NAMESPACE class QSGVideoItemSurface; class QVideoRendererControl; class QOpenGLContext; +class QAbstractVideoFilter; +class QVideoFilterRunnable; class QDeclarativeVideoRendererBackend : public QDeclarativeVideoBackend { @@ -70,7 +72,14 @@ public: void present(const QVideoFrame &frame); void stop(); + void appendFilter(QAbstractVideoFilter *filter) Q_DECL_OVERRIDE; + void clearFilters() Q_DECL_OVERRIDE; + void releaseResources() Q_DECL_OVERRIDE; + void invalidateSceneGraph() Q_DECL_OVERRIDE; + private: + void scheduleDeleteFilterResources(); + QPointer m_rendererControl; QList m_videoNodeFactories; QSGVideoItemSurface *m_surface; @@ -83,6 +92,14 @@ private: QMutex m_frameMutex; QRectF m_renderedRect; // Destination pixel coordinates, clipped QRectF m_sourceTextureRect; // Source texture coordinates + + struct Filter { + Filter() : filter(0), runnable(0) { } + Filter(QAbstractVideoFilter *filter) : filter(filter), runnable(0) { } + QAbstractVideoFilter *filter; + QVideoFilterRunnable *runnable; + }; + QList m_filters; }; class QSGVideoItemSurface : public QAbstractVideoSurface -- cgit v1.2.1