]> Creatis software - gdcm.git/blobdiff - src/jpeg/libijg/jdtrans.c
ENH: Update the jpeg library. This patch is the result of the ijg lib + ls-patch...
[gdcm.git] / src / jpeg / libijg / jdtrans.c
index 6c0ab715d32ab470950f6db9537381adced9741d..af35263c67a40c75caaf4c95460521626c9cffbb 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * jdtrans.c
  *
- * Copyright (C) 1995-1997, Thomas G. Lane.
+ * Copyright (C) 1995-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.
  *
@@ -13,6 +13,7 @@
 #define JPEG_INTERNALS
 #include "jinclude.h"
 #include "jpeglib.h"
+#include "jlossy.h"
 
 
 /* Forward declarations */
@@ -44,6 +45,14 @@ LOCAL(void) transdecode_master_selection JPP((j_decompress_ptr cinfo));
 GLOBAL(jvirt_barray_ptr *)
 jpeg_read_coefficients (j_decompress_ptr cinfo)
 {
+  /* j_lossy_d_ptr decomp; */
+
+  /* Can't read coefficients from lossless streams */
+  if (cinfo->process == JPROC_LOSSLESS) {
+    ERREXIT(cinfo, JERR_CANT_TRANSCODE);
+    return NULL;
+  }
+
   if (cinfo->global_state == DSTATE_READY) {
     /* First call: initialize active modules */
     transdecode_master_selection(cinfo);
@@ -55,20 +64,20 @@ jpeg_read_coefficients (j_decompress_ptr cinfo)
       int retcode;
       /* Call progress monitor hook if present */
       if (cinfo->progress != NULL)
-       (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
+  (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
       /* Absorb some more input */
       retcode = (*cinfo->inputctl->consume_input) (cinfo);
       if (retcode == JPEG_SUSPENDED)
-       return NULL;
+  return NULL;
       if (retcode == JPEG_REACHED_EOI)
-       break;
+  break;
       /* Advance progress counter if appropriate */
       if (cinfo->progress != NULL &&
-         (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) {
-       if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) {
-         /* startup underestimated number of scans; ratchet up one scan */
-         cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows;
-       }
+    (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) {
+  if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) {
+    /* startup underestimated number of scans; ratchet up one scan */
+    cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows;
+  }
       }
     }
     /* Set state so that jpeg_finish_decompress does the right thing */
@@ -80,11 +89,11 @@ jpeg_read_coefficients (j_decompress_ptr cinfo)
    */
   if ((cinfo->global_state == DSTATE_STOPPING ||
        cinfo->global_state == DSTATE_BUFIMAGE) && cinfo->buffered_image) {
-    return cinfo->coef->coef_arrays;
+    return ((j_lossy_d_ptr) cinfo->codec)->coef_arrays;
   }
   /* Oops, improper usage */
   ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
-  return NULL;                 /* keep compiler happy */
+  return NULL;      /* keep compiler happy */
 }
 
 
@@ -99,22 +108,8 @@ transdecode_master_selection (j_decompress_ptr cinfo)
   /* This is effectively a buffered-image operation. */
   cinfo->buffered_image = TRUE;
 
-  /* Entropy decoding: either Huffman or arithmetic coding. */
-  if (cinfo->arith_code) {
-    ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
-  } else {
-    if (cinfo->progressive_mode) {
-#ifdef D_PROGRESSIVE_SUPPORTED
-      jinit_phuff_decoder(cinfo);
-#else
-      ERREXIT(cinfo, JERR_NOT_COMPILED);
-#endif
-    } else
-      jinit_huff_decoder(cinfo);
-  }
-
-  /* Always get a full-image coefficient buffer. */
-  jinit_d_coef_controller(cinfo, TRUE);
+  /* Initialize decompression codec */
+  jinit_d_codec(cinfo);
 
   /* We can now tell the memory manager to allocate virtual arrays. */
   (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);
@@ -126,7 +121,7 @@ transdecode_master_selection (j_decompress_ptr cinfo)
   if (cinfo->progress != NULL) {
     int nscans;
     /* Estimate number of scans to set pass_limit. */
-    if (cinfo->progressive_mode) {
+    if (cinfo->process == JPROC_PROGRESSIVE) {
       /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */
       nscans = 2 + 3 * cinfo->num_components;
     } else if (cinfo->inputctl->has_multiple_scans) {