[FFmpeg-devel] port mplayer eq filter to libavfilter

William Yu genwillyu
Tue Nov 23 13:43:02 CET 2010


OK. I have understood. But I think if we meet a compiler that miss
optimizer or optimizer is be disable.
we will encounter "undefined symbol" link error.
and if use #if. we will help compiler ignore unnecessary code as soon
as possible.

2010/11/23 Aurelien Jacobs <aurel at gnuage.org>:
> On Tue, Nov 23, 2010 at 05:18:08PM +0800, William Yu wrote:
>> >> [...]
>> >> 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.
>> I think add this #if can reduce code when some people config it for
>> NOT use MMX, another side i think this can help compile it under other
>> arch. Is this correct?
>
> No. This #if won't reduce code and won't help compiling under other arch.
>
>> >> [...]
>> >> +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.
>> I think if we config HAVE_MMX to 0, we need not compile these code.
>
> The if(HAVE_MMX && ...) is enough so that the code is dropped by the
> optimizer when HAVE_MMX is 0.
>
> Aurel
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at mplayerhq.hu
> https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
>



More information about the ffmpeg-devel mailing list