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

📄 jpeglib.pas

📁 用pascal寫的jpeg codec, 測試過的
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    start_input_pass : procedure(cinfo : j_decompress_ptr);
    consume_data : function (cinfo : j_decompress_ptr) : int;
    start_output_pass : procedure(cinfo : j_decompress_ptr);
    decompress_data : function (cinfo : j_decompress_ptr;
                                output_buf : JSAMPIMAGE) : int;
  { Pointer to array of coefficient virtual arrays, or NIL if none }
    coef_arrays : jvirt_barray_tbl_ptr;
  end;

{ Decompression postprocessing (color quantization buffer control) }
  jpeg_d_post_controller_ptr = ^jpeg_d_post_controller;
  jpeg_d_post_controller = record
    start_pass : procedure(cinfo : j_decompress_ptr;
                           pass_mode : J_BUF_MODE);
    post_process_data : procedure(cinfo : j_decompress_ptr;
				  input_buf : JSAMPIMAGE;
				  var in_row_group_ctr : JDIMENSION;
				  in_row_groups_avail : JDIMENSION;
				  output_buf : JSAMPARRAY;
				  var out_row_ctr : JDIMENSION;
				  out_rows_avail : JDIMENSION);
  end;


{ Routine signature for application-supplied marker processing methods.
  Need not pass marker code since it is stored in cinfo^.unread_marker. }

  jpeg_marker_parser_method = function(cinfo : j_decompress_ptr) : boolean;

{ Marker reading & parsing }
  jpeg_marker_reader_ptr = ^jpeg_marker_reader;
  jpeg_marker_reader = record
    reset_marker_reader : procedure(cinfo : j_decompress_ptr);
    { Read markers until SOS or EOI.
      Returns same codes as are defined for jpeg_consume_input:
      JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. }

    read_markers : function (cinfo : j_decompress_ptr) : int;
    { Read a restart marker --- exported for use by entropy decoder only }
    read_restart_marker : jpeg_marker_parser_method;
    { Application-overridable marker processing methods }
    process_COM : jpeg_marker_parser_method;
    process_APPn : Array[0..16-1] of jpeg_marker_parser_method;

    { State of marker reader --- nominally internal, but applications
      supplying COM or APPn handlers might like to know the state. }

    saw_SOI : boolean;            { found SOI? }
    saw_SOF : boolean;            { found SOF? }
    next_restart_num : int;       { next restart number expected (0-7) }
    discarded_bytes : uint;       { # of bytes skipped looking for a marker }
  end;

{ 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;
  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;
  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 }
    is_decompressor : boolean;     { so common code can tell which is which }
    global_state : int;            { for checking call sequence validity }

⌨️ 快捷键说明

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