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

📄 jpeglib.pas

📁 DELPHI版的JPEG文件解码源程序
💻 PAS
📖 第 1 页 / 共 4 页
字号:
{ Entropy decoding }
  jpeg_entropy_decoder_ptr = ^jpeg_entropy_decoder;
  jpeg_entropy_decoder = record
    start_pass : procedure(cinfo : j_decompress_ptr);
    decode_mcu : function(cinfo : j_decompress_ptr;
                          var MCU_data : array of JBLOCKROW) : boolean;
  { This is here to share code between baseline and progressive decoders; }
  { other modules probably should not use it }
    insufficient_data : BOOLEAN;  { set TRUE after emitting warning }
  end;

{ Inverse DCT (also performs dequantization) }
  inverse_DCT_method_ptr = procedure(cinfo : j_decompress_ptr;
                 compptr : jpeg_component_info_ptr;
		 coef_block : JCOEFPTR;
		 output_buf : JSAMPARRAY; output_col : JDIMENSION);

  jpeg_inverse_dct_ptr = ^jpeg_inverse_dct;
  jpeg_inverse_dct = record
    start_pass : procedure(cinfo : j_decompress_ptr);
    { It is useful to allow each component to have a separate IDCT method. }
    inverse_DCT : Array[0..MAX_COMPONENTS-1] of inverse_DCT_method_ptr;
  end;

{ Upsampling (note that upsampler must also call color converter) }
  jpeg_upsampler_ptr = ^jpeg_upsampler;
  jpeg_upsampler = record
    start_pass : procedure(cinfo : j_decompress_ptr);
    upsample : procedure(cinfo : j_decompress_ptr;
                   input_buf : JSAMPIMAGE;
		   var in_row_group_ctr : JDIMENSION;  { array of }
		   in_row_groups_avail : JDIMENSION;
		   output_buf : JSAMPARRAY;
		   var out_row_ctr : JDIMENSION;
		   out_rows_avail : JDIMENSION);

    need_context_rows : boolean;  { TRUE if need rows above & below }
  end;

{ Colorspace conversion }
  jpeg_color_deconverter_ptr = ^jpeg_color_deconverter;
  jpeg_color_deconverter = record
    start_pass : procedure(cinfo: j_decompress_ptr);
    color_convert : procedure(cinfo : j_decompress_ptr;
                              input_buf : JSAMPIMAGE;
                              input_row : JDIMENSION;
                              output_buf : JSAMPARRAY;
                              num_rows : int);
  end;

{ Color quantization or color precision reduction }
  jpeg_color_quantizer_ptr = ^jpeg_color_quantizer;
  jpeg_color_quantizer = record
    start_pass : procedure(cinfo : j_decompress_ptr; is_pre_scan : boolean);
    color_quantize : procedure(cinfo : j_decompress_ptr;
                               input_buf : JSAMPARRAY;
                               output_buf : JSAMPARRAY;
                               num_rows : int);

    finish_pass : procedure(cinfo : j_decompress_ptr);
    new_color_map : procedure(cinfo : j_decompress_ptr);
  end;

  {int8array = Array[0..8-1] of int;}
  int8array = Array[0..8-1] of longint; { for TP FormatStr }

  jpeg_error_mgr = record
    { Error exit handler: does not return to caller }
    error_exit : procedure  (cinfo : j_common_ptr);
    { Conditionally emit a trace or warning message }
    emit_message : procedure (cinfo : j_common_ptr; msg_level : int);
    { Routine that actually outputs a trace or error message }
    output_message : procedure (cinfo : j_common_ptr);
    { Format a message string for the most recent JPEG error or message }
    format_message : procedure  (cinfo : j_common_ptr; var buffer : string);

    { Reset error state variables at start of a new image }
    reset_error_mgr : procedure (cinfo : j_common_ptr);

    { The message ID code and any parameters are saved here.
      A message can have one string parameter or up to 8 int parameters. }

    msg_code : int;

    msg_parm : record
      case byte of
      0:(i : int8array);
      1:(s : string[JMSG_STR_PARM_MAX]);
    end;

    { Standard state variables for error facility }

    trace_level : int;         { max msg_level that will be displayed }

    { For recoverable corrupt-data errors, we emit a warning message,
      but keep going unless emit_message chooses to abort.  emit_message
      should count warnings in num_warnings.  The surrounding application
      can check for bad data by seeing if num_warnings is nonzero at the
      end of processing. }

    num_warnings : long;       { number of corrupt-data warnings }

    { These fields point to the table(s) of error message strings.
      An application can change the table pointer to switch to a different
      message list (typically, to change the language in which errors are
      reported).  Some applications may wish to add additional error codes
      that will be handled by the JPEG library error mechanism; the second
      table pointer is used for this purpose.

      First table includes all errors generated by JPEG library itself.
      Error code 0 is reserved for a "no such error string" message. }

    {const char * const * jpeg_message_table; }
    jpeg_message_table : ^msg_table; { Library errors }

    last_jpeg_message : J_MESSAGE_CODE;
      { Table contains strings 0..last_jpeg_message }
    { Second table can be added by application (see cjpeg/djpeg for example).
      It contains strings numbered first_addon_message..last_addon_message. }

    {const char * const * addon_message_table; }
    addon_message_table : ^msg_table; { Non-library errors }

    first_addon_message : J_MESSAGE_CODE;  { code for first string in addon table }
    last_addon_message : J_MESSAGE_CODE;   { code for last string in addon table }
  end;


{ Progress monitor object }

  jpeg_progress_mgr = record
    progress_monitor : procedure(cinfo : j_common_ptr);

    pass_counter : long;        { work units completed in this pass }
    pass_limit : long;          { total number of work units in this pass }
    completed_passes : int;	{ passes completed so far }
    total_passes : int;         { total number of passes expected }
  end;


{ Data destination object for compression }
  jpeg_destination_mgr_ptr = ^jpeg_destination_mgr;
  jpeg_destination_mgr = record
    next_output_byte : JOCTETptr;  { => next byte to write in buffer }
    free_in_buffer : size_t;    { # of byte spaces remaining in buffer }

    init_destination : procedure (cinfo : j_compress_ptr);
    empty_output_buffer : function (cinfo : j_compress_ptr) : boolean;
    term_destination : procedure (cinfo : j_compress_ptr);
  end;


{ Data source object for decompression }

  jpeg_source_mgr_ptr = ^jpeg_source_mgr;
  jpeg_source_mgr = record
    {const JOCTET * next_input_byte;}
    next_input_byte : JOCTETptr;      { => next byte to read from buffer }
    bytes_in_buffer : size_t;       { # of bytes remaining in buffer }

    init_source : procedure  (cinfo : j_decompress_ptr);
    fill_input_buffer : function (cinfo : j_decompress_ptr) : boolean;
    skip_input_data : procedure (cinfo : j_decompress_ptr; num_bytes : long);
    resync_to_restart : function (cinfo : j_decompress_ptr;
                                  desired : int) : boolean;
    term_source : procedure (cinfo : j_decompress_ptr);
  end;


{ Memory manager object.
  Allocates "small" objects (a few K total), "large" objects (tens of K),
  and "really big" objects (virtual arrays with backing store if needed).
  The memory manager does not allow individual objects to be freed; rather,
  each created object is assigned to a pool, and whole pools can be freed
  at once.  This is faster and more convenient than remembering exactly what
  to free, especially where malloc()/free() are not too speedy.
  NB: alloc routines never return NIL.  They exit to error_exit if not
  successful. }


  jpeg_memory_mgr = record
    { Method pointers }
    alloc_small : function (cinfo : j_common_ptr; pool_id : int;
				  sizeofobject : size_t) : pointer;
    alloc_large : function (cinfo : j_common_ptr; pool_id : int;
				  sizeofobject : size_t) : pointer; {far}
    alloc_sarray : function (cinfo : j_common_ptr; pool_id : int;
                             samplesperrow : JDIMENSION;
                             numrows : JDIMENSION) : JSAMPARRAY;

    alloc_barray : function (cinfo : j_common_ptr; pool_id : int;
                             blocksperrow : JDIMENSION;
                             numrows : JDIMENSION) : JBLOCKARRAY;

    request_virt_sarray : function(cinfo : j_common_ptr;
                                   pool_id : int;
                                   pre_zero : boolean;
                                   samplesperrow : JDIMENSION;
                                   numrows : JDIMENSION;
                                   maxaccess : JDIMENSION) : jvirt_sarray_ptr;

    request_virt_barray : function(cinfo : j_common_ptr;
                                   pool_id : int;
                                   pre_zero : boolean;
                                   blocksperrow : JDIMENSION;
                                   numrows : JDIMENSION;
                                   maxaccess : JDIMENSION) : jvirt_barray_ptr;

    realize_virt_arrays : procedure (cinfo : j_common_ptr);

    access_virt_sarray : function (cinfo : j_common_ptr;
                                   ptr : jvirt_sarray_ptr;
                                   start_row : JDIMENSION;
                                   num_rows : JDIMENSION;
				   writable : boolean) : JSAMPARRAY;

    access_virt_barray : function (cinfo : j_common_ptr;
                                   ptr : jvirt_barray_ptr;
                                   start_row : JDIMENSION;
                                   num_rows : JDIMENSION;
                                   writable : boolean) : JBLOCKARRAY;

    free_pool : procedure  (cinfo : j_common_ptr; pool_id : int);
    self_destruct : procedure (cinfo : j_common_ptr);

    { Limit on memory allocation for this JPEG object.  (Note that this is
      merely advisory, not a guaranteed maximum; it only affects the space
      used for virtual-array buffers.)  May be changed by outer application
      after creating the JPEG object. }
    max_memory_to_use : long;

    { Maximum allocation request accepted by alloc_large. }
    max_alloc_chunk : long;
  end;

{ Routines that are to be used by both halves of the library are declared
  to receive a pointer to this structure.  There are no actual instances of
  jpeg_common_struct, only of jpeg_compress_struct and jpeg_decompress_struct.}
  jpeg_common_struct = record
  { Fields common to both master struct types }
    err : jpeg_error_mgr_ptr;           { Error handler module }
    mem : jpeg_memory_mgr_ptr;          { Memory manager module }
    progress : jpeg_progress_mgr_ptr;   { Progress monitor, or NIL if none }
    client_data : voidp;                { Available for use by application }
    is_decompressor : boolean;     { so common code can tell which is which }
    global_state : int;            { for checking call sequence validity }

  { Additional fields follow in an actual jpeg_compress_struct or
    jpeg_decompress_struct.  All three structs must agree on these
    initial fields!  (This would be a lot cleaner in C++.) }
  end;


{ Master record for a compression instance }

  jpeg_compress_struct = record
    { Fields shared with jpeg_decompress_struct }
    err : jpeg_error_mgr_ptr;          { Error handler module }
    mem : jpeg_memory_mgr_ptr;         { Memory manager module }
    progress : jpeg_progress_mgr_ptr;  { Progress monitor, or NIL if none }
    client_data : voidp;               { Available for use by application }
    is_decompressor : boolean;      { so common code can tell which is which }
    global_state : int;             { for checking call sequence validity }

  { Destination for compressed data }
    dest : jpeg_destination_mgr_ptr;

  { Description of source image --- these fields must be filled in by
    outer application before starting compression.  in_color_space must
    be correct before you can even call jpeg_set_defaults(). }


    image_width : JDIMENSION;         { input image width }
    image_height : JDIMENSION;        { input image height }
    input_components : int;           { # of color components in input image }
    in_color_space : J_COLOR_SPACE;   { colorspace of input image }

    input_gamma : double;             { image gamma of input image }

    { Compression parameters --- these fields must be set before calling
      jpeg_start_compress().  We recommend calling jpeg_set_defaults() to
      initialize everything to reasonable defaults, then changing anything
      the application specifically wants to change.  That way you won't get
      burnt when new parameters are added.  Also note that there are several
      helper routines to simplify changing parameters. }

    data_precision : int;             { bits of precision in image data }

    num_components : int;             { # of color components in JPEG image }
    jpeg_color_space : J_COLOR_SPACE; { colorspace of JPEG image }

    comp_info : jpeg_component_info_list_ptr;
    { comp_info^[i] describes component that appears i'th in SOF }

    quant_tbl_ptrs: Array[0..NUM_QUANT_TBLS-1] of JQUANT_TBL_PTR;
    { ptrs to coefficient quantization tables, or NIL if not defined }

    dc_huff_tbl_ptrs : Array[0..NUM_HUFF_TBLS-1] of JHUFF_TBL_PTR;
    ac_huff_tbl_ptrs : Array[0..NUM_HUFF_TBLS-1] of JHUFF_TBL_PTR;
    { ptrs to Huffman coding tables, or NIL if not defined }

    arith_dc_L : Array[0..NUM_ARITH_TBLS-1] of UINT8; { L values for DC arith-coding tables }
    arith_dc_U : Array[0..NUM_ARITH_TBLS-1] of UINT8; { U values for DC arith-coding tables }
    arith_ac_K : Array[0..NUM_ARITH_TBLS-1] of UINT8; { Kx values for AC arith-coding tables }

    num_scans : int;		 { # of entries in scan_info array }
    scan_info : jpeg_scan_info_ptr; { script for multi-scan file, or NIL }
    { The default value of scan_info is NIL, which causes a single-scan
      sequential JPEG file to be emitted.  To create a multi-scan file,
      set num_scans and scan_info to point to an array of scan definitions. }

    raw_data_in : boolean;        { TRUE=caller supplies downsampled data }
    arith_code : boolean;         { TRUE=arithmetic coding, FALSE=Huffman }
    optimize_coding : boolean;    { TRUE=optimize entropy encoding parms }
    CCIR601_sampling : boolean;   { TRUE=first samples are cosited }
    smoothing_factor : int;       { 1..100, or 0 for no input smoothing }
    dct_method : J_DCT_METHOD;    { DCT algorithm selector }

    { The restart interval can be specified in absolute MCUs by setting
      restart_interval, or in MCU rows by setting restart_in_rows
      (in which case the correct restart_interval will be figured
      for each scan). }

    restart_interval : uint;      { MCUs per restart, or 0 for no restart }
    restart_in_rows : int;        { if > 0, MCU rows per restart interval }

⌨️ 快捷键说明

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