libjpeg-turbo has never supported non-ANSI compilers, so get rid of the crufty SIZEOF() macro. It was not being used consistently anyhow, so it would not have been possible to build prior releases of libjpeg-turbo using the broken compilers for which that macro was designed.

git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@1313 632fc199-4ca6-4c93-a231-07263d6284db
This commit is contained in:
DRC
2014-05-18 19:04:03 +00:00
parent 5ad13790c2
commit 66245aa735
52 changed files with 216 additions and 217 deletions

View File

@@ -45,11 +45,6 @@ keywords can be inserted for use in Windows DLLs.)
A similar solution is used for external function declarations (see the EXTERN A similar solution is used for external function declarations (see the EXTERN
macro.) macro.)
It seems there are some non-ANSI compilers in which the sizeof() operator
is defined to return int, yet size_t is defined as long. Needless to say,
this is brain-damaged. Always use the SIZEOF() macro in place of sizeof(),
so that the result is guaranteed to be of type size_t.
The JPEG library is intended to be used within larger programs. Furthermore, The JPEG library is intended to be used within larger programs. Furthermore,
we want it to be reentrant so that it can be used by applications that process we want it to be reentrant so that it can be used by applications that process

View File

@@ -38,9 +38,9 @@ jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize)
cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */ cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */
if (version != JPEG_LIB_VERSION) if (version != JPEG_LIB_VERSION)
ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version); ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version);
if (structsize != SIZEOF(struct jpeg_compress_struct)) if (structsize != sizeof(struct jpeg_compress_struct))
ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE,
(int) SIZEOF(struct jpeg_compress_struct), (int) structsize); (int) sizeof(struct jpeg_compress_struct), (int) structsize);
/* For debugging purposes, we zero the whole master structure. /* For debugging purposes, we zero the whole master structure.
* But the application has already set the err pointer, and may have set * But the application has already set the err pointer, and may have set
@@ -51,7 +51,7 @@ jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize)
{ {
struct jpeg_error_mgr * err = cinfo->err; struct jpeg_error_mgr * err = cinfo->err;
void * client_data = cinfo->client_data; /* ignore Purify complaint here */ void * client_data = cinfo->client_data; /* ignore Purify complaint here */
MEMZERO(cinfo, SIZEOF(struct jpeg_compress_struct)); MEMZERO(cinfo, sizeof(struct jpeg_compress_struct));
cinfo->err = err; cinfo->err = err;
cinfo->client_data = client_data; cinfo->client_data = client_data;
} }

View File

@@ -1,8 +1,10 @@
/* /*
* jcarith.c * jcarith.c
* *
* This file was part of the Independent JPEG Group's software:
* Developed 1997-2009 by Guido Vollbeding. * Developed 1997-2009 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * It was modified by The libjpeg-turbo Project to include only code relevant
* to libjpeg-turbo.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
* This file contains portable arithmetic entropy encoding routines for JPEG * This file contains portable arithmetic entropy encoding routines for JPEG
@@ -909,7 +911,7 @@ jinit_arith_encoder (j_compress_ptr cinfo)
entropy = (arith_entropy_ptr) entropy = (arith_entropy_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(arith_entropy_encoder)); sizeof(arith_entropy_encoder));
cinfo->entropy = (struct jpeg_entropy_encoder *) entropy; cinfo->entropy = (struct jpeg_entropy_encoder *) entropy;
entropy->pub.start_pass = start_pass; entropy->pub.start_pass = start_pass;
entropy->pub.finish_pass = finish_pass; entropy->pub.finish_pass = finish_pass;

View File

@@ -180,7 +180,7 @@ compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
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],
(compptr->MCU_width - blockcnt) * SIZEOF(JBLOCK)); (compptr->MCU_width - blockcnt) * sizeof(JBLOCK));
for (bi = blockcnt; bi < compptr->MCU_width; bi++) { for (bi = blockcnt; bi < compptr->MCU_width; bi++) {
coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn+bi-1][0][0]; coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn+bi-1][0][0];
} }
@@ -188,7 +188,7 @@ compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
} else { } else {
/* Create a row of dummy blocks at the bottom of the image. */ /* Create a row of dummy blocks at the bottom of the image. */
jzero_far((void *) coef->MCU_buffer[blkn], jzero_far((void *) coef->MCU_buffer[blkn],
compptr->MCU_width * SIZEOF(JBLOCK)); compptr->MCU_width * sizeof(JBLOCK));
for (bi = 0; bi < compptr->MCU_width; bi++) { for (bi = 0; bi < compptr->MCU_width; bi++) {
coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn-1][0][0]; coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn-1][0][0];
} }
@@ -285,7 +285,7 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
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;
@@ -305,7 +305,7 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
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++) {
@@ -407,7 +407,7 @@ jinit_c_coef_controller (j_compress_ptr cinfo, boolean need_full_buffer)
coef = (my_coef_ptr) coef = (my_coef_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_coef_controller)); sizeof(my_coef_controller));
cinfo->coef = (struct jpeg_c_coef_controller *) coef; cinfo->coef = (struct jpeg_c_coef_controller *) coef;
coef->pub.start_pass = start_pass_coef; coef->pub.start_pass = start_pass_coef;
@@ -439,7 +439,7 @@ jinit_c_coef_controller (j_compress_ptr cinfo, boolean need_full_buffer)
buffer = (JBLOCKROW) buffer = (JBLOCKROW)
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); C_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) { for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {
coef->MCU_buffer[i] = buffer + i; coef->MCU_buffer[i] = buffer + i;
} }

View File

@@ -202,7 +202,7 @@ rgb_ycc_start (j_compress_ptr cinfo)
/* Allocate and fill in the conversion tables. */ /* Allocate and fill in the conversion tables. */
cconvert->rgb_ycc_tab = rgb_ycc_tab = (INT32 *) cconvert->rgb_ycc_tab = rgb_ycc_tab = (INT32 *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(TABLE_SIZE * SIZEOF(INT32))); (TABLE_SIZE * sizeof(INT32)));
for (i = 0; i <= MAXJSAMPLE; i++) { for (i = 0; i <= MAXJSAMPLE; i++) {
rgb_ycc_tab[i+R_Y_OFF] = FIX(0.29900) * i; rgb_ycc_tab[i+R_Y_OFF] = FIX(0.29900) * i;
@@ -507,7 +507,7 @@ jinit_color_converter (j_compress_ptr cinfo)
cconvert = (my_cconvert_ptr) cconvert = (my_cconvert_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_color_converter)); sizeof(my_color_converter));
cinfo->cconvert = (struct jpeg_color_converter *) cconvert; cinfo->cconvert = (struct jpeg_color_converter *) cconvert;
/* set start_pass to null method until we find out differently */ /* set start_pass to null method until we find out differently */
cconvert->pub.start_pass = null_method; cconvert->pub.start_pass = null_method;

View File

@@ -234,7 +234,7 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
if (fdct->divisors[qtblno] == NULL) { if (fdct->divisors[qtblno] == NULL) {
fdct->divisors[qtblno] = (DCTELEM *) fdct->divisors[qtblno] = (DCTELEM *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(DCTSIZE2 * 4) * SIZEOF(DCTELEM)); (DCTSIZE2 * 4) * sizeof(DCTELEM));
} }
dtbl = fdct->divisors[qtblno]; dtbl = fdct->divisors[qtblno];
for (i = 0; i < DCTSIZE2; i++) { for (i = 0; i < DCTSIZE2; i++) {
@@ -270,7 +270,7 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
if (fdct->divisors[qtblno] == NULL) { if (fdct->divisors[qtblno] == NULL) {
fdct->divisors[qtblno] = (DCTELEM *) fdct->divisors[qtblno] = (DCTELEM *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(DCTSIZE2 * 4) * SIZEOF(DCTELEM)); (DCTSIZE2 * 4) * sizeof(DCTELEM));
} }
dtbl = fdct->divisors[qtblno]; dtbl = fdct->divisors[qtblno];
for (i = 0; i < DCTSIZE2; i++) { for (i = 0; i < DCTSIZE2; i++) {
@@ -305,7 +305,7 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
if (fdct->float_divisors[qtblno] == NULL) { if (fdct->float_divisors[qtblno] == NULL) {
fdct->float_divisors[qtblno] = (FAST_FLOAT *) fdct->float_divisors[qtblno] = (FAST_FLOAT *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
DCTSIZE2 * SIZEOF(FAST_FLOAT)); DCTSIZE2 * sizeof(FAST_FLOAT));
} }
fdtbl = fdct->float_divisors[qtblno]; fdtbl = fdct->float_divisors[qtblno];
i = 0; i = 0;
@@ -546,7 +546,7 @@ jinit_forward_dct (j_compress_ptr cinfo)
fdct = (my_fdct_ptr) fdct = (my_fdct_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_fdct_controller)); sizeof(my_fdct_controller));
cinfo->fdct = (struct jpeg_forward_dct *) fdct; cinfo->fdct = (struct jpeg_forward_dct *) fdct;
fdct->pub.start_pass = start_pass_fdctmgr; fdct->pub.start_pass = start_pass_fdctmgr;
@@ -625,12 +625,12 @@ jinit_forward_dct (j_compress_ptr cinfo)
if (cinfo->dct_method == JDCT_FLOAT) if (cinfo->dct_method == JDCT_FLOAT)
fdct->float_workspace = (FAST_FLOAT *) fdct->float_workspace = (FAST_FLOAT *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(FAST_FLOAT) * DCTSIZE2); sizeof(FAST_FLOAT) * DCTSIZE2);
else else
#endif #endif
fdct->workspace = (DCTELEM *) fdct->workspace = (DCTELEM *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(DCTELEM) * DCTSIZE2); sizeof(DCTELEM) * DCTSIZE2);
/* Mark divisor tables unallocated */ /* Mark divisor tables unallocated */
for (i = 0; i < NUM_QUANT_TBLS; i++) { for (i = 0; i < NUM_QUANT_TBLS; i++) {

View File

@@ -174,13 +174,13 @@ start_pass_huff (j_compress_ptr cinfo, boolean gather_statistics)
if (entropy->dc_count_ptrs[dctbl] == NULL) if (entropy->dc_count_ptrs[dctbl] == NULL)
entropy->dc_count_ptrs[dctbl] = (long *) entropy->dc_count_ptrs[dctbl] = (long *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
257 * SIZEOF(long)); 257 * sizeof(long));
MEMZERO(entropy->dc_count_ptrs[dctbl], 257 * SIZEOF(long)); MEMZERO(entropy->dc_count_ptrs[dctbl], 257 * sizeof(long));
if (entropy->ac_count_ptrs[actbl] == NULL) if (entropy->ac_count_ptrs[actbl] == NULL)
entropy->ac_count_ptrs[actbl] = (long *) entropy->ac_count_ptrs[actbl] = (long *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
257 * SIZEOF(long)); 257 * sizeof(long));
MEMZERO(entropy->ac_count_ptrs[actbl], 257 * SIZEOF(long)); MEMZERO(entropy->ac_count_ptrs[actbl], 257 * sizeof(long));
#endif #endif
} else { } else {
/* Compute derived values for Huffman tables */ /* Compute derived values for Huffman tables */
@@ -238,7 +238,7 @@ jpeg_make_c_derived_tbl (j_compress_ptr cinfo, boolean isDC, int tblno,
if (*pdtbl == NULL) if (*pdtbl == NULL)
*pdtbl = (c_derived_tbl *) *pdtbl = (c_derived_tbl *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(c_derived_tbl)); sizeof(c_derived_tbl));
dtbl = *pdtbl; dtbl = *pdtbl;
/* Figure C.1: make table of Huffman code length for each symbol */ /* Figure C.1: make table of Huffman code length for each symbol */
@@ -281,7 +281,7 @@ jpeg_make_c_derived_tbl (j_compress_ptr cinfo, boolean isDC, int tblno,
* this lets us detect duplicate VAL entries here, and later * this lets us detect duplicate VAL entries here, and later
* allows emit_bits to detect any attempt to emit such symbols. * allows emit_bits to detect any attempt to emit such symbols.
*/ */
MEMZERO(dtbl->ehufsi, SIZEOF(dtbl->ehufsi)); MEMZERO(dtbl->ehufsi, sizeof(dtbl->ehufsi));
/* This is also a convenient place to check for out-of-range /* This is also a convenient place to check for out-of-range
* and duplicated VAL entries. We allow 0..255 for AC symbols * and duplicated VAL entries. We allow 0..255 for AC symbols
@@ -847,8 +847,8 @@ jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])
/* This algorithm is explained in section K.2 of the JPEG standard */ /* This algorithm is explained in section K.2 of the JPEG standard */
MEMZERO(bits, SIZEOF(bits)); MEMZERO(bits, sizeof(bits));
MEMZERO(codesize, SIZEOF(codesize)); MEMZERO(codesize, sizeof(codesize));
for (i = 0; i < 257; i++) for (i = 0; i < 257; i++)
others[i] = -1; /* init links to empty */ others[i] = -1; /* init links to empty */
@@ -950,7 +950,7 @@ jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])
bits[i]--; bits[i]--;
/* Return final symbol counts (only for lengths 0..16) */ /* Return final symbol counts (only for lengths 0..16) */
MEMCOPY(htbl->bits, bits, SIZEOF(htbl->bits)); MEMCOPY(htbl->bits, bits, sizeof(htbl->bits));
/* Return a list of the symbols sorted by code length */ /* Return a list of the symbols sorted by code length */
/* It's not real clear to me why we don't need to consider the codelength /* It's not real clear to me why we don't need to consider the codelength
@@ -988,8 +988,8 @@ finish_pass_gather (j_compress_ptr cinfo)
/* It's important not to apply jpeg_gen_optimal_table more than once /* It's important not to apply jpeg_gen_optimal_table more than once
* per table, because it clobbers the input frequency counts! * per table, because it clobbers the input frequency counts!
*/ */
MEMZERO(did_dc, SIZEOF(did_dc)); MEMZERO(did_dc, sizeof(did_dc));
MEMZERO(did_ac, SIZEOF(did_ac)); MEMZERO(did_ac, sizeof(did_ac));
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];
@@ -1028,7 +1028,7 @@ jinit_huff_encoder (j_compress_ptr cinfo)
entropy = (huff_entropy_ptr) entropy = (huff_entropy_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(huff_entropy_encoder)); sizeof(huff_entropy_encoder));
cinfo->entropy = (struct jpeg_entropy_encoder *) entropy; cinfo->entropy = (struct jpeg_entropy_encoder *) entropy;
entropy->pub.start_pass = start_pass_huff; entropy->pub.start_pass = start_pass_huff;

View File

@@ -252,7 +252,7 @@ jinit_c_main_controller (j_compress_ptr cinfo, boolean need_full_buffer)
main_ptr = (my_main_ptr) main_ptr = (my_main_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_main_controller)); sizeof(my_main_controller));
cinfo->main = (struct jpeg_c_main_controller *) main_ptr; cinfo->main = (struct jpeg_c_main_controller *) main_ptr;
main_ptr->pub.start_pass = start_pass_main; main_ptr->pub.start_pass = start_pass_main;

View File

@@ -649,7 +649,7 @@ jinit_marker_writer (j_compress_ptr cinfo)
/* Create the subobject */ /* Create the subobject */
marker = (my_marker_ptr) marker = (my_marker_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_marker_writer)); sizeof(my_marker_writer));
cinfo->marker = (struct jpeg_marker_writer *) marker; cinfo->marker = (struct jpeg_marker_writer *) marker;
/* Initialize method pointers */ /* Initialize method pointers */
marker->pub.write_file_header = write_file_header; marker->pub.write_file_header = write_file_header;

View File

@@ -581,7 +581,7 @@ jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only)
master = (my_master_ptr) master = (my_master_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_comp_master)); sizeof(my_comp_master));
cinfo->master = (struct jpeg_comp_master *) master; cinfo->master = (struct jpeg_comp_master *) master;
master->pub.prepare_for_pass = prepare_for_pass; master->pub.prepare_for_pass = prepare_for_pass;
master->pub.pass_startup = pass_startup; master->pub.pass_startup = pass_startup;

View File

@@ -1,8 +1,10 @@
/* /*
* jcomapi.c * jcomapi.c
* *
* Copyright (C) 1994-1997, Thomas G. Lane. * This file was part of the Independent JPEG Group's software:
* This file is part of the Independent JPEG Group's software. * Copyright (C) 1994-1997, Thomas G. Lane.0
* It was modified by The libjpeg-turbo Project to include only code relevant
* to libjpeg-turbo.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
* This file contains application interface routines that are used for both * This file contains application interface routines that are used for both
@@ -88,7 +90,7 @@ jpeg_alloc_quant_table (j_common_ptr cinfo)
JQUANT_TBL *tbl; JQUANT_TBL *tbl;
tbl = (JQUANT_TBL *) tbl = (JQUANT_TBL *)
(*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JQUANT_TBL)); (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, sizeof(JQUANT_TBL));
tbl->sent_table = FALSE; /* make sure this is false in any new table */ tbl->sent_table = FALSE; /* make sure this is false in any new table */
return tbl; return tbl;
} }
@@ -100,7 +102,7 @@ jpeg_alloc_huff_table (j_common_ptr cinfo)
JHUFF_TBL *tbl; JHUFF_TBL *tbl;
tbl = (JHUFF_TBL *) tbl = (JHUFF_TBL *)
(*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JHUFF_TBL)); (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, sizeof(JHUFF_TBL));
tbl->sent_table = FALSE; /* make sure this is false in any new table */ tbl->sent_table = FALSE; /* make sure this is false in any new table */
return tbl; return tbl;
} }

View File

@@ -192,7 +192,7 @@ jpeg_set_defaults (j_compress_ptr cinfo)
if (cinfo->comp_info == NULL) if (cinfo->comp_info == NULL)
cinfo->comp_info = (jpeg_component_info *) cinfo->comp_info = (jpeg_component_info *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
MAX_COMPONENTS * SIZEOF(jpeg_component_info)); MAX_COMPONENTS * sizeof(jpeg_component_info));
/* Initialize everything not dependent on the color space */ /* Initialize everything not dependent on the color space */
@@ -498,7 +498,7 @@ jpeg_simple_progression (j_compress_ptr cinfo)
cinfo->script_space_size = MAX(nscans, 10); cinfo->script_space_size = MAX(nscans, 10);
cinfo->script_space = (jpeg_scan_info *) cinfo->script_space = (jpeg_scan_info *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
cinfo->script_space_size * SIZEOF(jpeg_scan_info)); cinfo->script_space_size * sizeof(jpeg_scan_info));
} }
scanptr = cinfo->script_space; scanptr = cinfo->script_space;
cinfo->scan_info = scanptr; cinfo->scan_info = scanptr;

View File

@@ -134,7 +134,7 @@ start_pass_phuff (j_compress_ptr cinfo, boolean gather_statistics)
if (entropy->bit_buffer == NULL) if (entropy->bit_buffer == NULL)
entropy->bit_buffer = (char *) entropy->bit_buffer = (char *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
MAX_CORR_BITS * SIZEOF(char)); MAX_CORR_BITS * sizeof(char));
} }
} }
if (gather_statistics) if (gather_statistics)
@@ -167,8 +167,8 @@ start_pass_phuff (j_compress_ptr cinfo, boolean gather_statistics)
if (entropy->count_ptrs[tbl] == NULL) if (entropy->count_ptrs[tbl] == NULL)
entropy->count_ptrs[tbl] = (long *) entropy->count_ptrs[tbl] = (long *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
257 * SIZEOF(long)); 257 * sizeof(long));
MEMZERO(entropy->count_ptrs[tbl], 257 * SIZEOF(long)); MEMZERO(entropy->count_ptrs[tbl], 257 * sizeof(long));
} else { } else {
/* Compute derived values for Huffman table */ /* Compute derived values for Huffman table */
/* We may do this more than once for a table, but it's not expensive */ /* We may do this more than once for a table, but it's not expensive */
@@ -781,7 +781,7 @@ finish_pass_gather_phuff (j_compress_ptr cinfo)
/* It's important not to apply jpeg_gen_optimal_table more than once /* It's important not to apply jpeg_gen_optimal_table more than once
* per table, because it clobbers the input frequency counts! * per table, because it clobbers the input frequency counts!
*/ */
MEMZERO(did, SIZEOF(did)); MEMZERO(did, sizeof(did));
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];
@@ -818,7 +818,7 @@ jinit_phuff_encoder (j_compress_ptr cinfo)
entropy = (phuff_entropy_ptr) entropy = (phuff_entropy_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(phuff_entropy_encoder)); sizeof(phuff_entropy_encoder));
cinfo->entropy = (struct jpeg_entropy_encoder *) entropy; cinfo->entropy = (struct jpeg_entropy_encoder *) entropy;
entropy->pub.start_pass = start_pass_phuff; entropy->pub.start_pass = start_pass_phuff;

View File

@@ -1,8 +1,10 @@
/* /*
* jcprepct.c * jcprepct.c
* *
* This file is part of the Independent JPEG Group's software:
* Copyright (C) 1994-1996, Thomas G. Lane. * Copyright (C) 1994-1996, Thomas G. Lane.
* This file is part of the Independent JPEG Group's software. * It was modified by The libjpeg-turbo Project to include only code relevant
* to libjpeg-turbo.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
* This file contains the compression preprocessing controller. * This file contains the compression preprocessing controller.
@@ -278,7 +280,7 @@ create_context_buffer (j_compress_ptr cinfo)
fake_buffer = (JSAMPARRAY) fake_buffer = (JSAMPARRAY)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(cinfo->num_components * 5 * rgroup_height) * (cinfo->num_components * 5 * rgroup_height) *
SIZEOF(JSAMPROW)); sizeof(JSAMPROW));
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++) {
@@ -293,7 +295,7 @@ create_context_buffer (j_compress_ptr cinfo)
(JDIMENSION) (3 * rgroup_height)); (JDIMENSION) (3 * rgroup_height));
/* Copy true buffer row pointers into the middle of the fake row array */ /* Copy true buffer row pointers into the middle of the fake row array */
MEMCOPY(fake_buffer + rgroup_height, true_buffer, MEMCOPY(fake_buffer + rgroup_height, true_buffer,
3 * rgroup_height * SIZEOF(JSAMPROW)); 3 * rgroup_height * sizeof(JSAMPROW));
/* Fill in the above and below wraparound pointers */ /* Fill in the above and below wraparound pointers */
for (i = 0; i < rgroup_height; i++) { for (i = 0; i < rgroup_height; i++) {
fake_buffer[i] = true_buffer[2 * rgroup_height + i]; fake_buffer[i] = true_buffer[2 * rgroup_height + i];
@@ -323,7 +325,7 @@ jinit_c_prep_controller (j_compress_ptr cinfo, boolean need_full_buffer)
prep = (my_prep_ptr) prep = (my_prep_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_prep_controller)); sizeof(my_prep_controller));
cinfo->prep = (struct jpeg_c_prep_controller *) prep; cinfo->prep = (struct jpeg_c_prep_controller *) prep;
prep->pub.start_pass = start_pass_prep; prep->pub.start_pass = start_pass_prep;

View File

@@ -474,7 +474,7 @@ jinit_downsampler (j_compress_ptr cinfo)
downsample = (my_downsample_ptr) downsample = (my_downsample_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_downsampler)); sizeof(my_downsampler));
cinfo->downsample = (struct jpeg_downsampler *) downsample; cinfo->downsample = (struct jpeg_downsampler *) downsample;
downsample->pub.start_pass = start_pass_downsample; downsample->pub.start_pass = start_pass_downsample;
downsample->pub.downsample = sep_downsample; downsample->pub.downsample = sep_downsample;

View File

@@ -101,7 +101,7 @@ jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
*qtblptr = jpeg_alloc_quant_table((j_common_ptr) dstinfo); *qtblptr = jpeg_alloc_quant_table((j_common_ptr) dstinfo);
MEMCOPY((*qtblptr)->quantval, MEMCOPY((*qtblptr)->quantval,
srcinfo->quant_tbl_ptrs[tblno]->quantval, srcinfo->quant_tbl_ptrs[tblno]->quantval,
SIZEOF((*qtblptr)->quantval)); sizeof((*qtblptr)->quantval));
(*qtblptr)->sent_table = FALSE; (*qtblptr)->sent_table = FALSE;
} }
} }
@@ -382,7 +382,7 @@ transencode_coef_controller (j_compress_ptr cinfo,
coef = (my_coef_ptr) coef = (my_coef_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_coef_controller)); sizeof(my_coef_controller));
cinfo->coef = (struct jpeg_c_coef_controller *) coef; cinfo->coef = (struct jpeg_c_coef_controller *) coef;
coef->pub.start_pass = start_pass_coef; coef->pub.start_pass = start_pass_coef;
coef->pub.compress_data = compress_output; coef->pub.compress_data = compress_output;
@@ -393,8 +393,8 @@ transencode_coef_controller (j_compress_ptr cinfo,
/* Allocate and pre-zero space for dummy DCT blocks. */ /* Allocate and pre-zero space for dummy DCT blocks. */
buffer = (JBLOCKROW) buffer = (JBLOCKROW)
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); C_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
jzero_far((void *) buffer, C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); jzero_far((void *) buffer, C_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) { for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {
coef->dummy_buffer[i] = buffer + i; coef->dummy_buffer[i] = buffer + i;
} }

View File

@@ -1,8 +1,10 @@
/* /*
* jdapimin.c * jdapimin.c
* *
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1998, Thomas G. Lane. * Copyright (C) 1994-1998, Thomas G. Lane.
* This file is part of the Independent JPEG Group's software. * It was modified by The libjpeg-turbo Project to include only code relevant
* to libjpeg-turbo.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
* This file contains application interface code for the decompression half * This file contains application interface code for the decompression half
@@ -35,9 +37,9 @@ jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize)
cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */ cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */
if (version != JPEG_LIB_VERSION) if (version != JPEG_LIB_VERSION)
ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version); ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version);
if (structsize != SIZEOF(struct jpeg_decompress_struct)) if (structsize != sizeof(struct jpeg_decompress_struct))
ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE,
(int) SIZEOF(struct jpeg_decompress_struct), (int) structsize); (int) sizeof(struct jpeg_decompress_struct), (int) structsize);
/* For debugging purposes, we zero the whole master structure. /* For debugging purposes, we zero the whole master structure.
* But the application has already set the err pointer, and may have set * But the application has already set the err pointer, and may have set
@@ -48,7 +50,7 @@ jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize)
{ {
struct jpeg_error_mgr * err = cinfo->err; struct jpeg_error_mgr * err = cinfo->err;
void * client_data = cinfo->client_data; /* ignore Purify complaint here */ void * client_data = cinfo->client_data; /* ignore Purify complaint here */
MEMZERO(cinfo, SIZEOF(struct jpeg_decompress_struct)); MEMZERO(cinfo, sizeof(struct jpeg_decompress_struct));
cinfo->err = err; cinfo->err = err;
cinfo->client_data = client_data; cinfo->client_data = client_data;
} }

View File

@@ -1,8 +1,10 @@
/* /*
* jdarith.c * jdarith.c
* *
* This file was part of the Independent JPEG Group's software:
* Developed 1997-2009 by Guido Vollbeding. * Developed 1997-2009 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * It was modified by The libjpeg-turbo Project to include only code relevant
* to libjpeg-turbo.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
* This file contains portable arithmetic entropy decoding routines for JPEG * This file contains portable arithmetic entropy decoding routines for JPEG
@@ -734,7 +736,7 @@ jinit_arith_decoder (j_decompress_ptr cinfo)
entropy = (arith_entropy_ptr) entropy = (arith_entropy_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(arith_entropy_decoder)); sizeof(arith_entropy_decoder));
cinfo->entropy = (struct jpeg_entropy_decoder *) entropy; cinfo->entropy = (struct jpeg_entropy_decoder *) entropy;
entropy->pub.start_pass = start_pass; entropy->pub.start_pass = start_pass;
@@ -752,7 +754,7 @@ jinit_arith_decoder (j_decompress_ptr cinfo)
int *coef_bit_ptr, ci; int *coef_bit_ptr, ci;
cinfo->coef_bits = (int (*)[DCTSIZE2]) cinfo->coef_bits = (int (*)[DCTSIZE2])
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
cinfo->num_components*DCTSIZE2*SIZEOF(int)); cinfo->num_components*DCTSIZE2*sizeof(int));
coef_bit_ptr = & cinfo->coef_bits[0][0]; coef_bit_ptr = & cinfo->coef_bits[0][0];
for (ci = 0; ci < cinfo->num_components; ci++) for (ci = 0; ci < cinfo->num_components; ci++)
for (i = 0; i < DCTSIZE2; i++) for (i = 0; i < DCTSIZE2; i++)

View File

@@ -161,7 +161,7 @@ jpeg_mem_dest_tj (j_compress_ptr cinfo,
if (cinfo->dest == NULL) { /* first time for this JPEG object? */ if (cinfo->dest == NULL) { /* first time for this JPEG object? */
cinfo->dest = (struct jpeg_destination_mgr *) cinfo->dest = (struct jpeg_destination_mgr *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
SIZEOF(my_mem_destination_mgr)); sizeof(my_mem_destination_mgr));
dest = (my_mem_dest_ptr) cinfo->dest; dest = (my_mem_dest_ptr) cinfo->dest;
dest->newbuffer = NULL; dest->newbuffer = NULL;
} }

View File

@@ -72,7 +72,7 @@ init_destination (j_compress_ptr cinfo)
/* Allocate the output buffer --- it will be released when done with image */ /* Allocate the output buffer --- it will be released when done with image */
dest->buffer = (JOCTET *) dest->buffer = (JOCTET *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
OUTPUT_BUF_SIZE * SIZEOF(JOCTET)); OUTPUT_BUF_SIZE * sizeof(JOCTET));
dest->pub.next_output_byte = dest->buffer; dest->pub.next_output_byte = dest->buffer;
dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
@@ -216,7 +216,7 @@ jpeg_stdio_dest (j_compress_ptr cinfo, FILE * outfile)
if (cinfo->dest == NULL) { /* first time for this JPEG object? */ if (cinfo->dest == NULL) { /* first time for this JPEG object? */
cinfo->dest = (struct jpeg_destination_mgr *) cinfo->dest = (struct jpeg_destination_mgr *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
SIZEOF(my_destination_mgr)); sizeof(my_destination_mgr));
} }
dest = (my_dest_ptr) cinfo->dest; dest = (my_dest_ptr) cinfo->dest;
@@ -254,7 +254,7 @@ jpeg_mem_dest (j_compress_ptr cinfo,
if (cinfo->dest == NULL) { /* first time for this JPEG object? */ if (cinfo->dest == NULL) { /* first time for this JPEG object? */
cinfo->dest = (struct jpeg_destination_mgr *) cinfo->dest = (struct jpeg_destination_mgr *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
SIZEOF(my_mem_destination_mgr)); sizeof(my_mem_destination_mgr));
} }
dest = (my_mem_dest_ptr) cinfo->dest; dest = (my_mem_dest_ptr) cinfo->dest;

View File

@@ -171,7 +171,7 @@ jpeg_mem_src_tj (j_decompress_ptr cinfo,
if (cinfo->src == NULL) { /* first time for this JPEG object? */ if (cinfo->src == NULL) { /* first time for this JPEG object? */
cinfo->src = (struct jpeg_source_mgr *) cinfo->src = (struct jpeg_source_mgr *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
SIZEOF(struct jpeg_source_mgr)); sizeof(struct jpeg_source_mgr));
} }
src = cinfo->src; src = cinfo->src;

View File

@@ -227,11 +227,11 @@ jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile)
if (cinfo->src == NULL) { /* first time for this JPEG object? */ if (cinfo->src == NULL) { /* first time for this JPEG object? */
cinfo->src = (struct jpeg_source_mgr *) cinfo->src = (struct jpeg_source_mgr *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
SIZEOF(my_source_mgr)); sizeof(my_source_mgr));
src = (my_src_ptr) cinfo->src; src = (my_src_ptr) cinfo->src;
src->buffer = (JOCTET *) src->buffer = (JOCTET *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
INPUT_BUF_SIZE * SIZEOF(JOCTET)); INPUT_BUF_SIZE * sizeof(JOCTET));
} }
src = (my_src_ptr) cinfo->src; src = (my_src_ptr) cinfo->src;
@@ -268,7 +268,7 @@ jpeg_mem_src (j_decompress_ptr cinfo,
if (cinfo->src == NULL) { /* first time for this JPEG object? */ if (cinfo->src == NULL) { /* first time for this JPEG object? */
cinfo->src = (struct jpeg_source_mgr *) cinfo->src = (struct jpeg_source_mgr *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
SIZEOF(struct jpeg_source_mgr)); sizeof(struct jpeg_source_mgr));
} }
src = cinfo->src; src = cinfo->src;

View File

@@ -166,7 +166,7 @@ decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
MCU_col_num++) { MCU_col_num++) {
/* Try to fetch an MCU. Entropy decoder expects buffer to be zeroed. */ /* Try to fetch an MCU. Entropy decoder expects buffer to be zeroed. */
jzero_far((void *) coef->MCU_buffer[0], jzero_far((void *) coef->MCU_buffer[0],
(size_t) (cinfo->blocks_in_MCU * SIZEOF(JBLOCK))); (size_t) (cinfo->blocks_in_MCU * sizeof(JBLOCK)));
if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) { if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
/* Suspension forced; update state counters and exit */ /* Suspension forced; update state counters and exit */
coef->MCU_vert_offset = yoffset; coef->MCU_vert_offset = yoffset;
@@ -423,7 +423,7 @@ smoothing_ok (j_decompress_ptr cinfo)
coef->coef_bits_latch = (int *) coef->coef_bits_latch = (int *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
cinfo->num_components * cinfo->num_components *
(SAVED_COEFS * SIZEOF(int))); (SAVED_COEFS * sizeof(int)));
coef_bits_latch = coef->coef_bits_latch; coef_bits_latch = coef->coef_bits_latch;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
@@ -685,7 +685,7 @@ jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
coef = (my_coef_ptr) coef = (my_coef_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_coef_controller)); sizeof(my_coef_controller));
cinfo->coef = (struct jpeg_d_coef_controller *) coef; cinfo->coef = (struct jpeg_d_coef_controller *) coef;
coef->pub.start_input_pass = start_input_pass; coef->pub.start_input_pass = start_input_pass;
coef->pub.start_output_pass = start_output_pass; coef->pub.start_output_pass = start_output_pass;
@@ -731,7 +731,7 @@ jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
buffer = (JBLOCKROW) buffer = (JBLOCKROW)
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
D_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); D_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) { for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) {
coef->MCU_buffer[i] = buffer + i; coef->MCU_buffer[i] = buffer + i;
} }
@@ -743,5 +743,5 @@ jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
/* Allocate the workspace buffer */ /* Allocate the workspace buffer */
coef->workspace = (JCOEF *) coef->workspace = (JCOEF *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(JCOEF) * DCTSIZE2); sizeof(JCOEF) * DCTSIZE2);
} }

View File

@@ -216,16 +216,16 @@ build_ycc_rgb_table (j_decompress_ptr cinfo)
cconvert->Cr_r_tab = (int *) cconvert->Cr_r_tab = (int *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(MAXJSAMPLE+1) * SIZEOF(int)); (MAXJSAMPLE+1) * sizeof(int));
cconvert->Cb_b_tab = (int *) cconvert->Cb_b_tab = (int *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(MAXJSAMPLE+1) * SIZEOF(int)); (MAXJSAMPLE+1) * sizeof(int));
cconvert->Cr_g_tab = (INT32 *) cconvert->Cr_g_tab = (INT32 *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(MAXJSAMPLE+1) * SIZEOF(INT32)); (MAXJSAMPLE+1) * sizeof(INT32));
cconvert->Cb_g_tab = (INT32 *) cconvert->Cb_g_tab = (INT32 *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(MAXJSAMPLE+1) * SIZEOF(INT32)); (MAXJSAMPLE+1) * sizeof(INT32));
for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) { for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
/* i is the actual input pixel value, in the range 0..MAXJSAMPLE */ /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
@@ -308,7 +308,7 @@ build_rgb_y_table (j_decompress_ptr cinfo)
/* Allocate and fill in the conversion tables. */ /* Allocate and fill in the conversion tables. */
cconvert->rgb_y_tab = rgb_y_tab = (INT32 *) cconvert->rgb_y_tab = rgb_y_tab = (INT32 *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(TABLE_SIZE * SIZEOF(INT32))); (TABLE_SIZE * sizeof(INT32)));
for (i = 0; i <= MAXJSAMPLE; i++) { for (i = 0; i <= MAXJSAMPLE; i++) {
rgb_y_tab[i+R_Y_OFF] = FIX(0.29900) * i; rgb_y_tab[i+R_Y_OFF] = FIX(0.29900) * i;
@@ -570,7 +570,7 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
cconvert = (my_cconvert_ptr) cconvert = (my_cconvert_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_color_deconverter)); sizeof(my_color_deconverter));
cinfo->cconvert = (struct jpeg_color_deconverter *) cconvert; cinfo->cconvert = (struct jpeg_color_deconverter *) cconvert;
cconvert->pub.start_pass = start_pass_dcolor; cconvert->pub.start_pass = start_pass_dcolor;

View File

@@ -331,7 +331,7 @@ jinit_inverse_dct (j_decompress_ptr cinfo)
idct = (my_idct_ptr) idct = (my_idct_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_idct_controller)); sizeof(my_idct_controller));
cinfo->idct = (struct jpeg_inverse_dct *) idct; cinfo->idct = (struct jpeg_inverse_dct *) idct;
idct->pub.start_pass = start_pass; idct->pub.start_pass = start_pass;
@@ -340,8 +340,8 @@ jinit_inverse_dct (j_decompress_ptr cinfo)
/* Allocate and pre-zero a multiplier table for each component */ /* Allocate and pre-zero a multiplier table for each component */
compptr->dct_table = compptr->dct_table =
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(multiplier_table)); sizeof(multiplier_table));
MEMZERO(compptr->dct_table, SIZEOF(multiplier_table)); MEMZERO(compptr->dct_table, sizeof(multiplier_table));
/* Mark multiplier table not yet set up for any method */ /* Mark multiplier table not yet set up for any method */
idct->cur_method[ci] = -1; idct->cur_method[ci] = -1;
} }

View File

@@ -177,7 +177,7 @@ jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno,
if (*pdtbl == NULL) if (*pdtbl == NULL)
*pdtbl = (d_derived_tbl *) *pdtbl = (d_derived_tbl *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(d_derived_tbl)); sizeof(d_derived_tbl));
dtbl = *pdtbl; dtbl = *pdtbl;
dtbl->pub = htbl; /* fill in back link */ dtbl->pub = htbl; /* fill in back link */
@@ -804,7 +804,7 @@ jinit_huff_decoder (j_decompress_ptr cinfo)
entropy = (huff_entropy_ptr) entropy = (huff_entropy_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(huff_entropy_decoder)); sizeof(huff_entropy_decoder));
cinfo->entropy = (struct jpeg_entropy_decoder *) entropy; cinfo->entropy = (struct jpeg_entropy_decoder *) entropy;
entropy->pub.start_pass = start_pass_huff_decoder; entropy->pub.start_pass = start_pass_huff_decoder;
entropy->pub.decode_mcu = decode_mcu; entropy->pub.decode_mcu = decode_mcu;

View File

@@ -253,8 +253,8 @@ latch_quant_tables (j_decompress_ptr cinfo)
/* OK, save away the quantization table */ /* OK, save away the quantization table */
qtbl = (JQUANT_TBL *) qtbl = (JQUANT_TBL *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(JQUANT_TBL)); sizeof(JQUANT_TBL));
MEMCOPY(qtbl, cinfo->quant_tbl_ptrs[qtblno], SIZEOF(JQUANT_TBL)); MEMCOPY(qtbl, cinfo->quant_tbl_ptrs[qtblno], sizeof(JQUANT_TBL));
compptr->quant_table = qtbl; compptr->quant_table = qtbl;
} }
} }
@@ -382,7 +382,7 @@ jinit_input_controller (j_decompress_ptr cinfo)
/* Create subobject in permanent pool */ /* Create subobject in permanent pool */
inputctl = (my_inputctl_ptr) inputctl = (my_inputctl_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
SIZEOF(my_input_controller)); sizeof(my_input_controller));
cinfo->inputctl = (struct jpeg_input_controller *) inputctl; cinfo->inputctl = (struct jpeg_input_controller *) inputctl;
/* Initialize method pointers */ /* Initialize method pointers */
inputctl->pub.consume_input = consume_markers; inputctl->pub.consume_input = consume_markers;

View File

@@ -173,7 +173,7 @@ alloc_funny_pointers (j_decompress_ptr cinfo)
*/ */
main_ptr->xbuffer[0] = (JSAMPIMAGE) main_ptr->xbuffer[0] = (JSAMPIMAGE)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
cinfo->num_components * 2 * SIZEOF(JSAMPARRAY)); cinfo->num_components * 2 * sizeof(JSAMPARRAY));
main_ptr->xbuffer[1] = main_ptr->xbuffer[0] + cinfo->num_components; main_ptr->xbuffer[1] = main_ptr->xbuffer[0] + cinfo->num_components;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
@@ -185,7 +185,7 @@ alloc_funny_pointers (j_decompress_ptr cinfo)
*/ */
xbuf = (JSAMPARRAY) xbuf = (JSAMPARRAY)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
2 * (rgroup * (M + 4)) * SIZEOF(JSAMPROW)); 2 * (rgroup * (M + 4)) * sizeof(JSAMPROW));
xbuf += rgroup; /* want one row group at negative offsets */ xbuf += rgroup; /* want one row group at negative offsets */
main_ptr->xbuffer[0][ci] = xbuf; main_ptr->xbuffer[0][ci] = xbuf;
xbuf += rgroup * (M + 4); xbuf += rgroup * (M + 4);
@@ -484,7 +484,7 @@ jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
main_ptr = (my_main_ptr) main_ptr = (my_main_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_main_controller)); sizeof(my_main_controller));
cinfo->main = (struct jpeg_d_main_controller *) main_ptr; cinfo->main = (struct jpeg_d_main_controller *) main_ptr;
main_ptr->pub.start_pass = start_pass_main; main_ptr->pub.start_pass = start_pass_main;

View File

@@ -276,7 +276,7 @@ get_sof (j_decompress_ptr cinfo, boolean is_prog, boolean is_arith)
if (cinfo->comp_info == NULL) /* do only once, even if suspend */ if (cinfo->comp_info == NULL) /* do only once, even if suspend */
cinfo->comp_info = (jpeg_component_info *) (*cinfo->mem->alloc_small) cinfo->comp_info = (jpeg_component_info *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE,
cinfo->num_components * SIZEOF(jpeg_component_info)); cinfo->num_components * sizeof(jpeg_component_info));
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++) {
@@ -472,7 +472,7 @@ get_dht (j_decompress_ptr cinfo)
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
INPUT_BYTE(cinfo, huffval[i], return FALSE); INPUT_BYTE(cinfo, huffval[i], return FALSE);
MEMZERO(&huffval[count], (256 - count) * SIZEOF(UINT8)); MEMZERO(&huffval[count], (256 - count) * sizeof(UINT8));
length -= count; length -= count;
@@ -490,8 +490,8 @@ get_dht (j_decompress_ptr cinfo)
if (*htblptr == NULL) if (*htblptr == NULL)
*htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);
MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits)); MEMCOPY((*htblptr)->bits, bits, sizeof((*htblptr)->bits));
MEMCOPY((*htblptr)->huffval, huffval, SIZEOF((*htblptr)->huffval)); MEMCOPY((*htblptr)->huffval, huffval, sizeof((*htblptr)->huffval));
} }
if (length != 0) if (length != 0)
@@ -778,7 +778,7 @@ save_marker (j_decompress_ptr cinfo)
/* allocate and initialize the marker item */ /* allocate and initialize the marker item */
cur_marker = (jpeg_saved_marker_ptr) cur_marker = (jpeg_saved_marker_ptr)
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(struct jpeg_marker_struct) + limit); sizeof(struct jpeg_marker_struct) + limit);
cur_marker->next = NULL; cur_marker->next = NULL;
cur_marker->marker = (UINT8) cinfo->unread_marker; cur_marker->marker = (UINT8) cinfo->unread_marker;
cur_marker->original_length = (unsigned int) length; cur_marker->original_length = (unsigned int) length;
@@ -1283,7 +1283,7 @@ jinit_marker_reader (j_decompress_ptr cinfo)
/* Create subobject in permanent pool */ /* Create subobject in permanent pool */
marker = (my_marker_ptr) marker = (my_marker_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
SIZEOF(my_marker_reader)); sizeof(my_marker_reader));
cinfo->marker = (struct jpeg_marker_reader *) marker; cinfo->marker = (struct jpeg_marker_reader *) marker;
/* Initialize public method pointers */ /* Initialize public method pointers */
marker->pub.reset_marker_reader = reset_marker_reader; marker->pub.reset_marker_reader = reset_marker_reader;
@@ -1323,7 +1323,7 @@ jpeg_save_markers (j_decompress_ptr cinfo, int marker_code,
/* Length limit mustn't be larger than what we can allocate /* Length limit mustn't be larger than what we can allocate
* (should only be a concern in a 16-bit environment). * (should only be a concern in a 16-bit environment).
*/ */
maxlength = cinfo->mem->max_alloc_chunk - SIZEOF(struct jpeg_marker_struct); maxlength = cinfo->mem->max_alloc_chunk - sizeof(struct jpeg_marker_struct);
if (((long) length_limit) > maxlength) if (((long) length_limit) > maxlength)
length_limit = (unsigned int) maxlength; length_limit = (unsigned int) maxlength;

View File

@@ -429,11 +429,11 @@ prepare_range_limit_table (j_decompress_ptr cinfo)
table = (JSAMPLE *) table = (JSAMPLE *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * SIZEOF(JSAMPLE)); (5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * sizeof(JSAMPLE));
table += (MAXJSAMPLE+1); /* allow negative subscripts of simple table */ table += (MAXJSAMPLE+1); /* allow negative subscripts of simple table */
cinfo->sample_range_limit = table; cinfo->sample_range_limit = table;
/* First segment of "simple" table: limit[x] = 0 for x < 0 */ /* First segment of "simple" table: limit[x] = 0 for x < 0 */
MEMZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * SIZEOF(JSAMPLE)); MEMZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * sizeof(JSAMPLE));
/* Main part of "simple" table: limit[x] = x */ /* Main part of "simple" table: limit[x] = x */
for (i = 0; i <= MAXJSAMPLE; i++) for (i = 0; i <= MAXJSAMPLE; i++)
table[i] = (JSAMPLE) i; table[i] = (JSAMPLE) i;
@@ -443,9 +443,9 @@ prepare_range_limit_table (j_decompress_ptr cinfo)
table[i] = MAXJSAMPLE; table[i] = MAXJSAMPLE;
/* Second half of post-IDCT table */ /* Second half of post-IDCT table */
MEMZERO(table + (2 * (MAXJSAMPLE+1)), MEMZERO(table + (2 * (MAXJSAMPLE+1)),
(2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * SIZEOF(JSAMPLE)); (2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * sizeof(JSAMPLE));
MEMCOPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE), MEMCOPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE),
cinfo->sample_range_limit, CENTERJSAMPLE * SIZEOF(JSAMPLE)); cinfo->sample_range_limit, CENTERJSAMPLE * sizeof(JSAMPLE));
} }
@@ -726,7 +726,7 @@ jinit_master_decompress (j_decompress_ptr cinfo)
master = (my_master_ptr) master = (my_master_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_decomp_master)); sizeof(my_decomp_master));
cinfo->master = (struct jpeg_decomp_master *) master; cinfo->master = (struct jpeg_decomp_master *) master;
master->pub.prepare_for_output_pass = prepare_for_output_pass; master->pub.prepare_for_output_pass = prepare_for_output_pass;
master->pub.finish_output_pass = finish_output_pass; master->pub.finish_output_pass = finish_output_pass;

View File

@@ -227,16 +227,16 @@ build_ycc_rgb_table (j_decompress_ptr cinfo)
upsample->Cr_r_tab = (int *) upsample->Cr_r_tab = (int *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(MAXJSAMPLE+1) * SIZEOF(int)); (MAXJSAMPLE+1) * sizeof(int));
upsample->Cb_b_tab = (int *) upsample->Cb_b_tab = (int *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(MAXJSAMPLE+1) * SIZEOF(int)); (MAXJSAMPLE+1) * sizeof(int));
upsample->Cr_g_tab = (INT32 *) upsample->Cr_g_tab = (INT32 *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(MAXJSAMPLE+1) * SIZEOF(INT32)); (MAXJSAMPLE+1) * sizeof(INT32));
upsample->Cb_g_tab = (INT32 *) upsample->Cb_g_tab = (INT32 *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(MAXJSAMPLE+1) * SIZEOF(INT32)); (MAXJSAMPLE+1) * sizeof(INT32));
for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) { for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
/* i is the actual input pixel value, in the range 0..MAXJSAMPLE */ /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
@@ -801,7 +801,7 @@ jinit_merged_upsampler (j_decompress_ptr cinfo)
upsample = (my_upsample_ptr) upsample = (my_upsample_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_upsampler)); sizeof(my_upsampler));
cinfo->upsample = (struct jpeg_upsampler *) upsample; cinfo->upsample = (struct jpeg_upsampler *) upsample;
upsample->pub.start_pass = start_pass_merged_upsample; upsample->pub.start_pass = start_pass_merged_upsample;
upsample->pub.need_context_rows = FALSE; upsample->pub.need_context_rows = FALSE;
@@ -824,7 +824,7 @@ jinit_merged_upsampler (j_decompress_ptr cinfo)
/* Allocate a spare row buffer */ /* Allocate a spare row buffer */
upsample->spare_row = (JSAMPROW) upsample->spare_row = (JSAMPROW)
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(size_t) (upsample->out_row_width * SIZEOF(JSAMPLE))); (size_t) (upsample->out_row_width * sizeof(JSAMPLE)));
} else { } else {
upsample->pub.upsample = merged_1v_upsample; upsample->pub.upsample = merged_1v_upsample;
if (jsimd_can_h2v1_merged_upsample()) if (jsimd_can_h2v1_merged_upsample())

View File

@@ -649,7 +649,7 @@ jinit_phuff_decoder (j_decompress_ptr cinfo)
entropy = (phuff_entropy_ptr) entropy = (phuff_entropy_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(phuff_entropy_decoder)); sizeof(phuff_entropy_decoder));
cinfo->entropy = (struct jpeg_entropy_decoder *) entropy; cinfo->entropy = (struct jpeg_entropy_decoder *) entropy;
entropy->pub.start_pass = start_pass_phuff_decoder; entropy->pub.start_pass = start_pass_phuff_decoder;
@@ -661,7 +661,7 @@ jinit_phuff_decoder (j_decompress_ptr cinfo)
/* Create progression status table */ /* Create progression status table */
cinfo->coef_bits = (int (*)[DCTSIZE2]) cinfo->coef_bits = (int (*)[DCTSIZE2])
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
cinfo->num_components*DCTSIZE2*SIZEOF(int)); cinfo->num_components*DCTSIZE2*sizeof(int));
coef_bit_ptr = & cinfo->coef_bits[0][0]; coef_bit_ptr = & cinfo->coef_bits[0][0];
for (ci = 0; ci < cinfo->num_components; ci++) for (ci = 0; ci < cinfo->num_components; ci++)
for (i = 0; i < DCTSIZE2; i++) for (i = 0; i < DCTSIZE2; i++)

View File

@@ -252,7 +252,7 @@ jinit_d_post_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
post = (my_post_ptr) post = (my_post_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_post_controller)); sizeof(my_post_controller));
cinfo->post = (struct jpeg_d_post_controller *) post; cinfo->post = (struct jpeg_d_post_controller *) post;
post->pub.start_pass = start_pass_dpost; post->pub.start_pass = start_pass_dpost;
post->whole_image = NULL; /* flag for no virtual arrays */ post->whole_image = NULL; /* flag for no virtual arrays */

View File

@@ -412,7 +412,7 @@ jinit_upsampler (j_decompress_ptr cinfo)
upsample = (my_upsample_ptr) upsample = (my_upsample_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_upsampler)); sizeof(my_upsampler));
cinfo->upsample = (struct jpeg_upsampler *) upsample; cinfo->upsample = (struct jpeg_upsampler *) upsample;
upsample->pub.start_pass = start_pass_upsample; upsample->pub.start_pass = start_pass_upsample;
upsample->pub.upsample = sep_upsample; upsample->pub.upsample = sep_upsample;

View File

@@ -1,8 +1,10 @@
/* /*
* jinclude.h * jinclude.h
* *
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1994, Thomas G. Lane. * Copyright (C) 1991-1994, Thomas G. Lane.
* This file is part of the Independent JPEG Group's software. * It was modified by The libjpeg-turbo Project to include only code relevant
* to libjpeg-turbo.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
* This file exists to provide a single place to fix any problems with * This file exists to provide a single place to fix any problems with
@@ -69,16 +71,6 @@
#endif #endif
/*
* In ANSI C, and indeed any rational implementation, size_t is also the
* type returned by sizeof(). However, it seems there are some irrational
* implementations out there, in which sizeof() returns an int even though
* size_t is defined as long or unsigned long. To ensure consistent results
* we always use this SIZEOF() macro in place of using sizeof() directly.
*/
#define SIZEOF(object) ((size_t) sizeof(object))
/* /*
* The modules that use fread() and fwrite() always invoke them through * The modules that use fread() and fwrite() always invoke them through
* these macros. On some systems you may need to twiddle the argument casts. * these macros. On some systems you may need to twiddle the argument casts.

View File

@@ -82,7 +82,7 @@ round_up_pow2 (size_t a, size_t b)
#ifndef ALIGN_SIZE /* so can override from jconfig.h */ #ifndef ALIGN_SIZE /* so can override from jconfig.h */
#ifndef WITH_SIMD #ifndef WITH_SIMD
#define ALIGN_SIZE SIZEOF(double) #define ALIGN_SIZE sizeof(double)
#else #else
#define ALIGN_SIZE 16 /* Most SIMD implementations require this */ #define ALIGN_SIZE 16 /* Most SIMD implementations require this */
#endif #endif
@@ -278,7 +278,7 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
sizeofobject = round_up_pow2(sizeofobject, ALIGN_SIZE); sizeofobject = round_up_pow2(sizeofobject, ALIGN_SIZE);
/* Check for unsatisfiable request (do now to ensure no overflow below) */ /* Check for unsatisfiable request (do now to ensure no overflow below) */
if ((SIZEOF(small_pool_hdr) + sizeofobject + ALIGN_SIZE - 1) > MAX_ALLOC_CHUNK) if ((sizeof(small_pool_hdr) + sizeofobject + ALIGN_SIZE - 1) > MAX_ALLOC_CHUNK)
out_of_memory(cinfo, 1); /* request exceeds malloc's ability */ out_of_memory(cinfo, 1); /* request exceeds malloc's ability */
/* See if space is available in any existing pool */ /* See if space is available in any existing pool */
@@ -296,7 +296,7 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
/* Time to make a new pool? */ /* Time to make a new pool? */
if (hdr_ptr == NULL) { if (hdr_ptr == NULL) {
/* min_request is what we need now, slop is what will be leftover */ /* min_request is what we need now, slop is what will be leftover */
min_request = SIZEOF(small_pool_hdr) + sizeofobject + ALIGN_SIZE - 1; min_request = sizeof(small_pool_hdr) + sizeofobject + ALIGN_SIZE - 1;
if (prev_hdr_ptr == NULL) /* first pool in class? */ if (prev_hdr_ptr == NULL) /* first pool in class? */
slop = first_pool_slop[pool_id]; slop = first_pool_slop[pool_id];
else else
@@ -326,7 +326,7 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
/* OK, allocate the object from the current pool */ /* OK, allocate the object from the current pool */
data_ptr = (char *) hdr_ptr; /* point to first data byte in pool... */ data_ptr = (char *) hdr_ptr; /* point to first data byte in pool... */
data_ptr += SIZEOF(small_pool_hdr); /* ...by skipping the header... */ data_ptr += sizeof(small_pool_hdr); /* ...by skipping the header... */
if ((size_t)data_ptr % ALIGN_SIZE) /* ...and adjust for alignment */ if ((size_t)data_ptr % ALIGN_SIZE) /* ...and adjust for alignment */
data_ptr += ALIGN_SIZE - (size_t)data_ptr % ALIGN_SIZE; data_ptr += ALIGN_SIZE - (size_t)data_ptr % ALIGN_SIZE;
data_ptr += hdr_ptr->bytes_used; /* point to place for object */ data_ptr += hdr_ptr->bytes_used; /* point to place for object */
@@ -366,7 +366,7 @@ alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
sizeofobject = round_up_pow2(sizeofobject, ALIGN_SIZE); sizeofobject = round_up_pow2(sizeofobject, ALIGN_SIZE);
/* Check for unsatisfiable request (do now to ensure no overflow below) */ /* Check for unsatisfiable request (do now to ensure no overflow below) */
if ((SIZEOF(large_pool_hdr) + sizeofobject + ALIGN_SIZE - 1) > MAX_ALLOC_CHUNK) if ((sizeof(large_pool_hdr) + sizeofobject + ALIGN_SIZE - 1) > MAX_ALLOC_CHUNK)
out_of_memory(cinfo, 3); /* request exceeds malloc's ability */ out_of_memory(cinfo, 3); /* request exceeds malloc's ability */
/* Always make a new pool */ /* Always make a new pool */
@@ -374,11 +374,11 @@ alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */
hdr_ptr = (large_pool_ptr) jpeg_get_large(cinfo, sizeofobject + hdr_ptr = (large_pool_ptr) jpeg_get_large(cinfo, sizeofobject +
SIZEOF(large_pool_hdr) + sizeof(large_pool_hdr) +
ALIGN_SIZE - 1); ALIGN_SIZE - 1);
if (hdr_ptr == NULL) if (hdr_ptr == NULL)
out_of_memory(cinfo, 4); /* jpeg_get_large failed */ out_of_memory(cinfo, 4); /* jpeg_get_large failed */
mem->total_space_allocated += sizeofobject + SIZEOF(large_pool_hdr) + ALIGN_SIZE - 1; mem->total_space_allocated += sizeofobject + sizeof(large_pool_hdr) + ALIGN_SIZE - 1;
/* Success, initialize the new pool header and add to list */ /* Success, initialize the new pool header and add to list */
hdr_ptr->next = mem->large_list[pool_id]; hdr_ptr->next = mem->large_list[pool_id];
@@ -390,7 +390,7 @@ alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
mem->large_list[pool_id] = hdr_ptr; mem->large_list[pool_id] = hdr_ptr;
data_ptr = (char *) hdr_ptr; /* point to first data byte in pool... */ data_ptr = (char *) hdr_ptr; /* point to first data byte in pool... */
data_ptr += SIZEOF(small_pool_hdr); /* ...by skipping the header... */ data_ptr += sizeof(small_pool_hdr); /* ...by skipping the header... */
if ((size_t)data_ptr % ALIGN_SIZE) /* ...and adjust for alignment */ if ((size_t)data_ptr % ALIGN_SIZE) /* ...and adjust for alignment */
data_ptr += ALIGN_SIZE - (size_t)data_ptr % ALIGN_SIZE; data_ptr += ALIGN_SIZE - (size_t)data_ptr % ALIGN_SIZE;
@@ -426,13 +426,13 @@ alloc_sarray (j_common_ptr cinfo, int pool_id,
long ltemp; long ltemp;
/* Make sure each row is properly aligned */ /* Make sure each row is properly aligned */
if ((ALIGN_SIZE % SIZEOF(JSAMPLE)) != 0) if ((ALIGN_SIZE % sizeof(JSAMPLE)) != 0)
out_of_memory(cinfo, 5); /* safety check */ out_of_memory(cinfo, 5); /* safety check */
samplesperrow = (JDIMENSION)round_up_pow2(samplesperrow, (2 * ALIGN_SIZE) / SIZEOF(JSAMPLE)); samplesperrow = (JDIMENSION)round_up_pow2(samplesperrow, (2 * ALIGN_SIZE) / sizeof(JSAMPLE));
/* Calculate max # of rows allowed in one allocation chunk */ /* Calculate max # of rows allowed in one allocation chunk */
ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) / ltemp = (MAX_ALLOC_CHUNK-sizeof(large_pool_hdr)) /
((long) samplesperrow * SIZEOF(JSAMPLE)); ((long) samplesperrow * sizeof(JSAMPLE));
if (ltemp <= 0) if (ltemp <= 0)
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
if (ltemp < (long) numrows) if (ltemp < (long) numrows)
@@ -443,7 +443,7 @@ alloc_sarray (j_common_ptr cinfo, int pool_id,
/* Get space for row pointers (small object) */ /* Get space for row pointers (small object) */
result = (JSAMPARRAY) alloc_small(cinfo, pool_id, result = (JSAMPARRAY) alloc_small(cinfo, pool_id,
(size_t) (numrows * SIZEOF(JSAMPROW))); (size_t) (numrows * sizeof(JSAMPROW)));
/* Get the rows themselves (large objects) */ /* Get the rows themselves (large objects) */
currow = 0; currow = 0;
@@ -451,7 +451,7 @@ alloc_sarray (j_common_ptr cinfo, int pool_id,
rowsperchunk = MIN(rowsperchunk, numrows - currow); rowsperchunk = MIN(rowsperchunk, numrows - currow);
workspace = (JSAMPROW) alloc_large(cinfo, pool_id, workspace = (JSAMPROW) alloc_large(cinfo, pool_id,
(size_t) ((size_t) rowsperchunk * (size_t) samplesperrow (size_t) ((size_t) rowsperchunk * (size_t) samplesperrow
* SIZEOF(JSAMPLE))); * sizeof(JSAMPLE)));
for (i = rowsperchunk; i > 0; i--) { for (i = rowsperchunk; i > 0; i--) {
result[currow++] = workspace; result[currow++] = workspace;
workspace += samplesperrow; workspace += samplesperrow;
@@ -479,12 +479,12 @@ alloc_barray (j_common_ptr cinfo, int pool_id,
long ltemp; long ltemp;
/* Make sure each row is properly aligned */ /* Make sure each row is properly aligned */
if ((SIZEOF(JBLOCK) % ALIGN_SIZE) != 0) if ((sizeof(JBLOCK) % ALIGN_SIZE) != 0)
out_of_memory(cinfo, 6); /* safety check */ out_of_memory(cinfo, 6); /* safety check */
/* Calculate max # of rows allowed in one allocation chunk */ /* Calculate max # of rows allowed in one allocation chunk */
ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) / ltemp = (MAX_ALLOC_CHUNK-sizeof(large_pool_hdr)) /
((long) blocksperrow * SIZEOF(JBLOCK)); ((long) blocksperrow * sizeof(JBLOCK));
if (ltemp <= 0) if (ltemp <= 0)
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
if (ltemp < (long) numrows) if (ltemp < (long) numrows)
@@ -495,7 +495,7 @@ alloc_barray (j_common_ptr cinfo, int pool_id,
/* Get space for row pointers (small object) */ /* Get space for row pointers (small object) */
result = (JBLOCKARRAY) alloc_small(cinfo, pool_id, result = (JBLOCKARRAY) alloc_small(cinfo, pool_id,
(size_t) (numrows * SIZEOF(JBLOCKROW))); (size_t) (numrows * sizeof(JBLOCKROW)));
/* Get the rows themselves (large objects) */ /* Get the rows themselves (large objects) */
currow = 0; currow = 0;
@@ -503,7 +503,7 @@ alloc_barray (j_common_ptr cinfo, int pool_id,
rowsperchunk = MIN(rowsperchunk, numrows - currow); rowsperchunk = MIN(rowsperchunk, numrows - currow);
workspace = (JBLOCKROW) alloc_large(cinfo, pool_id, workspace = (JBLOCKROW) alloc_large(cinfo, pool_id,
(size_t) ((size_t) rowsperchunk * (size_t) blocksperrow (size_t) ((size_t) rowsperchunk * (size_t) blocksperrow
* SIZEOF(JBLOCK))); * sizeof(JBLOCK)));
for (i = rowsperchunk; i > 0; i--) { for (i = rowsperchunk; i > 0; i--) {
result[currow++] = workspace; result[currow++] = workspace;
workspace += blocksperrow; workspace += blocksperrow;
@@ -566,7 +566,7 @@ request_virt_sarray (j_common_ptr cinfo, int pool_id, boolean pre_zero,
/* get control block */ /* get control block */
result = (jvirt_sarray_ptr) alloc_small(cinfo, pool_id, result = (jvirt_sarray_ptr) alloc_small(cinfo, pool_id,
SIZEOF(struct jvirt_sarray_control)); sizeof(struct jvirt_sarray_control));
result->mem_buffer = NULL; /* marks array not yet realized */ result->mem_buffer = NULL; /* marks array not yet realized */
result->rows_in_array = numrows; result->rows_in_array = numrows;
@@ -596,7 +596,7 @@ request_virt_barray (j_common_ptr cinfo, int pool_id, boolean pre_zero,
/* get control block */ /* get control block */
result = (jvirt_barray_ptr) alloc_small(cinfo, pool_id, result = (jvirt_barray_ptr) alloc_small(cinfo, pool_id,
SIZEOF(struct jvirt_barray_control)); sizeof(struct jvirt_barray_control));
result->mem_buffer = NULL; /* marks array not yet realized */ result->mem_buffer = NULL; /* marks array not yet realized */
result->rows_in_array = numrows; result->rows_in_array = numrows;
@@ -630,17 +630,17 @@ realize_virt_arrays (j_common_ptr cinfo)
for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) { for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
if (sptr->mem_buffer == NULL) { /* if not realized yet */ if (sptr->mem_buffer == NULL) { /* if not realized yet */
space_per_minheight += (long) sptr->maxaccess * space_per_minheight += (long) sptr->maxaccess *
(long) sptr->samplesperrow * SIZEOF(JSAMPLE); (long) sptr->samplesperrow * sizeof(JSAMPLE);
maximum_space += (long) sptr->rows_in_array * maximum_space += (long) sptr->rows_in_array *
(long) sptr->samplesperrow * SIZEOF(JSAMPLE); (long) sptr->samplesperrow * sizeof(JSAMPLE);
} }
} }
for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) { for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
if (bptr->mem_buffer == NULL) { /* if not realized yet */ if (bptr->mem_buffer == NULL) { /* if not realized yet */
space_per_minheight += (long) bptr->maxaccess * space_per_minheight += (long) bptr->maxaccess *
(long) bptr->blocksperrow * SIZEOF(JBLOCK); (long) bptr->blocksperrow * sizeof(JBLOCK);
maximum_space += (long) bptr->rows_in_array * maximum_space += (long) bptr->rows_in_array *
(long) bptr->blocksperrow * SIZEOF(JBLOCK); (long) bptr->blocksperrow * sizeof(JBLOCK);
} }
} }
@@ -680,7 +680,7 @@ realize_virt_arrays (j_common_ptr cinfo)
jpeg_open_backing_store(cinfo, & sptr->b_s_info, jpeg_open_backing_store(cinfo, & sptr->b_s_info,
(long) sptr->rows_in_array * (long) sptr->rows_in_array *
(long) sptr->samplesperrow * (long) sptr->samplesperrow *
(long) SIZEOF(JSAMPLE)); (long) sizeof(JSAMPLE));
sptr->b_s_open = TRUE; sptr->b_s_open = TRUE;
} }
sptr->mem_buffer = alloc_sarray(cinfo, JPOOL_IMAGE, sptr->mem_buffer = alloc_sarray(cinfo, JPOOL_IMAGE,
@@ -704,7 +704,7 @@ realize_virt_arrays (j_common_ptr cinfo)
jpeg_open_backing_store(cinfo, & bptr->b_s_info, jpeg_open_backing_store(cinfo, & bptr->b_s_info,
(long) bptr->rows_in_array * (long) bptr->rows_in_array *
(long) bptr->blocksperrow * (long) bptr->blocksperrow *
(long) SIZEOF(JBLOCK)); (long) sizeof(JBLOCK));
bptr->b_s_open = TRUE; bptr->b_s_open = TRUE;
} }
bptr->mem_buffer = alloc_barray(cinfo, JPOOL_IMAGE, bptr->mem_buffer = alloc_barray(cinfo, JPOOL_IMAGE,
@@ -724,7 +724,7 @@ do_sarray_io (j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing)
{ {
long bytesperrow, file_offset, byte_count, rows, thisrow, i; long bytesperrow, file_offset, byte_count, rows, thisrow, i;
bytesperrow = (long) ptr->samplesperrow * SIZEOF(JSAMPLE); bytesperrow = (long) ptr->samplesperrow * sizeof(JSAMPLE);
file_offset = ptr->cur_start_row * bytesperrow; file_offset = ptr->cur_start_row * bytesperrow;
/* Loop to read or write each allocation chunk in mem_buffer */ /* Loop to read or write each allocation chunk in mem_buffer */
for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) { for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) {
@@ -757,7 +757,7 @@ do_barray_io (j_common_ptr cinfo, jvirt_barray_ptr ptr, boolean writing)
{ {
long bytesperrow, file_offset, byte_count, rows, thisrow, i; long bytesperrow, file_offset, byte_count, rows, thisrow, i;
bytesperrow = (long) ptr->blocksperrow * SIZEOF(JBLOCK); bytesperrow = (long) ptr->blocksperrow * sizeof(JBLOCK);
file_offset = ptr->cur_start_row * bytesperrow; file_offset = ptr->cur_start_row * bytesperrow;
/* Loop to read or write each allocation chunk in mem_buffer */ /* Loop to read or write each allocation chunk in mem_buffer */
for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) { for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) {
@@ -849,7 +849,7 @@ access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr,
if (writable) if (writable)
ptr->first_undef_row = end_row; ptr->first_undef_row = end_row;
if (ptr->pre_zero) { if (ptr->pre_zero) {
size_t bytesperrow = (size_t) ptr->samplesperrow * SIZEOF(JSAMPLE); size_t bytesperrow = (size_t) ptr->samplesperrow * sizeof(JSAMPLE);
undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */ undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */
end_row -= ptr->cur_start_row; end_row -= ptr->cur_start_row;
while (undef_row < end_row) { while (undef_row < end_row) {
@@ -934,7 +934,7 @@ access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr,
if (writable) if (writable)
ptr->first_undef_row = end_row; ptr->first_undef_row = end_row;
if (ptr->pre_zero) { if (ptr->pre_zero) {
size_t bytesperrow = (size_t) ptr->blocksperrow * SIZEOF(JBLOCK); size_t bytesperrow = (size_t) ptr->blocksperrow * sizeof(JBLOCK);
undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */ undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */
end_row -= ptr->cur_start_row; end_row -= ptr->cur_start_row;
while (undef_row < end_row) { while (undef_row < end_row) {
@@ -1003,7 +1003,7 @@ free_pool (j_common_ptr cinfo, int pool_id)
large_pool_ptr next_lhdr_ptr = lhdr_ptr->next; large_pool_ptr next_lhdr_ptr = lhdr_ptr->next;
space_freed = lhdr_ptr->bytes_used + space_freed = lhdr_ptr->bytes_used +
lhdr_ptr->bytes_left + lhdr_ptr->bytes_left +
SIZEOF(large_pool_hdr); sizeof(large_pool_hdr);
jpeg_free_large(cinfo, (void *) lhdr_ptr, space_freed); jpeg_free_large(cinfo, (void *) lhdr_ptr, space_freed);
mem->total_space_allocated -= space_freed; mem->total_space_allocated -= space_freed;
lhdr_ptr = next_lhdr_ptr; lhdr_ptr = next_lhdr_ptr;
@@ -1017,7 +1017,7 @@ free_pool (j_common_ptr cinfo, int pool_id)
small_pool_ptr next_shdr_ptr = shdr_ptr->next; small_pool_ptr next_shdr_ptr = shdr_ptr->next;
space_freed = shdr_ptr->bytes_used + space_freed = shdr_ptr->bytes_used +
shdr_ptr->bytes_left + shdr_ptr->bytes_left +
SIZEOF(small_pool_hdr); sizeof(small_pool_hdr);
jpeg_free_small(cinfo, (void *) shdr_ptr, space_freed); jpeg_free_small(cinfo, (void *) shdr_ptr, space_freed);
mem->total_space_allocated -= space_freed; mem->total_space_allocated -= space_freed;
shdr_ptr = next_shdr_ptr; shdr_ptr = next_shdr_ptr;
@@ -1044,7 +1044,7 @@ self_destruct (j_common_ptr cinfo)
} }
/* Release the memory manager control block too. */ /* Release the memory manager control block too. */
jpeg_free_small(cinfo, (void *) cinfo->mem, SIZEOF(my_memory_mgr)); jpeg_free_small(cinfo, (void *) cinfo->mem, sizeof(my_memory_mgr));
cinfo->mem = NULL; /* ensures I will be called only once */ cinfo->mem = NULL; /* ensures I will be called only once */
jpeg_mem_term(cinfo); /* system-dependent cleanup */ jpeg_mem_term(cinfo); /* system-dependent cleanup */
@@ -1067,7 +1067,7 @@ jinit_memory_mgr (j_common_ptr cinfo)
cinfo->mem = NULL; /* for safety if init fails */ cinfo->mem = NULL; /* for safety if init fails */
/* Check for configuration errors. /* Check for configuration errors.
* SIZEOF(ALIGN_TYPE) should be a power of 2; otherwise, it probably * sizeof(ALIGN_TYPE) should be a power of 2; otherwise, it probably
* doesn't reflect any real hardware alignment requirement. * doesn't reflect any real hardware alignment requirement.
* The test is a little tricky: for X>0, X and X-1 have no one-bits * The test is a little tricky: for X>0, X and X-1 have no one-bits
* in common if and only if X is a power of 2, ie has only one one-bit. * in common if and only if X is a power of 2, ie has only one one-bit.
@@ -1088,7 +1088,7 @@ jinit_memory_mgr (j_common_ptr cinfo)
max_to_use = jpeg_mem_init(cinfo); /* system-dependent initialization */ max_to_use = jpeg_mem_init(cinfo); /* system-dependent initialization */
/* Attempt to allocate memory manager's control block */ /* Attempt to allocate memory manager's control block */
mem = (my_mem_ptr) jpeg_get_small(cinfo, SIZEOF(my_memory_mgr)); mem = (my_mem_ptr) jpeg_get_small(cinfo, sizeof(my_memory_mgr));
if (mem == NULL) { if (mem == NULL) {
jpeg_mem_term(cinfo); /* system-dependent cleanup */ jpeg_mem_term(cinfo); /* system-dependent cleanup */
@@ -1121,7 +1121,7 @@ jinit_memory_mgr (j_common_ptr cinfo)
mem->virt_sarray_list = NULL; mem->virt_sarray_list = NULL;
mem->virt_barray_list = NULL; mem->virt_barray_list = NULL;
mem->total_space_allocated = SIZEOF(my_memory_mgr); mem->total_space_allocated = sizeof(my_memory_mgr);
/* Declare ourselves open for business */ /* Declare ourselves open for business */
cinfo->mem = & mem->pub; cinfo->mem = & mem->pub;

View File

@@ -403,7 +403,7 @@ make_odither_array (j_decompress_ptr cinfo, int ncolors)
odither = (ODITHER_MATRIX_PTR) odither = (ODITHER_MATRIX_PTR)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(ODITHER_MATRIX)); sizeof(ODITHER_MATRIX));
/* The inter-value distance for this color is MAXJSAMPLE/(ncolors-1). /* The inter-value distance for this color is MAXJSAMPLE/(ncolors-1).
* Hence the dither value for the matrix cell with fill order f * Hence the dither value for the matrix cell with fill order f
* (f=0..N-1) should be (N-1-2*f)/(2*N) * MAXJSAMPLE/(ncolors-1). * (f=0..N-1) should be (N-1-2*f)/(2*N) * MAXJSAMPLE/(ncolors-1).
@@ -532,7 +532,7 @@ quantize_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
for (row = 0; row < num_rows; row++) { for (row = 0; row < num_rows; row++) {
/* Initialize output values to 0 so can process components separately */ /* Initialize output values to 0 so can process components separately */
jzero_far((void *) output_buf[row], (size_t) (width * SIZEOF(JSAMPLE))); jzero_far((void *) output_buf[row], (size_t) (width * sizeof(JSAMPLE)));
row_index = cquantize->row_index; row_index = cquantize->row_index;
for (ci = 0; ci < nc; ci++) { for (ci = 0; ci < nc; ci++) {
input_ptr = input_buf[row] + ci; input_ptr = input_buf[row] + ci;
@@ -636,7 +636,7 @@ quantize_fs_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
for (row = 0; row < num_rows; row++) { for (row = 0; row < num_rows; row++) {
/* Initialize output values to 0 so can process components separately */ /* Initialize output values to 0 so can process components separately */
jzero_far((void *) output_buf[row], (size_t) (width * SIZEOF(JSAMPLE))); jzero_far((void *) output_buf[row], (size_t) (width * sizeof(JSAMPLE)));
for (ci = 0; ci < nc; ci++) { for (ci = 0; ci < nc; ci++) {
input_ptr = input_buf[row] + ci; input_ptr = input_buf[row] + ci;
output_ptr = output_buf[row]; output_ptr = output_buf[row];
@@ -725,7 +725,7 @@ alloc_fs_workspace (j_decompress_ptr cinfo)
size_t arraysize; size_t arraysize;
int i; int i;
arraysize = (size_t) ((cinfo->output_width + 2) * SIZEOF(FSERROR)); arraysize = (size_t) ((cinfo->output_width + 2) * sizeof(FSERROR));
for (i = 0; i < cinfo->out_color_components; i++) { for (i = 0; i < cinfo->out_color_components; i++) {
cquantize->fserrors[i] = (FSERRPTR) cquantize->fserrors[i] = (FSERRPTR)
(*cinfo->mem->alloc_large)((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize); (*cinfo->mem->alloc_large)((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize);
@@ -779,7 +779,7 @@ start_pass_1_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
if (cquantize->fserrors[0] == NULL) if (cquantize->fserrors[0] == NULL)
alloc_fs_workspace(cinfo); alloc_fs_workspace(cinfo);
/* Initialize the propagated errors to zero. */ /* Initialize the propagated errors to zero. */
arraysize = (size_t) ((cinfo->output_width + 2) * SIZEOF(FSERROR)); arraysize = (size_t) ((cinfo->output_width + 2) * sizeof(FSERROR));
for (i = 0; i < cinfo->out_color_components; i++) for (i = 0; i < cinfo->out_color_components; i++)
jzero_far((void *) cquantize->fserrors[i], arraysize); jzero_far((void *) cquantize->fserrors[i], arraysize);
break; break;
@@ -824,7 +824,7 @@ jinit_1pass_quantizer (j_decompress_ptr cinfo)
cquantize = (my_cquantize_ptr) cquantize = (my_cquantize_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_cquantizer)); sizeof(my_cquantizer));
cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize; cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize;
cquantize->pub.start_pass = start_pass_1_quant; cquantize->pub.start_pass = start_pass_1_quant;
cquantize->pub.finish_pass = finish_pass_1_quant; cquantize->pub.finish_pass = finish_pass_1_quant;

View File

@@ -524,7 +524,7 @@ select_colors (j_decompress_ptr cinfo, int desired_colors)
/* Allocate workspace for box list */ /* Allocate workspace for box list */
boxlist = (boxptr) (*cinfo->mem->alloc_small) boxlist = (boxptr) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, desired_colors * SIZEOF(box)); ((j_common_ptr) cinfo, JPOOL_IMAGE, desired_colors * sizeof(box));
/* Initialize one box containing whole space */ /* Initialize one box containing whole space */
numboxes = 1; numboxes = 1;
boxlist[0].c0min = 0; boxlist[0].c0min = 0;
@@ -1083,7 +1083,7 @@ init_error_limit (j_decompress_ptr cinfo)
int in, out; int in, out;
table = (int *) (*cinfo->mem->alloc_small) table = (int *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE*2+1) * SIZEOF(int)); ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE*2+1) * sizeof(int));
table += MAXJSAMPLE; /* so can index -MAXJSAMPLE .. +MAXJSAMPLE */ table += MAXJSAMPLE; /* so can index -MAXJSAMPLE .. +MAXJSAMPLE */
cquantize->error_limiter = table; cquantize->error_limiter = table;
@@ -1167,7 +1167,7 @@ start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
if (cinfo->dither_mode == JDITHER_FS) { if (cinfo->dither_mode == JDITHER_FS) {
size_t arraysize = (size_t) ((cinfo->output_width + 2) * size_t arraysize = (size_t) ((cinfo->output_width + 2) *
(3 * SIZEOF(FSERROR))); (3 * sizeof(FSERROR)));
/* Allocate Floyd-Steinberg workspace if we didn't already. */ /* Allocate Floyd-Steinberg workspace if we didn't already. */
if (cquantize->fserrors == NULL) if (cquantize->fserrors == NULL)
cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large) cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large)
@@ -1185,7 +1185,7 @@ start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
if (cquantize->needs_zeroed) { if (cquantize->needs_zeroed) {
for (i = 0; i < HIST_C0_ELEMS; i++) { for (i = 0; i < HIST_C0_ELEMS; i++) {
jzero_far((void *) histogram[i], jzero_far((void *) histogram[i],
HIST_C1_ELEMS*HIST_C2_ELEMS * SIZEOF(histcell)); HIST_C1_ELEMS*HIST_C2_ELEMS * sizeof(histcell));
} }
cquantize->needs_zeroed = FALSE; cquantize->needs_zeroed = FALSE;
} }
@@ -1218,7 +1218,7 @@ jinit_2pass_quantizer (j_decompress_ptr cinfo)
cquantize = (my_cquantize_ptr) cquantize = (my_cquantize_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_cquantizer)); sizeof(my_cquantizer));
cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize; cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize;
cquantize->pub.start_pass = start_pass_2_quant; cquantize->pub.start_pass = start_pass_2_quant;
cquantize->pub.new_color_map = new_color_map_2_quant; cquantize->pub.new_color_map = new_color_map_2_quant;
@@ -1231,11 +1231,11 @@ jinit_2pass_quantizer (j_decompress_ptr cinfo)
/* Allocate the histogram/inverse colormap storage */ /* Allocate the histogram/inverse colormap storage */
cquantize->histogram = (hist3d) (*cinfo->mem->alloc_small) cquantize->histogram = (hist3d) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, HIST_C0_ELEMS * SIZEOF(hist2d)); ((j_common_ptr) cinfo, JPOOL_IMAGE, HIST_C0_ELEMS * sizeof(hist2d));
for (i = 0; i < HIST_C0_ELEMS; i++) { for (i = 0; i < HIST_C0_ELEMS; i++) {
cquantize->histogram[i] = (hist2d) (*cinfo->mem->alloc_large) cquantize->histogram[i] = (hist2d) (*cinfo->mem->alloc_large)
((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE,
HIST_C1_ELEMS*HIST_C2_ELEMS * SIZEOF(histcell)); HIST_C1_ELEMS*HIST_C2_ELEMS * sizeof(histcell));
} }
cquantize->needs_zeroed = TRUE; /* histogram is garbage now */ cquantize->needs_zeroed = TRUE; /* histogram is garbage now */
@@ -1272,7 +1272,7 @@ jinit_2pass_quantizer (j_decompress_ptr cinfo)
if (cinfo->dither_mode == JDITHER_FS) { if (cinfo->dither_mode == JDITHER_FS) {
cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large) cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large)
((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE,
(size_t) ((cinfo->output_width + 2) * (3 * SIZEOF(FSERROR)))); (size_t) ((cinfo->output_width + 2) * (3 * sizeof(FSERROR))));
/* Might as well create the error-limiting table too. */ /* Might as well create the error-limiting table too. */
init_error_limit(cinfo); init_error_limit(cinfo);
} }

View File

@@ -28,7 +28,7 @@ add_huff_table (j_common_ptr cinfo,
return; return;
/* Copy the number-of-symbols-of-each-code-length counts */ /* Copy the number-of-symbols-of-each-code-length counts */
MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits)); MEMCOPY((*htblptr)->bits, bits, sizeof((*htblptr)->bits));
/* Validate the counts. We do this here mainly so we can copy the right /* Validate the counts. We do this here mainly so we can copy the right
* number of symbols from the val[] array, without risking marching off * number of symbols from the val[] array, without risking marching off
@@ -40,7 +40,7 @@ add_huff_table (j_common_ptr cinfo,
if (nsymbols < 1 || nsymbols > 256) if (nsymbols < 1 || nsymbols > 256)
ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
MEMCOPY((*htblptr)->huffval, val, nsymbols * SIZEOF(UINT8)); MEMCOPY((*htblptr)->huffval, val, nsymbols * sizeof(UINT8));
/* Initialize sent_table FALSE so table will be written to JPEG file. */ /* Initialize sent_table FALSE so table will be written to JPEG file. */
(*htblptr)->sent_table = FALSE; (*htblptr)->sent_table = FALSE;

View File

@@ -100,7 +100,7 @@ jcopy_sample_rows (JSAMPARRAY input_array, int source_row,
*/ */
{ {
register JSAMPROW inptr, outptr; register JSAMPROW inptr, outptr;
register size_t count = (size_t) (num_cols * SIZEOF(JSAMPLE)); register size_t count = (size_t) (num_cols * sizeof(JSAMPLE));
register int row; register int row;
input_array += source_row; input_array += source_row;
@@ -119,7 +119,7 @@ jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row,
JDIMENSION num_blocks) JDIMENSION num_blocks)
/* Copy a row of coefficient blocks from one place to another. */ /* Copy a row of coefficient blocks from one place to another. */
{ {
MEMCOPY(output_row, input_row, num_blocks * (DCTSIZE2 * SIZEOF(JCOEF))); MEMCOPY(output_row, input_row, num_blocks * (DCTSIZE2 * sizeof(JCOEF)));
} }

View File

@@ -469,7 +469,7 @@ jinit_read_bmp (j_compress_ptr cinfo)
/* Create module interface object */ /* Create module interface object */
source = (bmp_source_ptr) source = (bmp_source_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(bmp_source_struct)); sizeof(bmp_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_bmp; source->pub.start_input = start_input_bmp;

10
rdppm.c
View File

@@ -350,7 +350,7 @@ start_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
TRACEMS2(cinfo, 1, JTRC_PGM, w, h); TRACEMS2(cinfo, 1, JTRC_PGM, w, h);
if (maxval > 255) { if (maxval > 255) {
source->pub.get_pixel_rows = get_word_gray_row; source->pub.get_pixel_rows = get_word_gray_row;
} else if (maxval == MAXJSAMPLE && SIZEOF(JSAMPLE) == SIZEOF(U_CHAR)) { } else if (maxval == MAXJSAMPLE && sizeof(JSAMPLE) == sizeof(U_CHAR)) {
source->pub.get_pixel_rows = get_raw_row; source->pub.get_pixel_rows = get_raw_row;
use_raw_buffer = TRUE; use_raw_buffer = TRUE;
need_rescale = FALSE; need_rescale = FALSE;
@@ -365,7 +365,7 @@ start_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
TRACEMS2(cinfo, 1, JTRC_PPM, w, h); TRACEMS2(cinfo, 1, JTRC_PPM, w, h);
if (maxval > 255) { if (maxval > 255) {
source->pub.get_pixel_rows = get_word_rgb_row; source->pub.get_pixel_rows = get_word_rgb_row;
} else if (maxval == MAXJSAMPLE && SIZEOF(JSAMPLE) == SIZEOF(U_CHAR)) { } else if (maxval == MAXJSAMPLE && sizeof(JSAMPLE) == sizeof(U_CHAR)) {
source->pub.get_pixel_rows = get_raw_row; source->pub.get_pixel_rows = get_raw_row;
use_raw_buffer = TRUE; use_raw_buffer = TRUE;
need_rescale = FALSE; need_rescale = FALSE;
@@ -378,7 +378,7 @@ start_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
/* Allocate space for I/O buffer: 1 or 3 bytes or words/pixel. */ /* Allocate space for I/O buffer: 1 or 3 bytes or words/pixel. */
if (need_iobuffer) { if (need_iobuffer) {
source->buffer_width = (size_t) w * cinfo->input_components * source->buffer_width = (size_t) w * cinfo->input_components *
((maxval<=255) ? SIZEOF(U_CHAR) : (2*SIZEOF(U_CHAR))); ((maxval<=255) ? sizeof(U_CHAR) : (2*sizeof(U_CHAR)));
source->iobuffer = (U_CHAR *) source->iobuffer = (U_CHAR *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
source->buffer_width); source->buffer_width);
@@ -406,7 +406,7 @@ start_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
/* On 16-bit-int machines we have to be careful of maxval = 65535 */ /* On 16-bit-int machines we have to be careful of maxval = 65535 */
source->rescale = (JSAMPLE *) source->rescale = (JSAMPLE *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(size_t) (((long) maxval + 1L) * SIZEOF(JSAMPLE))); (size_t) (((long) maxval + 1L) * sizeof(JSAMPLE)));
half_maxval = maxval / 2; half_maxval = maxval / 2;
for (val = 0; val <= (INT32) maxval; val++) { for (val = 0; val <= (INT32) maxval; val++) {
/* The multiplication here must be done in 32 bits to avoid overflow */ /* The multiplication here must be done in 32 bits to avoid overflow */
@@ -439,7 +439,7 @@ jinit_read_ppm (j_compress_ptr cinfo)
/* Create module interface object */ /* Create module interface object */
source = (ppm_source_ptr) source = (ppm_source_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(ppm_source_struct)); sizeof(ppm_source_struct));
/* 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_ppm; source->pub.start_input = start_input_ppm;
source->pub.finish_input = finish_input_ppm; source->pub.finish_input = finish_input_ppm;

View File

@@ -3,8 +3,8 @@
* *
* This file was part of the Independent JPEG Group's software: * This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1996, Thomas G. Lane. * Copyright (C) 1991-1996, Thomas G. Lane.
* It was modified by The libjpeg-turbo Project to include only information * It was modified by The libjpeg-turbo Project to include only code and
* relevant to libjpeg-turbo. * information relevant to libjpeg-turbo.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
* This file contains routines to read input images in Utah RLE format. * This file contains routines to read input images in Utah RLE format.
@@ -376,7 +376,7 @@ jinit_read_rle (j_compress_ptr cinfo)
/* Create module interface object */ /* Create module interface object */
source = (rle_source_ptr) source = (rle_source_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(rle_source_struct)); sizeof(rle_source_struct));
/* Fill in method ptrs */ /* Fill in method ptrs */
source->pub.start_input = start_input_rle; source->pub.start_input = start_input_rle;
source->pub.finish_input = finish_input_rle; source->pub.finish_input = finish_input_rle;

View File

@@ -261,8 +261,8 @@ bogus:
*/ */
scanptr = (jpeg_scan_info *) scanptr = (jpeg_scan_info *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
scanno * SIZEOF(jpeg_scan_info)); scanno * sizeof(jpeg_scan_info));
MEMCOPY(scanptr, scans, scanno * SIZEOF(jpeg_scan_info)); MEMCOPY(scanptr, scans, scanno * sizeof(jpeg_scan_info));
cinfo->scan_info = scanptr; cinfo->scan_info = scanptr;
cinfo->num_scans = scanno; cinfo->num_scans = scanno;
} }

View File

@@ -489,7 +489,7 @@ jinit_read_targa (j_compress_ptr cinfo)
/* Create module interface object */ /* Create module interface object */
source = (tga_source_ptr) source = (tga_source_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(tga_source_struct)); sizeof(tga_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_tga; source->pub.start_input = start_input_tga;

View File

@@ -1093,7 +1093,7 @@ jtransform_request_workspace (j_decompress_ptr srcinfo,
if (need_workspace) { if (need_workspace) {
coef_arrays = (jvirt_barray_ptr *) coef_arrays = (jvirt_barray_ptr *)
(*srcinfo->mem->alloc_small) ((j_common_ptr) srcinfo, JPOOL_IMAGE, (*srcinfo->mem->alloc_small) ((j_common_ptr) srcinfo, JPOOL_IMAGE,
SIZEOF(jvirt_barray_ptr) * info->num_components); sizeof(jvirt_barray_ptr) * info->num_components);
width_in_iMCUs = (JDIMENSION) width_in_iMCUs = (JDIMENSION)
jdiv_round_up((long) info->output_width, jdiv_round_up((long) info->output_width,
(long) info->iMCU_sample_width); (long) info->iMCU_sample_width);

View File

@@ -1263,7 +1263,7 @@ static int setDecodeDefaults(struct jpeg_decompress_struct *dinfo,
dinfo->comp_info=(jpeg_component_info *) dinfo->comp_info=(jpeg_component_info *)
(*dinfo->mem->alloc_small)((j_common_ptr)dinfo, JPOOL_IMAGE, (*dinfo->mem->alloc_small)((j_common_ptr)dinfo, JPOOL_IMAGE,
dinfo->num_components*SIZEOF(jpeg_component_info)); dinfo->num_components*sizeof(jpeg_component_info));
for(i=0; i<dinfo->num_components; i++) for(i=0; i<dinfo->num_components; i++)
{ {

10
wrbmp.c
View File

@@ -215,8 +215,8 @@ write_bmp_header (j_decompress_ptr cinfo, bmp_dest_ptr dest)
bfSize = headersize + (INT32) dest->row_width * (INT32) cinfo->output_height; bfSize = headersize + (INT32) dest->row_width * (INT32) cinfo->output_height;
/* Set unused fields of header to 0 */ /* Set unused fields of header to 0 */
MEMZERO(bmpfileheader, SIZEOF(bmpfileheader)); MEMZERO(bmpfileheader, sizeof(bmpfileheader));
MEMZERO(bmpinfoheader, SIZEOF(bmpinfoheader)); MEMZERO(bmpinfoheader, sizeof(bmpinfoheader));
/* Fill the file header */ /* Fill the file header */
bmpfileheader[0] = 0x42; /* first 2 bytes are ASCII 'B', 'M' */ bmpfileheader[0] = 0x42; /* first 2 bytes are ASCII 'B', 'M' */
@@ -283,8 +283,8 @@ write_os2_header (j_decompress_ptr cinfo, bmp_dest_ptr dest)
bfSize = headersize + (INT32) dest->row_width * (INT32) cinfo->output_height; bfSize = headersize + (INT32) dest->row_width * (INT32) cinfo->output_height;
/* Set unused fields of header to 0 */ /* Set unused fields of header to 0 */
MEMZERO(bmpfileheader, SIZEOF(bmpfileheader)); MEMZERO(bmpfileheader, sizeof(bmpfileheader));
MEMZERO(bmpcoreheader, SIZEOF(bmpcoreheader)); MEMZERO(bmpcoreheader, sizeof(bmpcoreheader));
/* Fill the file header */ /* Fill the file header */
bmpfileheader[0] = 0x42; /* first 2 bytes are ASCII 'B', 'M' */ bmpfileheader[0] = 0x42; /* first 2 bytes are ASCII 'B', 'M' */
@@ -422,7 +422,7 @@ jinit_write_bmp (j_decompress_ptr cinfo, boolean is_os2)
/* Create module interface object, fill in method pointers */ /* Create module interface object, fill in method pointers */
dest = (bmp_dest_ptr) dest = (bmp_dest_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(bmp_dest_struct)); sizeof(bmp_dest_struct));
dest->pub.start_output = start_output_bmp; dest->pub.start_output = start_output_bmp;
dest->pub.finish_output = finish_output_bmp; dest->pub.finish_output = finish_output_bmp;
dest->is_os2 = is_os2; dest->is_os2 = is_os2;

View File

@@ -1,8 +1,10 @@
/* /*
* wrgif.c * wrgif.c
* *
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1997, Thomas G. Lane. * Copyright (C) 1991-1997, Thomas G. Lane.
* This file is part of the Independent JPEG Group's software. * It was modified by The libjpeg-turbo Project to include only code relevant
* to libjpeg-turbo.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
* This file contains routines to write output images in GIF format. * This file contains routines to write output images in GIF format.
@@ -364,7 +366,7 @@ jinit_write_gif (j_decompress_ptr cinfo)
/* Create module interface object, fill in method pointers */ /* Create module interface object, fill in method pointers */
dest = (gif_dest_ptr) dest = (gif_dest_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(gif_dest_struct)); sizeof(gif_dest_struct));
dest->cinfo = cinfo; /* make back link for subroutines */ dest->cinfo = cinfo; /* make back link for subroutines */
dest->pub.start_output = start_output_gif; dest->pub.start_output = start_output_gif;
dest->pub.put_pixel_rows = put_pixel_rows; dest->pub.put_pixel_rows = put_pixel_rows;

10
wrppm.c
View File

@@ -4,8 +4,8 @@
* This file was part of the Independent JPEG Group's software: * This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1996, Thomas G. Lane. * Copyright (C) 1991-1996, Thomas G. Lane.
* Modified 2009 by Guido Vollbeding. * Modified 2009 by Guido Vollbeding.
* It was modified by The libjpeg-turbo Project to include only information * It was modified by The libjpeg-turbo Project to include only code and
* relevant to libjpeg-turbo. * information relevant to libjpeg-turbo.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
* This file contains routines to write output images in PPM/PGM format. * This file contains routines to write output images in PPM/PGM format.
@@ -221,7 +221,7 @@ jinit_write_ppm (j_decompress_ptr cinfo)
/* Create module interface object, fill in method pointers */ /* Create module interface object, fill in method pointers */
dest = (ppm_dest_ptr) dest = (ppm_dest_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(ppm_dest_struct)); sizeof(ppm_dest_struct));
dest->pub.start_output = start_output_ppm; dest->pub.start_output = start_output_ppm;
dest->pub.finish_output = finish_output_ppm; dest->pub.finish_output = finish_output_ppm;
@@ -230,12 +230,12 @@ jinit_write_ppm (j_decompress_ptr cinfo)
/* Create physical I/O buffer */ /* Create physical I/O buffer */
dest->samples_per_row = cinfo->output_width * cinfo->out_color_components; dest->samples_per_row = cinfo->output_width * cinfo->out_color_components;
dest->buffer_width = dest->samples_per_row * (BYTESPERSAMPLE * SIZEOF(char)); dest->buffer_width = dest->samples_per_row * (BYTESPERSAMPLE * sizeof(char));
dest->iobuffer = (char *) (*cinfo->mem->alloc_small) dest->iobuffer = (char *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, dest->buffer_width); ((j_common_ptr) cinfo, JPOOL_IMAGE, dest->buffer_width);
if (cinfo->quantize_colors || BITS_IN_JSAMPLE != 8 || if (cinfo->quantize_colors || BITS_IN_JSAMPLE != 8 ||
SIZEOF(JSAMPLE) != SIZEOF(char)) { sizeof(JSAMPLE) != sizeof(char)) {
/* When quantizing, we need an output buffer for colormap indexes /* When quantizing, we need an output buffer for colormap indexes
* that's separate from the physical I/O buffer. We also need a * that's separate from the physical I/O buffer. We also need a
* separate buffer if pixel format translation must take place. * separate buffer if pixel format translation must take place.

View File

@@ -115,7 +115,7 @@ start_output_rle (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
if (cinfo->quantize_colors) { if (cinfo->quantize_colors) {
/* Allocate storage for RLE-style cmap, zero any extra entries */ /* Allocate storage for RLE-style cmap, zero any extra entries */
cmapsize = cinfo->out_color_components * CMAPLENGTH * SIZEOF(rle_map); cmapsize = cinfo->out_color_components * CMAPLENGTH * sizeof(rle_map);
dest->colormap = (rle_map *) (*cinfo->mem->alloc_small) dest->colormap = (rle_map *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, cmapsize); ((j_common_ptr) cinfo, JPOOL_IMAGE, cmapsize);
MEMZERO(dest->colormap, cmapsize); MEMZERO(dest->colormap, cmapsize);
@@ -282,7 +282,7 @@ jinit_write_rle (j_decompress_ptr cinfo)
/* Create module interface object, fill in method pointers */ /* Create module interface object, fill in method pointers */
dest = (rle_dest_ptr) dest = (rle_dest_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(rle_dest_struct)); sizeof(rle_dest_struct));
dest->pub.start_output = start_output_rle; dest->pub.start_output = start_output_rle;
dest->pub.finish_output = finish_output_rle; dest->pub.finish_output = finish_output_rle;

View File

@@ -3,8 +3,8 @@
* *
* This file was part of the Independent JPEG Group's software: * This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1996, Thomas G. Lane. * Copyright (C) 1991-1996, Thomas G. Lane.
* It was modified by The libjpeg-turbo Project to include only information * It was modified by The libjpeg-turbo Project to include only code and
* relevant to libjpeg-turbo. * information relevant to libjpeg-turbo.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
* This file contains routines to write output images in Targa format. * This file contains routines to write output images in Targa format.
@@ -50,7 +50,7 @@ write_header (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, int num_colors)
char targaheader[18]; char targaheader[18];
/* Set unused fields of header to 0 */ /* Set unused fields of header to 0 */
MEMZERO(targaheader, SIZEOF(targaheader)); MEMZERO(targaheader, sizeof(targaheader));
if (num_colors > 0) { if (num_colors > 0) {
targaheader[1] = 1; /* color map type 1 */ targaheader[1] = 1; /* color map type 1 */
@@ -222,7 +222,7 @@ jinit_write_targa (j_decompress_ptr cinfo)
/* Create module interface object, fill in method pointers */ /* Create module interface object, fill in method pointers */
dest = (tga_dest_ptr) dest = (tga_dest_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(tga_dest_struct)); sizeof(tga_dest_struct));
dest->pub.start_output = start_output_tga; dest->pub.start_output = start_output_tga;
dest->pub.finish_output = finish_output_tga; dest->pub.finish_output = finish_output_tga;
@@ -233,7 +233,7 @@ jinit_write_targa (j_decompress_ptr cinfo)
dest->buffer_width = cinfo->output_width * cinfo->output_components; dest->buffer_width = cinfo->output_width * cinfo->output_components;
dest->iobuffer = (char *) dest->iobuffer = (char *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(size_t) (dest->buffer_width * SIZEOF(char))); (size_t) (dest->buffer_width * sizeof(char)));
/* Create decompressor output buffer. */ /* Create decompressor output buffer. */
dest->pub.buffer = (*cinfo->mem->alloc_sarray) dest->pub.buffer = (*cinfo->mem->alloc_sarray)