⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lib_xvid.pas

📁 基于xvid 视频的捕获压缩传输
💻 PAS
📖 第 1 页 / 共 3 页
字号:
  XVID_PLG_AFTER   = (1 shl 5);

  // xvid_plg_info_t.flags*/ }
  XVID_REQORIGINAL = (1 shl 0); // plugin requires a copy of the original (uncompressed) image
  XVID_REQPSNR     = (1 shl 1); // plugin requires psnr between the uncompressed and compressed image
  XVID_REQDQUANTS  = (1 shl 2); // plugin requires access to the dquant table

type
  xvid_plg_info_t = packed record
    version: Integer;
    flags: Integer; // [in:opt] plugin flags
  end;

  xvid_plg_create_t = packed record
    version: Integer;
    num_zones: Integer; // [out]
    zones: PXVID_ENC_ZONE_T; // [out]

    width: Integer; // [out]
    height: Integer; // [out]
    mb_width: Integer; // [out]
    mb_height: Integer; // [out]
    fincr: Integer; // [out]
    fbase: Integer; // [out]

    param: Pointer; // [out]
  end;

  xvid_plg_destroy_t = packed record
    version: Integer;
    num_frames: Integer; // [out] total frame encoded
  end;

  xvid_plg_data_t = packed record
    version: Integer;
    zone: PXVID_ENC_ZONE_T; // [out] current zone

    width: Integer; // [out]
    height: Integer; // [out]
    mb_width: Integer; // [out]
    mb_height: Integer; // [out]
    fincr: Integer; // [out]
    fbase: Integer; // [out]

    min_quant: array[0..3 - 1] of Integer; // [out]
    max_quant: array[0..3 - 1] of Integer; // [out]

    reference: XVID_IMAGE_T; // [out] -> [out]
    current: XVID_IMAGE_T; // [out] -> [in,out]
    original: XVID_IMAGE_T; // [out] after: points the original (uncompressed) copy of the current frame
    frame_num: Integer; // [out] frame number

    _type: Integer; // [in,out]
    quant: Integer; // [in,out]

    dquant: PInteger; // [in,out] pointer to diff quantizer table
    dquant_stride: Integer; // [in,out] diff quantizer stride

    vop_flags: Integer; // [in,out]
    vol_flags: Integer; // [in,out]
    motion_flags: Integer; // [in,out]

    // Deprecated, use the stats field instead. }
    // Will disapear before 1.0 }
    length: Integer; // [out] after: length of encoded frame
    kblks: Integer; // [out] number of blocks compressed as Intra
    mblks: Integer; // [out] number of blocks compressed as Inter
    ublks: Integer; // [out] number of blocks marked not_coded
    sse_y: Integer; // [out] Y plane's sse
    sse_u: Integer; // [out] U plane's sse
    sse_v: Integer; // [out] V plane's sse
    // End of duplicated data, kept only for binary compatibility*/ }

    bquant_ratio: Integer; // [in]
    bquant_offset: Integer; // [in]

    stats: XVID_ENC_STATS_T; // [out] frame statistics
  end;

  //****************************************************************************
  {-xvid plugin system -- external }

  {-the application passes xvid an array of "xvid_plugin_t" at XVID_ENC_CREATE. the array }
  {-indicates the plugin function pointer and plugin-specific data. }
  {-xvidcore handles the rest. example: }

  {-xvid_enc_create_t create; }
  {-xvid_enc_plugin_t plugins[2]; }

  {-plugins[0].func = xvid_psnr_func; }
  {-plugins[0].param = NULL; }
  {-plugins[1].func = xvid_cbr_func; }
  {-plugins[1].param =  and cbr_data; }

  {-create.num_plugins = 2; }
  {-create.plugins = plugins; }

  //****************************************************************************

type
  XVID_PLUGIN_FUNC = function(HANDLE: pointer; OPT: Integer; PARAM1, PARAM2: Pointer): Integer;

  Pxvid_enc_plugin_t = ^xvid_enc_plugin_t;
  xvid_enc_plugin_t = packed record
    func: XVID_PLUGIN_FUNC;
    param: Pointer;
  end;

  { single-pass rate control }
  { two-pass rate control: first pass }
  { two-pass rate control: second pass }

  { lumimasking }

  { write psnr values to stdout }
  { dump before and after yuvpgms }

  { single pass rate control }
  { CBR and Constant quantizer modes }
type
  xvid_plugin_single_t = packed record
    version: Integer;
    bitrate: Integer; // [in] bits per second
    reaction_delay_factor: Integer; // [in]
    averaging_period: Integer; // [in]
    buffer: Integer; // [in]
  end;

  xvid_plugin_2pass1_t = packed record
    version: Integer;
    filename: PChar;
  end;

const
  XVID_PAYBACK_BIAS = 0; // payback with bias
  XVID_PAYBACK_PROP = 1; // payback proportionally

type
  xvid_plugin_2pass2_t = packed record
    version: Integer;
    bitrate: Integer; // [in] bits per second
    filename: PChar; // [in] first pass stats filename

    keyframe_boost: Integer; // [in] keyframe boost percentage: [0..100]
    curve_compression_high: Integer; // [in] percentage of compression performed on the high part of the curve (above average) }
    curve_compression_low: Integer; // [in] percentage of compression performed on the low part of the curve (below average) }
    overflow_control_strength: Integer; // [in] Payback delay expressed in number of frames }
    max_overflow_improvement: Integer; // [in] percentage of allowed range for a frame that gets bigger because of overflow bonus }
    max_overflow_degradation: Integer; // [in] percentage of allowed range for a frame that gets smaller because of overflow penalty }

    kfreduction: Integer; // [in] maximum bitrate reduction applied to an iframe under the kfthreshold distance limit }
    kfthreshold: Integer; // [in] if an iframe is closer to the next iframe than this distance, a quantity of bits }
    // is substracted from its bit allocation. The reduction is computed as multiples of
    // kfreduction/kthreshold. It reaches kfreduction when the distance == kfthreshold,
    // 0 for 1<distance<kfthreshold }

    container_frame_overhead: Integer; // [in] How many bytes the controller has to compensate per frame due to container format overhead }
  end;

  //****************************************************************************
  // ENCODER API
  //****************************************************************************

  //----------------------------------------------------------------------------
  // Encoder operations
  //----------------------------------------------------------------------------
const
  XVID_ENC_CREATE = 0; // create encoder instance; returns 0 on success
  XVID_ENC_DESTROY = 1; // destroy encoder instance; returns 0 on success
  XVID_ENC_ENCODE = 2; //* encode a frame: returns number of ouput bytes
  // * 0 means this frame should not be written (ie. encoder lag)
//----------------------------------------------------------------------------
// Encoder entry point
//----------------------------------------------------------------------------
{type

  xvid_encore = function(handle: Pointer;
    opt: Integer;
    param1: Pointer;
    param2: Pointer): Integer; cdecl;
}
  // Quick API reference
  //
  // XVID_ENC_CREATE operation
  // - handle: ignored
  // - opt: XVID_ENC_CREATE
  // - param1: address of a xvid_enc_create_t structure
  // - param2: ignored
  //
  // XVID_ENC_ENCODE operation
  // - handle: an instance returned by a CREATE op
  // - opt: XVID_ENC_ENCODE
  // - param1: address of a xvid_enc_frame_t structure
  // - param2: address of a xvid_enc_stats_t structure (optional)
  // its return value is asynchronous to what is written to the buffer
  // depending on the delay introduced by bvop use. It's display
  // ordered.
  //
  // XVID_ENC_DESTROY operation
  // - handle: an instance returned by a CREATE op
  // - opt: XVID_ENC_DESTROY
  // - param1: ignored
  // - param2: ignored

{/////////////////////////对于编码帧的参数关键参数说明///////////////////////////////////

其中width与height规定编码图像的尺寸;
finer与fbase一起用来指
定编码的帧速率;
rc_bitrate用来指定编码的期望比特率;
max_quantizer
与min-quantizer可以指定量化的最大间隔与最小间隔,这两个参数可以有
效的改变编码后媒体流的比特率。
Max_keyes_interval指定两个关键帧之间的最大预测帧数。
handle用于向用户返回编码实例的句柄
当opt为XVID_ENC_ENCODE时该函数对一帧图像进行编码。
这时的param1参数是一个指向XVID_ENC_FRAME结构的指针,
这个结构用于指定编码所用的各种信息(此时param2参数为一个指向XVID_ENC_STATS结构的指针,用于返回统计信息,可选)

///////////////////////////////////////////////////////////}


  //----------------------------------------------------------------------------
  // "Global" flags
  //
  // These flags are used for xvid_enc_create_t->global field during instance
  // creation (operation XVID_ENC_CREATE)
  //----------------------------------------------------------------------------

const
  XVID_GLOBAL_PACKED            = (1 shl 0); // packed bitstream
  XVID_GLOBAL_CLOSED_GOP        = (1 shl 1); // closed_gop: was DX50BVOP dx50 bvop compatibility
  XVID_GLOBAL_EXTRASTATS_ENABLE = (1 shl 2);
{$IFDEF 0}
  XVID_GLOBAL_VOL_AT_IVOP       = (1 shl 3); // write vol at every ivop: WIN32/divx compatibility
  XVID_GLOBAL_FORCE_VOL         = (1 shl 4); // when vol-based parameters are changed, insert an ivop NOT recommended
{$ENDIF}

  //----------------------------------------------------------------------------
  // "VOL" flags
  //
  // These flags are used for xvid_enc_frame_t->vol_flags field during frame
  // encoding (operation XVID_ENC_ENCODE)
  //----------------------------------------------------------------------------

const
  XVID_VOL_MPEGQUANT  = (1 shl 0); // enable MPEG type quantization
  XVID_VOL_EXTRASTATS = (1 shl 1); // enable plane sse stats
  XVID_VOL_QUARTERPEL = (1 shl 2); // enable quarterpel: frames will encoded as quarterpel
  XVID_VOL_GMC        = (1 shl 3); // enable GMC; frames will be checked for gmc suitability
  XVID_VOL_REDUCED_ENABLE = (1 shl 4); // enable reduced resolution vops: frames will be checked for rrv suitability
  XVID_VOL_INTERLACING    = (1 shl 5); // enable interlaced encoding

  //----------------------------------------------------------------------------
  // "VOP" flags
  //
  // These flags are used for xvid_enc_frame_t->vop_flags field during frame
  // encoding (operation XVID_ENC_ENCODE)
  //----------------------------------------------------------------------------

  // Always valid
const
  XVID_VOP_DEBUG         = (1 shl 0); // print debug messages in frames
  XVID_VOP_HALFPEL       = (1 shl 1); // use halfpel interpolation
  XVID_VOP_INTER4V       = (1 shl 2); // use 4 motion vectors per MB
  XVID_VOP_TRELLISQUANT  = (1 shl 3); // use trellis based R-D 'optimal' quantization
  XVID_VOP_CHROMAOPT     = (1 shl 4); // enable chroma optimization pre-filter
  XVID_VOP_CARTOON       = (1 shl 5); // use 'cartoon mode'
  XVID_VOP_GREYSCALE     = (1 shl 6); // enable greyscale only mode (even for color input material chroma is ignored)
  XVID_VOP_HQACPRED         = (1 shl 7); // high quality ac prediction
  XVID_VOP_MODEDECISION_RD  = (1 shl 8); // enable DCT-ME and use it for mode decision
  XVID_VOP_FAST_MODEDECISION_RD = (1 shl 12); // use simplified R-D mode decision

  // Only valid for vol_flags or =XVID_VOL_INTERLACING
const
  XVID_VOP_TOPFIELDFIRST = (1 shl 9); // set top-field-first flag
  XVID_VOP_ALTERNATESCAN = (1 shl 10); // set alternate vertical scan flag

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -