[FFmpeg-devel] [PATCH] libavfilter-soc?: implement fish filter

Michael Niedermayer michaelni
Sat May 30 22:04:52 CEST 2009


On Sat, May 30, 2009 at 11:38:11AM +0200, Stefano Sabatini wrote:
> Hi all,
> fish filter is back!!
> -- 
> FFmpeg = Fundamentalist Frightening Mysterious Peaceful Eager Gadget

note, i review this with the intent of it hitting ffmpeg svn not soc
i wont review patches twice for 2 trees


>  doc/vfilters.texi        |   55 +++++++
>  libavfilter/Makefile     |    1 
>  libavfilter/allfilters.c |    1 
>  libavfilter/vf_fish.c    |  346 +++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 403 insertions(+)
> e2421aedd3da958b39eb104bddd731d633e93748  fish-implement.patch
> Index: libavfilter-soc/ffmpeg/doc/vfilters.texi
> ===================================================================
> --- libavfilter-soc.orig/ffmpeg/doc/vfilters.texi	2009-05-28 21:05:20.000000000 +0200
> +++ libavfilter-soc/ffmpeg/doc/vfilters.texi	2009-05-30 11:35:20.000000000 +0200
> @@ -92,6 +92,61 @@
>  ./ffmpeg -i in.avi -vfilters "fifo" out.avi
>  @end example
>  
> + at section fish
> +
> +A fish detector. It is used to see when a goldfish passes in front of
> +the camera. It does this by counting the number of input pixels that
> +fall within a particular HSV range.
> +
> +When this happens the picture is sent to the output.
> +
> +Parameters are specified as a list of non-positional key=value pairs
> +separated by ``:''
> +
> + at table @option
> +
> + at item h, s, v
> +
> +Specify the range of H, S, V values that are fish. Takes as argument an
> +expression of the form: @var{first}- at var{second}, where @var{first} and
> + at var{second} are the values which detects the component interval.
> +Value for H are in the range 0-360, for S and V are in the range 0-255.
> +

> + at item zap, zap_color
> +
> +If zap is set to 1, set all non-fish values to the color specified by
> +zap_color (default is black).

redundant
(zap could be 1 if zap_color is specified)


> +
> + at item fill, fill_color
> +
> +If fill is set to 1, set all fish values to the color specified by
> +fill_color (default is black).

same

btw, setting the alpha plane to fishiness would be funny for things like
a blend filter ...


> +
> + at item debug
> +
> +If set to 1 turn debugging on.
> +

> + at item threshold
> +
> +Specify the threshold for the amount of fish pixels (range from 0.0 to
> +1.0).

unclear


> +
> + at item interval
> +
> +Specify how much time (in AV_TIME_BASE units) to wait before to try
> +again another fish detection.

float in seconds is nicer for humans


> +
> + at end table
> +
> + at example
> +ffplay -f video4linux /dev/video0 -vfilters "fish=debug=1: h=350-20 : v=100-255 : threshold=10 : zap=1 :zap_color=blue"
> + at end example
> +
> +The filter will look for all the pixels with a near-red color, if at
> +at least 10/1000 of the pixels are in that interval, it will send to
> +output the image, setting to the color ``blue'' all the other pixels
> +not ranging in the specified interval.
> +
>  @section format
>  
>  @example
> Index: libavfilter-soc/ffmpeg/libavfilter/allfilters.c
> ===================================================================
> --- libavfilter-soc.orig/ffmpeg/libavfilter/allfilters.c	2009-05-28 21:03:30.000000000 +0200
> +++ libavfilter-soc/ffmpeg/libavfilter/allfilters.c	2009-05-28 21:03:55.000000000 +0200
> @@ -37,6 +37,7 @@
>      REGISTER_FILTER(CROP,crop,vf);
>      REGISTER_FILTER(DRAWBOX,drawbox,vf);
>      REGISTER_FILTER(FIFO,fifo,vf);
> +    REGISTER_FILTER(FISH,fish,vf);
>      REGISTER_FILTER(FORMAT,format,vf);
>      REGISTER_FILTER(FPS,fps,vf);
>      REGISTER_FILTER(HFLIP,hflip,vf);
> Index: libavfilter-soc/ffmpeg/libavfilter/vf_fish.c
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ libavfilter-soc/ffmpeg/libavfilter/vf_fish.c	2009-05-30 11:24:54.000000000 +0200
> @@ -0,0 +1,346 @@
> +/*
> + * Fish Detector filter
> + * Copyright (c) 2002 Philip Gladstone
> + * Copyright (c) 2009 Stefano Sabatini
> + * 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
> + */
> +
> +#include "libavcodec/colorspace.h"
> +#include "libavcodec/dsputil.h"
> +#include "parseutils.h"
> +#include "avfilter.h"
> +

> +typedef struct HSV {
> +    int h;  /* 0 .. 360 */
> +    int s;  /* 0 .. 255 */
> +    int v;  /* 0 .. 255 */
> +} HSV;

doxy


> +
> +typedef struct {
> +    const AVClass *class;
> +
> +    int w, h;

> +    char *h_range, *s_range, *v_range;

They are ultimately not strings


> +
> +    int hsub, vsub;
> +
> +    char *zap_color_str;    ///< if enabled zapping, not matched pixels will be set to zap_color
> +    uint8_t zap_color[4];
> +    int zap;
> +
> +    char *fill_color_str;   ///< if enabled filling, matched pixels will be set to fill_color
> +    uint8_t fill_color[4];
> +    int fill;

same

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Breaking DRM is a little like attempting to break through a door even
though the window is wide open and the only thing in the house is a bunch
of things you dont want and which you would get tomorrow for free anyway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090530/9b0b7684/attachment.pgp>



More information about the ffmpeg-devel mailing list