Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

TransformS.hh

Go to the documentation of this file.
00001 /*
00002 
00003     DFT, DCT and DST routines
00004     Copyright (C) 1996-2001 Takuya OOURA
00005     Copyright (C) 1999-2003 Jussi Laako
00006 
00007     This program is free software; you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation; either version 2 of the License, or
00010     (at your option) any later version.
00011 
00012     This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 
00021     Version 1.0 : Converted T.OOURA's functions to C++ class
00022     Version 1.1 : Updated to match T.OOURA's Oct/99 code and all versions
00023     Version 1.2 : Some conversion and precision updates
00024     Version 1.3 : Updated to match T.OOURA's Oct/01 code
00025 
00026 */
00027 
00028 
00029 #include "dsp/DSPConfig.hh"
00030 
00031 
00032 /* This is decimation-in-frequency split-radix transform */
00033 
00034 
00035 #ifndef TRANSFORMS_HH
00036     #define TRANSFORMS_HH
00037 
00038     #ifdef TRANSFORM_INLINE
00039         #define TS_INLINE           inline
00040     #else
00041         #define TS_INLINE
00042     #endif
00043 
00044     #if (defined(_GNU_SOURCE) && (!defined(ALPHA)))
00045         #ifndef TRANSFORM_EXT_PREC
00046             #define TRANSFORM_EXT_PREC
00047         #endif
00048     #endif
00049 
00050     #if (defined(__BORLANDC__) || defined(SOLARIS) || defined(OSX))
00051         #define sinf(x)             sin(x)
00052         #define cosf(x)             cos(x)
00053         #define atanf(x)            atan(x)
00054     #endif
00055 
00056     // #define TRANSFORM_EXT_PREC for extended precision for table calculation
00057     // for single precision transforms
00058 
00059     // #define USE_CDFT_THREADS to enable parallelization
00060     
00061     #ifdef USE_CDFT_THREADS
00062         #include <pthread.h>
00063 
00064         #ifndef CDFT_THREADS_BEGIN_N
00065             #define CDFT_THREADS_BEGIN_N 8192
00066         #endif
00067         #ifndef CDFT_4THREADS_BEGIN_N
00068             #define CDFT_4THREADS_BEGIN_N 65536
00069         #endif
00070 
00071         #define cdft_thread_t pthread_t
00072         
00073         typedef struct cdft_arg_st {
00074             long n0;
00075             long n;
00076             void *a;  // float * / double *
00077             long nw;
00078             void *w;  // float * / double *
00079             void *klass;
00080         } cdft_arg_t;
00081     #endif
00082 
00083     
00092     class clTransformS
00093     {
00094             void makeipt(long, long *);
00095             void makewt(long, long *, float *);
00096             void makewt(long, long *, double *);
00097             void makect(long, long *, float *);
00098             void makect(long, long *, double *);
00099             void cftfsub(long, float *, long *, long, float *);
00100             void cftfsub(long, double *, long *, long, double *);
00101             void cftbsub(long, float *, long *, long, float *);
00102             void cftbsub(long, double *, long *, long, double *);
00103             void bitrv2(long, long *, float *);
00104             void bitrv2(long, long *, double *);
00105             void bitrv2conj(long, long *, float *);
00106             void bitrv2conj(long, long *, double *);
00107             void bitrv216(float *);
00108             void bitrv216(double *);
00109             void bitrv216neg(float *);
00110             void bitrv216neg(double *);
00111             void bitrv208(float *);
00112             void bitrv208(double *);
00113             void bitrv208neg(float *);
00114             void bitrv208neg(double *);
00115             void cftf1st(long, float *, float *);
00116             void cftf1st(long, double *, double *);
00117             void cftb1st(long, float *, float *);
00118             void cftb1st(long, double *, double *);
00119             void cftrec4(long, float *, long, float *);
00120             void cftrec4(long, double *, long, double *);
00121             long cfttree(long, long, long, float *, long, float *);
00122             long cfttree(long, long, long, double *, long, double *);
00123             void cftleaf(long, long, float *, long, float *);
00124             void cftleaf(long, long, double *, long, double *);
00125             void cftmdl1(long, float *, float *);
00126             void cftmdl1(long, double *, double *);
00127             void cftmdl2(long, float *, float *);
00128             void cftmdl2(long, double *, double *);
00129             void cftfx41(long, float *, long, float *);
00130             void cftfx41(long, double *, long, double *);
00131             void cftf161(float *, float *);
00132             void cftf161(double *, double *);
00133             void cftf162(float *, float *);
00134             void cftf162(double *, double *);
00135             void cftf081(float *, float *);
00136             void cftf081(double *, double *);
00137             void cftf082(float *, float *);
00138             void cftf082(double *, double *);
00139             void cftf040(float *);
00140             void cftf040(double *);
00141             void cftb040(float *);
00142             void cftb040(double *);
00143             void cftx020(float *);
00144             void cftx020(double *);
00145             void rftfsub(long, float *, long, float *);
00146             void rftfsub(long, double *, long, double *);
00147             void rftbsub(long, float *, long, float *);
00148             void rftbsub(long, double *, long, double *);
00149             void dctsub(long, float *, long, float *);
00150             void dctsub(long, double *, long, double *);
00151             void dstsub(long, float *, long, float *);
00152             void dstsub(long, double *, long, double *);
00153             #ifdef USE_CDFT_THREADS
00154             void cftrec4_th(long, float *, long, float *);
00155             void cftrec4_th(long, double *, long, double *);
00156             void cdft_thread_create(cdft_thread_t *, void * (*)(void *), cdft_arg_t *);
00157             void cdft_thread_wait(cdft_thread_t);
00158             #endif
00159         public:
00160             clTransformS() {}
00161             ~clTransformS() {}
00162             // Complex DFT
00163             // (2 * size, <1|-1>, input/output, work area [0] = 0 init,
00164             // cos/sin table)
00165             void cdft (long, long, float *, long *, float *);
00166             void cdft (long, long, double *, long *, double *);
00167             // Real DFT
00168             // (size, <1|-1>, input/output, work area, cos/sin table)
00169             void rdft (long, long, float *, long *, float *);
00170             void rdft (long, long, double *, long *, double *);
00171             // DCT
00172             void ddct (long, long, float *, long *, float *);
00173             void ddct (long, long, double *, long *, double *);
00174             // DST
00175             void ddst (long, long, float *, long *, float *);
00176             void ddst (long, long, double *, long *, double *);
00177             // CT of RDFT
00178             void dfct (long, float *, float *, long *, float *);
00179             void dfct (long, double *, double *, long *, double *);
00180             // ST of RDFT
00181             void dfst (long, float *, float *, long *, float *);
00182             void dfst (long, double *, double *, long *, double *);
00183             // Internal use only
00184             #ifdef USE_CDFT_THREADS
00185             void * cftrec1f_th(void *);
00186             void * cftrec1_th(void *);
00187             void * cftrec2f_th(void *);
00188             void * cftrec2_th(void *);
00189             #endif
00190     };
00191 
00192 #endif
00193 

Generated on Tue Mar 2 19:46:46 2004 for libDSP by doxygen 1.3.6