diff options
author | Lars Knoll <lars.knoll@qt.io> | 2021-03-02 13:11:36 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2021-03-16 07:41:44 +0000 |
commit | 5671ab651d9c938a0ff2df3a9c0baef9891e7e23 (patch) | |
tree | 4c5c6fde332af93b3d5f5cb4198df1ee0668434a /examples | |
parent | e7702afc9dfa6e69b1b05d68a38248ccc6b6dd87 (diff) |
Move HandleType and MapMode from QAbstractVideoBuffer to QVideoFrame
QAbstractVideoBuffer is a class that is only required inside our
implementation, so we can make it private. This change prepares
for it.
Change-Id: I4ba4542c1eab742f2fc93231e2e5063dbc5d5e94
Reviewed-by: Doris Verria <doris.verria@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'examples')
7 files changed, 19 insertions, 19 deletions
diff --git a/examples/multimedia/video/qmlvideofilter_opencl/main.cpp b/examples/multimedia/video/qmlvideofilter_opencl/main.cpp index 255c0b61b..58c8967f0 100644 --- a/examples/multimedia/video/qmlvideofilter_opencl/main.cpp +++ b/examples/multimedia/video/qmlvideofilter_opencl/main.cpp @@ -317,8 +317,8 @@ QVideoFrame CLFilterRunnable::run(QVideoFrame *input, const QVideoSurfaceFormat // The latter is the fast path where everything happens on GPU. THe former involves a texture upload. if (!input->isValid() - || (input->handleType() != QAbstractVideoBuffer::NoHandle - && input->handleType() != QAbstractVideoBuffer::GLTextureHandle)) { + || (input->handleType() != QVideoFrame::NoHandle + && input->handleType() != QVideoFrame::GLTextureHandle)) { qWarning("Invalid input format"); return *input; } @@ -337,13 +337,13 @@ QVideoFrame CLFilterRunnable::run(QVideoFrame *input, const QVideoSurfaceFormat // Create a texture from the image data. QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions(); GLuint texture; - if (input->handleType() == QAbstractVideoBuffer::NoHandle) { + if (input->handleType() == QVideoFrame::NoHandle) { // Upload. if (m_tempTexture) f->glBindTexture(GL_TEXTURE_2D, m_tempTexture); else m_tempTexture = newTexture(); - input->map(QAbstractVideoBuffer::ReadOnly); + input->map(QVideoFrame::ReadOnly); // glTexImage2D only once and use TexSubImage later on. This avoids the need // to recreate the CL image object on every frame. f->glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_size.width(), m_size.height(), @@ -482,11 +482,11 @@ QVideoFrame InfoFilterRunnable::run(QVideoFrame *input, const QVideoSurfaceForma InfoFilterResult *result = new InfoFilterResult; result->m_frameResolution = input->size(); switch (input->handleType()) { - case QAbstractVideoBuffer::NoHandle: + case QVideoFrame::NoHandle: result->m_handleType = QLatin1String("pixel data"); result->m_pixelFormat = input->pixelFormat(); break; - case QAbstractVideoBuffer::GLTextureHandle: + case QVideoFrame::GLTextureHandle: result->m_handleType = QLatin1String("OpenGL texture"); break; default: diff --git a/examples/multimedia/video/qmlvideofilter_opencl/rgbframehelper.h b/examples/multimedia/video/qmlvideofilter_opencl/rgbframehelper.h index 638337ea4..ea82b267e 100644 --- a/examples/multimedia/video/qmlvideofilter_opencl/rgbframehelper.h +++ b/examples/multimedia/video/qmlvideofilter_opencl/rgbframehelper.h @@ -60,21 +60,21 @@ /* Returns a QImage that wraps the given video frame. - This is suitable only for QAbstractVideoBuffer::NoHandle frames with RGB (or BGR) + This is suitable only for QVideoFrame::NoHandle frames with RGB (or BGR) data. YUV is not supported here. The QVideoFrame must be mapped and kept mapped as long as the wrapping QImage exists. As a convenience the function also supports frames with a handle type of - QAbstractVideoBuffer::GLTextureHandle. This allows creating a system memory backed + QVideoFrame::GLTextureHandle. This allows creating a system memory backed QVideoFrame containing the image data from an OpenGL texture. However, readback is a slow operation and may stall the GPU pipeline and should be avoided in production code. */ QImage imageWrapper(const QVideoFrame &frame) { #ifndef QT_NO_OPENGL - if (frame.handleType() == QAbstractVideoBuffer::GLTextureHandle) { + if (frame.handleType() == QVideoFrame::GLTextureHandle) { // Slow and inefficient path. Ideally what's on the GPU should remain on the GPU, instead of readbacks like this. QImage img(frame.width(), frame.height(), QImage::Format_RGBA8888); GLuint textureId = frame.handle().toUInt(); diff --git a/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.cpp b/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.cpp index b2dc6331d..0271f023a 100644 --- a/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.cpp +++ b/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.cpp @@ -73,7 +73,7 @@ void VideoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q_UNUSED(option); Q_UNUSED(widget); - if (currentFrame.map(QAbstractVideoBuffer::ReadOnly)) { + if (currentFrame.map(QVideoFrame::ReadOnly)) { const QTransform oldTransform = painter->transform(); if (surfaceFormat().scanLineDirection() == QVideoSurfaceFormat::BottomToTop) { @@ -96,9 +96,9 @@ void VideoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, } QList<QVideoFrame::PixelFormat> VideoItem::supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const + QVideoFrame::HandleType handleType) const { - if (handleType == QAbstractVideoBuffer::NoHandle) { + if (handleType == QVideoFrame::NoHandle) { return QList<QVideoFrame::PixelFormat>() << QVideoFrame::Format_RGB32 << QVideoFrame::Format_ARGB32 diff --git a/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.h b/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.h index 2dc121d92..7fff81a2f 100644 --- a/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.h +++ b/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.h @@ -70,7 +70,7 @@ public: //video surface QList<QVideoFrame::PixelFormat> supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const override; + QVideoFrame::HandleType handleType = QVideoFrame::NoHandle) const override; bool start(const QVideoSurfaceFormat &format) override; void stop() override; diff --git a/examples/multimediawidgets/customvideosurface/customvideowidget/videowidgetsurface.cpp b/examples/multimediawidgets/customvideosurface/customvideowidget/videowidgetsurface.cpp index 9b1d68202..a9b98e06e 100644 --- a/examples/multimediawidgets/customvideosurface/customvideowidget/videowidgetsurface.cpp +++ b/examples/multimediawidgets/customvideosurface/customvideowidget/videowidgetsurface.cpp @@ -63,9 +63,9 @@ VideoWidgetSurface::VideoWidgetSurface(QWidget *widget, QObject *parent) //! [0] QList<QVideoFrame::PixelFormat> VideoWidgetSurface::supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const + QVideoFrame::HandleType handleType) const { - if (handleType == QAbstractVideoBuffer::NoHandle) { + if (handleType == QVideoFrame::NoHandle) { return QList<QVideoFrame::PixelFormat>() << QVideoFrame::Format_RGB32 << QVideoFrame::Format_ARGB32 @@ -86,7 +86,7 @@ bool VideoWidgetSurface::isFormatSupported(const QVideoSurfaceFormat &format) co return imageFormat != QImage::Format_Invalid && !size.isEmpty() - && format.handleType() == QAbstractVideoBuffer::NoHandle; + && format.handleType() == QVideoFrame::NoHandle; } //! [1] @@ -157,7 +157,7 @@ void VideoWidgetSurface::updateVideoRect() //! [6] void VideoWidgetSurface::paint(QPainter *painter) { - if (currentFrame.map(QAbstractVideoBuffer::ReadOnly)) { + if (currentFrame.map(QVideoFrame::ReadOnly)) { const QTransform oldTransform = painter->transform(); if (surfaceFormat().scanLineDirection() == QVideoSurfaceFormat::BottomToTop) { diff --git a/examples/multimediawidgets/customvideosurface/customvideowidget/videowidgetsurface.h b/examples/multimediawidgets/customvideosurface/customvideowidget/videowidgetsurface.h index d9765d836..a445cf6d6 100644 --- a/examples/multimediawidgets/customvideosurface/customvideowidget/videowidgetsurface.h +++ b/examples/multimediawidgets/customvideosurface/customvideowidget/videowidgetsurface.h @@ -65,7 +65,7 @@ public: VideoWidgetSurface(QWidget *widget, QObject *parent = 0); QList<QVideoFrame::PixelFormat> supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const override; + QVideoFrame::HandleType handleType = QVideoFrame::NoHandle) const override; bool isFormatSupported(const QVideoSurfaceFormat &format) const override; bool start(const QVideoSurfaceFormat &format) override; diff --git a/examples/multimediawidgets/player/histogramwidget.cpp b/examples/multimediawidgets/player/histogramwidget.cpp index 488c89511..78a666c6d 100644 --- a/examples/multimediawidgets/player/histogramwidget.cpp +++ b/examples/multimediawidgets/player/histogramwidget.cpp @@ -208,7 +208,7 @@ void FrameProcessor::processFrame(QVideoFrame frame, int levels) if (!levels) break; - if (!frame.map(QAbstractVideoBuffer::ReadOnly)) + if (!frame.map(QVideoFrame::ReadOnly)) break; if (frame.pixelFormat() == QVideoFrame::Format_YUV420P || |