diff options
author | Lars Knoll <lars.knoll@qt.io> | 2021-03-23 12:59:28 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2021-04-06 08:11:32 +0000 |
commit | 33d4ef6367ad49c40ec77af69ab1165989a65064 (patch) | |
tree | 22b6b757dcf77315da29a7c89a400b3e49457999 /src | |
parent | f2841b24e351ab14fe35d617948d951bee609236 (diff) |
Remove the handle type from QVideoSurfaceFormat
This is a property of the individual QVideoFrame, and doesn't
belong here.
Change-Id: I85f180ff46023f6a48ef856a356d9c45c3f6be1b
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Doris Verria <doris.verria@qt.io>
Diffstat (limited to 'src')
15 files changed, 31 insertions, 83 deletions
diff --git a/src/multimedia/platform/gstreamer/common/qgstutils.cpp b/src/multimedia/platform/gstreamer/common/qgstutils.cpp index 1cd40bb8e..49d5a527c 100644 --- a/src/multimedia/platform/gstreamer/common/qgstutils.cpp +++ b/src/multimedia/platform/gstreamer/common/qgstutils.cpp @@ -228,7 +228,7 @@ static int indexOfVideoFormat(GstVideoFormat format) } QVideoSurfaceFormat QGstUtils::formatForCaps( - GstCaps *caps, GstVideoInfo *info, QVideoFrame::HandleType handleType) + GstCaps *caps, GstVideoInfo *info) { GstVideoInfo vidInfo; GstVideoInfo *infoPtr = info ? info : &vidInfo; @@ -239,8 +239,7 @@ QVideoSurfaceFormat QGstUtils::formatForCaps( if (index != -1) { QVideoSurfaceFormat format( QSize(infoPtr->width, infoPtr->height), - qt_videoFormatLookup[index].pixelFormat, - handleType); + qt_videoFormatLookup[index].pixelFormat); if (infoPtr->fps_d > 0) format.setFrameRate(qreal(infoPtr->fps_n) / infoPtr->fps_d); diff --git a/src/multimedia/platform/gstreamer/common/qgstutils_p.h b/src/multimedia/platform/gstreamer/common/qgstutils_p.h index be6138a20..81fd4d31c 100644 --- a/src/multimedia/platform/gstreamer/common/qgstutils_p.h +++ b/src/multimedia/platform/gstreamer/common/qgstutils_p.h @@ -76,8 +76,7 @@ namespace QGstUtils { Q_MULTIMEDIA_EXPORT QVideoSurfaceFormat formatForCaps( GstCaps *caps, - GstVideoInfo *info = 0, - QVideoFrame::HandleType handleType = QVideoFrame::NoHandle); + GstVideoInfo *info = 0); Q_MULTIMEDIA_EXPORT QGstMutableCaps capsForFormats(const QList<QVideoFrame::PixelFormat> &formats); void setFrameTimeStamps(QVideoFrame *frame, GstBuffer *buffer); diff --git a/src/multimedia/platform/gstreamer/common/qgstvideorenderersink.cpp b/src/multimedia/platform/gstreamer/common/qgstvideorenderersink.cpp index 3c0e8b120..0175cb938 100644 --- a/src/multimedia/platform/gstreamer/common/qgstvideorenderersink.cpp +++ b/src/multimedia/platform/gstreamer/common/qgstvideorenderersink.cpp @@ -156,7 +156,7 @@ QGstMutableCaps QGstVideoRenderer::getCaps() bool QGstVideoRenderer::start(GstCaps *caps) { m_flushed = true; - m_format = QGstUtils::formatForCaps(caps, &m_videoInfo, m_handleType); + m_format = QGstUtils::formatForCaps(caps, &m_videoInfo); return m_format.isValid(); } @@ -172,10 +172,10 @@ bool QGstVideoRenderer::present(QVideoSink *sink, GstBuffer *buffer) QGstVideoBuffer *videoBuffer = nullptr; #if QT_CONFIG(gstreamer_gl) - if (m_format.handleType() == QVideoFrame::GLTextureHandle) { + if (m_handleType == QVideoFrame::GLTextureHandle) { GstGLMemory *glmem = GST_GL_MEMORY_CAST(gst_buffer_peek_memory(buffer, 0)); guint textureId = gst_gl_memory_get_texture_id(glmem); - videoBuffer = new QGstVideoBuffer(buffer, m_videoInfo, m_format.handleType(), textureId); + videoBuffer = new QGstVideoBuffer(buffer, m_videoInfo, m_handleType, textureId); } #endif diff --git a/src/multimedia/platform/gstreamer/mediacapture/qgstreamercameraimagecapture.cpp b/src/multimedia/platform/gstreamer/mediacapture/qgstreamercameraimagecapture.cpp index 735a55aed..d893193b1 100644 --- a/src/multimedia/platform/gstreamer/mediacapture/qgstreamercameraimagecapture.cpp +++ b/src/multimedia/platform/gstreamer/mediacapture/qgstreamercameraimagecapture.cpp @@ -201,7 +201,7 @@ bool QGstreamerCameraImageCapture::probeBuffer(GstBuffer *buffer) gst_video_info_from_caps(&previewInfo, caps); auto *gstBuffer = new QGstVideoBuffer(buffer, previewInfo); - auto fmt = QGstUtils::formatForCaps(caps, &previewInfo, QVideoFrame::NoHandle); + auto fmt = QGstUtils::formatForCaps(caps, &previewInfo); QVideoFrame frame(gstBuffer, fmt.frameSize(), fmt.pixelFormat()); QImage img = frame.image(); if (img.isNull()) diff --git a/src/multimedia/video/qabstractvideosurface.cpp b/src/multimedia/video/qabstractvideosurface.cpp index a6100cc37..74347ce27 100644 --- a/src/multimedia/video/qabstractvideosurface.cpp +++ b/src/multimedia/video/qabstractvideosurface.cpp @@ -147,7 +147,7 @@ QAbstractVideoSurface::~QAbstractVideoSurface() = default; */ bool QAbstractVideoSurface::isFormatSupported(const QVideoSurfaceFormat &format) const { - return supportedPixelFormats(format.handleType()).contains(format.pixelFormat()); + return supportedPixelFormats(QVideoFrame::NoHandle).contains(format.pixelFormat()); } /*! diff --git a/src/multimedia/video/qvideosurfaceformat.cpp b/src/multimedia/video/qvideosurfaceformat.cpp index 05901b679..986734a65 100644 --- a/src/multimedia/video/qvideosurfaceformat.cpp +++ b/src/multimedia/video/qvideosurfaceformat.cpp @@ -54,10 +54,8 @@ public: QVideoSurfaceFormatPrivate( const QSize &size, - QVideoFrame::PixelFormat format, - QVideoFrame::HandleType type) + QVideoFrame::PixelFormat format) : pixelFormat(format) - , handleType(type) , frameSize(size) , viewport(QPoint(0, 0), size) { @@ -66,7 +64,6 @@ public: bool operator ==(const QVideoSurfaceFormatPrivate &other) const { if (pixelFormat == other.pixelFormat - && handleType == other.handleType && scanLineDirection == other.scanLineDirection && frameSize == other.frameSize && viewport == other.viewport @@ -84,7 +81,6 @@ public: } QVideoFrame::PixelFormat pixelFormat = QVideoFrame::Format_Invalid; - QVideoFrame::HandleType handleType = QVideoFrame::NoHandle; QVideoSurfaceFormat::Direction scanLineDirection = QVideoSurfaceFormat::TopToBottom; QSize frameSize; QVideoSurfaceFormat::YCbCrColorSpace ycbcrColorSpace = QVideoSurfaceFormat::YCbCr_Undefined; @@ -173,8 +169,8 @@ QVideoSurfaceFormat::QVideoSurfaceFormat() \a size and pixel \a format. */ QVideoSurfaceFormat::QVideoSurfaceFormat( - const QSize& size, QVideoFrame::PixelFormat format, QVideoFrame::HandleType type) - : d(new QVideoSurfaceFormatPrivate(size, format, type)) + const QSize& size, QVideoFrame::PixelFormat format) + : d(new QVideoSurfaceFormatPrivate(size, format)) { } @@ -228,19 +224,6 @@ QVideoFrame::PixelFormat QVideoSurfaceFormat::pixelFormat() const } /*! - Returns the type of handle the surface uses to present the frame data. - - If the handle type is \c QVideoFrame::NoHandle, buffers with any handle type are valid - provided they can be \l {QVideoFrame::map()}{mapped} with the - QVideoFrame::ReadOnly flag. If the handleType() is not QVideoFrame::NoHandle - then the handle type of the buffer must be the same as that of the surface format. -*/ -QVideoFrame::HandleType QVideoSurfaceFormat::handleType() const -{ - return d->handleType; -} - -/*! Returns the dimensions of frames in a video stream. \sa frameWidth(), frameHeight() @@ -449,7 +432,7 @@ QDebug operator<<(QDebug dbg, const QVideoSurfaceFormat &f) dbg.nospace(); dbg << "QVideoSurfaceFormat(" << f.pixelFormat() << ", " << f.frameSize() << ", viewport=" << f.viewport() - << ", handleType=" << f.handleType() << ", yCbCrColorSpace=" << f.yCbCrColorSpace() + << ", yCbCrColorSpace=" << f.yCbCrColorSpace() << ')' << "\n pixel format=" << f.pixelFormat() << "\n frame size=" << f.frameSize() diff --git a/src/multimedia/video/qvideosurfaceformat.h b/src/multimedia/video/qvideosurfaceformat.h index dca8c808c..694dd9a79 100644 --- a/src/multimedia/video/qvideosurfaceformat.h +++ b/src/multimedia/video/qvideosurfaceformat.h @@ -76,8 +76,7 @@ public: QVideoSurfaceFormat(); QVideoSurfaceFormat( const QSize &size, - QVideoFrame::PixelFormat pixelFormat, - QVideoFrame::HandleType handleType = QVideoFrame::NoHandle); + QVideoFrame::PixelFormat pixelFormat); QVideoSurfaceFormat(const QVideoSurfaceFormat &format); ~QVideoSurfaceFormat(); @@ -89,7 +88,6 @@ public: bool isValid() const; QVideoFrame::PixelFormat pixelFormat() const; - QVideoFrame::HandleType handleType() const; QSize frameSize() const; void setFrameSize(const QSize &size); diff --git a/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp b/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp index 969f058c5..32f7424bf 100644 --- a/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp +++ b/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp @@ -266,7 +266,7 @@ QSGNode *QDeclarativeVideoBackend::updatePaintNode(QSGNode *oldNode, } } - if (videoNode && (videoNode->pixelFormat() != m_frame.pixelFormat() || videoNode->handleType() != m_frame.handleType())) { + if (videoNode && videoNode->pixelFormat() != m_frame.pixelFormat()) { qCDebug(qLcVideo) << "updatePaintNode: deleting old video node because frame format changed"; delete videoNode; videoNode = nullptr; @@ -282,7 +282,7 @@ QSGNode *QDeclarativeVideoBackend::updatePaintNode(QSGNode *oldNode, for (QSGVideoNodeFactoryInterface* factory : qAsConst(m_videoNodeFactories)) { // Get a node that supports our frame. The surface is irrelevant, our // QSGVideoItemSurface supports (logically) anything. - QVideoSurfaceFormat nodeFormat(m_frame.size(), m_frame.pixelFormat(), m_frame.handleType()); + QVideoSurfaceFormat nodeFormat(m_frame.size(), m_frame.pixelFormat()); nodeFormat.setYCbCrColorSpace(m_surfaceFormat.yCbCrColorSpace()); nodeFormat.setScanLineDirection(m_surfaceFormat.scanLineDirection()); nodeFormat.setViewport(m_surfaceFormat.viewport()); @@ -318,9 +318,7 @@ QSGNode *QDeclarativeVideoBackend::updatePaintNode(QSGNode *oldNode, if ((q->flushMode() == QDeclarativeVideoOutput::FirstFrame && !m_frameOnFlush.isValid()) || q->flushMode() == QDeclarativeVideoOutput::LastFrame) { - m_frameOnFlush = m_surfaceFormat.handleType() == QVideoFrame::NoHandle - ? m_frame - : m_frame.image(); + m_frameOnFlush = m_frame; } //don't keep the frame for more than really necessary @@ -343,7 +341,7 @@ QRectF QDeclarativeVideoBackend::adjustedViewport() const void QDeclarativeVideoBackend::present(const QVideoFrame &frame) { m_frameMutex.lock(); - m_surfaceFormat = QVideoSurfaceFormat(frame.size(), frame.pixelFormat(), QVideoFrame::NoHandle); + m_surfaceFormat = QVideoSurfaceFormat(frame.size(), frame.pixelFormat()); m_frame = frame.isValid() ? frame : m_frameOnFlush; m_frameChanged = true; m_frameMutex.unlock(); diff --git a/src/qtmultimediaquicktools/qsgvideonode_p.h b/src/qtmultimediaquicktools/qsgvideonode_p.h index 75bf1da5b..7f6a04e01 100644 --- a/src/qtmultimediaquicktools/qsgvideonode_p.h +++ b/src/qtmultimediaquicktools/qsgvideonode_p.h @@ -72,7 +72,6 @@ public: virtual void setCurrentFrame(const QVideoFrame &frame, FrameFlags flags) = 0; virtual QVideoFrame::PixelFormat pixelFormat() const = 0; - virtual QVideoFrame::HandleType handleType() const = 0; void setTexturedRectGeometry(const QRectF &boundingRect, const QRectF &textureRect, int orientation); diff --git a/src/qtmultimediaquicktools/qsgvideonode_rgb.cpp b/src/qtmultimediaquicktools/qsgvideonode_rgb.cpp index cfe376ecf..7345291c8 100644 --- a/src/qtmultimediaquicktools/qsgvideonode_rgb.cpp +++ b/src/qtmultimediaquicktools/qsgvideonode_rgb.cpp @@ -62,7 +62,7 @@ QList<QVideoFrame::PixelFormat> QSGVideoNodeFactory_RGB::supportedPixelFormats( QSGVideoNode *QSGVideoNodeFactory_RGB::createNode(const QVideoSurfaceFormat &format) { - if (supportedPixelFormats(format.handleType()).contains(format.pixelFormat())) + if (supportedPixelFormats(QVideoFrame::NoHandle).contains(format.pixelFormat())) return new QSGVideoNode_RGB(format); return nullptr; diff --git a/src/qtmultimediaquicktools/qsgvideonode_rgb_p.h b/src/qtmultimediaquicktools/qsgvideonode_rgb_p.h index c17738b0a..165781475 100644 --- a/src/qtmultimediaquicktools/qsgvideonode_rgb_p.h +++ b/src/qtmultimediaquicktools/qsgvideonode_rgb_p.h @@ -67,9 +67,6 @@ public: QVideoFrame::PixelFormat pixelFormat() const override { return m_format.pixelFormat(); } - QVideoFrame::HandleType handleType() const override { - return QVideoFrame::NoHandle; - } void setCurrentFrame(const QVideoFrame &frame, FrameFlags flags) override; private: diff --git a/src/qtmultimediaquicktools/qsgvideonode_texture.cpp b/src/qtmultimediaquicktools/qsgvideonode_texture.cpp index 58a903065..0a52f06c4 100644 --- a/src/qtmultimediaquicktools/qsgvideonode_texture.cpp +++ b/src/qtmultimediaquicktools/qsgvideonode_texture.cpp @@ -46,38 +46,25 @@ QT_BEGIN_NAMESPACE QList<QVideoFrame::PixelFormat> QSGVideoNodeFactory_Texture::supportedPixelFormats( - QVideoFrame::HandleType handleType) const + QVideoFrame::HandleType) const { QList<QVideoFrame::PixelFormat> pixelFormats; - QList<QVideoFrame::HandleType> types; - - auto rhi = QSGRhiSupport::instance(); - auto metalEnabled = rhi->isRhiEnabled() && rhi->rhiBackend() == QRhi::Metal; - if (metalEnabled) - types.append(QVideoFrame::MTLTextureHandle); - -#if QT_CONFIG(opengl) - types.append(QVideoFrame::GLTextureHandle); -#endif - - if (types.contains(handleType)) { - pixelFormats.append(QVideoFrame::Format_RGB565); - pixelFormats.append(QVideoFrame::Format_RGB32); - pixelFormats.append(QVideoFrame::Format_ARGB32); - pixelFormats.append(QVideoFrame::Format_BGR32); - pixelFormats.append(QVideoFrame::Format_BGRA32); + pixelFormats.append(QVideoFrame::Format_RGB565); + pixelFormats.append(QVideoFrame::Format_RGB32); + pixelFormats.append(QVideoFrame::Format_ARGB32); + pixelFormats.append(QVideoFrame::Format_BGR32); + pixelFormats.append(QVideoFrame::Format_BGRA32); #if !QT_CONFIG(gpu_vivante) - pixelFormats.append(QVideoFrame::Format_ABGR32); + pixelFormats.append(QVideoFrame::Format_ABGR32); #endif - } return pixelFormats; } QSGVideoNode *QSGVideoNodeFactory_Texture::createNode(const QVideoSurfaceFormat &format) { - if (supportedPixelFormats(format.handleType()).contains(format.pixelFormat())) + if (supportedPixelFormats(QVideoFrame::NoHandle).contains(format.pixelFormat())) return new QSGVideoNode_Texture(format); return nullptr; diff --git a/src/qtmultimediaquicktools/qsgvideonode_texture_p.h b/src/qtmultimediaquicktools/qsgvideonode_texture_p.h index 7f0b02220..c8ccf8cd9 100644 --- a/src/qtmultimediaquicktools/qsgvideonode_texture_p.h +++ b/src/qtmultimediaquicktools/qsgvideonode_texture_p.h @@ -67,9 +67,6 @@ public: QVideoFrame::PixelFormat pixelFormat() const override { return m_format.pixelFormat(); } - QVideoFrame::HandleType handleType() const override { - return m_format.handleType(); - } void setCurrentFrame(const QVideoFrame &frame, FrameFlags flags) override; private: diff --git a/src/qtmultimediaquicktools/qsgvideonode_yuv.cpp b/src/qtmultimediaquicktools/qsgvideonode_yuv.cpp index 51b02f43b..729aa33ad 100644 --- a/src/qtmultimediaquicktools/qsgvideonode_yuv.cpp +++ b/src/qtmultimediaquicktools/qsgvideonode_yuv.cpp @@ -44,26 +44,20 @@ QT_BEGIN_NAMESPACE QList<QVideoFrame::PixelFormat> QSGVideoNodeFactory_YUV::supportedPixelFormats( - QVideoFrame::HandleType handleType) const + QVideoFrame::HandleType) const { QList<QVideoFrame::PixelFormat> formats; - if (handleType == QVideoFrame::NoHandle) { - formats << QVideoFrame::Format_YUV420P << QVideoFrame::Format_YV12 << QVideoFrame::Format_YUV422P - << QVideoFrame::Format_NV12 << QVideoFrame::Format_NV21 - << QVideoFrame::Format_UYVY << QVideoFrame::Format_YUYV; - } else if (handleType == QVideoFrame::GLTextureHandle) { - formats << QVideoFrame::Format_NV12 << QVideoFrame::Format_NV21; - } else if (handleType == QVideoFrame::MTLTextureHandle) { - formats << QVideoFrame::Format_NV12 << QVideoFrame::Format_NV21; - } + formats << QVideoFrame::Format_YUV420P << QVideoFrame::Format_YV12 << QVideoFrame::Format_YUV422P + << QVideoFrame::Format_NV12 << QVideoFrame::Format_NV21 + << QVideoFrame::Format_UYVY << QVideoFrame::Format_YUYV; return formats; } QSGVideoNode *QSGVideoNodeFactory_YUV::createNode(const QVideoSurfaceFormat &format) { - if (supportedPixelFormats(format.handleType()).contains(format.pixelFormat())) + if (supportedPixelFormats(QVideoFrame::NoHandle).contains(format.pixelFormat())) return new QSGVideoNode_YUV(format); return nullptr; diff --git a/src/qtmultimediaquicktools/qsgvideonode_yuv_p.h b/src/qtmultimediaquicktools/qsgvideonode_yuv_p.h index c8299e919..89257ab8d 100644 --- a/src/qtmultimediaquicktools/qsgvideonode_yuv_p.h +++ b/src/qtmultimediaquicktools/qsgvideonode_yuv_p.h @@ -66,9 +66,6 @@ public: QVideoFrame::PixelFormat pixelFormat() const override { return m_format.pixelFormat(); } - QVideoFrame::HandleType handleType() const override { - return QVideoFrame::NoHandle; - } void setCurrentFrame(const QVideoFrame &frame, FrameFlags flags) override; private: |