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.

116 lines
4.0KB

  1. /*
  2. * various filters for ACELP-based codecs
  3. *
  4. * Copyright (c) 2008 Vladimir Voroshilov
  5. *
  6. * This file is part of FFmpeg.
  7. *
  8. * FFmpeg 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. * FFmpeg 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 FFmpeg; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #ifndef FFMPEG_ACELP_FILTERS_H
  23. #define FFMPEG_ACELP_FILTERS_H
  24. #include <stdint.h>
  25. /**
  26. * \brief 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_acelp_convolve_circ(
  37. int16_t* fc_out,
  38. const int16_t* fc_in,
  39. const int16_t* filter,
  40. int subframe_size);
  41. /**
  42. * \brief LP synthesis filter
  43. * \param out [out] pointer to output buffer
  44. * \param filter_coeffs filter coefficients (-0x8000 <= (3.12) < 0x8000)
  45. * \param in input signal
  46. * \param buffer_length amount of data to process
  47. * \param filter_length filter length (11 for 10th order LP filter)
  48. * \param stop_on_overflow 1 - return immediately if overflow occurs
  49. * 0 - ignore overflows
  50. *
  51. * \return 1 if overflow occurred, 0 - otherwise
  52. *
  53. * \note Output buffer must contain 10 samples of past
  54. * speech data before pointer.
  55. *
  56. * Routine applies 1/A(z) filter to given speech data.
  57. */
  58. int ff_acelp_lp_synthesis_filter(
  59. int16_t *out,
  60. const int16_t* filter_coeffs,
  61. const int16_t* in,
  62. int buffer_length,
  63. int filter_length,
  64. int stop_on_overflow);
  65. /**
  66. * \brief Calculates coefficients of weighted A(z/weight) filter.
  67. * \param out [out] weighted A(z/weight) result
  68. * filter (-0x8000 <= (3.12) < 0x8000)
  69. * \param in source filter (-0x8000 <= (3.12) < 0x8000)
  70. * \param weight_pow array containing weight^i (-0x8000 <= (0.15) < 0x8000)
  71. * \param filter_length filter length (11 for 10th order LP filter)
  72. *
  73. * out[i]=weight_pow[i]*in[i] , i=0..9
  74. */
  75. void ff_acelp_weighted_filter(
  76. int16_t *out,
  77. const int16_t* in,
  78. const int16_t *weight_pow,
  79. int filter_length);
  80. /**
  81. * \brief high-pass filtering and upscaling (4.2.5 of G.729)
  82. * \param out [out] output buffer for filtered speech data
  83. * \param hpf_f [in/out] past filtered data from previous (2 items long)
  84. * frames (-0x20000000 <= (14.13) < 0x20000000)
  85. * \param in speech data to process
  86. * \param length input data size
  87. *
  88. * out[i] = 0.93980581 * in[i] - 1.8795834 * in[i-1] + 0.93980581 * in[i-2] +
  89. * 1.9330735 * out[i-1] - 0.93589199 * out[i-2]
  90. *
  91. * The filter has a cut-off frequency of 100Hz
  92. *
  93. * \note Two items before the top of the out buffer must contain two items from the
  94. * tail of the previous subframe.
  95. *
  96. * \remark It is safe to pass the same array in in and out parameters.
  97. *
  98. * \remark AMR uses mostly the same filter (cut-off frequency 60Hz, same formula,
  99. * but constants differs in 5th sign after comma). Fortunately in
  100. * fixed-point all coefficients are the same as in G.729. Thus this
  101. * routine can be used for the fixed-point AMR decoder, too.
  102. */
  103. void ff_acelp_high_pass_filter(
  104. int16_t* out,
  105. int hpf_f[2],
  106. const int16_t* in,
  107. int length);
  108. #endif /* FFMPEG_ACELP_FILTERS_H */