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.

478 lines
13 KiB

  1. //==========================================================================;
  2. //
  3. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4. // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5. // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6. // PURPOSE.
  7. //
  8. // Copyright (c) 1992-1998 Microsoft Corporation
  9. //
  10. //--------------------------------------------------------------------------;
  11. //
  12. // codec.h
  13. //
  14. // Description:
  15. // This file contains codec definitions, Win16/Win32 compatibility
  16. // definitions, and instance structure definitions.
  17. //
  18. //
  19. //==========================================================================;
  20. #ifndef _INC_CODEC
  21. #define _INC_CODEC // #defined if codec.h has been included
  22. #ifndef RC_INVOKED
  23. #pragma pack(1) // assume byte packing throughout
  24. #endif
  25. #ifndef EXTERN_C
  26. #ifdef __cplusplus
  27. #define EXTERN_C extern "C"
  28. #else
  29. #define EXTERN_C extern
  30. #endif
  31. #endif
  32. #ifdef __cplusplus
  33. extern "C" // assume C declarations for C++
  34. {
  35. #endif
  36. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  37. //
  38. // ACM Driver Version:
  39. //
  40. // the version is a 32 bit number that is broken into three parts as
  41. // follows:
  42. //
  43. // bits 24 - 31: 8 bit _major_ version number
  44. // bits 16 - 23: 8 bit _minor_ version number
  45. // bits 0 - 15: 16 bit build number
  46. //
  47. // this is then displayed as follows (in decimal form):
  48. //
  49. // bMajor = (BYTE)(dwVersion >> 24)
  50. // bMinor = (BYTE)(dwVersion >> 16) &
  51. // wBuild = LOWORD(dwVersion)
  52. //
  53. // VERSION_ACM_DRIVER is the version of this driver.
  54. // VERSION_MSACM is the version of the ACM that this driver
  55. // was designed for (requires).
  56. //
  57. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  58. #ifdef WIN32
  59. //
  60. // 32-bit versions
  61. //
  62. #if (WINVER >= 0x0400)
  63. #define VERSION_ACM_DRIVER MAKE_ACM_VERSION(4, 0, 0)
  64. #else
  65. #define VERSION_ACM_DRIVER MAKE_ACM_VERSION(3, 51, 0)
  66. #endif
  67. #define VERSION_MSACM MAKE_ACM_VERSION(3, 50, 0)
  68. #else
  69. //
  70. // 16-bit versions
  71. //
  72. #define VERSION_ACM_DRIVER MAKE_ACM_VERSION(2, 3, 0)
  73. #define VERSION_MSACM MAKE_ACM_VERSION(2, 1, 0)
  74. #endif
  75. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  76. //
  77. // Win 16/32 portability stuff...
  78. //
  79. //
  80. //
  81. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  82. #ifndef WIN32
  83. #ifndef FNLOCAL
  84. #define FNLOCAL NEAR PASCAL
  85. #define FNCLOCAL NEAR _cdecl
  86. #define FNGLOBAL FAR PASCAL
  87. #define FNCGLOBAL FAR _cdecl
  88. #ifdef _WINDLL
  89. #define FNWCALLBACK FAR PASCAL __loadds
  90. #define FNEXPORT FAR PASCAL __export
  91. #else
  92. #define FNWCALLBACK FAR PASCAL
  93. #define FNEXPORT FAR PASCAL __export
  94. #endif
  95. #endif
  96. //
  97. //
  98. //
  99. //
  100. #ifndef FIELD_OFFSET
  101. #define FIELD_OFFSET(type, field) ((LONG)&(((type *)0)->field))
  102. #endif
  103. //
  104. // based code makes since only in win 16 (to try and keep stuff out of
  105. // our fixed data segment...
  106. //
  107. #define BCODE _based(_segname("_CODE"))
  108. #define HUGE _huge
  109. //
  110. // stuff for Unicode in Win 32--make it a noop in Win 16
  111. //
  112. #ifndef _TCHAR_DEFINED
  113. #define _TCHAR_DEFINED
  114. typedef char TCHAR, *PTCHAR;
  115. typedef unsigned char TBYTE, *PTUCHAR;
  116. typedef PSTR PTSTR, PTCH;
  117. typedef LPSTR LPTSTR, LPTCH;
  118. typedef LPCSTR LPCTSTR;
  119. #endif
  120. #define TEXT(a) a
  121. #define SIZEOF(x) sizeof(x)
  122. #define SIZEOFACMSTR(x) sizeof(x)
  123. #else
  124. #ifndef FNLOCAL
  125. #define FNLOCAL _stdcall
  126. #define FNCLOCAL _stdcall
  127. #define FNGLOBAL _stdcall
  128. #define FNCGLOBAL _stdcall
  129. #define FNWCALLBACK CALLBACK
  130. #define FNEXPORT CALLBACK
  131. #endif
  132. #ifndef try
  133. #define try __try
  134. #define leave __leave
  135. #define except __except
  136. #define finally __finally
  137. #endif
  138. //
  139. // there is no reason to have based stuff in win 32
  140. //
  141. #define BCODE
  142. #define HUGE
  143. #define HTASK HANDLE
  144. #define SELECTOROF(a) (a)
  145. typedef LRESULT (CALLBACK* DRIVERPROC)(DWORD_PTR, HDRVR, UINT, LPARAM, LPARAM);
  146. //
  147. // for compiling Unicode
  148. //
  149. #ifdef UNICODE
  150. #define SIZEOF(x) (sizeof(x)/sizeof(WCHAR))
  151. #else
  152. #define SIZEOF(x) sizeof(x)
  153. #endif
  154. #define SIZEOFACMSTR(x) (sizeof(x)/sizeof(WCHAR))
  155. #endif
  156. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  157. //
  158. // Compilation options:
  159. //
  160. // If IMAADPCM_USECONFIG is defined, then the codec will be compiled
  161. // with a configuration dialog. If not, then the codec will not be
  162. // configurable. It is expected that the configuration is only
  163. // necessary for certain platforms...
  164. //
  165. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  166. #define IMAADPCM_USECONFIG
  167. #ifdef IMAADPCM_USECONFIG
  168. //
  169. // See codec.c for a description of this structure and its use.
  170. //
  171. typedef struct tRATELISTFORMAT
  172. {
  173. UINT uFormatType;
  174. UINT idsFormat;
  175. DWORD dwMonoRate;
  176. } RATELISTFORMAT;
  177. typedef RATELISTFORMAT *PRATELISTFORMAT;
  178. #define CONFIG_RLF_NONUMBER 1
  179. #define CONFIG_RLF_MONOONLY 2
  180. #define CONFIG_RLF_STEREOONLY 3
  181. #define CONFIG_RLF_MONOSTEREO 4
  182. #endif // IMAADPCM_USECONFIG
  183. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  184. //
  185. // misc defines for misc sizes and things...
  186. //
  187. //
  188. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  189. //
  190. // bilingual. this allows the same identifier to be used in resource files
  191. // and code without having to decorate the id in your code.
  192. //
  193. #ifdef RC_INVOKED
  194. #define RCID(id) id
  195. #else
  196. #define RCID(id) MAKEINTRESOURCE(id)
  197. #endif
  198. //
  199. //
  200. //
  201. #define SIZEOF_ARRAY(ar) (sizeof(ar)/sizeof((ar)[0]))
  202. //
  203. //
  204. //
  205. typedef BOOL FAR* LPBOOL;
  206. //
  207. // macros to compute block alignment and convert between samples and bytes
  208. // of PCM data. note that these macros assume:
  209. //
  210. // wBitsPerSample = 8 or 16
  211. // nChannels = 1 or 2
  212. //
  213. // the pwfx argument is a pointer to a WAVEFORMATEX structure.
  214. //
  215. #define PCM_BLOCKALIGNMENT(pwfx) (UINT)(((pwfx)->wBitsPerSample >> 3) << ((pwfx)->nChannels >> 1))
  216. #define PCM_AVGBYTESPERSEC(pwfx) (DWORD)((pwfx)->nSamplesPerSec * (pwfx)->nBlockAlign)
  217. #define PCM_BYTESTOSAMPLES(pwfx, cb) (DWORD)(cb / PCM_BLOCKALIGNMENT(pwfx))
  218. #define PCM_SAMPLESTOBYTES(pwfx, dw) (DWORD)(dw * PCM_BLOCKALIGNMENT(pwfx))
  219. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  220. //
  221. //
  222. //
  223. //
  224. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  225. typedef struct tDRIVERINSTANCE
  226. {
  227. //
  228. // although not required, it is suggested that the first two members
  229. // of this structure remain as fccType and DriverProc _in this order_.
  230. // the reason for this is that the driver will be easier to combine
  231. // with other types of drivers (defined by AVI) in the future.
  232. //
  233. FOURCC fccType; // type of driver: 'audc'
  234. DRIVERPROC fnDriverProc; // driver proc for the instance
  235. //
  236. // the remaining members of this structure are entirely open to what
  237. // your driver requires.
  238. //
  239. HDRVR hdrvr; // driver handle we were opened with
  240. HINSTANCE hinst; // DLL module handle.
  241. DWORD vdwACM; // current version of ACM opening you
  242. DWORD fdwOpen; // flags from open description
  243. DWORD fdwConfig; // stream instance configuration flags
  244. #ifdef IMAADPCM_USECONFIG
  245. LPDRVCONFIGINFO pdci;
  246. HKEY hkey;
  247. UINT nConfigMaxRTEncodeSetting;
  248. UINT nConfigMaxRTDecodeSetting;
  249. UINT nConfigPercentCPU;
  250. BOOL fHelpRunning; // Used by config DlgProc only.
  251. #ifdef WIN4
  252. HBRUSH hbrDialog; // Used by config DlgProc only.
  253. #endif
  254. #endif
  255. } DRIVERINSTANCE, *PDRIVERINSTANCE, FAR *LPDRIVERINSTANCE;
  256. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  257. //
  258. //
  259. //
  260. //
  261. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  262. //
  263. // This define deals with unaligned data for Win32, and huge data for Win16.
  264. // Basically, any time you cast an HPBYTE to a non-byte variable (ie long or
  265. // short), you should cast it to ( {short,long} HUGE_T *). This will cast
  266. // it to _huge for Win16, and make sure that there are no alignment problems
  267. // for Win32 on MIPS and Alpha machines.
  268. //
  269. typedef BYTE HUGE *HPBYTE;
  270. #ifdef WIN32
  271. #define HUGE_T UNALIGNED
  272. #else
  273. #define HUGE_T _huge
  274. #endif
  275. //
  276. //
  277. //
  278. //
  279. typedef DWORD (FNGLOBAL *STREAMCONVERTPROC)
  280. (
  281. HPBYTE pbSrc,
  282. DWORD cbSrcLength,
  283. HPBYTE pbDst,
  284. UINT nBlockAlignment,
  285. UINT cSamplesPerBlock,
  286. int * pnStepIndexL,
  287. int * pnStepIndexR
  288. );
  289. //
  290. //
  291. //
  292. //
  293. typedef struct tSTREAMINSTANCE
  294. {
  295. STREAMCONVERTPROC fnConvert; // stream instance conversion proc
  296. DWORD fdwConfig; // stream instance configuration flags
  297. int nStepIndexL; // Used to ensure that the step index
  298. int nStepIndexR; // is maintained across converts. For
  299. // mono signals, the index is stored in
  300. // nStepIndexL.
  301. } STREAMINSTANCE, *PSTREAMINSTANCE, FAR *LPSTREAMINSTANCE;
  302. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  303. //
  304. // resource id's
  305. //
  306. //
  307. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  308. #define IDS_ACM_DRIVER_SHORTNAME (1) // ACMDRIVERDETAILS.szShortName
  309. #define IDS_ACM_DRIVER_LONGNAME (2) // ACMDRIVERDETAILS.szLongName
  310. #define IDS_ACM_DRIVER_COPYRIGHT (3) // ACMDRIVERDETAILS.szCopyright
  311. #define IDS_ACM_DRIVER_LICENSING (4) // ACMDRIVERDETAILS.szLicensing
  312. #define IDS_ACM_DRIVER_FEATURES (5) // ACMDRIVERDETAILS.szFeatures
  313. #define IDS_ACM_DRIVER_TAG_NAME (20) // ACMFORMATTAGDETAILS.szFormatTag
  314. #ifdef IMAADPCM_USECONFIG
  315. //
  316. // resource id's for the configuration dialog box
  317. //
  318. #define IDS_CONFIG_NORATES (30)
  319. #define IDS_CONFIG_ALLRATES (31)
  320. #define IDS_CONFIG_MONOONLY (32)
  321. #define IDS_CONFIG_STEREOONLY (33)
  322. #define IDS_CONFIG_MONOSTEREO (34)
  323. #define IDS_ERROR (35)
  324. #define IDS_ERROR_NOMEM (36)
  325. #define IDD_CONFIG RCID(100)
  326. #define IDC_BTN_AUTOCONFIG 1001
  327. #define IDC_BTN_HELP 1002
  328. #define IDC_COMBO_MAXRTENCODE 1003
  329. #define IDC_COMBO_MAXRTDECODE 1004
  330. #define IDC_STATIC_COMPRESS 1005
  331. #define IDC_STATIC_DECOMPRESS 1006
  332. #define IDC_STATIC -1
  333. #endif
  334. //
  335. // global variables, etc...
  336. //
  337. #ifdef IMAADPCM_USECONFIG
  338. extern const UINT gauFormatIndexToSampleRate[];
  339. extern const UINT ACM_DRIVER_MAX_SAMPLE_RATES;
  340. extern const UINT ACM_DRIVER_MAX_CHANNELS;
  341. extern const RATELISTFORMAT gaRateListFormat[];
  342. extern const UINT IMAADPCM_CONFIG_NUMSETTINGS;
  343. #endif
  344. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  345. //
  346. // function prototypes
  347. //
  348. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  349. #ifdef IMAADPCM_USECONFIG
  350. BOOL FNGLOBAL acmdDriverConfigInit
  351. (
  352. PDRIVERINSTANCE pdi,
  353. LPCTSTR pszAliasName
  354. );
  355. INT_PTR FNWCALLBACK acmdDlgProcConfigure
  356. (
  357. HWND hwnd,
  358. UINT uMsg,
  359. WPARAM wParam,
  360. LPARAM lParam
  361. );
  362. LRESULT FNLOCAL acmdFormatSuggest
  363. (
  364. PDRIVERINSTANCE pdi,
  365. LPACMDRVFORMATSUGGEST padfs
  366. );
  367. LRESULT FNLOCAL acmdStreamSize
  368. (
  369. LPACMDRVSTREAMINSTANCE padsi,
  370. LPACMDRVSTREAMSIZE padss
  371. );
  372. LRESULT FNLOCAL acmdStreamConvert
  373. (
  374. PDRIVERINSTANCE pdi,
  375. LPACMDRVSTREAMINSTANCE padsi,
  376. LPACMDRVSTREAMHEADER padsh
  377. );
  378. #endif
  379. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  380. //
  381. //
  382. //
  383. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  384. #ifndef RC_INVOKED
  385. #pragma pack() // revert to default packing
  386. #endif
  387. #ifdef __cplusplus
  388. } // end of extern "C" {
  389. #endif
  390. #endif // _INC_CODEC