You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.5KB

  1. /*
  2. * Lowpass IIR filter
  3. * Copyright (c) 2008 Konstantin Shishkov
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. /**
  22. * @file lowpass.h
  23. * lowpass filter interface
  24. */
  25. #ifndef FFMPEG_LOWPASS_H
  26. #define FFMPEG_LOWPASS_H
  27. #include "avcodec.h"
  28. struct FFLPFilterCoeffs;
  29. struct FFLPFilterState;
  30. /**
  31. * Initialize filter coefficients.
  32. *
  33. * @param order filter order
  34. * @param cutoff_ratio cutoff to input frequency ratio
  35. *
  36. * @return pointer to filter coefficients structure or NULL if filter cannot be created
  37. */
  38. const struct FFLPFilterCoeffs* ff_lowpass_filter_init_coeffs(int order, float cutoff_ratio);
  39. /**
  40. * Create new filter state.
  41. *
  42. * @param order filter order
  43. *
  44. * @return pointer to new filter state or NULL if state creation fails
  45. */
  46. struct FFLPFilterState* ff_lowpass_filter_init_state(int order);
  47. #if 0 //enable with arbitrary order filter implementation, use av_free() for filter state only for now
  48. /**
  49. * Free filter coefficients.
  50. *
  51. * @param coeffs pointer allocated with ff_lowpass_filter_init_coeffs()
  52. */
  53. void ff_lowpass_filter_free_coeffs(struct FFLPFilterCoeffs *coeffs);
  54. /**
  55. * Free filter state.
  56. *
  57. * @param state pointer allocated with ff_lowpass_filter_init_state()
  58. */
  59. void ff_lowpass_filter_free_state(struct FFLPFilterState *state);
  60. #endif
  61. /**
  62. * Perform lowpass filtering on input samples.
  63. *
  64. * @param coeffs pointer to filter coefficients
  65. * @param state pointer to filter state
  66. * @param size input length
  67. * @param src source samples
  68. * @param sstep source stride
  69. * @param dst filtered samples (destination may be the same as input)
  70. * @param dstep destination stride
  71. */
  72. void ff_lowpass_filter(const struct FFLPFilterCoeffs *coeffs, struct FFLPFilterState *state, int size, int16_t *src, int sstep, int16_t *dst, int dstep);
  73. #endif /* FFMPEG_LOWPASS_H */