| Index: jctrans.c
|
| diff --git a/jctrans.c b/jctrans.c
|
| index 916e872faf063a0215e2fdef3a354f2ec601bd17..6f16b052cf564e8d3bee552f533ebe4bc4b713c7 100644
|
| --- a/jctrans.c
|
| +++ b/jctrans.c
|
| @@ -1,10 +1,13 @@
|
| /*
|
| * jctrans.c
|
| *
|
| + * This file was part of the Independent JPEG Group's software:
|
| * Copyright (C) 1995-1998, Thomas G. Lane.
|
| * Modified 2000-2009 by Guido Vollbeding.
|
| - * This file is part of the Independent JPEG Group's software.
|
| - * For conditions of distribution and use, see the accompanying README file.
|
| + * 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.ijg
|
| + * file.
|
| *
|
| * This file contains library routines for transcoding compression,
|
| * that is, writing raw DCT coefficient arrays to an output JPEG file.
|
| @@ -18,9 +21,9 @@
|
|
|
| /* Forward declarations */
|
| LOCAL(void) transencode_master_selection
|
| - JPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays));
|
| + (j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays);
|
| LOCAL(void) transencode_coef_controller
|
| - JPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays));
|
| + (j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays);
|
|
|
|
|
| /*
|
| @@ -36,7 +39,7 @@ LOCAL(void) transencode_coef_controller
|
| */
|
|
|
| GLOBAL(void)
|
| -jpeg_write_coefficients (j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays)
|
| +jpeg_write_coefficients (j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays)
|
| {
|
| if (cinfo->global_state != CSTATE_START)
|
| ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
| @@ -48,7 +51,7 @@ jpeg_write_coefficients (j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays)
|
| /* Perform master selection of active modules */
|
| transencode_master_selection(cinfo, coef_arrays);
|
| /* Wait for jpeg_finish_compress() call */
|
| - cinfo->next_scanline = 0; /* so jpeg_write_marker works */
|
| + cinfo->next_scanline = 0; /* so jpeg_write_marker works */
|
| cinfo->global_state = CSTATE_WRCOEFS;
|
| }
|
|
|
| @@ -62,9 +65,9 @@ jpeg_write_coefficients (j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays)
|
|
|
| GLOBAL(void)
|
| jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
|
| - j_compress_ptr dstinfo)
|
| + j_compress_ptr dstinfo)
|
| {
|
| - JQUANT_TBL ** qtblptr;
|
| + JQUANT_TBL **qtblptr;
|
| jpeg_component_info *incomp, *outcomp;
|
| JQUANT_TBL *c_quant, *slot_quant;
|
| int tblno, ci, coefi;
|
| @@ -96,10 +99,10 @@ jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
|
| if (srcinfo->quant_tbl_ptrs[tblno] != NULL) {
|
| qtblptr = & dstinfo->quant_tbl_ptrs[tblno];
|
| if (*qtblptr == NULL)
|
| - *qtblptr = jpeg_alloc_quant_table((j_common_ptr) dstinfo);
|
| + *qtblptr = jpeg_alloc_quant_table((j_common_ptr) dstinfo);
|
| MEMCOPY((*qtblptr)->quantval,
|
| - srcinfo->quant_tbl_ptrs[tblno]->quantval,
|
| - SIZEOF((*qtblptr)->quantval));
|
| + srcinfo->quant_tbl_ptrs[tblno]->quantval,
|
| + sizeof((*qtblptr)->quantval));
|
| (*qtblptr)->sent_table = FALSE;
|
| }
|
| }
|
| @@ -109,7 +112,7 @@ jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
|
| dstinfo->num_components = srcinfo->num_components;
|
| if (dstinfo->num_components < 1 || dstinfo->num_components > MAX_COMPONENTS)
|
| ERREXIT2(dstinfo, JERR_COMPONENT_COUNT, dstinfo->num_components,
|
| - MAX_COMPONENTS);
|
| + MAX_COMPONENTS);
|
| for (ci = 0, incomp = srcinfo->comp_info, outcomp = dstinfo->comp_info;
|
| ci < dstinfo->num_components; ci++, incomp++, outcomp++) {
|
| outcomp->component_id = incomp->component_id;
|
| @@ -122,14 +125,14 @@ jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
|
| */
|
| tblno = outcomp->quant_tbl_no;
|
| if (tblno < 0 || tblno >= NUM_QUANT_TBLS ||
|
| - srcinfo->quant_tbl_ptrs[tblno] == NULL)
|
| + srcinfo->quant_tbl_ptrs[tblno] == NULL)
|
| ERREXIT1(dstinfo, JERR_NO_QUANT_TABLE, tblno);
|
| slot_quant = srcinfo->quant_tbl_ptrs[tblno];
|
| c_quant = incomp->quant_table;
|
| if (c_quant != NULL) {
|
| for (coefi = 0; coefi < DCTSIZE2; coefi++) {
|
| - if (c_quant->quantval[coefi] != slot_quant->quantval[coefi])
|
| - ERREXIT1(dstinfo, JERR_MISMATCHED_QUANT_TABLE, tblno);
|
| + if (c_quant->quantval[coefi] != slot_quant->quantval[coefi])
|
| + ERREXIT1(dstinfo, JERR_MISMATCHED_QUANT_TABLE, tblno);
|
| }
|
| }
|
| /* Note: we do not copy the source's Huffman table assignments;
|
| @@ -163,7 +166,7 @@ jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
|
|
|
| LOCAL(void)
|
| transencode_master_selection (j_compress_ptr cinfo,
|
| - jvirt_barray_ptr * coef_arrays)
|
| + jvirt_barray_ptr *coef_arrays)
|
| {
|
| /* Although we don't actually use input_components for transcoding,
|
| * jcmaster.c's initial_setup will complain if input_components is 0.
|
| @@ -219,19 +222,19 @@ transencode_master_selection (j_compress_ptr cinfo,
|
| typedef struct {
|
| struct jpeg_c_coef_controller pub; /* public fields */
|
|
|
| - JDIMENSION iMCU_row_num; /* iMCU row # within image */
|
| - JDIMENSION mcu_ctr; /* counts MCUs processed in current row */
|
| - int MCU_vert_offset; /* counts MCU rows within iMCU row */
|
| - int MCU_rows_per_iMCU_row; /* number of such rows needed */
|
| + JDIMENSION iMCU_row_num; /* iMCU row # within image */
|
| + JDIMENSION mcu_ctr; /* counts MCUs processed in current row */
|
| + int MCU_vert_offset; /* counts MCU rows within iMCU row */
|
| + int MCU_rows_per_iMCU_row; /* number of such rows needed */
|
|
|
| /* Virtual block array for each component. */
|
| - jvirt_barray_ptr * whole_image;
|
| + jvirt_barray_ptr *whole_image;
|
|
|
| /* Workspace for constructing dummy blocks at right/bottom edges. */
|
| JBLOCKROW dummy_buffer[C_MAX_BLOCKS_IN_MCU];
|
| } my_coef_controller;
|
|
|
| -typedef my_coef_controller * my_coef_ptr;
|
| +typedef my_coef_controller *my_coef_ptr;
|
|
|
|
|
| LOCAL(void)
|
| @@ -289,7 +292,7 @@ METHODDEF(boolean)
|
| compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
| {
|
| my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
| - JDIMENSION MCU_col_num; /* index of current MCU within row */
|
| + JDIMENSION MCU_col_num; /* index of current MCU within row */
|
| JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
|
| JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
|
| int blkn, ci, xindex, yindex, yoffset, blockcnt;
|
| @@ -312,44 +315,44 @@ compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
| for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
|
| yoffset++) {
|
| for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row;
|
| - MCU_col_num++) {
|
| + MCU_col_num++) {
|
| /* Construct list of pointers to DCT blocks belonging to this MCU */
|
| - blkn = 0; /* index of current DCT block within MCU */
|
| + blkn = 0; /* index of current DCT block within MCU */
|
| for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
| - compptr = cinfo->cur_comp_info[ci];
|
| - start_col = MCU_col_num * compptr->MCU_width;
|
| - blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
|
| - : compptr->last_col_width;
|
| - for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
|
| - if (coef->iMCU_row_num < last_iMCU_row ||
|
| - yindex+yoffset < compptr->last_row_height) {
|
| - /* Fill in pointers to real blocks in this row */
|
| - buffer_ptr = buffer[ci][yindex+yoffset] + start_col;
|
| - for (xindex = 0; xindex < blockcnt; xindex++)
|
| - MCU_buffer[blkn++] = buffer_ptr++;
|
| - } else {
|
| - /* At bottom of image, need a whole row of dummy blocks */
|
| - xindex = 0;
|
| - }
|
| - /* Fill in any dummy blocks needed in this row.
|
| - * Dummy blocks are filled in the same way as in jccoefct.c:
|
| - * all zeroes in the AC entries, DC entries equal to previous
|
| - * block's DC value. The init routine has already zeroed the
|
| - * AC entries, so we need only set the DC entries correctly.
|
| - */
|
| - for (; xindex < compptr->MCU_width; xindex++) {
|
| - MCU_buffer[blkn] = coef->dummy_buffer[blkn];
|
| - MCU_buffer[blkn][0][0] = MCU_buffer[blkn-1][0][0];
|
| - blkn++;
|
| - }
|
| - }
|
| + compptr = cinfo->cur_comp_info[ci];
|
| + start_col = MCU_col_num * compptr->MCU_width;
|
| + blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
|
| + : compptr->last_col_width;
|
| + for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
|
| + if (coef->iMCU_row_num < last_iMCU_row ||
|
| + yindex+yoffset < compptr->last_row_height) {
|
| + /* Fill in pointers to real blocks in this row */
|
| + buffer_ptr = buffer[ci][yindex+yoffset] + start_col;
|
| + for (xindex = 0; xindex < blockcnt; xindex++)
|
| + MCU_buffer[blkn++] = buffer_ptr++;
|
| + } else {
|
| + /* At bottom of image, need a whole row of dummy blocks */
|
| + xindex = 0;
|
| + }
|
| + /* Fill in any dummy blocks needed in this row.
|
| + * Dummy blocks are filled in the same way as in jccoefct.c:
|
| + * all zeroes in the AC entries, DC entries equal to previous
|
| + * block's DC value. The init routine has already zeroed the
|
| + * AC entries, so we need only set the DC entries correctly.
|
| + */
|
| + for (; xindex < compptr->MCU_width; xindex++) {
|
| + MCU_buffer[blkn] = coef->dummy_buffer[blkn];
|
| + MCU_buffer[blkn][0][0] = MCU_buffer[blkn-1][0][0];
|
| + blkn++;
|
| + }
|
| + }
|
| }
|
| /* Try to write the MCU. */
|
| if (! (*cinfo->entropy->encode_mcu) (cinfo, MCU_buffer)) {
|
| - /* Suspension forced; update state counters and exit */
|
| - coef->MCU_vert_offset = yoffset;
|
| - coef->mcu_ctr = MCU_col_num;
|
| - return FALSE;
|
| + /* Suspension forced; update state counters and exit */
|
| + coef->MCU_vert_offset = yoffset;
|
| + coef->mcu_ctr = MCU_col_num;
|
| + return FALSE;
|
| }
|
| }
|
| /* Completed an MCU row, but perhaps not an iMCU row */
|
| @@ -372,7 +375,7 @@ compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
|
|
| LOCAL(void)
|
| transencode_coef_controller (j_compress_ptr cinfo,
|
| - jvirt_barray_ptr * coef_arrays)
|
| + jvirt_barray_ptr *coef_arrays)
|
| {
|
| my_coef_ptr coef;
|
| JBLOCKROW buffer;
|
| @@ -380,7 +383,7 @@ transencode_coef_controller (j_compress_ptr cinfo,
|
|
|
| coef = (my_coef_ptr)
|
| (*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;
|
| coef->pub.start_pass = start_pass_coef;
|
| coef->pub.compress_data = compress_output;
|
| @@ -391,8 +394,8 @@ transencode_coef_controller (j_compress_ptr cinfo,
|
| /* Allocate and pre-zero space for dummy DCT blocks. */
|
| buffer = (JBLOCKROW)
|
| (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
| - C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));
|
| - jzero_far((void FAR *) buffer, 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));
|
| for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {
|
| coef->dummy_buffer[i] = buffer + i;
|
| }
|
|
|