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,117 @@
|
||||
#include "videodecoder.hpp"
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#ifdef ZHAVE_VIDEO
|
||||
#include "nvidiaplayer.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef ZHAVE_FFMPEG
|
||||
#include "vaapiplayer.hpp"
|
||||
#endif
|
||||
|
||||
namespace ZShell::wallpaper {
|
||||
|
||||
VideoDecoder::~VideoDecoder() = default;
|
||||
|
||||
void VideoDecoder::setReadyCallback(std::function<void()> callback) {
|
||||
m_readyCb = std::move(callback);
|
||||
}
|
||||
|
||||
void VideoDecoder::setFrameCallback(std::function<void()> callback) {
|
||||
m_frameCb = std::move(callback);
|
||||
}
|
||||
|
||||
uint32_t VideoDecoder::textureId() const {
|
||||
return m_texY;
|
||||
}
|
||||
|
||||
uint32_t VideoDecoder::chromaTextureId() const {
|
||||
return m_texUV;
|
||||
}
|
||||
|
||||
int VideoDecoder::colorMatrix() const {
|
||||
return m_matrix;
|
||||
}
|
||||
|
||||
int VideoDecoder::colorRange() const {
|
||||
return m_range;
|
||||
}
|
||||
|
||||
QSize VideoDecoder::frameSize() const {
|
||||
return m_size;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
VideoBackend backendFromEnvironment() {
|
||||
if (qEnvironmentVariableIsSet("ZBAR_WALLPAPER_VAAPI"))
|
||||
return VideoBackend::Vaapi;
|
||||
if (qEnvironmentVariableIsSet("ZBAR_WALLPAPER_NVIDIA"))
|
||||
return VideoBackend::Nvidia;
|
||||
return VideoBackend::Auto;
|
||||
}
|
||||
|
||||
VideoBackend selectBackend(VideoBackend hint) {
|
||||
if (hint == VideoBackend::None) return VideoBackend::None;
|
||||
if (hint == VideoBackend::Auto) hint = backendFromEnvironment();
|
||||
|
||||
if (hint == VideoBackend::Nvidia) {
|
||||
#ifdef ZHAVE_VIDEO
|
||||
if (NvidiaPlayer::available()) return VideoBackend::Nvidia;
|
||||
#endif
|
||||
return VideoBackend::None;
|
||||
}
|
||||
|
||||
if (hint == VideoBackend::Vaapi) {
|
||||
#ifdef ZHAVE_FFMPEG
|
||||
if (VaapiPlayer::available()) return VideoBackend::Vaapi;
|
||||
#endif
|
||||
return VideoBackend::None;
|
||||
}
|
||||
|
||||
#ifdef ZHAVE_VIDEO
|
||||
if (NvidiaPlayer::available()) return VideoBackend::Nvidia;
|
||||
#endif
|
||||
|
||||
#ifdef ZHAVE_FFMPEG
|
||||
if (VaapiPlayer::available()) return VideoBackend::Vaapi;
|
||||
#endif
|
||||
|
||||
return VideoBackend::None;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
std::unique_ptr<VideoDecoder> createVideoDecoder(
|
||||
EGLDisplay display, VideoBackend hint) {
|
||||
switch (selectBackend(hint)) {
|
||||
#ifdef ZHAVE_VIDEO
|
||||
case VideoBackend::Nvidia:
|
||||
return std::make_unique<NvidiaPlayer>(display);
|
||||
#endif
|
||||
#ifdef ZHAVE_FFMPEG
|
||||
case VideoBackend::Vaapi:
|
||||
return std::make_unique<VaapiPlayer>(display);
|
||||
#endif
|
||||
case VideoBackend::Auto:
|
||||
case VideoBackend::None:
|
||||
break;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* resolveBackendName(VideoBackend hint) {
|
||||
switch (selectBackend(hint)) {
|
||||
case VideoBackend::Nvidia:
|
||||
return "nvidia";
|
||||
case VideoBackend::Vaapi:
|
||||
return "vaapi";
|
||||
case VideoBackend::Auto:
|
||||
case VideoBackend::None:
|
||||
break;
|
||||
}
|
||||
return "mpv";
|
||||
}
|
||||
|
||||
} // namespace ZShell::wallpaper
|
||||
Reference in New Issue
Block a user