зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1660336 Implement FFmpegLibWrapper::LinkVAAPILibs() to link VAAPI libraries and use at at FFmpegRuntimeLinker/FFVPXRuntimeLinker, r=jya
Depends on D90555 Differential Revision: https://phabricator.services.mozilla.com/D90556
This commit is contained in:
Родитель
46886a9bae
Коммит
ece6b57b31
|
@ -11,6 +11,10 @@
|
|||
#include "mozilla/Types.h"
|
||||
#include "PlatformDecoderModule.h"
|
||||
#include "prlink.h"
|
||||
#ifdef MOZ_WAYLAND
|
||||
# include "mozilla/widget/DMABufLibWrapper.h"
|
||||
# include "mozilla/StaticPrefs_media.h"
|
||||
#endif
|
||||
|
||||
#define AV_LOG_DEBUG 48
|
||||
#define AV_LOG_INFO 32
|
||||
|
@ -253,6 +257,46 @@ void FFmpegLibWrapper::Unlink() {
|
|||
PodZero(this);
|
||||
}
|
||||
|
||||
#ifdef MOZ_WAYLAND
|
||||
void FFmpegLibWrapper::LinkVAAPILibs() {
|
||||
if (widget::GetDMABufDevice()->IsDMABufVAAPIEnabled()) {
|
||||
PRLibSpec lspec;
|
||||
lspec.type = PR_LibSpec_Pathname;
|
||||
const char* libDrm = "libva-drm.so.2";
|
||||
lspec.value.pathname = libDrm;
|
||||
mVALibDrm = PR_LoadLibraryWithFlags(lspec, PR_LD_NOW | PR_LD_LOCAL);
|
||||
if (!mVALibDrm) {
|
||||
FFMPEG_LOG("VA-API support: Missing or old %s library.\n", libDrm);
|
||||
}
|
||||
|
||||
if (!StaticPrefs::media_ffmpeg_vaapi_drm_display_enabled()) {
|
||||
const char* libWayland = "libva-wayland.so.2";
|
||||
lspec.value.pathname = libWayland;
|
||||
mVALibWayland = PR_LoadLibraryWithFlags(lspec, PR_LD_NOW | PR_LD_LOCAL);
|
||||
if (!mVALibWayland) {
|
||||
FFMPEG_LOG("VA-API support: Missing or old %s library.\n", libWayland);
|
||||
}
|
||||
}
|
||||
|
||||
if (mVALibWayland || mVALibDrm) {
|
||||
const char* lib = "libva.so.2";
|
||||
lspec.value.pathname = lib;
|
||||
mVALib = PR_LoadLibraryWithFlags(lspec, PR_LD_NOW | PR_LD_LOCAL);
|
||||
// Don't use libva when it's missing vaExportSurfaceHandle.
|
||||
if (mVALib && !PR_FindSymbol(mVALib, "vaExportSurfaceHandle")) {
|
||||
PR_UnloadLibrary(mVALib);
|
||||
mVALib = nullptr;
|
||||
}
|
||||
if (!mVALib) {
|
||||
FFMPEG_LOG("VA-API support: Missing or old %s library.\n", lib);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
FFMPEG_LOG("VA-API FFmpeg is disabled by platform");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WAYLAND
|
||||
bool FFmpegLibWrapper::IsVAAPIAvailable() {
|
||||
# define VA_FUNC_LOADED(func) (func != nullptr)
|
||||
|
|
|
@ -56,6 +56,7 @@ struct MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS FFmpegLibWrapper {
|
|||
#ifdef MOZ_WAYLAND
|
||||
// Check if mVALib are available and we can use HW decode.
|
||||
bool IsVAAPIAvailable();
|
||||
void LinkVAAPILibs();
|
||||
#endif
|
||||
|
||||
// indicate the version of libavcodec linked to.
|
||||
|
|
|
@ -9,10 +9,6 @@
|
|||
#include "mozilla/ArrayUtils.h"
|
||||
#include "FFmpegLog.h"
|
||||
#include "prlink.h"
|
||||
#ifdef MOZ_WAYLAND
|
||||
# include "mozilla/widget/DMABufLibWrapper.h"
|
||||
# include "mozilla/StaticPrefs_media.h"
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -58,43 +54,7 @@ bool FFmpegRuntimeLinker::Init() {
|
|||
}
|
||||
|
||||
#ifdef MOZ_WAYLAND
|
||||
if (widget::GetDMABufDevice()->IsDMABufVAAPIEnabled()) {
|
||||
PRLibSpec lspec;
|
||||
lspec.type = PR_LibSpec_Pathname;
|
||||
const char* libDrm = "libva-drm.so.2";
|
||||
lspec.value.pathname = libDrm;
|
||||
sLibAV.mVALibDrm = PR_LoadLibraryWithFlags(lspec, PR_LD_NOW | PR_LD_LOCAL);
|
||||
if (!sLibAV.mVALibDrm) {
|
||||
FFMPEG_LOG("VA-API support: Missing or old %s library.\n", libDrm);
|
||||
}
|
||||
|
||||
if (!StaticPrefs::media_ffmpeg_vaapi_drm_display_enabled()) {
|
||||
const char* libWayland = "libva-wayland.so.2";
|
||||
lspec.value.pathname = libWayland;
|
||||
sLibAV.mVALibWayland =
|
||||
PR_LoadLibraryWithFlags(lspec, PR_LD_NOW | PR_LD_LOCAL);
|
||||
if (!sLibAV.mVALibWayland) {
|
||||
FFMPEG_LOG("VA-API support: Missing or old %s library.\n", libWayland);
|
||||
}
|
||||
}
|
||||
|
||||
if (sLibAV.mVALibWayland || sLibAV.mVALibDrm) {
|
||||
const char* lib = "libva.so.2";
|
||||
lspec.value.pathname = lib;
|
||||
sLibAV.mVALib = PR_LoadLibraryWithFlags(lspec, PR_LD_NOW | PR_LD_LOCAL);
|
||||
// Don't use libva when it's missing vaExportSurfaceHandle.
|
||||
if (sLibAV.mVALib &&
|
||||
!PR_FindSymbol(sLibAV.mVALib, "vaExportSurfaceHandle")) {
|
||||
PR_UnloadLibrary(sLibAV.mVALib);
|
||||
sLibAV.mVALib = nullptr;
|
||||
}
|
||||
if (!sLibAV.mVALib) {
|
||||
FFMPEG_LOG("VA-API support: Missing or old %s library.\n", lib);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
FFMPEG_LOG("VA-API FFmpeg is disabled by platform");
|
||||
}
|
||||
sLibAV.LinkVAAPILibs();
|
||||
#endif
|
||||
|
||||
// While going through all possible libs, this status will be updated with a
|
||||
|
|
|
@ -64,6 +64,10 @@ bool FFVPXRuntimeLinker::Init() {
|
|||
MOZ_ASSERT(NS_IsMainThread());
|
||||
sLinkStatus = LinkStatus_FAILED;
|
||||
|
||||
#ifdef MOZ_WAYLAND
|
||||
sFFVPXLib.LinkVAAPILibs();
|
||||
#endif
|
||||
|
||||
// We retrieve the path of the lgpllibs library as this is where mozavcodec
|
||||
// and mozavutil libs are located.
|
||||
PathString lgpllibsname = GetLibraryName(nullptr, "lgpllibs");
|
||||
|
|
Загрузка…
Ссылка в новой задаче