summaryrefslogtreecommitdiffstats
path: root/src/qtmultimediaquicktools
diff options
context:
space:
mode:
authorTomasz Olszak <olszak.tomasz@gmail.com>2017-06-12 13:11:25 +0200
committerVaL Doroshchuk <valentyn.doroshchuk@qt.io>2019-05-10 08:29:47 +0000
commitf0f354f2a1eec54733c871bf735f67e0c4ea945c (patch)
treee6df36abf1869f15ff0310b668014b66b5c135eb /src/qtmultimediaquicktools
parent2a8d9b8b998f0ce45651157377b3491b9997bcf8 (diff)
Add YUV422P format support to QVideoFrame and declarative renderer
[ChangeLog] Added QVideoFrame::Format_YUV422P. Change-Id: If7741db00cf0b628d7fc4b1cd3a6e424e0f8e2c0 Reviewed-by: VaL Doroshchuk <valentyn.doroshchuk@qt.io> Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch> Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Diffstat (limited to 'src/qtmultimediaquicktools')
-rw-r--r--src/qtmultimediaquicktools/qsgvideonode_yuv.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/qtmultimediaquicktools/qsgvideonode_yuv.cpp b/src/qtmultimediaquicktools/qsgvideonode_yuv.cpp
index 8e4ea01a1..f07362bf1 100644
--- a/src/qtmultimediaquicktools/qsgvideonode_yuv.cpp
+++ b/src/qtmultimediaquicktools/qsgvideonode_yuv.cpp
@@ -74,7 +74,7 @@ QList<QVideoFrame::PixelFormat> QSGVideoNodeFactory_YUV::supportedPixelFormats(
QList<QVideoFrame::PixelFormat> formats;
if (handleType == QAbstractVideoBuffer::NoHandle) {
- formats << QVideoFrame::Format_YUV420P << QVideoFrame::Format_YV12
+ formats << QVideoFrame::Format_YUV420P << QVideoFrame::Format_YV12 << QVideoFrame::Format_YUV422P
<< QVideoFrame::Format_NV12 << QVideoFrame::Format_NV21
<< QVideoFrame::Format_UYVY << QVideoFrame::Format_YUYV;
}
@@ -235,7 +235,7 @@ public:
return &uyvyType;
case QVideoFrame::Format_YUYV:
return &yuyvType;
- default: // Currently: YUV420P and YV12
+ default: // Currently: YUV420P, YUV422P and YV12
return &triPlanarType;
}
}
@@ -250,7 +250,7 @@ public:
return new QSGVideoMaterialShader_UYVY;
case QVideoFrame::Format_YUYV:
return new QSGVideoMaterialShader_YUYV;
- default: // Currently: YUV420P and YV12
+ default: // Currently: YUV420P, YUV422P and YV12
return new QSGVideoMaterialShader_YUV_TriPlanar;
}
}
@@ -308,6 +308,7 @@ QSGVideoMaterial_YUV::QSGVideoMaterial_YUV(const QVideoSurfaceFormat &format) :
break;
case QVideoFrame::Format_YUV420P:
case QVideoFrame::Format_YV12:
+ case QVideoFrame::Format_YUV422P:
m_planeCount = 3;
break;
case QVideoFrame::Format_UYVY:
@@ -408,18 +409,20 @@ void QSGVideoMaterial_YUV::bind()
functions->glActiveTexture(GL_TEXTURE0); // Finish with 0 as default texture unit
bindTexture(m_textureIds[0], m_frame.bytesPerLine(y), fh, m_frame.bits(y), texFormat1);
- } else { // YUV420P || YV12
+ } else { // YUV420P || YV12 || YUV422P
const int y = 0;
- const int u = m_frame.pixelFormat() == QVideoFrame::Format_YUV420P ? 1 : 2;
- const int v = m_frame.pixelFormat() == QVideoFrame::Format_YUV420P ? 2 : 1;
+ const int u = m_frame.pixelFormat() == QVideoFrame::Format_YV12 ? 2 : 1;
+ const int v = m_frame.pixelFormat() == QVideoFrame::Format_YV12 ? 1 : 2;
m_planeWidth[0] = qreal(fw) / m_frame.bytesPerLine(y);
m_planeWidth[1] = m_planeWidth[2] = qreal(fw) / (2 * m_frame.bytesPerLine(u));
+ const int uvHeight = m_frame.pixelFormat() == QVideoFrame::Format_YUV422P ? fh : fh / 2;
+
functions->glActiveTexture(GL_TEXTURE1);
- bindTexture(m_textureIds[1], m_frame.bytesPerLine(u), fh / 2, m_frame.bits(u), texFormat1);
+ bindTexture(m_textureIds[1], m_frame.bytesPerLine(u), uvHeight, m_frame.bits(u), texFormat1);
functions->glActiveTexture(GL_TEXTURE2);
- bindTexture(m_textureIds[2], m_frame.bytesPerLine(v), fh / 2, m_frame.bits(v), texFormat1);
+ bindTexture(m_textureIds[2], m_frame.bytesPerLine(v), uvHeight, m_frame.bits(v), texFormat1);
functions->glActiveTexture(GL_TEXTURE0); // Finish with 0 as default texture unit
bindTexture(m_textureIds[0], m_frame.bytesPerLine(y), fh, m_frame.bits(y), texFormat1);
}