Team Fortress 2 Source Code as on 22/4/2020
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.

138 lines
5.0 KiB

  1. /* Copyright (C) 2002 Jean-Marc Valin
  2. File: ltp.h
  3. Long-Term Prediction functions
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions
  6. are met:
  7. - Redistributions of source code must retain the above copyright
  8. notice, this list of conditions and the following disclaimer.
  9. - Redistributions in binary form must reproduce the above copyright
  10. notice, this list of conditions and the following disclaimer in the
  11. documentation and/or other materials provided with the distribution.
  12. - Neither the name of the Xiph.org Foundation nor the names of its
  13. contributors may be used to endorse or promote products derived from
  14. this software without specific prior written permission.
  15. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  16. ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  17. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  18. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
  19. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  20. EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  21. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  22. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  23. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  24. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. #include "speex_bits.h"
  28. typedef struct ltp_params {
  29. signed char *gain_cdbk;
  30. int gain_bits;
  31. int pitch_bits;
  32. } ltp_params;
  33. void open_loop_nbest_pitch(float *sw, int start, int end, int len, int *pitch, float *gain, int N, char *stack);
  34. /** Finds the best quantized 3-tap pitch predictor by analysis by synthesis */
  35. int pitch_search_3tap(
  36. float target[], /* Target vector */
  37. float *sw,
  38. float ak[], /* LPCs for this subframe */
  39. float awk1[], /* Weighted LPCs #1 for this subframe */
  40. float awk2[], /* Weighted LPCs #2 for this subframe */
  41. float exc[], /* Overlapping codebook */
  42. void *par,
  43. int start, /* Smallest pitch value allowed */
  44. int end, /* Largest pitch value allowed */
  45. float pitch_coef, /* Voicing (pitch) coefficient */
  46. int p, /* Number of LPC coeffs */
  47. int nsf, /* Number of samples in subframe */
  48. SpeexBits *bits,
  49. char *stack,
  50. float *exc2,
  51. float *r,
  52. int complexity
  53. );
  54. /*Unquantize adaptive codebook and update pitch contribution*/
  55. void pitch_unquant_3tap(
  56. float exc[], /* Excitation */
  57. int start, /* Smallest pitch value allowed */
  58. int end, /* Largest pitch value allowed */
  59. float pitch_coef, /* Voicing (pitch) coefficient */
  60. void *par,
  61. int nsf, /* Number of samples in subframe */
  62. int *pitch_val,
  63. float *gain_val,
  64. SpeexBits *bits,
  65. char *stack,
  66. int lost,
  67. int subframe_offset,
  68. float last_pitch_gain
  69. );
  70. float pitch_gain_search_3tap(
  71. float target[], /* Target vector */
  72. float ak[], /* LPCs for this subframe */
  73. float awk1[], /* Weighted LPCs #1 for this subframe */
  74. float awk2[], /* Weighted LPCs #2 for this subframe */
  75. float exc[], /* Excitation */
  76. void *par,
  77. int pitch, /* Pitch value */
  78. int p, /* Number of LPC coeffs */
  79. int nsf, /* Number of samples in subframe */
  80. SpeexBits *bits,
  81. char *stack,
  82. float *exc2,
  83. float *r,
  84. int *cdbk_index
  85. );
  86. /** Forced pitch delay and gain */
  87. int forced_pitch_quant(
  88. float target[], /* Target vector */
  89. float *sw,
  90. float ak[], /* LPCs for this subframe */
  91. float awk1[], /* Weighted LPCs #1 for this subframe */
  92. float awk2[], /* Weighted LPCs #2 for this subframe */
  93. float exc[], /* Excitation */
  94. void *par,
  95. int start, /* Smallest pitch value allowed */
  96. int end, /* Largest pitch value allowed */
  97. float pitch_coef, /* Voicing (pitch) coefficient */
  98. int p, /* Number of LPC coeffs */
  99. int nsf, /* Number of samples in subframe */
  100. SpeexBits *bits,
  101. char *stack,
  102. float *exc2,
  103. float *r,
  104. int complexity
  105. );
  106. /** Unquantize forced pitch delay and gain */
  107. void forced_pitch_unquant(
  108. float exc[], /* Excitation */
  109. int start, /* Smallest pitch value allowed */
  110. int end, /* Largest pitch value allowed */
  111. float pitch_coef, /* Voicing (pitch) coefficient */
  112. void *par,
  113. int nsf, /* Number of samples in subframe */
  114. int *pitch_val,
  115. float *gain_val,
  116. SpeexBits *bits,
  117. char *stack,
  118. int lost,
  119. int subframe_offset,
  120. float last_pitch_gain
  121. );