mirror of
https://github.com/mpv-player/mpv.git
synced 2024-09-20 03:52:22 +02:00
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.
This commit is contained in:
parent
1d29177c5c
commit
92727e7332
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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),
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user