static void remove_filter(AVFilterContext **filt_ctx)
{
    AVFilterLink *outlink = (*filt_ctx)->outputs[0];
    AVFilterContext *src  = (*filt_ctx)->inputs[0]->src;

    (*filt_ctx)->outputs[0] = NULL;
    avfilter_free(*filt_ctx);
    *filt_ctx = NULL;

    set_link_source(src, outlink);
}