From 4b32d51b962bc1950a7efeacdcfce5c45716bb67 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 21 Apr 2018 13:18:03 +0200 Subject: [PATCH] f_output_chain: log status of auto filters Just so users don't think the filters do anything when they don't insert any filters. --- filters/f_auto_filters.c | 29 +++++++++++++++++++++++++++++ filters/f_autoconvert.c | 5 +++++ filters/f_output_chain.c | 10 ++++++++++ filters/filter.h | 4 ++++ 4 files changed, 48 insertions(+) diff --git a/filters/f_auto_filters.c b/filters/f_auto_filters.c index 8071cb3712..3d4b650dd6 100644 --- a/filters/f_auto_filters.c +++ b/filters/f_auto_filters.c @@ -106,9 +106,21 @@ static void deint_destroy(struct mp_filter *f) TA_FREEP(&p->sub.filter); } +static bool deint_command(struct mp_filter *f, struct mp_filter_command *cmd) +{ + struct deint_priv *p = f->priv; + + if (cmd->type == MP_FILTER_COMMAND_IS_ACTIVE) { + cmd->is_active = !!p->sub.filter; + return true; + } + return false; +} + static const struct mp_filter_info deint_filter = { .name = "deint", .priv_size = sizeof(struct deint_priv), + .command = deint_command, .process = deint_process, .reset = deint_reset, .destroy = deint_destroy, @@ -220,9 +232,21 @@ static void rotate_destroy(struct mp_filter *f) TA_FREEP(&p->sub.filter); } +static bool rotate_command(struct mp_filter *f, struct mp_filter_command *cmd) +{ + struct rotate_priv *p = f->priv; + + if (cmd->type == MP_FILTER_COMMAND_IS_ACTIVE) { + cmd->is_active = !!p->sub.filter; + return true; + } + return false; +} + static const struct mp_filter_info rotate_filter = { .name = "autorotate", .priv_size = sizeof(struct rotate_priv), + .command = rotate_command, .process = rotate_process, .reset = rotate_reset, .destroy = rotate_destroy, @@ -291,6 +315,11 @@ static bool aspeed_command(struct mp_filter *f, struct mp_filter_command *cmd) return true; } + if (cmd->type == MP_FILTER_COMMAND_IS_ACTIVE) { + cmd->is_active = !!p->sub.filter; + return true; + } + return false; } diff --git a/filters/f_autoconvert.c b/filters/f_autoconvert.c index 6d53a5dce3..b441a2b50d 100644 --- a/filters/f_autoconvert.c +++ b/filters/f_autoconvert.c @@ -418,6 +418,11 @@ static bool command(struct mp_filter *f, struct mp_filter_command *cmd) return true; } + if (cmd->type == MP_FILTER_COMMAND_IS_ACTIVE) { + cmd->is_active = !!p->sub.filter; + return true; + } + return false; } diff --git a/filters/f_output_chain.c b/filters/f_output_chain.c index 00d5e75faf..3b96f4a0a5 100644 --- a/filters/f_output_chain.c +++ b/filters/f_output_chain.c @@ -66,6 +66,8 @@ struct mp_user_filter { struct mp_image_params last_in_vformat; struct mp_aframe *last_in_aformat; + bool last_is_active; + int64_t last_in_pts, last_out_pts; bool failed; @@ -198,6 +200,13 @@ static void process_user(struct mp_filter *f) u->last_out_pts = pts; mp_pin_in_write(f->ppins[1], frame); + + struct mp_filter_command cmd = {.type = MP_FILTER_COMMAND_IS_ACTIVE}; + if (mp_filter_command(u->f, &cmd) && u->last_is_active != cmd.is_active) { + u->last_is_active = cmd.is_active; + MP_VERBOSE(p, "[%s] (%sabled)\n", u->name, + u->last_is_active ? "en" : "dis"); + } } } @@ -236,6 +245,7 @@ static struct mp_user_filter *create_wrapper_filter(struct chain *p) wrapper->wrapper = f; wrapper->p = p; wrapper->last_in_aformat = talloc_steal(wrapper, mp_aframe_create()); + wrapper->last_is_active = true; mp_filter_add_pin(f, MP_PIN_IN, "in"); mp_filter_add_pin(f, MP_PIN_OUT, "out"); return wrapper; diff --git a/filters/filter.h b/filters/filter.h index 33177444c2..5e09a17ee7 100644 --- a/filters/filter.h +++ b/filters/filter.h @@ -357,6 +357,7 @@ enum mp_filter_command_type { MP_FILTER_COMMAND_GET_META, MP_FILTER_COMMAND_SET_SPEED, MP_FILTER_COMMAND_SET_SPEED_RESAMPLE, + MP_FILTER_COMMAND_IS_ACTIVE, }; struct mp_filter_command { @@ -371,6 +372,9 @@ struct mp_filter_command { // For MP_FILTER_COMMAND_SET_SPEED and MP_FILTER_COMMAND_SET_SPEED_RESAMPLE double speed; + + // For MP_FILTER_COMMAND_IS_ACTIVE + bool is_active; }; // Run a command on the filter. Returns success. For libavfilter.