Skip to content

Commit

Permalink
Improve readability and flexibility of compatibility macros
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@241 632fc199-4ca6-4c93-a231-07263d6284db
  • Loading branch information
dcommander committed Oct 9, 2010
1 parent 10acd81 commit 49967cd
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 58 deletions.
2 changes: 1 addition & 1 deletion jdapistd.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data,
}

/* Verify that at least one iMCU row can be returned. */
lines_per_iMCU_row = cinfo->max_v_samp_factor * _min_DCT_scaled_size;
lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->_min_DCT_scaled_size;
if (max_lines < lines_per_iMCU_row)
ERREXIT(cinfo, JERR_BUFFER_SIZE);

Expand Down
14 changes: 7 additions & 7 deletions jdcoefct.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
useful_width = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
: compptr->last_col_width;
output_ptr = output_buf[compptr->component_index] +
yoffset * _DCT_scaled_size;
yoffset * compptr->_DCT_scaled_size;
start_col = MCU_col_num * compptr->MCU_sample_width;
for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
if (cinfo->input_iMCU_row < last_iMCU_row ||
Expand All @@ -202,11 +202,11 @@ decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
(*inverse_DCT) (cinfo, compptr,
(JCOEFPTR) coef->MCU_buffer[blkn+xindex],
output_ptr, output_col);
output_col += _DCT_scaled_size;
output_col += compptr->_DCT_scaled_size;
}
}
blkn += compptr->MCU_width;
output_ptr += _DCT_scaled_size;
output_ptr += compptr->_DCT_scaled_size;
}
}
}
Expand Down Expand Up @@ -367,9 +367,9 @@ decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
(*inverse_DCT) (cinfo, compptr, (JCOEFPTR) buffer_ptr,
output_ptr, output_col);
buffer_ptr++;
output_col += _DCT_scaled_size;
output_col += compptr->_DCT_scaled_size;
}
output_ptr += _DCT_scaled_size;
output_ptr += compptr->_DCT_scaled_size;
}
}

Expand Down Expand Up @@ -662,9 +662,9 @@ decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
DC4 = DC5; DC5 = DC6;
DC7 = DC8; DC8 = DC9;
buffer_ptr++, prev_block_row++, next_block_row++;
output_col += _DCT_scaled_size;
output_col += compptr->_DCT_scaled_size;
}
output_ptr += _DCT_scaled_size;
output_ptr += compptr->_DCT_scaled_size;
}
}

Expand Down
4 changes: 2 additions & 2 deletions jddctmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ start_pass (j_decompress_ptr cinfo)
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
/* Select the proper IDCT routine for this component's scaling */
switch (_DCT_scaled_size) {
switch (compptr->_DCT_scaled_size) {
#ifdef IDCT_SCALING_SUPPORTED
case 1:
method_ptr = jpeg_idct_1x1;
Expand Down Expand Up @@ -158,7 +158,7 @@ start_pass (j_decompress_ptr cinfo)
}
break;
default:
ERREXIT1(cinfo, JERR_BAD_DCTSIZE, _DCT_scaled_size);
ERREXIT1(cinfo, JERR_BAD_DCTSIZE, compptr->_DCT_scaled_size);
break;
}
idct->pub.inverse_DCT[ci] = method_ptr;
Expand Down
2 changes: 1 addition & 1 deletion jdhuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ start_pass_huff_decoder (j_decompress_ptr cinfo)
if (compptr->component_needed) {
entropy->dc_needed[blkn] = TRUE;
/* we don't need the ACs if producing a 1/8th-size image */
entropy->ac_needed[blkn] = (_DCT_scaled_size > 1);
entropy->ac_needed[blkn] = (compptr->_DCT_scaled_size > 1);
} else {
entropy->dc_needed[blkn] = entropy->ac_needed[blkn] = FALSE;
}
Expand Down
4 changes: 2 additions & 2 deletions jdinput.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ per_scan_setup (j_decompress_ptr cinfo)
compptr->MCU_width = 1;
compptr->MCU_height = 1;
compptr->MCU_blocks = 1;
compptr->MCU_sample_width = _DCT_scaled_size;
compptr->MCU_sample_width = compptr->_DCT_scaled_size;
compptr->last_col_width = 1;
/* For noninterleaved scans, it is convenient to define last_row_height
* as the number of block rows present in the last iMCU row.
Expand Down Expand Up @@ -264,7 +264,7 @@ per_scan_setup (j_decompress_ptr cinfo)
compptr->MCU_width = compptr->h_samp_factor;
compptr->MCU_height = compptr->v_samp_factor;
compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height;
compptr->MCU_sample_width = compptr->MCU_width * _DCT_scaled_size;
compptr->MCU_sample_width = compptr->MCU_width * compptr->_DCT_scaled_size;
/* Figure number of non-dummy blocks in last MCU column & row */
tmp = (int) (compptr->width_in_blocks % compptr->MCU_width);
if (tmp == 0) tmp = compptr->MCU_width;
Expand Down
42 changes: 21 additions & 21 deletions jdmainct.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ alloc_funny_pointers (j_decompress_ptr cinfo)
{
my_main_ptr main = (my_main_ptr) cinfo->main;
int ci, rgroup;
int M = _min_DCT_scaled_size;
int M = cinfo->_min_DCT_scaled_size;
jpeg_component_info *compptr;
JSAMPARRAY xbuf;

Expand All @@ -177,8 +177,8 @@ alloc_funny_pointers (j_decompress_ptr cinfo)

for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
rgroup = (compptr->v_samp_factor * _DCT_scaled_size) /
_min_DCT_scaled_size; /* height of a row group of component */
rgroup = (compptr->v_samp_factor * compptr->_DCT_scaled_size) /
cinfo->_min_DCT_scaled_size; /* height of a row group of component */
/* Get space for pointer lists --- M+4 row groups in each list.
* We alloc both pointer lists with one call to save a few cycles.
*/
Expand All @@ -204,14 +204,14 @@ make_funny_pointers (j_decompress_ptr cinfo)
{
my_main_ptr main = (my_main_ptr) cinfo->main;
int ci, i, rgroup;
int M = _min_DCT_scaled_size;
int M = cinfo->_min_DCT_scaled_size;
jpeg_component_info *compptr;
JSAMPARRAY buf, xbuf0, xbuf1;

for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
rgroup = (compptr->v_samp_factor * _DCT_scaled_size) /
_min_DCT_scaled_size; /* height of a row group of component */
rgroup = (compptr->v_samp_factor * compptr->_DCT_scaled_size) /
cinfo->_min_DCT_scaled_size; /* height of a row group of component */
xbuf0 = main->xbuffer[0][ci];
xbuf1 = main->xbuffer[1][ci];
/* First copy the workspace pointers as-is */
Expand Down Expand Up @@ -244,14 +244,14 @@ set_wraparound_pointers (j_decompress_ptr cinfo)
{
my_main_ptr main = (my_main_ptr) cinfo->main;
int ci, i, rgroup;
int M = _min_DCT_scaled_size;
int M = cinfo->_min_DCT_scaled_size;
jpeg_component_info *compptr;
JSAMPARRAY xbuf0, xbuf1;

for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
rgroup = (compptr->v_samp_factor * _DCT_scaled_size) /
_min_DCT_scaled_size; /* height of a row group of component */
rgroup = (compptr->v_samp_factor * compptr->_DCT_scaled_size) /
cinfo->_min_DCT_scaled_size; /* height of a row group of component */
xbuf0 = main->xbuffer[0][ci];
xbuf1 = main->xbuffer[1][ci];
for (i = 0; i < rgroup; i++) {
Expand Down Expand Up @@ -279,8 +279,8 @@ set_bottom_pointers (j_decompress_ptr cinfo)
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
/* Count sample rows in one iMCU row and in one row group */
iMCUheight = compptr->v_samp_factor * _DCT_scaled_size;
rgroup = iMCUheight / _min_DCT_scaled_size;
iMCUheight = compptr->v_samp_factor * compptr->_DCT_scaled_size;
rgroup = iMCUheight / cinfo->_min_DCT_scaled_size;
/* Count nondummy sample rows remaining for this component */
rows_left = (int) (compptr->downsampled_height % (JDIMENSION) iMCUheight);
if (rows_left == 0) rows_left = iMCUheight;
Expand Down Expand Up @@ -359,7 +359,7 @@ process_data_simple_main (j_decompress_ptr cinfo,
}

/* There are always min_DCT_scaled_size row groups in an iMCU row. */
rowgroups_avail = (JDIMENSION) _min_DCT_scaled_size;
rowgroups_avail = (JDIMENSION) cinfo->_min_DCT_scaled_size;
/* Note: at the bottom of the image, we may pass extra garbage row groups
* to the postprocessor. The postprocessor has to check for bottom
* of image anyway (at row resolution), so no point in us doing it too.
Expand Down Expand Up @@ -419,7 +419,7 @@ process_data_context_main (j_decompress_ptr cinfo,
case CTX_PREPARE_FOR_IMCU:
/* Prepare to process first M-1 row groups of this iMCU row */
main->rowgroup_ctr = 0;
main->rowgroups_avail = (JDIMENSION) (_min_DCT_scaled_size - 1);
main->rowgroups_avail = (JDIMENSION) (cinfo->_min_DCT_scaled_size - 1);
/* Check for bottom of image: if so, tweak pointers to "duplicate"
* the last sample row, and adjust rowgroups_avail to ignore padding rows.
*/
Expand All @@ -442,8 +442,8 @@ process_data_context_main (j_decompress_ptr cinfo,
main->buffer_full = FALSE;
/* Still need to process last row group of this iMCU row, */
/* which is saved at index M+1 of the other xbuffer */
main->rowgroup_ctr = (JDIMENSION) (_min_DCT_scaled_size + 1);
main->rowgroups_avail = (JDIMENSION) (_min_DCT_scaled_size + 2);
main->rowgroup_ctr = (JDIMENSION) (cinfo->_min_DCT_scaled_size + 1);
main->rowgroups_avail = (JDIMENSION) (cinfo->_min_DCT_scaled_size + 2);
main->context_state = CTX_POSTPONED_ROW;
}
}
Expand Down Expand Up @@ -494,21 +494,21 @@ jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
* ngroups is the number of row groups we need.
*/
if (cinfo->upsample->need_context_rows) {
if (_min_DCT_scaled_size < 2) /* unsupported, see comments above */
if (cinfo->_min_DCT_scaled_size < 2) /* unsupported, see comments above */
ERREXIT(cinfo, JERR_NOTIMPL);
alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */
ngroups = _min_DCT_scaled_size + 2;
ngroups = cinfo->_min_DCT_scaled_size + 2;
} else {
ngroups = _min_DCT_scaled_size;
ngroups = cinfo->_min_DCT_scaled_size;
}

for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
rgroup = (compptr->v_samp_factor * _DCT_scaled_size) /
_min_DCT_scaled_size; /* height of a row group of component */
rgroup = (compptr->v_samp_factor * compptr->_DCT_scaled_size) /
cinfo->_min_DCT_scaled_size; /* height of a row group of component */
main->buffer[ci] = (*cinfo->mem->alloc_sarray)
((j_common_ptr) cinfo, JPOOL_IMAGE,
compptr->width_in_blocks * _DCT_scaled_size,
compptr->width_in_blocks * compptr->_DCT_scaled_size,
(JDIMENSION) (rgroup * ngroups));
}
}
23 changes: 8 additions & 15 deletions jdmaster.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,10 @@ use_merged_upsample (j_decompress_ptr cinfo)
cinfo->comp_info[2].v_samp_factor != 1)
return FALSE;
/* furthermore, it doesn't work if we've scaled the IDCTs differently */
#if JPEG_LIB_VERSION >= 70
if (cinfo->comp_info[0].DCT_h_scaled_size != cinfo->min_DCT_h_scaled_size ||
cinfo->comp_info[1].DCT_h_scaled_size != cinfo->min_DCT_h_scaled_size ||
cinfo->comp_info[2].DCT_h_scaled_size != cinfo->min_DCT_h_scaled_size)
return FALSE;
#else
if (cinfo->comp_info[0].DCT_scaled_size != cinfo->min_DCT_scaled_size ||
cinfo->comp_info[1].DCT_scaled_size != cinfo->min_DCT_scaled_size ||
cinfo->comp_info[2].DCT_scaled_size != cinfo->min_DCT_scaled_size)
if (cinfo->comp_info[0]._DCT_scaled_size != cinfo->_min_DCT_scaled_size ||
cinfo->comp_info[1]._DCT_scaled_size != cinfo->_min_DCT_scaled_size ||
cinfo->comp_info[2]._DCT_scaled_size != cinfo->_min_DCT_scaled_size)
return FALSE;
#endif
/* ??? also need to test for upsample-time rescaling, when & if supported */
return TRUE; /* by golly, it'll work... */
#else
Expand Down Expand Up @@ -161,12 +154,12 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
*/
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
int ssize = _min_DCT_scaled_size;
int ssize = cinfo->_min_DCT_scaled_size;
while (ssize < DCTSIZE &&
(compptr->h_samp_factor * ssize * 2 <=
cinfo->max_h_samp_factor * _min_DCT_scaled_size) &&
cinfo->max_h_samp_factor * cinfo->_min_DCT_scaled_size) &&
(compptr->v_samp_factor * ssize * 2 <=
cinfo->max_v_samp_factor * _min_DCT_scaled_size)) {
cinfo->max_v_samp_factor * cinfo->_min_DCT_scaled_size)) {
ssize = ssize * 2;
}
#if JPEG_LIB_VERSION >= 70
Expand All @@ -184,11 +177,11 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
/* Size in samples, after IDCT scaling */
compptr->downsampled_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width *
(long) (compptr->h_samp_factor * _DCT_scaled_size),
(long) (compptr->h_samp_factor * compptr->_DCT_scaled_size),
(long) (cinfo->max_h_samp_factor * DCTSIZE));
compptr->downsampled_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height *
(long) (compptr->v_samp_factor * _DCT_scaled_size),
(long) (compptr->v_samp_factor * compptr->_DCT_scaled_size),
(long) (cinfo->max_v_samp_factor * DCTSIZE));
}

Expand Down
10 changes: 5 additions & 5 deletions jdsample.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ jinit_upsampler (j_decompress_ptr cinfo)
/* jdmainct.c doesn't support context rows when min_DCT_scaled_size = 1,
* so don't ask for it.
*/
do_fancy = cinfo->do_fancy_upsampling && _min_DCT_scaled_size > 1;
do_fancy = cinfo->do_fancy_upsampling && cinfo->_min_DCT_scaled_size > 1;

/* Verify we can handle the sampling factors, select per-component methods,
* and create storage as needed.
Expand All @@ -432,10 +432,10 @@ jinit_upsampler (j_decompress_ptr cinfo)
/* Compute size of an "input group" after IDCT scaling. This many samples
* are to be converted to max_h_samp_factor * max_v_samp_factor pixels.
*/
h_in_group = (compptr->h_samp_factor * _DCT_scaled_size) /
_min_DCT_scaled_size;
v_in_group = (compptr->v_samp_factor * _DCT_scaled_size) /
_min_DCT_scaled_size;
h_in_group = (compptr->h_samp_factor * compptr->_DCT_scaled_size) /
cinfo->_min_DCT_scaled_size;
v_in_group = (compptr->v_samp_factor * compptr->_DCT_scaled_size) /
cinfo->_min_DCT_scaled_size;
h_out_group = cinfo->max_h_samp_factor;
v_out_group = cinfo->max_v_samp_factor;
upsample->rowgroup_height[ci] = v_in_group; /* save for use later */
Expand Down
8 changes: 4 additions & 4 deletions jpegcomp.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
*/

#if JPEG_LIB_VERSION >= 70
#define _DCT_scaled_size compptr->DCT_h_scaled_size
#define _min_DCT_scaled_size cinfo->min_DCT_h_scaled_size
#define _DCT_scaled_size DCT_h_scaled_size
#define _min_DCT_scaled_size min_DCT_h_scaled_size
#else
#define _DCT_scaled_size compptr->DCT_scaled_size
#define _min_DCT_scaled_size cinfo->min_DCT_scaled_size
#define _DCT_scaled_size DCT_scaled_size
#define _min_DCT_scaled_size min_DCT_scaled_size
#endif

0 comments on commit 49967cd

Please sign in to comment.