[FFmpeg-devel] [PATCH] lavfi/af_sofalizer: remove exp2 and replace clz by ff_clz

Ganesh Ajjanagadde gajjanagadde at gmail.com
Fri Jan 1 19:50:59 CET 2016


On Tue, Dec 29, 2015 at 1:17 PM, Ganesh Ajjanagadde
<gajjanagadde at gmail.com> wrote:
> ff_clz is faster, and uses an intrinsic (at the moment on GCC). exp2 is
> a wasteful function for a simple integer exponentiation.
>
> Untested.
>
> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
> ---
>  libavfilter/af_sofalizer.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/libavfilter/af_sofalizer.c b/libavfilter/af_sofalizer.c
> index 6a24cbc..0bd1931 100644
> --- a/libavfilter/af_sofalizer.c
> +++ b/libavfilter/af_sofalizer.c
> @@ -30,6 +30,7 @@
>
>  #include "libavcodec/avfft.h"
>  #include "libavutil/float_dsp.h"
> +#include "libavutil/intmath.h"
>  #include "libavutil/opt.h"
>  #include "avfilter.h"
>  #include "internal.h"
> @@ -996,8 +997,8 @@ static int config_input(AVFilterLink *inlink)
>      }
>      /* buffer length is longest IR plus max. delay -> next power of 2
>         (32 - count leading zeros gives required exponent)  */
> -    s->buffer_length = exp2(32 - clz((uint32_t)n_max));
> -    s->n_fft         = exp2(32 - clz((uint32_t)(n_max + inlink->sample_rate)));
> +    s->buffer_length = 1 << (32 - ff_clz(n_max));
> +    s->n_fft         = 1 << (32 - ff_clz(n_max + inlink->sample_rate));
>
>      if (s->type == FREQUENCY_DOMAIN) {
>          av_fft_end(s->fft[0]);
> --
> 2.6.4
>

ping


More information about the ffmpeg-devel mailing list