diff options
Diffstat (limited to 'video/out/opengl/hwdec.c')
-rw-r--r-- | video/out/opengl/hwdec.c | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/video/out/opengl/hwdec.c b/video/out/opengl/hwdec.c index 3c3a9785a6..300197ac00 100644 --- a/video/out/opengl/hwdec.c +++ b/video/out/opengl/hwdec.c @@ -1,23 +1,18 @@ /* * This file is part of mpv. * - * mpv is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * mpv is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * * mpv is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with mpv. If not, see <http://www.gnu.org/licenses/>. - * - * You can alternatively redistribute this file and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * You should have received a copy of the GNU Lesser General Public + * License along with mpv. If not, see <http://www.gnu.org/licenses/>. */ #include <stddef.h> @@ -33,6 +28,7 @@ extern const struct gl_hwdec_driver gl_hwdec_vaegl; extern const struct gl_hwdec_driver gl_hwdec_vaglx; extern const struct gl_hwdec_driver gl_hwdec_videotoolbox; extern const struct gl_hwdec_driver gl_hwdec_vdpau; +extern const struct gl_hwdec_driver gl_hwdec_dxva2gldx; extern const struct gl_hwdec_driver gl_hwdec_dxva2; static const struct gl_hwdec_driver *const mpgl_hwdec_drivers[] = { @@ -49,6 +45,9 @@ static const struct gl_hwdec_driver *const mpgl_hwdec_drivers[] = { &gl_hwdec_videotoolbox, #endif #if HAVE_DXVA2_HWACCEL +#if HAVE_GL_DXINTEROP + &gl_hwdec_dxva2gldx, +#endif &gl_hwdec_dxva2, #endif NULL @@ -62,13 +61,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"); @@ -77,13 +76,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; @@ -92,11 +91,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) |