FlatVideo.pas 117 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575
  1. unit FlatVideo;
  2. { just the AVIFile stuff (didn't have time to do the whole thing...) }
  3. interface
  4. {$I FlatStyle.inc}
  5. uses Windows, Classes, Graphics, SysUtils, Jpeg, FlatUtils;
  6. {---------Begin AVIWriter-----------}
  7. const
  8. { Create or Add File type to AVI }
  9. StreamTypeVideo = $73646976; // DWORD( 'v', 'i', 'd', 's' )
  10. StreamTypeAudio = $73647561; // DWORD( 'a', 'u', 'd', 's' )
  11. StreamTypeMidi = $7364696D; // DWORD( 'm', 'i', 'd', 's' )
  12. StreamTypeText = $73747874; // DWORD( 't', 'x', 't', 's' )
  13. CompTypeDIB = $20424944; // DWORD( 'D', 'I', 'B', ' ' )
  14. AVISTREAMINFO_DISABLED = $00000001;
  15. AVISTREAMINFO_FORMATCHANGES = $00010000;
  16. { Flags for FileHeadler }
  17. AVIFILEHANDLER_CANREAD = $0001;
  18. AVIFILEHANDLER_CANWRITE = $0002;
  19. AVIFILEHANDLER_CANACCEPTNONRGB = $0004;
  20. { Flags for dwFlags }
  21. AVIFILEINFO_HASINDEX = $00000010;
  22. AVIFILEINFO_MUSTUSEINDEX = $00000020;
  23. AVIFILEINFO_ISINTERLEAVED = $00000100;
  24. AVIFILEINFO_WASCAPTUREFILE = $00010000;
  25. AVIFILEINFO_COPYRIGHTED = $00020000;
  26. { Flags for dwCaps }
  27. AVIFILECAPS_CANREAD = $00000001;
  28. AVIFILECAPS_CANWRITE = $00000002;
  29. AVIFILECAPS_ALLKEYFRAMES = $00000010;
  30. AVIFILECAPS_NOCOMPRESSION = $00000020;
  31. { Defines for the dwFlags field of the AviCompressOptions struct
  32. Each of these flags determines if the appropriate field in the structure
  33. (dwInterleaveEvery, dwBytesPerSecond, and dwKeyFrameEvery) is payed
  34. attention to. See the autodoc in avisave.c for details.}
  35. AVICOMPRESSF_INTERLEAVE = $00000001; // interleave
  36. AVICOMPRESSF_DATARATE = $00000002; // use a data rate
  37. AVICOMPRESSF_KEYFRAMES = $00000004; // use keyframes
  38. AVICOMPRESSF_VALID = $00000008; // has valid data?
  39. { defines for uiFlags }
  40. ICMF_CHOOSE_KEYFRAME = $0001;// show KeyFrame Every box
  41. ICMF_CHOOSE_DATARATE = $0002;// show DataRate box
  42. ICMF_CHOOSE_PREVIEW = $0004;// allow expanded preview dialog
  43. ICMF_CHOOSE_ALLCOMPRESSORS = $0008;// don't only show those that
  44. { defines for ReadAVI Flags }
  45. AVIERR_OK = 0;
  46. AVIERR_UNSUPPORTED = $80044065; // MAKE_AVIERR(101)
  47. AVIERR_BADFORMAT = $80044066; // MAKE_AVIERR(102)
  48. AVIERR_MEMORY = $80044067; // MAKE_AVIERR(103)
  49. AVIERR_INTERNAL = $80044068; // MAKE_AVIERR(104)
  50. AVIERR_BADFLAGS = $80044069; // MAKE_AVIERR(105)
  51. AVIERR_BADPARAM = $8004406A; // MAKE_AVIERR(106)
  52. AVIERR_BADSIZE = $8004406B; // MAKE_AVIERR(107)
  53. AVIERR_BADHANDLE = $8004406C; // MAKE_AVIERR(108)
  54. AVIERR_FILEREAD = $8004406D; // MAKE_AVIERR(109)
  55. AVIERR_FILEWRITE = $8004406E; // MAKE_AVIERR(110)
  56. AVIERR_FILEOPEN = $8004406F; // MAKE_AVIERR(111)
  57. AVIERR_COMPRESSOR = $80044070; // MAKE_AVIERR(112)
  58. AVIERR_NOCOMPRESSOR = $80044071; // MAKE_AVIERR(113)
  59. AVIERR_READONLY = $80044072; // MAKE_AVIERR(114)
  60. AVIERR_NODATA = $80044073; // MAKE_AVIERR(115)
  61. AVIERR_BUFFERTOOSMALL = $80044074; // MAKE_AVIERR(116)
  62. AVIERR_CANTCOMPRESS = $80044075; // MAKE_AVIERR(117)
  63. AVIERR_USERABORT = $800440C6; // MAKE_AVIERR(198)
  64. AVIERR_ERROR = $800440C7; // MAKE_AVIERR(199)
  65. AVIIF_LIST = $00000001;
  66. AVIIF_TWOCC = $00000002;
  67. AVIIF_KEYFRAME = $00000010;
  68. { TAVIStreamInfo dwFlag values }
  69. AVISF_DISABLED = $00000001;
  70. AVISF_VIDEO_PALCHANGES = $00010000;
  71. AVISF_KNOWN_FLAGS = $00010001;
  72. { TAVIFileInfo dwFlag values }
  73. AVIF_HASINDEX = $00000010;
  74. AVIF_MUSTUSEINDEX = $00000020;
  75. AVIF_ISINTERLEAVED = $00000100;
  76. AVIF_WASCAPTUREFILE = $00010000;
  77. AVIF_COPYRIGHTED = $00020000;
  78. AVIF_KNOWN_FLAGS = $00030130;
  79. { flags for AVIStreamFindSample }
  80. FIND_DIR = $0000000F; // direction
  81. FIND_NEXT = $00000001; // go forward
  82. FIND_PREV = $00000004; // go backward
  83. FIND_TYPE = $000000F0; // type mask
  84. FIND_KEY = $00000010; // find key frame.
  85. FIND_ANY = $00000020; // find any (non-empty) sample
  86. FIND_FORMAT = $00000040; // find format change
  87. FIND_RET = $0000F000; // return mask
  88. FIND_POS = $00000000; // return logical position
  89. FIND_LENGTH = $00001000; // return logical size
  90. FIND_OFFSET = $00002000; // return physical position
  91. FIND_SIZE = $00003000; // return physical size
  92. FIND_INDEX = $00004000; // return physical index position
  93. type
  94. LONG = Longint;
  95. PVOID = Pointer;
  96. PAVIExtStream = Pointer;
  97. { TAviStreamInfoA }
  98. PAVIStreamInfoA = ^TAviStreamInfoA;
  99. TAviStreamInfoA = record
  100. fccType : DWORD;
  101. fccHandler : DWORD;
  102. dwFlags : DWORD; // Contains AVITF_* flags
  103. dwCaps : DWORD;
  104. wPriority : WORD;
  105. wLanguage : WORD;
  106. dwScale : DWORD;
  107. dwRate : DWORD;// dwRate / dwScale == samples/second
  108. dwStart : DWORD;
  109. dwLength : DWORD;// In units above...
  110. dwInitialFrames : DWORD;
  111. dwSuggestedBufferSize : DWORD;
  112. dwQuality : DWORD;
  113. dwSampleSize : DWORD;
  114. rcFrame : TRECT;
  115. dwEditCount : DWORD;
  116. dwFormatChangeCount : DWORD;
  117. szName : array[0..63] of AnsiChar;
  118. end;
  119. TAviStreamInfo = TAviStreamInfoA;
  120. { TAviStreamInfoW }
  121. PAVIStreamInfoW = ^TAviStreamInfoW;
  122. TAviStreamInfoW = record
  123. fccType : DWORD;
  124. fccHandler : DWORD;
  125. dwFlags : DWORD; // Contains AVITF_* flags
  126. dwCaps : DWORD;
  127. wPriority : WORD;
  128. wLanguage : WORD;
  129. dwScale : DWORD;
  130. dwRate : DWORD;// dwRate / dwScale == samples/second
  131. dwStart : DWORD;
  132. dwLength : DWORD;// In units above...
  133. dwInitialFrames : DWORD;
  134. dwSuggestedBufferSize : DWORD;
  135. dwQuality : DWORD;
  136. dwSampleSize : DWORD;
  137. rcFrame : TRECT;
  138. dwEditCount : DWORD;
  139. dwFormatChangeCount : DWORD;
  140. szName : array[0..63] of WideChar;
  141. end;
  142. { TAviFileInfoA }
  143. PAviFileInfoA = ^TAviFileInfoA;
  144. TAviFileInfoA = record
  145. dwMaxBytesPerSec : DWORD;// max. transfer rate
  146. dwFlags : DWORD;// the ever-present flags
  147. dwCaps : DWORD;
  148. dwStreams : DWORD;
  149. dwSuggestedBufferSize : DWORD;
  150. dwWidth : DWORD;
  151. dwHeight : DWORD;
  152. dwScale : DWORD;
  153. dwRate : DWORD;// dwRate / dwScale == samples/second
  154. dwLength : DWORD;
  155. dwEditCount : DWORD;
  156. // descriptive string for file type?
  157. szFileType : array[0..63] of Char;
  158. end;
  159. TAviFileInfo = TAviFileInfoA;
  160. { TAviFileInfoW }
  161. PAviFileInfoW = ^TAviFileInfoW;
  162. TAviFileInfoW = record
  163. dwMaxBytesPerSec : DWORD;// max. transfer rate
  164. dwFlags : DWORD;// the ever-present flags
  165. dwCaps : DWORD;
  166. dwStreams : DWORD;
  167. dwSuggestedBufferSize : DWORD;
  168. dwWidth : DWORD;
  169. dwHeight : DWORD;
  170. dwScale : DWORD;
  171. dwRate : DWORD;// dwRate / dwScale == samples/second
  172. dwLength : DWORD;
  173. dwEditCount : DWORD;
  174. // descriptive string for file type?
  175. szFileType : array[0..63] of WideChar;
  176. end;
  177. TAVISaveCallBack = function(Percentage : Integer): Boolean stdcall;
  178. AVISaveCallBack = ^TAVISaveCallBack;
  179. { TAviCompressOptions }
  180. PAviCompressOptions = ^TAviCompressOptions;
  181. TAviCompressOptions = record
  182. fccType : DWORD;// stream type, for consistency
  183. fccHandler : DWORD;// compressor
  184. dwKeyFrameEvery : DWORD;// keyframe rate
  185. dwQuality : DWORD;// compress quality 0-10,000
  186. dwBytesPerSecond : DWORD;// bytes per second
  187. dwFlags : DWORD;// flags... see aviopts.h
  188. lpFormat : PVOID;// save format
  189. cbFormat : DWORD;
  190. lpParms : PVOID;// compressor options
  191. cbParms : DWORD;
  192. dwInterleaveEvery : DWORD;// for non-video streams only
  193. end;
  194. { Globally unique ID }
  195. PGUID = ^TGUID;
  196. TGUID = record
  197. D1: LongWord;
  198. D2: Word;
  199. D3: Word;
  200. D4: array[0..7] of Byte;
  201. end;
  202. { Interface ID }
  203. PIID = PGUID;
  204. TIID = TGUID;
  205. { Class ID }
  206. PCLSID = PGUID;
  207. TCLSID = TGUID;
  208. { IUnknown interface }
  209. {$EXTERNALSYM IUnknown }
  210. IUnknown = class
  211. public
  212. function QueryInterface(const iid: TIID; var obj): HResult; virtual; stdcall; abstract;
  213. function AddRef: Longint; virtual; stdcall; abstract;
  214. function Release: Longint; virtual; stdcall; abstract;
  215. end;
  216. { #include "aviiface.h": All necessary stuff from "aviiface.h" follows }
  217. { IAVIStream interface }
  218. PAVIStream = ^IAVIStream;
  219. IAVIStream = class(IUnknown)
  220. function Create(lParam1, lParam2: LPARAM): HResult; virtual; stdcall; abstract;
  221. function Info(var psi: TAVIStreamInfoW; lSize: LONG): HResult; virtual; stdcall; abstract;
  222. function FindSample(lPos, lFlags: LONG): LONG; virtual; stdcall; abstract;
  223. function ReadFormat(lPos: LONG; lpFormat: PVOID; var lpcbFormat: LONG): HResult; virtual; stdcall; abstract;
  224. function SetFormat(lPos: LONG; lpFormat: PVOID; lpcbFormat: LONG): HResult; virtual; stdcall; abstract;
  225. function Read(lStart, lSamples: LONG; lpBuffer: PVOID; cbBuffer: LONG; var plBytes: LONG; var plSamples: LONG): HResult; virtual; stdcall; abstract;
  226. function Write(lStart, lSamples: LONG; lpBuffer: PVOID; cbBuffer: LONG; dwFlags: DWORD; var plSampWritten: LONG; var plBytesWritten: LONG): HResult; virtual; stdcall; abstract;
  227. function Delete(lStart, lSamples: LONG): HResult; virtual; stdcall; abstract;
  228. function ReadData(fcc: DWORD; lp: PVOID; var lpcb: LONG): HResult; virtual; stdcall; abstract;
  229. function WriteData(fcc: DWORD; lp: PVOID; cb: LONG): HResult; virtual; stdcall; abstract;
  230. function SetInfo(var lpInfo: TAVIStreamInfoW; cbInfo: LONG): HResult; virtual; stdcall; abstract;
  231. end;
  232. { IAVIEditStream interface }
  233. PAVIEditStream = ^IAVIEditStream;
  234. IAVIEditStream = class(IUnknown)
  235. function Info(var pfi:TAVIFileInfoW; lSize: LONG): HResult; virtual; stdcall; abstract;
  236. function Cut(var plStart:LONG; var plLength:Long; var ppResult :PAVIStream ): HResult; virtual; stdcall; abstract;
  237. function Copy(var plLength:Long; var ppResult :PAVIStream ): HResult; virtual; stdcall; abstract;
  238. function Paste(var plLength:Long; pstream :PAVIStream; lStart : LONG; lEnd : LONG ): HResult; virtual; stdcall; abstract;
  239. function Clone(var ppResult :PAVIStream ): HResult; virtual; stdcall; abstract;
  240. function SetInfo(var lpInfo: TAVIStreamInfoW; cbInfo: LONG): HResult; virtual; stdcall; abstract;
  241. end;
  242. { IAVIFile interface }
  243. PAVIFile = ^IAVIFile;
  244. IAVIFile = class(IUnknown)
  245. function Open(szFile:LPCSTR; mode:UINT): HResult; virtual; stdcall; abstract;
  246. function Info(var pfi:TAviFileInfo; lSize:LONG): HResult; virtual; stdcall; abstract;
  247. function GetStream(var ppStream: PAVIStream; fccType:DWORD; lParam:LONG): HResult; virtual; stdcall; abstract;
  248. function CreateStream(var ppStream: PAVIStream; psi:TAVISTREAMINFO): HResult; virtual; stdcall; abstract;
  249. function Save(szFile:LPCSTR; var lpOptions:TAviCompressOptions;lpfnCallback:AVISAVECALLBACK): HResult; virtual; stdcall; abstract;
  250. function WriteData(ckid:DWORD; lpData:PVOID;cbData:LONG): HResult; virtual; stdcall; abstract;
  251. function ReadData(ckid:DWORD; lpData:PVOID;var lpcbData:LONG): HResult; virtual; stdcall; abstract;
  252. function EndRecord: HResult; virtual; stdcall; abstract;
  253. end;
  254. { IGetFrame interface }
  255. PGetFrame = ^IGetFrame;
  256. IGetFrame = class(IUnknown)
  257. function GetFrame(lPos: LONG): PVOID; virtual; stdcall; abstract;
  258. function SetFormat(lpbi: PBITMAPINFOHEADER;lpBits:PVOID; x:Integer; y:Integer; dx:Integer; dy:Integer ): HResult; virtual; stdcall; abstract;
  259. end;
  260. { Defines control AVISaveV,AVSaveVA,AVSaveVW}
  261. APAVIStream = array[0..1] of PAVIStream;
  262. APAviCompressOptions = array[0..1] of PAviCompressOptions;
  263. Const
  264. { AVI interface IDs }
  265. IID_IAVIFile: TGUID=(D1:$00020020;D2:$0;D3:$0;D4:($C0,$0,$0,$0,$0,$0,$0,$46));
  266. IID_IAVIStream: TGUID=(D1:$00020021;D2:$0;D3:$0;D4:($C0,$0,$0,$0,$0,$0,$0,$46));
  267. IID_IAVIStreaming: TGUID=(D1:$00020022;D2:$0;D3:$0;D4:($C0,$0,$0,$0,$0,$0,$0,$46));
  268. IID_IGetFrame: TGUID=(D1:$00020023;D2:$0;D3:$0;D4:($C0,$0,$0,$0,$0,$0,$0,$46));
  269. IID_IAVIEditStream: TGUID=(D1:$00020024;D2:$0;D3:$0;D4:($C0,$0,$0,$0,$0,$0,$0,$46));
  270. { AVI class IDs }
  271. CLSID_AVISimpleUnMarshal:TGUID=(D1:$00020009;D2:$0;D3:$0;D4:($C0,$0,$0,$0,$0,$0,$0,$46));
  272. CLSID_AVIFile: TGUID=(D1:$00020000;D2:$0;D3:$0;D4:($C0,$0,$0,$0,$0,$0,$0,$46));
  273. { Defines call functions }
  274. procedure AVIFileInit; stdcall;
  275. procedure AVIFileExit; stdcall;
  276. function AVIFileAddRef(pfile: PAVIFILE): ULONG; stdcall;
  277. function AVIFileRelease(pfile: PAVIFILE): ULONG; stdcall;
  278. function AVIFileOpen(var ppfile: PAVIFile; szFile: LPCSTR; uMode: UINT;
  279. lpHandler: PCLSID): HResult; stdcall;
  280. function AVIFileInfo(pfile: PAVIFile; var pfi:TAVIFileInfo; lSize:Long): HResult; stdcall;
  281. function AVIFileGetStream(pfile: PAVIFile; var ppavi: PAVIStream;
  282. fccType:DWORD; lParam:LONG): HResult; stdcall;
  283. function AVIFileCreateStream(pfile: PAVIFile; var ppavi: PAVIStream;
  284. var psi: TAVIStreamInfoA): HResult; stdcall;
  285. function AVIFileWriteData(pfile: PAVIFile; ckid: DWORD; lpData: PVOID;
  286. cbData: LONG): HResult; stdcall;
  287. function AVIFileReadData(ckid: DWORD; lpData: PVOID;
  288. var lpcbData: LONG): HResult; stdcall;
  289. function AVIFileEndRecord(pfile: PAVIFile): HResult; stdcall;
  290. function AVIStreamAddRef(pavi: PAVIStream): ULONG; stdcall;
  291. function AVIStreamRelease(pavi: PAVIStream): ULONG; stdcall;
  292. function AVIStreamInfo(pavi: PAVIStream; var psi: TAVISTREAMINFO; lSize:LONG): HResult; stdcall;
  293. function AVIStreamFindSample(pavi: PAVIStream; lPos: LONG; lFlags:LONG): LONG; stdcall;
  294. function AVIStreamReadFormat(pavi: PAVIStream; lPos:LONG;lpFormat:PVOID;var lpcbFormat:LONG): HResult; stdcall;
  295. function AVIStreamSetFormat(pavi: PAVIStream; lPos: LONG; lpFormat: PVOID;
  296. cbFormat: LONG): HResult; stdcall;
  297. function AVIStreamReadData(pavi: PAVIStream; fcc: DWORD; lp: PVOID;var lpcb: LONG): HResult; stdcall;
  298. function AVIStreamWriteData(pavi: PAVIStream; fcc: DWORD; lp: PVOID;cb: LONG): HResult; stdcall;
  299. function AVIStreamRead(pavi: PAVIStream; lStart: LONG;lSamples: LONG;lpBuffer: PVOID;
  300. cbBuffer: LONG;var plBytes: LONG;var plSamples: LONG): HResult; stdcall;
  301. function AVIStreamWrite(pavi: PAVIStream; lStart, lSamples: LONG;lpBuffer: PVOID; cbBuffer: LONG;
  302. dwFlags: DWORD; var plSampWritten: LONG; var plBytesWritten: LONG):HResult; stdcall;
  303. function AVIStreamStart(pavi: PAVIStream): LONG; stdcall;
  304. function AVIStreamLength(pavi: PAVIStream): LONG; stdcall;
  305. function AVIStreamLengthTime(pavi: PAVIStream): LONG; stdcall;
  306. function AVIStreamTimeToSample(pavi: PAVIStream; lTime: LONG): LONG; stdcall;
  307. function AVIStreamSampleToTime(pavi: PAVIStream; lSample: LONG): LONG; stdcall;
  308. function AVIStreamBeginStreaming(pavi: PAVIStream; lStart: LONG; lEnd: LONG; lRate: LONG): LONG; stdcall;
  309. function AVIStreamEndStreaming(pavi: PAVIStream): LONG; stdcall;
  310. { helper functions for using IGetFrame }
  311. function AVIStreamGetFrameOpen(pavi:PAVIStream; lpbiWanted:PBITMAPINFOHEADER ):PGETFRAME; stdcall;
  312. function AVIStreamGetFrame(pg: PGETFRAME; lPos: LONG): PVOID; stdcall;
  313. function AVIStreamGetFrameClose(pg: PGETFRAME): HResult; stdcall;
  314. { Shortcut function }
  315. function AVIStreamOpenFromFile(var ppavi: PAVIStream; szFile: LPCSTR;
  316. fccType: DWORD; lParam: LONG; mode :UINT;
  317. pclsidHandler: PCLSID): HResult; stdcall;
  318. { Use to create disembodied streams }
  319. function AVIStreamCreate(var ppavi: PAVIStream; lParam1: LONG; lParam2 :LONG;
  320. pclsidHandler: PCLSID): HResult; stdcall;
  321. function AVISave(szFile:LPCSTR;pclsidHandler:PCLSID;lpfnCallback:TAVISaveCallback;nStreams:integer;
  322. var pavi:PAVISTREAM; var lpOptions:PAVICompressOptions):HResult;stdcall;
  323. { szFile:This parameter not support include chinese directory name }
  324. function AVISaveV(szFile:LPCSTR;pclsidHandler:PCLSID;lpfnCallback :AVISAVECALLBACK; nStreams: INTEGER;
  325. var ppavi: APAVIStream; var plpOptions: APAviCompressOptions):HResult; stdcall;
  326. { AVISaveVA function support for windowx Win9x and 2K/XP }
  327. { szFile:This parameter support include chinese directory name }
  328. function AVISaveFile(szFile:LPCSTR;pclsidHandler:PCLSID;lpfnCallback :AVISAVECALLBACK; nStreams: INTEGER;
  329. var ppavi: APAVIStream; var plpOptions: APAviCompressOptions):HRESULT;
  330. { wszFile:This parameter support widechar directory name }
  331. function AVISaveVW(wszFile:LPCWSTR;pclsidHandler:PCLSID;lpfnCallback :AVISAVECALLBACK; nStreams: INTEGER;
  332. var ppavi: APAVIStream; var plpOptions: APAviCompressOptions):HResult; stdcall;
  333. function AVISaveOptions(hwnd:HWND;uiFlags:UINT; nStreams:INTEGER;var pavi:PAVIStream;
  334. var plpOptions:PAviCompressOptions ):Boolean; stdcall;
  335. function AVISaveOptionsFree(nStreams:INTEGER; var plpOptions:PAviCompressOptions ):Boolean; stdcall;
  336. function CreateEditableStream(var ppsEditable: PAVIStream; psSource: PAVIStream): HResult; stdcall;
  337. function AVIBuildFilter(var szFilter: PChar; cbFilter: LongInt; fSaving: WordBool): HResult; stdcall;
  338. function AVIMakeFileFromStreams(var pFile: PAVIFile; nStreams: Integer;var pStream: PAVIStream): HResult; stdcall;
  339. function AVIMakeStreamFromClipboard(cfFormat: Word; hGlobal: THandle;var pStream: PAVIStream): HResult; stdcall;
  340. function AVIPutFileOnClipboard(pFile: PAVIFile): HResult; stdcall;
  341. function AVIGetFromClipboard(var pFile: PAVIFile): HResult; stdcall;
  342. function AVIClearClipboard: HResult; stdcall;
  343. function EditStreamCut(pStream: PAVIStream;var plStart, plLength: PLongInt;
  344. var pResult: PAVIStream): HResult; stdcall;
  345. function EditStreamCopy(pStream: PAVIStream;var plStart, plLength: PLongInt;
  346. var pResult: PAVIStream): HResult; stdcall;
  347. function EditStreamPaste(pStream: PAVIStream;var plPos, plLength: PLongInt;
  348. var pResult: PAVIStream;lStart, lLength: LongInt):HResult; stdcall;
  349. function EditStreamClone(pStream: PAVIStream;var pResult: PAVIStream): HResult; stdcall;
  350. function EditStreamSetName(pStream: PAVIStream; szName: PChar): HResult; stdcall;
  351. function EditStreamSetInfo(pStream: PAVIStream; var asiInfo: TAVIStreamInfo;
  352. cbInfo: LongInt): HResult; stdcall;
  353. {---------End AVIWriter-----------------}
  354. {---------Begin AVICAP window-----------}
  355. const
  356. // ------------------------------------------------------------------
  357. // Window Messages WM_CAP... which can be sent to an AVICAP window
  358. // ------------------------------------------------------------------
  359. // Defines start of the message range
  360. {$EXTERNALSYM DRV_USER}
  361. DRV_USER = $4000;
  362. {$EXTERNALSYM WM_USER}
  363. WM_USER = $0400;
  364. WM_CAP_START = WM_USER;
  365. WM_CAP_GET_CAPSTREAMPTR = (WM_CAP_START+ 1);
  366. WM_CAP_SET_CALLBACK_ERROR = (WM_CAP_START+ 2);
  367. WM_CAP_SET_CALLBACK_STATUS = (WM_CAP_START+ 3);
  368. WM_CAP_SET_CALLBACK_YIELD = (WM_CAP_START+ 4);
  369. WM_CAP_SET_CALLBACK_FRAME = (WM_CAP_START+ 5);
  370. WM_CAP_SET_CALLBACK_VIDEOSTREAM = (WM_CAP_START+ 6);
  371. WM_CAP_SET_CALLBACK_WAVESTREAM = (WM_CAP_START+ 7);
  372. WM_CAP_GET_USER_DATA = (WM_CAP_START+ 8);
  373. WM_CAP_SET_USER_DATA = (WM_CAP_START+ 9);
  374. WM_CAP_DRIVER_CONNECT = (WM_CAP_START+ 10);
  375. WM_CAP_DRIVER_DISCONNECT = (WM_CAP_START+ 11);
  376. WM_CAP_DRIVER_GET_NAME = (WM_CAP_START+ 12);
  377. WM_CAP_DRIVER_GET_VERSION = (WM_CAP_START+ 13);
  378. WM_CAP_DRIVER_GET_CAPS = (WM_CAP_START+ 14);
  379. WM_CAP_FILE_SET_CAPTURE_FILE = (WM_CAP_START+ 20);
  380. WM_CAP_FILE_GET_CAPTURE_FILE = (WM_CAP_START+ 21);
  381. WM_CAP_FILE_ALLOCATE = (WM_CAP_START+ 22);
  382. WM_CAP_FILE_SAVEAS = (WM_CAP_START+ 23);
  383. WM_CAP_FILE_SET_INFOCHUNK = (WM_CAP_START+ 24);
  384. WM_CAP_FILE_SAVEDIB = (WM_CAP_START+ 25);
  385. WM_CAP_EDIT_COPY = (WM_CAP_START+ 30);
  386. WM_CAP_SET_AUDIOFORMAT = (WM_CAP_START+ 35);
  387. WM_CAP_GET_AUDIOFORMAT = (WM_CAP_START+ 36);
  388. WM_CAP_DLG_VIDEOFORMAT = (WM_CAP_START+ 41);
  389. WM_CAP_DLG_VIDEOSOURCE = (WM_CAP_START+ 42);
  390. WM_CAP_DLG_VIDEODISPLAY = (WM_CAP_START+ 43);
  391. WM_CAP_GET_VIDEOFORMAT = (WM_CAP_START+ 44);
  392. WM_CAP_SET_VIDEOFORMAT = (WM_CAP_START+ 45);
  393. WM_CAP_DLG_VIDEOCOMPRESSION = (WM_CAP_START+ 46);
  394. WM_CAP_SET_PREVIEW = (WM_CAP_START+ 50);
  395. WM_CAP_SET_OVERLAY = (WM_CAP_START+ 51);
  396. WM_CAP_SET_PREVIEWRATE = (WM_CAP_START+ 52);
  397. WM_CAP_SET_SCALE = (WM_CAP_START+ 53);
  398. WM_CAP_GET_STATUS = (WM_CAP_START+ 54);
  399. WM_CAP_SET_SCROLL = (WM_CAP_START+ 55);
  400. WM_CAP_GRAB_FRAME = (WM_CAP_START+ 60);
  401. WM_CAP_GRAB_FRAME_NOSTOP = (WM_CAP_START+ 61);
  402. WM_CAP_SEQUENCE = (WM_CAP_START+ 62);
  403. WM_CAP_SEQUENCE_NOFILE = (WM_CAP_START+ 63);
  404. WM_CAP_SET_SEQUENCE_SETUP = (WM_CAP_START+ 64);
  405. WM_CAP_GET_SEQUENCE_SETUP = (WM_CAP_START+ 65);
  406. WM_CAP_SET_MCI_DEVICE = (WM_CAP_START+ 66);
  407. WM_CAP_GET_MCI_DEVICE = (WM_CAP_START+ 67);
  408. WM_CAP_STOP = (WM_CAP_START+ 68);
  409. WM_CAP_ABORT = (WM_CAP_START+ 69);
  410. WM_CAP_SINGLE_FRAME_OPEN = (WM_CAP_START+ 70);
  411. WM_CAP_SINGLE_FRAME_CLOSE = (WM_CAP_START+ 71);
  412. WM_CAP_SINGLE_FRAME = (WM_CAP_START+ 72);
  413. WM_CAP_PAL_OPEN = (WM_CAP_START+ 80);
  414. WM_CAP_PAL_SAVE = (WM_CAP_START+ 81);
  415. WM_CAP_PAL_PASTE = (WM_CAP_START+ 82);
  416. WM_CAP_PAL_AUTOCREATE = (WM_CAP_START+ 83);
  417. WM_CAP_PAL_MANUALCREATE = (WM_CAP_START+ 84);
  418. // Following added post VFW 1.1
  419. WM_CAP_SET_CALLBACK_CAPCONTROL = (WM_CAP_START+ 85);
  420. // Defines end of the message range
  421. WM_CAP_END = WM_CAP_SET_CALLBACK_CAPCONTROL;
  422. // dwFlags field of TVIDEOHDR
  423. VHDR_DONE = $00000001; // Done bit */
  424. VHDR_PREPARED = $00000002; // Set if this header has been prepared */
  425. VHDR_INQUEUE = $00000004; // Reserved for driver */
  426. VHDR_KEYFRAME = $00000008; // Key Frame */
  427. // ------------------------------------------------------------------
  428. // Structures
  429. // ------------------------------------------------------------------
  430. type
  431. {$EXTERNALSYM FOURCC}
  432. FOURCC = DWORD;
  433. { TCapDriverCaps }
  434. PCapDriverCaps = ^TCapDriverCaps;
  435. TCapDriverCaps = record
  436. wDeviceIndex :WORD; // Driver index in system.ini
  437. fHasOverlay :BOOL; // Can device overlay?
  438. fHasDlgVideoSource :BOOL; // Has Video source dlg?
  439. fHasDlgVideoFormat :BOOL; // Has Format dlg?
  440. fHasDlgVideoDisplay :BOOL; // Has External out dlg?
  441. fCaptureInitialized :BOOL; // Driver ready to capture?
  442. fDriverSuppliesPalettes :BOOL; // Can driver make palettes?
  443. hVideoIn :THANDLE; // Driver In channel
  444. hVideoOut :THANDLE; // Driver Out channel
  445. hVideoExtIn :THANDLE; // Driver Ext In channel
  446. hVideoExtOut :THANDLE; // Driver Ext Out channel
  447. end;
  448. { TCapStatus }
  449. PCapStatus = ^TCapStatus;
  450. TCapStatus = record
  451. uiImageWidth :UINT; // Width of the image
  452. uiImageHeight :UINT; // Height of the image
  453. fLiveWindow :BOOL; // Now Previewing video?
  454. fOverlayWindow :BOOL; // Now Overlaying video?
  455. fScale :BOOL; // Scale image to client?
  456. ptScroll :TPOINT; // Scroll position
  457. fUsingDefaultPalette :BOOL; // Using default driver palette?
  458. fAudioHardware :BOOL; // Audio hardware present?
  459. fCapFileExists :BOOL; // Does capture file exist?
  460. dwCurrentVideoFrame :DWORD; // # of video frames cap'td
  461. dwCurrentVideoFramesDropped :DWORD; // # of video frames dropped
  462. dwCurrentWaveSamples :DWORD; // # of wave samples cap'td
  463. dwCurrentTimeElapsedMS :DWORD; // Elapsed capture duration
  464. hPalCurrent :HPALETTE; // Current palette in use
  465. fCapturingNow :BOOL; // Capture in progress?
  466. dwReturn :DWORD; // Error value after any operation
  467. wNumVideoAllocated :UINT; // Actual number of video buffers
  468. wNumAudioAllocated :UINT; // Actual number of audio buffers
  469. end;
  470. { TCaptureParms }
  471. PCaptureParms = ^TCaptureParms;
  472. TCaptureParms = record // Default values in parenthesis
  473. dwRequestMicroSecPerFrame :DWORD; // Requested capture rate
  474. fMakeUserHitOKToCapture :BOOL; // Show "Hit OK to cap" dlg?
  475. wPercentDropForError :UINT; // Give error msg if > (10%)
  476. fYield :BOOL; // Capture via background task?
  477. dwIndexSize :DWORD; // Max index size in frames (32K)
  478. wChunkGranularity :UINT; // Junk chunk granularity (2K)
  479. fUsingDOSMemory :BOOL; // Use DOS buffers?
  480. wNumVideoRequested :UINT; // # video buffers, If 0, autocalc
  481. fCaptureAudio :BOOL; // Capture audio?
  482. wNumAudioRequested :UINT; // # audio buffers, If 0, autocalc
  483. vKeyAbort :UINT; // Virtual key causing abort
  484. fAbortLeftMouse :BOOL; // Abort on left mouse?
  485. fAbortRightMouse :BOOL; // Abort on right mouse?
  486. fLimitEnabled :BOOL; // Use wTimeLimit?
  487. wTimeLimit :UINT; // Seconds to capture
  488. fMCIControl :BOOL; // Use MCI video source?
  489. fStepMCIDevice :BOOL; // Step MCI device?
  490. dwMCIStartTime :DWORD; // Time to start in MS
  491. dwMCIStopTime :DWORD; // Time to stop in MS
  492. fStepCaptureAt2x :BOOL; // Perform spatial averaging 2x
  493. wStepCaptureAverageFrames :UINT; // Temporal average n Frames
  494. dwAudioBufferSize :DWORD; // Size of audio bufs (0 = default)
  495. fDisableWriteCache :BOOL; // Attempt to disable write cache
  496. AVStreamMaster :UINT; // Which stream controls length?
  497. end;
  498. { TCapInfoChunk }
  499. PCapInfoChunk = ^TCapInfoChunk;
  500. TCapInfoChunk = record
  501. fccInfoID :FOURCC; // Chunk ID, "ICOP" for copyright
  502. lpData :Pointer; // pointer to data
  503. cbData :LongInt; // size of lpData
  504. end;
  505. { TVIDEOHDR }
  506. PVIDEOHDR = ^TVIDEOHDR;
  507. TVIDEOHDR = record
  508. lpData:pByte; // pointer to locked data buffer
  509. dwBufferLength:DWORD; // Length of data buffer
  510. dwBytesUsed:DWORD; // Bytes actually used
  511. dwTimeCaptured:DWORD; // Milliseconds from start of stream
  512. dwUser:DWORD; // for client's use
  513. dwFlags:DWORD; // assorted flags (see defines)
  514. dwReserved: array [0..4] of DWORD; // reserved for driver
  515. end;
  516. // ------------------------------------------------------------------
  517. // Callback Definitions
  518. // ------------------------------------------------------------------
  519. PWaveHdr = ^TWaveHdr;
  520. {$EXTERNALSYM wavehdr_tag}
  521. wavehdr_tag = record
  522. lpData: PChar; { pointer to locked data buffer }
  523. dwBufferLength: DWORD; { length of data buffer }
  524. dwBytesRecorded: DWORD; { used for input only }
  525. dwUser: DWORD; { for client's use }
  526. dwFlags: DWORD; { assorted flags (see defines) }
  527. dwLoops: DWORD; { loop control counter }
  528. lpNext: PWaveHdr; { reserved for driver }
  529. reserved: DWORD; { reserved for driver }
  530. end;
  531. TWaveHdr = wavehdr_tag;
  532. {$EXTERNALSYM WAVEHDR}
  533. WAVEHDR = wavehdr_tag;
  534. PWaveFormatEx = ^TWaveFormatEx;
  535. {$EXTERNALSYM tWAVEFORMATEX}
  536. TWaveFormatEx = packed record
  537. wFormatTag: Word; { format type }
  538. nChannels: Word; { number of channels (i.e. mono, stereo, etc.) }
  539. nSamplesPerSec: DWORD; { sample rate }
  540. nAvgBytesPerSec: DWORD; { for buffer estimation }
  541. nBlockAlign: Word; { block size of data }
  542. wBitsPerSample: Word; { number of bits per sample of mono data }
  543. cbSize: Word; { the count in bytes of the size of }
  544. end;
  545. TCAPSTATUSCALLBACK = function(hWnd:HWND; nID:Integer; lpsz:PChar):LongInt; stdcall;
  546. TCAPYIELDCALLBACK = function(hWnd:HWND):LongInt; stdcall;
  547. TCAPERRORCALLBACK = function(hWnd:HWND; nID:Integer; lpsz:Pchar):LongInt; stdcall;
  548. TCAPVIDEOSTREAMCALLBACK = function(hWnd:HWND; lpVHdr:PVIDEOHDR):LongInt; stdcall;
  549. TCAPWAVESTREAMCALLBACK = function(hWnd:HWND; lpWHdr:PWAVEHDR):LongInt; stdcall;
  550. TCAPCONTROLCALLBACK = function(hWnd:HWND; nState:Integer):LongInt; stdcall;
  551. // ------------------------------------------------------------------
  552. // CapControlCallback states
  553. // ------------------------------------------------------------------
  554. Const
  555. CONTROLCALLBACK_PREROLL = 1; // Waiting to start capture
  556. CONTROLCALLBACK_CAPTURING = 2; // Now capturing
  557. // ------------------------------------------------------------------
  558. // Message crackers for above
  559. // ------------------------------------------------------------------
  560. function capSetCallbackOnError (hwnd:THandle; fpProc:TCAPERRORCALLBACK):LongInt;
  561. function capSetCallbackOnStatus(hwnd:THandle; fpProc:TCAPSTATUSCALLBACK):LongInt;
  562. function capSetCallbackOnYield (hwnd:THandle; fpProc:TCAPYIELDCALLBACK):LongInt;
  563. function capSetCallbackOnFrame (hwnd:THandle; fpProc:TCAPVIDEOSTREAMCALLBACK):LongInt; // Hier ist der Type der Callbackfunktion nicht klar !
  564. function capSetCallbackOnVideoStream(hwnd:THandle; fpProc:TCAPVIDEOSTREAMCALLBACK):LongInt;
  565. function capSetCallbackOnWaveStream (hwnd:THandle; fpProc: TCAPWAVESTREAMCALLBACK):LongInt;
  566. function capSetCallbackOnCapControl (hwnd:THandle; fpProc:TCAPCONTROLCALLBACK):LongInt;
  567. function capSetUserData(hwnd:THandle; lUser:LongInt):LongInt;
  568. function capGetUserData(hwnd:THandle):LongInt;
  569. function capDriverConnect(hwnd:THandle; I: Word):boolean;
  570. function capDriverDisconnect(hwnd:THandle):boolean;
  571. function capDriverGetName(hwnd:THandle; szName:PChar; wSize:Word):boolean;
  572. function capDriverGetVersion(hwnd:THandle; szVer:PChar; wSize:Word):Boolean;
  573. function capDriverGetCaps(hwnd:THandle; s:PCapDriverCaps; wSize:Word):boolean;
  574. function capFileSetCaptureFile(hwnd:THandle; szName:PChar):boolean;
  575. function capFileGetCaptureFile(hwnd:THandle; szName:PChar; wSize:Word):boolean;
  576. function capFileAlloc(hwnd:THandle; dwSize:DWORD):boolean;
  577. function capFileSaveAs(hwnd:THandle; szName:Pchar):boolean;
  578. function capFileSetInfoChunk(hwnd:THandle; lpInfoChunk:pCapInfoChunk):boolean;
  579. function capFileSaveDIB(hwnd:THandle; szName:Pchar):boolean;
  580. function capEditCopy(hwnd:THandle):boolean;
  581. function capSetAudioFormat(hwnd:THandle; s:PWaveFormatEx; wSize:Word):Boolean;
  582. function capGetAudioFormat(hwnd:THandle; s:PWaveFormatEx; wSize:Word):DWORD;
  583. function capGetAudioFormatSize(hwnd:THandle):DWORD;
  584. function capDlgVideoFormat(hwnd:THandle):boolean;
  585. function capDlgVideoSource(hwnd:THandle):boolean;
  586. function capDlgVideoDisplay(hwnd:THandle):boolean;
  587. function capDlgVideoCompression(hwnd:THandle):boolean;
  588. function capGetVideoFormat(hwnd:THandle; s:pBitmapInfo; wSize:Word):DWord;
  589. function capGetVideoFormatSize(hwnd:THandle):DWORD;
  590. function capSetVideoFormat(hwnd:THandle; s:pBitmapInfo; wSize:Word):boolean;
  591. function capPreview(hwnd:THandle; f:boolean):boolean;
  592. function capPreviewRate(hwnd:THandle; wMS:Word):boolean;
  593. function capOverlay(hwnd:THandle; f:boolean):boolean;
  594. function capPreviewScale(hwnd:THandle; f:boolean):boolean;
  595. function capGetStatus(hwnd:THandle; s:pCapStatus; wSize:Word):boolean;
  596. function capSetScrollPos(hwnd:THandle; lpP:pPoint):boolean;
  597. function capGrabFrame(hwnd:THandle):boolean;
  598. function capGrabFrameNoStop(hwnd:THandle):boolean;
  599. function capCaptureSequence(hwnd:THandle):Boolean;
  600. function capCaptureSequenceNoFile(hwnd:THandle):Boolean;
  601. function capCaptureStop(hwnd:THandle):boolean;
  602. function capCaptureAbort(hwnd:THandle):boolean;
  603. function capCaptureSingleFrameOpen(hwnd:THandle):boolean;
  604. function capCaptureSingleFrameClose(hwnd:THandle):boolean;
  605. function capCaptureSingleFrame(hwnd:THandle):boolean;
  606. function capCaptureGetSetup(hwnd:THandle; s:pCaptureParms; wSize:Word):boolean;
  607. function capCaptureSetSetup(hwnd:THandle; s:pCaptureParms; wSize:Word):boolean;
  608. function capSetMCIDeviceName(hwnd:THandle; szName:PChar):boolean;
  609. function capGetMCIDeviceName(hwnd:THandle; szName:PChar; wSize:Word):boolean;
  610. function capPaletteOpen(hwnd:THandle; szName:PChar):boolean;
  611. function capPaletteSave(hwnd:THandle; szName:PChar):boolean;
  612. function capPalettePaste(hwnd:THandle):Boolean;
  613. function capPaletteAuto(hwnd:THandle; iFrames:Word; iColors:word):boolean;
  614. function capPaletteManual(hwnd:THandle; fGrab:Word; iColors:word):boolean;
  615. // ------------------------------------------------------------------
  616. // The only exported functions from AVICAP.DLL
  617. // ------------------------------------------------------------------
  618. function capCreateCaptureWindow (
  619. lpszWindowName:PChar;
  620. dwStyle:DWord;
  621. x, y:Integer;
  622. nWidth, nHeight:Integer;
  623. hwndParent:THandle;
  624. nID:Integer ):THandle; stdcall;
  625. function capGetDriverDescription (
  626. wDriverIndex:DWord;
  627. lpszName:PChar;
  628. cbName:Integer;
  629. lpszVer:PChar;
  630. cbVer:Integer ):Boolean; stdcall;
  631. // ------------------------------------------------------------------
  632. // New Information chunk IDs
  633. // ------------------------------------------------------------------
  634. (*
  635. infotypeDIGITIZATION_TIME = mmioStringToFOURCC(PChar('IDIT'), MMIO_TOUPPER);
  636. infotypeSMPTE_TIME = mmioStringToFOURCC(PChar('ISMP'), MMIO_TOUPPER);
  637. *)
  638. // ------------------------------------------------------------------
  639. // String IDs from status and error callbacks
  640. // ------------------------------------------------------------------
  641. Const
  642. IDS_CAP_BEGIN = 300; (* "Capture Start" *)
  643. IDS_CAP_END = 301; (* "Capture End" *)
  644. IDS_CAP_INFO = 401; (* "%s" *)
  645. IDS_CAP_OUTOFMEM = 402; (* "Out of memory" *)
  646. IDS_CAP_FILEEXISTS = 403; (* "File '%s' exists -- overwrite it?" *)
  647. IDS_CAP_ERRORPALOPEN = 404; (* "Error opening palette '%s'" *)
  648. IDS_CAP_ERRORPALSAVE = 405; (* "Error saving palette '%s'" *)
  649. IDS_CAP_ERRORDIBSAVE = 406; (* "Error saving frame '%s'" *)
  650. IDS_CAP_DEFAVIEXT = 407; (* "avi" *)
  651. IDS_CAP_DEFPALEXT = 408; (* "pal" *)
  652. IDS_CAP_CANTOPEN = 409; (* "Cannot open '%s'" *)
  653. IDS_CAP_SEQ_MSGSTART = 410; (* "Select OK to start capture\nof video sequence\nto %s." *)
  654. IDS_CAP_SEQ_MSGSTOP = 411; (* "Hit ESCAPE or click to end capture" *)
  655. IDS_CAP_VIDEDITERR = 412; (* "An error occurred while trying to run VidEdit." *)
  656. IDS_CAP_READONLYFILE = 413; (* "The file '%s' is a read-only file." *)
  657. IDS_CAP_WRITEERROR = 414; (* "Unable to write to file '%s'.\nDisk may be full." *)
  658. IDS_CAP_NODISKSPACE = 415; (* "There is no space to create a capture file on the specified device." *)
  659. IDS_CAP_SETFILESIZE = 416; (* "Set File Size" *)
  660. IDS_CAP_SAVEASPERCENT = 417; (* "SaveAs: %2ld%% Hit Escape to abort." *)
  661. IDS_CAP_DRIVER_ERROR = 418; (* Driver specific error message *)
  662. IDS_CAP_WAVE_OPEN_ERROR = 419; (* "Error: Cannot open the wave input device.\nCheck sample size, frequency, and channels." *)
  663. IDS_CAP_WAVE_ALLOC_ERROR = 420; (* "Error: Out of memory for wave buffers." *)
  664. IDS_CAP_WAVE_PREPARE_ERROR = 421; (* "Error: Cannot prepare wave buffers." *)
  665. IDS_CAP_WAVE_ADD_ERROR = 422; (* "Error: Cannot add wave buffers." *)
  666. IDS_CAP_WAVE_SIZE_ERROR = 423; (* "Error: Bad wave size." *)
  667. IDS_CAP_VIDEO_OPEN_ERROR = 424; (* "Error: Cannot open the video input device." *)
  668. IDS_CAP_VIDEO_ALLOC_ERROR = 425; (* "Error: Out of memory for video buffers." *)
  669. IDS_CAP_VIDEO_PREPARE_ERROR = 426; (* "Error: Cannot prepare video buffers." *)
  670. IDS_CAP_VIDEO_ADD_ERROR = 427; (* "Error: Cannot add video buffers." *)
  671. IDS_CAP_VIDEO_SIZE_ERROR = 428; (* "Error: Bad video size." *)
  672. IDS_CAP_FILE_OPEN_ERROR = 429; (* "Error: Cannot open capture file." *)
  673. IDS_CAP_FILE_WRITE_ERROR = 430; (* "Error: Cannot write to capture file. Disk may be full." *)
  674. IDS_CAP_RECORDING_ERROR = 431; (* "Error: Cannot write to capture file. Data rate too high or disk full." *)
  675. IDS_CAP_RECORDING_ERROR2 = 432; (* "Error while recording" *)
  676. IDS_CAP_AVI_INIT_ERROR = 433; (* "Error: Unable to initialize for capture." *)
  677. IDS_CAP_NO_FRAME_CAP_ERROR = 434; (* "Warning: No frames captured.\nConfirm that vertical sync interrupts\nare configured and enabled." *)
  678. IDS_CAP_NO_PALETTE_WARN = 435; (* "Warning: Using default palette." *)
  679. IDS_CAP_MCI_CONTROL_ERROR = 436; (* "Error: Unable to access MCI device." *)
  680. IDS_CAP_MCI_CANT_STEP_ERROR = 437; (* "Error: Unable to step MCI device." *)
  681. IDS_CAP_NO_AUDIO_CAP_ERROR = 438; (* "Error: No audio data captured.\nCheck audio card settings." *)
  682. IDS_CAP_AVI_DRAWDIB_ERROR = 439; (* "Error: Unable to draw this data format." *)
  683. IDS_CAP_COMPRESSOR_ERROR = 440; (* "Error: Unable to initialize compressor." *)
  684. IDS_CAP_AUDIO_DROP_ERROR = 441; (* "Error: Audio data was lost during capture, reduce capture rate." *)
  685. (* status string IDs *)
  686. IDS_CAP_STAT_LIVE_MODE = 500; (* "Live window" *)
  687. IDS_CAP_STAT_OVERLAY_MODE = 501; (* "Overlay window" *)
  688. IDS_CAP_STAT_CAP_INIT = 502; (* "Setting up for capture - Please wait" *)
  689. IDS_CAP_STAT_CAP_FINI = 503; (* "Finished capture, now writing frame %ld" *)
  690. IDS_CAP_STAT_PALETTE_BUILD = 504; (* "Building palette map" *)
  691. IDS_CAP_STAT_OPTPAL_BUILD = 505; (* "Computing optimal palette" *)
  692. IDS_CAP_STAT_I_FRAMES = 506; (* "%d frames" *)
  693. IDS_CAP_STAT_L_FRAMES = 507; (* "%ld frames" *)
  694. IDS_CAP_STAT_CAP_L_FRAMES = 508; (* "Captured %ld frames" *)
  695. IDS_CAP_STAT_CAP_AUDIO = 509; (* "Capturing audio" *)
  696. IDS_CAP_STAT_VIDEOCURRENT = 510; (* "Captured %ld frames (%ld dropped) %d.%03d sec." *)
  697. IDS_CAP_STAT_VIDEOAUDIO = 511; (* "Captured %d.%03d sec. %ld frames (%ld dropped) (%d.%03d fps). %ld audio bytes (%d,%03d sps)" *)
  698. IDS_CAP_STAT_VIDEOONLY = 512; (* "Captured %d.%03d sec. %ld frames (%ld dropped) (%d.%03d fps)" *)
  699. IDS_CAP_STAT_FRAMESDROPPED = 513; (* "Dropped %ld of %ld frames (%d.%02d%%) during capture." *)
  700. {== DRAWDIB - Routines for drawing to the display ============================}
  701. type
  702. HDRAWDIB = THandle; // hdd
  703. { == DrawDib Flags ============================================================}
  704. const
  705. DDF_UPDATE = $0002; // re-draw the last DIB
  706. DDF_SAME_HDC = $0004; // HDC same as last call (all setup)
  707. DDF_SAME_DRAW = $0008; // draw params are the same
  708. DDF_DONTDRAW = $0010; // dont draw frame, just decompress
  709. DDF_ANIMATE = $0020; // allow palette animation
  710. DDF_BUFFER = $0040; // always buffer image
  711. DDF_JUSTDRAWIT = $0080; // just draw it with GDI
  712. DDF_FULLSCREEN = $0100; // use DisplayDib
  713. DDF_BACKGROUNDPAL = $0200; // Realize palette in background
  714. DDF_NOTKEYFRAME = $0400; // this is a partial frame update, hint
  715. DDF_HURRYUP = $0800; // hurry up please!
  716. DDF_HALFTONE = $1000; // always halftone
  717. DDF_PREROLL = DDF_DONTDRAW; // Builing up a non-keyframe
  718. DDF_SAME_DIB = DDF_SAME_DRAW;
  719. DDF_SAME_SIZE = DDF_SAME_DRAW;
  720. {== DrawDib functions ========================================================}
  721. {-- DrawDibOpen() ------------------------------------------------------------}
  722. function DrawDibOpen: HDRAWDIB; stdcall;
  723. {-- DrawDibClose() -----------------------------------------------------------}
  724. function DrawDibClose(hdd: HDRAWDIB): BOOL; stdcall;
  725. {-- DrawDibGetBuffer() -------------------------------------------------------}
  726. function DrawDibGetBuffer(hdd: HDRAWDIB; lpbi: PBITMAPINFOHEADER;
  727. dwSize: DWORD; dwFlags: DWORD): Pointer;stdcall;
  728. {-- DrawDibGetPalette() - get the palette used for drawing DIBs --------------}
  729. function DrawDibGetPalette(hdd: HDRAWDIB): HPALETTE; stdcall;
  730. {-- DrawDibSetPalette() - set the palette used for drawing DIBs --------------}
  731. function DrawDibSetPalette(hdd: HDRAWDIB; hpal: HPALETTE): BOOL; stdcall;
  732. {-- DrawDibChangePalette() ---------------------------------------------------}
  733. function DrawDibChangePalette(hdd: HDRAWDIB; iStart, iLen: integer;
  734. lppe: PPALETTEENTRY): BOOL; stdcall;
  735. {-- DrawDibRealize() - realize the palette in a HDD --------------------------}
  736. function DrawDibRealize(hdd: HDRAWDIB; hdc: HDC; fBackground: BOOL): UINT; stdcall;
  737. {-- DrawDibStart() - start of streaming playback -----------------------------}
  738. function DrawDibStart(hdd: HDRAWDIB; rate: DWORD): BOOL; stdcall;
  739. {-- DrawDibStop() - start of streaming playback ------------------------------}
  740. function DrawDibStop(hdd: HDRAWDIB): BOOL; stdcall;
  741. {-- DrawDibBegin() - prepare to draw -----------------------------------------}
  742. function DrawDibBegin(hdd:HDRAWDIB;hdc:HDC;dxDst:integer;dyDst:integer;
  743. lpbi:PBITMAPINFOHEADER;dxSrc:integer;dySrc:integer;
  744. wFlags:UINT): BOOL; stdcall;
  745. {-- DrawDibDraw() - actually draw a DIB to the screen ------------------------}
  746. function DrawDibDraw(hdd:HDRAWDIB;hdc:HDC;xDst:integer;yDst:integer;
  747. dxDst:integer;dyDst:integer;lpbi:PBITMAPINFOHEADER;
  748. lpBits:Pointer;xSrc:integer;ySrc:integer;
  749. dxSrc:integer;dySrc:integer;wFlags:UINT): BOOL; stdcall;
  750. {-- DrawDibUpdate() - redraw last image (may only be valid with DDF_BUFFER) --}
  751. //function DrawDibUpdate(hdd: HDRAWDIB; hdc: HDC; x, y: integer): BOOL;stdcall;
  752. {-- DrawDibEnd() -------------------------------------------------------------}
  753. function DrawDibEnd(hdd: HDRAWDIB): BOOL; stdcall;
  754. {-- DrawDibTime() - for debugging purposes only ------------------------------}
  755. type
  756. PDRAWDIBTIME = ^TDRAWDIBTIME;
  757. TDRAWDIBTIME = record
  758. timeCount:DWORD;
  759. timeDraw:DWORD;
  760. timeDecompress:DWORD;
  761. timeDither:DWORD;
  762. timeStretch:DWORD;
  763. timeBlt:DWORD;
  764. timeSetDIBits:DWORD;
  765. end;
  766. function DrawDibTime(hdd: HDRAWDIB; lpddtime: PDRAWDIBTIME): BOOL; stdcall;
  767. {-- Display profiling --------------------------------------------------------}
  768. const
  769. PD_CAN_DRAW_DIB = $0001; // if you can draw at all
  770. PD_CAN_STRETCHDIB = $0002; // basicly RC_STRETCHDIB
  771. PD_STRETCHDIB_1_1_OK = $0004; // is it fast?
  772. PD_STRETCHDIB_1_2_OK = $0008; // ...
  773. PD_STRETCHDIB_1_N_OK = $0010; // ...
  774. function DrawDibProfileDisplay(lpbi: PBITMAPINFOHEADER): DWORD; stdcall;
  775. // Helper fucntion for FOURCC
  776. function MKFOURCC(ch0, ch1, ch2, ch3: Char): FOURCC;
  777. {== COMPMAN - Installable Compression Manager ================================}
  778. const
  779. ICVERSION = $0104;
  780. type
  781. HIC = THandle; // Handle to an Installable Compressor
  782. // this code in biCompression means the DIB must be accesed via
  783. // 48 bit pointers! using *ONLY* the selector given.
  784. const
  785. BI_1632 = $32333631; // '1632'
  786. function mmioFOURCC(ch0, ch1, ch2, ch3: Char): FOURCC;
  787. type
  788. TWOCC = Word;
  789. function aviTWOCC(ch0, ch1: Char): TWOCC;
  790. const
  791. ICTYPE_VIDEO = $63646976; // mmioFOURCC('v', 'i', 'd', 'c')
  792. ICTYPE_AUDIO = $63647561; // mmioFOURCC('a', 'u', 'd', 'c')
  793. ICERR_OK = 0;
  794. ICERR_DONTDRAW = 1;
  795. ICERR_NEWPALETTE = 2;
  796. ICERR_GOTOKEYFRAME = 3;
  797. ICERR_STOPDRAWING = 4;
  798. ICERR_UNSUPPORTED = -1;
  799. ICERR_BADFORMAT = -2;
  800. ICERR_MEMORY = -3;
  801. ICERR_INTERNAL = -4;
  802. ICERR_BADFLAGS = -5;
  803. ICERR_BADPARAM = -6;
  804. ICERR_BADSIZE = -7;
  805. ICERR_BADHANDLE = -8;
  806. ICERR_CANTUPDATE = -9;
  807. ICERR_ABORT = -10;
  808. ICERR_ERROR = -100;
  809. ICERR_BADBITDEPTH = -200;
  810. ICERR_BADIMAGESIZE = -201;
  811. ICERR_CUSTOM = -400; // errors less than ICERR_CUSTOM...
  812. {-- Values for dwFlags of ICOpen() -------------------------------------------}
  813. ICMODE_COMPRESS = 1;
  814. ICMODE_DECOMPRESS = 2;
  815. ICMODE_FASTDECOMPRESS = 3;
  816. ICMODE_QUERY = 4;
  817. ICMODE_FASTCOMPRESS = 5;
  818. ICMODE_DRAW = 8;
  819. {-- quality flags ------------------------------------------------------------}
  820. ICQUALITY_LOW = 0;
  821. ICQUALITY_HIGH = 10000;
  822. ICQUALITY_DEFAULT = -1;
  823. {-----------------------------------------------------------------------------}
  824. ICM_USER = (DRV_USER+$0000);
  825. ICM_RESERVED_LOW = (DRV_USER+$1000);
  826. ICM_RESERVED_HIGH = (DRV_USER+$2000);
  827. ICM_RESERVED = ICM_RESERVED_LOW;
  828. {-- Messages -----------------------------------------------------------------}
  829. ICM_GETSTATE = (ICM_RESERVED+0); // Get compressor state
  830. ICM_SETSTATE = (ICM_RESERVED+1); // Set compressor state
  831. ICM_GETINFO = (ICM_RESERVED+2); // Query info about the compressor
  832. ICM_CONFIGURE = (ICM_RESERVED+10); // show the configure dialog
  833. ICM_ABOUT = (ICM_RESERVED+11); // show the about box
  834. ICM_GETDEFAULTQUALITY = (ICM_RESERVED+30); // get the default value for quality
  835. ICM_GETQUALITY = (ICM_RESERVED+31); // get the current value for quality
  836. ICM_SETQUALITY = (ICM_RESERVED+32); // set the default value for quality
  837. ICM_SET = (ICM_RESERVED+40); // Tell the driver something
  838. ICM_GET = (ICM_RESERVED+41); // Ask the driver something
  839. {-- Constants for ICM_SET: ---------------------------------------------------}
  840. ICM_FRAMERATE = $526D7246; // mmioFOURCC('F','r','m','R')
  841. ICM_KEYFRAMERATE = $5279654B; // mmioFOURCC('K','e','y','R')
  842. {-- ICM specific messages ----------------------------------------------------}
  843. ICM_COMPRESS_GET_FORMAT = (ICM_USER+4); // get compress format or size
  844. ICM_COMPRESS_GET_SIZE = (ICM_USER+5); // get output size
  845. ICM_COMPRESS_QUERY = (ICM_USER+6); // query support for compress
  846. ICM_COMPRESS_BEGIN = (ICM_USER+7); // begin a series of compress calls.
  847. ICM_COMPRESS = (ICM_USER+8); // compress a frame
  848. ICM_COMPRESS_END = (ICM_USER+9); // end of a series of compress calls.
  849. ICM_DECOMPRESS_GET_FORMAT = (ICM_USER+10); // get decompress format or size
  850. ICM_DECOMPRESS_QUERY = (ICM_USER+11); // query support for dempress
  851. ICM_DECOMPRESS_BEGIN = (ICM_USER+12); // start a series of decompress calls
  852. ICM_DECOMPRESS = (ICM_USER+13); // decompress a frame
  853. ICM_DECOMPRESS_END = (ICM_USER+14); // end a series of decompress calls
  854. ICM_DECOMPRESS_SET_PALETTE = (ICM_USER+29); // fill in the DIB color table
  855. ICM_DECOMPRESS_GET_PALETTE = (ICM_USER+30); // fill in the DIB color table
  856. ICM_DRAW_QUERY = (ICM_USER+31); // query support for dempress
  857. ICM_DRAW_BEGIN = (ICM_USER+15); // start a series of draw calls
  858. ICM_DRAW_GET_PALETTE = (ICM_USER+16); // get the palette needed for drawing
  859. ICM_DRAW_START = (ICM_USER+18); // start decompress clock
  860. ICM_DRAW_STOP = (ICM_USER+19); // stop decompress clock
  861. ICM_DRAW_END = (ICM_USER+21); // end a series of draw calls
  862. ICM_DRAW_GETTIME = (ICM_USER+32); // get value of decompress clock
  863. ICM_DRAW = (ICM_USER+33); // generalized "render" message
  864. ICM_DRAW_WINDOW = (ICM_USER+34); // drawing window has moved or hidden
  865. ICM_DRAW_SETTIME = (ICM_USER+35); // set correct value for decompress clock
  866. ICM_DRAW_REALIZE = (ICM_USER+36); // realize palette for drawing
  867. ICM_DRAW_FLUSH = (ICM_USER+37); // clear out buffered frames
  868. ICM_DRAW_RENDERBUFFER = (ICM_USER+38); // draw undrawn things in queue
  869. ICM_DRAW_START_PLAY = (ICM_USER+39); // start of a play
  870. ICM_DRAW_STOP_PLAY = (ICM_USER+40); // end of a play
  871. ICM_DRAW_SUGGESTFORMAT = (ICM_USER+50); // Like ICGetDisplayFormat
  872. ICM_DRAW_CHANGEPALETTE = (ICM_USER+51); // for animating palette
  873. ICM_GETBUFFERSWANTED = (ICM_USER+41); // ask about prebuffering
  874. ICM_GETDEFAULTKEYFRAMERATE = (ICM_USER+42); // get the default value for key frames
  875. ICM_DECOMPRESSEX_BEGIN = (ICM_USER+60); // start a series of decompress calls
  876. ICM_DECOMPRESSEX_QUERY = (ICM_USER+61); // start a series of decompress calls
  877. ICM_DECOMPRESSEX = (ICM_USER+62); // decompress a frame
  878. ICM_DECOMPRESSEX_END = (ICM_USER+63); // end a series of decompress calls
  879. ICM_COMPRESS_FRAMES_INFO = (ICM_USER+70); // tell about compress to come
  880. ICM_SET_STATUS_PROC = (ICM_USER+72); // set status callback
  881. {-----------------------------------------------------------------------------}
  882. type
  883. PICOPEN = ^TICOPEN;
  884. TICOPEN = record
  885. dwSize:DWORD; // sizeof(TICOPEN)
  886. fccType:DWORD; // 'vidc'
  887. fccHandler:DWORD; //
  888. dwVersion:DWORD; // version of compman opening you
  889. dwFlags:DWORD; // LOWORD is type specific
  890. dwError:DWORD; // error return.
  891. pV1Reserved:Pointer; // Reserved
  892. pV2Reserved:Pointer; // Reserved
  893. dnDevNode:DWORD; // Devnode for PnP devices
  894. end;
  895. {-----------------------------------------------------------------------------}
  896. PICINFO = ^TICINFO;
  897. TICINFO = record
  898. dwSize:DWORD; // sizeof(TICINFO)
  899. fccType:DWORD; // compressor type 'vidc' 'audc'
  900. fccHandler:DWORD; // compressor sub-type 'rle ' 'jpeg' 'pcm '
  901. dwFlags:DWORD; // flags LOWORD is type specific
  902. dwVersion:DWORD; // version of the driver
  903. dwVersionICM:DWORD; // version of the ICM used
  904. // under Win32, the driver always returns UNICODE strings.
  905. szName:array[0..15] of WideChar; // short name
  906. szDescription:array[0..127] of WideChar; // DWORD name
  907. szDriver:array[0..127] of WideChar; // driver that contains compressor
  908. end;
  909. {-- Flags for the field of the structure. -----------------}
  910. const
  911. VIDCF_QUALITY = $0001; // supports quality
  912. VIDCF_CRUNCH = $0002; // supports crunching to a frame size
  913. VIDCF_TEMPORAL = $0004; // supports inter-frame compress
  914. VIDCF_COMPRESSFRAMES = $0008; // wants the compress all frames message
  915. VIDCF_DRAW = $0010; // supports drawing
  916. VIDCF_FASTTEMPORALC = $0020; // does not need prev frame on compress
  917. VIDCF_FASTTEMPORALD = $0080; // does not need prev frame on decompress
  918. //VIDCF_QUALITYTIME = $0040; // supports temporal quality
  919. //VIDCF_FASTTEMPORAL = (VIDCF_FASTTEMPORALC or VIDCF_FASTTEMPORALD)
  920. {-----------------------------------------------------------------------------}
  921. ICCOMPRESS_KEYFRAME = $00000001;
  922. type
  923. PICCOMPRESS = ^TICCOMPRESS;
  924. TICCOMPRESS = record
  925. dwFlags:DWORD; // flags
  926. lpbiOutput:PBITMAPINFOHEADER; // output format
  927. lpOutput:Pointer; // output data
  928. lpbiInput:PBITMAPINFOHEADER; // format of frame to compress
  929. lpInput:Pointer; // frame data to compress
  930. lpckid:PDWORD; // ckid for data in AVI file
  931. lpdwFlags:PDWORD; // flags in the AVI index.
  932. lFrameNum:DWORD; // frame number of seq.
  933. dwFrameSize:DWORD; // reqested size in bytes. (if non zero)
  934. dwQuality:DWORD; // quality
  935. // these are new fields
  936. lpbiPrev:PBITMAPINFOHEADER; // format of previous frame
  937. lpPrev:Pointer; // previous frame
  938. end;
  939. {-----------------------------------------------------------------------------}
  940. const
  941. ICCOMPRESSFRAMES_PADDING = $00000001;
  942. type
  943. TICCompressProc = function(lInput: LPARAM; lFrame: DWORD; lpBits: Pointer; len: DWORD): DWORD; stdcall;
  944. PICCOMPRESSFRAMES = ^TICCOMPRESSFRAMES;
  945. TICCOMPRESSFRAMES = record
  946. dwFlags:DWORD; // flags
  947. lpbiOutput:PBITMAPINFOHEADER; // output format
  948. lOutput:LPARAM; // output identifier
  949. lpbiInput:PBITMAPINFOHEADER; // format of frame to compress
  950. lInput:LPARAM; // input identifier
  951. lStartFrame:DWORD; // start frame
  952. lFrameCount:DWORD; // # of frames
  953. lQuality:DWORD; // quality
  954. lDataRate:DWORD; // data rate
  955. lKeyRate:DWORD; // key frame rate
  956. dwRate:DWORD; // frame rate, as always
  957. dwScale:DWORD;
  958. dwOverheadPerFrame:DWORD;
  959. dwReserved2:DWORD;
  960. GetData:TICCompressProc;
  961. PutData:TICCompressProc;
  962. end;
  963. {-- Messages for Status callback ---------------------------------------------}
  964. const
  965. ICSTATUS_START = 0;
  966. ICSTATUS_STATUS = 1; // l = % done
  967. ICSTATUS_END = 2;
  968. ICSTATUS_ERROR = 3; // l = error string (LPSTR)
  969. ICSTATUS_YIELD = 4;
  970. type
  971. // return nonzero means abort operation in progress
  972. TICStatusProc = function(lParam: LPARAM; message: UINT; l: DWORD): DWORD; stdcall;
  973. PICSETSTATUSPROC = ^TICSETSTATUSPROC;
  974. TICSETSTATUSPROC = record
  975. dwFlags:DWORD;
  976. lParam:LPARAM;
  977. Status:TICStatusProc;
  978. end;
  979. {-----------------------------------------------------------------------------}
  980. const
  981. ICDECOMPRESS_HURRYUP = $80000000; // don't draw just buffer (hurry up!)
  982. ICDECOMPRESS_UPDATE = $40000000; // don't draw just update screen
  983. ICDECOMPRESS_PREROLL = $20000000; // this frame is before real start
  984. ICDECOMPRESS_NULLFRAME = $10000000; // repeat last frame
  985. ICDECOMPRESS_NOTKEYFRAME = $08000000; // this frame is not a key frame
  986. type
  987. PICDECOMPRESS = ^TICDECOMPRESS;
  988. TICDECOMPRESS = record
  989. dwFlags:DWORD; // flags (from AVI index...)
  990. lpbiInput:PBITMAPINFOHEADER; // BITMAPINFO of compressed data
  991. // biSizeImage has the chunk size
  992. lpInput:Pointer; // compressed data
  993. lpbiOutput:PBITMAPINFOHEADER; // DIB to decompress to
  994. lpOutput:Pointer;
  995. ckid:DWORD; // ckid from AVI file
  996. end;
  997. PICDECOMPRESSEX = ^TICDECOMPRESSEX;
  998. TICDECOMPRESSEX = record
  999. // same as ICM_DECOMPRESS
  1000. dwFlags:DWORD;
  1001. lpbiSrc:PBITMAPINFOHEADER; // BITMAPINFO of compressed data
  1002. lpSrc:Pointer; // compressed data
  1003. lpbiDst:PBITMAPINFOHEADER; // DIB to decompress to
  1004. lpDst:Pointer; // output data
  1005. // new for ICM_DECOMPRESSEX
  1006. xDst:integer; // destination rectangle
  1007. yDst:integer;
  1008. dxDst:integer;
  1009. dyDst:integer;
  1010. xSrc:integer; // source rectangle
  1011. ySrc:integer;
  1012. dxSrc:integer;
  1013. dySrc:integer;
  1014. end;
  1015. {-----------------------------------------------------------------------------}
  1016. const
  1017. ICDRAW_QUERY = $00000001; // test for support
  1018. ICDRAW_FULLSCREEN = $00000002; // draw to full screen
  1019. ICDRAW_HDC = $00000004; // draw to a HDC/HWND
  1020. ICDRAW_ANIMATE = $00000008; // expect palette animation
  1021. ICDRAW_CONTINUE = $00000010; // draw is a continuation of previous draw
  1022. ICDRAW_MEMORYDC = $00000020; // DC is offscreen, by the way
  1023. ICDRAW_UPDATING = $00000040; // We're updating, as opposed to playing
  1024. ICDRAW_RENDER = $00000080; // used to render data not draw it
  1025. ICDRAW_BUFFER = $00000100; // please buffer this data offscreen, we will need to update it
  1026. type
  1027. PICDRAWBEGIN = ^TICDRAWBEGIN;
  1028. TICDRAWBEGIN = record
  1029. dwFlags:DWORD; // flags
  1030. hpal:HPALETTE; // palette to draw with
  1031. hwnd:HWND; // window to draw to
  1032. hdc:HDC; // HDC to draw to
  1033. xDst:integer; // destination rectangle
  1034. yDst:integer;
  1035. dxDst:integer;
  1036. dyDst:integer;
  1037. lpbi:PBITMAPINFOHEADER;
  1038. // format of frame to draw
  1039. xSrc:integer; // source rectangle
  1040. ySrc:integer;
  1041. dxSrc:integer;
  1042. dySrc:integer;
  1043. dwRate:DWORD; // frames/second = (dwRate/dwScale)
  1044. dwScale:DWORD;
  1045. end;
  1046. {-----------------------------------------------------------------------------}
  1047. const
  1048. ICDRAW_HURRYUP = $80000000; // don't draw just buffer (hurry up!)
  1049. ICDRAW_UPDATE = $40000000; // don't draw just update screen
  1050. ICDRAW_PREROLL = $20000000; // this frame is before real start
  1051. ICDRAW_NULLFRAME = $10000000; // repeat last frame
  1052. ICDRAW_NOTKEYFRAME = $08000000; // this frame is not a key frame
  1053. type
  1054. PICDRAW = ^TICDRAW;
  1055. TICDRAW = record
  1056. dwFlags:DWORD; // flags
  1057. lpFormat:Pointer; // format of frame to decompress
  1058. lpData:Pointer; // frame data to decompress
  1059. cbData:DWORD;
  1060. lTime:DWORD; // time in drawbegin units (see dwRate and dwScale)
  1061. end;
  1062. PICDRAWSUGGEST = ^TICDRAWSUGGEST;
  1063. TICDRAWSUGGEST = record
  1064. lpbiIn:PBITMAPINFOHEADER; // format to be drawn
  1065. lpbiSuggest:PBITMAPINFOHEADER; // location for suggested format (or NULL to get size)
  1066. dxSrc:integer; // source extent or 0
  1067. dySrc:integer;
  1068. dxDst:integer; // dest extent or 0
  1069. dyDst:integer;
  1070. hicDecompressor:HIC; // decompressor you can talk to
  1071. end;
  1072. {-----------------------------------------------------------------------------}
  1073. PICPALETTE = ^TICPALETTE;
  1074. TICPALETTE = record
  1075. dwFlags:DWORD; // flags (from AVI index...)
  1076. iStart:integer; // first palette to change
  1077. iLen:integer; // count of entries to change.
  1078. lppe:PPALETTEENTRY; // palette
  1079. end;
  1080. {-- ICM function declarations ------------------------------------------------}
  1081. function ICInfo(fccType, fccHandler: DWORD; lpicinfo: PICINFO):BOOL; stdcall;
  1082. function ICInstall(fccType, fccHandler: DWORD; lParam: LPARAM; szDesc: LPSTR; wFlags: UINT):BOOL; stdcall;
  1083. function ICRemove(fccType, fccHandler: DWORD; wFlags: UINT):BOOL; stdcall;
  1084. function ICGetInfo(hic: HIC; picinfo: PICINFO; cb: DWORD):DWORD; stdcall;
  1085. function ICOpen(fccType, fccHandler: DWORD; wMode: UINT):HIC; stdcall;
  1086. function ICOpenFunction(fccType, fccHandler: DWORD; wMode: UINT; lpfnHandler: TFarProc):HIC; stdcall;
  1087. function ICClose(hic: HIC):DWORD; stdcall;
  1088. function ICSendMessage(hic: HIC; msg: UINT; dw1, dw2: integer):DWORD; stdcall;
  1089. {-- Values for wFlags of ICInstall -------------------------------------------}
  1090. const
  1091. ICINSTALL_UNICODE = $8000;
  1092. ICINSTALL_FUNCTION = $0001; // lParam is a DriverProc (function ptr)
  1093. ICINSTALL_DRIVER = $0002; // lParam is a driver name (string)
  1094. ICINSTALL_HDRV = $0004; // lParam is a HDRVR (driver handle)
  1095. ICINSTALL_DRIVERW = $8002; // lParam is a unicode driver name
  1096. {-- Query macros -------------------------------------------------------------}
  1097. ICMF_CONFIGURE_QUERY = $00000001;
  1098. ICMF_ABOUT_QUERY = $00000001;
  1099. function ICQueryAbout(hic: HIC): BOOL;
  1100. function ICAbout(hic: HIC; hwnd: HWND): DWORD;
  1101. function ICQueryConfigure(hic: HIC): BOOL;
  1102. function ICConfigure(hic: HIC; hwnd: HWND): DWORD;
  1103. {-- Get/Set state macros -----------------------------------------------------}
  1104. function ICGetState(hic: HIC; pv: Pointer; cb: DWORD): DWORD;
  1105. function ICSetState(hic: HIC; pv: Pointer; cb: DWORD): DWORD;
  1106. function ICGetStateSize(hic: HIC): DWORD;
  1107. {-- Get value macros ---------------------------------------------------------}
  1108. function ICGetDefaultQuality(hic: HIC): DWORD;
  1109. function ICGetDefaultKeyFrameRate(hic: HIC): DWORD;
  1110. {-- Draw window macro --------------------------------------------------------}
  1111. function ICDrawWindow(hic: HIC; prc: PRECT): DWORD;
  1112. {== Compression functions ====================================================}
  1113. {-- ICCompress() - compress a single frame -----------------------------------}
  1114. function ICCompress(hic:HIC;dwFlags:DWORD; // flags
  1115. lpbiOutput:PBITMAPINFOHEADER; // output format
  1116. lpData:Pointer; // output data
  1117. lpbiInput:PBITMAPINFOHEADER; // format of frame to compress
  1118. lpBits:Pointer; // frame data to compress
  1119. lpckid:PDWORD; // ckid for data in AVI file
  1120. lpdwFlags:PDWORD; // flags in the AVI index.
  1121. lFrameNum:DWORD; // frame number of seq.
  1122. dwFrameSize:DWORD; // reqested size in bytes. (if non zero)
  1123. dwQuality:DWORD; // quality within one frame
  1124. lpbiPrev:PBITMAPINFOHEADER; // format of previous frame
  1125. lpPrev:Pointer):DWORD; cdecl; // previous frame
  1126. {-- ICCompressBegin() - start compression from a source fmt to a dest fmt ----}
  1127. function ICCompressBegin(hic: HIC; lpbiInput: PBITMAPINFOHEADER;
  1128. lpbiOutput: PBITMAPINFOHEADER): DWORD;
  1129. {-- ICCompressQuery() - determines if compression from src to dst is supp ----}
  1130. function ICCompressQuery(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  1131. {-- ICCompressGetFormat() - get the output format (fmt of compressed) --------}
  1132. // if lpbiOutput is nil return the size in bytes needed for format.
  1133. function ICCompressGetFormat(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  1134. function ICCompressGetFormatSize(hic: HIC; lpbi: PBITMAPINFOHEADER): DWORD;
  1135. {-- ICCompressSize() - return the maximal size of a compressed frame ---------}
  1136. function ICCompressGetSize(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  1137. function ICCompressEnd(hic: HIC): DWORD;
  1138. {== Decompression functions ==================================================}
  1139. {-- ICDecompress() - decompress a single frame -------------------------------}
  1140. function ICDecompress(hic:HIC;dwFlags:DWORD; // flags (from AVI index...)
  1141. // BITMAPINFO of compressed data biSizeImage has the chunk size
  1142. lpbiFormat:PBITMAPINFOHEADER;
  1143. lpData:Pointer; // data
  1144. lpbi:PBITMAPINFOHEADER; // DIB to decompress to
  1145. lpBits:Pointer): DWORD; cdecl;
  1146. {-- ICDecompressBegin() - start compression from src fmt to a dest fmt -------}
  1147. function ICDecompressBegin(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  1148. {-- ICDecompressQuery() - determines if compression is supported -------------}
  1149. function ICDecompressQuery(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  1150. {-- ICDecompressGetFormat - get the output fmt (fmt of uncompressed data) ----}
  1151. // if lpbiOutput is NULL return the size in bytes needed for format.
  1152. function ICDecompressGetFormat(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  1153. function ICDecompressGetFormatSize(hic: HIC; lpbi: PBITMAPINFOHEADER): DWORD;
  1154. {-- ICDecompressGetPalette() - get the output palette ------------------------}
  1155. function ICDecompressGetPalette(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  1156. function ICDecompressSetPalette(hic: HIC; lpbiPalette: PBITMAPINFOHEADER): DWORD;
  1157. function ICDecompressEnd(hic: HIC): DWORD;
  1158. {== Decompression(ex) functions ==============================================}
  1159. // on Win16 these functions are macros that call ICMessage. ICMessage will
  1160. // not work on NT. rather than add new entrypoints we have given
  1161. // them as static inline functions
  1162. {-- ICDecompressEx() - decompress a single frame -----------------------------}
  1163. function ICDecompressEx(hic:HIC;dwFlags:DWORD;lpbiSrc:PBITMAPINFOHEADER;
  1164. lpSrc:Pointer;xSrc:integer;ySrc:integer;dxSrc:integer;
  1165. dySrc:integer;lpbiDst:PBITMAPINFOHEADER;lpDst:Pointer;
  1166. xDst:integer;yDst:integer;dxDst:integer;
  1167. dyDst:integer): DWORD; stdcall;
  1168. {-- ICDecompressExBegin() - start compression from a src fmt to a dest fmt ---}
  1169. function ICDecompressExBegin(hic:HIC;dwFlags:DWORD;lpbiSrc:PBITMAPINFOHEADER;
  1170. lpSrc:Pointer;xSrc:integer;ySrc:integer;dxSrc:integer;
  1171. dySrc:integer;lpbiDst:PBITMAPINFOHEADER;lpDst:Pointer;
  1172. xDst:integer;yDst:integer;dxDst:integer;
  1173. dyDst:integer): DWORD; stdcall;
  1174. {-- ICDecompressExQuery() ----------------------------------------------------}
  1175. function ICDecompressExQuery(hic:HIC;dwFlags:DWORD;lpbiSrc:PBITMAPINFOHEADER;
  1176. lpSrc:Pointer;xSrc:integer;ySrc:integer;dxSrc:integer;
  1177. dySrc:integer;lpbiDst:PBITMAPINFOHEADER;lpDst:Pointer;
  1178. xDst:integer;yDst:integer;dxDst:integer;
  1179. dyDst:integer): DWORD; stdcall;
  1180. function ICDecompressExEnd(hic: HIC): DWORD;
  1181. {== Drawing functions ========================================================}
  1182. {-- ICDrawBegin() - start decompressing data with fmt directly to screen -----}
  1183. // return zero if the decompressor supports drawing.
  1184. function ICDrawBegin(hic:HIC;dwFlags:DWORD; // flags
  1185. hpal:HPALETTE; // palette to draw with
  1186. hwnd:HWND; // window to draw to
  1187. hdc:HDC; // HDC to draw to
  1188. xDst:integer; // destination rectangle
  1189. yDst:integer;dxDst:integer;dyDst:integer;
  1190. lpbi:PBITMAPINFOHEADER; // format of frame to draw
  1191. xSrc:integer; // source rectangle
  1192. ySrc:integer;dxSrc:integer;dySrc:integer;
  1193. dwRate:DWORD; // frames/second = (dwRate/dwScale)
  1194. dwScale:DWORD): DWORD; cdecl;
  1195. {-- ICDraw() - decompress data directly to the screen ------------------------}
  1196. function ICDraw(hic:HIC;dwFlags:DWORD; // flags
  1197. lpFormat:Pointer; // format of frame to decompress
  1198. lpData:Pointer; // frame data to decompress
  1199. cbData:DWORD; // size of data
  1200. lTime:DWORD): DWORD; cdecl; // time to draw this frame
  1201. // ICMessage is not supported on Win32, so provide a static inline function
  1202. // to do the same job
  1203. function ICDrawSuggestFormat(hic:HIC;lpbiIn:PBITMAPINFOHEADER;lpbiOut:PBITMAPINFOHEADER;
  1204. dxSrc:integer;dySrc:integer;dxDst:integer;
  1205. dyDst:integer;hicDecomp:HIC): DWORD; stdcall;
  1206. {-- ICDrawQuery() - determines if the compressor is willing to render fmt ----}
  1207. function ICDrawQuery(hic: HIC; lpbiInput: PBITMAPINFOHEADER): DWORD;
  1208. function ICDrawChangePalette(hic: HIC; lpbiInput: PBITMAPINFOHEADER): DWORD;
  1209. function ICGetBuffersWanted(hic: HIC; lpdwBuffers: PDWORD): DWORD;
  1210. function ICDrawEnd(hic: HIC): DWORD;
  1211. function ICDrawStart(hic: HIC): DWORD;
  1212. function ICDrawStartPlay(hic: HIC; lFrom, lTo: DWORD): DWORD;
  1213. function ICDrawStop(hic: HIC): DWORD;
  1214. function ICDrawStopPlay(hic: HIC): DWORD;
  1215. function ICDrawGetTime(hic: HIC; lplTime: PDWORD): DWORD;
  1216. function ICDrawSetTime(hic: HIC; lTime: DWORD): DWORD;
  1217. function ICDrawRealize(hic: HIC; hdc: HDC; fBackground: BOOL): DWORD;
  1218. function ICDrawFlush(hic: HIC): DWORD;
  1219. function ICDrawRenderBuffer(hic: HIC): DWORD;
  1220. {== Status callback functions ================================================}
  1221. {-- ICSetStatusProc() - Set the status callback function ---------------------}
  1222. // ICMessage is not supported on NT
  1223. function ICSetStatusProc(hic:HIC;dwFlags:DWORD;lParam:DWORD;
  1224. fpfnStatus:TICStatusProc): DWORD; stdcall;
  1225. {== Helper routines for DrawDib and MCIAVI... ================================}
  1226. function ICLocate(fccType, fccHandler: DWORD; lpbiIn,
  1227. lpbiOut: PBITMAPINFOHEADER; wFlags: WORD): HIC; stdcall;
  1228. function ICGetDisplayFormat(hic: HIC; lpbiIn, lpbiOut: PBITMAPINFOHEADER;
  1229. BitDepth: integer; dx, dy: integer): HIC; stdcall;
  1230. function ICDecompressOpen(fccType, fccHandler: DWORD; lpbiIn, lpbiOut: PBITMAPINFOHEADER): HIC;
  1231. function ICDrawOpen(fccType, fccHandler: DWORD; lpbiIn: PBITMAPINFOHEADER): HIC;
  1232. {== Higher level functions ===================================================}
  1233. function ICImageCompress(hic:HIC; // compressor to use
  1234. uiFlags:UINT; // flags (none yet)
  1235. lpbiIn:PBITMAPINFO; // format to compress from
  1236. lpBits:Pointer; // data to compress
  1237. lpbiOut:PBITMAPINFO; // compress to this (NULL ==> default)
  1238. lQuality:DWORD; // quality to use
  1239. plSize:PDWORD): THANDLE; stdcall; // compress to this size (0=whatever)
  1240. function ICImageDecompress(hic:HIC; // compressor to use
  1241. uiFlags:UINT; // flags (none yet)
  1242. lpbiIn:PBITMAPINFO; // format to decompress from
  1243. lpBits:Pointer; // data to decompress
  1244. lpbiOut:PBITMAPINFO): THANDLE; stdcall; // decompress to this (NULL ==> default)
  1245. {-- TCompVars ----------------------------------------------------------------}
  1246. // Structure used by ICSeqCompressFrame and ICCompressorChoose routines
  1247. // Make sure this matches the autodoc in icm.c!
  1248. type
  1249. PCOMPVARS = ^TCOMPVARS;
  1250. TCOMPVARS = record
  1251. cbSize:DWORD; // set to sizeof(COMPVARS) before
  1252. // calling ICCompressorChoose
  1253. dwFlags:DWORD; // see below...
  1254. hic:HIC; // HIC of chosen compressor
  1255. fccType:DWORD; // basically ICTYPE_VIDEO
  1256. fccHandler:DWORD; // handler of chosen compressor or
  1257. // "" or "DIB "
  1258. lpbiIn:PBITMAPINFO; // input format
  1259. lpbiOut:PBITMAPINFO; // output format - will compress to this
  1260. lpBitsOut:Pointer;
  1261. lpBitsPrev:Pointer;
  1262. lFrame:DWORD;
  1263. lKey:DWORD; // key frames how often?
  1264. lDataRate:DWORD; // desired data rate KB/Sec
  1265. lQ:DWORD; // desired quality
  1266. lKeyCount:DWORD;
  1267. lpState:Pointer; // state of compressor
  1268. cbState:DWORD; // size of the state
  1269. end;
  1270. // FLAGS for dwFlags element of COMPVARS structure:
  1271. // set this flag if you initialize COMPVARS before calling ICCompressorChoose
  1272. const
  1273. ICMF_COMPVARS_VALID = $00000001; // COMPVARS contains valid data
  1274. {-- ICCompressorChoose() - allows user to choose compressor, quality etc... --}
  1275. function ICCompressorChoose(hwnd:HWND; // parent window for dialog
  1276. uiFlags:UINT; // flags
  1277. pvIn:Pointer; // input format (optional)
  1278. lpData:Pointer; // input data (optional)
  1279. pc:PCOMPVARS; // data about the compressor/dlg
  1280. lpszTitle:LPSTR): BOOL; stdcall; // dialog title (optional)
  1281. // can handle the input format or input data
  1282. function ICSeqCompressFrameStart(pc: PCOMPVARS; lpbiIn: PBITMAPINFO): BOOL; stdcall;
  1283. procedure ICSeqCompressFrameEnd(pc: PCOMPVARS); stdcall;
  1284. function ICSeqCompressFrame(pc:PCOMPVARS; // set by ICCompressorChoose
  1285. uiFlags:UINT; // flags
  1286. lpBits:Pointer; // input DIB bits
  1287. pfKey:PBOOL; // did it end up being a key frame?
  1288. plSize:PDWORD): Pointer; stdcall; // size to compress to/of returned image
  1289. procedure ICCompressorFree(pc: PCOMPVARS); stdcall;
  1290. {---------End AVICAP window-------------}
  1291. {---------Begin TFlatAviter-------------}
  1292. //const
  1293. // RIFF_PaletteChange: DWORD = 1668293411;
  1294. type
  1295. {TAVIPalChange = packed record
  1296. bFirstEntry : byte;
  1297. bNumEntries : byte;
  1298. wFlags : WORD;
  1299. peNew : array[byte] of TPaletteEntry;
  1300. end;
  1301. PAVIPalChange = ^TAVIPalChange;
  1302. TAVIStreamList = array[0..0] of PAVIStream;
  1303. PAVIStreamList = ^TAVIStreamList; }
  1304. TVDAVIEvent = procedure(Sender: TObject; Progress:Integer) of object;
  1305. TVDPixelFmt = (vd01bit,vd02bit,vd04bit,vd08bit,vd16bit,vd24bit,vd32bit,vdCustom);
  1306. TFlatAviter = class(TVersionComponent)
  1307. private
  1308. FVideoHeight: integer;
  1309. FVideoWidth: integer;
  1310. FPicStretch: boolean;
  1311. FFrameTime: integer;
  1312. FVideoFile: TFileName;
  1313. FAudioFile: TFileName;
  1314. FPixelFormat: TVDPixelFmt;
  1315. FPixelValue: Byte;
  1316. FOnProgress: TVDAVIEvent;
  1317. FShowDialog: boolean;
  1318. procedure SetAudioFile(value : TFileName);
  1319. { Private declarations }
  1320. protected
  1321. Bitmaps : TList;
  1322. Bitmap : TBitmap;
  1323. VideoTemper : TFileName;
  1324. VideoBuffer : PAVIFile;
  1325. VideoStream : PAVIStream;
  1326. AudioStream : PAVIStream;
  1327. procedure AddVideo;
  1328. procedure AddAudio;
  1329. procedure InternalGetBMPHeader(Bitmap: HBITMAP; var Info: TBitmapInfoHeader);
  1330. procedure InternalGetDIBSizes(Bitmap: HBITMAP; var HeaderSize: Integer;
  1331. var ImageSize: LongInt);
  1332. function InternalGetDIB(Bitmap: HBITMAP; Palette: HPALETTE;
  1333. var BitmapInfo; var Bits): Boolean;
  1334. function GetPictureCount: Integer;
  1335. { Protected declarations }
  1336. public
  1337. constructor Create(AOwner : TComponent); override;
  1338. destructor Destroy; override;
  1339. procedure MakeVideo;
  1340. procedure AddImage(FileName:TFileName);
  1341. procedure AddImages(Files:TStrings);
  1342. property PictureCount:Integer read GetPictureCount;
  1343. { Public declarations }
  1344. published
  1345. property VideoHeight : integer read FVideoHeight write FVideoHeight;
  1346. property VideoWidth : integer read FVideoWidth write FVideoWidth;
  1347. property FrameTime : integer read FFrameTime write FFrameTime;
  1348. property PICStretch : boolean read FPicStretch write FPicStretch;
  1349. property VideoFile : TFileName read FVideoFile write FVideoFile;
  1350. property AudioFile : TFileName read FAudioFile write SetAudioFile;
  1351. property PixelFormat : TVDPixelFmt read FPixelFormat write FPixelFormat default vd24Bit;
  1352. property PixelValue : Byte read FPixelValue write FPixelValue default 24;
  1353. property ShowDialog : boolean read FShowDialog write FShowDialog default false;
  1354. property OnProgress : TVDAVIEvent read FOnProgress write FOnProgress;
  1355. //property OnCallBack : TVDCallBack read FOnCallBack write FOnCallBack;
  1356. { Published declarations }
  1357. end;
  1358. {---------end TFlatAviter---------------}
  1359. implementation
  1360. {---------Begin AVIWriter---------------}
  1361. { Define LoadLibDll AVILIBDLL = 'avifil32.dll' }
  1362. const AVILIBDLL = 'avifil32.dll';
  1363. procedure AVIFileInit; stdcall; external AVILIBDLL name 'AVIFileInit';
  1364. procedure AVIFileExit; stdcall; external AVILIBDLL name 'AVIFileExit';
  1365. function AVIFileAddRef; external AVILIBDLL name 'AVIFileAddRef';
  1366. function AVIFileRelease; external AVILIBDLL name 'AVIFileRelease';
  1367. function AVIFileOpen; external AVILIBDLL name 'AVIFileOpenA';
  1368. function AVIFileInfo; external AVILIBDLL name 'AVIFileInfo';
  1369. function AVIFileGetStream; external AVILIBDLL name 'AVIFileGetStream';
  1370. function AVIFileCreateStream; external AVILIBDLL name 'AVIFileCreateStreamA';
  1371. function AVIFileWriteData; external AVILIBDLL name 'AVIFileWriteData';
  1372. function AVIFileReadData; external AVILIBDLL name 'AVIFileReadData';
  1373. function AVIFileEndRecord; external AVILIBDLL name 'AVIFileEndRecord';
  1374. function AVIStreamAddRef; external AVILIBDLL name 'AVIStreamAddRef';
  1375. function AVIStreamRelease; external AVILIBDLL name 'AVIStreamRelease';
  1376. function AVIStreamInfo; external AVILIBDLL name 'AVIStreamInfo';
  1377. function AVIStreamFindSample; external AVILIBDLL name 'AVIStreamFindSample';
  1378. function AVIStreamReadFormat; external AVILIBDLL name 'AVIStreamReadFormat';
  1379. function AVIStreamSetFormat; external AVILIBDLL name 'AVIStreamSetFormat';
  1380. function AVIStreamReadData; external AVILIBDLL name 'AVIStreamReadData';
  1381. function AVIStreamWriteData; external AVILIBDLL name 'AVIStreamWriteData';
  1382. function AVIStreamRead; external AVILIBDLL name 'AVIStreamRead';
  1383. function AVIStreamWrite; external AVILIBDLL name 'AVIStreamWrite';
  1384. function AVIStreamStart; external AVILIBDLL name 'AVIStreamStart';
  1385. function AVIStreamLength; external AVILIBDLL name 'AVIStreamLength';
  1386. function AVIStreamLengthTime; external AVILIBDLL name 'AVIStreamLengthTime';
  1387. function AVIStreamTimeToSample; external AVILIBDLL name 'AVIStreamTimeToSample';
  1388. function AVIStreamSampleToTime; external AVILIBDLL name 'AVIStreamSampleToTime';
  1389. function AVIStreamBeginStreaming; external AVILIBDLL name 'AVIStreamBeginStreaming';
  1390. function AVIStreamEndStreaming; external AVILIBDLL name 'AVIStreamEndStreaming';
  1391. function AVIStreamGetFrameOpen; external AVILIBDLL name 'AVIStreamGetFrameOpen';
  1392. function AVIStreamGetFrame; external AVILIBDLL name 'AVIStreamGetFrame';
  1393. function AVIStreamGetFrameClose; external AVILIBDLL name 'AVIStreamGetFrameClose';
  1394. function AVIStreamOpenFromFile; external AVILIBDLL name 'AVIStreamOpenFromFile';
  1395. function AVIStreamCreate; external AVILIBDLL name 'AVIStreamCreate';
  1396. function AVISave; external AVILIBDLL name 'AVISave';
  1397. function AVISaveV; external AVILIBDLL name 'AVISaveV';
  1398. {--------------------------------------------------------------------------------}
  1399. function AVISaveFile(szFile:LPCSTR;pclsidHandler:PCLSID;lpfnCallback :AVISAVECALLBACK; nStreams: INTEGER;
  1400. var ppavi: APAVIStream; var plpOptions: APAviCompressOptions):HRESULT;
  1401. VAR wszFile: LPCWSTR;
  1402. wszLen: integer;
  1403. OSVer: TOSVersionInfo;
  1404. begin
  1405. result := -1;
  1406. OSVer.dwOSVersionInfoSize:=SizeOf(OSVer);
  1407. if GetVersionEx(OSVer) then begin
  1408. case OSVer.dwPlatformId of
  1409. VER_PLATFORM_WIN32_NT :
  1410. begin
  1411. wszFile := nil;
  1412. if (szFile = nil) then exit;
  1413. wszLen := MultiByteToWideChar(CP_ACP, 0, szFile, -1, nil, 0);
  1414. if (wszLen <= 0) then exit;
  1415. wszFile := LPCWSTR(LocalAlloc(LPTR, wszLen*sizeof(LPCWSTR)));
  1416. if (wszFile = Nil) then exit;
  1417. MultiByteToWideChar(CP_ACP,0,szFile,-1,wszFile,wszLen);
  1418. result := AVISaveVW(wszFile,pclsidHandler,lpfnCallback,nStreams,ppavi,plpOptions);
  1419. LocalFree(HLOCAL(wszFile));
  1420. end;
  1421. else
  1422. result := AVISaveV(szFile,pclsidHandler,lpfnCallback,nStreams,ppavi,plpOptions);
  1423. end;
  1424. end;
  1425. end;
  1426. {--------------------------------------------------------------------------------}
  1427. function AVISaveVW; external AVILIBDLL name 'AVISaveVW';
  1428. function AVISaveOptions; external AVILIBDLL name 'AVISaveOptions';
  1429. function CreateEditableStream; external AVILIBDLL name 'CreateEditableStream';
  1430. function AVISaveOptionsFree; external AVILIBDLL name 'AVISaveOptionsFree';
  1431. function AVIBuildFilter; external AVILIBDLL name 'AVIBuildFilter';
  1432. function AVIMakeFileFromStreams; external AVILIBDLL name 'AVISaveOptionsFree';
  1433. function AVIMakeStreamFromClipboard; external AVILIBDLL name 'AVIMakeFileFromStreams';
  1434. function AVIPutFileOnClipboard; external AVILIBDLL name 'AVIPutFileOnClipboard';
  1435. function AVIGetFromClipboard; external AVILIBDLL name 'AVIGetFromClipboard';
  1436. function AVIClearClipboard; external AVILIBDLL name 'AVIClearClipboard';
  1437. function EditStreamCut; external AVILIBDLL name 'EditStreamCut';
  1438. function EditStreamCopy; external AVILIBDLL name 'EditStreamCopy';
  1439. function EditStreamPaste; external AVILIBDLL name 'EditStreamPaste';
  1440. function EditStreamClone; external AVILIBDLL name 'EditStreamClone';
  1441. function EditStreamSetName; external AVILIBDLL name 'EditStreamSetName';
  1442. function EditStreamSetInfo; external AVILIBDLL name 'EditStreamSetInfo';
  1443. {---------End AVIWriter-----------------}
  1444. {---------------------------------------------------------------------------------}
  1445. {---------Begin AVICAP window-----------}
  1446. const
  1447. AVICAP32 = 'AVICAP32.dll';
  1448. VFWDLL32 = 'MSVFW32.DLL';
  1449. (* Externals from AVICAP.DLL *)
  1450. function capGetDriverDescription; external AVICAP32 name 'capGetDriverDescriptionA';
  1451. function capCreateCaptureWindow; external AVICAP32 name 'capCreateCaptureWindowA';
  1452. (* Message crackers for above *)
  1453. function capSetCallbackOnError(hwnd:THandle; fpProc:TCAPERRORCALLBACK):LongInt;
  1454. begin
  1455. Result := SendMessage(hwnd,WM_CAP_SET_CALLBACK_ERROR, 0,LPARAM(@fpProc));
  1456. end;
  1457. function capSetCallbackOnStatus(hwnd:THandle; fpProc:TCAPSTATUSCALLBACK):LongInt;
  1458. begin
  1459. Result := SendMessage(hwnd,WM_CAP_SET_CALLBACK_STATUS, 0, LPARAM(@fpProc));
  1460. end;
  1461. function capSetCallbackOnYield (hwnd:THandle; fpProc:TCAPYIELDCALLBACK):LongInt;
  1462. begin
  1463. Result := SendMessage(hwnd, WM_CAP_SET_CALLBACK_YIELD, 0, LPARAM(@fpProc));
  1464. end;
  1465. function capSetCallbackOnFrame (hwnd:THandle; fpProc:TCAPVIDEOSTREAMCALLBACK):LongInt;
  1466. begin
  1467. Result := SendMessage(hwnd, WM_CAP_SET_CALLBACK_FRAME, 0,LPARAM( @fpProc));
  1468. end;
  1469. function capSetCallbackOnVideoStream(hwnd:THandle; fpProc:TCAPVIDEOSTREAMCALLBACK):LongInt;
  1470. begin
  1471. Result := SendMessage(hwnd, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, LPARAM(@fpProc));
  1472. end;
  1473. function capSetCallbackOnWaveStream (hwnd:THandle; fpProc:TCAPWAVESTREAMCALLBACK):LongInt;
  1474. begin
  1475. Result := SendMessage(hwnd, WM_CAP_SET_CALLBACK_WAVESTREAM, 0, LPARAM(@fpProc));
  1476. end;
  1477. function capSetCallbackOnCapControl (hwnd:THandle; fpProc:TCAPCONTROLCALLBACK):longint;
  1478. begin
  1479. Result := SendMessage(hwnd, WM_CAP_SET_CALLBACK_CAPCONTROL, 0, LPARAM(@fpProc));
  1480. end;
  1481. function capSetUserData(hwnd:THandle; lUser:LongInt):LongInt;
  1482. begin
  1483. Result := SendMessage(hwnd, WM_CAP_SET_USER_DATA, 0, lUser);
  1484. end;
  1485. function capGetUserData(hwnd:THandle):LongInt;
  1486. begin
  1487. Result := SendMessage(hwnd, WM_CAP_GET_USER_DATA, 0, 0);
  1488. end;
  1489. function capDriverConnect(hwnd:THandle; I: Word):boolean;
  1490. begin
  1491. Result :=boolean(SendMessage(hwnd, WM_CAP_DRIVER_CONNECT, WPARAM(I), 0));
  1492. end;
  1493. function capDriverDisconnect(hwnd:THandle):Boolean;
  1494. begin
  1495. Result :=boolean(SendMessage(hwnd, WM_CAP_DRIVER_DISCONNECT, 0, 0));
  1496. end;
  1497. function capDriverGetName(hwnd:THandle; szName:PChar; wSize:Word):boolean;
  1498. begin
  1499. Result :=boolean(SendMessage(hwnd, WM_CAP_DRIVER_GET_NAME, WPARAM(wSize), LPARAM( szName)));
  1500. end;
  1501. function capDriverGetVersion(hwnd:THandle; szVer:PChar; wSize:Word):boolean;
  1502. begin
  1503. Result :=boolean(SendMessage(hwnd, WM_CAP_DRIVER_GET_VERSION, WPARAM(wSize),LPARAM( szVer)));
  1504. end;
  1505. function capDriverGetCaps(hwnd:THandle; s:pCapDriverCaps; wSize:Word):boolean;
  1506. begin
  1507. Result :=boolean(SendMessage(hwnd, WM_CAP_DRIVER_GET_CAPS, WPARAM(wSize),LPARAM(s)));
  1508. end;
  1509. function capFileSetCaptureFile(hwnd:THandle; szName:PChar):boolean;
  1510. begin
  1511. Result :=boolean(SendMessage(hwnd, WM_CAP_FILE_SET_CAPTURE_FILE, 0, LPARAM(szName)));
  1512. end;
  1513. function capFileGetCaptureFile(hwnd:THandle; szName:PChar; wSize:Word):Boolean;
  1514. begin
  1515. Result :=boolean(SendMessage(hwnd, WM_CAP_FILE_GET_CAPTURE_FILE, wSize, LPARAM(szName)));
  1516. end;
  1517. function capFileAlloc(hwnd:THandle; dwSize:DWord):boolean;
  1518. begin
  1519. Result :=boolean(SendMessage(hwnd, WM_CAP_FILE_ALLOCATE, 0, LPARAM(dwSize)));
  1520. end;
  1521. function capFileSaveAs(hwnd:THandle; szName:Pchar):Boolean;
  1522. begin
  1523. Result :=boolean(SendMessage(hwnd, WM_CAP_FILE_SAVEAS, 0,LPARAM(szName)));
  1524. end;
  1525. function capFileSetInfoChunk(hwnd:THandle; lpInfoChunk:pCapInfoChunk):boolean;
  1526. begin
  1527. Result :=boolean(SendMessage(hwnd, WM_CAP_FILE_SET_INFOCHUNK, 0, LPARAM(lpInfoChunk)));
  1528. end;
  1529. function capFileSaveDIB(hwnd:THandle; szName:Pchar):Boolean;
  1530. begin
  1531. Result :=Boolean(SendMessage(hwnd, WM_CAP_FILE_SAVEDIB, 0,LPARAM(szName)));
  1532. end;
  1533. function capEditCopy(hwnd:THandle):Boolean;
  1534. begin
  1535. Result :=boolean(SendMessage(hwnd, WM_CAP_EDIT_COPY, 0, 0));
  1536. end;
  1537. function capSetAudioFormat(hwnd:THandle; s:PWaveFormatEx; wSize:Word):boolean;
  1538. begin
  1539. Result :=boolean(SendMessage(hwnd, WM_CAP_SET_AUDIOFORMAT, WPARAM(wSize),LPARAM(s)));
  1540. end;
  1541. function capGetAudioFormat(hwnd:THandle; s:PWaveFormatEx; wSize:Word):DWORD;
  1542. begin
  1543. Result :=DWORD( SendMessage(hwnd, WM_CAP_GET_AUDIOFORMAT, WPARAM(wSize),LPARAM(s)));
  1544. end;
  1545. function capGetAudioFormatSize(hwnd:THandle):DWORD;
  1546. begin
  1547. Result := DWORD(SendMessage(hwnd, WM_CAP_GET_AUDIOFORMAT, 0, 0));
  1548. end;
  1549. function capDlgVideoFormat(hwnd:THandle):boolean;
  1550. begin
  1551. Result :=boolean(SendMessage(hwnd, WM_CAP_DLG_VIDEOFORMAT, 0, 0));
  1552. end;
  1553. function capDlgVideoSource(hwnd:THandle):boolean;
  1554. begin
  1555. Result :=boolean (SendMessage(hwnd, WM_CAP_DLG_VIDEOSOURCE, 0, 0));
  1556. end;
  1557. function capDlgVideoDisplay(hwnd:THandle):boolean;
  1558. begin
  1559. Result :=boolean(SendMessage(hwnd, WM_CAP_DLG_VIDEODISPLAY, 0, 0));
  1560. end;
  1561. function capDlgVideoCompression(hwnd:THandle):boolean;
  1562. begin
  1563. Result :=boolean(SendMessage(hwnd, WM_CAP_DLG_VIDEOCOMPRESSION, 0, 0));
  1564. end;
  1565. function capGetVideoFormat(hwnd:THandle; s:pBitmapInfo; wSize:Word):DWord;
  1566. begin
  1567. Result := DWord(SendMessage(hwnd, WM_CAP_GET_VIDEOFORMAT, Wparam(wSize), LPARAM(s)));
  1568. end;
  1569. function capGetVideoFormatSize(hwnd:THandle):DWord;
  1570. begin
  1571. Result := DWord(SendMessage(hwnd, WM_CAP_GET_VIDEOFORMAT, 0, 0));
  1572. end;
  1573. function capSetVideoFormat(hwnd:THandle; s:PBitmapInfo; wSize:Word):Boolean;
  1574. begin
  1575. Result :=boolean(SendMessage(hwnd, WM_CAP_SET_VIDEOFORMAT, WPARAM(wSize), LPARAM(s)));
  1576. end;
  1577. function capPreview(hwnd:THandle; f:boolean):boolean;
  1578. begin
  1579. Result :=boolean(SendMessage(hwnd, WM_CAP_SET_PREVIEW, WPARAM(f), 0));
  1580. end;
  1581. function capPreviewRate(hwnd:THandle; wMS:Word):boolean;
  1582. begin
  1583. Result :=boolean(SendMessage(hwnd, WM_CAP_SET_PREVIEWRATE, WPARAM(wMS), 0));
  1584. end;
  1585. function capOverlay(hwnd:THandle; f:boolean):boolean;
  1586. begin
  1587. Result :=boolean(SendMessage(hwnd, WM_CAP_SET_OVERLAY, WPARAM(f), 0));
  1588. end;
  1589. function capPreviewScale(hwnd:THandle; f:boolean):Boolean;
  1590. begin
  1591. Result :=boolean(SendMessage(hwnd, WM_CAP_SET_SCALE,WPARAM(f), 0));
  1592. end;
  1593. function capGetStatus(hwnd:THandle; s:PCapStatus; wSize:Word):boolean;
  1594. begin
  1595. Result :=boolean(SendMessage(hwnd, WM_CAP_GET_STATUS, WPARAM(wSize),LPARAM(s)));
  1596. end;
  1597. function capSetScrollPos(hwnd:THandle; lpP:pPoint):Boolean;
  1598. begin
  1599. Result :=boolean(SendMessage(hwnd, WM_CAP_SET_SCROLL, 0, LParam(lpP)));
  1600. end;
  1601. function capGrabFrame(hwnd:THandle):boolean;
  1602. begin
  1603. Result :=boolean(SendMessage(hwnd, WM_CAP_GRAB_FRAME, 0, 0));
  1604. end;
  1605. function capGrabFrameNoStop(hwnd:THandle):boolean;
  1606. begin
  1607. Result :=boolean(SendMessage(hwnd, WM_CAP_GRAB_FRAME_NOSTOP, 0, 0));
  1608. end;
  1609. function capCaptureSequence(hwnd:THandle):boolean;
  1610. begin
  1611. Result :=boolean(SendMessage(hwnd, WM_CAP_SEQUENCE, 0, 0));
  1612. end;
  1613. function capCaptureSequenceNoFile(hwnd:THandle):boolean;
  1614. begin
  1615. Result :=Boolean(SendMessage(hwnd, WM_CAP_SEQUENCE_NOFILE, 0, 0));
  1616. end;
  1617. function capCaptureStop(hwnd:THandle):boolean;
  1618. begin
  1619. Result :=boolean(SendMessage(hwnd, WM_CAP_STOP, 0, 0));
  1620. end;
  1621. function capCaptureAbort(hwnd:THandle):Boolean;
  1622. begin
  1623. Result :=boolean(SendMessage(hwnd, WM_CAP_ABORT, 0, 0));
  1624. end;
  1625. function capCaptureSingleFrameOpen(hwnd:THandle):boolean;
  1626. begin
  1627. Result :=boolean(SendMessage(hwnd, WM_CAP_SINGLE_FRAME_OPEN, 0, 0));
  1628. end;
  1629. function capCaptureSingleFrameClose(hwnd:THandle):boolean;
  1630. begin
  1631. Result :=boolean(SendMessage(hwnd, WM_CAP_SINGLE_FRAME_CLOSE, 0, 0));
  1632. end;
  1633. function capCaptureSingleFrame(hwnd:THandle):boolean;
  1634. begin
  1635. Result :=Boolean(SendMessage(hwnd, WM_CAP_SINGLE_FRAME, 0, 0));
  1636. end;
  1637. function capCaptureGetSetup(hwnd:THandle; s:pCaptureParms; wSize:Word):boolean;
  1638. begin
  1639. Result :=boolean(SendMessage(hwnd, WM_CAP_GET_SEQUENCE_SETUP, WPARAM(wSize),LPARAM(s)));
  1640. end;
  1641. function capCaptureSetSetup(hwnd:THandle; s:pCaptureParms; wSize:Word):boolean;
  1642. begin
  1643. Result := Boolean (SendMessage(hwnd, WM_CAP_SET_SEQUENCE_SETUP, WParam(wSize),LParam(s)));
  1644. end;
  1645. function capSetMCIDeviceName(hwnd:THandle; szName:Pchar):Boolean;
  1646. begin
  1647. Result :=boolean(SendMessage(hwnd, WM_CAP_SET_MCI_DEVICE, 0, LParam(szName)));
  1648. end;
  1649. function capGetMCIDeviceName(hwnd:THandle; szName:Pchar; wSize:Word):Boolean;
  1650. begin
  1651. Result :=boolean(SendMessage(hwnd, WM_CAP_GET_MCI_DEVICE, Wparam(wSize), LPARAM(szName)));
  1652. end;
  1653. function capPaletteOpen(hwnd:THandle; szName:PChar):Boolean;
  1654. begin
  1655. Result :=boolean(SendMessage(hwnd, WM_CAP_PAL_OPEN, 0, LParam(szName)));
  1656. end;
  1657. function capPaletteSave(hwnd:THandle; szName:PChar):boolean;
  1658. begin
  1659. Result :=boolean(SendMessage(hwnd, WM_CAP_PAL_SAVE, 0,LParam(szName)));
  1660. end;
  1661. function capPalettePaste(hwnd:THandle):Boolean;
  1662. begin
  1663. Result :=boolean(SendMessage(hwnd, WM_CAP_PAL_PASTE, 0, 0));
  1664. end;
  1665. function capPaletteAuto(hwnd:THandle; iFrames:Word; iColors:word):Boolean;
  1666. begin
  1667. Result :=boolean(SendMessage(hwnd, WM_CAP_PAL_AUTOCREATE, WPARAM(iFrames),LPARAM(iColors)));
  1668. end;
  1669. function capPaletteManual(hwnd:THandle; fGrab:Word; iColors:word):Boolean;
  1670. begin
  1671. Result :=boolean(SendMessage(hwnd, WM_CAP_PAL_MANUALCREATE, WPARAM(fGrab),LPARAM(iColors)));
  1672. end;
  1673. {== DrawDib functions ========================================================}
  1674. {-- DrawDibOpen() ------------------------------------------------------------}
  1675. function DrawDibOpen: HDRAWDIB; stdcall; external VFWDLL32;
  1676. {-- DrawDibClose() -----------------------------------------------------------}
  1677. function DrawDibClose(hdd: HDRAWDIB): BOOL; stdcall; external VFWDLL32;
  1678. {-- DrawDibGetBuffer() -------------------------------------------------------}
  1679. function DrawDibGetBuffer(hdd: HDRAWDIB; lpbi: PBITMAPINFOHEADER; dwSize: DWORD; dwFlags: DWORD): Pointer; stdcall; external VFWDLL32;
  1680. {-- DrawDibGetPalette() - get the palette used for drawing DIBs --------------}
  1681. function DrawDibGetPalette(hdd: HDRAWDIB): HPALETTE; stdcall; external VFWDLL32;
  1682. {-- DrawDibSetPalette() - set the palette used for drawing DIBs --------------}
  1683. function DrawDibSetPalette(hdd: HDRAWDIB; hpal: HPALETTE): BOOL; stdcall; external VFWDLL32;
  1684. {-- DrawDibChangePalette() ---------------------------------------------------}
  1685. function DrawDibChangePalette(hdd: HDRAWDIB; iStart, iLen: integer; lppe: PPALETTEENTRY): BOOL; stdcall; external VFWDLL32;
  1686. {-- DrawDibRealize() - realize the palette in a HDD --------------------------}
  1687. function DrawDibRealize(hdd: HDRAWDIB; hdc: HDC; fBackground: BOOL): UINT; stdcall; external VFWDLL32;
  1688. {-- DrawDibStart() - start of streaming playback -----------------------------}
  1689. function DrawDibStart(hdd: HDRAWDIB; rate: DWORD): BOOL; stdcall; external VFWDLL32;
  1690. {-- DrawDibStop() - start of streaming playback ------------------------------}
  1691. function DrawDibStop(hdd: HDRAWDIB): BOOL; stdcall; external VFWDLL32;
  1692. {-- DrawDibBegin() - prepare to draw -----------------------------------------}
  1693. function DrawDibBegin(hdd:HDRAWDIB;hdc:HDC;dxDst:integer;dyDst:integer;
  1694. lpbi:PBITMAPINFOHEADER;dxSrc:integer;dySrc:integer;
  1695. wFlags:UINT): BOOL; stdcall; external VFWDLL32;
  1696. {-- DrawDibDraw() - actually draw a DIB to the screen ------------------------}
  1697. function DrawDibDraw(hdd:HDRAWDIB;hdc:HDC;xDst:integer;yDst:integer;
  1698. dxDst:integer;dyDst:integer;lpbi:PBITMAPINFOHEADER;
  1699. lpBits:Pointer;xSrc:integer;ySrc:integer;
  1700. dxSrc:integer;dySrc:integer;
  1701. wFlags:UINT): BOOL; stdcall; external VFWDLL32;
  1702. {-- DrawDibEnd() -------------------------------------------------------------}
  1703. function DrawDibEnd(hdd: HDRAWDIB): BOOL; stdcall; external VFWDLL32;
  1704. {-- DrawDibTime() - for debugging purposes only ------------------------------}
  1705. function DrawDibTime(hdd: HDRAWDIB; lpddtime: PDRAWDIBTIME): BOOL; stdcall; external VFWDLL32;
  1706. {-- Display profiling --------------------------------------------------------}
  1707. function DrawDibProfileDisplay(lpbi: PBITMAPINFOHEADER): DWORD; stdcall; external VFWDLL32;
  1708. // Installable Compression Manager
  1709. function MKFOURCC( ch0, ch1, ch2, ch3: Char ): FOURCC;
  1710. begin
  1711. Result := (DWord(Ord(ch0))) or (DWord(Ord(ch1)) shl 8) or
  1712. (DWord(Ord(ch2)) shl 16) or(DWord(Ord(ch3)) shl 24);
  1713. end;
  1714. function mmioFOURCC( ch0, ch1, ch2, ch3: Char ): FOURCC;
  1715. begin
  1716. Result := MKFOURCC(ch0,ch1,ch2,ch3);
  1717. end;
  1718. function aviTWOCC(ch0, ch1: Char): TWOCC;
  1719. begin
  1720. Result := (Word(Ord(ch0))) or (Word(Ord(ch1)) shl 8);
  1721. end;
  1722. {-- Query macros -------------------------------------------------------------}
  1723. function ICQueryAbout(hic: HIC): BOOL;
  1724. begin
  1725. Result := ICSendMessage(hic, ICM_ABOUT, -1, ICMF_ABOUT_QUERY) = ICERR_OK;
  1726. end;
  1727. function ICAbout(hic: HIC; hwnd: HWND): DWORD;
  1728. begin
  1729. Result := ICSendMessage(hic, ICM_ABOUT, hwnd, 0);
  1730. end;
  1731. function ICQueryConfigure(hic: HIC): BOOL;
  1732. begin
  1733. Result := ICSendMessage(hic, ICM_CONFIGURE, -1, ICMF_CONFIGURE_QUERY) = ICERR_OK;
  1734. end;
  1735. function ICConfigure(hic: HIC; hwnd: HWND): DWORD;
  1736. begin
  1737. Result := ICSendMessage(hic, ICM_CONFIGURE, hwnd, 0);
  1738. end;
  1739. {-- Get/Set state macros -----------------------------------------------------}
  1740. function ICGetState(hic: HIC; pv: Pointer; cb: DWORD): DWORD;
  1741. begin
  1742. Result := ICSendMessage(hic, ICM_GETSTATE, DWORD(pv), cb);
  1743. end;
  1744. function ICSetState(hic: HIC; pv: Pointer; cb: DWORD): DWORD;
  1745. begin
  1746. Result := ICSendMessage(hic, ICM_SETSTATE, DWORD(pv), cb);
  1747. end;
  1748. function ICGetStateSize(hic: HIC): DWORD;
  1749. begin
  1750. Result := ICGetState(hic, nil, 0);
  1751. end;
  1752. {-- Get value macros ---------------------------------------------------------}
  1753. function ICGetDefaultQuality(hic: HIC): DWORD;
  1754. begin
  1755. ICSendMessage(hic, ICM_GETDEFAULTQUALITY, DWORD(@Result), sizeof(Result));
  1756. end;
  1757. function ICGetDefaultKeyFrameRate(hic: HIC): DWORD;
  1758. begin
  1759. ICSendMessage(hic, ICM_GETDEFAULTKEYFRAMERATE, DWORD(@Result), sizeof(Result));
  1760. end;
  1761. {-- Draw window macro --------------------------------------------------------}
  1762. function ICDrawWindow(hic: HIC; prc: PRECT): DWORD;
  1763. begin
  1764. Result := ICSendMessage(hic, ICM_DRAW_WINDOW, DWORD(prc), sizeof(prc^));
  1765. end;
  1766. {-- ICCompressBegin() - start compression from a source fmt to a dest fmt ----}
  1767. function ICCompressBegin(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  1768. begin
  1769. Result := ICSendMessage(hic, ICM_COMPRESS_BEGIN, DWORD(lpbiInput), DWORD(lpbiOutput));
  1770. end;
  1771. {-- ICCompressQuery() - determines if compression from src to dst is supp ----}
  1772. function ICCompressQuery(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  1773. begin
  1774. Result := ICSendMessage(hic, ICM_COMPRESS_QUERY, DWORD(lpbiInput), DWORD(lpbiOutput));
  1775. end;
  1776. {-- ICCompressGetFormat() - get the output format (fmt of compressed) --------}
  1777. // if lpbiOutput is nil return the size in bytes needed for format.
  1778. function ICCompressGetFormat(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  1779. begin
  1780. Result := ICSendMessage(hic, ICM_COMPRESS_GET_FORMAT, DWORD(lpbiInput), DWORD(lpbiOutput));
  1781. end;
  1782. function ICCompressGetFormatSize(hic: HIC; lpbi: PBITMAPINFOHEADER): DWORD;
  1783. begin
  1784. Result := ICCompressGetFormat(hic, lpbi, nil);
  1785. end;
  1786. {-- ICCompressSize() - return the maximal size of a compressed frame ---------}
  1787. function ICCompressGetSize(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  1788. begin
  1789. Result := ICSendMessage(hic, ICM_COMPRESS_GET_SIZE, DWORD(lpbiInput), DWORD(lpbiOutput));
  1790. end;
  1791. function ICCompressEnd(hic: HIC): DWORD;
  1792. begin
  1793. Result := ICSendMessage(hic, ICM_COMPRESS_END, 0, 0);
  1794. end;
  1795. {-- ICDecompressBegin() - start compression from src fmt to a dest fmt -------}
  1796. function ICDecompressBegin(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  1797. begin
  1798. Result := ICSendMessage(hic, ICM_DECOMPRESS_BEGIN, DWORD(lpbiInput), DWORD(lpbiOutput));
  1799. end;
  1800. {-- ICDecompressQuery() - determines if compression is supported -------------}
  1801. function ICDecompressQuery(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  1802. begin
  1803. Result := ICSendMessage(hic, ICM_DECOMPRESS_QUERY, DWORD(lpbiInput), DWORD(lpbiOutput));
  1804. end;
  1805. {-- ICDecompressGetFormat - get the output fmt (fmt of uncompressed data) ----}
  1806. // if lpbiOutput is NULL return the size in bytes needed for format.
  1807. function ICDecompressGetFormat(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  1808. begin
  1809. Result := ICSendMessage(hic, ICM_DECOMPRESS_GET_FORMAT, DWORD(lpbiInput), DWORD(lpbiOutput));
  1810. end;
  1811. function ICDecompressGetFormatSize(hic: HIC; lpbi: PBITMAPINFOHEADER): DWORD;
  1812. begin
  1813. Result := ICDecompressGetFormat(hic, lpbi, nil);
  1814. end;
  1815. {-- ICDecompressGetPalette() - get the output palette ------------------------}
  1816. function ICDecompressGetPalette(hic: HIC; lpbiInput, lpbiOutput: PBITMAPINFOHEADER): DWORD;
  1817. begin
  1818. Result := ICSendMessage(hic, ICM_DECOMPRESS_GET_PALETTE, DWORD(lpbiInput), DWORD(lpbiOutput));
  1819. end;
  1820. function ICDecompressSetPalette(hic: HIC; lpbiPalette: PBITMAPINFOHEADER): DWORD;
  1821. begin
  1822. Result := ICSendMessage(hic, ICM_DECOMPRESS_SET_PALETTE, DWORD(lpbiPalette), 0);
  1823. end;
  1824. function ICDecompressEnd(hic: HIC): DWORD;
  1825. begin
  1826. Result := ICSendMessage(hic, ICM_DECOMPRESS_END, 0, 0);
  1827. end;
  1828. {-- ICM function declarations ------------------------------------------------}
  1829. function ICInfo(fccType, fccHandler: DWORD; lpicinfo: PICINFO):BOOL; stdcall; external VFWDLL32;
  1830. function ICInstall(fccType, fccHandler: DWORD; lParam: LPARAM; szDesc: LPSTR; wFlags: UINT):BOOL; stdcall; external VFWDLL32;
  1831. function ICRemove(fccType, fccHandler: DWORD; wFlags: UINT):BOOL; stdcall; external VFWDLL32;
  1832. function ICGetInfo(hic: HIC; picinfo: PICINFO; cb: DWORD):DWORD; stdcall; external VFWDLL32;
  1833. function ICOpen(fccType, fccHandler: DWORD; wMode: UINT):HIC; stdcall; external VFWDLL32;
  1834. function ICOpenFunction(fccType, fccHandler: DWORD; wMode: UINT; lpfnHandler: TFarProc):HIC; stdcall; external VFWDLL32;
  1835. function ICClose(hic: HIC):DWORD; stdcall; external VFWDLL32;
  1836. function ICSendMessage(hic: HIC; msg: UINT; dw1, dw2: integer):DWORD; stdcall; external VFWDLL32;
  1837. {== Compression functions ====================================================}
  1838. {-- ICCompress() - compress a single frame -----------------------------------}
  1839. function ICCompress(hic:HIC;dwFlags:DWORD; // flags
  1840. lpbiOutput:PBITMAPINFOHEADER; // output format
  1841. lpData:Pointer; // output data
  1842. lpbiInput:PBITMAPINFOHEADER; // format of frame to compress
  1843. lpBits:Pointer; // frame data to compress
  1844. lpckid:PDWORD; // ckid for data in AVI file
  1845. lpdwFlags:PDWORD; // flags in the AVI index.
  1846. lFrameNum:DWORD; // frame number of seq.
  1847. dwFrameSize:DWORD; // reqested size in bytes. (if non zero)
  1848. dwQuality:DWORD; // quality within one frame
  1849. lpbiPrev:PBITMAPINFOHEADER; // format of previous frame
  1850. lpPrev:Pointer // previous frame
  1851. ):DWORD; cdecl; external VFWDLL32;
  1852. {== Decompression functions ==================================================}
  1853. {-- ICDecompress() - decompress a single frame -------------------------------}
  1854. function ICDecompress(hic:HIC;dwFlags:DWORD; // flags (from AVI index...)
  1855. lpbiFormat:PBITMAPINFOHEADER; // BITMAPINFO of compressed data
  1856. // biSizeImage has the chunk size
  1857. lpData:Pointer; // data
  1858. lpbi:PBITMAPINFOHEADER; // DIB to decompress to
  1859. lpBits:Pointer): DWORD; cdecl; external VFWDLL32;
  1860. {== Drawing functions ========================================================}
  1861. {-- ICDrawBegin() - start decompressing data with fmt directly to screen -----}
  1862. // return zero if the decompressor supports drawing.
  1863. function ICDrawBegin(hic:HIC;dwFlags:DWORD; // flags
  1864. hpal:HPALETTE; // palette to draw with
  1865. hwnd:HWND; // window to draw to
  1866. hdc:HDC; // HDC to draw to
  1867. xDst:integer; // destination rectangle
  1868. yDst:integer;dxDst:integer;dyDst:integer;
  1869. lpbi:PBITMAPINFOHEADER; // format of frame to draw
  1870. xSrc:integer; // source rectangle
  1871. ySrc:integer;dxSrc:integer;dySrc:integer;
  1872. dwRate:DWORD; // frames/second = (dwRate/dwScale)
  1873. dwScale:DWORD): DWORD; cdecl; external VFWDLL32;
  1874. {-- ICDraw() - decompress data directly to the screen ------------------------}
  1875. function ICDraw(hic:HIC; dwFlags:DWORD; // flags
  1876. lpFormat:Pointer; // format of frame to decompress
  1877. lpData:Pointer; // frame data to decompress
  1878. cbData:DWORD; // size of data
  1879. lTime:DWORD // time to draw this frame
  1880. ): DWORD; cdecl; external VFWDLL32;
  1881. {== Helper routines for DrawDib and MCIAVI... ================================}
  1882. function ICLocate(fccType, fccHandler: DWORD; lpbiIn, lpbiOut: PBITMAPINFOHEADER; wFlags: WORD): HIC; stdcall; external VFWDLL32;
  1883. function ICGetDisplayFormat(hic: HIC; lpbiIn, lpbiOut: PBITMAPINFOHEADER; BitDepth: integer; dx, dy: integer): HIC; stdcall; external VFWDLL32;
  1884. {== Higher level functions ===================================================}
  1885. function ICImageCompress(hic:HIC; // compressor to use
  1886. uiFlags:UINT; // flags (none yet)
  1887. lpbiIn:PBITMAPINFO; // format to compress from
  1888. lpBits:Pointer; // data to compress
  1889. lpbiOut:PBITMAPINFO; // compress to this (NULL ==> default)
  1890. lQuality:DWORD; // quality to use
  1891. plSize:PDWORD // compress to this size (0=whatever)
  1892. ): THANDLE; stdcall; external VFWDLL32;
  1893. function ICImageDecompress(hic:HIC; // compressor to use
  1894. uiFlags:UINT; // flags (none yet)
  1895. lpbiIn:PBITMAPINFO; // format to decompress from
  1896. lpBits:Pointer; // data to decompress
  1897. lpbiOut:PBITMAPINFO // decompress to this (NULL ==> default)
  1898. ): THANDLE; stdcall; external VFWDLL32;
  1899. {-- ICCompressorChoose() - allows user to choose compressor, quality etc... --}
  1900. function ICCompressorChoose(hwnd:HWND; // parent window for dialog
  1901. uiFlags:UINT; // flags
  1902. pvIn:Pointer; // input format (optional)
  1903. lpData:Pointer; // input data (optional)
  1904. pc:PCOMPVARS; // data about the compressor/dlg
  1905. lpszTitle:LPSTR // dialog title (optional)
  1906. ): BOOL; stdcall; external VFWDLL32;
  1907. function ICSeqCompressFrameStart(pc: PCOMPVARS; lpbiIn: PBITMAPINFO): BOOL; stdcall; external VFWDLL32;
  1908. procedure ICSeqCompressFrameEnd(pc: PCOMPVARS); stdcall; external VFWDLL32;
  1909. function ICSeqCompressFrame(pc:PCOMPVARS; // set by ICCompressorChoose
  1910. uiFlags:UINT; // flags
  1911. lpBits:Pointer; // input DIB bits
  1912. pfKey:PBOOL; // did it end up being a key frame?
  1913. plSize:PDWORD // size to compress to/of returned image
  1914. ): Pointer; stdcall; external VFWDLL32;
  1915. procedure ICCompressorFree(pc: PCOMPVARS); stdcall; external VFWDLL32;
  1916. {-- ICDecompressEx() - decompress a single frame -----------------------------}
  1917. function ICDecompressEx(hic:HIC;dwFlags:DWORD;lpbiSrc:PBITMAPINFOHEADER;
  1918. lpSrc:Pointer;xSrc:integer;ySrc:integer;
  1919. dxSrc:integer;dySrc:integer;lpbiDst:PBITMAPINFOHEADER;
  1920. lpDst:Pointer;xDst:integer;yDst:integer;
  1921. dxDst:integer;dyDst:integer): DWORD; stdcall;
  1922. var ic:TICDECOMPRESSEX;
  1923. begin
  1924. ic.dwFlags := dwFlags;
  1925. ic.lpbiSrc := lpbiSrc;
  1926. ic.lpSrc := lpSrc;
  1927. ic.xSrc := xSrc;
  1928. ic.ySrc := ySrc;
  1929. ic.dxSrc := dxSrc;
  1930. ic.dySrc := dySrc;
  1931. ic.lpbiDst := lpbiDst;
  1932. ic.lpDst := lpDst;
  1933. ic.xDst := xDst;
  1934. ic.yDst := yDst;
  1935. ic.dxDst := dxDst;
  1936. ic.dyDst := dyDst;
  1937. // note that ICM swaps round the length and pointer
  1938. // length in lparam2, pointer in lparam1
  1939. Result := ICSendMessage(hic, ICM_DECOMPRESSEX, DWORD(@ic), sizeof(ic));
  1940. end;
  1941. {-- ICDecompressExBegin() - start compression from a src fmt to a dest fmt ---}
  1942. function ICDecompressExBegin(hic:HIC;dwFlags:DWORD;lpbiSrc:PBITMAPINFOHEADER;
  1943. lpSrc:Pointer;xSrc:integer;ySrc:integer;
  1944. dxSrc:integer;dySrc:integer;lpbiDst:PBITMAPINFOHEADER;
  1945. lpDst:Pointer;xDst:integer;yDst:integer;
  1946. dxDst:integer;dyDst:integer): DWORD; stdcall;
  1947. var ic:TICDECOMPRESSEX;
  1948. begin
  1949. ic.dwFlags := dwFlags;
  1950. ic.lpbiSrc := lpbiSrc;
  1951. ic.lpSrc := lpSrc;
  1952. ic.xSrc := xSrc;
  1953. ic.ySrc := ySrc;
  1954. ic.dxSrc := dxSrc;
  1955. ic.dySrc := dySrc;
  1956. ic.lpbiDst := lpbiDst;
  1957. ic.lpDst := lpDst;
  1958. ic.xDst := xDst;
  1959. ic.yDst := yDst;
  1960. ic.dxDst := dxDst;
  1961. ic.dyDst := dyDst;
  1962. // note that ICM swaps round the length and pointer
  1963. // length in lparam2, pointer in lparam1
  1964. Result := ICSendMessage(hic, ICM_DECOMPRESSEX_BEGIN, DWORD(@ic), sizeof(ic));
  1965. end;
  1966. {-- ICDecompressExQuery() ----------------------------------------------------}
  1967. function ICDecompressExQuery(hic:HIC;
  1968. dwFlags:DWORD;
  1969. lpbiSrc:PBITMAPINFOHEADER;
  1970. lpSrc:Pointer; xSrc:integer;
  1971. ySrc:integer; dxSrc:integer;
  1972. dySrc:integer;
  1973. lpbiDst:PBITMAPINFOHEADER;
  1974. lpDst:Pointer; xDst:integer;
  1975. yDst:integer; dxDst:integer;
  1976. dyDst:integer): DWORD; stdcall;
  1977. var ic:TICDECOMPRESSEX;
  1978. begin
  1979. ic.dwFlags := dwFlags;
  1980. ic.lpbiSrc := lpbiSrc;
  1981. ic.lpSrc := lpSrc;
  1982. ic.xSrc := xSrc;
  1983. ic.ySrc := ySrc;
  1984. ic.dxSrc := dxSrc;
  1985. ic.dySrc := dySrc;
  1986. ic.lpbiDst := lpbiDst;
  1987. ic.lpDst := lpDst;
  1988. ic.xDst := xDst;
  1989. ic.yDst := yDst;
  1990. ic.dxDst := dxDst;
  1991. ic.dyDst := dyDst;
  1992. // note that ICM swaps round the length and pointer
  1993. // length in lparam2, pointer in lparam1
  1994. Result := ICSendMessage(hic, ICM_DECOMPRESSEX_QUERY, DWORD(@ic), sizeof(ic));
  1995. end;
  1996. function ICDecompressExEnd(hic: HIC): DWORD;
  1997. begin
  1998. Result := ICSendMessage(hic, ICM_DECOMPRESSEX_END, 0, 0)
  1999. end;
  2000. function ICDrawSuggestFormat(hic:HIC;
  2001. lpbiIn:PBITMAPINFOHEADER;
  2002. lpbiOut:PBITMAPINFOHEADER;
  2003. dxSrc:integer; dySrc:integer;
  2004. dxDst:integer; dyDst:integer;
  2005. hicDecomp:HIC): DWORD; stdcall;
  2006. var ic:TICDRAWSUGGEST;
  2007. begin
  2008. ic.lpbiIn := lpbiIn;
  2009. ic.lpbiSuggest := lpbiOut;
  2010. ic.dxSrc := dxSrc;
  2011. ic.dySrc := dySrc;
  2012. ic.dxDst := dxDst;
  2013. ic.dyDst := dyDst;
  2014. ic.hicDecompressor := hicDecomp;
  2015. // note that ICM swaps round the length and pointer
  2016. // length in lparam2, pointer in lparam1
  2017. Result := ICSendMessage(hic, ICM_DRAW_SUGGESTFORMAT, DWORD(@ic), sizeof(ic));
  2018. end;
  2019. {-- ICDrawQuery() - determines if the compressor is willing to render fmt ----}
  2020. function ICDrawQuery(hic: HIC; lpbiInput: PBITMAPINFOHEADER): DWORD;
  2021. begin
  2022. Result := ICSendMessage(hic, ICM_DRAW_QUERY, DWORD(lpbiInput), 0);
  2023. end;
  2024. function ICDrawChangePalette(hic: HIC; lpbiInput: PBITMAPINFOHEADER): DWORD;
  2025. begin
  2026. Result := ICSendMessage(hic, ICM_DRAW_CHANGEPALETTE, DWORD(lpbiInput), 0);
  2027. end;
  2028. function ICGetBuffersWanted(hic: HIC; lpdwBuffers: PDWORD): DWORD;
  2029. begin
  2030. Result := ICSendMessage(hic, ICM_GETBUFFERSWANTED, DWORD(lpdwBuffers), 0);
  2031. end;
  2032. function ICDrawEnd(hic: HIC): DWORD;
  2033. begin
  2034. Result := ICSendMessage(hic, ICM_DRAW_END, 0, 0);
  2035. end;
  2036. function ICDrawStart(hic: HIC): DWORD;
  2037. begin
  2038. Result := ICSendMessage(hic, ICM_DRAW_START, 0, 0);
  2039. end;
  2040. function ICDrawStartPlay(hic: HIC; lFrom, lTo: DWORD): DWORD;
  2041. begin
  2042. Result := ICSendMessage(hic, ICM_DRAW_START_PLAY, lFrom, lTo);
  2043. end;
  2044. function ICDrawStop(hic: HIC): DWORD;
  2045. begin
  2046. Result := ICSendMessage(hic, ICM_DRAW_STOP, 0, 0);
  2047. end;
  2048. function ICDrawStopPlay(hic: HIC): DWORD;
  2049. begin
  2050. Result := ICSendMessage(hic, ICM_DRAW_STOP_PLAY, 0, 0);
  2051. end;
  2052. function ICDrawGetTime(hic: HIC; lplTime: PDWORD): DWORD;
  2053. begin
  2054. Result := ICSendMessage(hic, ICM_DRAW_GETTIME, DWORD(lplTime), 0);
  2055. end;
  2056. function ICDrawSetTime(hic: HIC; lTime: DWORD): DWORD;
  2057. begin
  2058. Result := ICSendMessage(hic, ICM_DRAW_SETTIME, lTime, 0);
  2059. end;
  2060. function ICDrawRealize(hic: HIC; hdc: HDC; fBackground: BOOL): DWORD;
  2061. begin
  2062. Result := ICSendMessage(hic, ICM_DRAW_REALIZE, DWORD(hdc), DWORD(fBackground));
  2063. end;
  2064. function ICDrawFlush(hic: HIC): DWORD;
  2065. begin
  2066. Result := ICSendMessage(hic, ICM_DRAW_FLUSH, 0, 0);
  2067. end;
  2068. function ICDrawRenderBuffer(hic: HIC): DWORD;
  2069. begin
  2070. Result := ICSendMessage(hic, ICM_DRAW_RENDERBUFFER, 0, 0);
  2071. end;
  2072. {-- ICSetStatusProc() - Set the status callback function ---------------------}
  2073. // ICMessage is not supported on NT
  2074. function ICSetStatusProc(hic:HIC;dwFlags:DWORD;lParam:DWORD;
  2075. fpfnStatus:TICStatusProc): DWORD; stdcall;
  2076. var ic:TICSETSTATUSPROC;
  2077. begin
  2078. ic.dwFlags := dwFlags;
  2079. ic.lParam := lParam;
  2080. ic.Status := fpfnStatus;
  2081. // note that ICM swaps round the length and pointer
  2082. // length in lparam2, pointer in lparam1
  2083. Result := ICSendMessage(hic, ICM_SET_STATUS_PROC, DWORD(@ic), sizeof(ic));
  2084. end;
  2085. {== Helper routines for DrawDib and MCIAVI... ================================}
  2086. function ICDecompressOpen(fccType, fccHandler: DWORD; lpbiIn, lpbiOut: PBITMAPINFOHEADER): HIC;
  2087. begin
  2088. Result := ICLocate(fccType, fccHandler, lpbiIn, lpbiOut, ICMODE_DECOMPRESS);
  2089. end;
  2090. function ICDrawOpen(fccType, fccHandler: DWORD; lpbiIn: PBITMAPINFOHEADER): HIC;
  2091. begin
  2092. Result := ICLocate(fccType, fccHandler, lpbiIn, nil, ICMODE_DRAW);
  2093. end;
  2094. {---------End AVICAP window-------------}
  2095. {---------Begin TFlatAviter-------------}
  2096. { TFlatAviter }
  2097. constructor TFlatAviter.Create(AOwner : TComponent);
  2098. begin
  2099. inherited Create(AOwner);
  2100. Bitmaps := TList.create;
  2101. VideoTemper := GetTempDirectory+'\~AWTemp.avi';
  2102. FVideoHeight := GetSystemMetrics(SM_CYSCREEN) div 5;
  2103. FVideoWidth := GetSystemMetrics(SM_CXSCREEN) div 5;
  2104. FFrameTime := 1000;
  2105. FPicStretch := true;
  2106. FShowDialog := false;
  2107. FPixelFormat := vd24bit;
  2108. FPixelValue := 24;
  2109. FVideoFile := '';
  2110. FAudioFile := '';
  2111. AVIFileInit;
  2112. end;
  2113. destructor TFlatAviter.Destroy;
  2114. begin
  2115. while Bitmaps.Count > 0 do
  2116. begin
  2117. Bitmap := Bitmaps[0];
  2118. Bitmap.Free;
  2119. Bitmaps.Delete(0);
  2120. end;
  2121. Bitmaps.Free;
  2122. AVIFileExit;
  2123. inherited Destroy;
  2124. end;
  2125. procedure TFlatAviter.AddVideo;
  2126. var PStream : PAVIStream;
  2127. SInfo : TAVIStreamInfo;
  2128. BInfo : PBitmapInfoHeader;
  2129. BISize,Index: Integer;
  2130. BSize : LongInt;
  2131. BBits : Pointer;
  2132. Bitmap, ExtBitmap : TBitmap;
  2133. SXMode, BYMode: LONG;
  2134. // AVIERR,i : integer;
  2135. const
  2136. attrib = OF_WRITE or OF_CREATE OR OF_SHARE_EXCLUSIVE;
  2137. begin
  2138. if (AVIFileOpen(VideoBuffer, PChar(VideoTemper),attrib, nil)<> AVIERR_OK) then
  2139. raise Exception.Create('Failed to create AVI video work file');
  2140. Bitmap := TBitmap.create;
  2141. Bitmap.Height := VideoHeight;
  2142. Bitmap.Width := VideoWidth;
  2143. try
  2144. FillChar(SInfo, sizeof(SInfo), 0);
  2145. SInfo.dwRate := 1000;
  2146. SInfo.dwScale := fFrameTime;
  2147. SInfo.fccType := StreamTypeVideo;
  2148. SInfo.fccHandler := 0;
  2149. SInfo.dwFlags := 0;
  2150. SInfo.dwSuggestedBufferSize := 0;
  2151. SInfo.rcFrame.Right := VideoWidth;
  2152. SInfo.rcFrame.Bottom := VideoHeight;
  2153. if (AVIFileCreateStream(VideoBuffer, pStream, SInfo)<>AVIERR_OK) then
  2154. raise Exception.Create('Failed to create AVI video stream');
  2155. try
  2156. for Index := 0 to Pred(Bitmaps.count) do begin
  2157. try
  2158. BInfo := nil;
  2159. BBits := nil;
  2160. ExtBitmap := Bitmaps[Index];
  2161. ProcessMessages;
  2162. if PicStretch then
  2163. Bitmap.Canvas.StretchDraw(Rect(0,0,VideoWidth,VideoHeight),ExtBitmap)
  2164. else try
  2165. with Bitmap.Canvas do begin
  2166. Brush.Color := ExtBitmap.Canvas.Pixels[0,0];
  2167. Brush.Style := bsSolid;
  2168. FillRect(Rect(0,0,Bitmap.Width,Bitmap.Height));
  2169. Draw(0,0,ExtBitmap);
  2170. end;
  2171. except
  2172. Bitmap.Canvas.StretchDraw(Rect(0,0,VideoWidth,VideoHeight),ExtBitmap);
  2173. end;
  2174. InternalGetDIBSizes(Bitmap.Handle, BISize, BSize);
  2175. if (BISize = 0) then raise Exception.Create('Failed to retrieve bitmap info');
  2176. GetMem(BInfo, BISize);
  2177. GetMem(BBits, BSize);
  2178. InternalGetDIB(Bitmap.Handle, 0, BInfo^, BBits^);
  2179. ProcessMessages;
  2180. if Index = 0 then
  2181. if (AVIStreamSetFormat(pStream, 0, BInfo, BISize)<>AVIERR_OK) then
  2182. raise Exception.Create('Failed to set AVI stream format');
  2183. //AVIERR :=AVIStreamWrite(pStream,i,1,BBits,BSize,AVIIF_KEYFRAME,SL_Written,BY_Written);
  2184. if AVIStreamWrite(PStream,Index,1,BBits,BSize,AVIIF_KEYFRAME,SXMode,BYMode)<>AVIERR_OK then
  2185. raise Exception.Create('Failed to add frame to AVI');//+ inttohex(AVIERR,8)
  2186. if Assigned(FOnProgress) then FOnProgress(self,Index+1);
  2187. finally
  2188. if (BInfo<>nil) then FreeMem(BInfo);
  2189. if (BBits<>nil) then FreeMem(BBits);
  2190. end;
  2191. end;
  2192. if CreateEditableStream(VideoStream,pStream)<>AVIERR_OK then
  2193. raise Exception.Create('Could not create Video Stream');
  2194. finally
  2195. AviStreamRelease(pStream);
  2196. end;
  2197. finally
  2198. Bitmap.free;
  2199. end;
  2200. end;
  2201. procedure TFlatAviter.AddAudio;
  2202. var OutFile : PAVIFILE;
  2203. OutStream : PAVIStream;
  2204. //EXT:STring;
  2205. begin
  2206. if AVIFileOpen(OutFile, PChar(AudioFile),OF_READ,NIL)<> AVIERR_OK then
  2207. raise Exception.Create('Unknown error opening audio file');
  2208. try
  2209. {Ext := ExtractFileExt(UpperCase(AudioFile));
  2210. if Ext='.WAV' then begin
  2211. if (AVIFileGetStream(OutFile, OutStream, StreamTypeAudio, 0)<>AVIERR_OK) then
  2212. raise Exception.Create('Unable to get audio stream');
  2213. end else if Ext='.MID' then begin
  2214. if (AVIFileGetStream(OutFile, OutStream, StreamTypeMidi, 0)<>AVIERR_OK) then
  2215. raise Exception.Create('Unable to get audio stream');
  2216. end; }
  2217. if (AVIFileGetStream(OutFile, OutStream, StreamTypeAudio, 0)<>AVIERR_OK) then
  2218. raise Exception.Create('Unable to get audio stream');
  2219. try
  2220. if (CreateEditableStream(AudioStream, OutStream)<>AVIERR_OK) then
  2221. raise Exception.Create('Failed to create editable AVI audio stream');
  2222. finally
  2223. AviStreamRelease(OutStream);
  2224. end;
  2225. finally
  2226. AviFileRelease(OutFile);
  2227. end;
  2228. end;
  2229. procedure TFlatAviter.MakeVideo;
  2230. var
  2231. ExtBitmap : TBitmap;
  2232. nstreams : integer;
  2233. Index : integer;
  2234. Streams : APAVIStream;
  2235. Options : APAviCompressOptions;
  2236. refcount : integer;
  2237. begin
  2238. AudioStream := nil;
  2239. VideoStream := nil;
  2240. if Bitmaps.count < 1 then raise Exception.Create('No bitmaps on the Bitmaps list');
  2241. for Index := 0 to Pred(Bitmaps.count) do begin
  2242. ExtBitmap := Bitmaps[Index];
  2243. ProcessMessages;
  2244. if not(ExtBitmap is TBitmap) then
  2245. raise Exception.CreateFmt('Bitmaps[%d] is not a TBitmap',[Index]);
  2246. end;
  2247. try
  2248. AddVideo;
  2249. if AudioFile<>'' then begin
  2250. AddAudio;
  2251. nStreams := 2;
  2252. end else begin
  2253. nstreams := 1;
  2254. end;
  2255. Streams[0] := VideoStream;
  2256. Streams[1] := AudioStream;
  2257. Options[0] := nil;
  2258. Options[1] := nil;
  2259. if AVISaveFile(LPCSTR(VideoFile),Nil,Nil,nStreams,Streams,Options)<>AVIERR_OK then
  2260. raise Exception.CreateFmt('Unable to create video file:%s',[VideoFile])
  2261. else if ShowDialog then
  2262. ShowDialogFmt('Create succeed video file:%s%s',[#13,VideoFile],'&OK');
  2263. finally
  2264. if Assigned(VideoStream) then AviStreamRelease(VideoStream);
  2265. if Assigned(AudioStream) then AviStreamRelease(AudioStream);
  2266. try
  2267. repeat
  2268. refcount := AviFileRelease(VideoBuffer);
  2269. until refcount <= 0;
  2270. except
  2271. end;
  2272. DeleteFile(VideoTemper);
  2273. end;
  2274. end;
  2275. function TFlatAviter.InternalGetDIB(Bitmap: HBITMAP; Palette: HPALETTE;
  2276. var BitmapInfo; var Bits): Boolean;
  2277. var OldPal : HPALETTE;
  2278. DC : HDC;
  2279. begin
  2280. OldPal := 0;
  2281. InternalGetBMPHeader(Bitmap, TBitmapInfoHeader(BitmapInfo));//, PixelFmt);
  2282. DC := CreateCompatibleDC(0);
  2283. try
  2284. if (Palette<>0) then begin
  2285. OldPal := SelectPalette(DC, Palette, False);
  2286. RealizePalette(DC);
  2287. end;
  2288. Result := (GetDIBits(DC, Bitmap, 0, abs(TBitmapInfoHeader(BitmapInfo).biHeight),
  2289. @Bits, TBitmapInfo(BitmapInfo), DIB_RGB_COLORS)<>0);
  2290. finally
  2291. if (OldPal<>0) then SelectPalette(DC, OldPal, False);
  2292. DeleteDC(DC);
  2293. end;
  2294. end;
  2295. procedure TFlatAviter.InternalGetDIBSizes(Bitmap: HBITMAP; var HeaderSize: Integer;
  2296. var ImageSize: longInt);
  2297. var Info:TBitmapInfoHeader;
  2298. begin
  2299. InternalGetBMPHeader(Bitmap, Info);
  2300. if (Info.biBitCount > 8) then begin
  2301. HeaderSize := SizeOf(TBitmapInfoHeader);
  2302. if ((Info.biCompression and BI_BITFIELDS)<>0) then
  2303. Inc(HeaderSize, 12);
  2304. end else
  2305. HeaderSize := SizeOf(TBitmapInfoHeader)+SizeOf(TRGBQuad)*(1 shl Info.biBitCount);
  2306. ImageSize := Info.biSizeImage;
  2307. end;
  2308. procedure TFlatAviter.InternalGetBMPHeader(Bitmap: HBITMAP; var Info: TBitmapInfoHeader);
  2309. var DIB : TDIBSection;
  2310. Bytes : Integer;
  2311. function AlignBit(Bits, BitsPerPixel, Alignment: Cardinal): Cardinal;
  2312. begin
  2313. Dec(Alignment);
  2314. Result := ((Bits * BitsPerPixel) + Alignment) and not Alignment;
  2315. Result := Result SHR 3;
  2316. end;
  2317. begin
  2318. DIB.dsbmih.biSize := 0;
  2319. Bytes := GetObject(Bitmap, SizeOf(DIB), @DIB);
  2320. if (Bytes = 0) then raise Exception.Create('Invalid bitmap');
  2321. if (Bytes >= (sizeof(DIB.dsbm) + sizeof(DIB.dsbmih)))and
  2322. (DIB.dsbmih.biSize >= sizeof(DIB.dsbmih)) then
  2323. Info := DIB.dsbmih
  2324. else begin
  2325. FillChar(Info, sizeof(Info), 0);
  2326. with Info, DIB.dsbm do begin
  2327. biSize := SizeOf(Info);
  2328. biWidth := bmWidth;
  2329. biHeight := bmHeight;
  2330. end;
  2331. end;
  2332. with Info do begin
  2333. case PixelFormat of
  2334. vd01bit : biBitCount := 1;
  2335. vd02bit : biBitCount := 2;
  2336. vd04bit : biBitCount := 4;
  2337. vd08bit : biBitCount := 8;
  2338. vd16bit : biBitCount := 16;
  2339. vd24bit : biBitCount := 24;
  2340. vd32bit : biBitCount := 32;
  2341. else
  2342. biBitCount := PixelValue;
  2343. end;
  2344. biPlanes := 1;
  2345. biCompression := BI_RGB; // Always return data in RGB format
  2346. biSizeImage := AlignBit(biWidth,biBitCount,32)*Cardinal(abs(biHeight));
  2347. end;
  2348. end;
  2349. procedure TFlatAviter.SetAudioFile(value : TFileName);
  2350. var Ext : String;
  2351. begin
  2352. Ext := UpperCase(ExtractFileExt(value));
  2353. if Value <> '' then begin
  2354. if (FAudioFile<>Value)and(Ext<>'.WAV') then begin
  2355. raise Exception.Create('Audio file must a file with the .wav extension')
  2356. end else FAudioFile := Value;
  2357. end else FAudioFile := value;
  2358. end;
  2359. procedure TFlatAviter.AddImage(FileName: TFileName);
  2360. var Ext:String; JPG:TJPEGImage;
  2361. begin
  2362. Bitmap := TBitmap.Create;
  2363. try
  2364. Ext := ExtractFileExt(UpperCase(FileName));
  2365. if Ext='.BMP' then begin
  2366. Bitmap.LoadFromFile(FileName);
  2367. Bitmaps.Add(Bitmap);
  2368. end else if Ext='.JPG' then begin
  2369. JPG := TJPEGImage.Create;
  2370. try
  2371. JPG.CompressionQuality := 100;
  2372. JPG.LoadFromFile(FileName);
  2373. Bitmap.Assign(JPG);
  2374. Bitmaps.Add(Bitmap);
  2375. finally
  2376. JPG.Free;
  2377. end;
  2378. end else raise Exception.Create('Cannot load pictures(support *.jpg,*.bmp)');
  2379. except
  2380. on E : Exception do
  2381. begin
  2382. Bitmap.Free;
  2383. raise Exception.Create('Cannot load bitmap because: '+E.Message);
  2384. end;
  2385. end;
  2386. end;
  2387. procedure TFlatAviter.AddImages(Files: TStrings);
  2388. var index:integer;
  2389. begin
  2390. for index := 0 to Pred(Files.Count) do begin
  2391. ProcessMessages;
  2392. AddImage(Files.Strings[index]);
  2393. if Assigned(FOnProgress) then FOnProgress(self,index+1);
  2394. end;
  2395. end;
  2396. function TFlatAviter.GetPictureCount: Integer;
  2397. begin
  2398. result := Bitmaps.Count;
  2399. end;
  2400. {---------end TFlatAviter---------------}
  2401. end.