Leaked source code of windows server 2003
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.

288 lines
7.0 KiB

  1. /*
  2. **
  3. ** File: "cst_lbc.h"
  4. **
  5. ** Description: This file contains global definition of the SG15
  6. ** LBC Coder for 6.3/5.3 kbps.
  7. **
  8. */
  9. /*
  10. ITU-T G.723 Floating Point Speech Coder ANSI C Source Code. Version 3.01
  11. Original fixed-point code copyright (c) 1995,
  12. AudioCodes, DSP Group, France Telecom, Universite de Sherbrooke.
  13. All rights reserved.
  14. Floating-point code copyright (c) 1995,
  15. Intel Corporation and France Telecom (CNET).
  16. All rights reserved.
  17. */
  18. /*
  19. This file contains global definition of the SG15
  20. LBR Coder for 6.4/5.3 kbps.
  21. */
  22. #include "typedef.h"
  23. #define False 0
  24. #define True 1
  25. //#if NOTMINI
  26. #define FALSE 0
  27. #define TRUE 1
  28. //#endif
  29. /* Definition of the working mode */
  30. enum Wmode { Both, Cod, Dec } ;
  31. /* Coder rate */
  32. //enum Crate { Silent, Rate53, Rate63, Lost } ;
  33. /* Changed in V4.1 */
  34. enum Crate { Rate63, Rate53, Silent, Lost } ;
  35. /* Coder global constants */
  36. #define Frame 240
  37. #define LpcFrame 180
  38. #define SubFrames 4
  39. #define SubFrLen (Frame/SubFrames)
  40. #define LpcOrder 10
  41. #define RidgeFact 10
  42. #define CosineTableSize 512
  43. #define PreCoef -0.25f
  44. #define LspPrd0 12288
  45. #define LspPrd1 23552
  46. #define LspPred0 (12.0f/32.0f)
  47. #define LspPred1 (23.0f/32.0f)
  48. #define LspQntBands 3
  49. #define LspCbSize 256
  50. #define LspCbBits 8
  51. #define PitchMin 18
  52. #define PitchMax (PitchMin+127)
  53. #define PwRange 3
  54. #define ClPitchOrd 5
  55. #define Pstep 1
  56. #define NbFilt085 85
  57. #define NbFilt170 170
  58. #define Sgrid 2
  59. #define MaxPulseNum 6
  60. #define MlqSteps 2
  61. /* acelp constants */
  62. #define SubFrLen2 (SubFrLen +4)
  63. #define DIM_RR 416
  64. #define NB_POS 8
  65. #define STEP 8
  66. #define MSIZE 64
  67. #define threshold 0.5f
  68. #define max_time 120
  69. #define NumOfGainLev 24
  70. #define ErrMaxNum 3
  71. /* Taming constants */
  72. #define NbFilt085_min 51
  73. #define NbFilt170_min 93
  74. #define SizErr 5
  75. #define Err0 0.00000381464f
  76. #define ThreshErr 128.0f
  77. #define SRCSTATELEN 16 // sample rate conversion state length
  78. #ifdef LOG_ENCODE_TIMINGS_ON // { LOG_ENCODE_TIMINGS_ON
  79. /* Encoder Timing Data - per frame
  80. */
  81. typedef struct {
  82. unsigned long dwEncode;
  83. #ifdef DETAILED_ENCODE_TIMINGS_ON // { DETAILED_ENCODE_TIMINGS_ON
  84. unsigned long dwRem_Dc;
  85. unsigned long dwComp_Lpc;
  86. unsigned long dwAtoLsp;
  87. unsigned long dwLsp_Qnt;
  88. unsigned long dwLsp_Inq;
  89. unsigned long dwLsp_Int;
  90. unsigned long dwMem_Shift;
  91. unsigned long dwWght_Lpc;
  92. unsigned long dwError_Wght;
  93. unsigned long dwFew_Lps_In_Coder;
  94. unsigned long dwFilt_Pw;
  95. unsigned long dwComp_Ir;
  96. unsigned long dwSub_Ring;
  97. unsigned long dwFind_Acbk;
  98. unsigned long dwFind_Fcbk;
  99. unsigned long dwDecode_Acbk;
  100. unsigned long dwReconstr_Excit;
  101. unsigned long dwUpd_Ring;
  102. unsigned long dwLine_Pack;
  103. #endif // } DETAILED_ENCODE_TIMINGS_ON
  104. } ENC_TIMING_INFO;
  105. // 2057 frames will allow us to store stats
  106. // for all of our Geo08kHz16BitMonoPCM.wav
  107. // test file...
  108. #define ENC_TIMING_INFO_FRAME_COUNT 2057
  109. #endif // } LOG_ENCODE_TIMINGS_ON
  110. #ifdef LOG_DECODE_TIMINGS_ON // { LOG_DECODE_TIMINGS_ON
  111. /* Encoder Timing Data - per frame
  112. */
  113. typedef struct {
  114. unsigned long dwDecode;
  115. #ifdef DETAILED_DECODE_TIMINGS_ON // { DETAILED_DECODE_TIMINGS_ON
  116. unsigned long dwLine_Unpk;
  117. unsigned long dwLsp_Inq;
  118. unsigned long dwLsp_Int;
  119. unsigned long dwVariousD;
  120. unsigned long dwFcbk_UnpkD;
  121. unsigned long dwDecod_AcbkD;
  122. unsigned long dwComp_Info;
  123. unsigned long dwRegen;
  124. unsigned long dwSynt;
  125. #endif // } DETAILED_DECODE_TIMINGS_ON
  126. } DEC_TIMING_INFO;
  127. // 2057 frames will allow us to store stats
  128. // for all of our Geo08kHz16BitMonoPCM.wav
  129. // test file...
  130. #define DEC_TIMING_INFO_FRAME_COUNT 2057
  131. #endif // } LOG_DECODE_TIMINGS_ON
  132. /*
  133. Used structures
  134. */
  135. typedef struct {
  136. float HpfZdl;
  137. float HpfPdl;
  138. /* Lsp previous vector */
  139. float PrevLsp[LpcOrder] ;
  140. /* All pitch operation buffers */
  141. float PrevWgt[PitchMax] ;
  142. float PrevErr[PitchMax] ;
  143. float PrevExc[PitchMax] ;
  144. /* Requered memory for the delay */
  145. float PrevDat[LpcFrame-SubFrLen] ;
  146. /* Used delay lines */
  147. float WghtFirDl[2*LpcOrder];
  148. float WghtIirDl[2*LpcOrder];
  149. float RingFirDl[2*LpcOrder];
  150. float RingIirDl[2*LpcOrder];
  151. /* For taming procedure */
  152. int SinDet;
  153. float Err[SizErr];
  154. //These entries are not part of the ITU 723 std.
  155. int p;
  156. int q;
  157. int srccount; // sampling rate conversion count
  158. short srcstate[SRCSTATELEN]; // sampling rate conversion state
  159. // Lsp previous vector
  160. /* All pitch operation buffers */
  161. int VadAct;
  162. Flag UseHp;
  163. enum Crate WrkRate;
  164. int quality;
  165. #ifdef LOG_ENCODE_TIMINGS_ON // { LOG_ENCODE_TIMINGS_ON
  166. ENC_TIMING_INFO EncTimingInfo[ENC_TIMING_INFO_FRAME_COUNT];
  167. unsigned long dwStatFrameCount;
  168. int bTimingThisFrame;
  169. unsigned long dwStartLow;
  170. unsigned long dwStartHigh;
  171. #endif // } LOG_ENCODE_TIMINGS_ON
  172. } CODDEF ;
  173. typedef struct {
  174. int Ecount;
  175. float InterGain;
  176. int InterIndx;
  177. int Rseed;
  178. // Lsp previous vector
  179. // Name changed to avoid confusion with encoder
  180. // previous LSPs
  181. //float PrevLSP[LpcOrder];
  182. float dPrevLsp[LpcOrder];
  183. /* All pitch operation buffers */
  184. // Name changed to avoid confusion with encoder
  185. // previous excitation
  186. //float PrevExc[PitchMax];
  187. float dPrevExc[PitchMax] ;
  188. /* Used delay lines */
  189. float SyntIirDl[2*LpcOrder] ;
  190. //These entries are not part of the ITU 723 std.
  191. int dp;
  192. int dq;
  193. int srccount; // sampling rate conversion count
  194. short srcstate[SRCSTATELEN]; // sampling rate conversion state
  195. short srcbuff[480]; // sampling rate conversion buffer
  196. int i;
  197. int VadAct;
  198. Flag UsePf;
  199. enum Crate WrkRate;
  200. #ifdef LOG_DECODE_TIMINGS_ON // { LOG_DECODE_TIMINGS_ON
  201. DEC_TIMING_INFO DecTimingInfo[DEC_TIMING_INFO_FRAME_COUNT];
  202. unsigned long dwStatFrameCount;
  203. int bTimingThisFrame;
  204. unsigned long dwStartLow;
  205. unsigned long dwStartHigh;
  206. #endif // } LOG_DECODE_TIMINGS_ON
  207. } DECDEF ;
  208. typedef struct {
  209. int AcLg;
  210. int AcGn;
  211. int Mamp;
  212. int Grid;
  213. int Tran;
  214. int Pamp;
  215. Word32 Ppos;
  216. } SFSDEF;
  217. typedef struct {
  218. int Crc ;
  219. Word32 LspId ;
  220. int Olp[SubFrames/2] ;
  221. SFSDEF Sfs[SubFrames] ;
  222. } LINEDEF ;
  223. typedef struct {
  224. int Indx;
  225. float Gain;
  226. } PWDEF;
  227. typedef struct {
  228. float MaxErr ;
  229. int GridId ;
  230. int MampId ;
  231. int UseTrn ;
  232. int Ploc[MaxPulseNum] ;
  233. float Pamp[MaxPulseNum] ;
  234. } BESTDEF ;
  235. /* Prototype used for the ACELP codebook */