From c7bd3131a8854814d59881339ac1d7a4af3c9863 Mon Sep 17 00:00:00 2001 From: VaL Doroshchuk Date: Wed, 11 Sep 2019 11:09:52 +0200 Subject: imx6: Fix mapping VPU texture using real physical address of data * Get real physical address of video frame data and provide it to imx6 vivante videonode to prevent memory leak from kernel. By default qtmultimedia does not depend on gstreamer-imx, but the plugin should exist on imx platform. So gstreamer_imxcommon will be disabled. And should be manually enabled in yocto receipt. Change-Id: I6e75746a2ba651d12bdd7697ae483699aad450fc Fixes: QTBUG-73084 Reviewed-by: Ville Voutilainen --- src/multimedia/configure.json | 17 +++++++++++++++++ src/plugins/videonode/imx6/imx6.pro | 6 ++++++ src/plugins/videonode/imx6/qsgvivantevideomaterial.cpp | 12 +++++++++++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/multimedia/configure.json b/src/multimedia/configure.json index 6d56af5ed..2db8ce55c 100644 --- a/src/multimedia/configure.json +++ b/src/multimedia/configure.json @@ -95,6 +95,18 @@ { "libs": "-lgstphotography-1.0" } ] }, + "gstreamer_imxcommon": { + "label": "GStreamer i.MX common", + "export": "gstreamer_imxcommon", + "test": { + "include": "gst/allocators/imx/phys_mem_meta.h" + }, + "use": "gstreamer_1_0", + "sources": [ + { "type": "pkgConfig", + "args": "gstimxcommon" } + ] + }, "libresourceqt5": { "label": "libresourceqt5", "test": "resourcepolicy", @@ -229,6 +241,11 @@ "condition": "(features.gstreamer_1_0 && libs.gstreamer_photography_1_0) || (features.gstreamer_0_10 && libs.gstreamer_photography_0_10)", "output": [ "privateFeature" ] }, + "gstreamer_imxcommon": { + "label": "GStreamer i.MX common", + "condition": "(features.gstreamer_1_0 && libs.gstreamer_imxcommon)", + "output": [ "privateFeature" ] + }, "gpu_vivante": { "label": "Vivante GPU", "condition": "features.gui && features.opengles2 && tests.gpu_vivante", diff --git a/src/plugins/videonode/imx6/imx6.pro b/src/plugins/videonode/imx6/imx6.pro index c8085a31e..43e17e725 100644 --- a/src/plugins/videonode/imx6/imx6.pro +++ b/src/plugins/videonode/imx6/imx6.pro @@ -2,6 +2,12 @@ TARGET = imx6vivantevideonode QT += multimedia-private qtmultimediaquicktools-private +qtConfig(gstreamer_imxcommon) { + QT += multimediagsttools-private + QMAKE_USE += gstreamer_imxcommon + DEFINES += GST_USE_UNSTABLE_API +} + HEADERS += \ qsgvivantevideonode.h \ qsgvivantevideomaterialshader.h \ diff --git a/src/plugins/videonode/imx6/qsgvivantevideomaterial.cpp b/src/plugins/videonode/imx6/qsgvivantevideomaterial.cpp index 4b68f47a4..e1468fe34 100644 --- a/src/plugins/videonode/imx6/qsgvivantevideomaterial.cpp +++ b/src/plugins/videonode/imx6/qsgvivantevideomaterial.cpp @@ -49,6 +49,11 @@ #include +#include +#if QT_CONFIG(gstreamer_imxcommon) +#include "private/qgstvideobuffer_p.h" +#include +#endif //#define QT_VIVANTE_VIDEO_DEBUG @@ -224,7 +229,12 @@ GLuint QSGVivanteVideoMaterial::vivanteMapping(QVideoFrame vF) #endif GLuint physical = ~0U; - +#if QT_CONFIG(gstreamer_imxcommon) + auto buffer = reinterpret_cast(vF.buffer()); + GstImxPhysMemMeta *meta = GST_IMX_PHYS_MEM_META_GET(buffer->buffer()); + if (meta && meta->phys_addr) + physical = meta->phys_addr; +#endif glBindTexture(GL_TEXTURE_2D, tmpTexId); glTexDirectVIVMap_LOCAL(GL_TEXTURE_2D, fullWidth, fullHeight, -- cgit v1.2.1