📄 vfw.pas
字号:
lpbiIn : PBITMAPINFO; // input format
lpbiOut : PBITMAPINFO; // output format - will compress to this
lpBitsOut : PVOID;
lpBitsPrev : PVOID;
lFrame : LONG;
lKey : LONG; // key frames how often?
lDataRate : LONG; // desired data rate KB/Sec
lQ : LONG; // desired quality
lKeyCount : LONG;
lpState : PVOID; // state of compressor
cbState : LONG; // size of the state
end;
// FLAGS for dwFlags element of COMPVARS structure:
// set this flag if you initialize COMPVARS before calling ICCompressorChoose
const
ICMF_COMPVARS_VALID = $00000001; // COMPVARS contains valid data
//
// allows user to choose compressor, quality etc...
//
function ICCompressorChoose(
hwnd : HWND; // parent window for dialog
uiFlags : UINT; // flags
pvIn : PVOID; // input format (optional)
lpData : PVOID; // input data (optional)
pc : PCOMPVARS; // data about the compressor/dlg
lpszTitle : LPSTR // dialog title (optional)
): BOOL; stdcall;
// defines for uiFlags
const
ICMF_CHOOSE_KEYFRAME = $0001; // show KeyFrame Every box
ICMF_CHOOSE_DATARATE = $0002; // show DataRate box
ICMF_CHOOSE_PREVIEW = $0004; // allow expanded preview dialog
ICMF_CHOOSE_ALLCOMPRESSORS = $0008; // don't only show those that
// can handle the input format
// or input data
function ICSeqCompressFrameStart(pc: PCOMPVARS; lpbiIn: PBITMAPINFO): BOOL; stdcall;
procedure ICSeqCompressFrameEnd(pc: PCOMPVARS); stdcall;
function ICSeqCompressFrame(
pc : PCOMPVARS; // set by ICCompressorChoose
uiFlags : UINT; // flags
lpBits : PVOID; // input DIB bits
pfKey : PBOOL; // did it end up being a key frame?
plSize : PDWORD // size to compress to/of returned image
): PVOID; stdcall;
procedure ICCompressorFree(pc: PCOMPVARS); stdcall;
(**************************************************************************
*
* DRAWDIB - Routines for drawing to the display.
*
*************************************************************************)
type
HDRAWDIB = THandle; // hdd
(*********************************************************************
DrawDib Flags
**********************************************************************)
const
DDF_UPDATE = $0002; // re-draw the last DIB
DDF_SAME_HDC = $0004; // HDC same as last call (all setup)
DDF_SAME_DRAW = $0008; // draw params are the same
DDF_DONTDRAW = $0010; // dont draw frame, just decompress
DDF_ANIMATE = $0020; // allow palette animation
DDF_BUFFER = $0040; // always buffer image
DDF_JUSTDRAWIT = $0080; // just draw it with GDI
DDF_FULLSCREEN = $0100; // use DisplayDib
DDF_BACKGROUNDPAL = $0200; // Realize palette in background
DDF_NOTKEYFRAME = $0400; // this is a partial frame update, hint
DDF_HURRYUP = $0800; // hurry up please!
DDF_HALFTONE = $1000; // always halftone
DDF_PREROLL = DDF_DONTDRAW; // Builing up a non-keyframe
DDF_SAME_DIB = DDF_SAME_DRAW;
DDF_SAME_SIZE = DDF_SAME_DRAW;
(*********************************************************************
DrawDib functions
*********************************************************************)
{-- DrawDibOpen() ------------------------------------------------------------}
function DrawDibOpen: HDRAWDIB; stdcall;
{-- DrawDibClose() -----------------------------------------------------------}
function DrawDibClose(hdd: HDRAWDIB): BOOL; stdcall;
{-- DrawDibGetBuffer() -------------------------------------------------------}
function DrawDibGetBuffer(hdd: HDRAWDIB; lpbi: PBITMAPINFOHEADER; dwSize: DWORD; dwFlags: DWORD): PVOID; stdcall;
{-- DrawDibGetPalette() - get the palette used for drawing DIBs --------------}
function DrawDibGetPalette(hdd: HDRAWDIB): HPALETTE; stdcall;
{-- DrawDibSetPalette() - set the palette used for drawing DIBs --------------}
function DrawDibSetPalette(hdd: HDRAWDIB; hpal: HPALETTE): BOOL; stdcall;
{-- DrawDibChangePalette() ---------------------------------------------------}
function DrawDibChangePalette(hdd: HDRAWDIB; iStart, iLen: int; lppe: PPALETTEENTRY): BOOL; stdcall;
{-- DrawDibRealize() - realize the palette in a HDD --------------------------}
function DrawDibRealize(hdd: HDRAWDIB; hdc: HDC; fBackground: BOOL): UINT; stdcall;
{-- DrawDibStart() - start of streaming playback -----------------------------}
function DrawDibStart(hdd: HDRAWDIB; rate: DWORD): BOOL; stdcall;
{-- DrawDibStop() - start of streaming playback ------------------------------}
function DrawDibStop(hdd: HDRAWDIB): BOOL; stdcall;
{-- DrawDibBegin() - prepare to draw -----------------------------------------}
function DrawDibBegin(
hdd : HDRAWDIB;
hdc : HDC;
dxDst : int;
dyDst : int;
lpbi : PBITMAPINFOHEADER;
dxSrc : int;
dySrc : int;
wFlags : UINT
): BOOL; stdcall;
{-- DrawDibDraw() - actually draw a DIB to the screen ------------------------}
function DrawDibDraw(
hdd : HDRAWDIB;
hdc : HDC;
xDst : int;
yDst : int;
dxDst : int;
dyDst : int;
lpbi : PBITMAPINFOHEADER;
lpBits : PVOID;
xSrc : int;
ySrc : int;
dxSrc : int;
dySrc : int;
wFlags : UINT
): BOOL; stdcall;
{-- DrawDibUpdate() - redraw last image (may only be valid with DDF_BUFFER) --}
function DrawDibUpdate(hdd: HDRAWDIB; hdc: HDC; x, y: int): BOOL;
{-- DrawDibEnd() -------------------------------------------------------------}
function DrawDibEnd(hdd: HDRAWDIB): BOOL; stdcall;
{-- DrawDibTime() - for debugging purposes only ------------------------------}
type
PDRAWDIBTIME = ^TDRAWDIBTIME;
TDRAWDIBTIME = packed record
timeCount : LONG;
timeDraw : LONG;
timeDecompress : LONG;
timeDither : LONG;
timeStretch : LONG;
timeBlt : LONG;
timeSetDIBits : LONG;
end;
function DrawDibTime(hdd: HDRAWDIB; lpddtime: PDRAWDIBTIME): BOOL; stdcall;
{-- Display profiling --------------------------------------------------------}
const
PD_CAN_DRAW_DIB = $0001; // if you can draw at all
PD_CAN_STRETCHDIB = $0002; // basicly RC_STRETCHDIB
PD_STRETCHDIB_1_1_OK = $0004; // is it fast?
PD_STRETCHDIB_1_2_OK = $0008; // ...
PD_STRETCHDIB_1_N_OK = $0010; // ...
function DrawDibProfileDisplay(lpbi: PBITMAPINFOHEADER): DWORD; stdcall;
(****************************************************************************
*
* AVIFMT - AVI file format definitions
*
****************************************************************************)
//
// The following is a short description of the AVI file format. Please
// see the accompanying documentation for a full explanation.
//
// An AVI file is the following RIFF form:
//
// RIFF('AVI'
// LIST('hdrl'
// avih(<MainAVIHeader>)
// LIST ('strl'
// strh(<Stream header>)
// strf(<Stream format>)
// ... additional header data
// LIST('movi'
// { LIST('rec'
// SubChunk...
// )
// | SubChunk } ....
// )
// [ <AVIIndex> ]
// )
//
// The main file header specifies how many streams are present. For
// each one, there must be a stream header chunk and a stream format
// chunk, enlosed in a 'strl' LIST chunk. The 'strf' chunk contains
// type-specific format information; for a video stream, this should
// be a BITMAPINFO structure, including palette. For an audio stream,
// this should be a WAVEFORMAT (or PCMWAVEFORMAT) structure.
//
// The actual data is contained in subchunks within the 'movi' LIST
// chunk. The first two characters of each data chunk are the
// stream number with which that data is associated.
//
// Some defined chunk types:
// Video Streams:
// ##db: RGB DIB bits
// ##dc: RLE8 compressed DIB bits
// ##pc: Palette Change
//
// Audio Streams:
// ##wb: waveform audio bytes
//
// The grouping into LIST 'rec' chunks implies only that the contents of
// the chunk should be read into memory at the same time. This
// grouping is used for files specifically intended to be played from
// CD-ROM.
//
// The index chunk at the end of the file should contain one entry for
// each data chunk in the file.
//
// Limitations for the current software:
// Only one video stream and one audio stream are allowed.
// The streams must start at the beginning of the file.
//
//
// To register codec types please obtain a copy of the Multimedia
// Developer Registration Kit from:
//
// Microsoft Corporation
// Multimedia Systems Group
// Product Marketing
// One Microsoft Way
// Redmond, WA 98052-6399
//
{-- form types, list types and chunk types -----------------------------------}
const
formtypeAVI = $20495641; // mmioFOURCC('A', 'V', 'I', ' ')
listtypeAVIHEADER = $6C726468; // mmioFOURCC('h', 'd', 'r', 'l')
ckidAVIMAINHDR = $68697661; // mmioFOURCC('a', 'v', 'i', 'h')
listtypeSTREAMHEADER = $6C727473; // mmioFOURCC('s', 't', 'r', 'l')
ckidSTREAMHEADER = $68727473; // mmioFOURCC('s', 't', 'r', 'h')
ckidSTREAMFORMAT = $66727473; // mmioFOURCC('s', 't', 'r', 'f')
ckidSTREAMHANDLERDATA = $64727473; // mmioFOURCC('s', 't', 'r', 'd')
ckidSTREAMNAME = $6E727473; // mmioFOURCC('s', 't', 'r', 'n')
listtypeAVIMOVIE = $69766F6D; // mmioFOURCC('m', 'o', 'v', 'i')
listtypeAVIRECORD = $20636572; // mmioFOURCC('r', 'e', 'c', ' ')
ckidAVINEWINDEX = $31786469; // mmioFOURCC('i', 'd', 'x', '1')
{-- Stream types for the <fccType> field of the stream header ----------------}
streamtypeVIDEO = $73646976; // mmioFOURCC('v', 'i', 'd', 's')
streamtypeAUDIO = $73647561; // mmioFOURCC('a', 'u', 'd', 's')
streamtypeMIDI = $7364696D; // mmioFOURCC('m', 'i', 'd', 's')
streamtypeTEXT = $73747874; // mmioFOURCC('t', 'x', 't', 's')
{-- Basic chunk types --------------------------------------------------------}
cktypeDIBbits = $6264; // aviTWOCC('d', 'b')
cktypeDIBcompressed = $6364; // aviTWOCC('d', 'c')
cktypePALchange = $6370; // aviTWOCC('p', 'c')
cktypeWAVEbytes = $6277; // aviTWOCC('w', 'b')
{-- Chunk id to use for extra chunks for padding -----------------------------}
ckidAVIPADDING = $4B4E554A; // mmioFOURCC('J', 'U', 'N', 'K')
(*
** Useful macros
**
** Warning: These are nasty macro, and MS C 6.0 compiles some of them
** incorrectly if optimizations are on. Ack.
*)
{-- Macro to get stream number out of a FOURCC ckid --------------------------}
function FromHex(n: BYTE): BYTE;
function StreamFromFOURCC(fcc: DWORD): BYTE;
{-- Macro to get TWOCC chunk type out of a FOURCC ckid -----------------------}
function TWOCCFromFOURCC(fcc: DWORD): WORD;
{-- Macro to make a ckid for a chunk out of a TWOCC and a stream num (0-255) -}
function ToHex(n: BYTE): BYTE;
function MAKEAVICKID(tcc: WORD; stream: BYTE): DWORD;
{-- Main AVI file header -----------------------------------------------------}
{-- flags for use in <dwFlags> in AVIFileHdr ---------------------------------}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -