File indexing completed on 2024-05-05 05:30:19

0001 /*
0002     SPDX-FileCopyrightText: 2023 Marco Martin <mart@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #pragma once
0008 
0009 #include <QByteArray>
0010 #include <QSize>
0011 
0012 extern "C" {
0013 #include <va/va.h>
0014 }
0015 
0016 class VaapiUtils
0017 {
0018 public:
0019     VaapiUtils();
0020     ~VaapiUtils();
0021 
0022     bool supportsProfile(VAProfile profile);
0023 
0024     QByteArray devicePath();
0025 
0026     QSize minimumSize() const;
0027     QSize maximumSize() const;
0028 
0029     bool supportsHardwareModifiers() const;
0030 
0031 private:
0032     static VADisplay openDevice(int *fd, const QByteArray &path);
0033     static void closeDevice(int *fd, VADisplay dpy);
0034     bool supportsH264(const QByteArray &path) const;
0035     void querySizeConstraints(VADisplay dpy) const;
0036     static bool supportsProfile(VAProfile profile, VADisplay dpy, const QByteArray &path);
0037     static uint32_t rateControlForProfile(VAProfile profile, VAEntrypoint entrypoint, VADisplay dpy, const QByteArray &path);
0038 
0039     QByteArray m_devicePath;
0040 
0041     mutable bool m_supportsHardwareModifiers = true;
0042     mutable QSize m_minSize;
0043     mutable QSize m_maxSize = QSize{std::numeric_limits<int>::max(), std::numeric_limits<int>::max()};
0044 };