diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index d0d5970176..9c87ed9038 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -2174,6 +2174,11 @@ Property list ``af-metadata/`` Equivalent to ``vf-metadata/``, 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`` Returns ``yes``/true if no file is loaded, but the player is staying around because of the ``--idle`` option. diff --git a/filters/f_auto_filters.c b/filters/f_auto_filters.c index fca8894b1a..f6d068ada6 100644 --- a/filters/f_auto_filters.c +++ b/filters/f_auto_filters.c @@ -168,6 +168,12 @@ static const struct mp_filter_info deint_filter = { .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 *f = mp_filter_create(parent, &deint_filter); diff --git a/filters/f_auto_filters.h b/filters/f_auto_filters.h index f315084158..f926f6e449 100644 --- a/filters/f_auto_filters.h +++ b/filters/f_auto_filters.h @@ -11,3 +11,5 @@ struct mp_filter *mp_autorotate_create(struct mp_filter *parent); // Insert a filter that inserts scaletempo2 depending on speed settings. struct mp_filter *mp_autoaspeed_create(struct mp_filter *parent); + +bool mp_deint_active(struct mp_filter *parent); diff --git a/filters/f_output_chain.c b/filters/f_output_chain.c index 2d4dcba417..ccb4d53af9 100644 --- a/filters/f_output_chain.c +++ b/filters/f_output_chain.c @@ -518,6 +518,17 @@ double mp_output_get_measured_total_delay(struct mp_output_chain *c) 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, struct m_obj_settings *list) { diff --git a/filters/f_output_chain.h b/filters/f_output_chain.h index f06769cdd9..f313f9a65f 100644 --- a/filters/f_output_chain.h +++ b/filters/f_output_chain.h @@ -85,3 +85,6 @@ void mp_output_chain_set_audio_speed(struct mp_output_chain *p, // due to the change. // Makes sense for audio only. 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); diff --git a/player/command.c b/player/command.c index ccde8647c3..66b808e438 100644 --- a/player/command.c +++ b/player/command.c @@ -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); } +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, int action, void *arg) { @@ -3882,6 +3894,7 @@ static const struct m_property mp_properties_base[] = { {"clock", mp_property_clock}, {"seekable", mp_property_seekable}, {"partially-seekable", mp_property_partially_seekable}, + {"deinterlace-active", mp_property_deinterlace}, {"idle-active", mp_property_idle}, {"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", "decoder-frame-drop-count", "frame-drop-count", "video-frame-info", "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(MPV_EVENT_VIDEO_RECONFIG, "video-out-params", "video-params", "video-format", "video-codec", "video-bitrate", "dwidth", "dheight",