summaryrefslogtreecommitdiffstats
path: root/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_videotoolbox.mm
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/multimedia/ffmpeg/qffmpeghwaccel_videotoolbox.mm')
-rw-r--r--src/plugins/multimedia/ffmpeg/qffmpeghwaccel_videotoolbox.mm76
1 files changed, 24 insertions, 52 deletions
diff --git a/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_videotoolbox.mm b/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_videotoolbox.mm
index d77eab142..948f7fc23 100644
--- a/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_videotoolbox.mm
+++ b/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_videotoolbox.mm
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qffmpeghwaccel_videotoolbox_p.h"
@@ -45,22 +9,27 @@
#include <qvideoframeformat.h>
#include <qffmpegvideobuffer_p.h>
+#include <qloggingcategory.h>
#include "private/qvideotexturehelper_p.h"
-#include <private/qrhi_p.h>
-#include <private/qrhimetal_p.h>
-#include <private/qrhigles2_p.h>
+#include <rhi/qrhi.h>
#include <CoreVideo/CVMetalTexture.h>
#include <CoreVideo/CVMetalTextureCache.h>
#include <qopenglcontext.h>
-
+#ifdef Q_OS_MACOS
#import <AppKit/AppKit.h>
+#endif
+#ifdef Q_OS_IOS
+#import <OpenGLES/EAGL.h>
+#endif
#import <Metal/Metal.h>
QT_BEGIN_NAMESPACE
+static Q_LOGGING_CATEGORY(qLcVideotoolbox, "qt.multimedia.ffmpeg.videotoolbox")
+
namespace QFFmpeg
{
@@ -70,7 +39,7 @@ class VideoToolBoxTextureSet : public TextureSet
{
public:
~VideoToolBoxTextureSet();
- qint64 textureHandle(int plane) override;
+ qint64 textureHandle(QRhi *, int plane) override;
QRhi *rhi = nullptr;
CVMetalTextureRef cvMetalTexture[3] = {};
@@ -91,7 +60,6 @@ VideoToolBoxTextureConverter::VideoToolBoxTextureConverter(QRhi *rhi)
return;
if (rhi->backend() == QRhi::Metal) {
- qDebug() << " using metal backend";
const auto *metal = static_cast<const QRhiMetalNativeHandles *>(rhi->nativeHandles());
// Create a Metal Core Video texture cache from the pixel buffer.
@@ -202,13 +170,13 @@ TextureSet *VideoToolBoxTextureConverter::getTextures(AVFrame *frame)
bool needsConversion = false;
QVideoFrameFormat::PixelFormat pixelFormat = QFFmpegVideoBuffer::toQtPixelFormat(HWAccel::format(frame), &needsConversion);
if (needsConversion) {
- qDebug() << "XXXXXXXXXXXX pixel format needs conversion" << pixelFormat << HWAccel::format(frame);
+ // qDebug() << "XXXXXXXXXXXX pixel format needs conversion" << pixelFormat << HWAccel::format(frame);
return nullptr;
}
CVPixelBufferRef buffer = (CVPixelBufferRef)frame->data[3];
- VideoToolBoxTextureSet *textureSet = new VideoToolBoxTextureSet;
+ auto textureSet = std::make_unique<VideoToolBoxTextureSet>();
textureSet->m_buffer = buffer;
textureSet->rhi = rhi;
CVPixelBufferRetain(buffer);
@@ -251,8 +219,10 @@ TextureSet *VideoToolBoxTextureConverter::getTextures(AVFrame *frame)
buffer,
nil,
&textureSet->cvOpenGLTexture);
- if (cvret != kCVReturnSuccess)
- qWarning() << "OpenGL texture creation failed" << cvret;
+ if (cvret != kCVReturnSuccess) {
+ qCWarning(qLcVideotoolbox) << "OpenGL texture creation failed" << cvret;
+ return nullptr;
+ }
Q_ASSERT(CVOpenGLTextureGetTarget(textureSet->cvOpenGLTexture) == GL_TEXTURE_RECTANGLE);
#endif
@@ -272,13 +242,15 @@ TextureSet *VideoToolBoxTextureConverter::getTextures(AVFrame *frame)
GL_UNSIGNED_BYTE,
0,
&textureSet->cvOpenGLESTexture);
- if (cvret != kCVReturnSuccess)
- qWarning() << "OpenGL ES texture creation failed" << cvret;
+ if (cvret != kCVReturnSuccess) {
+ qCWarning(qLcVideotoolbox) << "OpenGL ES texture creation failed" << cvret;
+ return nullptr;
+ }
#endif
#endif
}
- return textureSet;
+ return textureSet.release();
}
VideoToolBoxTextureSet::~VideoToolBoxTextureSet()
@@ -296,7 +268,7 @@ VideoToolBoxTextureSet::~VideoToolBoxTextureSet()
CVPixelBufferRelease(m_buffer);
}
-qint64 VideoToolBoxTextureSet::textureHandle(int plane)
+qint64 VideoToolBoxTextureSet::textureHandle(QRhi *, int plane)
{
if (rhi->backend() == QRhi::Metal)
return cvMetalTexture[plane] ? qint64(CVMetalTextureGetTexture(cvMetalTexture[plane])) : 0;