summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2024-01-21 21:37:49 -0600
committerDudemanguy <random342@airmail.cc>2024-02-07 14:50:09 +0000
commit003fb15cbb21d86186ab3fb5448ff8c908e1e0dd (patch)
tree4922ee5f0b838ffc3d75293fc3712b7098827afa
parent8dbbc2ad82d6ebfa986db4726e2e5006b7cb0a9d (diff)
downloadmpv-003fb15cbb21d86186ab3fb5448ff8c908e1e0dd.tar.bz2
mpv-003fb15cbb21d86186ab3fb5448ff8c908e1e0dd.tar.xz
player/command: add deinterlace-active property
-rw-r--r--DOCS/man/input.rst5
-rw-r--r--filters/f_auto_filters.c6
-rw-r--r--filters/f_auto_filters.h2
-rw-r--r--filters/f_output_chain.c11
-rw-r--r--filters/f_output_chain.h3
-rw-r--r--player/command.c16
6 files changed, 42 insertions, 1 deletions
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/<filter-label>``
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``
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",