summaryrefslogtreecommitdiffstats
path: root/src/imports/multimedia
diff options
context:
space:
mode:
authorDmytro Poplavskiy <dmytro.poplavskiy@nokia.com>2012-05-16 14:05:45 +1000
committerQt by Nokia <qt-info@nokia.com>2012-05-16 07:07:28 +0200
commit3b88e105f886995613518a4e32c51c7e818eb19a (patch)
tree38fe42731fad218d24683c436b93035a466b1a27 /src/imports/multimedia
parentbe6d80e57ad7bddedcceaa061027a04bbddc85bb (diff)
QML VideoOutput: don't keep video frames for more than necessary
The frame can be released as soon as it pushed to video node. Change-Id: Ib2621cc2a001629e722bf15b6e1ca09323170870 Reviewed-by: Mithra Pattison <mithra.pattison@nokia.com> Reviewed-by: Ling Hu <ling.hu@nokia.com>
Diffstat (limited to 'src/imports/multimedia')
-rw-r--r--src/imports/multimedia/qdeclarativevideooutput_render.cpp47
-rw-r--r--src/imports/multimedia/qdeclarativevideooutput_render_p.h1
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;