/multimedia/LazWinWebCam/VFW.pas

http://lazarus-br.googlecode.com/ · Pascal · 1678 lines · 871 code · 298 blank · 509 comment · 0 complexity · 89097b5e320e8ad599d4544bd16cf9c7 MD5 · raw file

  1. unit VFW;
  2. {$IFDEF FPC}
  3. {$MODE DELPHI}
  4. {$ENDIF}
  5. interface
  6. {$UNDEF UNICODE}
  7. (****************************************************************************
  8. *
  9. * VfW.H - Video for windows include file for WIN32
  10. *
  11. * Copyright (c) 1991-1999, Microsoft Corp. All rights reserved.
  12. *
  13. * This include files defines interfaces to the following
  14. * video components
  15. *
  16. * COMPMAN - Installable Compression Manager.
  17. * DRAWDIB - Routines for drawing to the display.
  18. * VIDEO - Video Capture Driver Interface
  19. *
  20. * AVIFMT - AVI File Format structure definitions.
  21. * MMREG - FOURCC and other things
  22. *
  23. * AVIFile - Interface for reading AVI Files and AVI Streams
  24. * MCIWND - MCI/AVI window class
  25. * AVICAP - AVI Capture Window class
  26. *
  27. * MSACM - Audio compression manager.
  28. *
  29. * The following symbols control inclusion of various parts of this file:
  30. *
  31. * NOCOMPMAN - dont include COMPMAN
  32. * NODRAWDIB - dont include DRAWDIB
  33. * NOVIDEO - dont include video capture interface
  34. *
  35. * NOAVIFMT - dont include AVI file format structs
  36. * NOMMREG - dont include MMREG
  37. *
  38. * NOAVIFILE - dont include AVIFile interface
  39. * NOMCIWND - dont include AVIWnd class.
  40. * NOAVICAP - dont include AVICap class.
  41. *
  42. * NOMSACM - dont include ACM stuff.
  43. *
  44. ****************************************************************************)
  45. (******************************************************************************)
  46. (* *)
  47. (* VFW.PAS Conversion by Ronald Dittrich *)
  48. (* *)
  49. (* E-Mail: info@swiftsoft.de *)
  50. (* http://www.swiftsoft.de *)
  51. (* *)
  52. (******************************************************************************)
  53. (******************************************************************************)
  54. (* *)
  55. (* Modyfied: 25.April.2000 *)
  56. (* *)
  57. (* E-Mail: *)
  58. (* Ivo Steinmann: isteinmann@bluewin.ch *)
  59. (* *)
  60. (* Please send all messages regarding specific errors and lacks of this unit *)
  61. (* to Ivo Steinmann *)
  62. (* *)
  63. (******************************************************************************)
  64. (******************************************************************************)
  65. (* *)
  66. (* Modyfied: 2000-12-07 *)
  67. (* *)
  68. (* E-Mail: *)
  69. (* Peter Haas: PeterJHaas@t-online.de *)
  70. (* *)
  71. (* Only modified line 1380 ( TAVIPALCHANGE.peNew ) *)
  72. (* *)
  73. (******************************************************************************)
  74. uses
  75. {$IFNDEF FPC}
  76. CommDlg,
  77. ActiveX, {Ole2}
  78. Dialogs,
  79. {$ENDIF}
  80. Windows,
  81. MMSystem,
  82. Messages;
  83. (****************************************************************************
  84. *
  85. * types
  86. *
  87. ***************************************************************************)
  88. type
  89. PVOID = pointer;
  90. LONG = longint;
  91. PLONG = ^LONG;
  92. int = integer;
  93. {$IFDEF FPC}
  94. POpenFilenameA = ^TOpenFilenameA;
  95. POpenFilenameW = ^TOpenFilenameW;
  96. POpenFilename = POpenFilenameA;
  97. tagOFNA = packed record
  98. lStructSize: DWORD;
  99. hWndOwner: HWND;
  100. hInstance: HINST;
  101. lpstrFilter: PAnsiChar;
  102. lpstrCustomFilter: PAnsiChar;
  103. nMaxCustFilter: DWORD;
  104. nFilterIndex: DWORD;
  105. lpstrFile: PAnsiChar;
  106. nMaxFile: DWORD;
  107. lpstrFileTitle: PAnsiChar;
  108. nMaxFileTitle: DWORD;
  109. lpstrInitialDir: PAnsiChar;
  110. lpstrTitle: PAnsiChar;
  111. Flags: DWORD;
  112. nFileOffset: Word;
  113. nFileExtension: Word;
  114. lpstrDefExt: PAnsiChar;
  115. lCustData: LPARAM;
  116. lpfnHook: function(Wnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): UINT stdcall;
  117. lpTemplateName: PAnsiChar;
  118. pvReserved: Pointer;
  119. dwReserved: DWORD;
  120. FlagsEx: DWORD;
  121. end;
  122. tagOFNW = packed record
  123. lStructSize: DWORD;
  124. hWndOwner: HWND;
  125. hInstance: HINST;
  126. lpstrFilter: PWideChar;
  127. lpstrCustomFilter: PWideChar;
  128. nMaxCustFilter: DWORD;
  129. nFilterIndex: DWORD;
  130. lpstrFile: PWideChar;
  131. nMaxFile: DWORD;
  132. lpstrFileTitle: PWideChar;
  133. nMaxFileTitle: DWORD;
  134. lpstrInitialDir: PWideChar;
  135. lpstrTitle: PWideChar;
  136. Flags: DWORD;
  137. nFileOffset: Word;
  138. nFileExtension: Word;
  139. lpstrDefExt: PWideChar;
  140. lCustData: LPARAM;
  141. lpfnHook: function(Wnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): UINT stdcall;
  142. lpTemplateName: PWideChar;
  143. pvReserved: Pointer;
  144. dwReserved: DWORD;
  145. FlagsEx: DWORD;
  146. end;
  147. tagOFN = tagOFNA;
  148. TOpenFilenameA = tagOFNA;
  149. TOpenFilenameW = tagOFNW;
  150. TOpenFilename = TOpenFilenameA;
  151. OPENFILENAMEA = tagOFNA;
  152. OPENFILENAMEW = tagOFNW;
  153. OPENFILENAME = OPENFILENAMEA;
  154. {$ENDIF}
  155. (****************************************************************************
  156. *
  157. * VideoForWindowsVersion() - returns version of VfW
  158. *
  159. ***************************************************************************)
  160. function VideoForWindowsVersion: DWORD; pascal;
  161. (****************************************************************************
  162. *
  163. * call these to start stop using VfW from your app.
  164. *
  165. ***************************************************************************)
  166. {
  167. function InitVFW: LONG; stdcall;
  168. function TermVFW: LONG; stdcall; }
  169. (****************************************************************************/
  170. /* */
  171. /* Macros */
  172. /* */
  173. /* should we define this?? */
  174. /* */
  175. /****************************************************************************)
  176. function MKFOURCC(ch0, ch1, ch2, ch3: Char): FOURCC;
  177. (****************************************************************************
  178. *
  179. * COMPMAN - Installable Compression Manager.
  180. *
  181. ****************************************************************************)
  182. const
  183. ICVERSION = $0104 ;
  184. type
  185. HIC = THandle; // Handle to an Installable Compressor
  186. //
  187. // this code in biCompression means the DIB must be accesed via
  188. // 48 bit pointers! using *ONLY* the selector given.
  189. //
  190. const
  191. BI_1632 = $32333631; // '1632'
  192. function mmioFOURCC(ch0, ch1, ch2, ch3: Char): FOURCC;
  193. type
  194. TWOCC = word;
  195. function aviTWOCC(ch0, ch1: Char): TWOCC;
  196. const
  197. ICTYPE_VIDEO = $63646976; {vidc}
  198. ICTYPE_AUDIO = $63647561; {audc}
  199. const
  200. ICERR_OK = 0 ;
  201. ICERR_DONTDRAW = 1 ;
  202. ICERR_NEWPALETTE = 2 ;
  203. ICERR_GOTOKEYFRAME = 3 ;
  204. ICERR_STOPDRAWING = 4 ;
  205. ICERR_UNSUPPORTED = -1 ;
  206. ICERR_BADFORMAT = -2 ;
  207. ICERR_MEMORY = -3 ;
  208. ICERR_INTERNAL = -4 ;
  209. ICERR_BADFLAGS = -5 ;
  210. ICERR_BADPARAM = -6 ;
  211. ICERR_BADSIZE = -7 ;
  212. ICERR_BADHANDLE = -8 ;
  213. ICERR_CANTUPDATE = -9 ;
  214. ICERR_ABORT = -10 ;
  215. ICERR_ERROR = -100 ;
  216. ICERR_BADBITDEPTH = -200 ;
  217. ICERR_BADIMAGESIZE = -201 ;
  218. ICERR_CUSTOM = -400 ; // errors less than ICERR_CUSTOM...
  219. {-- Values for dwFlags of ICOpen() -------------------------------------------}
  220. ICMODE_COMPRESS = 1 ;
  221. ICMODE_DECOMPRESS = 2 ;
  222. ICMODE_FASTDECOMPRESS = 3 ;
  223. ICMODE_QUERY = 4 ;
  224. ICMODE_FASTCOMPRESS = 5 ;
  225. ICMODE_DRAW = 8 ;
  226. {-- Flags for AVI file index -------------------------------------------------}
  227. AVIIF_LIST = $00000001 ;
  228. AVIIF_TWOCC = $00000002 ;
  229. AVIIF_KEYFRAME = $00000010 ;
  230. {-- quality flags ------------------------------------------------------------}
  231. ICQUALITY_LOW = 0 ;
  232. ICQUALITY_HIGH = 10000 ;
  233. ICQUALITY_DEFAULT = -1 ;
  234. (************************************************************************
  235. ************************************************************************)
  236. ICM_USER = (DRV_USER+$0000) ;
  237. ICM_RESERVED_LOW = (DRV_USER+$1000) ;
  238. ICM_RESERVED_HIGH = (DRV_USER+$2000) ;
  239. ICM_RESERVED = ICM_RESERVED_LOW ;
  240. (************************************************************************
  241. messages.
  242. ************************************************************************)
  243. ICM_GETSTATE = (ICM_RESERVED+0) ; // Get compressor state
  244. ICM_SETSTATE = (ICM_RESERVED+1) ; // Set compressor state
  245. ICM_GETINFO = (ICM_RESERVED+2) ; // Query info about the compressor
  246. ICM_CONFIGURE = (ICM_RESERVED+10); // show the configure dialog
  247. ICM_ABOUT = (ICM_RESERVED+11); // show the about box
  248. ICM_GETDEFAULTQUALITY = (ICM_RESERVED+30); // get the default value for quality
  249. ICM_GETQUALITY = (ICM_RESERVED+31); // get the current value for quality
  250. ICM_SETQUALITY = (ICM_RESERVED+32); // set the default value for quality
  251. ICM_SET = (ICM_RESERVED+40); // Tell the driver something
  252. ICM_GET = (ICM_RESERVED+41); // Ask the driver something
  253. {-- Constants for ICM_SET: ---------------------------------------------------}
  254. ICM_FRAMERATE = $526D7246; {FrmR}
  255. ICM_KEYFRAMERATE = $5279654B; {KeyR}
  256. (************************************************************************
  257. ICM specific messages.
  258. ************************************************************************)
  259. ICM_COMPRESS_GET_FORMAT = (ICM_USER+4) ; // get compress format or size
  260. ICM_COMPRESS_GET_SIZE = (ICM_USER+5) ; // get output size
  261. ICM_COMPRESS_QUERY = (ICM_USER+6) ; // query support for compress
  262. ICM_COMPRESS_BEGIN = (ICM_USER+7) ; // begin a series of compress calls.
  263. ICM_COMPRESS = (ICM_USER+8) ; // compress a frame
  264. ICM_COMPRESS_END = (ICM_USER+9) ; // end of a series of compress calls.
  265. ICM_DECOMPRESS_GET_FORMAT = (ICM_USER+10) ; // get decompress format or size
  266. ICM_DECOMPRESS_QUERY = (ICM_USER+11) ; // query support for dempress
  267. ICM_DECOMPRESS_BEGIN = (ICM_USER+12) ; // start a series of decompress calls
  268. ICM_DECOMPRESS = (ICM_USER+13) ; // decompress a frame
  269. ICM_DECOMPRESS_END = (ICM_USER+14) ; // end a series of decompress calls
  270. ICM_DECOMPRESS_SET_PALETTE = (ICM_USER+29) ; // fill in the DIB color table
  271. ICM_DECOMPRESS_GET_PALETTE = (ICM_USER+30) ; // fill in the DIB color table
  272. ICM_DRAW_QUERY = (ICM_USER+31) ; // query support for dempress
  273. ICM_DRAW_BEGIN = (ICM_USER+15) ; // start a series of draw calls
  274. ICM_DRAW_GET_PALETTE = (ICM_USER+16) ; // get the palette needed for drawing
  275. ICM_DRAW_START = (ICM_USER+18) ; // start decompress clock
  276. ICM_DRAW_STOP = (ICM_USER+19) ; // stop decompress clock
  277. ICM_DRAW_END = (ICM_USER+21) ; // end a series of draw calls
  278. ICM_DRAW_GETTIME = (ICM_USER+32) ; // get value of decompress clock
  279. ICM_DRAW = (ICM_USER+33) ; // generalized "render" message
  280. ICM_DRAW_WINDOW = (ICM_USER+34) ; // drawing window has moved or hidden
  281. ICM_DRAW_SETTIME = (ICM_USER+35) ; // set correct value for decompress clock
  282. ICM_DRAW_REALIZE = (ICM_USER+36) ; // realize palette for drawing
  283. ICM_DRAW_FLUSH = (ICM_USER+37) ; // clear out buffered frames
  284. ICM_DRAW_RENDERBUFFER = (ICM_USER+38) ; // draw undrawn things in queue
  285. ICM_DRAW_START_PLAY = (ICM_USER+39) ; // start of a play
  286. ICM_DRAW_STOP_PLAY = (ICM_USER+40) ; // end of a play
  287. ICM_DRAW_SUGGESTFORMAT = (ICM_USER+50) ; // Like ICGetDisplayFormat
  288. ICM_DRAW_CHANGEPALETTE = (ICM_USER+51) ; // for animating palette
  289. ICM_GETBUFFERSWANTED = (ICM_USER+41) ; // ask about prebuffering
  290. ICM_GETDEFAULTKEYFRAMERATE = (ICM_USER+42) ; // get the default value for key frames
  291. ICM_DECOMPRESSEX_BEGIN = (ICM_USER+60) ; // start a series of decompress calls
  292. ICM_DECOMPRESSEX_QUERY = (ICM_USER+61) ; // start a series of decompress calls
  293. ICM_DECOMPRESSEX = (ICM_USER+62) ; // decompress a frame
  294. ICM_DECOMPRESSEX_END = (ICM_USER+63) ; // end a series of decompress calls
  295. ICM_COMPRESS_FRAMES_INFO = (ICM_USER+70) ; // tell about compress to come
  296. ICM_SET_STATUS_PROC = (ICM_USER+72) ; // set status callback
  297. (************************************************************************
  298. ************************************************************************)
  299. type
  300. PICOPEN = ^TICOPEN;
  301. TICOPEN = packed record
  302. dwSize : DWORD ; // sizeof(ICOPEN)
  303. fccType : DWORD ; // 'vidc'
  304. fccHandler : DWORD ; //
  305. dwVersion : DWORD ; // version of compman opening you
  306. dwFlags : DWORD ; // LOWORD is type specific
  307. dwError : DWORD ; // error return.
  308. pV1Reserved : PVOID ; // Reserved
  309. pV2Reserved : PVOID ; // Reserved
  310. dnDevNode : DWORD ; // Devnode for PnP devices
  311. end;
  312. (************************************************************************
  313. ************************************************************************)
  314. PICINFO = ^TICINFO;
  315. TICINFO = packed record
  316. dwSize : DWORD; // sizeof(ICINFO)
  317. fccType : DWORD; // compressor type 'vidc' 'audc'
  318. fccHandler : DWORD; // compressor sub-type 'rle ' 'jpeg' 'pcm '
  319. dwFlags : DWORD; // flags LOWORD is type specific
  320. dwVersion : DWORD; // version of the driver
  321. dwVersionICM : DWORD; // version of the ICM used
  322. //
  323. // under Win32, the driver always returns UNICODE strings.
  324. //
  325. szName : array[0..15] of WChar ; // short name
  326. szDescription : array[0..127] of WChar ; // DWORD name
  327. szDriver : array[0..127] of WChar ; // driver that contains compressor
  328. end;
  329. {-- Flags for the <dwFlags> field of the <ICINFO> structure. ------------}
  330. const
  331. VIDCF_QUALITY = $0001 ; // supports quality
  332. VIDCF_CRUNCH = $0002 ; // supports crunching to a frame size
  333. VIDCF_TEMPORAL = $0004 ; // supports inter-frame compress
  334. VIDCF_COMPRESSFRAMES = $0008 ; // wants the compress all frames message
  335. VIDCF_DRAW = $0010 ; // supports drawing
  336. VIDCF_FASTTEMPORALC = $0020 ; // does not need prev frame on compress
  337. VIDCF_FASTTEMPORALD = $0080 ; // does not need prev frame on decompress
  338. //VIDCF_QUALITYTIME = $0040 ; // supports temporal quality
  339. //VIDCF_FASTTEMPORAL = (VIDCF_FASTTEMPORALC or VIDCF_FASTTEMPORALD)
  340. (************************************************************************
  341. ************************************************************************)
  342. ICCOMPRESS_KEYFRAME = $00000001;
  343. type
  344. PICCOMPRESS = ^TICCOMPRESS;
  345. TICCOMPRESS = packed record
  346. dwFlags : DWORD; // flags
  347. lpbiOutput : PBITMAPINFOHEADER ; // output format
  348. lpOutput : PVOID ; // output data
  349. lpbiInput : PBITMAPINFOHEADER ; // format of frame to compress
  350. lpInput : PVOID ; // frame data to compress
  351. lpckid : PDWORD ; // ckid for data in AVI file
  352. lpdwFlags : PDWORD; // flags in the AVI index.
  353. lFrameNum : LONG ; // frame number of seq.
  354. dwFrameSize : DWORD ; // reqested size in bytes. (if non zero)
  355. dwQuality : DWORD ; // quality
  356. // these are new fields
  357. lpbiPrev : PBITMAPINFOHEADER ; // format of previous frame
  358. lpPrev : PVOID ; // previous frame
  359. end;
  360. (************************************************************************
  361. ************************************************************************)
  362. const
  363. ICCOMPRESSFRAMES_PADDING = $00000001 ;
  364. type
  365. TICCompressProc = function(lInputOutput: LPARAM; lFrame: DWORD; lpBits: PVOID; len: LONG): LONG; stdcall;
  366. PICCOMPRESSFRAMES = ^TICCOMPRESSFRAMES;
  367. TICCOMPRESSFRAMES = packed record
  368. dwFlags : DWORD ; // flags
  369. lpbiOutput : PBITMAPINFOHEADER ; // output format
  370. lOutput : LPARAM ; // output identifier
  371. lpbiInput : PBITMAPINFOHEADER ; // format of frame to compress
  372. lInput : LPARAM ; // input identifier
  373. lStartFrame : LONG ; // start frame
  374. lFrameCount : LONG ; // # of frames
  375. lQuality : LONG ; // quality
  376. lDataRate : LONG ; // data rate
  377. lKeyRate : LONG ; // key frame rate
  378. dwRate : DWORD ; // frame rate, as always
  379. dwScale : DWORD ;
  380. dwOverheadPerFrame : DWORD ;
  381. dwReserved2 : DWORD ;
  382. GetData : TICCompressProc;
  383. PutData : TICCompressProc;
  384. end;
  385. {-- Messages for Status callback ---------------------------------------------}
  386. const
  387. ICSTATUS_START = 0 ;
  388. ICSTATUS_STATUS = 1 ; // l = % done
  389. ICSTATUS_END = 2 ;
  390. ICSTATUS_ERROR = 3 ; // l = error string (LPSTR)
  391. ICSTATUS_YIELD = 4 ;
  392. type
  393. // return nonzero means abort operation in progress
  394. TICStatusProc = function(lParam: LPARAM; message: UINT; l: LONG): LONG; stdcall;
  395. PICSETSTATUSPROC = ^TICSETSTATUSPROC;
  396. TICSETSTATUSPROC = packed record
  397. dwFlags : DWORD ;
  398. lParam : LPARAM ;
  399. Status : TICStatusProc;
  400. end;
  401. (************************************************************************
  402. ************************************************************************)
  403. const
  404. ICDECOMPRESS_HURRYUP = $80000000 ; // don't draw just buffer (hurry up!)
  405. ICDECOMPRESS_UPDATE = $40000000 ; // don't draw just update screen
  406. ICDECOMPRESS_PREROLL = $20000000 ; // this frame is before real start
  407. ICDECOMPRESS_NULLFRAME = $10000000 ; // repeat last frame
  408. ICDECOMPRESS_NOTKEYFRAME = $08000000 ; // this frame is not a key frame
  409. type
  410. PICDECOMPRESS = ^TICDECOMPRESS;
  411. TICDECOMPRESS = packed record
  412. dwFlags : DWORD ; // flags (from AVI index...)
  413. lpbiInput : PBITMAPINFOHEADER ; // BITMAPINFO of compressed data
  414. // biSizeImage has the chunk size
  415. lpInput : PVOID ; // compressed data
  416. lpbiOutput : PBITMAPINFOHEADER ; // DIB to decompress to
  417. lpOutput : PVOID ;
  418. ckid : DWORD ; // ckid from AVI file
  419. end;
  420. PICDECOMPRESSEX = ^TICDECOMPRESSEX;
  421. TICDECOMPRESSEX = packed record
  422. //
  423. // same as ICM_DECOMPRESS
  424. //
  425. dwFlags : DWORD;
  426. lpbiSrc : PBITMAPINFOHEADER; // BITMAPINFO of compressed data
  427. lpSrc : PVOID; // compressed data
  428. lpbiDst : PBITMAPINFOHEADER; // DIB to decompress to
  429. lpDst : PVOID; // output data
  430. //
  431. // new for ICM_DECOMPRESSEX
  432. //
  433. xDst : int; // destination rectangle
  434. yDst : int;
  435. dxDst : int;
  436. dyDst : int;
  437. xSrc : int; // source rectangle
  438. ySrc : int;
  439. dxSrc : int;
  440. dySrc : int;
  441. end;
  442. (************************************************************************
  443. ************************************************************************)
  444. const
  445. ICDRAW_QUERY = $00000001 ; // test for support
  446. ICDRAW_FULLSCREEN = $00000002 ; // draw to full screen
  447. ICDRAW_HDC = $00000004 ; // draw to a HDC/HWND
  448. ICDRAW_ANIMATE = $00000008 ; // expect palette animation
  449. ICDRAW_CONTINUE = $00000010 ; // draw is a continuation of previous draw
  450. ICDRAW_MEMORYDC = $00000020 ; // DC is offscreen, by the way
  451. ICDRAW_UPDATING = $00000040 ; // We're updating, as opposed to playing
  452. ICDRAW_RENDER = $00000080 ; // used to render data not draw it
  453. ICDRAW_BUFFER = $00000100 ; // please buffer this data offscreen, we will need to update it
  454. type
  455. PICDRAWBEGIN = ^TICDRAWBEGIN;
  456. TICDRAWBEGIN = packed record
  457. dwFlags : DWORD ; // flags
  458. hpal : HPALETTE ; // palette to draw with
  459. hwnd : HWND ; // window to draw to
  460. hdc : HDC ; // HDC to draw to
  461. xDst : int ; // destination rectangle
  462. yDst : int ;
  463. dxDst : int ;
  464. dyDst : int ;
  465. lpbi : PBITMAPINFOHEADER ;
  466. // format of frame to draw
  467. xSrc : int ; // source rectangle
  468. ySrc : int ;
  469. dxSrc : int ;
  470. dySrc : int ;
  471. dwRate : DWORD ; // frames/second = (dwRate/dwScale)
  472. dwScale : DWORD ;
  473. end;
  474. (************************************************************************
  475. ************************************************************************)
  476. const
  477. ICDRAW_HURRYUP = $80000000 ; // don't draw just buffer (hurry up!)
  478. ICDRAW_UPDATE = $40000000 ; // don't draw just update screen
  479. ICDRAW_PREROLL = $20000000 ; // this frame is before real start
  480. ICDRAW_NULLFRAME = $10000000 ; // repeat last frame
  481. ICDRAW_NOTKEYFRAME = $08000000 ; // this frame is not a key frame
  482. type
  483. PICDRAW = ^TICDRAW;
  484. TICDRAW = packed record
  485. dwFlags : DWORD ; // flags
  486. lpFormat : PVOID ; // format of frame to decompress
  487. lpData : PVOID ; // frame data to decompress
  488. cbData : DWORD ;
  489. lTime : LONG ; // time in drawbegin units (see dwRate and dwScale)
  490. end;
  491. PICDRAWSUGGEST = ^TICDRAWSUGGEST;
  492. TICDRAWSUGGEST = packed record
  493. lpbiIn : PBITMAPINFOHEADER ; // format to be drawn
  494. lpbiSuggest : PBITMAPINFOHEADER ; // location for suggested format (or NULL to get size)
  495. dxSrc : int ; // source extent or 0
  496. dySrc : int ;
  497. dxDst : int ; // dest extent or 0
  498. dyDst : int ;
  499. hicDecompressor : HIC ; // decompressor you can talk to
  500. end;
  501. (************************************************************************
  502. ************************************************************************)
  503. PICPALETTE = ^TICPALETTE;
  504. TICPALETTE = packed record
  505. dwFlags : DWORD ; // flags (from AVI index...)
  506. iStart : int ; // first palette to change
  507. iLen : int ; // count of entries to change.
  508. lppe : PPALETTEENTRY ; // palette
  509. end;
  510. (************************************************************************
  511. ICM function declarations
  512. ************************************************************************)
  513. function ICInfo(fccType, fccHandler: DWORD; lpicinfo: PICINFO) : BOOL ; stdcall ;
  514. function ICInstall(fccType, fccHandler: DWORD; lParam: LPARAM; szDesc: LPSTR; wFlags: UINT) : BOOL ; stdcall ;
  515. function ICRemove(fccType, fccHandler: DWORD; wFlags: UINT) : BOOL ; stdcall ;
  516. function ICGetInfo(hic: HIC; picinfo: PICINFO; cb: DWORD) : DWORD ; stdcall ;
  517. function ICOpen(fccType, fccHandler: DWORD; wMode: UINT) : HIC ; stdcall ;
  518. function ICOpenFunction(fccType, fccHandler: DWORD; wMode: UINT; lpfnHandler: TFarProc) : HIC ; stdcall ;
  519. function ICClose(hic: HIC) : DWORD; stdcall ;
  520. function ICSendMessage(hic: HIC; msg: UINT; dw1, dw2: DWORD) : DWORD ; stdcall ;
  521. {-- Values for wFlags of ICInstall -------------------------------------------}
  522. const
  523. ICINSTALL_UNICODE = $8000 ;
  524. ICINSTALL_FUNCTION = $0001 ; // lParam is a DriverProc (function ptr)
  525. ICINSTALL_DRIVER = $0002 ; // lParam is a driver name (string)
  526. ICINSTALL_HDRV = $0004 ; // lParam is a HDRVR (driver handle)
  527. ICINSTALL_DRIVERW = $8002 ; // lParam is a unicode driver name
  528. {-- Query macros -------------------------------------------------------------}
  529. ICMF_CONFIGURE_QUERY = $00000001 ;
  530. ICMF_ABOUT_QUERY = $00000001 ;
  531. function ICQueryAbout(hic: HIC): BOOL;
  532. function ICAbout(hic: HIC; hwnd: HWND): DWORD;
  533. function ICQueryConfigure(hic: HIC): BOOL;
  534. function ICConfigure(hic: HIC; hwnd: HWND): DWORD;
  535. {-- Get/Set state macros -----------------------------------------------------}
  536. function ICGetState(hic: HIC; pv: PVOID; cb: DWORD): DWORD;
  537. function ICSetState(hic: HIC; pv: PVOID; cb: DWORD): DWORD;
  538. function ICGetStateSize(hic: HIC): DWORD;
  539. {-- Get value macros ---------------------------------------------------------}
  540. function ICGetDefaultQuality(hic: HIC): DWORD;
  541. function ICGetDefaultKeyFrameRate(hic: HIC): DWORD;
  542. {-- Draw window macro --------------------------------------------------------}
  543. function ICDrawWindow(hic: HIC; prc: PRECT): DWORD;
  544. (************************************************************************
  545. compression functions
  546. ************************************************************************/
  547. /*
  548. * ICCompress()
  549. *
  550. * compress a single frame
  551. *
  552. *)
  553. function ICCompress(
  554. hic : HIC;
  555. dwFlags : DWORD; // flags
  556. lpbiOutput : PBITMAPINFOHEADER; // output format
  557. lpData : PVOID; // output data
  558. lpbiInput : PBITMAPINFOHEADER; // format of frame to compress
  559. lpBits : PVOID; // frame data to compress
  560. lpckid : PDWORD; // ckid for data in AVI file
  561. lpdwFlags : PDWORD; // flags in the AVI index.
  562. lFrameNum : DWORD; // frame number of seq.
  563. dwFrameSize : DWORD; // reqested size in bytes. (if non zero)
  564. dwQuality : DWORD; // quality within one frame
  565. lpbiPrev : PBITMAPINFOHEADER; // format of previous frame
  566. lpPrev : PVOID // previous frame
  567. ): DWORD; cdecl;
  568. (*
  569. * ICCompressBegin()
  570. *
  571. * start compression from a source format (lpbiInput) to a dest
  572. * format (lpbiOuput) is supported.
  573. *
  574. *)
  575. function ICCompressBegin(hic: HIC; lpbiInput: PBITMAPINFOHEADER; lpbiOutput: PBITMAPINFOHEADER): DWORD;
  576. (*
  577. * ICCompressQuery()
  578. *
  579. * determines if compression from a source format (lpbiInput) to a dest
  580. * format (lpbiOuput) is supported.
  581. *
  582. *)
  583. function ICCompressQuery(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  584. (*
  585. * ICCompressGetFormat()
  586. *
  587. * get the output format, (format of compressed data)
  588. * if lpbiOutput is NULL return the size in bytes needed for format.
  589. *
  590. *)
  591. function ICCompressGetFormat(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  592. function ICCompressGetFormatSize(hic: HIC; lpbi: PBITMAPINFOHEADER): DWORD;
  593. (*
  594. * ICCompressSize()
  595. *
  596. * return the maximal size of a compressed frame
  597. *
  598. *)
  599. function ICCompressGetSize(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  600. function ICCompressEnd(hic: HIC): DWORD;
  601. (************************************************************************
  602. decompression functions
  603. ************************************************************************)
  604. (*
  605. * ICDecompress()
  606. *
  607. * decompress a single frame
  608. *
  609. *)
  610. function ICDecompress(
  611. hic : HIC;
  612. dwFlags : DWORD; // flags (from AVI index...)
  613. lpbiFormat : PBITMAPINFOHEADER; // BITMAPINFO of compressed data
  614. // biSizeImage has the chunk size
  615. lpData : PVOID; // data
  616. lpbi : PBITMAPINFOHEADER; // DIB to decompress to
  617. lpBits : PVOID
  618. ): DWORD; cdecl;
  619. (*
  620. * ICDecompressBegin()
  621. *
  622. * start compression from a source format (lpbiInput) to a dest
  623. * format (lpbiOutput) is supported.
  624. *
  625. *)
  626. function ICDecompressBegin(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  627. (*
  628. * ICDecompressQuery()
  629. *
  630. * determines if compression from a source format (lpbiInput) to a dest
  631. * format (lpbiOutput) is supported.
  632. *
  633. *)
  634. function ICDecompressQuery(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  635. (*
  636. * ICDecompressGetFormat()
  637. *
  638. * get the output format, (format of un-compressed data)
  639. * if lpbiOutput is NULL return the size in bytes needed for format.
  640. *
  641. *)
  642. function ICDecompressGetFormat(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  643. function ICDecompressGetFormatSize(hic: HIC; lpbi: PBITMAPINFOHEADER): DWORD;
  644. (*
  645. * ICDecompressGetPalette()
  646. *
  647. * get the output palette
  648. *
  649. *)
  650. function ICDecompressGetPalette(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  651. function ICDecompressSetPalette(hic: HIC; lpbiPalette: PBITMAPINFOHEADER): DWORD;
  652. function ICDecompressEnd(hic: HIC): DWORD;
  653. (************************************************************************
  654. decompression (ex) functions
  655. ************************************************************************)
  656. //
  657. // on Win16 these functions are macros that call ICMessage. ICMessage will
  658. // not work on NT. rather than add new entrypoints we have given
  659. // them as static inline functions
  660. //
  661. (*
  662. * ICDecompressEx()
  663. *
  664. * decompress a single frame
  665. *
  666. *)
  667. function ICDecompressEx(
  668. hic : HIC;
  669. dwFlags : DWORD;
  670. lpbiSrc : PBITMAPINFOHEADER;
  671. lpSrc : PVOID;
  672. xSrc : int;
  673. ySrc : int;
  674. dxSrc : int;
  675. dySrc : int;
  676. lpbiDst : PBITMAPINFOHEADER;
  677. lpDst : PVOID;
  678. xDst : int;
  679. yDst : int;
  680. dxDst : int;
  681. dyDst : int
  682. ): DWORD; stdcall;
  683. (*
  684. * ICDecompressExBegin()
  685. *
  686. * start compression from a source format (lpbiInput) to a dest
  687. * format (lpbiOutput) is supported.
  688. *
  689. *)
  690. function ICDecompressExBegin(
  691. hic : HIC;
  692. dwFlags : DWORD;
  693. lpbiSrc : PBITMAPINFOHEADER;
  694. lpSrc : PVOID;
  695. xSrc : int;
  696. ySrc : int;
  697. dxSrc : int;
  698. dySrc : int;
  699. lpbiDst : PBITMAPINFOHEADER;
  700. lpDst : PVOID;
  701. xDst : int;
  702. yDst : int;
  703. dxDst : int;
  704. dyDst : int
  705. ): DWORD; stdcall;
  706. (*
  707. * ICDecompressExQuery()
  708. *
  709. *)
  710. function ICDecompressExQuery(
  711. hic : HIC;
  712. dwFlags : DWORD;
  713. lpbiSrc : PBITMAPINFOHEADER;
  714. lpSrc : PVOID;
  715. xSrc : int;
  716. ySrc : int;
  717. dxSrc : int;
  718. dySrc : int;
  719. lpbiDst : PBITMAPINFOHEADER;
  720. lpDst : PVOID;
  721. xDst : int;
  722. yDst : int;
  723. dxDst : int;
  724. dyDst : int
  725. ): DWORD; stdcall;
  726. function ICDecompressExEnd(hic: HIC): DWORD;
  727. (************************************************************************
  728. drawing functions
  729. ************************************************************************)
  730. (*
  731. * ICDrawBegin()
  732. *
  733. * start decompressing data with format (lpbiInput) directly to the screen
  734. *
  735. * return zero if the decompressor supports drawing.
  736. *
  737. *)
  738. function ICDrawBegin(
  739. hic : HIC;
  740. dwFlags : DWORD; // flags
  741. hpal : HPALETTE; // palette to draw with
  742. hwnd : HWND; // window to draw to
  743. hdc : HDC; // HDC to draw to
  744. xDst : int; // destination rectangle
  745. yDst : int;
  746. dxDst : int;
  747. dyDst : int;
  748. lpbi : PBITMAPINFOHEADER; // format of frame to draw
  749. xSrc : int; // source rectangle
  750. ySrc : int;
  751. dxSrc : int;
  752. dySrc : int;
  753. dwRate : DWORD; // frames/second = (dwRate/dwScale)
  754. dwScale : DWORD
  755. ): DWORD; cdecl;
  756. (*
  757. * ICDraw()
  758. *
  759. * decompress data directly to the screen
  760. *
  761. *)
  762. function ICDraw(
  763. hic : HIC;
  764. dwFlags : DWORD; // flags
  765. lpFormat : PVOID; // format of frame to decompress
  766. lpData : PVOID; // frame data to decompress
  767. cbData : DWORD; // size of data
  768. lTime : DWORD // time to draw this frame
  769. ): DWORD; cdecl;
  770. // ICMessage is not supported on Win32, so provide a static inline function
  771. // to do the same job
  772. function ICDrawSuggestFormat(
  773. hic : HIC;
  774. lpbiIn : PBITMAPINFOHEADER;
  775. lpbiOut : PBITMAPINFOHEADER;
  776. dxSrc : int;
  777. dySrc : int;
  778. dxDst : int;
  779. dyDst : int;
  780. hicDecomp : HIC
  781. ): DWORD; stdcall;
  782. (*
  783. * ICDrawQuery()
  784. *
  785. * determines if the compressor is willing to render the specified format.
  786. *
  787. *)
  788. function ICDrawQuery(hic: HIC; lpbiInput: PBITMAPINFOHEADER): DWORD;
  789. function ICDrawChangePalette(hic: HIC; lpbiInput: PBITMAPINFOHEADER): DWORD;
  790. function ICGetBuffersWanted(hic: HIC; lpdwBuffers: PDWORD): DWORD;
  791. function ICDrawEnd(hic: HIC): DWORD;
  792. function ICDrawStart(hic: HIC): DWORD;
  793. function ICDrawStartPlay(hic: HIC; lFrom, lTo: DWORD): DWORD;
  794. function ICDrawStop(hic: HIC): DWORD;
  795. function ICDrawStopPlay(hic: HIC): DWORD;
  796. function ICDrawGetTime(hic: HIC; lplTime: PDWORD): DWORD;
  797. function ICDrawSetTime(hic: HIC; lTime: DWORD): DWORD;
  798. function ICDrawRealize(hic: HIC; hdc: HDC; fBackground: BOOL): DWORD;
  799. function ICDrawFlush(hic: HIC): DWORD;
  800. function ICDrawRenderBuffer(hic: HIC): DWORD;
  801. (************************************************************************
  802. Status callback functions
  803. ************************************************************************/
  804. /*
  805. * ICSetStatusProc()
  806. *
  807. * Set the status callback function
  808. *
  809. *)
  810. // ICMessage is not supported on NT
  811. function ICSetStatusProc(
  812. hic : HIC;
  813. dwFlags : DWORD;
  814. lParam : DWORD;
  815. fpfnStatus : TICStatusProc
  816. ): DWORD; stdcall;
  817. (************************************************************************
  818. helper routines for DrawDib and MCIAVI...
  819. ************************************************************************)
  820. function ICLocate(fccType, fccHandler: DWORD; lpbiIn, lpbiOut: PBITMAPINFOHEADER; wFlags: WORD): HIC; stdcall;
  821. function ICGetDisplayFormat(hic: HIC; lpbiIn, lpbiOut: PBITMAPINFOHEADER; BitDepth: int; dx, dy: int): HIC; stdcall;
  822. function ICDecompressOpen(fccType, fccHandler: DWORD; lpbiIn, lpbiOut: PBITMAPINFOHEADER): HIC;
  823. function ICDrawOpen(fccType, fccHandler: DWORD; lpbiIn: PBITMAPINFOHEADER): HIC;
  824. (************************************************************************
  825. Higher level functions
  826. ************************************************************************)
  827. function ICImageCompress(
  828. hic : HIC; // compressor to use
  829. uiFlags : UINT; // flags (none yet)
  830. lpbiIn : PBITMAPINFO; // format to compress from
  831. lpBits : PVOID; // data to compress
  832. lpbiOut : PBITMAPINFO; // compress to this (NULL ==> default)
  833. lQuality : LONG; // quality to use
  834. plSize : PDWORD // compress to this size (0=whatever)
  835. ): THANDLE; stdcall;
  836. function ICImageDecompress(
  837. hic : HIC; // compressor to use
  838. uiFlags : UINT; // flags (none yet)
  839. lpbiIn : PBITMAPINFO; // format to decompress from
  840. lpBits : PVOID; // data to decompress
  841. lpbiOut : PBITMAPINFO // decompress to this (NULL ==> default)
  842. ): THANDLE; stdcall;
  843. {-- TCompVars ----------------------------------------------------------------}
  844. //
  845. // Structure used by ICSeqCompressFrame and ICCompressorChoose routines
  846. // Make sure this matches the autodoc in icm.c!
  847. //
  848. type
  849. PCOMPVARS = ^TCOMPVARS;
  850. TCOMPVARS = packed record
  851. cbSize : DWORD; // set to sizeof(COMPVARS) before
  852. // calling ICCompressorChoose
  853. dwFlags : DWORD; // see below...
  854. hic : HIC; // HIC of chosen compressor
  855. fccType : DWORD; // basically ICTYPE_VIDEO
  856. fccHandler : DWORD; // handler of chosen compressor or
  857. // "" or "DIB "
  858. lpbiIn : PBITMAPINFO; // input format
  859. lpbiOut : PBITMAPINFO; // output format - will compress to this
  860. lpBitsOut : PVOID;
  861. lpBitsPrev : PVOID;
  862. lFrame : LONG;
  863. lKey : LONG; // key frames how often?
  864. lDataRate : LONG; // desired data rate KB/Sec
  865. lQ : LONG; // desired quality
  866. lKeyCount : LONG;
  867. lpState : PVOID; // state of compressor
  868. cbState : LONG; // size of the state
  869. end;
  870. // FLAGS for dwFlags element of COMPVARS structure:
  871. // set this flag if you initialize COMPVARS before calling ICCompressorChoose
  872. const
  873. ICMF_COMPVARS_VALID = $00000001; // COMPVARS contains valid data
  874. //
  875. // allows user to choose compressor, quality etc...
  876. //
  877. function ICCompressorChoose(
  878. hwnd : HWND; // parent window for dialog
  879. uiFlags : UINT; // flags
  880. pvIn : PVOID; // input format (optional)
  881. lpData : PVOID; // input data (optional)
  882. pc : PCOMPVARS; // data about the compressor/dlg
  883. lpszTitle : LPSTR // dialog title (optional)
  884. ): BOOL; stdcall;
  885. // defines for uiFlags
  886. const
  887. ICMF_CHOOSE_KEYFRAME = $0001; // show KeyFrame Every box
  888. ICMF_CHOOSE_DATARATE = $0002; // show DataRate box
  889. ICMF_CHOOSE_PREVIEW = $0004; // allow expanded preview dialog
  890. ICMF_CHOOSE_ALLCOMPRESSORS = $0008; // don't only show those that
  891. // can handle the input format
  892. // or input data
  893. function ICSeqCompressFrameStart(pc: PCOMPVARS; lpbiIn: PBITMAPINFO): BOOL; stdcall;
  894. procedure ICSeqCompressFrameEnd(pc: PCOMPVARS); stdcall;
  895. function ICSeqCompressFrame(
  896. pc : PCOMPVARS; // set by ICCompressorChoose
  897. uiFlags : UINT; // flags
  898. lpBits : PVOID; // input DIB bits
  899. pfKey : PBOOL; // did it end up being a key frame?
  900. plSize : PDWORD // size to compress to/of returned image
  901. ): PVOID; stdcall;
  902. procedure ICCompressorFree(pc: PCOMPVARS); stdcall;
  903. (**************************************************************************
  904. *
  905. * DRAWDIB - Routines for drawing to the display.
  906. *
  907. *************************************************************************)
  908. type
  909. HDRAWDIB = THandle; // hdd
  910. (*********************************************************************
  911. DrawDib Flags
  912. **********************************************************************)
  913. const
  914. DDF_UPDATE = $0002; // re-draw the last DIB
  915. DDF_SAME_HDC = $0004; // HDC same as last call (all setup)
  916. DDF_SAME_DRAW = $0008; // draw params are the same
  917. DDF_DONTDRAW = $0010; // dont draw frame, just decompress
  918. DDF_ANIMATE = $0020; // allow palette animation
  919. DDF_BUFFER = $0040; // always buffer image
  920. DDF_JUSTDRAWIT = $0080; // just draw it with GDI
  921. DDF_FULLSCREEN = $0100; // use DisplayDib
  922. DDF_BACKGROUNDPAL = $0200; // Realize palette in background
  923. DDF_NOTKEYFRAME = $0400; // this is a partial frame update, hint
  924. DDF_HURRYUP = $0800; // hurry up please!
  925. DDF_HALFTONE = $1000; // always halftone
  926. DDF_PREROLL = DDF_DONTDRAW; // Builing up a non-keyframe
  927. DDF_SAME_DIB = DDF_SAME_DRAW;
  928. DDF_SAME_SIZE = DDF_SAME_DRAW;
  929. (*********************************************************************
  930. DrawDib functions
  931. *********************************************************************)
  932. {-- DrawDibOpen() ------------------------------------------------------------}
  933. function DrawDibOpen: HDRAWDIB; stdcall;
  934. {-- DrawDibClose() -----------------------------------------------------------}
  935. function DrawDibClose(hdd: HDRAWDIB): BOOL; stdcall;
  936. {-- DrawDibGetBuffer() -------------------------------------------------------}
  937. function DrawDibGetBuffer(hdd: HDRAWDIB; lpbi: PBITMAPINFOHEADER; dwSize: DWORD; dwFlags: DWORD): PVOID; stdcall;
  938. {-- DrawDibGetPalette() - get the palette used for drawing DIBs --------------}
  939. function DrawDibGetPalette(hdd: HDRAWDIB): HPALETTE; stdcall;
  940. {-- DrawDibSetPalette() - set the palette used for drawing DIBs --------------}
  941. function DrawDibSetPalette(hdd: HDRAWDIB; hpal: HPALETTE): BOOL; stdcall;
  942. {-- DrawDibChangePalette() ---------------------------------------------------}
  943. function DrawDibChangePalette(hdd: HDRAWDIB; iStart, iLen: int; lppe: PPALETTEENTRY): BOOL; stdcall;
  944. {-- DrawDibRealize() - realize the palette in a HDD --------------------------}
  945. function DrawDibRealize(hdd: HDRAWDIB; hdc: HDC; fBackground: BOOL): UINT; stdcall;
  946. {-- DrawDibStart() - start of streaming playback -----------------------------}
  947. function DrawDibStart(hdd: HDRAWDIB; rate: DWORD): BOOL; stdcall;
  948. {-- DrawDibStop() - start of streaming playback ------------------------------}
  949. function DrawDibStop(hdd: HDRAWDIB): BOOL; stdcall;
  950. {-- DrawDibBegin() - prepare to draw -----------------------------------------}
  951. function DrawDibBegin(
  952. hdd : HDRAWDIB;
  953. hdc : HDC;
  954. dxDst : int;
  955. dyDst : int;
  956. lpbi : PBITMAPINFOHEADER;
  957. dxSrc : int;
  958. dySrc : int;
  959. wFlags : UINT
  960. ): BOOL; stdcall;
  961. {-- DrawDibDraw() - actually draw a DIB to the screen ------------------------}
  962. function DrawDibDraw(
  963. hdd : HDRAWDIB;
  964. hdc : HDC;
  965. xDst : int;
  966. yDst : int;
  967. dxDst : int;
  968. dyDst : int;
  969. lpbi : PBITMAPINFOHEADER;
  970. lpBits : PVOID;
  971. xSrc : int;
  972. ySrc : int;
  973. dxSrc : int;
  974. dySrc : int;
  975. wFlags : UINT
  976. ): BOOL; stdcall;
  977. {-- DrawDibUpdate() - redraw last image (may only be valid with DDF_BUFFER) --}
  978. function DrawDibUpdate(hdd: HDRAWDIB; hdc: HDC; x, y: int): BOOL;
  979. {-- DrawDibEnd() -------------------------------------------------------------}
  980. function DrawDibEnd(hdd: HDRAWDIB): BOOL; stdcall;
  981. {-- DrawDibTime() - for debugging purposes only ------------------------------}
  982. type
  983. PDRAWDIBTIME = ^TDRAWDIBTIME;
  984. TDRAWDIBTIME = packed record
  985. timeCount : LONG;
  986. timeDraw : LONG;
  987. timeDecompress : LONG;
  988. timeDither : LONG;
  989. timeStretch : LONG;
  990. timeBlt : LONG;
  991. timeSetDIBits : LONG;
  992. end;
  993. function DrawDibTime(hdd: HDRAWDIB; lpddtime: PDRAWDIBTIME): BOOL; stdcall;
  994. {-- Display profiling --------------------------------------------------------}
  995. const
  996. PD_CAN_DRAW_DIB = $0001; // if you can draw at all
  997. PD_CAN_STRETCHDIB = $0002; // basicly RC_STRETCHDIB
  998. PD_STRETCHDIB_1_1_OK = $0004; // is it fast?
  999. PD_STRETCHDIB_1_2_OK = $0008; // ...
  1000. PD_STRETCHDIB_1_N_OK = $0010; // ...
  1001. function DrawDibProfileDisplay(lpbi: PBITMAPINFOHEADER): DWORD; stdcall;
  1002. (****************************************************************************
  1003. *
  1004. * AVIFMT - AVI file format definitions
  1005. *
  1006. ****************************************************************************)
  1007. //
  1008. // The following is a short description of the AVI file format. Please
  1009. // see the accompanying documentation for a full explanation.
  1010. //
  1011. // An AVI file is the following RIFF form:
  1012. //
  1013. // RIFF('AVI'
  1014. // LIST('hdrl'
  1015. // avih(<MainAVIHeader>)
  1016. // LIST ('strl'
  1017. // strh(<Stream header>)
  1018. // strf(<Stream format>)
  1019. // ... additional header data
  1020. // LIST('movi'
  1021. // { LIST('rec'
  1022. // SubChunk...
  1023. // )
  1024. // | SubChunk } ....
  1025. // )
  1026. // [ <AVIIndex> ]
  1027. // )
  1028. //
  1029. // The main file header specifies how many streams are present. For
  1030. // each one, there must be a stream header chunk and a stream format
  1031. // chunk, enlosed in a 'strl' LIST chunk. The 'strf' chunk contains
  1032. // type-specific format information; for a video stream, this should
  1033. // be a BITMAPINFO structure, including palette. For an audio stream,
  1034. // this should be a WAVEFORMAT (or PCMWAVEFORMAT) structure.
  1035. //
  1036. // The actual data is contained in subchunks within the 'movi' LIST
  1037. // chunk. The first two characters of each data chunk are the
  1038. // stream number with which that data is associated.
  1039. //
  1040. // Some defined chunk types:
  1041. // Video Streams:
  1042. // ##db: RGB DIB bits
  1043. // ##dc: RLE8 compressed DIB bits
  1044. // ##pc: Palette Change
  1045. //
  1046. // Audio Streams:
  1047. // ##wb: waveform audio bytes
  1048. //
  1049. // The grouping into LIST 'rec' chunks implies only that the contents of
  1050. // the chunk should be read into memory at the same time. This
  1051. // grouping is used for files specifically intended to be played from
  1052. // CD-ROM.
  1053. //
  1054. // The index chunk at the end of the file should contain one entry for
  1055. // each data chunk in the file.
  1056. //
  1057. // Limitations for the current software:
  1058. // Only one video stream and one audio stream are allowed.
  1059. // The streams must start at the beginning of the file.
  1060. //
  1061. //
  1062. // To register codec types please obtain a copy of the Multimedia
  1063. // Developer Registration Kit from:
  1064. //
  1065. // Microsoft Corporation
  1066. // Multimedia Systems Group
  1067. // Product Marketing
  1068. // One Microsoft Way
  1069. // Redmond, WA 98052-6399
  1070. //
  1071. {-- form types, list types and chunk types -----------------------------------}
  1072. const
  1073. formtypeAVI = $20495641; // mmioFOURCC('A', 'V', 'I', ' ')
  1074. listtypeAVIHEADER = $6C726468; // mmioFOURCC('h', 'd', 'r', 'l')
  1075. ckidAVIMAINHDR = $68697661; // mmioFOURCC('a', 'v', 'i', 'h')
  1076. listtypeSTREAMHEADER = $6C727473; // mmioFOURCC('s', 't', 'r', 'l')
  1077. ckidSTREAMHEADER = $68727473; // mmioFOURCC('s', 't', 'r', 'h')
  1078. ckidSTREAMFORMAT = $66727473; // mmioFOURCC('s', 't', 'r', 'f')
  1079. ckidSTREAMHANDLERDATA = $64727473; // mmioFOURCC('s', 't', 'r', 'd')
  1080. ckidSTREAMNAME = $6E727473; // mmioFOURCC('s', 't', 'r', 'n')
  1081. listtypeAVIMOVIE = $69766F6D; // mmioFOURCC('m', 'o', 'v', 'i')
  1082. listtypeAVIRECORD = $20636572; // mmioFOURCC('r', 'e', 'c', ' ')
  1083. ckidAVINEWINDEX = $31786469; // mmioFOURCC('i', 'd', 'x', '1')
  1084. {-- Stream types for the <fccType> field of the stream header ----------------}
  1085. streamtypeVIDEO = $73646976; // mmioFOURCC('v', 'i', 'd', 's')
  1086. streamtypeAUDIO = $73647561; // mmioFOURCC('a', 'u', 'd', 's')
  1087. streamtypeMIDI = $7364696D; // mmioFOURCC('m', 'i', 'd', 's')
  1088. streamtypeTEXT = $73747874; // mmioFOURCC('t', 'x', 't', 's')
  1089. {-- Basic chunk types --------------------------------------------------------}
  1090. cktypeDIBbits = $6264; // aviTWOCC('d', 'b')
  1091. cktypeDIBcompressed = $6364; // aviTWOCC('d', 'c')
  1092. cktypePALchange = $6370; // aviTWOCC('p', 'c')
  1093. cktypeWAVEbytes = $6277; // aviTWOCC('w', 'b')
  1094. {-- Chunk id to use for extra chunks for padding -----------------------------}
  1095. ckidAVIPADDING = $4B4E554A; // mmioFOURCC('J', 'U', 'N', 'K')
  1096. (*
  1097. ** Useful macros
  1098. **
  1099. ** Warning: These are nasty macro, and MS C 6.0 compiles some of them
  1100. ** incorrectly if optimizations are on. Ack.
  1101. *)
  1102. {-- Macro to get stream number out of a FOURCC ckid --------------------------}
  1103. function FromHex(n: BYTE): BYTE;
  1104. function StreamFromFOURCC(fcc: DWORD): BYTE;
  1105. {-- Macro to get TWOCC chunk type out of a FOURCC ckid -----------------------}
  1106. function TWOCCFromFOURCC(fcc: DWORD): WORD;
  1107. {-- Macro to make a ckid for a chunk out of a TWOCC and a stream num (0-255) -}
  1108. function ToHex(n: BYTE): BYTE;
  1109. function MAKEAVICKID(tcc: WORD; stream: BYTE): DWORD;
  1110. {-- Main AVI file header -----------------------------------------------------}
  1111. {-- flags for use in <dwFlags> in AVIFileHdr ---------------------------------}
  1112. const
  1113. AVIF_HASINDEX = $00000010; // Index at end of file?
  1114. AVIF_MUSTUSEINDEX = $00000020;
  1115. AVIF_ISINTERLEAVED = $00000100;
  1116. AVIF_TRUSTCKTYPE = $00000800; // Use CKType to find key frames?
  1117. AVIF_WASCAPTUREFILE = $00010000;
  1118. AVIF_COPYRIGHTED = $00020000;
  1119. {-- The AVI File Header LIST chunk should be padded to this size -------------}
  1120. const
  1121. AVI_HEADERSIZE = 2048; // size of AVI header list
  1122. type
  1123. PMainAVIHeader = ^TMainAVIHeader;
  1124. TMainAVIHeader = packed record
  1125. dwMicroSecPerFrame : DWORD; // frame display rate (or 0L)
  1126. dwMaxBytesPerSec : DWORD; // max. transfer rate
  1127. dwPaddingGranularity : DWORD; // pad to multiples of this
  1128. // size; normally 2K.
  1129. dwFlags : DWORD; // the ever-present flags
  1130. dwTotalFrames : DWORD; // # frames in file
  1131. dwInitialFrames : DWORD;
  1132. dwStreams : DWORD;
  1133. dwSuggestedBufferSize : DWORD;
  1134. dwWidth : DWORD;
  1135. dwHeight : DWORD;
  1136. dwReserved : array[0..3] of DWORD;
  1137. end;
  1138. {-- Stream header ------------------------------------------------------------}
  1139. const
  1140. AVISF_DISABLED = $00000001;
  1141. AVISF_VIDEO_PALCHANGES = $00010000;
  1142. type
  1143. PAVIStreamHeader = ^TAVIStreamHeader;
  1144. TAVIStreamHeader = packed record
  1145. fccType : FOURCC;
  1146. fccHandler : FOURCC;
  1147. dwFlags : DWORD; // Contains AVITF_* flags
  1148. wPriority : WORD;
  1149. wLanguage : WORD;
  1150. dwInitialFrames : DWORD;
  1151. dwScale : DWORD;
  1152. dwRate : DWORD; // dwRate / dwScale == samples/second
  1153. dwStart : DWORD;
  1154. dwLength : DWORD; // In units above...
  1155. dwSuggestedBufferSize : DWORD;
  1156. dwQuality : DWORD;
  1157. dwSampleSize : DWORD;
  1158. rcFrame : TRECT;
  1159. end;
  1160. {-- Flags for index ----------------------------------------------------------}
  1161. const
  1162. AVIIF_NOTIME = $00000100; // this frame doesn't take any time
  1163. AVIIF_COMPUSE = $0FFF0000; // these bits are for compressor use
  1164. type
  1165. PAVIINDEXENTRY = ^TAVIINDEXENTRY;
  1166. TAVIINDEXENTRY = packed record
  1167. ckid : DWORD;
  1168. dwFlags : DWORD;
  1169. dwChunkOffset : DWORD; // Position of chunk
  1170. dwChunkLength : DWORD; // Length of chunk
  1171. end;
  1172. {-- Palette change chunk (used in video streams) -----------------------------}
  1173. PAVIPALCHANGE = ^TAVIPALCHANGE;
  1174. TAVIPALCHANGE = packed record
  1175. bFirstEntry : BYTE; // first entry to change
  1176. bNumEntries : BYTE; // # entries to change (0 if 256)
  1177. wFlags : WORD; // Mostly to preserve alignment...
  1178. peNew : array[0..0] of TPALETTEENTRY; // New color specifications
  1179. end;
  1180. (****************************************************************************
  1181. *
  1182. * AVIFile - routines for reading/writing standard AVI files
  1183. *
  1184. ***************************************************************************)
  1185. //
  1186. // Ansi - Unicode thunking.
  1187. //
  1188. // Unicode or Ansi-only apps can call the avifile APIs.
  1189. // any Win32 app who wants to use
  1190. // any of the AVI COM interfaces must be UNICODE - the AVISTREAMINFO and
  1191. // AVIFILEINFO structures used in the Info methods of these interfaces are
  1192. // the unicode variants, and no thunking to or from ansi takes place
  1193. // except in the AVIFILE api entrypoints.
  1194. //
  1195. // For Ansi/Unicode thunking: for each entrypoint or structure that
  1196. // uses chars or strings, two versions are declared in the Win32 version,
  1197. // ApiNameW and ApiNameA. The default name ApiName is #defined to one or
  1198. // other of these depending on whether UNICODE is defined (during
  1199. // compilation of the app that is including this header). The source will
  1200. // contain ApiName and ApiNameA (with ApiName being the Win16 implementation,
  1201. // and also #defined to ApiNameW, and ApiNameA being the thunk entrypoint).
  1202. //
  1203. // For GetFrame::SetFormat - use the best format for the display
  1204. const
  1205. AVIGETFRAMEF_BESTDISPLAYFMT = 1;
  1206. //
  1207. // Structures used by AVIStreamInfo & AVIFileInfo.
  1208. //
  1209. // These are related to, but not identical to, the header chunks
  1210. // in an AVI file.
  1211. //
  1212. {-- AVISTREAMINFO ------------------------------------------------------------}
  1213. // for Unicode/Ansi thunking we need to declare three versions of this!
  1214. type
  1215. PAVIStreamInfoW = ^TAVIStreamInfoW;
  1216. TAVIStreamInfoW = packed record
  1217. fccType : DWORD;
  1218. fccHandler : DWORD;
  1219. dwFlags : DWORD; // Contains AVITF_* flags
  1220. dwCaps : DWORD;
  1221. wPriority : WORD;
  1222. wLanguage : WORD;
  1223. dwScale : DWORD;
  1224. dwRate : DWORD; // dwRate / dwScale == samples/second
  1225. dwStart : DWORD;
  1226. dwLength : DWORD; // In units above...
  1227. dwInitialFrames : DWORD;
  1228. dwSuggestedBufferSize : DWORD;
  1229. dwQuality : DWORD;
  1230. dwSampleSize : DWORD;
  1231. rcFrame : TRECT;
  1232. dwEditCount : DWORD;
  1233. dwFormatChangeCount : DWORD;
  1234. szName : array[0..63] of WideChar;
  1235. end;
  1236. PAVIStreamInfoA = ^TAVIStreamInfoA;
  1237. TAVIStreamInfoA = packed record
  1238. fccType : DWORD;
  1239. fccHandler : DWORD;
  1240. dwFlags : DWORD; // Contains AVITF_* flags
  1241. dwCaps : DWORD;
  1242. wPriority : WORD;
  1243. wLanguage : WORD;
  1244. dwScale : DWORD;
  1245. dwRate : DWORD; // dwRate / dwScale == samples/second
  1246. dwStart : DWORD;
  1247. dwLength : DWORD; // In units above...
  1248. dwInitialFrames : DWORD;
  1249. dwSuggestedBufferSize : DWORD;
  1250. dwQuality : DWORD;
  1251. dwSampleSize : DWORD;
  1252. rcFrame : TRECT;
  1253. dwEditCount : DWORD;
  1254. dwFormatChangeCount : DWORD;
  1255. szName : array[0..63] of AnsiChar;
  1256. end;
  1257. PAVIStreamInfo = ^TAVIStreamInfo;
  1258. {$IFDEF UNICODE}
  1259. TAVIStreamInfo = TAVIStreamInfoW;
  1260. {$ELSE}
  1261. TAVIStreamInfo = TAVIStreamInfoA;
  1262. {$ENDIF}
  1263. const
  1264. AVISTREAMINFO_DISABLED = $00000001;
  1265. AVISTREAMINFO_FORMATCHANGES = $00010000;
  1266. {-- AVIFILEINFO --------------------------------------------------------------}
  1267. type
  1268. PAVIFileInfoW = ^TAVIFileInfoW;
  1269. TAVIFileInfoW = packed record
  1270. dwMaxBytesPerSec : DWORD; // max. transfer rate
  1271. dwFlags : DWORD; // the ever-present flags
  1272. dwCaps : DWORD;
  1273. dwStreams : DWORD;
  1274. dwSuggestedBufferSize : DWORD;
  1275. dwWidth : DWORD;
  1276. dwHeight : DWORD;
  1277. dwScale : DWORD;
  1278. dwRate : DWORD; // dwRate / dwScale == samples/second
  1279. dwLength : DWORD;
  1280. dwEditCount : DWORD;
  1281. szFileType : array[0..63] of WideChar;
  1282. // descriptive string for file type?
  1283. end;
  1284. PAVIFileInfoA = ^TAVIFileInfoA;
  1285. TAVIFileInfoA = packed record
  1286. dwMaxBytesPerSec : DWORD; // max. transfer rate
  1287. dwFlags : DWORD; // the ever-present flags
  1288. dwCaps : DWORD;
  1289. dwStreams : DWORD;
  1290. dwSuggestedBufferSize : DWORD;
  1291. dwWidth : DWORD;
  1292. dwHeight : DWORD;
  1293. dwScale : DWORD;
  1294. dwRate : DWORD; // dwRate / dwScale == samples/second
  1295. dwLength : DWORD;
  1296. dwEditCount : DWORD;
  1297. szFileType : array[0..63] of AnsiChar;
  1298. // descriptive string for file type?
  1299. end;
  1300. PAVIFileInfo = ^TAVIFileInfo;
  1301. {$IFDEF UNICODE}
  1302. TAVIFileInfo = TAVIFileInfoW;
  1303. {$ELSE}
  1304. TAVIFileInfo = TAVIFileInfoA;
  1305. {$ENDIF}
  1306. {-- Flags for dwFlags --------------------------------------------------------}
  1307. const
  1308. AVIFILEINFO_HASINDEX = $00000010;
  1309. AVIFILEINFO_MUSTUSEINDEX = $00000020;
  1310. AVIFILEINFO_ISINTERLEAVED = $00000100;
  1311. AVIFILEINFO_WASCAPTUREFILE = $00010000;
  1312. AVIFILEINFO_COPYRIGHTED = $00020000;
  1313. {-- Flags for dwCaps ---------------------------------------------------------}
  1314. AVIFILECAPS_CANREAD = $00000001;
  1315. AVIFILECAPS_CANWRITE = $00000002;
  1316. AVIFILECAPS_ALLKEYFRAMES = $00000010;
  1317. AVIFILECAPS_NOCOMPRESSION = $00000020;
  1318. type
  1319. TAVISAVECALLBACK = function(i: int): BOOL; pascal;
  1320. {-- AVICOMPRESSOPTIONS -------------------------------------------------------}
  1321. // Make sure it matches the AutoDoc in avisave.c !!!
  1322. type
  1323. PAVICOMPRESSOPTIONS = ^TAVICOMPRESSOPTIONS;
  1324. TAVICOMPRESSOPTIONS = packed record
  1325. fccType : DWORD; // stream type, for consistency
  1326. fccHandler : DWORD; // compressor
  1327. dwKeyFrameEvery : DWORD; // keyframe rate
  1328. dwQuality : DWORD; // compress quality 0-10,000
  1329. dwBytesPerSecond : DWORD; // bytes per second
  1330. dwFlags : DWORD; // flags... see below
  1331. lpFormat : PVOID; // save format
  1332. cbFormat : DWORD;
  1333. lpParms : PVOID; // compressor options
  1334. cbParms : DWORD;
  1335. dwInterleaveEvery : DWORD; // for non-video streams only
  1336. end;
  1337. //
  1338. // Defines for the dwFlags field of the AVICOMPRESSOPTIONS struct
  1339. // Each of these flags determines if the appropriate field in the structure
  1340. // (dwInterleaveEvery, dwBytesPerSecond, and dwKeyFrameEvery) is payed
  1341. // attention to. See the autodoc in avisave.c for details.
  1342. //
  1343. const
  1344. AVICOMPRESSF_INTERLEAVE = $00000001; // interleave
  1345. AVICOMPRESSF_DATARATE = $00000002; // use a data rate
  1346. AVICOMPRESSF_KEYFRAMES = $00000004; // use keyframes
  1347. AVICOMPRESSF_VALID = $00000008; // has valid data?
  1348. (* - - - - - - - - */
  1349. /****** AVI Stream Interface *******************************************)
  1350. type
  1351. IAVIStream = interface(IUnknown)
  1352. function Create(lParam1, lParam2: LPARAM): HResult; stdcall;
  1353. function Info(var psi: TAVIStreamInfoW; lSize: LONG): HResult; stdcall;
  1354. function FindSample(lPos: LONG; lFlags: LONG): LONG; stdcall;
  1355. function ReadFormat(lPos: LONG; lpFormat: PVOID; var lpcbForm