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.

114 lines
3.9KB

  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. /**
  25. * \brief Circularly convolve fixed vector with a phase dispersion impulse
  26. * response filter (D.6.2 of G.729 and 6.1.5 of AMR).
  27. * \param fc_out vector with filter applied
  28. * \param fc_in source vector
  29. * \param filter phase filter coefficients
  30. *
  31. * fc_out[n] = sum(i,0,len-1){ fc_in[i] * filter[(len + n - i)%len] }
  32. *
  33. * \note fc_in and fc_out should not overlap!
  34. */
  35. void ff_acelp_convolve_circ(
  36. int16_t* fc_out,
  37. const int16_t* fc_in,
  38. const int16_t* filter,
  39. int subframe_size);
  40. /**
  41. * \brief LP synthesis filter
  42. * \param out [out] pointer to output buffer
  43. * \param filter_coeffs filter coefficients (-0x8000 <= (3.12) < 0x8000)
  44. * \param in input signal
  45. * \param buffer_length amount of data to process
  46. * \param filter_length filter length (11 for 10th order LP filter)
  47. * \param stop_on_overflow 1 - return immediately if overflow occurs
  48. * 0 - ignore overflows
  49. *
  50. * \return 1 if overflow occurred, 0 - otherwise
  51. *
  52. * \note Output buffer must contain 10 samples of past
  53. * speech data before pointer.
  54. *
  55. * Routine applies 1/A(z) filter to given speech data.
  56. */
  57. int ff_acelp_lp_synthesis_filter(
  58. int16_t *out,
  59. const int16_t* filter_coeffs,
  60. const int16_t* in,
  61. int buffer_length,
  62. int filter_length,
  63. int stop_on_overflow);
  64. /**
  65. * \brief Calculates coefficients of weighted A(z/weight) filter.
  66. * \param out [out] weighted A(z/weight) result
  67. * filter (-0x8000 <= (3.12) < 0x8000)
  68. * \param in source filter (-0x8000 <= (3.12) < 0x8000)
  69. * \param weight_pow array containing weight^i (-0x8000 <= (0.15) < 0x8000)
  70. * \param filter_length filter length (11 for 10th order LP filter)
  71. *
  72. * out[i]=weight_pow[i]*in[i] , i=0..9
  73. */
  74. void ff_acelp_weighted_filter(
  75. int16_t *out,
  76. const int16_t* in,
  77. const int16_t *weight_pow,
  78. int filter_length);
  79. /**
  80. * \brief high-pass filtering and upscaling (4.2.5 of G.729)
  81. * \param out [out] output buffer for filtered speech data
  82. * \param hpf_f [in/out] past filtered data from previous (2 items long)
  83. * frames (-0x20000000 <= (14.13) < 0x20000000)
  84. * \param in speech data to process
  85. * \param length input data size
  86. *
  87. * out[i] = 0.93980581 * in[i] - 1.8795834 * in[i-1] + 0.93980581 * in[i-2] +
  88. * 1.9330735 * out[i-1] - 0.93589199 * out[i-2]
  89. *
  90. * The filter has a cut-off frequency of 100Hz
  91. *
  92. * \note Two items before the top of the out buffer must contain two items from the
  93. * tail of the previous subframe.
  94. *
  95. * \remark It is safe to pass the same array in in and out parameters.
  96. *
  97. * \remark AMR uses mostly the same filter (cut-off frequency 60Hz, same formula,
  98. * but constants differs in 5th sign after comma). Fortunately in
  99. * fixed-point all coefficients are the same as in G.729. Thus this
  100. * routine can be used for the fixed-point AMR decoder, too.
  101. */
  102. void ff_acelp_high_pass_filter(
  103. int16_t* out,
  104. int hpf_f[2],
  105. const int16_t* in,
  106. int length);
  107. #endif // FFMPEG_ACELP_FILTERS_H