aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2016-05-04 16:55:26 +0200
committerGravatar wm4 <wm4@nowhere>2016-05-04 16:55:26 +0200
commit833375f88d0392cac49b30ee3a4704fbab58e814 (patch)
tree225c7d03869f633524d80c0eba3ecd698c1c1d63
parent86b5f1463c9084d83fbfb60bcd15bdb67795bb25 (diff)
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).
-rw-r--r--DOCS/interface-changes.rst3
-rw-r--r--DOCS/man/input.rst29
-rw-r--r--player/command.c47
-rw-r--r--video/hwdec.h1
-rw-r--r--video/out/opengl/hwdec.c2
-rw-r--r--video/out/opengl/hwdec.h2
6 files changed, 81 insertions, 3 deletions
diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst
index d1d8d870e2..5ca7f19639 100644
--- a/DOCS/interface-changes.rst
+++ b/DOCS/interface-changes.rst
@@ -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)
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index 83fddcf968..ea9eb07715 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -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
diff --git a/player/command.c b/player/command.c
index e6a3258741..c6391cc224 100644
--- a/player/command.c
+++ b/player/command.c
@@ -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},
diff --git a/video/hwdec.h b/video/hwdec.h
index 377f6779d1..94667774e7 100644
--- a/video/hwdec.h
+++ b/video/hwdec.h
@@ -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
diff --git a/video/out/opengl/hwdec.c b/video/out/opengl/hwdec.c
index 02aa0c2cd2..9c3bec1a0f 100644
--- a/video/out/opengl/hwdec.c
+++ b/video/out/opengl/hwdec.c
@@ -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;
}
diff --git a/video/out/opengl/hwdec.h b/video/out/opengl/hwdec.h
index 5126d7f0fa..a9d524a1d7 100644
--- a/video/out/opengl/hwdec.h
+++ b/video/out/opengl/hwdec.h
@@ -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;