summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/hwdec.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-05-09 19:42:03 +0200
committerwm4 <wm4@nowhere>2016-05-09 20:03:22 +0200
commit46fff8d31af0b79fe3de4aaee93bb66c248118a0 (patch)
treeefe5b04a4e9daf89195a4c758fe93ace9bee385f /video/out/opengl/hwdec.c
parentee4c00698f7e4b04579494f262e668840c2668b3 (diff)
downloadmpv-46fff8d31af0b79fe3de4aaee93bb66c248118a0.tar.bz2
mpv-46fff8d31af0b79fe3de4aaee93bb66c248118a0.tar.xz
video: refactor how VO exports hwdec device handles
The main change is with video/hwdec.h. mp_hwdec_info is made opaque (and renamed to mp_hwdec_devices). Its accessors are mainly thread-safe (or documented where not), which makes the whole thing saner and cleaner. In particular, thread-safety rules become less subtle and more obvious. The new internal API makes it easier to support multiple OpenGL interop backends. (Although this is not done yet, and it's not clear whether it ever will.) This also removes all the API-specific fields from mp_hwdec_ctx and replaces them with a "ctx" field. For d3d in particular, we drop the mp_d3d_ctx struct completely, and pass the interfaces directly. Remove the emulation checks from vaapi.c and vdpau.c; they are pointless, and the checks that matter are done on the VO layer. The d3d hardware decoders might slightly change behavior: dxva2-copy will not use the VO device anymore if the VO supports proper interop. This pretty much assumes that any in such cases the VO will not use any form of exclusive mode, which makes using the VO device in copy mode unnecessary. This is a big refactor. Some things may be untested and could be broken.
Diffstat (limited to 'video/out/opengl/hwdec.c')
-rw-r--r--video/out/opengl/hwdec.c29
1 files changed, 9 insertions, 20 deletions
diff --git a/video/out/opengl/hwdec.c b/video/out/opengl/hwdec.c
index 9c3bec1a0f..b4b5c23580 100644
--- a/video/out/opengl/hwdec.c
+++ b/video/out/opengl/hwdec.c
@@ -61,6 +61,7 @@ static const struct gl_hwdec_driver *const mpgl_hwdec_drivers[] = {
static struct gl_hwdec *load_hwdec_driver(struct mp_log *log, GL *gl,
struct mpv_global *global,
+ struct mp_hwdec_devices *devs,
const struct gl_hwdec_driver *drv,
bool is_auto)
{
@@ -70,6 +71,7 @@ static struct gl_hwdec *load_hwdec_driver(struct mp_log *log, GL *gl,
.log = mp_log_new(hwdec, log, drv->name),
.global = global,
.gl = gl,
+ .devs = devs,
.gl_texture_target = GL_TEXTURE_2D,
.probing = is_auto,
};
@@ -79,19 +81,19 @@ static struct gl_hwdec *load_hwdec_driver(struct mp_log *log, GL *gl,
mp_verbose(log, "Loading failed.\n");
return NULL;
}
- if (hwdec->hwctx && !hwdec->hwctx->driver_name)
- hwdec->hwctx->driver_name = hwdec->driver->name;
return hwdec;
}
-struct gl_hwdec *gl_hwdec_load_api_id(struct mp_log *log, GL *gl,
- struct mpv_global *g, int id)
+struct gl_hwdec *gl_hwdec_load_api(struct mp_log *log, GL *gl,
+ struct mpv_global *g,
+ struct mp_hwdec_devices *devs,
+ enum hwdec_type api)
{
- bool is_auto = id == HWDEC_AUTO;
+ bool is_auto = api == HWDEC_AUTO;
for (int n = 0; mpgl_hwdec_drivers[n]; n++) {
const struct gl_hwdec_driver *drv = mpgl_hwdec_drivers[n];
- if (is_auto || id == drv->api) {
- struct gl_hwdec *r = load_hwdec_driver(log, gl, g, drv, is_auto);
+ if (is_auto || api == drv->api) {
+ struct gl_hwdec *r = load_hwdec_driver(log, gl, g, devs, drv, is_auto);
if (r)
return r;
}
@@ -99,19 +101,6 @@ struct gl_hwdec *gl_hwdec_load_api_id(struct mp_log *log, GL *gl,
return NULL;
}
-// 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)
-{
- 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)
{
if (hwdec)