[FFmpeg-devel] [PATCH] Optimization of AC3 floating point decoder for MIPS

Vitor Sessak vitor1001 at gmail.com
Tue Jul 24 18:50:21 CEST 2012


On Thu, Jul 19, 2012 at 4:16 PM, Nedeljko Babic <nbabic at mips.com> wrote:
> FFT in MIPS implementation is working iteratively instead
>  of "recursively" calling functions for smaller FFT sizes.
> Some of DSP and format convert utils functions are also optimized.

Still a few comments (but we're getting close!):

> Signed-off-by: Nedeljko Babic <nbabic at mips.com>
> ---
>  doc/mips.txt                      |    1 +
>  libavcodec/dsputil.c              |    1 +
>  libavcodec/dsputil.h              |    1 +
>  libavcodec/fft.c                  |    3 +
>  libavcodec/fft.h                  |    1 +
>  libavcodec/fmtconvert.c           |    1 +
>  libavcodec/fmtconvert.h           |    1 +
>  libavcodec/mips/Makefile          |    4 +
>  libavcodec/mips/dsputil_mips.c    |  163 ++++++++++++
>  libavcodec/mips/fft_init_table.c  |   78 ++++++
>  libavcodec/mips/fft_mips.c        |  529 +++++++++++++++++++++++++++++++++++++
>  libavcodec/mips/fft_table.h       |   68 +++++
>  libavcodec/mips/fmtconvert_mips.c |  332 +++++++++++++++++++++++
>  13 files changed, 1183 insertions(+), 0 deletions(-)
>  create mode 100644 libavcodec/mips/dsputil_mips.c
>  create mode 100644 libavcodec/mips/fft_init_table.c
>  create mode 100644 libavcodec/mips/fft_mips.c
>  create mode 100644 libavcodec/mips/fft_table.h
>  create mode 100644 libavcodec/mips/fmtconvert_mips.c
>
> diff --git a/libavcodec/fft.c b/libavcodec/fft.c
> index 6b93a5c..8463bfb 100644
> --- a/libavcodec/fft.c
> +++ b/libavcodec/fft.c
> @@ -31,6 +31,7 @@
>  #include "libavutil/mathematics.h"
>  #include "fft.h"
>  #include "fft-internal.h"
> +#include "mips/fft_table.h"
>
>  /* cos(2*pi*x/n) for 0<=x<=n/4, followed by its reverse */
>  #if !CONFIG_HARDCODED_TABLES
> @@ -157,11 +158,13 @@ av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse)
>      s->mdct_calc   = ff_mdct_calc_c;
>  #endif
>
> +    if (ARCH_MIPS)    ff_fft_lut_init();
>  #if CONFIG_FFT_FLOAT
>      if (ARCH_ARM)     ff_fft_init_arm(s);
>      if (HAVE_ALTIVEC) ff_fft_init_altivec(s);
>      if (HAVE_MMX)     ff_fft_init_mmx(s);
>      if (CONFIG_MDCT)  s->mdct_calcw = s->mdct_calc;
> +    if (HAVE_MIPSFPU) ff_fft_init_mips(s);
>  #else
>      if (CONFIG_MDCT)  s->mdct_calcw = ff_mdct_calcw_c;
>      if (ARCH_ARM)     ff_fft_fixed_init_arm(s);

I think that you can do one single call here like for all the other archs.

> diff --git a/libavcodec/mips/fft_init_table.c b/libavcodec/mips/fft_init_table.c
> new file mode 100644
> index 0000000..2e729e1
> --- /dev/null
> +++ b/libavcodec/mips/fft_init_table.c
> @@ -0,0 +1,78 @@
> +/*
> + * Copyright (c) 2012
> + *      MIPS Technologies, Inc., California.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + * 1. Redistributions of source code must retain the above copyright
> + *    notice, this list of conditions and the following disclaimer.
> + * 2. Redistributions in binary form must reproduce the above copyright
> + *    notice, this list of conditions and the following disclaimer in the
> + *    documentation and/or other materials provided with the distribution.
> + * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its
> + *    contributors may be used to endorse or promote products derived from
> + *    this software without specific prior written permission.
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND
> + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> + * ARE DISCLAIMED.  IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE
> + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
> + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
> + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
> + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
> + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
> + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> + * SUCH DAMAGE.
> + *
> + * Author:  Stanislav Ocovaj (socovaj at mips.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
> + */
> +
> +/**
> + * @file
> + * definitions and initialization of LUT table for MIPS FFT
> + */
> +#include "fft_table.h"
> +
> +short * fft_offsets_lut;

Why not just

static uint16_t fft_offsets_lut[0x2aab];

?

This way, it'll never leak and can eventually be shared between threads.

> diff --git a/libavcodec/mips/fft_table.h b/libavcodec/mips/fft_table.h
> new file mode 100644
> index 0000000..6e87546
> --- /dev/null
> +++ b/libavcodec/mips/fft_table.h
> @@ -0,0 +1,68 @@
> +/*
> + * Copyright (c) 2012
> + *      MIPS Technologies, Inc., California.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + * 1. Redistributions of source code must retain the above copyright
> + *    notice, this list of conditions and the following disclaimer.
> + * 2. Redistributions in binary form must reproduce the above copyright
> + *    notice, this list of conditions and the following disclaimer in the
> + *    documentation and/or other materials provided with the distribution.
> + * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its
> + *    contributors may be used to endorse or promote products derived from
> + *    this software without specific prior written permission.
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND
> + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> + * ARE DISCLAIMED.  IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE
> + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
> + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
> + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
> + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
> + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
> + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> + * SUCH DAMAGE.
> + *
> + * Author:  Stanislav Ocovaj (socovaj at mips.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
> + */
> +
> +/**
> + * @file
> + * definitions and LUT table for MIPS FFT
> + */
> +#ifndef AVCODEC_MIPS_FFT_TABLE_H
> +#define AVCODEC_MIPS_FFT_TABLE_H
> +
> +#include "libavcodec/fft.h"
> +
> +enum _fftConsts{
> +    MIN_LOG2_NFFT = 4, //!< Specifies miniumum allowed fft size
> +    MAX_LOG2_NFFT = 16 //!< Specifies maxiumum allowed fft size
> +};
> +
> +#define MAX_FFT_SIZE (1 << MAX_LOG2_NFFT)
> +#define MIN_FFT_SIZE (1 << MIN_LOG2_NFFT)

Why does MIPS need this and the other archs don't?

-Vitor


More information about the ffmpeg-devel mailing list