summaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--DOCS/interface-changes.rst1
-rw-r--r--DOCS/man/options.rst16
-rw-r--r--options/options.c1
-rw-r--r--options/options.h3
-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
8 files changed, 42 insertions, 14 deletions
diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst
index c0fe2cd7cb..48e25fb7b2 100644
--- a/DOCS/interface-changes.rst
+++ b/DOCS/interface-changes.rst
@@ -20,6 +20,7 @@ Interface changes
::
--- mpv 0.10.0 will be released ---
+ - add --hwdec-preload
- add ao coreaudio exclusive suboption
- add ``track-list/N/forced`` property
- add audio-params/channel-count and ``audio-params-out/channel-count props.
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index 4086475e77..da0038bfbf 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -579,6 +579,22 @@ Video
codecs. See ``--hwdec-codecs`` to enable hardware decoding for more
codecs.
+``--hwdec-preload=<api>``
+ This is useful for the ``opengl`` and ``opengl-cb`` VOs for creating the
+ hardware decoding OpenGL interop context, but without actually enabling
+ hardware decoding itself (like ``--hwdec`` does).
+
+ If set to ``no`` (default), the ``--hwdec`` option is used.
+
+ For ``opengl``, if set, do not create the interop context on demand, but
+ when the VO is created.
+
+ For ``opengl-cb``, if set, load the interop context as soon as the OpenGL
+ context is created. Since ``opengl-cb`` has no on-demand loading, this
+ allows enabling hardware decoding at runtime at all, without having to
+ to temporarily set the ``hwdec`` option just during OpenGL context
+ initialization with ``mpv_opengl_cb_init_gl()``.
+
``--panscan=<0.0-1.0>``
Enables pan-and-scan functionality (cropping the sides of e.g. a 16:9
video to make it fit a 4:3 display without black bands). The range
diff --git a/options/options.c b/options/options.c
index d286e5b63c..d92a0eef5d 100644
--- a/options/options.c
+++ b/options/options.c
@@ -297,6 +297,7 @@ const m_option_t mp_opts[] = {
OPT_FLAG("ad-spdif-dtshd", dtshd, 0),
OPT_CHOICE_C("hwdec", hwdec_api, 0, mp_hwdec_names),
+ OPT_CHOICE_C("hwdec-preload", vo.hwdec_preload_api, 0, mp_hwdec_names),
OPT_STRING("hwdec-codecs", hwdec_codecs, 0),
OPT_SUBSTRUCT("sws", vo.sws_opts, sws_conf, 0),
diff --git a/options/options.h b/options/options.h
index b5e0e1f624..9d211390e0 100644
--- a/options/options.h
+++ b/options/options.h
@@ -42,7 +42,10 @@ typedef struct mp_vo_opts {
float monitor_pixel_aspect;
int force_window_position;
+ // vo_wayland, vo_drm
struct sws_opts *sws_opts;
+ // vo_opengl, vo_opengl_cb
+ int hwdec_preload_api;
} mp_vo_opts;
struct mp_cache_opts {
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;