gst_plugins_base/gst-libs/gst/fft/kiss_fft_s16.h
changeset 0 0e761a78d257
equal deleted inserted replaced
-1:000000000000 0:0e761a78d257
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 #ifndef KISS_FFT_S16_H
       
    18 #define KISS_FFT_S16_H
       
    19 
       
    20 #include <stdlib.h>
       
    21 #include <stdio.h>
       
    22 #include <math.h>
       
    23 #include <memory.h>
       
    24 #include <glib.h>
       
    25 
       
    26 #ifdef __cplusplus
       
    27 extern "C" {
       
    28 #endif
       
    29 
       
    30 /*
       
    31  ATTENTION!
       
    32  If you would like a :
       
    33  -- a utility that will handle the caching of fft objects
       
    34  -- real-only (no imaginary time component ) FFT
       
    35  -- a multi-dimensional FFT
       
    36  -- a command-line utility to perform ffts
       
    37  -- a command-line utility to perform fast-convolution filtering
       
    38 
       
    39  Then see kfc.h kiss_fftr.h kiss_fftnd.h fftutil.c kiss_fastfir.c
       
    40   in the tools/ directory.
       
    41 */
       
    42 
       
    43 #define KISS_FFT_S16_MALLOC g_malloc
       
    44 
       
    45 #include "machine/_stdint.h"
       
    46 
       
    47 #define kiss_fft_s16_scalar int16_t
       
    48 
       
    49 typedef struct {
       
    50     kiss_fft_s16_scalar r;
       
    51     kiss_fft_s16_scalar i;
       
    52 }kiss_fft_s16_cpx;
       
    53 
       
    54 typedef struct kiss_fft_s16_state* kiss_fft_s16_cfg;
       
    55 
       
    56 /* 
       
    57  *  kiss_fft_s16_alloc
       
    58  *  
       
    59  *  Initialize a FFT (or IFFT) algorithm's cfg/state buffer.
       
    60  *
       
    61  *  typical usage:      kiss_fft_s16_cfg mycfg=kiss_fft_s16_alloc(1024,0,NULL,NULL);
       
    62  *
       
    63  *  The return value from fft_alloc is a cfg buffer used internally
       
    64  *  by the fft routine or NULL.
       
    65  *
       
    66  *  If lenmem is NULL, then kiss_fft_s16_alloc will allocate a cfg buffer using malloc.
       
    67  *  The returned value should be free()d when done to avoid memory leaks.
       
    68  *  
       
    69  *  The state can be placed in a user supplied buffer 'mem':
       
    70  *  If lenmem is not NULL and mem is not NULL and *lenmem is large enough,
       
    71  *      then the function places the cfg in mem and the size used in *lenmem
       
    72  *      and returns mem.
       
    73  *  
       
    74  *  If lenmem is not NULL and ( mem is NULL or *lenmem is not large enough),
       
    75  *      then the function returns NULL and places the minimum cfg 
       
    76  *      buffer size in *lenmem.
       
    77  * */
       
    78 #ifdef __SYMBIAN32__
       
    79 IMPORT_C
       
    80 #endif
       
    81 
       
    82 
       
    83 kiss_fft_s16_cfg kiss_fft_s16_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem); 
       
    84 
       
    85 /*
       
    86  * kiss_fft(cfg,in_out_buf)
       
    87  *
       
    88  * Perform an FFT on a complex input buffer.
       
    89  * for a forward FFT,
       
    90  * fin should be  f[0] , f[1] , ... ,f[nfft-1]
       
    91  * fout will be   F[0] , F[1] , ... ,F[nfft-1]
       
    92  * Note that each element is complex and can be accessed like
       
    93     f[k].r and f[k].i
       
    94  * */
       
    95 #ifdef __SYMBIAN32__
       
    96 IMPORT_C
       
    97 #endif
       
    98 
       
    99 void kiss_fft_s16(kiss_fft_s16_cfg cfg,const kiss_fft_s16_cpx *fin,kiss_fft_s16_cpx *fout);
       
   100 
       
   101 /*
       
   102  A more generic version of the above function. It reads its input from every Nth sample.
       
   103  * */
       
   104 #ifdef __SYMBIAN32__
       
   105 IMPORT_C
       
   106 #endif
       
   107 
       
   108 void kiss_fft_s16_stride(kiss_fft_s16_cfg cfg,const kiss_fft_s16_cpx *fin,kiss_fft_s16_cpx *fout,int fin_stride);
       
   109 
       
   110 /* If kiss_fft_s16_alloc allocated a buffer, it is one contiguous 
       
   111    buffer and can be simply free()d when no longer needed*/
       
   112 #define kiss_fft_s16_free g_free
       
   113 
       
   114 /*
       
   115  Cleans up some memory that gets managed internally. Not necessary to call, but it might clean up 
       
   116  your compiler output to call this before you exit.
       
   117 */
       
   118 #ifdef __SYMBIAN32__
       
   119 IMPORT_C
       
   120 #endif
       
   121 
       
   122 void kiss_fft_s16_cleanup(void);
       
   123 	
       
   124 
       
   125 /*
       
   126  * Returns the smallest integer k, such that k>=n and k has only "fast" factors (2,3,5)
       
   127  */
       
   128 #ifdef __SYMBIAN32__
       
   129 IMPORT_C
       
   130 #endif
       
   131 
       
   132 int kiss_fft_s16_next_fast_size(int n);
       
   133 
       
   134 #ifdef __cplusplus
       
   135 } 
       
   136 #endif
       
   137 
       
   138 #endif