filters.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /* Copyright (C) 2002 Jean-Marc Valin */
  2. /**
  3. @file filters.h
  4. @brief Various analysis/synthesis filters
  5. */
  6. /*
  7. Redistribution and use in source and binary forms, with or without
  8. modification, are permitted provided that the following conditions
  9. are met:
  10. - Redistributions of source code must retain the above copyright
  11. notice, this list of conditions and the following disclaimer.
  12. - Redistributions in binary form must reproduce the above copyright
  13. notice, this list of conditions and the following disclaimer in the
  14. documentation and/or other materials provided with the distribution.
  15. - Neither the name of the Xiph.org Foundation nor the names of its
  16. contributors may be used to endorse or promote products derived from
  17. this software without specific prior written permission.
  18. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
  22. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  23. EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  24. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  25. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  26. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  27. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #ifndef FILTERS_H
  31. #define FILTERS_H
  32. #include "arch.h"
  33. spx_word16_t compute_rms(const spx_sig_t *x, int len);
  34. spx_word16_t compute_rms16(const spx_word16_t *x, int len);
  35. void signal_mul(const spx_sig_t *x, spx_sig_t *y, spx_word32_t scale, int len);
  36. void signal_div(const spx_word16_t *x, spx_word16_t *y, spx_word32_t scale, int len);
  37. #ifdef FIXED_POINT
  38. int normalize16(const spx_sig_t *x, spx_word16_t *y, spx_sig_t max_scale, int len);
  39. #endif
  40. #define HIGHPASS_NARROWBAND 0
  41. #define HIGHPASS_WIDEBAND 2
  42. #define HIGHPASS_INPUT 0
  43. #define HIGHPASS_OUTPUT 1
  44. #define HIGHPASS_IRS 4
  45. void highpass(const spx_word16_t *x, spx_word16_t *y, int len, int filtID, spx_mem_t *mem);
  46. void qmf_decomp(const spx_word16_t *xx, const spx_word16_t *aa, spx_word16_t *, spx_word16_t *y2, int N, int M, spx_word16_t *mem, char *stack);
  47. void qmf_synth(const spx_word16_t *x1, const spx_word16_t *x2, const spx_word16_t *a, spx_word16_t *y, int N, int M, spx_word16_t *mem1, spx_word16_t *mem2, char *stack);
  48. void filter_mem16(const spx_word16_t *x, const spx_coef_t *num, const spx_coef_t *den, spx_word16_t *y, int N, int ord, spx_mem_t *mem, char *stack);
  49. #ifdef MERGE_FILTERS
  50. #define OVERRIDE_IIR_MEM16
  51. #define OVERRIDE_FIR_MEM16
  52. extern const spx_word16_t zeros[];
  53. #define iir_mem16(x, den, y, N, ord, mem, stack) filter_mem16(x, zeros, den, y, N, ord, mem, stack)
  54. #define fir_mem16(x, num, y, N, ord, mem, stack) filter_mem16(x, num, zeros, y, N, ord, mem, stack)
  55. #else /* MERGE_FILTERS */
  56. void iir_mem16(const spx_word16_t *x, const spx_coef_t *den, spx_word16_t *y, int N, int ord, spx_mem_t *mem, char *stack);
  57. void fir_mem16(const spx_word16_t *x, const spx_coef_t *num, spx_word16_t *y, int N, int ord, spx_mem_t *mem, char *stack);
  58. #endif /* MERGE_FILTERS */
  59. /* Apply bandwidth expansion on LPC coef */
  60. void bw_lpc(spx_word16_t , const spx_coef_t *lpc_in, spx_coef_t *lpc_out, int order);
  61. void sanitize_values32(spx_word32_t *vec, spx_word32_t min_val, spx_word32_t max_val, int len);
  62. void syn_percep_zero16(const spx_word16_t *xx, const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_word16_t *y, int N, int ord, char *stack);
  63. void residue_percep_zero16(const spx_word16_t *xx, const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_word16_t *y, int N, int ord, char *stack);
  64. void compute_impulse_response(const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_word16_t *y, int N, int ord, char *stack);
  65. void multicomb(
  66. spx_word16_t *exc, /*decoded excitation*/
  67. spx_word16_t *new_exc, /*enhanced excitation*/
  68. spx_coef_t *ak, /*LPC filter coefs*/
  69. int p, /*LPC order*/
  70. int nsf, /*sub-frame size*/
  71. int pitch, /*pitch period*/
  72. int max_pitch, /*pitch gain (3-tap)*/
  73. spx_word16_t comb_gain, /*gain of comb filter*/
  74. char *stack
  75. );
  76. #define filter10(x, num, den, y, N, mem, stack) filter_mem16(x, num, den, y, N, 10, mem, stack)
  77. #endif