player/command: add deinterlace-active property

This commit is contained in:
Dudemanguy 2024-01-21 21:37:49 -06:00
parent 8dbbc2ad82
commit 003fb15cbb
6 changed files with 42 additions and 1 deletions

View File

@ -2174,6 +2174,11 @@ Property list
``af-metadata/<filter-label>`` ``af-metadata/<filter-label>``
Equivalent to ``vf-metadata/<filter-label>``, but for audio filters. Equivalent to ``vf-metadata/<filter-label>``, but for audio filters.
``deinterlace-active``
Returns ``yes``/true if mpv's deinterlacing filter is active. Note that it
will not detect any manually inserted deinterlacing filters done via
``--vf``.
``idle-active`` ``idle-active``
Returns ``yes``/true if no file is loaded, but the player is staying around Returns ``yes``/true if no file is loaded, but the player is staying around
because of the ``--idle`` option. because of the ``--idle`` option.

View File

@ -168,6 +168,12 @@ static const struct mp_filter_info deint_filter = {
.destroy = deint_destroy, .destroy = deint_destroy,
}; };
bool mp_deint_active(struct mp_filter *f)
{
struct deint_priv *p = f->priv;
return p->deinterlace_active;
}
struct mp_filter *mp_deint_create(struct mp_filter *parent) struct mp_filter *mp_deint_create(struct mp_filter *parent)
{ {
struct mp_filter *f = mp_filter_create(parent, &deint_filter); struct mp_filter *f = mp_filter_create(parent, &deint_filter);

View File

@ -11,3 +11,5 @@ struct mp_filter *mp_autorotate_create(struct mp_filter *parent);
// Insert a filter that inserts scaletempo2 depending on speed settings. // Insert a filter that inserts scaletempo2 depending on speed settings.
struct mp_filter *mp_autoaspeed_create(struct mp_filter *parent); struct mp_filter *mp_autoaspeed_create(struct mp_filter *parent);
bool mp_deint_active(struct mp_filter *parent);

View File

@ -518,6 +518,17 @@ double mp_output_get_measured_total_delay(struct mp_output_chain *c)
return delay; return delay;
} }
bool mp_output_chain_deinterlace_active(struct mp_output_chain *c)
{
struct chain *p = c->f->priv;
for (int n = 0; n < p->num_all_filters; n++) {
struct mp_user_filter *u = p->all_filters[n];
if (strcmp(u->name, "userdeint") == 0)
return mp_deint_active(u->f);
}
return false;
}
bool mp_output_chain_update_filters(struct mp_output_chain *c, bool mp_output_chain_update_filters(struct mp_output_chain *c,
struct m_obj_settings *list) struct m_obj_settings *list)
{ {

View File

@ -85,3 +85,6 @@ void mp_output_chain_set_audio_speed(struct mp_output_chain *p,
// due to the change. // due to the change.
// Makes sense for audio only. // Makes sense for audio only.
double mp_output_get_measured_total_delay(struct mp_output_chain *p); double mp_output_get_measured_total_delay(struct mp_output_chain *p);
// Check if deinterlace user filter is inserted
bool mp_output_chain_deinterlace_active(struct mp_output_chain *p);

View File

@ -1357,6 +1357,18 @@ static int mp_property_core_idle(void *ctx, struct m_property *prop,
return m_property_bool_ro(action, arg, !mpctx->playback_active); return m_property_bool_ro(action, arg, !mpctx->playback_active);
} }
static int mp_property_deinterlace(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
struct vo_chain *vo_c = mpctx->vo_chain;
if (!vo_c)
return M_PROPERTY_UNAVAILABLE;
bool deinterlace_active = mp_output_chain_deinterlace_active(vo_c->filter);
return m_property_bool_ro(action, arg, deinterlace_active);
}
static int mp_property_idle(void *ctx, struct m_property *prop, static int mp_property_idle(void *ctx, struct m_property *prop,
int action, void *arg) int action, void *arg)
{ {
@ -3882,6 +3894,7 @@ static const struct m_property mp_properties_base[] = {
{"clock", mp_property_clock}, {"clock", mp_property_clock},
{"seekable", mp_property_seekable}, {"seekable", mp_property_seekable},
{"partially-seekable", mp_property_partially_seekable}, {"partially-seekable", mp_property_partially_seekable},
{"deinterlace-active", mp_property_deinterlace},
{"idle-active", mp_property_idle}, {"idle-active", mp_property_idle},
{"window-id", mp_property_window_id}, {"window-id", mp_property_window_id},
@ -4056,7 +4069,8 @@ static const char *const *const mp_event_property_change[] = {
"secondary-sub-text", "audio-bitrate", "video-bitrate", "sub-bitrate", "secondary-sub-text", "audio-bitrate", "video-bitrate", "sub-bitrate",
"decoder-frame-drop-count", "frame-drop-count", "video-frame-info", "decoder-frame-drop-count", "frame-drop-count", "video-frame-info",
"vf-metadata", "af-metadata", "sub-start", "sub-end", "secondary-sub-start", "vf-metadata", "af-metadata", "sub-start", "sub-end", "secondary-sub-start",
"secondary-sub-end", "video-out-params", "video-dec-params", "video-params"), "secondary-sub-end", "video-out-params", "video-dec-params", "video-params",
"deinterlace-active"),
E(MP_EVENT_DURATION_UPDATE, "duration"), E(MP_EVENT_DURATION_UPDATE, "duration"),
E(MPV_EVENT_VIDEO_RECONFIG, "video-out-params", "video-params", E(MPV_EVENT_VIDEO_RECONFIG, "video-out-params", "video-params",
"video-format", "video-codec", "video-bitrate", "dwidth", "dheight", "video-format", "video-codec", "video-bitrate", "dwidth", "dheight",