[FFmpeg-devel] port mplayer eq filter to libavfilter

Aurelien Jacobs aurel
Mon Nov 22 23:33:51 CET 2010


On Mon, Nov 22, 2010 at 08:33:11PM +0800, William Yu wrote:
> I port mplayer's libmpcodec/vf_eq.c to libavfilter. May be some other
> people need it to adjust video's brightness and contrast
> 
> [...]
> diff --git a/configure b/configure
> index 7dcb50f..f599cec 100755
> --- a/configure
> +++ b/configure
> @@ -1408,6 +1408,7 @@ cropdetect_filter_deps="gpl"
>  frei0r_filter_deps="frei0r dlopen strtok_r"
>  ocv_smooth_filter_deps="libopencv"
>  yadif_filter_deps="gpl"
> +eq_filter_deps="gpl"

Did the original author refused to relicense under LGPL ?

> [...]
> diff --git a/libavfilter/eq.h b/libavfilter/eq.h
> new file mode 100644
> index 0000000..7084e5c
> --- /dev/null
> +++ b/libavfilter/eq.h
> @@ -0,0 +1,34 @@
> +/*
> + * Ported to FFmpeg from MPlayer libmpcodecs/vf_eq.c
> + * Port copyright (C) 2010 William Yu <genwillyu at gmail dot com>
> + *
> + * 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
> + */
> +
> +#ifndef AVFILTER_EQ_H
> +#define AVFILTER_EQ_H
> +
> +#include "avfilter.h"
> +
> +#if HAVE_MMX

This #if shouldn't be needed.

> +void ff_eq_filter_process_mmx(uint8_t *dest,
> +                              int dstride, uint8_t *src, int sstride,
> +                              int w, int h, int brightness,
> +                              int contrast);
> +#endif /* HAVE_MMX */
> +
> +#endif /* AVFILTER_EQ_H */
> diff --git a/libavfilter/vf_eq.c b/libavfilter/vf_eq.c
> new file mode 100644
> index 0000000..0c25a8e
> --- /dev/null
> +++ b/libavfilter/vf_eq.c
> @@ -0,0 +1,181 @@
> +/*
> + * Ported to FFmpeg from MPlayer libmpcodecs/vf_eq.c
> + * Port copyright (C) 2010 William Yu <genwillyu at gmail dot com>

You should keep the original copyright lines.

> [...]
> +static av_cold int init(AVFilterContext *ctx, const char * args, void * opaque)
> +{
> +    EQContext * eq = ctx->priv;
> +    av_unused int cpu_flags = av_get_cpu_flags();
> +
> +    eq->brightness = 0;
> +    eq->contrast = 0;
> +
> +    if (args)
> +        sscanf(args, "%d:%d", &(eq->brightness), &(eq->contrast));
> +
> +    if (eq->brightness < -100 || eq->brightness > 100 ||
> +        eq->contrast < -100 || eq->contrast > 100) {
> +        av_log(ctx, AV_LOG_ERROR,
> +                "Invalid brightness or contrast value %d:%d\n",
> +                eq->brightness, eq->contrast);
> +        return AVERROR(EINVAL);
> +    }
> +
> +    av_log(ctx, AV_LOG_INFO,
> +        "brightness and contrast value %d:%d\n",
> +        eq->brightness, eq->contrast);
> +    eq->process = process_c;
> +#if HAVE_MMX
> +    if (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX) {
> +        av_log(ctx,AV_LOG_INFO,"use mmx\n");
> +        eq->process = ff_eq_filter_process_mmx;
> +    }
> +#endif

And here again, the #if could be removed.

Aurel



More information about the ffmpeg-devel mailing list