📄 jpeglib.pas
字号:
{ Parameters controlling emission of special markers. }
write_JFIF_header : boolean; { should a JFIF marker be written? }
JFIF_major_version : UINT8; { What to write for the JFIF version number }
JFIF_minor_version : UINT8;
{ 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;
script_space : jpeg_scan_info_ptr; { workspace for jpeg_simple_progression }
script_space_size : int;
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 }
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 }
{ 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_list_ptr;
{ 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; only valid if saw_JFIF_marker is TRUE: }
JFIF_major_version : UINT8; { JFIF version number }
JFIF_minor_version : UINT8;
density_unit : UINT8; { JFIF code for pixel size units }
X_density : UINT16; { Horizontal pixel density }
Y_density : UINT16; { Vertical pixel density }
saw_Adobe_marker : boolean; { TRUE iff an Adobe APP14 marker was found }
Adobe_transform : UINT8; { Color transform code from Adobe marker }
CCIR601_sampling : boolean; { TRUE=first samples are cosited }
{ Aside from the specific data retained from APPn markers known to the
library, the uninterpreted contents of any or all APPn and COM markers
can be saved in a list for examination by the application. }
marker_list : jpeg_saved_marker_ptr; { Head of list of saved markers }
{ Remaining fields are known throughout decompressor, but generally
should not be touched by a surrounding application. }
{ These fields are computed during decompression startup }
max_h_samp_factor : int; { largest h_samp_factor }
max_v_samp_factor : int; { largest v_samp_factor }
min_DCT_scaled_size : int; { smallest DCT_scaled_size of any component }
total_iMCU_rows : JDIMENSION; { # of iMCU rows in image }
{ The coefficient controller's input and output progress is measured in
units of "iMCU" (interleaved MCU) rows. These are the same as MCU rows
in fully interleaved JPEG scans, but are used whether the scan is
interleaved or not. We define an iMCU row as v_samp_factor DCT block
rows of each component. Therefore, the IDCT output contains
v_samp_factor*DCT_scaled_size sample rows of a component per iMCU row.}
sample_range_limit : range_limit_table_ptr; { table for fast range-limiting }
{ These fields are valid during any one scan.
They describe the components and MCUs actually appearing in the scan.
Note that the decompressor output side must not use these fields. }
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 : JDIMENSION; { # of DCT blocks per MCU }
MCU_membership : Array[0..D_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 }
{ This field is shared between entropy decoder and marker parser.
It is either zero or the code of a JPEG marker that has been
read from the data source, but has not yet been processed. }
unread_marker : int;
{ Links to decompression subobjects
(methods, private variables of modules) }
master : jpeg_decomp_master_ptr;
main : jpeg_d_main_controller_ptr;
coef : jpeg_d_coef_controller_ptr;
post : jpeg_d_post_controller_ptr;
inputctl : jpeg_input_controller_ptr;
marker : jpeg_marker_reader_ptr;
entropy : jpeg_entropy_decoder_ptr;
idct : jpeg_inverse_dct_ptr;
upsample : jpeg_upsampler_ptr;
cconvert : jpeg_color_deconverter_ptr;
cquantize : jpeg_color_quantizer_ptr;
end;
{ Decompression startup: read start of JPEG datastream to see what's there
function jpeg_read_header (cinfo : j_decompress_ptr;
require_image : boolean) : int;
Return value is one of: }
const
JPEG_SUSPENDED = 0; { Suspended due to lack of input data }
JPEG_HEADER_OK = 1; { Found valid image datastream }
JPEG_HEADER_TABLES_ONLY = 2; { Found valid table-specs-only datastream }
{ If you pass require_image = TRUE (normal case), you need not check for
a TABLES_ONLY return code; an abbreviated file will cause an error exit.
JPEG_SUSPENDED is only possible if you use a data source module that can
give a suspension return (the stdio source module doesn't). }
{ function jpeg_consume_input (cinfo : j_decompress_ptr) : int;
Return value is one of: }
JPEG_REACHED_SOS = 1; { Reached start of new scan }
JPEG_REACHED_EOI = 2; { Reached end of image }
JPEG_ROW_COMPLETED = 3; { Completed one iMCU row }
JPEG_SCAN_COMPLETED = 4; { Completed last iMCU row of a scan }
implementation
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -