summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-01-22 15:32:23 +0100
committerwm4 <wm4@nowhere>2015-01-22 15:32:23 +0100
commitaae9af348e62d5feba6547855003df0d954cb3ae (patch)
treedd0d28655c65e1f814bec3ef537ea377a941b9b7 /video/out
parent29cf62d20133b32e1514a315b4f7e013ed9cb768 (diff)
downloadmpv-aae9af348e62d5feba6547855003df0d954cb3ae.tar.bz2
mpv-aae9af348e62d5feba6547855003df0d954cb3ae.tar.xz
video: have a generic context struct for hwdec backends
Before this commit, each hw backend had their own specific struct types for context, and some, like VDA, had none at all. Add a context struct (mp_hwdec_ctx) that provides a somewhat generic way to pass the hwdec context around. Some things get slightly better, some slightly more verbose. mp_hwdec_info is still around; it's still needed, but is reduced to its role of handling delayed loading of the hwdec backend.
Diffstat (limited to 'video/out')
-rw-r--r--video/out/gl_hwdec.c7
-rw-r--r--video/out/gl_hwdec.h5
-rw-r--r--video/out/gl_hwdec_vaglx.c6
-rw-r--r--video/out/gl_hwdec_vdpau.c6
-rw-r--r--video/out/vo_opengl.c4
-rw-r--r--video/out/vo_opengl_cb.c5
-rw-r--r--video/out/vo_vaapi.c2
-rw-r--r--video/out/vo_vdpau.c2
8 files changed, 16 insertions, 21 deletions
diff --git a/video/out/gl_hwdec.c b/video/out/gl_hwdec.c
index 3bab1c1e9c..7b8adb4fc4 100644
--- a/video/out/gl_hwdec.c
+++ b/video/out/gl_hwdec.c
@@ -49,7 +49,6 @@ static const struct gl_hwdec_driver *const mpgl_hwdec_drivers[] = {
static struct gl_hwdec *load_hwdec_driver(struct mp_log *log, GL *gl,
const struct gl_hwdec_driver *drv,
- struct mp_hwdec_info *info,
bool is_auto)
{
struct gl_hwdec *hwdec = talloc(NULL, struct gl_hwdec);
@@ -57,7 +56,6 @@ static struct gl_hwdec *load_hwdec_driver(struct mp_log *log, GL *gl,
.driver = drv,
.log = mp_log_new(hwdec, log, drv->api_name),
.gl = gl,
- .info = info,
.gl_texture_target = GL_TEXTURE_2D,
.reject_emulated = is_auto,
};
@@ -70,14 +68,13 @@ static struct gl_hwdec *load_hwdec_driver(struct mp_log *log, GL *gl,
}
struct gl_hwdec *gl_hwdec_load_api(struct mp_log *log, GL *gl,
- const char *api_name,
- struct mp_hwdec_info *info)
+ const char *api_name)
{
bool is_auto = api_name && strcmp(api_name, "auto") == 0;
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)) {
- struct gl_hwdec *r = load_hwdec_driver(log, gl, drv, info, is_auto);
+ struct gl_hwdec *r = load_hwdec_driver(log, gl, drv, is_auto);
if (r)
return r;
}
diff --git a/video/out/gl_hwdec.h b/video/out/gl_hwdec.h
index ea10ac08f8..8d2f563d5e 100644
--- a/video/out/gl_hwdec.h
+++ b/video/out/gl_hwdec.h
@@ -10,7 +10,7 @@ struct gl_hwdec {
const struct gl_hwdec_driver *driver;
struct mp_log *log;
GL *gl;
- struct mp_hwdec_info *info;
+ struct mp_hwdec_ctx *hwctx;
// For free use by hwdec driver
void *priv;
// For working around the vdpau vs. vaapi mess.
@@ -50,8 +50,7 @@ struct gl_hwdec_driver {
};
struct gl_hwdec *gl_hwdec_load_api(struct mp_log *log, GL *gl,
- const char *api_name,
- struct mp_hwdec_info *info);
+ const char *api_name);
void gl_hwdec_uninit(struct gl_hwdec *hwdec);
diff --git a/video/out/gl_hwdec_vaglx.c b/video/out/gl_hwdec_vaglx.c
index 555e61aec3..f9dc42911d 100644
--- a/video/out/gl_hwdec_vaglx.c
+++ b/video/out/gl_hwdec_vaglx.c
@@ -58,13 +58,11 @@ static void destroy(struct gl_hwdec *hw)
struct priv *p = hw->priv;
destroy_texture(hw);
va_destroy(p->ctx);
-
- hw->info->vaapi_ctx = NULL;
}
static int create(struct gl_hwdec *hw)
{
- if (hw->info->vaapi_ctx)
+ if (hw->hwctx)
return -1;
Display *x11disp = glXGetCurrentDisplay();
if (!x11disp)
@@ -84,7 +82,7 @@ static int create(struct gl_hwdec *hw)
destroy(hw);
return -1;
}
- hw->info->vaapi_ctx = p->ctx;
+ hw->hwctx = &p->ctx->hwctx;
hw->converted_imgfmt = IMGFMT_RGB0;
return 0;
}
diff --git a/video/out/gl_hwdec_vdpau.c b/video/out/gl_hwdec_vdpau.c
index c59d97bc1b..49f8e7c7b5 100644
--- a/video/out/gl_hwdec_vdpau.c
+++ b/video/out/gl_hwdec_vdpau.c
@@ -87,14 +87,12 @@ static void destroy(struct gl_hwdec *hw)
destroy_objects(hw);
mp_vdpau_mixer_destroy(p->mixer);
mp_vdpau_destroy(p->ctx);
-
- hw->info->vdpau_ctx = NULL;
}
static int create(struct gl_hwdec *hw)
{
GL *gl = hw->gl;
- if (hw->info->vdpau_ctx)
+ if (hw->hwctx)
return -1;
Display *x11disp = glXGetCurrentDisplay();
if (!x11disp)
@@ -115,7 +113,7 @@ static int create(struct gl_hwdec *hw)
destroy(hw);
return -1;
}
- hw->info->vdpau_ctx = p->ctx;
+ hw->hwctx = &p->ctx->hwctx;
hw->converted_imgfmt = IMGFMT_RGB0;
return 0;
}
diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c
index bfb1adbec8..058b305c2f 100644
--- a/video/out/vo_opengl.c
+++ b/video/out/vo_opengl.c
@@ -224,8 +224,10 @@ static void request_hwdec_api(struct gl_priv *p, const char *api_name)
if (p->hwdec)
return;
mpgl_lock(p->glctx);
- p->hwdec = gl_hwdec_load_api(p->vo->log, p->gl, api_name, &p->hwdec_info);
+ p->hwdec = gl_hwdec_load_api(p->vo->log, p->gl, api_name);
gl_video_set_hwdec(p->renderer, p->hwdec);
+ if (p->hwdec)
+ p->hwdec_info.hwctx = p->hwdec->hwctx;
mpgl_unlock(p->glctx);
}
diff --git a/video/out/vo_opengl_cb.c b/video/out/vo_opengl_cb.c
index 3d5c16d8f2..1a2e44f718 100644
--- a/video/out/vo_opengl_cb.c
+++ b/video/out/vo_opengl_cb.c
@@ -227,9 +227,10 @@ int mpv_opengl_cb_init_gl(struct mpv_opengl_cb_context *ctx, const char *exts,
if (!ctx->renderer)
return MPV_ERROR_UNSUPPORTED;
- ctx->hwdec = gl_hwdec_load_api(ctx->log, ctx->gl, ctx->hwapi, &ctx->hwdec_info);
+ ctx->hwdec = gl_hwdec_load_api(ctx->log, ctx->gl, ctx->hwapi);
gl_video_set_hwdec(ctx->renderer, ctx->hwdec);
-
+ if (ctx->hwdec)
+ ctx->hwdec_info.hwctx = ctx->hwdec->hwctx;
pthread_mutex_lock(&ctx->lock);
ctx->eq = *gl_video_eq_ptr(ctx->renderer);
diff --git a/video/out/vo_vaapi.c b/video/out/vo_vaapi.c
index 21e604f235..cf07787a48 100644
--- a/video/out/vo_vaapi.c
+++ b/video/out/vo_vaapi.c
@@ -609,7 +609,7 @@ static int preinit(struct vo *vo)
goto fail;
}
- p->hwdec_info.vaapi_ctx = p->mpvaapi;
+ p->hwdec_info.hwctx = &p->mpvaapi->hwctx;
if (va_guess_if_emulated(p->mpvaapi)) {
MP_WARN(vo, "VA-API is most likely emulated via VDPAU.\n"
diff --git a/video/out/vo_vdpau.c b/video/out/vo_vdpau.c
index 640e16e1a8..a022946c1b 100644
--- a/video/out/vo_vdpau.c
+++ b/video/out/vo_vdpau.c
@@ -988,7 +988,7 @@ static int preinit(struct vo *vo)
return -1;
}
- vc->hwdec_info.vdpau_ctx = vc->mpvdp;
+ vc->hwdec_info.hwctx = &vc->mpvdp->hwctx;
vc->video_mixer = mp_vdpau_mixer_create(vc->mpvdp, vo->log);