celp_filters.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * various filters for CELP-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 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(
  37. int16_t* fc_out,
  38. const int16_t* fc_in,
  39. const int16_t* filter,
  40. int len);
  41. /**
  42. * 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 (10 for 10th order LP filter)
  48. * @param stop_on_overflow 1 - return immediately if overflow occurs
  49. * 0 - ignore overflows
  50. * @param rounder the amount to add for rounding (usually 0x800 or 0xfff)
  51. *
  52. * @return 1 if overflow occurred, 0 - otherwise
  53. *
  54. * @note Output buffer must contain filter_length samples of past
  55. * speech data before pointer.
  56. *
  57. * Routine applies 1/A(z) filter to given speech data.
  58. */
  59. int ff_celp_lp_synthesis_filter(
  60. int16_t *out,
  61. const int16_t* filter_coeffs,
  62. const int16_t* in,
  63. int buffer_length,
  64. int filter_length,
  65. int stop_on_overflow,
  66. int rounder);
  67. /**
  68. * LP synthesis filter.
  69. * @param out [out] pointer to output buffer
  70. * - the array out[-filter_length, -1] must
  71. * contain the previous result of this filter
  72. * @param filter_coeffs filter coefficients.
  73. * @param in input signal
  74. * @param buffer_length amount of data to process
  75. * @param filter_length filter length (10 for 10th order LP filter)
  76. *
  77. * @note Output buffer must contain filter_length samples of past
  78. * speech data before pointer.
  79. *
  80. * Routine applies 1/A(z) filter to given speech data.
  81. */
  82. void ff_celp_lp_synthesis_filterf(
  83. float *out,
  84. const float* filter_coeffs,
  85. const float* in,
  86. int buffer_length,
  87. int filter_length);
  88. #endif /* AVCODEC_CELP_FILTERS_H */