iir.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #include "iir.h"
  2. #include <ippi.h>
  3. #include <ipps.h>
  4. #include <ippcc.h>
  5. /* 32 bit floating point */
  6. int nsutil_iir_Create_F32(const float *coefficients, int order, nsutil_iir_t *out_iir)
  7. {
  8. IppsIIRState_32f *state;
  9. ippsIIRInitAlloc_32f(&state, coefficients, order, 0);
  10. *out_iir = state;
  11. return 0;
  12. }
  13. int nsutil_iir_Filter_F32_IP(nsutil_iir_t *iir, float *samples, int num_samples)
  14. {
  15. ippsIIR_32f_I(samples, num_samples, (IppsIIRState_32f *)iir);
  16. return 0;
  17. }
  18. int nsutil_iir_Filter_F32(nsutil_iir_t *iir, const float *input, float *output, int num_samples)
  19. {
  20. ippsIIR_32f(input, output, num_samples, (IppsIIRState_32f *)iir);
  21. return 0;
  22. }
  23. int nsutil_iir_Reset_F32(nsutil_iir_t *iir)
  24. {
  25. ippsIIRSetDlyLine_32f((IppsIIRState_32f *)iir, 0);
  26. return 0;
  27. }
  28. int nsutil_iir_Destroy_F32(nsutil_iir_t *iir)
  29. {
  30. ippsIIRFree_32f((IppsIIRState_32f *)iir);
  31. return 0;
  32. }
  33. /* 64 bit floating point */
  34. int nsutil_iir_Create_F64(const double *coefficients, int order, nsutil_iir_t *out_iir)
  35. {
  36. IppsIIRState_64f *state;
  37. ippsIIRInitAlloc_64f(&state, coefficients, order, 0);
  38. *out_iir = state;
  39. return 0;
  40. }
  41. int nsutil_iir_Filter_F64_IP(nsutil_iir_t *iir, double *samples, int num_samples)
  42. {
  43. ippsIIR_64f_I(samples, num_samples, (IppsIIRState_64f *)iir);
  44. return 0;
  45. }
  46. int nsutil_iir_Filter_642(nsutil_iir_t *iir, const double *input, double *output, int num_samples)
  47. {
  48. ippsIIR_64f(input, output, num_samples, (IppsIIRState_64f *)iir);
  49. return 0;
  50. }
  51. int nsutil_iir_Reset_F64(nsutil_iir_t *iir)
  52. {
  53. ippsIIRSetDlyLine_64f((IppsIIRState_64f *)iir, 0);
  54. return 0;
  55. }
  56. int nsutil_iir_Destroy_F64(nsutil_iir_t *iir)
  57. {
  58. ippsIIRFree_64f((IppsIIRState_64f *)iir);
  59. return 0;
  60. }