From 493195d6e3700f2351cbe3e073ad737747c5d894 Mon Sep 17 00:00:00 2001 From: Stephan Rafin Date: Wed, 2 Oct 2024 14:28:14 +0200 Subject: [PATCH] Fix i.Mx8 low FPS when playing video using gstreamer imxvideoconvert_g2d was picked as video converter whereas it does not output a memory buffer which can be used as GL texture.. Instead, use glupload to get a proper buffer (with attribure memory:GLMemory) and glcolorconvert as CSC Notes: - This patch hardcodes the fix for iMx8 it does not care about being portable to orther targets - Maybe defining glUpload as a new attribute is overkill but I wanted to be sure to be safe regarding object lifetime --- .../gstreamer/common/qgstreamervideosink.cpp | 19 +++++++++---------- .../gstreamer/common/qgstreamervideosink_p.h | 1 + 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/plugins/multimedia/gstreamer/common/qgstreamervideosink.cpp b/src/plugins/multimedia/gstreamer/common/qgstreamervideosink.cpp index f49dd8278..a2f7dd908 100644 --- a/src/plugins/multimedia/gstreamer/common/qgstreamervideosink.cpp +++ b/src/plugins/multimedia/gstreamer/common/qgstreamervideosink.cpp @@ -48,16 +48,15 @@ QGstreamerVideoSink::QGstreamerVideoSink(QVideoSink *parent) // To fix this, simply insert the element into the pipeline if it's available. Otherwise // we simply use an identity element. gstQueue = QGstElement("queue"); - auto imxVideoConvert = QGstElement("imxvideoconvert_g2d"); - auto nvidiaVideoConvert = QGstElement("nvvidconv"); - if (!imxVideoConvert.isNull()) - gstPreprocess = imxVideoConvert; - else if (!nvidiaVideoConvert.isNull()) - gstPreprocess = nvidiaVideoConvert; - else - gstPreprocess = QGstElement("identity"); - sinkBin.add(gstQueue, gstPreprocess); - gstQueue.link(gstPreprocess); + + // For iMX8, we need to pass to qgstvideorenderersink a buffer which can be used + // as a GL texture (attribure memory:GLMemory) + // So use glupload to get proper buffer and glcolorconvert as CSC + glUpload = QGstElement("glupload"); + gstPreprocess = QGstElement("glcolorconvert"); + sinkBin.add(gstQueue, glUpload, gstPreprocess); + gstQueue.link(glUpload); + glUpload.link(gstPreprocess); sinkBin.addGhostPad(gstQueue, "sink"); gstSubtitleSink = GST_ELEMENT(QGstSubtitleSink::createSink(this)); diff --git a/src/plugins/multimedia/gstreamer/common/qgstreamervideosink_p.h b/src/plugins/multimedia/gstreamer/common/qgstreamervideosink_p.h index b61b2b18a..a03739f00 100644 --- a/src/plugins/multimedia/gstreamer/common/qgstreamervideosink_p.h +++ b/src/plugins/multimedia/gstreamer/common/qgstreamervideosink_p.h @@ -64,6 +64,7 @@ private: QGstBin sinkBin; QGstElement gstQueue; QGstElement gstPreprocess; + QGstElement glUpload; QGstElement gstVideoSink; QGstElement gstQtSink; QGstElement gstSubtitleSink; -- 2.25.1