home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 275 / DPCS0111DVD.ISO / Toolkit / Audio-Visual / VirtualDub / Source / VirtualDub-1.9.10-src.7z / src / h / vd2 / VDLib / fft.h < prev    next >
Encoding:
C/C++ Source or Header  |  2009-09-14  |  2.2 KB  |  79 lines

  1. //    VirtualDub - Video processing and capture application
  2. //    Application helper library
  3. //    Copyright (C) 1998-2006 Avery Lee
  4. //
  5. //    This program is free software; you can redistribute it and/or modify
  6. //    it under the terms of the GNU General Public License as published by
  7. //    the Free Software Foundation; either version 2 of the License, or
  8. //    (at your option) any later version.
  9. //
  10. //    This program is distributed in the hope that it will be useful,
  11. //    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. //    GNU General Public License for more details.
  14. //
  15. //    You should have received a copy of the GNU General Public License
  16. //    along with this program; if not, write to the Free Software
  17. //    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19. #ifndef f_VD2_VDLIB_FFT_H
  20. #define f_VD2_VDLIB_FFT_H
  21.  
  22. #include <vd2/system/vdtypes.h>
  23.  
  24. void VDMakePermuteTable(uint32 *dst0, unsigned bits);
  25. void VDCreateRaisedCosineWindow(float *dst, int n);
  26. void VDPermuteRevBitsComplex(float *v, unsigned bits, const uint32 *permuteTable);
  27. void VDComputeComplexFFT_DIT(float *p, unsigned bits);
  28. void VDComputeRealFFT(float *p, unsigned bits);
  29. void VDComputeComplexFFT_DIF(float *p, unsigned bits);
  30. void VDComputeRealIFFT(float *p, unsigned bits);
  31. void VDComputeComplexFFT_Reference(float *out, float *in, unsigned bits, double sign = -1);
  32.  
  33. class VDRealFFT {
  34. public:
  35.     VDRealFFT();
  36.     VDRealFFT(unsigned bits);
  37.     ~VDRealFFT();
  38.  
  39.     void Init(unsigned bits);
  40.     void Shutdown();
  41.  
  42.     void ComputeRealFFT(float *p);
  43.     void ComputeRealIFFT(float *p);
  44.  
  45. protected:
  46.     unsigned mBits;
  47.     uint32 *mpPermuteTable;
  48.     float *mpWeightTable;
  49. };
  50.  
  51. class VDRollingRealFFT {
  52. public:
  53.     VDRollingRealFFT();
  54.     VDRollingRealFFT(unsigned bits);
  55.     ~VDRollingRealFFT();
  56.  
  57.     void Init(unsigned bits);
  58.     void Shutdown();
  59.  
  60.     void Clear();
  61.     void Advance(uint32 samples);
  62.     void CopyIn8U(const uint8 *src, uint32 count, ptrdiff_t stride);
  63.     void CopyIn16S(const sint16 *src, uint32 count, ptrdiff_t stride);
  64.  
  65.     void Transform();
  66.  
  67.     float GetPower(int bin) const;
  68.  
  69. protected:
  70.     uint32    mPoints;
  71.     uint32    mBufferLevel;
  72.     float *mpWindow;
  73.     float *mpSampleBuffer;
  74.     float *mpTempArea;
  75.     VDRealFFT mFFT;
  76. };
  77.  
  78. #endif
  79.