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.
This commit is contained in:
wm4 2018-04-21 13:18:03 +02:00 committed by Jan Ekström
parent d8807ca833
commit 4b32d51b96
4 changed files with 48 additions and 0 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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.