| Index: jdmainct.c
|
| diff --git a/jdmainct.c b/jdmainct.c
|
| index 6bb8c2b0e9252ef8cb6a2c2e59259260159393d4..ebb069b0f4162e8e55e405ca0715017fed2dd8b2 100644
|
| --- a/jdmainct.c
|
| +++ b/jdmainct.c
|
| @@ -4,8 +4,9 @@
|
| * This file was part of the Independent JPEG Group's software:
|
| * Copyright (C) 1994-1996, Thomas G. Lane.
|
| * libjpeg-turbo Modifications:
|
| - * Copyright (C) 2010, D. R. Commander.
|
| - * For conditions of distribution and use, see the accompanying README file.
|
| + * Copyright (C) 2010, 2016, D. R. Commander.
|
| + * For conditions of distribution and use, see the accompanying README.ijg
|
| + * file.
|
| *
|
| * This file contains the main buffer controller for decompression.
|
| * The main buffer lies between the JPEG decompressor proper and the
|
| @@ -15,6 +16,7 @@
|
| * supplies the equivalent of the main buffer in that case.
|
| */
|
|
|
| +#include "jinclude.h"
|
| #include "jdmainct.h"
|
|
|
|
|
| @@ -111,15 +113,15 @@
|
|
|
| /* Forward declarations */
|
| METHODDEF(void) process_data_simple_main
|
| - JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
| - JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail));
|
| + (j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
| + JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
|
| METHODDEF(void) process_data_context_main
|
| - JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
| - JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail));
|
| + (j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
| + JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
|
| #ifdef QUANT_2PASS_SUPPORTED
|
| METHODDEF(void) process_data_crank_post
|
| - JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
| - JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail));
|
| + (j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
| + JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
|
| #endif
|
|
|
|
|
| @@ -140,7 +142,7 @@ alloc_funny_pointers (j_decompress_ptr cinfo)
|
| */
|
| main_ptr->xbuffer[0] = (JSAMPIMAGE)
|
| (*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;
|
|
|
| for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
| @@ -152,8 +154,8 @@ alloc_funny_pointers (j_decompress_ptr cinfo)
|
| */
|
| xbuf = (JSAMPARRAY)
|
| (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
| - 2 * (rgroup * (M + 4)) * SIZEOF(JSAMPROW));
|
| - xbuf += rgroup; /* want one row group at negative offsets */
|
| + 2 * (rgroup * (M + 4)) * sizeof(JSAMPROW));
|
| + xbuf += rgroup; /* want one row group at negative offsets */
|
| main_ptr->xbuffer[0][ci] = xbuf;
|
| xbuf += rgroup * (M + 4);
|
| main_ptr->xbuffer[1][ci] = xbuf;
|
| @@ -255,14 +257,14 @@ start_pass_main (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
|
| if (cinfo->upsample->need_context_rows) {
|
| main_ptr->pub.process_data = process_data_context_main;
|
| make_funny_pointers(cinfo); /* Create the xbuffer[] lists */
|
| - main_ptr->whichptr = 0; /* Read first iMCU row into xbuffer[0] */
|
| + main_ptr->whichptr = 0; /* Read first iMCU row into xbuffer[0] */
|
| main_ptr->context_state = CTX_PREPARE_FOR_IMCU;
|
| main_ptr->iMCU_row_ctr = 0;
|
| } else {
|
| /* Simple case with no context needed */
|
| main_ptr->pub.process_data = process_data_simple_main;
|
| }
|
| - main_ptr->buffer_full = FALSE; /* Mark buffer empty */
|
| + main_ptr->buffer_full = FALSE; /* Mark buffer empty */
|
| main_ptr->rowgroup_ctr = 0;
|
| break;
|
| #ifdef QUANT_2PASS_SUPPORTED
|
| @@ -285,8 +287,8 @@ start_pass_main (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
|
|
|
| METHODDEF(void)
|
| process_data_simple_main (j_decompress_ptr cinfo,
|
| - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
| - JDIMENSION out_rows_avail)
|
| + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
| + JDIMENSION out_rows_avail)
|
| {
|
| my_main_ptr main_ptr = (my_main_ptr) cinfo->main;
|
| JDIMENSION rowgroups_avail;
|
| @@ -294,8 +296,8 @@ process_data_simple_main (j_decompress_ptr cinfo,
|
| /* Read input data if we haven't filled the main buffer yet */
|
| if (! main_ptr->buffer_full) {
|
| if (! (*cinfo->coef->decompress_data) (cinfo, main_ptr->buffer))
|
| - return; /* suspension forced, can do nothing more */
|
| - main_ptr->buffer_full = TRUE; /* OK, we have an iMCU row to work with */
|
| + return; /* suspension forced, can do nothing more */
|
| + main_ptr->buffer_full = TRUE; /* OK, we have an iMCU row to work with */
|
| }
|
|
|
| /* There are always min_DCT_scaled_size row groups in an iMCU row. */
|
| @@ -307,8 +309,8 @@ process_data_simple_main (j_decompress_ptr cinfo,
|
|
|
| /* Feed the postprocessor */
|
| (*cinfo->post->post_process_data) (cinfo, main_ptr->buffer,
|
| - &main_ptr->rowgroup_ctr, rowgroups_avail,
|
| - output_buf, out_row_ctr, out_rows_avail);
|
| + &main_ptr->rowgroup_ctr, rowgroups_avail,
|
| + output_buf, out_row_ctr, out_rows_avail);
|
|
|
| /* Has postprocessor consumed all the data yet? If so, mark buffer empty */
|
| if (main_ptr->rowgroup_ctr >= rowgroups_avail) {
|
| @@ -325,18 +327,18 @@ process_data_simple_main (j_decompress_ptr cinfo,
|
|
|
| METHODDEF(void)
|
| process_data_context_main (j_decompress_ptr cinfo,
|
| - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
| - JDIMENSION out_rows_avail)
|
| + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
| + JDIMENSION out_rows_avail)
|
| {
|
| my_main_ptr main_ptr = (my_main_ptr) cinfo->main;
|
|
|
| /* Read input data if we haven't filled the main buffer yet */
|
| if (! main_ptr->buffer_full) {
|
| if (! (*cinfo->coef->decompress_data) (cinfo,
|
| - main_ptr->xbuffer[main_ptr->whichptr]))
|
| - return; /* suspension forced, can do nothing more */
|
| - main_ptr->buffer_full = TRUE; /* OK, we have an iMCU row to work with */
|
| - main_ptr->iMCU_row_ctr++; /* count rows received */
|
| + main_ptr->xbuffer[main_ptr->whichptr]))
|
| + return; /* suspension forced, can do nothing more */
|
| + main_ptr->buffer_full = TRUE; /* OK, we have an iMCU row to work with */
|
| + main_ptr->iMCU_row_ctr++; /* count rows received */
|
| }
|
|
|
| /* Postprocessor typically will not swallow all the input data it is handed
|
| @@ -348,13 +350,13 @@ process_data_context_main (j_decompress_ptr cinfo,
|
| case CTX_POSTPONED_ROW:
|
| /* Call postprocessor using previously set pointers for postponed row */
|
| (*cinfo->post->post_process_data) (cinfo, main_ptr->xbuffer[main_ptr->whichptr],
|
| - &main_ptr->rowgroup_ctr, main_ptr->rowgroups_avail,
|
| - output_buf, out_row_ctr, out_rows_avail);
|
| + &main_ptr->rowgroup_ctr, main_ptr->rowgroups_avail,
|
| + output_buf, out_row_ctr, out_rows_avail);
|
| if (main_ptr->rowgroup_ctr < main_ptr->rowgroups_avail)
|
| - return; /* Need to suspend */
|
| + return; /* Need to suspend */
|
| main_ptr->context_state = CTX_PREPARE_FOR_IMCU;
|
| if (*out_row_ctr >= out_rows_avail)
|
| - return; /* Postprocessor exactly filled output buf */
|
| + return; /* Postprocessor exactly filled output buf */
|
| /*FALLTHROUGH*/
|
| case CTX_PREPARE_FOR_IMCU:
|
| /* Prepare to process first M-1 row groups of this iMCU row */
|
| @@ -370,15 +372,15 @@ process_data_context_main (j_decompress_ptr cinfo,
|
| case CTX_PROCESS_IMCU:
|
| /* Call postprocessor using previously set pointers */
|
| (*cinfo->post->post_process_data) (cinfo, main_ptr->xbuffer[main_ptr->whichptr],
|
| - &main_ptr->rowgroup_ctr, main_ptr->rowgroups_avail,
|
| - output_buf, out_row_ctr, out_rows_avail);
|
| + &main_ptr->rowgroup_ctr, main_ptr->rowgroups_avail,
|
| + output_buf, out_row_ctr, out_rows_avail);
|
| if (main_ptr->rowgroup_ctr < main_ptr->rowgroups_avail)
|
| - return; /* Need to suspend */
|
| + return; /* Need to suspend */
|
| /* After the first iMCU, change wraparound pointers to normal state */
|
| if (main_ptr->iMCU_row_ctr == 1)
|
| set_wraparound_pointers(cinfo);
|
| /* Prepare to load new iMCU row using other xbuffer list */
|
| - main_ptr->whichptr ^= 1; /* 0=>1 or 1=>0 */
|
| + main_ptr->whichptr ^= 1; /* 0=>1 or 1=>0 */
|
| main_ptr->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 */
|
| @@ -399,12 +401,12 @@ process_data_context_main (j_decompress_ptr cinfo,
|
|
|
| METHODDEF(void)
|
| process_data_crank_post (j_decompress_ptr cinfo,
|
| - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
| - JDIMENSION out_rows_avail)
|
| + JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
| + JDIMENSION out_rows_avail)
|
| {
|
| (*cinfo->post->post_process_data) (cinfo, (JSAMPIMAGE) NULL,
|
| - (JDIMENSION *) NULL, (JDIMENSION) 0,
|
| - output_buf, out_row_ctr, out_rows_avail);
|
| + (JDIMENSION *) NULL, (JDIMENSION) 0,
|
| + output_buf, out_row_ctr, out_rows_avail);
|
| }
|
|
|
| #endif /* QUANT_2PASS_SUPPORTED */
|
| @@ -423,11 +425,11 @@ jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
|
|
| main_ptr = (my_main_ptr)
|
| (*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;
|
| main_ptr->pub.start_pass = start_pass_main;
|
|
|
| - if (need_full_buffer) /* shouldn't happen */
|
| + if (need_full_buffer) /* shouldn't happen */
|
| ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
|
|
| /* Allocate the workspace.
|
| @@ -447,8 +449,8 @@ jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
| rgroup = (compptr->v_samp_factor * compptr->_DCT_scaled_size) /
|
| cinfo->_min_DCT_scaled_size; /* height of a row group of component */
|
| main_ptr->buffer[ci] = (*cinfo->mem->alloc_sarray)
|
| - ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
| - compptr->width_in_blocks * compptr->_DCT_scaled_size,
|
| - (JDIMENSION) (rgroup * ngroups));
|
| + ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
| + compptr->width_in_blocks * compptr->_DCT_scaled_size,
|
| + (JDIMENSION) (rgroup * ngroups));
|
| }
|
| }
|
|
|