]> Creatis software - gdcm.git/blob - src/gdcmjpeg/README.GDCM.txt
ENH: Final -hopefully- change to jpeg lib. In order to match ITK structure, and be...
[gdcm.git] / src / gdcmjpeg / README.GDCM.txt
1 This directory contains a subset of the Independent JPEG Group's (IJG)
2 libjpeg version 6b.  We only include enough of distribution to build
3 libjpeg.  We do not include the standard executables that come with
4 libjpeg (cjpeg, djpeg, etc.). Furthermore, the standard libjpeg build
5 process is replaced with a CMake build process.
6
7 We'd like to thank the IJG for distributing a public JPEG IO library.
8
9 We'd like to also thank the dcmtk crew for releasing their toolkit under such a nice license that allow us to patch ijg properly to handle all sort of jpeg compression found in the DICOM implementation. The copyright can be found in COPYRIGHT.dcmtk.
10
11 Modifications
12 -------------
13
14 1.
15 jconfig.h is usually generated by the build process. For this distribution,
16 we ship a version of jconfig.h.in to be used across several platforms. It's 
17 purpose is also to allow generation of both 8bits and 12bits lib.
18
19
20
21 2.
22 jdhuff.c was modified to support special Philips MRI image:
23
24 Index: jdhuff.c
25 ===================================================================
26 RCS file: /cvs/public/gdcm/src/jpeg/libijg8/jdhuff.c,v
27 retrieving revision 1.1
28 diff -u -3 -p -r1.1 jdhuff.c
29 --- jdhuff.c    24 Jun 2003 10:09:48 -0000      1.1
30 +++ jdhuff.c    7 Oct 2004 02:29:43 -0000
31 @@ -259,8 +259,11 @@ jpeg_make_d_derived_tbl (j_decompress_pt
32    if (isDC) {
33      for (i = 0; i < numsymbols; i++) {
34        int sym = htbl->huffval[i];
35 -      if (sym < 0 || sym > 15)
36 -       ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
37 +      if (sym < 0 || sym > 15) {
38 +         // Now, we can read Philips MRI Images
39 +         htbl->huffval[i]=15;
40 +//     ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
41 +      }
42      }
43    }
44  }
45
46
47 3.
48 jmorecfg.h was modified so that we can modify it automatically at build time to
49 either generate a 8bits jpeg lib or 12bits jpeg library:
50
51 Index: jmorecfg.h
52 ===================================================================
53 RCS file: /cvs/public/gdcm/src/jpeg/libijg8/jmorecfg.h,v
54 retrieving revision 1.4
55 diff -u -3 -p -r1.4 jmorecfg.h
56 --- jmorecfg.h  31 Oct 2003 14:59:50 -0000      1.4
57 +++ jmorecfg.h  7 Oct 2004 02:30:40 -0000
58 @@ -19,7 +19,8 @@
59   * We do not support run-time selection of data precision, sorry.
60   */
61
62 -#define BITS_IN_JSAMPLE  8     /* use 8 or 12 */
63 +//#define BITS_IN_JSAMPLE  8   /* use 8 or 12 */
64 +#define BITS_IN_JSAMPLE @GDCM_BITS_IN_JSAMPLE@
65
66  /*
67   * Maximum number of components (color channels) allowed in JPEG image.
68
69
70
71
72 4.
73 To further allow us to have to different copy of the 8, 12 and 16 bits jpeg
74 library we had to mangle the name. Fur this purpose two new file were added to
75 the library: gdcm_mangle_8bits.h, gdcm_mangle_12bits.h and gdcm_mangle_16bits.h. 
76 Those file were generated using:
77
78         nm libgdcmijpeg8.a | grep " [R|T] " | colrm 1 11 | sort
79
80
81 5.
82 In order to read lossless images, we had to apply the ls-patch to jpeg-6b. So I started from scratch:
83
84 tar xvfz /tmp/jpegsrc.v6b.tar.gz                        (1)
85 patch < /tmp/ljpeg-6b.patch                             (2)
86 patch -p0 < arithmetic-without-arith-option-full.patch  (3)
87 patch -p0 < warnings10-14.patch                         (4)
88 patch -p0 < previous-gdcm.patch                         (5)
89 -----------------------------------------------------------
90 = The subdir src/jpeg/libijg
91
92 (now I also need to apply the redhat patch for cplusplus lib) 
93
94 (1) http://www.ijg.org/files/jpegsrc.v6b.tar.gz
95 (2) http://www.oceana.com/ftp/ljpeg/ljpeg-patch.v6b.tar.gz
96 (3), (4) and (5) http://www.creatis.insa-lyon.fr/~malaterre/jpeg/
97
98 (3) Was made with a carefull inspection of dcmtk code (see convert.sh at the same spot as the patch)
99 (4) Is basically just compilation of the lib with -W -Wall -Werror
100 (5) This contains some configuration copy/paste from VTK, and the 'well known' 12 bits Philips MRI DICOM patch
101
102
103
104 NOTE for later:
105 (shoud we disable getenv just as dcmtk ? there is a ijg flag for that NO_ENV or something similar