/*---------------------------------------------------------------------------*/
/*
  File: sbfpfft.h

  Block floating point FFT utilities for Blackfin.
*/
/*---------------------------------------------------------------------------*/

#ifndef SBFPFFT_H_
#define SBFPFFT_H_

#if defined(DIVA_BF53X)
#define SBFPFFT_ASM
#endif

#ifndef _LANGUAGE_ASM
#ifndef SDSPUTIL_H_
#include "sdsputil.h"
#endif
#endif

#ifdef __cplusplus
extern "C" {
#endif
/*---------------------------------------------------------------------------*/

#define SBFPFFT_MAX_FFT_SIZE_EXP          10
#define SBFPFFT_MAX_FFT_SIZE              (1 << SBFPFFT_MAX_FFT_SIZE_EXP)

#ifndef _LANGUAGE_ASM

#define sbfpfft_global_fft_buffer() (pdiva_task->sbfpfft_global_fft_buffer)
void sbfpfft_normalize (t_complex_short *fft_buffer, word fft_size, short *p_fft_exp, short bias_exp);
void sbfpfft_window (t_complex_short *fft_buffer, word fft_size, short *p_fft_exp);
void sbfpfft_custom_window (t_complex_short *fft_buffer, word fft_size, short *p_fft_exp, const short *neg_coefs, word coef_step);
void sbfpfft_execute (t_complex_short *fft_buffer, word fft_size, short *p_fft_exp);
void sbfpfft_invert_scale (t_complex_short *fft_buffer, word fft_size, short *p_fft_exp);
void sbfpfft_denormalize (t_complex_short *fft_buffer, word fft_size, short fft_exp, short result_exp);
void sbfpfft_sqr (t_complex_short *fft_buffer, word fft_size, short *p_fft_exp);
void sbfpfft_sqrt (t_complex_short *fft_buffer, word fft_size, short *p_fft_exp);
void sbfpfft_log (t_complex_short *fft_buffer, word fft_size, short fft_exp, word threshold);
short sbfpfft_magnitude (const t_complex_short *fft_buffer, word fft_size, short fft_exp, word *magnitude_buffer);
void sbfpfft_norm (const t_complex_short *fft_buffer, word fft_size, t_complex_short *result_buffer);
void sbfpfft_denorm (t_complex_short *fft_buffer, word fft_size, const word *magnitude_buffer);
void sbfpfft_mirror (t_complex_short *fft_buffer, word fft_size);
void sbfpfft_rotate_positive (t_complex_short *fft_buffer, word fft_size, const t_complex_short *angle_buffer);
void sbfpfft_rotate_negative (t_complex_short *fft_buffer, word fft_size, const t_complex_short *angle_buffer);
void sbfpfft_rotate_positive_norm (t_complex_short *fft_buffer, word fft_size, const t_complex_short *angle_buffer);
void sbfpfft_rotate_negative_norm (t_complex_short *fft_buffer, word fft_size, const t_complex_short *angle_buffer);
void sbfpfft_rotate_difference_norm (const t_complex_short *plus_angle_buffer, word fft_size,
  const t_complex_short *minus_angle_buffer, t_complex_short *result_buffer);

#endif
/*---------------------------------------------------------------------------*/
#ifdef __cplusplus
}
#endif

#endif

/*---------------------------------------------------------------------------*/
