command: change some hwdec properties

Introduce hwdec-current and hwdec-interop properties.

Deprecate hwdec-detected, which never made a lot of sense, and which is
replaced by the new properties. hwdec-active also becomes useless, as
hwdec-current is a superset, so it's deprecated too (for now).
This commit is contained in:
wm4 2016-05-04 16:55:26 +02:00
parent 86b5f1463c
commit 833375f88d
6 changed files with 81 additions and 3 deletions

View File

@ -25,6 +25,9 @@ Interface changes
point is unsert, and the end of the file for an unset B loop point
- deprecate --sub-ass=no option by --ass-style-override=strip
(also needs --embeddedfonts=no)
- add "hwdec-interop" and "hwdec-current" properties
- deprecated "hwdec-active" and "hwdec-detected" properties (to be removed
in mpv 0.19.0)
--- mpv 0.17.0 ---
- deprecate "track-list/N/audio-channels" property (use
"track-list/N/demux-channel-count" instead)

View File

@ -1385,14 +1385,39 @@ Property list
properties to see whether this was successful.
Unlike in mpv 0.9.x and before, this does not return the currently active
hardware decoder.
hardware decoder. Since mpv 0.17.1, ``hwdec-current`` is available for
this purpose.
``hwdec-current``
Return the current hardware decoding in use. If decoding is active, return
one of the values used by the ``hwdec`` option/property. ``no`` indicates
software decoding. If no decoder is loaded, the property is unavailable.
``hwdec-interop``
This returns the currently loaded hardware decoding/output interop driver.
This is known only once the VO has opened (and possibly later). With some
VOs (like ``opengl``), this might be never known in advance, but only when
the decoder attempted to create the hw decoder successfully. (Using
``--hwdec-preload`` can load it eagerly.) If there are multiple drivers
loaded, they will be separated by ``,``.
If no VO is active or no interop driver is known, this property is
unavailable.
This does not necessarily use the same values as ``hwdec``. There can be
multiple interop drivers for the same hardware decoder, depending on
platform and VO.
``hwdec-active``
Deprecated. To be removed in mpv 0.19.0. Use ``hwdec-current`` instead.
Return ``yes`` or ``no``, depending on whether any type of hardware decoding
is actually in use.
``hwdec-detected``
If software decoding is active, this returns the hardware decoder in use.
Deprecated. To be removed in mpv 0.19.0.
If hardware decoding is active, this returns the hardware decoder in use.
Otherwise, it returns either ``no``, or if applicable, the currently loaded
hardware decoding API. This is known only once the VO has opened (and
possibly later). With some VOs (like ``opengl``), this is never known in

View File

@ -2166,6 +2166,51 @@ static int mp_property_hwdec(void *ctx, struct m_property *prop,
return mp_property_generic_option(mpctx, prop, action, arg);
}
static int mp_property_hwdec_current(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
struct track *track = mpctx->current_track[0][STREAM_VIDEO];
struct dec_video *vd = track ? track->d_video : NULL;
if (!vd)
return M_PROPERTY_UNAVAILABLE;
switch (action) {
case M_PROPERTY_GET_TYPE: {
// Abuse another hwdec option to resolve the value names
struct m_property dummy = {.name = "hwdec"};
return mp_property_generic_option(mpctx, &dummy, action, arg);
}
case M_PROPERTY_GET: {
int current = HWDEC_NONE;
video_vd_control(vd, VDCTRL_GET_HWDEC, &current);
if (current == HWDEC_AUTO)
current = HWDEC_NONE;
*(int *)arg = current;
return M_PROPERTY_OK;
}
}
return M_PROPERTY_NOT_IMPLEMENTED;
}
static int mp_property_hwdec_interop(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
if (!mpctx->video_out)
return M_PROPERTY_UNAVAILABLE;
struct mp_hwdec_info *hwdec_info = NULL;
vo_control(mpctx->video_out, VOCTRL_GET_HWDEC_INFO, &hwdec_info);
struct mp_hwdec_ctx *hwctx = hwdec_info ? hwdec_info->hwctx : NULL;
const char *name = hwctx ? hwctx->driver_name : NULL;
if (!name && hwctx && hwctx->type != HWDEC_NONE && hwctx->type != HWDEC_AUTO)
name = m_opt_choice_str(mp_hwdec_names, hwctx->type);
return m_property_strdup_ro(action, arg, name);
}
static int mp_property_hwdec_active(void *ctx, struct m_property *prop,
int action, void *arg)
{
@ -3696,6 +3741,8 @@ static const struct m_property mp_properties[] = {
{"program", mp_property_program},
{"hwdec", mp_property_hwdec},
{"hwdec-active", mp_property_hwdec_active},
{"hwdec-current", mp_property_hwdec_current},
{"hwdec-interop", mp_property_hwdec_interop},
{"hwdec-detected", mp_property_detected_hwdec},
{"estimated-frame-count", mp_property_frame_count},

View File

@ -26,6 +26,7 @@ extern const struct m_opt_choice_alternatives mp_hwdec_names[];
struct mp_hwdec_ctx {
enum hwdec_type type;
const char *driver_name; // NULL if unknown/not loaded
void *priv; // for free use by hwdec implementation

View File

@ -79,6 +79,8 @@ 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;
}

View File

@ -27,7 +27,7 @@ struct gl_hwdec {
};
struct gl_hwdec_driver {
// Name of the interop backend. This is used for logging only.
// Name of the interop backend. This is used for informational purposes only.
const char *name;
// Used to explicitly request a specific API.
enum hwdec_type api;