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

Michael Niedermayer michaelni at gmx.at
Wed Jul 11 13:25:52 CEST 2012


On Wed, Jul 11, 2012 at 11:04:10AM +0000, Babic, Nedeljko 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.
> >[...]
> >> diff --git a/libavcodec/mips/fmtconvert_mips.c b/libavcodec/mips/fmtconvert_mips.c
> >> new file mode 100644
> >> index 0000000..9e45ba1
> >> --- /dev/null
> >> +++ b/libavcodec/mips/fmtconvert_mips.c
> >> @@ -0,0 +1,336 @@
> >> +/*
> >> + * Format Conversion Utils for MIPS
> >> + *
> >> + * 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 is
> >> + *    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:  Zoran Lukic (zoranl at mips.com)
> >> + * Author:  Nedeljko Babic (nbabic 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
> >> + */
> >> +#include "config.h"
> >> +#include "libavcodec/avcodec.h"
> >> +#include "libavcodec/fmtconvert.h"
> >> +
> >> +#if HAVE_INLINE_ASM
> >
> >if all code in the whole file depends on HAVE_INLINE_ASM then it
> >would be easiest to change the Makefile to only compile it in that
> >case instead of the #ifs
> >
> 
> To tell the truth, I am not sure how to do this in elegant way...
> Only place that something similar is done in ffmpeg is in optimizations for x86
> and there it is done in the same way as it is done here (file 
> libavcodec/x86/cavsdsp_mmx.c for example). 
> I am thinking of using ifeq in Makefile, but I am not sure this is a 
> right way of doing this...
> Is there a better way?

the following should work:
MIPSFPU-OBJS-$(HAVE_INLINE_ASM)        += mips/fmtconvert_mips.o


> 
> >
> >> +static void float_to_int16_mips(int16_t *dst, const float *src, long len) {
> >
> >you might want to look at libswresample/audioconvert
> >as well as libswresample/x86/audio_convert.asm (which is the x86
> >optimized variant of it)
> >
> >libswresample is what ffmpeg primarely uses to convert between
> >sample formats and packings (as well as sample rates & channel layouts)
> >the fmtconvert code is likely going to be used less and might totally
> >disappear as codecs should read & write their "native" format and
> >not convert internally ...
> >
> 
> The fmtconvert code was optimized as part of ac3 decoder optimization. 
> Do we need to optimize functions from libswresample/audioconvert in order for 
> patch for ac3 decoder to be accepted?

of course not, it was just a suggestion if you want to optimize more
code ...

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120711/f58fa88e/attachment.asc>


More information about the ffmpeg-devel mailing list