예제 #1
0
파일: dlm_xft.c 프로젝트: thias42/dLabPro
/**
 * Computes the complex (inverse) fast Fourier transform.
 * 
 * @param RE
 *          Pointer to an array containing the real part of the input, will be
 *          overwritten with real part of output.
 * @param IM
 *          Pointer to an array containing the imaginary part of the input, will
 *          be overwritten with imaginary part of output.
 * @param nXL
 *          Length of signals, must be a power of 2 (otherwise the function will
 *          return an <code>ERR_MDIM</code> error)
 * @param bInv
 *          If non-zero the function computes the inverse complex Fourier
 *          transform
 * @return <code>O_K</code> if successfull, a (begative) error code otherwise
 * 
 * <h4>Remarks</h4>
 * <ul>
 *   <li>The function creates the tables by its own, stores them in static arrays and
 *   reuses them for all subsequent calls with the same value of <code>nXL</code>.</li>
 * </ul>
 */
INT16 dlm_fft
(
  FLOAT64*       RE,
  FLOAT64*       IM,
  INT32          nXL,
  INT16          bInv
)
{
  extern int ifft(FLOAT64*,FLOAT64*,const int);
  extern int fft(FLOAT64*,FLOAT64*,const int);
  INT16  order;

  /* Initialize */                                                               /* --------------------------------- */
  order = (INT16)dlm_log2_i(nXL);                                                /* Compute FFT order                 */
  if (order<=0) return ERR_MDIM;                                                 /* nXL is not power of 2 --> ://     */
#ifndef __NOXALLOC
  DLPASSERT(dlp_size(RE)>=nXL*sizeof(FLOAT64));                                  /* Assert RE has the right length    */
  DLPASSERT(dlp_size(IM)>=nXL*sizeof(FLOAT64));                                  /* Assert IM has the right length    */
#endif

  if(bInv) {
    if(ifft(RE,IM,nXL) != 0) return NOT_EXEC;
  } else {
    if(fft(RE,IM,nXL) != 0) return NOT_EXEC;
  }

  return O_K;                                                                    /* All done                          */
}
예제 #2
0
/**
 * Analyse a frame
 *
 * Derived instances of FBAproc should override method
 * Analyse() to add the desired functionality
 *
 * @return O_K if successfull, NOT_EXEC otherwise
 */
INT16 CGEN_PROTECTED CFWTproc::AnalyzeFrame()
{
  INT16  ret = NOT_EXEC;

  if(dlm_log2_i(m_nLen) == -1)                                               /* handle to short signal array */
  {
    return ret = FWT_DIM_ERROR;
  }

  if(m_bHaar == true)
  {
    ret = dlm_fwt_haar((FLOAT64*)m_idRealFrame->XAddr(0,0),
                       (FLOAT64*)m_idRealFrame->XAddr(0,0),
                       m_nLen,
                       m_nLevel);
  }
  else
  {
    ret = dlm_fwt_d4((FLOAT64*)m_idRealFrame->XAddr(0,0),
                     (FLOAT64*)m_idRealFrame->XAddr(0,0),
                     m_nLen,
                     m_nLevel);
  }

  return ret;
}
예제 #3
0
파일: fwt_work.cpp 프로젝트: gitgun/dLabPro
/**
 * Analyse a frame
 *
 * Derived instances of FBAproc should override method
 * Analyse() to add the desired functionality
 *
 * @return O_K if successfull, NOT_EXEC otherwise
 */
INT16 CGEN_PROTECTED CFWTproc::AnalyzeFrame()
{
  INT16  ret = NOT_EXEC;
  INT16  di=GetDindex();

  if(dlm_log2_i(m_nLen) == -1)                                               /* handle to short signal array */
  {
    return ret = FWT_DIM_ERROR;
  }
  if(!di) return IERROR(this,ERR_INVALARG,"wvltype invalid",0,0);

  return dlm_fwt_dx((FLOAT64*)m_idRealFrame->XAddr(0,0),
                       (FLOAT64*)m_idRealFrame->XAddr(0,0),
                       m_nLen,
                       di,
                       m_nLevel);
}