📄 jpeglib.pas
字号:
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 }
{ 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 }
{$IFDEF macros}
{ Default error-management setup }
EXTERN
function jpeg_std_error(err : jpeg_error_mgr_ptr) : jpeg_error_mgr_ptr;
{ Initialization of JPEG compression objects.
jpeg_create_compress() and jpeg_create_decompress() are the exported
names that applications should call. These expand to calls on
jpeg_CreateCompress and jpeg_CreateDecompress with additional information
passed for version mismatch checking.
NB: you must set up the error-manager BEFORE calling jpeg_create_xxx. }
procedure jpeg_create_compress(cinfo);
begin
jpeg_CreateCompress(cinfo, JPEG_LIB_VERSION,
size_t(sizeof(jpeg_compress_struct)));
end;
procedure jpeg_create_decompress(cinfo);
begin
jpeg_CreateDecompress(cinfo, JPEG_LIB_VERSION,
size_t(sizeof(struct jpeg_decompress_struct)));
end;
EXTERN(void) jpeg_CreateCompress ((j_compress_ptr cinfo,
int version, size_t structsize));
EXTERN(void) jpeg_CreateDecompress ((cinfo : j_decompress_ptr,
int version, size_t structsize));
{ Destruction of JPEG compression objects }
EXTERN(void) jpeg_destroy_compress ((j_compress_ptr cinfo));
EXTERN(void) jpeg_destroy_decompress ((cinfo : j_decompress_ptr));
{ Standard data source and destination managers: stdio streams. }
{ Caller is responsible for opening the file before and closing after. }
EXTERN(void) jpeg_stdio_dest ((j_compress_ptr cinfo, FILE * outfile));
EXTERN(void) jpeg_stdio_src ((cinfo : j_decompress_ptr, FILE * infile));
{ Default parameter setup for compression }
EXTERN(void) jpeg_set_defaults ((j_compress_ptr cinfo));
{ Compression parameter setup aids }
EXTERN(void) jpeg_set_colorspace ((j_compress_ptr cinfo,
J_COLOR_SPACE colorspace));
EXTERN(void) jpeg_default_colorspace ((j_compress_ptr cinfo));
EXTERN(void) jpeg_set_quality ((j_compress_ptr cinfo, int quality,
boolean force_baseline));
EXTERN(void) jpeg_set_linear_quality ((j_compress_ptr cinfo,
int scale_factor,
boolean force_baseline));
EXTERN(void) jpeg_add_quant_table ((j_compress_ptr cinfo, int which_tbl,
const unsigned int *basic_table,
int scale_factor,
boolean force_baseline));
EXTERN(int) jpeg_quality_scaling ((int quality));
EXTERN(void) jpeg_simple_progression ((j_compress_ptr cinfo));
EXTERN(void) jpeg_suppress_tables ((j_compress_ptr cinfo,
boolean suppress));
EXTERN function jpeg_alloc_quant_table (cinfo : j_common_ptr) : JQUANT_TBLptr;
EXTERN function jpeg_alloc_huff_table (cinfo : j_common_ptr) : JHUFF_TBLptr;
{ Main entry points for compression }
EXTERN(void) jpeg_start_compress ((j_compress_ptr cinfo,
boolean write_all_tables));
EXTERN(JDIMENSION) jpeg_write_scanlines ((j_compress_ptr cinfo,
JSAMPARRAY scanlines,
JDIMENSION num_lines));
EXTERN(void) jpeg_finish_compress ((j_compress_ptr cinfo));
{ Replaces jpeg_write_scanlines when writing raw downsampled data. }
EXTERN(JDIMENSION) jpeg_write_raw_data ((j_compress_ptr cinfo,
JSAMPIMAGE data,
JDIMENSION num_lines));
{ Write a special marker. See libjpeg.doc concerning safe usage. }
EXTERN(void) jpeg_write_marker
((j_compress_ptr cinfo, int marker,
const JOCTET * dataptr, unsigned int datalen));
{ Alternate compression function: just write an abbreviated table file }
EXTERN(void) jpeg_write_tables ((j_compress_ptr cinfo));
{ Decompression startup: read start of JPEG datastream to see what's there }
EXTERN(int) jpeg_read_header ((cinfo : j_decompress_ptr,
boolean require_image));
{ Return value is one of: }
#define JPEG_SUSPENDED 0 { Suspended due to lack of input data }
#define JPEG_HEADER_OK 1 { Found valid image datastream }
#define 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).
}
{ Main entry points for decompression }
EXTERN(boolean) jpeg_start_decompress ((cinfo : j_decompress_ptr));
EXTERN(JDIMENSION) jpeg_read_scanlines ((cinfo : j_decompress_ptr,
JSAMPARRAY scanlines,
JDIMENSION max_lines));
EXTERN(boolean) jpeg_finish_decompress ((cinfo : j_decompress_ptr));
{ Replaces jpeg_read_scanlines when reading raw downsampled data. }
EXTERN(JDIMENSION) jpeg_read_raw_data ((cinfo : j_decompress_ptr,
JSAMPIMAGE data,
JDIMENSION max_lines));
{ Additional entry points for buffered-image mode. }
EXTERN(boolean) jpeg_has_multiple_scans ((cinfo : j_decompress_ptr));
EXTERN(boolean) jpeg_start_output ((cinfo : j_decompress_ptr,
int scan_number));
EXTERN(boolean) jpeg_finish_output ((cinfo : j_decompress_ptr));
EXTERN(boolean) jpeg_input_complete ((cinfo : j_decompress_ptr));
EXTERN(void) jpeg_new_colormap ((cinfo : j_decompress_ptr));
EXTERN(int) jpeg_consume_input ((cinfo : j_decompress_ptr));
{ Return value is one of: }
#define JPEG_SUSPENDED 0 Suspended due to lack of input data }
#define JPEG_REACHED_SOS 1 { Reached start of new scan }
#define JPEG_REACHED_EOI 2 { Reached end of image }
#define JPEG_ROW_COMPLETED 3 { Completed one iMCU row }
#define JPEG_SCAN_COMPLETED 4 { Completed last iMCU row of a scan }
{ Precalculate output dimensions for current decompression parameters. }
EXTERN(void) jpeg_calc_output_dimensions ((cinfo : j_decompress_ptr));
{ Install a special processing method for COM or APPn markers. }
EXTERN(void) jpeg_set_marker_processor
((cinfo : j_decompress_ptr, int marker_code,
jpeg_marker_parser_method routine));
{ Read or write raw DCT coefficients --- useful for lossless transcoding. }
EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients ((cinfo : j_decompress_ptr));
EXTERN procedure jpeg_write_coefficients ((j_compress_ptr cinfo,
jvirt_barray_ptr * coef_arrays));
EXTERN procedure jpeg_copy_critical_parameters ((j_decompress_ptr srcinfo,
j_compress_ptr dstinfo));
{ If you choose to abort compression or decompression before completing
jpeg_finish_(de)compress, then you need to clean up to release memory,
temporary files, etc. You can just call jpeg_destroy_(de)compress
if you're done with the JPEG object, but if you want to clean it up and
reuse it, call this: }
EXTERN procedure jpeg_abort_compress (cinfo : j_compress_ptr);
EXTERN procedure jpeg_abort_decompress (cinfo : j_decompress_ptr);
{ Generic versions of jpeg_abort and jpeg_destroy that work on either
flavor of JPEG object. These may be more convenient in some places. }
EXTERN procedure jpeg_abort (cinfo : j_common_ptr);
EXTERN procedure jpeg_destroy (cinfo : j_common_ptr);
{ Default restart-marker-resync procedure for use by data source modules }
EXTERN function jpeg_resync_to_restart (cinfo : j_decompress_ptr;
desired : int) : boolean;
{ Miscellaneous useful macros }
#undef MAX
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#undef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b))
{ We assume that right shift corresponds to signed division by 2 with
rounding towards minus infinity. This is correct for typical "arithmetic
shift" instructions that shift in copies of the sign bit. But some
C compilers implement >> with an unsigned shift. For these machines you
must define RIGHT_SHIFT_IS_UNSIGNED.
RIGHT_SHIFT provides a proper signed right shift of an INT32 quantity.
It is only applied with constant shift counts. SHIFT_TEMPS must be
included in the variables of any routine using RIGHT_SHIFT. }
{$ifdef RIGHT_SHIFT_IS_UNSIGNED} { is true for Borland Pascal }
#define SHIFT_TEMPS INT32 shift_temp;
#define RIGHT_SHIFT(x,shft) \
((shift_temp = (x)) < 0 ? \
(shift_temp >> (shft)) | ((~((INT32) 0)) << (32-(shft))) : \
(shift_temp >> (shft)))
{$else}
#define SHIFT_TEMPS
#define RIGHT_SHIFT(x,shft) ((x) shr (shft))
{$endif}
{ Short forms of external names for systems with brain-damaged linkers. }
{ Compression module initialization routines }
EXTERN(procedure) jinit_compress_master ((cinfo : j_compress_ptr));
EXTERN(procedure) jinit_c_master_control ((cinfo : j_compress_ptr,
boolean transcode_only));
EXTERN(procedure) jinit_c_main_controller ((cinfo : j_compress_ptr,
boolean need_full_buffer));
EXTERN(procedure) jinit_c_prep_controller ((cinfo : j_compress_ptr,
boolean need_full_buffer));
EXTERN(procedure) jinit_c_coef_controller ((cinfo : j_compress_ptr,
boolean need_full_buffer));
EXTERN(procedure) jinit_color_converter ((cinfo : j_compress_ptr));
E
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -