The Independent JPEG Group's JPEG software v5b

This commit is contained in:
Thomas G. Lane
1995-03-15 00:00:00 +00:00
committed by DRC
parent 9ba2f5ed36
commit a8b67c4fbb
28 changed files with 628 additions and 411 deletions

View File

@@ -1,7 +1,7 @@
/*
* jcmainct.c
*
* Copyright (C) 1994, Thomas G. Lane.
* Copyright (C) 1994-1995, Thomas G. Lane.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -28,9 +28,8 @@
typedef struct {
struct jpeg_c_main_controller pub; /* public fields */
JDIMENSION cur_mcu_row; /* number of current iMCU row */
JDIMENSION cur_iMCU_row; /* number of current iMCU row */
JDIMENSION rowgroup_ctr; /* counts row groups received in iMCU row */
JDIMENSION mcu_ctr; /* counts MCUs output from current row */
boolean suspended; /* remember if we suspended output */
J_BUF_MODE pass_mode; /* current operating mode */
@@ -75,9 +74,8 @@ start_pass_main (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
if (cinfo->raw_data_in)
return;
main->cur_mcu_row = 0; /* initialize counters */
main->cur_iMCU_row = 0; /* initialize counters */
main->rowgroup_ctr = 0;
main->mcu_ctr = 0;
main->suspended = FALSE;
main->pass_mode = pass_mode; /* save mode for use by process_data */
@@ -118,7 +116,7 @@ process_data_simple_main (j_compress_ptr cinfo,
{
my_main_ptr main = (my_main_ptr) cinfo->main;
while (main->cur_mcu_row < cinfo->total_iMCU_rows) {
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 < DCTSIZE)
(*cinfo->prep->pre_process_data) (cinfo,
@@ -134,15 +132,13 @@ process_data_simple_main (j_compress_ptr cinfo,
return;
/* Send the completed row to the compressor */
(*cinfo->coef->compress_data) (cinfo, main->buffer, &main->mcu_ctr);
/* 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->mcu_ctr < cinfo->MCUs_per_row) {
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;
@@ -156,9 +152,8 @@ process_data_simple_main (j_compress_ptr cinfo,
(*in_row_ctr)++;
main->suspended = FALSE;
}
main->mcu_ctr = 0;
main->rowgroup_ctr = 0;
main->cur_mcu_row++;
main->cur_iMCU_row++;
}
}
@@ -180,14 +175,14 @@ process_data_buffer_main (j_compress_ptr cinfo,
jpeg_component_info *compptr;
boolean writing = (main->pass_mode != JBUF_CRANK_DEST);
while (main->cur_mcu_row < cinfo->total_iMCU_rows) {
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_mcu_row * (compptr->v_samp_factor * DCTSIZE), writing);
main->cur_iMCU_row * (compptr->v_samp_factor * DCTSIZE), writing);
}
/* In a read pass, pretend we just read some source data. */
if (! writing) {
@@ -210,14 +205,13 @@ process_data_buffer_main (j_compress_ptr cinfo,
/* Emit data, unless this is a sink-only pass. */
if (main->pass_mode != JBUF_SAVE_SOURCE) {
(*cinfo->coef->compress_data) (cinfo, main->buffer, &main->mcu_ctr);
/* 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->mcu_ctr < cinfo->MCUs_per_row) {
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;
@@ -234,9 +228,8 @@ process_data_buffer_main (j_compress_ptr cinfo,
}
/* If get here, we are done with this iMCU row. Mark buffer empty. */
main->mcu_ctr = 0;
main->rowgroup_ctr = 0;
main->cur_mcu_row++;
main->cur_iMCU_row++;
}
}