📄 lib_xvid.pas
字号:
// only valid for vol_flags or =XVID_VOL_REDUCED_ENABLED
XVID_VOP_REDUCED = (1 shl 11); // reduced resolution vop
//----------------------------------------------------------------------------
// "Motion" flags
//
// These flags are used for xvid_enc_frame_t->motion field during frame
// encoding (operation XVID_ENC_ENCODE)
//----------------------------------------------------------------------------
// Motion Estimation Search Patterns
const
XVID_ME_ADVANCEDDIAMOND16 = (1 shl 0); // use advdiamonds instead of diamonds as search pattern
XVID_ME_ADVANCEDDIAMOND8 = (1 shl 1); // use advdiamond for XVID_ME_EXTSEARCH8
XVID_ME_USESQUARES16 = (1 shl 2); // use squares instead of diamonds as search pattern
XVID_ME_USESQUARES8 = (1 shl 3); // use square for XVID_ME_EXTSEARCH8
// SAD operator based flags
XVID_ME_HALFPELREFINE16 = (1 shl 4);
XVID_ME_HALFPELREFINE8 = (1 shl 6);
XVID_ME_QUARTERPELREFINE16 = (1 shl 7);
XVID_ME_QUARTERPELREFINE8 = (1 shl 8);
XVID_ME_GME_REFINE = (1 shl 9);
XVID_ME_EXTSEARCH16 = (1 shl 10); // extend PMV by more searches
XVID_ME_EXTSEARCH8 = (1 shl 11); // use diamond/square for extended 8x8 search
XVID_ME_CHROMA_PVOP = (1 shl 12); // also use chroma for P_VOP/S_VOP ME
XVID_ME_CHROMA_BVOP = (1 shl 13); // also use chroma for B_VOP ME
XVID_ME_FASTREFINE16 = (1 shl 25); // use low-complexity refinement functions
XVID_ME_FASTREFINE8 = (1 shl 29); // low-complexity 8x8 sub-block refinement
// Rate Distortion based flags
// Valid when XVID_VOP_MODEDECISION_RD is enabled
XVID_ME_HALFPELREFINE16_RD = (1 shl 14); // perform RD-based halfpel refinement
XVID_ME_HALFPELREFINE8_RD = (1 shl 15); // perform RD-based halfpel refinement for 8x8 mode
XVID_ME_QUARTERPELREFINE16_RD = (1 shl 16); // perform RD-based qpel refinement
XVID_ME_QUARTERPELREFINE8_RD = (1 shl 17); // perform RD-based qpel refinement for 8x8 mode
XVID_ME_EXTSEARCH_RD = (1 shl 18); // perform RD-based search using square pattern enable XVID_ME_EXTSEARCH8 to do this in 8x8 search as well
XVID_ME_CHECKPREDICTION_RD = (1 shl 19); // always check vector equal to prediction
// Other
XVID_ME_DETECT_STATIC_MOTION = (1 shl 24); // speed-up ME by detecting stationary scenes
XVID_ME_SKIP_DELTASEARCH = (1 shl 26); // speed-up by skipping b-frame delta search
XVID_ME_FAST_MODEINTERPOLATE = (1 shl 27); // speed-up by partly skipping interpolate mode
XVID_ME_BFRAME_EARLYSTOP = (1 shl 28); // speed-up by early exiting b-search
// Unused
XVID_ME_UNRESTRICTED16 = (1 shl 20); // unrestricted ME, not implemented
XVID_ME_OVERLAPPING16 = (1 shl 21); // overlapping ME, not implemented
XVID_ME_UNRESTRICTED8 = (1 shl 22); // unrestricted ME, not implemented
XVID_ME_OVERLAPPING8 = (1 shl 23); // overlapping ME, not implemented
//----------------------------------------------------------------------------
// xvid_enc_create_t structure definition
//
// This structure is passed as param1 during an instance creation (operation
// XVID_ENC_CREATE)
//----------------------------------------------------------------------------
type
xvid_enc_create_t = packed record
version: Integer;
profile: Integer; // [in] profile@level; refer to XVID_PROFILE_xxx
width: Integer; // [in] frame dimensions; width, pixel units
height: Integer; // [in] frame dimensions; height, pixel units
num_zones: Integer; // [in:opt] number of bitrate zones
zones: PXVID_ENC_ZONE_T; // ^^ zone array
num_plugins: Integer; // [in:opt] number of plugins
plugins: PXVID_ENC_PLUGIN_T; // ^^ plugin array
num_threads: Integer; // [in:opt] number of threads
max_bframes: Integer; // [in:opt] max sequential bframes (0=disable bframes)
global: Integer; // [in:opt] global flags; controls encoding behavior
// --- vol-based stuff; included here for convenience
fincr: Integer; // [in:opt] framerate increment; set to zero for variable framerate
fbase: Integer; // [in] framerate base frame_duration = fincr/fbase seconds
// ----------------------------------------------
// --- vop-based; included here for convenience
max_key_interval: Integer; // [in:opt] the maximum interval between key frames
frame_drop_ratio: Integer; // [in:opt] frame dropping: 0=drop none... 100=drop all
bquant_ratio: Integer; // [in:opt] bframe quantizer multipier/offeset; used to decide bframes quant when bquant==-1
bquant_offset: Integer; // bquant = (avg(past_ref_quant,future_ref_quant)*bquant_ratio + bquant_offset) / 100
min_quant: array[0..2] of Integer; // [in:opt]
max_quant: array[0..2] of Integer; // [in:opt]
// ----------------------------------------------
handle: Pointer; // [out] encoder instance handle
end;
//----------------------------------------------------------------------------
// xvid_enc_frame_t structure definition
//
// This structure is passed as param1 during a frame encoding (operation
// XVID_ENC_ENCODE)
//----------------------------------------------------------------------------
// out value for the frame structure->type field
// unlike stats output in param2, this field is not asynchronous and tells
// the client app, if the frame written into the stream buffer is an ivop
// usually used for indexing purpose in the container
const
XVID_KEYFRAME = (1 shl 1);
// The structure
type
xvid_enc_frame_t = packed record
version: Integer;
// VOL related stuff
// unless XVID_FORCEVOL is set, the encoder will not react to any changes
// here until the next VOL (keyframe).
vol_flags: Integer; // [in] vol flags
quant_intra_matrix: PByte; // [in:opt] custom intra qmatrix
quant_inter_matrix: PByte; // [in:opt] custom inter qmatrix
par: Integer; // [in:opt] pixel aspect ratio (refer to XVID_PAR_xxx above)
par_width: Integer; // [in:opt] aspect ratio width
par_height: Integer; // [in:opt] aspect ratio height
// Other fields that can change on a frame base
fincr: Integer; // [in:opt] framerate increment, for variable framerate only
vop_flags: Integer; // [in] (general)vop-based flags
motion: Integer; // [in] ME options
input: XVID_IMAGE_T; // [in] input image (read from)
coding_type: Integer; // [in:opt] coding type
quant: Integer; // [in] frame quantizer; if <=0, automatic (ratecontrol)
bframe_threshold: Integer;
bitstream: Pointer; // [in:opt] bitstream ptr (written to)
length: Integer; // [in:opt] bitstream length (bytes)
out_flags: Integer; // [out] bitstream output flags
end;
const
XviDCoreDll = 'xvidcore.dll';
{/*****************************************************************************
* Quality presets
****************************************************************************/}
type
Tmotion_presets = (quality0,quality1,quality2,quality3,quality4,quality5,quality6);
Const
motion_presets : array[Tmotion_presets] of Integer =
(
//* quality 0 */
0,
//* quality 1 */
XVID_ME_ADVANCEDDIAMOND16,
//* quality 2 */
XVID_ME_ADVANCEDDIAMOND16 or XVID_ME_HALFPELREFINE16,
//* quality 3 */
XVID_ME_ADVANCEDDIAMOND16 or XVID_ME_HALFPELREFINE16 or
XVID_ME_ADVANCEDDIAMOND8 or XVID_ME_HALFPELREFINE8,
//* quality 4 */
XVID_ME_ADVANCEDDIAMOND16 or XVID_ME_HALFPELREFINE16 or
XVID_ME_ADVANCEDDIAMOND8 or XVID_ME_HALFPELREFINE8 or
XVID_ME_CHROMA_PVOP or XVID_ME_CHROMA_BVOP,
//* quality 5 */
XVID_ME_ADVANCEDDIAMOND16 or XVID_ME_HALFPELREFINE16 or
XVID_ME_ADVANCEDDIAMOND8 or XVID_ME_HALFPELREFINE8 or
XVID_ME_CHROMA_PVOP or XVID_ME_CHROMA_BVOP,
//* quality 6 */
XVID_ME_ADVANCEDDIAMOND16 or XVID_ME_HALFPELREFINE16 or XVID_ME_EXTSEARCH16 or
XVID_ME_ADVANCEDDIAMOND8 or XVID_ME_HALFPELREFINE8 or XVID_ME_EXTSEARCH8 or
XVID_ME_CHROMA_PVOP or XVID_ME_CHROMA_BVOP
);
const ME_ELEMENTS = 2;
VOP_ELEMENTS = 2;
const
vop_presets : array[Tmotion_presets] of Integer = (
//* quality 0 */
0,
//* quality 1 */
0,
//* quality 2 */
XVID_VOP_HALFPEL,
//* quality 3 */
XVID_VOP_HALFPEL or XVID_VOP_INTER4V,
//* quality 4 */
XVID_VOP_HALFPEL or XVID_VOP_INTER4V,
//* quality 5 */
XVID_VOP_HALFPEL or XVID_VOP_INTER4V or
XVID_VOP_TRELLISQUANT,
//* quality 6 */
XVID_VOP_HALFPEL or XVID_VOP_INTER4V or
XVID_VOP_TRELLISQUANT or XVID_VOP_HQACPRED
);
{*******************************XVID库函数引用**********************************}
function XVID_MAKE_VERSION(a, b, c: Integer): Integer;
function XVID_VERSION_MAJOR(a: Integer): Byte;
function XVID_VERSION_MINOR(a: Integer): Byte;
function XVID_VERSION_PATCH(a: Integer): Byte;
function XVID_MAKE_API(a, b: Integer): Integer;
function XVID_API_MAJOR(a: Integer): Integer;
function XVID_API_MINOR(a: Integer): Integer;
function xvid_global(hnd: pointer; opt: integer; param1: pointer; param2: pointer): integer; cdecl; external XviDCoreDll;
function xvid_decore(hnd: pointer; opt: integer; param1: pointer; param2: pointer): integer; cdecl; external XviDCoreDll;
function xvid_encore(hnd: pointer; opt: integer; param1: pointer; param2: pointer): integer; cdecl; external XviDCoreDll;
function xvid_plugin_single(HANDLE: pointer; OPT: Integer; PARAM1, PARAM2: Pointer): Integer; cdecl; external XviDCoreDll;
function xvid_plugin_2pass1(HANDLE: pointer; OPT: Integer; PARAM1, PARAM2: Pointer): Integer; cdecl; external XviDCoreDll;
function xvid_plugin_2pass2(HANDLE: pointer; OPT: Integer; PARAM1, PARAM2: Pointer): Integer; cdecl; external XviDCoreDll;
function xvid_plugin_lumimasking(HANDLE: pointer; OPT: Integer; PARAM1, PARAM2: Pointer): Integer; cdecl; external XviDCoreDll;
function xvid_plugin_psnr(HANDLE: pointer; OPT: Integer; PARAM1, PARAM2: Pointer): Integer; cdecl; external XviDCoreDll;
function xvid_plugin_dump(HANDLE: pointer; OPT: Integer; PARAM1, PARAM2: Pointer): Integer; cdecl; external XviDCoreDll;
implementation
{public function}
function XVID_MAKE_VERSION(a, b, c: Integer): Integer;
begin
Result := ((a and $FF) shl 16) or ((b and $FF) shl 8) or (c and $FF);
end;
function XVID_VERSION_MAJOR(a: Integer): Byte;
begin
result := (a shr 16) and $FF;
end;
function XVID_VERSION_MINOR(a: Integer): Byte;
begin
result := (a shr 8) and $FF;
end;
function XVID_VERSION_PATCH(a: Integer): Byte;
begin
result := (a shr 0) and $FF;
end;
function XVID_MAKE_API(a, b: Integer): Integer;
begin
result := ((a and $FF) shl 16) or ((b and $FF) shl 0);
end;
function XVID_API_MAJOR(a: Integer): Integer;
begin
result := (a shr 16) and $FF;
end;
function XVID_API_MINOR(a: Integer): Integer;
begin
result := (a shr 0) and $FF;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -