diff options
Diffstat (limited to 'src/imports')
-rw-r--r-- | src/imports/multimedia/qdeclarativevideooutput_render.cpp | 47 | ||||
-rw-r--r-- | src/imports/multimedia/qdeclarativevideooutput_render_p.h | 1 |
2 files changed, 31 insertions, 17 deletions
diff --git a/src/imports/multimedia/qdeclarativevideooutput_render.cpp b/src/imports/multimedia/qdeclarativevideooutput_render.cpp index 8455794c2..1f8bd993a 100644 --- a/src/imports/multimedia/qdeclarativevideooutput_render.cpp +++ b/src/imports/multimedia/qdeclarativevideooutput_render.cpp @@ -53,7 +53,8 @@ Q_GLOBAL_STATIC_WITH_ARGS(QMediaPluginLoader, videoNodeFactoryLoader, (QSGVideoNodeFactoryInterface_iid, QLatin1String("video/videonode"), Qt::CaseInsensitive)) QDeclarativeVideoRendererBackend::QDeclarativeVideoRendererBackend(QDeclarativeVideoOutput *parent) - : QDeclarativeVideoBackend(parent) + : QDeclarativeVideoBackend(parent), + m_frameChanged(false) { m_surface = new QSGVideoItemSurface(this); QObject::connect(m_surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)), @@ -164,36 +165,47 @@ QSGNode *QDeclarativeVideoRendererBackend::updatePaintNode(QSGNode *oldNode, QMutexLocker lock(&m_frameMutex); - if (videoNode && videoNode->pixelFormat() != m_frame.pixelFormat()) { + if (m_frameChanged) { + if (videoNode && videoNode->pixelFormat() != m_frame.pixelFormat()) { #ifdef DEBUG_VIDEOITEM - qDebug() << "updatePaintNode: deleting old video node because frame format changed..."; + qDebug() << "updatePaintNode: deleting old video node because frame format changed..."; #endif - delete videoNode; - videoNode = 0; - } + delete videoNode; + videoNode = 0; + } - if (!m_frame.isValid()) { + if (!m_frame.isValid()) { #ifdef DEBUG_VIDEOITEM - qDebug() << "updatePaintNode: no frames yet... aborting..."; + qDebug() << "updatePaintNode: no frames yet... aborting..."; #endif - return 0; - } + m_frameChanged = false; + return 0; + } - if (!videoNode) { - foreach (QSGVideoNodeFactoryInterface* factory, m_videoNodeFactories) { - videoNode = factory->createNode(m_surface->surfaceFormat()); - if (videoNode) - break; + if (!videoNode) { + foreach (QSGVideoNodeFactoryInterface* factory, m_videoNodeFactories) { + videoNode = factory->createNode(m_surface->surfaceFormat()); + if (videoNode) + break; + } } } - if (!videoNode) + if (!videoNode) { + m_frameChanged = false; + m_frame = QVideoFrame(); return 0; + } // Negative rotations need lots of %360 videoNode->setTexturedRectGeometry(m_renderedRect, m_sourceTextureRect, qNormalizedOrientation(q->orientation())); - videoNode->setCurrentFrame(m_frame); + if (m_frameChanged) { + videoNode->setCurrentFrame(m_frame); + //don't keep the frame for more than really necessary + m_frameChanged = false; + m_frame = QVideoFrame(); + } return videoNode; } @@ -206,6 +218,7 @@ void QDeclarativeVideoRendererBackend::present(const QVideoFrame &frame) { m_frameMutex.lock(); m_frame = frame; + m_frameChanged = true; m_frameMutex.unlock(); q->update(); diff --git a/src/imports/multimedia/qdeclarativevideooutput_render_p.h b/src/imports/multimedia/qdeclarativevideooutput_render_p.h index e717ddb1d..e734215ea 100644 --- a/src/imports/multimedia/qdeclarativevideooutput_render_p.h +++ b/src/imports/multimedia/qdeclarativevideooutput_render_p.h @@ -78,6 +78,7 @@ private: QList<QSGVideoNodeFactoryInterface*> m_videoNodeFactories; QSGVideoItemSurface *m_surface; QVideoFrame m_frame; + bool m_frameChanged; QSGVideoNodeFactory_I420 m_i420Factory; QSGVideoNodeFactory_RGB m_rgbFactory; QMutex m_frameMutex; |