summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-02-01 20:02:52 +0100
committerwm4 <wm4@nowhere>2016-02-01 20:02:52 +0100
commit05ffde6599fde77cf3e5cd6e244063563f88c112 (patch)
treee457d31f4c937605da5958754da62d8b4f4f8c48 /video
parenta9dfd8d557b1651e6d9ae7a374426dbcd856da99 (diff)
downloadmpv-05ffde6599fde77cf3e5cd6e244063563f88c112.tar.bz2
mpv-05ffde6599fde77cf3e5cd6e244063563f88c112.tar.xz
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.
Diffstat (limited to 'video')
-rw-r--r--video/out/opengl/hwdec.c26
-rw-r--r--video/out/opengl/hwdec.h6
-rw-r--r--video/out/opengl/hwdec_dxva2.c3
-rw-r--r--video/out/opengl/hwdec_osx.c3
-rw-r--r--video/out/opengl/hwdec_vaegl.c3
-rw-r--r--video/out/opengl/hwdec_vaglx.c3
-rw-r--r--video/out/opengl/hwdec_vdpau.c3
7 files changed, 30 insertions, 17 deletions
diff --git a/video/out/opengl/hwdec.c b/video/out/opengl/hwdec.c
index f0e8994fe8..6afc9b6efd 100644
--- a/video/out/opengl/hwdec.c
+++ b/video/out/opengl/hwdec.c
@@ -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)
diff --git a/video/out/opengl/hwdec.h b/video/out/opengl/hwdec.h
index ac1771c28d..c04962dd76 100644
--- a/video/out/opengl/hwdec.h
+++ b/video/out/opengl/hwdec.h
@@ -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.
diff --git a/video/out/opengl/hwdec_dxva2.c b/video/out/opengl/hwdec_dxva2.c
index aba442b653..f72c817a20 100644
--- a/video/out/opengl/hwdec_dxva2.c
+++ b/video/out/opengl/hwdec_dxva2.c
@@ -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,
diff --git a/video/out/opengl/hwdec_osx.c b/video/out/opengl/hwdec_osx.c
index 53f9781bc9..78d01b3894 100644
--- a/video/out/opengl/hwdec_osx.c
+++ b/video/out/opengl/hwdec_osx.c
@@ -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,
diff --git a/video/out/opengl/hwdec_vaegl.c b/video/out/opengl/hwdec_vaegl.c
index 9d37697581..7b34d6bb5c 100644
--- a/video/out/opengl/hwdec_vaegl.c
+++ b/video/out/opengl/hwdec_vaegl.c
@@ -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,
diff --git a/video/out/opengl/hwdec_vaglx.c b/video/out/opengl/hwdec_vaglx.c
index ff97d14857..77b1f27c51 100644
--- a/video/out/opengl/hwdec_vaglx.c
+++ b/video/out/opengl/hwdec_vaglx.c
@@ -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,
diff --git a/video/out/opengl/hwdec_vdpau.c b/video/out/opengl/hwdec_vdpau.c
index f6f9367980..2396d8ad5d 100644
--- a/video/out/opengl/hwdec_vdpau.c
+++ b/video/out/opengl/hwdec_vdpau.c
@@ -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,