summaryrefslogtreecommitdiffstats
path: root/qt5-layer
diff options
context:
space:
mode:
authorOtavio Salvador <otavio@ossystems.com.br>2014-05-21 15:25:58 -0300
committerOtavio Salvador <otavio@ossystems.com.br>2014-05-24 19:02:29 -0300
commitafcb3a3dc0f3937b751e50a72f4284aeb4e09dd3 (patch)
tree9b3c2fec6b54019939b172cc152272353bc13988 /qt5-layer
parent2b82bb3450468460ea07a2db3317573b5278c2aa (diff)
downloadmeta-fsl-arm-afcb3a3dc0f3937b751e50a72f4284aeb4e09dd3.tar.gz
qtmultimedia: Add support for i.MX6
This patch implements GStreamer-buffer to OpenGL-texture for i.MX6 allowing fluid video-playback up to 1080p with very little CPU load. The patch has been backported from Qt 5.3. Change-Id: I9a5b47b5d3eb5917708d8c44602d4634dfc44cdc Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
Diffstat (limited to 'qt5-layer')
-rw-r--r--qt5-layer/recipes-qt/qt5/qtmultimedia/add-imx6-support.patch846
-rw-r--r--qt5-layer/recipes-qt/qt5/qtmultimedia_%.bbappend5
2 files changed, 851 insertions, 0 deletions
diff --git a/qt5-layer/recipes-qt/qt5/qtmultimedia/add-imx6-support.patch b/qt5-layer/recipes-qt/qt5/qtmultimedia/add-imx6-support.patch
new file mode 100644
index 0000000..ec495e8
--- /dev/null
+++ b/qt5-layer/recipes-qt/qt5/qtmultimedia/add-imx6-support.patch
@@ -0,0 +1,846 @@
1adding zero-copy-QSGVideoNode for imx6
2
3On imx6 there is a platform-specific API to implement
4memory-mapping from gstreamer-buffer to opengl-texture.
5
6This plugin uses this API to avoid CPU-based-memory-copy.
7
8This allows fluid video-playback up to 1080p with very little CPU load.
9Before even 720p used one cpu-core completely and wasn't fluid.
10
11Change-Id: I0c33eb5d475393a65459291ce9290fa0753de4a5
12
13Upstream-Status: Backport [5.3]
14
15Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
16
17diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
18index d947f3b..c107599 100644
19--- a/src/plugins/plugins.pro
20+++ b/src/plugins/plugins.pro
21@@ -6,7 +6,7 @@
22
23 TEMPLATE = subdirs
24
25-SUBDIRS += m3u
26+SUBDIRS += m3u videonode
27
28 android {
29 SUBDIRS += android opensles
30diff --git a/src/plugins/videonode/imx6/imx6.json b/src/plugins/videonode/imx6/imx6.json
31new file mode 100644
32index 0000000..08bb12c
33--- /dev/null
34+++ b/src/plugins/videonode/imx6/imx6.json
35@@ -0,0 +1,3 @@
36+{
37+ "Keys": ["sgvideonodes"]
38+}
39diff --git a/src/plugins/videonode/imx6/imx6.pro b/src/plugins/videonode/imx6/imx6.pro
40new file mode 100644
41index 0000000..a2e6798
42--- /dev/null
43+++ b/src/plugins/videonode/imx6/imx6.pro
44@@ -0,0 +1,21 @@
45+TARGET = imx6vivantevideonode
46+QT += multimedia-private qtmultimediaquicktools-private
47+
48+PLUGIN_TYPE=video/videonode
49+PLUGIN_CLASS_NAME = QSGVivanteVideoNodeFactory
50+load(qt_plugin)
51+
52+HEADERS += \
53+ qsgvivantevideonode.h \
54+ qsgvivantevideomaterialshader.h \
55+ qsgvivantevideomaterial.h \
56+ qsgvivantevideonodefactory.h
57+
58+SOURCES += \
59+ qsgvivantevideonode.cpp \
60+ qsgvivantevideomaterialshader.cpp \
61+ qsgvivantevideomaterial.cpp \
62+ qsgvivantevideonodefactory.cpp
63+
64+OTHER_FILES += \
65+ imx6.json
66diff --git a/src/plugins/videonode/imx6/qsgvivantevideomaterial.cpp b/src/plugins/videonode/imx6/qsgvivantevideomaterial.cpp
67new file mode 100644
68index 0000000..0ed4e1a
69--- /dev/null
70+++ b/src/plugins/videonode/imx6/qsgvivantevideomaterial.cpp
71@@ -0,0 +1,196 @@
72+/****************************************************************************
73+**
74+** Copyright (C) 2014 Pelagicore AG
75+** Contact: http://www.qt-project.org/legal
76+**
77+** This file is part of the Qt Toolkit.
78+**
79+** $QT_BEGIN_LICENSE:LGPL$
80+** Commercial License Usage
81+** Licensees holding valid commercial Qt licenses may use this file in
82+** accordance with the commercial license agreement provided with the
83+** Software or, alternatively, in accordance with the terms contained in
84+** a written agreement between you and Digia. For licensing terms and
85+** conditions see http://qt.digia.com/licensing. For further information
86+** use the contact form at http://qt.digia.com/contact-us.
87+**
88+** GNU Lesser General Public License Usage
89+** Alternatively, this file may be used under the terms of the GNU Lesser
90+** General Public License version 2.1 as published by the Free Software
91+** Foundation and appearing in the file LICENSE.LGPL included in the
92+** packaging of this file. Please review the following information to
93+** ensure the GNU Lesser General Public License version 2.1 requirements
94+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
95+**
96+** In addition, as a special exception, Digia gives you certain additional
97+** rights. These rights are described in the Digia Qt LGPL Exception
98+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
99+**
100+** GNU General Public License Usage
101+** Alternatively, this file may be used under the terms of the GNU
102+** General Public License version 3.0 as published by the Free Software
103+** Foundation and appearing in the file LICENSE.GPL included in the
104+** packaging of this file. Please review the following information to
105+** ensure the GNU General Public License version 3.0 requirements will be
106+** met: http://www.gnu.org/copyleft/gpl.html.
107+**
108+**
109+** $QT_END_LICENSE$
110+**
111+****************************************************************************/
112+
113+#include <GLES2/gl2.h>
114+#include <GLES2/gl2ext.h>
115+
116+#include "qsgvivantevideomaterial.h"
117+#include "qsgvivantevideomaterialshader.h"
118+#include "qsgvivantevideonode.h"
119+
120+#include <QOpenGLContext>
121+#include <QThread>
122+
123+#include <unistd.h>
124+
125+
126+//#define QT_VIVANTE_VIDEO_DEBUG
127+
128+QSGVivanteVideoMaterial::QSGVivanteVideoMaterial() :
129+ mOpacity(1.0),
130+ mCurrentTexture(0)
131+{
132+#ifdef QT_VIVANTE_VIDEO_DEBUG
133+ qDebug() << Q_FUNC_INFO;
134+#endif
135+
136+ setFlag(Blending, false);
137+}
138+
139+QSGVivanteVideoMaterial::~QSGVivanteVideoMaterial()
140+{
141+ for (GLuint id : mBitsToTextureMap.values()) {
142+#ifdef QT_VIVANTE_VIDEO_DEBUG
143+ qDebug() << "delete texture: " << id;
144+#endif
145+ glDeleteTextures(1, &id);
146+ }
147+}
148+
149+QSGMaterialType *QSGVivanteVideoMaterial::type() const {
150+ static QSGMaterialType theType;
151+ return &theType;
152+}
153+
154+QSGMaterialShader *QSGVivanteVideoMaterial::createShader() const {
155+ return new QSGVivanteVideoMaterialShader;
156+}
157+
158+int QSGVivanteVideoMaterial::compare(const QSGMaterial *other) const {
159+ if (this->type() == other->type()) {
160+ const QSGVivanteVideoMaterial *m = static_cast<const QSGVivanteVideoMaterial *>(other);
161+ if (this->mBitsToTextureMap == m->mBitsToTextureMap)
162+ return 0;
163+ else
164+ return 1;
165+ }
166+ return 1;
167+}
168+
169+void QSGVivanteVideoMaterial::updateBlending() {
170+ setFlag(Blending, qFuzzyCompare(mOpacity, qreal(1.0)) ? false : true);
171+}
172+
173+void QSGVivanteVideoMaterial::setCurrentFrame(const QVideoFrame &frame) {
174+ QMutexLocker lock(&mFrameMutex);
175+ mNextFrame = frame;
176+
177+#ifdef QT_VIVANTE_VIDEO_DEBUG
178+ qDebug() << Q_FUNC_INFO << " new frame: " << frame;
179+#endif
180+}
181+
182+void QSGVivanteVideoMaterial::bind()
183+{
184+ QOpenGLContext *glcontext = QOpenGLContext::currentContext();
185+ if (glcontext == 0) {
186+ qWarning() << Q_FUNC_INFO << "no QOpenGLContext::currentContext() => return";
187+ return;
188+ }
189+
190+ QMutexLocker lock(&mFrameMutex);
191+ if (mNextFrame.isValid()) {
192+ mCurrentFrame.unmap();
193+
194+ mCurrentFrame = mNextFrame;
195+ mCurrentTexture = vivanteMapping(mNextFrame);
196+ }
197+ else
198+ glBindTexture(GL_TEXTURE_2D, mCurrentTexture);
199+}
200+
201+GLuint QSGVivanteVideoMaterial::vivanteMapping(QVideoFrame vF)
202+{
203+ QOpenGLContext *glcontext = QOpenGLContext::currentContext();
204+ if (glcontext == 0) {
205+ qWarning() << Q_FUNC_INFO << "no QOpenGLContext::currentContext() => return 0";
206+ return 0;
207+ }
208+
209+ static PFNGLTEXDIRECTVIVMAPPROC glTexDirectVIVMap_LOCAL = 0;
210+ static PFNGLTEXDIRECTINVALIDATEVIVPROC glTexDirectInvalidateVIV_LOCAL = 0;
211+
212+ if (glTexDirectVIVMap_LOCAL == 0 || glTexDirectInvalidateVIV_LOCAL == 0) {
213+ glTexDirectVIVMap_LOCAL = reinterpret_cast<PFNGLTEXDIRECTVIVMAPPROC>(glcontext->getProcAddress("glTexDirectVIVMap"));
214+ glTexDirectInvalidateVIV_LOCAL = reinterpret_cast<PFNGLTEXDIRECTINVALIDATEVIVPROC>(glcontext->getProcAddress("glTexDirectInvalidateVIV"));
215+ }
216+ if (glTexDirectVIVMap_LOCAL == 0 || glTexDirectInvalidateVIV_LOCAL == 0) {
217+ qWarning() << Q_FUNC_INFO << "couldn't find \"glTexDirectVIVMap\" and/or \"glTexDirectInvalidateVIV\" => do nothing and return";
218+ return 0;
219+ }
220+
221+
222+ if (vF.map(QAbstractVideoBuffer::ReadOnly)) {
223+
224+ if (!mBitsToTextureMap.contains(vF.bits())) {
225+ GLuint tmpTexId;
226+ glGenTextures(1, &tmpTexId);
227+ mBitsToTextureMap.insert(vF.bits(), tmpTexId);
228+
229+ const uchar *constBits = vF.bits();
230+ void *bits = (void*)constBits;
231+
232+#ifdef QT_VIVANTE_VIDEO_DEBUG
233+ qDebug() << Q_FUNC_INFO << "new texture, texId: " << tmpTexId << "; constBits: " << constBits;
234+#endif
235+
236+ GLuint physical = ~0U;
237+
238+ glBindTexture(GL_TEXTURE_2D, tmpTexId);
239+ glTexDirectVIVMap_LOCAL(GL_TEXTURE_2D,
240+ vF.width(), vF.height(),
241+ QSGVivanteVideoNode::getVideoFormat2GLFormatMap().value(vF.pixelFormat()),
242+ &bits, &physical);
243+
244+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
245+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
246+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
247+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
248+ glTexDirectInvalidateVIV_LOCAL(GL_TEXTURE_2D);
249+
250+ return tmpTexId;
251+ }
252+ else {
253+ glBindTexture(GL_TEXTURE_2D, mBitsToTextureMap.value(vF.bits()));
254+ glTexDirectInvalidateVIV_LOCAL(GL_TEXTURE_2D);
255+ return mBitsToTextureMap.value(vF.bits());
256+ }
257+ }
258+ else {
259+#ifdef QT_VIVANTE_VIDEO_DEBUG
260+ qWarning() << " couldn't map the QVideoFrame vF: " << vF;
261+#endif
262+ return 0;
263+ }
264+
265+ Q_ASSERT(false); // should never reach this line!;
266+ return 0;
267+}
268diff --git a/src/plugins/videonode/imx6/qsgvivantevideomaterial.h b/src/plugins/videonode/imx6/qsgvivantevideomaterial.h
269new file mode 100644
270index 0000000..9d792b7
271--- /dev/null
272+++ b/src/plugins/videonode/imx6/qsgvivantevideomaterial.h
273@@ -0,0 +1,80 @@
274+/****************************************************************************
275+**
276+** Copyright (C) 2014 Pelagicore AG
277+** Contact: http://www.qt-project.org/legal
278+**
279+** This file is part of the Qt Toolkit.
280+**
281+** $QT_BEGIN_LICENSE:LGPL$
282+** Commercial License Usage
283+** Licensees holding valid commercial Qt licenses may use this file in
284+** accordance with the commercial license agreement provided with the
285+** Software or, alternatively, in accordance with the terms contained in
286+** a written agreement between you and Digia. For licensing terms and
287+** conditions see http://qt.digia.com/licensing. For further information
288+** use the contact form at http://qt.digia.com/contact-us.
289+**
290+** GNU Lesser General Public License Usage
291+** Alternatively, this file may be used under the terms of the GNU Lesser
292+** General Public License version 2.1 as published by the Free Software
293+** Foundation and appearing in the file LICENSE.LGPL included in the
294+** packaging of this file. Please review the following information to
295+** ensure the GNU Lesser General Public License version 2.1 requirements
296+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
297+**
298+** In addition, as a special exception, Digia gives you certain additional
299+** rights. These rights are described in the Digia Qt LGPL Exception
300+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
301+**
302+** GNU General Public License Usage
303+** Alternatively, this file may be used under the terms of the GNU
304+** General Public License version 3.0 as published by the Free Software
305+** Foundation and appearing in the file LICENSE.GPL included in the
306+** packaging of this file. Please review the following information to
307+** ensure the GNU General Public License version 3.0 requirements will be
308+** met: http://www.gnu.org/copyleft/gpl.html.
309+**
310+**
311+** $QT_END_LICENSE$
312+**
313+****************************************************************************/
314+
315+#ifndef QSGVIDEOMATERIAL_VIVMAP_H
316+#define QSGVIDEOMATERIAL_VIVMAP_H
317+
318+#include <QList>
319+#include <QPair>
320+
321+#include <QSGMaterial>
322+#include <QVideoFrame>
323+#include <QMutex>
324+
325+
326+class QSGVivanteVideoMaterial : public QSGMaterial
327+{
328+public:
329+ QSGVivanteVideoMaterial();
330+ ~QSGVivanteVideoMaterial();
331+
332+ virtual QSGMaterialType *type() const;
333+ virtual QSGMaterialShader *createShader() const;
334+ virtual int compare(const QSGMaterial *other) const;
335+ void updateBlending();
336+ void setCurrentFrame(const QVideoFrame &frame);
337+
338+ void bind();
339+ GLuint vivanteMapping(QVideoFrame texIdVideoFramePair);
340+
341+ void setOpacity(float o) { mOpacity = o; }
342+
343+private:
344+ qreal mOpacity;
345+
346+ QMap<const uchar*, GLuint> mBitsToTextureMap;
347+ QVideoFrame mCurrentFrame, mNextFrame;
348+ GLuint mCurrentTexture;
349+
350+ QMutex mFrameMutex;
351+};
352+
353+#endif // QSGVIDEOMATERIAL_VIVMAP_H
354diff --git a/src/plugins/videonode/imx6/qsgvivantevideomaterialshader.cpp b/src/plugins/videonode/imx6/qsgvivantevideomaterialshader.cpp
355new file mode 100644
356index 0000000..7b5e5e5
357--- /dev/null
358+++ b/src/plugins/videonode/imx6/qsgvivantevideomaterialshader.cpp
359@@ -0,0 +1,104 @@
360+/****************************************************************************
361+**
362+** Copyright (C) 2014 Pelagicore AG
363+** Contact: http://www.qt-project.org/legal
364+**
365+** This file is part of the Qt Toolkit.
366+**
367+** $QT_BEGIN_LICENSE:LGPL$
368+** Commercial License Usage
369+** Licensees holding valid commercial Qt licenses may use this file in
370+** accordance with the commercial license agreement provided with the
371+** Software or, alternatively, in accordance with the terms contained in
372+** a written agreement between you and Digia. For licensing terms and
373+** conditions see http://qt.digia.com/licensing. For further information
374+** use the contact form at http://qt.digia.com/contact-us.
375+**
376+** GNU Lesser General Public License Usage
377+** Alternatively, this file may be used under the terms of the GNU Lesser
378+** General Public License version 2.1 as published by the Free Software
379+** Foundation and appearing in the file LICENSE.LGPL included in the
380+** packaging of this file. Please review the following information to
381+** ensure the GNU Lesser General Public License version 2.1 requirements
382+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
383+**
384+** In addition, as a special exception, Digia gives you certain additional
385+** rights. These rights are described in the Digia Qt LGPL Exception
386+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
387+**
388+** GNU General Public License Usage
389+** Alternatively, this file may be used under the terms of the GNU
390+** General Public License version 3.0 as published by the Free Software
391+** Foundation and appearing in the file LICENSE.GPL included in the
392+** packaging of this file. Please review the following information to
393+** ensure the GNU General Public License version 3.0 requirements will be
394+** met: http://www.gnu.org/copyleft/gpl.html.
395+**
396+**
397+** $QT_END_LICENSE$
398+**
399+****************************************************************************/
400+
401+#include "qsgvivantevideomaterialshader.h"
402+#include "qsgvivantevideonode.h"
403+#include "qsgvivantevideomaterial.h"
404+
405+void QSGVivanteVideoMaterialShader::updateState(const RenderState &state,
406+ QSGMaterial *newMaterial,
407+ QSGMaterial *oldMaterial)
408+{
409+ Q_UNUSED(oldMaterial);
410+
411+ QSGVivanteVideoMaterial *mat = static_cast<QSGVivanteVideoMaterial *>(newMaterial);
412+ program()->setUniformValue(mIdTexture, 0);
413+ mat->bind();
414+ if (state.isOpacityDirty()) {
415+ mat->setOpacity(state.opacity());
416+ program()->setUniformValue(mIdOpacity, state.opacity());
417+ }
418+ if (state.isMatrixDirty())
419+ program()->setUniformValue(mIdMatrix, state.combinedMatrix());
420+}
421+
422+const char * const *QSGVivanteVideoMaterialShader::attributeNames() const {
423+ static const char *names[] = {
424+ "qt_VertexPosition",
425+ "qt_VertexTexCoord",
426+ 0
427+ };
428+ return names;
429+}
430+
431+const char *QSGVivanteVideoMaterialShader::vertexShader() const {
432+ static const char *shader =
433+ "uniform highp mat4 qt_Matrix; \n"
434+ "attribute highp vec4 qt_VertexPosition; \n"
435+ "attribute highp vec2 qt_VertexTexCoord; \n"
436+ "varying highp vec2 qt_TexCoord; \n"
437+ "void main() { \n"
438+ " qt_TexCoord = qt_VertexTexCoord; \n"
439+ " gl_Position = qt_Matrix * qt_VertexPosition; \n"
440+ "}";
441+ return shader;
442+}
443+
444+const char *QSGVivanteVideoMaterialShader::fragmentShader() const {
445+ static const char *shader =
446+ "uniform sampler2D texture;"
447+ "uniform lowp float opacity;"
448+ ""
449+ "varying highp vec2 qt_TexCoord;"
450+ ""
451+ "void main()"
452+ "{"
453+ " gl_FragColor = texture2D( texture, qt_TexCoord ) * opacity;\n"
454+ "}";
455+ return shader;
456+}
457+
458+
459+void QSGVivanteVideoMaterialShader::initialize() {
460+ mIdMatrix = program()->uniformLocation("qt_Matrix");
461+ mIdTexture = program()->uniformLocation("texture");
462+ mIdOpacity = program()->uniformLocation("opacity");
463+}
464diff --git a/src/plugins/videonode/imx6/qsgvivantevideomaterialshader.h b/src/plugins/videonode/imx6/qsgvivantevideomaterialshader.h
465new file mode 100644
466index 0000000..570be25
467--- /dev/null
468+++ b/src/plugins/videonode/imx6/qsgvivantevideomaterialshader.h
469@@ -0,0 +1,64 @@
470+/****************************************************************************
471+**
472+** Copyright (C) 2014 Pelagicore AG
473+** Contact: http://www.qt-project.org/legal
474+**
475+** This file is part of the Qt Toolkit.
476+**
477+** $QT_BEGIN_LICENSE:LGPL$
478+** Commercial License Usage
479+** Licensees holding valid commercial Qt licenses may use this file in
480+** accordance with the commercial license agreement provided with the
481+** Software or, alternatively, in accordance with the terms contained in
482+** a written agreement between you and Digia. For licensing terms and
483+** conditions see http://qt.digia.com/licensing. For further information
484+** use the contact form at http://qt.digia.com/contact-us.
485+**
486+** GNU Lesser General Public License Usage
487+** Alternatively, this file may be used under the terms of the GNU Lesser
488+** General Public License version 2.1 as published by the Free Software
489+** Foundation and appearing in the file LICENSE.LGPL included in the
490+** packaging of this file. Please review the following information to
491+** ensure the GNU Lesser General Public License version 2.1 requirements
492+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
493+**
494+** In addition, as a special exception, Digia gives you certain additional
495+** rights. These rights are described in the Digia Qt LGPL Exception
496+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
497+**
498+** GNU General Public License Usage
499+** Alternatively, this file may be used under the terms of the GNU
500+** General Public License version 3.0 as published by the Free Software
501+** Foundation and appearing in the file LICENSE.GPL included in the
502+** packaging of this file. Please review the following information to
503+** ensure the GNU General Public License version 3.0 requirements will be
504+** met: http://www.gnu.org/copyleft/gpl.html.
505+**
506+**
507+** $QT_END_LICENSE$
508+**
509+****************************************************************************/
510+
511+#ifndef QSGVIDEOMATERIALSHADER_VIVANTE_H
512+#define QSGVIDEOMATERIALSHADER_VIVANTE_H
513+
514+#include <QSGMaterial>
515+
516+class QSGVivanteVideoMaterialShader : public QSGMaterialShader
517+{
518+public:
519+ void updateState(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial);
520+ virtual char const *const *attributeNames() const;
521+
522+protected:
523+ virtual const char *vertexShader() const;
524+ virtual const char *fragmentShader() const;
525+ virtual void initialize();
526+
527+private:
528+ int mIdMatrix;
529+ int mIdTexture;
530+ int mIdOpacity;
531+};
532+
533+#endif // QSGVIDEOMATERIALSHADER_VIVANTE_H
534diff --git a/src/plugins/videonode/imx6/qsgvivantevideonode.cpp b/src/plugins/videonode/imx6/qsgvivantevideonode.cpp
535new file mode 100644
536index 0000000..d5f1e61
537--- /dev/null
538+++ b/src/plugins/videonode/imx6/qsgvivantevideonode.cpp
539@@ -0,0 +1,90 @@
540+/****************************************************************************
541+**
542+** Copyright (C) 2014 Pelagicore AG
543+** Contact: http://www.qt-project.org/legal
544+**
545+** This file is part of the Qt Toolkit.
546+**
547+** $QT_BEGIN_LICENSE:LGPL$
548+** Commercial License Usage
549+** Licensees holding valid commercial Qt licenses may use this file in
550+** accordance with the commercial license agreement provided with the
551+** Software or, alternatively, in accordance with the terms contained in
552+** a written agreement between you and Digia. For licensing terms and
553+** conditions see http://qt.digia.com/licensing. For further information
554+** use the contact form at http://qt.digia.com/contact-us.
555+**
556+** GNU Lesser General Public License Usage
557+** Alternatively, this file may be used under the terms of the GNU Lesser
558+** General Public License version 2.1 as published by the Free Software
559+** Foundation and appearing in the file LICENSE.LGPL included in the
560+** packaging of this file. Please review the following information to
561+** ensure the GNU Lesser General Public License version 2.1 requirements
562+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
563+**
564+** In addition, as a special exception, Digia gives you certain additional
565+** rights. These rights are described in the Digia Qt LGPL Exception
566+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
567+**
568+** GNU General Public License Usage
569+** Alternatively, this file may be used under the terms of the GNU
570+** General Public License version 3.0 as published by the Free Software
571+** Foundation and appearing in the file LICENSE.GPL included in the
572+** packaging of this file. Please review the following information to
573+** ensure the GNU General Public License version 3.0 requirements will be
574+** met: http://www.gnu.org/copyleft/gpl.html.
575+**
576+**
577+** $QT_END_LICENSE$
578+**
579+****************************************************************************/
580+
581+#include <GLES2/gl2.h>
582+#include <GLES2/gl2ext.h>
583+
584+#include "qsgvivantevideonode.h"
585+#include "qsgvivantevideomaterialshader.h"
586+#include "qsgvivantevideomaterial.h"
587+
588+QMap<QVideoFrame::PixelFormat, GLenum> QSGVivanteVideoNode::static_VideoFormat2GLFormatMap = QMap<QVideoFrame::PixelFormat, GLenum>();
589+
590+QSGVivanteVideoNode::QSGVivanteVideoNode(const QVideoSurfaceFormat &format) :
591+ mFormat(format)
592+{
593+ setFlag(QSGNode::OwnsMaterial, true);
594+ mMaterial = new QSGVivanteVideoMaterial();
595+ setMaterial(mMaterial);
596+}
597+
598+QSGVivanteVideoNode::~QSGVivanteVideoNode()
599+{
600+}
601+
602+void QSGVivanteVideoNode::setCurrentFrame(const QVideoFrame &frame)
603+{
604+ mMaterial->setCurrentFrame(frame);
605+ markDirty(DirtyMaterial);
606+}
607+
608+const QMap<QVideoFrame::PixelFormat, GLenum>& QSGVivanteVideoNode::getVideoFormat2GLFormatMap()
609+{
610+ if (static_VideoFormat2GLFormatMap.isEmpty()) {
611+ static_VideoFormat2GLFormatMap.insert(QVideoFrame::Format_YV12, GL_VIV_YV12);
612+ static_VideoFormat2GLFormatMap.insert(QVideoFrame::Format_NV12, GL_VIV_NV12);
613+
614+
615+ // The following formats should work but are untested!
616+ static_VideoFormat2GLFormatMap.insert(QVideoFrame::Format_NV21, GL_VIV_NV21);
617+ static_VideoFormat2GLFormatMap.insert(QVideoFrame::Format_UYVY, GL_VIV_UYVY);
618+ static_VideoFormat2GLFormatMap.insert(QVideoFrame::Format_YUYV, GL_VIV_YUY2);
619+ static_VideoFormat2GLFormatMap.insert(QVideoFrame::Format_RGB32, GL_RGBA);
620+ static_VideoFormat2GLFormatMap.insert(QVideoFrame::Format_RGB24, GL_RGB);
621+ static_VideoFormat2GLFormatMap.insert(QVideoFrame::Format_RGB565, GL_RGB565);
622+ static_VideoFormat2GLFormatMap.insert(QVideoFrame::Format_BGRA32, GL_BGRA_EXT);
623+ }
624+
625+ return static_VideoFormat2GLFormatMap;
626+}
627+
628+
629+
630diff --git a/src/plugins/videonode/imx6/qsgvivantevideonode.h b/src/plugins/videonode/imx6/qsgvivantevideonode.h
631new file mode 100644
632index 0000000..ae2120a
633--- /dev/null
634+++ b/src/plugins/videonode/imx6/qsgvivantevideonode.h
635@@ -0,0 +1,67 @@
636+/****************************************************************************
637+**
638+** Copyright (C) 2014 Pelagicore AG
639+** Contact: http://www.qt-project.org/legal
640+**
641+** This file is part of the Qt Toolkit.
642+**
643+** $QT_BEGIN_LICENSE:LGPL$
644+** Commercial License Usage
645+** Licensees holding valid commercial Qt licenses may use this file in
646+** accordance with the commercial license agreement provided with the
647+** Software or, alternatively, in accordance with the terms contained in
648+** a written agreement between you and Digia. For licensing terms and
649+** conditions see http://qt.digia.com/licensing. For further information
650+** use the contact form at http://qt.digia.com/contact-us.
651+**
652+** GNU Lesser General Public License Usage
653+** Alternatively, this file may be used under the terms of the GNU Lesser
654+** General Public License version 2.1 as published by the Free Software
655+** Foundation and appearing in the file LICENSE.LGPL included in the
656+** packaging of this file. Please review the following information to
657+** ensure the GNU Lesser General Public License version 2.1 requirements
658+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
659+**
660+** In addition, as a special exception, Digia gives you certain additional
661+** rights. These rights are described in the Digia Qt LGPL Exception
662+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
663+**
664+** GNU General Public License Usage
665+** Alternatively, this file may be used under the terms of the GNU
666+** General Public License version 3.0 as published by the Free Software
667+** Foundation and appearing in the file LICENSE.GPL included in the
668+** packaging of this file. Please review the following information to
669+** ensure the GNU General Public License version 3.0 requirements will be
670+** met: http://www.gnu.org/copyleft/gpl.html.
671+**
672+**
673+** $QT_END_LICENSE$
674+**
675+****************************************************************************/
676+
677+#ifndef QSGVIDEONODE_VIVANTE_H
678+#define QSGVIDEONODE_VIVANTE_H
679+
680+#include <private/qsgvideonode_p.h>
681+#include <QVideoSurfaceFormat>
682+
683+class QSGVivanteVideoMaterial;
684+class QSGVivanteVideoNode : public QSGVideoNode
685+{
686+public:
687+ QSGVivanteVideoNode(const QVideoSurfaceFormat &format);
688+ ~QSGVivanteVideoNode();
689+
690+ virtual QVideoFrame::PixelFormat pixelFormat() const { return mFormat.pixelFormat(); }
691+ void setCurrentFrame(const QVideoFrame &frame);
692+
693+ static const QMap<QVideoFrame::PixelFormat, GLenum>& getVideoFormat2GLFormatMap();
694+
695+private:
696+ QVideoSurfaceFormat mFormat;
697+ QSGVivanteVideoMaterial *mMaterial;
698+
699+ static QMap<QVideoFrame::PixelFormat, GLenum> static_VideoFormat2GLFormatMap;
700+};
701+
702+#endif // QSGVIDEONODE_VIVANTE_H
703diff --git a/src/plugins/videonode/imx6/qsgvivantevideonodefactory.cpp b/src/plugins/videonode/imx6/qsgvivantevideonodefactory.cpp
704new file mode 100644
705index 0000000..e0711e1
706--- /dev/null
707+++ b/src/plugins/videonode/imx6/qsgvivantevideonodefactory.cpp
708@@ -0,0 +1,60 @@
709+/****************************************************************************
710+**
711+** Copyright (C) 2014 Pelagicore AG
712+** Contact: http://www.qt-project.org/legal
713+**
714+** This file is part of the Qt Toolkit.
715+**
716+** $QT_BEGIN_LICENSE:LGPL$
717+** Commercial License Usage
718+** Licensees holding valid commercial Qt licenses may use this file in
719+** accordance with the commercial license agreement provided with the
720+** Software or, alternatively, in accordance with the terms contained in
721+** a written agreement between you and Digia. For licensing terms and
722+** conditions see http://qt.digia.com/licensing. For further information
723+** use the contact form at http://qt.digia.com/contact-us.
724+**
725+** GNU Lesser General Public License Usage
726+** Alternatively, this file may be used under the terms of the GNU Lesser
727+** General Public License version 2.1 as published by the Free Software
728+** Foundation and appearing in the file LICENSE.LGPL included in the
729+** packaging of this file. Please review the following information to
730+** ensure the GNU Lesser General Public License version 2.1 requirements
731+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
732+**
733+** In addition, as a special exception, Digia gives you certain additional
734+** rights. These rights are described in the Digia Qt LGPL Exception
735+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
736+**
737+** GNU General Public License Usage
738+** Alternatively, this file may be used under the terms of the GNU
739+** General Public License version 3.0 as published by the Free Software
740+** Foundation and appearing in the file LICENSE.GPL included in the
741+** packaging of this file. Please review the following information to
742+** ensure the GNU General Public License version 3.0 requirements will be
743+** met: http://www.gnu.org/copyleft/gpl.html.
744+**
745+**
746+** $QT_END_LICENSE$
747+**
748+****************************************************************************/
749+
750+#include "qsgvivantevideonodefactory.h"
751+#include "qsgvivantevideonode.h"
752+
753+QList<QVideoFrame::PixelFormat> QSGVivanteVideoNodeFactory::supportedPixelFormats(
754+ QAbstractVideoBuffer::HandleType handleType) const
755+{
756+ if (handleType == QAbstractVideoBuffer::NoHandle)
757+ return QSGVivanteVideoNode::getVideoFormat2GLFormatMap().keys();
758+ else
759+ return QList<QVideoFrame::PixelFormat>();
760+}
761+
762+QSGVideoNode *QSGVivanteVideoNodeFactory::createNode(const QVideoSurfaceFormat &format)
763+{
764+ if (supportedPixelFormats(format.handleType()).contains(format.pixelFormat())) {
765+ return new QSGVivanteVideoNode(format);
766+ }
767+ return 0;
768+}
769diff --git a/src/plugins/videonode/imx6/qsgvivantevideonodefactory.h b/src/plugins/videonode/imx6/qsgvivantevideonodefactory.h
770new file mode 100644
771index 0000000..6fda61b
772--- /dev/null
773+++ b/src/plugins/videonode/imx6/qsgvivantevideonodefactory.h
774@@ -0,0 +1,58 @@
775+/****************************************************************************
776+**
777+** Copyright (C) 2014 Pelagicore AG
778+** Contact: http://www.qt-project.org/legal
779+**
780+** This file is part of the Qt Toolkit.
781+**
782+** $QT_BEGIN_LICENSE:LGPL$
783+** Commercial License Usage
784+** Licensees holding valid commercial Qt licenses may use this file in
785+** accordance with the commercial license agreement provided with the
786+** Software or, alternatively, in accordance with the terms contained in
787+** a written agreement between you and Digia. For licensing terms and
788+** conditions see http://qt.digia.com/licensing. For further information
789+** use the contact form at http://qt.digia.com/contact-us.
790+**
791+** GNU Lesser General Public License Usage
792+** Alternatively, this file may be used under the terms of the GNU Lesser
793+** General Public License version 2.1 as published by the Free Software
794+** Foundation and appearing in the file LICENSE.LGPL included in the
795+** packaging of this file. Please review the following information to
796+** ensure the GNU Lesser General Public License version 2.1 requirements
797+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
798+**
799+** In addition, as a special exception, Digia gives you certain additional
800+** rights. These rights are described in the Digia Qt LGPL Exception
801+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
802+**
803+** GNU General Public License Usage
804+** Alternatively, this file may be used under the terms of the GNU
805+** General Public License version 3.0 as published by the Free Software
806+** Foundation and appearing in the file LICENSE.GPL included in the
807+** packaging of this file. Please review the following information to
808+** ensure the GNU General Public License version 3.0 requirements will be
809+** met: http://www.gnu.org/copyleft/gpl.html.
810+**
811+**
812+** $QT_END_LICENSE$
813+**
814+****************************************************************************/
815+
816+#ifndef QSGVIDEONODEFACTORY_VIVANTE_H
817+#define QSGVIDEONODEFACTORY_VIVANTE_H
818+
819+#include <QObject>
820+#include <private/qsgvideonode_p.h>
821+
822+class QSGVivanteVideoNodeFactory : public QObject, public QSGVideoNodeFactoryInterface
823+{
824+public:
825+ Q_OBJECT
826+ Q_PLUGIN_METADATA(IID QSGVideoNodeFactoryInterface_iid FILE "imx6.json")
827+ Q_INTERFACES(QSGVideoNodeFactoryInterface)
828+
829+ QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const;
830+ QSGVideoNode *createNode(const QVideoSurfaceFormat &format);
831+};
832+#endif // QSGVIDEONODEFACTORY_VIVANTE_H
833diff --git a/src/plugins/videonode/videonode.pro b/src/plugins/videonode/videonode.pro
834new file mode 100644
835index 0000000..ecc1c0c
836--- /dev/null
837+++ b/src/plugins/videonode/videonode.pro
838@@ -0,0 +1,5 @@
839+TEMPLATE = subdirs
840+
841+*imx6* {
842+ SUBDIRS += imx6
843+}
844--
8452.0.0.rc2
846
diff --git a/qt5-layer/recipes-qt/qt5/qtmultimedia_%.bbappend b/qt5-layer/recipes-qt/qt5/qtmultimedia_%.bbappend
new file mode 100644
index 0000000..873862b
--- /dev/null
+++ b/qt5-layer/recipes-qt/qt5/qtmultimedia_%.bbappend
@@ -0,0 +1,5 @@
1FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
2
3SRC_URI_append_mx6 += " file://add-imx6-support.patch"
4
5PACKAGE_ARCH_mx6 = "${MACHINE_SOCARCH}"