[FFmpeg-devel] [POF] libopencv smooth filter

Michael Niedermayer michaelni
Sun Sep 5 18:42:35 CEST 2010


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);

?

[...]
> +#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

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

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato
-------------- 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/20100905/6a12103d/attachment.pgp>



More information about the ffmpeg-devel mailing list