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.

598 lines
16 KiB

  1. //==========================================================================;
  2. //
  3. // INTEL Corporation Proprietary Information
  4. //
  5. // This listing is supplied under the terms of a license
  6. // agreement with INTEL Corporation and may not be copied
  7. // nor disclosed except in accordance with the terms of
  8. // that agreement.
  9. //
  10. // Copyright (c) 1996 Intel Corporation.
  11. // All Rights Reserved.
  12. //
  13. //--------------------------------------------------------------------------;
  14. //
  15. // g723.h
  16. //
  17. // Description:
  18. // This file contains prototypes for the filtering routines.
  19. //
  20. //
  21. //==========================================================================;
  22. #include "cst_lbc.h"
  23. #include "sdstruct.h"
  24. #ifndef _G723_H_
  25. #define _G723_H_
  26. #ifndef RC_INVOKED
  27. #pragma pack(1) // assume byte packing throughout
  28. #endif
  29. #ifndef EXTERN_C
  30. #ifdef __cplusplus
  31. #define EXTERN_C extern "C"
  32. #else
  33. #define EXTERN_C extern
  34. #endif
  35. #endif
  36. #ifdef __cplusplus
  37. extern "C" // assume C declarations for C++
  38. {
  39. #endif
  40. #define NETMEETING_MSG723_ACM_ID 82
  41. #define WAVE_FORMAT_MSG723 0x0042 /* Microsoft Corporation */
  42. #define G723MAGICWORD1 0xf7329ace
  43. #define G723MAGICWORD2 0xacdeaea2
  44. typedef struct msg723waveformat_tag {
  45. WAVEFORMATEX wfx;
  46. WORD wConfigWord;
  47. DWORD dwCodeword1;
  48. DWORD dwCodeword2;
  49. } MSG723WAVEFORMAT;
  50. typedef MSG723WAVEFORMAT *PMSG723WAVEFORMAT;
  51. typedef MSG723WAVEFORMAT NEAR *NPMSG723WAVEFORMAT;
  52. typedef MSG723WAVEFORMAT FAR *LPMSG723WAVEFORMAT;
  53. typedef struct {
  54. CODDEF CodStat;
  55. INSTNCE SD_Instance;
  56. } G723CODDEF;
  57. #define RATE 0x1
  58. #define POST_FILTER 0x2
  59. #define SILENCE_ENABLE 0x4
  60. //
  61. // array of sample rates supported
  62. //
  63. //
  64. const UINT G723_SAMPLING_RATE[] =
  65. {
  66. 8000,
  67. 8000,
  68. 8000,
  69. 8000
  70. };
  71. const UINT PCM_SAMPLING_RATE[] =
  72. {
  73. 11025,
  74. 8000
  75. };
  76. const UINT G723_SAMPLES_PER_BLOCK_PCM[] =
  77. {
  78. 330,
  79. 240
  80. };
  81. //
  82. //
  83. //
  84. //
  85. #define G723_MAX_CHANNELS 1
  86. #define G723_BITS_PER_SAMPLE 0
  87. #define G723_WFX_EXTRA_BYTES (sizeof(MSG723WAVEFORMAT) - sizeof(WAVEFORMATEX))
  88. #define G723_HEADER_LENGTH 0 // In bytes, per channel.
  89. #ifdef G723_USECONFIG
  90. #define G723_CONFIGTESTTIME 4 // seconds of PCM data for test.
  91. #define G723_CONFIG_DEFAULT 0x0000
  92. #define G723_CONFIG_DEFAULT_MAXRTENCODESETTING 5
  93. #define G723_CONFIG_DEFAULT_MAXRTDECODESETTING 6
  94. #define G723_CONFIG_UNCONFIGURED 0x0999
  95. #define G723_CONFIG_TEXTLEN 80
  96. #define G723_CONFIG_DEFAULTKEY HKEY_CURRENT_USER
  97. #define G723_CONFIG_MIN_ENCODE 4
  98. #define G723_CONFIG_MIN_DECODE 5
  99. #endif
  100. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  101. //
  102. // resource id's
  103. //
  104. //
  105. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  106. #define IDS_ACM_DRIVER_SHORTNAME (1) // ACMDRIVERDETAILS.szShortName
  107. #define IDS_ACM_DRIVER_LONGNAME (2) // ACMDRIVERDETAILS.szLongName
  108. #define IDS_ACM_DRIVER_COPYRIGHT (3) // ACMDRIVERDETAILS.szCopyright
  109. #define IDS_ACM_DRIVER_LICENSING (4) // ACMDRIVERDETAILS.szLicensing
  110. #define IDS_ACM_DRIVER_FEATURES (5) // ACMDRIVERDETAILS.szFeatures
  111. #define IDS_FORMAT_DETAILS_MONO_8KHZ_5333BIT_S (6)
  112. #define IDS_FORMAT_DETAILS_MONO_8KHZ_5333BIT_SID (7)
  113. #define IDS_FORMAT_DETAILS_MONO_8KHZ_6400BIT_S (8)
  114. #define IDS_FORMAT_DETAILS_MONO_8KHZ_6400BIT_SID (9)
  115. #define IDS_ACM_DRIVER_TAG_NAME (20) // ACMFORMATTAGDETAILS.szFormatTag
  116. #ifdef G723_USECONFIG
  117. //
  118. // resource id's for the configuration dialog box
  119. //
  120. #define IDS_CONFIG_NORATES (30)
  121. #define IDS_CONFIG_ALLRATES (31)
  122. #define IDS_CONFIG_MONOONLY (32)
  123. #define IDS_CONFIG_STEREOONLY (33)
  124. #define IDS_CONFIG_MONOSTEREO (34)
  125. #define IDS_ERROR (35)
  126. #define IDS_ERROR_NOMEM (36)
  127. #define IDD_CONFIG RCID(100)
  128. #define IDC_BTN_AUTOCONFIG 1001
  129. #define IDC_BTN_HELP 1002
  130. #define IDC_COMBO_MAXRTENCODE 1003
  131. #define IDC_COMBO_MAXRTDECODE 1004
  132. #define IDC_STATIC1 1005
  133. #define IDC_STATIC2 1006
  134. #define IDC_STATIC3 1007
  135. #endif
  136. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  137. //
  138. //
  139. //
  140. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  141. #ifndef RC_INVOKED
  142. #pragma pack() // revert to default packing
  143. #endif
  144. #ifdef __cplusplus
  145. } // end of extern "C" {
  146. #endif
  147. #endif // _G723_H_
  148. #ifndef RC_INVOKED
  149. #pragma pack(1) // assume byte packing throughout
  150. #endif
  151. #ifndef EXTERN_C
  152. #ifdef __cplusplus
  153. #define EXTERN_C extern "C"
  154. #else
  155. #define EXTERN_C extern
  156. #endif
  157. #endif
  158. #ifdef __cplusplus
  159. extern "C" // assume C declarations for C++
  160. {
  161. #endif
  162. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  163. //
  164. // ACM Driver Version:
  165. //
  166. // the version is a 32 bit number that is broken into three parts as
  167. // follows:
  168. //
  169. // bits 24 - 31: 8 bit _major_ version number
  170. // bits 16 - 23: 8 bit _minor_ version number
  171. // bits 0 - 15: 16 bit build number
  172. //
  173. // this is then displayed as follows (in decimal form):
  174. //
  175. // bMajor = (BYTE)(dwVersion >> 24)
  176. // bMinor = (BYTE)(dwVersion >> 16) &
  177. // wBuild = LOWORD(dwVersion)
  178. //
  179. // VERSION_ACM_DRIVER is the version of this driver.
  180. // VERSION_MSACM is the version of the ACM that this driver
  181. // was designed for (requires).
  182. //
  183. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  184. #ifdef _WIN32
  185. //
  186. // 32-bit versions
  187. //
  188. #if (WINVER >= 0x0400)
  189. #define VERSION_ACM_DRIVER MAKE_ACM_VERSION(1, 2, 1)
  190. #else
  191. #define VERSION_ACM_DRIVER MAKE_ACM_VERSION(3, 50, 0)
  192. #endif
  193. #define VERSION_MSACM MAKE_ACM_VERSION(3, 50, 0)
  194. #else
  195. //
  196. // 16-bit versions
  197. //
  198. #define VERSION_ACM_DRIVER MAKE_ACM_VERSION(2, 3, 0)
  199. #define VERSION_MSACM MAKE_ACM_VERSION(2, 1, 0)
  200. #endif
  201. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  202. //
  203. // Win 16/32 portability stuff...
  204. //
  205. //
  206. //
  207. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  208. #ifndef _WIN32
  209. #ifndef FNLOCAL
  210. #define FNLOCAL NEAR PASCAL
  211. #define FNCLOCAL NEAR _cdecl
  212. #define FNGLOBAL FAR PASCAL
  213. #define FNCGLOBAL FAR _cdecl
  214. #ifdef _WINDLL
  215. #define FNWCALLBACK FAR PASCAL __loadds
  216. #define FNEXPORT FAR PASCAL __export
  217. #else
  218. #define FNWCALLBACK FAR PASCAL
  219. #define FNEXPORT FAR PASCAL __export
  220. #endif
  221. #endif
  222. //
  223. //
  224. //
  225. //
  226. #ifndef FIELD_OFFSET
  227. #define FIELD_OFFSET(type, field) ((LONG)&(((type *)0)->field))
  228. #endif
  229. //
  230. // based code makes since only in win 16 (to try and keep stuff out of
  231. // our fixed data segment...
  232. //
  233. #define BCODE _based(_segname("_CODE"))
  234. #define HUGE _huge
  235. //
  236. // stuff for Unicode in Win 32--make it a noop in Win 16
  237. //
  238. #ifndef _TCHAR_DEFINED
  239. #define _TCHAR_DEFINED
  240. typedef char TCHAR, *PTCHAR;
  241. typedef unsigned char TBYTE, *PTUCHAR;
  242. typedef PSTR PTSTR, PTCH;
  243. typedef LPSTR LPTSTR, LPTCH;
  244. typedef LPCSTR LPCTSTR;
  245. #endif
  246. #define TEXT(a) a
  247. #define SIZEOF(x) sizeof(x)
  248. #define SIZEOFACMSTR(x) sizeof(x)
  249. #else
  250. #ifndef FNLOCAL
  251. #define FNLOCAL _stdcall
  252. #define FNCLOCAL _stdcall
  253. #define FNGLOBAL _stdcall
  254. #define FNCGLOBAL _stdcall
  255. #define FNWCALLBACK CALLBACK
  256. #define FNEXPORT CALLBACK
  257. #endif
  258. #ifndef _CRTAPI1
  259. #define _CRTAPI1 __cdecl
  260. #endif
  261. #ifndef _CRTAPI2
  262. #define _CRTAPI2 __cdecl
  263. #endif
  264. #ifndef try
  265. #define try __try
  266. #define leave __leave
  267. #define except __except
  268. #define finally __finally
  269. #endif
  270. //
  271. // there is no reason to have based stuff in win 32
  272. //
  273. #define BCODE
  274. #define HUGE
  275. #define HTASK HANDLE
  276. #define SELECTOROF(a) (a)
  277. typedef LRESULT (CALLBACK* DRIVERPROC)(DWORD, HDRVR, UINT, LPARAM, LPARAM);
  278. //
  279. // for compiling Unicode
  280. //
  281. #ifdef UNICODE
  282. #define SIZEOF(x) (sizeof(x)/sizeof(WCHAR))
  283. #else
  284. #define SIZEOF(x) sizeof(x)
  285. #endif
  286. #define SIZEOFACMSTR(x) (sizeof(x)/sizeof(WCHAR))
  287. #endif
  288. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  289. //
  290. // Compilation options:
  291. //
  292. // If G723_USECONFIG is defined, then the codec will be compiled
  293. // with a configuration dialog. If not, then the codec will not be
  294. // configurable. It is expected that the configuration is only
  295. // necessary for certain platforms...
  296. //
  297. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  298. //#define G723_USECONFIG
  299. #ifdef G723_USECONFIG
  300. //
  301. // See codec.c for a description of this structure and its use.
  302. //
  303. typedef struct tRATELISTFORMAT
  304. {
  305. UINT uFormatType;
  306. UINT idsFormat;
  307. DWORD dwMonoRate;
  308. } RATELISTFORMAT;
  309. typedef RATELISTFORMAT *PRATELISTFORMAT;
  310. #define CONFIG_RLF_NONUMBER 1
  311. #define CONFIG_RLF_MONOONLY 2
  312. #define CONFIG_RLF_STEREOONLY 3
  313. #define CONFIG_RLF_MONOSTEREO 4
  314. #endif // G723_USECONFIG
  315. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  316. //
  317. // misc defines for misc sizes and things...
  318. //
  319. //
  320. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  321. //
  322. // bilingual. this allows the same identifier to be used in resource files
  323. // and code without having to decorate the id in your code.
  324. //
  325. #ifdef RC_INVOKED
  326. #define RCID(id) id
  327. #else
  328. #define RCID(id) MAKEINTRESOURCE(id)
  329. #endif
  330. //
  331. //
  332. //
  333. #define SIZEOF_ARRAY(ar) (sizeof(ar)/sizeof((ar)[0]))
  334. //
  335. //
  336. //
  337. typedef BOOL FAR* LPBOOL;
  338. //
  339. // macros to compute block alignment and convert between samples and bytes
  340. // of PCM data. note that these macros assume:
  341. //
  342. // wBitsPerSample = 8 or 16
  343. // nChannels = 1 or 2
  344. //
  345. // the pwfx argument is a pointer to a WAVEFORMATEX structure.
  346. //
  347. #define PCM_BLOCKALIGNMENT(pwfx) (UINT)(((pwfx)->wBitsPerSample >> 3) << ((pwfx)->nChannels >> 1))
  348. #define PCM_AVGBYTESPERSEC(pwfx) (DWORD)((pwfx)->nSamplesPerSec * (pwfx)->nBlockAlign)
  349. #define PCM_BYTESTOSAMPLES(pwfx, cb) (DWORD)(cb / PCM_BLOCKALIGNMENT(pwfx))
  350. #define PCM_SAMPLESTOBYTES(pwfx, dw) (DWORD)(dw * PCM_BLOCKALIGNMENT(pwfx))
  351. #define FLOATTOSHORT(b) ((b < -32768.) ? (short)(-32768) : \
  352. ((b > 32767.) ? (short)(32767) : \
  353. ((b < 0.) ? (short)(b-0.5) : \
  354. (short)(b+0.5))))
  355. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  356. //
  357. //
  358. //
  359. //
  360. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  361. typedef struct tDRIVERINSTANCE
  362. {
  363. //
  364. // although not required, it is suggested that the first two members
  365. // of this structure remain as fccType and DriverProc _in this order_.
  366. // the reason for this is that the driver will be easier to combine
  367. // with other types of drivers (defined by AVI) in the future.
  368. //
  369. FOURCC fccType; // type of driver: 'audc'
  370. DRIVERPROC fnDriverProc; // driver proc for the instance
  371. //
  372. // the remaining members of this structure are entirely open to what
  373. // your driver requires.
  374. //
  375. HDRVR hdrvr; // driver handle we were opened with
  376. HINSTANCE hinst; // DLL module handle.
  377. DWORD vdwACM; // current version of ACM opening you
  378. DWORD fdwOpen; // flags from open description
  379. DWORD fdwConfig; // stream instance configuration flags
  380. BOOL enabled; // driver enabled flag
  381. #ifdef G723_USECONFIG
  382. LPDRVCONFIGINFO pdci;
  383. HKEY hkey;
  384. UINT nConfigMaxRTEncodeSetting;
  385. UINT nConfigMaxRTDecodeSetting;
  386. UINT nConfigPercentCPU;
  387. BOOL fHelpRunning; // Used by config DlgProc only.
  388. #ifdef WIN4
  389. HBRUSH hbrDialog; // Used by config DlgProc only.
  390. #endif
  391. #endif
  392. } DRIVERINSTANCE, *PDRIVERINSTANCE, FAR *LPDRIVERINSTANCE;
  393. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  394. //
  395. //
  396. //
  397. //
  398. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  399. //
  400. // This define deals with unaligned data for Win32, and huge data for Win16.
  401. // Basically, any time you cast an HPBYTE to a non-byte variable (ie long or
  402. // short), you should cast it to ( {short,long} HUGE_T *). This will cast
  403. // it to _huge for Win16, and make sure that there are no alignment problems
  404. // for Win32 on MIPS and Alpha machines.
  405. //
  406. typedef BYTE HUGE *HPBYTE;
  407. #ifdef _WIN32
  408. #define HUGE_T UNALIGNED
  409. #else
  410. #define HUGE_T _huge
  411. #endif
  412. //
  413. //
  414. //
  415. //
  416. typedef DWORD (FNGLOBAL *STREAMCONVERTPROC)
  417. (
  418. HPBYTE pbSrc,
  419. DWORD cbSrcLength,
  420. HPBYTE pbDst
  421. // UINT nBlockAlignment,
  422. // UINT cSamplesPerBlock,
  423. // int * pnStepIndexL,
  424. // int * pnStepIndexR
  425. );
  426. //
  427. //
  428. //
  429. //
  430. typedef struct tSTREAMINSTANCE
  431. {
  432. STREAMCONVERTPROC fnConvert; // stream instance conversion proc
  433. DWORD fdwConfig; // stream instance configuration flags
  434. } STREAMINSTANCE, *PSTREAMINSTANCE, FAR *LPSTREAMINSTANCE;
  435. //
  436. // global variables, etc...
  437. //
  438. #ifdef G723_USECONFIG
  439. extern const UINT gauFormatIndexToSampleRate[];
  440. extern const UINT ACM_DRIVER_MAX_SAMPLE_RATES;
  441. extern const UINT ACM_DRIVER_MAX_CHANNELS;
  442. extern const RATELISTFORMAT gaRateListFormat[];
  443. extern const UINT G723_CONFIG_NUMSETTINGS;
  444. #endif
  445. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  446. //
  447. // function prototypes
  448. //
  449. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  450. void convert11to8(short *in, short *out, short *prev, int len);
  451. void convert8to11(short *in, short *out, short *prev, int len);
  452. #ifdef G723_USECONFIG
  453. BOOL FNGLOBAL acmdDriverConfigInit
  454. (
  455. PDRIVERINSTANCE pdi,
  456. LPCTSTR pszAliasName
  457. );
  458. BOOL FNWCALLBACK acmdDlgProcConfigure
  459. (
  460. HWND hwnd,
  461. UINT uMsg,
  462. WPARAM wParam,
  463. LPARAM lParam
  464. );
  465. LRESULT FNLOCAL acmdFormatSuggest
  466. (
  467. PDRIVERINSTANCE pdi,
  468. LPACMDRVFORMATSUGGEST padfs
  469. );
  470. LRESULT FNLOCAL acmdStreamSize
  471. (
  472. LPACMDRVSTREAMINSTANCE padsi,
  473. LPACMDRVSTREAMSIZE padss
  474. );
  475. LRESULT FNLOCAL acmdStreamConvert
  476. (
  477. PDRIVERINSTANCE pdi,
  478. LPACMDRVSTREAMINSTANCE padsi,
  479. LPACMDRVSTREAMHEADER padsh
  480. );
  481. #endif
  482. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  483. //
  484. //
  485. //
  486. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  487. #ifndef RC_INVOKED
  488. #pragma pack() // revert to default packing
  489. #endif
  490. #ifdef __cplusplus
  491. } // end of extern "C" {
  492. #endif