]> Creatis software - gdcm.git/commitdiff
ENH: Created a new local dir libijg (from libijg8), then went on the server copy...
authormalaterre <malaterre>
Thu, 7 Oct 2004 02:55:13 +0000 (02:55 +0000)
committermalaterre <malaterre>
Thu, 7 Oct 2004 02:55:13 +0000 (02:55 +0000)
src/jpeg/libijg/CMakeLists.txt
src/jpeg/libijg/README.GDCM.txt
src/jpeg/libijg/jconfig.h.in
src/jpeg/libijg/jdhuff.c
src/jpeg/libijg/jmorecfg.h

index d9dbe443084bc238ea23fd26a8d346b5bb6ffb24..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,55 +0,0 @@
-# JPEG 8 bits project
-
-PROJECT(GDCMJPEG)
-INCLUDE_REGULAR_EXPRESSION("^(jchuff|jconfig|jdct|jdhuff|jerror|jinclude|jmemsys|jmorecfg|jpegint|jpeglib|jversion|jpeg|gdcm).*$")
-INCLUDE_DIRECTORIES(${GDCMJPEG_SOURCE_DIR})
-
-
-# memmgr back ends: compile only one of these into a working library
-# (For now, let's use the mode that requires the image fit into memory.
-# This is the recommended mode for Win32 anyway.)
-SET(systemdependent_SRCS jmemnobs.c)
-
-# library object files common to compression and decompression
-SET(common_SRCS
-jcomapi.c jutils.c jerror.c jmemmgr.c
-)
-
-# compression library object files
-SET(compression_SRCS
-jcapimin.c jcapistd.c jctrans.c jcparam.c jdatadst.c jcinit.c
-jcmaster.c jcmarker.c jcmainct.c jcprepct.c jccoefct.c jccolor.c
-jcsample.c jchuff.c jcphuff.c jcdctmgr.c jfdctfst.c jfdctflt.c
-jfdctint.c
-)
-
-# decompression library object files
-SET(decompression_SRCS
-jdapimin.c jdapistd.c jdtrans.c jdatasrc.c jdmaster.c
-jdinput.c jdmarker.c jdhuff.c jdphuff.c jdmainct.c jdcoefct.c
-jdpostct.c jddctmgr.c jidctfst.c jidctflt.c jidctint.c jidctred.c
-jdsample.c jdcolor.c jquant1.c jquant2.c jdmerge.c
-)
-
-ADD_LIBRARY(gdcmijpeg8 ${systemdependent_SRCS} ${common_SRCS} ${compression_SRCS} ${decompression_SRCS})
-
-INSTALL_TARGETS(/lib/ gdcmijpeg8)
-INSTALL_FILES(/include .h jconfig.linux jconfig.vc)
-
-# Attempt to generate two libraries: jpeg 8bits and 12 bits using only one
-# source directory
-
-# For now disable it
-
-#extremly dangerous as there could be a /usr/include/jconfig.h from regular jpeg lib
-#INCLUDE_DIRECTORIES(${GDCMJPEG_BINARY_DIR})
-
-SET(BITS_TYPE_JPEG_MANGLE_NAME gdcm_mangle_8bits.h)
-CONFIGURE_FILE(${GDCMJPEG_SOURCE_DIR}/jconfig.h.in
-               ${GDCMJPEG_BINARY_DIR}/jconfig.h @ONLY)
-#ADD_LIBRARY(gdcmijpeg8 ${systemdependent_SRCS} ${common_SRCS} ${compression_SRCS} ${decompression_SRCS})
-
-SET(BITS_TYPE_JPEG_MANGLE_NAME gdcm_mangle_12bits.h)
-CONFIGURE_FILE(${GDCMJPEG_SOURCE_DIR}/jconfig.h.in
-               ${GDCMJPEG_BINARY_DIR}/jconfig.h @ONLY)
-#ADD_LIBRARY(gdcmijpeg12 ${systemdependent_SRCS} ${common_SRCS} ${compression_SRCS} ${decompression_SRCS})
index 836b344b5465391e8653029a90eb5f89de2562d4..13fcdb04078a345e5f075e4586d81d16a7de178c 100644 (file)
@@ -9,7 +9,69 @@ We'd like to thank the IJG for distributing a public JPEG IO library.
 Modifications
 -------------
 
 Modifications
 -------------
 
+1.
 jconfig.h is usually generated by the build process. For this distribution,
 we ship a version of jconfig.h.in to be used across several platforms. It's 
 purpose is also to allow generation of both 8bits and 12bits lib.
 
 jconfig.h is usually generated by the build process. For this distribution,
 we ship a version of jconfig.h.in to be used across several platforms. It's 
 purpose is also to allow generation of both 8bits and 12bits lib.
 
+
+
+2.
+jdhuff.c was modified to support special Philips MRI image:
+
+Index: jdhuff.c
+===================================================================
+RCS file: /cvs/public/gdcm/src/jpeg/libijg8/jdhuff.c,v
+retrieving revision 1.1
+diff -u -3 -p -r1.1 jdhuff.c
+--- jdhuff.c    24 Jun 2003 10:09:48 -0000      1.1
++++ jdhuff.c    7 Oct 2004 02:29:43 -0000
+@@ -259,8 +259,11 @@ jpeg_make_d_derived_tbl (j_decompress_pt
+   if (isDC) {
+     for (i = 0; i < numsymbols; i++) {
+       int sym = htbl->huffval[i];
+-      if (sym < 0 || sym > 15)
+-       ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
++      if (sym < 0 || sym > 15) {
++         // Now, we can read Philips MRI Images
++         htbl->huffval[i]=15;
++//     ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
++      }
+     }
+   }
+ }
+
+
+3.
+jmorecfg.h was modified so that we can modify it automatically at build time to
+either generate a 8bits jpeg lib or 12bits jpeg library:
+
+Index: jmorecfg.h
+===================================================================
+RCS file: /cvs/public/gdcm/src/jpeg/libijg8/jmorecfg.h,v
+retrieving revision 1.4
+diff -u -3 -p -r1.4 jmorecfg.h
+--- jmorecfg.h  31 Oct 2003 14:59:50 -0000      1.4
++++ jmorecfg.h  7 Oct 2004 02:30:40 -0000
+@@ -19,7 +19,8 @@
+  * We do not support run-time selection of data precision, sorry.
+  */
+
+-#define BITS_IN_JSAMPLE  8     /* use 8 or 12 */
++//#define BITS_IN_JSAMPLE  8   /* use 8 or 12 */
++#define BITS_IN_JSAMPLE @GDCM_BITS_IN_JSAMPLE@
+
+ /*
+  * Maximum number of components (color channels) allowed in JPEG image.
+
+
+
+
+4.
+To further allow us to have to different copy of the 8bits and 12bits jpeg
+library we had to mangle the name. Fur this purpose two new file were added to
+the library: gdcm_mangle_8bits.h and gdcm_mangle_12bits.h. Those file were
+generated using:
+
+        nm libgdcmijpeg8.a | grep " T " | colrm 1 11 | sort
+
index 0f8fa10a28507b2702a3761f5af9a961210a8c0e..9a6b39dde6ca1e802abde3998b9189bbc19676a7 100644 (file)
@@ -63,3 +63,5 @@ typedef unsigned char boolean;
 /* GDCM stuff */
 
 #include "@BITS_TYPE_JPEG_MANGLE_NAME@"
 /* GDCM stuff */
 
 #include "@BITS_TYPE_JPEG_MANGLE_NAME@"
+//#include "jinclude.h"
+//#include "jpeglib.h"
index b5ba39f736a7ae4f059d4b0594f4cc8ff854e1f4..4c9765fa3da9060783d14154987c497000f009de 100644 (file)
@@ -17,7 +17,7 @@
 #define JPEG_INTERNALS
 #include "jinclude.h"
 #include "jpeglib.h"
 #define JPEG_INTERNALS
 #include "jinclude.h"
 #include "jpeglib.h"
-#include "jdhuff.h"            /* Declarations shared with jdphuff.c */
+#include "jdhuff.h"    /* Declarations shared with jdphuff.c */
 
 
 /*
 
 
 /*
@@ -41,10 +41,10 @@ typedef struct {
 #else
 #if MAX_COMPS_IN_SCAN == 4
 #define ASSIGN_STATE(dest,src)  \
 #else
 #if MAX_COMPS_IN_SCAN == 4
 #define ASSIGN_STATE(dest,src)  \
-       ((dest).last_dc_val[0] = (src).last_dc_val[0], \
-        (dest).last_dc_val[1] = (src).last_dc_val[1], \
-        (dest).last_dc_val[2] = (src).last_dc_val[2], \
-        (dest).last_dc_val[3] = (src).last_dc_val[3])
+  ((dest).last_dc_val[0] = (src).last_dc_val[0], \
+   (dest).last_dc_val[1] = (src).last_dc_val[1], \
+   (dest).last_dc_val[2] = (src).last_dc_val[2], \
+   (dest).last_dc_val[3] = (src).last_dc_val[3])
 #endif
 #endif
 
 #endif
 #endif
 
@@ -55,11 +55,11 @@ typedef struct {
   /* These fields are loaded into local variables at start of each MCU.
    * In case of suspension, we exit WITHOUT updating them.
    */
   /* These fields are loaded into local variables at start of each MCU.
    * In case of suspension, we exit WITHOUT updating them.
    */
-  bitread_perm_state bitstate; /* Bit buffer at start of MCU */
-  savable_state saved;         /* Other state at start of MCU */
+  bitread_perm_state bitstate;  /* Bit buffer at start of MCU */
+  savable_state saved;    /* Other state at start of MCU */
 
   /* These fields are NOT loaded into local working state. */
 
   /* These fields are NOT loaded into local working state. */
-  unsigned int restarts_to_go; /* MCUs left in this restart interval */
+  unsigned int restarts_to_go;  /* MCUs left in this restart interval */
 
   /* Pointers to derived tables (these workspaces have image lifespan) */
   d_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS];
 
   /* Pointers to derived tables (these workspaces have image lifespan) */
   d_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS];
@@ -104,9 +104,9 @@ start_pass_huff_decoder (j_decompress_ptr cinfo)
     /* Compute derived values for Huffman tables */
     /* We may do this more than once for a table, but it's not expensive */
     jpeg_make_d_derived_tbl(cinfo, TRUE, dctbl,
     /* Compute derived values for Huffman tables */
     /* We may do this more than once for a table, but it's not expensive */
     jpeg_make_d_derived_tbl(cinfo, TRUE, dctbl,
-                           & entropy->dc_derived_tbls[dctbl]);
+          & entropy->dc_derived_tbls[dctbl]);
     jpeg_make_d_derived_tbl(cinfo, FALSE, actbl,
     jpeg_make_d_derived_tbl(cinfo, FALSE, actbl,
-                           & entropy->ac_derived_tbls[actbl]);
+          & entropy->ac_derived_tbls[actbl]);
     /* Initialize DC predictions to 0 */
     entropy->saved.last_dc_val[ci] = 0;
   }
     /* Initialize DC predictions to 0 */
     entropy->saved.last_dc_val[ci] = 0;
   }
@@ -147,7 +147,7 @@ start_pass_huff_decoder (j_decompress_ptr cinfo)
 
 GLOBAL(void)
 jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno,
 
 GLOBAL(void)
 jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno,
-                        d_derived_tbl ** pdtbl)
+       d_derived_tbl ** pdtbl)
 {
   JHUFF_TBL *htbl;
   d_derived_tbl *dtbl;
 {
   JHUFF_TBL *htbl;
   d_derived_tbl *dtbl;
@@ -173,16 +173,16 @@ jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno,
   if (*pdtbl == NULL)
     *pdtbl = (d_derived_tbl *)
       (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
   if (*pdtbl == NULL)
     *pdtbl = (d_derived_tbl *)
       (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
-                                 SIZEOF(d_derived_tbl));
+          SIZEOF(d_derived_tbl));
   dtbl = *pdtbl;
   dtbl = *pdtbl;
-  dtbl->pub = htbl;            /* fill in back link */
+  dtbl->pub = htbl;    /* fill in back link */
   
   /* Figure C.1: make table of Huffman code length for each symbol */
 
   p = 0;
   for (l = 1; l <= 16; l++) {
     i = (int) htbl->bits[l];
   
   /* Figure C.1: make table of Huffman code length for each symbol */
 
   p = 0;
   for (l = 1; l <= 16; l++) {
     i = (int) htbl->bits[l];
-    if (i < 0 || p + i > 256)  /* protect against table overrun */
+    if (i < 0 || p + i > 256)  /* protect against table overrun */
       ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
     while (i--)
       huffsize[p++] = (char) l;
       ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
     while (i--)
       huffsize[p++] = (char) l;
@@ -222,7 +222,7 @@ jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno,
       p += htbl->bits[l];
       dtbl->maxcode[l] = huffcode[p-1]; /* maximum code of length l */
     } else {
       p += htbl->bits[l];
       dtbl->maxcode[l] = huffcode[p-1]; /* maximum code of length l */
     } else {
-      dtbl->maxcode[l] = -1;   /* -1 if no codes of this length */
+      dtbl->maxcode[l] = -1;  /* -1 if no codes of this length */
     }
   }
   dtbl->maxcode[17] = 0xFFFFFL; /* ensures jpeg_huff_decode terminates */
     }
   }
   dtbl->maxcode[17] = 0xFFFFFL; /* ensures jpeg_huff_decode terminates */
@@ -243,9 +243,9 @@ jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno,
       /* Generate left-justified code followed by all possible bit sequences */
       lookbits = huffcode[p] << (HUFF_LOOKAHEAD-l);
       for (ctr = 1 << (HUFF_LOOKAHEAD-l); ctr > 0; ctr--) {
       /* Generate left-justified code followed by all possible bit sequences */
       lookbits = huffcode[p] << (HUFF_LOOKAHEAD-l);
       for (ctr = 1 << (HUFF_LOOKAHEAD-l); ctr > 0; ctr--) {
-       dtbl->look_nbits[lookbits] = l;
-       dtbl->look_sym[lookbits] = htbl->huffval[p];
-       lookbits++;
+  dtbl->look_nbits[lookbits] = l;
+  dtbl->look_sym[lookbits] = htbl->huffval[p];
+  lookbits++;
       }
     }
   }
       }
     }
   }
@@ -259,8 +259,11 @@ jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno,
   if (isDC) {
     for (i = 0; i < numsymbols; i++) {
       int sym = htbl->huffval[i];
   if (isDC) {
     for (i = 0; i < numsymbols; i++) {
       int sym = htbl->huffval[i];
-      if (sym < 0 || sym > 15)
-       ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
+      if (sym < 0 || sym > 15) {
+         // Now, we can read Philips MRI Images
+         htbl->huffval[i]=15;
+//  ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
+      }
     }
   }
 }
     }
   }
 }
@@ -282,7 +285,7 @@ jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno,
  */
 
 #ifdef SLOW_SHIFT_32
  */
 
 #ifdef SLOW_SHIFT_32
-#define MIN_GET_BITS  15       /* minimum allowable value */
+#define MIN_GET_BITS  15  /* minimum allowable value */
 #else
 #define MIN_GET_BITS  (BIT_BUF_SIZE-7)
 #endif
 #else
 #define MIN_GET_BITS  (BIT_BUF_SIZE-7)
 #endif
@@ -290,8 +293,8 @@ jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno,
 
 GLOBAL(boolean)
 jpeg_fill_bit_buffer (bitread_working_state * state,
 
 GLOBAL(boolean)
 jpeg_fill_bit_buffer (bitread_working_state * state,
-                     register bit_buf_type get_buffer, register int bits_left,
-                     int nbits)
+          register bit_buf_type get_buffer, register int bits_left,
+          int nbits)
 /* Load up the bit buffer to a depth of at least nbits */
 {
   /* Copy heavily used state fields into locals (hopefully registers) */
 /* Load up the bit buffer to a depth of at least nbits */
 {
   /* Copy heavily used state fields into locals (hopefully registers) */
@@ -303,54 +306,54 @@ jpeg_fill_bit_buffer (bitread_working_state * state,
   /* (It is assumed that no request will be for more than that many bits.) */
   /* We fail to do so only if we hit a marker or are forced to suspend. */
 
   /* (It is assumed that no request will be for more than that many bits.) */
   /* We fail to do so only if we hit a marker or are forced to suspend. */
 
-  if (cinfo->unread_marker == 0) {     /* cannot advance past a marker */
+  if (cinfo->unread_marker == 0) {  /* cannot advance past a marker */
     while (bits_left < MIN_GET_BITS) {
       register int c;
 
       /* Attempt to read a byte */
       if (bytes_in_buffer == 0) {
     while (bits_left < MIN_GET_BITS) {
       register int c;
 
       /* Attempt to read a byte */
       if (bytes_in_buffer == 0) {
-       if (! (*cinfo->src->fill_input_buffer) (cinfo))
-         return FALSE;
-       next_input_byte = cinfo->src->next_input_byte;
-       bytes_in_buffer = cinfo->src->bytes_in_buffer;
+  if (! (*cinfo->src->fill_input_buffer) (cinfo))
+    return FALSE;
+  next_input_byte = cinfo->src->next_input_byte;
+  bytes_in_buffer = cinfo->src->bytes_in_buffer;
       }
       bytes_in_buffer--;
       c = GETJOCTET(*next_input_byte++);
 
       /* If it's 0xFF, check and discard stuffed zero byte */
       if (c == 0xFF) {
       }
       bytes_in_buffer--;
       c = GETJOCTET(*next_input_byte++);
 
       /* If it's 0xFF, check and discard stuffed zero byte */
       if (c == 0xFF) {
-       /* Loop here to discard any padding FF's on terminating marker,
-        * so that we can save a valid unread_marker value.  NOTE: we will
-        * accept multiple FF's followed by a 0 as meaning a single FF data
-        * byte.  This data pattern is not valid according to the standard.
-        */
-       do {
-         if (bytes_in_buffer == 0) {
-           if (! (*cinfo->src->fill_input_buffer) (cinfo))
-             return FALSE;
-           next_input_byte = cinfo->src->next_input_byte;
-           bytes_in_buffer = cinfo->src->bytes_in_buffer;
-         }
-         bytes_in_buffer--;
-         c = GETJOCTET(*next_input_byte++);
-       } while (c == 0xFF);
-
-       if (c == 0) {
-         /* Found FF/00, which represents an FF data byte */
-         c = 0xFF;
-       } else {
-         /* Oops, it's actually a marker indicating end of compressed data.
-          * Save the marker code for later use.
-          * Fine point: it might appear that we should save the marker into
-          * bitread working state, not straight into permanent state.  But
-          * once we have hit a marker, we cannot need to suspend within the
-          * current MCU, because we will read no more bytes from the data
-          * source.  So it is OK to update permanent state right away.
-          */
-         cinfo->unread_marker = c;
-         /* See if we need to insert some fake zero bits. */
-         goto no_more_bytes;
-       }
+  /* Loop here to discard any padding FF's on terminating marker,
+   * so that we can save a valid unread_marker value.  NOTE: we will
+   * accept multiple FF's followed by a 0 as meaning a single FF data
+   * byte.  This data pattern is not valid according to the standard.
+   */
+  do {
+    if (bytes_in_buffer == 0) {
+      if (! (*cinfo->src->fill_input_buffer) (cinfo))
+        return FALSE;
+      next_input_byte = cinfo->src->next_input_byte;
+      bytes_in_buffer = cinfo->src->bytes_in_buffer;
+    }
+    bytes_in_buffer--;
+    c = GETJOCTET(*next_input_byte++);
+  } while (c == 0xFF);
+
+  if (c == 0) {
+    /* Found FF/00, which represents an FF data byte */
+    c = 0xFF;
+  } else {
+    /* Oops, it's actually a marker indicating end of compressed data.
+     * Save the marker code for later use.
+     * Fine point: it might appear that we should save the marker into
+     * bitread working state, not straight into permanent state.  But
+     * once we have hit a marker, we cannot need to suspend within the
+     * current MCU, because we will read no more bytes from the data
+     * source.  So it is OK to update permanent state right away.
+     */
+    cinfo->unread_marker = c;
+    /* See if we need to insert some fake zero bits. */
+    goto no_more_bytes;
+  }
       }
 
       /* OK, load c into get_buffer */
       }
 
       /* OK, load c into get_buffer */
@@ -370,8 +373,8 @@ jpeg_fill_bit_buffer (bitread_working_state * state,
        * appears per data segment.
        */
       if (! cinfo->entropy->insufficient_data) {
        * appears per data segment.
        */
       if (! cinfo->entropy->insufficient_data) {
-       WARNMS(cinfo, JWRN_HIT_MARKER);
-       cinfo->entropy->insufficient_data = TRUE;
+  WARNMS(cinfo, JWRN_HIT_MARKER);
+  cinfo->entropy->insufficient_data = TRUE;
       }
       /* Fill the buffer with zero bits */
       get_buffer <<= MIN_GET_BITS - bits_left;
       }
       /* Fill the buffer with zero bits */
       get_buffer <<= MIN_GET_BITS - bits_left;
@@ -396,8 +399,8 @@ jpeg_fill_bit_buffer (bitread_working_state * state,
 
 GLOBAL(int)
 jpeg_huff_decode (bitread_working_state * state,
 
 GLOBAL(int)
 jpeg_huff_decode (bitread_working_state * state,
-                 register bit_buf_type get_buffer, register int bits_left,
-                 d_derived_tbl * htbl, int min_bits)
+      register bit_buf_type get_buffer, register int bits_left,
+      d_derived_tbl * htbl, int min_bits)
 {
   register int l = min_bits;
   register INT32 code;
 {
   register int l = min_bits;
   register INT32 code;
@@ -426,7 +429,7 @@ jpeg_huff_decode (bitread_working_state * state,
 
   if (l > 16) {
     WARNMS(state->cinfo, JWRN_HUFF_BAD_CODE);
 
   if (l > 16) {
     WARNMS(state->cinfo, JWRN_HUFF_BAD_CODE);
-    return 0;                  /* fake a zero as the safest result */
+    return 0;      /* fake a zero as the safest result */
   }
 
   return htbl->pub->huffval[ (int) (code + htbl->valoffset[l]) ];
   }
 
   return htbl->pub->huffval[ (int) (code + htbl->valoffset[l]) ];
@@ -525,7 +528,7 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
   if (cinfo->restart_interval) {
     if (entropy->restarts_to_go == 0)
       if (! process_restart(cinfo))
   if (cinfo->restart_interval) {
     if (entropy->restarts_to_go == 0)
       if (! process_restart(cinfo))
-       return FALSE;
+  return FALSE;
   }
 
   /* If we've run out of data, just leave the MCU set to zeroes.
   }
 
   /* If we've run out of data, just leave the MCU set to zeroes.
@@ -550,67 +553,67 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
       /* Section F.2.2.1: decode the DC coefficient difference */
       HUFF_DECODE(s, br_state, dctbl, return FALSE, label1);
       if (s) {
       /* Section F.2.2.1: decode the DC coefficient difference */
       HUFF_DECODE(s, br_state, dctbl, return FALSE, label1);
       if (s) {
-       CHECK_BIT_BUFFER(br_state, s, return FALSE);
-       r = GET_BITS(s);
-       s = HUFF_EXTEND(r, s);
+  CHECK_BIT_BUFFER(br_state, s, return FALSE);
+  r = GET_BITS(s);
+  s = HUFF_EXTEND(r, s);
       }
 
       if (entropy->dc_needed[blkn]) {
       }
 
       if (entropy->dc_needed[blkn]) {
-       /* Convert DC difference to actual value, update last_dc_val */
-       int ci = cinfo->MCU_membership[blkn];
-       s += state.last_dc_val[ci];
-       state.last_dc_val[ci] = s;
-       /* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */
-       (*block)[0] = (JCOEF) s;
+  /* Convert DC difference to actual value, update last_dc_val */
+  int ci = cinfo->MCU_membership[blkn];
+  s += state.last_dc_val[ci];
+  state.last_dc_val[ci] = s;
+  /* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */
+  (*block)[0] = (JCOEF) s;
       }
 
       if (entropy->ac_needed[blkn]) {
 
       }
 
       if (entropy->ac_needed[blkn]) {
 
-       /* Section F.2.2.2: decode the AC coefficients */
-       /* Since zeroes are skipped, output area must be cleared beforehand */
-       for (k = 1; k < DCTSIZE2; k++) {
-         HUFF_DECODE(s, br_state, actbl, return FALSE, label2);
+  /* Section F.2.2.2: decode the AC coefficients */
+  /* Since zeroes are skipped, output area must be cleared beforehand */
+  for (k = 1; k < DCTSIZE2; k++) {
+    HUFF_DECODE(s, br_state, actbl, return FALSE, label2);
       
       
-         r = s >> 4;
-         s &= 15;
+    r = s >> 4;
+    s &= 15;
       
       
-         if (s) {
-           k += r;
-           CHECK_BIT_BUFFER(br_state, s, return FALSE);
-           r = GET_BITS(s);
-           s = HUFF_EXTEND(r, s);
-           /* Output coefficient in natural (dezigzagged) order.
-            * Note: the extra entries in jpeg_natural_order[] will save us
-            * if k >= DCTSIZE2, which could happen if the data is corrupted.
-            */
-           (*block)[jpeg_natural_order[k]] = (JCOEF) s;
-         } else {
-           if (r != 15)
-             break;
-           k += 15;
-         }
-       }
+    if (s) {
+      k += r;
+      CHECK_BIT_BUFFER(br_state, s, return FALSE);
+      r = GET_BITS(s);
+      s = HUFF_EXTEND(r, s);
+      /* Output coefficient in natural (dezigzagged) order.
+       * Note: the extra entries in jpeg_natural_order[] will save us
+       * if k >= DCTSIZE2, which could happen if the data is corrupted.
+       */
+      (*block)[jpeg_natural_order[k]] = (JCOEF) s;
+    } else {
+      if (r != 15)
+        break;
+      k += 15;
+    }
+  }
 
       } else {
 
 
       } else {
 
-       /* Section F.2.2.2: decode the AC coefficients */
-       /* In this path we just discard the values */
-       for (k = 1; k < DCTSIZE2; k++) {
-         HUFF_DECODE(s, br_state, actbl, return FALSE, label3);
+  /* Section F.2.2.2: decode the AC coefficients */
+  /* In this path we just discard the values */
+  for (k = 1; k < DCTSIZE2; k++) {
+    HUFF_DECODE(s, br_state, actbl, return FALSE, label3);
       
       
-         r = s >> 4;
-         s &= 15;
+    r = s >> 4;
+    s &= 15;
       
       
-         if (s) {
-           k += r;
-           CHECK_BIT_BUFFER(br_state, s, return FALSE);
-           DROP_BITS(s);
-         } else {
-           if (r != 15)
-             break;
-           k += 15;
-         }
-       }
+    if (s) {
+      k += r;
+      CHECK_BIT_BUFFER(br_state, s, return FALSE);
+      DROP_BITS(s);
+    } else {
+      if (r != 15)
+        break;
+      k += 15;
+    }
+  }
 
       }
     }
 
       }
     }
@@ -639,7 +642,7 @@ jinit_huff_decoder (j_decompress_ptr cinfo)
 
   entropy = (huff_entropy_ptr)
     (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
 
   entropy = (huff_entropy_ptr)
     (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
-                               SIZEOF(huff_entropy_decoder));
+        SIZEOF(huff_entropy_decoder));
   cinfo->entropy = (struct jpeg_entropy_decoder *) entropy;
   entropy->pub.start_pass = start_pass_huff_decoder;
   entropy->pub.decode_mcu = decode_mcu;
   cinfo->entropy = (struct jpeg_entropy_decoder *) entropy;
   entropy->pub.start_pass = start_pass_huff_decoder;
   entropy->pub.decode_mcu = decode_mcu;
index dd0f188d014c73db8d906625326f08d52cf0c676..1f59794312d9edeb7c4044e32a9734c6efc7498d 100644 (file)
@@ -19,7 +19,8 @@
  * We do not support run-time selection of data precision, sorry.
  */
 
  * We do not support run-time selection of data precision, sorry.
  */
 
-#define BITS_IN_JSAMPLE  8     /* use 8 or 12 */
+//#define BITS_IN_JSAMPLE  8  /* use 8 or 12 */
+#define BITS_IN_JSAMPLE @GDCM_BITS_IN_JSAMPLE@
 
 /*
  * Maximum number of components (color channels) allowed in JPEG image.
 
 /*
  * Maximum number of components (color channels) allowed in JPEG image.
@@ -30,7 +31,7 @@
  * bytes of storage, whether actually used in an image or not.)
  */
 
  * bytes of storage, whether actually used in an image or not.)
  */
 
-#define MAX_COMPONENTS  10     /* maximum number of image components */
+#define MAX_COMPONENTS  10  /* maximum number of image components */
 
 
 /*
 
 
 /*
@@ -68,8 +69,8 @@ typedef char JSAMPLE;
 
 #endif /* HAVE_UNSIGNED_CHAR */
 
 
 #endif /* HAVE_UNSIGNED_CHAR */
 
-#define MAXJSAMPLE     255
-#define CENTERJSAMPLE  128
+#define MAXJSAMPLE  255
+#define CENTERJSAMPLE  128
 
 #endif /* BITS_IN_JSAMPLE == 8 */
 
 
 #endif /* BITS_IN_JSAMPLE == 8 */
 
@@ -82,8 +83,8 @@ typedef char JSAMPLE;
 typedef short JSAMPLE;
 #define GETJSAMPLE(value)  ((int) (value))
 
 typedef short JSAMPLE;
 #define GETJSAMPLE(value)  ((int) (value))
 
-#define MAXJSAMPLE     4095
-#define CENTERJSAMPLE  2048
+#define MAXJSAMPLE  4095
+#define CENTERJSAMPLE  2048
 
 #endif /* BITS_IN_JSAMPLE == 12 */
 
 
 #endif /* BITS_IN_JSAMPLE == 12 */
 
@@ -149,13 +150,13 @@ typedef unsigned int UINT16;
 
 /* INT16 must hold at least the values -32768..32767. */
 
 
 /* INT16 must hold at least the values -32768..32767. */
 
-#ifndef XMD_H                  /* X11/xmd.h correctly defines INT16 */
+#ifndef XMD_H      /* X11/xmd.h correctly defines INT16 */
 typedef short INT16;
 #endif
 
 /* INT32 must hold at least signed 32-bit values. */
 
 typedef short INT16;
 #endif
 
 /* INT32 must hold at least signed 32-bit values. */
 
-#ifndef XMD_H                  /* X11/xmd.h correctly defines INT32 */
+#ifndef XMD_H      /* X11/xmd.h correctly defines INT32 */
 typedef long INT32;
 #endif
 
 typedef long INT32;
 #endif
 
@@ -179,20 +180,20 @@ typedef unsigned int JDIMENSION;
  */
 
 /* a function called through method pointers: */
  */
 
 /* a function called through method pointers: */
-#define METHODDEF(type)                static type
+#define METHODDEF(type)    static type
 /* a function used only in its module: */
 /* a function used only in its module: */
-#define LOCAL(type)            static type
+#define LOCAL(type)    static type
 /* a function referenced thru EXTERNs: */
 #ifdef WIN32
 /* a function referenced thru EXTERNs: */
 #ifdef WIN32
-  #define GLOBAL(type)         __declspec( dllexport ) type
+  #define GLOBAL(type)    __declspec( dllexport ) type
 #else
 #else
-  #define GLOBAL(type)         type
+  #define GLOBAL(type)    type
 #endif
 /* a reference to a GLOBAL function: */
 #ifdef WIN32
 #endif
 /* a reference to a GLOBAL function: */
 #ifdef WIN32
-  #define EXTERN(type)         extern __declspec( dllexport ) type
+  #define EXTERN(type)    extern __declspec( dllexport ) type
 #else
 #else
-  #define EXTERN(type)         extern type
+  #define EXTERN(type)    extern type
 #endif
 
 
 #endif
 
 
@@ -232,11 +233,11 @@ typedef unsigned int JDIMENSION;
 #ifndef HAVE_BOOLEAN
 typedef int boolean;
 #endif
 #ifndef HAVE_BOOLEAN
 typedef int boolean;
 #endif
-#ifndef FALSE                  /* in case these macros already exist */
-#define FALSE  0               /* values of boolean */
+#ifndef FALSE      /* in case these macros already exist */
+#define FALSE  0    /* values of boolean */
 #endif
 #ifndef TRUE
 #endif
 #ifndef TRUE
-#define TRUE   1
+#define TRUE  1
 #endif
 
 
 #endif
 
 
@@ -266,16 +267,16 @@ typedef int boolean;
 
 /* Capability options common to encoder and decoder: */
 
 
 /* Capability options common to encoder and decoder: */
 
-#define DCT_ISLOW_SUPPORTED    /* slow but accurate integer algorithm */
-#define DCT_IFAST_SUPPORTED    /* faster, less accurate integer method */
-#define DCT_FLOAT_SUPPORTED    /* floating-point: accurate, fast on fast HW */
+#define DCT_ISLOW_SUPPORTED  /* slow but accurate integer algorithm */
+#define DCT_IFAST_SUPPORTED  /* faster, less accurate integer method */
+#define DCT_FLOAT_SUPPORTED  /* floating-point: accurate, fast on fast HW */
 
 /* Encoder capability options: */
 
 #undef  C_ARITH_CODING_SUPPORTED    /* Arithmetic coding back end? */
 #define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
 
 /* Encoder capability options: */
 
 #undef  C_ARITH_CODING_SUPPORTED    /* Arithmetic coding back end? */
 #define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
-#define C_PROGRESSIVE_SUPPORTED            /* Progressive JPEG? (Requires MULTISCAN)*/
-#define ENTROPY_OPT_SUPPORTED      /* Optimization of entropy coding parms? */
+#define C_PROGRESSIVE_SUPPORTED      /* Progressive JPEG? (Requires MULTISCAN)*/
+#define ENTROPY_OPT_SUPPORTED      /* Optimization of entropy coding parms? */
 /* Note: if you selected 12-bit data precision, it is dangerous to turn off
  * ENTROPY_OPT_SUPPORTED.  The standard Huffman tables are only good for 8-bit
  * precision, so jchuff.c normally uses entropy optimization to compute
 /* Note: if you selected 12-bit data precision, it is dangerous to turn off
  * ENTROPY_OPT_SUPPORTED.  The standard Huffman tables are only good for 8-bit
  * precision, so jchuff.c normally uses entropy optimization to compute
@@ -290,14 +291,14 @@ typedef int boolean;
 
 #undef  D_ARITH_CODING_SUPPORTED    /* Arithmetic coding back end? */
 #define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
 
 #undef  D_ARITH_CODING_SUPPORTED    /* Arithmetic coding back end? */
 #define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
-#define D_PROGRESSIVE_SUPPORTED            /* Progressive JPEG? (Requires MULTISCAN)*/
-#define SAVE_MARKERS_SUPPORTED     /* jpeg_save_markers() needed? */
+#define D_PROGRESSIVE_SUPPORTED      /* Progressive JPEG? (Requires MULTISCAN)*/
+#define SAVE_MARKERS_SUPPORTED      /* jpeg_save_markers() needed? */
 #define BLOCK_SMOOTHING_SUPPORTED   /* Block smoothing? (Progressive only) */
 #define BLOCK_SMOOTHING_SUPPORTED   /* Block smoothing? (Progressive only) */
-#define IDCT_SCALING_SUPPORTED     /* Output rescaling via IDCT? */
+#define IDCT_SCALING_SUPPORTED      /* Output rescaling via IDCT? */
 #undef  UPSAMPLE_SCALING_SUPPORTED  /* Output rescaling at upsample stage? */
 #define UPSAMPLE_MERGING_SUPPORTED  /* Fast path for sloppy upsampling? */
 #undef  UPSAMPLE_SCALING_SUPPORTED  /* Output rescaling at upsample stage? */
 #define UPSAMPLE_MERGING_SUPPORTED  /* Fast path for sloppy upsampling? */
-#define QUANT_1PASS_SUPPORTED      /* 1-pass color quantization? */
-#define QUANT_2PASS_SUPPORTED      /* 2-pass color quantization? */
+#define QUANT_1PASS_SUPPORTED      /* 1-pass color quantization? */
+#define QUANT_2PASS_SUPPORTED      /* 2-pass color quantization? */
 
 /* more capability options later, no doubt */
 
 
 /* more capability options later, no doubt */
 
@@ -317,10 +318,10 @@ typedef int boolean;
  *    can't use color quantization if you change that value.
  */
 
  *    can't use color quantization if you change that value.
  */
 
-#define RGB_RED                0       /* Offset of Red in an RGB scanline element */
-#define RGB_GREEN      1       /* Offset of Green */
-#define RGB_BLUE       2       /* Offset of Blue */
-#define RGB_PIXELSIZE  3       /* JSAMPLEs per RGB scanline element */
+#define RGB_RED    0  /* Offset of Red in an RGB scanline element */
+#define RGB_GREEN  1  /* Offset of Green */
+#define RGB_BLUE  2  /* Offset of Blue */
+#define RGB_PIXELSIZE  3  /* JSAMPLEs per RGB scanline element */
 
 
 /* Definitions for speed-related optimizations. */
 
 
 /* Definitions for speed-related optimizations. */
@@ -331,11 +332,11 @@ typedef int boolean;
  */
 
 #ifndef INLINE
  */
 
 #ifndef INLINE
-#ifdef __GNUC__                        /* for instance, GNU C knows about inline */
+#ifdef __GNUC__      /* for instance, GNU C knows about inline */
 #define INLINE __inline__
 #endif
 #ifndef INLINE
 #define INLINE __inline__
 #endif
 #ifndef INLINE
-#define INLINE                 /* default is to define it as empty */
+#define INLINE      /* default is to define it as empty */
 #endif
 #endif
 
 #endif
 #endif
 
@@ -346,7 +347,7 @@ typedef int boolean;
  */
 
 #ifndef MULTIPLIER
  */
 
 #ifndef MULTIPLIER
-#define MULTIPLIER  int                /* type for fastest integer multiply */
+#define MULTIPLIER  int    /* type for fastest integer multiply */
 #endif
 
 
 #endif