src/java.desktop/share/native/libjavajpeg/jpegint.h
author jiefu
Fri, 15 Nov 2019 20:39:26 +0800
changeset 59110 8c4c358272a9
parent 47216 71c04702a3d5
permissions -rw-r--r--
8234232: [TESTBUG] gc/shenandoah/jvmti/TestHeapDump.java fails with -Xcomp Reviewed-by: zgu
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * reserved comment block
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT REMOVE OR ALTER!
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * jpegint.h
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * Copyright (C) 1991-1997, Thomas G. Lane.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This file is part of the Independent JPEG Group's software.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * For conditions of distribution and use, see the accompanying README file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * This file provides common declarations for the various JPEG modules.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * These declarations are considered internal to the JPEG library; most
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * applications using the library shouldn't need to include this file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
/* Declarations for both compression & decompression */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
typedef enum {                  /* Operating modes for buffer controllers */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
        JBUF_PASS_THRU,         /* Plain stripwise operation */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
        /* Remaining modes require a full-image buffer to have been created */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
        JBUF_SAVE_SOURCE,       /* Run source subobject only, save output */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
        JBUF_CRANK_DEST,        /* Run dest subobject only, using saved data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
        JBUF_SAVE_AND_PASS      /* Run both subobjects, save output */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
} J_BUF_MODE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/* Values of global_state field (jdapi.c has some dependencies on ordering!) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#define CSTATE_START    100     /* after create_compress */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#define CSTATE_SCANNING 101     /* start_compress done, write_scanlines OK */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#define CSTATE_RAW_OK   102     /* start_compress done, write_raw_data OK */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#define CSTATE_WRCOEFS  103     /* jpeg_write_coefficients done */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#define DSTATE_START    200     /* after create_decompress */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#define DSTATE_INHEADER 201     /* reading header markers, no SOS yet */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#define DSTATE_READY    202     /* found SOS, ready for start_decompress */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#define DSTATE_PRELOAD  203     /* reading multiscan file in start_decompress*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#define DSTATE_PRESCAN  204     /* performing dummy pass for 2-pass quant */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#define DSTATE_SCANNING 205     /* start_decompress done, read_scanlines OK */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#define DSTATE_RAW_OK   206     /* start_decompress done, read_raw_data OK */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#define DSTATE_BUFIMAGE 207     /* expecting jpeg_start_output */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#define DSTATE_BUFPOST  208     /* looking for SOS/EOI in jpeg_finish_output */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
#define DSTATE_RDCOEFS  209     /* reading file in jpeg_read_coefficients */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
#define DSTATE_STOPPING 210     /* looking for EOI in jpeg_finish_decompress */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
/* Declarations for compression modules */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
/* Master control module */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
struct jpeg_comp_master {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
  JMETHOD(void, prepare_for_pass, (j_compress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
  JMETHOD(void, pass_startup, (j_compress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
  JMETHOD(void, finish_pass, (j_compress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
  /* State variables made visible to other modules */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
  boolean call_pass_startup;    /* True if pass_startup must be called */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
  boolean is_last_pass;         /* True during last pass */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
/* Main buffer control (downsampled-data buffer) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
struct jpeg_c_main_controller {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
  JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
  JMETHOD(void, process_data, (j_compress_ptr cinfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
                               JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
                               JDIMENSION in_rows_avail));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
/* Compression preprocessing (downsampling input buffer control) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
struct jpeg_c_prep_controller {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
  JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
  JMETHOD(void, pre_process_data, (j_compress_ptr cinfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
                                   JSAMPARRAY input_buf,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
                                   JDIMENSION *in_row_ctr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
                                   JDIMENSION in_rows_avail,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
                                   JSAMPIMAGE output_buf,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                                   JDIMENSION *out_row_group_ctr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                                   JDIMENSION out_row_groups_avail));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
/* Coefficient buffer control */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
struct jpeg_c_coef_controller {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
  JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
  JMETHOD(boolean, compress_data, (j_compress_ptr cinfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
                                   JSAMPIMAGE input_buf));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
/* Colorspace conversion */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
struct jpeg_color_converter {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
  JMETHOD(void, start_pass, (j_compress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
  JMETHOD(void, color_convert, (j_compress_ptr cinfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
                                JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                                JDIMENSION output_row, int num_rows));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
/* Downsampling */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
struct jpeg_downsampler {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
  JMETHOD(void, start_pass, (j_compress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
  JMETHOD(void, downsample, (j_compress_ptr cinfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
                             JSAMPIMAGE input_buf, JDIMENSION in_row_index,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                             JSAMPIMAGE output_buf,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                             JDIMENSION out_row_group_index));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
  boolean need_context_rows;    /* TRUE if need rows above & below */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
/* Forward DCT (also controls coefficient quantization) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
struct jpeg_forward_dct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
  JMETHOD(void, start_pass, (j_compress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
  /* perhaps this should be an array??? */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
  JMETHOD(void, forward_DCT, (j_compress_ptr cinfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
                              jpeg_component_info * compptr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                              JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                              JDIMENSION start_row, JDIMENSION start_col,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
                              JDIMENSION num_blocks));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
/* Entropy encoding */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
struct jpeg_entropy_encoder {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
  JMETHOD(void, start_pass, (j_compress_ptr cinfo, boolean gather_statistics));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
  JMETHOD(boolean, encode_mcu, (j_compress_ptr cinfo, JBLOCKROW *MCU_data));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
  JMETHOD(void, finish_pass, (j_compress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
/* Marker writing */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
struct jpeg_marker_writer {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
  JMETHOD(void, write_file_header, (j_compress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
  JMETHOD(void, write_frame_header, (j_compress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
  JMETHOD(void, write_scan_header, (j_compress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
  JMETHOD(void, write_file_trailer, (j_compress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
  JMETHOD(void, write_tables_only, (j_compress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
  /* These routines are exported to allow insertion of extra markers */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
  /* Probably only COM and APPn markers should be written this way */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
  JMETHOD(void, write_marker_header, (j_compress_ptr cinfo, int marker,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                                      unsigned int datalen));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
  JMETHOD(void, write_marker_byte, (j_compress_ptr cinfo, int val));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
/* Declarations for decompression modules */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
/* Master control module */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
struct jpeg_decomp_master {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
  JMETHOD(void, prepare_for_output_pass, (j_decompress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
  JMETHOD(void, finish_output_pass, (j_decompress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
  /* State variables made visible to other modules */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
  boolean is_dummy_pass;        /* True during 1st pass for 2-pass quant */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
/* Input control module */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
struct jpeg_input_controller {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
  JMETHOD(int, consume_input, (j_decompress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
  JMETHOD(void, reset_input_controller, (j_decompress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
  JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
  JMETHOD(void, finish_input_pass, (j_decompress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
  /* State variables made visible to other modules */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
  boolean has_multiple_scans;   /* True if file has multiple scans */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
  boolean eoi_reached;          /* True when EOI has been consumed */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
/* Main buffer control (downsampled-data buffer) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
struct jpeg_d_main_controller {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
  JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
  JMETHOD(void, process_data, (j_decompress_ptr cinfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                               JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                               JDIMENSION out_rows_avail));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
/* Coefficient buffer control */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
struct jpeg_d_coef_controller {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
  JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
  JMETHOD(int, consume_data, (j_decompress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
  JMETHOD(void, start_output_pass, (j_decompress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
  JMETHOD(int, decompress_data, (j_decompress_ptr cinfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                                 JSAMPIMAGE output_buf));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
  /* Pointer to array of coefficient virtual arrays, or NULL if none */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
  jvirt_barray_ptr *coef_arrays;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
/* Decompression postprocessing (color quantization buffer control) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
struct jpeg_d_post_controller {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
  JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
  JMETHOD(void, post_process_data, (j_decompress_ptr cinfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                                    JSAMPIMAGE input_buf,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                                    JDIMENSION *in_row_group_ctr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                                    JDIMENSION in_row_groups_avail,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                                    JSAMPARRAY output_buf,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                                    JDIMENSION *out_row_ctr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                                    JDIMENSION out_rows_avail));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
/* Marker reading & parsing */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
struct jpeg_marker_reader {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
  JMETHOD(void, reset_marker_reader, (j_decompress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
  /* Read markers until SOS or EOI.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
   * Returns same codes as are defined for jpeg_consume_input:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
   * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
  JMETHOD(int, read_markers, (j_decompress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
  /* Read a restart marker --- exported for use by entropy decoder only */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
  jpeg_marker_parser_method read_restart_marker;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
  /* State of marker reader --- nominally internal, but applications
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
   * supplying COM or APPn handlers might like to know the state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
  boolean saw_SOI;              /* found SOI? */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
  boolean saw_SOF;              /* found SOF? */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
  int next_restart_num;         /* next restart number expected (0-7) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
  unsigned int discarded_bytes; /* # of bytes skipped looking for a marker */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
/* Entropy decoding */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
struct jpeg_entropy_decoder {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
  JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
  JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                                JBLOCKROW *MCU_data));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
  /* This is here to share code between baseline and progressive decoders; */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
  /* other modules probably should not use it */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
  boolean insufficient_data;    /* set TRUE after emitting warning */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
/* Inverse DCT (also performs dequantization) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
typedef JMETHOD(void, inverse_DCT_method_ptr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                (j_decompress_ptr cinfo, jpeg_component_info * compptr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                 JCOEFPTR coef_block,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                 JSAMPARRAY output_buf, JDIMENSION output_col));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
struct jpeg_inverse_dct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
  JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
  /* It is useful to allow each component to have a separate IDCT method. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
  inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
/* Upsampling (note that upsampler must also call color converter) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
struct jpeg_upsampler {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
  JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
  JMETHOD(void, upsample, (j_decompress_ptr cinfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                           JSAMPIMAGE input_buf,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                           JDIMENSION *in_row_group_ctr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                           JDIMENSION in_row_groups_avail,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                           JSAMPARRAY output_buf,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                           JDIMENSION *out_row_ctr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                           JDIMENSION out_rows_avail));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
  boolean need_context_rows;    /* TRUE if need rows above & below */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
/* Colorspace conversion */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
struct jpeg_color_deconverter {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
  JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
  JMETHOD(void, color_convert, (j_decompress_ptr cinfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                                JSAMPIMAGE input_buf, JDIMENSION input_row,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                                JSAMPARRAY output_buf, int num_rows));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
/* Color quantization or color precision reduction */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
struct jpeg_color_quantizer {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
  JMETHOD(void, start_pass, (j_decompress_ptr cinfo, boolean is_pre_scan));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
  JMETHOD(void, color_quantize, (j_decompress_ptr cinfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                                 JSAMPARRAY input_buf, JSAMPARRAY output_buf,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                                 int num_rows));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
  JMETHOD(void, finish_pass, (j_decompress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
  JMETHOD(void, new_color_map, (j_decompress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
/* Miscellaneous useful macros */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
#undef MAX
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
#define MAX(a,b)        ((a) > (b) ? (a) : (b))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
#undef MIN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
#define MIN(a,b)        ((a) < (b) ? (a) : (b))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
/* We assume that right shift corresponds to signed division by 2 with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
 * rounding towards minus infinity.  This is correct for typical "arithmetic
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
 * shift" instructions that shift in copies of the sign bit.  But some
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
 * C compilers implement >> with an unsigned shift.  For these machines you
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
 * must define RIGHT_SHIFT_IS_UNSIGNED.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
 * RIGHT_SHIFT provides a proper signed right shift of an INT32 quantity.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
 * It is only applied with constant shift counts.  SHIFT_TEMPS must be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
 * included in the variables of any routine using RIGHT_SHIFT.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
#ifdef RIGHT_SHIFT_IS_UNSIGNED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
#define SHIFT_TEMPS     INT32 shift_temp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
#define RIGHT_SHIFT(x,shft)  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        ((shift_temp = (x)) < 0 ? \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
         (shift_temp >> (shft)) | ((~((INT32) 0)) << (32-(shft))) : \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
         (shift_temp >> (shft)))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
#define SHIFT_TEMPS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
#define RIGHT_SHIFT(x,shft)     ((x) >> (shft))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
/* Short forms of external names for systems with brain-damaged linkers. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
#ifdef NEED_SHORT_EXTERNAL_NAMES
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
#define jinit_compress_master   jICompress
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
#define jinit_c_master_control  jICMaster
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
#define jinit_c_main_controller jICMainC
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
#define jinit_c_prep_controller jICPrepC
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
#define jinit_c_coef_controller jICCoefC
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
#define jinit_color_converter   jICColor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
#define jinit_downsampler       jIDownsampler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
#define jinit_forward_dct       jIFDCT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
#define jinit_huff_encoder      jIHEncoder
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
#define jinit_phuff_encoder     jIPHEncoder
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
#define jinit_marker_writer     jIMWriter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
#define jinit_master_decompress jIDMaster
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
#define jinit_d_main_controller jIDMainC
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
#define jinit_d_coef_controller jIDCoefC
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
#define jinit_d_post_controller jIDPostC
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
#define jinit_input_controller  jIInCtlr
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
#define jinit_marker_reader     jIMReader
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
#define jinit_huff_decoder      jIHDecoder
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
#define jinit_phuff_decoder     jIPHDecoder
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
#define jinit_inverse_dct       jIIDCT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
#define jinit_upsampler         jIUpsampler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
#define jinit_color_deconverter jIDColor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
#define jinit_1pass_quantizer   jI1Quant
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
#define jinit_2pass_quantizer   jI2Quant
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
#define jinit_merged_upsampler  jIMUpsampler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
#define jinit_memory_mgr        jIMemMgr
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
#define jdiv_round_up           jDivRound
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
#define jround_up               jRound
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
#define jcopy_sample_rows       jCopySamples
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
#define jcopy_block_row         jCopyBlocks
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
#define jzero_far               jZeroFar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
#define jpeg_zigzag_order       jZIGTable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
#define jpeg_natural_order      jZAGTable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
#endif /* NEED_SHORT_EXTERNAL_NAMES */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
/* Compression module initialization routines */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
EXTERN(void) jinit_compress_master JPP((j_compress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
EXTERN(void) jinit_c_master_control JPP((j_compress_ptr cinfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
                                         boolean transcode_only));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
EXTERN(void) jinit_c_main_controller JPP((j_compress_ptr cinfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                                          boolean need_full_buffer));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
EXTERN(void) jinit_c_prep_controller JPP((j_compress_ptr cinfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
                                          boolean need_full_buffer));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
EXTERN(void) jinit_c_coef_controller JPP((j_compress_ptr cinfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
                                          boolean need_full_buffer));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
EXTERN(void) jinit_color_converter JPP((j_compress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
EXTERN(void) jinit_downsampler JPP((j_compress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
EXTERN(void) jinit_forward_dct JPP((j_compress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
EXTERN(void) jinit_huff_encoder JPP((j_compress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
EXTERN(void) jinit_phuff_encoder JPP((j_compress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
EXTERN(void) jinit_marker_writer JPP((j_compress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
/* Decompression module initialization routines */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
EXTERN(void) jinit_master_decompress JPP((j_decompress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
EXTERN(void) jinit_d_main_controller JPP((j_decompress_ptr cinfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
                                          boolean need_full_buffer));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
EXTERN(void) jinit_d_coef_controller JPP((j_decompress_ptr cinfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
                                          boolean need_full_buffer));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
EXTERN(void) jinit_d_post_controller JPP((j_decompress_ptr cinfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
                                          boolean need_full_buffer));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
EXTERN(void) jinit_input_controller JPP((j_decompress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
EXTERN(void) jinit_marker_reader JPP((j_decompress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
EXTERN(void) jinit_huff_decoder JPP((j_decompress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
EXTERN(void) jinit_phuff_decoder JPP((j_decompress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
EXTERN(void) jinit_inverse_dct JPP((j_decompress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
EXTERN(void) jinit_upsampler JPP((j_decompress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
EXTERN(void) jinit_color_deconverter JPP((j_decompress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
EXTERN(void) jinit_1pass_quantizer JPP((j_decompress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
EXTERN(void) jinit_2pass_quantizer JPP((j_decompress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
EXTERN(void) jinit_merged_upsampler JPP((j_decompress_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
/* Memory manager initialization */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
EXTERN(void) jinit_memory_mgr JPP((j_common_ptr cinfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
/* Utility routines in jutils.c */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
EXTERN(long) jdiv_round_up JPP((long a, long b));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
EXTERN(long) jround_up JPP((long a, long b));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
EXTERN(void) jcopy_sample_rows JPP((JSAMPARRAY input_array, int source_row,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
                                    JSAMPARRAY output_array, int dest_row,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
                                    int num_rows, JDIMENSION num_cols));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
EXTERN(void) jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
                                  JDIMENSION num_blocks));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
EXTERN(void) jzero_far JPP((void FAR * target, size_t bytestozero));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
/* Constant tables in jutils.c */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
#if 0                           /* This table is not actually needed in v6a */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
/* Suppress undefined-structure complaints if necessary. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
#ifdef INCOMPLETE_TYPES_BROKEN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
#ifndef AM_MEMORY_MANAGER       /* only jmemmgr.c defines these */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
struct jvirt_sarray_control { long dummy; };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
struct jvirt_barray_control { long dummy; };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
#endif /* INCOMPLETE_TYPES_BROKEN */