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

📄 lib_xvid.pas

📁 基于xvid 视频的捕获压缩传输
💻 PAS
📖 第 1 页 / 共 3 页
字号:
unit lib_xvid;

interface
uses
  windows, SysUtils, math, forms, Contnrs;

// Bitstream Version
const
  XVID_BS_VERSION = 46;
  XVID_VERSION = ((1 and $FF) shl 16) or ((1 and $FF) shl 8) or (3 and $FF);

  //****************************************************************************
  // error codes
  //****************************************************************************

  // all functions return values <0 indicate error
const
  XVID_ERR_FAIL     = -1; // general fault
  XVID_ERR_MEMORY   = -2; // memory allocation error
  XVID_ERR_FORMAT   = -3; // file format error
  XVID_ERR_VERSION  = -4; // structure version not supported
  XVID_ERR_END      = -5; // encoder only; end of stream reached

//****************************************************************************
// xvid_image_t
//****************************************************************************

// colorspace values
const
  XVID_CSP_PLANAR   = (1 shl 0);  // 4:2:0 planar (==I420, except for pointers/strides)
  XVID_CSP_USER     = XVID_CSP_PLANAR;
  XVID_CSP_I420     = (1 shl 1);  // 4:2:0 planar
  XVID_CSP_YV12     = (1 shl 2);  // 4:2:0 planar
  XVID_CSP_YUY2     = (1 shl 3);  // 4:2:2 packed
  XVID_CSP_UYVY     = (1 shl 4);  // 4:2:2 packed
  XVID_CSP_YVYU     = (1 shl 5);  // 4:2:2 packed
  XVID_CSP_BGRA     = (1 shl 6);  // 32-bit bgra packed
  XVID_CSP_ABGR     = (1 shl 7);  // 32-bit abgr packed
  XVID_CSP_RGBA     = (1 shl 8);  // 32-bit rgba packed
  XVID_CSP_ARGB     = (1 shl 15); // 32-bit argb packed
  XVID_CSP_BGR      = (1 shl 9);  // 24-bit bgr packed
  XVID_CSP_RGB555   = (1 shl 10); // 16-bit rgb555 packed
  XVID_CSP_RGB565   = (1 shl 11); // 16-bit rgb565 packed
  XVID_CSP_SLICE    = (1 shl 12); // decoder only: 4:2:0 planar, per slice rendering
  XVID_CSP_INTERNAL = (1 shl 13); // decoder only: 4:2:0 planar, returns ptrs to internal buffers
  XVID_CSP_NULL     = (1 shl 14); // decoder only: dont output anything
  XVID_CSP_VFLIP    = (1 shl 31); // vertical flip mask

  // xvid_image_t
type
  xvid_image_t = packed record
    csp: Integer; // [in] colorspace; or with XVID_CSP_VFLIP to perform vertical flip
    plane: array[0..3] of Pointer; // [in] image plane ptrs
    stride: array[0..3] of Integer; // [in] image stride; "bytes per row"
  end;

  // video-object-sequence profiles
const
  XVID_PROFILE_S_L0    = $08; // simple
  XVID_PROFILE_S_L1    = $01;
  XVID_PROFILE_S_L2    = $02;
  XVID_PROFILE_S_L3    = $03;
  XVID_PROFILE_ARTS_L1 = $91; // advanced realtime simple
  XVID_PROFILE_ARTS_L2 = $92;
  XVID_PROFILE_ARTS_L3 = $93;
  XVID_PROFILE_ARTS_L4 = $94;
  XVID_PROFILE_AS_L0   = $F0; // advanced simple
  XVID_PROFILE_AS_L1   = $F1;
  XVID_PROFILE_AS_L2   = $F2;
  XVID_PROFILE_AS_L3   = $F3;
  XVID_PROFILE_AS_L4   = $F4;

  // aspect ratios
const
  XVID_PAR_11_VGA   = 1; // 1:1 vga (square), default if supplied PAR is not a valid value
  XVID_PAR_43_PAL   = 2; // 4:3 pal (12:11 625-line)
  XVID_PAR_43_NTSC  = 3; // 4:3 ntsc (10:11 525-line)
  XVID_PAR_169_PAL  = 4; // 16:9 pal (16:11 625-line)
  XVID_PAR_169_NTSC = 5; // 16:9 ntsc (40:33 525-line)
  XVID_PAR_EXT      = 15; // extended par; use par_width, par_height

  // frame type flags
const
  XVID_TYPE_VOL     = -1; // decoder only: vol was decoded
  XVID_TYPE_NOTHING = 0; // decoder only (encoder stats): nothing was decoded/encoded
  XVID_TYPE_AUTO    = 0; // encoder: automatically determine coding type
  XVID_TYPE_IVOP    = 1; // intra frame
  XVID_TYPE_PVOP    = 2; // predicted frame
  XVID_TYPE_BVOP    = 3; // bidirectionally encoded
  XVID_TYPE_SVOP    = 4; // predicted+sprite frame

  //****************************************************************************
  // xvid_global()
  //****************************************************************************

  // cpu_flags definitions (make sure to sync this with cpuid.asm for ia32)
const
  XVID_CPU_FORCE    = (1 shl 31); // force passed cpu flags
  XVID_CPU_ASM      = (1 shl 7); // native assembly
  // ARCH_IS_IA32
  XVID_CPU_MMX      = (1 shl 0); // mmx : pentiumMMX,k6
  XVID_CPU_MMXEXT   = (1 shl 1); // mmx-ext : pentium2, athlon
  XVID_CPU_SSE      = (1 shl 2); // sse : pentium3, athlonXP
  XVID_CPU_SSE2     = (1 shl 3); // sse2 : pentium4, athlon64
  XVID_CPU_3DNOW    = (1 shl 4); // 3dnow : k6-2
  XVID_CPU_3DNOWEXT = (1 shl 5); // 3dnow-ext : athlon
  XVID_CPU_TSC      = (1 shl 6); // tsc : Pentium // ARCH_IS_PPC
  XVID_CPU_ALTIVEC  = (1 shl 0); // altivec

  XVID_DEBUG_ERROR     = (1 shl 0);
  XVID_DEBUG_STARTCODE = (1 shl 1);
  XVID_DEBUG_HEADER    = (1 shl 2);
  XVID_DEBUG_TIMECODE  = (1 shl 3);
  XVID_DEBUG_MB        = (1 shl 4);
  XVID_DEBUG_COEFF     = (1 shl 5);
  XVID_DEBUG_MV        = (1 shl 6);
  XVID_DEBUG_RC        = (1 shl 7);
  XVID_DEBUG_DEBUG     = (1 shl 31);

  // XVID_GBL_INIT param1
type
  xvid_gbl_init_t = packed record
    version: Integer;
    cpu_flags: Word; // [in:opt] zero = autodetect cpu; XVID_CPU_FORCE or {cpu features} = force cpu features
    debug: Integer;  // [in:opt] debug level
  end;

  // XVID_GBL_INFO param1
  xvid_gbl_info_t = packed record
    version       : Integer;
    actual_version: Integer; // [out] returns the actual xvidcore version
    build         : Pchar; // [out] if !null, points to description of this xvid core build
    cpu_flags     : Word; // [out] detected cpu features
    num_threads   : Integer; // [out] detected number of cpus/threads
  end;

  // XVID_GBL_CONVERT param1
  xvid_gbl_convert_t = packed record
    version: Integer;
    input: XVID_IMAGE_T; // [in] input image  and  colorspace
    output: XVID_IMAGE_T; // [in] output image  and  colorspace
    width: Integer; // [in] width
    height: Integer; // [in] height
    interlacing: Integer; // [in] interlacing
  end;

const
  XVID_GBL_INIT = 0; // initialize xvidcore; must be called before using xvid_decore, or xvid_encore)
  XVID_GBL_INFO = 1; // return some info about xvidcore, and the host computer
  XVID_GBL_CONVERT = 2; // colorspace conversion utility

 //****************************************************************************
  // xvid_decore()
  //****************************************************************************
const
  XVID_DEC_CREATE  = 0; // create decore instance; return 0 on success
  XVID_DEC_DESTROY = 1; // destroy decore instance: return 0 on success
  XVID_DEC_DECODE  = 2; // decode a frame: returns number of bytes consumed >= 0

type
  xvid_dec_create_t = packed record
    version: Integer;
    width: Integer; // [in:opt] image width
    height: Integer; // [in:opt] image width
    handle: Pointer; // [out] decore context handle
  end;

  // XVID_DEC_DECODE param1
  // general flags
const
  XVID_LOWDELAY       = (1 shl 0); // lowdelay mode
  XVID_DISCONTINUITY  = (1 shl 1); // indicates break in stream
  XVID_DEBLOCKY       = (1 shl 2); // perform luma deblocking
  XVID_DEBLOCKUV   = (1 shl 3); // perform chroma deblocking
  XVID_FILMEFFECT  = (1 shl 4); // adds film grain
  XVID_DERINGUV    =   (1 shl 5); // perform chroma deringing, requires deblocking to work */
  XVID_DERINGY     =   (1 shl 6); // perform luma deringing, requires deblocking to work */

  XVID_DEC_FAST    =  (1 shl 29); // disable postprocessing to decrease cpu usage *todo* */
  XVID_DEC_DROP    =  (1 shl 30); // drop bframes to decrease cpu usage *todo* */
  XVID_DEC_PREROLL =  (1 shl 31); // decode as fast as you can, don't even show output *todo* */

type
  xvid_dec_frame_t = packed record
    version: Integer;
    general: Integer;     // [in:opt] general flags
    bitstream: Pointer;   // [in] bitstream (read from)
    length: Integer;      // [in] bitstream length
    output: XVID_IMAGE_T; // [in] output image (written to)
    //1.1.x增加的
    brightness : Integer; //[in]  brightness offset (0=none)
  end;

  // XVID_DEC_DECODE param2 :: optional
  vop_t = packed record
    general: Integer;         // [out] flags
    time_base: Integer;       // [out] time base
    time_increment: Integer;  // [out] time increment
    // XXX: external deblocking stuff
    qscale: PInteger;         // [out] pointer to quantizer table
    qscale_stride: Integer;   // [out] quantizer scale stride
  end;

  vol_t = record // XVID_TYPE_VOL
    general: Integer;     // [out] flags
    width: Integer;       // [out] width
    height: Integer;      // [out] height
    par: Integer;         // [out] pixel aspect ratio (refer to XVID_PAR_xxx above)
    par_width: Integer;   // [out] aspect ratio width [1..255]
    par_height: Integer;  // [out] aspect ratio height [1..255]
  end;
  
  xvid_dec_stats_t = packed record
    version: integer;
    frametype: integer;       // [out] output data type */
    case Integer of
     0: (vop: vop_t);
     1: (vol: vol_t);
  end;

const
  XVID_ZONE_QUANT = (1 shl 0);
  XVID_ZONE_WEIGHT = (1 shl 1);

type
  Pxvid_enc_zone_t = ^xvid_enc_zone_t;
  xvid_enc_zone_t = packed record
    frame: Integer;
    mode: Integer;
    increment: Integer;
    base: Integer;
  end;

  //----------------------------------------------------------------------------
  // xvid_enc_stats_t structure
  //
  // Used in:
  // - xvid_plg_data_t structure
  // - optional parameter in xvid_encore() function
  //
  // .coding_type = XVID_TYPE_NOTHING if the stats are not given
  //----------------------------------------------------------------------------

type
  xvid_enc_stats_t = packed record
    version     : Integer; // encoding parameters
    frame_type  : Integer; // [out] coding type
    quant       : Integer; // [out] frame quantizer
    vol_flags   : Integer; // [out] vol flags (see above)
    vop_flags   : Integer; // [out] vop flags (see above)

    // bitrate
    length      : Integer; // [out] frame length
    hlength     : Integer; // [out] header length (bytes)
    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 as 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;

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

  {-xvidcore will call XVID_PLG_INFO and XVID_PLG_CREATE during XVID_ENC_CREATE }
  {-before encoding each frame xvidcore will call XVID_PLG_BEFORE }
  {-after encoding each frame xvidcore will call XVID_PLG_AFTER }
  {-xvidcore will call XVID_PLG_DESTROY during XVID_ENC_DESTROY }
  //****************************************************************************

const
  XVID_PLG_CREATE  = (1 shl 0);
  XVID_PLG_DESTROY = (1 shl 1);
  XVID_PLG_INFO    = (1 shl 2);
  XVID_PLG_BEFORE  = (1 shl 3);
  XVID_PLG_FRAME   = (1 shl 4);

⌨️ 快捷键说明

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