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

Vitor Sessak vitor1001 at gmail.com
Sat Jul 28 18:33:18 CEST 2012


On Wed, Jul 25, 2012 at 1:34 PM, Babic, Nedeljko <nbabic at mips.com> wrote:
>>> 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.
>>
> In the next patch that we are preparing implementation and optimization of AC3
> fixed point decoder will be delivered.  The same LUT is used
> in this patch so I moved initialization of LUT in separate call in order for it
> to be usable for both floating and fixed point code.

It will still be MIPS specific, so can still be done in ff_fft_init_mips(),

>>> 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.
>>
> If I do that fft_offset_lut will have scope only in fft_init_table.c file and
> will not be visible from fft where it is used (in fft_mips.c).
> Since the same LUT table will be used also for fixed point fft I had to make it
> global.
> I can put:
>     static uint16_t fft_offsets_lut[0x2aab];
> in fft_table.h but I wanted to avoid using static definition in header file.

Sorry, that should be then

    uint16_t fft_offsets_lut[0x2aab];

-Vitor


More information about the ffmpeg-devel mailing list