[FFmpeg-devel] [PATCH] Separate format conversion DSP functions from DSPContext.

Måns Rullgård mans
Sun Jan 30 17:05:18 CET 2011


Justin Ruggles <justin.ruggles at gmail.com> writes:

> This will be beneficial for use with the audio conversion API without
> requiring it to depend on all of dsputil.
> ---
>
> Tested on x86-64 and ppc.
>
>  libavcodec/Makefile                 |    1 +
>  libavcodec/aac.h                    |    2 +
>  libavcodec/aacdec.c                 |    4 +-
>  libavcodec/ac3dec.c                 |    5 +-
>  libavcodec/ac3dec.h                 |    2 +
>  libavcodec/arm/Makefile             |    3 +
>  libavcodec/arm/dsputil_init_neon.c  |   10 -
>  libavcodec/arm/dsputil_init_vfp.c   |    4 -
>  libavcodec/arm/fmtconvert_arm.c     |   53 +++++
>  libavcodec/arm/fmtconvert_neon.S    |  391 +++++++++++++++++++++++++++++++++++
>  libavcodec/arm/fmtconvert_vfp.S     |   79 +++++++

You forgot to remove the functions from dsputil_*.S.  I'm fixing this
and a few other nits in the ARM files.

>  libavcodec/binkaudio.c              |    6 +-
>  libavcodec/dca.c                    |    7 +-
>  libavcodec/dsputil.c                |   33 ---
>  libavcodec/dsputil.h                |    5 -
>  libavcodec/fmtconvert.c             |   68 ++++++
>  libavcodec/fmtconvert.h             |   81 +++++++
>  libavcodec/nellymoserdec.c          |    5 +-
>  libavcodec/ppc/Makefile             |    1 +
>  libavcodec/ppc/float_altivec.c      |  112 ----------
>  libavcodec/ppc/fmtconvert_altivec.c |  142 +++++++++++++
>  libavcodec/vorbis_dec.c             |    6 +-
>  libavcodec/wma.c                    |    1 +
>  libavcodec/wma.h                    |    2 +
>  libavcodec/wmadec.c                 |    2 +-
>  libavcodec/x86/Makefile             |    2 +
>  libavcodec/x86/dsputil_mmx.c        |  220 --------------------
>  libavcodec/x86/fmtconvert.asm       |   91 ++++++++
>  libavcodec/x86/fmtconvert_mmx.c     |  266 ++++++++++++++++++++++++
>  29 files changed, 1211 insertions(+), 393 deletions(-)
>  create mode 100644 libavcodec/arm/fmtconvert_arm.c
>  create mode 100644 libavcodec/arm/fmtconvert_neon.S
>  create mode 100644 libavcodec/arm/fmtconvert_vfp.S
>  create mode 100644 libavcodec/fmtconvert.c
>  create mode 100644 libavcodec/fmtconvert.h
>  create mode 100644 libavcodec/ppc/fmtconvert_altivec.c
>  create mode 100644 libavcodec/x86/fmtconvert.asm
>  create mode 100644 libavcodec/x86/fmtconvert_mmx.c
[...]
> diff --git a/libavcodec/fmtconvert.h b/libavcodec/fmtconvert.h
> new file mode 100644
> index 0000000..2ebb135
> --- /dev/null
> +++ b/libavcodec/fmtconvert.h
> @@ -0,0 +1,81 @@
> +/*
> + * Format Conversion Utils
> + * Copyright (c) 2000, 2001 Fabrice Bellard
> + * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
> + *
> + * 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 AVCODEC_FMTCONVERT_H
> +#define AVCODEC_FMTCONVERT_H
> +
> +#include "avcodec.h"
> +
> +typedef struct FmtConvertContext {
> +    /**
> +     * Convert an array of int32_t to float and multiply by a float value.
> +     * @param dst destination array of float.
> +     *            constraints: 16-byte aligned
> +     * @param src source array of int32_t.
> +     *            constraints: 16-byte aligned
> +     * @param len number of elements to convert.
> +     *            constraints: multiple of 8
> +     */
> +    void (*int32_to_float_fmul_scalar)(float *dst, const int *src, float mul, int len);
> +
> +    /**
> +     * Convert an array of float to an array of int16_t.
> +     *
> +     * C version: convert floats from the range [384.0,386.0] to ints in
> +     *            the range [-32768,32767]
> +     * SIMD versions: convert floats from [-32768.0,32767.0] without rescaling

Stale comment.

> +     * @param dst destination array of int16_t.
> +     *            constraints: 16-byte aligned
> +     * @param src source array of float.
> +     *            constraints: 16-byte aligned
> +     * @param len number of elements to convert.
> +     *            constraints: multiple of 8
> +     */
> +    void (*float_to_int16)(int16_t *dst, const float *src, long len);
> +
> +    /**
> +     * Convert multiple arrays of float to an interleaved array of int16_t.
> +     *
> +     * C version: convert floats from the range [384.0,386.0] to ints in
> +     *            the range [-32768,32767]
> +     * SIMD versions: convert floats from [-32768.0,32767.0] without rescaling

Ditto.

I'm fixing these.

> +     * @param dst destination array of interleaved int16_t.
> +     *            constraints: 16-byte aligned
> +     * @param src source array of float arrays, one for each channel.
> +     *            constraints: 16-byte aligned
> +     * @param len number of elements to convert.
> +     *            constraints: multiple of 8
> +     * @param channels number of channels
> +     */
> +    void (*float_to_int16_interleave)(int16_t *dst, const float **src,
> +                                      long len, int channels);
> +} FmtConvertContext;
> +
> +void ff_fmt_convert_init(FmtConvertContext *c, AVCodecContext *avctx);
> +
> +void ff_fmt_convert_init_arm(FmtConvertContext *c, AVCodecContext *avctx);
> +void ff_fmt_convert_init_ppc(FmtConvertContext *c, AVCodecContext *avctx);
> +void ff_fmt_convert_init_x86(FmtConvertContext *c, AVCodecContext *avctx);

I'd like to get rid of the AVCodecContext here.  It's only used for a
few flags which could be passed directly or perhaps set in the
FmtConvertContext.  This is for a second round, of course.

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list