[FFmpeg-devel] [POF] libopencv smooth filter

Michael Niedermayer michaelni
Tue Sep 7 19:52:00 CEST 2010


On Sun, Sep 05, 2010 at 11:34:16PM +0200, Stefano Sabatini wrote:
> On date Sunday 2010-09-05 18:42:35 +0200, Michael Niedermayer encoded:
> > On Tue, Aug 03, 2010 at 03:05:11AM +0200, Stefano Sabatini wrote:
> > [...]
> > > + *
> > > + * 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
> > > + * libopencv wrapper functions
> > > + */
> > > +
> > > +#include "opencv/cv.h"
> > > +#include "opencv/cxtypes.h"
> > > +#include "avfilter.h"
> > > +
> > > +static void fill_iplimage_from_picref(IplImage *img, const AVFilterPicRef *picref, enum PixelFormat pixfmt)
> > > +{
> > > +    int i;
> > > +    IplImage *tmpimg;
> > > +
> > > +    struct {
> > > +        enum PixelFormat pixfmt;
> > > +        int depth;
> > > +        int channels;
> > > +    } entry, pixfmt_iplimage_map[] = {
> > > +        { PIX_FMT_GRAY8, IPL_DEPTH_8U, 1 },
> > > +        { PIX_FMT_BGRA , IPL_DEPTH_8U, 4 },
> > > +        { PIX_FMT_BGR24, IPL_DEPTH_8U, 3 },
> > > +        { PIX_FMT_NONE                   }
> > > +    };
> > > +
> > > +    for (i = 0; i < FF_ARRAY_ELEMS(pixfmt_iplimage_map); i++) {
> > > +        entry = pixfmt_iplimage_map[i];
> > > +        if (pixfmt == entry.pixfmt)
> > > +            break;
> > > +    }
> > 
> > > +    if (entry.pixfmt == PIX_FMT_NONE)
> > > +        assert(1);
> > 
> > ?
> 
> Ehm I suppose I can skip this.
> 
> > [...]
> > > +#if CONFIG_OCV_SMOOTH_FILTER
> > > +
> > > +typedef struct {
> > > +    int type;
> > > +    int    param1, param2;
> > > +    double param3, param4;
> > > +} SmoothContext;
> > > +
> > > +static av_cold int smooth_init(AVFilterContext *ctx, const char *args, void *opaque)
> > > +{
> > > +    SmoothContext *smooth = ctx->priv;
> > > +    char type_str[128] = "gaussian";
> > > +
> > > +    smooth->param1 = 3;
> > > +    smooth->param2 = 0;
> > > +    smooth->param3 = 0.0;
> > > +    smooth->param4 = 0.0;
> > > +
> > > +    if (args)
> > > +        sscanf(args, "%127[^:]:%d:%d:%lf:%lf", type_str, &smooth->param1, &smooth->param2, &smooth->param3, &smooth->param4);
> > > +
> > > +    if      (!strcmp(type_str, "blur"         )) smooth->type = CV_BLUR;
> > > +    else if (!strcmp(type_str, "blur_no_scale")) smooth->type = CV_BLUR_NO_SCALE;
> > > +    else if (!strcmp(type_str, "median"       )) smooth->type = CV_MEDIAN;
> > > +    else if (!strcmp(type_str, "gaussian"     )) smooth->type = CV_GAUSSIAN;
> > > +    else if (!strcmp(type_str, "bilateral"    )) smooth->type = CV_BILATERAL;
> > > +    else {
> > > +        av_log(ctx, AV_LOG_ERROR, "Smoothing type '%s' unknown\n.", type_str);
> > > +        return AVERROR(EINVAL);
> > > +    }
> > 
> > its a bit ugly, to implement such wraper for each filter
> 
> What do you exactly mean? For opencv there is no way to implement a
> general wrapper (as opposed to frei0r) because for filtering we have
> to use each time a different function with a different interface.

so each function need to be wraped in a generic interface, it seems you do
more than that.

[...]
-- 
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: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100907/d15de4ee/attachment.pgp>



More information about the ffmpeg-devel mailing list