📄 jpeglib.pas
字号:
{ 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; { 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 }
{ 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_ptr;
{ actually a jpeg_component_info_list_ptr; - Nomssi }
{ 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 }
{ Parameters controlling emission of special markers. }
write_JFIF_header : boolean; { should a JFIF marker be written? }
{ These three values are not used by the JPEG code, merely copied }
{ into the JFIF APP0 marker. density_unit can be 0 for unknown, }
{ 1 for dots/inch, or 2 for dots/cm. Note that the pixel aspect }
{ ratio is defined by X_density/Y_density even when density_unit=0. }
density_unit : UINT8; { JFIF code for pixel size units }
X_density : UINT16; { Horizontal pixel density }
Y_density : UINT16; { Vertical pixel density }
write_Adobe_marker : boolean; { should an Adobe marker be written? }
{ State variable: index of next scanline to be written to
jpeg_write_scanlines(). Application may use this to control its
processing loop, e.g., "while (next_scanline < image_height)". }
next_scanline : JDIMENSION; { 0 .. image_height-1 }
{ Remaining fields are known throughout compressor, but generally
should not be touched by a surrounding application. }
{ These fields are computed during compression startup }
progressive_mode : boolean; { TRUE if scan script uses progressive mode }
max_h_samp_factor : int; { largest h_samp_factor }
max_v_samp_factor : int; { largest v_samp_factor }
total_iMCU_rows : JDIMENSION; { # of iMCU rows to be input to coef ctlr }
{ The coefficient controller receives data in units of MCU rows as defined
for fully interleaved scans (whether the JPEG file is interleaved or not).
There are v_samp_factor * DCTSIZE sample rows of each component in an
"iMCU" (interleaved MCU) row. }
{ These fields are valid during any one scan.
They describe the components and MCUs actually appearing in the scan. }
comps_in_scan : int; { # of JPEG components in this scan }
cur_comp_info : Array[0..MAX_COMPS_IN_SCAN-1] of jpeg_component_info_ptr;
{ cur_comp_info[i]^ describes component that appears i'th in SOS }
MCUs_per_row : JDIMENSION; { # of MCUs across the image }
MCU_rows_in_scan : JDIMENSION;{ # of MCU rows in the image }
blocks_in_MCU : int; { # of DCT blocks per MCU }
MCU_membership : Array[0..C_MAX_BLOCKS_IN_MCU-1] of int;
{ MCU_membership[i] is index in cur_comp_info of component owning }
{ i'th block in an MCU }
Ss, Se, Ah, Al : int; { progressive JPEG parameters for scan }
{ Links to compression subobjects (methods and private variables of modules) }
master : jpeg_comp_master_ptr;
main : jpeg_c_main_controller_ptr;
prep : jpeg_c_prep_controller_ptr;
coef : jpeg_c_coef_controller_ptr;
marker : jpeg_marker_writer_ptr;
cconvert : jpeg_color_converter_ptr;
downsample : jpeg_downsampler_ptr;
fdct : jpeg_forward_dct_ptr;
entropy : jpeg_entropy_encoder_ptr;
end;
{ Master record for a decompression instance }
coef_bits_field = Array[0..DCTSIZE2-1] of int;
coef_bits_ptr = ^coef_bits_field;
coef_bits_ptrfield = Array[0..MAX_COMPS_IN_SCAN-1] of coef_bits_field;
coef_bits_ptrrow = ^coef_bits_ptrfield;
range_limit_table = array[-(MAXJSAMPLE+1)..4*(MAXJSAMPLE+1)
+ CENTERJSAMPLE -1] of JSAMPLE;
range_limit_table_ptr = ^range_limit_table;
jpeg_decompress_struct = record
{ Fields shared with jpeg_compress_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 }
is_decompressor : boolean; { so common code can tell which is which }
global_state : int; { for checking call sequence validity }
{ Source of compressed data }
src : jpeg_source_mgr_ptr;
{ Basic description of image --- filled in by jpeg_read_header(). }
{ Application may inspect these values to decide how to process image. }
image_width : JDIMENSION; { nominal image width (from SOF marker) }
image_height : JDIMENSION; { nominal image height }
num_components : int; { # of color components in JPEG image }
jpeg_color_space : J_COLOR_SPACE; { colorspace of JPEG image }
{ Decompression processing parameters --- these fields must be set before
calling jpeg_start_decompress(). Note that jpeg_read_header()
initializes them to default values. }
out_color_space : J_COLOR_SPACE; { colorspace for output }
scale_num, scale_denom : uint ; { fraction by which to scale image }
output_gamma : double; { image gamma wanted in output }
buffered_image : boolean; { TRUE=multiple output passes }
raw_data_out : boolean; { TRUE=downsampled data wanted }
dct_method : J_DCT_METHOD; { IDCT algorithm selector }
do_fancy_upsampling : boolean; { TRUE=apply fancy upsampling }
do_block_smoothing : boolean; { TRUE=apply interblock smoothing }
quantize_colors : boolean; { TRUE=colormapped output wanted }
{ the following are ignored if not quantize_colors: }
dither_mode : J_DITHER_MODE; { type of color dithering to use }
two_pass_quantize : boolean; { TRUE=use two-pass color quantization }
desired_number_of_colors : int; { max # colors to use in created colormap }
{ these are significant only in buffered-image mode: }
enable_1pass_quant : boolean; { enable future use of 1-pass quantizer }
enable_external_quant : boolean; { enable future use of external colormap }
enable_2pass_quant : boolean; { enable future use of 2-pass quantizer }
{ Description of actual output image that will be returned to application.
These fields are computed by jpeg_start_decompress().
You can also use jpeg_calc_output_dimensions() to determine these values
in advance of calling jpeg_start_decompress(). }
output_width : JDIMENSION; { scaled image width }
output_height: JDIMENSION; { scaled image height }
out_color_components : int; { # of color components in out_color_space }
output_components : int; { # of color components returned }
{ output_components is 1 (a colormap index) when quantizing colors;
otherwise it equals out_color_components. }
rec_outbuf_height : int; { min recommended height of scanline buffer }
{ If the buffer passed to jpeg_read_scanlines() is less than this many
rows high, space and time will be wasted due to unnecessary data
copying. Usually rec_outbuf_height will be 1 or 2, at most 4. }
{ When quantizing colors, the output colormap is described by these
fields. The application can supply a colormap by setting colormap
non-NIL before calling jpeg_start_decompress; otherwise a colormap
is created during jpeg_start_decompress or jpeg_start_output. The map
has out_color_components rows and actual_number_of_colors columns. }
actual_number_of_colors : int; { number of entries in use }
colormap : JSAMPARRAY; { The color map as a 2-D pixel array }
{ State variables: these variables indicate the progress of decompression.
The application may examine these but must not modify them. }
{ Row index of next scanline to be read from jpeg_read_scanlines().
Application may use this to control its processing loop, e.g.,
"while (output_scanline < output_height)". }
output_scanline : JDIMENSION; { 0 .. output_height-1 }
{ Current input scan number and number of iMCU rows completed in scan.
These indicate the progress of the decompressor input side. }
input_scan_number : int; { Number of SOS markers seen so far }
input_iMCU_row : JDIMENSION; { Number of iMCU rows completed }
{ The "output scan number" is the notional scan being displayed by the
output side. The decompressor will not allow output scan/row number
to get ahead of input scan/row, but it can fall arbitrarily far behind.}
output_scan_number : int; { Nominal scan number being displayed }
output_iMCU_row : int; { Number of iMCU rows read }
{ Current progression status. coef_bits[c][i] indicates the precision
with which component c's DCT coefficient i (in zigzag order) is known.
It is -1 when no data has yet been received, otherwise it is the point
transform (shift) value for the most recent scan of the coefficient
(thus, 0 at completion of the progression).
This pointer is NIL when reading a non-progressive file. }
coef_bits : coef_bits_ptrrow;
{ -1 or current Al value for each coef }
{ Internal JPEG parameters --- the application usually need not look at
these fields. Note that the decompressor output side may not use
any parameters that can change between scans. }
{ Quantization and Huffman tables are carried forward across input
datastreams when processing abbreviated JPEG datastreams. }
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 }
{ These parameters are never carried across datastreams, since they
are given in SOF/SOS markers or defined to be reset by SOI. }
data_precision : int; { bits of precision in image data }
comp_info : jpeg_component_info_ptr;
{ actually a jpeg_component_info_list_ptr; - Nomssi }
{ comp_info[i] describes component that appears i'th in SOF }
progressive_mode : boolean; { TRUE if SOFn specifies progressive mode }
arith_code : boolean; { TRUE=arithmetic coding, FALSE=Huffman }
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 }
restart_interval : uint; { MCUs per restart interval, or 0 for no restart }
{ These fields record data obtained from optional markers recognized by
the JPEG library. }
saw_JFIF_marker : boolean; { TRUE iff a JFIF APP0 marker was found }
{ Data copied from JFIF marker: }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -