< prev index next >

modules/javafx.graphics/src/main/native-iio/libjpeg7/jcmainct.c

Print this page

        

*** 1,9 **** --- 1,10 ---- /* * jcmainct.c * * Copyright (C) 1994-1996, Thomas G. Lane. + * Modified 2003-2012 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. * * This file contains the main buffer controller for compression. * The main buffer lies between the pre-processor and the JPEG
*** 66,101 **** */ METHODDEF(void) start_pass_main (j_compress_ptr cinfo, J_BUF_MODE pass_mode) { ! my_main_ptr main = (my_main_ptr) cinfo->main; /* Do nothing in raw-data mode. */ if (cinfo->raw_data_in) return; ! main->cur_iMCU_row = 0; /* initialize counters */ ! main->rowgroup_ctr = 0; ! main->suspended = FALSE; ! main->pass_mode = pass_mode; /* save mode for use by process_data */ switch (pass_mode) { case JBUF_PASS_THRU: #ifdef FULL_MAIN_BUFFER_SUPPORTED ! if (main->whole_image[0] != NULL) ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); #endif ! main->pub.process_data = process_data_simple_main; break; #ifdef FULL_MAIN_BUFFER_SUPPORTED case JBUF_SAVE_SOURCE: case JBUF_CRANK_DEST: case JBUF_SAVE_AND_PASS: ! if (main->whole_image[0] == NULL) ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); ! main->pub.process_data = process_data_buffer_main; break; #endif default: ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); break; --- 67,102 ---- */ METHODDEF(void) start_pass_main (j_compress_ptr cinfo, J_BUF_MODE pass_mode) { ! my_main_ptr mainp = (my_main_ptr) cinfo->main; /* Do nothing in raw-data mode. */ if (cinfo->raw_data_in) return; ! mainp->cur_iMCU_row = 0; /* initialize counters */ ! mainp->rowgroup_ctr = 0; ! mainp->suspended = FALSE; ! mainp->pass_mode = pass_mode; /* save mode for use by process_data */ switch (pass_mode) { case JBUF_PASS_THRU: #ifdef FULL_MAIN_BUFFER_SUPPORTED ! if (mainp->whole_image[0] != NULL) ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); #endif ! mainp->pub.process_data = process_data_simple_main; break; #ifdef FULL_MAIN_BUFFER_SUPPORTED case JBUF_SAVE_SOURCE: case JBUF_CRANK_DEST: case JBUF_SAVE_AND_PASS: ! if (mainp->whole_image[0] == NULL) ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); ! mainp->pub.process_data = process_data_buffer_main; break; #endif default: ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); break;
*** 112,161 **** METHODDEF(void) process_data_simple_main (j_compress_ptr cinfo, JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail) { ! my_main_ptr main = (my_main_ptr) cinfo->main; ! while (main->cur_iMCU_row < cinfo->total_iMCU_rows) { /* Read input data if we haven't filled the main buffer yet */ ! if (main->rowgroup_ctr < (JDIMENSION) cinfo->min_DCT_v_scaled_size) (*cinfo->prep->pre_process_data) (cinfo, input_buf, in_row_ctr, in_rows_avail, ! main->buffer, &main->rowgroup_ctr, (JDIMENSION) cinfo->min_DCT_v_scaled_size); /* If we don't have a full iMCU row buffered, return to application for * more data. Note that preprocessor will always pad to fill the iMCU row * at the bottom of the image. */ ! if (main->rowgroup_ctr != (JDIMENSION) cinfo->min_DCT_v_scaled_size) return; /* Send the completed row to the compressor */ ! if (! (*cinfo->coef->compress_data) (cinfo, main->buffer)) { /* If compressor did not consume the whole row, then we must need to * suspend processing and return to the application. In this situation * we pretend we didn't yet consume the last input row; otherwise, if * it happened to be the last row of the image, the application would * think we were done. */ ! if (! main->suspended) { (*in_row_ctr)--; ! main->suspended = TRUE; } return; } /* We did finish the row. Undo our little suspension hack if a previous * call suspended; then mark the main buffer empty. */ ! if (main->suspended) { (*in_row_ctr)++; ! main->suspended = FALSE; } ! main->rowgroup_ctr = 0; ! main->cur_iMCU_row++; } } #ifdef FULL_MAIN_BUFFER_SUPPORTED --- 113,162 ---- METHODDEF(void) process_data_simple_main (j_compress_ptr cinfo, JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail) { ! my_main_ptr mainp = (my_main_ptr) cinfo->main; ! while (mainp->cur_iMCU_row < cinfo->total_iMCU_rows) { /* Read input data if we haven't filled the main buffer yet */ ! if (mainp->rowgroup_ctr < (JDIMENSION) cinfo->min_DCT_v_scaled_size) (*cinfo->prep->pre_process_data) (cinfo, input_buf, in_row_ctr, in_rows_avail, ! mainp->buffer, &mainp->rowgroup_ctr, (JDIMENSION) cinfo->min_DCT_v_scaled_size); /* If we don't have a full iMCU row buffered, return to application for * more data. Note that preprocessor will always pad to fill the iMCU row * at the bottom of the image. */ ! if (mainp->rowgroup_ctr != (JDIMENSION) cinfo->min_DCT_v_scaled_size) return; /* Send the completed row to the compressor */ ! if (! (*cinfo->coef->compress_data) (cinfo, mainp->buffer)) { /* If compressor did not consume the whole row, then we must need to * suspend processing and return to the application. In this situation * we pretend we didn't yet consume the last input row; otherwise, if * it happened to be the last row of the image, the application would * think we were done. */ ! if (! mainp->suspended) { (*in_row_ctr)--; ! mainp->suspended = TRUE; } return; } /* We did finish the row. Undo our little suspension hack if a previous * call suspended; then mark the main buffer empty. */ ! if (mainp->suspended) { (*in_row_ctr)++; ! mainp->suspended = FALSE; } ! mainp->rowgroup_ctr = 0; ! mainp->cur_iMCU_row++; } } #ifdef FULL_MAIN_BUFFER_SUPPORTED
*** 168,238 **** METHODDEF(void) process_data_buffer_main (j_compress_ptr cinfo, JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail) { ! my_main_ptr main = (my_main_ptr) cinfo->main; int ci; jpeg_component_info *compptr; ! boolean writing = (main->pass_mode != JBUF_CRANK_DEST); ! while (main->cur_iMCU_row < cinfo->total_iMCU_rows) { /* Realign the virtual buffers if at the start of an iMCU row. */ ! if (main->rowgroup_ctr == 0) { for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; ci++, compptr++) { ! main->buffer[ci] = (*cinfo->mem->access_virt_sarray) ! ((j_common_ptr) cinfo, main->whole_image[ci], ! main->cur_iMCU_row * (compptr->v_samp_factor * DCTSIZE), ! (JDIMENSION) (compptr->v_samp_factor * DCTSIZE), writing); } /* In a read pass, pretend we just read some source data. */ if (! writing) { ! *in_row_ctr += cinfo->max_v_samp_factor * DCTSIZE; ! main->rowgroup_ctr = DCTSIZE; } } /* If a write pass, read input data until the current iMCU row is full. */ /* Note: preprocessor will pad if necessary to fill the last iMCU row. */ if (writing) { (*cinfo->prep->pre_process_data) (cinfo, input_buf, in_row_ctr, in_rows_avail, ! main->buffer, &main->rowgroup_ctr, ! (JDIMENSION) DCTSIZE); /* Return to application if we need more data to fill the iMCU row. */ ! if (main->rowgroup_ctr < DCTSIZE) return; } /* Emit data, unless this is a sink-only pass. */ ! if (main->pass_mode != JBUF_SAVE_SOURCE) { ! if (! (*cinfo->coef->compress_data) (cinfo, main->buffer)) { /* If compressor did not consume the whole row, then we must need to * suspend processing and return to the application. In this situation * we pretend we didn't yet consume the last input row; otherwise, if * it happened to be the last row of the image, the application would * think we were done. */ ! if (! main->suspended) { (*in_row_ctr)--; ! main->suspended = TRUE; } return; } /* We did finish the row. Undo our little suspension hack if a previous * call suspended; then mark the main buffer empty. */ ! if (main->suspended) { (*in_row_ctr)++; ! main->suspended = FALSE; } } /* If get here, we are done with this iMCU row. Mark buffer empty. */ ! main->rowgroup_ctr = 0; ! main->cur_iMCU_row++; } } #endif /* FULL_MAIN_BUFFER_SUPPORTED */ --- 169,241 ---- METHODDEF(void) process_data_buffer_main (j_compress_ptr cinfo, JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail) { ! my_main_ptr mainp = (my_main_ptr) cinfo->main; int ci; jpeg_component_info *compptr; ! boolean writing = (mainp->pass_mode != JBUF_CRANK_DEST); ! while (mainp->cur_iMCU_row < cinfo->total_iMCU_rows) { /* Realign the virtual buffers if at the start of an iMCU row. */ ! if (mainp->rowgroup_ctr == 0) { for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; ci++, compptr++) { ! mainp->buffer[ci] = (*cinfo->mem->access_virt_sarray) ! ((j_common_ptr) cinfo, mainp->whole_image[ci], mainp->cur_iMCU_row * ! ((JDIMENSION) (compptr->v_samp_factor * cinfo->min_DCT_v_scaled_size)), ! (JDIMENSION) (compptr->v_samp_factor * cinfo->min_DCT_v_scaled_size), ! writing); } /* In a read pass, pretend we just read some source data. */ if (! writing) { ! *in_row_ctr += (JDIMENSION) ! (cinfo->max_v_samp_factor * cinfo->min_DCT_v_scaled_size); ! mainp->rowgroup_ctr = (JDIMENSION) cinfo->min_DCT_v_scaled_size; } } /* If a write pass, read input data until the current iMCU row is full. */ /* Note: preprocessor will pad if necessary to fill the last iMCU row. */ if (writing) { (*cinfo->prep->pre_process_data) (cinfo, input_buf, in_row_ctr, in_rows_avail, ! mainp->buffer, &mainp->rowgroup_ctr, ! (JDIMENSION) cinfo->min_DCT_v_scaled_size); /* Return to application if we need more data to fill the iMCU row. */ ! if (mainp->rowgroup_ctr < (JDIMENSION) cinfo->min_DCT_v_scaled_size) return; } /* Emit data, unless this is a sink-only pass. */ ! if (mainp->pass_mode != JBUF_SAVE_SOURCE) { ! if (! (*cinfo->coef->compress_data) (cinfo, mainp->buffer)) { /* If compressor did not consume the whole row, then we must need to * suspend processing and return to the application. In this situation * we pretend we didn't yet consume the last input row; otherwise, if * it happened to be the last row of the image, the application would * think we were done. */ ! if (! mainp->suspended) { (*in_row_ctr)--; ! mainp->suspended = TRUE; } return; } /* We did finish the row. Undo our little suspension hack if a previous * call suspended; then mark the main buffer empty. */ ! if (mainp->suspended) { (*in_row_ctr)++; ! mainp->suspended = FALSE; } } /* If get here, we are done with this iMCU row. Mark buffer empty. */ ! mainp->rowgroup_ctr = 0; ! mainp->cur_iMCU_row++; } } #endif /* FULL_MAIN_BUFFER_SUPPORTED */
*** 242,260 **** */ GLOBAL(void) jinit_c_main_controller (j_compress_ptr cinfo, boolean need_full_buffer) { ! my_main_ptr main; int ci; jpeg_component_info *compptr; ! main = (my_main_ptr) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_main_controller)); ! cinfo->main = (struct jpeg_c_main_controller *) main; ! main->pub.start_pass = start_pass_main; /* We don't need to create a buffer in raw-data mode. */ if (cinfo->raw_data_in) return; --- 245,263 ---- */ GLOBAL(void) jinit_c_main_controller (j_compress_ptr cinfo, boolean need_full_buffer) { ! my_main_ptr mainp; int ci; jpeg_component_info *compptr; ! mainp = (my_main_ptr) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_main_controller)); ! cinfo->main = &mainp->pub; ! mainp->pub.start_pass = start_pass_main; /* We don't need to create a buffer in raw-data mode. */ if (cinfo->raw_data_in) return;
*** 265,293 **** #ifdef FULL_MAIN_BUFFER_SUPPORTED /* Allocate a full-image virtual array for each component */ /* Note we pad the bottom to a multiple of the iMCU height */ for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; ci++, compptr++) { ! main->whole_image[ci] = (*cinfo->mem->request_virt_sarray) ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, ! compptr->width_in_blocks * compptr->DCT_h_scaled_size, ! (JDIMENSION) jround_up((long) compptr->height_in_blocks, ! (long) compptr->v_samp_factor) * DCTSIZE, (JDIMENSION) (compptr->v_samp_factor * compptr->DCT_v_scaled_size)); } #else ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); #endif } else { #ifdef FULL_MAIN_BUFFER_SUPPORTED ! main->whole_image[0] = NULL; /* flag for no virtual arrays */ #endif /* Allocate a strip buffer for each component */ for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; ci++, compptr++) { ! main->buffer[ci] = (*cinfo->mem->alloc_sarray) ((j_common_ptr) cinfo, JPOOL_IMAGE, ! compptr->width_in_blocks * compptr->DCT_h_scaled_size, (JDIMENSION) (compptr->v_samp_factor * compptr->DCT_v_scaled_size)); } } } --- 268,297 ---- #ifdef FULL_MAIN_BUFFER_SUPPORTED /* Allocate a full-image virtual array for each component */ /* Note we pad the bottom to a multiple of the iMCU height */ for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; ci++, compptr++) { ! mainp->whole_image[ci] = (*cinfo->mem->request_virt_sarray) ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, ! compptr->width_in_blocks * ((JDIMENSION) compptr->DCT_h_scaled_size), ! ((JDIMENSION) jround_up((long) compptr->height_in_blocks, ! (long) compptr->v_samp_factor)) * ! ((JDIMENSION) cinfo->min_DCT_v_scaled_size), (JDIMENSION) (compptr->v_samp_factor * compptr->DCT_v_scaled_size)); } #else ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); #endif } else { #ifdef FULL_MAIN_BUFFER_SUPPORTED ! mainp->whole_image[0] = NULL; /* flag for no virtual arrays */ #endif /* Allocate a strip buffer for each component */ for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; ci++, compptr++) { ! mainp->buffer[ci] = (*cinfo->mem->alloc_sarray) ((j_common_ptr) cinfo, JPOOL_IMAGE, ! compptr->width_in_blocks * ((JDIMENSION) compptr->DCT_h_scaled_size), (JDIMENSION) (compptr->v_samp_factor * compptr->DCT_v_scaled_size)); } } }
< prev index next >