[FFmpeg-devel] [PATCH 1/2] Add split filter.

Michael Niedermayer michaelni
Tue Aug 3 18:38:33 CEST 2010


On Sat, Jul 31, 2010 at 02:07:12AM +0200, Stefano Sabatini wrote:
> ---
>  doc/filters.texi         |   15 ++++++++++
>  libavfilter/Makefile     |    1 +
>  libavfilter/allfilters.c |    1 +
>  libavfilter/vf_split.c   |   66 ++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 83 insertions(+), 0 deletions(-)
>  create mode 100644 libavfilter/vf_split.c
> 
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 7f0cb71..3ce60b3 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -164,6 +164,21 @@ not specified it will use the default value of 16.
>  Adding this in the beginning of filter chains should make filtering
>  faster due to better use of the memory cache.
>  
> + at section split
> +
> +Pass on the input video to two outputs. Both outputs are perfectly
> +identical to the input video.
> +
> +For example if you want to process the same input using two different
> +filterchains, you can use the split filter to issue two different
> +outputs.
> +
> +For example:
> + at example
> +"split [splitout1][splitout2]; [splitout1] crop=0:0:100:100 [cropout]; [splitout2] pad=200:200:100:100 [padout]; 
> + at end example
> +will create two separate outputs, one cropped and one padded.
> +
>  @section unsharp
>  
>  Sharpen or blur the input video.
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index feef16c..b7d3ddb 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -24,6 +24,7 @@ OBJS-$(CONFIG_PIXDESCTEST_FILTER)            += vf_pixdesctest.o
>  OBJS-$(CONFIG_PIXELASPECT_FILTER)            += vf_aspect.o
>  OBJS-$(CONFIG_SCALE_FILTER)                  += vf_scale.o
>  OBJS-$(CONFIG_SLICIFY_FILTER)                += vf_slicify.o
> +OBJS-$(CONFIG_SPLIT_FILTER)                  += vf_split.o
>  OBJS-$(CONFIG_UNSHARP_FILTER)                += vf_unsharp.o
>  OBJS-$(CONFIG_VFLIP_FILTER)                  += vf_vflip.o
>  
> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> index e8bc771..3282a31 100644
> --- a/libavfilter/allfilters.c
> +++ b/libavfilter/allfilters.c
> @@ -44,6 +44,7 @@ void avfilter_register_all(void)
>      REGISTER_FILTER (PIXELASPECT, pixelaspect, vf);
>      REGISTER_FILTER (SCALE,       scale,       vf);
>      REGISTER_FILTER (SLICIFY,     slicify,     vf);
> +    REGISTER_FILTER (SPLIT,       split,       vf);
>      REGISTER_FILTER (UNSHARP,     unsharp,     vf);
>      REGISTER_FILTER (VFLIP,       vflip,       vf);
>  
> diff --git a/libavfilter/vf_split.c b/libavfilter/vf_split.c
> new file mode 100644
> index 0000000..5643249
> --- /dev/null
> +++ b/libavfilter/vf_split.c
> @@ -0,0 +1,66 @@
> +/*
> + * copyright (c) 2007 Bobby Bingham
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +/**
> + * @file
> + * Video splitter
> + */
> +
> +#include "avfilter.h"
> +
> +static void start_frame(AVFilterLink *inlink, AVFilterPicRef *picref)
> +{
> +    avfilter_start_frame(inlink->dst->outputs[0],
> +                         avfilter_ref_pic(picref, ~AV_PERM_WRITE));
> +    avfilter_start_frame(inlink->dst->outputs[1],
> +                         avfilter_ref_pic(picref, ~AV_PERM_WRITE));
> +}
> +
> +static void end_frame(AVFilterLink *inlink)
> +{
> +    avfilter_end_frame(inlink->dst->outputs[0]);
> +    avfilter_end_frame(inlink->dst->outputs[1]);
> +
> +    avfilter_unref_pic(inlink->cur_pic);
> +}
> +
> +static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
> +{
> +    avfilter_draw_slice(inlink->dst->outputs[0], y, h, slice_dir);
> +    avfilter_draw_slice(inlink->dst->outputs[1], y, h, slice_dir);
> +}

this implementation does have some issues as frames are pushed down both
sides no matter if either is ready.
Its not a problem as such but what iam thinking of is that the filter core
should insert split and fifo filters as needed and not require them to be
manually specified

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Opposition brings concord. Out of discord comes the fairest harmony.
-- Heraclitus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100803/12546098/attachment.pgp>



More information about the ffmpeg-devel mailing list