]> Creatis software - gdcm.git/blobdiff - src/jpeg/libijg/jdmainct.c
ENH: ok making too many mistakes time to go to bed
[gdcm.git] / src / jpeg / libijg / jdmainct.c
index 996d7b490fa24527cd623b0d488edd5104e55431..43cb09b719e48f297974d8c8a1babbe797166741 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * jdmainct.c
  *
- * Copyright (C) 1994-1996, Thomas G. Lane.
+ * Copyright (C) 1994-1998, 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.
  *
  * rescaling, and doing this in an efficient fashion is a bit tricky.
  *
  * Postprocessor input data is counted in "row groups".  A row group
- * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size)
- * sample rows of each component.  (We require DCT_scaled_size values to be
- * chosen such that these numbers are integers.  In practice DCT_scaled_size
+ * is defined to be (v_samp_factor * codec_data_unit / min_codec_data_unit)
+ * sample rows of each component.  (We require codec_data_unit values to be
+ * chosen such that these numbers are integers.  In practice codec_data_unit
  * values will likely be powers of two, so we actually have the stronger
- * condition that DCT_scaled_size / min_DCT_scaled_size is an integer.)
+ * condition that codec_data_unit / min_codec_data_unit is an integer.)
  * Upsampling will typically produce max_v_samp_factor pixel rows from each
  * row group (times any additional scale factor that the upsampler is
  * applying).
  *
- * The coefficient controller will deliver data to us one iMCU row at a time;
- * each iMCU row contains v_samp_factor * DCT_scaled_size sample rows, or
- * exactly min_DCT_scaled_size row groups.  (This amount of data corresponds
+ * The decompression codec will deliver data to us one iMCU row at a time;
+ * each iMCU row contains v_samp_factor * codec_data_unit sample rows, or
+ * exactly min_codec_data_unit row groups.  (This amount of data corresponds
  * to one row of MCUs when the image is fully interleaved.)  Note that the
  * number of sample rows varies across components, but the number of row
  * groups does not.  Some garbage sample rows may be included in the last iMCU
@@ -64,7 +64,7 @@
  * supporting arbitrary output rescaling might wish for more than one row
  * group of context when shrinking the image; tough, we don't handle that.
  * (This is justified by the assumption that downsizing will be handled mostly
- * by adjusting the DCT_scaled_size values, so that the actual scale factor at
+ * by adjusting the codec_data_unit values, so that the actual scale factor at
  * the upsample step needn't be much less than one.)
  *
  * To provide the desired context, we have to retain the last two row groups
@@ -74,7 +74,7 @@
  * We could do this most simply by copying data around in our buffer, but
  * that'd be very slow.  We can avoid copying any data by creating a rather
  * strange pointer structure.  Here's how it works.  We allocate a workspace
- * consisting of M+2 row groups (where M = min_DCT_scaled_size is the number
+ * consisting of M+2 row groups (where M = min_codec_data_unit is the number
  * of row groups per iMCU row).  We create two sets of redundant pointers to
  * the workspace.  Labeling the physical row groups 0 to M+1, the synthesized
  * pointer lists look like this:
  * the first or last sample row as necessary (this is cheaper than copying
  * sample rows around).
  *
- * This scheme breaks down if M < 2, ie, min_DCT_scaled_size is 1.  In that
+ * This scheme breaks down if M < 2, ie, min_codec_data_unit is 1.  In that
  * situation each iMCU row provides only one row group so the buffering logic
  * must be different (eg, we must read two iMCU rows before we can emit the
  * first row group).  For now, we simply do not support providing context
- * rows when min_DCT_scaled_size is 1.  That combination seems unlikely to
+ * rows when min_codec_data_unit is 1.  That combination seems unlikely to
  * be worth providing --- if someone wants a 1/8th-size preview, they probably
  * want it quick and dirty, so a context-free upsampler is sufficient.
  */
@@ -161,7 +161,7 @@ alloc_funny_pointers (j_decompress_ptr cinfo)
 {
   my_main_ptr mainPtr = (my_main_ptr) cinfo->main;
   int ci, rgroup;
-  int M = cinfo->min_DCT_scaled_size;
+  int M = cinfo->min_codec_data_unit;
   jpeg_component_info *compptr;
   JSAMPARRAY xbuf;
 
@@ -175,8 +175,8 @@ alloc_funny_pointers (j_decompress_ptr cinfo)
 
   for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
        ci++, compptr++) {
-    rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) /
-      cinfo->min_DCT_scaled_size; /* height of a row group of component */
+    rgroup = (compptr->v_samp_factor * compptr->codec_data_unit) /
+      cinfo->min_codec_data_unit; /* height of a row group of component */
     /* Get space for pointer lists --- M+4 row groups in each list.
      * We alloc both pointer lists with one call to save a few cycles.
      */
@@ -202,14 +202,14 @@ make_funny_pointers (j_decompress_ptr cinfo)
 {
   my_main_ptr mainPtr = (my_main_ptr) cinfo->main;
   int ci, i, rgroup;
-  int M = cinfo->min_DCT_scaled_size;
+  int M = cinfo->min_codec_data_unit;
   jpeg_component_info *compptr;
   JSAMPARRAY buf, xbuf0, xbuf1;
 
   for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
        ci++, compptr++) {
-    rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) /
-      cinfo->min_DCT_scaled_size; /* height of a row group of component */
+    rgroup = (compptr->v_samp_factor * compptr->codec_data_unit) /
+      cinfo->min_codec_data_unit; /* height of a row group of component */
     xbuf0 = mainPtr->xbuffer[0][ci];
     xbuf1 = mainPtr->xbuffer[1][ci];
     /* First copy the workspace pointers as-is */
@@ -242,14 +242,14 @@ set_wraparound_pointers (j_decompress_ptr cinfo)
 {
   my_main_ptr mainPtr = (my_main_ptr) cinfo->main;
   int ci, i, rgroup;
-  int M = cinfo->min_DCT_scaled_size;
+  int M = cinfo->min_codec_data_unit;
   jpeg_component_info *compptr;
   JSAMPARRAY xbuf0, xbuf1;
 
   for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
        ci++, compptr++) {
-    rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) /
-      cinfo->min_DCT_scaled_size; /* height of a row group of component */
+    rgroup = (compptr->v_samp_factor * compptr->codec_data_unit) /
+      cinfo->min_codec_data_unit; /* height of a row group of component */
     xbuf0 = mainPtr->xbuffer[0][ci];
     xbuf1 = mainPtr->xbuffer[1][ci];
     for (i = 0; i < rgroup; i++) {
@@ -277,8 +277,8 @@ set_bottom_pointers (j_decompress_ptr cinfo)
   for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
        ci++, compptr++) {
     /* Count sample rows in one iMCU row and in one row group */
-    iMCUheight = compptr->v_samp_factor * compptr->DCT_scaled_size;
-    rgroup = iMCUheight / cinfo->min_DCT_scaled_size;
+    iMCUheight = compptr->v_samp_factor * compptr->codec_data_unit;
+    rgroup = iMCUheight / cinfo->min_codec_data_unit;
     /* Count nondummy sample rows remaining for this component */
     rows_left = (int) (compptr->downsampled_height % (JDIMENSION) iMCUheight);
     if (rows_left == 0) rows_left = iMCUheight;
@@ -351,13 +351,13 @@ process_data_simple_main (j_decompress_ptr cinfo,
 
   /* Read input data if we haven't filled the main buffer yet */
   if (! mainPtr->buffer_full) {
-    if (! (*cinfo->coef->decompress_data) (cinfo, mainPtr->buffer))
+    if (! (*cinfo->codec->decompress_data) (cinfo, mainPtr->buffer))
       return;      /* suspension forced, can do nothing more */
     mainPtr->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. */
-  rowgroups_avail = (JDIMENSION) cinfo->min_DCT_scaled_size;
+  /* There are always min_codec_data_unit row groups in an iMCU row. */
+  rowgroups_avail = (JDIMENSION) cinfo->min_codec_data_unit;
   /* Note: at the bottom of the image, we may pass extra garbage row groups
    * to the postprocessor.  The postprocessor has to check for bottom
    * of image anyway (at row resolution), so no point in us doing it too.
@@ -390,7 +390,7 @@ process_data_context_main (j_decompress_ptr cinfo,
 
   /* Read input data if we haven't filled the main buffer yet */
   if (! mainPtr->buffer_full) {
-    if (! (*cinfo->coef->decompress_data) (cinfo,
+    if (! (*cinfo->codec->decompress_data) (cinfo,
              mainPtr->xbuffer[mainPtr->whichptr]))
       return;      /* suspension forced, can do nothing more */
     mainPtr->buffer_full = TRUE;  /* OK, we have an iMCU row to work with */
@@ -417,7 +417,7 @@ process_data_context_main (j_decompress_ptr cinfo,
   case CTX_PREPARE_FOR_IMCU:
     /* Prepare to process first M-1 row groups of this iMCU row */
     mainPtr->rowgroup_ctr = 0;
-    mainPtr->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size - 1);
+    mainPtr->rowgroups_avail = (JDIMENSION) (cinfo->min_codec_data_unit - 1);
     /* Check for bottom of image: if so, tweak pointers to "duplicate"
      * the last sample row, and adjust rowgroups_avail to ignore padding rows.
      */
@@ -440,8 +440,8 @@ process_data_context_main (j_decompress_ptr cinfo,
     mainPtr->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 */
-    mainPtr->rowgroup_ctr = (JDIMENSION) (cinfo->min_DCT_scaled_size + 1);
-    mainPtr->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size + 2);
+    mainPtr->rowgroup_ctr = (JDIMENSION) (cinfo->min_codec_data_unit + 1);
+    mainPtr->rowgroups_avail = (JDIMENSION) (cinfo->min_codec_data_unit + 2);
     mainPtr->context_state = CTX_POSTPONED_ROW;
   }
 }
@@ -492,21 +492,21 @@ jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
    * ngroups is the number of row groups we need.
    */
   if (cinfo->upsample->need_context_rows) {
-    if (cinfo->min_DCT_scaled_size < 2) /* unsupported, see comments above */
+    if (cinfo->min_codec_data_unit < 2) /* unsupported, see comments above */
       ERREXIT(cinfo, JERR_NOTIMPL);
     alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */
-    ngroups = cinfo->min_DCT_scaled_size + 2;
+    ngroups = cinfo->min_codec_data_unit + 2;
   } else {
-    ngroups = cinfo->min_DCT_scaled_size;
+    ngroups = cinfo->min_codec_data_unit;
   }
 
   for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
        ci++, compptr++) {
-    rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) /
-      cinfo->min_DCT_scaled_size; /* height of a row group of component */
+    rgroup = (compptr->v_samp_factor * compptr->codec_data_unit) /
+      cinfo->min_codec_data_unit; /* height of a row group of component */
     mainPtr->buffer[ci] = (*cinfo->mem->alloc_sarray)
       ((j_common_ptr) cinfo, JPOOL_IMAGE,
-       compptr->width_in_blocks * compptr->DCT_scaled_size,
+       compptr->width_in_data_units * compptr->codec_data_unit,
        (JDIMENSION) (rgroup * ngroups));
   }
 }