[FFmpeg-devel] [PATCH v2 4/8] avfilter/overlay_subs: Add overlay_subs filter

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Mon Aug 30 21:44:45 EEST 2021


Soft Works:
> Signed-off-by: softworkz <softworkz at hotmail.com>
> ---
> v2 Update:
> 
> - Implemented Andreas' suggestions
> - overlay_subs filter:
>   - removed duplicated code
>   - implemented direct (no pre-conversion) blending of graphical
>     subtitle rects
>   - Supported input formats:
>     - all packed RGB formats (with and without alpha)
> 	- yuv420p, yuv422p, yuv444p
> 
>  libavfilter/Makefile          |   1 +
>  libavfilter/allfilters.c      |   1 +
>  libavfilter/vf_overlay_subs.c | 549 ++++++++++++++++++++++++++++++++++
>  libavfilter/vf_overlay_subs.h |  65 ++++
>  4 files changed, 616 insertions(+)
>  create mode 100644 libavfilter/vf_overlay_subs.c
>  create mode 100644 libavfilter/vf_overlay_subs.h
> 
> +static const AVFilterPad overlay_subs_inputs[] = {
> +    {
> +        .name         = "main",
> +        .type         = AVMEDIA_TYPE_VIDEO,
> +        .config_props = config_input_main,
> +        .flags        = AVFILTERPAD_FLAG_NEEDS_WRITABLE,
> +    },
> +    {
> +        .name         = "overlay",
> +        .type         = AVMEDIA_TYPE_SUBTITLE,
> +    },
> +    { NULL }
> +};
> +
> +static const AVFilterPad overlay_subs_outputs[] = {
> +    {
> +        .name          = "default",
> +        .type          = AVMEDIA_TYPE_VIDEO,
> +        .config_props  = config_output,
> +    },
> +    { NULL }
> +};
> +
> +const AVFilter ff_vf_overlay_subs = {
> +    .name          = "overlay_subs",
> +    .description   = NULL_IF_CONFIG_SMALL("Overlay graphical subtitles on top of the input."),
> +    .preinit       = overlay_subs_framesync_preinit,
> +    .init          = init,
> +    .uninit        = uninit,
> +    .priv_size     = sizeof(OverlaySubsContext),
> +    .priv_class    = &overlay_subs_class,
> +    .query_formats = query_formats,
> +    .activate      = activate,
> +    .inputs        = overlay_subs_inputs,
> +    .outputs       = overlay_subs_outputs,
> +};
Did you test this? Did it work? It shouldn't: The sentinel for the
inputs and outputs has been removed, see
8be701d9f7f77ff2282cc7fe6e0791ca5419de70.

- Andreas


More information about the ffmpeg-devel mailing list