The Independent JPEG Group's JPEG software v5b
diff --git a/jcmainct.c b/jcmainct.c
index 5359268..c7315c9 100644
--- a/jcmainct.c
+++ b/jcmainct.c
@@ -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 @@
   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 @@
 {
   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 @@
       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 @@
       (*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 @@
   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 @@
 
     /* 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 @@
     }
 
     /* 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++;
   }
 }