Reconcile indentation, whitespace, and other code formatting with libjpeg-turbo.
For whatever reason, some of these files didn't get fully merged from libjpeg-turbo 1.4. They still contained tab characters and other formatting conventions from libjpeg-turbo 1.3. This patch also fixes some obvious indentation errors in the mozjpeg-specific code. There is more formatting work that needs to be done to the mozjpeg-specific code, to fix line overruns, incorrect operator whitespace, and other issues that make it not consistent with the libjpeg/libjpeg-turbo code.
This commit is contained in:
26
cdjpeg.h
26
cdjpeg.h
@@ -13,12 +13,12 @@
|
|||||||
* cjpeg and djpeg. It is NOT used by the core JPEG library.
|
* cjpeg and djpeg. It is NOT used by the core JPEG library.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define JPEG_CJPEG_DJPEG /* define proper options in jconfig.h */
|
#define JPEG_CJPEG_DJPEG /* define proper options in jconfig.h */
|
||||||
#define JPEG_INTERNAL_OPTIONS /* cjpeg.c,djpeg.c need to see xxx_SUPPORTED */
|
#define JPEG_INTERNAL_OPTIONS /* cjpeg.c,djpeg.c need to see xxx_SUPPORTED */
|
||||||
#include "jinclude.h"
|
#include "jinclude.h"
|
||||||
#include "jpeglib.h"
|
#include "jpeglib.h"
|
||||||
#include "jerror.h" /* get library error codes too */
|
#include "jerror.h" /* get library error codes too */
|
||||||
#include "cderror.h" /* get application-specific error codes */
|
#include "cderror.h" /* get application-specific error codes */
|
||||||
|
|
||||||
#define JPEG_RAW_READER 0
|
#define JPEG_RAW_READER 0
|
||||||
|
|
||||||
@@ -85,9 +85,9 @@ struct djpeg_dest_struct {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
struct cdjpeg_progress_mgr {
|
struct cdjpeg_progress_mgr {
|
||||||
struct jpeg_progress_mgr pub; /* fields known to JPEG library */
|
struct jpeg_progress_mgr pub; /* fields known to JPEG library */
|
||||||
int completed_extra_passes; /* extra passes completed */
|
int completed_extra_passes; /* extra passes completed */
|
||||||
int total_extra_passes; /* total extra */
|
int total_extra_passes; /* total extra */
|
||||||
/* last printed percentage stored here to avoid multiple printouts */
|
/* last printed percentage stored here to avoid multiple printouts */
|
||||||
int percent_done;
|
int percent_done;
|
||||||
};
|
};
|
||||||
@@ -137,15 +137,15 @@ EXTERN(FILE *) write_stdout (void);
|
|||||||
|
|
||||||
/* miscellaneous useful macros */
|
/* miscellaneous useful macros */
|
||||||
|
|
||||||
#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */
|
#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */
|
||||||
#define READ_BINARY "r"
|
#define READ_BINARY "r"
|
||||||
#define WRITE_BINARY "w"
|
#define WRITE_BINARY "w"
|
||||||
#else
|
#else
|
||||||
#define READ_BINARY "rb"
|
#define READ_BINARY "rb"
|
||||||
#define WRITE_BINARY "wb"
|
#define WRITE_BINARY "wb"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef EXIT_FAILURE /* define exit() codes if not provided */
|
#ifndef EXIT_FAILURE /* define exit() codes if not provided */
|
||||||
#define EXIT_FAILURE 1
|
#define EXIT_FAILURE 1
|
||||||
#endif
|
#endif
|
||||||
#ifndef EXIT_SUCCESS
|
#ifndef EXIT_SUCCESS
|
||||||
|
|||||||
21
cjpeg.c
21
cjpeg.c
@@ -294,7 +294,7 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
|
|
||||||
} else if (keymatch(arg, "dct", 2)) {
|
} else if (keymatch(arg, "dct", 2)) {
|
||||||
/* Select DCT algorithm. */
|
/* Select DCT algorithm. */
|
||||||
if (++argn >= argc) { /* advance to next argument */
|
if (++argn >= argc) { /* advance to next argument */
|
||||||
fprintf(stderr, "%s: missing argument for dct\n", progname);
|
fprintf(stderr, "%s: missing argument for dct\n", progname);
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
@@ -340,14 +340,14 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
jpeg_set_colorspace(cinfo, JCS_RGB);
|
jpeg_set_colorspace(cinfo, JCS_RGB);
|
||||||
|
|
||||||
} else if (keymatch(arg, "lambda1", 7)) {
|
} else if (keymatch(arg, "lambda1", 7)) {
|
||||||
if (++argn >= argc) /* advance to next argument */
|
if (++argn >= argc) /* advance to next argument */
|
||||||
usage();
|
usage();
|
||||||
jpeg_c_set_float_param(cinfo, JFLOAT_LAMBDA_LOG_SCALE1,
|
jpeg_c_set_float_param(cinfo, JFLOAT_LAMBDA_LOG_SCALE1,
|
||||||
atof(argv[argn]));
|
atof(argv[argn]));
|
||||||
|
|
||||||
} else if (keymatch(arg, "lambda2", 7)) {
|
} else if (keymatch(arg, "lambda2", 7)) {
|
||||||
if (++argn >= argc) /* advance to next argument */
|
if (++argn >= argc) /* advance to next argument */
|
||||||
usage();
|
usage();
|
||||||
jpeg_c_set_float_param(cinfo, JFLOAT_LAMBDA_LOG_SCALE2,
|
jpeg_c_set_float_param(cinfo, JFLOAT_LAMBDA_LOG_SCALE2,
|
||||||
atof(argv[argn]));
|
atof(argv[argn]));
|
||||||
|
|
||||||
@@ -379,7 +379,7 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
|
|
||||||
} else if (keymatch(arg, "outfile", 4)) {
|
} else if (keymatch(arg, "outfile", 4)) {
|
||||||
/* Set output file name. */
|
/* Set output file name. */
|
||||||
if (++argn >= argc) { /* advance to next argument */
|
if (++argn >= argc) { /* advance to next argument */
|
||||||
fprintf(stderr, "%s: missing argument for outfile\n", progname);
|
fprintf(stderr, "%s: missing argument for outfile\n", progname);
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
@@ -408,7 +408,7 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
|
|
||||||
} else if (keymatch(arg, "quality", 1)) {
|
} else if (keymatch(arg, "quality", 1)) {
|
||||||
/* Quality ratings (quantization table scaling factors). */
|
/* Quality ratings (quantization table scaling factors). */
|
||||||
if (++argn >= argc) { /* advance to next argument */
|
if (++argn >= argc) { /* advance to next argument */
|
||||||
fprintf(stderr, "%s: missing argument for quality\n", progname);
|
fprintf(stderr, "%s: missing argument for quality\n", progname);
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
@@ -743,7 +743,7 @@ main (int argc, char **argv)
|
|||||||
GETJOCTET(marker->data[2]) == 0x49 &&
|
GETJOCTET(marker->data[2]) == 0x49 &&
|
||||||
GETJOCTET(marker->data[3]) == 0x46 &&
|
GETJOCTET(marker->data[3]) == 0x46 &&
|
||||||
GETJOCTET(marker->data[4]) == 0)
|
GETJOCTET(marker->data[4]) == 0)
|
||||||
continue; /* reject duplicate JFIF */
|
continue; /* reject duplicate JFIF */
|
||||||
if (cinfo.write_Adobe_marker &&
|
if (cinfo.write_Adobe_marker &&
|
||||||
marker->marker == JPEG_APP0+14 &&
|
marker->marker == JPEG_APP0+14 &&
|
||||||
marker->data_length >= 5 &&
|
marker->data_length >= 5 &&
|
||||||
@@ -752,8 +752,9 @@ main (int argc, char **argv)
|
|||||||
GETJOCTET(marker->data[2]) == 0x6F &&
|
GETJOCTET(marker->data[2]) == 0x6F &&
|
||||||
GETJOCTET(marker->data[3]) == 0x62 &&
|
GETJOCTET(marker->data[3]) == 0x62 &&
|
||||||
GETJOCTET(marker->data[4]) == 0x65)
|
GETJOCTET(marker->data[4]) == 0x65)
|
||||||
continue; /* reject duplicate Adobe */
|
continue; /* reject duplicate Adobe */
|
||||||
jpeg_write_marker(&cinfo, marker->marker, marker->data, marker->data_length);
|
jpeg_write_marker(&cinfo, marker->marker, marker->data,
|
||||||
|
marker->data_length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
50
jccoefct.c
50
jccoefct.c
@@ -19,6 +19,7 @@
|
|||||||
#include "jpeglib.h"
|
#include "jpeglib.h"
|
||||||
#include "jchuff.h"
|
#include "jchuff.h"
|
||||||
|
|
||||||
|
|
||||||
/* We use a full-image coefficient buffer when doing Huffman optimization,
|
/* We use a full-image coefficient buffer when doing Huffman optimization,
|
||||||
* and also for writing multiple-scan JPEG files. In all cases, the DCT
|
* and also for writing multiple-scan JPEG files. In all cases, the DCT
|
||||||
* step is run during the first pass, and subsequent passes need only read
|
* step is run during the first pass, and subsequent passes need only read
|
||||||
@@ -190,7 +191,8 @@ compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
|||||||
(*cinfo->fdct->forward_DCT) (cinfo, compptr,
|
(*cinfo->fdct->forward_DCT) (cinfo, compptr,
|
||||||
input_buf[compptr->component_index],
|
input_buf[compptr->component_index],
|
||||||
coef->MCU_buffer[blkn],
|
coef->MCU_buffer[blkn],
|
||||||
ypos, xpos, (JDIMENSION) blockcnt, NULL);
|
ypos, xpos, (JDIMENSION) blockcnt,
|
||||||
|
NULL);
|
||||||
if (blockcnt < compptr->MCU_width) {
|
if (blockcnt < compptr->MCU_width) {
|
||||||
/* Create some dummy blocks at the right edge of the image. */
|
/* Create some dummy blocks at the right edge of the image. */
|
||||||
jzero_far((void *) coef->MCU_buffer[blkn + blockcnt],
|
jzero_far((void *) coef->MCU_buffer[blkn + blockcnt],
|
||||||
@@ -302,7 +304,8 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
|||||||
(*cinfo->fdct->forward_DCT) (cinfo, compptr,
|
(*cinfo->fdct->forward_DCT) (cinfo, compptr,
|
||||||
input_buf[ci], thisblockrow,
|
input_buf[ci], thisblockrow,
|
||||||
(JDIMENSION) (block_row * DCTSIZE),
|
(JDIMENSION) (block_row * DCTSIZE),
|
||||||
(JDIMENSION) 0, blocks_across, buffer_dst[block_row]);
|
(JDIMENSION) 0, blocks_across,
|
||||||
|
buffer_dst[block_row]);
|
||||||
if (ndummy > 0) {
|
if (ndummy > 0) {
|
||||||
/* Create dummy blocks at the right edge of the image. */
|
/* Create dummy blocks at the right edge of the image. */
|
||||||
thisblockrow += blocks_across; /* => first dummy block */
|
thisblockrow += blocks_across; /* => first dummy block */
|
||||||
@@ -410,13 +413,13 @@ compress_trellis_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
|||||||
&lastDC);
|
&lastDC);
|
||||||
|
|
||||||
if (ndummy > 0) {
|
if (ndummy > 0) {
|
||||||
/* Create dummy blocks at the right edge of the image. */
|
/* Create dummy blocks at the right edge of the image. */
|
||||||
thisblockrow += blocks_across; /* => first dummy block */
|
thisblockrow += blocks_across; /* => first dummy block */
|
||||||
jzero_far((void *) thisblockrow, ndummy * sizeof(JBLOCK));
|
jzero_far((void *) thisblockrow, ndummy * sizeof(JBLOCK));
|
||||||
lastDC = thisblockrow[-1][0];
|
lastDC = thisblockrow[-1][0];
|
||||||
for (bi = 0; bi < ndummy; bi++) {
|
for (bi = 0; bi < ndummy; bi++) {
|
||||||
thisblockrow[bi][0] = lastDC;
|
thisblockrow[bi][0] = lastDC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* If at end of image, create dummy block rows as needed.
|
/* If at end of image, create dummy block rows as needed.
|
||||||
@@ -425,22 +428,22 @@ compress_trellis_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
|||||||
* This squeezes a few more bytes out of the resulting file...
|
* This squeezes a few more bytes out of the resulting file...
|
||||||
*/
|
*/
|
||||||
if (coef->iMCU_row_num == last_iMCU_row) {
|
if (coef->iMCU_row_num == last_iMCU_row) {
|
||||||
blocks_across += ndummy; /* include lower right corner */
|
blocks_across += ndummy; /* include lower right corner */
|
||||||
MCUs_across = blocks_across / h_samp_factor;
|
MCUs_across = blocks_across / h_samp_factor;
|
||||||
for (block_row = block_rows; block_row < compptr->v_samp_factor;
|
for (block_row = block_rows; block_row < compptr->v_samp_factor;
|
||||||
block_row++) {
|
block_row++) {
|
||||||
thisblockrow = buffer[block_row];
|
thisblockrow = buffer[block_row];
|
||||||
lastblockrow = buffer[block_row-1];
|
lastblockrow = buffer[block_row-1];
|
||||||
jzero_far((void *) thisblockrow,
|
jzero_far((void *) thisblockrow,
|
||||||
(size_t) (blocks_across * sizeof(JBLOCK)));
|
(size_t) (blocks_across * sizeof(JBLOCK)));
|
||||||
for (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) {
|
for (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) {
|
||||||
lastDC = lastblockrow[h_samp_factor-1][0];
|
lastDC = lastblockrow[h_samp_factor-1][0];
|
||||||
for (bi = 0; bi < h_samp_factor; bi++) {
|
for (bi = 0; bi < h_samp_factor; bi++) {
|
||||||
thisblockrow[bi][0] = lastDC;
|
thisblockrow[bi][0] = lastDC;
|
||||||
}
|
}
|
||||||
thisblockrow += h_samp_factor; /* advance to next MCU in row */
|
thisblockrow += h_samp_factor; /* advance to next MCU in row */
|
||||||
lastblockrow += h_samp_factor;
|
lastblockrow += h_samp_factor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -503,7 +506,6 @@ compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try to write the MCU. */
|
/* Try to write the MCU. */
|
||||||
if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
|
if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
|
||||||
/* Suspension forced; update state counters and exit */
|
/* Suspension forced; update state counters and exit */
|
||||||
|
|||||||
23
jcdctmgr.c
23
jcdctmgr.c
@@ -25,6 +25,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
|
||||||
/* Private subobject for this module */
|
/* Private subobject for this module */
|
||||||
|
|
||||||
typedef void (*forward_DCT_method_ptr) (DCTELEM * data);
|
typedef void (*forward_DCT_method_ptr) (DCTELEM * data);
|
||||||
@@ -663,7 +664,7 @@ METHODDEF(void)
|
|||||||
forward_DCT (j_compress_ptr cinfo, jpeg_component_info * compptr,
|
forward_DCT (j_compress_ptr cinfo, jpeg_component_info * compptr,
|
||||||
JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
|
JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
|
||||||
JDIMENSION start_row, JDIMENSION start_col,
|
JDIMENSION start_row, JDIMENSION start_col,
|
||||||
JDIMENSION num_blocks, JBLOCKROW dst)
|
JDIMENSION num_blocks, JBLOCKROW dst)
|
||||||
/* This version is used for integer DCT implementations. */
|
/* This version is used for integer DCT implementations. */
|
||||||
{
|
{
|
||||||
/* This routine is heavily used, so it's worth coding it tightly. */
|
/* This routine is heavily used, so it's worth coding it tightly. */
|
||||||
@@ -697,17 +698,17 @@ forward_DCT (j_compress_ptr cinfo, jpeg_component_info * compptr,
|
|||||||
if (dst) {
|
if (dst) {
|
||||||
int i;
|
int i;
|
||||||
if (cinfo->dct_method == JDCT_IFAST) {
|
if (cinfo->dct_method == JDCT_IFAST) {
|
||||||
static const INT16 aanscales[DCTSIZE2] = {
|
static const INT16 aanscales[DCTSIZE2] = {
|
||||||
/* precomputed values scaled up by 14 bits */
|
/* precomputed values scaled up by 14 bits */
|
||||||
16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520,
|
16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520,
|
||||||
22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270,
|
22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270,
|
||||||
21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906,
|
21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906,
|
||||||
19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315,
|
19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315,
|
||||||
16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520,
|
16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520,
|
||||||
12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552,
|
12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552,
|
||||||
8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446,
|
8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446,
|
||||||
4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247
|
4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247
|
||||||
};
|
};
|
||||||
|
|
||||||
for (i = 0; i < DCTSIZE2; i++) {
|
for (i = 0; i < DCTSIZE2; i++) {
|
||||||
int x = workspace[i];
|
int x = workspace[i];
|
||||||
@@ -789,7 +790,7 @@ METHODDEF(void)
|
|||||||
forward_DCT_float (j_compress_ptr cinfo, jpeg_component_info * compptr,
|
forward_DCT_float (j_compress_ptr cinfo, jpeg_component_info * compptr,
|
||||||
JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
|
JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
|
||||||
JDIMENSION start_row, JDIMENSION start_col,
|
JDIMENSION start_row, JDIMENSION start_col,
|
||||||
JDIMENSION num_blocks, JBLOCKROW dst)
|
JDIMENSION num_blocks, JBLOCKROW dst)
|
||||||
/* This version is used for floating-point DCT implementations. */
|
/* This version is used for floating-point DCT implementations. */
|
||||||
{
|
{
|
||||||
/* This routine is heavily used, so it's worth coding it tightly. */
|
/* This routine is heavily used, so it's worth coding it tightly. */
|
||||||
|
|||||||
4
jchuff.h
4
jchuff.h
@@ -29,8 +29,8 @@
|
|||||||
/* Derived data constructed for each Huffman table */
|
/* Derived data constructed for each Huffman table */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned int ehufco[256]; /* code for each symbol */
|
unsigned int ehufco[256]; /* code for each symbol */
|
||||||
char ehufsi[256]; /* length of code for each symbol */
|
char ehufsi[256]; /* length of code for each symbol */
|
||||||
/* If no code has been allocated for a symbol S, ehufsi[S] contains 0 */
|
/* If no code has been allocated for a symbol S, ehufsi[S] contains 0 */
|
||||||
} c_derived_tbl;
|
} c_derived_tbl;
|
||||||
|
|
||||||
|
|||||||
124
jcmarker.c
124
jcmarker.c
@@ -17,7 +17,7 @@
|
|||||||
#include "jpegcomp.h"
|
#include "jpegcomp.h"
|
||||||
|
|
||||||
|
|
||||||
typedef enum { /* JPEG marker codes */
|
typedef enum { /* JPEG marker codes */
|
||||||
M_SOF0 = 0xc0,
|
M_SOF0 = 0xc0,
|
||||||
M_SOF1 = 0xc1,
|
M_SOF1 = 0xc1,
|
||||||
M_SOF2 = 0xc2,
|
M_SOF2 = 0xc2,
|
||||||
@@ -173,7 +173,7 @@ emit_dqt (j_compress_ptr cinfo, int index)
|
|||||||
/* The table entries must be emitted in zigzag order. */
|
/* The table entries must be emitted in zigzag order. */
|
||||||
unsigned int qval = qtbl->quantval[jpeg_natural_order[i]];
|
unsigned int qval = qtbl->quantval[jpeg_natural_order[i]];
|
||||||
if (prec)
|
if (prec)
|
||||||
emit_byte(cinfo, (int) (qval >> 8));
|
emit_byte(cinfo, (int) (qval >> 8));
|
||||||
emit_byte(cinfo, (int) (qval & 0xFF));
|
emit_byte(cinfo, (int) (qval & 0xFF));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,33 +253,33 @@ emit_dht (j_compress_ptr cinfo, int index, boolean is_ac)
|
|||||||
{
|
{
|
||||||
JHUFF_TBL * htbl;
|
JHUFF_TBL * htbl;
|
||||||
int length, i;
|
int length, i;
|
||||||
|
|
||||||
if (is_ac) {
|
if (is_ac) {
|
||||||
htbl = cinfo->ac_huff_tbl_ptrs[index];
|
htbl = cinfo->ac_huff_tbl_ptrs[index];
|
||||||
index += 0x10; /* output index has AC bit set */
|
index += 0x10; /* output index has AC bit set */
|
||||||
} else {
|
} else {
|
||||||
htbl = cinfo->dc_huff_tbl_ptrs[index];
|
htbl = cinfo->dc_huff_tbl_ptrs[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (htbl == NULL)
|
if (htbl == NULL)
|
||||||
ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, index);
|
ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, index);
|
||||||
|
|
||||||
if (! htbl->sent_table) {
|
if (! htbl->sent_table) {
|
||||||
emit_marker(cinfo, M_DHT);
|
emit_marker(cinfo, M_DHT);
|
||||||
|
|
||||||
length = 0;
|
length = 0;
|
||||||
for (i = 1; i <= 16; i++)
|
for (i = 1; i <= 16; i++)
|
||||||
length += htbl->bits[i];
|
length += htbl->bits[i];
|
||||||
|
|
||||||
emit_2bytes(cinfo, length + 2 + 1 + 16);
|
emit_2bytes(cinfo, length + 2 + 1 + 16);
|
||||||
emit_byte(cinfo, index);
|
emit_byte(cinfo, index);
|
||||||
|
|
||||||
for (i = 1; i <= 16; i++)
|
for (i = 1; i <= 16; i++)
|
||||||
emit_byte(cinfo, htbl->bits[i]);
|
emit_byte(cinfo, htbl->bits[i]);
|
||||||
|
|
||||||
for (i = 0; i < length; i++)
|
for (i = 0; i < length; i++)
|
||||||
emit_byte(cinfo, htbl->huffval[i]);
|
emit_byte(cinfo, htbl->huffval[i]);
|
||||||
|
|
||||||
htbl->sent_table = TRUE;
|
htbl->sent_table = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -427,12 +427,12 @@ emit_dac (j_compress_ptr cinfo)
|
|||||||
|
|
||||||
for (i = 0; i < NUM_ARITH_TBLS; i++) {
|
for (i = 0; i < NUM_ARITH_TBLS; i++) {
|
||||||
if (dc_in_use[i]) {
|
if (dc_in_use[i]) {
|
||||||
emit_byte(cinfo, i);
|
emit_byte(cinfo, i);
|
||||||
emit_byte(cinfo, cinfo->arith_dc_L[i] + (cinfo->arith_dc_U[i]<<4));
|
emit_byte(cinfo, cinfo->arith_dc_L[i] + (cinfo->arith_dc_U[i]<<4));
|
||||||
}
|
}
|
||||||
if (ac_in_use[i]) {
|
if (ac_in_use[i]) {
|
||||||
emit_byte(cinfo, i + 0x10);
|
emit_byte(cinfo, i + 0x10);
|
||||||
emit_byte(cinfo, cinfo->arith_ac_K[i]);
|
emit_byte(cinfo, cinfo->arith_ac_K[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -445,8 +445,8 @@ emit_dri (j_compress_ptr cinfo)
|
|||||||
/* Emit a DRI marker */
|
/* Emit a DRI marker */
|
||||||
{
|
{
|
||||||
emit_marker(cinfo, M_DRI);
|
emit_marker(cinfo, M_DRI);
|
||||||
|
|
||||||
emit_2bytes(cinfo, 4); /* fixed length */
|
emit_2bytes(cinfo, 4); /* fixed length */
|
||||||
|
|
||||||
emit_2bytes(cinfo, (int) cinfo->restart_interval);
|
emit_2bytes(cinfo, (int) cinfo->restart_interval);
|
||||||
}
|
}
|
||||||
@@ -458,9 +458,9 @@ emit_sof (j_compress_ptr cinfo, JPEG_MARKER code)
|
|||||||
{
|
{
|
||||||
int ci;
|
int ci;
|
||||||
jpeg_component_info *compptr;
|
jpeg_component_info *compptr;
|
||||||
|
|
||||||
emit_marker(cinfo, code);
|
emit_marker(cinfo, code);
|
||||||
|
|
||||||
emit_2bytes(cinfo, 3 * cinfo->num_components + 2 + 5 + 1); /* length */
|
emit_2bytes(cinfo, 3 * cinfo->num_components + 2 + 5 + 1); /* length */
|
||||||
|
|
||||||
/* Make sure image isn't bigger than SOF field can handle */
|
/* Make sure image isn't bigger than SOF field can handle */
|
||||||
@@ -489,13 +489,13 @@ emit_sos (j_compress_ptr cinfo)
|
|||||||
{
|
{
|
||||||
int i, td, ta;
|
int i, td, ta;
|
||||||
jpeg_component_info *compptr;
|
jpeg_component_info *compptr;
|
||||||
|
|
||||||
emit_marker(cinfo, M_SOS);
|
emit_marker(cinfo, M_SOS);
|
||||||
|
|
||||||
emit_2bytes(cinfo, 2 * cinfo->comps_in_scan + 2 + 1 + 3); /* length */
|
emit_2bytes(cinfo, 2 * cinfo->comps_in_scan + 2 + 1 + 3); /* length */
|
||||||
|
|
||||||
emit_byte(cinfo, cinfo->comps_in_scan);
|
emit_byte(cinfo, cinfo->comps_in_scan);
|
||||||
|
|
||||||
for (i = 0; i < cinfo->comps_in_scan; i++) {
|
for (i = 0; i < cinfo->comps_in_scan; i++) {
|
||||||
compptr = cinfo->cur_comp_info[i];
|
compptr = cinfo->cur_comp_info[i];
|
||||||
emit_byte(cinfo, compptr->component_id);
|
emit_byte(cinfo, compptr->component_id);
|
||||||
@@ -523,22 +523,22 @@ emit_jfif_app0 (j_compress_ptr cinfo)
|
|||||||
/* Emit a JFIF-compliant APP0 marker */
|
/* Emit a JFIF-compliant APP0 marker */
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Length of APP0 block (2 bytes)
|
* Length of APP0 block (2 bytes)
|
||||||
* Block ID (4 bytes - ASCII "JFIF")
|
* Block ID (4 bytes - ASCII "JFIF")
|
||||||
* Zero byte (1 byte to terminate the ID string)
|
* Zero byte (1 byte to terminate the ID string)
|
||||||
* Version Major, Minor (2 bytes - major first)
|
* Version Major, Minor (2 bytes - major first)
|
||||||
* Units (1 byte - 0x00 = none, 0x01 = inch, 0x02 = cm)
|
* Units (1 byte - 0x00 = none, 0x01 = inch, 0x02 = cm)
|
||||||
* Xdpu (2 bytes - dots per unit horizontal)
|
* Xdpu (2 bytes - dots per unit horizontal)
|
||||||
* Ydpu (2 bytes - dots per unit vertical)
|
* Ydpu (2 bytes - dots per unit vertical)
|
||||||
* Thumbnail X size (1 byte)
|
* Thumbnail X size (1 byte)
|
||||||
* Thumbnail Y size (1 byte)
|
* Thumbnail Y size (1 byte)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
emit_marker(cinfo, M_APP0);
|
emit_marker(cinfo, M_APP0);
|
||||||
|
|
||||||
emit_2bytes(cinfo, 2 + 4 + 1 + 2 + 1 + 2 + 2 + 1 + 1); /* length */
|
emit_2bytes(cinfo, 2 + 4 + 1 + 2 + 1 + 2 + 2 + 1 + 1); /* length */
|
||||||
|
|
||||||
emit_byte(cinfo, 0x4A); /* Identifier: ASCII "JFIF" */
|
emit_byte(cinfo, 0x4A); /* Identifier: ASCII "JFIF" */
|
||||||
emit_byte(cinfo, 0x46);
|
emit_byte(cinfo, 0x46);
|
||||||
emit_byte(cinfo, 0x49);
|
emit_byte(cinfo, 0x49);
|
||||||
emit_byte(cinfo, 0x46);
|
emit_byte(cinfo, 0x46);
|
||||||
@@ -548,7 +548,7 @@ emit_jfif_app0 (j_compress_ptr cinfo)
|
|||||||
emit_byte(cinfo, cinfo->density_unit); /* Pixel size information */
|
emit_byte(cinfo, cinfo->density_unit); /* Pixel size information */
|
||||||
emit_2bytes(cinfo, (int) cinfo->X_density);
|
emit_2bytes(cinfo, (int) cinfo->X_density);
|
||||||
emit_2bytes(cinfo, (int) cinfo->Y_density);
|
emit_2bytes(cinfo, (int) cinfo->Y_density);
|
||||||
emit_byte(cinfo, 0); /* No thumbnail image */
|
emit_byte(cinfo, 0); /* No thumbnail image */
|
||||||
emit_byte(cinfo, 0);
|
emit_byte(cinfo, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -558,12 +558,12 @@ emit_adobe_app14 (j_compress_ptr cinfo)
|
|||||||
/* Emit an Adobe APP14 marker */
|
/* Emit an Adobe APP14 marker */
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Length of APP14 block (2 bytes)
|
* Length of APP14 block (2 bytes)
|
||||||
* Block ID (5 bytes - ASCII "Adobe")
|
* Block ID (5 bytes - ASCII "Adobe")
|
||||||
* Version Number (2 bytes - currently 100)
|
* Version Number (2 bytes - currently 100)
|
||||||
* Flags0 (2 bytes - currently 0)
|
* Flags0 (2 bytes - currently 0)
|
||||||
* Flags1 (2 bytes - currently 0)
|
* Flags1 (2 bytes - currently 0)
|
||||||
* Color transform (1 byte)
|
* Color transform (1 byte)
|
||||||
*
|
*
|
||||||
* Although Adobe TN 5116 mentions Version = 101, all the Adobe files
|
* Although Adobe TN 5116 mentions Version = 101, all the Adobe files
|
||||||
* now in circulation seem to use Version = 100, so that's what we write.
|
* now in circulation seem to use Version = 100, so that's what we write.
|
||||||
@@ -572,28 +572,28 @@ emit_adobe_app14 (j_compress_ptr cinfo)
|
|||||||
* YCbCr, 2 if it's YCCK, 0 otherwise. Adobe's definition has to do with
|
* YCbCr, 2 if it's YCCK, 0 otherwise. Adobe's definition has to do with
|
||||||
* whether the encoder performed a transformation, which is pretty useless.
|
* whether the encoder performed a transformation, which is pretty useless.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
emit_marker(cinfo, M_APP14);
|
emit_marker(cinfo, M_APP14);
|
||||||
|
|
||||||
emit_2bytes(cinfo, 2 + 5 + 2 + 2 + 2 + 1); /* length */
|
emit_2bytes(cinfo, 2 + 5 + 2 + 2 + 2 + 1); /* length */
|
||||||
|
|
||||||
emit_byte(cinfo, 0x41); /* Identifier: ASCII "Adobe" */
|
emit_byte(cinfo, 0x41); /* Identifier: ASCII "Adobe" */
|
||||||
emit_byte(cinfo, 0x64);
|
emit_byte(cinfo, 0x64);
|
||||||
emit_byte(cinfo, 0x6F);
|
emit_byte(cinfo, 0x6F);
|
||||||
emit_byte(cinfo, 0x62);
|
emit_byte(cinfo, 0x62);
|
||||||
emit_byte(cinfo, 0x65);
|
emit_byte(cinfo, 0x65);
|
||||||
emit_2bytes(cinfo, 100); /* Version */
|
emit_2bytes(cinfo, 100); /* Version */
|
||||||
emit_2bytes(cinfo, 0); /* Flags0 */
|
emit_2bytes(cinfo, 0); /* Flags0 */
|
||||||
emit_2bytes(cinfo, 0); /* Flags1 */
|
emit_2bytes(cinfo, 0); /* Flags1 */
|
||||||
switch (cinfo->jpeg_color_space) {
|
switch (cinfo->jpeg_color_space) {
|
||||||
case JCS_YCbCr:
|
case JCS_YCbCr:
|
||||||
emit_byte(cinfo, 1); /* Color transform = 1 */
|
emit_byte(cinfo, 1); /* Color transform = 1 */
|
||||||
break;
|
break;
|
||||||
case JCS_YCCK:
|
case JCS_YCCK:
|
||||||
emit_byte(cinfo, 2); /* Color transform = 2 */
|
emit_byte(cinfo, 2); /* Color transform = 2 */
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
emit_byte(cinfo, 0); /* Color transform = 0 */
|
emit_byte(cinfo, 0); /* Color transform = 0 */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -611,12 +611,12 @@ METHODDEF(void)
|
|||||||
write_marker_header (j_compress_ptr cinfo, int marker, unsigned int datalen)
|
write_marker_header (j_compress_ptr cinfo, int marker, unsigned int datalen)
|
||||||
/* Emit an arbitrary marker header */
|
/* Emit an arbitrary marker header */
|
||||||
{
|
{
|
||||||
if (datalen > (unsigned int) 65533) /* safety check */
|
if (datalen > (unsigned int) 65533) /* safety check */
|
||||||
ERREXIT(cinfo, JERR_BAD_LENGTH);
|
ERREXIT(cinfo, JERR_BAD_LENGTH);
|
||||||
|
|
||||||
emit_marker(cinfo, (JPEG_MARKER) marker);
|
emit_marker(cinfo, (JPEG_MARKER) marker);
|
||||||
|
|
||||||
emit_2bytes(cinfo, (int) (datalen + 2)); /* total length */
|
emit_2bytes(cinfo, (int) (datalen + 2)); /* total length */
|
||||||
}
|
}
|
||||||
|
|
||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
@@ -643,12 +643,12 @@ write_file_header (j_compress_ptr cinfo)
|
|||||||
{
|
{
|
||||||
my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
|
my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
|
||||||
|
|
||||||
emit_marker(cinfo, M_SOI); /* first the SOI */
|
emit_marker(cinfo, M_SOI); /* first the SOI */
|
||||||
|
|
||||||
/* SOI is defined to reset restart interval to 0 */
|
/* SOI is defined to reset restart interval to 0 */
|
||||||
marker->last_restart_interval = 0;
|
marker->last_restart_interval = 0;
|
||||||
|
|
||||||
if (cinfo->write_JFIF_header) /* next an optional JFIF APP0 */
|
if (cinfo->write_JFIF_header) /* next an optional JFIF APP0 */
|
||||||
emit_jfif_app0(cinfo);
|
emit_jfif_app0(cinfo);
|
||||||
if (cinfo->write_Adobe_marker) /* next an optional Adobe APP14 */
|
if (cinfo->write_Adobe_marker) /* next an optional Adobe APP14 */
|
||||||
emit_adobe_app14(cinfo);
|
emit_adobe_app14(cinfo);
|
||||||
@@ -669,7 +669,7 @@ write_frame_header (j_compress_ptr cinfo)
|
|||||||
int ci, prec;
|
int ci, prec;
|
||||||
boolean is_baseline;
|
boolean is_baseline;
|
||||||
jpeg_component_info *compptr;
|
jpeg_component_info *compptr;
|
||||||
|
|
||||||
/* Emit DQT for each quantization table.
|
/* Emit DQT for each quantization table.
|
||||||
* Note that emit_dqt() suppresses any duplicate tables.
|
* Note that emit_dqt() suppresses any duplicate tables.
|
||||||
*/
|
*/
|
||||||
@@ -692,9 +692,9 @@ write_frame_header (j_compress_ptr cinfo)
|
|||||||
} else {
|
} else {
|
||||||
is_baseline = TRUE;
|
is_baseline = TRUE;
|
||||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||||
ci++, compptr++) {
|
ci++, compptr++) {
|
||||||
if (compptr->dc_tbl_no > 1 || compptr->ac_tbl_no > 1)
|
if (compptr->dc_tbl_no > 1 || compptr->ac_tbl_no > 1)
|
||||||
is_baseline = FALSE;
|
is_baseline = FALSE;
|
||||||
}
|
}
|
||||||
if (prec && is_baseline) {
|
if (prec && is_baseline) {
|
||||||
is_baseline = FALSE;
|
is_baseline = FALSE;
|
||||||
@@ -711,11 +711,11 @@ write_frame_header (j_compress_ptr cinfo)
|
|||||||
emit_sof(cinfo, M_SOF9); /* SOF code for sequential arithmetic */
|
emit_sof(cinfo, M_SOF9); /* SOF code for sequential arithmetic */
|
||||||
} else {
|
} else {
|
||||||
if (cinfo->progressive_mode)
|
if (cinfo->progressive_mode)
|
||||||
emit_sof(cinfo, M_SOF2); /* SOF code for progressive Huffman */
|
emit_sof(cinfo, M_SOF2); /* SOF code for progressive Huffman */
|
||||||
else if (is_baseline)
|
else if (is_baseline)
|
||||||
emit_sof(cinfo, M_SOF0); /* SOF code for baseline implementation */
|
emit_sof(cinfo, M_SOF0); /* SOF code for baseline implementation */
|
||||||
else
|
else
|
||||||
emit_sof(cinfo, M_SOF1); /* SOF code for non-baseline Huffman file */
|
emit_sof(cinfo, M_SOF1); /* SOF code for non-baseline Huffman file */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -801,9 +801,9 @@ write_tables_only (j_compress_ptr cinfo)
|
|||||||
if (! cinfo->arith_code) {
|
if (! cinfo->arith_code) {
|
||||||
for (i = 0; i < NUM_HUFF_TBLS; i++) {
|
for (i = 0; i < NUM_HUFF_TBLS; i++) {
|
||||||
if (cinfo->dc_huff_tbl_ptrs[i] != NULL)
|
if (cinfo->dc_huff_tbl_ptrs[i] != NULL)
|
||||||
emit_dht(cinfo, i, FALSE);
|
emit_dht(cinfo, i, FALSE);
|
||||||
if (cinfo->ac_huff_tbl_ptrs[i] != NULL)
|
if (cinfo->ac_huff_tbl_ptrs[i] != NULL)
|
||||||
emit_dht(cinfo, i, TRUE);
|
emit_dht(cinfo, i, TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
144
jcmaster.c
144
jcmaster.c
@@ -12,7 +12,7 @@
|
|||||||
*
|
*
|
||||||
* This file contains master control logic for the JPEG compressor.
|
* This file contains master control logic for the JPEG compressor.
|
||||||
* These routines are concerned with parameter validation, initial setup,
|
* These routines are concerned with parameter validation, initial setup,
|
||||||
* and inter-pass control (determining the number of passes and the work
|
* and inter-pass control (determining the number of passes and the work
|
||||||
* to be done in each pass).
|
* to be done in each pass).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -26,21 +26,21 @@
|
|||||||
/* Private state */
|
/* Private state */
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
main_pass, /* input data, also do first output step */
|
main_pass, /* input data, also do first output step */
|
||||||
huff_opt_pass, /* Huffman code optimization pass */
|
huff_opt_pass, /* Huffman code optimization pass */
|
||||||
output_pass, /* data output pass */
|
output_pass, /* data output pass */
|
||||||
trellis_pass /* trellis quantization pass */
|
trellis_pass /* trellis quantization pass */
|
||||||
} c_pass_type;
|
} c_pass_type;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
struct jpeg_comp_master pub; /* public fields */
|
struct jpeg_comp_master pub; /* public fields */
|
||||||
|
|
||||||
c_pass_type pass_type; /* the type of the current pass */
|
c_pass_type pass_type; /* the type of the current pass */
|
||||||
|
|
||||||
int pass_number; /* # of passes completed */
|
int pass_number; /* # of passes completed */
|
||||||
int total_passes; /* total # of passes needed */
|
int total_passes; /* total # of passes needed */
|
||||||
|
|
||||||
int scan_number; /* current index in scan_info[] */
|
int scan_number; /* current index in scan_info[] */
|
||||||
|
|
||||||
/* fields for scan optimisation */
|
/* fields for scan optimisation */
|
||||||
int pass_number_scan_opt_base; /* pass number where scan optimization begins */
|
int pass_number_scan_opt_base; /* pass number where scan optimization begins */
|
||||||
@@ -122,7 +122,7 @@ initial_setup (j_compress_ptr cinfo, boolean transcode_only)
|
|||||||
/* Check that number of components won't exceed internal array sizes */
|
/* Check that number of components won't exceed internal array sizes */
|
||||||
if (cinfo->num_components > MAX_COMPONENTS)
|
if (cinfo->num_components > MAX_COMPONENTS)
|
||||||
ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,
|
ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,
|
||||||
MAX_COMPONENTS);
|
MAX_COMPONENTS);
|
||||||
|
|
||||||
/* Compute maximum sampling factors; check factor validity */
|
/* Compute maximum sampling factors; check factor validity */
|
||||||
cinfo->max_h_samp_factor = 1;
|
cinfo->max_h_samp_factor = 1;
|
||||||
@@ -130,12 +130,12 @@ initial_setup (j_compress_ptr cinfo, boolean transcode_only)
|
|||||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||||
ci++, compptr++) {
|
ci++, compptr++) {
|
||||||
if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR ||
|
if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR ||
|
||||||
compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR)
|
compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR)
|
||||||
ERREXIT(cinfo, JERR_BAD_SAMPLING);
|
ERREXIT(cinfo, JERR_BAD_SAMPLING);
|
||||||
cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor,
|
cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor,
|
||||||
compptr->h_samp_factor);
|
compptr->h_samp_factor);
|
||||||
cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor,
|
cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor,
|
||||||
compptr->v_samp_factor);
|
compptr->v_samp_factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compute dimensions of components */
|
/* Compute dimensions of components */
|
||||||
@@ -152,17 +152,17 @@ initial_setup (j_compress_ptr cinfo, boolean transcode_only)
|
|||||||
/* Size in DCT blocks */
|
/* Size in DCT blocks */
|
||||||
compptr->width_in_blocks = (JDIMENSION)
|
compptr->width_in_blocks = (JDIMENSION)
|
||||||
jdiv_round_up((long) cinfo->_jpeg_width * (long) compptr->h_samp_factor,
|
jdiv_round_up((long) cinfo->_jpeg_width * (long) compptr->h_samp_factor,
|
||||||
(long) (cinfo->max_h_samp_factor * DCTSIZE));
|
(long) (cinfo->max_h_samp_factor * DCTSIZE));
|
||||||
compptr->height_in_blocks = (JDIMENSION)
|
compptr->height_in_blocks = (JDIMENSION)
|
||||||
jdiv_round_up((long) cinfo->_jpeg_height * (long) compptr->v_samp_factor,
|
jdiv_round_up((long) cinfo->_jpeg_height * (long) compptr->v_samp_factor,
|
||||||
(long) (cinfo->max_v_samp_factor * DCTSIZE));
|
(long) (cinfo->max_v_samp_factor * DCTSIZE));
|
||||||
/* Size in samples */
|
/* Size in samples */
|
||||||
compptr->downsampled_width = (JDIMENSION)
|
compptr->downsampled_width = (JDIMENSION)
|
||||||
jdiv_round_up((long) cinfo->_jpeg_width * (long) compptr->h_samp_factor,
|
jdiv_round_up((long) cinfo->_jpeg_width * (long) compptr->h_samp_factor,
|
||||||
(long) cinfo->max_h_samp_factor);
|
(long) cinfo->max_h_samp_factor);
|
||||||
compptr->downsampled_height = (JDIMENSION)
|
compptr->downsampled_height = (JDIMENSION)
|
||||||
jdiv_round_up((long) cinfo->_jpeg_height * (long) compptr->v_samp_factor,
|
jdiv_round_up((long) cinfo->_jpeg_height * (long) compptr->v_samp_factor,
|
||||||
(long) cinfo->max_v_samp_factor);
|
(long) cinfo->max_v_samp_factor);
|
||||||
/* Mark component needed (this flag isn't actually used for compression) */
|
/* Mark component needed (this flag isn't actually used for compression) */
|
||||||
compptr->component_needed = TRUE;
|
compptr->component_needed = TRUE;
|
||||||
}
|
}
|
||||||
@@ -172,7 +172,7 @@ initial_setup (j_compress_ptr cinfo, boolean transcode_only)
|
|||||||
*/
|
*/
|
||||||
cinfo->total_iMCU_rows = (JDIMENSION)
|
cinfo->total_iMCU_rows = (JDIMENSION)
|
||||||
jdiv_round_up((long) cinfo->_jpeg_height,
|
jdiv_round_up((long) cinfo->_jpeg_height,
|
||||||
(long) (cinfo->max_v_samp_factor*DCTSIZE));
|
(long) (cinfo->max_v_samp_factor*DCTSIZE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -213,15 +213,15 @@ validate_script (j_compress_ptr cinfo)
|
|||||||
#ifdef C_PROGRESSIVE_SUPPORTED
|
#ifdef C_PROGRESSIVE_SUPPORTED
|
||||||
cinfo->progressive_mode = TRUE;
|
cinfo->progressive_mode = TRUE;
|
||||||
last_bitpos_ptr = & last_bitpos[0][0];
|
last_bitpos_ptr = & last_bitpos[0][0];
|
||||||
for (ci = 0; ci < cinfo->num_components; ci++)
|
for (ci = 0; ci < cinfo->num_components; ci++)
|
||||||
for (coefi = 0; coefi < DCTSIZE2; coefi++)
|
for (coefi = 0; coefi < DCTSIZE2; coefi++)
|
||||||
*last_bitpos_ptr++ = -1;
|
*last_bitpos_ptr++ = -1;
|
||||||
#else
|
#else
|
||||||
ERREXIT(cinfo, JERR_NOT_COMPILED);
|
ERREXIT(cinfo, JERR_NOT_COMPILED);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
cinfo->progressive_mode = FALSE;
|
cinfo->progressive_mode = FALSE;
|
||||||
for (ci = 0; ci < cinfo->num_components; ci++)
|
for (ci = 0; ci < cinfo->num_components; ci++)
|
||||||
component_sent[ci] = FALSE;
|
component_sent[ci] = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,10 +233,10 @@ validate_script (j_compress_ptr cinfo)
|
|||||||
for (ci = 0; ci < ncomps; ci++) {
|
for (ci = 0; ci < ncomps; ci++) {
|
||||||
thisi = scanptr->component_index[ci];
|
thisi = scanptr->component_index[ci];
|
||||||
if (thisi < 0 || thisi >= cinfo->num_components)
|
if (thisi < 0 || thisi >= cinfo->num_components)
|
||||||
ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
|
ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
|
||||||
/* Components must appear in SOF order within each scan */
|
/* Components must appear in SOF order within each scan */
|
||||||
if (ci > 0 && thisi <= scanptr->component_index[ci-1])
|
if (ci > 0 && thisi <= scanptr->component_index[ci-1])
|
||||||
ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
|
ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
|
||||||
}
|
}
|
||||||
/* Validate progression parameters */
|
/* Validate progression parameters */
|
||||||
Ss = scanptr->Ss;
|
Ss = scanptr->Ss;
|
||||||
@@ -258,43 +258,43 @@ validate_script (j_compress_ptr cinfo)
|
|||||||
#define MAX_AH_AL 13
|
#define MAX_AH_AL 13
|
||||||
#endif
|
#endif
|
||||||
if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 ||
|
if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 ||
|
||||||
Ah < 0 || Ah > MAX_AH_AL || Al < 0 || Al > MAX_AH_AL)
|
Ah < 0 || Ah > MAX_AH_AL || Al < 0 || Al > MAX_AH_AL)
|
||||||
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
||||||
if (Ss == 0) {
|
if (Ss == 0) {
|
||||||
if (Se != 0) /* DC and AC together not OK */
|
if (Se != 0) /* DC and AC together not OK */
|
||||||
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
||||||
} else {
|
} else {
|
||||||
if (ncomps != 1) /* AC scans must be for only one component */
|
if (ncomps != 1) /* AC scans must be for only one component */
|
||||||
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
||||||
}
|
}
|
||||||
for (ci = 0; ci < ncomps; ci++) {
|
for (ci = 0; ci < ncomps; ci++) {
|
||||||
last_bitpos_ptr = & last_bitpos[scanptr->component_index[ci]][0];
|
last_bitpos_ptr = & last_bitpos[scanptr->component_index[ci]][0];
|
||||||
if (Ss != 0 && last_bitpos_ptr[0] < 0) /* AC without prior DC scan */
|
if (Ss != 0 && last_bitpos_ptr[0] < 0) /* AC without prior DC scan */
|
||||||
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
||||||
for (coefi = Ss; coefi <= Se; coefi++) {
|
for (coefi = Ss; coefi <= Se; coefi++) {
|
||||||
if (last_bitpos_ptr[coefi] < 0) {
|
if (last_bitpos_ptr[coefi] < 0) {
|
||||||
/* first scan of this coefficient */
|
/* first scan of this coefficient */
|
||||||
if (Ah != 0)
|
if (Ah != 0)
|
||||||
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
||||||
} else {
|
} else {
|
||||||
/* not first scan */
|
/* not first scan */
|
||||||
if (Ah != last_bitpos_ptr[coefi] || Al != Ah-1)
|
if (Ah != last_bitpos_ptr[coefi] || Al != Ah-1)
|
||||||
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
||||||
}
|
}
|
||||||
last_bitpos_ptr[coefi] = Al;
|
last_bitpos_ptr[coefi] = Al;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
/* For sequential JPEG, all progression parameters must be these: */
|
/* For sequential JPEG, all progression parameters must be these: */
|
||||||
if (Ss != 0 || Se != DCTSIZE2-1 || Ah != 0 || Al != 0)
|
if (Ss != 0 || Se != DCTSIZE2-1 || Ah != 0 || Al != 0)
|
||||||
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
||||||
/* Make sure components are not sent twice */
|
/* Make sure components are not sent twice */
|
||||||
for (ci = 0; ci < ncomps; ci++) {
|
for (ci = 0; ci < ncomps; ci++) {
|
||||||
thisi = scanptr->component_index[ci];
|
thisi = scanptr->component_index[ci];
|
||||||
if (component_sent[thisi])
|
if (component_sent[thisi])
|
||||||
ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
|
ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
|
||||||
component_sent[thisi] = TRUE;
|
component_sent[thisi] = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -309,13 +309,13 @@ validate_script (j_compress_ptr cinfo)
|
|||||||
*/
|
*/
|
||||||
for (ci = 0; ci < cinfo->num_components; ci++) {
|
for (ci = 0; ci < cinfo->num_components; ci++) {
|
||||||
if (last_bitpos[ci][0] < 0)
|
if (last_bitpos[ci][0] < 0)
|
||||||
ERREXIT(cinfo, JERR_MISSING_DATA);
|
ERREXIT(cinfo, JERR_MISSING_DATA);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
for (ci = 0; ci < cinfo->num_components; ci++) {
|
for (ci = 0; ci < cinfo->num_components; ci++) {
|
||||||
if (! component_sent[ci])
|
if (! component_sent[ci])
|
||||||
ERREXIT(cinfo, JERR_MISSING_DATA);
|
ERREXIT(cinfo, JERR_MISSING_DATA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -356,7 +356,7 @@ select_scan_parameters (j_compress_ptr cinfo)
|
|||||||
cinfo->comps_in_scan = scanptr->comps_in_scan;
|
cinfo->comps_in_scan = scanptr->comps_in_scan;
|
||||||
for (ci = 0; ci < scanptr->comps_in_scan; ci++) {
|
for (ci = 0; ci < scanptr->comps_in_scan; ci++) {
|
||||||
cinfo->cur_comp_info[ci] =
|
cinfo->cur_comp_info[ci] =
|
||||||
&cinfo->comp_info[scanptr->component_index[ci]];
|
&cinfo->comp_info[scanptr->component_index[ci]];
|
||||||
}
|
}
|
||||||
cinfo->Ss = scanptr->Ss;
|
cinfo->Ss = scanptr->Ss;
|
||||||
cinfo->Se = scanptr->Se;
|
cinfo->Se = scanptr->Se;
|
||||||
@@ -384,7 +384,7 @@ select_scan_parameters (j_compress_ptr cinfo)
|
|||||||
/* Prepare for single sequential-JPEG scan containing all components */
|
/* Prepare for single sequential-JPEG scan containing all components */
|
||||||
if (cinfo->num_components > MAX_COMPS_IN_SCAN)
|
if (cinfo->num_components > MAX_COMPS_IN_SCAN)
|
||||||
ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,
|
ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,
|
||||||
MAX_COMPS_IN_SCAN);
|
MAX_COMPS_IN_SCAN);
|
||||||
cinfo->comps_in_scan = cinfo->num_components;
|
cinfo->comps_in_scan = cinfo->num_components;
|
||||||
for (ci = 0; ci < cinfo->num_components; ci++) {
|
for (ci = 0; ci < cinfo->num_components; ci++) {
|
||||||
cinfo->cur_comp_info[ci] = &cinfo->comp_info[ci];
|
cinfo->cur_comp_info[ci] = &cinfo->comp_info[ci];
|
||||||
@@ -404,16 +404,16 @@ per_scan_setup (j_compress_ptr cinfo)
|
|||||||
{
|
{
|
||||||
int ci, mcublks, tmp;
|
int ci, mcublks, tmp;
|
||||||
jpeg_component_info *compptr;
|
jpeg_component_info *compptr;
|
||||||
|
|
||||||
if (cinfo->comps_in_scan == 1) {
|
if (cinfo->comps_in_scan == 1) {
|
||||||
|
|
||||||
/* Noninterleaved (single-component) scan */
|
/* Noninterleaved (single-component) scan */
|
||||||
compptr = cinfo->cur_comp_info[0];
|
compptr = cinfo->cur_comp_info[0];
|
||||||
|
|
||||||
/* Overall image size in MCUs */
|
/* Overall image size in MCUs */
|
||||||
cinfo->MCUs_per_row = compptr->width_in_blocks;
|
cinfo->MCUs_per_row = compptr->width_in_blocks;
|
||||||
cinfo->MCU_rows_in_scan = compptr->height_in_blocks;
|
cinfo->MCU_rows_in_scan = compptr->height_in_blocks;
|
||||||
|
|
||||||
/* For noninterleaved scan, always one block per MCU */
|
/* For noninterleaved scan, always one block per MCU */
|
||||||
compptr->MCU_width = 1;
|
compptr->MCU_width = 1;
|
||||||
compptr->MCU_height = 1;
|
compptr->MCU_height = 1;
|
||||||
@@ -426,28 +426,28 @@ per_scan_setup (j_compress_ptr cinfo)
|
|||||||
tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
|
tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
|
||||||
if (tmp == 0) tmp = compptr->v_samp_factor;
|
if (tmp == 0) tmp = compptr->v_samp_factor;
|
||||||
compptr->last_row_height = tmp;
|
compptr->last_row_height = tmp;
|
||||||
|
|
||||||
/* Prepare array describing MCU composition */
|
/* Prepare array describing MCU composition */
|
||||||
cinfo->blocks_in_MCU = 1;
|
cinfo->blocks_in_MCU = 1;
|
||||||
cinfo->MCU_membership[0] = 0;
|
cinfo->MCU_membership[0] = 0;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/* Interleaved (multi-component) scan */
|
/* Interleaved (multi-component) scan */
|
||||||
if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN)
|
if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN)
|
||||||
ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan,
|
ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan,
|
||||||
MAX_COMPS_IN_SCAN);
|
MAX_COMPS_IN_SCAN);
|
||||||
|
|
||||||
/* Overall image size in MCUs */
|
/* Overall image size in MCUs */
|
||||||
cinfo->MCUs_per_row = (JDIMENSION)
|
cinfo->MCUs_per_row = (JDIMENSION)
|
||||||
jdiv_round_up((long) cinfo->_jpeg_width,
|
jdiv_round_up((long) cinfo->_jpeg_width,
|
||||||
(long) (cinfo->max_h_samp_factor*DCTSIZE));
|
(long) (cinfo->max_h_samp_factor*DCTSIZE));
|
||||||
cinfo->MCU_rows_in_scan = (JDIMENSION)
|
cinfo->MCU_rows_in_scan = (JDIMENSION)
|
||||||
jdiv_round_up((long) cinfo->_jpeg_height,
|
jdiv_round_up((long) cinfo->_jpeg_height,
|
||||||
(long) (cinfo->max_v_samp_factor*DCTSIZE));
|
(long) (cinfo->max_v_samp_factor*DCTSIZE));
|
||||||
|
|
||||||
cinfo->blocks_in_MCU = 0;
|
cinfo->blocks_in_MCU = 0;
|
||||||
|
|
||||||
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
||||||
compptr = cinfo->cur_comp_info[ci];
|
compptr = cinfo->cur_comp_info[ci];
|
||||||
/* Sampling factors give # of blocks of component in each MCU */
|
/* Sampling factors give # of blocks of component in each MCU */
|
||||||
@@ -465,12 +465,12 @@ per_scan_setup (j_compress_ptr cinfo)
|
|||||||
/* Prepare array describing MCU composition */
|
/* Prepare array describing MCU composition */
|
||||||
mcublks = compptr->MCU_blocks;
|
mcublks = compptr->MCU_blocks;
|
||||||
if (cinfo->blocks_in_MCU + mcublks > C_MAX_BLOCKS_IN_MCU)
|
if (cinfo->blocks_in_MCU + mcublks > C_MAX_BLOCKS_IN_MCU)
|
||||||
ERREXIT(cinfo, JERR_BAD_MCU_SIZE);
|
ERREXIT(cinfo, JERR_BAD_MCU_SIZE);
|
||||||
while (mcublks-- > 0) {
|
while (mcublks-- > 0) {
|
||||||
cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci;
|
cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert restart specified in rows to actual MCU count. */
|
/* Convert restart specified in rows to actual MCU count. */
|
||||||
@@ -512,8 +512,8 @@ prepare_for_pass (j_compress_ptr cinfo)
|
|||||||
(*cinfo->fdct->start_pass) (cinfo);
|
(*cinfo->fdct->start_pass) (cinfo);
|
||||||
(*cinfo->entropy->start_pass) (cinfo, cinfo->optimize_coding);
|
(*cinfo->entropy->start_pass) (cinfo, cinfo->optimize_coding);
|
||||||
(*cinfo->coef->start_pass) (cinfo,
|
(*cinfo->coef->start_pass) (cinfo,
|
||||||
(master->total_passes > 1 ?
|
(master->total_passes > 1 ?
|
||||||
JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));
|
JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));
|
||||||
(*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);
|
(*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);
|
||||||
if (cinfo->optimize_coding) {
|
if (cinfo->optimize_coding) {
|
||||||
/* No immediate data output; postpone writing frame/scan headers */
|
/* No immediate data output; postpone writing frame/scan headers */
|
||||||
@@ -946,7 +946,7 @@ jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only)
|
|||||||
cinfo->num_scans = 1;
|
cinfo->num_scans = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cinfo->progressive_mode && !cinfo->arith_code) /* TEMPORARY HACK ??? */
|
if (cinfo->progressive_mode && !cinfo->arith_code) /* TEMPORARY HACK ??? */
|
||||||
cinfo->optimize_coding = TRUE; /* assume default tables no good for progressive mode */
|
cinfo->optimize_coding = TRUE; /* assume default tables no good for progressive mode */
|
||||||
|
|
||||||
/* Initialize my private state */
|
/* Initialize my private state */
|
||||||
|
|||||||
16
jconfig.txt
16
jconfig.txt
@@ -78,10 +78,10 @@
|
|||||||
/* Define "boolean" as unsigned char, not int, on Windows systems.
|
/* Define "boolean" as unsigned char, not int, on Windows systems.
|
||||||
*/
|
*/
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */
|
#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */
|
||||||
typedef unsigned char boolean;
|
typedef unsigned char boolean;
|
||||||
#endif
|
#endif
|
||||||
#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */
|
#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -114,12 +114,12 @@ typedef unsigned char boolean;
|
|||||||
|
|
||||||
/* These defines indicate which image (non-JPEG) file formats are allowed. */
|
/* These defines indicate which image (non-JPEG) file formats are allowed. */
|
||||||
|
|
||||||
#define PNG_SUPPORTED /* PNG image file format */
|
#define PNG_SUPPORTED /* PNG image file format */
|
||||||
#define BMP_SUPPORTED /* BMP image file format */
|
#define BMP_SUPPORTED /* BMP image file format */
|
||||||
#define GIF_SUPPORTED /* GIF image file format */
|
#define GIF_SUPPORTED /* GIF image file format */
|
||||||
#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */
|
#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */
|
||||||
#undef RLE_SUPPORTED /* Utah RLE image file format */
|
#undef RLE_SUPPORTED /* Utah RLE image file format */
|
||||||
#define TARGA_SUPPORTED /* Targa image file format */
|
#define TARGA_SUPPORTED /* Targa image file format */
|
||||||
|
|
||||||
/* Define this if you want to name both input and output files on the command
|
/* Define this if you want to name both input and output files on the command
|
||||||
* line, rather than using stdout and optionally stdin. You MUST do this if
|
* line, rather than using stdout and optionally stdin. You MUST do this if
|
||||||
|
|||||||
101
jcparam.c
101
jcparam.c
@@ -117,11 +117,11 @@ jpeg_default_qtables (j_compress_ptr cinfo, boolean force_baseline)
|
|||||||
jpeg_add_quant_table(cinfo, 1, flat_quant_tbl,
|
jpeg_add_quant_table(cinfo, 1, flat_quant_tbl,
|
||||||
cinfo->q_scale_factor[1], force_baseline);
|
cinfo->q_scale_factor[1], force_baseline);
|
||||||
} else {
|
} else {
|
||||||
jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,
|
jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,
|
||||||
cinfo->q_scale_factor[0], force_baseline);
|
cinfo->q_scale_factor[0], force_baseline);
|
||||||
jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
|
jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
|
||||||
cinfo->q_scale_factor[1], force_baseline);
|
cinfo->q_scale_factor[1], force_baseline);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -142,11 +142,11 @@ jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor,
|
|||||||
jpeg_add_quant_table(cinfo, 1, flat_quant_tbl,
|
jpeg_add_quant_table(cinfo, 1, flat_quant_tbl,
|
||||||
scale_factor, force_baseline);
|
scale_factor, force_baseline);
|
||||||
} else {
|
} else {
|
||||||
jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,
|
jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,
|
||||||
scale_factor, force_baseline);
|
scale_factor, force_baseline);
|
||||||
jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
|
jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
|
||||||
scale_factor, force_baseline);
|
scale_factor, force_baseline);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -249,9 +249,9 @@ jpeg_set_defaults (j_compress_ptr cinfo)
|
|||||||
cinfo->scan_info = NULL;
|
cinfo->scan_info = NULL;
|
||||||
cinfo->num_scans = 0;
|
cinfo->num_scans = 0;
|
||||||
if (!cinfo->master->use_moz_defaults) {
|
if (!cinfo->master->use_moz_defaults) {
|
||||||
/* Default is no multiple-scan output */
|
/* Default is no multiple-scan output */
|
||||||
cinfo->scan_info = NULL;
|
cinfo->scan_info = NULL;
|
||||||
cinfo->num_scans = 0;
|
cinfo->num_scans = 0;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* Default is no multiple-scan output */
|
/* Default is no multiple-scan output */
|
||||||
@@ -270,8 +270,8 @@ jpeg_set_defaults (j_compress_ptr cinfo)
|
|||||||
/* By default, do extra passes to optimize entropy coding */
|
/* By default, do extra passes to optimize entropy coding */
|
||||||
cinfo->optimize_coding = TRUE;
|
cinfo->optimize_coding = TRUE;
|
||||||
else
|
else
|
||||||
/* By default, don't do extra passes to optimize entropy coding */
|
/* By default, don't do extra passes to optimize entropy coding */
|
||||||
cinfo->optimize_coding = FALSE;
|
cinfo->optimize_coding = FALSE;
|
||||||
#else
|
#else
|
||||||
/* By default, don't do extra passes to optimize entropy coding */
|
/* By default, don't do extra passes to optimize entropy coding */
|
||||||
cinfo->optimize_coding = FALSE;
|
cinfo->optimize_coding = FALSE;
|
||||||
@@ -494,7 +494,7 @@ fill_a_scan (jpeg_scan_info * scanptr, int ci,
|
|||||||
|
|
||||||
LOCAL(jpeg_scan_info *)
|
LOCAL(jpeg_scan_info *)
|
||||||
fill_a_scan_pair (jpeg_scan_info * scanptr, int ci,
|
fill_a_scan_pair (jpeg_scan_info * scanptr, int ci,
|
||||||
int Ss, int Se, int Ah, int Al)
|
int Ss, int Se, int Ah, int Al)
|
||||||
/* Support routine: generate one scan for pair of components */
|
/* Support routine: generate one scan for pair of components */
|
||||||
{
|
{
|
||||||
scanptr->comps_in_scan = 2;
|
scanptr->comps_in_scan = 2;
|
||||||
@@ -705,16 +705,16 @@ jpeg_simple_progression (j_compress_ptr cinfo)
|
|||||||
} else {
|
} else {
|
||||||
/* All-purpose script for other color spaces. */
|
/* All-purpose script for other color spaces. */
|
||||||
if (cinfo->master->use_moz_defaults == TRUE) {
|
if (cinfo->master->use_moz_defaults == TRUE) {
|
||||||
if (ncomps > MAX_COMPS_IN_SCAN)
|
if (ncomps > MAX_COMPS_IN_SCAN)
|
||||||
nscans = 5 * ncomps; /* 2 DC + 4 AC scans per component */
|
nscans = 5 * ncomps; /* 2 DC + 4 AC scans per component */
|
||||||
else
|
else
|
||||||
nscans = 1 + 4 * ncomps; /* 2 DC scans; 4 AC scans per component */
|
nscans = 1 + 4 * ncomps; /* 2 DC scans; 4 AC scans per component */
|
||||||
} else {
|
} else {
|
||||||
if (ncomps > MAX_COMPS_IN_SCAN)
|
if (ncomps > MAX_COMPS_IN_SCAN)
|
||||||
nscans = 6 * ncomps; /* 2 DC + 4 AC scans per component */
|
nscans = 6 * ncomps; /* 2 DC + 4 AC scans per component */
|
||||||
else
|
else
|
||||||
nscans = 2 + 4 * ncomps; /* 2 DC scans; 4 AC scans per component */
|
nscans = 2 + 4 * ncomps; /* 2 DC scans; 4 AC scans per component */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate space for script.
|
/* Allocate space for script.
|
||||||
@@ -764,23 +764,23 @@ jpeg_simple_progression (j_compress_ptr cinfo)
|
|||||||
scanptr = fill_a_scan(scanptr, 2, 9, 63, 0, 0);
|
scanptr = fill_a_scan(scanptr, 2, 9, 63, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
/* Initial DC scan */
|
/* Initial DC scan */
|
||||||
scanptr = fill_dc_scans(scanptr, ncomps, 0, 1);
|
scanptr = fill_dc_scans(scanptr, ncomps, 0, 1);
|
||||||
/* Initial AC scan: get some luma data out in a hurry */
|
/* Initial AC scan: get some luma data out in a hurry */
|
||||||
scanptr = fill_a_scan(scanptr, 0, 1, 5, 0, 2);
|
scanptr = fill_a_scan(scanptr, 0, 1, 5, 0, 2);
|
||||||
/* Chroma data is too small to be worth expending many scans on */
|
/* Chroma data is too small to be worth expending many scans on */
|
||||||
scanptr = fill_a_scan(scanptr, 2, 1, 63, 0, 1);
|
scanptr = fill_a_scan(scanptr, 2, 1, 63, 0, 1);
|
||||||
scanptr = fill_a_scan(scanptr, 1, 1, 63, 0, 1);
|
scanptr = fill_a_scan(scanptr, 1, 1, 63, 0, 1);
|
||||||
/* Complete spectral selection for luma AC */
|
/* Complete spectral selection for luma AC */
|
||||||
scanptr = fill_a_scan(scanptr, 0, 6, 63, 0, 2);
|
scanptr = fill_a_scan(scanptr, 0, 6, 63, 0, 2);
|
||||||
/* Refine next bit of luma AC */
|
/* Refine next bit of luma AC */
|
||||||
scanptr = fill_a_scan(scanptr, 0, 1, 63, 2, 1);
|
scanptr = fill_a_scan(scanptr, 0, 1, 63, 2, 1);
|
||||||
/* Finish DC successive approximation */
|
/* Finish DC successive approximation */
|
||||||
scanptr = fill_dc_scans(scanptr, ncomps, 1, 0);
|
scanptr = fill_dc_scans(scanptr, ncomps, 1, 0);
|
||||||
/* Finish AC successive approximation */
|
/* Finish AC successive approximation */
|
||||||
scanptr = fill_a_scan(scanptr, 2, 1, 63, 1, 0);
|
scanptr = fill_a_scan(scanptr, 2, 1, 63, 1, 0);
|
||||||
scanptr = fill_a_scan(scanptr, 1, 1, 63, 1, 0);
|
scanptr = fill_a_scan(scanptr, 1, 1, 63, 1, 0);
|
||||||
/* Luma bottom bit comes last since it's usually largest scan */
|
/* Luma bottom bit comes last since it's usually largest scan */
|
||||||
scanptr = fill_a_scan(scanptr, 0, 1, 63, 1, 0);
|
scanptr = fill_a_scan(scanptr, 0, 1, 63, 1, 0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* All-purpose script for other color spaces. */
|
/* All-purpose script for other color spaces. */
|
||||||
@@ -788,7 +788,7 @@ jpeg_simple_progression (j_compress_ptr cinfo)
|
|||||||
/* scan defined in jpeg_scan_bw.txt in jpgcrush */
|
/* scan defined in jpeg_scan_bw.txt in jpgcrush */
|
||||||
/* DC component, no successive approximation */
|
/* DC component, no successive approximation */
|
||||||
scanptr = fill_dc_scans(scanptr, ncomps, 0, 0);
|
scanptr = fill_dc_scans(scanptr, ncomps, 0, 0);
|
||||||
/* Successive approximation first pass */
|
/* Successive approximation first pass */
|
||||||
scanptr = fill_scans(scanptr, ncomps, 1, 8, 0, 2);
|
scanptr = fill_scans(scanptr, ncomps, 1, 8, 0, 2);
|
||||||
scanptr = fill_scans(scanptr, ncomps, 9, 63, 0, 2);
|
scanptr = fill_scans(scanptr, ncomps, 9, 63, 0, 2);
|
||||||
/* Successive approximation second pass */
|
/* Successive approximation second pass */
|
||||||
@@ -797,17 +797,16 @@ jpeg_simple_progression (j_compress_ptr cinfo)
|
|||||||
scanptr = fill_scans(scanptr, ncomps, 1, 63, 1, 0);
|
scanptr = fill_scans(scanptr, ncomps, 1, 63, 1, 0);
|
||||||
} else {
|
} else {
|
||||||
/* Successive approximation first pass */
|
/* Successive approximation first pass */
|
||||||
scanptr = fill_dc_scans(scanptr, ncomps, 0, 1);
|
scanptr = fill_dc_scans(scanptr, ncomps, 0, 1);
|
||||||
scanptr = fill_scans(scanptr, ncomps, 1, 5, 0, 2);
|
scanptr = fill_scans(scanptr, ncomps, 1, 5, 0, 2);
|
||||||
scanptr = fill_scans(scanptr, ncomps, 6, 63, 0, 2);
|
scanptr = fill_scans(scanptr, ncomps, 6, 63, 0, 2);
|
||||||
/* Successive approximation second pass */
|
/* Successive approximation second pass */
|
||||||
scanptr = fill_scans(scanptr, ncomps, 1, 63, 2, 1);
|
scanptr = fill_scans(scanptr, ncomps, 1, 63, 2, 1);
|
||||||
/* Successive approximation final pass */
|
/* Successive approximation final pass */
|
||||||
scanptr = fill_dc_scans(scanptr, ncomps, 1, 0);
|
scanptr = fill_dc_scans(scanptr, ncomps, 1, 0);
|
||||||
scanptr = fill_scans(scanptr, ncomps, 1, 63, 1, 0);
|
scanptr = fill_scans(scanptr, ncomps, 1, 63, 1, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* C_PROGRESSIVE_SUPPORTED */
|
#endif /* C_PROGRESSIVE_SUPPORTED */
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ start_pass_phuff (j_compress_ptr cinfo, boolean gather_statistics)
|
|||||||
int i, j;
|
int i, j;
|
||||||
for (i = 0; i < 16; i++)
|
for (i = 0; i < 16; i++)
|
||||||
for (j = 0; j < 12; j++)
|
for (j = 0; j < 12; j++)
|
||||||
entropy->count_ptrs[tbl][16*i+j] = 1;
|
entropy->count_ptrs[tbl][16 * i + j] = 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Compute derived values for Huffman table */
|
/* Compute derived values for Huffman table */
|
||||||
|
|||||||
@@ -23,9 +23,8 @@ typedef enum { /* Operating modes for buffer controllers */
|
|||||||
/* Remaining modes require a full-image buffer to have been created */
|
/* Remaining modes require a full-image buffer to have been created */
|
||||||
JBUF_SAVE_SOURCE, /* Run source subobject only, save output */
|
JBUF_SAVE_SOURCE, /* Run source subobject only, save output */
|
||||||
JBUF_CRANK_DEST, /* Run dest subobject only, using saved data */
|
JBUF_CRANK_DEST, /* Run dest subobject only, using saved data */
|
||||||
JBUF_SAVE_AND_PASS, /* Run both subobjects, save output */
|
JBUF_SAVE_AND_PASS, /* Run both subobjects, save output */
|
||||||
JBUF_REQUANT /* Requantize */
|
JBUF_REQUANT /* Requantize */
|
||||||
|
|
||||||
} J_BUF_MODE;
|
} J_BUF_MODE;
|
||||||
|
|
||||||
/* Values of global_state field (jdapi.c has some dependencies on ordering!) */
|
/* Values of global_state field (jdapi.c has some dependencies on ordering!) */
|
||||||
|
|||||||
430
jpeglib.h
430
jpeglib.h
@@ -25,10 +25,10 @@
|
|||||||
* manual configuration options that most people need not worry about.
|
* manual configuration options that most people need not worry about.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef JCONFIG_INCLUDED /* in case jinclude.h already did */
|
#ifndef JCONFIG_INCLUDED /* in case jinclude.h already did */
|
||||||
#include "jconfig.h" /* widely used configuration options */
|
#include "jconfig.h" /* widely used configuration options */
|
||||||
#endif
|
#endif
|
||||||
#include "jmorecfg.h" /* seldom changed options */
|
#include "jmorecfg.h" /* seldom changed options */
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@@ -43,13 +43,13 @@ extern "C" {
|
|||||||
* if you want to be compatible.
|
* if you want to be compatible.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DCTSIZE 8 /* The basic DCT block is 8x8 samples */
|
#define DCTSIZE 8 /* The basic DCT block is 8x8 samples */
|
||||||
#define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */
|
#define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */
|
||||||
#define NUM_QUANT_TBLS 4 /* Quantization tables are numbered 0..3 */
|
#define NUM_QUANT_TBLS 4 /* Quantization tables are numbered 0..3 */
|
||||||
#define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */
|
#define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */
|
||||||
#define NUM_ARITH_TBLS 16 /* Arith-coding tables are numbered 0..15 */
|
#define NUM_ARITH_TBLS 16 /* Arith-coding tables are numbered 0..15 */
|
||||||
#define MAX_COMPS_IN_SCAN 4 /* JPEG limit on # of components in one scan */
|
#define MAX_COMPS_IN_SCAN 4 /* JPEG limit on # of components in one scan */
|
||||||
#define MAX_SAMP_FACTOR 4 /* JPEG limit on sampling factors */
|
#define MAX_SAMP_FACTOR 4 /* JPEG limit on sampling factors */
|
||||||
/* Unfortunately, some bozo at Adobe saw no reason to be bound by the standard;
|
/* Unfortunately, some bozo at Adobe saw no reason to be bound by the standard;
|
||||||
* the PostScript DCT filter can emit files with many more than 10 blocks/MCU.
|
* the PostScript DCT filter can emit files with many more than 10 blocks/MCU.
|
||||||
* If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU
|
* If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU
|
||||||
@@ -67,13 +67,13 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
typedef JSAMPLE *JSAMPROW; /* ptr to one image row of pixel samples. */
|
typedef JSAMPLE *JSAMPROW; /* ptr to one image row of pixel samples. */
|
||||||
typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */
|
typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */
|
||||||
typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */
|
typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */
|
||||||
|
|
||||||
typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */
|
typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */
|
||||||
typedef JBLOCK *JBLOCKROW; /* pointer to one row of coefficient blocks */
|
typedef JBLOCK *JBLOCKROW; /* pointer to one row of coefficient blocks */
|
||||||
typedef JBLOCKROW *JBLOCKARRAY; /* a 2-D array of coefficient blocks */
|
typedef JBLOCKROW *JBLOCKARRAY; /* a 2-D array of coefficient blocks */
|
||||||
typedef JBLOCKARRAY *JBLOCKIMAGE; /* a 3-D array of coefficient blocks */
|
typedef JBLOCKARRAY *JBLOCKIMAGE; /* a 3-D array of coefficient blocks */
|
||||||
|
|
||||||
typedef JCOEF *JCOEFPTR; /* useful in a couple of places */
|
typedef JCOEF *JCOEFPTR; /* useful in a couple of places */
|
||||||
|
|
||||||
@@ -88,13 +88,13 @@ typedef struct {
|
|||||||
* (not the zigzag order in which they are stored in a JPEG DQT marker).
|
* (not the zigzag order in which they are stored in a JPEG DQT marker).
|
||||||
* CAUTION: IJG versions prior to v6a kept this array in zigzag order.
|
* CAUTION: IJG versions prior to v6a kept this array in zigzag order.
|
||||||
*/
|
*/
|
||||||
UINT16 quantval[DCTSIZE2]; /* quantization step for each coefficient */
|
UINT16 quantval[DCTSIZE2]; /* quantization step for each coefficient */
|
||||||
/* This field is used only during compression. It's initialized FALSE when
|
/* This field is used only during compression. It's initialized FALSE when
|
||||||
* the table is created, and set TRUE when it's been output to the file.
|
* the table is created, and set TRUE when it's been output to the file.
|
||||||
* You could suppress output of a table by setting this to TRUE.
|
* You could suppress output of a table by setting this to TRUE.
|
||||||
* (See jpeg_suppress_tables for an example.)
|
* (See jpeg_suppress_tables for an example.)
|
||||||
*/
|
*/
|
||||||
boolean sent_table; /* TRUE when table has been output */
|
boolean sent_table; /* TRUE when table has been output */
|
||||||
} JQUANT_TBL;
|
} JQUANT_TBL;
|
||||||
|
|
||||||
|
|
||||||
@@ -102,15 +102,15 @@ typedef struct {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* These two fields directly represent the contents of a JPEG DHT marker */
|
/* These two fields directly represent the contents of a JPEG DHT marker */
|
||||||
UINT8 bits[17]; /* bits[k] = # of symbols with codes of */
|
UINT8 bits[17]; /* bits[k] = # of symbols with codes of */
|
||||||
/* length k bits; bits[0] is unused */
|
/* length k bits; bits[0] is unused */
|
||||||
UINT8 huffval[256]; /* The symbols, in order of incr code length */
|
UINT8 huffval[256]; /* The symbols, in order of incr code length */
|
||||||
/* This field is used only during compression. It's initialized FALSE when
|
/* This field is used only during compression. It's initialized FALSE when
|
||||||
* the table is created, and set TRUE when it's been output to the file.
|
* the table is created, and set TRUE when it's been output to the file.
|
||||||
* You could suppress output of a table by setting this to TRUE.
|
* You could suppress output of a table by setting this to TRUE.
|
||||||
* (See jpeg_suppress_tables for an example.)
|
* (See jpeg_suppress_tables for an example.)
|
||||||
*/
|
*/
|
||||||
boolean sent_table; /* TRUE when table has been output */
|
boolean sent_table; /* TRUE when table has been output */
|
||||||
} JHUFF_TBL;
|
} JHUFF_TBL;
|
||||||
|
|
||||||
|
|
||||||
@@ -120,20 +120,20 @@ typedef struct {
|
|||||||
/* These values are fixed over the whole image. */
|
/* These values are fixed over the whole image. */
|
||||||
/* For compression, they must be supplied by parameter setup; */
|
/* For compression, they must be supplied by parameter setup; */
|
||||||
/* for decompression, they are read from the SOF marker. */
|
/* for decompression, they are read from the SOF marker. */
|
||||||
int component_id; /* identifier for this component (0..255) */
|
int component_id; /* identifier for this component (0..255) */
|
||||||
int component_index; /* its index in SOF or cinfo->comp_info[] */
|
int component_index; /* its index in SOF or cinfo->comp_info[] */
|
||||||
int h_samp_factor; /* horizontal sampling factor (1..4) */
|
int h_samp_factor; /* horizontal sampling factor (1..4) */
|
||||||
int v_samp_factor; /* vertical sampling factor (1..4) */
|
int v_samp_factor; /* vertical sampling factor (1..4) */
|
||||||
int quant_tbl_no; /* quantization table selector (0..3) */
|
int quant_tbl_no; /* quantization table selector (0..3) */
|
||||||
/* These values may vary between scans. */
|
/* These values may vary between scans. */
|
||||||
/* For compression, they must be supplied by parameter setup; */
|
/* For compression, they must be supplied by parameter setup; */
|
||||||
/* for decompression, they are read from the SOS marker. */
|
/* for decompression, they are read from the SOS marker. */
|
||||||
/* The decompressor output side may not use these variables. */
|
/* The decompressor output side may not use these variables. */
|
||||||
int dc_tbl_no; /* DC entropy table selector (0..3) */
|
int dc_tbl_no; /* DC entropy table selector (0..3) */
|
||||||
int ac_tbl_no; /* AC entropy table selector (0..3) */
|
int ac_tbl_no; /* AC entropy table selector (0..3) */
|
||||||
|
|
||||||
/* Remaining fields should be treated as private by applications. */
|
/* Remaining fields should be treated as private by applications. */
|
||||||
|
|
||||||
/* These values are computed during compression or decompression startup: */
|
/* These values are computed during compression or decompression startup: */
|
||||||
/* Component's size in DCT blocks.
|
/* Component's size in DCT blocks.
|
||||||
* Any dummy blocks added to complete an MCU are not counted; therefore
|
* Any dummy blocks added to complete an MCU are not counted; therefore
|
||||||
@@ -159,22 +159,22 @@ typedef struct {
|
|||||||
* and similarly for height. For decompression, IDCT scaling is included, so
|
* and similarly for height. For decompression, IDCT scaling is included, so
|
||||||
* downsampled_width = ceil(image_width * Hi/Hmax * DCT_[h_]scaled_size/DCTSIZE)
|
* downsampled_width = ceil(image_width * Hi/Hmax * DCT_[h_]scaled_size/DCTSIZE)
|
||||||
*/
|
*/
|
||||||
JDIMENSION downsampled_width; /* actual width in samples */
|
JDIMENSION downsampled_width; /* actual width in samples */
|
||||||
JDIMENSION downsampled_height; /* actual height in samples */
|
JDIMENSION downsampled_height; /* actual height in samples */
|
||||||
/* This flag is used only for decompression. In cases where some of the
|
/* This flag is used only for decompression. In cases where some of the
|
||||||
* components will be ignored (eg grayscale output from YCbCr image),
|
* components will be ignored (eg grayscale output from YCbCr image),
|
||||||
* we can skip most computations for the unused components.
|
* we can skip most computations for the unused components.
|
||||||
*/
|
*/
|
||||||
boolean component_needed; /* do we need the value of this component? */
|
boolean component_needed; /* do we need the value of this component? */
|
||||||
|
|
||||||
/* These values are computed before starting a scan of the component. */
|
/* These values are computed before starting a scan of the component. */
|
||||||
/* The decompressor output side may not use these variables. */
|
/* The decompressor output side may not use these variables. */
|
||||||
int MCU_width; /* number of blocks per MCU, horizontally */
|
int MCU_width; /* number of blocks per MCU, horizontally */
|
||||||
int MCU_height; /* number of blocks per MCU, vertically */
|
int MCU_height; /* number of blocks per MCU, vertically */
|
||||||
int MCU_blocks; /* MCU_width * MCU_height */
|
int MCU_blocks; /* MCU_width * MCU_height */
|
||||||
int MCU_sample_width; /* MCU width in samples, MCU_width*DCT_[h_]scaled_size */
|
int MCU_sample_width; /* MCU width in samples, MCU_width*DCT_[h_]scaled_size */
|
||||||
int last_col_width; /* # of non-dummy blocks across in last MCU */
|
int last_col_width; /* # of non-dummy blocks across in last MCU */
|
||||||
int last_row_height; /* # of non-dummy blocks down in last MCU */
|
int last_row_height; /* # of non-dummy blocks down in last MCU */
|
||||||
|
|
||||||
/* Saved quantization table for component; NULL if none yet saved.
|
/* Saved quantization table for component; NULL if none yet saved.
|
||||||
* See jdinput.c comments about the need for this information.
|
* See jdinput.c comments about the need for this information.
|
||||||
@@ -190,10 +190,10 @@ typedef struct {
|
|||||||
/* The script for encoding a multiple-scan file is an array of these: */
|
/* The script for encoding a multiple-scan file is an array of these: */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int comps_in_scan; /* number of components encoded in this scan */
|
int comps_in_scan; /* number of components encoded in this scan */
|
||||||
int component_index[MAX_COMPS_IN_SCAN]; /* their SOF/comp_info[] indexes */
|
int component_index[MAX_COMPS_IN_SCAN]; /* their SOF/comp_info[] indexes */
|
||||||
int Ss, Se; /* progressive JPEG spectral selection parms */
|
int Ss, Se; /* progressive JPEG spectral selection parms */
|
||||||
int Ah, Al; /* progressive JPEG successive approx. parms */
|
int Ah, Al; /* progressive JPEG successive approx. parms */
|
||||||
} jpeg_scan_info;
|
} jpeg_scan_info;
|
||||||
|
|
||||||
/* The decompressor can save APPn and COM markers in a list of these: */
|
/* The decompressor can save APPn and COM markers in a list of these: */
|
||||||
@@ -201,10 +201,10 @@ typedef struct {
|
|||||||
typedef struct jpeg_marker_struct * jpeg_saved_marker_ptr;
|
typedef struct jpeg_marker_struct * jpeg_saved_marker_ptr;
|
||||||
|
|
||||||
struct jpeg_marker_struct {
|
struct jpeg_marker_struct {
|
||||||
jpeg_saved_marker_ptr next; /* next in list, or NULL */
|
jpeg_saved_marker_ptr next; /* next in list, or NULL */
|
||||||
UINT8 marker; /* marker code: JPEG_COM, or JPEG_APP0+n */
|
UINT8 marker; /* marker code: JPEG_COM, or JPEG_APP0+n */
|
||||||
unsigned int original_length; /* # bytes of data in the file */
|
unsigned int original_length; /* # bytes of data in the file */
|
||||||
unsigned int data_length; /* # bytes of data saved at data[] */
|
unsigned int data_length; /* # bytes of data saved at data[] */
|
||||||
JOCTET * data; /* the data contained in the marker */
|
JOCTET * data; /* the data contained in the marker */
|
||||||
/* the marker length word is not counted in data_length or original_length */
|
/* the marker length word is not counted in data_length or original_length */
|
||||||
};
|
};
|
||||||
@@ -215,28 +215,28 @@ struct jpeg_marker_struct {
|
|||||||
#define JCS_ALPHA_EXTENSIONS 1
|
#define JCS_ALPHA_EXTENSIONS 1
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
JCS_UNKNOWN, /* error/unspecified */
|
JCS_UNKNOWN, /* error/unspecified */
|
||||||
JCS_GRAYSCALE, /* monochrome */
|
JCS_GRAYSCALE, /* monochrome */
|
||||||
JCS_RGB, /* red/green/blue as specified by the RGB_RED,
|
JCS_RGB, /* red/green/blue as specified by the RGB_RED,
|
||||||
RGB_GREEN, RGB_BLUE, and RGB_PIXELSIZE macros */
|
RGB_GREEN, RGB_BLUE, and RGB_PIXELSIZE macros */
|
||||||
JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */
|
JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */
|
||||||
JCS_CMYK, /* C/M/Y/K */
|
JCS_CMYK, /* C/M/Y/K */
|
||||||
JCS_YCCK, /* Y/Cb/Cr/K */
|
JCS_YCCK, /* Y/Cb/Cr/K */
|
||||||
JCS_EXT_RGB, /* red/green/blue */
|
JCS_EXT_RGB, /* red/green/blue */
|
||||||
JCS_EXT_RGBX, /* red/green/blue/x */
|
JCS_EXT_RGBX, /* red/green/blue/x */
|
||||||
JCS_EXT_BGR, /* blue/green/red */
|
JCS_EXT_BGR, /* blue/green/red */
|
||||||
JCS_EXT_BGRX, /* blue/green/red/x */
|
JCS_EXT_BGRX, /* blue/green/red/x */
|
||||||
JCS_EXT_XBGR, /* x/blue/green/red */
|
JCS_EXT_XBGR, /* x/blue/green/red */
|
||||||
JCS_EXT_XRGB, /* x/red/green/blue */
|
JCS_EXT_XRGB, /* x/red/green/blue */
|
||||||
/* When out_color_space it set to JCS_EXT_RGBX, JCS_EXT_BGRX, JCS_EXT_XBGR,
|
/* When out_color_space it set to JCS_EXT_RGBX, JCS_EXT_BGRX, JCS_EXT_XBGR,
|
||||||
or JCS_EXT_XRGB during decompression, the X byte is undefined, and in
|
or JCS_EXT_XRGB during decompression, the X byte is undefined, and in
|
||||||
order to ensure the best performance, libjpeg-turbo can set that byte to
|
order to ensure the best performance, libjpeg-turbo can set that byte to
|
||||||
whatever value it wishes. Use the following colorspace constants to
|
whatever value it wishes. Use the following colorspace constants to
|
||||||
ensure that the X byte is set to 0xFF, so that it can be interpreted as an
|
ensure that the X byte is set to 0xFF, so that it can be interpreted as an
|
||||||
opaque alpha channel. */
|
opaque alpha channel. */
|
||||||
JCS_EXT_RGBA, /* red/green/blue/alpha */
|
JCS_EXT_RGBA, /* red/green/blue/alpha */
|
||||||
JCS_EXT_BGRA, /* blue/green/red/alpha */
|
JCS_EXT_BGRA, /* blue/green/red/alpha */
|
||||||
JCS_EXT_ABGR, /* alpha/blue/green/red */
|
JCS_EXT_ABGR, /* alpha/blue/green/red */
|
||||||
JCS_EXT_ARGB, /* alpha/red/green/blue */
|
JCS_EXT_ARGB, /* alpha/red/green/blue */
|
||||||
JCS_RGB565 /* 5-bit red/6-bit green/5-bit blue */
|
JCS_RGB565 /* 5-bit red/6-bit green/5-bit blue */
|
||||||
} J_COLOR_SPACE;
|
} J_COLOR_SPACE;
|
||||||
@@ -244,24 +244,24 @@ typedef enum {
|
|||||||
/* DCT/IDCT algorithm options. */
|
/* DCT/IDCT algorithm options. */
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
JDCT_ISLOW, /* slow but accurate integer algorithm */
|
JDCT_ISLOW, /* slow but accurate integer algorithm */
|
||||||
JDCT_IFAST, /* faster, less accurate integer method */
|
JDCT_IFAST, /* faster, less accurate integer method */
|
||||||
JDCT_FLOAT /* floating-point: accurate, fast on fast HW */
|
JDCT_FLOAT /* floating-point: accurate, fast on fast HW */
|
||||||
} J_DCT_METHOD;
|
} J_DCT_METHOD;
|
||||||
|
|
||||||
#ifndef JDCT_DEFAULT /* may be overridden in jconfig.h */
|
#ifndef JDCT_DEFAULT /* may be overridden in jconfig.h */
|
||||||
#define JDCT_DEFAULT JDCT_ISLOW
|
#define JDCT_DEFAULT JDCT_ISLOW
|
||||||
#endif
|
#endif
|
||||||
#ifndef JDCT_FASTEST /* may be overridden in jconfig.h */
|
#ifndef JDCT_FASTEST /* may be overridden in jconfig.h */
|
||||||
#define JDCT_FASTEST JDCT_IFAST
|
#define JDCT_FASTEST JDCT_IFAST
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Dithering options for decompression. */
|
/* Dithering options for decompression. */
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
JDITHER_NONE, /* no dithering */
|
JDITHER_NONE, /* no dithering */
|
||||||
JDITHER_ORDERED, /* simple ordered dither */
|
JDITHER_ORDERED, /* simple ordered dither */
|
||||||
JDITHER_FS /* Floyd-Steinberg error diffusion dither */
|
JDITHER_FS /* Floyd-Steinberg error diffusion dither */
|
||||||
} J_DITHER_MODE;
|
} J_DITHER_MODE;
|
||||||
|
|
||||||
|
|
||||||
@@ -307,19 +307,19 @@ typedef enum {
|
|||||||
/* Common fields between JPEG compression and decompression master structs. */
|
/* Common fields between JPEG compression and decompression master structs. */
|
||||||
|
|
||||||
#define jpeg_common_fields \
|
#define jpeg_common_fields \
|
||||||
struct jpeg_error_mgr * err; /* Error handler module */\
|
struct jpeg_error_mgr * err; /* Error handler module */\
|
||||||
struct jpeg_memory_mgr * mem; /* Memory manager module */\
|
struct jpeg_memory_mgr * mem; /* Memory manager module */\
|
||||||
struct jpeg_progress_mgr * progress; /* Progress monitor, or NULL if none */\
|
struct jpeg_progress_mgr * progress; /* Progress monitor, or NULL if none */\
|
||||||
void * client_data; /* Available for use by application */\
|
void * client_data; /* Available for use by application */\
|
||||||
boolean is_decompressor; /* So common code can tell which is which */\
|
boolean is_decompressor; /* So common code can tell which is which */\
|
||||||
int global_state /* For checking call sequence validity */
|
int global_state /* For checking call sequence validity */
|
||||||
|
|
||||||
/* Routines that are to be used by both halves of the library are declared
|
/* 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
|
* 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, only of jpeg_compress_struct and jpeg_decompress_struct.
|
||||||
*/
|
*/
|
||||||
struct jpeg_common_struct {
|
struct jpeg_common_struct {
|
||||||
jpeg_common_fields; /* Fields common to both master struct types */
|
jpeg_common_fields; /* Fields common to both master struct types */
|
||||||
/* Additional fields follow in an actual jpeg_compress_struct or
|
/* Additional fields follow in an actual jpeg_compress_struct or
|
||||||
* jpeg_decompress_struct. All three structs must agree on these
|
* jpeg_decompress_struct. All three structs must agree on these
|
||||||
* initial fields! (This would be a lot cleaner in C++.)
|
* initial fields! (This would be a lot cleaner in C++.)
|
||||||
@@ -334,7 +334,7 @@ typedef struct jpeg_decompress_struct * j_decompress_ptr;
|
|||||||
/* Master record for a compression instance */
|
/* Master record for a compression instance */
|
||||||
|
|
||||||
struct jpeg_compress_struct {
|
struct jpeg_compress_struct {
|
||||||
jpeg_common_fields; /* Fields shared with jpeg_decompress_struct */
|
jpeg_common_fields; /* Fields shared with jpeg_decompress_struct */
|
||||||
|
|
||||||
/* Destination for compressed data */
|
/* Destination for compressed data */
|
||||||
struct jpeg_destination_mgr * dest;
|
struct jpeg_destination_mgr * dest;
|
||||||
@@ -344,12 +344,12 @@ struct jpeg_compress_struct {
|
|||||||
* be correct before you can even call jpeg_set_defaults().
|
* be correct before you can even call jpeg_set_defaults().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
JDIMENSION image_width; /* input image width */
|
JDIMENSION image_width; /* input image width */
|
||||||
JDIMENSION image_height; /* input image height */
|
JDIMENSION image_height; /* input image height */
|
||||||
int input_components; /* # of color components in input image */
|
int input_components; /* # of color components in input image */
|
||||||
J_COLOR_SPACE in_color_space; /* colorspace of input image */
|
J_COLOR_SPACE in_color_space; /* colorspace of input image */
|
||||||
|
|
||||||
double input_gamma; /* image gamma of input image */
|
double input_gamma; /* image gamma of input image */
|
||||||
|
|
||||||
/* Compression parameters --- these fields must be set before calling
|
/* Compression parameters --- these fields must be set before calling
|
||||||
* jpeg_start_compress(). We recommend calling jpeg_set_defaults() to
|
* jpeg_start_compress(). We recommend calling jpeg_set_defaults() to
|
||||||
@@ -362,8 +362,8 @@ struct jpeg_compress_struct {
|
|||||||
#if JPEG_LIB_VERSION >= 70
|
#if JPEG_LIB_VERSION >= 70
|
||||||
unsigned int scale_num, scale_denom; /* fraction by which to scale image */
|
unsigned int scale_num, scale_denom; /* fraction by which to scale image */
|
||||||
|
|
||||||
JDIMENSION jpeg_width; /* scaled JPEG image width */
|
JDIMENSION jpeg_width; /* scaled JPEG image width */
|
||||||
JDIMENSION jpeg_height; /* scaled JPEG image height */
|
JDIMENSION jpeg_height; /* scaled JPEG image height */
|
||||||
/* Dimensions of actual JPEG image that will be written to file,
|
/* Dimensions of actual JPEG image that will be written to file,
|
||||||
* derived from input dimensions by scaling factors above.
|
* derived from input dimensions by scaling factors above.
|
||||||
* These fields are computed by jpeg_start_compress().
|
* These fields are computed by jpeg_start_compress().
|
||||||
@@ -372,9 +372,9 @@ struct jpeg_compress_struct {
|
|||||||
*/
|
*/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int data_precision; /* bits of precision in image data */
|
int data_precision; /* bits of precision in image data */
|
||||||
|
|
||||||
int num_components; /* # of color components in JPEG image */
|
int num_components; /* # of color components in JPEG image */
|
||||||
J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */
|
J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */
|
||||||
|
|
||||||
jpeg_component_info * comp_info;
|
jpeg_component_info * comp_info;
|
||||||
@@ -396,22 +396,22 @@ struct jpeg_compress_struct {
|
|||||||
UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */
|
UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */
|
||||||
UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */
|
UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */
|
||||||
|
|
||||||
int num_scans; /* # of entries in scan_info array */
|
int num_scans; /* # of entries in scan_info array */
|
||||||
const jpeg_scan_info * scan_info; /* script for multi-scan file, or NULL */
|
const jpeg_scan_info * scan_info; /* script for multi-scan file, or NULL */
|
||||||
/* The default value of scan_info is NULL, which causes a single-scan
|
/* The default value of scan_info is NULL, which causes a single-scan
|
||||||
* sequential JPEG file to be emitted. To create a multi-scan file,
|
* 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.
|
* set num_scans and scan_info to point to an array of scan definitions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
boolean raw_data_in; /* TRUE=caller supplies downsampled data */
|
boolean raw_data_in; /* TRUE=caller supplies downsampled data */
|
||||||
boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */
|
boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */
|
||||||
boolean optimize_coding; /* TRUE=optimize entropy encoding parms */
|
boolean optimize_coding; /* TRUE=optimize entropy encoding parms */
|
||||||
boolean CCIR601_sampling; /* TRUE=first samples are cosited */
|
boolean CCIR601_sampling; /* TRUE=first samples are cosited */
|
||||||
#if JPEG_LIB_VERSION >= 70
|
#if JPEG_LIB_VERSION >= 70
|
||||||
boolean do_fancy_downsampling; /* TRUE=apply fancy downsampling */
|
boolean do_fancy_downsampling; /* TRUE=apply fancy downsampling */
|
||||||
#endif
|
#endif
|
||||||
int smoothing_factor; /* 1..100, or 0 for no input smoothing */
|
int smoothing_factor; /* 1..100, or 0 for no input smoothing */
|
||||||
J_DCT_METHOD dct_method; /* DCT algorithm selector */
|
J_DCT_METHOD dct_method; /* DCT algorithm selector */
|
||||||
|
|
||||||
/* The restart interval can be specified in absolute MCUs by setting
|
/* The restart interval can be specified in absolute MCUs by setting
|
||||||
* restart_interval, or in MCU rows by setting restart_in_rows
|
* restart_interval, or in MCU rows by setting restart_in_rows
|
||||||
@@ -419,28 +419,28 @@ struct jpeg_compress_struct {
|
|||||||
* for each scan).
|
* for each scan).
|
||||||
*/
|
*/
|
||||||
unsigned int restart_interval; /* MCUs per restart, or 0 for no restart */
|
unsigned int restart_interval; /* MCUs per restart, or 0 for no restart */
|
||||||
int restart_in_rows; /* if > 0, MCU rows per restart interval */
|
int restart_in_rows; /* if > 0, MCU rows per restart interval */
|
||||||
|
|
||||||
/* Parameters controlling emission of special markers. */
|
/* Parameters controlling emission of special markers. */
|
||||||
|
|
||||||
boolean write_JFIF_header; /* should a JFIF marker be written? */
|
boolean write_JFIF_header; /* should a JFIF marker be written? */
|
||||||
UINT8 JFIF_major_version; /* What to write for the JFIF version number */
|
UINT8 JFIF_major_version; /* What to write for the JFIF version number */
|
||||||
UINT8 JFIF_minor_version;
|
UINT8 JFIF_minor_version;
|
||||||
/* These three values are not used by the JPEG code, merely copied */
|
/* These three values are not used by the JPEG code, merely copied */
|
||||||
/* into the JFIF APP0 marker. density_unit can be 0 for unknown, */
|
/* 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 */
|
/* 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. */
|
/* ratio is defined by X_density/Y_density even when density_unit=0. */
|
||||||
UINT8 density_unit; /* JFIF code for pixel size units */
|
UINT8 density_unit; /* JFIF code for pixel size units */
|
||||||
UINT16 X_density; /* Horizontal pixel density */
|
UINT16 X_density; /* Horizontal pixel density */
|
||||||
UINT16 Y_density; /* Vertical pixel density */
|
UINT16 Y_density; /* Vertical pixel density */
|
||||||
boolean write_Adobe_marker; /* should an Adobe marker be written? */
|
boolean write_Adobe_marker; /* should an Adobe marker be written? */
|
||||||
|
|
||||||
/* State variable: index of next scanline to be written to
|
/* State variable: index of next scanline to be written to
|
||||||
* jpeg_write_scanlines(). Application may use this to control its
|
* jpeg_write_scanlines(). Application may use this to control its
|
||||||
* processing loop, e.g., "while (next_scanline < image_height)".
|
* processing loop, e.g., "while (next_scanline < image_height)".
|
||||||
*/
|
*/
|
||||||
|
|
||||||
JDIMENSION next_scanline; /* 0 .. image_height-1 */
|
JDIMENSION next_scanline; /* 0 .. image_height-1 */
|
||||||
|
|
||||||
/* Remaining fields are known throughout compressor, but generally
|
/* Remaining fields are known throughout compressor, but generally
|
||||||
* should not be touched by a surrounding application.
|
* should not be touched by a surrounding application.
|
||||||
@@ -449,44 +449,44 @@ struct jpeg_compress_struct {
|
|||||||
/*
|
/*
|
||||||
* These fields are computed during compression startup
|
* These fields are computed during compression startup
|
||||||
*/
|
*/
|
||||||
boolean progressive_mode; /* TRUE if scan script uses progressive mode */
|
boolean progressive_mode; /* TRUE if scan script uses progressive mode */
|
||||||
int max_h_samp_factor; /* largest h_samp_factor */
|
int max_h_samp_factor; /* largest h_samp_factor */
|
||||||
int max_v_samp_factor; /* largest v_samp_factor */
|
int max_v_samp_factor; /* largest v_samp_factor */
|
||||||
|
|
||||||
#if JPEG_LIB_VERSION >= 70
|
#if JPEG_LIB_VERSION >= 70
|
||||||
int min_DCT_h_scaled_size; /* smallest DCT_h_scaled_size of any component */
|
int min_DCT_h_scaled_size; /* smallest DCT_h_scaled_size of any component */
|
||||||
int min_DCT_v_scaled_size; /* smallest DCT_v_scaled_size of any component */
|
int min_DCT_v_scaled_size; /* smallest DCT_v_scaled_size of any component */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */
|
JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */
|
||||||
/* The coefficient controller receives data in units of MCU rows as defined
|
/* The coefficient controller receives data in units of MCU rows as defined
|
||||||
* for fully interleaved scans (whether the JPEG file is interleaved or not).
|
* 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
|
* There are v_samp_factor * DCTSIZE sample rows of each component in an
|
||||||
* "iMCU" (interleaved MCU) row.
|
* "iMCU" (interleaved MCU) row.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These fields are valid during any one scan.
|
* These fields are valid during any one scan.
|
||||||
* They describe the components and MCUs actually appearing in the scan.
|
* They describe the components and MCUs actually appearing in the scan.
|
||||||
*/
|
*/
|
||||||
int comps_in_scan; /* # of JPEG components in this scan */
|
int comps_in_scan; /* # of JPEG components in this scan */
|
||||||
jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN];
|
jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN];
|
||||||
/* *cur_comp_info[i] describes component that appears i'th in SOS */
|
/* *cur_comp_info[i] describes component that appears i'th in SOS */
|
||||||
|
|
||||||
JDIMENSION MCUs_per_row; /* # of MCUs across the image */
|
JDIMENSION MCUs_per_row; /* # of MCUs across the image */
|
||||||
JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */
|
JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */
|
||||||
|
|
||||||
int blocks_in_MCU; /* # of DCT blocks per MCU */
|
int blocks_in_MCU; /* # of DCT blocks per MCU */
|
||||||
int MCU_membership[C_MAX_BLOCKS_IN_MCU];
|
int MCU_membership[C_MAX_BLOCKS_IN_MCU];
|
||||||
/* MCU_membership[i] is index in cur_comp_info of component owning */
|
/* MCU_membership[i] is index in cur_comp_info of component owning */
|
||||||
/* i'th block in an MCU */
|
/* i'th block in an MCU */
|
||||||
|
|
||||||
int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */
|
int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */
|
||||||
|
|
||||||
#if JPEG_LIB_VERSION >= 80
|
#if JPEG_LIB_VERSION >= 80
|
||||||
int block_size; /* the basic DCT block size: 1..16 */
|
int block_size; /* the basic DCT block size: 1..16 */
|
||||||
const int * natural_order; /* natural-order position array */
|
const int * natural_order; /* natural-order position array */
|
||||||
int lim_Se; /* min( Se, DCTSIZE2-1 ) */
|
int lim_Se; /* min( Se, DCTSIZE2-1 ) */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -509,7 +509,7 @@ struct jpeg_compress_struct {
|
|||||||
/* Master record for a decompression instance */
|
/* Master record for a decompression instance */
|
||||||
|
|
||||||
struct jpeg_decompress_struct {
|
struct jpeg_decompress_struct {
|
||||||
jpeg_common_fields; /* Fields shared with jpeg_compress_struct */
|
jpeg_common_fields; /* Fields shared with jpeg_compress_struct */
|
||||||
|
|
||||||
/* Source of compressed data */
|
/* Source of compressed data */
|
||||||
struct jpeg_source_mgr * src;
|
struct jpeg_source_mgr * src;
|
||||||
@@ -517,9 +517,9 @@ struct jpeg_decompress_struct {
|
|||||||
/* Basic description of image --- filled in by jpeg_read_header(). */
|
/* Basic description of image --- filled in by jpeg_read_header(). */
|
||||||
/* Application may inspect these values to decide how to process image. */
|
/* Application may inspect these values to decide how to process image. */
|
||||||
|
|
||||||
JDIMENSION image_width; /* nominal image width (from SOF marker) */
|
JDIMENSION image_width; /* nominal image width (from SOF marker) */
|
||||||
JDIMENSION image_height; /* nominal image height */
|
JDIMENSION image_height; /* nominal image height */
|
||||||
int num_components; /* # of color components in JPEG image */
|
int num_components; /* # of color components in JPEG image */
|
||||||
J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */
|
J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */
|
||||||
|
|
||||||
/* Decompression processing parameters --- these fields must be set before
|
/* Decompression processing parameters --- these fields must be set before
|
||||||
@@ -531,24 +531,24 @@ struct jpeg_decompress_struct {
|
|||||||
|
|
||||||
unsigned int scale_num, scale_denom; /* fraction by which to scale image */
|
unsigned int scale_num, scale_denom; /* fraction by which to scale image */
|
||||||
|
|
||||||
double output_gamma; /* image gamma wanted in output */
|
double output_gamma; /* image gamma wanted in output */
|
||||||
|
|
||||||
boolean buffered_image; /* TRUE=multiple output passes */
|
boolean buffered_image; /* TRUE=multiple output passes */
|
||||||
boolean raw_data_out; /* TRUE=downsampled data wanted */
|
boolean raw_data_out; /* TRUE=downsampled data wanted */
|
||||||
|
|
||||||
J_DCT_METHOD dct_method; /* IDCT algorithm selector */
|
J_DCT_METHOD dct_method; /* IDCT algorithm selector */
|
||||||
boolean do_fancy_upsampling; /* TRUE=apply fancy upsampling */
|
boolean do_fancy_upsampling; /* TRUE=apply fancy upsampling */
|
||||||
boolean do_block_smoothing; /* TRUE=apply interblock smoothing */
|
boolean do_block_smoothing; /* TRUE=apply interblock smoothing */
|
||||||
|
|
||||||
boolean quantize_colors; /* TRUE=colormapped output wanted */
|
boolean quantize_colors; /* TRUE=colormapped output wanted */
|
||||||
/* the following are ignored if not quantize_colors: */
|
/* the following are ignored if not quantize_colors: */
|
||||||
J_DITHER_MODE dither_mode; /* type of color dithering to use */
|
J_DITHER_MODE dither_mode; /* type of color dithering to use */
|
||||||
boolean two_pass_quantize; /* TRUE=use two-pass color quantization */
|
boolean two_pass_quantize; /* TRUE=use two-pass color quantization */
|
||||||
int desired_number_of_colors; /* max # colors to use in created colormap */
|
int desired_number_of_colors; /* max # colors to use in created colormap */
|
||||||
/* these are significant only in buffered-image mode: */
|
/* these are significant only in buffered-image mode: */
|
||||||
boolean enable_1pass_quant; /* enable future use of 1-pass quantizer */
|
boolean enable_1pass_quant; /* enable future use of 1-pass quantizer */
|
||||||
boolean enable_external_quant;/* enable future use of external colormap */
|
boolean enable_external_quant;/* enable future use of external colormap */
|
||||||
boolean enable_2pass_quant; /* enable future use of 2-pass quantizer */
|
boolean enable_2pass_quant; /* enable future use of 2-pass quantizer */
|
||||||
|
|
||||||
/* Description of actual output image that will be returned to application.
|
/* Description of actual output image that will be returned to application.
|
||||||
* These fields are computed by jpeg_start_decompress().
|
* These fields are computed by jpeg_start_decompress().
|
||||||
@@ -556,14 +556,14 @@ struct jpeg_decompress_struct {
|
|||||||
* in advance of calling jpeg_start_decompress().
|
* in advance of calling jpeg_start_decompress().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
JDIMENSION output_width; /* scaled image width */
|
JDIMENSION output_width; /* scaled image width */
|
||||||
JDIMENSION output_height; /* scaled image height */
|
JDIMENSION output_height; /* scaled image height */
|
||||||
int out_color_components; /* # of color components in out_color_space */
|
int out_color_components; /* # of color components in out_color_space */
|
||||||
int output_components; /* # of color components returned */
|
int output_components; /* # of color components returned */
|
||||||
/* output_components is 1 (a colormap index) when quantizing colors;
|
/* output_components is 1 (a colormap index) when quantizing colors;
|
||||||
* otherwise it equals out_color_components.
|
* otherwise it equals out_color_components.
|
||||||
*/
|
*/
|
||||||
int rec_outbuf_height; /* min recommended height of scanline buffer */
|
int rec_outbuf_height; /* min recommended height of scanline buffer */
|
||||||
/* If the buffer passed to jpeg_read_scanlines() is less than this many rows
|
/* 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.
|
* high, space and time will be wasted due to unnecessary data copying.
|
||||||
* Usually rec_outbuf_height will be 1 or 2, at most 4.
|
* Usually rec_outbuf_height will be 1 or 2, at most 4.
|
||||||
@@ -575,8 +575,8 @@ struct jpeg_decompress_struct {
|
|||||||
* jpeg_start_decompress or jpeg_start_output.
|
* jpeg_start_decompress or jpeg_start_output.
|
||||||
* The map has out_color_components rows and actual_number_of_colors columns.
|
* The map has out_color_components rows and actual_number_of_colors columns.
|
||||||
*/
|
*/
|
||||||
int actual_number_of_colors; /* number of entries in use */
|
int actual_number_of_colors; /* number of entries in use */
|
||||||
JSAMPARRAY colormap; /* The color map as a 2-D pixel array */
|
JSAMPARRAY colormap; /* The color map as a 2-D pixel array */
|
||||||
|
|
||||||
/* State variables: these variables indicate the progress of decompression.
|
/* State variables: these variables indicate the progress of decompression.
|
||||||
* The application may examine these but must not modify them.
|
* The application may examine these but must not modify them.
|
||||||
@@ -586,20 +586,20 @@ struct jpeg_decompress_struct {
|
|||||||
* Application may use this to control its processing loop, e.g.,
|
* Application may use this to control its processing loop, e.g.,
|
||||||
* "while (output_scanline < output_height)".
|
* "while (output_scanline < output_height)".
|
||||||
*/
|
*/
|
||||||
JDIMENSION output_scanline; /* 0 .. output_height-1 */
|
JDIMENSION output_scanline; /* 0 .. output_height-1 */
|
||||||
|
|
||||||
/* Current input scan number and number of iMCU rows completed in scan.
|
/* Current input scan number and number of iMCU rows completed in scan.
|
||||||
* These indicate the progress of the decompressor input side.
|
* These indicate the progress of the decompressor input side.
|
||||||
*/
|
*/
|
||||||
int input_scan_number; /* Number of SOS markers seen so far */
|
int input_scan_number; /* Number of SOS markers seen so far */
|
||||||
JDIMENSION input_iMCU_row; /* Number of iMCU rows completed */
|
JDIMENSION input_iMCU_row; /* Number of iMCU rows completed */
|
||||||
|
|
||||||
/* The "output scan number" is the notional scan being displayed by the
|
/* The "output scan number" is the notional scan being displayed by the
|
||||||
* output side. The decompressor will not allow output scan/row number
|
* 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.
|
* to get ahead of input scan/row, but it can fall arbitrarily far behind.
|
||||||
*/
|
*/
|
||||||
int output_scan_number; /* Nominal scan number being displayed */
|
int output_scan_number; /* Nominal scan number being displayed */
|
||||||
JDIMENSION output_iMCU_row; /* Number of iMCU rows read */
|
JDIMENSION output_iMCU_row; /* Number of iMCU rows read */
|
||||||
|
|
||||||
/* Current progression status. coef_bits[c][i] indicates the precision
|
/* Current progression status. coef_bits[c][i] indicates the precision
|
||||||
* with which component c's DCT coefficient i (in zigzag order) is known.
|
* with which component c's DCT coefficient i (in zigzag order) is known.
|
||||||
@@ -608,7 +608,7 @@ struct jpeg_decompress_struct {
|
|||||||
* (thus, 0 at completion of the progression).
|
* (thus, 0 at completion of the progression).
|
||||||
* This pointer is NULL when reading a non-progressive file.
|
* This pointer is NULL when reading a non-progressive file.
|
||||||
*/
|
*/
|
||||||
int (*coef_bits)[DCTSIZE2]; /* -1 or current Al value for each coef */
|
int (*coef_bits)[DCTSIZE2]; /* -1 or current Al value for each coef */
|
||||||
|
|
||||||
/* Internal JPEG parameters --- the application usually need not look at
|
/* Internal JPEG parameters --- the application usually need not look at
|
||||||
* these fields. Note that the decompressor output side may not use
|
* these fields. Note that the decompressor output side may not use
|
||||||
@@ -630,16 +630,16 @@ struct jpeg_decompress_struct {
|
|||||||
* are given in SOF/SOS markers or defined to be reset by SOI.
|
* are given in SOF/SOS markers or defined to be reset by SOI.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int data_precision; /* bits of precision in image data */
|
int data_precision; /* bits of precision in image data */
|
||||||
|
|
||||||
jpeg_component_info * comp_info;
|
jpeg_component_info * comp_info;
|
||||||
/* comp_info[i] describes component that appears i'th in SOF */
|
/* comp_info[i] describes component that appears i'th in SOF */
|
||||||
|
|
||||||
#if JPEG_LIB_VERSION >= 80
|
#if JPEG_LIB_VERSION >= 80
|
||||||
boolean is_baseline; /* TRUE if Baseline SOF0 encountered */
|
boolean is_baseline; /* TRUE if Baseline SOF0 encountered */
|
||||||
#endif
|
#endif
|
||||||
boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */
|
boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */
|
||||||
boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */
|
boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */
|
||||||
|
|
||||||
UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */
|
UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */
|
||||||
UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */
|
UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */
|
||||||
@@ -650,17 +650,17 @@ struct jpeg_decompress_struct {
|
|||||||
/* These fields record data obtained from optional markers recognized by
|
/* These fields record data obtained from optional markers recognized by
|
||||||
* the JPEG library.
|
* the JPEG library.
|
||||||
*/
|
*/
|
||||||
boolean saw_JFIF_marker; /* TRUE iff a JFIF APP0 marker was found */
|
boolean saw_JFIF_marker; /* TRUE iff a JFIF APP0 marker was found */
|
||||||
/* Data copied from JFIF marker; only valid if saw_JFIF_marker is TRUE: */
|
/* Data copied from JFIF marker; only valid if saw_JFIF_marker is TRUE: */
|
||||||
UINT8 JFIF_major_version; /* JFIF version number */
|
UINT8 JFIF_major_version; /* JFIF version number */
|
||||||
UINT8 JFIF_minor_version;
|
UINT8 JFIF_minor_version;
|
||||||
UINT8 density_unit; /* JFIF code for pixel size units */
|
UINT8 density_unit; /* JFIF code for pixel size units */
|
||||||
UINT16 X_density; /* Horizontal pixel density */
|
UINT16 X_density; /* Horizontal pixel density */
|
||||||
UINT16 Y_density; /* Vertical pixel density */
|
UINT16 Y_density; /* Vertical pixel density */
|
||||||
boolean saw_Adobe_marker; /* TRUE iff an Adobe APP14 marker was found */
|
boolean saw_Adobe_marker; /* TRUE iff an Adobe APP14 marker was found */
|
||||||
UINT8 Adobe_transform; /* Color transform code from Adobe marker */
|
UINT8 Adobe_transform; /* Color transform code from Adobe marker */
|
||||||
|
|
||||||
boolean CCIR601_sampling; /* TRUE=first samples are cosited */
|
boolean CCIR601_sampling; /* TRUE=first samples are cosited */
|
||||||
|
|
||||||
/* Aside from the specific data retained from APPn markers known to the
|
/* Aside from the specific data retained from APPn markers known to the
|
||||||
* library, the uninterpreted contents of any or all APPn and COM markers
|
* library, the uninterpreted contents of any or all APPn and COM markers
|
||||||
@@ -675,17 +675,17 @@ struct jpeg_decompress_struct {
|
|||||||
/*
|
/*
|
||||||
* These fields are computed during decompression startup
|
* These fields are computed during decompression startup
|
||||||
*/
|
*/
|
||||||
int max_h_samp_factor; /* largest h_samp_factor */
|
int max_h_samp_factor; /* largest h_samp_factor */
|
||||||
int max_v_samp_factor; /* largest v_samp_factor */
|
int max_v_samp_factor; /* largest v_samp_factor */
|
||||||
|
|
||||||
#if JPEG_LIB_VERSION >= 70
|
#if JPEG_LIB_VERSION >= 70
|
||||||
int min_DCT_h_scaled_size; /* smallest DCT_h_scaled_size of any component */
|
int min_DCT_h_scaled_size; /* smallest DCT_h_scaled_size of any component */
|
||||||
int min_DCT_v_scaled_size; /* smallest DCT_v_scaled_size of any component */
|
int min_DCT_v_scaled_size; /* smallest DCT_v_scaled_size of any component */
|
||||||
#else
|
#else
|
||||||
int min_DCT_scaled_size; /* smallest DCT_scaled_size of any component */
|
int min_DCT_scaled_size; /* smallest DCT_scaled_size of any component */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */
|
JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */
|
||||||
/* The coefficient controller's input and output progress is measured in
|
/* The coefficient controller's input and output progress is measured in
|
||||||
* units of "iMCU" (interleaved MCU) rows. These are the same as MCU rows
|
* 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
|
* in fully interleaved JPEG scans, but are used whether the scan is
|
||||||
@@ -701,26 +701,26 @@ struct jpeg_decompress_struct {
|
|||||||
* They describe the components and MCUs actually appearing in the scan.
|
* They describe the components and MCUs actually appearing in the scan.
|
||||||
* Note that the decompressor output side must not use these fields.
|
* Note that the decompressor output side must not use these fields.
|
||||||
*/
|
*/
|
||||||
int comps_in_scan; /* # of JPEG components in this scan */
|
int comps_in_scan; /* # of JPEG components in this scan */
|
||||||
jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN];
|
jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN];
|
||||||
/* *cur_comp_info[i] describes component that appears i'th in SOS */
|
/* *cur_comp_info[i] describes component that appears i'th in SOS */
|
||||||
|
|
||||||
JDIMENSION MCUs_per_row; /* # of MCUs across the image */
|
JDIMENSION MCUs_per_row; /* # of MCUs across the image */
|
||||||
JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */
|
JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */
|
||||||
|
|
||||||
int blocks_in_MCU; /* # of DCT blocks per MCU */
|
int blocks_in_MCU; /* # of DCT blocks per MCU */
|
||||||
int MCU_membership[D_MAX_BLOCKS_IN_MCU];
|
int MCU_membership[D_MAX_BLOCKS_IN_MCU];
|
||||||
/* MCU_membership[i] is index in cur_comp_info of component owning */
|
/* MCU_membership[i] is index in cur_comp_info of component owning */
|
||||||
/* i'th block in an MCU */
|
/* i'th block in an MCU */
|
||||||
|
|
||||||
int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */
|
int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */
|
||||||
|
|
||||||
#if JPEG_LIB_VERSION >= 80
|
#if JPEG_LIB_VERSION >= 80
|
||||||
/* These fields are derived from Se of first SOS marker.
|
/* These fields are derived from Se of first SOS marker.
|
||||||
*/
|
*/
|
||||||
int block_size; /* the basic DCT block size: 1..16 */
|
int block_size; /* the basic DCT block size: 1..16 */
|
||||||
const int * natural_order; /* natural-order position array for entropy decode */
|
const int * natural_order; /* natural-order position array for entropy decode */
|
||||||
int lim_Se; /* min( Se, DCTSIZE2-1 ) for entropy decode */
|
int lim_Se; /* min( Se, DCTSIZE2-1 ) for entropy decode */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This field is shared between entropy decoder and marker parser.
|
/* This field is shared between entropy decoder and marker parser.
|
||||||
@@ -765,10 +765,10 @@ struct jpeg_error_mgr {
|
|||||||
void (*output_message) (j_common_ptr cinfo);
|
void (*output_message) (j_common_ptr cinfo);
|
||||||
/* Format a message string for the most recent JPEG error or message */
|
/* Format a message string for the most recent JPEG error or message */
|
||||||
void (*format_message) (j_common_ptr cinfo, char * buffer);
|
void (*format_message) (j_common_ptr cinfo, char * buffer);
|
||||||
#define JMSG_LENGTH_MAX 200 /* recommended size of format_message buffer */
|
#define JMSG_LENGTH_MAX 200 /* recommended size of format_message buffer */
|
||||||
/* Reset error state variables at start of a new image */
|
/* Reset error state variables at start of a new image */
|
||||||
void (*reset_error_mgr) (j_common_ptr cinfo);
|
void (*reset_error_mgr) (j_common_ptr cinfo);
|
||||||
|
|
||||||
/* The message ID code and any parameters are saved here.
|
/* The message ID code and any parameters are saved here.
|
||||||
* A message can have one string parameter or up to 8 int parameters.
|
* A message can have one string parameter or up to 8 int parameters.
|
||||||
*/
|
*/
|
||||||
@@ -778,18 +778,18 @@ struct jpeg_error_mgr {
|
|||||||
int i[8];
|
int i[8];
|
||||||
char s[JMSG_STR_PARM_MAX];
|
char s[JMSG_STR_PARM_MAX];
|
||||||
} msg_parm;
|
} msg_parm;
|
||||||
|
|
||||||
/* Standard state variables for error facility */
|
/* Standard state variables for error facility */
|
||||||
|
|
||||||
int trace_level; /* max msg_level that will be displayed */
|
int trace_level; /* max msg_level that will be displayed */
|
||||||
|
|
||||||
/* For recoverable corrupt-data errors, we emit a warning message,
|
/* For recoverable corrupt-data errors, we emit a warning message,
|
||||||
* but keep going unless emit_message chooses to abort. emit_message
|
* but keep going unless emit_message chooses to abort. emit_message
|
||||||
* should count warnings in num_warnings. The surrounding application
|
* should count warnings in num_warnings. The surrounding application
|
||||||
* can check for bad data by seeing if num_warnings is nonzero at the
|
* can check for bad data by seeing if num_warnings is nonzero at the
|
||||||
* end of processing.
|
* end of processing.
|
||||||
*/
|
*/
|
||||||
long num_warnings; /* number of corrupt-data warnings */
|
long num_warnings; /* number of corrupt-data warnings */
|
||||||
|
|
||||||
/* These fields point to the table(s) of error message strings.
|
/* These fields point to the table(s) of error message strings.
|
||||||
* An application can change the table pointer to switch to a different
|
* An application can change the table pointer to switch to a different
|
||||||
@@ -807,8 +807,8 @@ struct jpeg_error_mgr {
|
|||||||
* It contains strings numbered first_addon_message..last_addon_message.
|
* It contains strings numbered first_addon_message..last_addon_message.
|
||||||
*/
|
*/
|
||||||
const char * const * addon_message_table; /* Non-library errors */
|
const char * const * addon_message_table; /* Non-library errors */
|
||||||
int first_addon_message; /* code for first string in addon table */
|
int first_addon_message; /* code for first string in addon table */
|
||||||
int last_addon_message; /* code for last string in addon table */
|
int last_addon_message; /* code for last string in addon table */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -817,18 +817,18 @@ struct jpeg_error_mgr {
|
|||||||
struct jpeg_progress_mgr {
|
struct jpeg_progress_mgr {
|
||||||
void (*progress_monitor) (j_common_ptr cinfo);
|
void (*progress_monitor) (j_common_ptr cinfo);
|
||||||
|
|
||||||
long pass_counter; /* work units completed in this pass */
|
long pass_counter; /* work units completed in this pass */
|
||||||
long pass_limit; /* total number of work units in this pass */
|
long pass_limit; /* total number of work units in this pass */
|
||||||
int completed_passes; /* passes completed so far */
|
int completed_passes; /* passes completed so far */
|
||||||
int total_passes; /* total number of passes expected */
|
int total_passes; /* total number of passes expected */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* Data destination object for compression */
|
/* Data destination object for compression */
|
||||||
|
|
||||||
struct jpeg_destination_mgr {
|
struct jpeg_destination_mgr {
|
||||||
JOCTET * next_output_byte; /* => next byte to write in buffer */
|
JOCTET * next_output_byte; /* => next byte to write in buffer */
|
||||||
size_t free_in_buffer; /* # of byte spaces remaining in buffer */
|
size_t free_in_buffer; /* # of byte spaces remaining in buffer */
|
||||||
|
|
||||||
void (*init_destination) (j_compress_ptr cinfo);
|
void (*init_destination) (j_compress_ptr cinfo);
|
||||||
boolean (*empty_output_buffer) (j_compress_ptr cinfo);
|
boolean (*empty_output_buffer) (j_compress_ptr cinfo);
|
||||||
@@ -840,7 +840,7 @@ struct jpeg_destination_mgr {
|
|||||||
|
|
||||||
struct jpeg_source_mgr {
|
struct jpeg_source_mgr {
|
||||||
const JOCTET * next_input_byte; /* => next byte to read from buffer */
|
const JOCTET * next_input_byte; /* => next byte to read from buffer */
|
||||||
size_t bytes_in_buffer; /* # of bytes remaining in buffer */
|
size_t bytes_in_buffer; /* # of bytes remaining in buffer */
|
||||||
|
|
||||||
void (*init_source) (j_decompress_ptr cinfo);
|
void (*init_source) (j_decompress_ptr cinfo);
|
||||||
boolean (*fill_input_buffer) (j_decompress_ptr cinfo);
|
boolean (*fill_input_buffer) (j_decompress_ptr cinfo);
|
||||||
@@ -861,9 +861,9 @@ struct jpeg_source_mgr {
|
|||||||
* successful.
|
* successful.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define JPOOL_PERMANENT 0 /* lasts until master record is destroyed */
|
#define JPOOL_PERMANENT 0 /* lasts until master record is destroyed */
|
||||||
#define JPOOL_IMAGE 1 /* lasts until done with image/datastream */
|
#define JPOOL_IMAGE 1 /* lasts until done with image/datastream */
|
||||||
#define JPOOL_NUMPOOLS 2
|
#define JPOOL_NUMPOOLS 2
|
||||||
|
|
||||||
typedef struct jvirt_sarray_control * jvirt_sarray_ptr;
|
typedef struct jvirt_sarray_control * jvirt_sarray_ptr;
|
||||||
typedef struct jvirt_barray_control * jvirt_barray_ptr;
|
typedef struct jvirt_barray_control * jvirt_barray_ptr;
|
||||||
@@ -879,14 +879,14 @@ struct jpeg_memory_mgr {
|
|||||||
JBLOCKARRAY (*alloc_barray) (j_common_ptr cinfo, int pool_id,
|
JBLOCKARRAY (*alloc_barray) (j_common_ptr cinfo, int pool_id,
|
||||||
JDIMENSION blocksperrow, JDIMENSION numrows);
|
JDIMENSION blocksperrow, JDIMENSION numrows);
|
||||||
jvirt_sarray_ptr (*request_virt_sarray) (j_common_ptr cinfo, int pool_id,
|
jvirt_sarray_ptr (*request_virt_sarray) (j_common_ptr cinfo, int pool_id,
|
||||||
boolean pre_zero,
|
boolean pre_zero,
|
||||||
JDIMENSION samplesperrow,
|
JDIMENSION samplesperrow,
|
||||||
JDIMENSION numrows,
|
JDIMENSION numrows,
|
||||||
JDIMENSION maxaccess);
|
JDIMENSION maxaccess);
|
||||||
jvirt_barray_ptr (*request_virt_barray) (j_common_ptr cinfo, int pool_id,
|
jvirt_barray_ptr (*request_virt_barray) (j_common_ptr cinfo, int pool_id,
|
||||||
boolean pre_zero,
|
boolean pre_zero,
|
||||||
JDIMENSION blocksperrow,
|
JDIMENSION blocksperrow,
|
||||||
JDIMENSION numrows,
|
JDIMENSION numrows,
|
||||||
JDIMENSION maxaccess);
|
JDIMENSION maxaccess);
|
||||||
void (*realize_virt_arrays) (j_common_ptr cinfo);
|
void (*realize_virt_arrays) (j_common_ptr cinfo);
|
||||||
JSAMPARRAY (*access_virt_sarray) (j_common_ptr cinfo, jvirt_sarray_ptr ptr,
|
JSAMPARRAY (*access_virt_sarray) (j_common_ptr cinfo, jvirt_sarray_ptr ptr,
|
||||||
@@ -928,10 +928,10 @@ EXTERN(struct jpeg_error_mgr *) jpeg_std_error (struct jpeg_error_mgr * err);
|
|||||||
*/
|
*/
|
||||||
#define jpeg_create_compress(cinfo) \
|
#define jpeg_create_compress(cinfo) \
|
||||||
jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \
|
jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \
|
||||||
(size_t) sizeof(struct jpeg_compress_struct))
|
(size_t) sizeof(struct jpeg_compress_struct))
|
||||||
#define jpeg_create_decompress(cinfo) \
|
#define jpeg_create_decompress(cinfo) \
|
||||||
jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \
|
jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \
|
||||||
(size_t) sizeof(struct jpeg_decompress_struct))
|
(size_t) sizeof(struct jpeg_decompress_struct))
|
||||||
EXTERN(void) jpeg_CreateCompress (j_compress_ptr cinfo, int version,
|
EXTERN(void) jpeg_CreateCompress (j_compress_ptr cinfo, int version,
|
||||||
size_t structsize);
|
size_t structsize);
|
||||||
EXTERN(void) jpeg_CreateDecompress (j_decompress_ptr cinfo, int version,
|
EXTERN(void) jpeg_CreateDecompress (j_decompress_ptr cinfo, int version,
|
||||||
@@ -968,7 +968,7 @@ EXTERN(void) jpeg_default_qtables (j_compress_ptr cinfo,
|
|||||||
boolean force_baseline);
|
boolean force_baseline);
|
||||||
#endif
|
#endif
|
||||||
EXTERN(void) jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl,
|
EXTERN(void) jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl,
|
||||||
const unsigned int *basic_table,
|
const unsigned int *basic_table,
|
||||||
int scale_factor, boolean force_baseline);
|
int scale_factor, boolean force_baseline);
|
||||||
EXTERN(int) jpeg_quality_scaling (int quality);
|
EXTERN(int) jpeg_quality_scaling (int quality);
|
||||||
EXTERN(float) jpeg_float_quality_scaling (float quality);
|
EXTERN(float) jpeg_float_quality_scaling (float quality);
|
||||||
@@ -981,7 +981,7 @@ EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table (j_common_ptr cinfo);
|
|||||||
EXTERN(void) jpeg_start_compress (j_compress_ptr cinfo,
|
EXTERN(void) jpeg_start_compress (j_compress_ptr cinfo,
|
||||||
boolean write_all_tables);
|
boolean write_all_tables);
|
||||||
EXTERN(JDIMENSION) jpeg_write_scanlines (j_compress_ptr cinfo,
|
EXTERN(JDIMENSION) jpeg_write_scanlines (j_compress_ptr cinfo,
|
||||||
JSAMPARRAY scanlines,
|
JSAMPARRAY scanlines,
|
||||||
JDIMENSION num_lines);
|
JDIMENSION num_lines);
|
||||||
EXTERN(void) jpeg_finish_compress (j_compress_ptr cinfo);
|
EXTERN(void) jpeg_finish_compress (j_compress_ptr cinfo);
|
||||||
|
|
||||||
@@ -1008,9 +1008,9 @@ EXTERN(void) jpeg_write_tables (j_compress_ptr cinfo);
|
|||||||
/* Decompression startup: read start of JPEG datastream to see what's there */
|
/* Decompression startup: read start of JPEG datastream to see what's there */
|
||||||
EXTERN(int) jpeg_read_header (j_decompress_ptr cinfo, boolean require_image);
|
EXTERN(int) jpeg_read_header (j_decompress_ptr cinfo, boolean require_image);
|
||||||
/* Return value is one of: */
|
/* Return value is one of: */
|
||||||
#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */
|
#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */
|
||||||
#define JPEG_HEADER_OK 1 /* Found valid image datastream */
|
#define JPEG_HEADER_OK 1 /* Found valid image datastream */
|
||||||
#define JPEG_HEADER_TABLES_ONLY 2 /* Found valid table-specs-only 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
|
/* 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.
|
* 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
|
* JPEG_SUSPENDED is only possible if you use a data source module that can
|
||||||
@@ -1020,7 +1020,7 @@ EXTERN(int) jpeg_read_header (j_decompress_ptr cinfo, boolean require_image);
|
|||||||
/* Main entry points for decompression */
|
/* Main entry points for decompression */
|
||||||
EXTERN(boolean) jpeg_start_decompress (j_decompress_ptr cinfo);
|
EXTERN(boolean) jpeg_start_decompress (j_decompress_ptr cinfo);
|
||||||
EXTERN(JDIMENSION) jpeg_read_scanlines (j_decompress_ptr cinfo,
|
EXTERN(JDIMENSION) jpeg_read_scanlines (j_decompress_ptr cinfo,
|
||||||
JSAMPARRAY scanlines,
|
JSAMPARRAY scanlines,
|
||||||
JDIMENSION max_lines);
|
JDIMENSION max_lines);
|
||||||
EXTERN(boolean) jpeg_finish_decompress (j_decompress_ptr cinfo);
|
EXTERN(boolean) jpeg_finish_decompress (j_decompress_ptr cinfo);
|
||||||
|
|
||||||
@@ -1036,11 +1036,11 @@ EXTERN(boolean) jpeg_input_complete (j_decompress_ptr cinfo);
|
|||||||
EXTERN(void) jpeg_new_colormap (j_decompress_ptr cinfo);
|
EXTERN(void) jpeg_new_colormap (j_decompress_ptr cinfo);
|
||||||
EXTERN(int) jpeg_consume_input (j_decompress_ptr cinfo);
|
EXTERN(int) jpeg_consume_input (j_decompress_ptr cinfo);
|
||||||
/* Return value is one of: */
|
/* Return value is one of: */
|
||||||
/* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */
|
/* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */
|
||||||
#define JPEG_REACHED_SOS 1 /* Reached start of new scan */
|
#define JPEG_REACHED_SOS 1 /* Reached start of new scan */
|
||||||
#define JPEG_REACHED_EOI 2 /* Reached end of image */
|
#define JPEG_REACHED_EOI 2 /* Reached end of image */
|
||||||
#define JPEG_ROW_COMPLETED 3 /* Completed one iMCU row */
|
#define JPEG_ROW_COMPLETED 3 /* Completed one iMCU row */
|
||||||
#define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */
|
#define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */
|
||||||
|
|
||||||
/* Precalculate output dimensions for current decompression parameters. */
|
/* Precalculate output dimensions for current decompression parameters. */
|
||||||
#if JPEG_LIB_VERSION >= 80
|
#if JPEG_LIB_VERSION >= 80
|
||||||
@@ -1108,10 +1108,10 @@ EXTERN(int) jpeg_c_get_int_param (j_compress_ptr cinfo, J_INT_PARAM param);
|
|||||||
* are likely to want to use them.
|
* are likely to want to use them.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define JPEG_RST0 0xD0 /* RST0 marker code */
|
#define JPEG_RST0 0xD0 /* RST0 marker code */
|
||||||
#define JPEG_EOI 0xD9 /* EOI marker code */
|
#define JPEG_EOI 0xD9 /* EOI marker code */
|
||||||
#define JPEG_APP0 0xE0 /* APP0 marker code */
|
#define JPEG_APP0 0xE0 /* APP0 marker code */
|
||||||
#define JPEG_COM 0xFE /* COM marker code */
|
#define JPEG_COM 0xFE /* COM marker code */
|
||||||
|
|
||||||
|
|
||||||
/* If we have a brain-damaged compiler that emits warnings (or worse, errors)
|
/* If we have a brain-damaged compiler that emits warnings (or worse, errors)
|
||||||
@@ -1120,7 +1120,7 @@ EXTERN(int) jpeg_c_get_int_param (j_compress_ptr cinfo, J_INT_PARAM param);
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef INCOMPLETE_TYPES_BROKEN
|
#ifdef INCOMPLETE_TYPES_BROKEN
|
||||||
#ifndef JPEG_INTERNALS /* will be defined in jpegint.h */
|
#ifndef JPEG_INTERNALS /* will be defined in jpegint.h */
|
||||||
struct jvirt_sarray_control { long dummy; };
|
struct jvirt_sarray_control { long dummy; };
|
||||||
struct jvirt_barray_control { long dummy; };
|
struct jvirt_barray_control { long dummy; };
|
||||||
struct jpeg_comp_master { long dummy; };
|
struct jpeg_comp_master { long dummy; };
|
||||||
@@ -1155,8 +1155,8 @@ struct jpeg_color_quantizer { long dummy; };
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef JPEG_INTERNALS
|
#ifdef JPEG_INTERNALS
|
||||||
#include "jpegint.h" /* fetch private declarations */
|
#include "jpegint.h" /* fetch private declarations */
|
||||||
#include "jerror.h" /* fetch error codes too */
|
#include "jerror.h" /* fetch error codes too */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
8
rdjpeg.c
8
rdjpeg.c
@@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
|
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
|
||||||
|
|
||||||
#if JPEG_RAW_READER
|
#if JPEG_RAW_READER
|
||||||
#define NUM_ROWS 32
|
#define NUM_ROWS 32
|
||||||
@@ -22,7 +22,7 @@ typedef struct _jpeg_source_struct * jpeg_source_ptr;
|
|||||||
typedef struct _jpeg_source_struct {
|
typedef struct _jpeg_source_struct {
|
||||||
struct cjpeg_source_struct pub; /* public fields */
|
struct cjpeg_source_struct pub; /* public fields */
|
||||||
|
|
||||||
j_compress_ptr cinfo; /* back link saves passing separate parm */
|
j_compress_ptr cinfo; /* back link saves passing separate parm */
|
||||||
|
|
||||||
struct jpeg_decompress_struct dinfo;
|
struct jpeg_decompress_struct dinfo;
|
||||||
struct jpeg_error_mgr jerr;
|
struct jpeg_error_mgr jerr;
|
||||||
@@ -150,8 +150,8 @@ jinit_read_jpeg (j_compress_ptr cinfo)
|
|||||||
/* Create module interface object */
|
/* Create module interface object */
|
||||||
source = (jpeg_source_ptr)
|
source = (jpeg_source_ptr)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
sizeof(jpeg_source_struct));
|
sizeof(jpeg_source_struct));
|
||||||
source->cinfo = cinfo; /* make back link for subroutines */
|
source->cinfo = cinfo; /* make back link for subroutines */
|
||||||
/* Fill in method ptrs, except get_pixel_rows which start_input sets */
|
/* Fill in method ptrs, except get_pixel_rows which start_input sets */
|
||||||
source->pub.start_input = start_input_jpeg;
|
source->pub.start_input = start_input_jpeg;
|
||||||
source->pub.finish_input = finish_input_jpeg;
|
source->pub.finish_input = finish_input_jpeg;
|
||||||
|
|||||||
84
rdswitch.c
84
rdswitch.c
@@ -9,15 +9,15 @@
|
|||||||
*
|
*
|
||||||
* This file contains routines to process some of cjpeg's more complicated
|
* This file contains routines to process some of cjpeg's more complicated
|
||||||
* command-line switches. Switches processed here are:
|
* command-line switches. Switches processed here are:
|
||||||
* -qtables file Read quantization tables from text file
|
* -qtables file Read quantization tables from text file
|
||||||
* -scans file Read scan script from text file
|
* -scans file Read scan script from text file
|
||||||
* -quality N[,N,...] Set quality ratings
|
* -quality N[,N,...] Set quality ratings
|
||||||
* -qslots N[,N,...] Set component quantization table selectors
|
* -qslots N[,N,...] Set component quantization table selectors
|
||||||
* -sample HxV[,HxV,...] Set component sampling factors
|
* -sample HxV[,HxV,...] Set component sampling factors
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
|
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
|
||||||
#include <ctype.h> /* to declare isdigit(), isspace() */
|
#include <ctype.h> /* to declare isdigit(), isspace() */
|
||||||
|
|
||||||
|
|
||||||
LOCAL(int)
|
LOCAL(int)
|
||||||
@@ -26,7 +26,7 @@ text_getc (FILE * file)
|
|||||||
/* A comment/newline sequence is returned as a newline */
|
/* A comment/newline sequence is returned as a newline */
|
||||||
{
|
{
|
||||||
register int ch;
|
register int ch;
|
||||||
|
|
||||||
ch = getc(file);
|
ch = getc(file);
|
||||||
if (ch == '#') {
|
if (ch == '#') {
|
||||||
do {
|
do {
|
||||||
@@ -44,7 +44,7 @@ read_text_integer (FILE * file, long * result, int * termchar)
|
|||||||
{
|
{
|
||||||
register int ch;
|
register int ch;
|
||||||
register long val;
|
register long val;
|
||||||
|
|
||||||
/* Skip any leading whitespace, detect EOF */
|
/* Skip any leading whitespace, detect EOF */
|
||||||
do {
|
do {
|
||||||
ch = text_getc(file);
|
ch = text_getc(file);
|
||||||
@@ -53,7 +53,7 @@ read_text_integer (FILE * file, long * result, int * termchar)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
} while (isspace(ch));
|
} while (isspace(ch));
|
||||||
|
|
||||||
if (! isdigit(ch)) {
|
if (! isdigit(ch)) {
|
||||||
*termchar = ch;
|
*termchar = ch;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -108,15 +108,15 @@ read_quant_tables (j_compress_ptr cinfo, char * filename, boolean force_baseline
|
|||||||
table[0] = (unsigned int) val;
|
table[0] = (unsigned int) val;
|
||||||
for (i = 1; i < DCTSIZE2; i++) {
|
for (i = 1; i < DCTSIZE2; i++) {
|
||||||
if (! read_text_integer(fp, &val, &termchar)) {
|
if (! read_text_integer(fp, &val, &termchar)) {
|
||||||
fprintf(stderr, "Invalid table data in file %s\n", filename);
|
fprintf(stderr, "Invalid table data in file %s\n", filename);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
table[i] = (unsigned int) val;
|
table[i] = (unsigned int) val;
|
||||||
}
|
}
|
||||||
#if JPEG_LIB_VERSION >= 70
|
#if JPEG_LIB_VERSION >= 70
|
||||||
jpeg_add_quant_table(cinfo, tblno, table, cinfo->q_scale_factor[tblno],
|
jpeg_add_quant_table(cinfo, tblno, table, cinfo->q_scale_factor[tblno],
|
||||||
force_baseline);
|
force_baseline);
|
||||||
#else
|
#else
|
||||||
jpeg_add_quant_table(cinfo, tblno, table, q_scale_factor[tblno],
|
jpeg_add_quant_table(cinfo, tblno, table, q_scale_factor[tblno],
|
||||||
force_baseline);
|
force_baseline);
|
||||||
@@ -150,7 +150,7 @@ read_scan_integer (FILE * file, long * result, int * termchar)
|
|||||||
ch = *termchar;
|
ch = *termchar;
|
||||||
while (ch != EOF && isspace(ch))
|
while (ch != EOF && isspace(ch))
|
||||||
ch = text_getc(file);
|
ch = text_getc(file);
|
||||||
if (isdigit(ch)) { /* oops, put it back */
|
if (isdigit(ch)) { /* oops, put it back */
|
||||||
if (ungetc(ch, file) == EOF)
|
if (ungetc(ch, file) == EOF)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
ch = ' ';
|
ch = ' ';
|
||||||
@@ -188,7 +188,7 @@ read_scan_script (j_compress_ptr cinfo, char * filename)
|
|||||||
int scanno, ncomps, termchar;
|
int scanno, ncomps, termchar;
|
||||||
long val;
|
long val;
|
||||||
jpeg_scan_info * scanptr;
|
jpeg_scan_info * scanptr;
|
||||||
#define MAX_SCANS 100 /* quite arbitrary limit */
|
#define MAX_SCANS 100 /* quite arbitrary limit */
|
||||||
jpeg_scan_info scans[MAX_SCANS];
|
jpeg_scan_info scans[MAX_SCANS];
|
||||||
|
|
||||||
if ((fp = fopen(filename, "r")) == NULL) {
|
if ((fp = fopen(filename, "r")) == NULL) {
|
||||||
@@ -208,29 +208,29 @@ read_scan_script (j_compress_ptr cinfo, char * filename)
|
|||||||
ncomps = 1;
|
ncomps = 1;
|
||||||
while (termchar == ' ') {
|
while (termchar == ' ') {
|
||||||
if (ncomps >= MAX_COMPS_IN_SCAN) {
|
if (ncomps >= MAX_COMPS_IN_SCAN) {
|
||||||
fprintf(stderr, "Too many components in one scan in file %s\n",
|
fprintf(stderr, "Too many components in one scan in file %s\n",
|
||||||
filename);
|
filename);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (! read_scan_integer(fp, &val, &termchar))
|
if (! read_scan_integer(fp, &val, &termchar))
|
||||||
goto bogus;
|
goto bogus;
|
||||||
scanptr->component_index[ncomps] = (int) val;
|
scanptr->component_index[ncomps] = (int) val;
|
||||||
ncomps++;
|
ncomps++;
|
||||||
}
|
}
|
||||||
scanptr->comps_in_scan = ncomps;
|
scanptr->comps_in_scan = ncomps;
|
||||||
if (termchar == ':') {
|
if (termchar == ':') {
|
||||||
if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ')
|
if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ')
|
||||||
goto bogus;
|
goto bogus;
|
||||||
scanptr->Ss = (int) val;
|
scanptr->Ss = (int) val;
|
||||||
if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ')
|
if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ')
|
||||||
goto bogus;
|
goto bogus;
|
||||||
scanptr->Se = (int) val;
|
scanptr->Se = (int) val;
|
||||||
if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ')
|
if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ')
|
||||||
goto bogus;
|
goto bogus;
|
||||||
scanptr->Ah = (int) val;
|
scanptr->Ah = (int) val;
|
||||||
if (! read_scan_integer(fp, &val, &termchar))
|
if (! read_scan_integer(fp, &val, &termchar))
|
||||||
goto bogus;
|
goto bogus;
|
||||||
scanptr->Al = (int) val;
|
scanptr->Al = (int) val;
|
||||||
} else {
|
} else {
|
||||||
/* set non-progressive parameters */
|
/* set non-progressive parameters */
|
||||||
@@ -337,7 +337,7 @@ set_quality_ratings (j_compress_ptr cinfo, char *arg, boolean force_baseline)
|
|||||||
* If there are more q-table slots than parameters, the last value is replicated.
|
* If there are more q-table slots than parameters, the last value is replicated.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
float val = 75.f; /* default value */
|
float val = 75.f; /* default value */
|
||||||
int tblno;
|
int tblno;
|
||||||
char ch;
|
char ch;
|
||||||
|
|
||||||
@@ -355,7 +355,7 @@ set_quality_ratings (j_compress_ptr cinfo, char *arg, boolean force_baseline)
|
|||||||
q_scale_factor[tblno] = jpeg_float_quality_scaling(val);
|
q_scale_factor[tblno] = jpeg_float_quality_scaling(val);
|
||||||
#endif
|
#endif
|
||||||
while (*arg && *arg++ != ',') /* advance to next segment of arg string */
|
while (*arg && *arg++ != ',') /* advance to next segment of arg string */
|
||||||
;
|
;
|
||||||
} else {
|
} else {
|
||||||
/* reached end of parameter, set remaining factors to last value */
|
/* reached end of parameter, set remaining factors to last value */
|
||||||
#if JPEG_LIB_VERSION >= 70
|
#if JPEG_LIB_VERSION >= 70
|
||||||
@@ -377,25 +377,25 @@ set_quant_slots (j_compress_ptr cinfo, char *arg)
|
|||||||
* If there are more components than parameters, the last value is replicated.
|
* If there are more components than parameters, the last value is replicated.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
int val = 0; /* default table # */
|
int val = 0; /* default table # */
|
||||||
int ci;
|
int ci;
|
||||||
char ch;
|
char ch;
|
||||||
|
|
||||||
for (ci = 0; ci < MAX_COMPONENTS; ci++) {
|
for (ci = 0; ci < MAX_COMPONENTS; ci++) {
|
||||||
if (*arg) {
|
if (*arg) {
|
||||||
ch = ','; /* if not set by sscanf, will be ',' */
|
ch = ','; /* if not set by sscanf, will be ',' */
|
||||||
if (sscanf(arg, "%d%c", &val, &ch) < 1)
|
if (sscanf(arg, "%d%c", &val, &ch) < 1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (ch != ',') /* syntax check */
|
if (ch != ',') /* syntax check */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (val < 0 || val >= NUM_QUANT_TBLS) {
|
if (val < 0 || val >= NUM_QUANT_TBLS) {
|
||||||
fprintf(stderr, "JPEG quantization tables are numbered 0..%d\n",
|
fprintf(stderr, "JPEG quantization tables are numbered 0..%d\n",
|
||||||
NUM_QUANT_TBLS-1);
|
NUM_QUANT_TBLS-1);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
cinfo->comp_info[ci].quant_tbl_no = val;
|
cinfo->comp_info[ci].quant_tbl_no = val;
|
||||||
while (*arg && *arg++ != ',') /* advance to next segment of arg string */
|
while (*arg && *arg++ != ',') /* advance to next segment of arg string */
|
||||||
;
|
;
|
||||||
} else {
|
} else {
|
||||||
/* reached end of parameter, set remaining components to last table */
|
/* reached end of parameter, set remaining components to last table */
|
||||||
cinfo->comp_info[ci].quant_tbl_no = val;
|
cinfo->comp_info[ci].quant_tbl_no = val;
|
||||||
@@ -417,19 +417,19 @@ set_sample_factors (j_compress_ptr cinfo, char *arg)
|
|||||||
|
|
||||||
for (ci = 0; ci < MAX_COMPONENTS; ci++) {
|
for (ci = 0; ci < MAX_COMPONENTS; ci++) {
|
||||||
if (*arg) {
|
if (*arg) {
|
||||||
ch2 = ','; /* if not set by sscanf, will be ',' */
|
ch2 = ','; /* if not set by sscanf, will be ',' */
|
||||||
if (sscanf(arg, "%d%c%d%c", &val1, &ch1, &val2, &ch2) < 3)
|
if (sscanf(arg, "%d%c%d%c", &val1, &ch1, &val2, &ch2) < 3)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if ((ch1 != 'x' && ch1 != 'X') || ch2 != ',') /* syntax check */
|
if ((ch1 != 'x' && ch1 != 'X') || ch2 != ',') /* syntax check */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (val1 <= 0 || val1 > 4 || val2 <= 0 || val2 > 4) {
|
if (val1 <= 0 || val1 > 4 || val2 <= 0 || val2 > 4) {
|
||||||
fprintf(stderr, "JPEG sampling factors must be 1..4\n");
|
fprintf(stderr, "JPEG sampling factors must be 1..4\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
cinfo->comp_info[ci].h_samp_factor = val1;
|
cinfo->comp_info[ci].h_samp_factor = val1;
|
||||||
cinfo->comp_info[ci].v_samp_factor = val2;
|
cinfo->comp_info[ci].v_samp_factor = val2;
|
||||||
while (*arg && *arg++ != ',') /* advance to next segment of arg string */
|
while (*arg && *arg++ != ',') /* advance to next segment of arg string */
|
||||||
;
|
;
|
||||||
} else {
|
} else {
|
||||||
/* reached end of parameter, set remaining components to 1x1 sampling */
|
/* reached end of parameter, set remaining components to 1x1 sampling */
|
||||||
cinfo->comp_info[ci].h_samp_factor = 1;
|
cinfo->comp_info[ci].h_samp_factor = 1;
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ static int setCompDefaults(struct jpeg_compress_struct *cinfo,
|
|||||||
/* Set scan pattern again as colorspace might have changed */
|
/* Set scan pattern again as colorspace might have changed */
|
||||||
if (cinfo->master->use_moz_defaults)
|
if (cinfo->master->use_moz_defaults)
|
||||||
jpeg_simple_progression(cinfo);
|
jpeg_simple_progression(cinfo);
|
||||||
|
|
||||||
cinfo->comp_info[0].h_samp_factor=tjMCUWidth[subsamp]/8;
|
cinfo->comp_info[0].h_samp_factor=tjMCUWidth[subsamp]/8;
|
||||||
cinfo->comp_info[1].h_samp_factor=1;
|
cinfo->comp_info[1].h_samp_factor=1;
|
||||||
cinfo->comp_info[2].h_samp_factor=1;
|
cinfo->comp_info[2].h_samp_factor=1;
|
||||||
|
|||||||
Reference in New Issue
Block a user