1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-25 16:33:02 +00:00
mpv/video/out/placebo/utils.c
Niklas Haas 7006d6752d vo_gpu: vulkan: use libplacebo instead
This commit rips out the entire mpv vulkan implementation in favor of
exposing lightweight wrappers on top of libplacebo instead, which
provides much of the same except in a more up-to-date and polished form.

This (finally) unifies the code base between mpv and libplacebo, which
is something I've been hoping to do for a long time.

Note: The ra_pl wrappers are abstract enough from the actual libplacebo
device type that we can in theory re-use them for other devices like
d3d11 or even opengl in the future, so I moved them to a separate
directory for the time being. However, the rest of the code is still
vulkan-specific, so I've kept the "vulkan" naming and file paths, rather
than introducing a new `--gpu-api` type. (Which would have been ended up
with significantly more code duplicaiton)

Plus, the code and functionality is similar enough that for most users
this should just be a straight-up drop-in replacement.

Note: This commit excludes some changes; specifically, the updates to
context_win and hwdec_cuda are deferred to separate commits for
authorship reasons.
2019-04-21 23:55:22 +03:00

63 lines
1.6 KiB
C

#include "common/common.h"
#include "utils.h"
static const int pl_log_to_msg_lev[PL_LOG_ALL+1] = {
[PL_LOG_FATAL] = MSGL_FATAL,
[PL_LOG_ERR] = MSGL_ERR,
[PL_LOG_WARN] = MSGL_WARN,
[PL_LOG_INFO] = MSGL_V,
[PL_LOG_DEBUG] = MSGL_DEBUG,
[PL_LOG_TRACE] = MSGL_TRACE,
};
static const enum pl_log_level msg_lev_to_pl_log[MSGL_MAX+1] = {
[MSGL_FATAL] = PL_LOG_FATAL,
[MSGL_ERR] = PL_LOG_ERR,
[MSGL_WARN] = PL_LOG_WARN,
[MSGL_INFO] = PL_LOG_WARN,
[MSGL_STATUS] = PL_LOG_WARN,
[MSGL_V] = PL_LOG_INFO,
[MSGL_DEBUG] = PL_LOG_DEBUG,
[MSGL_TRACE] = PL_LOG_TRACE,
[MSGL_MAX] = PL_LOG_ALL,
};
// translates log levels while probing
static const enum pl_log_level probing_map(enum pl_log_level level)
{
switch (level) {
case PL_LOG_FATAL:
return PL_LOG_ERR;
case PL_LOG_ERR:
case PL_LOG_WARN:
return PL_LOG_INFO;
default:
return level;
}
}
static void log_cb(void *priv, enum pl_log_level level, const char *msg)
{
struct mp_log *log = priv;
mp_msg(log, pl_log_to_msg_lev[level], "%s\n", msg);
}
static void log_cb_probing(void *priv, enum pl_log_level level, const char *msg)
{
struct mp_log *log = priv;
mp_msg(log, pl_log_to_msg_lev[probing_map(level)], "%s\n", msg);
}
void mppl_ctx_set_log(struct pl_context *ctx, struct mp_log *log, bool probing)
{
assert(log);
pl_context_update(ctx, &(struct pl_context_params) {
.log_cb = probing ? log_cb_probing : log_cb,
.log_level = msg_lev_to_pl_log[mp_msg_level(log)],
.log_priv = log,
});
}