mirror of https://github.com/mpv-player/mpv
command: change the hwdec properties
Another very minor step towards property/option unification. Not bothering with interface compatibility here.
This commit is contained in:
parent
449cdfc0ff
commit
6bfbd4ebdc
|
@ -20,6 +20,11 @@ Interface changes
|
|||
::
|
||||
|
||||
--- mpv 0.10.0 will be released ---
|
||||
- completely change how the hwdec properties work:
|
||||
- "hwdec" now reflects the --hwdec option
|
||||
- "hwdec-detected" does partially what the old "hwdec" property did
|
||||
(and also, "detected-hwdec" is removed)
|
||||
- "hwdec-active" is added
|
||||
- add protocol-list property
|
||||
- deprecate audio-samplerate and audio-channels properties
|
||||
(audio-params sub-properties are the replacement)
|
||||
|
|
|
@ -1246,25 +1246,29 @@ Property list
|
|||
See ``--hue``.
|
||||
|
||||
``hwdec`` (RW)
|
||||
Return the current hardware decoder that is used. This uses the same values
|
||||
as the ``--hwdec`` option. If software decoding is active, this returns
|
||||
``no``. You can write this property. Then the ``--hwdec`` option is set to
|
||||
the new value, and video decoding will be reinitialized (internally, the
|
||||
player will perform a seek to refresh the video properly).
|
||||
Reflects the ``--hwdec`` option.
|
||||
|
||||
Note that you don't know the success of the operation immediately after
|
||||
writing this property. It happens with a delay as video is reinitialized.
|
||||
Writing to it may change the currently used hardware decoder, if possible.
|
||||
(Internally, the player may reinitialize the decoder, and will perform a
|
||||
seek to refresh the video properly.) You can watch the other hwdec
|
||||
properties to see whether this was successful.
|
||||
|
||||
``detected-hwdec``
|
||||
Return the current hardware decoder that was detected and opened. Returns
|
||||
the same values as ``hwdec``.
|
||||
Unlike in mpv 0.9.x and before, this does not return the currently active
|
||||
hardware decoder.
|
||||
|
||||
This is known only once the VO has opened (and possibly later). With some
|
||||
VOs (like ``opengl``), this is never known in advance, but only when the
|
||||
decoder attempted to create the hw decoder successfully. Also, hw decoders
|
||||
with ``-copy`` suffix are returned only while hw decoding is active (and
|
||||
unset afterwards). All this reflects how detecting hw decoders are
|
||||
detected and used internally in mpv.
|
||||
``hwdec-active``
|
||||
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.
|
||||
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
|
||||
advance, but only when the decoder attempted to create the hw decoder
|
||||
successfully. Also, hw decoders with ``-copy`` suffix will return ``no``
|
||||
while no video is being decoded. All this reflects how detecting hw decoders
|
||||
are detected and used internally in mpv.
|
||||
|
||||
``panscan`` (RW)
|
||||
See ``--panscan``.
|
||||
|
|
|
@ -2010,41 +2010,51 @@ static int mp_property_hwdec(void *ctx, struct m_property *prop,
|
|||
MPContext *mpctx = ctx;
|
||||
struct MPOpts *opts = mpctx->opts;
|
||||
struct dec_video *vd = mpctx->d_video;
|
||||
if (!vd)
|
||||
return M_PROPERTY_UNAVAILABLE;
|
||||
|
||||
int current = 0;
|
||||
video_vd_control(vd, VDCTRL_GET_HWDEC, ¤t);
|
||||
|
||||
switch (action) {
|
||||
case M_PROPERTY_GET:
|
||||
*(int *)arg = current;
|
||||
return M_PROPERTY_OK;
|
||||
case M_PROPERTY_SET: {
|
||||
if (action == M_PROPERTY_SET) {
|
||||
int new = *(int *)arg;
|
||||
if (current == new)
|
||||
|
||||
if (opts->hwdec_api == new)
|
||||
return M_PROPERTY_OK;
|
||||
if (!mpctx->d_video)
|
||||
return M_PROPERTY_ERROR;
|
||||
double last_pts = mpctx->last_vo_pts;
|
||||
uninit_video_chain(mpctx);
|
||||
|
||||
opts->hwdec_api = new;
|
||||
reinit_video_chain(mpctx);
|
||||
if (last_pts != MP_NOPTS_VALUE)
|
||||
queue_seek(mpctx, MPSEEK_ABSOLUTE, last_pts, MPSEEK_EXACT, true);
|
||||
|
||||
if (!vd)
|
||||
return M_PROPERTY_OK;
|
||||
|
||||
int current = -2;
|
||||
video_vd_control(vd, VDCTRL_GET_HWDEC, ¤t);
|
||||
if (current != opts->hwdec_api) {
|
||||
double last_pts = mpctx->last_vo_pts;
|
||||
uninit_video_chain(mpctx);
|
||||
reinit_video_chain(mpctx);
|
||||
if (last_pts != MP_NOPTS_VALUE)
|
||||
queue_seek(mpctx, MPSEEK_ABSOLUTE, last_pts, MPSEEK_EXACT, true);
|
||||
}
|
||||
return M_PROPERTY_OK;
|
||||
}
|
||||
}
|
||||
return mp_property_generic_option(mpctx, prop, action, arg);
|
||||
}
|
||||
|
||||
static int mp_property_hwdec_active(void *ctx, struct m_property *prop,
|
||||
int action, void *arg)
|
||||
{
|
||||
MPContext *mpctx = ctx;
|
||||
struct dec_video *vd = mpctx->d_video;
|
||||
bool active = false;
|
||||
if (vd) {
|
||||
int current = 0;
|
||||
video_vd_control(vd, VDCTRL_GET_HWDEC, ¤t);
|
||||
active = current > 0;
|
||||
}
|
||||
return m_property_flag_ro(action, arg, active);
|
||||
}
|
||||
|
||||
static int mp_property_detected_hwdec(void *ctx, struct m_property *prop,
|
||||
int action, void *arg)
|
||||
{
|
||||
MPContext *mpctx = ctx;
|
||||
struct dec_video *vd = mpctx->d_video;
|
||||
if (!vd || !vd->hwdec_info)
|
||||
return M_PROPERTY_UNAVAILABLE;
|
||||
|
||||
switch (action) {
|
||||
case M_PROPERTY_GET_TYPE: {
|
||||
|
@ -2053,14 +2063,16 @@ static int mp_property_detected_hwdec(void *ctx, struct m_property *prop,
|
|||
return mp_property_generic_option(mpctx, &dummy, action, arg);
|
||||
}
|
||||
case M_PROPERTY_GET: {
|
||||
int d = vd->hwdec_info->hwctx ? vd->hwdec_info->hwctx->type : HWDEC_NONE;
|
||||
if (d) {
|
||||
*(int *)arg = d;
|
||||
} else {
|
||||
// Maybe one of the "-copy" ones. These are "detected" every time
|
||||
// the decoder is opened, so we don't know much about them otherwise.
|
||||
return mp_property_hwdec(ctx, prop, action, arg);
|
||||
}
|
||||
int current = 0;
|
||||
if (vd)
|
||||
video_vd_control(vd, VDCTRL_GET_HWDEC, ¤t);
|
||||
|
||||
if (current <= 0 && vd && vd->hwdec_info && vd->hwdec_info->hwctx)
|
||||
current = vd->hwdec_info->hwctx->type;
|
||||
|
||||
// In case of the "-copy" ones, which are "detected" every time the
|
||||
// decoder is opened, return "no" if no decoding is active.
|
||||
*(int *)arg = current > 0 ? current : 0;
|
||||
return M_PROPERTY_OK;
|
||||
}
|
||||
}
|
||||
|
@ -3397,7 +3409,8 @@ static const struct m_property mp_properties[] = {
|
|||
{"vid", mp_property_video},
|
||||
{"program", mp_property_program},
|
||||
{"hwdec", mp_property_hwdec},
|
||||
{"detected-hwdec", mp_property_detected_hwdec},
|
||||
{"hwdec-active", mp_property_hwdec_active},
|
||||
{"hwdec-detected", mp_property_detected_hwdec},
|
||||
|
||||
{"estimated-frame-count", mp_property_frame_count},
|
||||
{"estimated-frame-number", mp_property_frame_number},
|
||||
|
|
Loading…
Reference in New Issue