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.

121 lines
4.4KB

  1. /*
  2. * various filters for CELP-based codecs
  3. *
  4. * Copyright (c) 2008 Vladimir Voroshilov
  5. *
  6. * This file is part of Libav.
  7. *
  8. * Libav is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * Libav is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with Libav; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #ifndef AVCODEC_CELP_FILTERS_H
  23. #define AVCODEC_CELP_FILTERS_H
  24. #include <stdint.h>
  25. /**
  26. * Circularly convolve fixed vector with a phase dispersion impulse
  27. * response filter (D.6.2 of G.729 and 6.1.5 of AMR).
  28. * @param fc_out vector with filter applied
  29. * @param fc_in source vector
  30. * @param filter phase filter coefficients
  31. *
  32. * fc_out[n] = sum(i,0,len-1){ fc_in[i] * filter[(len + n - i)%len] }
  33. *
  34. * @note fc_in and fc_out should not overlap!
  35. */
  36. void ff_celp_convolve_circ(int16_t *fc_out, const int16_t *fc_in,
  37. const int16_t *filter, int len);
  38. /**
  39. * Add an array to a rotated array.
  40. *
  41. * out[k] = in[k] + fac * lagged[k-lag] with wrap-around
  42. *
  43. * @param out result vector
  44. * @param in samples to be added unfiltered
  45. * @param lagged samples to be rotated, multiplied and added
  46. * @param lag lagged vector delay in the range [0, n]
  47. * @param fac scalefactor for lagged samples
  48. * @param n number of samples
  49. */
  50. void ff_celp_circ_addf(float *out, const float *in,
  51. const float *lagged, int lag, float fac, int n);
  52. /**
  53. * LP synthesis filter.
  54. * @param[out] out pointer to output buffer
  55. * @param filter_coeffs filter coefficients (-0x8000 <= (3.12) < 0x8000)
  56. * @param in input signal
  57. * @param buffer_length amount of data to process
  58. * @param filter_length filter length (10 for 10th order LP filter)
  59. * @param stop_on_overflow 1 - return immediately if overflow occurs
  60. * 0 - ignore overflows
  61. * @param shift the result is shifted right by this value
  62. * @param rounder the amount to add for rounding (usually 0x800 or 0xfff)
  63. *
  64. * @return 1 if overflow occurred, 0 - otherwise
  65. *
  66. * @note Output buffer must contain filter_length samples of past
  67. * speech data before pointer.
  68. *
  69. * Routine applies 1/A(z) filter to given speech data.
  70. */
  71. int ff_celp_lp_synthesis_filter(int16_t *out, const int16_t *filter_coeffs,
  72. const int16_t *in, int buffer_length,
  73. int filter_length, int stop_on_overflow,
  74. int shift, int rounder);
  75. /**
  76. * LP synthesis filter.
  77. * @param[out] out pointer to output buffer
  78. * - the array out[-filter_length, -1] must
  79. * contain the previous result of this filter
  80. * @param filter_coeffs filter coefficients.
  81. * @param in input signal
  82. * @param buffer_length amount of data to process
  83. * @param filter_length filter length (10 for 10th order LP filter). Must be
  84. * greater than 4 and even.
  85. *
  86. * @note Output buffer must contain filter_length samples of past
  87. * speech data before pointer.
  88. *
  89. * Routine applies 1/A(z) filter to given speech data.
  90. */
  91. void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs,
  92. const float *in, int buffer_length,
  93. int filter_length);
  94. /**
  95. * LP zero synthesis filter.
  96. * @param[out] out pointer to output buffer
  97. * @param filter_coeffs filter coefficients.
  98. * @param in input signal
  99. * - the array in[-filter_length, -1] must
  100. * contain the previous input of this filter
  101. * @param buffer_length amount of data to process
  102. * @param filter_length filter length (10 for 10th order LP filter)
  103. *
  104. * @note Output buffer must contain filter_length samples of past
  105. * speech data before pointer.
  106. *
  107. * Routine applies A(z) filter to given speech data.
  108. */
  109. void ff_celp_lp_zero_synthesis_filterf(float *out, const float *filter_coeffs,
  110. const float *in, int buffer_length,
  111. int filter_length);
  112. #endif /* AVCODEC_CELP_FILTERS_H */