📄 vfw.pas
字号:
unit VFW;
interface
uses
Windows,
MMSystem,
Messages,
CommDlg,
Ole2;
{== General ==================================================================}
type
PDWORD = ^DWORD;
PLONG = PDWORD;
UDWORD = DWORD;
PVOID = Pointer;
int = Integer;
{-- Returns version of VFW ---------------------------------------------------}
function VideoForWindowsVersion: DWord; pascal;
{-- Call these to start stop using VfW from your app -------------------------}
{ TODO: Where are these functions? }
// function InitVFW: DWORD; stdcall;
// function TermVFW: DWORD; stdcall;
{-- Macros -------------------------------------------------------------------}
function MKFOURCC(ch0, ch1, ch2, ch3: Char): FOURCC;
{== COMPMAN - Installable Compression Manager ================================}
const
ICVERSION = $0104 ;
type
HIC = THandle; // Handle to an Installable Compressor
//
// this code in biCompression means the DIB must be accesed via
// 48 bit pointers! using *ONLY* the selector given.
//
const
BI_1632 = $32333631; // '1632'
function mmioFOURCC(ch0, ch1, ch2, ch3: Char): FOURCC;
type
TWOCC = Word;
function aviTWOCC(ch0, ch1: Char): TWOCC;
const
ICTYPE_VIDEO = $63646976; // mmioFOURCC('v', 'i', 'd', 'c')
ICTYPE_AUDIO = $63647561; // mmioFOURCC('a', 'u', 'd', 'c')
const
ICERR_OK = 0 ;
ICERR_DONTDRAW = 1 ;
ICERR_NEWPALETTE = 2 ;
ICERR_GOTOKEYFRAME = 3 ;
ICERR_STOPDRAWING = 4 ;
ICERR_UNSUPPORTED = -1 ;
ICERR_BADFORMAT = -2 ;
ICERR_MEMORY = -3 ;
ICERR_INTERNAL = -4 ;
ICERR_BADFLAGS = -5 ;
ICERR_BADPARAM = -6 ;
ICERR_BADSIZE = -7 ;
ICERR_BADHANDLE = -8 ;
ICERR_CANTUPDATE = -9 ;
ICERR_ABORT = -10 ;
ICERR_ERROR = -100 ;
ICERR_BADBITDEPTH = -200 ;
ICERR_BADIMAGESIZE = -201 ;
ICERR_CUSTOM = -400 ; // errors less than ICERR_CUSTOM...
{-- Values for dwFlags of ICOpen() -------------------------------------------}
ICMODE_COMPRESS = 1 ;
ICMODE_DECOMPRESS = 2 ;
ICMODE_FASTDECOMPRESS = 3 ;
ICMODE_QUERY = 4 ;
ICMODE_FASTCOMPRESS = 5 ;
ICMODE_DRAW = 8 ;
{-- Flags for AVI file index -------------------------------------------------}
AVIIF_LIST = $00000001 ;
AVIIF_TWOCC = $00000002 ;
AVIIF_KEYFRAME = $00000010 ;
{-- quality flags ------------------------------------------------------------}
ICQUALITY_LOW = 0 ;
ICQUALITY_HIGH = 10000 ;
ICQUALITY_DEFAULT = -1 ;
{-----------------------------------------------------------------------------}
ICM_USER = (DRV_USER+$0000) ;
ICM_RESERVED_LOW = (DRV_USER+$1000) ;
ICM_RESERVED_HIGH = (DRV_USER+$2000) ;
ICM_RESERVED = ICM_RESERVED_LOW ;
{-- Messages -----------------------------------------------------------------}
ICM_GETSTATE = (ICM_RESERVED+0) ; // Get compressor state
ICM_SETSTATE = (ICM_RESERVED+1) ; // Set compressor state
ICM_GETINFO = (ICM_RESERVED+2) ; // Query info about the compressor
ICM_CONFIGURE = (ICM_RESERVED+10); // show the configure dialog
ICM_ABOUT = (ICM_RESERVED+11); // show the about box
ICM_GETDEFAULTQUALITY = (ICM_RESERVED+30); // get the default value for quality
ICM_GETQUALITY = (ICM_RESERVED+31); // get the current value for quality
ICM_SETQUALITY = (ICM_RESERVED+32); // set the default value for quality
ICM_SET = (ICM_RESERVED+40); // Tell the driver something
ICM_GET = (ICM_RESERVED+41); // Ask the driver something
{-- Constants for ICM_SET: ---------------------------------------------------}
ICM_FRAMERATE = $526D7246; // mmioFOURCC('F','r','m','R')
ICM_KEYFRAMERATE = $5279654B; // mmioFOURCC('K','e','y','R')
{-- ICM specific messages ----------------------------------------------------}
ICM_COMPRESS_GET_FORMAT = (ICM_USER+4) ; // get compress format or size
ICM_COMPRESS_GET_SIZE = (ICM_USER+5) ; // get output size
ICM_COMPRESS_QUERY = (ICM_USER+6) ; // query support for compress
ICM_COMPRESS_BEGIN = (ICM_USER+7) ; // begin a series of compress calls.
ICM_COMPRESS = (ICM_USER+8) ; // compress a frame
ICM_COMPRESS_END = (ICM_USER+9) ; // end of a series of compress calls.
ICM_DECOMPRESS_GET_FORMAT = (ICM_USER+10) ; // get decompress format or size
ICM_DECOMPRESS_QUERY = (ICM_USER+11) ; // query support for dempress
ICM_DECOMPRESS_BEGIN = (ICM_USER+12) ; // start a series of decompress calls
ICM_DECOMPRESS = (ICM_USER+13) ; // decompress a frame
ICM_DECOMPRESS_END = (ICM_USER+14) ; // end a series of decompress calls
ICM_DECOMPRESS_SET_PALETTE = (ICM_USER+29) ; // fill in the DIB color table
ICM_DECOMPRESS_GET_PALETTE = (ICM_USER+30) ; // fill in the DIB color table
ICM_DRAW_QUERY = (ICM_USER+31) ; // query support for dempress
ICM_DRAW_BEGIN = (ICM_USER+15) ; // start a series of draw calls
ICM_DRAW_GET_PALETTE = (ICM_USER+16) ; // get the palette needed for drawing
ICM_DRAW_START = (ICM_USER+18) ; // start decompress clock
ICM_DRAW_STOP = (ICM_USER+19) ; // stop decompress clock
ICM_DRAW_END = (ICM_USER+21) ; // end a series of draw calls
ICM_DRAW_GETTIME = (ICM_USER+32) ; // get value of decompress clock
ICM_DRAW = (ICM_USER+33) ; // generalized "render" message
ICM_DRAW_WINDOW = (ICM_USER+34) ; // drawing window has moved or hidden
ICM_DRAW_SETTIME = (ICM_USER+35) ; // set correct value for decompress clock
ICM_DRAW_REALIZE = (ICM_USER+36) ; // realize palette for drawing
ICM_DRAW_FLUSH = (ICM_USER+37) ; // clear out buffered frames
ICM_DRAW_RENDERBUFFER = (ICM_USER+38) ; // draw undrawn things in queue
ICM_DRAW_START_PLAY = (ICM_USER+39) ; // start of a play
ICM_DRAW_STOP_PLAY = (ICM_USER+40) ; // end of a play
ICM_DRAW_SUGGESTFORMAT = (ICM_USER+50) ; // Like ICGetDisplayFormat
ICM_DRAW_CHANGEPALETTE = (ICM_USER+51) ; // for animating palette
ICM_GETBUFFERSWANTED = (ICM_USER+41) ; // ask about prebuffering
ICM_GETDEFAULTKEYFRAMERATE = (ICM_USER+42) ; // get the default value for key frames
ICM_DECOMPRESSEX_BEGIN = (ICM_USER+60) ; // start a series of decompress calls
ICM_DECOMPRESSEX_QUERY = (ICM_USER+61) ; // start a series of decompress calls
ICM_DECOMPRESSEX = (ICM_USER+62) ; // decompress a frame
ICM_DECOMPRESSEX_END = (ICM_USER+63) ; // end a series of decompress calls
ICM_COMPRESS_FRAMES_INFO = (ICM_USER+70) ; // tell about compress to come
ICM_SET_STATUS_PROC = (ICM_USER+72) ; // set status callback
{-----------------------------------------------------------------------------}
type
PICOPEN = ^TICOPEN;
TICOPEN = record
dwSize : DWORD ; // sizeof(ICOPEN)
fccType : DWORD ; // 'vidc'
fccHandler : DWORD ; //
dwVersion : DWORD ; // version of compman opening you
dwFlags : DWORD ; // LOWORD is type specific
dwError : DWORD ; // error return.
pV1Reserved : PVOID ; // Reserved
pV2Reserved : PVOID ; // Reserved
dnDevNode : DWORD ; // Devnode for PnP devices
end;
{-----------------------------------------------------------------------------}
PICINFO = ^TICINFO ;
TICINFO = record
dwSize : DWORD; // sizeof(ICINFO)
fccType : DWORD; // compressor type 'vidc' 'audc'
fccHandler : DWORD; // compressor sub-type 'rle ' 'jpeg' 'pcm '
dwFlags : DWORD; // flags LOWORD is type specific
dwVersion : DWORD; // version of the driver
dwVersionICM : DWORD; // version of the ICM used
//
// under Win32, the driver always returns UNICODE strings.
//
szName : array[0..15] of WideChar ; // short name
szDescription : array[0..127] of WideChar ; // DWORD name
szDriver : array[0..127] of WideChar ; // driver that contains compressor
end;
{-- Flags for the <dwFlags> field of the <ICINFO> structure. -----------------}
const
VIDCF_QUALITY = $0001 ; // supports quality
VIDCF_CRUNCH = $0002 ; // supports crunching to a frame size
VIDCF_TEMPORAL = $0004 ; // supports inter-frame compress
VIDCF_COMPRESSFRAMES = $0008 ; // wants the compress all frames message
VIDCF_DRAW = $0010 ; // supports drawing
VIDCF_FASTTEMPORALC = $0020 ; // does not need prev frame on compress
VIDCF_FASTTEMPORALD = $0080 ; // does not need prev frame on decompress
//VIDCF_QUALITYTIME = $0040 ; // supports temporal quality
//VIDCF_FASTTEMPORAL = (VIDCF_FASTTEMPORALC or VIDCF_FASTTEMPORALD)
{-----------------------------------------------------------------------------}
ICCOMPRESS_KEYFRAME = $00000001;
type
PICCOMPRESS = ^TICCOMPRESS;
TICCOMPRESS = record
dwFlags : DWORD; // flags
lpbiOutput : PBITMAPINFOHEADER ; // output format
lpOutput : PVOID ; // output data
lpbiInput : PBITMAPINFOHEADER ; // format of frame to compress
lpInput : PVOID ; // frame data to compress
lpckid : PDWORD ; // ckid for data in AVI file
lpdwFlags : PDWORD; // flags in the AVI index.
lFrameNum : DWORD ; // frame number of seq.
dwFrameSize : DWORD ; // reqested size in bytes. (if non zero)
dwQuality : DWORD ; // quality
// these are new fields
lpbiPrev : PBITMAPINFOHEADER ; // format of previous frame
lpPrev : PVOID ; // previous frame
end;
{-----------------------------------------------------------------------------}
const
ICCOMPRESSFRAMES_PADDING = $00000001 ;
type
TICCompressProc = function(lInput: LPARAM; lFrame: DWORD; lpBits: PVOID; len: DWORD): DWORD; stdcall;
PICCOMPRESSFRAMES = ^TICCOMPRESSFRAMES;
TICCOMPRESSFRAMES = record
dwFlags : DWORD ; // flags
lpbiOutput : PBITMAPINFOHEADER ; // output format
lOutput : LPARAM ; // output identifier
lpbiInput : PBITMAPINFOHEADER ; // format of frame to compress
lInput : LPARAM ; // input identifier
lStartFrame : DWORD ; // start frame
lFrameCount : DWORD ; // # of frames
lQuality : DWORD ; // quality
lDataRate : DWORD ; // data rate
lKeyRate : DWORD ; // key frame rate
dwRate : DWORD ; // frame rate, as always
dwScale : DWORD ;
dwOverheadPerFrame : DWORD ;
dwReserved2 : DWORD ;
GetData : TICCompressProc;
PutData : TICCompressProc;
end;
{-- Messages for Status callback ---------------------------------------------}
const
ICSTATUS_START = 0 ;
ICSTATUS_STATUS = 1 ; // l = % done
ICSTATUS_END = 2 ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -