summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-07-07 14:53:58 +0200
committerwm4 <wm4@nowhere>2015-07-07 15:05:32 +0200
commit92727e7332cd8c9237552675fd8e8dba9b1a4127 (patch)
treeca66eb301794513652a994eeb3bd0eb56cb4b1c0 /video
parent1d29177c5c150e700cace0c875185c6fa5e92d3c (diff)
downloadmpv-92727e7332cd8c9237552675fd8e8dba9b1a4127.tar.bz2
mpv-92727e7332cd8c9237552675fd8e8dba9b1a4127.tar.xz
vo_opengl_cb, vo_opengl: add option for preloading hwdec context
See manpage additions. This is mainly useful for vo_opengl_cb, but can also be applied to vo_opengl. On a side note, gl_hwdec_load_api() should stop using a name string, and instead always use the IDs. This should be cleaned up another time.
Diffstat (limited to 'video')
-rw-r--r--video/out/gl_hwdec.c6
-rw-r--r--video/out/gl_hwdec.h1
-rw-r--r--video/out/vo_opengl.c8
-rw-r--r--video/out/vo_opengl_cb.c20
4 files changed, 21 insertions, 14 deletions
diff --git a/video/out/gl_hwdec.c b/video/out/gl_hwdec.c
index ba15950129..f491694e48 100644
--- a/video/out/gl_hwdec.c
+++ b/video/out/gl_hwdec.c
@@ -86,6 +86,12 @@ 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, int id)
+{
+ return gl_hwdec_load_api(log, gl, m_opt_choice_str(mp_hwdec_names, id));
+}
+
void gl_hwdec_uninit(struct gl_hwdec *hwdec)
{
if (hwdec)
diff --git a/video/out/gl_hwdec.h b/video/out/gl_hwdec.h
index e60218ff88..f2b3fd5787 100644
--- a/video/out/gl_hwdec.h
+++ b/video/out/gl_hwdec.h
@@ -46,6 +46,7 @@ struct gl_hwdec_driver {
struct gl_hwdec *gl_hwdec_load_api(struct mp_log *log, GL *gl,
const char *api_name);
+struct gl_hwdec *gl_hwdec_load_api_id(struct mp_log *log, GL *gl, int id);
void gl_hwdec_uninit(struct gl_hwdec *hwdec);
diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c
index 043ddaa836..b25d162d7b 100644
--- a/video/out/vo_opengl.c
+++ b/video/out/vo_opengl.c
@@ -440,6 +440,14 @@ static int preinit(struct vo *vo)
p->hwdec_info.load_api = call_request_hwdec_api;
p->hwdec_info.load_api_ctx = vo;
+ if (vo->opts->hwdec_preload_api != HWDEC_NONE) {
+ p->hwdec =
+ gl_hwdec_load_api_id(p->vo->log, p->gl, vo->opts->hwdec_preload_api);
+ gl_video_set_hwdec(p->renderer, p->hwdec);
+ if (p->hwdec)
+ p->hwdec_info.hwctx = p->hwdec->hwctx;
+ }
+
return 0;
err_out:
diff --git a/video/out/vo_opengl_cb.c b/video/out/vo_opengl_cb.c
index 217e15d76a..35241de207 100644
--- a/video/out/vo_opengl_cb.c
+++ b/video/out/vo_opengl_cb.c
@@ -83,6 +83,8 @@ struct mpv_opengl_cb_context {
int64_t recent_flip;
int64_t approx_vsync;
bool frozen; // libmpv user is not redrawing frames
+ struct vo *active;
+ int hwdec_api;
// --- All of these can only be accessed from the thread where the host
// application's OpenGL context is current - i.e. only while the
@@ -91,12 +93,6 @@ struct mpv_opengl_cb_context {
struct gl_video *renderer;
struct gl_hwdec *hwdec;
struct mp_hwdec_info hwdec_info; // it's also semi-immutable after init
-
- // --- Immutable or semi-threadsafe.
-
- const char *hwapi;
-
- struct vo *active;
};
static void update(struct vo_priv *p);
@@ -194,13 +190,9 @@ struct mpv_opengl_cb_context *mp_opengl_create(struct mpv_global *g,
ctx->log = mp_log_new(ctx, g->log, "opengl-cb");
ctx->client_api = client_api;
- switch (g->opts->hwdec_api) {
- case HWDEC_AUTO: ctx->hwapi = "auto"; break;
- case HWDEC_VDPAU: ctx->hwapi = "vdpau"; break;
- case HWDEC_VDA: ctx->hwapi = "vda"; break;
- case HWDEC_VAAPI: ctx->hwapi = "vaapi"; break;
- default: ctx->hwapi = "";
- }
+ ctx->hwdec_api = g->opts->vo.hwdec_preload_api;
+ if (ctx->hwdec_api == HWDEC_NONE)
+ ctx->hwdec_api = g->opts->hwdec_api;
return ctx;
}
@@ -243,7 +235,7 @@ 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 = gl_hwdec_load_api_id(ctx->log, ctx->gl, ctx->hwdec_api);
gl_video_set_hwdec(ctx->renderer, ctx->hwdec);
if (ctx->hwdec)
ctx->hwdec_info.hwctx = ctx->hwdec->hwctx;