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>
This commit is contained in:
committed by
Qt by Nokia
parent
be6d80e57a
commit
3b88e105f8
@@ -53,7 +53,8 @@ Q_GLOBAL_STATIC_WITH_ARGS(QMediaPluginLoader, videoNodeFactoryLoader,
|
|||||||
(QSGVideoNodeFactoryInterface_iid, QLatin1String("video/videonode"), Qt::CaseInsensitive))
|
(QSGVideoNodeFactoryInterface_iid, QLatin1String("video/videonode"), Qt::CaseInsensitive))
|
||||||
|
|
||||||
QDeclarativeVideoRendererBackend::QDeclarativeVideoRendererBackend(QDeclarativeVideoOutput *parent)
|
QDeclarativeVideoRendererBackend::QDeclarativeVideoRendererBackend(QDeclarativeVideoOutput *parent)
|
||||||
: QDeclarativeVideoBackend(parent)
|
: QDeclarativeVideoBackend(parent),
|
||||||
|
m_frameChanged(false)
|
||||||
{
|
{
|
||||||
m_surface = new QSGVideoItemSurface(this);
|
m_surface = new QSGVideoItemSurface(this);
|
||||||
QObject::connect(m_surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)),
|
QObject::connect(m_surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)),
|
||||||
@@ -164,36 +165,47 @@ QSGNode *QDeclarativeVideoRendererBackend::updatePaintNode(QSGNode *oldNode,
|
|||||||
|
|
||||||
QMutexLocker lock(&m_frameMutex);
|
QMutexLocker lock(&m_frameMutex);
|
||||||
|
|
||||||
if (videoNode && videoNode->pixelFormat() != m_frame.pixelFormat()) {
|
if (m_frameChanged) {
|
||||||
|
if (videoNode && videoNode->pixelFormat() != m_frame.pixelFormat()) {
|
||||||
#ifdef DEBUG_VIDEOITEM
|
#ifdef DEBUG_VIDEOITEM
|
||||||
qDebug() << "updatePaintNode: deleting old video node because frame format changed...";
|
qDebug() << "updatePaintNode: deleting old video node because frame format changed...";
|
||||||
#endif
|
#endif
|
||||||
delete videoNode;
|
delete videoNode;
|
||||||
videoNode = 0;
|
videoNode = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_frame.isValid()) {
|
if (!m_frame.isValid()) {
|
||||||
#ifdef DEBUG_VIDEOITEM
|
#ifdef DEBUG_VIDEOITEM
|
||||||
qDebug() << "updatePaintNode: no frames yet... aborting...";
|
qDebug() << "updatePaintNode: no frames yet... aborting...";
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
m_frameChanged = false;
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!videoNode) {
|
if (!videoNode) {
|
||||||
foreach (QSGVideoNodeFactoryInterface* factory, m_videoNodeFactories) {
|
foreach (QSGVideoNodeFactoryInterface* factory, m_videoNodeFactories) {
|
||||||
videoNode = factory->createNode(m_surface->surfaceFormat());
|
videoNode = factory->createNode(m_surface->surfaceFormat());
|
||||||
if (videoNode)
|
if (videoNode)
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!videoNode)
|
if (!videoNode) {
|
||||||
|
m_frameChanged = false;
|
||||||
|
m_frame = QVideoFrame();
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Negative rotations need lots of %360
|
// Negative rotations need lots of %360
|
||||||
videoNode->setTexturedRectGeometry(m_renderedRect, m_sourceTextureRect,
|
videoNode->setTexturedRectGeometry(m_renderedRect, m_sourceTextureRect,
|
||||||
qNormalizedOrientation(q->orientation()));
|
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;
|
return videoNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,6 +218,7 @@ void QDeclarativeVideoRendererBackend::present(const QVideoFrame &frame)
|
|||||||
{
|
{
|
||||||
m_frameMutex.lock();
|
m_frameMutex.lock();
|
||||||
m_frame = frame;
|
m_frame = frame;
|
||||||
|
m_frameChanged = true;
|
||||||
m_frameMutex.unlock();
|
m_frameMutex.unlock();
|
||||||
|
|
||||||
q->update();
|
q->update();
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ private:
|
|||||||
QList<QSGVideoNodeFactoryInterface*> m_videoNodeFactories;
|
QList<QSGVideoNodeFactoryInterface*> m_videoNodeFactories;
|
||||||
QSGVideoItemSurface *m_surface;
|
QSGVideoItemSurface *m_surface;
|
||||||
QVideoFrame m_frame;
|
QVideoFrame m_frame;
|
||||||
|
bool m_frameChanged;
|
||||||
QSGVideoNodeFactory_I420 m_i420Factory;
|
QSGVideoNodeFactory_I420 m_i420Factory;
|
||||||
QSGVideoNodeFactory_RGB m_rgbFactory;
|
QSGVideoNodeFactory_RGB m_rgbFactory;
|
||||||
QMutex m_frameMutex;
|
QMutex m_frameMutex;
|
||||||
|
|||||||
Reference in New Issue
Block a user