feat: add vaapi path for video wallpapers on generic gpus
C++ / fmt (pull_request) Failing after 6s
C++ / build (pull_request) Failing after 10s
C++ / clang-tidy (pull_request) Failing after 11s
JS/TS / fmt (pull_request) Successful in 10s
JS/TS / lint (pull_request) Successful in 8s
Python / static (pull_request) Failing after 32s
Rust / build (pull_request) Successful in 52s
Python / verify (pull_request) Failing after 1m23s
Rust / fmt (pull_request) Successful in 51s
Rust / clippy (pull_request) Successful in 1m2s
C++ / fmt (pull_request) Failing after 6s
C++ / build (pull_request) Failing after 10s
C++ / clang-tidy (pull_request) Failing after 11s
JS/TS / fmt (pull_request) Successful in 10s
JS/TS / lint (pull_request) Successful in 8s
Python / static (pull_request) Failing after 32s
Rust / build (pull_request) Successful in 52s
Python / verify (pull_request) Failing after 1m23s
Rust / fmt (pull_request) Successful in 51s
Rust / clippy (pull_request) Successful in 1m2s
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
#pragma once
|
||||
|
||||
#include "videodecoder.hpp"
|
||||
|
||||
#include <EGL/egl.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
#include <QSize>
|
||||
#include <QString>
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#ifdef ZHAVE_VAAPI
|
||||
#include <EGL/eglext.h>
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libavutil/buffer.h>
|
||||
#include <libavutil/frame.h>
|
||||
#include <libavutil/hwcontext.h>
|
||||
#include <libavutil/pixfmt.h>
|
||||
#include <libavutil/pixdesc.h>
|
||||
}
|
||||
|
||||
namespace ZShell::wallpaper {
|
||||
|
||||
class VaapiPlayer : public VideoDecoder {
|
||||
public:
|
||||
explicit VaapiPlayer(EGLDisplay display);
|
||||
~VaapiPlayer() override;
|
||||
|
||||
[[nodiscard]] static bool available();
|
||||
|
||||
bool start(const QString& path) override;
|
||||
void stop() override;
|
||||
bool importCurrentFrame() override;
|
||||
void deleteTexture() override;
|
||||
|
||||
[[nodiscard]] const char* backendName() const override { return "vaapi"; }
|
||||
|
||||
private:
|
||||
void decodeLoop(const QString& path, uint32_t generation);
|
||||
bool openDecoder(const QString& path);
|
||||
void closeDecoder();
|
||||
|
||||
bool ensureDevice();
|
||||
bool ensureTextures(unsigned w, unsigned h, int compBytes);
|
||||
|
||||
#ifdef ZHAVE_VAAPI
|
||||
bool importEglImages(AVFrame* frame);
|
||||
#endif
|
||||
|
||||
EGLDisplay m_eglDisplay = EGL_NO_DISPLAY;
|
||||
|
||||
std::thread m_thread;
|
||||
std::atomic<bool> m_threadRunning{false};
|
||||
std::atomic<uint32_t> m_generation{0};
|
||||
|
||||
mutable std::mutex m_mtx;
|
||||
AVFrame* m_pending = nullptr;
|
||||
bool m_haveFrame = false;
|
||||
|
||||
AVFrame* m_displayed = nullptr;
|
||||
|
||||
AVFormatContext* m_fmt = nullptr;
|
||||
AVCodecContext* m_codec = nullptr;
|
||||
AVBufferRef* m_hwDeviceCtx = nullptr;
|
||||
int m_streamIndex = -1;
|
||||
|
||||
QSize m_texSize;
|
||||
int m_texComp = 1;
|
||||
|
||||
#ifdef ZHAVE_VAAPI
|
||||
EGLImageKHR m_imageY = EGL_NO_IMAGE_KHR;
|
||||
EGLImageKHR m_imageUV = EGL_NO_IMAGE_KHR;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace ZShell::wallpaper
|
||||
Reference in New Issue
Block a user