summaryrefslogtreecommitdiffstats
path: root/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_vaapi.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Plugins: avoid allocationsTim Blechmann2024-05-241-1/+1
| | | | | | | | | | `QPlatformNativeInterface` uses `QByteArray` in the interface. The plugins use string literals, which result in memory allocations. We can avoid them by use bytearray literals. Pick-to: 6.5 6.7 Change-Id: I6160231fc651b8eb524e6026b04584df219b083f Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
* FFmpeg VAAPI: Fix not closing fd's when returning from getTextures()Lars Sutterud2024-04-301-4/+8
| | | | | | | | | | | | Added a QScopeGuard to make sure we close all file descriptors in the VADRMPRIMESurfaceDescriptor struct after calling vaExportSurfaceHandle() There are multiple return points in VAAPITextureConverter::getTextures() and the QScopeGuard will iterate through the struct and close all fd's upon destruction. Change-Id: I34037d5ca30bdeb27ec73beaabd559595a509910 Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
* Prevent lost D3D11 device with QVideoFrame::toImage() with Qt QuickJøger Hansegård2024-04-161-1/+1
| | | | | | | | | | | | | | | | | | This patch ensures that QFFmpeg::TextureConverter is only used to convert frames when the destination QRhi instance is the same as the one it was initialized on. If QVideoFrame::toImage() is called from the main thread while the frame is also being rendered in the Qt Quick render thread, QVideoFrame::toImage() will create its own QRhi instance. In this case we need to disable direct texture transfer of the QFFmpeg textures, and instead fall back to mapping the texture data through CPU memory. Task-number: QTBUG-113627 Pick-to: 6.7 6.5 Change-Id: I3184796d05627fcac1a069400e8a6a5879fcd5bc Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
* FFmpeg EGL/vaapi: Disable HW accelerated texture conversion when failingLars Sutterud2024-03-131-5/+16
| | | | | | | | | | | | | | | | | | | | | | | | | This change applies to hardware accelerated texture conversion using EGL and VA-API. If a call to eglCreateImage() inside VAAPITextureConverter::getTextures() fails with EGL_BAD_MATCH error, this change makes sure we fall back to software decoding by setting this->rhi = nullptr. This specific error can be reproduced in a Linux environment with both a NVIDIA and AMD gpu, when NVIDIA is used as the EGL vendor. By initializing the hw context manually using vaInitialize(), it is possible to detect this problem before trying to decode frames. But we can't since we let FFmpeg do this for us when we call av_hwdevice_ctx_create(). The related qWarning() messages are also elaborated with error codes and more relevant information. Fixes: QTBUG-112312 Pick-to: 6.7 6.6 6.5 Change-Id: Ie90623c7b2b18b70b1000ae3ad6f96872933e884 Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io> Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
* Adapt to the RHI API conceptLaszlo Agocs2023-05-221-2/+1
| | | | | | Task-number: QTBUG-113331 Change-Id: I992f3cbc9e4ceff6e62452bf354e5c46dd8fa84b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add missing QT_BEGIN_NAMESPACEAllan Sandfeld Jensen2023-02-201-0/+2
| | | | | | | | | Fixes namespaced builds with enabling VA-API Pick-to: 6.5 Fixes: QTBUG-111269 Change-Id: I032b7c25c8395b8ab54d42bb77a55af1766a2992 Reviewed-by: Lars Knoll <lars@knoll.priv.no>
* Set Q_LOGGING_CATEGORY staticArtem Dyomin2023-01-181-1/+1
| | | | | | | | | | | Q_LOGGING_CATEGORY is a macro with a function under the hood. Since we're using it in cpp files, better to make it static in order to get rid of extra public linking symbols. Pick-to: 6.5 Change-Id: If384073993fdc70a2affab4bd3bf50c0c4129687 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars@knoll.priv.no>
* Use SPDX license identifiersLucie Gérard2022-06-241-38/+2
| | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: Ida08dfe6c84778656e942178c3d39042c9ef1ed2 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Remove some of qDebug() and move the remaining to qCDebug()Piotr Srebrny2022-06-071-13/+15
| | | | | | | | | This patch moves most of the qDebug() messages to qCDebug(). Some of the messages that seems to be of minor utility are removed. Still some debug messages that are commented out don't compile anymore. Change-Id: Ie30f213f41d7f4adce8aa36b15ace0ddbedfe616 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Enable HW acceleration on Windows with D3D11 texturesPiotr Srebrny2022-04-251-1/+1
| | | | | | | | | | | | | | | This patch enables HW accelerated decoding of video with D3D11. The decoded frames arrive as a texture array with an index into the array pointing to where the decoded frame is located. This texture is shared with the D3D11 display device. Two elements are missing: 1) D3D11 rendered texture sharing with OpenGL display QRhi 2) Seting up the correct D3D11 adapter for texture decoding to avoid copying texture between decoding adapter and displaying adapter Change-Id: I18629a7d18471607d9920cf23cf9d81adcec1e7c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Restructure the HW codec supportLars Knoll2022-03-251-20/+28
| | | | | | | | | | | | | | | | Disentangle HW codec support from the conversion into RHI compatible textures. Move the latter to a new TextureConverter class that controlled by the video sink, and only set on the video buffer when it passes through the sink. Properly create a HW context for the camera and add some preliminary support to the encoder on macOS. Adjust the VAAPI code to the new structure. Change-Id: I21ecf67fd276dfaa3ee7e04c80fe2304a3d536be Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Piotr Srebrny <piotr.srebrny@qt.io>
* FFmpeg: Small cleanup in the HW acceleration frameworkLars Knoll2022-03-251-10/+1
| | | | | | Change-Id: Ia64e67822d6fac566b0b8dd08a5ca462c14c4527 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Piotr Srebrny <piotr.srebrny@qt.io>
* Fix fatal warning: control reaches end of non-void functionShawn Rutledge2022-01-261-0/+1
| | | | | | | Comes from -Werror=return-type Change-Id: I9adcb688f935e40cd10a0e74263179c535b2d618 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Rework the thread handling in the decoderLars Knoll2022-01-191-1/+1
| | | | | | | | | | | | Large restructuring of the source code to have clearer responsibilities between the threads. Prepare for more than one audio and video pipeline. Now seeking also works fine both when playing and when paused. Change-Id: I525206a374d70596c4497d67fcbdf680b1a036b8 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* FFmpeg: Zero copy support on macOSLars Knoll2022-01-191-19/+28
| | | | | | | | Implement zero copy rendering for macOS. This brings down CPU load to ~30% for rendering our 4K HDR test video. Change-Id: I8953a1b55fb49ad52bde94c3dfc681f8b1a22dc4 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* FFmpeg: Add support for a zero copy path when using egl and vaapiLars Knoll2022-01-191-0/+373
Use DMA buffers to copy the VAAPI surface over to OpenGL. This only works when using QT_XCB_GL_INTEGRATION=xcb_egl. For GLX, the DMA buffer integration is unfortunately not usable. It should work on wayland as well, but that's untested. Change-Id: Ib72d88621261b5b59b13d52d66796320ac02b8ae Reviewed-by: Lars Knoll <lars.knoll@qt.io>