media/libopus/celt/kiss_fft.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/libopus/celt/kiss_fft.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,139 @@
     1.4 +/*Copyright (c) 2003-2004, Mark Borgerding
     1.5 +  Lots of modifications by Jean-Marc Valin
     1.6 +  Copyright (c) 2005-2007, Xiph.Org Foundation
     1.7 +  Copyright (c) 2008,      Xiph.Org Foundation, CSIRO
     1.8 +
     1.9 +  All rights reserved.
    1.10 +
    1.11 +  Redistribution and use in source and binary forms, with or without
    1.12 +   modification, are permitted provided that the following conditions are met:
    1.13 +
    1.14 +    * Redistributions of source code must retain the above copyright notice,
    1.15 +       this list of conditions and the following disclaimer.
    1.16 +    * Redistributions in binary form must reproduce the above copyright notice,
    1.17 +       this list of conditions and the following disclaimer in the
    1.18 +       documentation and/or other materials provided with the distribution.
    1.19 +
    1.20 +  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    1.21 +  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    1.22 +  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    1.23 +  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
    1.24 +  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    1.25 +  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    1.26 +  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    1.27 +  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    1.28 +  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    1.29 +  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    1.30 +  POSSIBILITY OF SUCH DAMAGE.*/
    1.31 +
    1.32 +#ifndef KISS_FFT_H
    1.33 +#define KISS_FFT_H
    1.34 +
    1.35 +#include <stdlib.h>
    1.36 +#include <math.h>
    1.37 +#include "arch.h"
    1.38 +
    1.39 +#ifdef __cplusplus
    1.40 +extern "C" {
    1.41 +#endif
    1.42 +
    1.43 +#ifdef USE_SIMD
    1.44 +# include <xmmintrin.h>
    1.45 +# define kiss_fft_scalar __m128
    1.46 +#define KISS_FFT_MALLOC(nbytes) memalign(16,nbytes)
    1.47 +#else
    1.48 +#define KISS_FFT_MALLOC opus_alloc
    1.49 +#endif
    1.50 +
    1.51 +#ifdef FIXED_POINT
    1.52 +#include "arch.h"
    1.53 +
    1.54 +#  define kiss_fft_scalar opus_int32
    1.55 +#  define kiss_twiddle_scalar opus_int16
    1.56 +
    1.57 +
    1.58 +#else
    1.59 +# ifndef kiss_fft_scalar
    1.60 +/*  default is float */
    1.61 +#   define kiss_fft_scalar float
    1.62 +#   define kiss_twiddle_scalar float
    1.63 +#   define KF_SUFFIX _celt_single
    1.64 +# endif
    1.65 +#endif
    1.66 +
    1.67 +typedef struct {
    1.68 +    kiss_fft_scalar r;
    1.69 +    kiss_fft_scalar i;
    1.70 +}kiss_fft_cpx;
    1.71 +
    1.72 +typedef struct {
    1.73 +   kiss_twiddle_scalar r;
    1.74 +   kiss_twiddle_scalar i;
    1.75 +}kiss_twiddle_cpx;
    1.76 +
    1.77 +#define MAXFACTORS 8
    1.78 +/* e.g. an fft of length 128 has 4 factors
    1.79 + as far as kissfft is concerned
    1.80 + 4*4*4*2
    1.81 + */
    1.82 +
    1.83 +typedef struct kiss_fft_state{
    1.84 +    int nfft;
    1.85 +#ifndef FIXED_POINT
    1.86 +    kiss_fft_scalar scale;
    1.87 +#endif
    1.88 +    int shift;
    1.89 +    opus_int16 factors[2*MAXFACTORS];
    1.90 +    const opus_int16 *bitrev;
    1.91 +    const kiss_twiddle_cpx *twiddles;
    1.92 +} kiss_fft_state;
    1.93 +
    1.94 +/*typedef struct kiss_fft_state* kiss_fft_cfg;*/
    1.95 +
    1.96 +/**
    1.97 + *  opus_fft_alloc
    1.98 + *
    1.99 + *  Initialize a FFT (or IFFT) algorithm's cfg/state buffer.
   1.100 + *
   1.101 + *  typical usage:      kiss_fft_cfg mycfg=opus_fft_alloc(1024,0,NULL,NULL);
   1.102 + *
   1.103 + *  The return value from fft_alloc is a cfg buffer used internally
   1.104 + *  by the fft routine or NULL.
   1.105 + *
   1.106 + *  If lenmem is NULL, then opus_fft_alloc will allocate a cfg buffer using malloc.
   1.107 + *  The returned value should be free()d when done to avoid memory leaks.
   1.108 + *
   1.109 + *  The state can be placed in a user supplied buffer 'mem':
   1.110 + *  If lenmem is not NULL and mem is not NULL and *lenmem is large enough,
   1.111 + *      then the function places the cfg in mem and the size used in *lenmem
   1.112 + *      and returns mem.
   1.113 + *
   1.114 + *  If lenmem is not NULL and ( mem is NULL or *lenmem is not large enough),
   1.115 + *      then the function returns NULL and places the minimum cfg
   1.116 + *      buffer size in *lenmem.
   1.117 + * */
   1.118 +
   1.119 +kiss_fft_state *opus_fft_alloc_twiddles(int nfft,void * mem,size_t * lenmem, const kiss_fft_state *base);
   1.120 +
   1.121 +kiss_fft_state *opus_fft_alloc(int nfft,void * mem,size_t * lenmem);
   1.122 +
   1.123 +/**
   1.124 + * opus_fft(cfg,in_out_buf)
   1.125 + *
   1.126 + * Perform an FFT on a complex input buffer.
   1.127 + * for a forward FFT,
   1.128 + * fin should be  f[0] , f[1] , ... ,f[nfft-1]
   1.129 + * fout will be   F[0] , F[1] , ... ,F[nfft-1]
   1.130 + * Note that each element is complex and can be accessed like
   1.131 +    f[k].r and f[k].i
   1.132 + * */
   1.133 +void opus_fft(const kiss_fft_state *cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout);
   1.134 +void opus_ifft(const kiss_fft_state *cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout);
   1.135 +
   1.136 +void opus_fft_free(const kiss_fft_state *cfg);
   1.137 +
   1.138 +#ifdef __cplusplus
   1.139 +}
   1.140 +#endif
   1.141 +
   1.142 +#endif

mercurial