mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
vo_opengl: hwdec: use IDs for API, and log which backend is used
Since there can be multiple backends for a single API (vaapi can use GLX or EGL), not logging the exact backend name is annoying. So add it. At the same time, there is no need to duplicate the name as used by the --hwdec options, so replace it with using the numeric hwdec API ID.
This commit is contained in:
@@ -57,13 +57,13 @@ static struct gl_hwdec *load_hwdec_driver(struct mp_log *log, GL *gl,
|
||||
struct gl_hwdec *hwdec = talloc(NULL, struct gl_hwdec);
|
||||
*hwdec = (struct gl_hwdec) {
|
||||
.driver = drv,
|
||||
.log = mp_log_new(hwdec, log, drv->api_name),
|
||||
.log = mp_log_new(hwdec, log, drv->name),
|
||||
.global = global,
|
||||
.gl = gl,
|
||||
.gl_texture_target = GL_TEXTURE_2D,
|
||||
.probing = is_auto,
|
||||
};
|
||||
mp_verbose(log, "Loading hwdec driver '%s'\n", drv->api_name);
|
||||
mp_verbose(log, "Loading hwdec driver '%s'\n", drv->name);
|
||||
if (hwdec->driver->create(hwdec) < 0) {
|
||||
talloc_free(hwdec);
|
||||
mp_verbose(log, "Loading failed.\n");
|
||||
@@ -72,13 +72,13 @@ static struct gl_hwdec *load_hwdec_driver(struct mp_log *log, GL *gl,
|
||||
return hwdec;
|
||||
}
|
||||
|
||||
struct gl_hwdec *gl_hwdec_load_api(struct mp_log *log, GL *gl,
|
||||
struct mpv_global *g, const char *api_name)
|
||||
struct gl_hwdec *gl_hwdec_load_api_id(struct mp_log *log, GL *gl,
|
||||
struct mpv_global *g, int id)
|
||||
{
|
||||
bool is_auto = api_name && strcmp(api_name, "auto") == 0;
|
||||
bool is_auto = id == HWDEC_AUTO;
|
||||
for (int n = 0; mpgl_hwdec_drivers[n]; n++) {
|
||||
const struct gl_hwdec_driver *drv = mpgl_hwdec_drivers[n];
|
||||
if (is_auto || (api_name && strcmp(drv->api_name, api_name) == 0)) {
|
||||
if (is_auto || id == drv->api) {
|
||||
struct gl_hwdec *r = load_hwdec_driver(log, gl, g, drv, is_auto);
|
||||
if (r)
|
||||
return r;
|
||||
@@ -87,11 +87,17 @@ struct gl_hwdec *gl_hwdec_load_api(struct mp_log *log, GL *gl,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Like gl_hwdec_load_api(), but use HWDEC_... identifiers.
|
||||
struct gl_hwdec *gl_hwdec_load_api_id(struct mp_log *log, GL *gl,
|
||||
struct mpv_global *g, int id)
|
||||
// Like gl_hwdec_load_api_id(), but use option names.
|
||||
struct gl_hwdec *gl_hwdec_load_api(struct mp_log *log, GL *gl,
|
||||
struct mpv_global *g, const char *api_name)
|
||||
{
|
||||
return gl_hwdec_load_api(log, gl, g, m_opt_choice_str(mp_hwdec_names, id));
|
||||
int id = HWDEC_NONE;
|
||||
for (const struct m_opt_choice_alternatives *c = mp_hwdec_names; c->name; c++)
|
||||
{
|
||||
if (strcmp(c->name, api_name) == 0)
|
||||
id = c->value;
|
||||
}
|
||||
return gl_hwdec_load_api_id(log, gl, g, id);
|
||||
}
|
||||
|
||||
void gl_hwdec_uninit(struct gl_hwdec *hwdec)
|
||||
|
||||
@@ -27,8 +27,10 @@ struct gl_hwdec {
|
||||
};
|
||||
|
||||
struct gl_hwdec_driver {
|
||||
// Same name as used by mp_hwdec_info->load_api()
|
||||
const char *api_name;
|
||||
// Name of the interop backend. This is used for logging only.
|
||||
const char *name;
|
||||
// Used to explicitly request a specific API.
|
||||
enum hwdec_type api;
|
||||
// The hardware surface IMGFMT_ that must be passed to map_image later.
|
||||
int imgfmt;
|
||||
// Create the hwdec device. It must fill in hw->info, if applicable.
|
||||
|
||||
@@ -55,7 +55,8 @@ static int map_image(struct gl_hwdec *hw, struct mp_image *hw_image,
|
||||
}
|
||||
|
||||
const struct gl_hwdec_driver gl_hwdec_dxva2 = {
|
||||
.api_name = "dxva2",
|
||||
.name = "dxva2-dummy",
|
||||
.api = HWDEC_DXVA2_COPY,
|
||||
.imgfmt = -1,
|
||||
.create = create,
|
||||
.reinit = reinit,
|
||||
|
||||
@@ -237,7 +237,8 @@ static void destroy(struct gl_hwdec *hw)
|
||||
}
|
||||
|
||||
const struct gl_hwdec_driver gl_hwdec_videotoolbox = {
|
||||
.api_name = "videotoolbox",
|
||||
.name = "videotoolbox",
|
||||
.api = HWDEC_VIDEOTOOLBOX,
|
||||
.imgfmt = IMGFMT_VIDEOTOOLBOX,
|
||||
.create = create,
|
||||
.reinit = reinit,
|
||||
|
||||
@@ -401,7 +401,8 @@ static bool test_format(struct gl_hwdec *hw)
|
||||
}
|
||||
|
||||
const struct gl_hwdec_driver gl_hwdec_vaegl = {
|
||||
.api_name = "vaapi",
|
||||
.name = "vaapi-egl",
|
||||
.api = HWDEC_VAAPI,
|
||||
.imgfmt = IMGFMT_VAAPI,
|
||||
.create = create,
|
||||
.reinit = reinit,
|
||||
|
||||
@@ -194,7 +194,8 @@ static int map_image(struct gl_hwdec *hw, struct mp_image *hw_image,
|
||||
}
|
||||
|
||||
const struct gl_hwdec_driver gl_hwdec_vaglx = {
|
||||
.api_name = "vaapi",
|
||||
.name = "vaapi-glx",
|
||||
.api = HWDEC_VAAPI,
|
||||
.imgfmt = IMGFMT_VAAPI,
|
||||
.create = create,
|
||||
.reinit = reinit,
|
||||
|
||||
@@ -200,7 +200,8 @@ static int map_image(struct gl_hwdec *hw, struct mp_image *hw_image,
|
||||
}
|
||||
|
||||
const struct gl_hwdec_driver gl_hwdec_vdpau = {
|
||||
.api_name = "vdpau",
|
||||
.name = "vdpau-glx",
|
||||
.api = HWDEC_VDPAU,
|
||||
.imgfmt = IMGFMT_VDPAU,
|
||||
.create = create,
|
||||
.reinit = reinit,
|
||||
|
||||
Reference in New Issue
Block a user